Make WordPress Core

Changeset 6761


Ignore:
Timestamp:
02/08/2008 07:57:50 PM (17 years ago)
Author:
ryan
Message:

Postbox save updates and admin js refactoring from nbachiyski. fixes #5799

Location:
trunk
Files:
2 added
11 edited

Legend:

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

    r6739 r6761  
    514514break;
    515515case 'closed-postboxes' :
    516     check_ajax_referer( $action );
    517     $closed = explode(',', $_POST['closed']);
     516    check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' );
     517    $closed = isset( $_POST['closed'] )? $_POST['closed'] : '';
     518    $closed = explode( ',', $_POST['closed'] );
     519    $page = isset( $_POST['page'] )? $_POST['page'] : '';
     520    if ( !preg_match( '/^[a-z-]+$/', $page ) ) {
     521        die(-1);
     522    }
    518523    if (!is_array($closed)) break;
    519524    $current_user = wp_get_current_user();
    520     update_usermeta($current_user->ID, 'closedpostboxes', $closed);
     525    update_usermeta($current_user->ID, 'closedpostboxes_'.$page, $closed);
    521526break;
    522527case 'sample-permalink':
  • trunk/wp-admin/edit-form-advanced.php

    r6758 r6761  
    9090<?php the_editor($post->post_content); ?>
    9191<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
     92<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    9293</div>
    9394
     
    176177?>" /></p>
    177178
    178 <div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv'); ?>">
     179<div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv', 'post'); ?>">
    179180<h3><?php _e('Tags'); ?></h3>
    180181<div class="inside">
     
    184185</div>
    185186
    186 <div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv'); ?>">
     187<div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>">
    187188<h3><?php _e('Categories') ?></h3>
    188189<div class="inside">
     
    235236<h2><?php _e('Advanced Options'); ?></h2>
    236237
    237 <div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt'); ?>">
     238<div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt', 'post'); ?>">
    238239<h3><?php _e('Optional Excerpt') ?></h3>
    239240<div class="inside"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div>
    240241</div>
    241242
    242 <div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv'); ?>">
     243<div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv', 'post'); ?>">
    243244<h3><?php _e('Trackbacks') ?></h3>
    244245<div class="inside">
     
    251252</div>
    252253
    253 <div id="postcustom" class="postbox <?php echo postbox_classes('postcustom'); ?>">
     254<div id="postcustom" class="postbox <?php echo postbox_classes('postcustom', 'post'); ?>">
    254255<h3><?php _e('Custom Fields') ?></h3>
    255256<div class="inside">
     
    272273<?php do_action('dbx_post_advanced'); ?>
    273274
    274 <div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv'); ?>">
     275<div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv', 'post'); ?>">
    275276<h3><?php _e('Discussion') ?></h3>
    276277<div class="inside">
     
    283284</div>
    284285
    285 <div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv'); ?>">
     286<div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv', 'post'); ?>">
    286287<h3><?php _e('Post Password') ?></h3>
    287288<div class="inside">
     
    290291</div>
    291292
    292 <div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv'); ?>">
     293<div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv', 'post'); ?>">
    293294<h3><?php _e('Post Slug') ?></h3>
    294295<div class="inside">
     
    298299
    299300<?php if ( current_user_can('edit_posts') ) : ?>
    300 <div id="posttimestampdiv" class="postbox <?php echo postbox_classes('posttimestampdiv'); ?>">
     301<div id="posttimestampdiv" class="postbox <?php echo postbox_classes('posttimestampdiv', 'post'); ?>">
    301302<h3><?php _e('Post Timestamp'); ?></h3>
    302303<div class="inside"><?php touch_time(($action == 'edit')); ?></div>
     
    310311if ( $authors && count( $authors ) > 1 ) :
    311312?>
    312 <div id="authordiv" class="postbox <?php echo postbox_classes('authordiv'); ?>">
     313<div id="authordiv" class="postbox <?php echo postbox_classes('authordiv', 'post'); ?>">
    313314<h3><?php _e('Post Author'); ?></h3>
    314315<div class="inside">
  • trunk/wp-admin/edit-link-form.php

    r6713 r6761  
    3333<?php echo $form ?>
    3434<?php wp_nonce_field($nonce_action); ?>
     35<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    3536
    3637<div class="wrap">
     
    6566</div>
    6667
    67 <div id="linkcategorydiv" class="postbox <?php echo postbox_classes('linkcategorydiv'); ?>">
     68<div id="linkcategorydiv" class="postbox <?php echo postbox_classes('linkcategorydiv', 'link'); ?>">
    6869<h3><?php _e('Categories') ?></h3>
    6970<div class="inside">
     
    101102<h2><?php _e('Advanced Options'); ?></h2>
    102103
    103 <div id="linktargetdiv" class="postbox <?php echo postbox_classes('linktargetdiv'); ?>">
     104<div id="linktargetdiv" class="postbox <?php echo postbox_classes('linktargetdiv', 'link'); ?>">
    104105<h3><?php _e('Target') ?></h3>
    105106<div class="inside">
     
    116117</div>
    117118
    118 <div id="linkvisiblediv" class="postbox <?php echo postbox_classes('linkvisiblediv'); ?>">
     119<div id="linkvisiblediv" class="postbox <?php echo postbox_classes('linkvisiblediv', 'link'); ?>">
    119120<h3><?php _e('Visible') ?></h3>
    120121<div class="inside">
     
    128129</div>
    129130
    130 <div id="linkxfndiv" class="postbox <?php echo postbox_classes('linkxfndiv'); ?>">
     131<div id="linkxfndiv" class="postbox <?php echo postbox_classes('linkxfndiv', 'link'); ?>">
    131132<h3><?php _e('Link Relationship (XFN)') ?></h3>
    132133<div class="inside">
     
    241242</div>
    242243
    243 <div id="linkadvanceddiv" class="postbox <?php echo postbox_classes('linkadvanceddiv'); ?>">
     244<div id="linkadvanceddiv" class="postbox <?php echo postbox_classes('linkadvanceddiv', 'link'); ?>">
    244245<h3><?php _e('Advanced') ?></h3>
    245246<div class="inside">
  • trunk/wp-admin/edit-page-form.php

    r6739 r6761  
    5858<?php the_editor($post->post_content); ?>
    5959<?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
     60<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    6061</div>
    6162
     
    137138<h2><?php _e('Advanced Options'); ?></h2>
    138139
    139 <div id="pagepostcustom" class="postbox <?php echo postbox_classes('pagepostcustom'); ?>">
     140<div id="pagepostcustom" class="postbox <?php echo postbox_classes('pagepostcustom', 'page'); ?>">
    140141<h3><?php _e('Custom Fields') ?></h3>
    141142<div class="inside">
     
    156157</div>
    157158
    158 <div id="pagecommentstatusdiv" class="postbox <?php echo postbox_classes('pagecommentstatusdiv'); ?>">
     159<div id="pagecommentstatusdiv" class="postbox <?php echo postbox_classes('pagecommentstatusdiv', 'page'); ?>">
    159160<h3><?php _e('Discussion') ?></h3>
    160161<div class="inside">
     
    167168</div>
    168169
    169 <div id="pagepassworddiv" class="postbox <?php echo postbox_classes('pagepassworddiv'); ?>">
     170<div id="pagepassworddiv" class="postbox <?php echo postbox_classes('pagepassworddiv', 'page'); ?>">
    170171<h3><?php _e('Page Password') ?></h3>
    171172<div class="inside">
     
    174175</div>
    175176
    176 <div id="pageslugdiv" class="postbox <?php echo postbox_classes('pageslugdiv'); ?>">
     177<div id="pageslugdiv" class="postbox <?php echo postbox_classes('pageslugdiv', 'page'); ?>">
    177178<h3><?php _e('Page Slug') ?></h3>
    178179<div class="inside">
     
    181182</div>
    182183
    183 <div id="pageparentdiv" class="postbox <?php echo postbox_classes('pageparentdiv'); ?>">
     184<div id="pageparentdiv" class="postbox <?php echo postbox_classes('pageparentdiv', 'page'); ?>">
    184185<h3><?php _e('Page Parent') ?></h3>
    185186<div class="inside">
     
    192193
    193194<?php if ( 0 != count( get_page_templates() ) ) { ?>
    194 <div id="pagetemplatediv" class="postbox <?php echo postbox_classes('pagetemplatediv'); ?>">
     195<div id="pagetemplatediv" class="postbox <?php echo postbox_classes('pagetemplatediv', 'page'); ?>">
    195196<h3><?php _e('Page Template') ?></h3>
    196197<div class="inside">
     
    203204<?php } ?>
    204205
    205 <div id="pageorderdiv" class="postbox <?php echo postbox_classes('pageorderdiv'); ?>">
     206<div id="pageorderdiv" class="postbox <?php echo postbox_classes('pageorderdiv', 'page'); ?>">
    206207<h3><?php _e('Page Order') ?></h3>
    207208<div class="inside">
     
    216217if ( $authors && count( $authors ) > 1 ) :
    217218?>
    218 <div id="pageauthordiv" class="postbox <?php echo postbox_classes('pageauthordiv'); ?>">
     219<div id="pageauthordiv" class="postbox <?php echo postbox_classes('pageauthordiv', 'page'); ?>">
    219220<h3><?php _e('Post Author'); ?></h3>
    220221<div class="inside">
  • trunk/wp-admin/includes/post.php

    r6733 r6761  
    518518}
    519519
    520 function postbox_classes( $id ) {
     520function postbox_classes( $id, $page ) {
    521521    $current_user = wp_get_current_user();
    522     if ( $closed = get_usermeta( $current_user->ID, 'closedpostboxes' ) ) {
     522    if ( $closed = get_usermeta( $current_user->ID, 'closedpostboxes_'.$page ) ) {
    523523        if ( !is_array( $closed ) ) return '';
    524524        return in_array( $id, $closed )? 'closed' : '';
  • trunk/wp-admin/js/link.js

    r6713 r6761  
    11addLoadEvent( function() {
    22    // postboxes
    3     add_postbox_toggles();
     3    add_postbox_toggles('link');
    44
    55    // category tabs
  • trunk/wp-admin/js/post.js

    r6694 r6761  
    5353}
    5454
    55 function edit_permalink(post_id) {
    56     var i, c = 0;
    57     var e = jQuery('#editable-post-name');
    58     var revert_e = e.html();   
    59     var real_slug = jQuery('#post_name');
    60     var b = jQuery('#edit-slug-buttons');
    61     var revert_b = b.html();
    62     var old_slug = e.children('span').html();
    63 
    64     b.html('<a href="" class="save">'+postL10n.save+'</a> <a class="cancel" href="">'+postL10n.cancel+'</a>');
    65     b.children('.save').click(function() {
    66         var new_slug = e.children('input').attr('value');
    67         jQuery.post(postL10n.requestFile, {
    68             action: 'sample-permalink',
    69             post_id: post_id,
    70             new_slug: new_slug,
    71             cookie: document.cookie}, function(data) {
    72                 jQuery('#sample-permalink').html(data);
    73                 b.html(revert_b);
    74                 real_slug.attr('value', new_slug); 
    75                 make_slugedit_clickable();
    76             });
    77         return false;
    78     });
    79     jQuery('#edit-slug-buttons .cancel').click(function() {
    80         e.html(revert_e);
    81         b.html(revert_b);
    82         real_slug.attr('value', revert_e);
    83         return false;
    84     });
    85     for(i=0; i < revert_e.length; ++i) {
    86         if ('%' == revert_e.charAt(i)) c++;
    87     }
    88     slug_value = (c > revert_e.length/4)? '' : revert_e;
    89     e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e){
    90         var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
    91         // on enter, just save the new slug, don't save the post
    92         if (13 == key) {b.children('.save').click();return false;}
    93         if (27 == key) {b.children('.cancel').click();return false;}
    94         real_slug.attr('value', this.value)}).focus();
    95 }
    96 
    97 function make_slugedit_clickable() {
    98     jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()});
    99 }
    100 
    10155addLoadEvent( function() {
    10256    // postboxes
    103     add_postbox_toggles();
     57    add_postbox_toggles('post');
    10458
    10559    // If no tags on the page, skip the tag and category stuff.
  • trunk/wp-admin/js/postbox.js

    r6713 r6761  
    1 function add_postbox_toggles() {
     1function add_postbox_toggles(page) {
    22    jQuery('.postbox h3').prepend('<a class="togbox">+</a> ');
    3     jQuery('.togbox').click( function() { jQuery(jQuery(this).parent().parent().get(0)).toggleClass('closed'); save_postboxes_state(); } );
     3    jQuery('.togbox').click( function() { jQuery(jQuery(this).parent().parent().get(0)).toggleClass('closed'); save_postboxes_state(page); } );
    44}
    55
    6 function save_postboxes_state() {
     6function save_postboxes_state(page) {
    77    var closed = jQuery('.postbox').filter('.closed').map(function() { return this.id; }).get().join(',');
    88    jQuery.post(postboxL10n.requestFile, {
    99        action: 'closed-postboxes',
    1010        closed: closed,
    11         cookie: document.cookie});
     11        closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
     12        page: page
     13    });
    1214}
  • trunk/wp-admin/page-new.php

    r6712 r6761  
    55$editing = true;
    66wp_enqueue_script('autosave');
    7 wp_enqueue_script('post');
     7wp_enqueue_script('page');
    88wp_enqueue_script('thickbox');
    99wp_enqueue_script('media-upload');
  • trunk/wp-admin/page.php

    r6665 r6761  
    5353    }
    5454
    55     wp_enqueue_script('post');
     55    wp_enqueue_script('page');
    5656    wp_enqueue_script('thickbox');
    5757    wp_enqueue_script('media-upload');
  • trunk/wp-includes/script-loader.php

    r6757 r6761  
    136136                'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
    137137            ) );
    138             $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox'), '20080128' );
     138            $this->add( 'slug', '/wp-admin/js/slug.js', array('jquery'), '20080208' );
     139            $this->localize( 'slug', 'slugL10n', array(
     140                'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
     141                'save' => __('Save'),
     142                'cancel' => __('Cancel'),
     143            ) );
     144            $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080128' );
    139145            $this->localize( 'post', 'postL10n', array(
    140146                'tagsUsed' =>  __('Tags used on this post:'),
     
    142148                'addTag' => attribute_escape(__('Add new tag')),
    143149                'separate' => __('Separate tags with commas'),
    144                 'save' => __('Save'),
    145                 'cancel' => __('Cancel'),
    146                 'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
    147             ) );
     150            ) );
     151            $this->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'postbox'), '20080208' );
    148152            $this->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080131' );
    149153            $this->add( 'media-upload', '/wp-admin/js/media-upload.js', false, '20080109' );
Note: See TracChangeset for help on using the changeset viewer.