Merge pull request #18141 from woocommerce/helper-connect-prompt

Helper: Prompt connection to WooCommerce.com for updates/support
This commit is contained in:
Claudiu Lodromanean 2017-12-13 09:43:41 -08:00 committed by GitHub
commit 1296d6e087
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 43 additions and 1 deletions

View File

@ -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() {
if ( apply_filters( 'woocommerce_helper_suppress_admin_notices', false ) ) {
return;
}
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
self::_prompt_helper_connect( $screen_id );
if ( 'update-core' !== $screen_id ) {
return;
}
@ -1220,12 +1226,48 @@ class WC_Helper {
return;
}
// Add a note about available extension updates if Woo core has an update available.
$notice = self::_get_extensions_update_notice();
if ( ! empty( $notice ) ) {
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&section=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.
*