WordPress.org

Make WordPress Core

Changeset 37425


Ignore:
Timestamp:
05/12/2016 08:22:15 PM (4 years ago)
Author:
ocean90
Message:

Widgets: Make WP_Widget a real abstract class.

This removes the die() call from WP_Widget::widget() and converts it to an abstract method.
WP_Widgets (later renamed to WP_Widget) was introduced in [10764] where the minimum PHP requirement was 4.3, thus no abstract was available.

Props johnbillion.
Fixes #35981.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-widget.php

    r37343 r37425  
    1717 * @since 2.8.0
    1818 * @since 4.4.0 Moved to its own file from wp-includes/widgets.php
     19 * @abstract
    1920 */
    20 class WP_Widget {
     21abstract class WP_Widget {
    2122
    2223    /**
     
    9798     * @since 2.8.0
    9899     * @access public
     100     * @abstract
    99101     *
    100102     * @param array $args     Display arguments including 'before_title', 'after_title',
     
    102104     * @param array $instance The settings for the particular instance of the widget.
    103105     */
    104     public function widget( $args, $instance ) {
    105         die('function WP_Widget::widget() must be over-ridden in a sub-class.');
    106     }
     106    abstract public function widget( $args, $instance );
    107107
    108108    /**
     
    170170     *
    171171     * @see __construct()
    172      * 
     172     *
    173173     * @param string $id_base         Optional Base ID for the widget, lowercase and unique. If left empty,
    174174     *                                a portion of the widget's class name will be used Has to be unique.
Note: See TracChangeset for help on using the changeset viewer.