diff --git a/includes/admin/class-site-health.php b/includes/admin/class-site-health.php index 3e04df1d..4e4c13cf 100644 --- a/includes/admin/class-site-health.php +++ b/includes/admin/class-site-health.php @@ -55,7 +55,7 @@ class Site_Health { } private function get_member_directories() { - $query = new \WP_Query; + $query = new \WP_Query(); $member_directories = $query->query( array( 'post_type' => 'um_directory', @@ -95,19 +95,27 @@ class Site_Health { 'fields' => array(), ); - // Pages settings - $pages = apply_filters( - 'um_debug_information_pages', - array( - 'User' => null !== UM()->options()->get( 'core_user' ) ? get_the_title( UM()->options()->get( 'core_user' ) ) . ' (ID#' . UM()->options()->get( 'core_user' ) . ') | ' . get_permalink( UM()->options()->get( 'core_user' ) ) : $labels['nopages'], - 'Login' => null !== UM()->options()->get( 'core_login' ) ? get_the_title( UM()->options()->get( 'core_login' ) ) . ' (ID#' . UM()->options()->get( 'core_login' ) . ') | ' . get_permalink( UM()->options()->get( 'core_login' ) ) : $labels['nopages'], - 'Register' => null !== UM()->options()->get( 'core_register' ) ? get_the_title( UM()->options()->get( 'core_register' ) ) . ' (ID#' . UM()->options()->get( 'core_register' ) . ') | ' . get_permalink( UM()->options()->get( 'core_register' ) ) : $labels['nopages'], - 'Members' => null !== UM()->options()->get( 'core_members' ) ? get_the_title( UM()->options()->get( 'core_members' ) ) . ' (ID#' . UM()->options()->get( 'core_members' ) . ') | ' . get_permalink( UM()->options()->get( 'core_members' ) ) : $labels['nopages'], - 'Logout' => null !== UM()->options()->get( 'core_logout' ) ? get_the_title( UM()->options()->get( 'core_logout' ) ) . ' (ID#' . UM()->options()->get( 'core_logout' ) . ') | ' . get_permalink( UM()->options()->get( 'core_logout' ) ) : $labels['nopages'], - 'Account' => null !== UM()->options()->get( 'core_account' ) ? get_the_title( UM()->options()->get( 'core_account' ) ) . ' (ID#' . UM()->options()->get( 'core_account' ) . ') | ' . get_permalink( UM()->options()->get( 'core_account' ) ) : $labels['nopages'], - 'Password reset' => null !== UM()->options()->get( 'core_password' ) ? get_the_title( UM()->options()->get( 'core_password-reset' ) ) . ' (ID#' . UM()->options()->get( 'core_password-reset' ) . ') | ' . get_permalink( UM()->options()->get( 'core_password-reset' ) ) : $labels['nopages'], - ) - ); + // Pages settings. + $pages = array(); + $predefined_pages = UM()->config()->core_pages; + foreach ( $predefined_pages as $page_s => $page ) { + $page_id = UM()->options()->get_core_page_id( $page_s ); + $page_title = ! empty( $page['title'] ) ? $page['title'] : ''; + if ( empty( $page_title ) ) { + continue; + } + + $predefined_page_id = UM()->options()->get( $page_id ); + + if ( empty( $predefined_page_id ) ) { + $pages[ $page_title ] = $labels['nopages']; + continue; + } + // translators: %1$s is a predefined page title; %2$d is a predefined page ID; %3$s is a predefined page permalink. + $pages[ $page_title ] = sprintf( __( '%1$s (ID#%2$d) | %3$s', 'ultimate-member' ), get_the_title( $predefined_page_id ), $predefined_page_id, get_permalink( $predefined_page_id ) ); + } + + $pages = apply_filters( 'um_debug_information_pages', $pages ); $pages_settings = array( 'um-pages' => array( @@ -117,24 +125,8 @@ class Site_Health { ); // User settings - $permalink_base = array( - 'user_login' => __( 'Username', 'ultimate-member' ), - 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ), - 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ), - 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ), - 'user_id' => __( 'User ID', 'ultimate-member' ), - ); - $display_name = array( - 'default' => __( 'Default WP Display Name', 'ultimate-member' ), - 'nickname' => __( 'Nickname', 'ultimate-member' ), - 'username' => __( 'Username', 'ultimate-member' ), - 'full_name' => __( 'First name & last name', 'ultimate-member' ), - 'sur_name' => __( 'Last name & first name', 'ultimate-member' ), - 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ), - 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ), - 'first_name' => __( 'First name only', 'ultimate-member' ), - 'field' => __( 'Custom field(s)', 'ultimate-member' ), - ); + $permalink_base = UM()->config()->permalink_base_options; + $display_name = UM()->config()->display_name_options; $user_settings = array( 'um-permalink_base' => array( @@ -183,7 +175,33 @@ class Site_Health { ), ); - if ( 1 === absint( UM()->options()->get( 'use_gravatars' ) ) ) { + if ( 'custom_meta' === UM()->options()->get( 'permalink_base' ) ) { + $user_settings = UM()->array_insert_before( + $user_settings, + 'um-display_name', + array( + 'um-permalink_base_custom_meta' => array( + 'label' => __( 'Profile Permalink Base Custom Meta Key', 'ultimate-member' ), + 'value' => UM()->options()->get( 'permalink_base_custom_meta' ), + ), + ) + ); + } + + if ( 'field' === UM()->options()->get( 'display_name' ) ) { + $user_settings = UM()->array_insert_before( + $user_settings, + 'um-author_redirect', + array( + 'um-display_name_field' => array( + 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ), + 'value' => UM()->options()->get( 'display_name_field' ), + ), + ) + ); + } + + if ( UM()->options()->get( 'use_gravatars' ) ) { $gravatar_options = array( 'default' => __( 'Default', 'ultimate-member' ), '404' => __( '404 ( File Not Found response )', 'ultimate-member' ), @@ -209,37 +227,46 @@ class Site_Health { // Account settings $account_settings = array( - 'um-account_tab_password' => array( + 'um-account_tab_password' => array( 'label' => __( 'Password Account Tab', 'ultimate-member' ), 'value' => UM()->options()->get( 'account_tab_password' ) ? $labels['yes'] : $labels['no'], ), - 'um-account_tab_privacy' => array( + 'um-account_tab_privacy' => array( 'label' => __( 'Privacy Account Tab', 'ultimate-member' ), 'value' => UM()->options()->get( 'account_tab_privacy' ) ? $labels['yes'] : $labels['no'], ), - 'um-account_tab_notifications' => array( - 'label' => __( 'Notifications Account Tab', 'ultimate-member' ), - 'value' => UM()->options()->get( 'account_tab_notifications' ) ? $labels['yes'] : $labels['no'], - ), - 'um-account_tab_delete' => array( - 'label' => __( 'Delete Account Tab', 'ultimate-member' ), - 'value' => UM()->options()->get( 'account_tab_delete' ) ? $labels['yes'] : $labels['no'], - ), - 'um-delete_account_text' => array( - 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ), - 'value' => UM()->options()->get( 'delete_account_text' ), - ), - 'um-delete_account_no_pass_required_text' => array( - 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ), - 'value' => UM()->options()->get( 'delete_account_no_pass_required_text' ), - ), - 'um-account_name' => array( - 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ), - 'value' => UM()->options()->get( 'account_name' ) ? $labels['yes'] : $labels['no'], - ), ); - if ( 1 === absint( UM()->options()->get( 'account_name' ) ) ) { + if ( false !== UM()->account()->is_notifications_tab_visible() ) { + $account_settings['um-account_tab_notifications'] = array( + 'label' => __( 'Notifications Account Tab', 'ultimate-member' ), + 'value' => UM()->options()->get( 'account_tab_notifications' ) ? $labels['yes'] : $labels['no'], + ); + } + + $account_settings = array_merge( + $account_settings, + array( + 'um-account_tab_delete' => array( + 'label' => __( 'Delete Account Tab', 'ultimate-member' ), + 'value' => UM()->options()->get( 'account_tab_delete' ) ? $labels['yes'] : $labels['no'], + ), + 'um-delete_account_text' => array( + 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ), + 'value' => UM()->options()->get( 'delete_account_text' ), + ), + 'um-delete_account_no_pass_required_text' => array( + 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ), + 'value' => UM()->options()->get( 'delete_account_no_pass_required_text' ), + ), + 'um-account_name' => array( + 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ), + 'value' => UM()->options()->get( 'account_name' ) ? $labels['yes'] : $labels['no'], + ), + ) + ); + + if ( UM()->options()->get( 'account_name' ) ) { $account_settings['um-account_name_disable'] = array( 'label' => __( 'Disable First & Last name field editing', 'ultimate-member' ), 'value' => UM()->options()->get( 'account_name_disable' ) ? $labels['yes'] : $labels['no'], @@ -250,12 +277,22 @@ class Site_Health { ); } + $account_settings['um-account_email'] = array( + 'label' => __( 'Allow users to change e-mail', 'ultimate-member' ), + 'value' => UM()->options()->get( 'account_email' ) ? $labels['yes'] : $labels['no'], + ); + + $account_settings['um-account_general_password'] = array( + 'label' => __( 'Password is required?', 'ultimate-member' ), + 'value' => UM()->options()->get( 'account_general_password' ) ? $labels['yes'] : $labels['no'], + ); + $account_settings['um-account_hide_in_directory'] = array( 'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ), 'value' => UM()->options()->get( 'account_hide_in_directory' ) ? $labels['yes'] : $labels['no'], ); - if ( 1 === absint( UM()->options()->get( 'account_name' ) ) ) { + if ( UM()->options()->get( 'account_hide_in_directory' ) ) { $account_settings['um-account_hide_in_directory_default'] = array( 'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ), 'value' => UM()->options()->get( 'account_hide_in_directory_default' ), @@ -328,27 +365,27 @@ class Site_Health { } } + $accessible = absint( UM()->options()->get( 'accessible' ) ); + $restrict_settings = array( 'um-accessible' => array( 'label' => __( 'Global Site Access', 'ultimate-member' ), - 'value' => 0 === UM()->options()->get( 'accessible' ) ? __( 'Site accessible to Everyone', 'ultimate-member' ) : __( 'Site accessible to Logged In Users', 'ultimate-member' ), + 'value' => 0 === $accessible ? __( 'Site accessible to Everyone', 'ultimate-member' ) : __( 'Site accessible to Logged In Users', 'ultimate-member' ), ), ); - if ( 2 === absint( UM()->options()->get( 'accessible' ) ) ) { + if ( 2 === $accessible ) { $exclude_uris = UM()->options()->get( 'access_exclude_uris' ); $exclude_uris_list = ''; if ( ! empty( $exclude_uris ) ) { - foreach ( $exclude_uris as $key => $url ) { - $exclude_uris_list = empty( $exclude_uris_list ) ? $url : $exclude_uris_list . ', ' . $url; - } + $exclude_uris_list = implode( ', ', $exclude_uris ); } $restrict_settings['um-access_redirect'] = array( 'label' => __( 'Custom Redirect URL', 'ultimate-member' ), 'value' => UM()->options()->get( 'access_redirect' ), ); $restrict_settings['um-access_exclude_uris'] = array( - 'label' => __( 'Account Deletion Text', 'ultimate-member' ), + 'label' => __( 'Exclude the following URLs', 'ultimate-member' ), 'value' => $exclude_uris_list, ); $restrict_settings['um-home_page_accessible'] = array( @@ -365,7 +402,7 @@ class Site_Health { 'label' => __( 'Restricted Content Titles', 'ultimate-member' ), 'value' => UM()->options()->get( 'restricted_post_title_replace' ) ? $labels['yes'] : $labels['no'], ); - if ( 1 === absint( UM()->options()->get( 'restricted_post_title_replace' ) ) ) { + if ( UM()->options()->get( 'restricted_post_title_replace' ) ) { $restrict_settings['um-restricted_access_post_title'] = array( 'label' => __( 'Restricted Content Title Text', 'ultimate-member' ), 'value' => stripslashes( UM()->options()->get( 'restricted_access_post_title' ) ), @@ -380,7 +417,7 @@ class Site_Health { 'label' => __( 'Enable the "Content Restriction" settings for the Gutenberg Blocks', 'ultimate-member' ), 'value' => UM()->options()->get( 'restricted_blocks' ) ? $labels['yes'] : $labels['no'], ); - if ( 1 === absint( UM()->options()->get( 'restricted_blocks' ) ) ) { + if ( UM()->options()->get( 'restricted_blocks' ) ) { $restrict_settings['um-restricted_block_message'] = array( 'label' => __( 'Restricted Access Block Message', 'ultimate-member' ), 'value' => stripslashes( UM()->options()->get( 'restricted_block_message' ) ), @@ -421,7 +458,7 @@ class Site_Health { 'value' => stripslashes( $blocked_emails ), ); $access_other_settings['um-blocked_words'] = array( - 'label' => __( 'Banned Usernames', 'ultimate-member' ), + 'label' => __( 'Blacklist Words', 'ultimate-member' ), 'value' => stripslashes( $blocked_words ), ); $access_other_settings['um-allowed_choice_callbacks'] = array( @@ -455,14 +492,16 @@ class Site_Health { $emails = UM()->config()->email_notifications; foreach ( $emails as $key => $email ) { - if ( 1 === absint( UM()->options()->get( $key . '_on' ) ) ) { + if ( UM()->options()->get( $key . '_on' ) ) { $email_settings[ 'um-' . $key ] = array( - 'label' => $email['title'] . __( ' Subject', 'ultimate-member' ), + // translators: %s is email template title. + 'label' => sprintf( __( '"%s" Subject', 'ultimate-member' ), $email['title'] ), 'value' => UM()->options()->get( $key . '_sub' ), ); $email_settings[ 'um-theme_' . $key ] = array( - 'label' => __( 'Template ', 'ultimate-member' ) . $email['title'] . __( ' in theme?', 'ultimate-member' ), + // translators: %s is email template title. + 'label' => sprintf( __( 'Template "%s" in theme?', 'ultimate-member' ), $email['title'] ), 'value' => '' !== locate_template( array( 'ultimate-member/emails/' . $key . '.php' ) ) ? $labels['yes'] : $labels['no'], ); } @@ -484,10 +523,15 @@ class Site_Health { 'right' => __( 'Right aligned', 'ultimate-member' ), ); + $profile_templates = UM()->shortcodes()->get_templates( 'profile' ); + $profile_template_key = UM()->options()->get( 'profile_template' ); + $profile_template_title = array_key_exists( $profile_template_key, $profile_templates ) ? $profile_templates[ $profile_template_key ] : __( 'No template name', 'ultimate-member' ); + $appearance_settings = array( 'um-profile_template' => array( 'label' => __( 'Profile Default Template', 'ultimate-member' ), - 'value' => UM()->options()->get( 'profile_template' ), + // translators: %1$s - profile template name, %2$s - profile template filename + 'value' => sprintf( __( '%1$s (filename: %2$s.php)', 'ultimate-member' ), $profile_template_title, $profile_template_key ), ), 'um-profile_max_width' => array( 'label' => __( 'Profile Maximum Width', 'ultimate-member' ), @@ -2149,34 +2193,6 @@ class Site_Health { } } - // Active extensions - $plugins = get_plugins(); - $active_plugins = get_option( 'active_plugins', array() ); - $active_exts = array(); - - foreach ( $plugins as $plugin_path => $plugin ) { - if ( strpos( $plugin_path, 'um-' ) === false ) { - - continue; - } - if ( ! in_array( $plugin_path, $active_plugins, true ) ) { - continue; - } - $name = str_replace( 'Ultimate Member -', '', $plugin['Name'] ); - $active_exts[] = $name . ': ' . $plugin['Version'] . "\n"; - } - - $info['ultimate-member-extensions'] = array( - 'label' => __( 'Ultimate Member Active Extensions', 'ultimate-member' ), - 'description' => __( 'This debug information about active extensions.', 'ultimate-member' ), - 'fields' => array( - 'um-extensions' => array( - 'label' => __( 'Active extensions', 'ultimate-member' ), - 'value' => $active_exts, - ), - ), - ); - return $info; } } diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 0928738a..0f4bb2bd 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -293,7 +293,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { ); } - $settings_map[ $page_id ] = array( 'sanitize' => 'absint', ); @@ -709,9 +708,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'account_tab_privacy' => array( 'sanitize' => 'bool', ), - 'account_tab_notifications' => array( - 'sanitize' => 'bool', - ), 'account_tab_delete' => array( 'sanitize' => 'bool', ), @@ -967,6 +963,115 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { ) ); + $account_fields = array( + array( + 'id' => 'account_tab_password', + 'type' => 'checkbox', + 'label' => __( 'Password Account Tab', 'ultimate-member' ), + 'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ), + ), + array( + 'id' => 'account_tab_privacy', + 'type' => 'checkbox', + 'label' => __( 'Privacy Account Tab', 'ultimate-member' ), + 'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ), + ), + ); + + if ( false !== UM()->account()->is_notifications_tab_visible() ) { + $account_fields[] = array( + 'id' => 'account_tab_notifications', + 'type' => 'checkbox', + 'label' => __( 'Notifications Account Tab', 'ultimate-member' ), + 'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ), + ); + + $settings_map['account_tab_notifications'] = array( + 'sanitize' => 'bool', + ); + } + + $account_fields = array_merge( + $account_fields, + array( + array( + 'id' => 'account_tab_delete', + 'type' => 'checkbox', + 'label' => __( 'Delete Account Tab', 'ultimate-member' ), + 'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ), + ), + array( + 'id' => 'delete_account_text', + 'type' => 'textarea', // bug with wp 4.4? should be editor + 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ), + 'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password is required.', 'ultimate-member' ), + 'args' => array( + 'textarea_rows' => 6, + ), + ), + array( + 'id' => 'delete_account_no_pass_required_text', + 'type' => 'textarea', + 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ), + 'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password isn\'t required.', 'ultimate-member' ), + 'args' => array( + 'textarea_rows' => 6, + ), + ), + array( + 'id' => 'account_name', + 'type' => 'checkbox', + 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ), + 'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ), + ), + array( + 'id' => 'account_name_disable', + 'type' => 'checkbox', + 'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ), + 'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ), + 'conditional' => array( 'account_name', '=', '1' ), + ), + array( + 'id' => 'account_name_require', + 'type' => 'checkbox', + 'label' => __( 'Require First & Last Name', 'ultimate-member' ), + 'tooltip' => __( 'Require first and last name?', 'ultimate-member' ), + 'conditional' => array( 'account_name', '=', '1' ), + ), + array( + 'id' => 'account_email', + 'type' => 'checkbox', + 'label' => __( 'Allow users to change e-mail', 'ultimate-member' ), + 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ), + ), + array( + 'id' => 'account_general_password', + 'type' => 'checkbox', + 'label' => __( 'Password is required?', 'ultimate-member' ), + 'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ), + ), + array( + 'id' => 'account_hide_in_directory', + 'type' => 'checkbox', + 'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ), + 'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ), + 'conditional' => array( 'account_tab_privacy', '=', '1' ), + ), + array( + 'id' => 'account_hide_in_directory_default', + 'type' => 'select', + 'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ), + 'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ), + 'options' => array( + 'No' => __( 'No', 'ultimate-member' ), + 'Yes' => __( 'Yes', 'ultimate-member' ), + ), + 'size' => 'small', + 'conditional' => array( 'account_hide_in_directory', '=', '1' ), + ), + ) + ); + $this->settings_map = apply_filters( 'um_settings_map', $settings_map ); /** @@ -1009,15 +1114,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'label' => __( 'Profile Permalink Base', 'ultimate-member' ), // translators: %s: Profile page URL 'tooltip' => sprintf( __( 'Here you can control the permalink structure of the user profile URL globally e.g. %susername/', 'ultimate-member' ), trailingslashit( um_get_core_page( 'user' ) ) ), - 'options' => array( - 'user_login' => __( 'Username', 'ultimate-member' ), - 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ), - 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ), - 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ), - 'user_id' => __( 'User ID', 'ultimate-member' ), - 'hash' => __( 'Unique hash string', 'ultimate-member' ), - 'custom_meta' => __( 'Custom usermeta', 'ultimate-member' ), - ), + 'options' => UM()->config()->permalink_base_options, 'placeholder' => __( 'Select...', 'ultimate-member' ), ), array( @@ -1034,17 +1131,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'size' => 'medium', 'label' => __( 'User Display Name', 'ultimate-member' ), 'tooltip' => __( 'This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists', 'ultimate-member' ), - 'options' => array( - 'default' => __( 'Default WP Display Name', 'ultimate-member' ), - 'nickname' => __( 'Nickname', 'ultimate-member' ), - 'username' => __( 'Username', 'ultimate-member' ), - 'full_name' => __( 'First name & last name', 'ultimate-member' ), - 'sur_name' => __( 'Last name & first name', 'ultimate-member' ), - 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ), - 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ), - 'first_name' => __( 'First name only', 'ultimate-member' ), - 'field' => __( 'Custom field(s)', 'ultimate-member' ), - ), + 'options' => UM()->config()->display_name_options, 'placeholder' => __( 'Select...', 'ultimate-member' ), ), array( @@ -1146,101 +1233,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { ), 'account' => array( 'title' => __( 'Account', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'account_tab_password', - 'type' => 'checkbox', - 'label' => __( 'Password Account Tab', 'ultimate-member' ), - 'tooltip' => __( 'Enable/disable the Password account tab in account page', 'ultimate-member' ), - ), - array( - 'id' => 'account_tab_privacy', - 'type' => 'checkbox', - 'label' => __( 'Privacy Account Tab', 'ultimate-member' ), - 'tooltip' => __( 'Enable/disable the Privacy account tab in account page', 'ultimate-member' ), - ), - array( - 'id' => 'account_tab_notifications', - 'type' => 'checkbox', - 'label' => __( 'Notifications Account Tab', 'ultimate-member' ), - 'tooltip' => __( 'Enable/disable the Notifications account tab in account page', 'ultimate-member' ), - ), - array( - 'id' => 'account_tab_delete', - 'type' => 'checkbox', - 'label' => __( 'Delete Account Tab', 'ultimate-member' ), - 'tooltip' => __( 'Enable/disable the Delete account tab in account page', 'ultimate-member' ), - ), - array( - 'id' => 'delete_account_text', - 'type' => 'textarea', // bug with wp 4.4? should be editor - 'label' => __( 'Account Deletion Custom Text', 'ultimate-member' ), - 'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password is required.', 'ultimate-member' ), - 'args' => array( - 'textarea_rows' => 6, - ), - ), - array( - 'id' => 'delete_account_no_pass_required_text', - 'type' => 'textarea', - 'label' => __( 'Account Deletion without password Custom Text', 'ultimate-member' ), - 'tooltip' => __( 'This is custom text that will be displayed to users before they delete their accounts from your site when password isn\'t required.', 'ultimate-member' ), - 'args' => array( - 'textarea_rows' => 6, - ), - ), - array( - 'id' => 'account_name', - 'type' => 'checkbox', - 'label' => __( 'Add a First & Last Name fields', 'ultimate-member' ), - 'tooltip' => __( 'Whether to enable these fields on the user account page by default or hide them.', 'ultimate-member' ), - ), - array( - 'id' => 'account_name_disable', - 'type' => 'checkbox', - 'label' => __( 'Disable First & Last Name fields', 'ultimate-member' ), - 'tooltip' => __( 'Whether to allow users changing their first and last name in account page.', 'ultimate-member' ), - 'conditional' => array( 'account_name', '=', '1' ), - ), - array( - 'id' => 'account_name_require', - 'type' => 'checkbox', - 'label' => __( 'Require First & Last Name', 'ultimate-member' ), - 'tooltip' => __( 'Require first and last name?', 'ultimate-member' ), - 'conditional' => array( 'account_name', '=', '1' ), - ), - array( - 'id' => 'account_email', - 'type' => 'checkbox', - 'label' => __( 'Allow users to change e-mail', 'ultimate-member' ), - 'tooltip' => __( 'Whether to allow users changing their email in account page.', 'ultimate-member' ), - ), - array( - 'id' => 'account_general_password', - 'type' => 'checkbox', - 'label' => __( 'Password is required?', 'ultimate-member' ), - 'tooltip' => __( 'Password is required to save account data.', 'ultimate-member' ), - ), - array( - 'id' => 'account_hide_in_directory', - 'type' => 'checkbox', - 'label' => __( 'Allow users to hide their profiles from directory', 'ultimate-member' ), - 'tooltip' => __( 'Whether to allow users changing their profile visibility from member directory in account page.', 'ultimate-member' ), - 'conditional' => array( 'account_tab_privacy', '=', '1' ), - ), - array( - 'id' => 'account_hide_in_directory_default', - 'type' => 'select', - 'label' => __( 'Hide profiles from directory by default', 'ultimate-member' ), - 'tooltip' => __( 'Set default value for the "Hide my profile from directory" option', 'ultimate-member' ), - 'options' => array( - 'No' => __( 'No', 'ultimate-member' ), - 'Yes' => __( 'Yes', 'ultimate-member' ), - ), - 'size' => 'small', - 'conditional' => array( 'account_hide_in_directory', '=', '1' ), - ), - ), + 'fields' => $account_fields, ), 'uploads' => array( 'title' => __( 'Uploads', 'ultimate-member' ), diff --git a/includes/class-config.php b/includes/class-config.php index 6390cb93..c246004b 100644 --- a/includes/class-config.php +++ b/includes/class-config.php @@ -81,6 +81,10 @@ if ( ! class_exists( 'um\Config' ) ) { */ public $default_roles_metadata = array(); + public $permalink_base_options = array(); + + public $display_name_options = array(); + /** * Config constructor. */ @@ -775,6 +779,29 @@ if ( ! class_exists( 'um\Config' ) ) { '_um_auto_approve_act' => 'redirect_profile', ), ); + + $this->permalink_base_options = array( + 'user_login' => __( 'Username', 'ultimate-member' ), + 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ), + 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ), + 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ), + 'user_id' => __( 'User ID', 'ultimate-member' ), + 'hash' => __( 'Unique hash string', 'ultimate-member' ), + 'custom_meta' => __( 'Custom usermeta', 'ultimate-member' ), + ); + $this->permalink_base_options = apply_filters( 'um_config_permalink_base_options', $this->permalink_base_options ); + + $this->display_name_options = array( + 'default' => __( 'Default WP Display Name', 'ultimate-member' ), + 'nickname' => __( 'Nickname', 'ultimate-member' ), + 'username' => __( 'Username', 'ultimate-member' ), + 'full_name' => __( 'First name & last name', 'ultimate-member' ), + 'sur_name' => __( 'Last name & first name', 'ultimate-member' ), + 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ), + 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ), + 'first_name' => __( 'First name only', 'ultimate-member' ), + 'field' => __( 'Custom field(s)', 'ultimate-member' ), + ); } diff --git a/includes/core/class-account.php b/includes/core/class-account.php index d48e08d1..dd685573 100644 --- a/includes/core/class-account.php +++ b/includes/core/class-account.php @@ -49,80 +49,75 @@ if ( ! class_exists( 'um\core\Account' ) ) { } /** - * Init AllTabs for user account + * Init AllTabs for user account. * - * @param $args + * @param array $args * * @throws \Exception */ - function init_tabs( $args ) { - + public function init_tabs( $args ) { $this->tabs = $this->get_tabs(); ksort( $this->tabs ); - $tabs_structed = array(); + $tabs_structured = array(); foreach ( $this->tabs as $k => $arr ) { - foreach ( $arr as $id => $info ) { - - if ( ! empty( $args['tab'] ) && $id != $args['tab'] ) { + if ( ! empty( $args['tab'] ) && $id !== $args['tab'] ) { continue; } $output = $this->get_tab_fields( $id, $args ); if ( ! empty( $output ) ) { - $tabs_structed[ $id ] = $info; + $tabs_structured[ $id ] = $info; } - } - } - $this->tabs = $tabs_structed; + $this->tabs = $tabs_structured; } - /** - * Get all Account tabs + * Get all Account tabs. * * @return array */ - function get_tabs() { - $tabs = array(); + public function get_tabs() { + $tabs = array(); $tabs[100]['general'] = array( - 'icon' => 'um-faicon-user', - 'title' => __( 'Account', 'ultimate-member' ), - 'submit_title' => __( 'Update Account', 'ultimate-member' ), + 'icon' => 'um-faicon-user', + 'title' => __( 'Account', 'ultimate-member' ), + 'submit_title' => __( 'Update Account', 'ultimate-member' ), ); $tabs[200]['password'] = array( - 'icon' => 'um-faicon-asterisk', - 'title' => __( 'Change Password', 'ultimate-member' ), - 'submit_title' => __( 'Update Password', 'ultimate-member' ), + 'icon' => 'um-faicon-asterisk', + 'title' => __( 'Change Password', 'ultimate-member' ), + 'submit_title' => __( 'Update Password', 'ultimate-member' ), ); $tabs[300]['privacy'] = array( - 'icon' => 'um-faicon-lock', - 'title' => __( 'Privacy', 'ultimate-member' ), - 'submit_title' => __( 'Update Privacy', 'ultimate-member' ), + 'icon' => 'um-faicon-lock', + 'title' => __( 'Privacy', 'ultimate-member' ), + 'submit_title' => __( 'Update Privacy', 'ultimate-member' ), ); + // Init here, but default account tab content is empty, so it's hidden. + // Init required here for the using inside the extensions where is possible to disable email notification. + // Default Ultimate Member core notifications cannot be disabled on the user's side. $tabs[400]['notifications'] = array( - 'icon' => 'um-faicon-envelope', - 'title' => __( 'Notifications', 'ultimate-member' ), - 'submit_title' => __( 'Update Notifications', 'ultimate-member' ), + 'icon' => 'um-faicon-envelope', + 'title' => __( 'Notifications', 'ultimate-member' ), + 'submit_title' => __( 'Update Notifications', 'ultimate-member' ), ); - //if user cannot delete profile hide delete tab + // If user cannot delete profile hide delete tab. if ( um_user( 'can_delete_profile' ) || um_user( 'can_delete_everyone' ) ) { - $tabs[99999]['delete'] = array( - 'icon' => 'um-faicon-trash-o', - 'title' => __( 'Delete Account', 'ultimate-member' ), - 'submit_title' => __( 'Delete Account', 'ultimate-member' ), + 'icon' => 'um-faicon-trash-o', + 'title' => __( 'Delete Account', 'ultimate-member' ), + 'submit_title' => __( 'Delete Account', 'ultimate-member' ), ); - } /** @@ -567,9 +562,9 @@ if ( ! class_exists( 'um\core\Account' ) ) { function get_tab_fields( $id, $shortcode_args ) { $output = null; - UM()->fields()->set_id = absint( $id ); + UM()->fields()->set_id = absint( $id ); UM()->fields()->set_mode = 'account'; - UM()->fields()->editing = true; + UM()->fields()->editing = true; if ( ! empty( $this->tab_output[ $id ]['content'] ) && ! empty( $this->tab_output[ $id ]['hash'] ) && $this->tab_output[ $id ]['hash'] == md5( json_encode( $shortcode_args ) ) ) { @@ -784,7 +779,6 @@ if ( ! class_exists( 'um\core\Account' ) ) { */ $output = apply_filters( "um_account_content_hook_{$id}", $output, $shortcode_args ); break; - } $this->tab_output[ $id ] = array( 'content' => $output, 'hash' => md5( json_encode( $shortcode_args ) ) ); @@ -940,15 +934,14 @@ if ( ! class_exists( 'um\core\Account' ) ) { return $classes; } - /** - * Checks account actions require current password + * Checks account actions require current password. * - * @param $tab_key + * @param string $tab_key * * @return bool */ - function current_password_is_required( $tab_key ) { + public function current_password_is_required( $tab_key ) { $is_required = true; switch ( $tab_key ) { @@ -956,17 +949,22 @@ if ( ! class_exists( 'um\core\Account' ) ) { $is_required = UM()->options()->get( 'account_general_password' ); break; case 'delete': - break; case 'password': - break; case 'privacy_erase_data': case 'privacy_download_data': break; } - $is_required = apply_filters( "um_account_{$tab_key}_require_current", $is_required ); + return apply_filters( "um_account_{$tab_key}_require_current", $is_required ); + } - return $is_required; + /** + * Check the conditional hook for getting notifications tab data. + * + * @return bool + */ + public function is_notifications_tab_visible() { + return apply_filters( 'um_account_notifications_tab_enabled', false ); } } } diff --git a/includes/core/um-actions-account.php b/includes/core/um-actions-account.php index 9d4c4e02..41e520dc 100644 --- a/includes/core/um-actions-account.php +++ b/includes/core/um-actions-account.php @@ -511,9 +511,8 @@ function um_before_account_delete() { } add_action( 'um_before_account_delete', 'um_before_account_delete' ); - /** - * Before notifications account tab content + * Before notifications account tab content. * * @param array $args * @@ -521,15 +520,14 @@ add_action( 'um_before_account_delete', 'um_before_account_delete' ); */ function um_before_account_notifications( $args = array() ) { $output = UM()->account()->get_tab_fields( 'notifications', $args ); - if ( substr_count( $output, '_enable_new_' ) ) { ?> - -

- - +

+ +} +?>
@@ -42,7 +43,8 @@ if ( ! defined( 'ABSPATH' ) ) { * } * ?> */ - do_action( 'um_account_page_hidden_fields', $args ); ?> + do_action( 'um_account_page_hidden_fields', $args ); + ?>
@@ -56,7 +58,7 @@ if ( ! defined( 'ABSPATH' ) ) {
@@ -97,7 +99,7 @@ if ( ! defined( 'ABSPATH' ) ) {
@@ -105,9 +107,11 @@ if ( ! defined( 'ABSPATH' ) ) {
- */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( 'um_before_form', $args ); foreach ( UM()->account()->tabs as $id => $info ) { - + $tab_enabled = UM()->options()->get( 'account_tab_' . $id ); $current_tab = UM()->account()->current_tab; - if ( isset( $info['custom'] ) || UM()->options()->get( 'account_tab_' . $id ) == 1 || $id == 'general' ) { ?> - + if ( isset( $info['custom'] ) || ! empty( $tab_enabled ) || 'general' === $id ) { + ?>
- + @@ -177,10 +164,10 @@ if ( ! defined( 'ABSPATH' ) ) { account()->render_account_tab( $id, $info, $args ); ?>
- - - +
@@ -203,8 +190,7 @@ if ( ! defined( 'ABSPATH' ) ) { * } * ?> */ - do_action( 'um_after_account_page_load' ); ?> - + do_action( 'um_after_account_page_load' ); + ?> - diff --git a/templates/login.php b/templates/login.php index 8423ee92..8ca04fb8 100644 --- a/templates/login.php +++ b/templates/login.php @@ -6,7 +6,7 @@ * * Page: "Login" * - * @version 2.6.1 + * @version 2.6.12 * * @var string $mode * @var int $form_id @@ -14,143 +14,26 @@ */ if ( ! defined( 'ABSPATH' ) ) { exit; -} ?> +} +?>
-
-
- - */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( 'um_before_form', $args ); - - /** - * UM hook - * - * @type action - * @title um_before_{$mode}_fields - * @description Some actions before login form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Login form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_before_{$mode}_fields', 'function_name', 10, 1 ); - * @example - * - */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( "um_before_{$mode}_fields", $args ); - - /** - * UM hook - * - * @type action - * @title um_main_{$mode}_fields - * @description Some actions before login form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Login form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_before_{$mode}_fields', 'function_name', 10, 1 ); - * @example - * - */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( "um_main_{$mode}_fields", $args ); - - /** - * UM hook - * - * @type action - * @title um_after_form_fields - * @description Some actions after login form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Login form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_form_fields', 'function_name', 10, 1 ); - * @example - * - */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( 'um_after_form_fields', $args ); - - /** - * UM hook - * - * @type action - * @title um_after_{$mode}_fields - * @description Some actions after login form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Login form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_{$mode}_fields', 'function_name', 10, 1 ); - * @example - * - */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( "um_after_{$mode}_fields", $args ); - - /** - * UM hook - * - * @type action - * @title um_after_form - * @description Some actions after login form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Login form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_form', 'function_name', 10, 1 ); - * @example - * - */ - do_action( 'um_after_form', $args ); ?> - + /** This action is documented in includes/core/um-actions-profile.php */ + do_action( 'um_after_form', $args ); + ?>
-
-
diff --git a/templates/password-change.php b/templates/password-change.php index 0ecc4f03..89d4e361 100644 --- a/templates/password-change.php +++ b/templates/password-change.php @@ -6,7 +6,7 @@ * * Call: function ultimatemember_password() * - * @version 2.6.1 + * @version 2.6.12 * * @var string $mode * @var string $rp_key @@ -15,7 +15,8 @@ */ if ( ! defined( 'ABSPATH' ) ) { exit; -} ?> +} +?>
@@ -90,27 +91,9 @@ if ( ! defined( 'ABSPATH' ) ) { * ?> */ do_action( 'um_change_password_form', $args ); - - /** - * UM hook - * - * @type action - * @title um_after_form_fields - * @description Password change after form content - * @input_vars - * [{"var":"$args","type":"array","desc":"Password change shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_form_fields', 'function_name', 10, 1 ); - * @example - * - */ - do_action( 'um_after_form_fields', $args ); ?> + /** This action is documented in includes/core/um-actions-profile.php */ + do_action( 'um_after_form_fields', $args ); + ?>
diff --git a/templates/password-reset.php b/templates/password-reset.php index e9ec2251..d0d0bcc9 100644 --- a/templates/password-reset.php +++ b/templates/password-reset.php @@ -6,7 +6,7 @@ * * Call: function ultimatemember_password() * - * @version 2.6.1 + * @version 2.6.12 * * @var string $mode * @var int $form_id @@ -14,7 +14,8 @@ */ if ( ! defined( 'ABSPATH' ) ) { exit; -} ?> +} +?>
@@ -143,28 +144,10 @@ if ( ! defined( 'ABSPATH' ) ) { * ?> */ do_action( 'um_reset_password_form', $args ); - - /** - * UM hook - * - * @type action - * @title um_after_form_fields - * @description Password reset after display form - * @input_vars - * [{"var":"$args","type":"array","desc":"Password reset shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_form_fields', 'function_name', 10, 1 ); - * @example - * - */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( 'um_after_form_fields', $args ); - } ?> + } + ?>
diff --git a/templates/register.php b/templates/register.php index 255b8a1a..d2b1fc72 100644 --- a/templates/register.php +++ b/templates/register.php @@ -6,7 +6,7 @@ * * Page: "Register" * - * @version 2.6.1 + * @version 2.6.12 * * @var string $mode * @var int $form_id @@ -18,143 +18,26 @@ if ( ! defined( 'ABSPATH' ) ) { if ( ! is_user_logged_in() ) { um_reset_user(); -} ?> +} +?>
- -
- +
- - */ - do_action( "um_before_form", $args ); - - /** - * UM hook - * - * @type action - * @title um_before_{$mode}_fields - * @description Some actions before register form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Register form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_before_{$mode}_fields', 'function_name', 10, 1 ); - * @example - * - */ + /** This action is documented in includes/core/um-actions-profile.php */ + do_action( 'um_before_form', $args ); + /** This action is documented in includes/core/um-actions-profile.php */ do_action( "um_before_{$mode}_fields", $args ); - - /** - * UM hook - * - * @type action - * @title um_before_{$mode}_fields - * @description Some actions before register form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Register form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_before_{$mode}_fields', 'function_name', 10, 1 ); - * @example - * - */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( "um_main_{$mode}_fields", $args ); - - /** - * UM hook - * - * @type action - * @title um_after_form_fields - * @description Some actions after register form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Register form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_form_fields', 'function_name', 10, 1 ); - * @example - * - */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( 'um_after_form_fields', $args ); - - /** - * UM hook - * - * @type action - * @title um_after_{$mode}_fields - * @description Some actions after register form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Register form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_{$mode}_fields', 'function_name', 10, 1 ); - * @example - * - */ + /** This action is documented in includes/core/um-actions-profile.php */ do_action( "um_after_{$mode}_fields", $args ); - - /** - * UM hook - * - * @type action - * @title um_after_form - * @description Some actions after register form fields - * @input_vars - * [{"var":"$args","type":"array","desc":"Register form shortcode arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_form', 'function_name', 10, 1 ); - * @example - * - */ - do_action( 'um_after_form', $args ); ?> - + /** This action is documented in includes/core/um-actions-profile.php */ + do_action( 'um_after_form', $args ); + ?>
-
-