| @@ -1,0 +1,97 @@ | ||
| 1 | +<?php | |
| 2 | +/* | |
| 3 | + * License: GPLv3 | |
| 4 | + * License URI: https://www.gnu.org/licenses/gpl.txt | |
| 5 | + * Copyright 2012-2026 Jean-Sebastien Morisset (https://wpsso.com/) | |
| 6 | + */ | |
| 7 | + | |
| 8 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 9 | + | |
| 10 | + die( 'These aren\'t the droids you\'re looking for.' ); | |
| 11 | +} | |
| 12 | + | |
| 13 | +if ( ! defined( 'WPSSO_PLUGINDIR' ) ) { | |
| 14 | + | |
| 15 | + die( 'Do. Or do not. There is no try.' ); | |
| 16 | +} | |
| 17 | + | |
| 18 | +if ( ! class_exists( 'WpssoIntegDataAbstractSeoMeta' ) ) { | |
| 19 | + | |
| 20 | + require_once WPSSO_PLUGINDIR . 'lib/integ/data/abstract/seo-meta.php'; | |
| 21 | +} | |
| 22 | + | |
| 23 | +/* | |
| 24 | + * Import Rank Math SEO metadata. | |
| 25 | + */ | |
| 26 | +if ( ! class_exists( 'WpssoIntegDataRankmathMeta' ) ) { | |
| 27 | + | |
| 28 | + class WpssoIntegDataRankmathMeta extends WpssoIntegDataAbstractSeoMeta { | |
| 29 | + | |
| 30 | + protected $plugin_avail_key = 'rankmath'; | |
| 31 | + | |
| 32 | + protected $opt_meta_keys = array( | |
| 33 | + 'post' => array( | |
| 34 | + 'primary_term_id' => 'rank_math_primary_category', | |
| 35 | + 'seo_title' => 'rank_math_title', | |
| 36 | + 'seo_desc' => 'rank_math_description', | |
| 37 | + 'og_title' => 'rank_math_facebook_title', | |
| 38 | + 'og_desc' => 'rank_math_facebook_description', | |
| 39 | + 'og_img_id' => 'rank_math_facebook_image_id', | |
| 40 | + 'og_img_url' => 'rank_math_facebook_image', | |
| 41 | + 'schema_title' => 'rank_math_snippet_title', | |
| 42 | + 'schema_desc' => 'rank_math_snippet_desc', | |
| 43 | + 'tc_title' => 'rank_math_twitter_title', | |
| 44 | + 'tc_desc' => 'rank_math_twitter_description', | |
| 45 | + 'tc_sum_img_id' => 'rank_math_twitter_image_id', | |
| 46 | + 'tc_sum_img_url' => 'rank_math_twitter_image', | |
| 47 | + 'tc_lrg_img_id' => 'rank_math_twitter_image_id', | |
| 48 | + 'tc_lrg_img_url' => 'rank_math_twitter_image', | |
| 49 | + 'canonical_url' => 'rank_math_canonical_url', | |
| 50 | + ), | |
| 51 | + 'term' => array( | |
| 52 | + 'og_title' => 'rank_math_facebook_title', | |
| 53 | + 'og_desc' => 'rank_math_facebook_description', | |
| 54 | + 'og_img_id' => 'rank_math_facebook_image_id', | |
| 55 | + 'og_img_url' => 'rank_math_facebook_image', | |
| 56 | + 'seo_desc' => 'rank_math_description', | |
| 57 | + 'schema_title' => 'rank_math_snippet_title', | |
| 58 | + 'schema_desc' => 'rank_math_snippet_desc', | |
| 59 | + 'tc_title' => 'rank_math_twitter_title', | |
| 60 | + 'tc_desc' => 'rank_math_twitter_description', | |
| 61 | + 'tc_sum_img_id' => 'rank_math_twitter_image_id', | |
| 62 | + 'tc_sum_img_url' => 'rank_math_twitter_image', | |
| 63 | + 'tc_lrg_img_id' => 'rank_math_twitter_image_id', | |
| 64 | + 'tc_lrg_img_url' => 'rank_math_twitter_image', | |
| 65 | + 'canonical_url' => 'rank_math_canonical_url', | |
| 66 | + ), | |
| 67 | + 'user' => array( | |
| 68 | + 'og_title' => 'rank_math_facebook_title', | |
| 69 | + 'og_desc' => 'rank_math_facebook_description', | |
| 70 | + 'og_img_id' => 'rank_math_facebook_image_id', | |
| 71 | + 'og_img_url' => 'rank_math_facebook_image', | |
| 72 | + 'seo_desc' => 'rank_math_description', | |
| 73 | + 'schema_title' => 'rank_math_snippet_title', | |
| 74 | + 'schema_desc' => 'rank_math_snippet_desc', | |
| 75 | + 'tc_title' => 'rank_math_twitter_title', | |
| 76 | + 'tc_desc' => 'rank_math_twitter_description', | |
| 77 | + 'tc_sum_img_id' => 'rank_math_twitter_image_id', | |
| 78 | + 'tc_sum_img_url' => 'rank_math_twitter_image', | |
| 79 | + 'tc_lrg_img_id' => 'rank_math_twitter_image_id', | |
| 80 | + 'tc_lrg_img_url' => 'rank_math_twitter_image', | |
| 81 | + 'canonical_url' => 'rank_math_canonical_url', | |
| 82 | + ), | |
| 83 | + ); | |
| 84 | + | |
| 85 | + protected function maybe_convert_vars( $value, array $mod ) { | |
| 86 | + | |
| 87 | + if ( false !== strpos( $value, '%' ) ) { | |
| 88 | + | |
| 89 | + $value = preg_replace( '/%+([^%]+)%+/', '%%$1%%', $value ); // Convert inline variable names. | |
| 90 | + | |
| 91 | + $value = $this->p->util->inline->replace_variables( $value, $mod ); | |
| 92 | + } | |
| 93 | + | |
| 94 | + return $value; | |
| 95 | + } | |
| 96 | + } | |
| 97 | +} | |