Merge pull request #18141 from woocommerce/helper-connect-prompt
Helper: Prompt connection to WooCommerce.com for updates/support
This commit is contained in:
commit
1296d6e087
|
@ -1205,12 +1205,18 @@ class WC_Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a note about available extension updates if Woo core has an update available.
|
* Various Helper-related admin notices.
|
||||||
*/
|
*/
|
||||||
public static function admin_notices() {
|
public static function admin_notices() {
|
||||||
|
if ( apply_filters( 'woocommerce_helper_suppress_admin_notices', false ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
$screen_id = $screen ? $screen->id : '';
|
$screen_id = $screen ? $screen->id : '';
|
||||||
|
|
||||||
|
self::_prompt_helper_connect( $screen_id );
|
||||||
|
|
||||||
if ( 'update-core' !== $screen_id ) {
|
if ( 'update-core' !== $screen_id ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1220,12 +1226,48 @@ class WC_Helper {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a note about available extension updates if Woo core has an update available.
|
||||||
$notice = self::_get_extensions_update_notice();
|
$notice = self::_get_extensions_update_notice();
|
||||||
if ( ! empty( $notice ) ) {
|
if ( ! empty( $notice ) ) {
|
||||||
echo '<div class="updated woocommerce-message"><p>' . $notice . '</p></div>';
|
echo '<div class="updated woocommerce-message"><p>' . $notice . '</p></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompt a Helper connection if the user has WooCommerce.com extensions.
|
||||||
|
*/
|
||||||
|
private static function _prompt_helper_connect( $screen_id ) {
|
||||||
|
// Don't show the notice on the Helper screens.
|
||||||
|
if ( 'woocommerce_page_wc-addons' == $screen_id && ! empty( $_REQUEST['section'] ) && 'helper' == $_REQUEST['section'] ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We believe have an active connection.
|
||||||
|
$auth = WC_Helper_Options::get( 'auth' );
|
||||||
|
if ( ! empty( $auth['access_token'] ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
|
||||||
|
if ( empty( $active_plugins ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$woo_plugins = self::get_local_woo_plugins();
|
||||||
|
if ( empty( $woo_plugins ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$active_woo_plugins = array_intersect_key( $woo_plugins, array_flip( $active_plugins ) );
|
||||||
|
|
||||||
|
if ( count( $active_woo_plugins ) > 0 ) {
|
||||||
|
/* translators: %s: helper screen url */
|
||||||
|
$notice = __( '<a href="%s">Connect your store</a> to WooCommerce.com to receive extensions updates and support.', 'woocommerce' );
|
||||||
|
$notice = sprintf( $notice, admin_url( 'admin.php?page=wc-addons§ion=helper' ) );
|
||||||
|
echo '<div class="updated woocommerce-message"><p>' . $notice . '</p></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an update notice if one or more Woo extensions has an update available.
|
* Get an update notice if one or more Woo extensions has an update available.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue