get_inline_data

Adds hidden fields with the data for use in the inline editor for posts and pages.

Description

get_inline_data( (WP_Post) $post ); 

Parameters (1)

0. $post (WP_Post)
Post object.

Usage

  1. if ( !function_exists( 'get_inline_data' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/template.php'; 
  3.  
  4. // Post object. 
  5. $post = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_inline_data($post); 
  9.  

Defined (1)

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

/wp-admin/includes/template.php  
  1. function get_inline_data($post) { 
  2. $post_type_object = get_post_type_object($post->post_type); 
  3. if ( ! current_user_can( 'edit_post', $post->ID ) ) 
  4. return; 
  5.  
  6. $title = esc_textarea( trim( $post->post_title ) ); 
  7.  
  8. /** This filter is documented in wp-admin/edit-tag-form.php */ 
  9. echo ' 
  10. <div class="hidden" id="inline_' . $post->ID . '"> 
  11. <div class="post_title">' . $title . '</div>' . 
  12. /** This filter is documented in wp-admin/edit-tag-form.php */ 
  13. '<div class="post_name">' . apply_filters( 'editable_slug', $post->post_name, $post ) . '</div> 
  14. <div class="post_author">' . $post->post_author . '</div> 
  15. <div class="comment_status">' . esc_html( $post->comment_status ) . '</div> 
  16. <div class="ping_status">' . esc_html( $post->ping_status ) . '</div> 
  17. <div class="_status">' . esc_html( $post->post_status ) . '</div> 
  18. <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div> 
  19. <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div> 
  20. <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div> 
  21. <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div> 
  22. <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div> 
  23. <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div> 
  24. <div class="post_password">' . esc_html( $post->post_password ) . '</div>'; 
  25.  
  26. if ( $post_type_object->hierarchical ) 
  27. echo '<div class="post_parent">' . $post->post_parent . '</div>'; 
  28.  
  29. if ( $post->post_type == 'page' ) 
  30. echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>'; 
  31.  
  32. if ( post_type_supports( $post->post_type, 'page-attributes' ) ) 
  33. echo '<div class="menu_order">' . $post->menu_order . '</div>'; 
  34.  
  35. $taxonomy_names = get_object_taxonomies( $post->post_type ); 
  36. foreach ( $taxonomy_names as $taxonomy_name) { 
  37. $taxonomy = get_taxonomy( $taxonomy_name ); 
  38.  
  39. if ( $taxonomy->hierarchical && $taxonomy->show_ui ) { 
  40.  
  41. $terms = get_object_term_cache( $post->ID, $taxonomy_name ); 
  42. if ( false === $terms ) { 
  43. $terms = wp_get_object_terms( $post->ID, $taxonomy_name ); 
  44. wp_cache_add( $post->ID, wp_list_pluck( $terms, 'term_id' ), $taxonomy_name . '_relationships' ); 
  45. $term_ids = empty( $terms ) ? array() : wp_list_pluck( $terms, 'term_id' ); 
  46.  
  47. echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">' . implode( ', ', $term_ids ) . '</div>'; 
  48.  
  49. } elseif ( $taxonomy->show_ui ) { 
  50.  
  51. $terms_to_edit = get_terms_to_edit( $post->ID, $taxonomy_name ); 
  52. if ( ! is_string( $terms_to_edit ) ) { 
  53. $terms_to_edit = ''; 
  54.  
  55. echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">' 
  56. . esc_html( str_replace( ', ', ', ', $terms_to_edit ) ) . '</div>'; 
  57.  
  58.  
  59. if ( !$post_type_object->hierarchical ) 
  60. echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; 
  61.  
  62. if ( post_type_supports( $post->post_type, 'post-formats' ) ) 
  63. echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>'; 
  64.  
  65. echo '</div>';