Add wc-admin notice.

This commit is contained in:
Timmy Crawford 2019-05-08 17:33:22 -07:00
parent 90aa716098
commit 43cd7dc04c
2 changed files with 67 additions and 0 deletions

View File

@ -34,6 +34,7 @@ class WC_Admin_Notices {
'regenerating_thumbnails' => 'regenerating_thumbnails_notice',
'regenerating_lookup_table' => 'regenerating_lookup_table_notice',
'no_secure_connection' => 'secure_connection_notice',
'wc_admin' => 'wc_admin_feature_plugin_notice',
);
/**
@ -82,6 +83,7 @@ class WC_Admin_Notices {
if ( ! self::is_ssl() ) {
self::add_notice( 'no_secure_connection' );
}
self::add_wc_admin_feature_plugin_notice();
self::add_notice( 'template_files' );
}
@ -341,6 +343,36 @@ class WC_Admin_Notices {
include dirname( __FILE__ ) . '/views/html-notice-regenerating-lookup-table.php';
}
/**
* If on WordPress 5.0 or greater, inform users of WooCommerce Admin feature plugin.
*
* @since 3.6.4
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
*/
public static function add_wc_admin_feature_plugin_notice() {
$wordpress_version = get_bloginfo( 'version' );
if ( version_compare( $wordpress_version, '4.9.9', '>' ) ) {
self::add_notice( 'wc_admin' );
}
}
/**
* Notice to try WooCommerce Admin
*
* @since 3.6.4
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
*/
public static function wc_admin_feature_plugin_notice() {
if ( get_user_meta( get_current_user_id(), 'dismissed_wc_admin_notice', true ) || self::is_plugin_active( 'woocommerce-admin/woocommerce-admin.php' ) ) {
self::remove_notice( 'wc_admin' );
return;
}
include dirname( __FILE__ ) . '/views/html-notice-wc-admin.php';
}
/**
* Determine if the store is running SSL.
*

View File

@ -0,0 +1,35 @@
<?php
/**
* Admin View: Notice - WooCommerce Admin Feature Plugin
*
* @package admin.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div id="message" class="updated woocommerce-message woocommerce-admin-promo-messages">
<a class="woocommerce-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'wc_admin' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'woocommerce' ); ?></a>
<p>
<?php echo wp_kses_post( __( 'Test drive the future of WooCommerce. A quicker, javascript powered interface with exciting new features and reports.', 'woocommerce' ) ); ?>
</p>
<?php if ( file_exists( WP_PLUGIN_DIR . '/woocommerce-admin/woocommerce-admin.php' ) && ! is_plugin_active( 'woocommerce-admin/woocommerce-admin.php' ) && current_user_can( 'activate_plugin', 'woocommerce-admin/woocommerce-admin.php' ) ) : ?>
<p>
<a href="<?php echo esc_url( wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=woocommerce-admin/woocommerce-admin.php&plugin_status=active' ), 'activate-plugin_woocommerce-admin/woocommerce-admin.php' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Activate WooCommerce Admin', 'woocommerce' ); ?></a>
</p>
<?php else : ?>
<?php
if ( current_user_can( 'install_plugins' ) ) {
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce-admin' ), 'install-plugin_woocommerce-admin' );
} else {
$url = 'https://wordpress.org/plugins/woocommerce-admin/';
}
?>
<p>
<a href="<?php echo esc_url( $url ); ?>" class="button button-primary"><?php esc_html_e( 'Install WooCommerce Admin', 'woocommerce' ); ?></a>
</p>
<?php endif; ?>
</div>