mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
Upgrade widget options only from admin, props ryan, fixes #9629
git-svn-id: http://svn.automattic.com/wordpress/trunk@11074 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5bb3173d78
commit
e1922c01b6
@ -340,6 +340,11 @@ $wp_registered_widgets = array();
|
|||||||
$wp_registered_widget_controls = array();
|
$wp_registered_widget_controls = array();
|
||||||
$wp_registered_widget_updates = array();
|
$wp_registered_widget_updates = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private
|
||||||
|
*/
|
||||||
|
$_wp_sidebars_widgets = array();
|
||||||
|
|
||||||
/* Template tags & API functions */
|
/* Template tags & API functions */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -836,9 +841,18 @@ function is_dynamic_sidebar() {
|
|||||||
* @return array Upgraded list of widgets to version 2 array format.
|
* @return array Upgraded list of widgets to version 2 array format.
|
||||||
*/
|
*/
|
||||||
function wp_get_sidebars_widgets($update = true) {
|
function wp_get_sidebars_widgets($update = true) {
|
||||||
global $wp_registered_widgets, $wp_registered_sidebars;
|
global $wp_registered_widgets, $wp_registered_sidebars, $_wp_sidebars_widgets;
|
||||||
|
|
||||||
|
// If loading from front page, consult $_wp_sidebars_widgets rather than options
|
||||||
|
// to see if wp_convert_widget_settings() has made manipulations in memory.
|
||||||
|
if ( is_admin() ) {
|
||||||
$sidebars_widgets = get_option('sidebars_widgets', array());
|
$sidebars_widgets = get_option('sidebars_widgets', array());
|
||||||
|
} else {
|
||||||
|
if ( empty($_wp_sidebars_widgets) )
|
||||||
|
$sidebars_widgets = get_option('sidebars_widgets', array());
|
||||||
|
else
|
||||||
|
$sidebars_widgets = &$_wp_sidebars_widgets;
|
||||||
|
}
|
||||||
$_sidebars_widgets = array();
|
$_sidebars_widgets = array();
|
||||||
|
|
||||||
if ( !isset($sidebars_widgets['array_version']) )
|
if ( !isset($sidebars_widgets['array_version']) )
|
||||||
@ -904,7 +918,7 @@ function wp_get_sidebars_widgets($update = true) {
|
|||||||
unset($_sidebars_widgets);
|
unset($_sidebars_widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $update )
|
if ( $update && is_admin() )
|
||||||
update_option('sidebars_widgets', $sidebars_widgets);
|
update_option('sidebars_widgets', $sidebars_widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -956,6 +970,7 @@ function wp_get_widget_defaults() {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function wp_convert_widget_settings($base_name, $option_name, $settings) {
|
function wp_convert_widget_settings($base_name, $option_name, $settings) {
|
||||||
|
global $_wp_sidebars_widgets;
|
||||||
// This test may need expanding.
|
// This test may need expanding.
|
||||||
$single = false;
|
$single = false;
|
||||||
if ( empty($settings) ) {
|
if ( empty($settings) ) {
|
||||||
@ -974,7 +989,15 @@ function wp_convert_widget_settings($base_name, $option_name, $settings) {
|
|||||||
if ( $single ) {
|
if ( $single ) {
|
||||||
$settings = array( 2 => $settings );
|
$settings = array( 2 => $settings );
|
||||||
|
|
||||||
|
// If loading from the front page, update sidebar in memory but don't save to options
|
||||||
|
if ( is_admin() ) {
|
||||||
$sidebars_widgets = get_option('sidebars_widgets');
|
$sidebars_widgets = get_option('sidebars_widgets');
|
||||||
|
} else {
|
||||||
|
if ( empty($GLOBALS['_wp_sidebars_widgets']) )
|
||||||
|
$GLOBALS['_wp_sidebars_widgets'] = get_option('sidebars_widgets');
|
||||||
|
$sidebars_widgets = &$GLOBALS['_wp_sidebars_widgets'];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ( (array) $sidebars_widgets as $index => $sidebar ) {
|
foreach ( (array) $sidebars_widgets as $index => $sidebar ) {
|
||||||
if ( is_array($sidebar) ) {
|
if ( is_array($sidebar) ) {
|
||||||
foreach ( $sidebar as $i => $name ) {
|
foreach ( $sidebar as $i => $name ) {
|
||||||
@ -986,10 +1009,12 @@ function wp_convert_widget_settings($base_name, $option_name, $settings) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( is_admin() )
|
||||||
update_option('sidebars_widgets', $sidebars_widgets);
|
update_option('sidebars_widgets', $sidebars_widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
$settings['_multiwidget'] = 1;
|
$settings['_multiwidget'] = 1;
|
||||||
|
if ( is_admin() )
|
||||||
update_option( $option_name, $settings );
|
update_option( $option_name, $settings );
|
||||||
|
|
||||||
return $settings;
|
return $settings;
|
||||||
|
Loading…
Reference in New Issue
Block a user