Edit File by line
/home/barbar84/www/wp-inclu...
File: widgets.php
* @global array $wp_registered_widget_updates
[500] Fix | Delete
* @global array $wp_registered_widgets
[501] Fix | Delete
* @global array $_wp_deprecated_widgets_callbacks
[502] Fix | Delete
*
[503] Fix | Delete
* @param int|string $id Sidebar ID.
[504] Fix | Delete
* @param string $name Sidebar display name.
[505] Fix | Delete
* @param callable $control_callback Run when sidebar is displayed.
[506] Fix | Delete
* @param array $options {
[507] Fix | Delete
* Optional. Array or string of control options. Default empty array.
[508] Fix | Delete
*
[509] Fix | Delete
* @type int $height Never used. Default 200.
[510] Fix | Delete
* @type int $width Width of the fully expanded control form (but try hard to use the default width).
[511] Fix | Delete
* Default 250.
[512] Fix | Delete
* @type int|string $id_base Required for multi-widgets, i.e widgets that allow multiple instances such as the
[513] Fix | Delete
* text widget. The widget id will end up looking like `{$id_base}-{$unique_number}`.
[514] Fix | Delete
* }
[515] Fix | Delete
* @param mixed ...$params Optional additional parameters to pass to the callback function when it's called.
[516] Fix | Delete
*/
[517] Fix | Delete
function wp_register_widget_control( $id, $name, $control_callback, $options = array(), ...$params ) {
[518] Fix | Delete
global $wp_registered_widget_controls, $wp_registered_widget_updates, $wp_registered_widgets, $_wp_deprecated_widgets_callbacks;
[519] Fix | Delete
[520] Fix | Delete
$id = strtolower( $id );
[521] Fix | Delete
$id_base = _get_widget_id_base( $id );
[522] Fix | Delete
[523] Fix | Delete
if ( empty( $control_callback ) ) {
[524] Fix | Delete
unset( $wp_registered_widget_controls[ $id ] );
[525] Fix | Delete
unset( $wp_registered_widget_updates[ $id_base ] );
[526] Fix | Delete
return;
[527] Fix | Delete
}
[528] Fix | Delete
[529] Fix | Delete
if ( in_array( $control_callback, $_wp_deprecated_widgets_callbacks, true ) && ! is_callable( $control_callback ) ) {
[530] Fix | Delete
unset( $wp_registered_widgets[ $id ] );
[531] Fix | Delete
return;
[532] Fix | Delete
}
[533] Fix | Delete
[534] Fix | Delete
if ( isset( $wp_registered_widget_controls[ $id ] ) && ! did_action( 'widgets_init' ) ) {
[535] Fix | Delete
return;
[536] Fix | Delete
}
[537] Fix | Delete
[538] Fix | Delete
$defaults = array(
[539] Fix | Delete
'width' => 250,
[540] Fix | Delete
'height' => 200,
[541] Fix | Delete
); // Height is never used.
[542] Fix | Delete
$options = wp_parse_args( $options, $defaults );
[543] Fix | Delete
$options['width'] = (int) $options['width'];
[544] Fix | Delete
$options['height'] = (int) $options['height'];
[545] Fix | Delete
[546] Fix | Delete
$widget = array(
[547] Fix | Delete
'name' => $name,
[548] Fix | Delete
'id' => $id,
[549] Fix | Delete
'callback' => $control_callback,
[550] Fix | Delete
'params' => $params,
[551] Fix | Delete
);
[552] Fix | Delete
$widget = array_merge( $widget, $options );
[553] Fix | Delete
[554] Fix | Delete
$wp_registered_widget_controls[ $id ] = $widget;
[555] Fix | Delete
[556] Fix | Delete
if ( isset( $wp_registered_widget_updates[ $id_base ] ) ) {
[557] Fix | Delete
return;
[558] Fix | Delete
}
[559] Fix | Delete
[560] Fix | Delete
if ( isset( $widget['params'][0]['number'] ) ) {
[561] Fix | Delete
$widget['params'][0]['number'] = -1;
[562] Fix | Delete
}
[563] Fix | Delete
[564] Fix | Delete
unset( $widget['width'], $widget['height'], $widget['name'], $widget['id'] );
[565] Fix | Delete
$wp_registered_widget_updates[ $id_base ] = $widget;
[566] Fix | Delete
}
[567] Fix | Delete
[568] Fix | Delete
/**
[569] Fix | Delete
* Registers the update callback for a widget.
[570] Fix | Delete
*
[571] Fix | Delete
* @since 2.8.0
[572] Fix | Delete
* @since 5.3.0 Formalized the existing and already documented `...$params` parameter
[573] Fix | Delete
* by adding it to the function signature.
[574] Fix | Delete
*
[575] Fix | Delete
* @global array $wp_registered_widget_updates
[576] Fix | Delete
*
[577] Fix | Delete
* @param string $id_base The base ID of a widget created by extending WP_Widget.
[578] Fix | Delete
* @param callable $update_callback Update callback method for the widget.
[579] Fix | Delete
* @param array $options Optional. Widget control options. See wp_register_widget_control().
[580] Fix | Delete
* Default empty array.
[581] Fix | Delete
* @param mixed ...$params Optional additional parameters to pass to the callback function when it's called.
[582] Fix | Delete
*/
[583] Fix | Delete
function _register_widget_update_callback( $id_base, $update_callback, $options = array(), ...$params ) {
[584] Fix | Delete
global $wp_registered_widget_updates;
[585] Fix | Delete
[586] Fix | Delete
if ( isset( $wp_registered_widget_updates[ $id_base ] ) ) {
[587] Fix | Delete
if ( empty( $update_callback ) ) {
[588] Fix | Delete
unset( $wp_registered_widget_updates[ $id_base ] );
[589] Fix | Delete
}
[590] Fix | Delete
return;
[591] Fix | Delete
}
[592] Fix | Delete
[593] Fix | Delete
$widget = array(
[594] Fix | Delete
'callback' => $update_callback,
[595] Fix | Delete
'params' => $params,
[596] Fix | Delete
);
[597] Fix | Delete
[598] Fix | Delete
$widget = array_merge( $widget, $options );
[599] Fix | Delete
$wp_registered_widget_updates[ $id_base ] = $widget;
[600] Fix | Delete
}
[601] Fix | Delete
[602] Fix | Delete
/**
[603] Fix | Delete
* Registers the form callback for a widget.
[604] Fix | Delete
*
[605] Fix | Delete
* @since 2.8.0
[606] Fix | Delete
* @since 5.3.0 Formalized the existing and already documented `...$params` parameter
[607] Fix | Delete
* by adding it to the function signature.
[608] Fix | Delete
*
[609] Fix | Delete
* @global array $wp_registered_widget_controls
[610] Fix | Delete
*
[611] Fix | Delete
* @param int|string $id Widget ID.
[612] Fix | Delete
* @param string $name Name attribute for the widget.
[613] Fix | Delete
* @param callable $form_callback Form callback.
[614] Fix | Delete
* @param array $options Optional. Widget control options. See wp_register_widget_control().
[615] Fix | Delete
* Default empty array.
[616] Fix | Delete
* @param mixed ...$params Optional additional parameters to pass to the callback function when it's called.
[617] Fix | Delete
*/
[618] Fix | Delete
[619] Fix | Delete
function _register_widget_form_callback( $id, $name, $form_callback, $options = array(), ...$params ) {
[620] Fix | Delete
global $wp_registered_widget_controls;
[621] Fix | Delete
[622] Fix | Delete
$id = strtolower( $id );
[623] Fix | Delete
[624] Fix | Delete
if ( empty( $form_callback ) ) {
[625] Fix | Delete
unset( $wp_registered_widget_controls[ $id ] );
[626] Fix | Delete
return;
[627] Fix | Delete
}
[628] Fix | Delete
[629] Fix | Delete
if ( isset( $wp_registered_widget_controls[ $id ] ) && ! did_action( 'widgets_init' ) ) {
[630] Fix | Delete
return;
[631] Fix | Delete
}
[632] Fix | Delete
[633] Fix | Delete
$defaults = array(
[634] Fix | Delete
'width' => 250,
[635] Fix | Delete
'height' => 200,
[636] Fix | Delete
);
[637] Fix | Delete
$options = wp_parse_args( $options, $defaults );
[638] Fix | Delete
$options['width'] = (int) $options['width'];
[639] Fix | Delete
$options['height'] = (int) $options['height'];
[640] Fix | Delete
[641] Fix | Delete
$widget = array(
[642] Fix | Delete
'name' => $name,
[643] Fix | Delete
'id' => $id,
[644] Fix | Delete
'callback' => $form_callback,
[645] Fix | Delete
'params' => $params,
[646] Fix | Delete
);
[647] Fix | Delete
$widget = array_merge( $widget, $options );
[648] Fix | Delete
[649] Fix | Delete
$wp_registered_widget_controls[ $id ] = $widget;
[650] Fix | Delete
}
[651] Fix | Delete
[652] Fix | Delete
/**
[653] Fix | Delete
* Remove control callback for widget.
[654] Fix | Delete
*
[655] Fix | Delete
* @since 2.2.0
[656] Fix | Delete
*
[657] Fix | Delete
* @param int|string $id Widget ID.
[658] Fix | Delete
*/
[659] Fix | Delete
function wp_unregister_widget_control( $id ) {
[660] Fix | Delete
wp_register_widget_control( $id, '', '' );
[661] Fix | Delete
}
[662] Fix | Delete
[663] Fix | Delete
/**
[664] Fix | Delete
* Display dynamic sidebar.
[665] Fix | Delete
*
[666] Fix | Delete
* By default this displays the default sidebar or 'sidebar-1'. If your theme specifies the 'id' or
[667] Fix | Delete
* 'name' parameter for its registered sidebars you can pass an ID or name as the $index parameter.
[668] Fix | Delete
* Otherwise, you can pass in a numerical index to display the sidebar at that index.
[669] Fix | Delete
*
[670] Fix | Delete
* @since 2.2.0
[671] Fix | Delete
*
[672] Fix | Delete
* @global array $wp_registered_sidebars Registered sidebars.
[673] Fix | Delete
* @global array $wp_registered_widgets Registered widgets.
[674] Fix | Delete
*
[675] Fix | Delete
* @param int|string $index Optional. Index, name or ID of dynamic sidebar. Default 1.
[676] Fix | Delete
* @return bool True, if widget sidebar was found and called. False if not found or not called.
[677] Fix | Delete
*/
[678] Fix | Delete
function dynamic_sidebar( $index = 1 ) {
[679] Fix | Delete
global $wp_registered_sidebars, $wp_registered_widgets;
[680] Fix | Delete
[681] Fix | Delete
if ( is_int( $index ) ) {
[682] Fix | Delete
$index = "sidebar-$index";
[683] Fix | Delete
} else {
[684] Fix | Delete
$index = sanitize_title( $index );
[685] Fix | Delete
foreach ( (array) $wp_registered_sidebars as $key => $value ) {
[686] Fix | Delete
if ( sanitize_title( $value['name'] ) === $index ) {
[687] Fix | Delete
$index = $key;
[688] Fix | Delete
break;
[689] Fix | Delete
}
[690] Fix | Delete
}
[691] Fix | Delete
}
[692] Fix | Delete
[693] Fix | Delete
$sidebars_widgets = wp_get_sidebars_widgets();
[694] Fix | Delete
if ( empty( $wp_registered_sidebars[ $index ] ) || empty( $sidebars_widgets[ $index ] ) || ! is_array( $sidebars_widgets[ $index ] ) ) {
[695] Fix | Delete
/** This action is documented in wp-includes/widget.php */
[696] Fix | Delete
do_action( 'dynamic_sidebar_before', $index, false );
[697] Fix | Delete
/** This action is documented in wp-includes/widget.php */
[698] Fix | Delete
do_action( 'dynamic_sidebar_after', $index, false );
[699] Fix | Delete
/** This filter is documented in wp-includes/widget.php */
[700] Fix | Delete
return apply_filters( 'dynamic_sidebar_has_widgets', false, $index );
[701] Fix | Delete
}
[702] Fix | Delete
[703] Fix | Delete
$sidebar = $wp_registered_sidebars[ $index ];
[704] Fix | Delete
[705] Fix | Delete
$sidebar['before_sidebar'] = sprintf( $sidebar['before_sidebar'], $sidebar['id'], $sidebar['class'] );
[706] Fix | Delete
[707] Fix | Delete
/**
[708] Fix | Delete
* Fires before widgets are rendered in a dynamic sidebar.
[709] Fix | Delete
*
[710] Fix | Delete
* Note: The action also fires for empty sidebars, and on both the front end
[711] Fix | Delete
* and back end, including the Inactive Widgets sidebar on the Widgets screen.
[712] Fix | Delete
*
[713] Fix | Delete
* @since 3.9.0
[714] Fix | Delete
*
[715] Fix | Delete
* @param int|string $index Index, name, or ID of the dynamic sidebar.
[716] Fix | Delete
* @param bool $has_widgets Whether the sidebar is populated with widgets.
[717] Fix | Delete
* Default true.
[718] Fix | Delete
*/
[719] Fix | Delete
do_action( 'dynamic_sidebar_before', $index, true );
[720] Fix | Delete
[721] Fix | Delete
if ( ! is_admin() && ! empty( $sidebar['before_sidebar'] ) ) {
[722] Fix | Delete
echo $sidebar['before_sidebar'];
[723] Fix | Delete
}
[724] Fix | Delete
[725] Fix | Delete
$did_one = false;
[726] Fix | Delete
foreach ( (array) $sidebars_widgets[ $index ] as $id ) {
[727] Fix | Delete
[728] Fix | Delete
if ( ! isset( $wp_registered_widgets[ $id ] ) ) {
[729] Fix | Delete
continue;
[730] Fix | Delete
}
[731] Fix | Delete
[732] Fix | Delete
$params = array_merge(
[733] Fix | Delete
array(
[734] Fix | Delete
array_merge(
[735] Fix | Delete
$sidebar,
[736] Fix | Delete
array(
[737] Fix | Delete
'widget_id' => $id,
[738] Fix | Delete
'widget_name' => $wp_registered_widgets[ $id ]['name'],
[739] Fix | Delete
)
[740] Fix | Delete
),
[741] Fix | Delete
),
[742] Fix | Delete
(array) $wp_registered_widgets[ $id ]['params']
[743] Fix | Delete
);
[744] Fix | Delete
[745] Fix | Delete
// Substitute HTML `id` and `class` attributes into `before_widget`.
[746] Fix | Delete
$classname_ = '';
[747] Fix | Delete
foreach ( (array) $wp_registered_widgets[ $id ]['classname'] as $cn ) {
[748] Fix | Delete
if ( is_string( $cn ) ) {
[749] Fix | Delete
$classname_ .= '_' . $cn;
[750] Fix | Delete
} elseif ( is_object( $cn ) ) {
[751] Fix | Delete
$classname_ .= '_' . get_class( $cn );
[752] Fix | Delete
}
[753] Fix | Delete
}
[754] Fix | Delete
$classname_ = ltrim( $classname_, '_' );
[755] Fix | Delete
$params[0]['before_widget'] = sprintf( $params[0]['before_widget'], $id, $classname_ );
[756] Fix | Delete
[757] Fix | Delete
/**
[758] Fix | Delete
* Filters the parameters passed to a widget's display callback.
[759] Fix | Delete
*
[760] Fix | Delete
* Note: The filter is evaluated on both the front end and back end,
[761] Fix | Delete
* including for the Inactive Widgets sidebar on the Widgets screen.
[762] Fix | Delete
*
[763] Fix | Delete
* @since 2.5.0
[764] Fix | Delete
*
[765] Fix | Delete
* @see register_sidebar()
[766] Fix | Delete
*
[767] Fix | Delete
* @param array $params {
[768] Fix | Delete
* @type array $args {
[769] Fix | Delete
* An array of widget display arguments.
[770] Fix | Delete
*
[771] Fix | Delete
* @type string $name Name of the sidebar the widget is assigned to.
[772] Fix | Delete
* @type string $id ID of the sidebar the widget is assigned to.
[773] Fix | Delete
* @type string $description The sidebar description.
[774] Fix | Delete
* @type string $class CSS class applied to the sidebar container.
[775] Fix | Delete
* @type string $before_widget HTML markup to prepend to each widget in the sidebar.
[776] Fix | Delete
* @type string $after_widget HTML markup to append to each widget in the sidebar.
[777] Fix | Delete
* @type string $before_title HTML markup to prepend to the widget title when displayed.
[778] Fix | Delete
* @type string $after_title HTML markup to append to the widget title when displayed.
[779] Fix | Delete
* @type string $widget_id ID of the widget.
[780] Fix | Delete
* @type string $widget_name Name of the widget.
[781] Fix | Delete
* }
[782] Fix | Delete
* @type array $widget_args {
[783] Fix | Delete
* An array of multi-widget arguments.
[784] Fix | Delete
*
[785] Fix | Delete
* @type int $number Number increment used for multiples of the same widget.
[786] Fix | Delete
* }
[787] Fix | Delete
* }
[788] Fix | Delete
*/
[789] Fix | Delete
$params = apply_filters( 'dynamic_sidebar_params', $params );
[790] Fix | Delete
[791] Fix | Delete
$callback = $wp_registered_widgets[ $id ]['callback'];
[792] Fix | Delete
[793] Fix | Delete
/**
[794] Fix | Delete
* Fires before a widget's display callback is called.
[795] Fix | Delete
*
[796] Fix | Delete
* Note: The action fires on both the front end and back end, including
[797] Fix | Delete
* for widgets in the Inactive Widgets sidebar on the Widgets screen.
[798] Fix | Delete
*
[799] Fix | Delete
* The action is not fired for empty sidebars.
[800] Fix | Delete
*
[801] Fix | Delete
* @since 3.0.0
[802] Fix | Delete
*
[803] Fix | Delete
* @param array $widget {
[804] Fix | Delete
* An associative array of widget arguments.
[805] Fix | Delete
*
[806] Fix | Delete
* @type string $name Name of the widget.
[807] Fix | Delete
* @type string $id Widget ID.
[808] Fix | Delete
* @type callable $callback When the hook is fired on the front end, `$callback` is an array
[809] Fix | Delete
* containing the widget object. Fired on the back end, `$callback`
[810] Fix | Delete
* is 'wp_widget_control', see `$_callback`.
[811] Fix | Delete
* @type array $params An associative array of multi-widget arguments.
[812] Fix | Delete
* @type string $classname CSS class applied to the widget container.
[813] Fix | Delete
* @type string $description The widget description.
[814] Fix | Delete
* @type array $_callback When the hook is fired on the back end, `$_callback` is populated
[815] Fix | Delete
* with an array containing the widget object, see `$callback`.
[816] Fix | Delete
* }
[817] Fix | Delete
*/
[818] Fix | Delete
do_action( 'dynamic_sidebar', $wp_registered_widgets[ $id ] );
[819] Fix | Delete
[820] Fix | Delete
if ( is_callable( $callback ) ) {
[821] Fix | Delete
call_user_func_array( $callback, $params );
[822] Fix | Delete
$did_one = true;
[823] Fix | Delete
}
[824] Fix | Delete
}
[825] Fix | Delete
[826] Fix | Delete
if ( ! is_admin() && ! empty( $sidebar['after_sidebar'] ) ) {
[827] Fix | Delete
echo $sidebar['after_sidebar'];
[828] Fix | Delete
}
[829] Fix | Delete
[830] Fix | Delete
/**
[831] Fix | Delete
* Fires after widgets are rendered in a dynamic sidebar.
[832] Fix | Delete
*
[833] Fix | Delete
* Note: The action also fires for empty sidebars, and on both the front end
[834] Fix | Delete
* and back end, including the Inactive Widgets sidebar on the Widgets screen.
[835] Fix | Delete
*
[836] Fix | Delete
* @since 3.9.0
[837] Fix | Delete
*
[838] Fix | Delete
* @param int|string $index Index, name, or ID of the dynamic sidebar.
[839] Fix | Delete
* @param bool $has_widgets Whether the sidebar is populated with widgets.
[840] Fix | Delete
* Default true.
[841] Fix | Delete
*/
[842] Fix | Delete
do_action( 'dynamic_sidebar_after', $index, true );
[843] Fix | Delete
[844] Fix | Delete
/**
[845] Fix | Delete
* Filters whether a sidebar has widgets.
[846] Fix | Delete
*
[847] Fix | Delete
* Note: The filter is also evaluated for empty sidebars, and on both the front end
[848] Fix | Delete
* and back end, including the Inactive Widgets sidebar on the Widgets screen.
[849] Fix | Delete
*
[850] Fix | Delete
* @since 3.9.0
[851] Fix | Delete
*
[852] Fix | Delete
* @param bool $did_one Whether at least one widget was rendered in the sidebar.
[853] Fix | Delete
* Default false.
[854] Fix | Delete
* @param int|string $index Index, name, or ID of the dynamic sidebar.
[855] Fix | Delete
*/
[856] Fix | Delete
return apply_filters( 'dynamic_sidebar_has_widgets', $did_one, $index );
[857] Fix | Delete
}
[858] Fix | Delete
[859] Fix | Delete
/**
[860] Fix | Delete
* Determines whether a given widget is displayed on the front end.
[861] Fix | Delete
*
[862] Fix | Delete
* Either $callback or $id_base can be used
[863] Fix | Delete
* $id_base is the first argument when extending WP_Widget class
[864] Fix | Delete
* Without the optional $widget_id parameter, returns the ID of the first sidebar
[865] Fix | Delete
* in which the first instance of the widget with the given callback or $id_base is found.
[866] Fix | Delete
* With the $widget_id parameter, returns the ID of the sidebar where
[867] Fix | Delete
* the widget with that callback/$id_base AND that ID is found.
[868] Fix | Delete
*
[869] Fix | Delete
* NOTE: $widget_id and $id_base are the same for single widgets. To be effective
[870] Fix | Delete
* this function has to run after widgets have initialized, at action {@see 'init'} or later.
[871] Fix | Delete
*
[872] Fix | Delete
* For more information on this and similar theme functions, check out
[873] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[874] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[875] Fix | Delete
*
[876] Fix | Delete
* @since 2.2.0
[877] Fix | Delete
*
[878] Fix | Delete
* @global array $wp_registered_widgets
[879] Fix | Delete
*
[880] Fix | Delete
* @param callable|false $callback Optional. Widget callback to check. Default false.
[881] Fix | Delete
* @param string|false $widget_id Optional. Widget ID. Optional, but needed for checking.
[882] Fix | Delete
* Default false.
[883] Fix | Delete
* @param string|false $id_base Optional. The base ID of a widget created by extending WP_Widget.
[884] Fix | Delete
* Default false.
[885] Fix | Delete
* @param bool $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'.
[886] Fix | Delete
* Default true.
[887] Fix | Delete
* @return string|false ID of the sidebar in which the widget is active,
[888] Fix | Delete
* false if the widget is not active.
[889] Fix | Delete
*/
[890] Fix | Delete
function is_active_widget( $callback = false, $widget_id = false, $id_base = false, $skip_inactive = true ) {
[891] Fix | Delete
global $wp_registered_widgets;
[892] Fix | Delete
[893] Fix | Delete
$sidebars_widgets = wp_get_sidebars_widgets();
[894] Fix | Delete
[895] Fix | Delete
if ( is_array( $sidebars_widgets ) ) {
[896] Fix | Delete
foreach ( $sidebars_widgets as $sidebar => $widgets ) {
[897] Fix | Delete
if ( $skip_inactive && ( 'wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) ) {
[898] Fix | Delete
continue;
[899] Fix | Delete
}
[900] Fix | Delete
[901] Fix | Delete
if ( is_array( $widgets ) ) {
[902] Fix | Delete
foreach ( $widgets as $widget ) {
[903] Fix | Delete
if ( ( $callback && isset( $wp_registered_widgets[ $widget ]['callback'] ) && $wp_registered_widgets[ $widget ]['callback'] === $callback ) || ( $id_base && _get_widget_id_base( $widget ) === $id_base ) ) {
[904] Fix | Delete
if ( ! $widget_id || $widget_id === $wp_registered_widgets[ $widget ]['id'] ) {
[905] Fix | Delete
return $sidebar;
[906] Fix | Delete
}
[907] Fix | Delete
}
[908] Fix | Delete
}
[909] Fix | Delete
}
[910] Fix | Delete
}
[911] Fix | Delete
}
[912] Fix | Delete
return false;
[913] Fix | Delete
}
[914] Fix | Delete
[915] Fix | Delete
/**
[916] Fix | Delete
* Determines whether the dynamic sidebar is enabled and used by the theme.
[917] Fix | Delete
*
[918] Fix | Delete
* For more information on this and similar theme functions, check out
[919] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[920] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[921] Fix | Delete
*
[922] Fix | Delete
* @since 2.2.0
[923] Fix | Delete
*
[924] Fix | Delete
* @global array $wp_registered_widgets Registered widgets.
[925] Fix | Delete
* @global array $wp_registered_sidebars Registered sidebars.
[926] Fix | Delete
*
[927] Fix | Delete
* @return bool True if using widgets, false otherwise.
[928] Fix | Delete
*/
[929] Fix | Delete
function is_dynamic_sidebar() {
[930] Fix | Delete
global $wp_registered_widgets, $wp_registered_sidebars;
[931] Fix | Delete
[932] Fix | Delete
$sidebars_widgets = get_option( 'sidebars_widgets' );
[933] Fix | Delete
[934] Fix | Delete
foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
[935] Fix | Delete
if ( ! empty( $sidebars_widgets[ $index ] ) ) {
[936] Fix | Delete
foreach ( (array) $sidebars_widgets[ $index ] as $widget ) {
[937] Fix | Delete
if ( array_key_exists( $widget, $wp_registered_widgets ) ) {
[938] Fix | Delete
return true;
[939] Fix | Delete
}
[940] Fix | Delete
}
[941] Fix | Delete
}
[942] Fix | Delete
}
[943] Fix | Delete
[944] Fix | Delete
return false;
[945] Fix | Delete
}
[946] Fix | Delete
[947] Fix | Delete
/**
[948] Fix | Delete
* Determines whether a sidebar contains widgets.
[949] Fix | Delete
*
[950] Fix | Delete
* For more information on this and similar theme functions, check out
[951] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[952] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[953] Fix | Delete
*
[954] Fix | Delete
* @since 2.8.0
[955] Fix | Delete
*
[956] Fix | Delete
* @param string|int $index Sidebar name, id or number to check.
[957] Fix | Delete
* @return bool True if the sidebar has widgets, false otherwise.
[958] Fix | Delete
*/
[959] Fix | Delete
function is_active_sidebar( $index ) {
[960] Fix | Delete
$index = ( is_int( $index ) ) ? "sidebar-$index" : sanitize_title( $index );
[961] Fix | Delete
$sidebars_widgets = wp_get_sidebars_widgets();
[962] Fix | Delete
$is_active_sidebar = ! empty( $sidebars_widgets[ $index ] );
[963] Fix | Delete
[964] Fix | Delete
/**
[965] Fix | Delete
* Filters whether a dynamic sidebar is considered "active".
[966] Fix | Delete
*
[967] Fix | Delete
* @since 3.9.0
[968] Fix | Delete
*
[969] Fix | Delete
* @param bool $is_active_sidebar Whether or not the sidebar should be considered "active".
[970] Fix | Delete
* In other words, whether the sidebar contains any widgets.
[971] Fix | Delete
* @param int|string $index Index, name, or ID of the dynamic sidebar.
[972] Fix | Delete
*/
[973] Fix | Delete
return apply_filters( 'is_active_sidebar', $is_active_sidebar, $index );
[974] Fix | Delete
}
[975] Fix | Delete
[976] Fix | Delete
//
[977] Fix | Delete
// Internal Functions.
[978] Fix | Delete
//
[979] Fix | Delete
[980] Fix | Delete
/**
[981] Fix | Delete
* Retrieve full list of sidebars and their widget instance IDs.
[982] Fix | Delete
*
[983] Fix | Delete
* Will upgrade sidebar widget list, if needed. Will also save updated list, if
[984] Fix | Delete
* needed.
[985] Fix | Delete
*
[986] Fix | Delete
* @since 2.2.0
[987] Fix | Delete
* @access private
[988] Fix | Delete
*
[989] Fix | Delete
* @global array $_wp_sidebars_widgets
[990] Fix | Delete
* @global array $sidebars_widgets
[991] Fix | Delete
*
[992] Fix | Delete
* @param bool $deprecated Not used (argument deprecated).
[993] Fix | Delete
* @return array Upgraded list of widgets to version 3 array format when called from the admin.
[994] Fix | Delete
*/
[995] Fix | Delete
function wp_get_sidebars_widgets( $deprecated = true ) {
[996] Fix | Delete
if ( true !== $deprecated ) {
[997] Fix | Delete
_deprecated_argument( __FUNCTION__, '2.8.1' );
[998] Fix | Delete
}
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function