.wp-submenu > li'; $after = [ $menu . ':has(> a[href$="page=' . GEMOFFLOAD_PLUGIN_SLUG . '"])', $menu . ':has(+ li > a[href$="page=' . GEMOFFLOAD_PLUGIN_SLUG . '-settings"])', ]; wp_register_style( 'gemoffload-menu', false, [], GEMOFFLOAD_VERSION ); wp_enqueue_style( 'gemoffload-menu' ); wp_add_inline_style( 'gemoffload-menu', implode( ',', $after ) . '{margin-bottom:6px;padding-bottom:7px;border-bottom:1px solid rgba(255,255,255,.14)}' ); } public function admin_menu(): void { $title = apply_filters( 'gemoffload/admin/toplevel_menu_title', __( 'GemOffload', 'gemoffload' ) ); $menu_title = esc_html( $title ); add_menu_page( $title, $menu_title, 'manage_options', GEMOFFLOAD_PLUGIN_SLUG, [ $this, 'load_main_template' ], self::icon(), 81 ); foreach ( Helper::get_admin_menu_list() as $key => $item ) { add_submenu_page( $item['parent_slug'], $item['title'], $item['title'], $item['capability'], $key, [ $this, 'load_main_template' ] ); } } public function load_main_template(): void { echo '
' . esc_html__( 'Loading…', 'gemoffload' ) . '
'; } /** * One shape with a single fill, so WordPress can repaint it for the admin colour scheme. */ private static function icon(): string { $path = GEMOFFLOAD_ASSETS_DIR_PATH . 'images/menu-icon.svg'; if ( ! is_readable( $path ) ) { return 'dashicons-cloud'; } // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents, WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- a file this plugin ships, as a data URI. return 'data:image/svg+xml;base64,' . base64_encode( (string) file_get_contents( $path ) ); } }