PluginProbe
Themify Builder / 7.7.0
Themify Builder v7.7.0
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / includes / plugin-compat / rankmath.php

rankmath.php in Themify Builder 7.7.0, at includes/plugin-compat/rankmath.php

49 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Builder Plugin Compatibility Code
4 *
5 * @package Themify_Builder
6 * @subpackage Themify_Builder/classes
7 */
8
9 class Themify_Builder_Plugin_Compat_RankMath {
10
11 static function init() {
12 if(is_admin()){
13 add_filter( 'rank_math/video/content', [ __CLASS__, 'scan_builder_content' ], 10, 2 );
14 add_filter( 'rank_math/links/content', [ __CLASS__, 'scan_builder_content' ], 10, 2 );
15 add_filter( 'rank_math/metabox/values', [ __CLASS__, 'has_toc_filter' ] );
16 }
17 add_filter( 'rank_math/sitemap/content_before_parse_html_images', array( __CLASS__, 'sitemap' ), 10, 2 );
18 }
19
20 /**
21 * Themify Builder has built-in Table of Content support, let RankMath know
22 */
23 public static function has_toc_filter(array $values ):array {
24 $values['assessor']['hasTOCPlugin'] = true;
25
26 return $values;
27 }
28
29 /**
30 * Fix the image counter in Rank Math site map.
31 *
32 * Append a plain text version of Builder output, before Rank Math
33 * searches for images in the post content.
34 */
35 public static function sitemap(string $content,int $post_id ):string {
36 $builder_data = ThemifyBuilder_Data_Manager::get_data( $post_id );
37 $plain_text = ThemifyBuilder_Data_Manager::_get_all_builder_text_content( $builder_data );
38 $plain_text = do_shortcode( $plain_text ); // render shortcodes that might be in the Themify_Builder_Component_Module::get_plain_text()
39
40 return $content . $plain_text;
41 }
42
43 /**
44 * Enable RankMath to scan Builder's contents
45 */
46 public static function scan_builder_content(string $content, int $object_id ):string {
47 return $content . ' ' . Themify_Builder::render( $object_id );
48 }
49 }