WordPress.org

Make WordPress Core

Changeset 6953


Ignore:
Timestamp:
02/21/2008 06:19:46 AM (13 years ago)
Author:
ryan
Message:

Auto add preview link after autosaving a new post or page. Props filosofo. see #5847

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r6788 r6953  
    525525    update_usermeta($current_user->ID, 'closedpostboxes_'.$page, $closed);
    526526break;
     527case 'get-permalink':
     528    check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
     529    $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
     530    die(get_permalink($post_id));
     531break;
    527532case 'sample-permalink':
    528533    check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
  • trunk/wp-admin/edit-form-advanced.php

    r6950 r6953  
    9393<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    9494<?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
     95<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
    9596</div>
    9697
  • trunk/wp-admin/edit-page-form.php

    r6950 r6953  
    6060<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
    6161<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
     62<?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
    6263</div>
    6364
  • trunk/wp-includes/js/autosave.js

    r6739 r6953  
    4747    }
    4848    jQuery('#autosave').html(message);
     49    autosave_update_preview_link(res);
    4950    autosave_enable_buttons();
     51}
     52
     53function autosave_update_preview_link(post_id) {
     54    // Add preview button if not already there
     55    if ( ! jQuery('#previewview > *').get()[0] ) {
     56        var post_type = jQuery('#post_type').val();
     57        var previewText = 'page' == post_type ? autosaveL10n.previewPageText : autosaveL10n.previewPostText;
     58        jQuery.post(autosaveL10n.requestFile, {
     59            action: "get-permalink",
     60            post_id: post_id,
     61            getpermalinknonce: jQuery('#getpermalinknonce').val()
     62        }, function(permalink) {
     63            jQuery('#previewview').html('<a target="_blank" href="'+permalink+'">'+previewText+'</a>');
     64        });
     65       
     66    }
    5067}
    5168
     
    6481    }
    6582    jQuery('#autosave').html(message);
     83    autosave_update_preview_link(res);
    6684    autosave_enable_buttons();
    6785}
  • trunk/wp-includes/script-loader.php

    r6923 r6953  
    4343        $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
    4444
    45         $this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080206');
     45        $this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080220');
    4646        $this->localize( 'autosave', 'autosaveL10n', array(
    4747            'autosaveInterval' => apply_filters('autosave_interval', '120'),
    4848            'errorText' => __('Error: %response%'),
    4949            'failText' => __('Error: Autosave Failed.'),
     50            'previewPageText' => __('Preview this Page'),
     51            'previewPostText' => __('Preview this Post'),
    5052            'saveText' => __('Saved at %time%.'),
    5153            'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
Note: See TracChangeset for help on using the changeset viewer.