Make WordPress Core

Changeset 22129


Ignore:
Timestamp:
10/07/2012 03:44:30 AM (12 years ago)
Author:
nacin
Message:

Pass the screen context directly to get_sample_permalink_html(). see #16379.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ajax-actions.php

    r22120 r22129  
    12991299    $title = isset($_POST['new_title'])? $_POST['new_title'] : '';
    13001300    $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
    1301     wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
     1301    $screen = isset( $_POST['screen'] ) ? $_POST['screen'] : 'post';
     1302    wp_die( get_sample_permalink_html( $post_id, $title, $slug, $screen ) );
    13021303}
    13031304
  • trunk/wp-admin/includes/post.php

    r22127 r22129  
    10481048
    10491049/**
    1050  * sample permalink html
    1051  *
    1052  * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
     1050 * Returns the HTML of the sample permalink slug editor.
    10531051 *
    10541052 * @since 2.5.0
    10551053 *
    10561054 * @param int|object $id Post ID or post object.
    1057  * @param string $new_title (optional) New title
    1058  * @param string $new_slug (optional) New slug
    1059  * @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
    1060  */
    1061 function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
     1055 * @param string $new_title Optional. New title.
     1056 * @param string $new_slug Optional. New slug.
     1057 * @param string|WP_Screen $screen Optional. Screen where the editor is being shown.
     1058 * @return string The HTML of the sample permalink slug editor.
     1059 */
     1060function get_sample_permalink_html( $id, $new_title = null, $new_slug = null, $screen = null ) {
    10621061    global $wpdb;
    10631062    $post = get_post($id);
    10641063
    1065     $context = isset( $_POST['context'] ) ? $_POST['context'] : get_current_screen()->id;
    10661064    list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
     1065
     1066    if ( isset( $screen ) )
     1067        $screen = convert_to_screen( $screen );
     1068    else
     1069        $screen = get_current_screen();
    10671070
    10681071    if ( 'publish' == get_post_status( $post ) ) {
     
    10751078
    10761079    if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
    1077         if ( 'options-reading' == $context )
     1080        if ( 'options-reading' == $screen->id )
    10781081            return '';
    10791082        $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n";
     
    11051108    $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
    11061109    $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
    1107     $return  = ( 'options-reading' == $context ) ? __( 'Located at' ) . "\n" : '<strong>' . __( 'Permalink:' ) . "</strong>\n";
     1110    $return  = ( 'options-reading' == $screen->id ) ? __( 'Located at' ) . "\n" : '<strong>' . __( 'Permalink:' ) . "</strong>\n";
    11081111    $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
    11091112    $return .= '&lrm;'; // Fix bi-directional text display defect in RTL languages.
    11101113    $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";
    11111114    $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
    1112     if ( isset( $view_post ) && 'options-reading' != $context )
     1115    if ( isset( $view_post ) && 'options-reading' != $screen->id )
    11131116        $return .= "<span id='view-post-btn'><a href='$view_link' class='button button-small'>$view_post</a></span>\n";
    11141117
  • trunk/wp-admin/js/sample-permalink.js

    r22127 r22129  
    2626                new_slug: new_slug,
    2727                new_title: $('#title').val(),
    28                 context: pagenow,
     28                screen: pagenow,
    2929                samplepermalinknonce: $('#samplepermalinknonce').val()
    3030            }, function(data) {
  • trunk/wp-includes/script-loader.php

    r22127 r22129  
    370370        $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 );
    371371
    372         $scripts->add( 'sample-permalink', "/wp-admin/js/sample-permalink.js", array(), false, 1 );
     372        $scripts->add( 'sample-permalink', "/wp-admin/js/sample-permalink$suffix.js", array(), false, 1 );
    373373        did_action( 'init' ) && $scripts->localize( 'sample-permalink', 'samplePermalinkL10n', array(
    374374            'ok' => __('OK'),
Note: See TracChangeset for help on using the changeset viewer.