Skip to content

Commit

Permalink
Merge branch 'release/21.4' of https://github.com/Yoast/wordpress-seo
Browse files Browse the repository at this point in the history
…into trunk
  • Loading branch information
marinakoleva committed Oct 12, 2023
2 parents 9c26e03 + 4eb6e8b commit 24cd586
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 48 deletions.
4 changes: 2 additions & 2 deletions admin/class-gutenberg-compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class WPSEO_Gutenberg_Compatibility {
*
* @var string
*/
const CURRENT_RELEASE = '16.7.1';
const CURRENT_RELEASE = '16.8.0';

/**
* The minimally supported version of Gutenberg by the plugin.
*
* @var string
*/
const MINIMUM_SUPPORTED = '16.7.1';
const MINIMUM_SUPPORTED = '16.8.0';

/**
* Holds the current version.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"typescript": "^4.2.4"
},
"yoast": {
"pluginVersion": "21.4-RC6"
"pluginVersion": "21.4-RC7"
},
"version": "0.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe( "test to get sentences from the tree", () => {
} );
it( "returns the sentences from paragraph and heading nodes", () => {
const paper = new Paper( "<div><p>A very intelligent cat loves their human. A dog is very cute.</p><h3>A subheading 3" +
"</h3>text text text<h4>A subheading 4</h4>more text.</div>" );
"</h3><h4>A subheading 4</h4></div>" );
researcher.setPaper( paper );
buildTree( paper, researcher );
expect( getSentencesFromTree( paper ) ).toEqual( [
Expand Down Expand Up @@ -76,48 +76,76 @@ describe( "test to get sentences from the tree", () => {
parentClientId: "",
},
{
sourceCodeRange: { startOffset: 96, endOffset: 110 },
parentStartOffset: 96,
text: "text text text",
sourceCodeRange: { startOffset: 100, endOffset: 114 },
parentStartOffset: 100,
text: "A subheading 4",
tokens: [
{ sourceCodeRange: { startOffset: 96, endOffset: 100 }, text: "text" },
{ sourceCodeRange: { startOffset: 100, endOffset: 101 }, text: " " },
{ sourceCodeRange: { startOffset: 101, endOffset: 105 }, text: "text" },
{ sourceCodeRange: { startOffset: 105, endOffset: 106 }, text: " " },
{ sourceCodeRange: { startOffset: 106, endOffset: 110 }, text: "text" },
{ sourceCodeRange: { startOffset: 100, endOffset: 101 }, text: "A" },
{ sourceCodeRange: { startOffset: 101, endOffset: 102 }, text: " " },
{ sourceCodeRange: { startOffset: 102, endOffset: 112 }, text: "subheading" },
{ sourceCodeRange: { startOffset: 112, endOffset: 113 }, text: " " },
{ sourceCodeRange: { startOffset: 113, endOffset: 114 }, text: "4" },
],
isParentFirstSectionOfBlock: false,
parentAttributeId: "",
parentClientId: "",
},
] );
} );
it( "returns the sentences from an implicit paragraph (an image caption)", () => {
const paper = new Paper( "[caption id=\"attachment_75\" align=\"alignnone\" width=\"200\"]<img class=\"wp-image-75 size-medium\"" +
" src=\"https://basic.wordpress.test/wp-content/uploads/2023/05/African_Bush_Elephant-200x300.jpg\" alt=\"elephant\"" +
" width=\"200\" height=\"300\" /> elephant[/caption]", { shortcodes: [ "caption" ] } );
researcher.setPaper( paper );
buildTree( paper, researcher );
expect( getSentencesFromTree( paper ) ).toEqual( [
{
sourceCodeRange: { startOffset: 114, endOffset: 128 },
parentStartOffset: 114,
text: "A subheading 4",
tokens: [
{ sourceCodeRange: { startOffset: 114, endOffset: 115 }, text: "A" },
{ sourceCodeRange: { startOffset: 115, endOffset: 116 }, text: " " },
{ sourceCodeRange: { startOffset: 116, endOffset: 126 }, text: "subheading" },
{ sourceCodeRange: { startOffset: 126, endOffset: 127 }, text: " " },
{ sourceCodeRange: { startOffset: 127, endOffset: 128 }, text: "4" },
],
isParentFirstSectionOfBlock: false,
parentAttributeId: "",
parentClientId: "",
},
{
sourceCodeRange: { startOffset: 133, endOffset: 143 },
parentStartOffset: 133,
text: "more text.",
parentStartOffset: 0,
sourceCodeRange: {
endOffset: 252,
startOffset: 0,
},
text: " elephant",
tokens: [
{ sourceCodeRange: { startOffset: 133, endOffset: 137 }, text: "more" },
{ sourceCodeRange: { startOffset: 137, endOffset: 138 }, text: " " },
{ sourceCodeRange: { startOffset: 138, endOffset: 142 }, text: "text" },
{ sourceCodeRange: { startOffset: 142, endOffset: 143 }, text: "." },
{
sourceCodeRange: {
endOffset: 234,
startOffset: 233,
},
text: " ",
},
{
sourceCodeRange: {
endOffset: 242,
startOffset: 234,
},
text: "elephant",
},
{
sourceCodeRange: {
endOffset: 243,
startOffset: 242,
},
text: "[",
},
{
sourceCodeRange: {
endOffset: 251,
startOffset: 243,
},
text: "/caption",
},
{
sourceCodeRange: {
endOffset: 252,
startOffset: 251,
},
text: "]",
},
],
isParentFirstSectionOfBlock: false,
parentAttributeId: "",
parentClientId: "",
},
] );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ function getStartOffset( node ) {

/**
* Retrieves the parent node for a given node.
* @param {Paper} paper The current paper.
* @param {Node} node The current node.
* @param {Paper} paper The current paper.
* @param {Node} node The current node.
* @returns {Node} The parent node.
*/
function getParentNode( paper, node ) {
return paper.getTree().findAll( treeNode => treeNode.childNodes && treeNode.childNodes.includes( node ) )[ 0 ];
// Includes a fallback so that if a parent node cannot be found for an implicit paragraph, we use the current node as the parent node.
return paper.getTree().findAll( treeNode => treeNode.childNodes && treeNode.childNodes.includes( node ) )[ 0 ] || node;
}

/**
Expand Down Expand Up @@ -45,9 +46,10 @@ export default function( paper ) {
// The block client id of the parent node.
parentClientId: parentNode.clientId || "",
// The attribute id of the parent node, if available, otherwise an empty string.
parentAttributeId: parentNode.attributeId || "",
// Whether the parent node is the first section of Yoast sub-blocks.
isParentFirstSectionOfBlock: parentNode.isFirstSection || false,
// Only used for position-based highlighting in sub-blocks of Yoast blocks.
parentAttributeId: node.attributeId || "",
// Whether the parent node is the first section of Yoast sub-blocks. Only used for position-based highlighting.
isParentFirstSectionOfBlock: node.isFirstSection || false,
};
} ) );
}
6 changes: 3 additions & 3 deletions packages/yoastseo/src/parse/structure/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class Node {
/**
* Finds all nodes in the tree that satisfies the given condition.
*
* @param {function} condition The condition that a node should satisfy to end up in the list.
* @param {boolean} recurseFoundNodes=false Whether to recurse into found nodes
* to see if the condition also applies to sub-nodes of the found node.
* @param {function} condition The condition that a node should satisfy to end up in the list.
* @param {boolean} recurseFoundNodes=false Whether to recurse into found nodes to see if the condition
* also applies to sub-nodes of the found node.
*
* @returns {(Node|Text|Paragraph|Heading)[]} The list of nodes that satisfy the condition.
*/
Expand Down
7 changes: 4 additions & 3 deletions packages/yoastseo/src/parse/traverse/findAllInTree.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Finds all nodes in the tree that satisfies the given condition.
*
* @param {Object} tree The tree.
* @param {function} condition The condition that a node should satisfy to end up in the list.
* @param {boolean} recurseFoundNodes=false Whether to recurse into found nodes to see if the condition also applies to sub-nodes of the found node.
* @param {Object} tree The tree.
* @param {function} condition The condition that a node should satisfy to end up in the list.
* @param {boolean} recurseFoundNodes=false Whether to recurse into found nodes to see if the condition also applies to
* sub-nodes of the found node.
* If false, as soon as a node is found that satisfies the condition, it is added to the list and no further recursion is done through its children.
* If true, the node is added to the list and its children are also checked for the condition.
* If they satisfy the condition, they are also added to the list.
Expand Down
2 changes: 1 addition & 1 deletion wp-seo-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* {@internal Nobody should be able to overrule the real version number as this can cause
* serious issues with the options, so no if ( ! defined() ).}}
*/
define( 'WPSEO_VERSION', '21.4-RC6' );
define( 'WPSEO_VERSION', '21.4-RC7' );


if ( ! defined( 'WPSEO_PATH' ) ) {
Expand Down
2 changes: 1 addition & 1 deletion wp-seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* @wordpress-plugin
* Plugin Name: Yoast SEO
* Version: 21.4-RC6
* Version: 21.4-RC7
* Plugin URI: https://yoa.st/1uj
* Description: The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more.
* Author: Team Yoast
Expand Down

0 comments on commit 24cd586

Please sign in to comment.