| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Exposes shortlinks in a global, so that we can pass them to our Javascript components. |
| 10 |
*/ |
| 11 |
class WPSEO_Expose_Shortlinks implements WPSEO_WordPress_Integration { |
| 12 |
|
| 13 |
/** |
| 14 |
* Array containing the keys and shortlinks. |
| 15 |
* |
| 16 |
* @var array |
| 17 |
*/ |
| 18 |
private $shortlinks = [ |
| 19 |
'shortlinks.advanced.allow_search_engines' => 'https://yoa.st/allow-search-engines', |
| 20 |
'shortlinks.advanced.follow_links' => 'https://yoa.st/follow-links', |
| 21 |
'shortlinks.advanced.meta_robots' => 'https://yoa.st/meta-robots-advanced', |
| 22 |
'shortlinks.advanced.breadcrumbs_title' => 'https://yoa.st/breadcrumbs-title', |
| 23 |
'shortlinks.metabox.schema.explanation' => 'https://yoa.st/400', |
| 24 |
'shortlinks.metabox.schema.page_type' => 'https://yoa.st/402', |
| 25 |
'shortlinks.sidebar.schema.explanation' => 'https://yoa.st/401', |
| 26 |
'shortlinks.sidebar.schema.page_type' => 'https://yoa.st/403', |
| 27 |
'shortlinks.focus_keyword_info' => 'https://yoa.st/focus-keyword', |
| 28 |
'shortlinks.nofollow_sponsored' => 'https://yoa.st/nofollow-sponsored', |
| 29 |
'shortlinks.snippet_preview_info' => 'https://yoa.st/snippet-preview', |
| 30 |
'shortlinks.cornerstone_content_info' => 'https://yoa.st/1i9', |
| 31 |
'shortlinks.upsell.social_previews' => 'https://yoa.st/social-preview-cta', |
| 32 |
'shortlinks.upsell.sidebar.focus_keyword_synonyms_link' => 'https://yoa.st/textlink-synonyms-popup-sidebar', |
| 33 |
'shortlinks.upsell.sidebar.focus_keyword_synonyms_button' => 'https://yoa.st/keyword-synonyms-popup-sidebar', |
| 34 |
'shortlinks.upsell.sidebar.focus_keyword_additional_link' => 'https://yoa.st/textlink-keywords-popup-sidebar', |
| 35 |
'shortlinks.upsell.sidebar.focus_keyword_additional_button' => 'https://yoa.st/add-keywords-popup-sidebar', |
| 36 |
'shortlinks.upsell.sidebar.additional_link' => 'https://yoa.st/textlink-keywords-sidebar', |
| 37 |
'shortlinks.upsell.sidebar.additional_button' => 'https://yoa.st/add-keywords-sidebar', |
| 38 |
'shortlinks.upsell.metabox.go_premium' => 'https://yoa.st/pe-premium-page', |
| 39 |
'shortlinks.upsell.metabox.focus_keyword_synonyms_link' => 'https://yoa.st/textlink-synonyms-popup-metabox', |
| 40 |
'shortlinks.upsell.metabox.focus_keyword_synonyms_button' => 'https://yoa.st/keyword-synonyms-popup', |
| 41 |
'shortlinks.upsell.metabox.focus_keyword_additional_link' => 'https://yoa.st/textlink-keywords-popup-metabox', |
| 42 |
'shortlinks.upsell.metabox.focus_keyword_additional_button' => 'https://yoa.st/add-keywords-popup', |
| 43 |
'shortlinks.upsell.metabox.additional_link' => 'https://yoa.st/textlink-keywords-metabox', |
| 44 |
'shortlinks.upsell.metabox.additional_button' => 'https://yoa.st/add-keywords-metabox', |
| 45 |
'shortlinks.upsell.gsc.create_redirect_button' => 'https://yoa.st/redirects', |
| 46 |
'shortlinks.readability_analysis_info' => 'https://yoa.st/readability-analysis', |
| 47 |
'shortlinks.activate_premium_info' => 'https://yoa.st/activate-subscription', |
| 48 |
'shortlinks.upsell.sidebar.morphology_upsell_metabox' => 'https://yoa.st/morphology-upsell-metabox', |
| 49 |
'shortlinks.upsell.sidebar.morphology_upsell_sidebar' => 'https://yoa.st/morphology-upsell-sidebar', |
| 50 |
'shortlinks.semrush.volume_help' => 'https://yoa.st/3-v', |
| 51 |
'shortlinks.semrush.trend_help' => 'https://yoa.st/3-v', |
| 52 |
'shortlinks.semrush.prices' => 'https://yoa.st/semrush-prices', |
| 53 |
'shortlinks.semrush.premium_landing_page' => 'https://yoa.st/413', |
| 54 |
'shortlinks.wincher.seo_performance' => 'https://yoa.st/wincher-integration', |
| 55 |
]; |
| 56 |
|
| 57 |
/** |
| 58 |
* Registers all hooks to WordPress. |
| 59 |
* |
| 60 |
* @return void |
| 61 |
*/ |
| 62 |
public function register_hooks() { |
| 63 |
add_filter( 'wpseo_admin_l10n', [ $this, 'expose_shortlinks' ] ); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Adds shortlinks to the passed array. |
| 68 |
* |
| 69 |
* @param array $input The array to add shortlinks to. |
| 70 |
* |
| 71 |
* @return array The passed array with the additional shortlinks. |
| 72 |
*/ |
| 73 |
public function expose_shortlinks( $input ) { |
| 74 |
foreach ( $this->get_shortlinks() as $key => $shortlink ) { |
| 75 |
$input[ $key ] = WPSEO_Shortlinker::get( $shortlink ); |
| 76 |
} |
| 77 |
|
| 78 |
$input['default_query_params'] = WPSEO_Shortlinker::get_query_params(); |
| 79 |
|
| 80 |
return $input; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Retrieves the shortlinks. |
| 85 |
* |
| 86 |
* @return array The shortlinks. |
| 87 |
*/ |
| 88 |
private function get_shortlinks() { |
| 89 |
if ( ! $this->is_term_edit() ) { |
| 90 |
return $this->shortlinks; |
| 91 |
} |
| 92 |
|
| 93 |
$shortlinks = $this->shortlinks; |
| 94 |
|
| 95 |
$shortlinks['shortlinks.upsell.metabox.focus_keyword_synonyms_link'] = 'https://yoa.st/textlink-synonyms-popup-metabox-term'; |
| 96 |
$shortlinks['shortlinks.upsell.metabox.focus_keyword_synonyms_button'] = 'https://yoa.st/keyword-synonyms-popup-term'; |
| 97 |
$shortlinks['shortlinks.upsell.metabox.focus_keyword_additional_link'] = 'https://yoa.st/textlink-keywords-popup-metabox-term'; |
| 98 |
$shortlinks['shortlinks.upsell.metabox.focus_keyword_additional_button'] = 'https://yoa.st/add-keywords-popup-term'; |
| 99 |
$shortlinks['shortlinks.upsell.metabox.additional_link'] = 'https://yoa.st/textlink-keywords-metabox-term'; |
| 100 |
$shortlinks['shortlinks.upsell.metabox.additional_button'] = 'https://yoa.st/add-keywords-metabox-term'; |
| 101 |
$shortlinks['shortlinks.upsell.sidebar.morphology_upsell_metabox'] = 'https://yoa.st/morphology-upsell-metabox-term'; |
| 102 |
|
| 103 |
return $shortlinks; |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* Checks if the current page is a term edit page. |
| 108 |
* |
| 109 |
* @return bool True when page is term edit. |
| 110 |
*/ |
| 111 |
private function is_term_edit() { |
| 112 |
global $pagenow; |
| 113 |
|
| 114 |
return WPSEO_Taxonomy::is_term_edit( $pagenow ); |
| 115 |
} |
| 116 |
} |
| 117 |
|