WordPress.org

Make WordPress Core

Changeset 10458


Ignore:
Timestamp:
01/29/2009 12:11:52 PM (9 years ago)
Author:
azaozz
Message:

Show the permalink even when not "pretty" and add "View Post" button if the post is published, see #8976

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r10348 r10458  
    8989
    9090<div id="preview-action">
    91 <?php $preview_link = 'publish' == $post->post_status ? clean_url(get_permalink($post->ID)) : clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>
    92 
    93 <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php _e('Preview'); ?></a>
     91<?php
     92if ( 'publish' == $post->post_status ) {
     93    $preview_link = clean_url(get_permalink($post->ID));
     94    $preview_button = __('Preview Changes');
     95} else {
     96    $preview_link = clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID))));
     97    $preview_button = __('Preview');
     98}
     99?>
     100<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php echo $preview_button; ?></a>
    94101<input type="hidden" name="wp-preview" id="wp-preview" value="" />
    95102</div>
  • trunk/wp-admin/edit-page-form.php

    r10182 r10458  
    8181
    8282<div id="preview-action">
    83 <?php $preview_link = 'publish' == $post->post_status ? clean_url(get_permalink($post->ID)) : clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>
    84 
    85 <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php _e('Preview'); ?></a>
     83<?php
     84if ( 'publish' == $post->post_status ) {
     85    $preview_link = clean_url(get_permalink($post->ID));
     86    $preview_button = __('Preview Changes');
     87} else {
     88    $preview_link = clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID))));
     89    $preview_button = __('Preview');
     90}
     91?>
     92<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php echo $preview_button; ?></a>
    8693<input type="hidden" name="wp-preview" id="wp-preview" value="" />
    8794</div>
  • trunk/wp-admin/includes/post.php

    r10384 r10458  
    947947    $post = &get_post($id);
    948948    list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
    949     if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) {
    950         return '';
    951     }
     949    if ( 'publish' == $post->post_status )
     950        $view_post = 'post' == $post->post_type ? __('View Post') : __('View Page');
     951   
     952    if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
     953        if ( 'page' == $post->post_type )
     954            return '';
     955       
     956        $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n";
     957        $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
     958        if ( isset($view_post) )
     959            $return .= "<span id='view-post-btn'><a href='$permalink' class='button' target='_blank'>$view_post</a></span>\n";
     960
     961        return $return;
     962    }
     963
    952964    $title = __('Click to edit this part of the permalink');
    953965    if (function_exists('mb_strlen')) {
     
    964976        }
    965977    }
     978
    966979    $post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name_abridged.'</span><span id="editable-post-name-full">'.$post_name.'</span>';
    967980    $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
     981    $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
    968982    $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $display_link . "</span>\n";
    969983    $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button" onclick="edit_permalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
     984    if ( isset($view_post) )
     985        $return .= "<span id='view-post-btn'><a href='$view_link' class='button' target='_blank'>$view_post</a></span>\n";
     986
    970987    return $return;
    971988}
Note: See TracChangeset for help on using the changeset viewer.