mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Show the permalink even when not "pretty" and add "View Post" button if the post is published, see #8976
git-svn-id: https://develop.svn.wordpress.org/trunk@10458 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -946,9 +946,21 @@ function get_sample_permalink($id, $title=null, $name = null) {
|
||||
function get_sample_permalink_html($id, $new_title=null, $new_slug=null) {
|
||||
$post = &get_post($id);
|
||||
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
|
||||
if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) {
|
||||
return '';
|
||||
if ( 'publish' == $post->post_status )
|
||||
$view_post = 'post' == $post->post_type ? __('View Post') : __('View Page');
|
||||
|
||||
if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
|
||||
if ( 'page' == $post->post_type )
|
||||
return '';
|
||||
|
||||
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n";
|
||||
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
|
||||
if ( isset($view_post) )
|
||||
$return .= "<span id='view-post-btn'><a href='$permalink' class='button' target='_blank'>$view_post</a></span>\n";
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
$title = __('Click to edit this part of the permalink');
|
||||
if (function_exists('mb_strlen')) {
|
||||
if (mb_strlen($post_name) > 30) {
|
||||
@@ -963,10 +975,15 @@ function get_sample_permalink_html($id, $new_title=null, $new_slug=null) {
|
||||
$post_name_abridged = $post_name;
|
||||
}
|
||||
}
|
||||
|
||||
$post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name_abridged.'</span><span id="editable-post-name-full">'.$post_name.'</span>';
|
||||
$display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
|
||||
$view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
|
||||
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $display_link . "</span>\n";
|
||||
$return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button" onclick="edit_permalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
|
||||
if ( isset($view_post) )
|
||||
$return .= "<span id='view-post-btn'><a href='$view_link' class='button' target='_blank'>$view_post</a></span>\n";
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user