Merge pull request #20524 from woocommerce/add/wootenbergjitm
Wootenberg JITM
This commit is contained in:
commit
f6519e3361
|
@ -34,6 +34,7 @@ class WC_Admin_Notices {
|
|||
'simplify_commerce' => 'simplify_commerce_notice',
|
||||
'regenerating_thumbnails' => 'regenerating_thumbnails_notice',
|
||||
'no_secure_connection' => 'secure_connection_notice',
|
||||
'wootenberg' => 'wootenberg_feature_plugin_notice',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -49,6 +50,7 @@ class WC_Admin_Notices {
|
|||
|
||||
if ( current_user_can( 'manage_woocommerce' ) ) {
|
||||
add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) );
|
||||
add_action( 'activate_gutenberg/gutenberg.php', array( __CLASS__, 'add_wootenberg_feature_plugin_notice_on_gutenberg_activate' ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,6 +93,7 @@ class WC_Admin_Notices {
|
|||
WC_Admin_Notices::add_notice( 'no_secure_connection' );
|
||||
}
|
||||
|
||||
WC_Admin_Notices::add_wootenberg_feature_plugin_notice();
|
||||
self::add_notice( 'template_files' );
|
||||
}
|
||||
|
||||
|
@ -357,6 +360,42 @@ class WC_Admin_Notices {
|
|||
|
||||
include dirname( __FILE__ ) . '/views/html-notice-secure-connection.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* If Gutenberg is active, tell people about the Products block feature plugin.
|
||||
*
|
||||
* @since 3.4.3
|
||||
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
|
||||
*/
|
||||
public static function add_wootenberg_feature_plugin_notice() {
|
||||
if ( is_plugin_active( 'gutenberg/gutenberg.php' ) && ! is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
|
||||
self::add_notice( 'wootenberg' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell people about the Products block feature plugin when they activate Gutenberg.
|
||||
*
|
||||
* @since 3.4.3
|
||||
* @todo Remove this notice and associated code once the feature plugin has been merged into core.
|
||||
*/
|
||||
public static function add_wootenberg_feature_plugin_notice_on_gutenberg_activate() {
|
||||
if ( ! is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
|
||||
self::add_notice( 'wootenberg' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notice about trying the Products block.
|
||||
*/
|
||||
public static function wootenberg_feature_plugin_notice() {
|
||||
if ( get_user_meta( get_current_user_id(), 'dismissed_wootenberg_notice', true ) || is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) {
|
||||
self::remove_notice( 'wootenberg' );
|
||||
return;
|
||||
}
|
||||
|
||||
include dirname( __FILE__ ) . '/views/html-notice-wootenberg.php';
|
||||
}
|
||||
}
|
||||
|
||||
WC_Admin_Notices::init();
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin View: Notice - Wootenberg Feature Plugin
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="message" class="updated woocommerce-message woocommerce-wootenberg-promo-messages">
|
||||
<a class="woocommerce-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'wootenberg' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'woocommerce' ); ?></a>
|
||||
|
||||
<p>
|
||||
<?php echo wp_kses_post( __( "We noticed you're experimenting with Gutenberg: Try the WooCommerce Gutenberg Products Block for a powerful new way to feature products in posts.", 'woocommerce' ) ); ?>
|
||||
</p>
|
||||
<?php if ( file_exists( WP_PLUGIN_DIR . '/woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) && ! is_plugin_active( 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) && current_user_can( 'activate_plugin', 'woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ) : ?>
|
||||
<p>
|
||||
<a href="<?php echo esc_url( wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php&plugin_status=active' ), 'activate-plugin_woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Active the Gutenberg Products Block', '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=woo-gutenberg-products-block' ), 'install-plugin_woo-gutenberg-products-block' );
|
||||
} else {
|
||||
$url = 'https://wordpress.org/plugins/woo-gutenberg-products-block/';
|
||||
}
|
||||
?>
|
||||
<p>
|
||||
<a href="<?php echo esc_url( $url ); ?>" class="button button-primary"><?php esc_html_e( 'Install the WooCommerce Gutenberg Products Block', 'woocommerce' ); ?></a>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
Loading…
Reference in New Issue