Skip to content

Commit

Permalink
Merge pull request #20489 from Yoast/feature/lingo-fixes
Browse files Browse the repository at this point in the history
Merges the feature branch into trunk
  • Loading branch information
mhkuu committed Jul 10, 2023
2 parents f602e03 + 33b5211 commit 2caaaaa
Show file tree
Hide file tree
Showing 16 changed files with 422 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/WordOccurrenceInsights.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getKeywordResearchArticleLink = ( url ) => {
mixedString: keywordsResearchLinkTranslation,
components: {
// eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-no-target-blank
a: <a href={ url } target="_blank" />,
a: <a href={ url } target="_blank" rel="noreferrer" />,
},
} );
};
Expand Down
28 changes: 22 additions & 6 deletions packages/js/src/components/contentAnalysis/Results.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { __ } from "@wordpress/i18n";
import { doAction } from "@wordpress/hooks";
import PropTypes from "prop-types";
import { ContentAnalysis } from "@yoast/analysis-report";
import { Component, Fragment } from "@wordpress/element";
Expand Down Expand Up @@ -131,8 +132,7 @@ class Results extends Component {
// The keyword key is used for labelling the related keyphrase(s).
const keywordKey = this.props.keywordKey;
const elementID = keywordKey === "" ? "focus-keyword-input-" + inputFieldLocation
: "yoast-keyword-input-" + keywordKey + "-" + inputFieldLocation;

: "yoast-keyword-input-" + keywordKey + "-" + inputFieldLocation;

const element = document.getElementById( elementID );
element.focus();
Expand Down Expand Up @@ -180,23 +180,39 @@ class Results extends Component {
*/
handleEditButtonClick( id ) {
// Whether the user is in the metabox or sidebar.
let inputFieldLocation = this.props.location;
const inputFieldLocation = this.props.location;

if ( id === "functionWordsInKeyphrase" || id === "keyphraseLength" ) {
this.focusOnKeyphraseField( inputFieldLocation );
return;
}

/*
* For all the other assessments that have an edit button, we need to jump to the relevant Google preview fields.
* (metadescription, slug, or title). If the user is in the sidebar, these are accessed through a modal. So if the
* inputFieldLocation string is 'sidebar' it should now be changed to 'modal'.
*/
*/
if ( [ "metaDescriptionKeyword", "metaDescriptionLength", "titleWidth", "keyphraseInSEOTitle", "slugKeyword" ].includes( id ) ) {
this.handleGooglePreviewFocus( inputFieldLocation, id );
}

doAction( "yoast.focus.input", id );
}

/**
* Handles focus on Google Preview elements, when an edit button is clicked.
*
* @param {string} inputFieldLocation The location of the input field.
* @param {string} id The id of the input field.
*
* @returns {void}
*/
handleGooglePreviewFocus( inputFieldLocation, id ) {
if ( inputFieldLocation === "sidebar" ) {
inputFieldLocation = "modal";
// Open the modal.
document.getElementById( "yoast-google-preview-modal-open-button" ).click();
// Wait for the input field elements to become available, then focus on the relevant field.
setTimeout( () => this.focusOnGooglePreviewField( id, inputFieldLocation ), 500 );
setTimeout( () => this.focusOnGooglePreviewField( id, "modal" ), 500 );
} else {
const googlePreviewCollapsible = document.getElementById( "yoast-snippet-editor-metabox" );
// Check if the collapsible is closed before clicking on it.
Expand Down
22 changes: 22 additions & 0 deletions packages/js/src/settings/routes/crawl-optimization.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,33 @@ const CrawlOptimization = () => {
"<code1/>",
"<code2/>",
"<code3/>"
) +
sprintf(
/**
* translators:
* %1$s through %7$s each expand to a parameter name within a <code> tag. For example, <code>gclid</code>.
*/
__( "Note that the following commonly-used parameters will not be removed: %1$s, %2$s, %3$s, %4$s, %5$s, %6$s, and %7$s.",
"wordpress-seo" ),
"<code4/>",
"<code5/>",
"<code6/>",
"<code7/>",
"<code8/>",
"<code9/>",
"<code10/>"
),
{
code1: <Code>301</Code>,
code2: <Code variant="block">https://www.example.com/?unknown_parameter=yes</Code>,
code3: <Code variant="block">https://www.example.com</Code>,
code4: <Code>gclid</Code>,
code5: <Code>gtm_debug</Code>,
code6: <Code>utm_campaign</Code>,
code7: <Code>utm_content</Code>,
code8: <Code>utm_medium</Code>,
code9: <Code>utm_source</Code>,
code10: <Code>utm_term</Code>,
}
),
cleanPermalinksExtraVariables: createInterpolateElement(
Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/settings/routes/site-connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const SiteConnections = () => {
"<a>",
"</a>"
),
addQueryArgs( "https://www.google.com/webmasters/verification/verification", { hl: "en", tid: "alternate", siteUrl } ),
addQueryArgs( "https://search.google.com/search-console/users", { hl: "en", tid: "alternate", siteUrl } ),
"link-google-search-console"
) }
placeholder={ __( "Add verification code", "wordpress-seo" ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ describe( "a test for Product identifiers assessment for WooCommerce", function(

expect( assessmentResult.getScore() ).toEqual( 6 );
expect( assessmentResult.getText() ).toEqual( "<a href='https://yoa.st/4ly' target='_blank'>Product identifier</a>:" +
" Your product is missing an identifier (like a GTIN code). You can add a product identifier via the \"Yoast SEO\" tab " +
"in the Product data box. <a href='https://yoa.st/4lz' target='_blank'>Include" +
" Your product is missing an identifier (like a GTIN code)." +
" <a href='https://yoa.st/4lz' target='_blank'>Include" +
" it if you can, as it will help search engines to better understand your content.</a>" );
} );

Expand All @@ -103,8 +103,8 @@ describe( "a test for Product identifiers assessment for WooCommerce", function(

expect( assessmentResult.getScore() ).toEqual( 6 );
expect( assessmentResult.getText() ).toEqual( "<a href='https://yoa.st/4ly' target='_blank'>Product identifier</a>:" +
" Not all your product variants have an identifier. You can add a product identifier via the \"Variations\" " +
"tab in the Product data box. <a href='https://yoa.st/4lz' target='_blank'>Include it if you can, as it " +
" Not all your product variants have an identifier. " +
"<a href='https://yoa.st/4lz' target='_blank'>Include it if you can, as it " +
"will help search engines to better understand your content.</a>" );
} );

Expand All @@ -121,8 +121,8 @@ describe( "a test for Product identifiers assessment for WooCommerce", function(

expect( assessmentResult.getScore() ).toEqual( 6 );
expect( assessmentResult.getText() ).toEqual( "<a href='https://yoa.st/4ly' target='_blank'>Product identifier</a>:" +
" Not all your product variants have an identifier. You can add a product identifier via the \"Variations\"" +
" tab in the Product data box. <a href='https://yoa.st/4lz' target='_blank'>Include" +
" Not all your product variants have an identifier." +
" <a href='https://yoa.st/4lz' target='_blank'>Include" +
" it if you can, as it will help search engines to better understand your content.</a>" );
} );

Expand Down Expand Up @@ -156,8 +156,8 @@ describe( "a test for Product identifiers assessment for WooCommerce", function(

expect( assessmentResult.getScore() ).toEqual( 6 );
expect( assessmentResult.getText() ).toEqual( "<a href='https://yoa.st/4ly' target='_blank'>Product identifier</a>:" +
" Your product is missing an identifier (like a GTIN code). You can add a product identifier via the \"Yoast SEO\" tab " +
"in the Product data box. <a href='https://yoa.st/4lz' target='_blank'>Include" +
" Your product is missing an identifier (like a GTIN code)." +
" <a href='https://yoa.st/4lz' target='_blank'>Include" +
" it if you can, as it will help search engines to better understand your content.</a>" );
} );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe( "a test for SKU assessment for WooCommerce", function() {

expect( assessmentResult.getScore() ).toEqual( 6 );
expect( assessmentResult.getText() ).toEqual( "<a href='https://yoa.st/4lw' target='_blank'>SKU</a>:" +
" Your product is missing a SKU. You can add a SKU via the \"Inventory\" tab in the Product data box. " +
" Your product is missing a SKU. " +
"<a href='https://yoa.st/4lx' target='_blank'>Include it if you can, as it will help search engines " +
"to better understand your content.</a>" );
} );
Expand Down Expand Up @@ -149,7 +149,7 @@ describe( "a test for SKU assessment for WooCommerce", function() {

expect( assessmentResult.getScore() ).toEqual( 6 );
expect( assessmentResult.getText() ).toEqual( "<a href='https://yoa.st/4lw' target='_blank'>SKU</a>:" +
" Your product is missing a SKU. You can add a SKU via the \"Inventory\" tab in the Product data box. " +
" Your product is missing a SKU. " +
"<a href='https://yoa.st/4lx' target='_blank'>Include it if you can, as it will help search engines to " +
"better understand your content.</a>" );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,14 @@ const expectedResults = {
isApplicable: true,
score: 6,
resultText: "<a href='https://yoa.st/4ly' target='_blank'>Product identifier</a>: Your product is missing an identifier " +
"(like a GTIN code). You can add a product identifier via the \"Yoast SEO\" tab in the Product data box." +
"(like a GTIN code)." +
" <a href='https://yoa.st/4lz' target='_blank'>Include it if you can, as it will " +
"help search engines to better understand your content.</a>",
},
productSKU: {
isApplicable: true,
score: 6,
resultText: "<a href='https://yoa.st/4lw' target='_blank'>SKU</a>: Your product is missing a SKU. " +
"You can add a SKU via the \"Inventory\" tab in the Product data box. " +
"<a href='https://yoa.st/4lx' target='_blank'>Include it if you can, as it will " +
"help search engines to better understand your content.</a>",
},
Expand Down Expand Up @@ -179,7 +178,8 @@ const expectedResults = {
wordComplexity: {
isApplicable: true,
score: 6,
resultText: "<a href='https://yoa.st/shopify77' target='_blank'>Word complexity</a>: 11.11% of the words in your text " +
resultText: "<a href='https://yoa.st/shopify77' target='_blank'>Word complexity</a>: 11.11% of the words in your " +
"text " +
"are considered complex." +
" <a href='https://yoa.st/shopify78' target='_blank'>Try to use shorter and more familiar words to improve readability</a>.",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const expectedResults = {
isApplicable: true,
score: 6,
resultText: "<a href='https://yoa.st/4ly' target='_blank'>Product identifier</a>: Not all your product variants" +
" have an identifier. You can add a product identifier via the \"Variations\" tab in the Product data box. " +
" have an identifier. " +
"<a href='https://yoa.st/4lz' target='_blank'>Include it if you can, as it" +
" will help search engines to better understand your content.</a>",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class ProductIdentifiersAssessment extends Assessment {
urlCallToAction: createAnchorOpeningTag( "https://yoa.st/4lz" ),
assessVariants: true,
productIdentifierOrBarcode: "Product identifier",
shouldShowEditButton: true,
};

this.identifier = "productIdentifier";
Expand All @@ -53,6 +54,11 @@ export default class ProductIdentifiersAssessment extends Assessment {
assessmentResult.setText( result.text );
}

if ( assessmentResult.getScore() < 9 && this._config.shouldShowEditButton ) {
assessmentResult.setHasJumps( true );
assessmentResult.setEditFieldName( __( "Product identifiers", "yoast-woo-seo" ) );
}

return assessmentResult;
}

Expand Down Expand Up @@ -100,11 +106,9 @@ export default class ProductIdentifiersAssessment extends Assessment {

if ( this._config.productIdentifierOrBarcode === "Product identifier" ) {
feedbackStrings = {
okNoVariants: __( "Your product is missing an identifier (like a GTIN code). " +
"You can add a product identifier via the \"Yoast SEO\" tab in the Product data box", "yoast-woo-seo" ),
okNoVariants: __( "Your product is missing an identifier (like a GTIN code)", "yoast-woo-seo" ),
goodNoVariants: __( "Your product has an identifier", "yoast-woo-seo" ),
okWithVariants: __( "Not all your product variants have an identifier. " +
"You can add a product identifier via the \"Variations\" tab in the Product data box", "yoast-woo-seo" ),
okWithVariants: __( "Not all your product variants have an identifier", "yoast-woo-seo" ),
goodWithVariants: __( "All your product variants have an identifier", "yoast-woo-seo" ),
};
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export default class ProductSKUAssessment extends Assessment {
assessmentResult.setText( result.text );
}

if ( assessmentResult.getScore() < 9 && this._config.shouldShowEditButton ) {
assessmentResult.setHasJumps( true );
assessmentResult.setEditFieldName( __( "SKU", "yoast-woo-seo" ) );
}

return assessmentResult;
}

Expand Down Expand Up @@ -98,14 +103,6 @@ export default class ProductSKUAssessment extends Assessment {
* or empty object if no score should be returned.
*/
scoreProductSKU( productSKUData, config ) {
// Check if we want to add information about where to add the SKU in the feedback string or not.
// Currently we want to implement it only for Woo Product pages.
let feedbackString = "";
if ( this._config.addSKULocation === true ) {
// Translators: please keep the space at the start of the sentence in your translation unless your language does not use spaces.
feedbackString = __( " You can add a SKU via the \"Inventory\" tab in the Product data box.", "yoast-woo-seo" );
}

// Apply the following scoring conditions to products without variants.
if ( [ "simple", "external", "grouped" ].includes( productSKUData.productType ) ||
( productSKUData.productType === "variable" && ! productSKUData.hasVariants ) ) {
Expand All @@ -114,16 +111,14 @@ export default class ProductSKUAssessment extends Assessment {
score: config.scores.ok,
text: sprintf(
// Translators: %1$s and %2$s expand to links on yoast.com, %3$s expands to the anchor end tag.
// %4$s expands to "You can add a SKU via the "Inventory" tab in the Product data box." or to an empty string.
__(
"%1$sSKU%3$s: Your product is missing a SKU.%4$s" +
"%1$sSKU%3$s: Your product is missing a SKU." +
" %2$sInclude it if you can, as it will help search engines to better understand your content.%3$s",
"yoast-woo-seo"
),
this._config.urlTitle,
this._config.urlCallToAction,
"</a>",
feedbackString
"</a>"
),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@ const ProductCornerstoneSEOAssessor = function( researcher, options ) {
urlCallToAction: createAnchorOpeningTag( options.productIdentifierCTAUrl ),
assessVariants: options.assessVariants,
productIdentifierOrBarcode: options.productIdentifierOrBarcode,
shouldShowEditButton: options.shouldShowEditButtons,
} ),
new ProductSKUAssessment( {
urlTitle: createAnchorOpeningTag( options.productSKUUrlTitle ),
urlCallToAction: createAnchorOpeningTag( options.productSKUCTAUrl ),
assessVariants: options.assessVariants,
addSKULocation: options.addSKULocation,
shouldShowEditButton: options.shouldShowEditButtons,
} ),
];
};
Expand Down
2 changes: 2 additions & 0 deletions packages/yoastseo/src/scoring/productPages/seoAssessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,14 @@ const ProductSEOAssessor = function( researcher, options ) {
urlCallToAction: createAnchorOpeningTag( options.productIdentifierCTAUrl ),
assessVariants: options.assessVariants,
productIdentifierOrBarcode: options.productIdentifierOrBarcode,
shouldShowEditButton: options.shouldShowEditButtons,
} ),
new ProductSKUAssessment( {
urlTitle: createAnchorOpeningTag( options.productSKUUrlTitle ),
urlCallToAction: createAnchorOpeningTag( options.productSKUCTAUrl ),
assessVariants: options.assessVariants,
addSKULocation: options.addSKULocation,
shouldShowEditButton: options.shouldShowEditButtons,
} ),
];
};
Expand Down
13 changes: 12 additions & 1 deletion src/helpers/crawl-cleanup-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,25 @@ public function should_avoid_redirect() {
* @return array The list of the allowed extra vars.
*/
public function get_allowed_extravars() {
$default_allowed_extravars = [
'utm_source',
'utm_medium',
'utm_campaign',
'utm_term',
'utm_content',
'gclid',
'gtm_debug',
];

/**
* Filter: 'Yoast\WP\SEO\allowlist_permalink_vars' - Allows plugins to register their own variables not to clean.
*
* @since 19.2.0
*
* @param array $allowed_extravars The list of the allowed vars (empty by default).
*/
$allowed_extravars = \apply_filters( 'Yoast\WP\SEO\allowlist_permalink_vars', [] );

$allowed_extravars = \apply_filters( 'Yoast\WP\SEO\allowlist_permalink_vars', $default_allowed_extravars );

$clean_permalinks_extra_variables = $this->options_helper->get( 'clean_permalinks_extra_variables' );

Expand Down
Loading

0 comments on commit 2caaaaa

Please sign in to comment.