Index: /trunk/wp-admin/includes/ajax-actions.php
===================================================================
--- /trunk/wp-admin/includes/ajax-actions.php (revision 22128)
+++ /trunk/wp-admin/includes/ajax-actions.php (revision 22129)
@@ -1299,5 +1299,6 @@
$title = isset($_POST['new_title'])? $_POST['new_title'] : '';
$slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
- wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
+ $screen = isset( $_POST['screen'] ) ? $_POST['screen'] : 'post';
+ wp_die( get_sample_permalink_html( $post_id, $title, $slug, $screen ) );
}
Index: /trunk/wp-admin/includes/post.php
===================================================================
--- /trunk/wp-admin/includes/post.php (revision 22128)
+++ /trunk/wp-admin/includes/post.php (revision 22129)
@@ -1048,21 +1048,24 @@
/**
- * sample permalink html
- *
- * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
+ * Returns the HTML of the sample permalink slug editor.
*
* @since 2.5.0
*
* @param int|object $id Post ID or post object.
- * @param string $new_title (optional) New title
- * @param string $new_slug (optional) New slug
- * @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
- */
-function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
+ * @param string $new_title Optional. New title.
+ * @param string $new_slug Optional. New slug.
+ * @param string|WP_Screen $screen Optional. Screen where the editor is being shown.
+ * @return string The HTML of the sample permalink slug editor.
+ */
+function get_sample_permalink_html( $id, $new_title = null, $new_slug = null, $screen = null ) {
global $wpdb;
$post = get_post($id);
- $context = isset( $_POST['context'] ) ? $_POST['context'] : get_current_screen()->id;
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
+
+ if ( isset( $screen ) )
+ $screen = convert_to_screen( $screen );
+ else
+ $screen = get_current_screen();
if ( 'publish' == get_post_status( $post ) ) {
@@ -1075,5 +1078,5 @@
if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
- if ( 'options-reading' == $context )
+ if ( 'options-reading' == $screen->id )
return '';
$return = '' . __('Permalink:') . "\n" . '' . $permalink . "\n";
@@ -1105,10 +1108,10 @@
$display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
$view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
- $return = ( 'options-reading' == $context ) ? __( 'Located at' ) . "\n" : '' . __( 'Permalink:' ) . "\n";
+ $return = ( 'options-reading' == $screen->id ) ? __( 'Located at' ) . "\n" : '' . __( 'Permalink:' ) . "\n";
$return .= '' . $display_link . "\n";
$return .= ''; // Fix bi-directional text display defect in RTL languages.
$return .= '' . __('Edit') . "\n";
$return .= '' . $post_name . "\n";
- if ( isset( $view_post ) && 'options-reading' != $context )
+ if ( isset( $view_post ) && 'options-reading' != $screen->id )
$return .= "$view_post\n";
Index: /trunk/wp-admin/js/sample-permalink.js
===================================================================
--- /trunk/wp-admin/js/sample-permalink.js (revision 22128)
+++ /trunk/wp-admin/js/sample-permalink.js (revision 22129)
@@ -26,5 +26,5 @@
new_slug: new_slug,
new_title: $('#title').val(),
- context: pagenow,
+ screen: pagenow,
samplepermalinknonce: $('#samplepermalinknonce').val()
}, function(data) {
Index: /trunk/wp-includes/script-loader.php
===================================================================
--- /trunk/wp-includes/script-loader.php (revision 22128)
+++ /trunk/wp-includes/script-loader.php (revision 22129)
@@ -370,5 +370,5 @@
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 );
- $scripts->add( 'sample-permalink', "/wp-admin/js/sample-permalink.js", array(), false, 1 );
+ $scripts->add( 'sample-permalink', "/wp-admin/js/sample-permalink$suffix.js", array(), false, 1 );
did_action( 'init' ) && $scripts->localize( 'sample-permalink', 'samplePermalinkL10n', array(
'ok' => __('OK'),