PluginProbe
Sharing Image / 3.3
Sharing Image v3.3
3.10 trunk 2.0 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0 3.1 3.2 3.3 All 29 releases
sharing-image / snippets / class-theseoframework.php

class-theseoframework.php in Sharing Image 3.3, at snippets/class-theseoframework.php

92 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The SEO Framework Snippet class.
4 *
5 * @package sharing-image
6 * @author Anton Lukin
7 */
8
9 namespace Sharing_Image\Snippets;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 die;
13 }
14
15 /**
16 * The SEO Framework Snippet class.
17 *
18 * @class RankMath
19 */
20 class TheSEOFramework {
21 /**
22 * Get snippet name.
23 */
24 public static function get_name() {
25 $name = array(
26 'title' => 'The SEO Framework',
27 'link' => 'https://wordpress.org/plugins/autodescription/',
28 );
29
30 return $name;
31 }
32
33 /**
34 * Check if plugin is activated.
35 */
36 public static function is_activated() {
37 if ( defined( 'THE_SEO_FRAMEWORK_VERSION' ) ) {
38 return true;
39 }
40
41 return false;
42 }
43
44 /**
45 * Init snippet filters.
46 */
47 public static function init_filters() {
48 add_filter( 'the_seo_framework_meta_render_data', array( __CLASS__, 'update_render_data' ), 11 );
49 }
50
51 /**
52 * Update rendered meta tags.
53 *
54 * @param array $tags List of rendered tags.
55 */
56 public static function update_render_data( $tags ) {
57 $post_id = the_seo_framework()->query()->get_the_real_id();
58
59 $sharing_image = sharing_image_poster_src( $post_id );
60
61 if ( empty( $sharing_image ) ) {
62 return $tags;
63 }
64
65 foreach ( $tags as $key => &$tag ) {
66 if ( empty( $tag['attributes'] ) ) {
67 continue;
68 }
69
70 $attributes = $tag['attributes'];
71
72 if ( isset( $attributes['property'] ) && 'og:image' === $attributes['property'] ) {
73 unset( $tags[ $key ] );
74 }
75
76 if ( isset( $attributes['property'] ) && 'og:image:width' === $attributes['property'] ) {
77 unset( $tags[ $key ] );
78 }
79
80 if ( isset( $attributes['property'] ) && 'og:image:height' === $attributes['property'] ) {
81 unset( $tags[ $key ] );
82 }
83
84 if ( isset( $attributes['name'] ) && 'twitter:image' === $attributes['name'] ) {
85 unset( $tags[ $key ] );
86 }
87 }
88
89 return $tags;
90 }
91 }
92