Make WordPress Core


Ignore:
Timestamp:
05/25/2021 08:26:21 AM (3 years ago)
Author:
noisysocks
Message:

REST API: Add widget endpoints

Adds the sidebars, widgets and widget-types REST API endpoints from the
Gutenberg plugin.

Fixes #41683.
Props TimothyBlynJacobs, spacedmonkey, zieladam, jorgefilipecosta, youknowriad, kevin940726.

File:
1 edited

Legend:

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

    r50994 r50995  
    103103        }
    104104    }
     105
     106    /**
     107     * Returns the registered WP_Widget object for the given widget type.
     108     *
     109     * @since 5.8.0
     110     *
     111     * @param string $id_base Widget type ID.
     112     * @return WP_Widget|null
     113     */
     114    public function get_widget_object( $id_base ) {
     115        foreach ( $this->widgets as $widget_object ) {
     116            if ( $widget_object->id_base === $id_base ) {
     117                return $widget_object;
     118            }
     119        }
     120
     121        return null;
     122    }
    105123}
Note: See TracChangeset for help on using the changeset viewer.