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

Props MikeSchinkel, jesin.
Fixes #31568.


git-svn-id: https://develop.svn.wordpress.org/trunk@34319 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-09-19 05:48:30 +00:00
parent 09e3149b7a
commit 1c5f85e1a4
5 changed files with 14 additions and 10 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>