diff --git a/includes/admin/class-cocart-admin-notices.php b/includes/admin/class-cocart-admin-notices.php index b8a50e14..1cc3b6fc 100644 --- a/includes/admin/class-cocart-admin-notices.php +++ b/includes/admin/class-cocart-admin-notices.php @@ -81,6 +81,8 @@ public function __construct() { if ( CoCart_Helpers::user_has_capabilities() ) { add_action( 'admin_print_styles', array( $this, 'add_notices' ) ); } + + add_action( 'admin_notices', array( $this, 'wordpress_playground_notice' ) ); } // END __construct() /** @@ -230,6 +232,11 @@ public function add_notices() { return; } + // Don't show notices if on WordPress Playground. + if ( CoCart_Helpers::is_on_wordpress_playground() ) { + return; + } + $notices = self::get_notices(); if ( empty( $notices ) ) { @@ -476,6 +483,21 @@ public function setup_wizard_notice() { include_once COCART_ABSPATH . 'includes/admin/views/html-notice-setup-wizard.php'; } // END setup_wizard_notice() + /** + * Displays a notice if the user installed CoCart on WordPress Playground. + * + * @access public + * + * @since 3.10.0 Introduced. + * + * @return void + */ + public function wordpress_playground_notice() { + if ( CoCart_Helpers::is_on_wordpress_playground() ) { + include_once COCART_ABSPATH . 'includes/admin/views/html-notice-playground.php'; + } + } // END wordpress_playground_notice() + } // END class. } // END if class exists. diff --git a/includes/admin/views/html-notice-playground.php b/includes/admin/views/html-notice-playground.php new file mode 100644 index 00000000..ddc841f9 --- /dev/null +++ b/includes/admin/views/html-notice-playground.php @@ -0,0 +1,39 @@ + +
+
+
+ CoCart Logo +
+ +
+

+ +

+
+ +
+ +
+
+
diff --git a/includes/class-cocart-helpers.php b/includes/class-cocart-helpers.php index 8b1b72f2..48cbdb7a 100644 --- a/includes/class-cocart-helpers.php +++ b/includes/class-cocart-helpers.php @@ -778,6 +778,29 @@ public static function is_wc_admin_enabled() { return self::$is_wc_admin_enabled; } // END is_wc_admin_enabled() + /** + * Returns true if plugin is accessed from WordPress Playground. + * + * @access public + * + * @static + * + * @since 3.10.0 Introduced. + * + * @ignore Function ignored when parsed into Code Reference. + * + * @return bool + */ + public static function is_on_wordpress_playground() { + $site_url = get_site_url(); + + if ( strpos( $site_url, 'playground.wordpress.net' ) !== false ) { + return true; + } + + return false; + } // END is_on_wordpress_playground() + } // END class return new CoCart_Helpers();