From 1876f76283dcc43c6e37125d539e96f21204b198 Mon Sep 17 00:00:00 2001 From: Thijs van der Heijden Date: Thu, 19 Oct 2023 13:49:59 +0200 Subject: [PATCH 01/26] Changes the default value for the ai option and introduces a new option. --- inc/options/class-wpseo-option-wpseo.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/options/class-wpseo-option-wpseo.php b/inc/options/class-wpseo-option-wpseo.php index 56f9708f6d0..f709745b494 100644 --- a/inc/options/class-wpseo-option-wpseo.php +++ b/inc/options/class-wpseo-option-wpseo.php @@ -58,7 +58,8 @@ class WPSEO_Option_Wpseo extends WPSEO_Option { 'enable_xml_sitemap' => true, 'enable_text_link_counter' => true, 'enable_index_now' => true, - 'enable_ai_generator' => false, + 'enable_ai_generator' => true, + 'ai_enabled_pre_default' => false, 'show_onboarding_notice' => false, 'first_activated_on' => false, 'myyoast-oauth' => [ From d28308e03edaf3be7480a2c2ef48cbca7ea990d8 Mon Sep 17 00:00:00 2001 From: Vraja Das Date: Thu, 19 Oct 2023 14:41:59 +0200 Subject: [PATCH 02/26] enable ai button in products --- packages/js/src/post-edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/src/post-edit.js b/packages/js/src/post-edit.js index 868174abf9c..5467bea3231 100644 --- a/packages/js/src/post-edit.js +++ b/packages/js/src/post-edit.js @@ -56,7 +56,7 @@ domReady( () => { initializeInsights(); - const AI_IGNORED_POST_TYPES = [ "attachment", "product" ]; + const AI_IGNORED_POST_TYPES = [ "attachment" ]; if ( window.wpseoScriptData.postType && ! AI_IGNORED_POST_TYPES.includes( window.wpseoScriptData.postType ) ) { // Initialize the AI Generator upsell. From 10f892346050c0f6373ebb3682a2e477765666b5 Mon Sep 17 00:00:00 2001 From: Vraja Das Date: Fri, 20 Oct 2023 11:45:35 +0200 Subject: [PATCH 03/26] remove duplicate isWooCommerceActive --- admin/metabox/class-metabox.php | 1 - 1 file changed, 1 deletion(-) diff --git a/admin/metabox/class-metabox.php b/admin/metabox/class-metabox.php index 31fda910e33..48eab592982 100644 --- a/admin/metabox/class-metabox.php +++ b/admin/metabox/class-metabox.php @@ -935,7 +935,6 @@ public function enqueue() { 'isJetpackBoostNotPremium' => ( $is_block_editor ) ? YoastSEO()->classes->get( Jetpack_Boost_Not_Premium_Conditional::class )->is_met() : false, 'isWooCommerceActive' => $woocommerce_active, 'woocommerceUpsell' => get_post_type( $post_id ) === 'product' && ! $woocommerce_seo_active && $woocommerce_active, - 'isWooCommerceActive' => $woocommerce_active, 'linkParams' => WPSEO_Shortlinker::get_query_params(), 'pluginUrl' => \plugins_url( '', \WPSEO_FILE ), 'wistiaEmbedPermission' => YoastSEO()->classes->get( Wistia_Embed_Permission_Repository::class )->get_value_for_user( \get_current_user_id() ), From 8e726ba6fb694af3a9c82d745a0ce82d52830ae7 Mon Sep 17 00:00:00 2001 From: Vraja Das Date: Fri, 20 Oct 2023 11:46:48 +0200 Subject: [PATCH 04/26] Add woo seo selector to store --- packages/js/src/redux/selectors/index.js | 1 + packages/js/src/redux/selectors/isWooSEO.js | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 packages/js/src/redux/selectors/isWooSEO.js diff --git a/packages/js/src/redux/selectors/index.js b/packages/js/src/redux/selectors/index.js index 0a057da39c6..2293c15e696 100644 --- a/packages/js/src/redux/selectors/index.js +++ b/packages/js/src/redux/selectors/index.js @@ -37,4 +37,5 @@ export * from "./WincherModal"; export * from "./WincherRequest"; export * from "./WincherSEOPerformance"; export * from "./isPremium"; +export * from "./isWooSEO"; export * from "./postId"; diff --git a/packages/js/src/redux/selectors/isWooSEO.js b/packages/js/src/redux/selectors/isWooSEO.js new file mode 100644 index 00000000000..58941473125 --- /dev/null +++ b/packages/js/src/redux/selectors/isWooSEO.js @@ -0,0 +1,8 @@ +import { get } from "lodash"; + +/** + * Determines whether the WooCommerce SEO addon is not active in a product page. + * + * @returns {Boolean} Whether the plugin is WooCommerce SEO or not. + */ +export const getIsWooSeoUpsell = () => get( window, "wpseoScriptData.woocommerceUpsell", false ); From 0677adced207d6081a6c24df96540af4ffe698e7 Mon Sep 17 00:00:00 2001 From: Vraja Das Date: Fri, 20 Oct 2023 11:47:50 +0200 Subject: [PATCH 05/26] remove upsell link prop --- packages/js/src/ai-generator/components/modal-content.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/js/src/ai-generator/components/modal-content.js b/packages/js/src/ai-generator/components/modal-content.js index a6d795add24..f7e78615313 100644 --- a/packages/js/src/ai-generator/components/modal-content.js +++ b/packages/js/src/ai-generator/components/modal-content.js @@ -9,7 +9,7 @@ const STORE = "yoast-seo/editor"; */ export const ModalContent = () => { const learnMoreLink = useSelect( select => select( STORE ).selectLink( "https://www.yoa.st/ai-generator-learn-more" ), [] ); - const upsellLink = useSelect( select => select( STORE ).selectLink( "https://yoa.st/ai-generator-upsell" ), [] ); + const imageLink = useSelect( select => select( STORE ).selectImageLink( "ai-generator-preview.png" ), [] ); const thumbnail = useMemo( () => ( { @@ -23,10 +23,10 @@ export const ModalContent = () => { const { setWistiaEmbedPermission: set } = useDispatch( STORE ); const wistiaEmbedPermission = useMemo( () => ( { value, status, set } ), [ value, status, set ] ); + return ( From f0b07f824bfa4a3b3da60a352b0e44e5fadc3dbe Mon Sep 17 00:00:00 2001 From: Vraja Das Date: Fri, 20 Oct 2023 11:59:45 +0200 Subject: [PATCH 06/26] show upsell introduction modal in product pages --- packages/js/src/ai-generator/initialize.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/js/src/ai-generator/initialize.js b/packages/js/src/ai-generator/initialize.js index 974645e9661..23d9edf4628 100644 --- a/packages/js/src/ai-generator/initialize.js +++ b/packages/js/src/ai-generator/initialize.js @@ -44,19 +44,25 @@ AiGeneratorUpsell.propTypes = { fieldId: PropTypes.string.isRequired, }; +const STORE = "yoast-seo/editor"; + /** * Initializes the AI Generator upsell. * * @returns {void} */ const initializeAiGenerator = () => { - const isPremium = select( "yoast-seo/editor" ).getIsPremium(); + const isPremium = select( STORE ).getIsPremium(); + const isWooSeoUpsell = select( STORE ).getIsWooSeoUpsell(); + const isProduct = select( STORE ).getIsProduct(); + + const shouldShowAiGeneratorUpsell = ( isProduct ) ? ! isPremium || isWooSeoUpsell : ! isPremium; addFilter( "yoast.replacementVariableEditor.additionalButtons", "yoast/yoast-seo-premium/AiGenerator", ( buttons, { fieldId } ) => { - if ( ! isPremium ) { + if ( shouldShowAiGeneratorUpsell ) { buttons.push( From b0db4e87dc5ac3a21b6c25010c3e009767df8eb8 Mon Sep 17 00:00:00 2001 From: Vraja Das Date: Fri, 20 Oct 2023 12:00:49 +0200 Subject: [PATCH 07/26] add CTA labels and links --- ...generate-titles-and-descriptions-upsell.js | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/packages/js/src/shared-admin/components/ai-generate-titles-and-descriptions-upsell.js b/packages/js/src/shared-admin/components/ai-generate-titles-and-descriptions-upsell.js index f6a7c74b349..ab68ea0fbf1 100644 --- a/packages/js/src/shared-admin/components/ai-generate-titles-and-descriptions-upsell.js +++ b/packages/js/src/shared-admin/components/ai-generate-titles-and-descriptions-upsell.js @@ -1,20 +1,62 @@ import { LockOpenIcon } from "@heroicons/react/outline"; import { ArrowNarrowRightIcon } from "@heroicons/react/solid"; import { createInterpolateElement } from "@wordpress/element"; +import { useSelect } from "@wordpress/data"; import { __, sprintf } from "@wordpress/i18n"; import { Badge, Button, useModalContext } from "@yoast/ui-library"; import PropTypes from "prop-types"; import { OutboundLink, VideoFlow } from "."; +const STORE = "yoast-seo/editor"; + /** * @param {string} learnMoreLink The learn more link. - * @param {string} upsellLink The upsell link. * @param {Object} thumbnail The thumbnail: img props. * @param {Object} wistiaEmbedPermission The value, status and set for the Wistia embed permission. * @returns {JSX.Element} The element. */ -export const AiGenerateTitlesAndDescriptionsUpsell = ( { learnMoreLink, upsellLink, thumbnail, wistiaEmbedPermission } ) => { +export const AiGenerateTitlesAndDescriptionsUpsell = ( { learnMoreLink, thumbnail, wistiaEmbedPermission } ) => { const { onClose, initialFocus } = useModalContext(); + const upsellLinkPremium = useSelect( select => select( STORE ).selectLink( "https://yoa.st/ai-generator-upsell" ), [] ); + const upsellLinkWooPremiumBundle = useSelect( select => select( STORE ).selectLink( "https://yoa.st/ai-generator-upsell-woo-seo-premium-bundle" ), [] ); + const upsellLinkWoo = useSelect( select => select( STORE ).selectLink( "https://yoa.st/ai-generator-upsell-woo-seo" ), [] ); + let upsellLink = upsellLinkPremium; + + const isPremium = useSelect( select => select( STORE ).getIsPremium(), [] ); + const isWooSeoUpsell = useSelect( select => select( STORE ).getIsWooSeoUpsell(), [] ); + let upsellLabel = sprintf( + /* translators: %1$s expands to Yoast SEO Premium. */ + __( "Unlock with %1$s", "wordpress-seo" ), + "Yoast SEO Premium" + ); + let bundleNote = ""; + + if ( isWooSeoUpsell ) { + if ( ! isPremium ) { + upsellLabel = `${sprintf( + /* translators: %1$s expands to Woo Premium bundle. */ + __( "Unlock with the %1$s", "wordpress-seo" ), + "Woo Premium bundle" + )}*`; + bundleNote =
+ { `*${sprintf( + /* translators: %1$s expands to Yoast SEO Premium, %2$s expands to Yoast WooCommerce SEO. */ + __( "%1$s + %2$s", "wordpress-seo" ), + "Yoast SEO Premium", + "Yoast WooCommerce SEO" + )}` } +
; + upsellLink = upsellLinkWooPremiumBundle; + } + if ( isPremium ) { + upsellLabel = sprintf( + /* translators: %1$s expands to Yoast WooCommerce SEO. */ + __( "Unlock with %1$s", "wordpress-seo" ), + "Yoast WooCommerce SEO" + ); + upsellLink = upsellLinkWoo; + } + } return (
@@ -76,7 +118,7 @@ export const AiGenerateTitlesAndDescriptionsUpsell = ( { learnMoreLink, upsellLi ref={ initialFocus } > - { __( "Unlock with Premium", "wordpress-seo" ) } + { upsellLabel } { /* translators: Hidden accessibility text. */ @@ -85,6 +127,7 @@ export const AiGenerateTitlesAndDescriptionsUpsell = ( { learnMoreLink, upsellLi
+ { bundleNote }