WordPress.org

Make WordPress Core

Changeset 6955


Ignore:
Timestamp:
02/21/2008 08:19:34 PM (10 years ago)
Author:
ryan
Message:

Slug edit for pages. Hide advanced slug field if JS enabled. Trigger first autosave after 15 chars. Set autosave interval to 60s. Props filosofo. see #5749

Location:
trunk
Files:
8 edited

Legend:

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

    r6954 r6955  
    8686<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
    8787<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
     88<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
    8889<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
    89 <?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
    9090</div>
    9191
  • trunk/wp-admin/edit-page-form.php

    r6953 r6955  
    5252<div class="inside">
    5353  <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" />
     54<?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
     55    <div id="edit-slug-box">
     56<?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
     57    echo $sample_permalink_html;
     58endif; ?>
     59    </div>
    5460</div>
    5561</div>
     
    6167<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    6268<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
     69<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
    6370</div>
    6471
  • trunk/wp-admin/includes/post.php

    r6954 r6955  
    594594    $post = &get_post($id);
    595595    list($permalink, $post_name) = get_sample_permalink($post->ID, $new_slug);
    596     if (false === strpos($permalink, '%postname%')) {
     596    if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) {
    597597        return '';
    598598    }
     
    604604    }
    605605    $post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name_abridged.'</span><span id="editable-post-name-full">'.$post_name.'</span>';
    606     $display_link = str_replace('%postname%', $post_name_html, $permalink);
     606    $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
    607607    $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $display_link . "</span>\n";
    608608    $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug" onclick="edit_permalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
  • trunk/wp-admin/js/page.js

    r6904 r6955  
    22    add_postbox_toggles('page');
    33    make_slugedit_clickable();
     4
     5    // hide advanced slug field
     6    jQuery('#pageslugdiv').hide();
    47
    58    jQuery('#timestamp').css('display', 'none');
  • trunk/wp-admin/js/post.js

    r6904 r6955  
    6969    // Editable slugs
    7070    make_slugedit_clickable();
     71   
     72    // hide advanced slug field
     73    jQuery('#slugdiv').hide();
    7174
    7275    jQuery('#tags-input').hide();
  • trunk/wp-includes/js/autosave.js

    r6954 r6955  
    1313    jQuery("#post #publish").click(function() { jQuery.cancel(autosavePeriodical); });
    1414    jQuery("#post #deletepost").click(function() { jQuery.cancel(autosavePeriodical); });
     15
     16    // Autosave early on for a new post
     17    jQuery("#content").keypress(function() {
     18        if ( 1 === ( jQuery(this).val().length % 15 ) && 1 > parseInt(jQuery("#post_ID").val(),10) )
     19            setTimeout(autosave, 5000);
     20    });
    1521}
    1622addLoadEvent(autosave_start_timer)
     
    133139   
    134140    post_data["content"] = jQuery("#content").val();
     141    if ( jQuery('#post_name').val() )
     142        post_data["post_name"] = jQuery('#post_name').val();
    135143
    136144    if(post_data["post_title"].length==0 || post_data["content"].length==0 || post_data["post_title"] + post_data["content"] == autosaveLast) {
  • trunk/wp-includes/link-template.php

    r6777 r6955  
    6464
    6565    if ( $post->post_type == 'page' )
    66         return get_page_link($post->ID);
     66        return get_page_link($post->ID, $leavename);
    6767    elseif ($post->post_type == 'attachment')
    6868        return get_attachment_link($post->ID);
     
    119119
    120120// Respects page_on_front.  Use this one.
    121 function get_page_link($id = false) {
     121function get_page_link($id = false, $leavename = false) {
    122122    global $post;
    123123
     
    129129        $link = get_option('home');
    130130    else
    131         $link = _get_page_link( $id );
     131        $link = _get_page_link( $id , $leavename );
    132132
    133133    return apply_filters('page_link', $link, $id);
     
    135135
    136136// Ignores page_on_front.  Internal use only.
    137 function _get_page_link( $id = false ) {
     137function _get_page_link( $id = false, $leavename = false ) {
    138138    global $post, $wp_rewrite;
    139139
     
    147147    if ( '' != $pagestruct && isset($post->post_status) && 'draft' != $post->post_status ) {
    148148        $link = get_page_uri($id);
    149         $link = str_replace('%pagename%', $link, $pagestruct);
     149        $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct);
    150150        $link = get_option('home') . "/$link";
    151151        $link = user_trailingslashit($link, 'page');
  • trunk/wp-includes/script-loader.php

    r6954 r6955  
    4545        $this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080221');
    4646        $this->localize( 'autosave', 'autosaveL10n', array(
    47             'autosaveInterval' => apply_filters('autosave_interval', '120'),
     47            'autosaveInterval' => apply_filters('autosave_interval', '60'),
    4848            'errorText' => __('Error: %response%'),
    4949            'failText' => __('Error: Autosave Failed.'),
     
    149149                'cancel' => __('Cancel'),
    150150            ) );
    151             $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080128' );
     151            $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080221' );
    152152            $this->localize( 'post', 'postL10n', array(
    153153                'tagsUsed' =>  __('Tags used on this post:'),
Note: See TracChangeset for help on using the changeset viewer.