PluginProbe
Polylang / 1.3
Polylang v1.3
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / include / plugins-compat.php

plugins-compat.php in Polylang 1.3, at include/plugins-compat.php

108 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * manages compatibility with 3rd party plugins
5 * this class is available as soon as the plugin is loaded
6 *
7 * @since 1.0
8 */
9 class PLL_Plugins_Compat {
10
11 /*
12 * constructor
13 *
14 * @since 1.0
15 */
16 public function __construct() {
17 // WordPress Importer
18 add_action('init', array(&$this, 'maybe_wordpress_importer'));
19
20 // YARPP
21 // just makes YARPP aware of the language taxonomy (after Polylang registered it)
22 add_action('init', create_function('',"\$GLOBALS['wp_taxonomies']['language']->yarpp_support = 1;"), 20);
23
24 // WordPress SEO by Yoast
25 add_action('pll_language_defined', array(&$this, 'wpseo_translate_options'));
26 add_filter('get_terms_args', array(&$this, 'wpseo_remove_terms_filter'));
27 add_filter('pll_home_url_white_list', create_function('$arr', "return array_merge(\$arr, array(array('file' => 'wordpress-seo')));"));
28
29 // Custom field template
30 add_action('add_meta_boxes', array(&$this, 'cft_copy'), 10, 2);
31
32 // Aqua Resizer
33 add_filter('pll_home_url_black_list', create_function('$arr', "return array_merge(\$arr, array(array('function' => 'aq_resize')));"));
34 }
35
36 /*
37 * WordPress Importer
38 * if WordPress Importer is active, replace the wordpress_importer_init function
39 *
40 * @since 1.2
41 */
42 function maybe_wordpress_importer() {
43 if (class_exists('WP_Import')) {
44 remove_action('admin_init', 'wordpress_importer_init');
45 add_action('admin_init', array(&$this, 'wordpress_importer_init'));
46 }
47 }
48
49 /*
50 * WordPress Importer
51 * loads our child class PLL_WP_Import instead of WP_Import
52 *
53 * @since 1.2
54 */
55 function wordpress_importer_init() {
56 $class = new ReflectionClass('WP_Import');
57 load_plugin_textdomain( 'wordpress-importer', false, basename(dirname( $class->getFileName() )) . '/languages' );
58
59 $GLOBALS['wp_import'] = new PLL_WP_Import();
60 register_importer( 'wordpress', 'WordPress', __('Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'wordpress-importer'), array( $GLOBALS['wp_import'], 'dispatch' ) );
61 }
62
63 /*
64 * WordPress SEO by Yoast
65 * reloads options once the language has been defined to enable translations
66 * useful only when the language is set from content
67 *
68 * @since 1.2
69 *
70 */
71 public function wpseo_translate_options() {
72 if (defined('WPSEO_VERSION') && !PLL_ADMIN && did_action('wp_loaded')) {
73 global $wpseo_front;
74 foreach ( get_wpseo_options_arr() as $opt )
75 $wpseo_front->options = array_merge( $wpseo_front->options, (array) get_option( $opt ) );
76 }
77 }
78
79 /*
80 * WordPress SEO by Yoast
81 * removes the language filter for the taxonomy sitemaps
82 *
83 * @since 1.0.3
84 *
85 * @param array $args get_terms arguments
86 * @return array modified list of arguments
87 */
88 public function wpseo_remove_terms_filter($args) {
89 if (defined('WPSEO_VERSION') && isset($GLOBALS['wp_query']->query['sitemap']))
90 $args['lang'] = 0;
91 return $args;
92 }
93
94 /*
95 * Custom field template does check $_REQUEST['post'] to populate the custom fields values
96 *
97 * @since 1.0.2
98 *
99 * @param string $post_type unused
100 * @param object $post current post object
101 */
102 public function cft_copy($post_type, $post) {
103 global $custom_field_template;
104 if (isset($custom_field_template, $_REQUEST['from_post'], $_REQUEST['new_lang']) && !empty($post))
105 $_REQUEST['post'] = $post->ID;
106 }
107 }
108