PluginProbe
Sharing Image / 3.7
Sharing Image v3.7
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-rankmath.php

class-rankmath.php in Sharing Image 3.7, at snippets/class-rankmath.php

79 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * RankMath 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 * Snippet class.
17 *
18 * @class RankMath
19 */
20 class RankMath {
21 /**
22 * Get snippet name.
23 */
24 public static function get_name() {
25 $name = array(
26 'title' => 'Rank Math SEO',
27 'link' => 'https://wordpress.org/plugins/seo-by-rank-math/',
28 );
29
30 return $name;
31 }
32
33 /**
34 * Check if plugin is activated.
35 */
36 public static function is_activated() {
37 if ( defined( 'RANK_MATH_VERSION' ) ) {
38 return true;
39 }
40
41 return false;
42 }
43
44 /**
45 * Init snippet filters.
46 */
47 public static function init_filters() {
48 foreach ( array( 'facebook', 'twitter' ) as $network ) {
49 add_filter( "rank_math/opengraph/{$network}/image_array", array( __CLASS__, 'update_image_array' ) );
50 }
51
52 add_filter( 'sharing_image_show_header', '__return_false' );
53 }
54
55 /**
56 * Update image array.
57 *
58 * @param array $attachment Image array data.
59 */
60 public static function update_image_array( $attachment ) {
61 $poster = sharing_image_poster_src();
62
63 if ( empty( $poster ) ) {
64 return $attachment;
65 }
66
67 if ( empty( $attachment ) ) {
68 $attachment = array();
69 }
70
71 $attachment['id'] = 0;
72 $attachment['url'] = $poster[0];
73 $attachment['width'] = $poster[1];
74 $attachment['height'] = $poster[2];
75
76 return $attachment;
77 }
78 }
79