Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/dashboard/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
}
}

.woo-dashboard__admin-notice-list-hide {
display: none;
}

.woo-dashboard {
display: grid;
grid-template-columns: auto 300px;
Expand Down
35 changes: 32 additions & 3 deletions lib/admin.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/**
* Returns true if we are on a JS powered admin page.
*/
function woo_dash_is_admin_page() {
global $hook_suffix;
if ( in_array( $hook_suffix, array( 'toplevel_page_woodash' ) ) ) {
return true;
}
return false;
}

/**
* Register a new menu page for the Dashboard
*/
Expand All @@ -20,8 +31,8 @@ function woo_dash_register_page(){
/**
* Load the assets on the Dashboard page
*/
function woo_dash_enqueue_script( $hook ){
if ( 'toplevel_page_woodash' !== $hook ) {
function woo_dash_enqueue_script(){
if ( ! woo_dash_is_admin_page() ) {
return;
}

Expand All @@ -33,7 +44,7 @@ function woo_dash_enqueue_script( $hook ){
function woo_dash_admin_body_class( $admin_body_class = '' ) {
global $hook_suffix;

if ( ! in_array( $hook_suffix, array( 'toplevel_page_woodash' ) ) ) {
if ( ! woo_dash_is_admin_page() ) {
return $admin_body_class;
}

Expand All @@ -45,6 +56,24 @@ function woo_dash_admin_body_class( $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 '<div class="woo-dashboard__admin-notice-list-hide">';
echo '<div class="wp-header-end"></div>'; // 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 '</div>';
}
add_action( 'admin_notices', 'woo_dash_admin_after_notices', PHP_INT_MAX );


/**
* Set up a div for the app to render into.
*/
Expand Down