?php /** * WordPress Version * * Contains version information for the current WordPress release. * * @package WordPress * @since 1.2.0 */ /** * The WordPress version string. * * Holds the current version number for WordPress core. Used to bust caches * and to enable development mode for scripts when running from the /src directory. * * @global string $wp_version */ $wp_version = '6.7.1'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * * @global int $wp_db_version */ $wp_db_version = 58975; /** * Holds the TinyMCE version. * * @global string $tinymce_version */ $tinymce_version = '49110-20201110'; /** * Holds the required PHP version. * * @global string $required_php_version */ $required_php_version = '7.2.24'; /** * Holds the required MySQL version. * * @global string $required_mysql_version */ $required_mysql_version = '5.5.5'; ?php /** * Widget API: WP_Widget_Factory class * * @package WordPress * @subpackage Widgets * @since 4.4.0 */ /** * Singleton that registers and instantiates WP_Widget classes. * * @since 2.8.0 * @since 4.4.0 Moved to its own file from wp-includes/widgets.php */ #[AllowDynamicProperties] class WP_Widget_Factory { /** * Widgets array. * * @since 2.8.0 * @var array */ public $widgets = array(); /** * PHP5 constructor. * * @since 4.3.0 */ public function __construct() { add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 ); } /** * PHP4 constructor. * * @since 2.8.0 * @deprecated 4.3.0 Use __construct() instead. * * @see WP_Widget_Factory::__construct() */ public function WP_Widget_Factory() { _deprecated_constructor( 'WP_Widget_Factory', '4.3.0' ); self::__construct(); } /** * Registers a widget subclass. * * @since 2.8.0 * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object * instead of simply a `WP_Widget` subclass name. * * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. */ public function register( $widget ) { if ( $widget instanceof WP_Widget ) { $this->widgets[ spl_object_hash( $widget ) ] = $widget; } else { $this->widgets[ $widget ] = new $widget(); } } /** * Un-registers a widget subclass. * * @since 2.8.0 * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object * instead of simply a `WP_Widget` subclass name. * * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. */ public function unregister( $widget ) { if ( $widget instanceof WP_Widget ) { unset( $this->widgets[ spl_object_hash( $widget ) ] ); } else { unset( $this->widgets[ $widget ] ); } } /** * Serves as a utility method for adding widgets to the registered widgets global. * * @since 2.8.0 * * @global array $wp_registered_widgets */ public function _register_widgets() { global $wp_registered_widgets; $keys = array_keys( $this->widgets ); $registered = array_keys( $wp_registered_widgets ); $registered = array_map( '_get_widget_id_base', $registered ); foreach ( $keys as $key ) { // Don't register new widget if old widget with the same id is already registered. if ( in_array( $this->widgets[ $key ]->id_base, $registered, true ) ) { unset( $this->widgets[ $key ] ); continue; } $this->widgets[ $key ]->_register(); } } /** * Returns the registered WP_Widget object for the given widget type. * * @since 5.8.0 * * @param string $id_base Widget type ID. * @return WP_Widget|null */ public function get_widget_object( $id_base ) { $key = $this->get_widget_key( $id_base ); if ( '' === $key ) { return null; } return $this->widgets[ $key ]; } /** * Returns the registered key for the given widget type. * * @since 5.8.0 * * @param string $id_base Widget type ID. * @return string */ public function get_widget_key( $id_base ) { foreach ( $this->widgets as $key => $widget_object ) { if ( $widget_object->id_base === $id_base ) { return $key; } } return ''; } } s $post_type ) { if ( current_user_can( $post_type->cap->edit_posts ) ) { return true; } } /* * Verify if the current user has edit_theme_options capability. */ if ( current_user_can( 'edit_theme_options' ) ) { return true; } return new WP_Error( 'rest_cannot_read_global_styles', __( 'Sorry, you are not allowed to access the global styles on this site.' ), array( 'status' => rest_authorization_required_code(), ) ); } /** * Returns the given theme global styles config. * * @since 5.9.0 * @since 6.6.0 Added custom relative theme file URIs to `_links`. * * @param WP_REST_Request $request The request instance. * @return WP_REST_Response|WP_Error */ public function get_theme_item( $request ) { if ( get_stylesheet() !== $request['stylesheet'] ) { // This endpoint only supports the active theme for now. return new WP_Error( 'rest_theme_not_found', __( 'Theme not found.' ), array( 'status' => 404 ) ); } $theme = WP_Theme_JSON_Resolver::get_merged_data( 'theme' ); $fields = $this->get_fields_for_response( $request ); $data = array(); if ( rest_is_field_included( 'settings', $fields ) ) { $data['settings'] = $theme->get_settings(); } if ( rest_is_field_included( 'styles', $fields ) ) { $raw_data = $theme->get_raw_data(); $data['styles'] = isset( $raw_data['styles'] ) ? $raw_data['styles'] : array(); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $links = array( 'self' => array( 'href' => rest_url( sprintf( '%s/%s/themes/%s', $this->namespace, $this->rest_base, $request['stylesheet'] ) ), ), ); $resolved_theme_uris = WP_Theme_JSON_Resolver::get_resolved_theme_uris( $theme ); if ( ! empty( $resolved_theme_uris ) ) { $links['https://api.w.org/theme-file'] = $resolved_theme_uris; } $response->add_links( $links ); } return $response; } /** * Checks if a given request has access to read a single theme global styles config. * * @since 6.0.0 * @since 6.7.0 Allow users with edit post capabilities to view theme global styles. * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise. */ public function get_theme_items_permissions_check( $request ) { return $this->get_theme_item_permissions_check( $request ); } /** * Returns the given theme global styles variations. * * @since 6.0.0 * @since 6.2.0 Returns parent theme variations, if they exist. * @since 6.6.0 Added custom relative theme file URIs to `_links` for each item. * * @param WP_REST_Request $request The request instance. * * @return WP_REST_Response|WP_Error */ public function get_theme_items( $request ) { if ( get_stylesheet() !== $request['stylesheet'] ) { // This endpoint only supports the active theme for now. return new WP_Error( 'rest_theme_not_found', __( 'Theme not found.' ), array( 'status' => 404 ) ); } $response = array(); // Register theme-defined variations e.g. from block style variation partials under `/styles`. $partials = WP_Theme_JSON_Resolver::get_style_variations( 'block' ); wp_register_block_style_variations_from_theme_json_partials( $partials ); $variations = WP_Theme_JSON_Resolver::get_style_variations(); foreach ( $variations as $variation ) { $variation_theme_json = new WP_Theme_JSON( $variation ); $resolved_theme_uris = WP_Theme_JSON_Resolver::get_resolved_theme_uris( $variation_theme_json ); $data = rest_ensure_response( $variation ); if ( ! empty( $resolved_theme_uris ) ) { $data->add_links( array( 'https://api.w.org/theme-file' => $resolved_theme_uris, ) ); } $response[] = $this->prepare_response_for_collection( $data ); } return rest_ensure_response( $response ); } /** * Validate style.css as valid CSS. * * Currently just checks for invalid markup. * * @since 6.2.0 * @since 6.4.0 Changed method visibility to protected. * * @param string $css CSS to validate. * @return true|WP_Error True if the input was validated, otherwise WP_Error. */ protected function validate_custom_css( $css ) { if ( preg_match( '# 400 ) ); } return true; } }