js
3 years ago
acf-widgets.php
2 years ago
amp.php
5 years ago
gravity-forms.php
3 years ago
jetpack.php
3 years ago
layout-block.php
2 years ago
lazy-load-backgrounds.php
3 years ago
polylang.php
3 years ago
rank-math.php
3 years ago
widget-options.php
3 years ago
yoast.php
3 years ago
yoast.php
90 lines
| 1 | <?php |
| 2 | |
| 3 | if ( |
| 4 | class_exists( 'WPSEO_Options' ) && |
| 5 | method_exists( 'WPSEO_Options', 'get' ) && |
| 6 | WPSEO_Options::get( 'opengraph' ) |
| 7 | ) { |
| 8 | /** |
| 9 | * If Yoast OpenGraph is enabled, we'll need disable PB when it gets the excerpt |
| 10 | * to avoid conflicts with other plugins. |
| 11 | */ |
| 12 | function siteorigin_yoast_opengraph_panels_disable( $content ) { |
| 13 | global $wp_current_filter; |
| 14 | |
| 15 | if ( count( $wp_current_filter ) > 2 && $wp_current_filter[1] == 'wpseo_head' ) { |
| 16 | // Temporarily disable Page Builder for this instance of the_content. |
| 17 | add_filter( 'siteorigin_panels_filter_content_enabled', '__return_false' ); |
| 18 | } else { |
| 19 | add_filter( 'siteorigin_panels_filter_content_enabled', '__return_true' ); |
| 20 | } |
| 21 | |
| 22 | return $content; |
| 23 | } |
| 24 | |
| 25 | // If Yoast OpenGraph is enabled, disable Page Builder as needed. |
| 26 | add_filter( 'the_content', 'siteorigin_yoast_opengraph_panels_disable', 1 ); |
| 27 | } |
| 28 | |
| 29 | if ( defined( 'WPSEO_FILE' ) ) { |
| 30 | /** |
| 31 | * Returns a list of all images added using Page Builder to allow for their inclusion in the Yoast Sitemap. |
| 32 | * |
| 33 | * @param $images an array of all detected images used in the current post. |
| 34 | * @param $post_id the current post id. |
| 35 | * |
| 36 | * @return array |
| 37 | */ |
| 38 | function siteorigin_yoast_sitemap_images_compat( $images, $post_id ) { |
| 39 | if ( |
| 40 | get_post_meta( $post_id, 'panels_data', true ) && |
| 41 | extension_loaded( 'xml' ) && |
| 42 | class_exists( 'DOMDocument' ) |
| 43 | ) { |
| 44 | $content = SiteOrigin_Panels::renderer()->render( |
| 45 | $post_id, |
| 46 | false |
| 47 | ); |
| 48 | |
| 49 | libxml_use_internal_errors( true ); |
| 50 | $dom = new DOMDocument(); |
| 51 | $dom->loadHTML( '<?xml encoding="UTF-8">' . $content ); |
| 52 | libxml_clear_errors(); |
| 53 | |
| 54 | foreach ( $dom->getElementsByTagName( 'img' ) as $img ) { |
| 55 | $src = $img->getAttribute( 'src' ); |
| 56 | |
| 57 | if ( ! empty( $src ) && $src == esc_url( $src ) ) { |
| 58 | $images[] = array( |
| 59 | 'src' => $src, |
| 60 | ); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return $images; |
| 66 | } |
| 67 | |
| 68 | add_filter( 'wpseo_sitemap_urlimages', 'siteorigin_yoast_sitemap_images_compat', 10, 2 ); |
| 69 | } |
| 70 | |
| 71 | if ( function_exists( 'yoast_wpseo_video_seo_init' ) ) { |
| 72 | /** |
| 73 | * If the Yoast SEO: Video plugin is trying to index a post, and the post has a page builder layout, render it using Page Builder. |
| 74 | * |
| 75 | * @param $content The content to analyze. |
| 76 | * @param $vid Array with video info, usually empty. |
| 77 | * @param $post Post object. |
| 78 | * |
| 79 | * @return string |
| 80 | */ |
| 81 | function siteorigin_yoast_video_render_page_builder( $content, $vid, $post ) { |
| 82 | if ( ! empty( $_POST['panels_data'] ) ) { |
| 83 | $content = SiteOrigin_Panels::renderer()->render( $post->ID ); |
| 84 | } |
| 85 | |
| 86 | return $content; |
| 87 | } |
| 88 | add_filter( 'wpseo_video_index_content', 'siteorigin_yoast_video_render_page_builder', 10, 3 ); |
| 89 | } |
| 90 |