Fix metabox hiding. Props scribu. fixes #12439
git-svn-id: http://svn.automattic.com/wordpress/trunk@13551 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b37894c348
commit
95623b4ce5
|
@ -1021,11 +1021,11 @@ case 'closed-postboxes' :
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
if ( is_array($closed) )
|
if ( is_array($closed) )
|
||||||
update_user_meta($user->ID, 'closedpostboxes_'.$page, $closed);
|
update_user_option($user->ID, "closedpostboxes_$page", $closed);
|
||||||
|
|
||||||
if ( is_array($hidden) ) {
|
if ( is_array($hidden) ) {
|
||||||
$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv') ); // postboxes that are always shown
|
$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv') ); // postboxes that are always shown
|
||||||
update_user_meta($user->ID, 'meta-box-hidden_'.$page, $hidden);
|
update_user_option($user->ID, "meta-box-hidden_$page", $hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
die('1');
|
die('1');
|
||||||
|
@ -1043,7 +1043,7 @@ case 'hidden-columns' :
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
if ( is_array($hidden) )
|
if ( is_array($hidden) )
|
||||||
update_user_meta($user->ID, "manage-$page-columns-hidden", $hidden);
|
update_user_option($user->ID, "manage-$page-columns-hidden", $hidden);
|
||||||
|
|
||||||
die('1');
|
die('1');
|
||||||
break;
|
break;
|
||||||
|
@ -1063,7 +1063,7 @@ case 'meta-box-order':
|
||||||
update_user_option($user->ID, "meta-box-order_$page", $order);
|
update_user_option($user->ID, "meta-box-order_$page", $order);
|
||||||
|
|
||||||
if ( $page_columns )
|
if ( $page_columns )
|
||||||
update_user_meta($user->ID, "screen_layout_$page", $page_columns);
|
update_user_option($user->ID, "screen_layout_$page", $page_columns);
|
||||||
|
|
||||||
die('1');
|
die('1');
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -34,8 +34,17 @@ $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
||||||
var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
|
var userSettings = {
|
||||||
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php echo substr($pagenow, 0, -4); ?>', typenow = '<?php echo $typenow; ?>', adminpage = '<?php echo $admin_body_class; ?>', thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>';
|
'url': '<?php echo SITECOOKIEPATH; ?>',
|
||||||
|
'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
|
||||||
|
'time':'<?php echo time() ?>'
|
||||||
|
},
|
||||||
|
ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
|
||||||
|
pagenow = '<?php echo $current_screen->id; ?>',
|
||||||
|
typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
|
||||||
|
adminpage = '<?php echo $admin_body_class; ?>',
|
||||||
|
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
|
||||||
|
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>';
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -228,17 +228,9 @@ WPRemoveThumbnail = function(){
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
jQuery(document).ready( function($) {
|
jQuery(document).ready( function($) {
|
||||||
var stamp, visibility, sticky = '', post = 'post' == pagenow || 'post-new' == pagenow, page = 'page' == pagenow || 'page-new' == pagenow;
|
var stamp, visibility, sticky = '';
|
||||||
|
|
||||||
// postboxes
|
postboxes.add_postbox_toggles(pagenow);
|
||||||
if ( post ) {
|
|
||||||
type = 'post';
|
|
||||||
if ( typenow )
|
|
||||||
type = typenow;
|
|
||||||
postboxes.add_postbox_toggles(type);
|
|
||||||
} else if ( page ) {
|
|
||||||
postboxes.add_postbox_toggles('page');
|
|
||||||
}
|
|
||||||
|
|
||||||
// multi-taxonomies
|
// multi-taxonomies
|
||||||
if ( $('#tagsdiv-post_tag').length ) {
|
if ( $('#tagsdiv-post_tag').length ) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5,6 +5,7 @@ var postboxes;
|
||||||
this.init(page,args);
|
this.init(page,args);
|
||||||
$('.postbox h3, .postbox .handlediv').click( function() {
|
$('.postbox h3, .postbox .handlediv').click( function() {
|
||||||
var p = $(this).parent('.postbox'), id = p.attr('id');
|
var p = $(this).parent('.postbox'), id = p.attr('id');
|
||||||
|
|
||||||
p.toggleClass('closed');
|
p.toggleClass('closed');
|
||||||
postboxes.save_state(page);
|
postboxes.save_state(page);
|
||||||
if ( id ) {
|
if ( id ) {
|
||||||
|
@ -19,6 +20,7 @@ var postboxes;
|
||||||
} );
|
} );
|
||||||
$('.hide-postbox-tog').click( function() {
|
$('.hide-postbox-tog').click( function() {
|
||||||
var box = $(this).val();
|
var box = $(this).val();
|
||||||
|
|
||||||
if ( $(this).attr('checked') ) {
|
if ( $(this).attr('checked') ) {
|
||||||
$('#' + box).show();
|
$('#' + box).show();
|
||||||
if ( $.isFunction( postboxes.pbshow ) )
|
if ( $.isFunction( postboxes.pbshow ) )
|
||||||
|
@ -115,7 +117,8 @@ var postboxes;
|
||||||
|
|
||||||
save_state : function(page) {
|
save_state : function(page) {
|
||||||
var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','),
|
var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','),
|
||||||
hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
|
hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
|
||||||
|
|
||||||
$.post(ajaxurl, {
|
$.post(ajaxurl, {
|
||||||
action: 'closed-postboxes',
|
action: 'closed-postboxes',
|
||||||
closed: closed,
|
closed: closed,
|
||||||
|
@ -127,6 +130,7 @@ var postboxes;
|
||||||
|
|
||||||
save_order : function(page) {
|
save_order : function(page) {
|
||||||
var postVars, page_columns = $('.columns-prefs input:checked').val() || 0;
|
var postVars, page_columns = $('.columns-prefs input:checked').val() || 0;
|
||||||
|
|
||||||
postVars = {
|
postVars = {
|
||||||
action: 'meta-box-order',
|
action: 'meta-box-order',
|
||||||
_ajax_nonce: $('#meta-box-order-nonce').val(),
|
_ajax_nonce: $('#meta-box-order-nonce').val(),
|
||||||
|
|
|
@ -203,7 +203,6 @@ function get_user_option( $option, $user = 0, $deprecated = '' ) {
|
||||||
if ( !empty( $deprecated ) )
|
if ( !empty( $deprecated ) )
|
||||||
_deprecated_argument( __FUNCTION__, '3.0' );
|
_deprecated_argument( __FUNCTION__, '3.0' );
|
||||||
|
|
||||||
$option = preg_replace('|[^a-z0-9_]|i', '', $option);
|
|
||||||
if ( empty($user) )
|
if ( empty($user) )
|
||||||
$user = wp_get_current_user();
|
$user = wp_get_current_user();
|
||||||
else
|
else
|
||||||
|
@ -237,6 +236,7 @@ function get_user_option( $option, $user = 0, $deprecated = '' ) {
|
||||||
*/
|
*/
|
||||||
function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {
|
function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
if ( !$global )
|
if ( !$global )
|
||||||
$option_name = $wpdb->prefix . $option_name;
|
$option_name = $wpdb->prefix . $option_name;
|
||||||
return update_user_meta( $user_id, $option_name, $newvalue );
|
return update_user_meta( $user_id, $option_name, $newvalue );
|
||||||
|
|
Loading…
Reference in New Issue