$submenu_item ) { if ( 'woodash' === $submenu_item[2] ) { $woodash_key = $submenu_key; break; } } if ( ! $woodash_key ) { return; } $dashmenu = $submenu['woocommerce'][ $woodash_key ]; $dashmenu[2] = 'admin.php?page=woodash#/'; unset( $submenu['woocommerce'][ $woodash_key ] ); array_unshift( $submenu['woocommerce'], $dashmenu ); $submenu['woodash#/analytics'][0][0] = __( 'Overview', 'woo-dash' ); } // priority is 20 to run after https://github.com/woocommerce/woocommerce/blob/a55ae325306fc2179149ba9b97e66f32f84fdd9c/includes/admin/class-wc-admin-menus.php#L165 add_action( 'admin_head', 'woo_dash_link_structure', 20 ); /** * Load the assets on the Dashboard page */ function woo_dash_enqueue_script(){ if ( ! woo_dash_is_admin_page() ) { return; } wp_enqueue_script( WOO_DASH_APP ); wp_enqueue_style( WOO_DASH_APP ); } add_action( 'admin_enqueue_scripts', 'woo_dash_enqueue_script' ); function woo_dash_admin_body_class( $admin_body_class = '' ) { global $hook_suffix; if ( ! woo_dash_is_admin_page() ) { return $admin_body_class; } $classes = explode( ' ', trim( $admin_body_class ) ); $classes[] = 'woocommerce-page'; $admin_body_class = implode( ' ', array_unique( $classes ) ); return " $admin_body_class "; } add_filter( 'admin_body_class', 'woo_dash_admin_body_class' ); function woo_dash_admin_before_notices() { if ( ! woo_dash_is_admin_page() ) { return; } echo '
'; echo '
'; // https://github.com/WordPress/WordPress/blob/f6a37e7d39e2534d05b9e542045174498edfe536/wp-admin/js/common.js#L737 } add_action( 'admin_notices', 'woo_dash_admin_before_notices', 0 ); function woo_dash_admin_after_notices() { if ( ! woo_dash_is_admin_page() ) { return; } echo '
'; } add_action( 'admin_notices', 'woo_dash_admin_after_notices', PHP_INT_MAX ); // TODO Can we do some URL rewriting so we can figure out which page they are on server side? function woo_dash_admin_title( $admin_title ) { if ( ! woo_dash_is_admin_page() ) { return $admin_title; } return sprintf( __( '%1$s ‹ %2$s — WooCommerce' ), __( 'Dashboard', 'woo-dash' ), get_bloginfo( 'name' ) ); } add_filter( 'admin_title', 'woo_dash_admin_title' ); /** * Set up a div for the app to render into. */ function woo_dash_page(){ ?>