PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.0.22
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.0.22
4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 All 169 releases
searchpro / inc / thirdparty / plugin / TranslatePress.php

TranslatePress.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.0.22, at inc/thirdparty/plugin/TranslatePress.php

30 lines 1008 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4
5 class berqTranslatePress extends berqIntegrations {
6 function __construct() {
7 add_filter( 'berqwp_page_translation_urls', [$this, 'get_page_translations'], 10, 2 );
8 }
9
10 function get_page_translations($translated_urls, $post_url) {
11 if (class_exists('TRP_Translate_Press')) {
12 $trp = TRP_Translate_Press::get_trp_instance();
13 $trp_settings = $trp->get_component( 'settings' );
14 $settings = $trp_settings->get_settings();
15 $url_converter = $trp->get_component( 'url_converter' );
16
17 // iterating over active TranslatePress languages
18 foreach ( $settings['publish-languages'] as $language ) {
19 // generate translated url for a particular language
20 $translated_urls[] = esc_url( $url_converter->get_url_for_language( $language, $post_url ) );
21 }
22 }
23
24 return $translated_urls;
25 }
26
27
28 }
29
30 new berqTranslatePress();