Simplify logic in get_sample_permalink_html(), remove duplicated code.

see #28350.
Built from https://develop.svn.wordpress.org/trunk@28947


git-svn-id: http://core.svn.wordpress.org/trunk@28744 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-07-02 00:04:15 +00:00
parent 16bb742b66
commit fc24029d65
2 changed files with 30 additions and 46 deletions

View File

@ -1197,33 +1197,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) { if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) {
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
} }
if ( isset( $view_post ) ) {
if( 'draft' == $post->post_status ) {
$preview_link = set_url_scheme( get_permalink( $post->ID ) );
/** This filter is documented in wp-admin/includes/meta-boxes.php */
$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) );
$return .= "<span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n";
} else { } else {
$return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
}
}
/**
* Filter the sample permalink HTML markup.
*
* @since 2.9.0
*
* @param string $return Sample permalink HTML markup.
* @param int|WP_Post $id Post object or ID.
* @param string $new_title New sample permalink title.
* @param string $new_slug New sample permalink slug.
*/
$return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug );
return $return;
}
if ( function_exists( 'mb_strlen' ) ) { if ( function_exists( 'mb_strlen' ) ) {
if ( mb_strlen( $post_name ) > 30 ) { if ( mb_strlen( $post_name ) > 30 ) {
$post_name_abridged = mb_substr( $post_name, 0, 14 ) . '&hellip;' . mb_substr( $post_name, -14 ); $post_name_abridged = mb_substr( $post_name, 0, 14 ) . '&hellip;' . mb_substr( $post_name, -14 );
@ -1246,6 +1220,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
$return .= '&lrm;'; // Fix bi-directional text display defect in RTL languages. $return .= '&lrm;'; // Fix bi-directional text display defect in RTL languages.
$return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __( 'Edit' ) . "</a></span>\n"; $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __( 'Edit' ) . "</a></span>\n";
$return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
}
if ( isset( $view_post ) ) { if ( isset( $view_post ) ) {
if( 'draft' == $post->post_status ) { if( 'draft' == $post->post_status ) {
@ -1258,7 +1233,16 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
} }
} }
/** This filter is documented in wp-admin/includes/post.php */ /**
* Filter the sample permalink HTML markup.
*
* @since 2.9.0
*
* @param string $return Sample permalink HTML markup.
* @param int|WP_Post $id Post object or ID.
* @param string $new_title New sample permalink title.
* @param string $new_slug New sample permalink slug.
*/
$return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug ); $return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug );
return $return; return $return;

View File

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