} /** * @return array */ public function toDbFormat() { return $this->rawItems; } /** * @param array $items * @return static */ public static function fromDbFormat($items) { return new static($items); } /** * @return array */ public function flatten() { $results = []; foreach ($this->rawItems as $trigger => $items) { foreach ($items as $properties) { if ( !is_array($properties) ) { continue; } $properties['trigger'] = $trigger; $results[] = $properties; } } return $results; } /** * Add a redirect to the collection. * * @param array $redirectProperties */ public function add($redirectProperties) { $trigger = $redirectProperties['trigger']; if ( !isset($this->rawItems[$trigger]) ) { $this->rawItems[$trigger] = []; } $this->rawItems[$trigger][] = $redirectProperties; } } abstract class Triggers { const LOGIN = 'login'; const LOGOUT = 'logout'; const REGISTRATION = 'registration'; const FIRST_LOGIN = 'firstLogin'; public static function getValues() { return [self::LOGIN, self::LOGOUT, self::REGISTRATION, self::FIRST_LOGIN]; } } class MenuExtractor { private $items = []; public function __construct($menuTree) { foreach ($menuTree as $item) { $this->processItem($item); } } private function processItem($item, $parentTitle = null) { //Skip separators. if ( !empty($item['separator']) ) { return; } $templateId = ameMenuItem::get($item, 'template_id'); $url = ameMenuItem::get($item, 'url'); $rawTitle = ameMenuItem::get($item, 'menu_title', '[Untitled]'); $fullTitle = trim(wp_strip_all_tags(ameMenuItem::remove_update_count($rawTitle))); if ( $parentTitle !== null ) { $fullTitle = $parentTitle . ' → ' . $fullTitle; } if ( empty($item['custom']) && ($templateId !== null) && !$this->looksLikeUnusableSlug($url) ) { //Add the admin URL shortcode to the URL if it looks like a relative URL that points //to a dashboard page. if ( $this->looksLikeDashboardUrl($url) ) { $url = '[ame-wp-admin]' . $url; } $this->items[] = [ 'templateId' => $templateId, 'title' => $fullTitle, 'url' => $url, ]; } if ( !empty($item['items']) ) { foreach ($item['items'] as $submenu) { $this->processItem($submenu, $fullTitle); } } } /** * @param string $url * @return boolean */ private function looksLikeDashboardUrl($url) { $scheme = wp_parse_url($url, PHP_URL_SCHEME); if ( !empty($scheme) ) { return false; } return preg_match('@^[a-z0-9][a-z0-9_-]{0,30}?\.php@i', $url) === 1; } /** * Check if a string looks like a plain admin menu slug and not a usable URL. * * Sometimes plugins create admin menus that don't have a callback function. A menu like that * will show up fine, and it can be used as a parent for other menu items. However, the menu * itself won't have a working URL, so we don't want to offer it as a redirect option. * * For example, the top level "WooCommerce" menu doesn't have a valid URL, it just has * a slug: "woocommerce". You just usually don't notice this because WordPress automatically * replaces the menu URL with the URL of the first child item. * * @param string|mixed $url * @return bool */ private function looksLikeUnusableSlug($url) { if ( !is_string($url) ) { return true; } //Technically, a menu slug could be anything, so we can't easily determine if a string //is really a slug or just a weird relative URL. However, it seems safe to assume that //a "URL" that has no dots (so no file extension or domain name) and no slashes (so no //protocol or relative directories) is probably unusable. $suspiciousSegmentLength = strcspn($url, './'); return ($suspiciousSegmentLength === strlen($url)); } public function getUsableItems() { return $this->items; } }
Fatal error: Uncaught Error: Class '\YahnisElsts\AdminMenuEditor\Redirects\Module' not found in /var/www/html/cineorna.com/web/wp-content/plugins/admin-menu-editor/includes/menu-editor-core.php:507 Stack trace: #0 /var/www/html/cineorna.com/web/wp-includes/class-wp-hook.php(324): WPMenuEditor->load_modules('') #1 /var/www/html/cineorna.com/web/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #2 /var/www/html/cineorna.com/web/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #3 /var/www/html/cineorna.com/web/wp-settings.php(555): do_action('plugins_loaded') #4 /var/www/html/cineorna.com/web/wp-config.php(99): require_once('/var/www/html/c...') #5 /var/www/html/cineorna.com/web/wp-load.php(50): require_once('/var/www/html/c...') #6 /var/www/html/cineorna.com/web/wp-blog-header.php(13): require_once('/var/www/html/c...') #7 /var/www/html/cineorna.com/web/index.php(17): require('/var/www/html/c...') #8 {main} thrown in /var/www/html/cineorna.com/web/wp-content/plugins/admin-menu-editor/includes/menu-editor-core.php on line 507