wp/wp-includes/class-wp-widget.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- a/wp/wp-includes/class-wp-widget.php	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/class-wp-widget.php	Tue Dec 15 13:49:49 2020 +0100
@@ -101,7 +101,7 @@
 	/**
 	 * Echoes the widget content.
 	 *
-	 * Sub-classes should over-ride this function to generate their widget code.
+	 * Subclasses should override this function to generate their widget code.
 	 *
 	 * @since 2.8.0
 	 *
@@ -110,7 +110,7 @@
 	 * @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 overridden in a subclass.' );
 	}
 
 	/**
@@ -151,11 +151,11 @@
 	 *
 	 * @since 2.8.0
 	 *
-	 * @param string $id_base         Optional Base ID for the widget, lowercase and unique. If left empty,
-	 *                                a portion of the widget's class name will be used Has to be unique.
+	 * @param string $id_base         Optional. Base ID for the widget, lowercase and unique. If left empty,
+	 *                                a portion of the widget's class name will be used. Has to be unique.
 	 * @param string $name            Name for the widget displayed on the configuration page.
-	 * @param array  $widget_options  Optional. Widget options. See wp_register_sidebar_widget() for information
-	 *                                on accepted arguments. Default empty array.
+	 * @param array  $widget_options  Optional. Widget options. See wp_register_sidebar_widget() for
+	 *                                information on accepted arguments. Default empty array.
 	 * @param array  $control_options Optional. Widget control options. See wp_register_widget_control() for
 	 *                                information on accepted arguments. Default empty array.
 	 */
@@ -177,14 +177,15 @@
 	 * PHP4 constructor.
 	 *
 	 * @since 2.8.0
+	 * @deprecated 4.3.0 Use __construct() instead.
 	 *
-	 * @see __construct()
+	 * @see WP_Widget::__construct()
 	 *
-	 * @param string $id_base         Optional Base ID for the widget, lowercase and unique. If left empty,
-	 *                                a portion of the widget's class name will be used Has to be unique.
+	 * @param string $id_base         Optional. Base ID for the widget, lowercase and unique. If left empty,
+	 *                                a portion of the widget's class name will be used. Has to be unique.
 	 * @param string $name            Name for the widget displayed on the configuration page.
-	 * @param array  $widget_options  Optional. Widget options. See wp_register_sidebar_widget() for information
-	 *                                on accepted arguments. Default empty array.
+	 * @param array  $widget_options  Optional. Widget options. See wp_register_sidebar_widget() for
+	 *                                information on accepted arguments. Default empty array.
 	 * @param array  $control_options Optional. Widget control options. See wp_register_widget_control() for
 	 *                                information on accepted arguments. Default empty array.
 	 */
@@ -206,7 +207,8 @@
 	 * @return string Name attribute for $field_name
 	 */
 	public function get_field_name( $field_name ) {
-		if ( false === $pos = strpos( $field_name, '[' ) ) {
+		$pos = strpos( $field_name, '[' );
+		if ( false === $pos ) {
 			return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
 		} else {
 			return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) );
@@ -397,13 +399,13 @@
 
 		$all_instances = $this->get_settings();
 
-		// We need to update the data
+		// We need to update the data.
 		if ( $this->updated ) {
 			return;
 		}
 
 		if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) {
-			// Delete the settings for this instance of the widget
+			// Delete the settings for this instance of the widget.
 			if ( isset( $_POST['the-widget-id'] ) ) {
 				$del_id = $_POST['the-widget-id'];
 			} else {
@@ -462,7 +464,7 @@
 					$all_instances[ $number ] = $instance;
 				}
 
-				break; // run only once
+				break; // Run only once.
 			}
 		}
 
@@ -492,7 +494,7 @@
 		$all_instances = $this->get_settings();
 
 		if ( -1 == $widget_args['number'] ) {
-			// We echo out a form where 'number' can be set later
+			// We echo out a form where 'number' can be set later.
 			$this->_set( '__i__' );
 			$instance = array();
 		} else {