Make WordPress Core

Changeset 6584


Ignore:
Timestamp:
01/09/2008 05:46:13 PM (16 years ago)
Author:
ryan
Message:

Save toggle box open/closed state. Props nbachiyski. fixes #5610

Location:
trunk
Files:
5 edited

Legend:

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

    r6570 r6584  
    442442    die('0');
    443443break;
     444case 'closed-postboxes' :
     445    check_ajax_referer( $action );
     446    $closed = explode(',', $_POST['closed']);
     447    if (!is_array($closed)) break;
     448    $current_user = wp_get_current_user();
     449    update_usermeta($current_user->ID, 'closedpostboxes', $closed);
     450break;
    444451default :
    445452    do_action( 'wp_ajax_' . $_POST['action'] );
  • trunk/wp-admin/edit-form-advanced.php

    r6567 r6584  
    111111?>" /></p>
    112112
    113 <div id="tagsdiv" class="postbox">
     113<div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv'); ?>">
    114114<h3><?php _e('Tags'); ?></h3>
    115115<div class="inside">
     
    119119</div>
    120120
    121 <div id="categorydiv" class="postbox">
     121<div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv'); ?>">
    122122<h3><?php _e('Categories') ?></h3>
    123123<div class="inside">
     
    141141<h2><?php _e('Advanced Options'); ?></h2>
    142142
    143 <div id="postexcerpt" class="postbox">
     143<div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt'); ?>">
    144144<h3><?php _e('Optional Excerpt') ?></h3>
    145145<div class="inside"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div>
    146146</div>
    147147
    148 <div id="trackbacksdiv" class="postbox">
     148<div id="trackbacksdiv" class="postbox <?php echo postbox_classes('trackbacksdiv'); ?>">
    149149<h3><?php _e('Trackbacks') ?></h3>
    150150<div class="inside">
     
    157157</div>
    158158
    159 <div id="postcustom" class="postbox">
     159<div id="postcustom" class="postbox <?php echo postbox_classes('postcustom'); ?>">
    160160<h3><?php _e('Custom Fields') ?></h3>
    161161<div class="inside">
     
    178178<?php do_action('dbx_post_advanced'); ?>
    179179
    180 <div id="commentstatusdiv" class="postbox">
     180<div id="commentstatusdiv" class="postbox <?php echo postbox_classes('commentstatusdiv'); ?>">
    181181<h3><?php _e('Discussion') ?></h3>
    182182<div class="inside">
     
    189189</div>
    190190
    191 <div id="passworddiv" class="postbox">
     191<div id="passworddiv" class="postbox <?php echo postbox_classes('passworddiv'); ?>">
    192192<h3><?php _e('Post Password') ?></h3>
    193193<div class="inside">
     
    196196</div>
    197197
    198 <div id="slugdiv" class="postbox">
     198<div id="slugdiv" class="postbox <?php echo postbox_classes('slugdiv'); ?>">
    199199<h3><?php _e('Post Slug') ?></h3>
    200200<div class="inside">
     
    203203</div>
    204204
    205 <div id="poststatusdiv" class="postbox">
     205<div id="poststatusdiv" class="postbox <?php echo postbox_classes('poststatusdiv'); ?>">
    206206<h3><?php _e('Post Status') ?></h3>
    207207<div class="inside">
     
    216216
    217217<?php if ( current_user_can('edit_posts') ) : ?>
    218 <div id="posttimestampdiv" class="postbox">
     218<div id="posttimestampdiv" class="postbox <?php echo postbox_classes('posttimestampdiv'); ?>">
    219219<h3><?php _e('Post Timestamp'); ?></h3>
    220220<div class="inside"><?php touch_time(($action == 'edit')); ?></div>
     
    228228if ( $authors && count( $authors ) > 1 ) :
    229229?>
    230 <div id="authordiv" class="postbox">
     230<div id="authordiv" class="postbox <?php echo postbox_classes('authordiv'); ?>">
    231231<h3><?php _e('Post Author'); ?></h3>
    232232<div class="inside">
  • trunk/wp-admin/includes/post.php

    r6354 r6584  
    514514}
    515515
     516function postbox_classes( $id ) {
     517    $current_user = wp_get_current_user();
     518    $closed = get_usermeta( $current_user->ID, 'closedpostboxes' );
     519    if ( !is_array( $closed ) ) return '';
     520    return in_array( $id, $closed )? 'closed' : '';
     521}
     522
    516523?>
  • trunk/wp-admin/js/post.js

    r6578 r6584  
    3232    });
    3333    if ( shown )
    34         jQuery( '#tagchecklist' ).prepend( '<strong>Tags used on this post:</strong><br />' );
     34        jQuery( '#tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' );
    3535}
    3636
     
    5555function add_postbox_toggles() {
    5656    jQuery('.postbox h3').prepend('<a class="togbox">+</a> ');
    57     jQuery('.togbox').click( function() { jQuery(jQuery(this).parent().parent().get(0)).toggleClass('closed'); } );
     57    jQuery('.togbox').click( function() { jQuery(jQuery(this).parent().parent().get(0)).toggleClass('closed'); save_postboxes_state(); } );
     58}
     59
     60function save_postboxes_state() {
     61    var closed = jQuery('.postbox').filter('.closed').map(function() { return this.id; }).get().join(',');
     62    jQuery.post(postL10n.requestFile, {
     63        action: 'closed-postboxes',
     64        closed: closed,
     65        cookie: document.cookie});
    5866}
    5967
     
    6270    tag_update_quickclicks();
    6371    // add the quickadd form
    64     jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" size="16" autocomplete="off" value="Add new tag" /><input type="button" class="button" id="tagadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span class="howto">Separate tags with commas</span></span>');
     72    jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '"/><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>');
    6573    jQuery('#tagadd').click( tag_flush_to_text );
    6674//  jQuery('#newtag').keydown( tag_press_key );
    6775    jQuery('#newtag').focus(function() {
    68         if ( this.value == 'Add new tag' ) {
     76        if ( this.value == postL10n.addTag ) {
    6977            this.value = '';
    7078            this.style.color = '#333';
     
    7381    jQuery('#newtag').blur(function() {
    7482        if ( this.value == '' ) {
    75             this.value = 'Add new tag';
     83            this.value = postL10n.addTag;
    7684            this.style.color = '#999'
    7785        }
     
    8088    // auto-suggest stuff
    8189    jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { onSelect: tag_flush_to_text, delay: 500, minchars: 2 } );
     90
     91    // postboxes
    8292    add_postbox_toggles();
    8393});
  • trunk/wp-includes/script-loader.php

    r6582 r6584  
    109109            $this->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
    110110            $this->add( 'post', '/wp-admin/js/post.js', array('suggest'), '20080102' );
     111            $this->localize( 'post', 'postL10n', array(
     112                'tagsUsed' =>  __('Tags used on this post:'),
     113                'add' => attribute_escape(__('Add')),
     114                'addTag' => attribute_escape(__('Add new tag')),
     115                'separate' => __('Separate tags with commas'),
     116                'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
     117            ) );
    111118            $this->add( 'media-upload', '/wp-admin/js/media-upload.js', false, '20080109' );
    112119            $this->localize( 'upload', 'uploadL10n', array(
Note: See TracChangeset for help on using the changeset viewer.