bp_docs_edit_parent_dropdown

Get a list of an item's docs for display in the parent dropdown.

Description

bp_docs_edit_parent_dropdown(); 

Usage

  1. if ( !function_exists( 'bp_docs_edit_parent_dropdown' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-docs/includes/templatetags-edit.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_docs_edit_parent_dropdown(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/templatetags-edit.php  
  1. function bp_docs_edit_parent_dropdown() { 
  2. $bp = buddypress(); 
  3.  
  4. $include = array( 0 ); 
  5.  
  6. $query_args = apply_filters( 'bp_docs_parent_dropdown_query_args', array( 
  7. 'doc_slug' => false,  
  8. 'posts_per_page' => -1,  
  9. ) ); 
  10. $doc_query_builder = new BP_Docs_Query( $query_args ); 
  11. $doc_query = $doc_query_builder->get_wp_query(); 
  12.  
  13. if ( $doc_query->have_posts() ) { 
  14. while ( $doc_query->have_posts() ) { 
  15. $doc_query->the_post();; 
  16. $include[] = get_the_ID(); 
  17.  
  18. $current_doc = get_queried_object(); 
  19. $exclude = $parent = false; 
  20.  
  21. // If this is a failed submission, use the value from the POST cookie 
  22. if ( ! empty( $bp->bp_docs->submitted_data->parent_id ) ) { 
  23. $parent = intval( $bp->bp_docs->submitted_data->parent_id ); 
  24. } else if ( isset( $current_doc->post_type ) && $bp->bp_docs->post_type_name === $current_doc->post_type ) { 
  25. $exclude = array( $current_doc->ID ); 
  26. $parent = $current_doc->post_parent; 
  27.  
  28. $pages = wp_dropdown_pages( array( 
  29. 'post_type' => $bp->bp_docs->post_type_name,  
  30. 'exclude' => $exclude,  
  31. 'include' => $include,  
  32. 'selected' => $parent,  
  33. 'name' => 'parent_id',  
  34. 'show_option_none' => __( '(no parent)', 'bp-docs' ),  
  35. 'sort_column' => 'menu_order, post_title',  
  36. 'echo' => 0 ) 
  37. ); 
  38.  
  39. echo $pages;