| 1 |
<?php |
| 2 |
|
| 3 |
class Polylang_Plugins_Compat { |
| 4 |
function __construct() { |
| 5 |
global $polylang; |
| 6 |
|
| 7 |
// YARPP |
| 8 |
// just makes YARPP aware of the language taxonomy (after Polylang registered it) |
| 9 |
add_action('init', create_function('',"\$GLOBALS['wp_taxonomies']['language']->yarpp_support = 1;"), 20); |
| 10 |
|
| 11 |
// WordPress SEO by Yoast |
| 12 |
add_filter('override_load_textdomain', array(&$this, 'wpseo_override_load_textdomain'), 10, 2); |
| 13 |
add_filter('get_terms_args', array(&$this, 'wpseo_remove_terms_filter')); |
| 14 |
add_filter('pll_home_url_white_list', create_function('$arr', "return array_merge(\$arr, array(array('file' => 'wordpress-seo')));")); |
| 15 |
|
| 16 |
// Custom field template |
| 17 |
add_action('dbx_post_advanced', array(&$this, 'cft_copy')); |
| 18 |
|
| 19 |
// Jetpack infinite scroll |
| 20 |
add_filter('pre_get_posts', array(&$this, 'jetpack_infinite_scroll')); |
| 21 |
|
| 22 |
// Aqua Resizer |
| 23 |
add_filter('pll_home_url_black_list', create_function('$arr', "return array_merge(\$arr, array(array('function' => 'aq_resize')));")); |
| 24 |
} |
| 25 |
|
| 26 |
// Unfortunately WPSEO loads the text domain before Polylang is able to modify the locale |
| 27 |
// this hack works because Polylang is loaded before WPSEO... |
| 28 |
function wpseo_override_load_textdomain( $return, $domain ) { |
| 29 |
if ($domain == 'wordpress-seo' && !did_action('plugins_loaded')) { |
| 30 |
add_filter('plugins_loaded', create_function('', "load_plugin_textdomain('wordpress-seo', false, dirname(WPSEO_BASENAME).'/languages');")); |
| 31 |
return true; |
| 32 |
} |
| 33 |
return $return; |
| 34 |
} |
| 35 |
|
| 36 |
// removes the language filter for the taxonomy sitemaps |
| 37 |
function wpseo_remove_terms_filter($args) { |
| 38 |
if (defined('WPSEO_VERSION') && isset($GLOBALS['wp_query']->query['sitemap'])) |
| 39 |
$args['lang'] = 0; |
| 40 |
return $args; |
| 41 |
} |
| 42 |
|
| 43 |
// Custom field template does check $_REQUEST['post'] to populate the custom fields values |
| 44 |
function cft_copy() { |
| 45 |
global $post, $custom_field_template; |
| 46 |
if (isset($custom_field_template, $_REQUEST['from_post'], $_REQUEST['new_lang']) && !empty($post)) |
| 47 |
$_REQUEST['post'] = $post->ID; |
| 48 |
} |
| 49 |
|
| 50 |
// Currently it is not possible to set the language in ajax url so let's use our cookie |
| 51 |
function jetpack_infinite_scroll($query) { |
| 52 |
if (isset($_GET['infinity'], $_GET['page'])) { |
| 53 |
$query->set('lang', $GLOBALS['polylang']->get_preferred_language()->slug); |
| 54 |
if (empty($qv['post_type']) && !$query->is_search) |
| 55 |
$query->set('post_type', 'post'); |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
new Polylang_Plugins_Compat(); |
| 61 |
|