Make WordPress Core

Ticket #5799: postboxes-on-all-pages.diff

File postboxes-on-all-pages.diff, 17.2 KB (added by nbachiyski, 17 years ago)
  • wp-includes/script-loader.php

     
    135135                        $this->localize( 'postbox', 'postboxL10n', array(
    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:'),
    141147                                'add' => attribute_escape(__('Add')),
    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',
    147150                        ) );
     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' );
    150154                        $this->localize( 'upload', 'uploadL10n', array(
  • wp-admin/admin-ajax.php

     
    513513        die('0');
    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':
    523528        check_ajax_referer( $action );
  • wp-admin/includes/post.php

     
    517517        return array($post_stati, $avail_post_stati);
    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' : '';
    525525        } else {
  • wp-admin/js/post.js

     
    5252        }
    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.
    10660        if ( !jQuery('#tags-input').size() ) {
  • wp-admin/js/link.js

     
    11addLoadEvent( function() {
    22        // postboxes
    3         add_postbox_toggles();
     3        add_postbox_toggles('link');
    44
    55        // category tabs
    66        var categoryTabs = jQuery('#category-tabs').tabs();
     
    4343                return false;
    4444        } );
    4545        jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
    46 });
    47  No newline at end of file
     46});
  • wp-admin/js/postbox.js

     
    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});
    12 }
    13  No newline at end of file
     11                closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
     12                page: page
     13        });
     14}
  • wp-admin/edit-page-form.php

     
    5757<h3><?php _e('Page') ?></h3>
    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
    6263<div id="submitpost">
     
    136137
    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">
    142143<div id="postcustomstuff">
     
    155156</div>
    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">
    161162<input name="advanced_view" type="hidden" value="1" />
     
    166167</div>
    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">
    172173<input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" />
    173174</div>
    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">
    179180<input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
    180181</div>
    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">
    186187<select name="parent_id">
     
    191192</div>
    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">
    197198<select name="page_template">
     
    202203</div>
    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">
    208209<input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $post->menu_order ?>" />
     
    215216        $authors[] = $post->post_author;
    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">
    221222<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?>
  • wp-admin/edit-link-form.php

     
    3232
    3333<?php echo $form ?>
    3434<?php wp_nonce_field($nonce_action); ?>
     35<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    3536
    3637<div class="wrap">
    3738
     
    6465</p>
    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">
    7071
     
    100101
    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">
    106107<label for="link_target_blank" class="selectit">
     
    115116</div>
    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">
    121122<label for="link_visible_yes" class="selectit">
     
    127128</div>
    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">
    133134<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     
    240241</div>
    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">
    246247<table class="editform" width="100%" cellspacing="2" cellpadding="5">
  • wp-admin/edit-form-advanced.php

     
    8989<h3><?php _e('Post') ?></h3>
    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
    9495<?php echo $form_pingback ?>
     
    175176        echo clean_url(stripslashes(wp_get_referer()));
    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">
    181182<p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></p>
     
    183184</div>
    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">
    189190
     
    232233
    233234<h2><?php _e('Advanced Options'); ?></h2>
    234235
    235 <div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt'); ?>">
     236<div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt', 'post'); ?>">
    236237<h3><?php _e('Optional Excerpt') ?></h3>
    237238<div class="inside"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div>
    238239</div>
    239240
    240 <div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv'); ?>">
     241<div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv', 'post'); ?>">
    241242<h3><?php _e('Trackbacks') ?></h3>
    242243<div class="inside">
    243244<?php _e('Send trackbacks to:'); ?> <?php echo $form_trackback; ?> (<?php _e('Separate multiple URLs with spaces'); ?>)
     
    248249</div>
    249250</div>
    250251
    251 <div id="postcustom" class="postbox <?php echo postbox_classes('postcustom'); ?>">
     252<div id="postcustom" class="postbox <?php echo postbox_classes('postcustom', 'post'); ?>">
    252253<h3><?php _e('Custom Fields') ?></h3>
    253254<div class="inside">
    254255<div id="postcustomstuff">
     
    269270
    270271<?php do_action('dbx_post_advanced'); ?>
    271272
    272 <div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv'); ?>">
     273<div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv', 'post'); ?>">
    273274<h3><?php _e('Discussion') ?></h3>
    274275<div class="inside">
    275276<input name="advanced_view" type="hidden" value="1" />
     
    280281</div>
    281282</div>
    282283
    283 <div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv'); ?>">
     284<div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv', 'post'); ?>">
    284285<h3><?php _e('Post Password') ?></h3>
    285286<div class="inside">
    286287<input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" />
    287288</div>
    288289</div>
    289290
    290 <div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv'); ?>">
     291<div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv', 'post'); ?>">
    291292<h3><?php _e('Post Slug') ?></h3>
    292293<div class="inside">
    293294<input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
     
    295296</div>
    296297
    297298<?php if ( current_user_can('edit_posts') ) : ?>
    298 <div id="posttimestampdiv" class="postbox <?php echo postbox_classes('posttimestampdiv'); ?>">
     299<div id="posttimestampdiv" class="postbox <?php echo postbox_classes('posttimestampdiv', 'post'); ?>">
    299300<h3><?php _e('Post Timestamp'); ?></h3>
    300301<div class="inside"><?php touch_time(($action == 'edit')); ?></div>
    301302</div>
     
    307308        $authors[] = $post->post_author;
    308309if ( $authors && count( $authors ) > 1 ) :
    309310?>
    310 <div id="authordiv" class="postbox <?php echo postbox_classes('authordiv'); ?>">
     311<div id="authordiv" class="postbox <?php echo postbox_classes('authordiv', 'post'); ?>">
    311312<h3><?php _e('Post Author'); ?></h3>
    312313<div class="inside">
    313314<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?>
  • wp-admin/page-new.php

     
    44$parent_file = 'post-new.php';
    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');
    1010
  • wp-admin/page.php

     
    5252                exit();
    5353        }
    5454
    55         wp_enqueue_script('post');
     55        wp_enqueue_script('page');
    5656        wp_enqueue_script('thickbox');
    5757        wp_enqueue_script('media-upload');
    5858