network->register(); } /** * The PixelKeep mark in one color, which WordPress repaints to match the admin color scheme. * * A photo whose edge turns into shrinking pixels. Same shapes as the plugin directory icon. */ private const ICON_SVG = ''; /** * Returns the menu icon as the data URI WordPress expects for SVG menu icons. * * @return string */ public static function icon(): string { // Base64 is the format add_menu_page() documents for SVG icons; it encodes a constant, nothing is hidden. return 'data:image/svg+xml;base64,' . base64_encode( self::ICON_SVG ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode } /** * Adds the network settings page. * * @return void */ public function add_network_page(): void { if ( ! $this->network->is_available() ) { return; } add_menu_page( __( 'PixelKeep', 'pixelkeep' ), __( 'PixelKeep', 'pixelkeep' ), 'manage_network_options', 'pixelkeep-network', array( $this->network, 'render' ), self::icon(), 81 ); } /** * Adds the menu pages. * * @return void */ public function add_pages(): void { add_menu_page( __( 'PixelKeep', 'pixelkeep' ), __( 'PixelKeep', 'pixelkeep' ), 'manage_options', self::SLUG, array( $this->overview, 'render' ), self::icon(), 81 ); $pages = array( self::SLUG => array( __( 'Overview', 'pixelkeep' ), array( $this->overview, 'render' ) ), self::SLUG_BULK => array( __( 'Bulk Optimization', 'pixelkeep' ), array( $this->bulk, 'render' ) ), self::SLUG_HISTORY => array( __( 'History', 'pixelkeep' ), array( $this->history, 'render' ) ), self::SLUG_CONVERT => array( __( 'Format Conversion', 'pixelkeep' ), array( $this->conversion, 'render' ) ), self::SLUG_SETTINGS => array( __( 'Settings', 'pixelkeep' ), array( $this->settings, 'render' ) ), self::SLUG_TOOLS => array( __( 'Tools', 'pixelkeep' ), array( $this->tools, 'render' ) ), ); foreach ( $pages as $slug => $page ) { add_submenu_page( self::SLUG, $page[0], $page[0], 'manage_options', $slug, $page[1] ); } } }