Skip to content

Commit

Permalink
Merge pull request #21865 from Yoast/semrush-move-links-and-link-para…
Browse files Browse the repository at this point in the history
…ms-to-client-side

Semrush move links and link params to client side and tests
  • Loading branch information
pls78 authored Dec 20, 2024
2 parents d629521 + 156f527 commit 364d23f
Show file tree
Hide file tree
Showing 5 changed files with 578 additions and 37 deletions.
4 changes: 0 additions & 4 deletions admin/class-expose-shortlinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class WPSEO_Expose_Shortlinks implements WPSEO_WordPress_Integration {
'shortlinks.activate_premium_info' => 'https://yoa.st/activate-subscription',
'shortlinks.upsell.sidebar.morphology_upsell_metabox' => 'https://yoa.st/morphology-upsell-metabox',
'shortlinks.upsell.sidebar.morphology_upsell_sidebar' => 'https://yoa.st/morphology-upsell-sidebar',
'shortlinks.semrush.volume_help' => 'https://yoa.st/3-v',
'shortlinks.semrush.trend_help' => 'https://yoa.st/3-v',
'shortlinks.semrush.prices' => 'https://yoa.st/semrush-prices',
'shortlinks.semrush.premium_landing_page' => 'https://yoa.st/413',
'shortlinks.wincher.seo_performance' => 'https://yoa.st/wincher-integration',
'shortlinks-insights-estimated_reading_time' => 'https://yoa.st/4fd',
'shortlinks-insights-flesch_reading_ease' => 'https://yoa.st/34r',
Expand Down
39 changes: 15 additions & 24 deletions packages/js/src/components/SEMrushRelatedKeyphrasesModalContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,32 @@ export function getUserMessage( props ) {
*/
export default function RelatedKeyphraseModalContent( props ) {
const {
response,
lastRequestKeyphrase,
keyphrase,
response = {},
lastRequestKeyphrase = "",
keyphrase = "",
newRequest,
setCountry,
renderAction,
renderAction = null,
countryCode,
requestLimitReached,
requestLimitReached = false,
setRequestFailed,
setNoResultsFound,
relatedKeyphrases,
relatedKeyphrases = [],
setRequestSucceeded,
setRequestLimitReached,
isPending,
isRtl,
isPremium,
userLocale,
isRtl = false,
isPremium = false,
userLocale = "en_US",
semrushUpsellLink = "",
premiumUpsellLink = "",
} = props;

return (
<Root context={ { isRtl } }>

{ ! requestLimitReached && ! isPremium && <PremiumUpsell
url={ window.wpseoAdminL10n[ "shortlinks.semrush.premium_landing_page" ] }
url={ premiumUpsellLink }
className="yst-mb-4"
/> }

Expand All @@ -114,7 +116,7 @@ export default function RelatedKeyphraseModalContent( props ) {

{ ! isPending && <UserMessage
variant={ getUserMessage( props ) }
upsellLink={ window.wpseoAdminL10n[ "shortlinks.semrush.prices" ] }
upsellLink={ semrushUpsellLink }
/> }

<KeyphrasesTable
Expand Down Expand Up @@ -147,17 +149,6 @@ RelatedKeyphraseModalContent.propTypes = {
userLocale: PropTypes.string,
isPending: PropTypes.bool,
isPremium: PropTypes.bool,
};

RelatedKeyphraseModalContent.defaultProps = {
keyphrase: "",
relatedKeyphrases: [],
renderAction: null,
requestLimitReached: false,
response: {},
lastRequestKeyphrase: "",
isRtl: false,
userLocale: "en_US",
isPending: false,
isPremium: false,
semrushUpsellLink: PropTypes.string,
premiumUpsellLink: PropTypes.string,
};
4 changes: 4 additions & 0 deletions packages/js/src/containers/SEMrushRelatedKeyphrases.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* External dependencies */
import { withDispatch, withSelect } from "@wordpress/data";
import { compose } from "@wordpress/compose";
import { addQueryArgs } from "@wordpress/url";

/* Internal dependencies */
import RelatedKeyphrasesModalContent from "../components/SEMrushRelatedKeyphrasesModalContent";
Expand All @@ -18,6 +19,7 @@ export default compose( [
getSEMrushRequestKeyphrase,
getPreference,
getIsPremium,
selectLinkParams,
} = select( "yoast-seo/editor" );

return {
Expand All @@ -32,6 +34,8 @@ export default compose( [
isRtl: getPreference( "isRtl", false ),
userLocale: getPreference( "userLocale", "en_US" ),
isPremium: getIsPremium(),
semrushUpsellLink: addQueryArgs( "https://yoa.st/semrush-prices", selectLinkParams() ),
premiumUpsellLink: addQueryArgs( "https://yoa.st/413", selectLinkParams() ),
};
} ),
withDispatch( ( dispatch ) => {
Expand Down
Loading

0 comments on commit 364d23f

Please sign in to comment.