/var/www/html_it/wp-content/plugins/yaymail/src/Integrations/RankMath.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php

namespace YayMail\Integrations;

use 
YayMail\PostTypes\TemplatePostType;
use 
YayMail\Utils\SingletonTrait;

/**
 * RankMath
 * * @method static RankMath get_instance()
 */
class RankMath {
    use 
SingletonTrait;

    protected function 
__construct() {

        if ( ! 
class_exists'RankMath' ) ) {
            return;
        }

        
add_filter(
            
'rank_math/sitemap/exclude_post_type',
            function( 
$check$post_type ) {
                if ( 
$post_type === TemplatePostType::POST_TYPE ) {
                    return 
true;
                }
                return 
$check;
            },
            
10,
            
2
        
);

        
// Trick to delete all the duplicate value in the previous version of the plugin
        
add_action'init', [ $this'init' ], PHP_INT_MAX );
    }

    public function 
init() {
        
$titles_settings get_option'rank-math-options-titles', [] );
        if ( empty( 
$titles_settings ) ) {
            return;
        }

        
$title_meta_key 'pt_' TemplatePostType::POST_TYPE '_robots';

        if ( empty( 
$titles_settings$title_meta_key ] ) ) {
            
$titles_settings$title_meta_key ] = [];
        }

        
$titles_settings$title_meta_key ] = array_unique$titles_settings$title_meta_key ] );

        
update_option'rank-math-options-titles'$titles_settings );
    }
}