diff --git a/src/Admin/Settings/Page.php b/src/Admin/Settings/Page.php index 0efb06a9..a90bf5c2 100644 --- a/src/Admin/Settings/Page.php +++ b/src/Admin/Settings/Page.php @@ -514,10 +514,13 @@ public function register_menu() { } } + $settings = Helpers::get_settings(); + /** * Don't show the Analytics dashboard, if View Stats is disabled. */ - if ( ! empty( Helpers::get_settings()[ 'enable_analytics_dashboard' ] ) ) { + if ( ! empty( $settings[ 'enable_analytics_dashboard' ] ) || + ( ! empty( $settings[ 'self_hosted_domain' ] ) && ! empty( $settings[ 'self_hosted_shared_link' ] ) ) ) { // Setup `Analytics` page under Dashboard. add_dashboard_page( esc_html__( 'Analytics', 'plausible-analytics' ), diff --git a/src/Includes/Actions.php b/src/Includes/Actions.php index 9c41dbb9..7bbdc040 100644 --- a/src/Includes/Actions.php +++ b/src/Includes/Actions.php @@ -85,36 +85,38 @@ public function admin_bar_node( $admin_bar ) { } // Add main admin bar node. - $args = [ + $args[] = [ 'id' => 'plausible-admin-bar', 'title' => 'Plausible Analytics', ]; - $admin_bar->add_node( $args ); - // Add link to view all stats. - $args = []; - $args[] = [ - 'id' => 'view-analytics', - 'title' => esc_html__( 'View Analytics', 'plausible-analytics' ), - 'href' => admin_url( 'index.php?page=plausible_analytics_statistics' ), - 'parent' => 'plausible-admin-bar', - ]; - - // Add link to individual page stats. - if ( is_singular() ) { - global $post; - $uri = wp_make_link_relative( get_permalink( $post->ID ) ); + $settings = Helpers::get_settings(); + if ( ! empty( $settings[ 'enable_analytics_dashboard' ] ) || + ( ! empty( $settings[ 'self_hosted_domain' ] ) && ! empty( $settings[ 'self_hosted_shared_link' ] ) ) ) { $args[] = [ - 'id' => 'view-page-analytics', - 'title' => esc_html__( 'View Page Analytics', 'plausible-analytics' ), - 'href' => add_query_arg( - 'page-url', - is_home() ? '' : $uri, - admin_url( 'index.php?page=plausible_analytics_statistics' ) - ), + 'id' => 'view-analytics', + 'title' => esc_html__( 'View Analytics', 'plausible-analytics' ), + 'href' => admin_url( 'index.php?page=plausible_analytics_statistics' ), 'parent' => 'plausible-admin-bar', ]; + + // Add link to individual page stats. + if ( is_singular() ) { + global $post; + $uri = wp_make_link_relative( get_permalink( $post->ID ) ); + + $args[] = [ + 'id' => 'view-page-analytics', + 'title' => esc_html__( 'View Page Analytics', 'plausible-analytics' ), + 'href' => add_query_arg( + 'page-url', + is_home() ? '' : $uri, + admin_url( 'index.php?page=plausible_analytics_statistics' ) + ), + 'parent' => 'plausible-admin-bar', + ]; + } } // Add link to Plausible Settings page. @@ -124,6 +126,7 @@ public function admin_bar_node( $admin_bar ) { 'href' => admin_url( 'options-general.php?page=plausible_analytics' ), 'parent' => 'plausible-admin-bar', ]; + foreach ( $args as $arg ) { $admin_bar->add_node( $arg ); }