nuEditor->current_user_can_edit_menu() ) { //This should never happen since we already check permissions when adding //the admin menu item, but let's be extra safe. wp_die('You do not have permission to access this AME page.'); } $post = $this->menuEditor->get_post_params(); if ( isset($post['action']) && ($post['action'] == self::SAVE_ACTION) ) { $this->handleSettingsForm($post); } $this->outputMainTemplate(); //Output the "select visible users" dialog template. This doesn't happen //automatically outside the "Settings -> Menu Editor (Pro)" page. do_action('admin_menu_editor-visible_users_template'); } private function outputMainTemplate() { $settingsPageUrl = $this->getSettingsPageUrl(); $moduleTitle = 'Easy Hide'; $moduleSettingsUrl = $this->menuEditor->get_settings_page_url() . '#ame-available-modules'; $isExplanationVisible = !$this->isExplanationHidden->__invoke(); require __DIR__ . '/' . 'easy-hide-template.php'; } private function getSettingsPageUrl() { return add_query_arg('page', self::MENU_SLUG, self_admin_url($this->parentMenuSlug)); } /** * @param array $post */ private function handleSettingsForm($post) { check_admin_referer(self::SAVE_ACTION); if ( !isset($post['settings']) || !is_string($post['settings']) ) { wp_die('The required "settings" parameter is missing or invalid.'); } $settings = json_decode($post['settings'], true); if ( !isset($settings['items']) || !is_array($settings['items']) ) { wp_die('The required "items" key is missing or has an incorrect data type.'); } //This script doesn't actually change any settings, it just notifies //other components and plugins that new settings should be saved. //First, a global notification about all items. $errors = apply_filters('admin_menu_editor-save_hideable_items', [], $settings['items']); //Trigger individual actions for each component. This way a component/module //won't have to scan the whole item list to find the settings it cares about. $itemsByComponent = []; foreach ($settings['items'] as $id => $itemData) { if ( isset($itemData['component']) ) { if ( !isset($itemsByComponent[$itemData['component']]) ) { $itemsByComponent[$itemData['component']] = []; } $itemsByComponent[$itemData['component']][$id] = $itemData; } } foreach ($itemsByComponent as $component => $items) { $componentErrors = apply_filters( 'admin_menu_editor-save_hideable_items-' . $component, [], $items ); $errors = array_merge($errors, $componentErrors); } if ( empty($errors) ) { //Pass through the previously selected actor and so on. $redirectParams = ['message' => 1]; $passThrough = ['selectedActor', 'selectedCategory']; foreach ($passThrough as $parameter) { if ( !empty($post[$parameter]) ) { $redirectParams[$parameter] = (string)$post[$parameter]; } } wp_redirect(add_query_arg($redirectParams, $this->getSettingsPageUrl())); exit(); } else { $container = new WP_Error( 'eh_save_failed', 'One or more errors occurred while saving settings.' ); foreach ($errors as $error) { if ( is_wp_error($error) ) { $container->merge_from($error); } else if ( is_string($error) ) { $container->add('string_error', $error); } else { $container->add( 'invalid_error', 'Unrecognized error type. Expected a string or a WP_Error instance.' ); } } wp_die($container); } } /** * @return HideableItemStore */ private function getPopulatedStore() { if ( $this->store !== null ) { return $this->store; } $this->store = new HideableItemStore(); //Let modules register their items. do_action( 'admin_menu_editor-register_hideable_items', $this->store ); return $this->store; } } class HideableItemStore implements JsonSerializable { /** * @var array */ private $categories = []; /** * @var array */ private $items = []; /** * @param string $id * @param string $label * @param Category[] $categories * @param string|HideableItem|null $parent * @param Array $enabled * @param string|null $component * @param string|null $tooltip * @param bool|null $inverted * @return HideableItem */ public function addItem( $id, $label, $categories = [], $parent = null, $enabled = [], $component = null, $tooltip = null, $inverted = null ) { if ( is_string($parent) ) { $parent = $this->items[$parent]; } $item = new HideableItem( $id, $label, array_filter($categories), $parent, $enabled, $component, $tooltip, $inverted ); $this->items[$id] = $item; return $item; } /** * @param string $id * @param string $label * @param Category[] $categories * @param string|HideableItem|null $parent * @param boolean $enabledForAll * @param string|null $component * @param string|null $tooltip * @param bool|null $inverted * @return BinaryHideableItem */ public function addBinaryItem( $id, $label, $categories = [], $parent = null, $enabledForAll = false, $component = null, $tooltip = null, $inverted = null ) { if ( is_string($parent) ) { $parent = $this->items[$parent]; } $item = new BinaryHideableItem( $id, $label, array_filter($categories), $parent, $enabledForAll, $component, $tooltip, $inverted ); $this->items[$id] = $item; return $item; } /** * @param string $id * @return \YahnisElsts\AdminMenuEditor\EasyHide\HideableItem|null */ public function getItemById($id) { if ( isset($this->items[$id]) ) { return $this->items[$id]; } return null; } /** * @param string $id * @param string $label * @param Category|null $parent * @param bool $invertItemState * @param int $defaultSortOrder * @param int $itemSortOrder * @return Category */ public function getOrCreateCategory( $id, $label, $parent = null, $invertItemState = false, $defaultSortOrder = Category::SORT_ALPHA, $itemSortOrder = Category::SORT_INSERTION ) { if ( isset($this->categories[$id]) ) { return $this->categories[$id]; } $cat = new Category( $id, $label, $parent, $invertItemState, $defaultSortOrder, $itemSortOrder ); $this->categories[$id] = $cat; return $cat; } /** * @param Array $hierarchy * @return Category */ public function getOrCreateCategoryTree($hierarchy) { $previous = null; $cat = null; foreach ($hierarchy as $id => $label) { $cat = $this->getOrCreateCategory($id, $label, $previous); $previous = $cat; } return $cat; } /** * @param string $id * @return Category|null */ public function getCategory($id) { if ( isset($this->categories[$id]) ) { return $this->categories[$id]; } return null; } #[\ReturnTypeWillChange] public function jsonSerialize() { $cats = []; foreach ($this->categories as $category) { $cats[] = $category->jsonSerialize(); } $items = []; foreach ($this->items as $item) { $items[] = $item->jsonSerialize(); } return [ 'categories' => $cats, 'items' => $items, ]; } } class Category implements JsonSerializable { const SORT_ALPHA = 0; const SORT_INSERTION = 1; protected $id; protected $label; protected $parent; protected $invertItemState; protected $defaultSortOrder; protected $itemSortOrder; protected $priority = null; protected $subtitle = null; protected $tableView = []; public function __construct( $id, $label, Category $parent = null, $invertItemState = false, $defaultSortOrder = self::SORT_ALPHA, $itemSortOrder = self::SORT_INSERTION ) { $this->id = $id; $this->label = $label; $this->parent = $parent; $this->invertItemState = $invertItemState; $this->defaultSortOrder = $defaultSortOrder; $this->itemSortOrder = $itemSortOrder; } public function getId() { return $this->id; } /** * @param Category $rowCategory * @param Category $columnCategory * @return $this */ public function enableTableView($rowCategory, $columnCategory) { $this->tableView = [ 'rowCategory' => $rowCategory, 'columnCategory' => $columnCategory, ]; return $this; } /** * @param string $subtitle * @return $this */ public function addSubtitle($subtitle) { $this->subtitle = $subtitle; return $this; } /** * @param int|null $priority * @return \YahnisElsts\AdminMenuEditor\EasyHide\Category */ public function setSortPriority($priority) { $this->priority = $priority; return $this; } #[\ReturnTypeWillChange] public function jsonSerialize() { $result = [ 'id' => $this->id, 'label' => $this->label, ]; if ( $this->parent !== null ) { $result['parent'] = $this->parent->getId(); } if ( $this->defaultSortOrder !== self::SORT_ALPHA ) { $result['sort'] = $this->defaultSortOrder; } if ( $this->itemSortOrder !== self::SORT_INSERTION ) { $result['itemSort'] = $this->itemSortOrder; } if ( $this->invertItemState ) { $result['invertItemState'] = true; } if ( !empty($this->tableView) ) { $result['tableView'] = [ 'rowCategory' => $this->tableView['rowCategory']->getId(), 'columnCategory' => $this->tableView['columnCategory']->getId(), ]; } if ( !empty($this->subtitle) ) { $result['subtitle'] = $this->subtitle; } if ( $this->priority !== null ) { $result['priority'] = $this->priority; } return $result; } public function isInvertingItemState() { return $this->invertItemState; } } class HideableItem implements JsonSerializable { private $id; private $label; /** * @var Category[] */ private $categories; /** * @var HideableItem|null */ private $parent; private $enabled; private $component; private $tooltip; private $subtitle; private $inverted; /** * @param $id * @param $label * @param Category[] $categories * @param HideableItem|null $parent * @param array $enabled * @param $component * @param string|null $tooltip * @param bool|null $inverted */ public function __construct( $id, $label, $categories = [], HideableItem $parent = null, $enabled = [], $component = null, $tooltip = null, $inverted = null ) { $this->id = $id; $this->label = $label; $this->categories = $categories; $this->parent = $parent; $this->enabled = $enabled; $this->component = $component; $this->tooltip = $tooltip; $this->inverted = $inverted; } #[\ReturnTypeWillChange] public function jsonSerialize() { $result = [ 'id' => $this->id, 'label' => $this->label, 'categories' => $this->getCategoryIds(), ]; if ( $this->parent !== null ) { $result['parent'] = $this->parent->getId(); } if ( !empty($this->enabled) ) { $result['enabled'] = $this->enabled; } if ( $this->component !== null ) { $result['component'] = $this->component; } if ( !empty($this->tooltip) ) { $result['tooltip'] = $this->tooltip; } if ( !empty($this->subtitle) ) { $result['subtitle'] = $this->subtitle; } if ( $this->inverted !== null ) { $result['inverted'] = $this->inverted; } return $result; } private function getCategoryIds() { $ids = []; foreach ($this->categories as $category) { $ids[] = $category->getId(); } return $ids; } public function getId() { return $this->id; } public function addSubtitle($text) { $this->subtitle = $text; } } class BinaryHideableItem extends HideableItem { /** * @var bool */ private $enabledForAll = false; public function __construct( $id, $label, $categories = [], HideableItem $parent = null, $enabledForAll = false, $component = null, $tooltip = null, $inverted = null ) { parent::__construct($id, $label, $categories, $parent, array(), $component, $tooltip, $inverted); $this->enabledForAll = $enabledForAll; } public function jsonSerialize() { $result = parent::jsonSerialize(); $result['binary'] = true; unset($result['enabled']); $result['enabledForAll'] = $this->enabledForAll; return $result; } }
Fatal error: Uncaught Error: Class "\YahnisElsts\AdminMenuEditor\EasyHide\Core" not found in /htdocs/wp-content/plugins/admin-menu-editor-pro/includes/menu-editor-core.php:505 Stack trace: #0 /htdocs/wp-content/plugins/admin-menu-editor-pro/includes/menu-editor-core.php(1512): WPMenuEditor->load_modules() #1 /htdocs/wp-content/plugins/admin-menu-editor-pro/includes/menu-editor-core.php(3264): WPMenuEditor->load_custom_menu() #2 /htdocs/wp-content/plugins/admin-menu-editor-pro/extras.php(1613): WPMenuEditor->get_virtual_caps(3) #3 /htdocs/wp-includes/class-wp-hook.php(310): wsMenuEditorExtras->prepare_virtual_caps_for_user(Array, Object(WP_User)) #4 /htdocs/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #5 /htdocs/wp-content/plugins/admin-menu-editor-pro/includes/menu-editor-core.php(4556): apply_filters('admin_menu_edit...', Array, Object(WP_User)) #6 /htdocs/wp-content/plugins/admin-menu-editor-pro/includes/menu-editor-core.php(4582): WPMenuEditor->update_virtual_cap_cache(Object(WP_User)) #7 /htdocs/wp-includes/class-wp-hook.php(312): WPMenuEditor->grant_virtual_caps_to_user(Array, Array, Array) #8 /htdocs/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #9 /htdocs/wp-includes/class-wp-user.php(808): apply_filters('user_has_cap', Array, Array, Array, Object(WP_User)) #10 /htdocs/wp-includes/capabilities.php(985): WP_User->has_cap('unfiltered_html') #11 /htdocs/wp-includes/capabilities.php(877): user_can(Object(WP_User), 'unfiltered_html') #12 /htdocs/wp-includes/kses.php(2263): current_user_can('unfiltered_html') #13 /htdocs/wp-includes/class-wp-hook.php(310): kses_init('') #14 /htdocs/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array) #15 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #16 /htdocs/wp-includes/pluggable.php(48): do_action('set_current_use...') #17 /htdocs/wp-includes/user.php(3624): wp_set_current_user(0) #18 /htdocs/wp-includes/pluggable.php(70): _wp_get_current_user() #19 /htdocs/wp-includes/user.php(639): wp_get_current_user() #20 /htdocs/wp-includes/class-wp-query.php(2572): get_current_user_id() #21 /htdocs/wp-includes/class-wp-query.php(3800): WP_Query->get_posts() #22 /htdocs/wp-includes/post.php(2441): WP_Query->query(Array) #23 /htdocs/wp-content/plugins/bacola-core/init.php(42): get_posts(Array) #24 /htdocs/wp-content/plugins/bacola-core/inc/customizer.php(2621): bacola_get_elementorTemplates('section') #25 /htdocs/wp-content/plugins/bacola-core/bacola-core.php(147): require_once('/htdocs/wp-cont...') #26 /htdocs/wp-includes/class-wp-hook.php(310): Bacola_Elementor_Addons->init('') #27 /htdocs/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array) #28 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #29 /htdocs/wp-settings.php(495): do_action('plugins_loaded') #30 /htdocs/wp-config.php(96): require_once('/htdocs/wp-sett...') #31 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #32 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #33 /htdocs/index.php(17): require('/htdocs/wp-blog...') #34 {main} thrown in /htdocs/wp-content/plugins/admin-menu-editor-pro/includes/menu-editor-core.php on line 505