diff --git a/includes/core/um-navmenu.php b/includes/admin/core/class-admin-navmenu.php similarity index 61% rename from includes/core/um-navmenu.php rename to includes/admin/core/class-admin-navmenu.php index 00b4a8a1..9e2a4e17 100644 --- a/includes/core/um-navmenu.php +++ b/includes/admin/core/class-admin-navmenu.php @@ -1,36 +1,34 @@ __( 'Display Mode' ), - 'um_nav_roles' => __( 'By Role' ) + 'um_nav_public' => __( 'Display Mode', 'ultimate-member' ), + 'um_nav_roles' => __( 'By Role', 'ultimate-member' ) ); - add_action( 'wp_update_nav_menu_item', array( __CLASS__, '_save' ), 10, 3 ); - //add_filter( 'manage_nav-menus_columns', array( __CLASS__, '_columns' ), 99 ); + add_action( 'wp_update_nav_menu_item', array( &$this, '_save' ), 10, 3 ); + //add_filter( 'manage_nav-menus_columns', array( &$this, '_columns' ), 99 ); - add_action( 'load-nav-menus.php', array( __CLASS__, 'enqueue_nav_menus_scripts' ) ); - add_action( 'admin_footer-nav-menus.php', array( __CLASS__, '_wp_template' ) ); + add_action( 'load-nav-menus.php', array( &$this, 'enqueue_nav_menus_scripts' ) ); + add_action( 'admin_footer-nav-menus.php', array( &$this, '_wp_template' ) ); } @@ -39,7 +37,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { * @param $menu_item_db_id * @param $menu_item_args */ - public static function _save( $menu_id, $menu_item_db_id, $menu_item_args ) { + function _save( $menu_id, $menu_item_db_id, $menu_item_args ) { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { return; } @@ -56,7 +54,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) { // Do some checks here... $value = is_array( $_POST[ $key ][ $menu_item_db_id ] ) ? - array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ]; + array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ]; } else { $value = null; } @@ -76,7 +74,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { * * @return array */ - public static function _columns( $columns ) { + function _columns( $columns ) { $columns = array_merge( $columns, self::$fields ); return $columns; @@ -86,20 +84,20 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { /** * */ - public static function enqueue_nav_menus_scripts() { - add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) ); + function enqueue_nav_menus_scripts() { + add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); } /** * */ - public static function admin_enqueue_scripts() { + function admin_enqueue_scripts() { UM()->admin_enqueue()->load_nav_manus_scripts(); - $menus = get_posts( 'post_type=nav_menu_item&numberposts=-1' ); $menu_restriction_data = array(); + $menus = get_posts( 'post_type=nav_menu_item&numberposts=-1' ); foreach ( $menus as $data ) { $_nav_roles_meta = get_post_meta( $data->ID, 'menu-item-um_nav_roles', true ); @@ -117,6 +115,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { 'um_nav_roles' => $um_nav_roles, ); } + wp_localize_script( 'um_admin_nav_manus', 'um_menu_restriction_data', $menu_restriction_data ); } @@ -124,7 +123,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) { /** * */ - public static function _wp_template() { + function _wp_template() { ?> Network Structure: options()->get( 'network_permalink_structure' ). "\n"; ?> -Nav Menu Settings: options()->get( 'disable_menu' ) == 0 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?> Port Forwarding in URL: options()->get( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?> Exclude CSS/JS on Home: options()->get( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?> diff --git a/includes/class-functions.php b/includes/class-functions.php index 7b4d0977..b40141cc 100644 --- a/includes/class-functions.php +++ b/includes/class-functions.php @@ -1,6 +1,4 @@ -init_variables(); } @@ -91,14 +76,6 @@ if ( ! class_exists( 'UM_Functions' ) ) { } - /** - * Set variables - */ - function init_variables() { - $this->options = get_option( 'um_options' ); - } - - /** * Help Tip displaying * @@ -344,6 +321,9 @@ if ( ! class_exists( 'UM_Functions' ) ) { } + /** + * @return mixed|void + */ function cpt_list() { /** * UM hook diff --git a/includes/class-init.php b/includes/class-init.php index 2ffbbbb9..902f6c86 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -1,4 +1,4 @@ -classes[$class_name] ) ) { + if ( empty( $this->classes[ $class_name ] ) ) { $class = 'UM_' . $class_name; - $this->classes[$class_name] = $instance ? $class::instance() : new $class; + $this->classes[ $class_name ] = $instance ? $class::instance() : new $class; } } @@ -179,16 +181,18 @@ if ( ! class_exists( 'UM' ) ) { * @since 2.0.18 */ function _um_construct() { - if ( get_option( 'permalink_structure' ) ) - $this->permalinks = true; - //register autoloader for include UM classes spl_autoload_register( array( $this, 'um__autoloader' ) ); if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { + if ( get_option( 'permalink_structure' ) ) { + $this->is_permalinks = true; + } + $this->is_filtering = 0; $this->honeypot = 'request'; + $this->available_languages = array( 'en_US' => 'English (US)', 'es_ES' => 'Español', @@ -214,82 +218,11 @@ if ( ! class_exists( 'UM' ) ) { 'ar' => 'العربية', ); - /** - * UM hook - * - * @type filter - * @title um_language_textdomain - * @description Change UM textdomain - * @input_vars - * [{"var":"$domain","type":"string","desc":"UM Textdomain"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_language_textdomain', 'function_name', 10, 1 ); - * @example - * - */ - $language_domain = apply_filters( 'um_language_textdomain', 'ultimate-member' ); - - $language_locale = ( get_locale() != '' ) ? get_locale() : 'en_US'; - - /** - * UM hook - * - * @type filter - * @title um_language_locale - * @description Change UM language locale - * @input_vars - * [{"var":"$locale","type":"string","desc":"UM language locale"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_language_locale', 'function_name', 10, 1 ); - * @example - * - */ - $language_locale = apply_filters( 'um_language_locale', $language_locale ); - - $language_file = WP_LANG_DIR . '/plugins/' . $language_domain . '-' . $language_locale . '.mo'; - - /** - * UM hook - * - * @type filter - * @title um_language_file - * @description Change UM language file path - * @input_vars - * [{"var":"$language_file","type":"string","desc":"UM language file path"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_language_file', 'function_name', 10, 1 ); - * @example - * - */ - $language_file = apply_filters( 'um_language_file', $language_file ); - - load_textdomain( $language_domain, $language_file ); - + // textdomain loading + $this->localize(); // include UM classes $this->includes(); - $this->plugins_loaded(); // include hook files add_action( 'plugins_loaded', array( &$this, 'init' ), 0 ); @@ -302,7 +235,6 @@ if ( ! class_exists( 'UM' ) ) { // init widgets add_action( 'widgets_init', array( &$this, 'widgets_init' ) ); - //include short non class functions require_once 'um-short-functions.php'; require_once 'um-deprecated-functions.php'; @@ -310,18 +242,90 @@ if ( ! class_exists( 'UM' ) ) { } - public function plugins_loaded() { - //gravity forms - if ( ! function_exists('members_get_capabilities' ) ) { + /** + * Loading UM textdomain + * + * 'ultimate-member' by default + */ + function localize() { + $language_locale = ( get_locale() != '' ) ? get_locale() : 'en_US'; - function members_get_capabilities() { + /** + * UM hook + * + * @type filter + * @title um_language_locale + * @description Change UM language locale + * @input_vars + * [{"var":"$locale","type":"string","desc":"UM language locale"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_language_locale', 'function_name', 10, 1 ); + * @example + * + */ + $language_locale = apply_filters( 'um_language_locale', $language_locale ); - } - } + /** + * UM hook + * + * @type filter + * @title um_language_textdomain + * @description Change UM textdomain + * @input_vars + * [{"var":"$domain","type":"string","desc":"UM Textdomain"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_language_textdomain', 'function_name', 10, 1 ); + * @example + * + */ + $language_domain = apply_filters( 'um_language_textdomain', 'ultimate-member' ); + + $language_file = WP_LANG_DIR . '/plugins/' . $language_domain . '-' . $language_locale . '.mo'; + + /** + * UM hook + * + * @type filter + * @title um_language_file + * @description Change UM language file path + * @input_vars + * [{"var":"$language_file","type":"string","desc":"UM language file path"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_language_file', 'function_name', 10, 1 ); + * @example + * + */ + $language_file = apply_filters( 'um_language_file', $language_file ); + + load_textdomain( $language_domain, $language_file ); } + /** + * 1.3.x active extensions deactivate for properly running 2.0.x AJAX upgrades + */ function old_update_patch() { global $um_woocommerce, $um_bbpress, $um_followers, $um_friends, $um_mailchimp, $um_messaging, $um_mycred, $um_notices, $um_notifications, $um_online, $um_private_content, $um_profile_completeness, $um_recaptcha, $um_reviews, $um_activity, $um_social_login, $um_user_tags, $um_verified; @@ -521,6 +525,7 @@ if ( ! class_exists( 'UM' ) ) { $this->admin_gdpr(); $this->columns(); $this->notices(); + $this->admin_navmenu(); } elseif ( $this->is_request( 'admin' ) ) { $this->admin(); $this->admin_menu(); @@ -534,6 +539,7 @@ if ( ! class_exists( 'UM' ) ) { $this->dragdrop(); $this->plugin_updater(); $this->admin_gdpr(); + $this->admin_navmenu(); } elseif ( $this->is_request( 'frontend' ) ) { $this->enqueue(); $this->account(); @@ -653,6 +659,19 @@ if ( ! class_exists( 'UM' ) ) { } + /** + * @since 2.0.26 + * + * @return um\admin\core\Admin_Navmenu() + */ + function admin_navmenu() { + if ( empty( $this->classes['admin_navmenu'] ) ) { + $this->classes['admin_navmenu'] = new um\admin\core\Admin_Navmenu(); + } + return $this->classes['admin_navmenu']; + } + + /** * @since 2.0 * @@ -1312,10 +1331,6 @@ if ( ! class_exists( 'UM' ) ) { ob_start(); - if ( $this->options()->get( 'disable_menu' ) == 0 ) { - require_once 'core/um-navmenu.php'; - } - require_once 'core/um-actions-form.php'; require_once 'core/um-actions-access.php'; require_once 'core/um-actions-wpadmin.php'; diff --git a/includes/core/class-external-integrations.php b/includes/core/class-external-integrations.php index 9171104c..91763115 100644 --- a/includes/core/class-external-integrations.php +++ b/includes/core/class-external-integrations.php @@ -31,6 +31,23 @@ if ( ! class_exists( 'um\core\External_Integrations' ) ) { add_filter( 'um_localize_permalink_filter', array( &$this, 'um_localize_permalink_filter' ), 10, 2 ); add_filter( 'icl_ls_languages', array( &$this, 'um_core_page_wpml_permalink' ), 10, 1 ); + + $this->plugins_loaded(); + } + + + /** + * Gravity forms role capabilities compatibility + */ + public function plugins_loaded() { + //gravity forms + if ( ! function_exists('members_get_capabilities' ) ) { + + function members_get_capabilities() { + + } + + } } diff --git a/includes/core/class-files.php b/includes/core/class-files.php index 1275890a..a492507a 100644 --- a/includes/core/class-files.php +++ b/includes/core/class-files.php @@ -81,7 +81,7 @@ if ( ! class_exists( 'um\core\Files' ) ) { function get_download_link( $form_id, $field_key, $user_id ) { $field_key = urlencode( $field_key ); - if ( UM()->permalinks ) { + if ( UM()->is_permalinks ) { $url = get_site_url( get_current_blog_id() ); $nonce = wp_create_nonce( $user_id . $form_id . 'um-download-nonce' ); return $url . "/um-download/{$form_id}/{$field_key}/{$user_id}/{$nonce}"; diff --git a/includes/widgets/class-um-search-widget.php b/includes/widgets/class-um-search-widget.php index 15e2045f..468b695d 100644 --- a/includes/widgets/class-um-search-widget.php +++ b/includes/widgets/class-um-search-widget.php @@ -1,6 +1,7 @@