PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.2
YayMail – WooCommerce Email Customizer v4.4.2
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / src / Integrations / RankMath.php

RankMath.php in YayMail – WooCommerce Email Customizer 4.4.2, at src/Integrations/RankMath.php

54 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Integrations;
4
5 use YayMail\PostTypes\TemplatePostType;
6 use YayMail\Utils\SingletonTrait;
7
8 /**
9 * RankMath
10 * * @method static RankMath get_instance()
11 */
12 class RankMath {
13 use SingletonTrait;
14
15 protected function __construct() {
16
17 if ( ! class_exists( 'RankMath' ) ) {
18 return;
19 }
20
21 add_filter(
22 'rank_math/sitemap/exclude_post_type',
23 function( $check, $post_type ) {
24 if ( $post_type === TemplatePostType::POST_TYPE ) {
25 return true;
26 }
27 return $check;
28 },
29 10,
30 2
31 );
32
33 // Trick to delete all the duplicate value in the previous version of the plugin
34 add_action( 'init', [ $this, 'init' ], PHP_INT_MAX );
35 }
36
37 public function init() {
38 $titles_settings = get_option( 'rank-math-options-titles', [] );
39 if ( empty( $titles_settings ) ) {
40 return;
41 }
42
43 $title_meta_key = 'pt_' . TemplatePostType::POST_TYPE . '_robots';
44
45 if ( empty( $titles_settings[ $title_meta_key ] ) ) {
46 $titles_settings[ $title_meta_key ] = [];
47 }
48
49 $titles_settings[ $title_meta_key ] = array_unique( $titles_settings[ $title_meta_key ] );
50
51 update_option( 'rank-math-options-titles', $titles_settings );
52 }
53 }
54