mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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
git-svn-id: https://develop.svn.wordpress.org/trunk@6955 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -12,6 +12,12 @@ function autosave_start_timer() {
|
||||
jQuery("#post #submit").click(function() { jQuery.cancel(autosavePeriodical); });
|
||||
jQuery("#post #publish").click(function() { jQuery.cancel(autosavePeriodical); });
|
||||
jQuery("#post #deletepost").click(function() { jQuery.cancel(autosavePeriodical); });
|
||||
|
||||
// Autosave early on for a new post
|
||||
jQuery("#content").keypress(function() {
|
||||
if ( 1 === ( jQuery(this).val().length % 15 ) && 1 > parseInt(jQuery("#post_ID").val(),10) )
|
||||
setTimeout(autosave, 5000);
|
||||
});
|
||||
}
|
||||
addLoadEvent(autosave_start_timer)
|
||||
|
||||
@@ -132,6 +138,8 @@ function autosave() {
|
||||
}
|
||||
|
||||
post_data["content"] = jQuery("#content").val();
|
||||
if ( jQuery('#post_name').val() )
|
||||
post_data["post_name"] = jQuery('#post_name').val();
|
||||
|
||||
if(post_data["post_title"].length==0 || post_data["content"].length==0 || post_data["post_title"] + post_data["content"] == autosaveLast) {
|
||||
return;
|
||||
|
||||
@@ -63,7 +63,7 @@ function get_permalink($id = 0, $leavename=false) {
|
||||
if ( empty($post->ID) ) return FALSE;
|
||||
|
||||
if ( $post->post_type == 'page' )
|
||||
return get_page_link($post->ID);
|
||||
return get_page_link($post->ID, $leavename);
|
||||
elseif ($post->post_type == 'attachment')
|
||||
return get_attachment_link($post->ID);
|
||||
|
||||
@@ -118,7 +118,7 @@ function post_permalink($post_id = 0, $deprecated = '') {
|
||||
}
|
||||
|
||||
// Respects page_on_front. Use this one.
|
||||
function get_page_link($id = false) {
|
||||
function get_page_link($id = false, $leavename = false) {
|
||||
global $post;
|
||||
|
||||
$id = (int) $id;
|
||||
@@ -128,13 +128,13 @@ function get_page_link($id = false) {
|
||||
if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
|
||||
$link = get_option('home');
|
||||
else
|
||||
$link = _get_page_link( $id );
|
||||
$link = _get_page_link( $id , $leavename );
|
||||
|
||||
return apply_filters('page_link', $link, $id);
|
||||
}
|
||||
|
||||
// Ignores page_on_front. Internal use only.
|
||||
function _get_page_link( $id = false ) {
|
||||
function _get_page_link( $id = false, $leavename = false ) {
|
||||
global $post, $wp_rewrite;
|
||||
|
||||
if ( !$id )
|
||||
@@ -146,7 +146,7 @@ function _get_page_link( $id = false ) {
|
||||
|
||||
if ( '' != $pagestruct && isset($post->post_status) && 'draft' != $post->post_status ) {
|
||||
$link = get_page_uri($id);
|
||||
$link = str_replace('%pagename%', $link, $pagestruct);
|
||||
$link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct);
|
||||
$link = get_option('home') . "/$link";
|
||||
$link = user_trailingslashit($link, 'page');
|
||||
} else {
|
||||
|
||||
@@ -44,7 +44,7 @@ class WP_Scripts {
|
||||
|
||||
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080221');
|
||||
$this->localize( 'autosave', 'autosaveL10n', array(
|
||||
'autosaveInterval' => apply_filters('autosave_interval', '120'),
|
||||
'autosaveInterval' => apply_filters('autosave_interval', '60'),
|
||||
'errorText' => __('Error: %response%'),
|
||||
'failText' => __('Error: Autosave Failed.'),
|
||||
'previewPageText' => __('Preview this Page'),
|
||||
@@ -148,7 +148,7 @@ class WP_Scripts {
|
||||
'save' => __('Save'),
|
||||
'cancel' => __('Cancel'),
|
||||
) );
|
||||
$this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080128' );
|
||||
$this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080221' );
|
||||
$this->localize( 'post', 'postL10n', array(
|
||||
'tagsUsed' => __('Tags used on this post:'),
|
||||
'add' => attribute_escape(__('Add')),
|
||||
|
||||
Reference in New Issue
Block a user