Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
@ -110,7 +110,7 @@ class WP_Widget {
|
|||
* @param array $instance The settings for the particular instance of the widget.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
die('function WP_Widget::widget() must be over-ridden in a sub-class.');
|
||||
die( 'function WP_Widget::widget() must be over-ridden in a sub-class.' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,7 +140,7 @@ class WP_Widget {
|
|||
* @return string Default return is 'noform'.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
echo '<p class="no-options-widget">' . __('There are no options for this widget.') . '</p>';
|
||||
echo '<p class="no-options-widget">' . __( 'There are no options for this widget.' ) . '</p>';
|
||||
return 'noform';
|
||||
}
|
||||
|
||||
|
@ -160,10 +160,16 @@ class WP_Widget {
|
|||
* information on accepted arguments. Default empty array.
|
||||
*/
|
||||
public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
|
||||
$this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base);
|
||||
$this->name = $name;
|
||||
$this->option_name = 'widget_' . $this->id_base;
|
||||
$this->widget_options = wp_parse_args( $widget_options, array( 'classname' => $this->option_name, 'customize_selective_refresh' => false ) );
|
||||
$this->id_base = empty( $id_base ) ? preg_replace( '/(wp_)?widget_/', '', strtolower( get_class( $this ) ) ) : strtolower( $id_base );
|
||||
$this->name = $name;
|
||||
$this->option_name = 'widget_' . $this->id_base;
|
||||
$this->widget_options = wp_parse_args(
|
||||
$widget_options,
|
||||
array(
|
||||
'classname' => $this->option_name,
|
||||
'customize_selective_refresh' => false,
|
||||
)
|
||||
);
|
||||
$this->control_options = wp_parse_args( $control_options, array( 'id_base' => $this->id_base ) );
|
||||
}
|
||||
|
||||
|
@ -199,7 +205,7 @@ class WP_Widget {
|
|||
* @param string $field_name Field name
|
||||
* @return string Name attribute for $field_name
|
||||
*/
|
||||
public function get_field_name($field_name) {
|
||||
public function get_field_name( $field_name ) {
|
||||
if ( false === $pos = strpos( $field_name, '[' ) ) {
|
||||
return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
|
||||
} else {
|
||||
|
@ -230,7 +236,7 @@ class WP_Widget {
|
|||
*/
|
||||
public function _register() {
|
||||
$settings = $this->get_settings();
|
||||
$empty = true;
|
||||
$empty = true;
|
||||
|
||||
// When $settings is an array-like object, get an intrinsic array for use with array_keys().
|
||||
if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) {
|
||||
|
@ -262,9 +268,9 @@ class WP_Widget {
|
|||
* @param int $number The unique order number of this widget instance compared to other
|
||||
* instances of the same class.
|
||||
*/
|
||||
public function _set($number) {
|
||||
public function _set( $number ) {
|
||||
$this->number = $number;
|
||||
$this->id = $this->id_base . '-' . $number;
|
||||
$this->id = $this->id_base . '-' . $number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,7 +281,7 @@ class WP_Widget {
|
|||
* @return callable Display callback.
|
||||
*/
|
||||
public function _get_display_callback() {
|
||||
return array($this, 'display_callback');
|
||||
return array( $this, 'display_callback' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -286,7 +292,7 @@ class WP_Widget {
|
|||
* @return callable Update callback.
|
||||
*/
|
||||
public function _get_update_callback() {
|
||||
return array($this, 'update_callback');
|
||||
return array( $this, 'update_callback' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -297,7 +303,7 @@ class WP_Widget {
|
|||
* @return callable Form callback.
|
||||
*/
|
||||
public function _get_form_callback() {
|
||||
return array($this, 'form_callback');
|
||||
return array( $this, 'form_callback' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -316,7 +322,7 @@ class WP_Widget {
|
|||
*/
|
||||
public function is_preview() {
|
||||
global $wp_customize;
|
||||
return ( isset( $wp_customize ) && $wp_customize->is_preview() ) ;
|
||||
return ( isset( $wp_customize ) && $wp_customize->is_preview() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,37 +398,40 @@ class WP_Widget {
|
|||
$all_instances = $this->get_settings();
|
||||
|
||||
// We need to update the data
|
||||
if ( $this->updated )
|
||||
if ( $this->updated ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
|
||||
if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) {
|
||||
// Delete the settings for this instance of the widget
|
||||
if ( isset($_POST['the-widget-id']) )
|
||||
if ( isset( $_POST['the-widget-id'] ) ) {
|
||||
$del_id = $_POST['the-widget-id'];
|
||||
else
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset($wp_registered_widgets[$del_id]['params'][0]['number']) ) {
|
||||
$number = $wp_registered_widgets[$del_id]['params'][0]['number'];
|
||||
if ( isset( $wp_registered_widgets[ $del_id ]['params'][0]['number'] ) ) {
|
||||
$number = $wp_registered_widgets[ $del_id ]['params'][0]['number'];
|
||||
|
||||
if ( $this->id_base . '-' . $number == $del_id )
|
||||
unset($all_instances[$number]);
|
||||
if ( $this->id_base . '-' . $number == $del_id ) {
|
||||
unset( $all_instances[ $number ] );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) {
|
||||
$settings = $_POST['widget-' . $this->id_base];
|
||||
} elseif ( isset($_POST['id_base']) && $_POST['id_base'] == $this->id_base ) {
|
||||
$num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number'];
|
||||
if ( isset( $_POST[ 'widget-' . $this->id_base ] ) && is_array( $_POST[ 'widget-' . $this->id_base ] ) ) {
|
||||
$settings = $_POST[ 'widget-' . $this->id_base ];
|
||||
} elseif ( isset( $_POST['id_base'] ) && $_POST['id_base'] == $this->id_base ) {
|
||||
$num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number'];
|
||||
$settings = array( $num => array() );
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $settings as $number => $new_instance ) {
|
||||
$new_instance = stripslashes_deep($new_instance);
|
||||
$this->_set($number);
|
||||
$new_instance = stripslashes_deep( $new_instance );
|
||||
$this->_set( $number );
|
||||
|
||||
$old_instance = isset($all_instances[$number]) ? $all_instances[$number] : array();
|
||||
$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
|
||||
|
||||
$was_cache_addition_suspended = wp_suspend_cache_addition();
|
||||
if ( $this->is_preview() && ! $was_cache_addition_suspended ) {
|
||||
|
@ -450,14 +459,14 @@ class WP_Widget {
|
|||
*/
|
||||
$instance = apply_filters( 'widget_update_callback', $instance, $new_instance, $old_instance, $this );
|
||||
if ( false !== $instance ) {
|
||||
$all_instances[$number] = $instance;
|
||||
$all_instances[ $number ] = $instance;
|
||||
}
|
||||
|
||||
break; // run only once
|
||||
}
|
||||
}
|
||||
|
||||
$this->save_settings($all_instances);
|
||||
$this->save_settings( $all_instances );
|
||||
$this->updated = true;
|
||||
}
|
||||
|
||||
|
@ -475,18 +484,19 @@ class WP_Widget {
|
|||
* @return string|null
|
||||
*/
|
||||
public function form_callback( $widget_args = 1 ) {
|
||||
if ( is_numeric($widget_args) )
|
||||
if ( is_numeric( $widget_args ) ) {
|
||||
$widget_args = array( 'number' => $widget_args );
|
||||
}
|
||||
|
||||
$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
|
||||
$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
|
||||
$all_instances = $this->get_settings();
|
||||
|
||||
if ( -1 == $widget_args['number'] ) {
|
||||
// We echo out a form where 'number' can be set later
|
||||
$this->_set('__i__');
|
||||
$this->_set( '__i__' );
|
||||
$instance = array();
|
||||
} else {
|
||||
$this->_set($widget_args['number']);
|
||||
$this->_set( $widget_args['number'] );
|
||||
$instance = $all_instances[ $widget_args['number'] ];
|
||||
}
|
||||
|
||||
|
@ -504,7 +514,7 @@ class WP_Widget {
|
|||
|
||||
$return = null;
|
||||
if ( false !== $instance ) {
|
||||
$return = $this->form($instance);
|
||||
$return = $this->form( $instance );
|
||||
|
||||
/**
|
||||
* Fires at the end of the widget control form.
|
||||
|
@ -536,9 +546,9 @@ class WP_Widget {
|
|||
* compared to other instances of the same class. Default -1.
|
||||
*/
|
||||
public function _register_one( $number = -1 ) {
|
||||
wp_register_sidebar_widget( $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) );
|
||||
wp_register_sidebar_widget( $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) );
|
||||
_register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) );
|
||||
_register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) );
|
||||
_register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue