-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide the plugin banner on non-wpcom-connected users or agency-managed…
… users
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
projects/packages/jetpack-mu-wpcom/src/features/wpcom-plugins/wpcom-plugins.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Adds a tiny WordPress.com Plugins integration to the plugin list. | ||
* | ||
* @package automattic/jetpack-mu-wpcom | ||
*/ | ||
|
||
/** | ||
* Displays a banner before the plugin browser that links to the WP.com Plugins Marketplace. | ||
*/ | ||
function wpcom_plugins_show_banner() { | ||
|
||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended | ||
if ( isset( $_GET['tab'] ) && 'favorites' === $_GET['tab'] ) { | ||
// no banner on the favorites tab, it's a bit overbearing given they presumably want | ||
// something specific. | ||
return; | ||
} | ||
|
||
// No banner for agency-managed sites. | ||
if ( ! empty( get_option( 'is_fully_managed_agency_site' ) ) ) { | ||
return; | ||
} | ||
if ( function_exists( 'current_user_has_wpcom_account' ) && ! current_user_has_wpcom_account() ) { | ||
return; | ||
} | ||
|
||
$site_slug = wp_parse_url( home_url(), PHP_URL_HOST ); | ||
$wpcom_logo = plugins_url( 'images/wpcom-logo.svg', __FILE__ ); | ||
$background_image = plugins_url( 'images/banner-background.webp', __FILE__ ); | ||
|
||
wp_enqueue_script( | ||
'wpcom-plugins-banner', | ||
plugins_url( 'js/banner.js', __FILE__ ), | ||
array(), | ||
WPCOMSH_VERSION, | ||
array( | ||
'strategy' => 'defer', | ||
'in_footer' => true, | ||
) | ||
); | ||
wp_localize_script( | ||
'wpcom-plugins-banner', | ||
'wpcomPluginsBanner', | ||
array( | ||
'logo' => esc_url( $wpcom_logo ), | ||
'title' => esc_html__( "Flex your site's features with plugins", 'jetpack-mu-wpcom' ), | ||
'description' => esc_html__( "Access a variety of free and paid plugins that can enhance your site's functionality and features.", 'jetpack-mu-wpcom' ), | ||
'actionUrl' => esc_url( "https://wordpress.com/plugins/$site_slug?ref=woa-plugin-banner" ), | ||
'actionText' => esc_html__( 'Explore plugins', 'jetpack-mu-wpcom' ), | ||
'bannerBackground' => esc_url( $background_image ), | ||
) | ||
); | ||
wp_enqueue_style( | ||
'wpcom-plugins-banner', | ||
plugins_url( 'css/banner.css', __FILE__ ), | ||
array(), | ||
WPCOMSH_VERSION | ||
); | ||
} | ||
add_action( 'load-plugin-install.php', 'wpcom_plugins_show_banner' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters