Edit File by line
/home/barbar84/www/wp-inclu...
File: class-wp-widget.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Widget API: WP_Widget base class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Widgets
[5] Fix | Delete
* @since 4.4.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Core base class extended to register widgets.
[10] Fix | Delete
*
[11] Fix | Delete
* This class must be extended for each widget, and WP_Widget::widget() must be overridden.
[12] Fix | Delete
*
[13] Fix | Delete
* If adding widget options, WP_Widget::update() and WP_Widget::form() should also be overridden.
[14] Fix | Delete
*
[15] Fix | Delete
* @since 2.8.0
[16] Fix | Delete
* @since 4.4.0 Moved to its own file from wp-includes/widgets.php
[17] Fix | Delete
*/
[18] Fix | Delete
class WP_Widget {
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Root ID for all widgets of this type.
[22] Fix | Delete
*
[23] Fix | Delete
* @since 2.8.0
[24] Fix | Delete
* @var mixed|string
[25] Fix | Delete
*/
[26] Fix | Delete
public $id_base;
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Name for this widget type.
[30] Fix | Delete
*
[31] Fix | Delete
* @since 2.8.0
[32] Fix | Delete
* @var string
[33] Fix | Delete
*/
[34] Fix | Delete
public $name;
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Option name for this widget type.
[38] Fix | Delete
*
[39] Fix | Delete
* @since 2.8.0
[40] Fix | Delete
* @var string
[41] Fix | Delete
*/
[42] Fix | Delete
public $option_name;
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Alt option name for this widget type.
[46] Fix | Delete
*
[47] Fix | Delete
* @since 2.8.0
[48] Fix | Delete
* @var string
[49] Fix | Delete
*/
[50] Fix | Delete
public $alt_option_name;
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* Option array passed to wp_register_sidebar_widget().
[54] Fix | Delete
*
[55] Fix | Delete
* @since 2.8.0
[56] Fix | Delete
* @var array
[57] Fix | Delete
*/
[58] Fix | Delete
public $widget_options;
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Option array passed to wp_register_widget_control().
[62] Fix | Delete
*
[63] Fix | Delete
* @since 2.8.0
[64] Fix | Delete
* @var array
[65] Fix | Delete
*/
[66] Fix | Delete
public $control_options;
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Unique ID number of the current instance.
[70] Fix | Delete
*
[71] Fix | Delete
* @since 2.8.0
[72] Fix | Delete
* @var bool|int
[73] Fix | Delete
*/
[74] Fix | Delete
public $number = false;
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Unique ID string of the current instance (id_base-number).
[78] Fix | Delete
*
[79] Fix | Delete
* @since 2.8.0
[80] Fix | Delete
* @var bool|string
[81] Fix | Delete
*/
[82] Fix | Delete
public $id = false;
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Whether the widget data has been updated.
[86] Fix | Delete
*
[87] Fix | Delete
* Set to true when the data is updated after a POST submit - ensures it does
[88] Fix | Delete
* not happen twice.
[89] Fix | Delete
*
[90] Fix | Delete
* @since 2.8.0
[91] Fix | Delete
* @var bool
[92] Fix | Delete
*/
[93] Fix | Delete
public $updated = false;
[94] Fix | Delete
[95] Fix | Delete
//
[96] Fix | Delete
// Member functions that must be overridden by subclasses.
[97] Fix | Delete
//
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Echoes the widget content.
[101] Fix | Delete
*
[102] Fix | Delete
* Subclasses should override this function to generate their widget code.
[103] Fix | Delete
*
[104] Fix | Delete
* @since 2.8.0
[105] Fix | Delete
*
[106] Fix | Delete
* @param array $args Display arguments including 'before_title', 'after_title',
[107] Fix | Delete
* 'before_widget', and 'after_widget'.
[108] Fix | Delete
* @param array $instance The settings for the particular instance of the widget.
[109] Fix | Delete
*/
[110] Fix | Delete
public function widget( $args, $instance ) {
[111] Fix | Delete
die( 'function WP_Widget::widget() must be overridden in a subclass.' );
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Updates a particular instance of a widget.
[116] Fix | Delete
*
[117] Fix | Delete
* This function should check that `$new_instance` is set correctly. The newly-calculated
[118] Fix | Delete
* value of `$instance` should be returned. If false is returned, the instance won't be
[119] Fix | Delete
* saved/updated.
[120] Fix | Delete
*
[121] Fix | Delete
* @since 2.8.0
[122] Fix | Delete
*
[123] Fix | Delete
* @param array $new_instance New settings for this instance as input by the user via
[124] Fix | Delete
* WP_Widget::form().
[125] Fix | Delete
* @param array $old_instance Old settings for this instance.
[126] Fix | Delete
* @return array Settings to save or bool false to cancel saving.
[127] Fix | Delete
*/
[128] Fix | Delete
public function update( $new_instance, $old_instance ) {
[129] Fix | Delete
return $new_instance;
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* Outputs the settings update form.
[134] Fix | Delete
*
[135] Fix | Delete
* @since 2.8.0
[136] Fix | Delete
*
[137] Fix | Delete
* @param array $instance Current settings.
[138] Fix | Delete
* @return string Default return is 'noform'.
[139] Fix | Delete
*/
[140] Fix | Delete
public function form( $instance ) {
[141] Fix | Delete
echo '<p class="no-options-widget">' . __( 'There are no options for this widget.' ) . '</p>';
[142] Fix | Delete
return 'noform';
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
// Functions you'll need to call.
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* PHP5 constructor.
[149] Fix | Delete
*
[150] Fix | Delete
* @since 2.8.0
[151] Fix | Delete
*
[152] Fix | Delete
* @param string $id_base Optional. Base ID for the widget, lowercase and unique. If left empty,
[153] Fix | Delete
* a portion of the widget's class name will be used. Has to be unique.
[154] Fix | Delete
* @param string $name Name for the widget displayed on the configuration page.
[155] Fix | Delete
* @param array $widget_options Optional. Widget options. See wp_register_sidebar_widget() for
[156] Fix | Delete
* information on accepted arguments. Default empty array.
[157] Fix | Delete
* @param array $control_options Optional. Widget control options. See wp_register_widget_control() for
[158] Fix | Delete
* information on accepted arguments. Default empty array.
[159] Fix | Delete
*/
[160] Fix | Delete
public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
[161] Fix | Delete
$this->id_base = empty( $id_base ) ? preg_replace( '/(wp_)?widget_/', '', strtolower( get_class( $this ) ) ) : strtolower( $id_base );
[162] Fix | Delete
$this->name = $name;
[163] Fix | Delete
$this->option_name = 'widget_' . $this->id_base;
[164] Fix | Delete
$this->widget_options = wp_parse_args(
[165] Fix | Delete
$widget_options,
[166] Fix | Delete
array(
[167] Fix | Delete
'classname' => $this->option_name,
[168] Fix | Delete
'customize_selective_refresh' => false,
[169] Fix | Delete
)
[170] Fix | Delete
);
[171] Fix | Delete
$this->control_options = wp_parse_args( $control_options, array( 'id_base' => $this->id_base ) );
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
/**
[175] Fix | Delete
* PHP4 constructor.
[176] Fix | Delete
*
[177] Fix | Delete
* @since 2.8.0
[178] Fix | Delete
* @deprecated 4.3.0 Use __construct() instead.
[179] Fix | Delete
*
[180] Fix | Delete
* @see WP_Widget::__construct()
[181] Fix | Delete
*
[182] Fix | Delete
* @param string $id_base Optional. Base ID for the widget, lowercase and unique. If left empty,
[183] Fix | Delete
* a portion of the widget's class name will be used. Has to be unique.
[184] Fix | Delete
* @param string $name Name for the widget displayed on the configuration page.
[185] Fix | Delete
* @param array $widget_options Optional. Widget options. See wp_register_sidebar_widget() for
[186] Fix | Delete
* information on accepted arguments. Default empty array.
[187] Fix | Delete
* @param array $control_options Optional. Widget control options. See wp_register_widget_control() for
[188] Fix | Delete
* information on accepted arguments. Default empty array.
[189] Fix | Delete
*/
[190] Fix | Delete
public function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) {
[191] Fix | Delete
_deprecated_constructor( 'WP_Widget', '4.3.0', get_class( $this ) );
[192] Fix | Delete
WP_Widget::__construct( $id_base, $name, $widget_options, $control_options );
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Constructs name attributes for use in form() fields
[197] Fix | Delete
*
[198] Fix | Delete
* This function should be used in form() methods to create name attributes for fields
[199] Fix | Delete
* to be saved by update()
[200] Fix | Delete
*
[201] Fix | Delete
* @since 2.8.0
[202] Fix | Delete
* @since 4.4.0 Array format field names are now accepted.
[203] Fix | Delete
*
[204] Fix | Delete
* @param string $field_name Field name
[205] Fix | Delete
* @return string Name attribute for $field_name
[206] Fix | Delete
*/
[207] Fix | Delete
public function get_field_name( $field_name ) {
[208] Fix | Delete
$pos = strpos( $field_name, '[' );
[209] Fix | Delete
if ( false === $pos ) {
[210] Fix | Delete
return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
[211] Fix | Delete
} else {
[212] Fix | Delete
return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) );
[213] Fix | Delete
}
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
/**
[217] Fix | Delete
* Constructs id attributes for use in WP_Widget::form() fields.
[218] Fix | Delete
*
[219] Fix | Delete
* This function should be used in form() methods to create id attributes
[220] Fix | Delete
* for fields to be saved by WP_Widget::update().
[221] Fix | Delete
*
[222] Fix | Delete
* @since 2.8.0
[223] Fix | Delete
* @since 4.4.0 Array format field IDs are now accepted.
[224] Fix | Delete
*
[225] Fix | Delete
* @param string $field_name Field name.
[226] Fix | Delete
* @return string ID attribute for `$field_name`.
[227] Fix | Delete
*/
[228] Fix | Delete
public function get_field_id( $field_name ) {
[229] Fix | Delete
return 'widget-' . $this->id_base . '-' . $this->number . '-' . trim( str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ), '-' );
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
/**
[233] Fix | Delete
* Register all widget instances of this widget class.
[234] Fix | Delete
*
[235] Fix | Delete
* @since 2.8.0
[236] Fix | Delete
*/
[237] Fix | Delete
public function _register() {
[238] Fix | Delete
$settings = $this->get_settings();
[239] Fix | Delete
$empty = true;
[240] Fix | Delete
[241] Fix | Delete
// When $settings is an array-like object, get an intrinsic array for use with array_keys().
[242] Fix | Delete
if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) {
[243] Fix | Delete
$settings = $settings->getArrayCopy();
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
if ( is_array( $settings ) ) {
[247] Fix | Delete
foreach ( array_keys( $settings ) as $number ) {
[248] Fix | Delete
if ( is_numeric( $number ) ) {
[249] Fix | Delete
$this->_set( $number );
[250] Fix | Delete
$this->_register_one( $number );
[251] Fix | Delete
$empty = false;
[252] Fix | Delete
}
[253] Fix | Delete
}
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
if ( $empty ) {
[257] Fix | Delete
// If there are none, we register the widget's existence with a generic template.
[258] Fix | Delete
$this->_set( 1 );
[259] Fix | Delete
$this->_register_one();
[260] Fix | Delete
}
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
/**
[264] Fix | Delete
* Sets the internal order number for the widget instance.
[265] Fix | Delete
*
[266] Fix | Delete
* @since 2.8.0
[267] Fix | Delete
*
[268] Fix | Delete
* @param int $number The unique order number of this widget instance compared to other
[269] Fix | Delete
* instances of the same class.
[270] Fix | Delete
*/
[271] Fix | Delete
public function _set( $number ) {
[272] Fix | Delete
$this->number = $number;
[273] Fix | Delete
$this->id = $this->id_base . '-' . $number;
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
/**
[277] Fix | Delete
* Retrieves the widget display callback.
[278] Fix | Delete
*
[279] Fix | Delete
* @since 2.8.0
[280] Fix | Delete
*
[281] Fix | Delete
* @return callable Display callback.
[282] Fix | Delete
*/
[283] Fix | Delete
public function _get_display_callback() {
[284] Fix | Delete
return array( $this, 'display_callback' );
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
/**
[288] Fix | Delete
* Retrieves the widget update callback.
[289] Fix | Delete
*
[290] Fix | Delete
* @since 2.8.0
[291] Fix | Delete
*
[292] Fix | Delete
* @return callable Update callback.
[293] Fix | Delete
*/
[294] Fix | Delete
public function _get_update_callback() {
[295] Fix | Delete
return array( $this, 'update_callback' );
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
/**
[299] Fix | Delete
* Retrieves the form callback.
[300] Fix | Delete
*
[301] Fix | Delete
* @since 2.8.0
[302] Fix | Delete
*
[303] Fix | Delete
* @return callable Form callback.
[304] Fix | Delete
*/
[305] Fix | Delete
public function _get_form_callback() {
[306] Fix | Delete
return array( $this, 'form_callback' );
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
/**
[310] Fix | Delete
* Determines whether the current request is inside the Customizer preview.
[311] Fix | Delete
*
[312] Fix | Delete
* If true -- the current request is inside the Customizer preview, then
[313] Fix | Delete
* the object cache gets suspended and widgets should check this to decide
[314] Fix | Delete
* whether they should store anything persistently to the object cache,
[315] Fix | Delete
* to transients, or anywhere else.
[316] Fix | Delete
*
[317] Fix | Delete
* @since 3.9.0
[318] Fix | Delete
*
[319] Fix | Delete
* @global WP_Customize_Manager $wp_customize
[320] Fix | Delete
*
[321] Fix | Delete
* @return bool True if within the Customizer preview, false if not.
[322] Fix | Delete
*/
[323] Fix | Delete
public function is_preview() {
[324] Fix | Delete
global $wp_customize;
[325] Fix | Delete
return ( isset( $wp_customize ) && $wp_customize->is_preview() );
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
/**
[329] Fix | Delete
* Generates the actual widget content (Do NOT override).
[330] Fix | Delete
*
[331] Fix | Delete
* Finds the instance and calls WP_Widget::widget().
[332] Fix | Delete
*
[333] Fix | Delete
* @since 2.8.0
[334] Fix | Delete
*
[335] Fix | Delete
* @param array $args Display arguments. See WP_Widget::widget() for information
[336] Fix | Delete
* on accepted arguments.
[337] Fix | Delete
* @param int|array $widget_args {
[338] Fix | Delete
* Optional. Internal order number of the widget instance, or array of multi-widget arguments.
[339] Fix | Delete
* Default 1.
[340] Fix | Delete
*
[341] Fix | Delete
* @type int $number Number increment used for multiples of the same widget.
[342] Fix | Delete
* }
[343] Fix | Delete
*/
[344] Fix | Delete
public function display_callback( $args, $widget_args = 1 ) {
[345] Fix | Delete
if ( is_numeric( $widget_args ) ) {
[346] Fix | Delete
$widget_args = array( 'number' => $widget_args );
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
[350] Fix | Delete
$this->_set( $widget_args['number'] );
[351] Fix | Delete
$instances = $this->get_settings();
[352] Fix | Delete
[353] Fix | Delete
if ( array_key_exists( $this->number, $instances ) ) {
[354] Fix | Delete
$instance = $instances[ $this->number ];
[355] Fix | Delete
[356] Fix | Delete
/**
[357] Fix | Delete
* Filters the settings for a particular widget instance.
[358] Fix | Delete
*
[359] Fix | Delete
* Returning false will effectively short-circuit display of the widget.
[360] Fix | Delete
*
[361] Fix | Delete
* @since 2.8.0
[362] Fix | Delete
*
[363] Fix | Delete
* @param array $instance The current widget instance's settings.
[364] Fix | Delete
* @param WP_Widget $widget The current widget instance.
[365] Fix | Delete
* @param array $args An array of default widget arguments.
[366] Fix | Delete
*/
[367] Fix | Delete
$instance = apply_filters( 'widget_display_callback', $instance, $this, $args );
[368] Fix | Delete
[369] Fix | Delete
if ( false === $instance ) {
[370] Fix | Delete
return;
[371] Fix | Delete
}
[372] Fix | Delete
[373] Fix | Delete
$was_cache_addition_suspended = wp_suspend_cache_addition();
[374] Fix | Delete
if ( $this->is_preview() && ! $was_cache_addition_suspended ) {
[375] Fix | Delete
wp_suspend_cache_addition( true );
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
$this->widget( $args, $instance );
[379] Fix | Delete
[380] Fix | Delete
if ( $this->is_preview() ) {
[381] Fix | Delete
wp_suspend_cache_addition( $was_cache_addition_suspended );
[382] Fix | Delete
}
[383] Fix | Delete
}
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
/**
[387] Fix | Delete
* Handles changed settings (Do NOT override).
[388] Fix | Delete
*
[389] Fix | Delete
* @since 2.8.0
[390] Fix | Delete
*
[391] Fix | Delete
* @global array $wp_registered_widgets
[392] Fix | Delete
*
[393] Fix | Delete
* @param int $deprecated Not used.
[394] Fix | Delete
*/
[395] Fix | Delete
public function update_callback( $deprecated = 1 ) {
[396] Fix | Delete
global $wp_registered_widgets;
[397] Fix | Delete
[398] Fix | Delete
$all_instances = $this->get_settings();
[399] Fix | Delete
[400] Fix | Delete
// We need to update the data.
[401] Fix | Delete
if ( $this->updated ) {
[402] Fix | Delete
return;
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) {
[406] Fix | Delete
// Delete the settings for this instance of the widget.
[407] Fix | Delete
if ( isset( $_POST['the-widget-id'] ) ) {
[408] Fix | Delete
$del_id = $_POST['the-widget-id'];
[409] Fix | Delete
} else {
[410] Fix | Delete
return;
[411] Fix | Delete
}
[412] Fix | Delete
[413] Fix | Delete
if ( isset( $wp_registered_widgets[ $del_id ]['params'][0]['number'] ) ) {
[414] Fix | Delete
$number = $wp_registered_widgets[ $del_id ]['params'][0]['number'];
[415] Fix | Delete
[416] Fix | Delete
if ( $this->id_base . '-' . $number == $del_id ) {
[417] Fix | Delete
unset( $all_instances[ $number ] );
[418] Fix | Delete
}
[419] Fix | Delete
}
[420] Fix | Delete
} else {
[421] Fix | Delete
if ( isset( $_POST[ 'widget-' . $this->id_base ] ) && is_array( $_POST[ 'widget-' . $this->id_base ] ) ) {
[422] Fix | Delete
$settings = $_POST[ 'widget-' . $this->id_base ];
[423] Fix | Delete
} elseif ( isset( $_POST['id_base'] ) && $_POST['id_base'] == $this->id_base ) {
[424] Fix | Delete
$num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number'];
[425] Fix | Delete
$settings = array( $num => array() );
[426] Fix | Delete
} else {
[427] Fix | Delete
return;
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
foreach ( $settings as $number => $new_instance ) {
[431] Fix | Delete
$new_instance = stripslashes_deep( $new_instance );
[432] Fix | Delete
$this->_set( $number );
[433] Fix | Delete
[434] Fix | Delete
$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
[435] Fix | Delete
[436] Fix | Delete
$was_cache_addition_suspended = wp_suspend_cache_addition();
[437] Fix | Delete
if ( $this->is_preview() && ! $was_cache_addition_suspended ) {
[438] Fix | Delete
wp_suspend_cache_addition( true );
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
$instance = $this->update( $new_instance, $old_instance );
[442] Fix | Delete
[443] Fix | Delete
if ( $this->is_preview() ) {
[444] Fix | Delete
wp_suspend_cache_addition( $was_cache_addition_suspended );
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
/**
[448] Fix | Delete
* Filters a widget's settings before saving.
[449] Fix | Delete
*
[450] Fix | Delete
* Returning false will effectively short-circuit the widget's ability
[451] Fix | Delete
* to update settings.
[452] Fix | Delete
*
[453] Fix | Delete
* @since 2.8.0
[454] Fix | Delete
*
[455] Fix | Delete
* @param array $instance The current widget instance's settings.
[456] Fix | Delete
* @param array $new_instance Array of new widget settings.
[457] Fix | Delete
* @param array $old_instance Array of old widget settings.
[458] Fix | Delete
* @param WP_Widget $widget The current widget instance.
[459] Fix | Delete
*/
[460] Fix | Delete
$instance = apply_filters( 'widget_update_callback', $instance, $new_instance, $old_instance, $this );
[461] Fix | Delete
if ( false !== $instance ) {
[462] Fix | Delete
$all_instances[ $number ] = $instance;
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
break; // Run only once.
[466] Fix | Delete
}
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
$this->save_settings( $all_instances );
[470] Fix | Delete
$this->updated = true;
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
/**
[474] Fix | Delete
* Generates the widget control form (Do NOT override).
[475] Fix | Delete
*
[476] Fix | Delete
* @since 2.8.0
[477] Fix | Delete
*
[478] Fix | Delete
* @param int|array $widget_args {
[479] Fix | Delete
* Optional. Internal order number of the widget instance, or array of multi-widget arguments.
[480] Fix | Delete
* Default 1.
[481] Fix | Delete
*
[482] Fix | Delete
* @type int $number Number increment used for multiples of the same widget.
[483] Fix | Delete
* }
[484] Fix | Delete
* @return string|null
[485] Fix | Delete
*/
[486] Fix | Delete
public function form_callback( $widget_args = 1 ) {
[487] Fix | Delete
if ( is_numeric( $widget_args ) ) {
[488] Fix | Delete
$widget_args = array( 'number' => $widget_args );
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
[492] Fix | Delete
$all_instances = $this->get_settings();
[493] Fix | Delete
[494] Fix | Delete
if ( -1 == $widget_args['number'] ) {
[495] Fix | Delete
// We echo out a form where 'number' can be set later.
[496] Fix | Delete
$this->_set( '__i__' );
[497] Fix | Delete
$instance = array();
[498] Fix | Delete
} else {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function