From 53b688faa1a39ef364bf6cfd88471ea3425e22a0 Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Thu, 24 Jan 2019 15:12:44 +0200 Subject: [PATCH] - Transposh integration; --- includes/core/class-external-integrations.php | 16 ++++++++++------ readme.txt | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/core/class-external-integrations.php b/includes/core/class-external-integrations.php index db8b8b40..a46174bb 100644 --- a/includes/core/class-external-integrations.php +++ b/includes/core/class-external-integrations.php @@ -83,7 +83,7 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) { * @see http://transposh.org/ * * @global transposh_plugin $my_transposh_plugin - * @global WP_Query $wp_query Global WP_Query instance. + * @global \WP_Query $wp_query Global WP_Query instance. */ public function transposh_user_profile() { global $my_transposh_plugin, $wp_query; @@ -92,21 +92,25 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) { return; } - if ( !$wp_query->is_404() ) { + if ( ! $wp_query->is_404() ) { return; } $profile_id = UM()->options()->get( 'core_user' ); $post = get_post( $profile_id ); - if ( stripos( $_SERVER['REQUEST_URI'], "$my_transposh_plugin->target_language/$post->post_name" ) !== false ) { - preg_match( "#/$post->post_name/([^\/\?$]+)#", $_SERVER['REQUEST_URI'], $maches ); + if ( empty( $post ) || is_wp_error( $post ) ) { + return; + } - if ( isset( $maches[1] ) ) { + if ( ! empty( $_SERVER['REQUEST_URI'] ) && stripos( $_SERVER['REQUEST_URI'], "$my_transposh_plugin->target_language/$post->post_name" ) !== false ) { + preg_match( "#/$post->post_name/([^\/\?$]+)#", $_SERVER['REQUEST_URI'], $matches ); + + if ( isset( $matches[1] ) ) { query_posts( array( 'page_id' => $post->ID ) ); - set_query_var( 'um_user', $maches[1] ); + set_query_var( 'um_user', $matches[1] ); wp_reset_postdata(); } } diff --git a/readme.txt b/readme.txt index 8e6e6798..5408e795 100644 --- a/readme.txt +++ b/readme.txt @@ -137,6 +137,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat * Enhancements: - Restored option for disable users cache + - Transposh plugin integration * Bugfixes: - Fixed delete users handlers on single/multisite installs