# sharing-image/3.3/snippets/class-rankmath.php

Sharing Image, version 3.3. 79 lines.

- Page: https://pluginprobe.com/plugins/sharing-image/3.3/code/snippets/class-rankmath.php
- Raw: https://pluginprobe.com/plugins/sharing-image/3.3/raw/snippets/class-rankmath.php
- Modified: 2024-06-26T16:46:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/sharing-image/3.3/code/snippets/class-rankmath.php#L10-L20`.

```php
<?php
/**
 * RankMath Snippet class.
 *
 * @package sharing-image
 * @author  Anton Lukin
 */

namespace Sharing_Image\Snippets;

if ( ! defined( 'ABSPATH' ) ) {
	die;
}

/**
 * Snippet class.
 *
 * @class RankMath
 */
class RankMath {
	/**
	 * Get snippet name.
	 */
	public static function get_name() {
		$name = array(
			'title' => 'Rank Math SEO',
			'link'  => 'https://wordpress.org/plugins/seo-by-rank-math/',
		);

		return $name;
	}

	/**
	 * Check if plugin is activated.
	 */
	public static function is_activated() {
		if ( defined( 'RANK_MATH_VERSION' ) ) {
			return true;
		}

		return false;
	}

	/**
	 * Init snippet filters.
	 */
	public static function init_filters() {
		foreach ( array( 'facebook', 'twitter' ) as $network ) {
			add_filter( "rank_math/opengraph/{$network}/image_array", array( __CLASS__, 'update_image_array' ) );
		}

		add_filter( 'sharing_image_show_header', '__return_false' );
	}

	/**
	 * Update image array.
	 *
	 * @param array $attachment Image array data.
	 */
	public static function update_image_array( $attachment ) {
		$poster = sharing_image_poster_src();

		if ( empty( $poster ) ) {
			return $attachment;
		}

		if ( empty( $attachment ) ) {
			$attachment = array();
		}

		$attachment['id']     = 0;
		$attachment['url']    = $poster[0];
		$attachment['width']  = $poster[1];
		$attachment['height'] = $poster[2];

		return $attachment;
	}
}

```
