From 819d5333db8613ca15bcbc032eba3942043019a5 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 15 Nov 2018 18:53:59 +0200 Subject: [PATCH] - notices texts changes; - remove language notice; - fixed duplicated "redirect_to" field; - added compatibility with PHP7.2 (removed deprecated functions and ini variables); --- includes/admin/class-admin.php | 36 --------- includes/admin/core/class-admin-menu.php | 74 ------------------- includes/admin/core/class-admin-notices.php | 40 ---------- includes/admin/core/class-admin-settings.php | 31 +++++--- includes/admin/core/class-admin-upgrade.php | 30 -------- .../templates/dashboard/language-download.php | 9 --- .../templates/dashboard/language-update.php | 9 --- includes/admin/templates/extensions.php | 6 +- includes/class-init.php | 33 --------- includes/core/um-actions-misc.php | 18 ++--- includes/um-short-functions.php | 30 ++++---- readme.txt | 2 +- 12 files changed, 44 insertions(+), 274 deletions(-) delete mode 100644 includes/admin/templates/dashboard/language-download.php delete mode 100644 includes/admin/templates/dashboard/language-update.php diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index e8368818..48494113 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -37,7 +37,6 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) ); add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) ); add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) ); - add_action( 'um_admin_do_action__um_language_downloader', array( &$this, 'um_language_downloader' ) ); add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) ); add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) ); add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) ); @@ -209,41 +208,6 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { } - /** - * Download a language remotely - * - * @param $action - */ - function um_language_downloader( $action ) { - if ( !is_admin() || !current_user_can('manage_options') ) die(); - - $locale = get_option('WPLANG'); - if ( !$locale ) return; - if ( !isset( UM()->available_languages[$locale] ) ) return; - - $path = UM()->files()->upload_basedir; - $path = str_replace('/uploads/ultimatemember','',$path); - $path = $path . '/languages/plugins/'; - $path = str_replace('//','/',$path); - - $remote = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.po'; - $remote2 = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.mo'; - - $remote_tmp = download_url( $remote, $timeout = 300 ); - copy( $remote_tmp, $path . 'ultimatemember-' . $locale . '.po' ); - unlink( $remote_tmp ); - - $remote2_tmp = download_url( $remote2, $timeout = 300 ); - copy( $remote2_tmp, $path . 'ultimatemember-' . $locale . '.mo' ); - unlink( $remote2_tmp ); - - $url = remove_query_arg('um_adm_action', UM()->permalinks()->get_current_url() ); - $url = add_query_arg('update','language_updated',$url); - exit( wp_redirect($url) ); - - } - - /** * Action to hide notices in admin * diff --git a/includes/admin/core/class-admin-menu.php b/includes/admin/core/class-admin-menu.php index 26bafe60..e0f17f4a 100644 --- a/includes/admin/core/class-admin-menu.php +++ b/includes/admin/core/class-admin-menu.php @@ -215,14 +215,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { add_meta_box( 'um-metaboxes-sidebox-2', __( 'User Cache', 'ultimate-member' ), array( &$this, 'user_cache' ), $this->pagehook, 'side', 'core' ); - if ( $this->language_avaialable_not_installed() ) { - add_meta_box( 'um-metaboxes-sidebox-2', __( 'Language', 'ultimate-member' ), array( &$this, 'dl_language' ), $this->pagehook, 'side', 'core' ); - } else if ( $this->language_avaialable_installed() ) { - add_meta_box( 'um-metaboxes-sidebox-2', __( 'Language', 'ultimate-member' ), array( &$this, 'up_language' ), $this->pagehook, 'side', 'core' ); - } else if ( $this->language_not_available() ) { - add_meta_box( 'um-metaboxes-sidebox-2', __( 'Language', 'ultimate-member' ), array( &$this, 'ct_language' ), $this->pagehook, 'side', 'core' ); - } - //If there are active and licensed extensions - show metabox for upgrade it $exts = UM()->plugin_updater()->um_get_active_plugins(); if ( 0 < count( $exts ) ) { @@ -231,33 +223,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { } - /** - * - */ - function up_language() { - $locale = get_option('WPLANG'); - include_once UM()->admin()->templates_path . 'dashboard/language-update.php'; - } - - - /** - * - */ - function dl_language() { - $locale = get_option('WPLANG'); - include_once UM()->admin()->templates_path . 'dashboard/language-download.php'; - } - - - /** - * - */ - function ct_language() { - $locale = get_option('WPLANG'); - include_once UM()->admin()->templates_path . 'dashboard/language-contrib.php'; - } - - /** * */ @@ -298,45 +263,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { } - /** - * Language not available - * - * @return bool - */ - function language_not_available() { - $locale = get_option( 'WPLANG' ); - if ( $locale && !strstr($locale, 'en_') && !isset( UM()->available_languages[$locale] ) && !file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) - return true; - return false; - } - - - /** - * Language available but not installed - * - * @return bool - */ - function language_avaialable_not_installed() { - $locale = get_option('WPLANG'); - if ( $locale && isset( UM()->available_languages[$locale] ) && !file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) - return true; - return false; - } - - - /** - * Language available and installed - * - * @return bool - */ - function language_avaialable_installed() { - $locale = get_option('WPLANG'); - if ( $locale && isset( UM()->available_languages[$locale] ) && file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) - return true; - return false; - } - - /** * Get a directory size * diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index 05a032b6..1419932a 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -38,7 +38,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { $this->old_extensions_notice(); $this->install_core_page_notice(); $this->exif_extension_notice(); - $this->localize_note(); $this->show_update_messages(); $this->check_wrong_install_folder(); $this->admin_notice_opt_in(); @@ -358,45 +357,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { } - /** - * Localization notice - */ - function localize_note() { - $locale = get_option( 'WPLANG' ); - if ( ! $locale || strstr( $locale, 'en_' ) ) { - return; - } - - if ( file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) { - return; - } - - $hide_locale_notice = get_option( 'um_hide_locale_notice' ); - if ( $hide_locale_notice ) { - return; - } - - if ( isset( UM()->available_languages[ $locale ] ) ) { - - $download_uri = add_query_arg( 'um_adm_action', 'um_language_downloader' ); - - $this->add_notice( 'locale', array( - 'class' => 'updated', - 'message' => '

' . sprintf( __( 'Your site language is %1$s. Good news! Ultimate Member is already available in %2$s language. Download the translation files and start using the plugin in your language now. Hide this notice','ultimate-member'), $locale, UM()->available_languages[ $locale ], $download_uri, add_query_arg( 'um_adm_action', 'um_hide_locale_notice' ) ) . '

', - ), 40 ); - - } else { - - $this->add_notice( 'locale', array( - 'class' => 'updated', - 'message' => '

' . sprintf( __( 'Ultimate Member has not yet been translated to your language: %1$s. If you have translated the plugin you need put these files ultimatemember-%1$s.po and ultimatemember-%1$s.mo in /wp-content/languages/plugins/ for the plugin to be translated in your language. Hide this notice', 'ultimate-member' ), $locale, add_query_arg( 'um_adm_action', 'um_hide_locale_notice' ) ) . '

', - ), 40 ); - - } - - } - - /** * Updating users */ diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index af0435f9..3e9a43a5 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -1061,19 +1061,25 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { */ function sorting_licenses_options( $settings ) { //sorting licenses - if ( empty( $settings['licenses']['fields'] ) ) + if ( empty( $settings['licenses']['fields'] ) ) { return $settings; + } + $licenses = $settings['licenses']['fields']; - @uasort( $licenses, create_function( '$a,$b', 'return strnatcasecmp($a["label"],$b["label"]);' ) ); + @uasort( $licenses, function( $a, $b ) { + return strnatcasecmp( $a["label"], $b["label"] ); + } ); $settings['licenses']['fields'] = $licenses; - //sorting extensions - if ( empty( $settings['extensions']['sections'] ) ) + if ( empty( $settings['extensions']['sections'] ) ) { return $settings; + } $extensions = $settings['extensions']['sections']; - @uasort( $extensions, create_function( '$a,$b', 'return strnatcasecmp($a["title"],$b["title"]);' ) ); + @uasort( $extensions, function( $a, $b ) { + return strnatcasecmp( $a["title"], $b["title"] ); + } ); $keys = array_keys( $extensions ); if ( $keys[0] != "" ) { @@ -1082,7 +1088,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $extensions[$new_key] = $temp; $extensions[""] = $extensions[$keys[0]]; unset( $extensions[$keys[0]] ); - @uasort( $extensions, create_function( '$a,$b', 'return strnatcasecmp($a["title"],$b["title"]);' ) ); + @uasort( $extensions, function( $a, $b ) { + return strnatcasecmp( $a["title"], $b["title"] ); + } ); } $settings['extensions']['sections'] = $extensions; @@ -1099,13 +1107,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { */ function get_section_fields( $tab, $section ) { - if ( empty( $this->settings_structure[$tab] ) ) + if ( empty( $this->settings_structure[ $tab ] ) ) { return array(); + } - if ( ! empty( $this->settings_structure[$tab]['sections'][$section]['fields'] ) ) { - return $this->settings_structure[$tab]['sections'][$section]['fields']; - } elseif ( ! empty( $this->settings_structure[$tab]['fields'] ) ) { - return $this->settings_structure[$tab]['fields']; + if ( ! empty( $this->settings_structure[ $tab ]['sections'][ $section ]['fields'] ) ) { + return $this->settings_structure[ $tab ]['sections'][ $section ]['fields']; + } elseif ( ! empty( $this->settings_structure[ $tab ]['fields'] ) ) { + return $this->settings_structure[ $tab ]['fields']; } return array(); diff --git a/includes/admin/core/class-admin-upgrade.php b/includes/admin/core/class-admin-upgrade.php index 2179daf4..86237bfc 100644 --- a/includes/admin/core/class-admin-upgrade.php +++ b/includes/admin/core/class-admin-upgrade.php @@ -350,36 +350,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) { wp_send_json_success( array( 'packages' => $update_versions ) ); } - /** - * Load packages - */ - /*public function packages() { - if ( ! ini_get( 'safe_mode' ) ) { - @set_time_limit(0); - } - - $this->set_update_versions(); - - $um_last_version_upgrade = get_option( 'um_last_version_upgrade' ); - $um_last_version_upgrade = ! $um_last_version_upgrade ? '0.0.0' : $um_last_version_upgrade; - - foreach ( $this->update_versions as $update_version ) { - - if ( version_compare( $update_version, $um_last_version_upgrade, '<=' ) ) - continue; - - if ( version_compare( $update_version, ultimatemember_version, '>' ) ) - continue; - - $file_path = $this->packages_dir . $update_version . '.php'; - - if ( file_exists( $file_path ) ) { - include_once( $file_path ); - update_option( 'um_last_version_upgrade', $update_version ); - } - } - }*/ - /** * Parse packages dir for packages files diff --git a/includes/admin/templates/dashboard/language-download.php b/includes/admin/templates/dashboard/language-download.php deleted file mode 100644 index ab5f06d7..00000000 --- a/includes/admin/templates/dashboard/language-download.php +++ /dev/null @@ -1,9 +0,0 @@ -

- %1$s (%2$s).', 'ultimate-member' ), UM()->available_languages[ $locale ], $locale ); ?> -

- -

- - - -

\ No newline at end of file diff --git a/includes/admin/templates/dashboard/language-update.php b/includes/admin/templates/dashboard/language-update.php deleted file mode 100644 index 4287e3b7..00000000 --- a/includes/admin/templates/dashboard/language-update.php +++ /dev/null @@ -1,9 +0,0 @@ -

- %1$s (%2$s).', 'ultimate-member' ), UM()->available_languages[ $locale ], $locale ); ?> -

- -

- - - -

\ No newline at end of file diff --git a/includes/admin/templates/extensions.php b/includes/admin/templates/extensions.php index c3755722..e475db72 100644 --- a/includes/admin/templates/extensions.php +++ b/includes/admin/templates/extensions.php @@ -162,11 +162,11 @@ $free['terms-conditions'] = array(
- Core Extensions Bundle – Check out our extensions bundle which includes all extensions at a significant discount. + All Access Pass – Get access to all Ultimate Member extensions at a significant discount with our All Access Pass.', 'ultimate-member' ) ?>
diff --git a/includes/class-init.php b/includes/class-init.php index 61449315..7e790b4f 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -65,14 +65,6 @@ if ( ! class_exists( 'UM' ) ) { public $is_permalinks; - /** - * UM Available Languages - * - * @var array - */ - var $available_languages; - - /** * Main UM Instance * @@ -198,31 +190,6 @@ if ( ! class_exists( 'UM' ) ) { $this->is_filtering = 0; $this->honeypot = 'request'; - $this->available_languages = array( - 'en_US' => 'English (US)', - 'es_ES' => 'Español', - 'es_MX' => 'Español (México)', - 'fr_FR' => 'Français', - 'it_IT' => 'Italiano', - 'de_DE' => 'Deutsch', - 'nl_NL' => 'Nederlands', - 'pt_BR' => 'Português do Brasil', - 'fi_FI' => 'Suomi', - 'ro_RO' => 'Română', - 'da_DK' => 'Dansk', - 'sv_SE' => 'Svenska', - 'pl_PL' => 'Polski', - 'cs_CZ' => 'Czech', - 'el' => 'Greek', - 'id_ID' => 'Indonesian', - 'zh_CN' => '简体中文', - 'ru_RU' => 'Русский', - 'tr_TR' => 'Türkçe', - 'fa_IR' => 'Farsi', - 'he_IL' => 'Hebrew', - 'ar' => 'العربية', - ); - // textdomain loading $this->localize(); diff --git a/includes/core/um-actions-misc.php b/includes/core/um-actions-misc.php index df9b737f..2def15d0 100644 --- a/includes/core/um-actions-misc.php +++ b/includes/core/um-actions-misc.php @@ -12,33 +12,30 @@ function um_browser_url_redirect_to( $args ) { $url = ''; if ( ! empty( $_REQUEST['redirect_to'] ) ) { + $url = $_REQUEST['redirect_to']; - echo ''; } elseif ( ! empty( $args['after_login'] ) ) { - + switch ( $args['after_login'] ) { - + case 'redirect_admin': $url = admin_url(); break; - + case 'redirect_profile': $url = um_user_profile_url(); break; - + case 'redirect_url': $url = $args['redirect_url']; break; - + case 'refresh': - $url = UM()->permalinks()->get_current_url(); - break; - + } - } /** @@ -66,7 +63,6 @@ function um_browser_url_redirect_to( $args ) { if ( ! empty( $url ) ) { echo ''; } - } add_action( 'um_after_form_fields', 'um_browser_url_redirect_to' ); diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 6006db8a..8a3c17df 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -439,27 +439,25 @@ function um_redirect_home() { * @param $url */ function um_js_redirect( $url ) { - if (headers_sent() || empty( $url )) { + if ( headers_sent() || empty( $url ) ) { //for blank redirects - if ('' == $url) { + if ( '' == $url ) { $url = set_url_scheme( '//' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ); } - $funtext = "echo \"\";"; - register_shutdown_function( create_function( '', $funtext ) ); + register_shutdown_function( function( $url ) { + echo ''; + }, $url ); - if (1 < ob_get_level()) { - while (ob_get_level() > 1) { + if ( 1 < ob_get_level() ) { + while ( ob_get_level() > 1 ) { ob_end_clean(); } - } - - ?> - - + +