Edit File by line
/home/barbar84/www/wp-inclu...
File: widgets.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Core Widgets API
[2] Fix | Delete
*
[3] Fix | Delete
* This API is used for creating dynamic sidebar without hardcoding functionality into
[4] Fix | Delete
* themes
[5] Fix | Delete
*
[6] Fix | Delete
* Includes both internal WordPress routines and theme-use routines.
[7] Fix | Delete
*
[8] Fix | Delete
* This functionality was found in a plugin before the WordPress 2.2 release, which
[9] Fix | Delete
* included it in the core from that point on.
[10] Fix | Delete
*
[11] Fix | Delete
* @link https://wordpress.org/support/article/wordpress-widgets/
[12] Fix | Delete
* @link https://developer.wordpress.org/themes/functionality/widgets/
[13] Fix | Delete
*
[14] Fix | Delete
* @package WordPress
[15] Fix | Delete
* @subpackage Widgets
[16] Fix | Delete
* @since 2.2.0
[17] Fix | Delete
*/
[18] Fix | Delete
[19] Fix | Delete
//
[20] Fix | Delete
// Global Variables.
[21] Fix | Delete
//
[22] Fix | Delete
[23] Fix | Delete
/** @ignore */
[24] Fix | Delete
global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates;
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Stores the sidebars, since many themes can have more than one.
[28] Fix | Delete
*
[29] Fix | Delete
* @global array $wp_registered_sidebars Registered sidebars.
[30] Fix | Delete
* @since 2.2.0
[31] Fix | Delete
*/
[32] Fix | Delete
$wp_registered_sidebars = array();
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Stores the registered widgets.
[36] Fix | Delete
*
[37] Fix | Delete
* @global array $wp_registered_widgets
[38] Fix | Delete
* @since 2.2.0
[39] Fix | Delete
*/
[40] Fix | Delete
$wp_registered_widgets = array();
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Stores the registered widget controls (options).
[44] Fix | Delete
*
[45] Fix | Delete
* @global array $wp_registered_widget_controls
[46] Fix | Delete
* @since 2.2.0
[47] Fix | Delete
*/
[48] Fix | Delete
$wp_registered_widget_controls = array();
[49] Fix | Delete
/**
[50] Fix | Delete
* @global array $wp_registered_widget_updates
[51] Fix | Delete
*/
[52] Fix | Delete
$wp_registered_widget_updates = array();
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Private
[56] Fix | Delete
*
[57] Fix | Delete
* @global array $_wp_sidebars_widgets
[58] Fix | Delete
*/
[59] Fix | Delete
$_wp_sidebars_widgets = array();
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Private
[63] Fix | Delete
*
[64] Fix | Delete
* @global array $_wp_deprecated_widgets_callbacks
[65] Fix | Delete
*/
[66] Fix | Delete
$GLOBALS['_wp_deprecated_widgets_callbacks'] = array(
[67] Fix | Delete
'wp_widget_pages',
[68] Fix | Delete
'wp_widget_pages_control',
[69] Fix | Delete
'wp_widget_calendar',
[70] Fix | Delete
'wp_widget_calendar_control',
[71] Fix | Delete
'wp_widget_archives',
[72] Fix | Delete
'wp_widget_archives_control',
[73] Fix | Delete
'wp_widget_links',
[74] Fix | Delete
'wp_widget_meta',
[75] Fix | Delete
'wp_widget_meta_control',
[76] Fix | Delete
'wp_widget_search',
[77] Fix | Delete
'wp_widget_recent_entries',
[78] Fix | Delete
'wp_widget_recent_entries_control',
[79] Fix | Delete
'wp_widget_tag_cloud',
[80] Fix | Delete
'wp_widget_tag_cloud_control',
[81] Fix | Delete
'wp_widget_categories',
[82] Fix | Delete
'wp_widget_categories_control',
[83] Fix | Delete
'wp_widget_text',
[84] Fix | Delete
'wp_widget_text_control',
[85] Fix | Delete
'wp_widget_rss',
[86] Fix | Delete
'wp_widget_rss_control',
[87] Fix | Delete
'wp_widget_recent_comments',
[88] Fix | Delete
'wp_widget_recent_comments_control',
[89] Fix | Delete
);
[90] Fix | Delete
[91] Fix | Delete
//
[92] Fix | Delete
// Template tags & API functions.
[93] Fix | Delete
//
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Register a widget
[97] Fix | Delete
*
[98] Fix | Delete
* Registers a WP_Widget widget
[99] Fix | Delete
*
[100] Fix | Delete
* @since 2.8.0
[101] Fix | Delete
* @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
[102] Fix | Delete
* instead of simply a `WP_Widget` subclass name.
[103] Fix | Delete
*
[104] Fix | Delete
* @see WP_Widget
[105] Fix | Delete
*
[106] Fix | Delete
* @global WP_Widget_Factory $wp_widget_factory
[107] Fix | Delete
*
[108] Fix | Delete
* @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
[109] Fix | Delete
*/
[110] Fix | Delete
function register_widget( $widget ) {
[111] Fix | Delete
global $wp_widget_factory;
[112] Fix | Delete
[113] Fix | Delete
$wp_widget_factory->register( $widget );
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Unregisters a widget.
[118] Fix | Delete
*
[119] Fix | Delete
* Unregisters a WP_Widget widget. Useful for un-registering default widgets.
[120] Fix | Delete
* Run within a function hooked to the {@see 'widgets_init'} action.
[121] Fix | Delete
*
[122] Fix | Delete
* @since 2.8.0
[123] Fix | Delete
* @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
[124] Fix | Delete
* instead of simply a `WP_Widget` subclass name.
[125] Fix | Delete
*
[126] Fix | Delete
* @see WP_Widget
[127] Fix | Delete
*
[128] Fix | Delete
* @global WP_Widget_Factory $wp_widget_factory
[129] Fix | Delete
*
[130] Fix | Delete
* @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
[131] Fix | Delete
*/
[132] Fix | Delete
function unregister_widget( $widget ) {
[133] Fix | Delete
global $wp_widget_factory;
[134] Fix | Delete
[135] Fix | Delete
$wp_widget_factory->unregister( $widget );
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* Creates multiple sidebars.
[140] Fix | Delete
*
[141] Fix | Delete
* If you wanted to quickly create multiple sidebars for a theme or internally.
[142] Fix | Delete
* This function will allow you to do so. If you don't pass the 'name' and/or
[143] Fix | Delete
* 'id' in `$args`, then they will be built for you.
[144] Fix | Delete
*
[145] Fix | Delete
* @since 2.2.0
[146] Fix | Delete
*
[147] Fix | Delete
* @see register_sidebar() The second parameter is documented by register_sidebar() and is the same here.
[148] Fix | Delete
*
[149] Fix | Delete
* @global array $wp_registered_sidebars The new sidebars are stored in this array by sidebar ID.
[150] Fix | Delete
*
[151] Fix | Delete
* @param int $number Optional. Number of sidebars to create. Default 1.
[152] Fix | Delete
* @param array|string $args {
[153] Fix | Delete
* Optional. Array or string of arguments for building a sidebar.
[154] Fix | Delete
*
[155] Fix | Delete
* @type string $id The base string of the unique identifier for each sidebar. If provided, and multiple
[156] Fix | Delete
* sidebars are being defined, the ID will have "-2" appended, and so on.
[157] Fix | Delete
* Default 'sidebar-' followed by the number the sidebar creation is currently at.
[158] Fix | Delete
* @type string $name The name or title for the sidebars displayed in the admin dashboard. If registering
[159] Fix | Delete
* more than one sidebar, include '%d' in the string as a placeholder for the uniquely
[160] Fix | Delete
* assigned number for each sidebar.
[161] Fix | Delete
* Default 'Sidebar' for the first sidebar, otherwise 'Sidebar %d'.
[162] Fix | Delete
* }
[163] Fix | Delete
*/
[164] Fix | Delete
function register_sidebars( $number = 1, $args = array() ) {
[165] Fix | Delete
global $wp_registered_sidebars;
[166] Fix | Delete
$number = (int) $number;
[167] Fix | Delete
[168] Fix | Delete
if ( is_string( $args ) ) {
[169] Fix | Delete
parse_str( $args, $args );
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
for ( $i = 1; $i <= $number; $i++ ) {
[173] Fix | Delete
$_args = $args;
[174] Fix | Delete
[175] Fix | Delete
if ( $number > 1 ) {
[176] Fix | Delete
if ( isset( $args['name'] ) ) {
[177] Fix | Delete
$_args['name'] = sprintf( $args['name'], $i );
[178] Fix | Delete
} else {
[179] Fix | Delete
/* translators: %d: Sidebar number. */
[180] Fix | Delete
$_args['name'] = sprintf( __( 'Sidebar %d' ), $i );
[181] Fix | Delete
}
[182] Fix | Delete
} else {
[183] Fix | Delete
$_args['name'] = isset( $args['name'] ) ? $args['name'] : __( 'Sidebar' );
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
// Custom specified ID's are suffixed if they exist already.
[187] Fix | Delete
// Automatically generated sidebar names need to be suffixed regardless starting at -0.
[188] Fix | Delete
if ( isset( $args['id'] ) ) {
[189] Fix | Delete
$_args['id'] = $args['id'];
[190] Fix | Delete
$n = 2; // Start at -2 for conflicting custom IDs.
[191] Fix | Delete
while ( is_registered_sidebar( $_args['id'] ) ) {
[192] Fix | Delete
$_args['id'] = $args['id'] . '-' . $n++;
[193] Fix | Delete
}
[194] Fix | Delete
} else {
[195] Fix | Delete
$n = count( $wp_registered_sidebars );
[196] Fix | Delete
do {
[197] Fix | Delete
$_args['id'] = 'sidebar-' . ++$n;
[198] Fix | Delete
} while ( is_registered_sidebar( $_args['id'] ) );
[199] Fix | Delete
}
[200] Fix | Delete
register_sidebar( $_args );
[201] Fix | Delete
}
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
/**
[205] Fix | Delete
* Builds the definition for a single sidebar and returns the ID.
[206] Fix | Delete
*
[207] Fix | Delete
* Accepts either a string or an array and then parses that against a set
[208] Fix | Delete
* of default arguments for the new sidebar. WordPress will automatically
[209] Fix | Delete
* generate a sidebar ID and name based on the current number of registered
[210] Fix | Delete
* sidebars if those arguments are not included.
[211] Fix | Delete
*
[212] Fix | Delete
* When allowing for automatic generation of the name and ID parameters, keep
[213] Fix | Delete
* in mind that the incrementor for your sidebar can change over time depending
[214] Fix | Delete
* on what other plugins and themes are installed.
[215] Fix | Delete
*
[216] Fix | Delete
* If theme support for 'widgets' has not yet been added when this function is
[217] Fix | Delete
* called, it will be automatically enabled through the use of add_theme_support()
[218] Fix | Delete
*
[219] Fix | Delete
* @since 2.2.0
[220] Fix | Delete
* @since 5.6.0 Added the `before_sidebar` and `after_sidebar` arguments.
[221] Fix | Delete
*
[222] Fix | Delete
* @global array $wp_registered_sidebars Registered sidebars.
[223] Fix | Delete
*
[224] Fix | Delete
* @param array|string $args {
[225] Fix | Delete
* Optional. Array or string of arguments for the sidebar being registered.
[226] Fix | Delete
*
[227] Fix | Delete
* @type string $name The name or title of the sidebar displayed in the Widgets
[228] Fix | Delete
* interface. Default 'Sidebar $instance'.
[229] Fix | Delete
* @type string $id The unique identifier by which the sidebar will be called.
[230] Fix | Delete
* Default 'sidebar-$instance'.
[231] Fix | Delete
* @type string $description Description of the sidebar, displayed in the Widgets interface.
[232] Fix | Delete
* Default empty string.
[233] Fix | Delete
* @type string $class Extra CSS class to assign to the sidebar in the Widgets interface.
[234] Fix | Delete
* Default empty.
[235] Fix | Delete
* @type string $before_widget HTML content to prepend to each widget's HTML output when assigned
[236] Fix | Delete
* to this sidebar. Receives the widget's ID attribute as `%1$s`
[237] Fix | Delete
* and class name as `%2$s`. Default is an opening list item element.
[238] Fix | Delete
* @type string $after_widget HTML content to append to each widget's HTML output when assigned
[239] Fix | Delete
* to this sidebar. Default is a closing list item element.
[240] Fix | Delete
* @type string $before_title HTML content to prepend to the sidebar title when displayed.
[241] Fix | Delete
* Default is an opening h2 element.
[242] Fix | Delete
* @type string $after_title HTML content to append to the sidebar title when displayed.
[243] Fix | Delete
* Default is a closing h2 element.
[244] Fix | Delete
* @type string $before_sidebar HTML content to prepend to the sidebar when displayed.
[245] Fix | Delete
* Receives the `$id` argument as `%1$s` and `$class` as `%2$s`.
[246] Fix | Delete
* Outputs after the {@see 'dynamic_sidebar_before'} action.
[247] Fix | Delete
* Default empty string.
[248] Fix | Delete
* @type string $after_sidebar HTML content to append to the sidebar when displayed.
[249] Fix | Delete
* Outputs before the {@see 'dynamic_sidebar_after'} action.
[250] Fix | Delete
* Default empty string.
[251] Fix | Delete
* }
[252] Fix | Delete
* @return string Sidebar ID added to $wp_registered_sidebars global.
[253] Fix | Delete
*/
[254] Fix | Delete
function register_sidebar( $args = array() ) {
[255] Fix | Delete
global $wp_registered_sidebars;
[256] Fix | Delete
[257] Fix | Delete
$i = count( $wp_registered_sidebars ) + 1;
[258] Fix | Delete
[259] Fix | Delete
$id_is_empty = empty( $args['id'] );
[260] Fix | Delete
[261] Fix | Delete
$defaults = array(
[262] Fix | Delete
/* translators: %d: Sidebar number. */
[263] Fix | Delete
'name' => sprintf( __( 'Sidebar %d' ), $i ),
[264] Fix | Delete
'id' => "sidebar-$i",
[265] Fix | Delete
'description' => '',
[266] Fix | Delete
'class' => '',
[267] Fix | Delete
'before_widget' => '<li id="%1$s" class="widget %2$s">',
[268] Fix | Delete
'after_widget' => "</li>\n",
[269] Fix | Delete
'before_title' => '<h2 class="widgettitle">',
[270] Fix | Delete
'after_title' => "</h2>\n",
[271] Fix | Delete
'before_sidebar' => '',
[272] Fix | Delete
'after_sidebar' => '',
[273] Fix | Delete
);
[274] Fix | Delete
[275] Fix | Delete
/**
[276] Fix | Delete
* Filters the sidebar default arguments.
[277] Fix | Delete
*
[278] Fix | Delete
* @since 5.3.0
[279] Fix | Delete
*
[280] Fix | Delete
* @see register_sidebar()
[281] Fix | Delete
*
[282] Fix | Delete
* @param array $defaults The default sidebar arguments.
[283] Fix | Delete
*/
[284] Fix | Delete
$sidebar = wp_parse_args( $args, apply_filters( 'register_sidebar_defaults', $defaults ) );
[285] Fix | Delete
[286] Fix | Delete
if ( $id_is_empty ) {
[287] Fix | Delete
_doing_it_wrong(
[288] Fix | Delete
__FUNCTION__,
[289] Fix | Delete
sprintf(
[290] Fix | Delete
/* translators: 1: The 'id' argument, 2: Sidebar name, 3: Recommended 'id' value. */
[291] Fix | Delete
__( 'No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.' ),
[292] Fix | Delete
'<code>id</code>',
[293] Fix | Delete
$sidebar['name'],
[294] Fix | Delete
$sidebar['id']
[295] Fix | Delete
),
[296] Fix | Delete
'4.2.0'
[297] Fix | Delete
);
[298] Fix | Delete
}
[299] Fix | Delete
[300] Fix | Delete
$wp_registered_sidebars[ $sidebar['id'] ] = $sidebar;
[301] Fix | Delete
[302] Fix | Delete
add_theme_support( 'widgets' );
[303] Fix | Delete
[304] Fix | Delete
/**
[305] Fix | Delete
* Fires once a sidebar has been registered.
[306] Fix | Delete
*
[307] Fix | Delete
* @since 3.0.0
[308] Fix | Delete
*
[309] Fix | Delete
* @param array $sidebar Parsed arguments for the registered sidebar.
[310] Fix | Delete
*/
[311] Fix | Delete
do_action( 'register_sidebar', $sidebar );
[312] Fix | Delete
[313] Fix | Delete
return $sidebar['id'];
[314] Fix | Delete
}
[315] Fix | Delete
[316] Fix | Delete
/**
[317] Fix | Delete
* Removes a sidebar from the list.
[318] Fix | Delete
*
[319] Fix | Delete
* @since 2.2.0
[320] Fix | Delete
*
[321] Fix | Delete
* @global array $wp_registered_sidebars Registered sidebars.
[322] Fix | Delete
*
[323] Fix | Delete
* @param string|int $sidebar_id The ID of the sidebar when it was registered.
[324] Fix | Delete
*/
[325] Fix | Delete
function unregister_sidebar( $sidebar_id ) {
[326] Fix | Delete
global $wp_registered_sidebars;
[327] Fix | Delete
[328] Fix | Delete
unset( $wp_registered_sidebars[ $sidebar_id ] );
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
/**
[332] Fix | Delete
* Checks if a sidebar is registered.
[333] Fix | Delete
*
[334] Fix | Delete
* @since 4.4.0
[335] Fix | Delete
*
[336] Fix | Delete
* @global array $wp_registered_sidebars Registered sidebars.
[337] Fix | Delete
*
[338] Fix | Delete
* @param string|int $sidebar_id The ID of the sidebar when it was registered.
[339] Fix | Delete
* @return bool True if the sidebar is registered, false otherwise.
[340] Fix | Delete
*/
[341] Fix | Delete
function is_registered_sidebar( $sidebar_id ) {
[342] Fix | Delete
global $wp_registered_sidebars;
[343] Fix | Delete
[344] Fix | Delete
return isset( $wp_registered_sidebars[ $sidebar_id ] );
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
/**
[348] Fix | Delete
* Register an instance of a widget.
[349] Fix | Delete
*
[350] Fix | Delete
* The default widget option is 'classname' that can be overridden.
[351] Fix | Delete
*
[352] Fix | Delete
* The function can also be used to un-register widgets when `$output_callback`
[353] Fix | Delete
* parameter is an empty string.
[354] Fix | Delete
*
[355] Fix | Delete
* @since 2.2.0
[356] Fix | Delete
* @since 5.3.0 Formalized the existing and already documented `...$params` parameter
[357] Fix | Delete
* by adding it to the function signature.
[358] Fix | Delete
*
[359] Fix | Delete
* @global array $wp_registered_widgets Uses stored registered widgets.
[360] Fix | Delete
* @global array $wp_registered_widget_controls Stores the registered widget controls (options).
[361] Fix | Delete
* @global array $wp_registered_widget_updates
[362] Fix | Delete
* @global array $_wp_deprecated_widgets_callbacks
[363] Fix | Delete
*
[364] Fix | Delete
* @param int|string $id Widget ID.
[365] Fix | Delete
* @param string $name Widget display title.
[366] Fix | Delete
* @param callable $output_callback Run when widget is called.
[367] Fix | Delete
* @param array $options {
[368] Fix | Delete
* Optional. An array of supplementary widget options for the instance.
[369] Fix | Delete
*
[370] Fix | Delete
* @type string $classname Class name for the widget's HTML container. Default is a shortened
[371] Fix | Delete
* version of the output callback name.
[372] Fix | Delete
* @type string $description Widget description for display in the widget administration
[373] Fix | Delete
* panel and/or theme.
[374] Fix | Delete
* }
[375] Fix | Delete
* @param mixed ...$params Optional additional parameters to pass to the callback function when it's called.
[376] Fix | Delete
*/
[377] Fix | Delete
function wp_register_sidebar_widget( $id, $name, $output_callback, $options = array(), ...$params ) {
[378] Fix | Delete
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates, $_wp_deprecated_widgets_callbacks;
[379] Fix | Delete
[380] Fix | Delete
$id = strtolower( $id );
[381] Fix | Delete
[382] Fix | Delete
if ( empty( $output_callback ) ) {
[383] Fix | Delete
unset( $wp_registered_widgets[ $id ] );
[384] Fix | Delete
return;
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
$id_base = _get_widget_id_base( $id );
[388] Fix | Delete
if ( in_array( $output_callback, $_wp_deprecated_widgets_callbacks, true ) && ! is_callable( $output_callback ) ) {
[389] Fix | Delete
unset( $wp_registered_widget_controls[ $id ] );
[390] Fix | Delete
unset( $wp_registered_widget_updates[ $id_base ] );
[391] Fix | Delete
return;
[392] Fix | Delete
}
[393] Fix | Delete
[394] Fix | Delete
$defaults = array( 'classname' => $output_callback );
[395] Fix | Delete
$options = wp_parse_args( $options, $defaults );
[396] Fix | Delete
$widget = array(
[397] Fix | Delete
'name' => $name,
[398] Fix | Delete
'id' => $id,
[399] Fix | Delete
'callback' => $output_callback,
[400] Fix | Delete
'params' => $params,
[401] Fix | Delete
);
[402] Fix | Delete
$widget = array_merge( $widget, $options );
[403] Fix | Delete
[404] Fix | Delete
if ( is_callable( $output_callback ) && ( ! isset( $wp_registered_widgets[ $id ] ) || did_action( 'widgets_init' ) ) ) {
[405] Fix | Delete
[406] Fix | Delete
/**
[407] Fix | Delete
* Fires once for each registered widget.
[408] Fix | Delete
*
[409] Fix | Delete
* @since 3.0.0
[410] Fix | Delete
*
[411] Fix | Delete
* @param array $widget An array of default widget arguments.
[412] Fix | Delete
*/
[413] Fix | Delete
do_action( 'wp_register_sidebar_widget', $widget );
[414] Fix | Delete
$wp_registered_widgets[ $id ] = $widget;
[415] Fix | Delete
}
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
/**
[419] Fix | Delete
* Retrieve description for widget.
[420] Fix | Delete
*
[421] Fix | Delete
* When registering widgets, the options can also include 'description' that
[422] Fix | Delete
* describes the widget for display on the widget administration panel or
[423] Fix | Delete
* in the theme.
[424] Fix | Delete
*
[425] Fix | Delete
* @since 2.5.0
[426] Fix | Delete
*
[427] Fix | Delete
* @global array $wp_registered_widgets
[428] Fix | Delete
*
[429] Fix | Delete
* @param int|string $id Widget ID.
[430] Fix | Delete
* @return string|void Widget description, if available.
[431] Fix | Delete
*/
[432] Fix | Delete
function wp_widget_description( $id ) {
[433] Fix | Delete
if ( ! is_scalar( $id ) ) {
[434] Fix | Delete
return;
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
global $wp_registered_widgets;
[438] Fix | Delete
[439] Fix | Delete
if ( isset( $wp_registered_widgets[ $id ]['description'] ) ) {
[440] Fix | Delete
return esc_html( $wp_registered_widgets[ $id ]['description'] );
[441] Fix | Delete
}
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
/**
[445] Fix | Delete
* Retrieve description for a sidebar.
[446] Fix | Delete
*
[447] Fix | Delete
* When registering sidebars a 'description' parameter can be included that
[448] Fix | Delete
* describes the sidebar for display on the widget administration panel.
[449] Fix | Delete
*
[450] Fix | Delete
* @since 2.9.0
[451] Fix | Delete
*
[452] Fix | Delete
* @global array $wp_registered_sidebars Registered sidebars.
[453] Fix | Delete
*
[454] Fix | Delete
* @param string $id sidebar ID.
[455] Fix | Delete
* @return string|void Sidebar description, if available.
[456] Fix | Delete
*/
[457] Fix | Delete
function wp_sidebar_description( $id ) {
[458] Fix | Delete
if ( ! is_scalar( $id ) ) {
[459] Fix | Delete
return;
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
global $wp_registered_sidebars;
[463] Fix | Delete
[464] Fix | Delete
if ( isset( $wp_registered_sidebars[ $id ]['description'] ) ) {
[465] Fix | Delete
return wp_kses( $wp_registered_sidebars[ $id ]['description'], 'sidebar_description' );
[466] Fix | Delete
}
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
/**
[470] Fix | Delete
* Remove widget from sidebar.
[471] Fix | Delete
*
[472] Fix | Delete
* @since 2.2.0
[473] Fix | Delete
*
[474] Fix | Delete
* @param int|string $id Widget ID.
[475] Fix | Delete
*/
[476] Fix | Delete
function wp_unregister_sidebar_widget( $id ) {
[477] Fix | Delete
[478] Fix | Delete
/**
[479] Fix | Delete
* Fires just before a widget is removed from a sidebar.
[480] Fix | Delete
*
[481] Fix | Delete
* @since 3.0.0
[482] Fix | Delete
*
[483] Fix | Delete
* @param int $id The widget ID.
[484] Fix | Delete
*/
[485] Fix | Delete
do_action( 'wp_unregister_sidebar_widget', $id );
[486] Fix | Delete
[487] Fix | Delete
wp_register_sidebar_widget( $id, '', '' );
[488] Fix | Delete
wp_unregister_widget_control( $id );
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
/**
[492] Fix | Delete
* Registers widget control callback for customizing options.
[493] Fix | Delete
*
[494] Fix | Delete
* @since 2.2.0
[495] Fix | Delete
* @since 5.3.0 Formalized the existing and already documented `...$params` parameter
[496] Fix | Delete
* by adding it to the function signature.
[497] Fix | Delete
*
[498] Fix | Delete
* @global array $wp_registered_widget_controls
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function