/** * Unregister all widgets if asked in the manifest * * @global array $wp_registered_sidebars List all sidebars * @global array $wp_widget_factory List all widgets * * @return void * * @static * @uses Core::$adminSubMenuItemsToRemove * @uses Core::$manifest * @uses Core::$sidebarsToRemove * @uses Core::$widgetsToRemove * @uses Tools::parseBooleans() */ private static function removeWidgetFeature() { if (array_key_exists('theme-features', self::$manifest) && array_key_exists('widget', self::$manifest['theme-features'])) { $widgetFeature = self::$manifest['theme-features']['widget']; Tools::parseBooleans($widgetFeature); // remove defaults widget $defaultWidgets = ['WP_Widget_Pages', 'WP_Widget_Archives', 'WP_Widget_Meta', 'WP_Widget_Text', 'WP_Widget_Recent_Posts', 'WP_Widget_Recent_Comments', 'WP_Widget_Calendar', 'WP_Widget_Links', 'WP_Widget_Search', 'WP_Widget_Categories', 'WP_Widget_RSS', 'WP_Widget_Tag_Cloud', 'WP_Nav_Menu_Widget', 'Twenty_Eleven_Ephemera_Widget']; foreach ($defaultWidgets as $widget) { self::$widgetsToRemove[] = $widget; } // list all custom widgets for unregistration global $wp_widget_factory; $widgets = $wp_widget_factory->widgets; foreach ($widgets as $id => $widget) { self::$widgetsToRemove[] = $id; } // list all sidebars for unregistration global $wp_registered_sidebars; $sidebars = $wp_registered_sidebars; foreach ($sidebars as $id => $sidebar) { self::$sidebarsToRemove[] = $id; } // remove widget admin menu item self::$adminSubMenuItemsToRemove[] = ['themes.php', 'widgets.php']; } }
/** * Declare all features asked in the manifest * * @return void * * @link https://developer.wordpress.org/reference/functions/add_theme_support/ * @uses Raccoon::$manifest */ private function loadThemeSupports() { if (array_key_exists('theme-support', $this->manifest)) { $supports = $this->manifest['theme-support']; foreach ($supports as $key => $value) { Tools::parseBooleans($value); switch (gettype($value)) { case "boolean": if ($value === true) { add_theme_support($key); } break; default: add_theme_support($key, $value); break; } } } }