IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 23 | 23 | // |
| 24 | 24 | |
| 25 | 25 | /** @ignore */ |
| 26 | | global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates; |
| | 26 | global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates, $wp_current_widget; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Stores the sidebars, since many themes can have more than one. |
| … |
… |
|
| 54 | 54 | $wp_registered_widget_updates = array(); |
| 55 | 55 | |
| 56 | 56 | /** |
| | 57 | * @since 4.5.0 |
| | 58 | * |
| | 59 | * @global array $wp_current_widget |
| | 60 | */ |
| | 61 | $wp_current_widget = array(); |
| | 62 | |
| | 63 | /** |
| 57 | 64 | * Private |
| 58 | 65 | * |
| 59 | 66 | * @global array $_wp_sidebars_widgets |
| … |
… |
|
| 95 | 102 | // |
| 96 | 103 | |
| 97 | 104 | /** |
| | 105 | * Get option from current widget array |
| | 106 | * |
| | 107 | * @since 4.5.0 |
| | 108 | * |
| | 109 | * @param string $option Option to get from current widget |
| | 110 | * |
| | 111 | * @return bool|string |
| | 112 | */ |
| | 113 | function _get_current_widget_option( $option ) { |
| | 114 | global $wp_current_widget; |
| | 115 | |
| | 116 | if ( isset( $wp_current_widget[ $option ] ) ) { |
| | 117 | return $wp_current_widget[ $option ]; |
| | 118 | } |
| | 119 | |
| | 120 | return false; |
| | 121 | } |
| | 122 | |
| | 123 | /** |
| | 124 | * Get current widget id |
| | 125 | * |
| | 126 | * @since 4.5.0 |
| | 127 | * |
| | 128 | * @return bool|string |
| | 129 | */ |
| | 130 | function current_widget_id() { |
| | 131 | return _get_current_widget_option( 'widget_id' ); |
| | 132 | } |
| | 133 | |
| | 134 | /** |
| | 135 | * Get current widget id base |
| | 136 | * |
| | 137 | * @since 4.5.0 |
| | 138 | * |
| | 139 | * @return bool|string |
| | 140 | */ |
| | 141 | function current_widget() { |
| | 142 | return _get_current_widget_option( 'id_base' ); |
| | 143 | } |
| | 144 | |
| | 145 | /** |
| 98 | 146 | * Register a widget |
| 99 | 147 | * |
| 100 | 148 | * Registers a WP_Widget widget |
| … |
… |
|
| 1017 | 1065 | * @since 2.8.0 |
| 1018 | 1066 | * |
| 1019 | 1067 | * @global WP_Widget_Factory $wp_widget_factory |
| | 1068 | * @global array $wp_current_widget |
| 1020 | 1069 | * |
| 1021 | 1070 | * @param string $widget The widget's PHP class name (see class-wp-widget.php). |
| 1022 | 1071 | * @param array $instance Optional. The widget's instance settings. Default empty array. |
| … |
… |
|
| 1034 | 1083 | * } |
| 1035 | 1084 | */ |
| 1036 | 1085 | function the_widget( $widget, $instance = array(), $args = array() ) { |
| 1037 | | global $wp_widget_factory; |
| | 1086 | global $wp_widget_factory, $wp_current_widget; |
| 1038 | 1087 | |
| 1039 | 1088 | $widget_obj = $wp_widget_factory->widgets[$widget]; |
| 1040 | 1089 | if ( ! ( $widget_obj instanceof WP_Widget ) ) { |
| … |
… |
|
| 1064 | 1113 | do_action( 'the_widget', $widget, $instance, $args ); |
| 1065 | 1114 | |
| 1066 | 1115 | $widget_obj->_set(-1); |
| | 1116 | |
| | 1117 | $wp_current_widget = array( 'id_base' => $this->id_base, 'widget_id' => $args['widget_id'] ); |
| | 1118 | |
| 1067 | 1119 | $widget_obj->widget($args, $instance); |
| | 1120 | |
| | 1121 | $wp_current_widget = array(); |
| 1068 | 1122 | } |
| 1069 | 1123 | |
| 1070 | 1124 | /** |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 315 | 315 | * @since 2.8.0 |
| 316 | 316 | * @access public |
| 317 | 317 | * |
| | 318 | * @global array $wp_current_widget |
| | 319 | * |
| 318 | 320 | * @param array $args Display arguments. See {@see WP_Widget::widget()} for information |
| 319 | 321 | * on accepted arguments. |
| 320 | 322 | * @param int|array $widget_args { |
| … |
… |
|
| 325 | 327 | * } |
| 326 | 328 | */ |
| 327 | 329 | public function display_callback( $args, $widget_args = 1 ) { |
| | 330 | global $wp_current_widget; |
| | 331 | |
| 328 | 332 | if ( is_numeric( $widget_args ) ) { |
| 329 | 333 | $widget_args = array( 'number' => $widget_args ); |
| 330 | 334 | } |
| … |
… |
|
| 358 | 362 | wp_suspend_cache_addition( true ); |
| 359 | 363 | } |
| 360 | 364 | |
| | 365 | $wp_current_widget = array( 'id_base' => $this->id_base, 'widget_id' => $args['widget_id'] ); |
| | 366 | |
| 361 | 367 | $this->widget( $args, $instance ); |
| | 368 | |
| | 369 | $wp_current_widget = array(); |
| 362 | 370 | |
| 363 | 371 | if ( $this->is_preview() ) { |
| 364 | 372 | wp_suspend_cache_addition( $was_cache_addition_suspended ); |