diff --git a/includes/admin/class-admin-functions.php b/includes/admin/class-admin-functions.php index 727002fe..2796f70b 100644 --- a/includes/admin/class-admin-functions.php +++ b/includes/admin/class-admin-functions.php @@ -28,7 +28,7 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) { * @param bool $action */ function check_ajax_nonce( $action = false ) { - $nonce = isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : ''; + $nonce = isset( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : ''; $action = empty( $action ) ? 'um-admin-nonce' : $action; if ( ! wp_verify_nonce( $nonce, $action ) ) { @@ -81,7 +81,7 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) { if ( in_array( $post_type, $cpt ) ) { return true; } - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' ) { + } elseif ( isset( $_REQUEST['action'] ) && sanitize_key( $_REQUEST['action'] ) == 'edit' ) { $post_type = get_post_type(); if ( in_array( $post_type, $cpt ) ) { return true; @@ -113,4 +113,4 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) { return false; } } -} \ No newline at end of file +} diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index ed634aec..8a290e75 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -2,7 +2,9 @@ namespace um\admin; // Exit if accessed directly. -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} if ( ! class_exists( 'um\admin\Admin' ) ) { @@ -17,17 +19,494 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { /** * @var string */ - var $templates_path; + public $templates_path; + + + /** + * @var array + */ + public $role_meta; + + + /** + * @var array + */ + public $restriction_term_meta; + + + /** + * @var array + */ + public $member_directory_meta; + + + /** + * @var array + */ + public $form_meta; + + + /** + * @var array + */ + public $restriction_post_meta; /** * Admin constructor. */ - function __construct() { + public function __construct() { parent::__construct(); $this->templates_path = um_path . 'includes/admin/templates/'; + $this->role_meta = apply_filters( + 'um_role_meta_map', + array( + '_um_priority' => array( + 'sanitize' => 'int', + ), + '_um_can_access_wpadmin' => array( + 'sanitize' => 'bool', + ), + '_um_can_not_see_adminbar' => array( + 'sanitize' => 'bool', + ), + '_um_can_edit_everyone' => array( + 'sanitize' => 'bool', + ), + '_um_can_edit_roles' => array( + 'sanitize' => array( $this, 'sanitize_existed_role' ), + ), + '_um_can_delete_everyone' => array( + 'sanitize' => 'bool', + ), + '_um_can_delete_roles' => array( + 'sanitize' => array( $this, 'sanitize_existed_role' ), + ), + '_um_can_edit_profile' => array( + 'sanitize' => 'bool', + ), + '_um_can_delete_profile' => array( + 'sanitize' => 'bool', + ), + '_um_can_view_all' => array( + 'sanitize' => 'bool', + ), + '_um_can_view_roles' => array( + 'sanitize' => array( $this, 'sanitize_existed_role' ), + ), + '_um_can_make_private_profile' => array( + 'sanitize' => 'bool', + ), + '_um_can_access_private_profile' => array( + 'sanitize' => 'bool', + ), + '_um_profile_noindex' => array( + 'sanitize' => array( $this, 'sanitize_profile_noindex' ), + ), + '_um_default_homepage' => array( + 'sanitize' => 'bool', + ), + '_um_redirect_homepage' => array( + 'sanitize' => 'url', + ), + '_um_status' => array( + 'sanitize' => 'sanitize_array_key', + 'default' => 'approved', + 'array' => array( 'approved', 'checkmail', 'pending' ), + ), + '_um_auto_approve_act' => array( + 'sanitize' => 'sanitize_array_key', + 'default' => 'redirect_profile', + 'array' => array( 'redirect_profile', 'redirect_url' ), + ), + '_um_auto_approve_url' => array( + 'sanitize' => 'url', + ), + '_um_login_email_activate' => array( + 'sanitize' => 'bool', + ), + '_um_checkmail_action' => array( + 'sanitize' => 'sanitize_array_key', + 'default' => 'show_message', + 'array' => array( 'show_message', 'redirect_url' ), + ), + '_um_checkmail_message' => array( + 'sanitize' => 'textarea', + ), + '_um_checkmail_url' => array( + 'sanitize' => 'url', + ), + '_um_url_email_activate' => array( + 'sanitize' => 'url', + ), + '_um_pending_action' => array( + 'sanitize' => 'sanitize_array_key', + 'default' => 'show_message', + 'array' => array( 'show_message', 'redirect_url' ), + ), + '_um_pending_message' => array( + 'sanitize' => 'textarea', + ), + '_um_pending_url' => array( + 'sanitize' => 'url', + ), + '_um_after_login' => array( + 'sanitize' => 'sanitize_array_key', + 'default' => 'redirect_profile', + 'array' => array( 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ), + ), + '_um_login_redirect_url' => array( + 'sanitize' => 'url', + ), + '_um_after_logout' => array( + 'sanitize' => 'sanitize_array_key', + 'default' => 'redirect_home', + 'array' => array( 'redirect_home', 'redirect_url' ), + ), + '_um_logout_redirect_url' => array( + 'sanitize' => 'url', + ), + '_um_after_delete' => array( + 'sanitize' => 'sanitize_array_key', + 'default' => 'redirect_home', + 'array' => array( 'redirect_home', 'redirect_url' ), + ), + '_um_delete_redirect_url' => array( + 'sanitize' => 'url', + ), + 'wp_capabilities' => array( + 'sanitize' => array( $this, 'sanitize_wp_capabilities' ), + ), + ) + ); + + $this->restriction_post_meta = apply_filters( + 'um_restriction_post_meta_map', + array( + '_um_custom_access_settings' => array( + 'sanitize' => 'bool', + ), + '_um_accessible' => array( + 'sanitize' => 'int', + ), + '_um_access_roles' => array( + 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ), + ), + '_um_noaccess_action' => array( + 'sanitize' => 'int', + ), + '_um_restrict_by_custom_message' => array( + 'sanitize' => 'int', + ), + '_um_restrict_custom_message' => array( + 'sanitize' => 'textarea', + ), + '_um_access_redirect' => array( + 'sanitize' => 'int', + ), + '_um_access_redirect_url' => array( + 'sanitize' => 'url', + ), + '_um_access_hide_from_queries' => array( + 'sanitize' => 'bool', + ), + ) + ); + + $this->restriction_term_meta = apply_filters( + 'um_restriction_term_meta_map', + array( + '_um_custom_access_settings' => array( + 'sanitize' => 'bool', + ), + '_um_accessible' => array( + 'sanitize' => 'int', + ), + '_um_access_roles' => array( + 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ), + ), + '_um_noaccess_action' => array( + 'sanitize' => 'int', + ), + '_um_restrict_by_custom_message' => array( + 'sanitize' => 'int', + ), + '_um_restrict_custom_message' => array( + 'sanitize' => 'textarea', + ), + '_um_access_redirect' => array( + 'sanitize' => 'int', + ), + '_um_access_redirect_url' => array( + 'sanitize' => 'url', + ), + '_um_access_hide_from_queries' => array( + 'sanitize' => 'bool', + ), + ) + ); + + $this->member_directory_meta = apply_filters( + 'um_member_directory_meta_map', + array( + '_um_directory_template' => array( + 'sanitize' => 'text', + ), + '_um_mode' => array( + 'sanitize' => 'key', + ), + '_um_view_types' => array( + 'sanitize' => array( $this, 'sanitize_md_view_types' ), + ), + '_um_default_view' => array( + 'sanitize' => 'key', + ), + '_um_roles' => array( + 'sanitize' => array( $this, 'sanitize_existed_role' ), + ), + '_um_has_profile_photo' => array( + 'sanitize' => 'bool', + ), + '_um_show_these_users' => array( + 'sanitize' => 'textarea', + ), + '_um_exclude_these_users' => array( + 'sanitize' => 'textarea', + ), + '_um_must_search' => array( + 'sanitize' => 'bool', + ), + '_um_max_users' => array( + 'sanitize' => 'absint', + ), + '_um_profiles_per_page' => array( + 'sanitize' => 'absint', + ), + '_um_profiles_per_page_mobile' => array( + 'sanitize' => 'absint', + ), + '_um_directory_header' => array( + 'sanitize' => 'text', + ), + '_um_directory_header_single' => array( + 'sanitize' => 'text', + ), + '_um_directory_no_users' => array( + 'sanitize' => 'text', + ), + '_um_profile_photo' => array( + 'sanitize' => 'bool', + ), + '_um_cover_photos' => array( + 'sanitize' => 'bool', + ), + '_um_show_name' => array( + 'sanitize' => 'bool', + ), + '_um_show_tagline' => array( + 'sanitize' => 'bool', + ), + '_um_tagline_fields' => array( + 'sanitize' => array( $this, 'sanitize_user_field' ), + ), + '_um_show_userinfo' => array( + 'sanitize' => 'bool', + ), + '_um_reveal_fields' => array( + 'sanitize' => array( $this, 'sanitize_user_field' ), + ), + '_um_show_social' => array( + 'sanitize' => 'bool', + ), + '_um_userinfo_animate' => array( + 'sanitize' => 'bool', + ), + '_um_search' => array( + 'sanitize' => 'bool', + ), + '_um_roles_can_search' => array( + 'sanitize' => array( $this, 'sanitize_existed_role' ), + ), + '_um_filters' => array( + 'sanitize' => 'bool', + ), + '_um_roles_can_filter' => array( + 'sanitize' => array( $this, 'sanitize_existed_role' ), + ), + '_um_search_fields' => array( + 'sanitize' => array( $this, 'sanitize_filter_fields' ), + ), + '_um_filters_expanded' => array( + 'sanitize' => 'bool', + ), + '_um_filters_is_collapsible' => array( + 'sanitize' => 'bool', + ), + '_um_search_filters' => array( + 'sanitize' => array( $this, 'sanitize_md_default_filters' ), + ), + '_um_sortby' => array( + 'sanitize' => array( $this, 'sanitize_sort_by_fields' ), + ), + '_um_sortby_custom' => array( + 'sanitize' => 'text', + ), + '_um_sortby_custom_label' => array( + 'sanitize' => 'text', + ), + '_um_enable_sorting' => array( + 'sanitize' => 'bool', + ), + '_um_sorting_fields' => array( + 'sanitize' => array( $this, 'sanitize_md_sorting_fields' ), + ), + ) + ); + + $this->form_meta = apply_filters( + 'um_form_meta_map', + array( + '_um_mode' => array( + 'sanitize' => 'key', + ), + '_um_register_use_gdpr' => array( + 'sanitize' => 'bool', + ), + '_um_register_use_gdpr_content_id' => array( + 'sanitize' => 'absint', + ), + '_um_register_use_gdpr_toggle_show' => array( + 'sanitize' => 'text', + ), + '_um_register_use_gdpr_toggle_hide' => array( + 'sanitize' => 'text', + ), + '_um_register_use_gdpr_agreement' => array( + 'sanitize' => 'text', + ), + '_um_register_use_gdpr_error_text' => array( + 'sanitize' => 'text', + ), + '_um_register_use_custom_settings' => array( + 'sanitize' => 'bool', + ), + '_um_register_role' => array( + 'sanitize' => array( $this, 'sanitize_existed_role' ), + ), + '_um_register_template' => array( + 'sanitize' => 'text', + ), + '_um_register_max_width' => array( + 'sanitize' => 'absint', + ), + '_um_register_icons' => array( + 'sanitize' => 'key', + ), + '_um_register_primary_btn_word' => array( + 'sanitize' => 'text', + ), + '_um_register_secondary_btn' => array( + 'sanitize' => 'bool', + ), + '_um_register_secondary_btn_word' => array( + 'sanitize' => 'text', + ), + '_um_login_after_login' => array( + 'sanitize' => 'key', + ), + '_um_login_redirect_url' => array( + 'sanitize' => 'url', + ), + '_um_login_use_custom_settings' => array( + 'sanitize' => 'bool', + ), + '_um_login_template' => array( + 'sanitize' => 'text', + ), + '_um_login_max_width' => array( + 'sanitize' => 'absint', + ), + '_um_login_icons' => array( + 'sanitize' => 'key', + ), + '_um_login_primary_btn_word' => array( + 'sanitize' => 'text', + ), + '_um_login_secondary_btn' => array( + 'sanitize' => 'bool', + ), + '_um_login_secondary_btn_word' => array( + 'sanitize' => 'text', + ), + '_um_login_forgot_pass_link' => array( + 'sanitize' => 'bool', + ), + '_um_login_show_rememberme' => array( + 'sanitize' => 'bool', + ), + '_um_profile_metafields' => array( + 'sanitize' => array( $this, 'sanitize_user_field' ), + ), + '_um_profile_use_custom_settings' => array( + 'sanitize' => 'bool', + ), + '_um_profile_role' => array( + 'sanitize' => array( $this, 'sanitize_existed_role' ), + ), + '_um_profile_template' => array( + 'sanitize' => 'text', + ), + '_um_profile_max_width' => array( + 'sanitize' => 'absint', + ), + '_um_profile_area_max_width' => array( + 'sanitize' => 'absint', + ), + '_um_profile_icons' => array( + 'sanitize' => 'key', + ), + '_um_profile_primary_btn_word' => array( + 'sanitize' => 'text', + ), + '_um_profile_secondary_btn' => array( + 'sanitize' => 'bool', + ), + '_um_profile_secondary_btn_word' => array( + 'sanitize' => 'text', + ), + '_um_profile_cover_enabled' => array( + 'sanitize' => 'bool', + ), + '_um_profile_coversize' => array( + 'sanitize' => 'absint', + ), + '_um_profile_cover_ratio' => array( + 'sanitize' => 'text', + ), + '_um_profile_disable_photo_upload' => array( + 'sanitize' => 'bool', + ), + '_um_profile_photosize' => array( + 'sanitize' => array( $this, 'sanitize_photosize' ), + ), + '_um_profile_photo_required' => array( + 'sanitize' => 'bool', + ), + '_um_profile_show_name' => array( + 'sanitize' => 'bool', + ), + '_um_profile_show_social_links' => array( + 'sanitize' => 'bool', + ), + '_um_profile_show_bio' => array( + 'sanitize' => 'bool', + ), + + ) + ); + add_action( 'admin_init', array( &$this, 'admin_init' ), 0 ); $prefix = is_network_admin() ? 'network_admin_' : ''; @@ -52,6 +531,601 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { } + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_md_sorting_fields( $value ) { + $filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) ); + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $filter_fields ) { + return in_array( sanitize_text_field( $v ), $filter_fields, true ); + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_sort_by_fields( $value ) { + $sorting_fields = UM()->member_directory()->default_sorting; + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $sorting_fields ) { + return in_array( sanitize_text_field( $v ), $sorting_fields, true ); + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_md_default_filters( $value ) { + $filter_fields = UM()->member_directory()->filter_fields; + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $filter_fields ) { + return in_array( sanitize_text_field( $v ), $filter_fields, true ); + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_filter_fields( $value ) { + $filter_fields = UM()->member_directory()->filter_fields; + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $filter_fields ) { + return in_array( sanitize_text_field( $v ), $filter_fields, true ); + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_user_field( $value ) { + $user_fields = array(); + foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) { + $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : ''; + } + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $user_fields ) { + return in_array( sanitize_text_field( $v ), $user_fields, true ); + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_photosize( $value ) { + $sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ); + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $sizes ) { + return in_array( sanitize_text_field( $v ), $sizes, true ); + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_md_view_types( $value ) { + $view_types = array_map( + function( $item ) { + return $item['title']; + }, + UM()->member_directory()->view_types + ); + + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $view_types ) { + return in_array( sanitize_key( $k ), $view_types, true ) && 1 === (int) $v; + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_restriction_existed_role( $value ) { + $all_roles = UM()->roles()->get_roles( false ); + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $all_roles ) { + return in_array( sanitize_key( $k ), $all_roles, true ) && 1 === (int) $v; + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_existed_role( $value ) { + $all_roles = array_keys( UM()->roles()->get_roles() ); + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $all_roles ) { + return in_array( sanitize_key( $v ), $all_roles, true ); + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param array|string $value + * + * @return array|string + */ + public function sanitize_tabs_privacy( $value ) { + $all_privacy = array_keys( UM()->profile()->tabs_privacy() ); + + if ( '' !== $value ) { + $value = array_filter( + $value, + function( $v, $k ) use ( $all_privacy ) { + return in_array( $v, $all_privacy, true ); + }, + ARRAY_FILTER_USE_BOTH + ); + } + + return $value; + } + + + /** + * @param $value + * + * @return bool|string + */ + public function sanitize_profile_noindex( $value ) { + $value = '' !== $value ? (bool) $value : $value; + return $value; + } + + + /** + * @param $value + * + * @return array + */ + public function sanitize_wp_capabilities( $value ) { + $value = array_map( 'boolval', array_filter( $value ) ); + return $value; + } + + + /** + * @param array $data + * + * @return array + */ + public function sanitize_role_meta( $data ) { + $sanitized = array(); + foreach ( $data as $k => $v ) { + if ( ! array_key_exists( $k, $this->role_meta ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( ! array_key_exists( 'sanitize', $this->role_meta[ $k ] ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( is_callable( $this->role_meta[ $k ]['sanitize'], true, $callable_name ) ) { + add_filter( 'um_role_meta_sanitize_' . $k, $this->role_meta[ $k ]['sanitize'], 10, 1 ); + } + + switch ( $this->role_meta[ $k ]['sanitize'] ) { + default: + $sanitized[ $k ] = apply_filters( 'um_role_meta_sanitize_' . $k, $data[ $k ] ); + break; + case 'int': + $sanitized[ $k ] = (int) $v; + break; + case 'bool': + $sanitized[ $k ] = (bool) $v; + break; + case 'url': + $sanitized[ $k ] = esc_url_raw( $v ); + break; + case 'textarea': + $sanitized[ $k ] = sanitize_textarea_field( $v ); + break; + case 'sanitize_array_key': + if ( ! array_key_exists( 'default', $this->role_meta[ $k ] ) || ! array_key_exists( 'array', $this->role_meta[ $k ] ) ) { + continue 2; + } + + $sanitized[ $k ] = ! in_array( sanitize_key( $v ), $this->role_meta[ $k ]['array'], true ) ? $this->role_meta[ $k ]['default'] : sanitize_key( $v ); + break; + } + } + + $data = $sanitized; + + $data = apply_filters( 'um_save_role_meta_sanitize', $data ); + + return $data; + } + + + /** + * @param array $data + * + * @return array + */ + public function sanitize_post_restriction_meta( $data ) { + $sanitized = array(); + foreach ( $data as $k => $v ) { + if ( ! array_key_exists( $k, $this->restriction_post_meta ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( ! array_key_exists( 'sanitize', $this->restriction_post_meta[ $k ] ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( is_callable( $this->restriction_post_meta[ $k ]['sanitize'], true, $callable_name ) ) { + add_filter( 'um_restriction_post_meta_sanitize_' . $k, $this->restriction_post_meta[ $k ]['sanitize'], 10, 1 ); + } + + switch ( $this->restriction_post_meta[ $k ]['sanitize'] ) { + default: + $sanitized[ $k ] = apply_filters( 'um_restriction_post_meta_sanitize_' . $k, $data[ $k ] ); + break; + case 'int': + $sanitized[ $k ] = (int) $v; + break; + case 'bool': + $sanitized[ $k ] = (bool) $v; + break; + case 'url': + $sanitized[ $k ] = esc_url_raw( $v ); + break; + case 'textarea': + $sanitized[ $k ] = sanitize_textarea_field( $v ); + break; + } + } + + $data = $sanitized; + + $data = apply_filters( 'um_save_restriction_post_meta_sanitize', $data ); + + return $data; + } + + + /** + * @param array $data + * + * @return array + */ + public function sanitize_term_restriction_meta( $data ) { + $sanitized = array(); + foreach ( $data as $k => $v ) { + if ( ! array_key_exists( $k, $this->restriction_term_meta ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( ! array_key_exists( 'sanitize', $this->restriction_term_meta[ $k ] ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( is_callable( $this->restriction_term_meta[ $k ]['sanitize'], true, $callable_name ) ) { + add_filter( 'um_restriction_term_meta_sanitize_' . $k, $this->restriction_term_meta[ $k ]['sanitize'], 10, 1 ); + } + + switch ( $this->restriction_term_meta[ $k ]['sanitize'] ) { + default: + $sanitized[ $k ] = apply_filters( 'um_restriction_term_meta_sanitize_' . $k, $data[ $k ] ); + break; + case 'int': + $sanitized[ $k ] = (int) $v; + break; + case 'bool': + $sanitized[ $k ] = (bool) $v; + break; + case 'url': + $sanitized[ $k ] = esc_url_raw( $v ); + break; + case 'textarea': + $sanitized[ $k ] = sanitize_textarea_field( $v ); + break; + } + } + + $data = $sanitized; + + $data = apply_filters( 'um_save_restriction_term_meta_sanitize', $data ); + + return $data; + } + + + /** + * @param array $data + * + * @return array + */ + public function sanitize_member_directory_meta( $data ) { + $sanitized = array(); + foreach ( $data as $k => $v ) { + if ( ! array_key_exists( $k, $this->member_directory_meta ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( ! array_key_exists( 'sanitize', $this->member_directory_meta[ $k ] ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( is_callable( $this->member_directory_meta[ $k ]['sanitize'], true, $callable_name ) ) { + add_filter( 'um_member_directory_meta_sanitize_' . $k, $this->member_directory_meta[ $k ]['sanitize'], 10, 1 ); + } + + switch ( $this->member_directory_meta[ $k ]['sanitize'] ) { + default: + $sanitized[ $k ] = apply_filters( 'um_member_directory_meta_sanitize_' . $k, $data[ $k ] ); + break; + case 'int': + $sanitized[ $k ] = (int) $v; + break; + case 'bool': + $sanitized[ $k ] = (bool) $v; + break; + case 'url': + $sanitized[ $k ] = esc_url_raw( $v ); + break; + case 'text': + $sanitized[ $k ] = sanitize_text_field( $v ); + break; + case 'textarea': + $sanitized[ $k ] = sanitize_textarea_field( $v ); + break; + } + } + + $data = $sanitized; + + $data = apply_filters( 'um_save_member_directory_meta_sanitize', $data ); + + return $data; + } + + + /** + * @param array $data + * + * @return array + */ + public function sanitize_form_meta( $data ) { + $sanitized = array(); + foreach ( $data as $k => $v ) { + if ( ! array_key_exists( $k, $this->form_meta ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( ! array_key_exists( 'sanitize', $this->form_meta[ $k ] ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( is_callable( $this->form_meta[ $k ]['sanitize'], true, $callable_name ) ) { + add_filter( 'um_form_meta_sanitize_' . $k, $this->form_meta[ $k ]['sanitize'], 10, 1 ); + } + + switch ( $this->form_meta[ $k ]['sanitize'] ) { + default: + $sanitized[ $k ] = apply_filters( 'um_form_meta_sanitize_' . $k, $data[ $k ] ); + break; + case 'int': + $sanitized[ $k ] = (int) $v; + break; + case 'bool': + $sanitized[ $k ] = (bool) $v; + break; + case 'url': + $sanitized[ $k ] = esc_url_raw( $v ); + break; + case 'text': + $sanitized[ $k ] = sanitize_text_field( $v ); + break; + case 'textarea': + $sanitized[ $k ] = sanitize_textarea_field( $v ); + break; + } + } + + $data = $sanitized; + + $data = apply_filters( 'um_save_form_meta_sanitize', $data ); + + return $data; + } + + + /** + * @param array $data + * + * @return array + */ + public function sanitize_options( $data ) { + $sanitized = array(); + foreach ( $data as $k => $v ) { + if ( ! array_key_exists( $k, UM()->admin_settings()->settings_map ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( ! array_key_exists( 'sanitize', UM()->admin_settings()->settings_map[ $k ] ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( is_callable( UM()->admin_settings()->settings_map[ $k ]['sanitize'], true, $callable_name ) ) { + add_filter( 'um_settings_sanitize_' . $k, UM()->admin_settings()->settings_map[ $k ]['sanitize'], 10, 1 ); + } + + switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) { + default: + $sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $data[ $k ] ); + break; + case 'int': + $sanitized[ $k ] = (int) $v; + break; + case 'absint': + $sanitized[ $k ] = absint( $v ); + break; + case 'absints_array': + $sanitized[ $k ] = array_map( 'absint', $v ); + break; + case 'key': + $sanitized[ $k ] = sanitize_key( $v ); + break; + case 'keys_array': + $sanitized[ $k ] = array_map( 'sanitize_key', $v ); + break; + case 'bool': + $sanitized[ $k ] = (bool) $v; + break; + case 'url': + $sanitized[ $k ] = esc_url_raw( $v ); + break; + case 'urls_array': + $sanitized[ $k ] = array_map( 'esc_url_raw', $v ); + break; + case 'wp_kses': + $sanitized[ $k ] = wp_kses_post( $v ); + break; + case 'textarea': + $sanitized[ $k ] = sanitize_textarea_field( $v ); + break; + case 'sanitize_array_key': + if ( ! array_key_exists( 'default', UM()->admin_settings()->settings_map[ $k ] ) || ! array_key_exists( 'array', UM()->admin_settings()->settings_map[ $k ] ) ) { + continue 2; + } + + $sanitized[ $k ] = ! in_array( sanitize_key( $v ), UM()->admin_settings()->settings_map[ $k ]['array'], true ) ? UM()->admin_settings()->settings_map[ $k ]['default'] : sanitize_key( $v ); + break; + } + } + + $data = $sanitized; + + $data = apply_filters( 'um_save_settings_sanitize', $data ); + + return $data; + } + + /** * Adds class to our admin pages * @@ -59,7 +1133,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { * * @return string */ - function admin_body_class( $classes ) { + public function admin_body_class( $classes ) { if ( $this->is_um_screen() ) { return "$classes um-admin"; } @@ -70,7 +1144,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { /** * */ - function manual_upgrades_request() { + public function manual_upgrades_request() { if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) { die(); } @@ -458,4 +1532,4 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { return UM()->classes['admin_notices']; } } -} \ No newline at end of file +} diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php index 2831816f..451bee1c 100644 --- a/includes/admin/core/class-admin-builder.php +++ b/includes/admin/core/class-admin-builder.php @@ -781,7 +781,19 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { */ extract( $_POST ); - switch ( $act_id ) { + if ( isset( $arg1 ) ) { + $arg1 = sanitize_text_field( $arg1 ); + } + + if ( isset( $arg2 ) ) { + $arg2 = sanitize_text_field( $arg2 ); + } + + if ( isset( $arg3 ) ) { + $arg3 = sanitize_text_field( $arg3 ); + } + + switch ( sanitize_key( $act_id ) ) { default: @@ -806,7 +818,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { * } * ?> */ - do_action( 'um_admin_ajax_modal_content__hook', $act_id ); + do_action( 'um_admin_ajax_modal_content__hook', sanitize_key( $act_id ) ); /** * UM hook * @@ -824,7 +836,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { * } * ?> */ - do_action( "um_admin_ajax_modal_content__hook_{$act_id}" ); + do_action( "um_admin_ajax_modal_content__hook_" . sanitize_key( $act_id ) ); $output = ob_get_clean(); break; @@ -1208,4 +1220,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { } } -} \ No newline at end of file +} diff --git a/includes/admin/core/class-admin-dragdrop.php b/includes/admin/core/class-admin-dragdrop.php index 1b0005f7..b8675d00 100644 --- a/includes/admin/core/class-admin-dragdrop.php +++ b/includes/admin/core/class-admin-dragdrop.php @@ -26,7 +26,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { /** * Update order of fields */ - function update_order() { + public function update_order() { UM()->admin()->check_ajax_nonce(); if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) { @@ -38,14 +38,18 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { */ extract( $_POST ); + if ( isset( $form_id ) ) { + $form_id = absint( $form_id ); + } + $fields = UM()->query()->get_attr( 'custom_fields', $form_id ); - $this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() ); + $this->row_data = get_option( 'um_form_rowdata_' . $form_id, array() ); $this->exist_rows = array(); if ( ! empty( $fields ) ) { foreach ( $fields as $key => $array ) { - if ( $array['type'] == 'row' ) { + if ( 'row' === $array['type'] ) { $this->row_data[ $key ] = $array; unset( $fields[ $key ] ); } @@ -56,6 +60,8 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { foreach ( $_POST as $key => $value ) { + $key = sanitize_key( $key ); + // adding rows if ( 0 === strpos( $key, '_um_row_' ) ) { @@ -64,18 +70,18 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { $row_id = str_replace( '_um_row_', '', $key ); $row_array = array( - 'type' => 'row', - 'id' => $value, - 'sub_rows' => $_POST[ '_um_rowsub_' . $row_id . '_rows' ], - 'cols' => $_POST[ '_um_rowcols_' . $row_id . '_cols' ], - 'origin' => $_POST[ '_um_roworigin_' . $row_id . '_val' ], + 'type' => 'row', + 'id' => sanitize_key( $value ), + 'sub_rows' => absint( $_POST[ '_um_rowsub_' . $row_id . '_rows' ] ), + 'cols' => absint( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] ), + 'origin' => sanitize_key( $_POST[ '_um_roworigin_' . $row_id . '_val' ] ), ); $row_args = $row_array; if ( isset( $this->row_data[ $row_array['origin'] ] ) ) { foreach ( $this->row_data[ $row_array['origin'] ] as $k => $v ) { - if ( $k != 'position' && $k != 'metakey' ) { + if ( 'position' !== $k && 'metakey' !== $k ) { $update_args[ $k ] = $v; } } @@ -93,7 +99,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { if ( 0 === strpos( $key, 'um_position_' ) ) { $field_key = str_replace( 'um_position_', '', $key ); if ( isset( $fields[ $field_key ] ) ) { - $fields[ $field_key ]['position'] = $value; + $fields[ $field_key ]['position'] = absint( $value ); } } @@ -101,7 +107,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { if ( 0 === strpos( $key, 'um_row_' ) ) { $field_key = str_replace( 'um_row_', '', $key ); if ( isset( $fields[ $field_key ] ) ) { - $fields[ $field_key ]['in_row'] = $value; + $fields[ $field_key ]['in_row'] = sanitize_key( $value ); } } @@ -109,7 +115,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { if ( 0 === strpos( $key, 'um_subrow_' ) ) { $field_key = str_replace( 'um_subrow_', '', $key ); if ( isset( $fields[ $field_key ] ) ) { - $fields[ $field_key ]['in_sub_row'] = $value; + $fields[ $field_key ]['in_sub_row'] = sanitize_key( $value ); } } @@ -117,7 +123,7 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { if ( 0 === strpos( $key, 'um_col_' ) ) { $field_key = str_replace( 'um_col_', '', $key ); if ( isset( $fields[ $field_key ] ) ) { - $fields[ $field_key ]['in_column'] = $value; + $fields[ $field_key ]['in_column'] = absint( $value ); } } @@ -125,21 +131,20 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { if ( 0 === strpos( $key, 'um_group_' ) ) { $field_key = str_replace( 'um_group_', '', $key ); if ( isset( $fields[ $field_key ] ) ) { - $fields[ $field_key ]['in_group'] = $value; + $fields[ $field_key ]['in_group'] = absint( $value ); } } - } foreach ( $this->row_data as $k => $v ) { - if ( ! in_array( $k, $this->exist_rows ) ) { + if ( ! in_array( $k, $this->exist_rows, true ) ) { unset( $this->row_data[ $k ] ); } } update_option( 'um_existing_rows_' . $form_id, $this->exist_rows ); - update_option( 'um_form_rowdata_' . $form_id , $this->row_data ); + update_option( 'um_form_rowdata_' . $form_id, $this->row_data ); UM()->query()->update_attr( 'custom_fields', $form_id, $fields ); @@ -149,11 +154,11 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { /** * Load form to maintain form order */ - function load_field_order() { + public function load_field_order() { $screen = get_current_screen(); - if ( ! isset( $screen->id ) || $screen->id != 'um_form' ) { + if ( ! isset( $screen->id ) || 'um_form' !== $screen->id ) { return; } ?> @@ -235,4 +240,4 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) { } } -} \ No newline at end of file +} diff --git a/includes/admin/core/class-admin-enqueue.php b/includes/admin/core/class-admin-enqueue.php index d1a27aab..bae17427 100644 --- a/includes/admin/core/class-admin-enqueue.php +++ b/includes/admin/core/class-admin-enqueue.php @@ -96,10 +96,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * */ function enqueue_cpt_scripts() { - if ( ( isset( $_GET['post_type'] ) && 'um_form' == sanitize_key( $_GET['post_type'] ) ) || - ( isset( $_GET['post'] ) && 'um_form' == get_post_type( absint( $_GET['post'] ) ) ) ) { + if ( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) || + ( isset( $_GET['post'] ) && 'um_form' === get_post_type( absint( $_GET['post'] ) ) ) ) { $this->um_cpt_form_screen = true; - add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ), 20 ); + add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ), 20 ); } $this->post_page = true; @@ -296,9 +296,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { //and WP calculate page height $hide_footer = false; global $pagenow, $post; - if ( ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) && - ( ( isset( $_GET['post_type'] ) && 'um_form' == sanitize_key( $_GET['post_type'] ) ) || - ( isset( $post->post_type ) && 'um_form' == $post->post_type ) ) ) { + if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && + ( ( isset( $_GET['post_type'] ) && 'um_form' === sanitize_key( $_GET['post_type'] ) ) || + ( isset( $post->post_type ) && 'um_form' === $post->post_type ) ) ) { $hide_footer = true; } diff --git a/includes/admin/core/class-admin-menu.php b/includes/admin/core/class-admin-menu.php index 6cabd17d..26c07eb3 100644 --- a/includes/admin/core/class-admin-menu.php +++ b/includes/admin/core/class-admin-menu.php @@ -191,7 +191,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { function um_roles_pages() { if ( empty( $_GET['tab'] ) ) { include_once um_path . 'includes/admin/core/list-tables/roles-list-table.php'; - } elseif ( sanitize_key( $_GET['tab'] ) == 'add' || sanitize_key( $_GET['tab'] ) == 'edit' ) { + } elseif ( 'add' === sanitize_key( $_GET['tab'] ) || 'edit' === sanitize_key( $_GET['tab'] ) ) { include_once um_path . 'includes/admin/templates/role/role-edit.php'; } else { um_js_redirect( add_query_arg( array( 'page' => 'um_roles' ), get_admin_url( 'admin.php' ) ) ); @@ -340,4 +340,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { } } -} \ No newline at end of file +} diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index ceaf819f..d8a32c7d 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -195,7 +195,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { * @param $post_id * @param $post */ - function save_metabox_custom( $post_id, $post ) { + public function save_metabox_custom( $post_id, $post ) { // validate nonce if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) || ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) { @@ -313,7 +313,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { } if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) { - update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] ); + $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] ); + + update_post_meta( $post_id, 'um_content_restriction', $restriction_meta ); } else { delete_post_meta( $post_id, 'um_content_restriction' ); } @@ -340,7 +342,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { } if ( ! empty( $_POST['um_content_restriction'] ) && is_array( $_POST['um_content_restriction'] ) ) { - update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] ); + $restriction_meta = UM()->admin()->sanitize_post_restriction_meta( $_POST['um_content_restriction'] ); + + update_post_meta( $post_id, 'um_content_restriction', $restriction_meta ); } else { delete_post_meta( $post_id, 'um_content_restriction' ); } @@ -666,7 +670,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { } if ( ! empty( $_REQUEST['um_content_restriction'] ) && is_array( $_REQUEST['um_content_restriction'] ) ) { - update_term_meta( $termID, 'um_content_restriction', $_REQUEST['um_content_restriction'] ); + $restriction_meta = UM()->admin()->sanitize_term_restriction_meta( $_REQUEST['um_content_restriction'] ); + + update_term_meta( $termID, 'um_content_restriction', $restriction_meta ); } else { delete_term_meta( $termID, 'um_content_restriction' ); } @@ -851,7 +857,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { ) ); - if ( ! isset( $_GET['id'] ) || 'administrator' != sanitize_key( $_GET['id'] ) ) { + if ( ! isset( $_GET['id'] ) || 'administrator' !== sanitize_key( $_GET['id'] ) ) { $roles_metaboxes[] = array( 'id' => 'um-admin-form-home', 'title' => __( 'Homepage Options', 'ultimate-member' ), @@ -1094,13 +1100,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { delete_post_meta( $post_id, '_um_search_filters_gmt' ); //save metadata - foreach ( $_POST['um_metadata'] as $k => $v ) { + $metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] ); + foreach ( $metadata as $k => $v ) { - if ( $k == '_um_show_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) { + if ( $k == '_um_show_these_users' && trim( $v ) ) { $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY ); } - if ( $k == '_um_exclude_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) { + if ( $k == '_um_exclude_these_users' && trim( $v ) ) { $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY ); } @@ -1172,7 +1179,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { // save delete_post_meta( $post_id, '_um_profile_metafields' ); - foreach ( $_POST['form'] as $k => $v ) { + + + $form_meta = UM()->admin()->sanitize_form_meta( $_POST['form'] ); + + foreach ( $form_meta as $k => $v ) { if ( strstr( $k, '_um_' ) ) { if ( $k === '_um_is_default' ) { $mode = UM()->query()->get_attr( 'mode', $post_id ); @@ -2411,4 +2422,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { } } -} \ No newline at end of file +} diff --git a/includes/admin/core/class-admin-navmenu.php b/includes/admin/core/class-admin-navmenu.php index e7adb112..bb0dcd4f 100644 --- a/includes/admin/core/class-admin-navmenu.php +++ b/includes/admin/core/class-admin-navmenu.php @@ -146,9 +146,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) { /** - * @param $menu_id - * @param $menu_item_db_id - * @param $menu_item_args + * @param int $menu_id + * @param int $menu_item_db_id + * @param array $menu_item_args */ function _save( $menu_id, $menu_item_db_id, $menu_item_args ) { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { @@ -167,7 +167,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) { 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_map( 'sanitize_key', array_keys( $_POST[ $key ][ $menu_item_db_id ] ) ) : (int) $_POST[ $key ][ $menu_item_db_id ]; } else { $value = null; } diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index 653abdd9..61a32bcd 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -580,8 +580,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { 'message' => $message, ), 4 ); } else { - if ( isset( $_GET['msg'] ) && 'updated' == sanitize_key( $_GET['msg'] ) ) { - if ( isset( $_GET['page'] ) && 'um_options' == sanitize_key( $_GET['page'] ) ) { + if ( isset( $_GET['msg'] ) && 'updated' === sanitize_key( $_GET['msg'] ) ) { + if ( isset( $_GET['page'] ) && 'um_options' === sanitize_key( $_GET['page'] ) ) { $this->add_notice( 'settings_upgrade', array( 'class' => 'updated', 'message' => '
' . __( 'Settings successfully upgraded', 'ultimate-member' ) . '
', @@ -697,4 +697,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { wp_send_json_success(); } } -} \ No newline at end of file +} diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 6e8eda63..e0b9685b 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -1,9 +1,9 @@ admin()->check_ajax_nonce(); if ( empty( $_POST['cb_func'] ) ) { @@ -93,7 +99,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $cb_func = sanitize_key( $_POST['cb_func'] ); - if ( 'um_usermeta_fields' == $cb_func ) { + if ( 'um_usermeta_fields' === $cb_func ) { //first install metatable global $wpdb; @@ -110,9 +116,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { foreach ( $sites as $blog_id ) { $metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities'; } - } else { - $blog_id = get_current_blog_id(); + $blog_id = get_current_blog_id(); $metakeys[] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities'; } @@ -124,7 +129,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $metakeys[] = '_reviews_avg'; //myCred meta - if ( function_exists( 'mycred_get_types' ) ) { + if ( function_exists( 'mycred_get_types' ) ) { $mycred_types = mycred_get_types(); if ( ! empty( $mycred_types ) ) { foreach ( array_keys( $mycred_types ) as $point_type ) { @@ -145,7 +150,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { foreach ( $custom_val as $sort_value ) { if ( is_array( $sort_value ) ) { - $field_keys = array_keys( $sort_value ); + $field_keys = array_keys( $sort_value ); $sortby_custom_keys[] = $field_keys[0]; } } @@ -154,7 +159,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { if ( ! empty( $sortby_custom_keys ) ) { $sortby_custom_keys = array_unique( $sortby_custom_keys ); - $metakeys = array_merge( $metakeys, $sortby_custom_keys ); + $metakeys = array_merge( $metakeys, $sortby_custom_keys ); } $skip_fields = UM()->builtin()->get_fields_without_metakey(); @@ -177,53 +182,61 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { UM()->options()->update( 'member_directory_own_table', true ); wp_send_json_success(); - } elseif ( 'um_get_metadata' == $cb_func ) { + } elseif ( 'um_get_metadata' === $cb_func ) { global $wpdb; $wp_usermeta_option = get_option( 'um_usermeta_fields', array() ); $count = $wpdb->get_var( - "SELECT COUNT(*) - FROM {$wpdb->usermeta} - WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')" + $wpdb->prepare( + "SELECT COUNT(*) + FROM {$wpdb->usermeta} + WHERE meta_key IN (%s)", + implode( "','", $wp_usermeta_option ) + ) ); wp_send_json_success( array( 'count' => $count ) ); - } elseif ( 'um_update_metadata_per_page' == $cb_func ) { + } elseif ( 'um_update_metadata_per_page' === $cb_func ) { if ( empty( $_POST['page'] ) ) { wp_send_json_error( __( 'Wrong data', 'ultimate-member' ) ); } - $per_page = 500; + $per_page = 500; $wp_usermeta_option = get_option( 'um_usermeta_fields', array() ); global $wpdb; - $metadata = $wpdb->get_results( $wpdb->prepare( - "SELECT * - FROM {$wpdb->usermeta} - WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "') - LIMIT %d, %d", - ( absint( $_POST['page'] ) - 1 ) * $per_page, - $per_page - ), ARRAY_A ); + $metadata = $wpdb->get_results( + $wpdb->prepare( + "SELECT * + FROM {$wpdb->usermeta} + WHERE meta_key IN (%s) + LIMIT %d, %d", + implode( "','", $wp_usermeta_option ), + ( absint( $_POST['page'] ) - 1 ) * $per_page, + $per_page + ), + ARRAY_A + ); $values = array(); foreach ( $metadata as $metarow ) { - $values[] = $wpdb->prepare('(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] ); + $values[] = $wpdb->prepare( '(%d, %s, %s)', $metarow['user_id'], $metarow['meta_key'], $metarow['meta_value'] ); } if ( ! empty( $values ) ) { - $wpdb->query( - "INSERT INTO - {$wpdb->prefix}um_metadata(user_id, um_key, um_value) - VALUES " . implode( ',', $values ) ); + $wpdb->query( + "INSERT INTO + {$wpdb->prefix}um_metadata(user_id, um_key, um_value) + VALUES " . implode( ',', $values ) + ); } $from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1; - $to = absint( $_POST['page'] ) * $per_page; + $to = absint( $_POST['page'] ) * $per_page; - wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) ); + wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %1$s to %2$s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) ); } } @@ -231,58 +244,71 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { /** * */ - function init_variables() { + public function init_variables() { + + $settings_map = array(); + $general_pages_fields = array( array( 'id' => 'pages_settings', 'type' => 'hidden', 'value' => true, - 'is_option' => false - ) + 'is_option' => false, + ), ); $core_pages = UM()->config()->core_pages; foreach ( $core_pages as $page_s => $page ) { $have_pages = UM()->query()->wp_pages(); - $page_id = UM()->options()->get_core_page_id( $page_s ); + $page_id = UM()->options()->get_core_page_id( $page_s ); $page_title = ! empty( $page['title'] ) ? $page['title'] : ''; - if ( 'reached_maximum_limit' == $have_pages ) { + if ( 'reached_maximum_limit' === $have_pages ) { $general_pages_fields[] = array( - 'id' => $page_id, - 'type' => 'text', - 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), - 'placeholder' => __( 'Add page ID', 'ultimate-member' ), - 'compiler' => true, - 'size' => 'small' + 'id' => $page_id, + 'type' => 'text', + // translators: %s: Page title + 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), + 'placeholder' => __( 'Add page ID', 'ultimate-member' ), + 'compiler' => true, + 'size' => 'small', ); } else { $general_pages_fields[] = array( - 'id' => $page_id, - 'type' => 'select', - 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), - 'options' => UM()->query()->wp_pages(), - 'placeholder' => __( 'Choose a page...', 'ultimate-member' ), - 'compiler' => true, - 'size' => 'small' + 'id' => $page_id, + 'type' => 'select', + // translators: %s: Page title + 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), + 'options' => UM()->query()->wp_pages(), + 'placeholder' => __( 'Choose a page...', 'ultimate-member' ), + 'compiler' => true, + 'size' => 'small', ); } - } + $settings_map[ $page_id ] = array( + 'sanitize' => 'absint', + ); + } + $appearances_profile_menu_fields = array( array( 'id' => 'profile_menu', 'type' => 'checkbox', 'label' => __( 'Enable profile menu', 'ultimate-member' ), - ) + ), + ); + + $settings_map['profile_menu'] = array( + 'sanitize' => 'bool', ); $tabs = UM()->profile()->tabs(); - $tabs_options = array(); + $tabs_options = array(); $tabs_condition = array(); foreach ( $tabs as $id => $tab ) { @@ -292,48 +318,70 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { if ( isset( $tab['name'] ) ) { $tabs_options[ $id ] = $tab['name']; - $tabs_condition[] = 'profile_tab_' . $id; + $tabs_condition[] = 'profile_tab_' . $id; } if ( isset( $tab['default_privacy'] ) ) { $fields = array( array( - 'id' => 'profile_tab_' . $id, - 'type' => 'checkbox', - 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ), - 'conditional' => array( 'profile_menu', '=', 1 ), - 'data' => array( 'fill_profile_menu_default_tab' => $id ), + 'id' => 'profile_tab_' . $id, + 'type' => 'checkbox', + // translators: %s: Tab title + 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ), + 'conditional' => array( 'profile_menu', '=', 1 ), + 'data' => array( 'fill_profile_menu_default_tab' => $id ), ), ); + + $settings_map[ 'profile_tab_' . $id ] = array( + 'sanitize' => 'bool', + ); } else { $fields = array( array( - 'id' => 'profile_tab_' . $id, - 'type' => 'checkbox', - 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ), - 'conditional' => array( 'profile_menu', '=', 1 ), - 'data' => array( 'fill_profile_menu_default_tab' => $id ), + 'id' => 'profile_tab_' . $id, + 'type' => 'checkbox', + // translators: %s: Tab title + 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ), + 'conditional' => array( 'profile_menu', '=', 1 ), + 'data' => array( 'fill_profile_menu_default_tab' => $id ), ), array( - 'id' => 'profile_tab_' . $id . '_privacy', - 'type' => 'select', - 'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ), - 'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ), - 'options' => UM()->profile()->tabs_privacy(), - 'conditional' => array( 'profile_tab_' . $id, '=', 1 ), - 'size' => 'small' + 'id' => 'profile_tab_' . $id . '_privacy', + 'type' => 'select', + // translators: %s: Tab title + 'label' => sprintf( __( 'Who can see %s Tab?', 'ultimate-member' ), $tab['name'] ), + 'tooltip' => __( 'Select which users can view this tab.', 'ultimate-member' ), + 'options' => UM()->profile()->tabs_privacy(), + 'conditional' => array( 'profile_tab_' . $id, '=', 1 ), + 'size' => 'small', ), array( - 'id' => 'profile_tab_' . $id . '_roles', - 'type' => 'select', - 'multi' => true, - 'label' => __( 'Allowed roles', 'ultimate-member' ), - 'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ), - 'options' => UM()->roles()->get_roles(), - 'placeholder' => __( 'Choose user roles...', 'ultimate-member' ), - 'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', [ '4', '5' ] ), - 'size' => 'small' + 'id' => 'profile_tab_' . $id . '_roles', + 'type' => 'select', + 'multi' => true, + 'label' => __( 'Allowed roles', 'ultimate-member' ), + 'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ), + 'options' => UM()->roles()->get_roles(), + 'placeholder' => __( 'Choose user roles...', 'ultimate-member' ), + 'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', array( '4', '5' ) ), + 'size' => 'small', + ), + ); + + $settings_map = array_merge( + $settings_map, + array( + "profile_tab_{$id}" => array( + 'sanitize' => 'bool', + ), + "profile_tab_{$id}_privacy" => array( + 'sanitize' => array( UM()->admin(), 'sanitize_tabs_privacy' ), + ), + "profile_tab_{$id}_roles" => array( + 'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ), + ), ) ); } @@ -342,42 +390,53 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } $appearances_profile_menu_fields[] = array( - 'id' => 'profile_menu_default_tab', - 'type' => 'select', - 'label' => __( 'Profile menu default tab', 'ultimate-member' ), - 'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ), - 'options' => $tabs_options, - 'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ), - 'size' => 'small' + 'id' => 'profile_menu_default_tab', + 'type' => 'select', + 'label' => __( 'Profile menu default tab', 'ultimate-member' ), + 'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ), + 'options' => $tabs_options, + 'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ), + 'size' => 'small', ); - $appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, array( + $settings_map['profile_menu_default_tab'] = array( + 'sanitize' => 'key', + ); + + $appearances_profile_menu_fields = array_merge( + $appearances_profile_menu_fields, array( - 'id' => 'profile_menu_icons', - 'type' => 'checkbox', - 'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ), - 'conditional' => array( 'profile_menu', '=', 1 ), - ), - ) ); + array( + 'id' => 'profile_menu_icons', + 'type' => 'checkbox', + 'label' => __( 'Enable menu icons in desktop view', 'ultimate-member' ), + 'conditional' => array( 'profile_menu', '=', 1 ), + ), + ) + ); + + $settings_map['profile_menu_icons'] = array( + 'sanitize' => 'bool', + ); $post_types_options = array(); - $all_post_types = get_post_types( array( 'public' => true ), 'objects' ); + $all_post_types = get_post_types( array( 'public' => true ), 'objects' ); foreach ( $all_post_types as $key => $post_type_data ) { $post_types_options[ $key ] = $post_type_data->labels->singular_name; } + $duplicates = array(); $taxonomies_options = array(); $exclude_taxonomies = UM()->excluded_taxonomies(); - $all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); - $duplicates = array(); + $all_taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); foreach ( $all_taxonomies as $key => $taxonomy ) { - if ( in_array( $key , $exclude_taxonomies ) ) { + if ( in_array( $key, $exclude_taxonomies, true ) ) { continue; } - if ( ! in_array( $taxonomy->labels->singular_name, $duplicates ) ) { + if ( ! in_array( $taxonomy->labels->singular_name, $duplicates, true ) ) { $duplicates[] = $taxonomy->labels->singular_name; - $label = $taxonomy->labels->singular_name; + $label = $taxonomy->labels->singular_name; } else { $label = $taxonomy->labels->singular_name . ' (' . $key . ')'; } @@ -386,7 +445,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } $restricted_access_post_metabox_value = array(); - if ( $restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' ) ) { + $restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' ); + if ( ! empty( $restricted_access_post_metabox ) && is_array( $restricted_access_post_metabox ) ) { foreach ( $restricted_access_post_metabox as $key => $value ) { if ( $value ) { $restricted_access_post_metabox_value[] = $key; @@ -396,7 +456,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $restricted_access_taxonomy_metabox_value = array(); - if ( $restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' ) ) { + $restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' ); + if ( ! empty( $restricted_access_taxonomy_metabox ) && is_array( $restricted_access_taxonomy_metabox ) ) { foreach ( $restricted_access_taxonomy_metabox as $key => $value ) { if ( $value ) { $restricted_access_taxonomy_metabox_value[] = $key; @@ -406,116 +467,447 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $access_fields = array( array( - 'id' => 'accessible', - 'type' => 'select', - 'label' => __( 'Global Site Access', 'ultimate-member' ), - 'tooltip' => __( 'Globally control the access of your site, you can have seperate restrict options per post/page by editing the desired item.', 'ultimate-member' ), - 'options' => array( - 0 => __( 'Site accessible to Everyone', 'ultimate-member' ), - 2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ), + 'id' => 'accessible', + 'type' => 'select', + 'label' => __( 'Global Site Access', 'ultimate-member' ), + 'tooltip' => __( 'Globally control the access of your site, you can have separate restrict options per post/page by editing the desired item.', 'ultimate-member' ), + 'options' => array( + 0 => __( 'Site accessible to Everyone', 'ultimate-member' ), + 2 => __( 'Site accessible to Logged In Users', 'ultimate-member' ), ), - 'size' => 'medium', + 'size' => 'medium', ), array( - 'id' => 'access_redirect', - 'type' => 'text', - 'label' => __( 'Custom Redirect URL', 'ultimate-member' ), - 'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ), - 'conditional' => array( 'accessible', '=', 2 ), + 'id' => 'access_redirect', + 'type' => 'text', + 'label' => __( 'Custom Redirect URL', 'ultimate-member' ), + 'tooltip' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site', 'ultimate-member' ), + 'conditional' => array( 'accessible', '=', 2 ), ), array( - 'id' => 'access_exclude_uris', - 'type' => 'multi_text', - 'label' => __( 'Exclude the following URLs', 'ultimate-member' ), - 'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ), - 'add_text' => __( 'Add New URL', 'ultimate-member' ), - 'conditional' => array( 'accessible', '=', 2 ), - 'show_default_number' => 1, + 'id' => 'access_exclude_uris', + 'type' => 'multi_text', + 'label' => __( 'Exclude the following URLs', 'ultimate-member' ), + 'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone', 'ultimate-member' ), + 'add_text' => __( 'Add New URL', 'ultimate-member' ), + 'conditional' => array( 'accessible', '=', 2 ), + 'show_default_number' => 1, ), array( - 'id' => 'home_page_accessible', - 'type' => 'checkbox', - 'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ), - 'conditional' => array( 'accessible', '=', 2 ), + 'id' => 'home_page_accessible', + 'type' => 'checkbox', + 'label' => __( 'Allow Homepage to be accessible', 'ultimate-member' ), + 'conditional' => array( 'accessible', '=', 2 ), ), array( - 'id' => 'category_page_accessible', - 'type' => 'checkbox', - 'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ), - 'conditional' => array( 'accessible', '=', 2 ), + 'id' => 'category_page_accessible', + 'type' => 'checkbox', + 'label' => __( 'Allow Category pages to be accessible', 'ultimate-member' ), + 'conditional' => array( 'accessible', '=', 2 ), ), array( - 'id' => 'restricted_access_message', - 'type' => 'wp_editor', - 'label' => __( 'Restricted Access Message', 'ultimate-member' ), - 'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ), + 'id' => 'restricted_access_message', + 'type' => 'wp_editor', + 'label' => __( 'Restricted Access Message', 'ultimate-member' ), + 'tooltip' => __( 'This is the message shown to users that do not have permission to view the content', 'ultimate-member' ), + ), + ); + + $settings_map = array_merge( + $settings_map, + array( + 'accessible' => array( + 'sanitize' => 'int', + ), + 'access_redirect' => array( + 'sanitize' => 'url', + ), + 'access_exclude_uris' => array( + 'sanitize' => 'urls_array', + ), + 'home_page_accessible' => array( + 'sanitize' => 'bool', + ), + 'category_page_accessible' => array( + 'sanitize' => 'bool', + ), + 'restricted_access_message' => array( + 'sanitize' => 'wp_kses', + ), ) ); global $wp_version; if ( version_compare( $wp_version, '5.0', '>=' ) ) { - $access_fields = array_merge( $access_fields, array( array( - 'id' => 'restricted_blocks', - 'type' => 'checkbox', - 'label' => __( 'Allow Gutenberg Blocks restriction options', 'ultimate-member' ), - ), - array( - 'id' => 'restricted_block_message', - 'type' => 'textarea', - 'label' => __( 'Restricted Block Message', 'ultimate-member' ), - 'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ), - 'conditional' => array( 'restricted_blocks', '=', 1 ), - ) ) ); - } - $access_fields = array_merge( $access_fields, array( - array( - 'id' => 'restricted_access_post_metabox', - 'type' => 'hidden', - 'value' => '', - ), - array( - 'id' => 'restricted_access_taxonomy_metabox', - 'type' => 'hidden', - 'value' => '', - ), - array( - 'id' => 'restricted_access_post_metabox', - 'type' => 'multi_checkbox', - 'label' => __( 'Restricted Access to Posts', 'ultimate-member' ), - 'tooltip' => __( 'Restriction content of the current Posts', 'ultimate-member' ), - 'options' => $post_types_options, - 'columns' => 3, - 'value' => $restricted_access_post_metabox_value, - 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ), - ), - array( - 'id' => 'restricted_access_taxonomy_metabox', - 'type' => 'multi_checkbox', - 'label' => __( 'Restricted Access to Taxonomies', 'ultimate-member' ), - 'tooltip' => __( 'Restriction content of the current Taxonomies', 'ultimate-member' ), - 'options' => $taxonomies_options, - 'columns' => 3, - 'value' => $restricted_access_taxonomy_metabox_value, - 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ), - ) ) ); + $access_fields = array_merge( + $access_fields, + array( + array( + 'id' => 'restricted_blocks', + 'type' => 'checkbox', + 'label' => __( 'Allow Gutenberg Blocks restriction options', 'ultimate-member' ), + ), + array( + 'id' => 'restricted_block_message', + 'type' => 'textarea', + 'label' => __( 'Restricted Block Message', 'ultimate-member' ), + 'tooltip' => __( 'This is the message shown to users that do not have permission to view the block\'s content', 'ultimate-member' ), + 'conditional' => array( 'restricted_blocks', '=', 1 ), + ), + ) + ); - $latest_update = get_option( 'um_member_directory_update_meta', false ); + $settings_map['restricted_blocks'] = array( + 'sanitize' => 'bool', + ); + $settings_map['restricted_block_message'] = array( + 'sanitize' => 'textarea', + ); + } + + $access_fields = array_merge( + $access_fields, + array( + array( + 'id' => 'restricted_access_post_metabox', + 'type' => 'hidden', + 'value' => '', + ), + array( + 'id' => 'restricted_access_taxonomy_metabox', + 'type' => 'hidden', + 'value' => '', + ), + array( + 'id' => 'restricted_access_post_metabox', + 'type' => 'multi_checkbox', + 'label' => __( 'Restricted Access to Posts', 'ultimate-member' ), + 'tooltip' => __( 'Restriction content of the current Posts', 'ultimate-member' ), + 'options' => $post_types_options, + 'columns' => 3, + 'value' => $restricted_access_post_metabox_value, + 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ), + ), + array( + 'id' => 'restricted_access_taxonomy_metabox', + 'type' => 'multi_checkbox', + 'label' => __( 'Restricted Access to Taxonomies', 'ultimate-member' ), + 'tooltip' => __( 'Restriction content of the current Taxonomies', 'ultimate-member' ), + 'options' => $taxonomies_options, + 'columns' => 3, + 'value' => $restricted_access_taxonomy_metabox_value, + 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ), + ), + ) + ); + + $settings_map = array_merge( + $settings_map, + array( + 'restricted_access_post_metabox' => array( + 'sanitize' => 'keys_array', + ), + 'restricted_access_taxonomy_metabox' => array( + 'sanitize' => 'keys_array', + ), + ) + ); + + $latest_update = get_option( 'um_member_directory_update_meta', false ); $latest_truncate = get_option( 'um_member_directory_truncated', false ); $same_page_update = array( - 'id' => 'member_directory_own_table', - 'type' => 'same_page_update', - 'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ), - 'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ), + 'id' => 'member_directory_own_table', + 'type' => 'same_page_update', + 'label' => __( 'Enable custom table for usermeta', 'ultimate-member' ), + 'tooltip' => __( 'Check this box if you would like to enable the use of a custom table for user metadata. Improved performance for member directory searches.', 'ultimate-member' ), ); if ( empty( $latest_update ) || ( ! empty( $latest_truncate ) && $latest_truncate > $latest_update ) ) { - $same_page_update['upgrade_cb'] = 'sync_metatable'; + $same_page_update['upgrade_cb'] = 'sync_metatable'; $same_page_update['upgrade_description'] = '' . __( 'We recommend creating a backup of your site before running the update process. Do not exit the page before the update process has complete.', 'ultimate-member' ) . '
' . __( 'After clicking the "Run" button, the update process will start. All information will be displayed in the field below.', 'ultimate-member' ) . '
' . __( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ) . '
'; } + $settings_map = array_merge( + $settings_map, + array( + 'permalink_base' => array( + 'sanitize' => 'key', + ), + 'display_name' => array( + 'sanitize' => 'key', + ), + 'display_name_field' => array( + 'sanitize' => 'text', + ), + 'author_redirect' => array( + 'sanitize' => 'bool', + ), + 'members_page' => array( + 'sanitize' => 'bool', + ), + 'use_gravatars' => array( + 'sanitize' => 'bool', + ), + 'use_um_gravatar_default_builtin_image' => array( + 'sanitize' => 'key', + ), + 'use_um_gravatar_default_image' => array( + 'sanitize' => 'bool', + ), + 'reset_require_strongpass' => array( + 'sanitize' => 'bool', + ), + 'profile_noindex' => array( + 'sanitize' => 'bool', + ), + 'activation_link_expiry_time' => array( + 'sanitize' => 'absint', + ), + 'account_tab_password' => array( + 'sanitize' => 'bool', + ), + 'account_tab_privacy' => array( + 'sanitize' => 'bool', + ), + 'account_tab_notifications' => array( + 'sanitize' => 'bool', + ), + 'account_tab_delete' => array( + 'sanitize' => 'bool', + ), + 'delete_account_text' => array( + 'sanitize' => 'textarea', + ), + 'delete_account_no_pass_required_text' => array( + 'sanitize' => 'textarea', + ), + 'account_name' => array( + 'sanitize' => 'bool', + ), + 'account_name_disable' => array( + 'sanitize' => 'bool', + ), + 'account_name_require' => array( + 'sanitize' => 'bool', + ), + 'account_email' => array( + 'sanitize' => 'bool', + ), + 'account_general_password' => array( + 'sanitize' => 'bool', + ), + 'account_require_strongpass' => array( + 'sanitize' => 'bool', + ), + 'account_hide_in_directory' => array( + 'sanitize' => 'bool', + ), + 'account_hide_in_directory_default' => array( + 'sanitize' => 'text', + ), + 'profile_photo_max_size' => array( + 'sanitize' => 'absint', + ), + 'cover_photo_max_size' => array( + 'sanitize' => 'absint', + ), + 'photo_thumb_sizes' => array( + 'sanitize' => 'absints_array', + ), + 'cover_thumb_sizes' => array( + 'sanitize' => 'absints_array', + ), + 'image_orientation_by_exif' => array( + 'sanitize' => 'bool', + ), + 'image_compression' => array( + 'sanitize' => 'absint', + ), + 'image_max_width' => array( + 'sanitize' => 'absint', + ), + 'cover_min_width' => array( + 'sanitize' => 'absint', + ), + 'enable_reset_password_limit' => array( + 'sanitize' => 'bool', + ), + 'reset_password_limit_number' => array( + 'sanitize' => 'absint', + ), + 'blocked_emails' => array( + 'sanitize' => 'textarea', + ), + 'blocked_words' => array( + 'sanitize' => 'textarea', + ), + 'admin_email' => array( + 'sanitize' => 'text', + ), + 'mail_from' => array( + 'sanitize' => 'text', + ), + 'mail_from_addr' => array( + 'sanitize' => 'text', + ), + 'email_html' => array( + 'sanitize' => 'bool', + ), + 'profile_template' => array( + 'sanitize' => 'text', + ), + 'profile_max_width' => array( + 'sanitize' => 'absint', + ), + 'profile_area_max_width' => array( + 'sanitize' => 'absint', + ), + 'profile_icons' => array( + 'sanitize' => 'key', + ), + 'profile_primary_btn_word' => array( + 'sanitize' => 'text', + ), + 'profile_secondary_btn' => array( + 'sanitize' => 'bool', + ), + 'profile_secondary_btn_word' => array( + 'sanitize' => 'text', + ), + 'default_avatar' => array( + 'sanitize' => 'url', + ), + 'default_cover' => array( + 'sanitize' => 'url', + ), + 'disable_profile_photo_upload' => array( + 'sanitize' => 'bool', + ), + 'profile_photosize' => array( + 'sanitize' => array( UM()->admin(), 'sanitize_photosize' ), + ), + 'profile_cover_enabled' => array( + 'sanitize' => 'bool', + ), + 'profile_coversize' => array( + 'sanitize' => array( UM()->admin(), 'sanitize_photosize' ), + ), + 'profile_cover_ratio' => array( + 'sanitize' => 'text', + ), + 'profile_show_metaicon' => array( + 'sanitize' => 'bool', + ), + 'profile_show_name' => array( + 'sanitize' => 'bool', + ), + 'profile_show_social_links' => array( + 'sanitize' => 'bool', + ), + 'profile_show_bio' => array( + 'sanitize' => 'bool', + ), + 'profile_show_html_bio' => array( + 'sanitize' => 'bool', + ), + 'profile_bio_maxchars' => array( + 'sanitize' => 'absint', + ), + 'profile_header_menu' => array( + 'sanitize' => 'key', + ), + 'profile_empty_text' => array( + 'sanitize' => 'bool', + ), + 'profile_empty_text_emo' => array( + 'sanitize' => 'bool', + ), + 'register_template' => array( + 'sanitize' => 'text', + ), + 'register_max_width' => array( + 'sanitize' => 'absint', + ), + 'register_align' => array( + 'sanitize' => 'key', + ), + 'register_icons' => array( + 'sanitize' => 'key', + ), + 'register_primary_btn_word' => array( + 'sanitize' => 'text', + ), + 'register_secondary_btn' => array( + 'sanitize' => 'bool', + ), + 'register_secondary_btn_word' => array( + 'sanitize' => 'text', + ), + 'register_secondary_btn_url' => array( + 'sanitize' => 'url', + ), + 'register_role' => array( + 'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ), + ), + 'login_template' => array( + 'sanitize' => 'text', + ), + 'login_max_width' => array( + 'sanitize' => 'absint', + ), + 'login_align' => array( + 'sanitize' => 'key', + ), + 'login_icons' => array( + 'sanitize' => 'key', + ), + 'login_primary_btn_word' => array( + 'sanitize' => 'text', + ), + 'login_secondary_btn' => array( + 'sanitize' => 'bool', + ), + 'login_secondary_btn_word' => array( + 'sanitize' => 'text', + ), + 'login_secondary_btn_url' => array( + 'sanitize' => 'url', + ), + 'login_forgot_pass_link' => array( + 'sanitize' => 'bool', + ), + 'login_show_rememberme' => array( + 'sanitize' => 'bool', + ), + 'form_asterisk' => array( + 'sanitize' => 'bool', + ), + 'profile_title' => array( + 'sanitize' => 'text', + ), + 'profile_desc' => array( + 'sanitize' => 'textarea', + ), + 'um_profile_object_cache_stop' => array( + 'sanitize' => 'bool', + ), + 'enable_blocks' => array( + 'sanitize' => 'bool', + ), + 'rest_api_version' => array( + 'sanitize' => 'text', + ), + 'uninstall_on_delete' => array( + 'sanitize' => 'bool', + ), + ) + ); + + $this->settings_map = apply_filters( 'um_settings_map', $settings_map ); + /** * UM hook * @@ -536,851 +928,852 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { * } * ?> */ - $this->settings_structure = apply_filters( 'um_settings_structure', array( - '' => array( - 'title' => __( 'General', 'ultimate-member' ), - 'sections' => array( - '' => array( - 'title' => __( 'Pages', 'ultimate-member' ), - 'fields' => $general_pages_fields - ), - 'users' => array( - 'title' => __( 'Users', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'permalink_base', - 'type' => 'select', - 'size' => 'small', - 'label' => __( 'Profile Permalink Base','ultimate-member' ), - 'tooltip' => __( 'Here you can control the permalink structure of the user profile URL globally e.g. ' . trailingslashit( um_get_core_page('user') ) . 'username/','ultimate-member' ), - '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' ), + $this->settings_structure = apply_filters( + 'um_settings_structure', + array( + '' => array( + 'title' => __( 'General', 'ultimate-member' ), + 'sections' => array( + '' => array( + 'title' => __( 'Pages', 'ultimate-member' ), + 'fields' => $general_pages_fields, + ), + 'users' => array( + 'title' => __( 'Users', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'permalink_base', + 'type' => 'select', + 'size' => 'small', + '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' ), + ), + 'placeholder' => __( 'Select...', 'ultimate-member' ), ), - 'placeholder' => __( 'Select...', 'ultimate-member' ), - ), - array( - 'id' => 'display_name', - 'type' => 'select', - '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' ), + array( + 'id' => 'display_name', + 'type' => 'select', + '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' ), + ), + 'placeholder' => __( 'Select...', 'ultimate-member' ), ), - 'placeholder' => __( 'Select...', 'ultimate-member' ), - ), - array( - 'id' => 'display_name_field', - 'type' => 'text', - 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ), - 'tooltip' => __( 'Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site', 'ultimate-member' ), - 'conditional' => array( 'display_name', '=', 'field' ), - ), - array( - 'id' => 'author_redirect', - 'type' => 'checkbox', - 'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ), - 'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ), - ), - array( - 'id' => 'members_page', - 'type' => 'checkbox', - 'label' => __( 'Enable Members Directory', 'ultimate-member' ), - 'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ), - ), - array( - 'id' => 'use_gravatars', - 'type' => 'checkbox', - 'label' => __( 'Use Gravatars?', 'ultimate-member' ), - 'tooltip' => __( 'Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ), - ), - array( - 'id' => 'use_um_gravatar_default_builtin_image', - 'type' => 'select', - 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ), - 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ), - 'options' => array( - 'default' => __( 'Default', 'ultimate-member' ), - '404' => __( '404 ( File Not Found response )', 'ultimate-member' ), - 'mm' => __( 'Mystery Man', 'ultimate-member' ), - 'identicon' => __( 'Identicon', 'ultimate-member' ), - 'monsterid' => __( 'Monsterid', 'ultimate-member' ), - 'wavatar' => __( 'Wavatar', 'ultimate-member' ), - 'retro' => __( 'Retro', 'ultimate-member' ), - 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ), + array( + 'id' => 'display_name_field', + 'type' => 'text', + 'label' => __( 'Display Name Custom Field(s)', 'ultimate-member' ), + 'tooltip' => __( 'Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site', 'ultimate-member' ), + 'conditional' => array( 'display_name', '=', 'field' ), ), - 'conditional' => array( 'use_gravatars', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'use_um_gravatar_default_image', - 'type' => 'checkbox', - 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ), - 'tooltip' => __( 'Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ), - 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ), - ), - array( - 'id' => 'reset_require_strongpass', - 'type' => 'checkbox', - 'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ), - 'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ), - ), - array( - 'id' => 'profile_noindex', - 'type' => 'select', - 'size' => 'small', - 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ), - 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ), - 'options' => [ - '0' => __( 'No', 'ultimate-member' ), - '1' => __( 'Yes', 'ultimate-member' ), - ] - ), - array( - 'id' => 'activation_link_expiry_time', - 'type' => 'number', - 'label' => __( 'Activation link lifetime', 'ultimate-member' ), - 'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ), - 'size' => 'small', - ), - ) - ), - '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' => 'author_redirect', + 'type' => 'checkbox', + 'label' => __( 'Automatically redirect author page to their profile?', 'ultimate-member' ), + 'tooltip' => __( 'If enabled, author pages will automatically redirect to the user\'s profile page', 'ultimate-member' ), + ), + array( + 'id' => 'members_page', + 'type' => 'checkbox', + 'label' => __( 'Enable Members Directory', 'ultimate-member' ), + 'tooltip' => __( 'Control whether to enable or disable member directories on this site', 'ultimate-member' ), + ), + array( + 'id' => 'use_gravatars', + 'type' => 'checkbox', + 'label' => __( 'Use Gravatars?', 'ultimate-member' ), + 'tooltip' => __( 'Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ), + ), + array( + 'id' => 'use_um_gravatar_default_builtin_image', + 'type' => 'select', + 'label' => __( 'Use Gravatar builtin image', 'ultimate-member' ), + 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults', 'ultimate-member' ), + 'options' => array( + 'default' => __( 'Default', 'ultimate-member' ), + '404' => __( '404 ( File Not Found response )', 'ultimate-member' ), + 'mm' => __( 'Mystery Man', 'ultimate-member' ), + 'identicon' => __( 'Identicon', 'ultimate-member' ), + 'monsterid' => __( 'Monsterid', 'ultimate-member' ), + 'wavatar' => __( 'Wavatar', 'ultimate-member' ), + 'retro' => __( 'Retro', 'ultimate-member' ), + 'blank' => __( 'Blank ( a transparent PNG image )', 'ultimate-member' ), + ), + 'conditional' => array( 'use_gravatars', '=', 1 ), + 'size' => 'medium', + ), + array( + 'id' => 'use_um_gravatar_default_image', + 'type' => 'checkbox', + 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar', 'ultimate-member' ), + 'tooltip' => __( 'Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)', 'ultimate-member' ), + 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ), + ), + array( + 'id' => 'reset_require_strongpass', + 'type' => 'checkbox', + 'label' => __( 'Require a strong password? (when user resets password only)', 'ultimate-member' ), + 'tooltip' => __( 'Enable or disable a strong password rules on password reset and change procedure', 'ultimate-member' ), + ), + array( + 'id' => 'profile_noindex', + 'type' => 'select', + 'size' => 'small', + 'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ), + 'tooltip' => __( 'Hides the profile page for robots. This setting can be overridden by individual role settings.', 'ultimate-member' ), + 'options' => array( + '0' => __( 'No', 'ultimate-member' ), + '1' => __( 'Yes', 'ultimate-member' ), + ), + ), + array( + 'id' => 'activation_link_expiry_time', + 'type' => 'number', + 'label' => __( 'Activation link lifetime', 'ultimate-member' ), + 'tooltip' => __( 'How long does an activation link live in seconds? Leave empty for endless links.', 'ultimate-member' ), + 'size' => 'small', ), ), - 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 + ), + '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_require_strongpass', + 'type' => 'checkbox', + 'label' => __( 'Require a strong password?', 'ultimate-member' ), + 'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', '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' ), ), ), - 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_require_strongpass', - 'type' => 'checkbox', - 'label' => __( 'Require a strong password?', 'ultimate-member' ), - 'tooltip' => __( 'Enable or disable a strong password rules on account page / change password tab', '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' ) + ), + 'uploads' => array( + 'title' => __( 'Uploads', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'profile_photo_max_size', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ), + 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ), + ), + array( + 'id' => 'cover_photo_max_size', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ), + 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ), + ), + array( + 'id' => 'photo_thumb_sizes', + 'type' => 'multi_text', + 'size' => 'small', + 'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ), + 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ), + 'validate' => 'numeric', + 'add_text' => __( 'Add New Size', 'ultimate-member' ), + 'show_default_number' => 1, + ), + array( + 'id' => 'cover_thumb_sizes', + 'type' => 'multi_text', + 'size' => 'small', + 'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ), + 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ), + 'validate' => 'numeric', + 'add_text' => __( 'Add New Size', 'ultimate-member' ), + 'show_default_number' => 1, + ), + array( + 'id' => 'image_orientation_by_exif', + 'type' => 'checkbox', + 'label' => __( 'Change image orientation', 'ultimate-member' ), + 'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ), + ), + array( + 'id' => 'image_compression', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Image Quality', 'ultimate-member' ), + 'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ), ), - 'size' => 'small', - 'conditional' => array( 'account_hide_in_directory', '=', '1' ), - ), - ) - ), - 'uploads' => array( - 'title' => __( 'Uploads', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'profile_photo_max_size', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ), - 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ), - ), - array( - 'id' => 'cover_photo_max_size', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ), - 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ), - ), - array( - 'id' => 'photo_thumb_sizes', - 'type' => 'multi_text', - 'size' => 'small', - 'label' => __( 'Profile Photo Thumbnail Sizes (px)', 'ultimate-member' ), - 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.', 'ultimate-member' ), - 'validate' => 'numeric', - 'add_text' => __( 'Add New Size', 'ultimate-member' ), - 'show_default_number' => 1, - ), - array( - 'id' => 'cover_thumb_sizes', - 'type' => 'multi_text', - 'size' => 'small', - 'label' => __( 'Cover Photo Thumbnail Sizes (px)', 'ultimate-member' ), - 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.', 'ultimate-member' ), - 'validate' => 'numeric', - 'add_text' => __( 'Add New Size', 'ultimate-member' ), - 'show_default_number' => 1, - ), + array( + 'id' => 'image_max_width', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ), + 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ), + ), - array( - 'id' => 'image_orientation_by_exif', - 'type' => 'checkbox', - 'label' => __( 'Change image orientation', 'ultimate-member' ), - 'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ), - ), - array( - 'id' => 'image_compression', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Image Quality', 'ultimate-member' ), - 'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ), - ), - - array( - 'id' => 'image_max_width', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ), - 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ), - ), - - array( - 'id' => 'cover_min_width', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ), - 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ), - ), - ) - ) - ) - ), - 'access' => array( - 'title' => __( 'Access', 'ultimate-member' ), - 'sections' => array( - '' => array( - 'title' => __( 'Restriction Content', 'ultimate-member' ), - 'fields' => $access_fields - ), - 'other' => array( - 'title' => __( 'Other', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'enable_reset_password_limit', - 'type' => 'checkbox', - 'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ), - ), - array( - 'id' => 'reset_password_limit_number', - 'type' => 'text', - 'label' => __( 'Reset Password Limit', 'ultimate-member' ), - 'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ), - 'validate' => 'numeric', - 'conditional' => array( 'enable_reset_password_limit', '=', 1 ), - 'size' => 'small', - ), - array( - 'id' => 'blocked_emails', - 'type' => 'textarea', - 'label' => __( 'Blocked Email Addresses', 'ultimate-member' ), - 'tooltip' => __( 'This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com', 'ultimate-member' ), - ), - array( - 'id' => 'blocked_words', - 'type' => 'textarea', - 'label' => __( 'Blacklist Words', 'ultimate-member' ), - 'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ), - ) - ) - ), - ) - ), - 'email' => array( - 'title' => __( 'Email', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'admin_email', - 'type' => 'text', - 'label' => __( 'Admin E-mail Address', 'ultimate-member' ), - 'tooltip' => __( 'e.g. admin@companyname.com','ultimate-member' ), - ), - array( - 'id' => 'mail_from', - 'type' => 'text', - 'label' => __( 'Mail appears from','ultimate-member' ), - 'tooltip' => __( 'e.g. Site Name','ultimate-member' ), - ), - array( - 'id' => 'mail_from_addr', - 'type' => 'text', - 'label' => __( 'Mail appears from address','ultimate-member' ), - 'tooltip' => __( 'e.g. admin@companyname.com','ultimate-member' ), - ), - array( - 'id' => 'email_html', - 'type' => 'checkbox', - 'label' => __( 'Use HTML for E-mails?','ultimate-member' ), - 'tooltip' => __( 'If you plan use e-mails with HTML, please make sure that this option is enabled. Otherwise, HTML will be displayed as plain text.','ultimate-member'), - ) - ) - ), - 'appearance' => array( - 'title' => __( 'Appearance', 'ultimate-member' ), - 'sections' => array( - '' => array( - 'title' => __( 'Profile', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'profile_template', - 'type' => 'select', - 'label' => __( 'Profile Default Template', 'ultimate-member' ), - 'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_template' ), - 'options' => UM()->shortcodes()->get_templates( 'profile' ), - 'size' => 'small' - ), - array( - 'id' => 'profile_max_width', - 'type' => 'text', - 'label' => __( 'Profile Maximum Width', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_max_width' ), - 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ), - 'size' => 'small' - ), - - array( - 'id' => 'profile_area_max_width', - 'type' => 'text', - 'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_area_max_width' ), - 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ), - 'size' => 'small' - ), - array( - 'id' => 'profile_icons', - 'type' => 'select', - 'label' => __( 'Profile Field Icons', 'ultimate-member' ), - 'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_icons' ), - 'options' => array( - 'field' => __( 'Show inside text field', 'ultimate-member' ), - 'label' => __( 'Show with label', 'ultimate-member' ), - 'off' => __( 'Turn off', 'ultimate-member' ), - ), - 'size' => 'small' - ), - array( - 'id' => 'profile_primary_btn_word', - 'type' => 'text', - 'label' => __( 'Profile Primary Button Text','ultimate-member' ), - 'default' => um_get_metadefault( 'profile_primary_btn_word' ), - 'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ), - 'size' => 'medium' - ), - array( - 'id' => 'profile_secondary_btn', - 'type' => 'checkbox', - 'label' => __( 'Profile Secondary Button', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_secondary_btn' ), - 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ), - ), - array( - 'id' => 'profile_secondary_btn_word', - 'type' => 'text', - 'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_secondary_btn_word' ), - 'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ), - 'conditional' => array( 'profile_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'default_avatar', - 'type' => 'media', - 'label' => __( 'Default Profile Photo', 'ultimate-member' ), - 'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ), - 'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ), - 'default' => array( - 'url' => um_url . 'assets/img/default_avatar.jpg', + array( + 'id' => 'cover_min_width', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ), + 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ), ), ), - array( - 'id' => 'default_cover', - 'type' => 'media', - 'url' => true, - 'preview' => false, - 'label' => __( 'Default Cover Photo', 'ultimate-member' ), - 'tooltip' => __( 'You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member'), - 'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ), - ), - array( - 'id' => 'disable_profile_photo_upload', - 'type' => 'checkbox', - 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ), - 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ), - 'default' => um_get_metadefault( 'disable_profile_photo_upload' ), - ), - array( - 'id' => 'profile_photosize', - 'type' => 'select', - 'label' => __( 'Profile Photo Size', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_photosize' ), - 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ), - 'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ), - 'size' => 'small' - ), - array( - 'id' => 'profile_cover_enabled', - 'type' => 'checkbox', - 'label' => __( 'Profile Cover Photos', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_cover_enabled' ), - 'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ), - ), - array( - 'id' => 'profile_coversize', - 'type' => 'select', - 'label' => __( 'Profile Cover Size', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_coversize' ), - 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ), - 'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ), - 'conditional' => array( 'profile_cover_enabled', '=', 1 ), - 'size' => 'small' - ), - array( - 'id' => 'profile_cover_ratio', - 'type' => 'select', - 'label' => __( 'Profile Cover Ratio', 'ultimate-member' ), - 'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_cover_ratio' ), - 'options' => array( - '1.6:1' => '1.6:1', - '2.7:1' => '2.7:1', - '2.2:1' => '2.2:1', - '3.2:1' => '3.2:1', - ), - 'conditional' => array( 'profile_cover_enabled', '=', 1 ), - 'size' => 'small' - ), - array( - 'id' => 'profile_show_metaicon', - 'type' => 'checkbox', - 'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ), - 'default' => 0, - 'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ), - ), - array( - 'id' => 'profile_show_name', - 'type' => 'checkbox', - 'label' => __( 'Show display name in profile header', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_show_name' ), - 'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ), - ), - array( - 'id' => 'profile_show_social_links', - 'type' => 'checkbox', - 'label' => __( 'Show social links in profile header', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_show_social_links' ), - 'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ), - ), - array( - 'id' => 'profile_show_bio', - 'type' => 'checkbox', - 'label' => __( 'Show user description in header', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_show_bio' ), - 'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ), - ), - array( - 'id' => 'profile_show_html_bio', - 'type' => 'checkbox', - 'label' => __( 'Enable HTML support for user description', 'ultimate-member' ), - 'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ), - ), - array( - 'id' => 'profile_bio_maxchars', - 'type' => 'text', - 'label' => __( 'User description maximum chars', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_bio_maxchars' ), - 'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ), - 'conditional' => array( 'profile_show_bio', '=', 1 ), - 'size' => 'small' - ), - array( - 'id' => 'profile_header_menu', - 'type' => 'select', - 'label' => __( 'Profile Header Menu Position', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_header_menu' ), - 'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ), - 'options' => array( - 'bc' => __( 'Bottom of Icon', 'ultimate-member' ), - 'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ), - ), - 'size' => 'small' - ), - array( - 'id' => 'profile_empty_text', - 'type' => 'checkbox', - 'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_empty_text' ), - 'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ), - ), - array( - 'id' => 'profile_empty_text_emo', - 'type' => 'checkbox', - 'label' => __( 'Show the emoticon', 'ultimate-member' ), - 'default' => um_get_metadefault( 'profile_empty_text_emo' ), - 'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ), - 'conditional' => array( 'profile_empty_text', '=', 1 ), - ) - ) - ), - 'profile_menu' => array( - 'title' => __( 'Profile Menu', 'ultimate-member' ), - 'fields' => $appearances_profile_menu_fields - ), - 'registration_form' => array( - 'title' => __( 'Registration Form', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'register_template', - 'type' => 'select', - 'label' => __( 'Registration Default Template', 'ultimate-member' ), - 'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ), - 'default' => um_get_metadefault('register_template'), - 'options' => UM()->shortcodes()->get_templates( 'register' ), - 'size' => 'small', - ), - array( - 'id' => 'register_max_width', - 'type' => 'text', - 'label' => __( 'Registration Maximum Width', 'ultimate-member' ), - 'default' => um_get_metadefault('register_max_width'), - 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ), - 'size' => 'small' - ), - array( - 'id' => 'register_align', - 'type' => 'select', - 'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ), - 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ), - 'default' => um_get_metadefault( 'register_align' ), - 'options' => array( - 'center' => __( 'Centered', 'ultimate-member' ), - 'left' => __( 'Left aligned', 'ultimate-member' ), - 'right' => __( 'Right aligned', 'ultimate-member' ), - ), - 'size' => 'small' - ), - array( - 'id' => 'register_icons', - 'type' => 'select', - 'label' => __( 'Registration Field Icons', 'ultimate-member' ), - 'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ), - 'default' => um_get_metadefault( 'register_icons' ), - 'options' => array( - 'field' => __( 'Show inside text field', 'ultimate-member' ), - 'label' => __( 'Show with label', 'ultimate-member' ), - 'off' => __( 'Turn off', 'ultimate-member' ), - ), - 'size' => 'small' - ), - array( - 'id' => 'register_primary_btn_word', - 'type' => 'text', - 'label' => __( 'Registration Primary Button Text', 'ultimate-member' ), - 'default' => um_get_metadefault('register_primary_btn_word'), - 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ), - 'size' => 'medium' - ), - array( - 'id' => 'register_secondary_btn', - 'type' => 'checkbox', - 'label' => __( 'Registration Secondary Button', 'ultimate-member' ), - 'default' => 1, - 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ), - ), - array( - 'id' => 'register_secondary_btn_word', - 'type' => 'text', - 'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ), - 'default' => um_get_metadefault( 'register_secondary_btn_word' ), - 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ), - 'conditional' => array( 'register_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'register_secondary_btn_url', - 'type' => 'text', - 'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ), - 'default' => um_get_metadefault('register_secondary_btn_url'), - 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ), - 'conditional' => array( 'register_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'register_role', - 'type' => 'select', - 'label' => __( 'Registration Default Role', 'ultimate-member' ), - 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ), - 'default' => um_get_metadefault( 'register_role' ), - 'options' => UM()->roles()->get_roles( $add_default = 'Default' ), - 'size' => 'small' - ) - ) - ), - 'login_form' => array( - 'title' => __( 'Login Form', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'login_template', - 'type' => 'select', - 'label' => __( 'Login Default Template', 'ultimate-member' ), - 'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ), - 'default' => um_get_metadefault( 'login_template' ), - 'options' => UM()->shortcodes()->get_templates( 'login' ), - 'size' => 'small' - ), - array( - 'id' => 'login_max_width', - 'type' => 'text', - 'label' => __( 'Login Maximum Width', 'ultimate-member' ), - 'default' => um_get_metadefault( 'login_max_width' ), - 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ), - 'size' => 'small' - ), - array( - 'id' => 'login_align', - 'type' => 'select', - 'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ), - 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ), - 'default' => um_get_metadefault( 'login_align' ), - 'options' => array( - 'center' => __( 'Centered', 'ultimate-member' ), - 'left' => __( 'Left aligned', 'ultimate-member' ), - 'right' => __( 'Right aligned', 'ultimate-member' ), - ), - 'size' => 'small' - ), - array( - 'id' => 'login_icons', - 'type' => 'select', - 'label' => __( 'Login Field Icons', 'ultimate-member' ), - 'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ), - 'default' => um_get_metadefault( 'login_icons' ), - 'options' => array( - 'field' => __( 'Show inside text field', 'ultimate-member' ), - 'label' => __( 'Show with label', 'ultimate-member' ), - 'off' => __( 'Turn off', 'ultimate-member' ), - ), - 'size' => 'small' - ), - array( - 'id' => 'login_primary_btn_word', - 'type' => 'text', - 'label' => __( 'Login Primary Button Text','ultimate-member' ), - 'default' => um_get_metadefault( 'login_primary_btn_word' ), - 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ), - 'size' => 'medium' - ), - array( - 'id' => 'login_secondary_btn', - 'type' => 'checkbox', - 'label' => __( 'Login Secondary Button', 'ultimate-member' ), - 'default' => 1, - 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ), - ), - array( - 'id' => 'login_secondary_btn_word', - 'type' => 'text', - 'label' => __( 'Login Secondary Button Text', 'ultimate-member' ), - 'default' => um_get_metadefault( 'login_secondary_btn_word' ), - 'tooltip' => __('The text that is used for the secondary button text', 'ultimate-member' ), - 'conditional' => array( 'login_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'login_secondary_btn_url', - 'type' => 'text', - 'label' => __( 'Login Secondary Button URL', 'ultimate-member' ), - 'default' => um_get_metadefault( 'login_secondary_btn_url' ), - 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ), - 'conditional' => array( 'login_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'login_forgot_pass_link', - 'type' => 'checkbox', - 'label' => __( 'Login Forgot Password Link', 'ultimate-member' ), - 'default' => 1, - 'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ), - ), - array( - 'id' => 'login_show_rememberme', - 'type' => 'checkbox', - 'label' => __( 'Show "Remember Me"', 'ultimate-member' ), - 'default' => 1, - 'tooltip' => __( 'Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.', 'ultimate-member' ), - ) - ) - ) - ) - ), - 'extensions' => array( - 'title' => __( 'Extensions', 'ultimate-member' ) - ), - 'licenses' => array( - 'title' => __( 'Licenses', 'ultimate-member' ), - ), - 'misc' => array( - 'title' => __( 'Misc', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'form_asterisk', - 'type' => 'checkbox', - 'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ), - ), - array( - 'id' => 'profile_title', - 'type' => 'text', - 'label' => __( 'User Profile Title', 'ultimate-member' ), - 'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ), - 'size' => 'medium' - ), - array( - 'id' => 'profile_desc', - 'type' => 'textarea', - 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ), - 'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ), - 'args' => array( - 'textarea_rows' => 6 - ) - ), - array( - 'id' => 'um_profile_object_cache_stop', - 'type' => 'checkbox', - 'label' => __( 'Disable Cache User Profile', 'ultimate-member' ), - 'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ), - ), - array( - 'id' => 'enable_blocks', - 'type' => 'checkbox', - 'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ), - 'tooltip' => __( 'Check this box if you would like to use Ultimate Member blocks in Gutenberg editor. Important some themes have the conflicts with Gutenberg editor.', 'ultimate-member' ), - ), - array( - 'id' => 'rest_api_version', - 'type' => 'select', - 'label' => __( 'REST API version','ultimate-member' ), - 'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ), - 'options' => array( - '1.0' => __( '1.0 version', 'ultimate-member' ), - '2.0' => __( '2.0 version', 'ultimate-member' ), ), ), - $same_page_update, - array( - 'id' => 'uninstall_on_delete', - 'type' => 'checkbox', - 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ), - 'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ), - ) - ) - ), - 'install_info' => array( - 'title' => __( 'Install Info', 'ultimate-member' ), - 'fields' => array( - array( - 'type' => 'install_info', + ), + 'access' => array( + 'title' => __( 'Access', 'ultimate-member' ), + 'sections' => array( + '' => array( + 'title' => __( 'Restriction Content', 'ultimate-member' ), + 'fields' => $access_fields, + ), + 'other' => array( + 'title' => __( 'Other', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'enable_reset_password_limit', + 'type' => 'checkbox', + 'label' => __( 'Enable the Reset Password Limit?', 'ultimate-member' ), + ), + array( + 'id' => 'reset_password_limit_number', + 'type' => 'text', + 'label' => __( 'Reset Password Limit', 'ultimate-member' ), + 'tooltip' => __( 'Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.', 'ultimate-member' ), + 'validate' => 'numeric', + 'conditional' => array( 'enable_reset_password_limit', '=', 1 ), + 'size' => 'small', + ), + array( + 'id' => 'blocked_emails', + 'type' => 'textarea', + 'label' => __( 'Blocked Email Addresses', 'ultimate-member' ), + 'tooltip' => __( 'This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com', 'ultimate-member' ), + ), + array( + 'id' => 'blocked_words', + 'type' => 'textarea', + 'label' => __( 'Blacklist Words', 'ultimate-member' ), + 'tooltip' => __( 'This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username', 'ultimate-member' ), + ), + ), + ), ), - ) - ), - ) ); + ), + 'email' => array( + 'title' => __( 'Email', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'admin_email', + 'type' => 'text', + 'label' => __( 'Admin E-mail Address', 'ultimate-member' ), + 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ), + ), + array( + 'id' => 'mail_from', + 'type' => 'text', + 'label' => __( 'Mail appears from', 'ultimate-member' ), + 'tooltip' => __( 'e.g. Site Name', 'ultimate-member' ), + ), + array( + 'id' => 'mail_from_addr', + 'type' => 'text', + 'label' => __( 'Mail appears from address', 'ultimate-member' ), + 'tooltip' => __( 'e.g. admin@companyname.com', 'ultimate-member' ), + ), + array( + 'id' => 'email_html', + 'type' => 'checkbox', + 'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ), + 'tooltip' => __( 'If you plan use e-mails with HTML, please make sure that this option is enabled. Otherwise, HTML will be displayed as plain text.', 'ultimate-member' ), + ), + ), + ), + 'appearance' => array( + 'title' => __( 'Appearance', 'ultimate-member' ), + 'sections' => array( + '' => array( + 'title' => __( 'Profile', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'profile_template', + 'type' => 'select', + 'label' => __( 'Profile Default Template', 'ultimate-member' ), + 'tooltip' => __( 'This will be the default template to output profile', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_template' ), + 'options' => UM()->shortcodes()->get_templates( 'profile' ), + 'size' => 'small', + ), + array( + 'id' => 'profile_max_width', + 'type' => 'text', + 'label' => __( 'Profile Maximum Width', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_max_width' ), + 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ), + 'size' => 'small', + ), + array( + 'id' => 'profile_area_max_width', + 'type' => 'text', + 'label' => __( 'Profile Area Maximum Width', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_area_max_width' ), + 'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ), + 'size' => 'small', + ), + array( + 'id' => 'profile_icons', + 'type' => 'select', + 'label' => __( 'Profile Field Icons', 'ultimate-member' ), + 'tooltip' => __( 'This is applicable for edit mode only', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_icons' ), + 'options' => array( + 'field' => __( 'Show inside text field', 'ultimate-member' ), + 'label' => __( 'Show with label', 'ultimate-member' ), + 'off' => __( 'Turn off', 'ultimate-member' ), + ), + 'size' => 'small', + ), + array( + 'id' => 'profile_primary_btn_word', + 'type' => 'text', + 'label' => __( 'Profile Primary Button Text', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_primary_btn_word' ), + 'tooltip' => __( 'The text that is used for updating profile button', 'ultimate-member' ), + 'size' => 'medium', + ), + array( + 'id' => 'profile_secondary_btn', + 'type' => 'checkbox', + 'label' => __( 'Profile Secondary Button', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_secondary_btn' ), + 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ), + ), + array( + 'id' => 'profile_secondary_btn_word', + 'type' => 'text', + 'label' => __( 'Profile Secondary Button Text', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_secondary_btn_word' ), + 'tooltip' => __( 'The text that is used for cancelling update profile button', 'ultimate-member' ), + 'conditional' => array( 'profile_secondary_btn', '=', 1 ), + 'size' => 'medium', + ), + array( + 'id' => 'default_avatar', + 'type' => 'media', + 'label' => __( 'Default Profile Photo', 'ultimate-member' ), + 'tooltip' => __( 'You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member' ), + 'upload_frame_title' => __( 'Select Default Profile Photo', 'ultimate-member' ), + 'default' => array( + 'url' => um_url . 'assets/img/default_avatar.jpg', + ), + ), + array( + 'id' => 'default_cover', + 'type' => 'media', + 'url' => true, + 'preview' => false, + 'label' => __( 'Default Cover Photo', 'ultimate-member' ), + 'tooltip' => __( 'You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member' ), + 'upload_frame_title' => __( 'Select Default Cover Photo', 'ultimate-member' ), + ), + array( + 'id' => 'disable_profile_photo_upload', + 'type' => 'checkbox', + 'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ), + 'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ), + 'default' => um_get_metadefault( 'disable_profile_photo_upload' ), + ), + array( + 'id' => 'profile_photosize', + 'type' => 'select', + 'label' => __( 'Profile Photo Size', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_photosize' ), + 'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ), + 'tooltip' => __( 'The global default of profile photo size. This can be overridden by individual form settings', 'ultimate-member' ), + 'size' => 'small', + ), + array( + 'id' => 'profile_cover_enabled', + 'type' => 'checkbox', + 'label' => __( 'Profile Cover Photos', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_cover_enabled' ), + 'tooltip' => __( 'Switch on/off the profile cover photos', 'ultimate-member' ), + ), + array( + 'id' => 'profile_coversize', + 'type' => 'select', + 'label' => __( 'Profile Cover Size', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_coversize' ), + 'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ), + 'tooltip' => __( 'The global default width of cover photo size. This can be overridden by individual form settings', 'ultimate-member' ), + 'conditional' => array( 'profile_cover_enabled', '=', 1 ), + 'size' => 'small', + ), + array( + 'id' => 'profile_cover_ratio', + 'type' => 'select', + 'label' => __( 'Profile Cover Ratio', 'ultimate-member' ), + 'tooltip' => __( 'Choose global ratio for cover photos of profiles', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_cover_ratio' ), + 'options' => array( + '1.6:1' => '1.6:1', + '2.7:1' => '2.7:1', + '2.2:1' => '2.2:1', + '3.2:1' => '3.2:1', + ), + 'conditional' => array( 'profile_cover_enabled', '=', 1 ), + 'size' => 'small', + ), + array( + 'id' => 'profile_show_metaicon', + 'type' => 'checkbox', + 'label' => __( 'Profile Header Meta Text Icon', 'ultimate-member' ), + 'default' => 0, + 'tooltip' => __( 'Display field icons for related user meta fields in header or not', 'ultimate-member' ), + ), + array( + 'id' => 'profile_show_name', + 'type' => 'checkbox', + 'label' => __( 'Show display name in profile header', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_show_name' ), + 'tooltip' => __( 'Switch on/off the user name on profile header', 'ultimate-member' ), + ), + array( + 'id' => 'profile_show_social_links', + 'type' => 'checkbox', + 'label' => __( 'Show social links in profile header', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_show_social_links' ), + 'tooltip' => __( 'Switch on/off the social links on profile header', 'ultimate-member' ), + ), + array( + 'id' => 'profile_show_bio', + 'type' => 'checkbox', + 'label' => __( 'Show user description in header', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_show_bio' ), + 'tooltip' => __( 'Switch on/off the user description on profile header', 'ultimate-member' ), + ), + array( + 'id' => 'profile_show_html_bio', + 'type' => 'checkbox', + 'label' => __( 'Enable HTML support for user description', 'ultimate-member' ), + 'tooltip' => __( 'Switch on/off to enable/disable support for html tags on user description.', 'ultimate-member' ), + ), + array( + 'id' => 'profile_bio_maxchars', + 'type' => 'text', + 'label' => __( 'User description maximum chars', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_bio_maxchars' ), + 'tooltip' => __( 'Maximum number of characters to allow in user description field in header.', 'ultimate-member' ), + 'conditional' => array( 'profile_show_bio', '=', 1 ), + 'size' => 'small', + ), + array( + 'id' => 'profile_header_menu', + 'type' => 'select', + 'label' => __( 'Profile Header Menu Position', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_header_menu' ), + 'tooltip' => __( 'For incompatible themes, please make the menu open from left instead of bottom by default.', 'ultimate-member' ), + 'options' => array( + 'bc' => __( 'Bottom of Icon', 'ultimate-member' ), + 'lc' => __( 'Left of Icon (right for RTL)', 'ultimate-member' ), + ), + 'size' => 'small', + ), + array( + 'id' => 'profile_empty_text', + 'type' => 'checkbox', + 'label' => __( 'Show a custom message if profile is empty', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_empty_text' ), + 'tooltip' => __( 'Switch on/off the custom message that appears when the profile is empty', 'ultimate-member' ), + ), + array( + 'id' => 'profile_empty_text_emo', + 'type' => 'checkbox', + 'label' => __( 'Show the emoticon', 'ultimate-member' ), + 'default' => um_get_metadefault( 'profile_empty_text_emo' ), + 'tooltip' => __( 'Switch on/off the emoticon (sad face) that appears above the message', 'ultimate-member' ), + 'conditional' => array( 'profile_empty_text', '=', 1 ), + ), + ), + ), + 'profile_menu' => array( + 'title' => __( 'Profile Menu', 'ultimate-member' ), + 'fields' => $appearances_profile_menu_fields, + ), + 'registration_form' => array( + 'title' => __( 'Registration Form', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'register_template', + 'type' => 'select', + 'label' => __( 'Registration Default Template', 'ultimate-member' ), + 'tooltip' => __( 'This will be the default template to output registration', 'ultimate-member' ), + 'default' => um_get_metadefault( 'register_template' ), + 'options' => UM()->shortcodes()->get_templates( 'register' ), + 'size' => 'small', + ), + array( + 'id' => 'register_max_width', + 'type' => 'text', + 'label' => __( 'Registration Maximum Width', 'ultimate-member' ), + 'default' => um_get_metadefault( 'register_max_width' ), + 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ), + 'size' => 'small', + ), + array( + 'id' => 'register_align', + 'type' => 'select', + 'label' => __( 'Registration Shortcode Alignment', 'ultimate-member' ), + 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ), + 'default' => um_get_metadefault( 'register_align' ), + 'options' => array( + 'center' => __( 'Centered', 'ultimate-member' ), + 'left' => __( 'Left aligned', 'ultimate-member' ), + 'right' => __( 'Right aligned', 'ultimate-member' ), + ), + 'size' => 'small', + ), + array( + 'id' => 'register_icons', + 'type' => 'select', + 'label' => __( 'Registration Field Icons', 'ultimate-member' ), + 'tooltip' => __( 'This controls the display of field icons in the registration form', 'ultimate-member' ), + 'default' => um_get_metadefault( 'register_icons' ), + 'options' => array( + 'field' => __( 'Show inside text field', 'ultimate-member' ), + 'label' => __( 'Show with label', 'ultimate-member' ), + 'off' => __( 'Turn off', 'ultimate-member' ), + ), + 'size' => 'small', + ), + array( + 'id' => 'register_primary_btn_word', + 'type' => 'text', + 'label' => __( 'Registration Primary Button Text', 'ultimate-member' ), + 'default' => um_get_metadefault( 'register_primary_btn_word' ), + 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ), + 'size' => 'medium', + ), + array( + 'id' => 'register_secondary_btn', + 'type' => 'checkbox', + 'label' => __( 'Registration Secondary Button', 'ultimate-member' ), + 'default' => 1, + 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ), + ), + array( + 'id' => 'register_secondary_btn_word', + 'type' => 'text', + 'label' => __( 'Registration Secondary Button Text', 'ultimate-member' ), + 'default' => um_get_metadefault( 'register_secondary_btn_word' ), + 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ), + 'conditional' => array( 'register_secondary_btn', '=', 1 ), + 'size' => 'medium', + ), + array( + 'id' => 'register_secondary_btn_url', + 'type' => 'text', + 'label' => __( 'Registration Secondary Button URL', 'ultimate-member' ), + 'default' => um_get_metadefault( 'register_secondary_btn_url' ), + 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ), + 'conditional' => array( 'register_secondary_btn', '=', 1 ), + 'size' => 'medium', + ), + array( + 'id' => 'register_role', + 'type' => 'select', + 'label' => __( 'Registration Default Role', 'ultimate-member' ), + 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form', 'ultimate-member' ), + 'default' => um_get_metadefault( 'register_role' ), + 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ), + 'size' => 'small', + ), + ), + ), + 'login_form' => array( + 'title' => __( 'Login Form', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'login_template', + 'type' => 'select', + 'label' => __( 'Login Default Template', 'ultimate-member' ), + 'tooltip' => __( 'This will be the default template to output login', 'ultimate-member' ), + 'default' => um_get_metadefault( 'login_template' ), + 'options' => UM()->shortcodes()->get_templates( 'login' ), + 'size' => 'small', + ), + array( + 'id' => 'login_max_width', + 'type' => 'text', + 'label' => __( 'Login Maximum Width', 'ultimate-member' ), + 'default' => um_get_metadefault( 'login_max_width' ), + 'tooltip' => __( 'The maximum width this shortcode can take from the page width', 'ultimate-member' ), + 'size' => 'small', + ), + array( + 'id' => 'login_align', + 'type' => 'select', + 'label' => __( 'Login Shortcode Alignment', 'ultimate-member' ), + 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ), + 'default' => um_get_metadefault( 'login_align' ), + 'options' => array( + 'center' => __( 'Centered', 'ultimate-member' ), + 'left' => __( 'Left aligned', 'ultimate-member' ), + 'right' => __( 'Right aligned', 'ultimate-member' ), + ), + 'size' => 'small', + ), + array( + 'id' => 'login_icons', + 'type' => 'select', + 'label' => __( 'Login Field Icons', 'ultimate-member' ), + 'tooltip' => __( 'This controls the display of field icons in the login form', 'ultimate-member' ), + 'default' => um_get_metadefault( 'login_icons' ), + 'options' => array( + 'field' => __( 'Show inside text field', 'ultimate-member' ), + 'label' => __( 'Show with label', 'ultimate-member' ), + 'off' => __( 'Turn off', 'ultimate-member' ), + ), + 'size' => 'small', + ), + array( + 'id' => 'login_primary_btn_word', + 'type' => 'text', + 'label' => __( 'Login Primary Button Text', 'ultimate-member' ), + 'default' => um_get_metadefault( 'login_primary_btn_word' ), + 'tooltip' => __( 'The text that is used for primary button text', 'ultimate-member' ), + 'size' => 'medium', + ), + array( + 'id' => 'login_secondary_btn', + 'type' => 'checkbox', + 'label' => __( 'Login Secondary Button', 'ultimate-member' ), + 'default' => 1, + 'tooltip' => __( 'Switch on/off the secondary button display in the form', 'ultimate-member' ), + ), + array( + 'id' => 'login_secondary_btn_word', + 'type' => 'text', + 'label' => __( 'Login Secondary Button Text', 'ultimate-member' ), + 'default' => um_get_metadefault( 'login_secondary_btn_word' ), + 'tooltip' => __( 'The text that is used for the secondary button text', 'ultimate-member' ), + 'conditional' => array( 'login_secondary_btn', '=', 1 ), + 'size' => 'medium', + ), + array( + 'id' => 'login_secondary_btn_url', + 'type' => 'text', + 'label' => __( 'Login Secondary Button URL', 'ultimate-member' ), + 'default' => um_get_metadefault( 'login_secondary_btn_url' ), + 'tooltip' => __( 'You can replace default link for this button by entering custom URL', 'ultimate-member' ), + 'conditional' => array( 'login_secondary_btn', '=', 1 ), + 'size' => 'medium', + ), + array( + 'id' => 'login_forgot_pass_link', + 'type' => 'checkbox', + 'label' => __( 'Login Forgot Password Link', 'ultimate-member' ), + 'default' => 1, + 'tooltip' => __( 'Switch on/off the forgot password link in login form', 'ultimate-member' ), + ), + array( + 'id' => 'login_show_rememberme', + 'type' => 'checkbox', + 'label' => __( 'Show "Remember Me"', 'ultimate-member' ), + 'default' => 1, + 'tooltip' => __( 'Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.', 'ultimate-member' ), + ), + ), + ), + ), + ), + 'extensions' => array( + 'title' => __( 'Extensions', 'ultimate-member' ), + ), + 'licenses' => array( + 'title' => __( 'Licenses', 'ultimate-member' ), + ), + 'misc' => array( + 'title' => __( 'Misc', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'form_asterisk', + 'type' => 'checkbox', + 'label' => __( 'Show an asterisk for required fields', 'ultimate-member' ), + ), + array( + 'id' => 'profile_title', + 'type' => 'text', + 'label' => __( 'User Profile Title', 'ultimate-member' ), + 'tooltip' => __( 'This is the title that is displayed on a specific user profile', 'ultimate-member' ), + 'size' => 'medium', + ), + array( + 'id' => 'profile_desc', + 'type' => 'textarea', + 'label' => __( 'User Profile Dynamic Meta Description', 'ultimate-member' ), + 'tooltip' => __( 'This will be used in the meta description that is available for search-engines.', 'ultimate-member' ), + 'args' => array( + 'textarea_rows' => 6, + ), + ), + array( + 'id' => 'um_profile_object_cache_stop', + 'type' => 'checkbox', + 'label' => __( 'Disable Cache User Profile', 'ultimate-member' ), + 'tooltip' => __( 'Check this box if you would like to disable Ultimate Member user\'s cache.', 'ultimate-member' ), + ), + array( + 'id' => 'enable_blocks', + 'type' => 'checkbox', + 'label' => __( 'Enable Gutenberg Blocks', 'ultimate-member' ), + 'tooltip' => __( 'Check this box if you would like to use Ultimate Member blocks in Gutenberg editor. Important some themes have the conflicts with Gutenberg editor.', 'ultimate-member' ), + ), + array( + 'id' => 'rest_api_version', + 'type' => 'select', + 'label' => __( 'REST API version', 'ultimate-member' ), + 'tooltip' => __( 'This controls the REST API version, we recommend to use the last version', 'ultimate-member' ), + 'options' => array( + '1.0' => __( '1.0 version', 'ultimate-member' ), + '2.0' => __( '2.0 version', 'ultimate-member' ), + ), + ), + $same_page_update, + array( + 'id' => 'uninstall_on_delete', + 'type' => 'checkbox', + 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ), + 'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ), + ), + ), + ), + 'install_info' => array( + 'title' => __( 'Install Info', 'ultimate-member' ), + 'fields' => array( + array( + 'type' => 'install_info', + ), + ), + ), + ) + ); } /** - * @param $settings + * @param array $settings * - * @return mixed + * @return array */ - function sorting_licenses_options( $settings ) { + public function sorting_licenses_options( $settings ) { //sorting licenses if ( empty( $settings['licenses']['fields'] ) ) { return $settings; @@ -1388,7 +1781,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $licenses = $settings['licenses']['fields']; @uasort( $licenses, function( $a, $b ) { - return strnatcasecmp( $a["label"], $b["label"] ); + return strnatcasecmp( $a['label'], $b['label'] ); } ); $settings['licenses']['fields'] = $licenses; @@ -1399,18 +1792,18 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $extensions = $settings['extensions']['sections']; @uasort( $extensions, function( $a, $b ) { - return strnatcasecmp( $a["title"], $b["title"] ); + return strnatcasecmp( $a['title'], $b['title'] ); } ); $keys = array_keys( $extensions ); - if ( $keys[0] != "" ) { - $new_key = strtolower( str_replace( " ", "_", $extensions[""]['title'] ) ); - $temp = $extensions[""]; - $extensions[$new_key] = $temp; - $extensions[""] = $extensions[$keys[0]]; - unset( $extensions[$keys[0]] ); + if ( $keys[0] !== '' ) { + $new_key = strtolower( str_replace( ' ', '_', $extensions['']['title'] ) ); + $temp = $extensions['']; + $extensions[ $new_key ] = $temp; + $extensions[''] = $extensions[ $keys[0] ]; + unset( $extensions[ $keys[0] ] ); @uasort( $extensions, function( $a, $b ) { - return strnatcasecmp( $a["title"], $b["title"] ); + return strnatcasecmp( $a['title'], $b['title'] ); } ); } @@ -1650,9 +2043,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] ); foreach ( $menu_tabs as $name => $label ) { $active = ( $current_tab == $name ) ? 'nav-tab-active' : ''; - $tabs .= '' . - $label . - ''; + $tabs .= '' . + $label . + ''; } break; @@ -1707,8 +2100,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { foreach ( $menu_subtabs as $name => $label ) { $active = ( $current_subtab == $name ) ? 'current' : ''; $subtabs .= '' - . $label . - ' | '; + . $label . + ' | '; } return substr( $subtabs, 0, -3 ) . ''; @@ -1722,7 +2115,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { */ function save_settings_handler() { - if ( isset( $_POST['um-settings-action'] ) && 'save' == sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) { + if ( isset( $_POST['um-settings-action'] ) && 'save' === sanitize_key( $_POST['um-settings-action'] ) && ! empty( $_POST['um_options'] ) ) { $nonce = ! empty( $_POST['__umnonce'] ) ? $_POST['__umnonce'] : ''; @@ -1772,6 +2165,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { */ $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] ); + $settings = UM()->admin()->sanitize_options( $settings ); + foreach ( $settings as $key => $value ) { UM()->options()->update( $key, $value ); } @@ -1862,7 +2257,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { */ function check_permalinks_changes() { if ( ! empty( $_POST['um_options']['permalink_base'] ) ) { - if ( UM()->options()->get( 'permalink_base' ) != $_POST['um_options']['permalink_base'] ) { + if ( UM()->options()->get( 'permalink_base' ) !== $_POST['um_options']['permalink_base'] ) { $this->need_change_permalinks = true; } } @@ -1981,7 +2376,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { global $wpdb; - if ( $_POST['um_options']['account_hide_in_directory_default'] == 'No' ) { + if ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) { $results = $wpdb->get_col( "SELECT u.ID FROM {$wpdb->users} AS u @@ -2007,7 +2402,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { foreach ( $results as $user_id ) { $md_data = get_user_meta( $user_id, 'um_member_directory_data', true ); if ( ! empty( $md_data ) ) { - $md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] == 'No' ) ? false : true; + $md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true; update_user_meta( $user_id, 'um_member_directory_data', $md_data ); } } @@ -2027,7 +2422,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } foreach ( $_POST['um_options'] as $key => $value ) { - $this->previous_licenses[ $key ] = UM()->options()->get( $key ); + $this->previous_licenses[ sanitize_key( $key ) ] = UM()->options()->get( $key ); } } @@ -2041,6 +2436,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } foreach ( $_POST['um_options'] as $key => $value ) { + $key = sanitize_key( $key ); + $value = sanitize_text_field( $value ); + $edd_action = ''; $license_key = ''; if ( empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[ $key ] ) && ! empty( $value ) && $this->previous_licenses[ $key ] != $value ) ) { @@ -2642,7 +3040,7 @@ Generate Slugs on Directories: options()->get( 'um_generate_slug Force UTF-8 Encoding: options()->get( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?> JS/CSS Compression: - Network Structure: options()->get( 'network_permalink_structure' ). "\n"; ?> + Network Structure: options()->get( 'network_permalink_structure' ). "\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"; ?> @@ -2707,7 +3105,7 @@ Redirect author to profile: info_value( UM()->options()->get Enable Members Directory: info_value( UM()->options()->get('members_page'), 'yesno', true ); ?> Use Gravatars: info_value( UM()->options()->get('use_gravatars'), 'yesno', true ); ?> options()->get('use_gravatars') ): ?>Gravatar builtin image: options()->get('use_um_gravatar_default_builtin_image') . "\n"; ?> - UM Avatar as blank Gravatar: info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?> + UM Avatar as blank Gravatar: info_value( UM()->options()->get('use_um_gravatar_default_image'), 'yesno', true ); ?> Require a strong password: info_value( UM()->options()->get('reset_require_strongpass'), 'onoff', true ); ?> @@ -2765,50 +3163,50 @@ Password Changed Email: info_value( UM()->options()->get('ch --- UM Total Users --- - $count ) { - echo $role."(".$count.")\n"; - } ?> + $count ) { + echo $role."(".$count.")\n"; + } ?> --- UM Roles --- - roles()->get_roles() as $role_id => $role ) { - echo $role." ({$role_id})\n"; - } ?> + roles()->get_roles() as $role_id => $role ) { + echo $role." ({$role_id})\n"; + } ?> --- UM Custom Templates --- - + --- UM Email HTML Templates --- - + if ( ! empty( $dir ) ) { + $found = glob( $dir ); + if ( ! empty( $found ) ){ + foreach ( glob( $dir ) as $file ) { + echo "File: ". $file . "\n"; + } + } else { + echo 'N/A'."\n"; + } + } ?> --- Web Server Configurations --- @@ -2854,81 +3252,80 @@ Use Only Cookies: $plugin ) { - // If the plugin isn't active, don't show it. - if ( ! in_array( $plugin_path, $active_plugins ) ) - continue; + foreach ( $plugins as $plugin_path => $plugin ) { + // If the plugin isn't active, don't show it. + if ( ! in_array( $plugin_path, $active_plugins ) ) + continue; - echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n"; - } + echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n"; + } - if ( is_multisite() ) { ?> + if ( is_multisite() ) { ?> --- WordPress Network Active Plugins --- - - */ - do_action( 'um_install_info_after' ); ?> + /** + * UM hook + * + * @type action + * @title um_install_info_after + * @description After install info + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_install_info_after', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_install_info_after' ); ?> ### End Install Info ### - -- - -
- + ++ + +
+ - query_vars["order"] = 'desc'; - $query->query_orderby = " ORDER BY user_registered " . ( $query->query_vars["order"] == 'desc' ? 'desc ' : 'asc ' ); //set sort order + $query->query_vars['order'] = 'desc'; + $query->query_orderby = ' ORDER BY user_registered ' . ( 'desc' === $query->query_vars['order'] ? 'desc ' : 'asc ' ); //set sort order } } @@ -326,13 +326,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) { * @param $query * @return mixed */ - function filter_users_by_status( $query ) { + public function filter_users_by_status( $query ) { global $wpdb, $pagenow; - if ( is_admin() && $pagenow == 'users.php' && ! empty( $_REQUEST['um_status'] ) ) { + if ( is_admin() && 'users.php' === $pagenow && ! empty( $_REQUEST['um_status'] ) ) { $status = sanitize_key( $_REQUEST['um_status'] ); - - if ( $status == 'needs-verification' ) { + + if ( 'needs-verification' === $status ) { $query->query_where = str_replace('WHERE 1=1', "WHERE 1=1 AND {$wpdb->users}.ID IN ( SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta @@ -349,7 +349,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) { $query->query_where ); } - } return $query; @@ -360,9 +359,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) { * Add status links to WP Users List Table * * @param $views - * @return array|mixed|void + * @return array */ - function add_status_links( $views ) { + public function add_status_links( $views ) { remove_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) ); $old_views = $views; @@ -375,17 +374,17 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) { } $status = array( - 'approved' => __( 'Approved', 'ultimate-member' ), - 'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ), - 'awaiting_email_confirmation' => __( 'Waiting e-mail confirmation', 'ultimate-member' ), - 'inactive' => __( 'Inactive', 'ultimate-member' ), - 'rejected' => __( 'Rejected', 'ultimate-member' ) + 'approved' => __( 'Approved', 'ultimate-member' ), + 'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ), + 'awaiting_email_confirmation' => __( 'Waiting e-mail confirmation', 'ultimate-member' ), + 'inactive' => __( 'Inactive', 'ultimate-member' ), + 'rejected' => __( 'Rejected', 'ultimate-member' ), ); UM()->query()->count_users_by_status( 'unassigned' ); foreach ( $status as $k => $v ) { - if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) == $k ) { + if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) === $k ) { $current = 'class="current"'; } else { $current = ''; @@ -429,11 +428,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) { // hide filters with not accessible roles if ( ! current_user_can( 'administrator' ) ) { - $wp_roles = wp_roles(); + $wp_roles = wp_roles(); $can_view_roles = um_user( 'can_view_roles' ); if ( ! empty( $can_view_roles ) ) { foreach ( $wp_roles->get_names() as $this_role => $name ) { - if ( ! in_array( $this_role, $can_view_roles ) ) { + if ( ! in_array( $this_role, $can_view_roles, true ) ) { unset( $views[ $this_role ] ); } } @@ -447,20 +446,20 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) { /** * Bulk user editing actions */ - function um_bulk_users_edit() { + public function um_bulk_users_edit() { // bulk edit users if ( ! empty( $_REQUEST['users'] ) && ! empty( $_REQUEST['um_bulkedit'] ) && ! empty( $_REQUEST['um_bulk_action'] ) ) { $rolename = UM()->roles()->get_priority_user_role( get_current_user_id() ); - $role = get_role( $rolename ); + $role = get_role( $rolename ); - if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) { - wp_die( __( 'You do not have enough permissions to do that.', 'ultimate-member' ) ); + if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) { + wp_die( esc_html__( 'You do not have enough permissions to do that.', 'ultimate-member' ) ); } check_admin_referer( 'bulk-users' ); - $users = array_map( 'absint', (array) $_REQUEST['users'] ); + $users = array_map( 'absint', (array) $_REQUEST['users'] ); $bulk_action = current( array_filter( $_REQUEST['um_bulk_action'] ) ); foreach ( $users as $user_id ) { @@ -552,4 +551,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) { } } -} \ No newline at end of file +} diff --git a/includes/admin/core/list-tables/roles-list-table.php b/includes/admin/core/list-tables/roles-list-table.php index 31e94f5e..947159f9 100644 --- a/includes/admin/core/list-tables/roles-list-table.php +++ b/includes/admin/core/list-tables/roles-list-table.php @@ -1,11 +1,13 @@ - get_current_blog_id(), - 'role__in' => $um_custom_roles, - 'number' => -1, - 'count_total' => false, - 'fields' => 'ids', + 'blog_id' => get_current_blog_id(), + 'role__in' => $um_custom_roles, + 'number' => -1, + 'count_total' => false, + 'fields' => 'ids', ); $users_to_subscriber = get_users( $args ); if ( ! empty( $users_to_subscriber ) ) { @@ -70,7 +72,12 @@ if ( isset( $_GET['action'] ) ) { //update user role if it's empty if ( empty( $object_user->roles ) ) { - wp_update_user( array( 'ID' => $user_id, 'role' => 'subscriber' ) ); + wp_update_user( + array( + 'ID' => $user_id, + 'role' => 'subscriber', + ) + ); } } } @@ -85,7 +92,7 @@ if ( isset( $_GET['action'] ) ) { if ( isset( $_REQUEST['id'] ) ) { check_admin_referer( 'um_role_reset' . sanitize_key( $_REQUEST['id'] ) . get_current_user_id() ); $role_keys = (array) sanitize_key( $_REQUEST['id'] ); - } elseif( isset( $_REQUEST['item'] ) ) { + } elseif ( isset( $_REQUEST['item'] ) ) { check_admin_referer( 'bulk-' . sanitize_key( __( 'Roles', 'ultimate-member' ) ) ); $role_keys = array_map( 'sanitize_key', $_REQUEST['item'] ); } @@ -98,7 +105,7 @@ if ( isset( $_GET['action'] ) ) { $role_meta = get_option( "um_role_{$role_key}_meta" ); if ( ! empty( $role_meta['_um_is_custom'] ) ) { - unset( $role_keys[ array_search( $role_key, $role_keys ) ] ); + unset( $role_keys[ array_search( $role_key, $role_keys, true ) ] ); continue; } @@ -113,14 +120,14 @@ if ( isset( $_GET['action'] ) ) { //remove extra query arg if ( ! empty( $_GET['_wp_http_referer'] ) ) { - um_js_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); + um_js_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); } $order_by = 'name'; -$order = ( isset( $_GET['order'] ) && 'asc' == strtolower( sanitize_key( $_GET['order'] ) ) ) ? 'ASC' : 'DESC'; +$order = ( isset( $_GET['order'] ) && 'asc' === strtolower( sanitize_key( $_GET['order'] ) ) ) ? 'ASC' : 'DESC'; if ( ! class_exists( 'WP_List_Table' ) ) { - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; } @@ -171,11 +178,11 @@ class UM_Roles_List_Table extends WP_List_Table { * * @param array $args */ - function __construct( $args = array() ){ + function __construct( $args = array() ) { $args = wp_parse_args( $args, array( - 'singular' => __( 'item', 'ultimate-member' ), - 'plural' => __( 'items', 'ultimate-member' ), - 'ajax' => false + 'singular' => __( 'item', 'ultimate-member' ), + 'plural' => __( 'items', 'ultimate-member' ), + 'ajax' => false, ) ); $this->no_items_message = $args['plural'] . ' ' . __( 'not found.', 'ultimate-member' ); @@ -199,9 +206,9 @@ class UM_Roles_List_Table extends WP_List_Table { * */ function prepare_items() { - $columns = $this->get_columns(); - $hidden = array(); - $sortable = $this->get_sortable_columns(); + $columns = $this->get_columns(); + $hidden = array(); + $sortable = $this->get_sortable_columns(); $this->_column_headers = array( $columns, $hidden, $sortable ); } @@ -236,11 +243,11 @@ class UM_Roles_List_Table extends WP_List_Table { */ function set_sortable_columns( $args = array() ) { $return_args = array(); - foreach( $args as $k=>$val ) { - if( is_numeric( $k ) ) { - $return_args[ $val ] = array( $val, $val == $this->default_sorting_field ); - } else if( is_string( $k ) ) { - $return_args[ $k ] = array( $val, $k == $this->default_sorting_field ); + foreach ( $args as $k => $val ) { + if ( is_numeric( $k ) ) { + $return_args[ $val ] = array( $val, $val === $this->default_sorting_field ); + } elseif ( is_string( $k ) ) { + $return_args[ $k ] = array( $val, $k === $this->default_sorting_field ); } else { continue; } @@ -336,21 +343,21 @@ class UM_Roles_List_Table extends WP_List_Table { function column_title( $item ) { $actions = array(); - $actions['edit'] = '' . __( 'Edit', 'ultimate-member' ). ''; + $actions['edit'] = '' . __( 'Edit', 'ultimate-member' ) . ''; if ( ! empty( $item['_um_is_custom'] ) ) { - $actions['delete'] = '' . __( 'Delete', 'ultimate-member' ). ''; + $actions['delete'] = '' . __( 'Delete', 'ultimate-member' ) . ''; } else { $role_meta = get_option( "um_role_{$item['key']}_meta" ); if ( ! empty( $role_meta ) ) { - $actions['reset'] = '' . __( 'Reset UM Role meta', 'ultimate-member' ). ''; + $actions['reset'] = '' . __( 'Reset UM Role meta', 'ultimate-member' ) . ''; } } - return sprintf('%1$s %2$s', '' . stripslashes( $item['name'] ) . '', $this->row_actions( $actions ) ); + return sprintf('%1$s %2$s', '' . stripslashes( $item['name'] ) . '', $this->row_actions( $actions ) ); } @@ -487,7 +494,7 @@ $ListTable->um_set_pagination_args( array( 'total_items' => count( $roles ), 'pe' . __( 'User Role Deleted Successfully.', 'ultimate-member' ) . '
'; break; @@ -498,4 +505,4 @@ $ListTable->um_set_pagination_args( array( 'total_items' => count( $roles ), 'pe display(); ?> - \ No newline at end of file + diff --git a/includes/admin/core/packages/2.0-beta1/functions.php b/includes/admin/core/packages/2.0-beta1/functions.php index e44e9f16..2c998794 100644 --- a/includes/admin/core/packages/2.0-beta1/functions.php +++ b/includes/admin/core/packages/2.0-beta1/functions.php @@ -32,7 +32,7 @@ function um_upgrade_get_users_per_role20beta1() { 'meta_query' => array( array( 'key' => 'role', - 'value' => $_POST['key_in_meta'] + 'value' => sanitize_key( $_POST['key_in_meta'] ), ) ), 'number' => '', @@ -62,10 +62,10 @@ function um_upgrade_update_users_per_page20beta1() { 'meta_query' => array( array( 'key' => 'role', - 'value' => $_POST['key_in_meta'] + 'value' => sanitize_key( $_POST['key_in_meta'] ), ) ), - 'paged' => $_POST['page'], + 'paged' => absint( $_POST['page'] ), 'number' => $users_per_page, ); $all_users = get_users( $args ); @@ -74,17 +74,17 @@ function um_upgrade_update_users_per_page20beta1() { foreach ( $all_users as $k => $user ) { $user_object = get_userdata( $user->ID ); - if ( ! in_array( $_POST['role_key'], $all_wp_roles ) ) { - $user_object->add_role( 'um_' . $_POST['role_key'] ); + if ( ! in_array( sanitize_key( $_POST['role_key'] ), $all_wp_roles ) ) { + $user_object->add_role( 'um_' . sanitize_key( $_POST['role_key'] ) ); } else { - if ( ! in_array( $_POST['role_key'], (array) $user_object->roles ) ) { - $user_object->add_role( $_POST['role_key'] ); + if ( ! in_array( sanitize_key( $_POST['role_key'] ), (array) $user_object->roles ) ) { + $user_object->add_role( sanitize_key( $_POST['role_key'] ) ); } } } - $from = ( $_POST['page'] * $users_per_page ) - $users_per_page + 1; - $to = $_POST['page'] * $users_per_page; + $from = ( absint( $_POST['page'] ) * $users_per_page ) - $users_per_page + 1; + $to = absint( $_POST['page'] ) * $users_per_page; wp_send_json_success( array( 'message' => sprintf( __( 'Users from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) ); } else { @@ -184,7 +184,7 @@ function um_upgrade_update_forum_per_page20beta1() { $p_query = new WP_Query; $bb_forums = $p_query->query( array( 'post_type' => 'forum', - 'paged' => $_POST['page'], + 'paged' => absint( $_POST['page'] ), 'posts_per_page' => $posts_per_page, 'fields' => 'ids' ) ); @@ -212,8 +212,8 @@ function um_upgrade_update_forum_per_page20beta1() { } } - $from = ( $_POST['page'] * $posts_per_page ) - $posts_per_page + 1; - $to = $_POST['page'] * $posts_per_page; + $from = ( absint( $_POST['page'] ) * $posts_per_page ) - $posts_per_page + 1; + $to = absint( $_POST['page'] ) * $posts_per_page; wp_send_json_success( array( 'message' => sprintf( __( 'Forums from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) ); } else { @@ -250,7 +250,7 @@ function um_upgrade_update_products_per_page20beta1() { $p_query = new WP_Query; $wc_products = $p_query->query( array( 'post_type' => 'product', - 'paged' => $_POST['page'], + 'paged' => absint( $_POST['page'] ), 'posts_per_page' => $posts_per_page, 'fields' => 'ids' ) ); @@ -299,8 +299,8 @@ function um_upgrade_update_products_per_page20beta1() { } } - $from = ( $_POST['page'] * $posts_per_page ) - $posts_per_page + 1; - $to = $_POST['page'] * $posts_per_page; + $from = ( absint( $_POST['page'] ) * $posts_per_page ) - $posts_per_page + 1; + $to = absint( $_POST['page'] ) * $posts_per_page; wp_send_json_success( array( 'message' => sprintf( __( 'Woocommerce Products from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) ); } else { @@ -321,4 +321,4 @@ function um_upgrade_email_templates20beta1() { delete_option( 'um_roles_associations' ); wp_send_json_success( array( 'message' => __( 'Email Templates was upgraded successfully', 'ultimate-member' ) ) ); -} \ No newline at end of file +} diff --git a/includes/admin/core/packages/2.1.3-beta3/functions.php b/includes/admin/core/packages/2.1.3-beta3/functions.php index 373a3b7a..66cffd7f 100644 --- a/includes/admin/core/packages/2.1.3-beta3/functions.php +++ b/includes/admin/core/packages/2.1.3-beta3/functions.php @@ -36,7 +36,7 @@ function um_upgrade_metadata_per_user213beta3() { ORDER BY u.ID LIMIT %d, %d ) as dt", - ( $_POST['page'] - 1 ) * $per_page, + ( absint( $_POST['page'] ) - 1 ) * $per_page, $per_page ), ARRAY_A ); @@ -112,8 +112,8 @@ function um_upgrade_metadata_per_user213beta3() { } } - $from = ( $_POST['page'] * $per_page ) - $per_page + 1; - $to = $_POST['page'] * $per_page; + $from = ( absint( $_POST['page'] ) * $per_page ) - $per_page + 1; + $to = absint( $_POST['page'] ) * $per_page; wp_send_json_success( array( 'message' => sprintf( __( 'Metadata from %s to %s users were upgraded successfully...', 'ultimate-member' ), $from, $to ) ) ); } @@ -144,4 +144,4 @@ KEY meta_value_indx (um_value(191)) update_option( 'um_last_version_upgrade', '2.1.3-beta3' ); wp_send_json_success( array( 'message' => __( 'Usermeta table was upgraded successfully', 'ultimate-member' ) ) ); -} \ No newline at end of file +} diff --git a/includes/admin/templates/directory/appearance.php b/includes/admin/templates/directory/appearance.php index 230d986c..63ef56b9 100644 --- a/includes/admin/templates/directory/appearance.php +++ b/includes/admin/templates/directory/appearance.php @@ -1,18 +1,23 @@ - - + \ No newline at end of file + )->render_form(); + ?> + diff --git a/includes/admin/templates/directory/general.php b/includes/admin/templates/directory/general.php index 60a40d7d..c1bde05e 100644 --- a/includes/admin/templates/directory/general.php +++ b/includes/admin/templates/directory/general.php @@ -1,4 +1,6 @@ -member_directory()->view_types ); +$view_types_options = array_map( + function( $item ) { + return $item['title']; + }, + UM()->member_directory()->view_types +); $conditional = array(); foreach ( $view_types_options as $key => $value ) { $conditional[] = '_um_view_types_' . $key; -} ?> +} + + +$fields = array( + array( + 'id' => '_um_mode', + 'type' => 'hidden', + 'value' => 'directory', + ), + array( + 'id' => '_um_view_types', + 'type' => 'multi_checkbox', + 'label' => __( 'View type(s)', 'ultimate-member' ), + 'tooltip' => __( 'View type a specific parameter in the directory', 'ultimate-member' ), + 'options' => $view_types_options, + 'columns' => 3, + 'value' => $_um_view_types_value, + 'data' => array( 'fill__um_default_view' => 'checkbox_key' ), + ), + array( + 'id' => '_um_default_view', + 'type' => 'select', + 'label' => __( 'Default view type', 'ultimate-member' ), + 'tooltip' => __( 'Default directory view type', 'ultimate-member' ), + 'options' => $view_types_options, + 'value' => UM()->query()->get_meta_value( '_um_default_view', null, 'grid' ), + 'conditional' => array( implode( '|', $conditional ), '~', 1 ), + ), + array( + 'id' => '_um_roles', + 'type' => 'multi_checkbox', + 'label' => __( 'User Roles to Display', 'ultimate-member' ), + 'tooltip' => __( 'If you do not want to show all members, select only user roles to appear in this directory', 'ultimate-member' ), + 'options' => UM()->roles()->get_roles(), + 'columns' => 3, + 'value' => $_um_roles_value, + ), + array( + 'id' => '_um_has_profile_photo', + 'type' => 'checkbox', + 'label' => __( 'Only show members who have uploaded a profile photo', 'ultimate-member' ), + 'tooltip' => __( 'If \'Use Gravatars\' as profile photo is enabled, this option is ignored', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_has_profile_photo' ), + ), + array( + 'id' => '_um_has_cover_photo', + 'type' => 'checkbox', + 'label' => __( 'Only show members who have uploaded a cover photo', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_has_cover_photo' ), + ), + array( + 'id' => '_um_show_these_users', + 'type' => 'textarea', + 'label' => __( 'Only show specific users (Enter one username per line)', 'ultimate-member' ), + 'value' => $show_these_users, + ), + array( + 'id' => '_um_exclude_these_users', + 'type' => 'textarea', + 'label' => __( 'Exclude specific users (Enter one username per line)', 'ultimate-member' ), + 'value' => $exclude_these_users, + ), +); + +/** + * UM hook + * + * @type filter + * @title um_admin_extend_directory_options_general + * @description Extend Directory options fields + * @input_vars + * [{"var":"$fields","type":"array","desc":"Directory options fields"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 ); + * @example + * + */ +$fields = apply_filters( 'um_admin_extend_directory_options_general', $fields ); ?> \ No newline at end of file + diff --git a/includes/admin/templates/directory/pagination.php b/includes/admin/templates/directory/pagination.php index 3a516c60..a30fcc49 100644 --- a/includes/admin/templates/directory/pagination.php +++ b/includes/admin/templates/directory/pagination.php @@ -1,68 +1,72 @@ - - + \ No newline at end of file + diff --git a/includes/admin/templates/directory/profile.php b/includes/admin/templates/directory/profile.php index c2bffda0..facd94f3 100644 --- a/includes/admin/templates/directory/profile.php +++ b/includes/admin/templates/directory/profile.php @@ -1,117 +1,120 @@ - +builtin()->all_user_fields() as $key => $arr ) { + $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : ''; +} + +$post_id = get_the_ID(); +$_um_tagline_fields = get_post_meta( $post_id, '_um_tagline_fields', true ); +$_um_reveal_fields = get_post_meta( $post_id, '_um_reveal_fields', true ); + + +$fields = array( + array( + 'id' => '_um_profile_photo', + 'type' => 'checkbox', + 'label' => __( 'Enable Profile Photo', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_profile_photo', null, 1 ), + ), + array( + 'id' => '_um_cover_photos', + 'type' => 'checkbox', + 'label' => __( 'Enable Cover Photo', 'ultimate-member' ), + 'tooltip' => __( 'If turned on, the users cover photo will appear in the directory', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_cover_photos', null, 1 ), + ), + array( + 'id' => '_um_show_name', + 'type' => 'checkbox', + 'label' => __( 'Show display name', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_show_name', null, 1 ), + ), + array( + 'id' => '_um_show_tagline', + 'type' => 'checkbox', + 'label' => __( 'Show tagline below profile name', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_show_tagline' ), + ), + array( + 'id' => '_um_tagline_fields', + 'type' => 'multi_selects', + 'label' => __( 'Choose field(s) to display in tagline', 'ultimate-member' ), + 'value' => $_um_tagline_fields, + 'conditional' => array( '_um_show_tagline', '=', 1 ), + 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ), + 'options' => $user_fields, + 'show_default_number' => 1, + 'sorting' => true, + ), + array( + 'id' => '_um_show_userinfo', + 'type' => 'checkbox', + 'label' => __( 'Show extra user information below tagline?', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_show_userinfo' ), + ), + array( + 'id' => '_um_reveal_fields', + 'type' => 'multi_selects', + 'label' => __( 'Choose field(s) to display in extra user information section', 'ultimate-member' ), + 'value' => $_um_reveal_fields, + 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ), + 'conditional' => array( '_um_show_userinfo', '=', 1 ), + 'options' => $user_fields, + 'show_default_number' => 1, + 'sorting' => true, + ), + array( + 'id' => '_um_show_social', + 'type' => 'checkbox', + 'label' => __( 'Show social connect icons in extra user information section', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_show_social' ), + 'conditional' => array( '_um_show_userinfo', '=', 1 ), + ), + array( + 'id' => '_um_userinfo_animate', + 'type' => 'checkbox', + 'label' => __( 'Hide extra user information to the reveal section', 'ultimate-member' ), + 'tooltip' => __( 'If not checked always shown', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_userinfo_animate' ), + 'conditional' => array( '_um_show_userinfo', '=', 1 ), + ), +); + + +/** + * UM hook + * + * @type filter + * @title um_admin_extend_directory_options_general + * @description Extend Directory options fields + * @input_vars + * [{"var":"$fields","type":"array","desc":"Directory options fields"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_directory_sort_users_select', 'function_name', 10, 1 ); + * @example + * + */ +$fields = apply_filters( 'um_admin_extend_directory_options_profile', $fields ); ?> \ No newline at end of file + diff --git a/includes/admin/templates/directory/search.php b/includes/admin/templates/directory/search.php index 0c7e72cb..6d140aae 100644 --- a/includes/admin/templates/directory/search.php +++ b/includes/admin/templates/directory/search.php @@ -1,97 +1,100 @@ - +global $post_id; + +$_um_roles_search_value = get_post_meta( $post_id, '_um_roles_can_search', true ); +$_um_roles_search_value = empty( $_um_roles_search_value ) ? array() : $_um_roles_search_value; + +$_um_roles_filter_value = get_post_meta( $post_id, '_um_roles_can_filter', true ); +$_um_roles_filter_value = empty( $_um_roles_filter_value ) ? array() : $_um_roles_filter_value; + +$_um_search_fields = get_post_meta( $post_id, '_um_search_fields', true ); +$_um_search_filters = get_post_meta( $post_id, '_um_search_filters', true ); ?> \ No newline at end of file + diff --git a/includes/admin/templates/directory/shortcode.php b/includes/admin/templates/directory/shortcode.php index 81cb3b0e..1a3ba7fe 100644 --- a/includes/admin/templates/directory/shortcode.php +++ b/includes/admin/templates/directory/shortcode.php @@ -1,4 +1,6 @@ - + \ No newline at end of file + diff --git a/includes/admin/templates/directory/sorting.php b/includes/admin/templates/directory/sorting.php index 4074ea16..81a22dd6 100644 --- a/includes/admin/templates/directory/sorting.php +++ b/includes/admin/templates/directory/sorting.php @@ -1,62 +1,65 @@ - +$_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields; + +$fields = array( + array( + 'id' => '_um_sortby', + 'type' => 'select', + 'label' => __( 'Default sort users by', 'ultimate-member' ), + 'tooltip' => __( 'Default sorting users by a specific parameter in the directory', 'ultimate-member' ), + 'options' => UM()->member_directory()->default_sorting, + 'value' => UM()->query()->get_meta_value( '_um_sortby' ), + ), + array( + 'id' => '_um_sortby_custom', + 'type' => 'text', + 'label' => __( 'Meta key', 'ultimate-member' ), + 'tooltip' => __( 'To sort by a custom field, enter the meta key of field here', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_sortby_custom', null, 'na' ), + 'conditional' => array( '_um_sortby', '=', 'other' ), + ), + array( + 'id' => '_um_sortby_custom_label', + 'type' => 'text', + 'label' => __( 'Label of custom sort', 'ultimate-member' ), + 'tooltip' => __( 'To sort by a custom field, enter the label of sorting here', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_sortby_custom_label', null, 'na' ), + 'conditional' => array( '_um_sortby', '=', 'other' ), + ), + array( + 'id' => '_um_enable_sorting', + 'type' => 'checkbox', + 'label' => __( 'Enable custom sorting', 'ultimate-member' ), + 'tooltip' => __( 'Whether to provide an ability to change the sorting on the directory page', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_enable_sorting' ), + ), + array( + 'id' => '_um_sorting_fields', + 'type' => 'md_sorting_fields', + 'label' => __( 'Choose field(s) to enable in sorting', 'ultimate-member' ), + 'value' => $_um_sorting_fields, + 'options' => array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) ), + 'add_text' => __( 'Add New Field', 'ultimate-member' ), + 'show_default_number' => 1, + 'conditional' => array( '_um_enable_sorting', '=', 1 ), + ), +); ?> \ No newline at end of file + diff --git a/includes/admin/templates/form/builder.php b/includes/admin/templates/form/builder.php index 415f7872..c3513bfe 100644 --- a/includes/admin/templates/form/builder.php +++ b/includes/admin/templates/form/builder.php @@ -1,5 +1,6 @@ -builder()->form_id ) ) { UM()->builder()->form_id = $this->form_id; @@ -9,8 +10,10 @@ if ( empty( UM()->builder()->form_id ) ) {' . __( 'User Role Added Successfully.', 'ultimate-member' ) . '