From ef653c29d367228d9b4acde2f307a3756a7c79ad Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 14 Nov 2017 12:36:44 +0200 Subject: [PATCH] - small notices fixes; - fixed issue #344; --- includes/admin/core/class-admin-metabox.php | 17 +++++----- includes/admin/core/class-admin-settings.php | 2 +- includes/um-short-functions.php | 33 +++++++++++++++++--- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index 1a5c5f7a..5b99941a 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -1962,20 +1962,17 @@ if ( ! class_exists( 'Admin_Metabox' ) ) { case '_parent_dropdown_relationship': ?> -

+

diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 44676b87..0ba5b526 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -1404,7 +1404,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) { $filtered_settings[$key] = $value; foreach( $fields as $field ) { - if ( $field['id'] == $key && $field['type'] == 'multi_text' ) { + if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) { $filtered_settings[$key] = array_filter( $settings[$key] ); } } diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 85b25b21..28987c4a 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -585,14 +585,21 @@ return false; } - /*** - *** @Get a translated core page URL - ***/ + + /** + * Get a translated core page URL + * + * @param $post_id + * @param $language + * @return bool|false|string + */ function um_get_url_for_language( $post_id, $language ) { + if ( ! um_is_wpml_active() ) + return ''; + $lang_post_id = icl_object_id( $post_id, 'page', true, $language ); - $url = ""; - if ($lang_post_id != 0) { + if ( $lang_post_id != 0 ) { $url = get_permalink( $lang_post_id ); } else { // No page found, it's most likely the homepage @@ -603,6 +610,22 @@ return $url; } + + /** + * Check if WPML is active + * + * @return bool|mixed + */ + function um_is_wpml_active() { + if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { + global $sitepress; + + return $sitepress->get_setting( 'setup_complete' ); + } + + return false; + } + /*** *** @Get core page url ***/