When applying the 'editable_slug' filter, add a second param that provides more context.

Props MikeSchinkel, jesin.
Fixes #31568.

Built from https://develop.svn.wordpress.org/trunk@34319


git-svn-id: http://core.svn.wordpress.org/trunk@34283 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-19 05:49:24 +00:00
parent 170a2cc4be
commit d28e914a06
6 changed files with 15 additions and 11 deletions

View File

@ -121,11 +121,13 @@ do_action( "{$taxonomy}_term_edit_form_tag" );
* post URIs and term slugs.
*
* @since 2.6.0
* @since 4.4.0 The `$tag` parameter was added.
*
* @param string $slug The editable slug. Will be either a term slug or post URI depending
* upon the context in which it is evaluated.
* @param string $slug The editable slug. Will be either a term slug or post URI depending
* upon the context in which it is evaluated.
* @param object|WP_Post $tag Term or WP_Post object.
*/
$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug ) : '';
$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
?>
<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
<p class="description"><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td>

View File

@ -373,7 +373,7 @@ class WP_Terms_List_Table extends WP_List_Table {
$out .= '<div class="name">' . $qe_data->name . '</div>';
/** This filter is documented in wp-admin/edit-tag-form.php */
$out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>';
$out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>';
$out .= '<div class="parent">' . $qe_data->parent . '</div></div>';
return $out;
@ -471,7 +471,7 @@ class WP_Terms_List_Table extends WP_List_Table {
*/
public function column_slug( $tag ) {
/** This filter is documented in wp-admin/edit-tag-form.php */
return apply_filters( 'editable_slug', $tag->slug );
return apply_filters( 'editable_slug', $tag->slug, $tag );
}
/**

View File

@ -694,8 +694,9 @@ function post_comment_meta_box( $post ) {
*/
function post_slug_meta_box($post) {
/** This filter is documented in wp-admin/edit-tag-form.php */
$editable_slug = apply_filters( 'editable_slug', $post->post_name, $post );
?>
<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( apply_filters( 'editable_slug', $post->post_name ) ); ?>" />
<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $editable_slug ); ?>" />
<?php
}

View File

@ -1243,14 +1243,14 @@ function get_sample_permalink($id, $title = null, $name = null) {
}
/** This filter is documented in wp-admin/edit-tag-form.php */
$uri = apply_filters( 'editable_slug', $uri );
$uri = apply_filters( 'editable_slug', $uri, $post );
if ( !empty($uri) )
$uri .= '/';
$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
}
/** This filter is documented in wp-admin/edit-tag-form.php */
$permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name ) );
$permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name, $post ) );
$post->post_status = $original_status;
$post->post_date = $original_date;
$post->post_name = $original_name;

View File

@ -273,8 +273,9 @@ function get_inline_data($post) {
/** 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_title">' . $title . '</div>' .
/** This filter is documented in wp-admin/edit-tag-form.php */
'<div class="post_name">' . apply_filters( 'editable_slug', $post->post_name, $post ) . '</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>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34318';
$wp_version = '4.4-alpha-34319';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.