WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 months ago

#27833 closed enhancement (duplicate)

Add hook to hidden inline data for quick edit

Reported by: helgatheviking Owned by: chriscct7
Milestone: Priority: normal
Severity: normal Version: 3.8.3
Component: Quick/Bulk Edit Keywords: dev-feedback needs-unit-tests
Focuses: administration Cc:

Description

It'd be handy to be able to add data that will be used by the quick edit in the same place that the default data is already added. This could be achieved by adding an action hook in the get_inline_data() function.

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.7.0
 *
 * @param unknown_type $post
 */
function get_inline_data($post) {
	$post_type_object = get_post_type_object($post->post_type);
	if ( ! current_user_can( 'edit_post', $post->ID ) )
		return;

	$title = esc_textarea( trim( $post->post_title ) );

	/** This filter is documented in wp-admin/edit-tag-form.php */
	echo '
<div class="hidden" id="inline_' . $post->ID . '">
	<div class="post_title">' . $title . '</div>
	<div class="post_name">' . apply_filters( 'editable_slug', $post->post_name ) . '</div>
	<div class="post_author">' . $post->post_author . '</div>
	<div class="comment_status">' . esc_html( $post->comment_status ) . '</div>
	<div class="ping_status">' . esc_html( $post->ping_status ) . '</div>
	<div class="_status">' . esc_html( $post->post_status ) . '</div>
	<div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
	<div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
	<div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
	<div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
	<div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
	<div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
	<div class="post_password">' . esc_html( $post->post_password ) . '</div>';

	if ( $post_type_object->hierarchical )
		echo '<div class="post_parent">' . $post->post_parent . '</div>';

	if ( $post->post_type == 'page' )
		echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';

	if ( post_type_supports( $post->post_type, 'page-attributes' ) )
		echo '<div class="menu_order">' . $post->menu_order . '</div>';

	$taxonomy_names = get_object_taxonomies( $post->post_type );
	foreach ( $taxonomy_names as $taxonomy_name) {
		$taxonomy = get_taxonomy( $taxonomy_name );

		if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
				echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">'
					. implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array( 'fields' => 'ids' ) ) ) . '</div>';
		} elseif ( $taxonomy->show_ui ) {
			echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
				. esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
		}
	}

	if ( !$post_type_object->hierarchical )
		echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';

	if ( post_type_supports( $post->post_type, 'post-formats' ) )
		echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';

	do_action( 'inline_data', $post );
	
	echo '</div>';
}

Attachments (1)

27833.diff (857 bytes) - added by Mte90 17 months ago.
hook with docs

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
4 years ago

  • Component changed from General to Quick/Bulk Edit

#2 @chriscct7
3 years ago

  • Focuses administration added
  • Keywords needs-patch added
  • Owner set to chriscct7
  • Status changed from new to assigned

@Mte90
17 months ago

hook with docs

#3 @Mte90
17 months ago

  • Keywords dev-feedback needs-unit-tests added; needs-patch removed

I added the hook with a little bit of docs, I also removed a duplicated comment in the get_inline_data function.

#4 @Mte90
10 months ago

I was trying to understand for unit tests for this but I am not sure if have to add a unit test for an hook. Also the same function as a filter editale_slug that doesn't have unit test.

#5 @jazbek
6 months ago

Here for removal of that duplicate comment. I was starting to think I was crazy -- there is no filter there, right? 🤯

#6 @johnbillion
4 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from assigned to closed

Duplicate of #36085.

Note: See TracTickets for help on using tickets.