Skip to content

Commit

Permalink
feat: add RankMath for Posts block
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Sep 20, 2023
1 parent 3f486b1 commit 50ba79e
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 136 deletions.
12 changes: 12 additions & 0 deletions inc/render/class-posts-grid-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ class Posts_Grid_Block {
* @return mixed|string
*/
public function render( $attributes ) {

if ( ! empty( $attributes['enableRankMathContentAnalysis'] ) ) {

// Load script for rank math integration.
$asset_file = include OTTER_BLOCKS_PATH . '/build/blocks/rank-math-content.asset.php';
$asset_file['dependencies'][] = 'wp-hooks';
$asset_file['dependencies'][] = 'rank-math-analyzer';
wp_enqueue_script( 'otter-rank-math-integration', OTTER_BLOCKS_URL . 'build/blocks/rank-math-content.js', $asset_file['dependencies'], $asset_file['version'], true );
wp_script_add_data( 'otter-rank-math-integration', 'defer', true );
}


$categories = 0;

if ( isset( $attributes['categories'] ) ) {
Expand Down
4 changes: 4 additions & 0 deletions src/blocks/blocks/posts/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@
},
"featuredPostOrder": {
"type": "string"
},
"enableRankMathContentAnalysis": {
"type": "boolean",
"default": false
}
},
"supports": {
Expand Down
Loading

0 comments on commit 50ba79e

Please sign in to comment.