diff --git a/README.md b/README.md index 402615b9..cd7c71a6 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl | Latest Version |Requires at least|Stable Tag| | :------------: |:------------:|:------------:| -| 2.0.5 | WordPress 4.9 or higher| 2.0.5 | +| 2.0.7 | WordPress 4.9 or higher| 2.0.7 | Features of the plugin include: @@ -48,7 +48,7 @@ GNU Version 2 or Any Later Version Releases ==================== -[Official Release Version: 2.0.5](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.5). +[Official Release Version: 2.0.7](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.7). [Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases). diff --git a/includes/admin/core/class-admin-upgrade.php b/includes/admin/core/class-admin-upgrade.php index eb586d88..e48cb7c9 100644 --- a/includes/admin/core/class-admin-upgrade.php +++ b/includes/admin/core/class-admin-upgrade.php @@ -45,8 +45,46 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) { add_action( 'wp_ajax_um_run_package', array( $this, 'ajax_run_package' ) ); add_action( 'wp_ajax_um_get_packages', array( $this, 'ajax_get_packages' ) ); } + + //add_action( 'in_plugin_update_message-' . um_plugin, array( $this, 'in_plugin_update_message' ) ); } + /** + * Function for major updates + * + */ + /*function in_plugin_update_message( $args ) { + + $lastversion = get_option( '%UNIQUE_ID%_last_version', false ); + if ( $lastversion && version_compare( $lastversion, %UNIQUE_ID%_current_version, '>' ) ) { + $upgrade_notice = get_option( '%UNIQUE_ID%_major_update' . $lastversion ); + + echo '' . wp_kses_post( $upgrade_notice ); + } + }*/ + /** * Get array of necessary upgrade packages diff --git a/includes/class-init.php b/includes/class-init.php index c9c198c2..249a103e 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -539,7 +539,6 @@ if ( ! class_exists( 'UM' ) ) { $this->plugin_updater(); } elseif ( $this->is_request( 'frontend' ) ) { $this->enqueue(); - $this->rewrite(); $this->account(); $this->password(); $this->login(); @@ -551,6 +550,7 @@ if ( ! class_exists( 'UM' ) ) { } //common includes + $this->rewrite(); $this->mail(); $this->rest_api(); $this->shortcodes(); diff --git a/includes/core/class-rewrite.php b/includes/core/class-rewrite.php index be0399bb..68b93f41 100644 --- a/includes/core/class-rewrite.php +++ b/includes/core/class-rewrite.php @@ -18,16 +18,14 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) { * Rewrite constructor. */ function __construct() { + //add rewrite rules add_filter( 'query_vars', array(&$this, 'query_vars'), 10, 1 ); - + add_filter( 'rewrite_rules_array', array( &$this, '_add_rewrite_rules' ), 10, 1 ); add_action( 'init', array( &$this, 'rewrite_rules'), 100000000 ); + add_action( 'template_redirect', array( &$this, 'redirect_author_page'), 9999 ); - add_action( 'template_redirect', array( &$this, 'locate_user_profile'), 9999 ); - - //add rewrite rules - add_filter( 'rewrite_rules_array', array( &$this, '_add_rewrite_rules' ), 10, 1 ); } @@ -66,35 +64,23 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) { $newrules['um-api/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?um_page=api&um_action=$matches[1]&um_resource=$matches[2]&um_method=$matches[3]&um_verify=$matches[4]'; - return $newrules + $rules; - } - - - /** - * Setup rewrite rules - */ - function rewrite_rules() { - if ( isset( UM()->config()->permalinks['user'] ) ) { $user_page_id = UM()->config()->permalinks['user']; - $account_page_id = UM()->config()->permalinks['account']; - $user = get_post($user_page_id); + $user = get_post( $user_page_id ); if ( isset( $user->post_name ) ) { $user_slug = $user->post_name; - $account = get_post($account_page_id); - $account_slug = $account->post_name; $add_lang_code = ''; $language_code = ''; - if ( function_exists('icl_object_id') || function_exists('icl_get_current_language') ) { + if ( function_exists('icl_object_id') || function_exists('icl_get_current_language') ) { - if( function_exists('icl_get_current_language') ){ + if ( function_exists('icl_get_current_language') ) { $language_code = icl_get_current_language(); - }else if( function_exists('icl_object_id') && defined('ICL_LANGUAGE_CODE') ){ + } elseif( function_exists('icl_object_id') && defined('ICL_LANGUAGE_CODE') ) { $language_code = ICL_LANGUAGE_CODE; } @@ -105,53 +91,89 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) { $user_slug = $lang_post_obj->post_name; } - // Account page translated slug - $lang_post_id = icl_object_id( $account->ID, 'post', FALSE, $language_code ); - $lang_post_obj = get_post( $lang_post_id ); - if( isset( $lang_post_obj->post_name ) ){ - $account_slug = $lang_post_obj->post_name; - } - if( $language_code != icl_get_default_language() ){ $add_lang_code = $language_code; } } - add_rewrite_rule( $user_slug.'/([^/]+)/?$', - 'index.php?page_id='.$user_page_id.'&um_user=$matches[1]&lang='.$add_lang_code, - 'top' - ); + $newrules[ $user_slug.'/([^/]+)/?$' ] = 'index.php?page_id='.$user_page_id.'&um_user=$matches[1]&lang='.$add_lang_code; + } + } - add_rewrite_rule( $account_slug.'/([^/]+)?$', - 'index.php?page_id='.$account_page_id.'&um_tab=$matches[1]&lang='.$add_lang_code, - 'top' - ); + if ( isset( UM()->config()->permalinks['account'] ) ) { - /** - * UM hook - * - * @type filter - * @title um_rewrite_flush_rewrite_rules - * @description Enable flushing rewrite rules - * @input_vars - * [{"var":"$stop_flush","type":"bool","desc":"Stop flushing rewrite rules"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * - */ - if ( ! apply_filters( 'um_rewrite_flush_rewrite_rules', UM()->options()->get( 'um_flush_stop' ) ) ) - flush_rewrite_rules( true ); + $account_page_id = UM()->config()->permalinks['account']; + $account = get_post( $account_page_id ); + if ( isset( $account->post_name ) ) { + + $account_slug = $account->post_name; + + $add_lang_code = ''; + $language_code = ''; + + if ( function_exists('icl_object_id') || function_exists('icl_get_current_language') ) { + + if ( function_exists('icl_get_current_language') ){ + $language_code = icl_get_current_language(); + } elseif( function_exists('icl_object_id') && defined('ICL_LANGUAGE_CODE') ) { + $language_code = ICL_LANGUAGE_CODE; + } + + // Account page translated slug + $lang_post_id = icl_object_id( $account->ID, 'post', FALSE, $language_code ); + $lang_post_obj = get_post( $lang_post_id ); + if ( isset( $lang_post_obj->post_name ) ){ + $account_slug = $lang_post_obj->post_name; + } + + if ( $language_code != icl_get_default_language() ) { + $add_lang_code = $language_code; + } + + } + + $newrules[ $account_slug.'/([^/]+)?$' ] = 'index.php?page_id='.$account_page_id.'&um_tab=$matches[1]&lang='.$add_lang_code; + + } + + } + + return $newrules + $rules; + } + + + /** + * Setup rewrite rules + */ + function rewrite_rules() { + + if ( isset( UM()->config()->permalinks['user'] ) && isset( UM()->config()->permalinks['account'] ) ) { + + /** + * UM hook + * + * @type filter + * @title um_rewrite_flush_rewrite_rules + * @description Enable flushing rewrite rules + * @input_vars + * [{"var":"$stop_flush","type":"bool","desc":"Stop flushing rewrite rules"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ + if ( ! apply_filters( 'um_rewrite_flush_rewrite_rules', UM()->options()->get( 'um_flush_stop' ) ) ) { + flush_rewrite_rules( true ); } } diff --git a/readme.txt b/readme.txt index e48bc111..2fb2539c 100644 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,4 @@ -=== Ultimate Member - User Profile & Membership Plugin === +=== Ultimate Member - User Profile & Membership Plugin === Author URI: https://ultimatemember.com/ Plugin URI: https://ultimatemember.com/ Contributors: ultimatemember, champsupertramp, nsinelnikov @@ -6,7 +6,7 @@ Donate link: Tags: community, member, membership, user-profile, user-registration Requires at least: 4.1 Tested up to: 4.9 -Stable tag: 2.0.5 +Stable tag: 2.0.7 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -129,6 +129,15 @@ The plugin works with popular caching plugins by automatically excluding Ultimat == Changelog == += 2.0.7: xxxx, 2018 = + +* Bugfixes: + - Fixed add rewrite rules for UM pages + += 2.0.6: April 12, 2018 = + +* Bugfixes: + - Fixed nav-menu content restriction issues for Administrator role = 2.0.5: April 12, 2018 = diff --git a/ultimate-member.php b/ultimate-member.php index 1faa081d..6e9483bc 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.5 +Version: 2.0.7 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member