Skip to content

Commit

Permalink
Merge pull request #1956 from Codeinwp/fix/mathrank
Browse files Browse the repository at this point in the history
Prevent rank math filter to erase previous content
  • Loading branch information
HardeepAsrani authored Nov 3, 2023
2 parents b0b53b2 + 0171f32 commit 49c6f34
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/blocks/blocks/posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,14 @@ domReady( () => {
let maxTries = 10;

const init = () => {
window.wp.hooks.addFilter( 'rank_math_content', 'rank-math', () => {

window.wp.hooks.addFilter( 'rank_math_content', 'rank-math', ( content ) => {

/**
* @type {NodeListOf<HTMLDivElement>} postsHtml - The HTML nodes which contain the relevent post content for RankMath.
*/
const postsHtml = document.querySelectorAll( '.o-posts-grid-post-body' );
return Array.from( postsHtml ).map( ( post ) => post.innerHTML ).join( '' );
return ( content ?? '' ) + ( Array.from( postsHtml )?.map( ( post ) => post.innerHTML )?.join( '' ) ?? '' );
});

window?.rankMathEditor?.refresh( 'content' );
Expand Down

0 comments on commit 49c6f34

Please sign in to comment.