<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[22129] trunk: Pass the screen context directly to get_sample_permalink_html().</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/22129">22129</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-10-07 03:44:30 +0000 (Sun, 07 Oct 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Pass the screen context directly to get_sample_permalink_html(). see <a href="http://core.trac.wordpress.org/ticket/16379">#16379</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesajaxactionsphp">trunk/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpadminjssamplepermalinkjs">trunk/wp-admin/js/sample-permalink.js</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpadminjssamplepermalinkminjs">trunk/wp-admin/js/sample-permalink.min.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/ajax-actions.php (22128 => 22129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/ajax-actions.php        2012-10-07 02:27:48 UTC (rev 22128)
+++ trunk/wp-admin/includes/ajax-actions.php        2012-10-07 03:44:30 UTC (rev 22129)
</span><span class="lines">@@ -1298,7 +1298,8 @@
</span><span class="cx">         $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
</span><span class="cx">         $title = isset($_POST['new_title'])? $_POST['new_title'] : '';
</span><span class="cx">         $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
</span><del>-        wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
</del><ins>+        $screen = isset( $_POST['screen'] ) ? $_POST['screen'] : 'post';
+        wp_die( get_sample_permalink_html( $post_id, $title, $slug, $screen ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function wp_ajax_inline_save() {
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (22128 => 22129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2012-10-07 02:27:48 UTC (rev 22128)
+++ trunk/wp-admin/includes/post.php        2012-10-07 03:44:30 UTC (rev 22129)
</span><span class="lines">@@ -1047,24 +1047,27 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * sample permalink html
</del><ins>+ * Returns the HTML of the sample permalink slug editor.
</ins><span class="cx">  *
</span><del>- * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
- *
</del><span class="cx">  * @since 2.5.0
</span><span class="cx">  *
</span><span class="cx">  * @param int|object $id Post ID or post object.
</span><del>- * @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.
</del><ins>+ * @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.
</ins><span class="cx">  */
</span><del>-function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
</del><ins>+function get_sample_permalink_html( $id, $new_title = null, $new_slug = null, $screen = null ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx">         $post = get_post($id);
</span><span class="cx"> 
</span><del>-        $context = isset( $_POST['context'] ) ? $_POST['context'] : get_current_screen()-&gt;id;
</del><span class="cx">         list($permalink, $post_name) = get_sample_permalink($post-&gt;ID, $new_title, $new_slug);
</span><span class="cx"> 
</span><ins>+        if ( isset( $screen ) )
+                $screen = convert_to_screen( $screen );
+        else
+                $screen = get_current_screen();
+
</ins><span class="cx">         if ( 'publish' == get_post_status( $post ) ) {
</span><span class="cx">                 $ptype = get_post_type_object($post-&gt;post_type);
</span><span class="cx">                 $view_post = $ptype-&gt;labels-&gt;view_item;
</span><span class="lines">@@ -1074,7 +1077,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( false === strpos($permalink, '%postname%') &amp;&amp; false === strpos($permalink, '%pagename%') ) {
</span><del>-                if ( 'options-reading' == $context )
</del><ins>+                if ( 'options-reading' == $screen-&gt;id )
</ins><span class="cx">                         return '';
</span><span class="cx">                 $return = '&lt;strong&gt;' . __('Permalink:') . &quot;&lt;/strong&gt;\n&quot; . '&lt;span id=&quot;sample-permalink&quot; tabindex=&quot;-1&quot;&gt;' . $permalink . &quot;&lt;/span&gt;\n&quot;;
</span><span class="cx">                 if ( '' == get_option( 'permalink_structure' ) &amp;&amp; current_user_can( 'manage_options' ) &amp;&amp; !( 'page' == get_option('show_on_front') &amp;&amp; $id == get_option('page_on_front') ) )
</span><span class="lines">@@ -1104,12 +1107,12 @@
</span><span class="cx">         $post_name_html = '&lt;span id=&quot;editable-post-name&quot; title=&quot;' . $title . '&quot;&gt;' . $post_name_abridged . '&lt;/span&gt;';
</span><span class="cx">         $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
</span><span class="cx">         $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
</span><del>-        $return  = ( 'options-reading' == $context ) ? __( 'Located at' ) . &quot;\n&quot; : '&lt;strong&gt;' . __( 'Permalink:' ) . &quot;&lt;/strong&gt;\n&quot;;
</del><ins>+        $return  = ( 'options-reading' == $screen-&gt;id ) ? __( 'Located at' ) . &quot;\n&quot; : '&lt;strong&gt;' . __( 'Permalink:' ) . &quot;&lt;/strong&gt;\n&quot;;
</ins><span class="cx">         $return .= '&lt;span id=&quot;sample-permalink&quot; tabindex=&quot;-1&quot;&gt;' . $display_link . &quot;&lt;/span&gt;\n&quot;;
</span><span class="cx">         $return .= '&amp;lrm;'; // Fix bi-directional text display defect in RTL languages.
</span><span class="cx">         $return .= '&lt;span id=&quot;edit-slug-buttons&quot;&gt;&lt;a href=&quot;#post_name&quot; class=&quot;edit-slug button button-small hide-if-no-js&quot; onclick=&quot;editPermalink(' . $id . '); return false;&quot;&gt;' . __('Edit') . &quot;&lt;/a&gt;&lt;/span&gt;\n&quot;;
</span><span class="cx">         $return .= '&lt;span id=&quot;editable-post-name-full&quot;&gt;' . $post_name . &quot;&lt;/span&gt;\n&quot;;
</span><del>-        if ( isset( $view_post ) &amp;&amp; 'options-reading' != $context )
</del><ins>+        if ( isset( $view_post ) &amp;&amp; 'options-reading' != $screen-&gt;id )
</ins><span class="cx">                 $return .= &quot;&lt;span id='view-post-btn'&gt;&lt;a href='$view_link' class='button button-small'&gt;$view_post&lt;/a&gt;&lt;/span&gt;\n&quot;;
</span><span class="cx"> 
</span><span class="cx">         $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
</span></span></pre></div>
<a id="trunkwpadminjssamplepermalinkjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/sample-permalink.js (22128 => 22129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/sample-permalink.js        2012-10-07 02:27:48 UTC (rev 22128)
+++ trunk/wp-admin/js/sample-permalink.js        2012-10-07 03:44:30 UTC (rev 22129)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">                                 post_id: post_id,
</span><span class="cx">                                 new_slug: new_slug,
</span><span class="cx">                                 new_title: $('#title').val(),
</span><del>-                                context: pagenow,
</del><ins>+                                screen: pagenow,
</ins><span class="cx">                                 samplepermalinknonce: $('#samplepermalinknonce').val()
</span><span class="cx">                         }, function(data) {
</span><span class="cx">                                 $('#edit-slug-box').html(data);
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (22128 => 22129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2012-10-07 02:27:48 UTC (rev 22128)
+++ trunk/wp-includes/script-loader.php        2012-10-07 03:44:30 UTC (rev 22129)
</span><span class="lines">@@ -369,7 +369,7 @@
</span><span class="cx"> 
</span><span class="cx">                 $scripts-&gt;add( 'postbox', &quot;/wp-admin/js/postbox$suffix.js&quot;, array('jquery-ui-sortable'), false, 1 );
</span><span class="cx"> 
</span><del>-                $scripts-&gt;add( 'sample-permalink', &quot;/wp-admin/js/sample-permalink.js&quot;, array(), false, 1 );
</del><ins>+                $scripts-&gt;add( 'sample-permalink', &quot;/wp-admin/js/sample-permalink$suffix.js&quot;, array(), false, 1 );
</ins><span class="cx">                 did_action( 'init' ) &amp;&amp; $scripts-&gt;localize( 'sample-permalink', 'samplePermalinkL10n', array(
</span><span class="cx">                         'ok' =&gt; __('OK'),
</span><span class="cx">                         'cancel' =&gt; __('Cancel'),
</span></span></pre>
</div>
</div>

</body>
</html>