Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"Yoast\\WP\\SEO\\Composer\\Actions::check_coding_standards"
],
"check-cs-thresholds": [
"@putenv YOASTCS_THRESHOLD_ERRORS=2395",
"@putenv YOASTCS_THRESHOLD_ERRORS=2385",
"@putenv YOASTCS_THRESHOLD_WARNINGS=251",
"Yoast\\WP\\SEO\\Composer\\Actions::check_cs_thresholds"
],
Expand Down
19 changes: 12 additions & 7 deletions packages/js/src/support/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ const openHelpScoutBeacon = () => {
}
};

/* eslint-disable complexity */

/**
* @returns {JSX.Element} The app component.
*
*/
export const App = () => {
const isPremium = useSelectSupport( "selectPreference", [], "isPremium", false );
const hasPremiumSubscription = useSelectSupport( "selectPreference", [], "hasPremiumSubscription", false );
const hasWooSeoSubscription = useSelectSupport( "selectPreference", [], "hasWooSeoSubscription", false );
const isWooCommerceActive = useSelectSupport( "selectPreference", [], "isWooCommerceActive", false );
const hasAnyAddon = hasPremiumSubscription || hasWooSeoSubscription;
const premiumUpsellConfig = useSelectSupport( "selectUpsellSettingsAsProps" );
const pluginUrl = useSelectSupport( "selectPreference", [], "pluginUrl", "" );
const linkParams = useSelectSupport( "selectLinkParams" );
Expand All @@ -48,7 +54,6 @@ export const App = () => {
const githubLink = useSelectSupport( "selectLink", [], "https://yoa.st/github-repository-support-card" );
const contactSupportLink = useSelectSupport( "selectLink", [], "https://yoa.st/contact-support-to-unlock-premium-support-section" );
const { isPromotionActive } = useSelect( STORE_NAME );
const isWooCommerceActive = useSelectSupport( "selectPreference", [], "isWooCommerceActive" );

const faq = useMemo( () => ( [
{
Expand Down Expand Up @@ -87,7 +92,7 @@ export const App = () => {

return (
<div className="yst-p-4 min-[783px]:yst-p-8">
<div className={ classNames( "yst-flex yst-flex-grow yst-flex-wrap", ! isPremium && "xl:yst-pe-[17.5rem]" ) }>
<div className={ classNames( "yst-flex yst-flex-grow yst-flex-wrap", ! hasAnyAddon && "xl:yst-pe-[17.5rem]" ) }>
<Paper as="main" className="yst-max-w-page yst-flex-grow yst-mb-8 xl:yst-mb-0">
<Paper.Header>
<div className="yst-max-w-screen-sm">
Expand Down Expand Up @@ -182,7 +187,7 @@ export const App = () => {
title={ (
<div className="yst-flex yst-items-center yst-gap-1.5">
<span>{ __( "Contact our support team", "wordpress-seo" ) }</span>
{ isPremium && <Badge variant="upsell">Premium</Badge> }
{ hasAnyAddon && <Badge variant="upsell">Premium</Badge> }
</div>
) }
description={ (
Expand All @@ -203,7 +208,7 @@ export const App = () => {
) }
>
<FeatureUpsell
shouldUpsell={ ! isPremium }
shouldUpsell={ ! hasAnyAddon }
variant="card"
cardLink={ contactSupportLink }
cardText={ sprintf(
Expand All @@ -213,7 +218,7 @@ export const App = () => {
) }
{ ...premiumUpsellConfig }
>
<div className={ classNames( "yst-flex", ! isPremium && "yst-opacity-50" ) }>
<div className={ classNames( "yst-flex", ! hasAnyAddon && "yst-opacity-50" ) }>
<div className="yst-me-6">
<p>{ __( "Our support team is here to answer any questions you may have. Fill out the (pop-up) contact form, and we'll get back to you as soon as possible!", "wordpress-seo" ) }</p>
<Button
Expand All @@ -239,7 +244,7 @@ export const App = () => {
</div>
</Paper.Content>
</Paper>
{ ! isPremium &&
{ ! hasAnyAddon &&
<div className="xl:yst-max-w-3xl xl:yst-fixed xl:yst-end-8 xl:yst-w-[16rem]">
<SidebarRecommendations
premiumLink={ isWooCommerceActive ? wooLink : premiumLink }
Expand Down
76 changes: 60 additions & 16 deletions src/integrations/admin/helpscout-beacon.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,24 @@ class HelpScout_Beacon implements Integration_Interface {
*/
protected $beacon_id_tracking_users = '6b8e74c5-aa81-4295-b97b-c2a62a13ea7f';

/**
* The id for the beacon for Premium users.
*
* @var string
*/
protected $beacon_id_premium = '1ae02e91-5865-4f13-b220-7daed946ba25';

/**
* The id for the beacon for WooCommerce SEO users.
*
* @var string
*/
protected $beacon_id_woocommerce = '8535d745-4e80-48b9-b211-087880aa857d';

/**
* The products the beacon is loaded for.
*
* @var array
* @var array<string>
*/
protected $products = [];

Expand All @@ -55,17 +69,24 @@ class HelpScout_Beacon implements Integration_Interface {
*/
protected $options;

/**
* The addon manager.
*
* @var WPSEO_Addon_Manager
*/
protected $addon_manager;

/**
* The array of pages we need to show the beacon on with their respective beacon IDs.
*
* @var array
* @var array<string, string>
*/
protected $pages_ids;

/**
* The array of pages we need to show the beacon on.
*
* @var array
* @var array<string>
*/
protected $base_pages = [
'wpseo_dashboard',
Expand Down Expand Up @@ -106,10 +127,12 @@ class HelpScout_Beacon implements Integration_Interface {
* @param Options_Helper $options The options helper.
* @param WPSEO_Admin_Asset_Manager $asset_manager The asset manager.
* @param Migration_Status $migration_status The migrations status.
* @param WPSEO_Addon_Manager $addon_manager The addon manager.
*/
public function __construct( Options_Helper $options, WPSEO_Admin_Asset_Manager $asset_manager, Migration_Status $migration_status ) {
public function __construct( Options_Helper $options, WPSEO_Admin_Asset_Manager $asset_manager, Migration_Status $migration_status, WPSEO_Addon_Manager $addon_manager ) {
$this->options = $options;
$this->asset_manager = $asset_manager;
$this->addon_manager = $addon_manager;
$this->ask_consent = ! $this->options->get( 'tracking' );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['page'] ) && \is_string( $_GET['page'] ) ) {
Expand All @@ -121,19 +144,16 @@ public function __construct( Options_Helper $options, WPSEO_Admin_Asset_Manager
}
$this->migration_status = $migration_status;

$beacon_id = $this->get_beacon_id();
foreach ( $this->base_pages as $page ) {
if ( $this->ask_consent ) {
// We want to be able to show surveys to people who have tracking on, so we give them a different beacon.
$this->pages_ids[ $page ] = $this->beacon_id_tracking_users;
}
else {
$this->pages_ids[ $page ] = $this->beacon_id;
}
$this->pages_ids[ $page ] = $beacon_id;
}
}

/**
* {@inheritDoc}
*
* @return void
*/
public function register_hooks() {
\add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_help_scout_script' ] );
Expand Down Expand Up @@ -247,7 +267,7 @@ protected function get_session_data() {
/**
* Returns basic info about the server software.
*
* @return array
* @return array<string, string>
*/
private function get_server_info() {
$server_tracking_data = new WPSEO_Tracking_Server_Data();
Expand Down Expand Up @@ -441,12 +461,37 @@ private function get_language_settings() {
/**
* Returns the conditionals based on which this integration should be active.
*
* @return array The array of conditionals.
* @return array<string> The array of conditionals.
*/
public static function get_conditionals() {
return [ Admin_Conditional::class ];
}

/**
* Get the beacon id to use based on the user's subscription and tracking settings.
*
* @return string The beacon id to use.
*/
private function get_beacon_id() {
// Case where the user has a Yoast WooCommerce SEO plan subscription (highest priority).
if ( $this->addon_manager->has_valid_subscription( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ) ) {
return $this->beacon_id_woocommerce;
}

// Case where the user has a Yoast SEO Premium plan subscription.
if ( $this->addon_manager->has_valid_subscription( WPSEO_Addon_Manager::PREMIUM_SLUG ) ) {
return $this->beacon_id_premium;
}

// Case where the user has no plan active and tracking enabled.
if ( $this->ask_consent ) {
return $this->beacon_id_tracking_users;
}

// Case where the user has no plan active and tracking disabled.
return $this->beacon_id;
}

/**
* Allows filtering of the HelpScout settings. Hooked to admin_head to prevent timing issues, not too early, not too late.
*
Expand All @@ -464,8 +509,7 @@ protected function filter_settings() {
* @param string $beacon_settings The HelpScout beacon settings.
*/
$helpscout_settings = \apply_filters( 'wpseo_helpscout_beacon_settings', $filterable_helpscout_setting );

$this->products = $helpscout_settings['products'];
$this->pages_ids = $helpscout_settings['pages_ids'];
$this->products = $helpscout_settings['products'];
$this->pages_ids = $helpscout_settings['pages_ids'];
}
}
34 changes: 23 additions & 11 deletions src/integrations/support-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Yoast\WP\SEO\Integrations;

use WPSEO_Addon_Manager;
use WPSEO_Admin_Asset_Manager;
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
use Yoast\WP\SEO\Conditionals\User_Can_Manage_Wpseo_Options_Conditional;
Expand Down Expand Up @@ -55,6 +56,13 @@ class Support_Integration implements Integration_Interface {
*/
private $woocommerce_conditional;

/**
* Holds the WPSEO_Addon_Manager.
*
* @var WPSEO_Addon_Manager
*/
private $addon_manager;

/**
* Constructs Support_Integration.
*
Expand All @@ -63,25 +71,28 @@ class Support_Integration implements Integration_Interface {
* @param Product_Helper $product_helper The Product_Helper.
* @param Short_Link_Helper $shortlink_helper The Short_Link_Helper.
* @param WooCommerce_Conditional $woocommerce_conditional The WooCommerce_Conditional.
* @param WPSEO_Addon_Manager $addon_manager The WPSEO_Addon_Manager.
*/
public function __construct(
WPSEO_Admin_Asset_Manager $asset_manager,
Current_Page_Helper $current_page_helper,
Product_Helper $product_helper,
Short_Link_Helper $shortlink_helper,
WooCommerce_Conditional $woocommerce_conditional
WooCommerce_Conditional $woocommerce_conditional,
WPSEO_Addon_Manager $addon_manager
) {
$this->asset_manager = $asset_manager;
$this->current_page_helper = $current_page_helper;
$this->product_helper = $product_helper;
$this->shortlink_helper = $shortlink_helper;
$this->woocommerce_conditional = $woocommerce_conditional;
$this->addon_manager = $addon_manager;
}

/**
* Returns the conditionals based on which this loadable should be active.
*
* @return array
* @return array<string>
*/
public static function get_conditionals() {
return [ Admin_Conditional::class, User_Can_Manage_Wpseo_Options_Conditional::class ];
Expand All @@ -108,11 +119,11 @@ public function register_hooks() {
/**
* Adds the page.
*
* @param array $pages The pages.
* @param array<array<string|callable>> $pages The pages.
*
* @return array The pages.
* @return array<array<string|callable>> The pages.
*/
public function add_page( $pages ) {
public function add_page( array $pages ) {
$pages[] = [
'wpseo_dashboard',
'',
Expand Down Expand Up @@ -165,19 +176,20 @@ public function remove_notices() {
/**
* Creates the script data.
*
* @return array The script data.
* @return array<string, array<array<string, bool|string|array<string>>, bool, string>> The script data.
*/
public function get_script_data() {
return [
'preferences' => [
'isPremium' => $this->product_helper->is_premium(),
'isRtl' => \is_rtl(),
'pluginUrl' => \plugins_url( '', \WPSEO_FILE ),
'upsellSettings' => [
'hasPremiumSubscription' => $this->addon_manager->has_valid_subscription( WPSEO_Addon_Manager::PREMIUM_SLUG ),
'hasWooSeoSubscription' => $this->addon_manager->has_valid_subscription( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ),
'isRtl' => \is_rtl(),
'pluginUrl' => \plugins_url( '', \WPSEO_FILE ),
'upsellSettings' => [
'actionId' => 'load-nfd-ctb',
'premiumCtbId' => 'f6a84663-465f-4cb5-8ba5-f7a6d72224b2',
],
'isWooCommerceActive' => $this->woocommerce_conditional->is_met(),
'isWooCommerceActive' => $this->woocommerce_conditional->is_met(),
],
'linkParams' => $this->shortlink_helper->get_query_params(),
'currentPromotions' => \YoastSEO()->classes->get( Promotion_Manager::class )->get_current_promotions(),
Expand Down
Loading