label and store URL. The id picks the * style: 'pro' is solid yellow, the others yellow-outlined. * * @return array */ public static function items(): array { $items = array(); if ( ! defined( 'AIOU_PRO_VERSION' ) ) { $items['pro'] = array( 'label' => __( 'Upgrade to Pro', 'all-in-one-utilities' ), 'url' => self::PRO_URL, ); } if ( class_exists( 'WooCommerce' ) && ! defined( 'AIOU_WOO_VERSION' ) ) { $items['woo'] = array( 'label' => __( 'Get Woo Add-on', 'all-in-one-utilities' ), 'url' => self::WOO_URL, ); } /** * Filters the yellow upgrade links under the admin menu. * * @param array $items Id => label and URL. */ return (array) apply_filters( 'aiou_upgrade_menu_items', $items ); } /** * Add the links. A full URL as the menu slug makes WordPress link * straight to it. * * @return void */ public static function add_links(): void { foreach ( self::items() as $id => $item ) { $label = $item['label']; add_submenu_page( Menu::SLUG, $label, '' . esc_html( $label ) . '', 'manage_options', esc_url_raw( $item['url'] ) ); } } /** * Style the links on every admin screen (the menu is everywhere) and * open them in a new tab. * * @return void */ public static function enqueue(): void { if ( ! current_user_can( 'manage_options' ) || ! self::items() ) { return; } wp_add_inline_style( 'admin-menu', '#adminmenu .wp-submenu a:has(> .aiou-upgrade-link){padding-top:4px;padding-bottom:4px}' // Outlined: black with a yellow border, turning yellow on hover. . '#adminmenu .aiou-upgrade-link{background:#111;border:1px solid #ffd400;border-radius:5px;box-sizing:border-box;color:#ffd400;display:block;font-weight:600;line-height:1.4;padding:4px 10px;text-align:center;transition:background-color .15s ease,color .15s ease}' . '#adminmenu a:hover > .aiou-upgrade-link,#adminmenu a:focus > .aiou-upgrade-link{background:#ffd400;color:#111}' // Pro: solid yellow, turning black with yellow text on hover. . '#adminmenu .aiou-upgrade-link--pro{background:#ffd400;color:#111}' . '#adminmenu a:hover > .aiou-upgrade-link--pro,#adminmenu a:focus > .aiou-upgrade-link--pro{background:#111;color:#ffd400}' ); wp_add_inline_script( 'common', 'document.querySelectorAll("#adminmenu .aiou-upgrade-link").forEach(function(s){var a=s.parentNode;a.target="_blank";a.rel="noopener noreferrer";});' ); } }