Skip to content

Commit

Permalink
Merge pull request #21582 from Yoast/21580-move-links-from-wpseoscrip…
Browse files Browse the repository at this point in the history
…tdata-to-js

21580 move links from wpseoscriptdata to js
  • Loading branch information
mykola committed Sep 5, 2024
2 parents f5d6880 + a34cc6a commit 0368085
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 17 deletions.
1 change: 0 additions & 1 deletion admin/class-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public function config_page_scripts() {
'isPremium' => YoastSEO()->helpers->product->is_premium(),
'isWooCommerceActive' => $woocommerce_conditional->is_met(),
'currentPromotions' => YoastSEO()->classes->get( Promotion_Manager::class )->get_current_promotions(),
'webinarIntroSettingsUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/webinar-intro-settings' ),
'webinarIntroFirstTimeConfigUrl' => $this->get_webinar_shortlink(),
'linkParams' => WPSEO_Shortlinker::get_query_params(),
'pluginUrl' => plugins_url( '', WPSEO_FILE ),
Expand Down
5 changes: 0 additions & 5 deletions admin/formatter/class-metabox-formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public function get_values() {
*/
private function get_defaults() {
$schema_types = new Schema_Types();
$host = YoastSEO()->helpers->url->get_url_host( get_site_url() );

$defaults = [
'author_name' => get_the_author_meta( 'display_name' ),
Expand All @@ -73,10 +72,6 @@ private function get_defaults() {
* @param bool $showMarkers Should the markers being enabled. Default = true.
*/
'show_markers' => apply_filters( 'wpseo_enable_assessment_markers', true ),
'getJetpackBoostPrePublishLink' => WPSEO_Shortlinker::get( 'https://yoa.st/jetpack-boost-get-prepublish?domain=' . $host ),
'upgradeJetpackBoostPrePublishLink' => WPSEO_Shortlinker::get( 'https://yoa.st/jetpack-boost-upgrade-prepublish?domain=' . $host ),
'woocommerceUpsellSchemaLink' => WPSEO_Shortlinker::get( 'https://yoa.st/product-schema-metabox' ),
'woocommerceUpsellGooglePreviewLink' => WPSEO_Shortlinker::get( 'https://yoa.st/product-google-preview-metabox' ),
];

$integration_information_repo = YoastSEO()->classes->get( Integration_Information_Repository::class );
Expand Down
5 changes: 3 additions & 2 deletions packages/js/src/components/JetpackBoost.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ const getDescription = ( isJetpackBoostActive ) => {
* @returns {JSX.Element} The JetpackBoost element (which is null when dismissed).
*/
const JetpackBoost = ( { store, isAlertDismissed, onDismissed } ) => {
const host = window.location.host;
const isJetpackBoostActive = get( window, "wpseoScriptData.isJetpackBoostActive", "" ) === "1";
const isJetpackBoostNotPremium = get( window, "wpseoScriptData.isJetpackBoostNotPremium", "" ) === "1";
const getJetpackBoostPrePublishLink = get( window, "wpseoScriptData.metabox.getJetpackBoostPrePublishLink", "" );
const upgradeJetpackBoostPrePublishLink = get( window, "wpseoScriptData.metabox.upgradeJetpackBoostPrePublishLink", "" );
const getJetpackBoostPrePublishLink = useSelect( select => select( store ).selectLink( `https://yoa.st/jetpack-boost-get-prepublish?domain=${host}`, [] ) );
const upgradeJetpackBoostPrePublishLink = useSelect( select => select( store ).selectLink( `https://yoa.st/jetpack-boost-upgrade-prepublish?domain=${host}`, [] ) );

const isPremium = useSelect( select => select( store ).getIsPremium() );
if ( isPremium || isAlertDismissed || ! isJetpackBoostNotPremium ) {
Expand Down
3 changes: 1 addition & 2 deletions packages/js/src/components/SchemaTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import interpolateComponents from "interpolate-components";
import PropTypes from "prop-types";
import styled from "styled-components";
import WooCommerceUpsell from "./WooCommerceUpsell";
import { get } from "lodash";
import { useSelect } from "@wordpress/data";

const NewsLandingPageLink = makeOutboundLink();
Expand Down Expand Up @@ -167,7 +166,7 @@ function isNewsArticleType( selectedValue, defaultValue ) {
const Content = ( props ) => {
const schemaPageTypeOptions = getSchemaTypeOptions( props.pageTypeOptions, props.defaultPageType, props.postTypeName );
const schemaArticleTypeOptions = getSchemaTypeOptions( props.articleTypeOptions, props.defaultArticleType, props.postTypeName );
const woocommerceUpsellLink = get( window, "wpseoScriptData.metabox.woocommerceUpsellSchemaLink", "" );
const woocommerceUpsellLink = useSelect( select => select( STORE ).selectLink( "https://yoa.st/product-schema-metabox" ), [] );
const woocommerceUpsell = useSelect( ( select ) => select( STORE ).getIsWooSeoUpsell(), [] );
const [ focusedArticleType, setFocusedArticleType ] = useState( props.schemaArticleTypeSelected );
const woocommerceUpsellText = __( "Want your products stand out in search results with rich results like price, reviews and more?", "wordpress-seo" );
Expand Down
3 changes: 1 addition & 2 deletions packages/js/src/containers/SnippetEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import SnippetPreviewSection from "../components/SnippetPreviewSection";
import { applyReplaceUsingPlugin } from "../helpers/replacementVariableHelpers";
import getMemoizedFindCustomFields from "../helpers/getMemoizedFindCustomFields";
import WooCommerceUpsell from "../components/WooCommerceUpsell";
import { get } from "lodash";

/**
* Process the snippet editor form data before it's being displayed in the snippet preview.
Expand Down Expand Up @@ -50,7 +49,7 @@ export const mapEditorDataToPreview = function( data, context ) {
* @returns {wp.Element} The component.
*/
const SnippetEditorWrapper = ( props ) => {
const woocommerceUpsellLink = get( window, "wpseoScriptData.metabox.woocommerceUpsellGooglePreviewLink", "" );
const woocommerceUpsellLink = useSelect( select => select( "yoast-seo/editor" ).selectLink( "https://yoa.st/product-google-preview-metabox" ), [] );
const woocommerceUpsell = useSelect( ( select ) => select( "yoast-seo/editor" ).getIsWooSeoUpsell(), [] );
const woocommerceUpsellText = __( "Want an enhanced Google preview of how your WooCommerce products look in the search results?", "wordpress-seo" );

Expand Down
4 changes: 2 additions & 2 deletions packages/js/src/elementor/components/fills/ElementorFill.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// External dependencies.
import { Fill } from "@wordpress/components";
import { Fragment, useEffect } from "@wordpress/element";
import { useSelect } from "@wordpress/data";
import { __ } from "@wordpress/i18n";
import { get } from "lodash";
import PropTypes from "prop-types";
import { InternalLinkingSuggestionsUpsell } from "../../../components/modals/InternalLinkingSuggestionsUpsell";

Expand Down Expand Up @@ -34,7 +34,7 @@ import KeywordUpsell from "../../../components/modals/KeywordUpsell";
* @constructor
*/
export default function ElementorFill( { isLoading, onLoad, settings } ) {
const webinarIntroUrl = get( window, "wpseoScriptData.webinarIntroElementorUrl", "https://yoa.st/webinar-intro-elementor" );
const webinarIntroUrl = useSelect( select => select( "yoast-seo/editor" ).selectLink( "https://yoa.st/webinar-intro-elementor" ), [] );
const FirstEligibleNotification = useFirstEligibleNotification( { webinarIntroUrl } );

useEffect( () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/js/src/initializers/settings-header.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { get } from "lodash";
import { useSelect } from "@wordpress/data";
import { render } from "@wordpress/element";
import { ThemeProvider } from "styled-components";
import WebinarPromoNotification from "../components/WebinarPromoNotification";
Expand All @@ -13,7 +14,7 @@ import { shouldShowWebinarPromotionNotificationInDashboard } from "../helpers/sh
const initSettingsHeader = () => {
const reactRoot = document.getElementById( "yst-settings-header-root" );
const isRtl = Boolean( get( window, "wpseoScriptData.isRtl", false ) );
const webinarIntroSettingsUrl = get( window, "wpseoScriptData.webinarIntroSettingsUrl", "https://yoa.st/webinar-intro-settings" );
const webinarIntroSettingsUrl = useSelect( select => select( "yoast-seo/editor" ).selectLink( "https://yoa.st/webinar-intro-settings" ), [] );
const isWooCommerce = get( window, "wpseoScriptData.isWooCommerceActive", "" );

if ( reactRoot ) {
Expand Down
2 changes: 0 additions & 2 deletions src/integrations/third-party/elementor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use WPSEO_Metabox_Formatter;
use WPSEO_Post_Metabox_Formatter;
use WPSEO_Replace_Vars;
use WPSEO_Shortlinker;
use WPSEO_Utils;
use Yoast\WP\SEO\Conditionals\Third_Party\Elementor_Edit_Conditional;
use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
Expand Down Expand Up @@ -425,7 +424,6 @@ public function enqueue() {
'plugins' => $plugins_script_data,
'worker' => $worker_script_data,
],
'webinarIntroElementorUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/webinar-intro-elementor' ),
'usedKeywordsNonce' => \wp_create_nonce( 'wpseo-keyword-usage-and-post-types' ),
];

Expand Down

0 comments on commit 0368085

Please sign in to comment.