Move widget stuff around. see #4169
git-svn-id: http://svn.automattic.com/wordpress/trunk@5360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
72a19935ff
commit
58d8ed1284
|
@ -173,5 +173,7 @@ add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
|
||||||
add_action('admin_print_scripts', 'wp_print_scripts', 20);
|
add_action('admin_print_scripts', 'wp_print_scripts', 20);
|
||||||
add_action('mce_options', '_mce_set_direction');
|
add_action('mce_options', '_mce_set_direction');
|
||||||
add_action('init', 'smilies_init', 5);
|
add_action('init', 'smilies_init', 5);
|
||||||
add_action('init', 'wp_widgets_init', 1);
|
|
||||||
|
add_action( 'plugins_loaded', 'wp_load_widgets', 0 );
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1502,4 +1502,8 @@ function wp_parse_args( $args, $defaults = '' ) {
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wp_load_widgets() {
|
||||||
|
require_once ABSPATH . WPINC . '/widgets.php';
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,7 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
Check if another widget plugin is active. If this is so,
|
||||||
|
then bail out.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( function_exists( 'dynamic_sidebars' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Global Variables */
|
/* Global Variables */
|
||||||
|
|
||||||
|
global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_styles, $wp_registered_widget_defaults;
|
||||||
|
|
||||||
$wp_registered_sidebars = array();
|
$wp_registered_sidebars = array();
|
||||||
$wp_registered_widgets = array();
|
$wp_registered_widgets = array();
|
||||||
$wp_registered_widget_controls = array();
|
$wp_registered_widget_controls = array();
|
||||||
|
@ -10,7 +21,6 @@ $wp_register_widget_defaults = false;
|
||||||
|
|
||||||
/* Template tags & API functions */
|
/* Template tags & API functions */
|
||||||
|
|
||||||
if ( !function_exists( 'register_sidebars' ) ):
|
|
||||||
function register_sidebars($number = 1, $args = array()) {
|
function register_sidebars($number = 1, $args = array()) {
|
||||||
$number = (int) $number;
|
$number = (int) $number;
|
||||||
|
|
||||||
|
@ -31,9 +41,7 @@ function register_sidebars($number = 1, $args = array()) {
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( !function_exists( 'register_sidebar' ) ):
|
|
||||||
function register_sidebar($args = array()) {
|
function register_sidebar($args = array()) {
|
||||||
global $wp_registered_sidebars;
|
global $wp_registered_sidebars;
|
||||||
|
|
||||||
|
@ -57,18 +65,14 @@ function register_sidebar($args = array()) {
|
||||||
|
|
||||||
return $sidebar['id'];
|
return $sidebar['id'];
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( !function_exists( 'unregister_sidebar' ) ):
|
|
||||||
function unregister_sidebar( $name ) {
|
function unregister_sidebar( $name ) {
|
||||||
global $wp_registered_sidebars;
|
global $wp_registered_sidebars;
|
||||||
|
|
||||||
if ( isset( $wp_registered_sidebars[$name] ) )
|
if ( isset( $wp_registered_sidebars[$name] ) )
|
||||||
unset( $wp_registered_sidebars[$name] );
|
unset( $wp_registered_sidebars[$name] );
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( !function_exists( 'register_sidebar_widget' ) ):
|
|
||||||
function register_sidebar_widget($name, $output_callback, $classname = '', $id = '') {
|
function register_sidebar_widget($name, $output_callback, $classname = '', $id = '') {
|
||||||
global $wp_registered_widgets, $wp_register_widget_defaults;
|
global $wp_registered_widgets, $wp_register_widget_defaults;
|
||||||
|
|
||||||
|
@ -100,17 +104,13 @@ function register_sidebar_widget($name, $output_callback, $classname = '', $id =
|
||||||
elseif ( is_callable($output_callback) && ( !isset($wp_registered_widgets[$id]) || !$wp_register_widget_defaults) )
|
elseif ( is_callable($output_callback) && ( !isset($wp_registered_widgets[$id]) || !$wp_register_widget_defaults) )
|
||||||
$wp_registered_widgets[$id] = $widget;
|
$wp_registered_widgets[$id] = $widget;
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( !function_exists( 'unregister_sidebar_widget' ) ):
|
|
||||||
function unregister_sidebar_widget($id) {
|
function unregister_sidebar_widget($id) {
|
||||||
$id = sanitize_title($id);
|
$id = sanitize_title($id);
|
||||||
register_sidebar_widget('', '', '', $id);
|
register_sidebar_widget('', '', '', $id);
|
||||||
unregister_widget_control($id);
|
unregister_widget_control($id);
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( !function_exists( 'register_widget_control' ) ):
|
|
||||||
function register_widget_control($name, $control_callback, $width = 300, $height = 200, $id = '') {
|
function register_widget_control($name, $control_callback, $width = 300, $height = 200, $id = '') {
|
||||||
global $wp_registered_widget_controls, $wp_register_widget_defaults;
|
global $wp_registered_widget_controls, $wp_register_widget_defaults;
|
||||||
|
|
||||||
|
@ -142,16 +142,12 @@ function register_widget_control($name, $control_callback, $width = 300, $height
|
||||||
'params' => array_slice(func_get_args(), 5)
|
'params' => array_slice(func_get_args(), 5)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( !function_exists( 'unregister_widget_control' ) ):
|
|
||||||
function unregister_widget_control($id) {
|
function unregister_widget_control($id) {
|
||||||
$id = sanitize_title($id);
|
$id = sanitize_title($id);
|
||||||
return register_widget_control($id, '');
|
return register_widget_control($id, '');
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( !function_exists( 'dynamic_sidebar' ) ):
|
|
||||||
function dynamic_sidebar($index = 1) {
|
function dynamic_sidebar($index = 1) {
|
||||||
global $wp_registered_sidebars, $wp_registered_widgets;
|
global $wp_registered_sidebars, $wp_registered_widgets;
|
||||||
|
|
||||||
|
@ -185,9 +181,7 @@ function dynamic_sidebar($index = 1) {
|
||||||
|
|
||||||
return $did_one;
|
return $did_one;
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( !function_exists( 'is_active_widget' ) ):
|
|
||||||
function is_active_widget($callback) {
|
function is_active_widget($callback) {
|
||||||
global $wp_registered_widgets;
|
global $wp_registered_widgets;
|
||||||
|
|
||||||
|
@ -200,9 +194,7 @@ function is_active_widget($callback) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if ( !function_exists( 'is_dynamic_sidebar' ) ):
|
|
||||||
function is_dynamic_sidebar() {
|
function is_dynamic_sidebar() {
|
||||||
global $wp_registered_widgets, $wp_registered_sidebars;
|
global $wp_registered_widgets, $wp_registered_sidebars;
|
||||||
$sidebars_widgets = get_option('sidebars_widgets');
|
$sidebars_widgets = get_option('sidebars_widgets');
|
||||||
|
@ -215,7 +207,6 @@ function is_dynamic_sidebar() {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
/* Internal Functions */
|
/* Internal Functions */
|
||||||
|
|
||||||
|
@ -909,4 +900,6 @@ function wp_widgets_init() {
|
||||||
do_action('widgets_init');
|
do_action('widgets_init');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_action('init', 'wp_widgets_init', 1);
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -168,7 +168,6 @@ require (ABSPATH . WPINC . '/cron.php');
|
||||||
require (ABSPATH . WPINC . '/version.php');
|
require (ABSPATH . WPINC . '/version.php');
|
||||||
require (ABSPATH . WPINC . '/deprecated.php');
|
require (ABSPATH . WPINC . '/deprecated.php');
|
||||||
require (ABSPATH . WPINC . '/script-loader.php');
|
require (ABSPATH . WPINC . '/script-loader.php');
|
||||||
require (ABSPATH . WPINC . '/widgets.php');
|
|
||||||
|
|
||||||
if (strpos($_SERVER['PHP_SELF'], 'install.php') === false) {
|
if (strpos($_SERVER['PHP_SELF'], 'install.php') === false) {
|
||||||
// Used to guarantee unique hash cookies
|
// Used to guarantee unique hash cookies
|
||||||
|
|
Loading…
Reference in New Issue