From cf282c48755b81b9396e4e34051f5b1ac58df90d Mon Sep 17 00:00:00 2001 From: Champ Camba Date: Mon, 3 May 2021 14:30:51 +0800 Subject: [PATCH 01/29] Fix slider filter query and results --- includes/core/class-member-directory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/core/class-member-directory.php b/includes/core/class-member-directory.php index 3aceb388..e2645394 100644 --- a/includes/core/class-member-directory.php +++ b/includes/core/class-member-directory.php @@ -1660,6 +1660,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { 'value' => $value, 'compare' => 'BETWEEN', 'inclusive' => true, + 'type' => 'NUMERIC', ); break; From 23d1b982a41319aa7d2331e49b1e0076a7ef309f Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Thu, 17 Jun 2021 13:56:24 +0300 Subject: [PATCH 02/29] - changed version; --- readme.txt | 4 ++++ ultimate-member.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index fa40b0ed..dcb1216e 100644 --- a/readme.txt +++ b/readme.txt @@ -155,6 +155,10 @@ The plugin works with popular caching plugins by automatically excluding Ultimat * To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0) * UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin += 2.1.22: July xx, 2021 = + + + = 2.1.21: June 17, 2021 = * Enhancements: diff --git a/ultimate-member.php b/ultimate-member.php index 18745d02..4c3967c8 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.1.21 +Version: 2.1.22-alpha Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From d7f198838c8c4edb023bb6e9a3ce1f83001d27d7 Mon Sep 17 00:00:00 2001 From: ashubawork <43743394+ashubawork@users.noreply.github.com> Date: Wed, 23 Jun 2021 11:13:32 +0300 Subject: [PATCH 03/29] - exclude posts from query for restricted posts --- includes/core/class-access.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index d1ad50b4..ba079289 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -55,6 +55,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { //there also will be redirects if they need //protect posts types add_filter( 'the_posts', array( &$this, 'filter_protected_posts' ), 99, 2 ); + add_filter( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 ); //protect pages for wp_list_pages func add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 ); //filter menu items @@ -1013,6 +1014,33 @@ if ( ! class_exists( 'um\core\Access' ) ) { } + /** + * Exclude posts from query + * + * @param $query + */ + function exclude_posts( $query ) { + if( $query->is_main_query() ){ + global $wpdb; + $exclude_posts = array(); + $posts = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'um_content_restriction'"); + foreach ( $posts as $post ) { + $content_restriction = get_post_meta( $post, 'um_content_restriction', true ); + + if ( is_user_logged_in() && $content_restriction['_um_custom_access_settings'] == 1 && $content_restriction['_um_accessible'] == 1 ) { + array_push( $exclude_posts, $post ); + } + if ( ! is_user_logged_in() && $content_restriction['_um_custom_access_settings'] == 1 && $content_restriction['_um_accessible'] == 2 ) { + array_push( $exclude_posts, $post ); + } + + } + + $query->set('post__not_in', $exclude_posts ); + } + } + + /** * @param string $single_template * From 07e664be807ae8fbabe353b3225a3a8d88c82015 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Tue, 29 Jun 2021 02:51:54 +0300 Subject: [PATCH 04/29] - intermediate results with sanitizing form handlers; --- includes/admin/class-admin-functions.php | 6 +- includes/admin/class-admin.php | 1086 ++++++- includes/admin/core/class-admin-builder.php | 20 +- includes/admin/core/class-admin-dragdrop.php | 45 +- includes/admin/core/class-admin-enqueue.php | 12 +- includes/admin/core/class-admin-menu.php | 4 +- includes/admin/core/class-admin-metabox.php | 31 +- includes/admin/core/class-admin-navmenu.php | 8 +- includes/admin/core/class-admin-notices.php | 6 +- includes/admin/core/class-admin-settings.php | 2632 ++++++++++------- includes/admin/core/class-admin-users.php | 49 +- .../core/list-tables/roles-list-table.php | 75 +- .../core/packages/2.0-beta1/functions.php | 32 +- .../core/packages/2.1.3-beta3/functions.php | 8 +- .../admin/templates/directory/appearance.php | 35 +- .../admin/templates/directory/general.php | 202 +- .../admin/templates/directory/pagination.php | 130 +- .../admin/templates/directory/profile.php | 227 +- includes/admin/templates/directory/search.php | 181 +- .../admin/templates/directory/shortcode.php | 6 +- .../admin/templates/directory/sorting.php | 109 +- includes/admin/templates/form/builder.php | 15 +- .../admin/templates/form/login_customize.php | 190 +- .../admin/templates/form/login_settings.php | 60 +- includes/admin/templates/form/mode.php | 26 +- .../templates/form/profile_customize.php | 405 +-- .../admin/templates/form/profile_settings.php | 59 +- .../templates/form/register_customize.php | 180 +- .../admin/templates/form/register_gdpr.php | 134 +- includes/admin/templates/role/publish.php | 34 +- includes/admin/templates/role/role-edit.php | 221 +- .../admin/templates/role/wp-capabilities.php | 5 +- includes/class-functions.php | 4 +- includes/core/class-access.php | 4 +- includes/core/class-account.php | 4 +- includes/core/class-fields.php | 6 +- includes/core/class-files.php | 32 +- includes/core/class-form.php | 30 +- includes/core/class-logout.php | 8 +- includes/core/class-member-directory-meta.php | 13 +- includes/core/class-member-directory.php | 46 +- includes/core/class-options.php | 5 +- includes/core/class-password.php | 91 +- includes/core/class-permalinks.php | 8 +- includes/core/class-profile.php | 49 +- includes/core/class-query.php | 4 +- includes/core/class-roles-capabilities.php | 16 +- includes/core/class-shortcodes.php | 12 +- includes/core/class-user-posts.php | 6 +- includes/core/class-user.php | 20 +- includes/core/um-actions-account.php | 370 ++- includes/core/um-actions-ajax.php | 4 +- includes/core/um-actions-core.php | 47 +- includes/core/um-actions-login.php | 10 +- includes/core/um-actions-misc.php | 22 +- includes/core/um-actions-profile.php | 10 +- includes/core/um-actions-wpadmin.php | 9 +- includes/core/um-filters-fields.php | 26 +- includes/core/um-filters-login.php | 22 +- includes/um-short-functions.php | 14 +- templates/email/checkmail_email.php | 2 +- templates/members.php | 8 +- templates/password-reset.php | 14 +- 63 files changed, 4337 insertions(+), 2812 deletions(-) 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 @@ - - +
- admin_forms( array( - 'class' => 'um-member-directory-appearance um-top-label', - 'prefix_id' => 'um_metadata', - 'fields' => array( - array( - 'id' => '_um_directory_template', - 'type' => 'select', - 'label' => __( 'Template', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_directory_template', null, UM()->options()->get( 'directory_template' ) ), - 'options' => UM()->shortcodes()->get_templates( 'members' ), - ) + admin_forms( + array( + 'class' => 'um-member-directory-appearance um-top-label', + 'prefix_id' => 'um_metadata', + 'fields' => array( + array( + 'id' => '_um_directory_template', + 'type' => 'select', + 'label' => __( 'Template', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_directory_template', null, UM()->options()->get( 'directory_template' ) ), + 'options' => UM()->shortcodes()->get_templates( 'members' ), + ), + ), ) - ) )->render_form(); ?> -
\ 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 ); ?>
- - admin_forms( 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 ); - - UM()->admin_forms( array( - 'class' => 'um-member-directory-general um-half-column', - 'prefix_id' => 'um_metadata', - 'fields' => $fields - ) )->render_form(); ?> + 'class' => 'um-member-directory-general um-half-column', + 'prefix_id' => 'um_metadata', + 'fields' => $fields, + ) + )->render_form(); + ?>
- -
\ 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 @@ - - +
- admin_forms( array( - 'class' => 'um-member-directory-pagination um-half-column', - 'prefix_id' => 'um_metadata', - 'fields' => array( - array( - 'id' => '_um_must_search', - 'type' => 'checkbox', - 'label' => __( 'Show results only after search/filtration', 'ultimate-member' ), - 'tooltip' => __( 'If turned on, member results will only appear after search/filter is performed', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_must_search' ), - 'conditional' => array( '_um_search||_um_filters', '=', 1 ), - ), - array( - 'id' => '_um_max_users', - 'type' => 'number', - 'label' => __( 'Maximum number of profiles', 'ultimate-member' ), - 'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ), - 'size' => 'small' - ), - array( - 'id' => '_um_profiles_per_page', - 'type' => 'number', - 'label' => __( 'Number of profiles per page', 'ultimate-member' ), - 'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ), - 'size' => 'small' - ), - array( - 'id' => '_um_profiles_per_page_mobile', - 'type' => 'number', - 'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ), - 'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ), - 'size' => 'small' - ), - array( - 'id' => '_um_directory_header', - 'type' => 'text', - 'label' => __( 'Results Text', 'ultimate-member' ), - 'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ), - 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_directory_header', null, 'na' ), - ), - array( - 'id' => '_um_directory_header_single', - 'type' => 'text', - 'label' => __( 'Single Result Text', 'ultimate-member' ), - 'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ), - 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_directory_header_single', null, 'na' ), - ), - array( - 'id' => '_um_directory_no_users', - 'type' => 'text', - 'label' => __( 'Custom text if no users were found', 'ultimate-member' ), - 'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_directory_no_users', null, 'na' ), + admin_forms( + array( + 'class' => 'um-member-directory-pagination um-half-column', + 'prefix_id' => 'um_metadata', + 'fields' => array( + array( + 'id' => '_um_must_search', + 'type' => 'checkbox', + 'label' => __( 'Show results only after search/filtration', 'ultimate-member' ), + 'tooltip' => __( 'If turned on, member results will only appear after search/filter is performed', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_must_search' ), + 'conditional' => array( '_um_search||_um_filters', '=', 1 ), + ), + array( + 'id' => '_um_max_users', + 'type' => 'number', + 'label' => __( 'Maximum number of profiles', 'ultimate-member' ), + 'tooltip' => __( 'Use this setting to control the maximum number of profiles to appear in this directory. Leave blank to disable this limit', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_max_users', null, 'na' ), + 'size' => 'small', + ), + array( + 'id' => '_um_profiles_per_page', + 'type' => 'number', + 'label' => __( 'Number of profiles per page', 'ultimate-member' ), + 'tooltip' => __( 'Number of profiles to appear on page for standard users', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page', null, 12 ), + 'size' => 'small', + ), + array( + 'id' => '_um_profiles_per_page_mobile', + 'type' => 'number', + 'label' => __( 'Number of profiles per page (for Mobiles & Tablets)', 'ultimate-member' ), + 'tooltip' => __( 'Number of profiles to appear on page for mobile users', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_profiles_per_page_mobile', null, 8 ), + 'size' => 'small', + ), + array( + 'id' => '_um_directory_header', + 'type' => 'text', + 'label' => __( 'Results Text', 'ultimate-member' ), + 'tooltip' => __( 'Customize the search result text . e.g. Found 3,000 Members. Leave this blank to not show result text', 'ultimate-member' ), + 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_directory_header', null, 'na' ), + ), + array( + 'id' => '_um_directory_header_single', + 'type' => 'text', + 'label' => __( 'Single Result Text', 'ultimate-member' ), + 'tooltip' => __( 'Same as above but in case of 1 user found only', 'ultimate-member' ), + 'description' => __( 'You could use {total_users} placeholder for getting users count', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_directory_header_single', null, 'na' ), + ), + array( + 'id' => '_um_directory_no_users', + 'type' => 'text', + 'label' => __( 'Custom text if no users were found', 'ultimate-member' ), + 'tooltip' => __( 'This is the text that is displayed if no users are found during a search', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_directory_no_users', null, 'na' ), + ), ), ) - ) )->render_form(); ?> - + )->render_form(); + ?>
-
\ 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 ); ?>
- - 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( + admin_forms( 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 ); - - UM()->admin_forms( array( - 'class' => 'um-member-directory-profile um-half-column', - 'prefix_id' => 'um_metadata', - 'fields' => $fields, - ) )->render_form(); ?> - + 'class' => 'um-member-directory-profile um-half-column', + 'prefix_id' => 'um_metadata', + 'fields' => $fields, + ) + )->render_form(); + ?>
-
\ 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 ); ?>
admin_forms( array( - 'class' => 'um-member-directory-search um-half-column', - 'prefix_id' => 'um_metadata', - 'fields' => array( - array( - 'id' => '_um_search', - 'type' => 'checkbox', - 'label' => __( 'Enable Search feature', 'ultimate-member' ), - 'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_search' ), - ), - array( - 'id' => '_um_roles_can_search', - 'type' => 'multi_checkbox', - 'label' => __( 'User Roles that can use search', 'ultimate-member' ), - 'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ), - 'value' => $_um_roles_search_value, - 'options' => UM()->roles()->get_roles(), - 'columns' => 3, - 'conditional' => array( '_um_search', '=', 1 ) - ), - array( - 'id' => '_um_filters', - 'type' => 'checkbox', - 'label' => __( 'Enable Filters feature', 'ultimate-member' ), - 'tooltip' => __( 'If turned on, users will be able to filter members in this directory', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_filters' ), - ), - array( - 'id' => '_um_roles_can_filter', - 'type' => 'multi_checkbox', - 'label' => __( 'User Roles that can use filters', 'ultimate-member' ), - 'tooltip' => __( 'If you want to allow specific user roles to be able to filter only', 'ultimate-member' ), - 'value' => $_um_roles_filter_value, - 'options' => UM()->roles()->get_roles(), - 'columns' => 3, - 'conditional' => array( '_um_filters', '=', 1 ) - ), - array( - 'id' => '_um_search_fields', - 'type' => 'multi_selects', - 'label' => __( 'Choose filter(s) meta to enable', 'ultimate-member' ), - 'value' => $_um_search_fields, - 'conditional' => array( '_um_filters', '=', 1 ), - 'options' => UM()->member_directory()->filter_fields, - 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ), - 'show_default_number' => 1, - 'sorting' => true, - ), - array( - 'id' => '_um_filters_expanded', - 'type' => 'checkbox', - 'label' => __( 'Expand the filter bar by default', 'ultimate-member' ), - 'tooltip' => __( 'If turned on, filters bar will be visible after a page loading', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_filters_expanded' ), - 'conditional' => array( '_um_filters', '=', 1 ) - ), - array( - 'id' => '_um_filters_is_collapsible', - 'type' => 'checkbox', - 'label' => __( 'Can filter bar be collapsed', 'ultimate-member' ), - 'tooltip' => __( 'If turned on, filters bar can be collapsed after a page loading', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_filters_is_collapsible' ), - 'conditional' => array( '_um_filters_expanded', '=', 1 ) - ), - array( - 'id' => '_um_search_filters', - 'type' => 'md_default_filters', - 'label' => __( 'Admin filtering', 'ultimate-member' ), - 'tooltip' => __( 'Limit which users appear in the member directory e.g only display users from USA', 'ultimate-member' ), - 'value' => $_um_search_filters, - 'options' => UM()->member_directory()->filter_fields, - 'add_text' => __( 'Add New Filter', 'ultimate-member' ), - 'show_default_number' => 0, + UM()->admin_forms( + array( + 'class' => 'um-member-directory-search um-half-column', + 'prefix_id' => 'um_metadata', + 'fields' => array( + array( + 'id' => '_um_search', + 'type' => 'checkbox', + 'label' => __( 'Enable Search feature', 'ultimate-member' ), + 'tooltip' => __( 'If turned on, users will be able to search members in this directory', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_search' ), + ), + array( + 'id' => '_um_roles_can_search', + 'type' => 'multi_checkbox', + 'label' => __( 'User Roles that can use search', 'ultimate-member' ), + 'tooltip' => __( 'If you want to allow specific user roles to be able to search only', 'ultimate-member' ), + 'value' => $_um_roles_search_value, + 'options' => UM()->roles()->get_roles(), + 'columns' => 3, + 'conditional' => array( '_um_search', '=', 1 ), + ), + array( + 'id' => '_um_filters', + 'type' => 'checkbox', + 'label' => __( 'Enable Filters feature', 'ultimate-member' ), + 'tooltip' => __( 'If turned on, users will be able to filter members in this directory', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_filters' ), + ), + array( + 'id' => '_um_roles_can_filter', + 'type' => 'multi_checkbox', + 'label' => __( 'User Roles that can use filters', 'ultimate-member' ), + 'tooltip' => __( 'If you want to allow specific user roles to be able to filter only', 'ultimate-member' ), + 'value' => $_um_roles_filter_value, + 'options' => UM()->roles()->get_roles(), + 'columns' => 3, + 'conditional' => array( '_um_filters', '=', 1 ), + ), + array( + 'id' => '_um_search_fields', + 'type' => 'multi_selects', + 'label' => __( 'Choose filter(s) meta to enable', 'ultimate-member' ), + 'value' => $_um_search_fields, + 'conditional' => array( '_um_filters', '=', 1 ), + 'options' => UM()->member_directory()->filter_fields, + 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ), + 'show_default_number' => 1, + 'sorting' => true, + ), + array( + 'id' => '_um_filters_expanded', + 'type' => 'checkbox', + 'label' => __( 'Expand the filter bar by default', 'ultimate-member' ), + 'tooltip' => __( 'If turned on, filters bar will be visible after a page loading', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_filters_expanded' ), + 'conditional' => array( '_um_filters', '=', 1 ), + ), + array( + 'id' => '_um_filters_is_collapsible', + 'type' => 'checkbox', + 'label' => __( 'Can filter bar be collapsed', 'ultimate-member' ), + 'tooltip' => __( 'If turned on, filters bar can be collapsed after a page loading', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_filters_is_collapsible' ), + 'conditional' => array( '_um_filters_expanded', '=', 1 ), + ), + array( + 'id' => '_um_search_filters', + 'type' => 'md_default_filters', + 'label' => __( 'Admin filtering', 'ultimate-member' ), + 'tooltip' => __( 'Limit which users appear in the member directory e.g only display users from USA', 'ultimate-member' ), + 'value' => $_um_search_filters, + 'options' => UM()->member_directory()->filter_fields, + 'add_text' => __( 'Add New Filter', 'ultimate-member' ), + 'show_default_number' => 0, + ), ), ) - ) )->render_form(); ?> - + )->render_form(); + ?>
-
\ 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 @@ - +
@@ -24,4 +26,4 @@

shortcodes()->get_shortcode( get_the_ID() ); ?>

shortcodes()->get_default_shortcode( get_the_ID() ); ?> -
\ 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 ), + ), +); ?>
- - admin_forms( 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 ), + 'class' => 'um-member-directory-sorting um-half-column', + 'prefix_id' => 'um_metadata', + 'fields' => $fields, ) - ); - - UM()->admin_forms( array( - 'class' => 'um-member-directory-sorting um-half-column', - 'prefix_id' => 'um_metadata', - 'fields' => $fields - ) )->render_form(); ?> - + )->render_form(); + ?>
-
\ 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 ) ) {
- + + +
@@ -19,9 +22,7 @@ if ( empty( UM()->builder()->form_id ) ) {
- builder()->show_builder(); ?> -
builder()->form_id ) ) {
-
\ No newline at end of file + diff --git a/includes/admin/templates/form/login_customize.php b/includes/admin/templates/form/login_customize.php index ea1fefcb..cf16a16d 100644 --- a/includes/admin/templates/form/login_customize.php +++ b/includes/admin/templates/form/login_customize.php @@ -1,102 +1,106 @@ - - +
- admin_forms( array( - 'class' => 'um-form-login-customize um-top-label', - 'prefix_id' => 'form', - 'fields' => array( - array( - 'id' => '_um_login_use_custom_settings', - 'type' => 'select', - 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ), - 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_use_custom_settings', null, 0 ), - 'options' => array( - 0 => __( 'No', 'ultimate-member' ), - 1 => __( 'Yes', 'ultimate-member' ), + admin_forms( + array( + 'class' => 'um-form-login-customize um-top-label', + 'prefix_id' => 'form', + 'fields' => array( + array( + 'id' => '_um_login_use_custom_settings', + 'type' => 'select', + 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ), + 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_use_custom_settings', null, 0 ), + 'options' => array( + 0 => __( 'No', 'ultimate-member' ), + 1 => __( 'Yes', 'ultimate-member' ), + ), ), - ), - array( - 'id' => '_um_login_template', - 'type' => 'select', - 'label' => __( 'Template', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_template', null, UM()->options()->get( 'login_template' ) ), - 'options' => UM()->shortcodes()->get_templates( 'login' ), - 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ) - ), - array( - 'id' => '_um_login_max_width', - 'type' => 'text', - 'label' => __( 'Max. Width (px)', 'ultimate-member' ), - 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_login_max_width', null, UM()->options()->get( 'login_max_width' ) ), - 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ) - ), - array( - 'id' => '_um_login_icons', - 'type' => 'select', - 'label' => __( 'Field Icons', 'ultimate-member' ), - 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_icons', null, UM()->options()->get( 'login_icons' ) ) , - 'options' => array( - 'field' => __( 'Show inside text field', 'ultimate-member' ), - 'label' => __( 'Show with label', 'ultimate-member' ), - 'off' => __( 'Turn off', 'ultimate-member' ) + array( + 'id' => '_um_login_template', + 'type' => 'select', + 'label' => __( 'Template', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_template', null, UM()->options()->get( 'login_template' ) ), + 'options' => UM()->shortcodes()->get_templates( 'login' ), + 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), ), - 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ) - ), - array( - 'id' => '_um_login_primary_btn_word', - 'type' => 'text', - 'label' => __( 'Primary Button Text', 'ultimate-member' ), - 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, UM()->options()->get( 'login_primary_btn_word' ) ), - 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ) - ), - array( - 'id' => '_um_login_secondary_btn', - 'type' => 'select', - 'label' => __( 'Show Secondary Button', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn', null, UM()->options()->get( 'login_secondary_btn' ) ), - 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), - 'options' => array( - 0 => __( 'No', 'ultimate-member' ), - 1 => __( 'Yes', 'ultimate-member' ), - ), - ), - array( - 'id' => '_um_login_secondary_btn_word', - 'type' => 'text', - 'label' => __( 'Secondary Button Text', 'ultimate-member' ), - 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ), - 'conditional' => array( '_um_login_secondary_btn', '=', 1 ) - ), - array( - 'id' => '_um_login_forgot_pass_link', - 'type' => 'select', - 'label' => __( 'Show Forgot Password Link?', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_forgot_pass_link', null, UM()->options()->get('login_forgot_pass_link') ), - 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), - 'options' => array( - 0 => __( 'No', 'ultimate-member' ), - 1 => __( 'Yes', 'ultimate-member' ), + array( + 'id' => '_um_login_max_width', + 'type' => 'text', + 'label' => __( 'Max. Width (px)', 'ultimate-member' ), + 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_max_width', null, UM()->options()->get( 'login_max_width' ) ), + 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), ), - ), - array( - 'id' => '_um_login_show_rememberme', - 'type' => 'select', - 'label' => __( 'Show "Remember Me"?', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_show_rememberme', null, UM()->options()->get('login_show_rememberme') ), - 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), - 'options' => array( - 0 => __( 'No', 'ultimate-member' ), - 1 => __( 'Yes', 'ultimate-member' ), + array( + 'id' => '_um_login_icons', + 'type' => 'select', + 'label' => __( 'Field Icons', 'ultimate-member' ), + 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_icons', null, UM()->options()->get( 'login_icons' ) ), + 'options' => array( + 'field' => __( 'Show inside text field', 'ultimate-member' ), + 'label' => __( 'Show with label', 'ultimate-member' ), + 'off' => __( 'Turn off', 'ultimate-member' ), + ), + 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), + ), + array( + 'id' => '_um_login_primary_btn_word', + 'type' => 'text', + 'label' => __( 'Primary Button Text', 'ultimate-member' ), + 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_primary_btn_word', null, UM()->options()->get( 'login_primary_btn_word' ) ), + 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), + ), + array( + 'id' => '_um_login_secondary_btn', + 'type' => 'select', + 'label' => __( 'Show Secondary Button', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn', null, UM()->options()->get( 'login_secondary_btn' ) ), + 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), + 'options' => array( + 0 => __( 'No', 'ultimate-member' ), + 1 => __( 'Yes', 'ultimate-member' ), + ), + ), + array( + 'id' => '_um_login_secondary_btn_word', + 'type' => 'text', + 'label' => __( 'Secondary Button Text', 'ultimate-member' ), + 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ), + 'conditional' => array( '_um_login_secondary_btn', '=', 1 ), + ), + array( + 'id' => '_um_login_forgot_pass_link', + 'type' => 'select', + 'label' => __( 'Show Forgot Password Link?', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_forgot_pass_link', null, UM()->options()->get( 'login_forgot_pass_link' ) ), + 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), + 'options' => array( + 0 => __( 'No', 'ultimate-member' ), + 1 => __( 'Yes', 'ultimate-member' ), + ), + ), + array( + 'id' => '_um_login_show_rememberme', + 'type' => 'select', + 'label' => __( 'Show "Remember Me"?', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_show_rememberme', null, UM()->options()->get( 'login_show_rememberme' ) ), + 'conditional' => array( '_um_login_use_custom_settings', '=', 1 ), + 'options' => array( + 0 => __( 'No', 'ultimate-member' ), + 1 => __( 'Yes', 'ultimate-member' ), + ), ), ), ) - ) )->render_form(); ?> - + )->render_form(); + ?>
-
\ No newline at end of file + diff --git a/includes/admin/templates/form/login_settings.php b/includes/admin/templates/form/login_settings.php index bc1321ca..88c3d160 100644 --- a/includes/admin/templates/form/login_settings.php +++ b/includes/admin/templates/form/login_settings.php @@ -1,34 +1,38 @@ - - +
- admin_forms( array( - 'class' => 'um-form-login-settings um-top-label', - 'prefix_id' => 'form', - 'fields' => array( - array( - 'id' => '_um_login_after_login', - 'type' => 'select', - 'label' => __( 'Redirection after Login', 'ultimate-member' ), - 'tooltip' => __( 'Change this If you want to override role redirection settings after login only.', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_login_after_login', null, 0 ), - 'options' => array( - '0' => __( 'Default', 'ultimate-member' ), - 'redirect_profile' => __( 'Redirect to profile', 'ultimate-member' ), - 'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ), - 'refresh' => __( 'Refresh active page', 'ultimate-member' ), - 'redirect_admin' => __( 'Redirect to WordPress Admin', 'ultimate-member' ), + admin_forms( + array( + 'class' => 'um-form-login-settings um-top-label', + 'prefix_id' => 'form', + 'fields' => array( + array( + 'id' => '_um_login_after_login', + 'type' => 'select', + 'label' => __( 'Redirection after Login', 'ultimate-member' ), + 'tooltip' => __( 'Change this If you want to override role redirection settings after login only.', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_after_login', null, 0 ), + 'options' => array( + '0' => __( 'Default', 'ultimate-member' ), + 'redirect_profile' => __( 'Redirect to profile', 'ultimate-member' ), + 'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ), + 'refresh' => __( 'Refresh active page', 'ultimate-member' ), + 'redirect_admin' => __( 'Redirect to WordPress Admin', 'ultimate-member' ), + ), + ), + array( + 'id' => '_um_login_redirect_url', + 'type' => 'text', + 'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_login_redirect_url', null, 'na' ), + 'conditional' => array( '_um_login_after_login', '=', 'redirect_url' ), ), ), - array( - 'id' => '_um_login_redirect_url', - 'type' => 'text', - 'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_login_redirect_url', null, 'na' ), - 'conditional' => array( '_um_login_after_login', '=', 'redirect_url' ) - ) ) - ) )->render_form(); ?> - + )->render_form(); + ?>
-
\ No newline at end of file + diff --git a/includes/admin/templates/form/mode.php b/includes/admin/templates/form/mode.php index 045c4139..cc1e9bdb 100644 --- a/includes/admin/templates/form/mode.php +++ b/includes/admin/templates/form/mode.php @@ -1,21 +1,29 @@ - - diff --git a/includes/admin/templates/form/profile_settings.php b/includes/admin/templates/form/profile_settings.php index 54001e4c..de18de4f 100644 --- a/includes/admin/templates/form/profile_settings.php +++ b/includes/admin/templates/form/profile_settings.php @@ -1,32 +1,37 @@ - +builtin()->all_user_fields() as $key => $arr ) { + $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : ''; +} + +$post_id = get_the_ID(); +$_um_search_fields = get_post_meta( $post_id, '_um_profile_metafields', true ); +$_um_search_fields = empty( $_um_search_fields ) ? array() : $_um_search_fields; ?>
- builtin()->all_user_fields() as $key => $arr ) { - $user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : ''; - } - - $post_id = get_the_ID(); - $_um_search_fields = get_post_meta( $post_id, '_um_profile_metafields', true ); - $_um_search_fields = empty( $_um_search_fields ) ? array() : $_um_search_fields; - - UM()->admin_forms( array( - 'class' => 'um-form-profile-settings um-top-label', - 'prefix_id' => 'form', - 'fields' => array( - array( - 'id' => '_um_profile_metafields', - 'type' => 'multi_selects', - 'label' => __( 'Field(s) to show in user meta', 'ultimate-member' ), - 'tooltip' => __( 'Fields selected here will appear in the profile header area below the user\'s display name', 'ultimate-member' ), - 'value' => $_um_search_fields, - 'options' => $user_fields, - 'add_text' => __( 'Add New Field', 'ultimate-member' ), - 'show_default_number' => 0, - ) + admin_forms( + array( + 'class' => 'um-form-profile-settings um-top-label', + 'prefix_id' => 'form', + 'fields' => array( + array( + 'id' => '_um_profile_metafields', + 'type' => 'multi_selects', + 'label' => __( 'Field(s) to show in user meta', 'ultimate-member' ), + 'tooltip' => __( 'Fields selected here will appear in the profile header area below the user\'s display name', 'ultimate-member' ), + 'value' => $_um_search_fields, + 'options' => $user_fields, + 'add_text' => __( 'Add New Field', 'ultimate-member' ), + 'show_default_number' => 0, + ), + ), ) - ) )->render_form(); ?> - + )->render_form(); + ?>
-
\ No newline at end of file + diff --git a/includes/admin/templates/form/register_customize.php b/includes/admin/templates/form/register_customize.php index 86a94864..53c63952 100644 --- a/includes/admin/templates/form/register_customize.php +++ b/includes/admin/templates/form/register_customize.php @@ -1,95 +1,99 @@ - +roles()->get_roles( __( 'Default', 'ultimate-member' ) ) as $key => $value ) { + $_um_register_role = UM()->query()->get_meta_value( '_um_register_role', $key ); + if ( ! empty( $_um_register_role ) ) { + $register_role = $_um_register_role; + } +} ?>
- - roles()->get_roles( __( 'Default', 'ultimate-member' ) ) as $key => $value ) { - $_um_register_role = UM()->query()->get_meta_value( '_um_register_role', $key ); - if ( ! empty( $_um_register_role ) ) - $register_role = $_um_register_role; - } - - UM()->admin_forms( array( - 'class' => 'um-form-register-customize um-top-label', - 'prefix_id' => 'form', - 'fields' => array( - array( - 'id' => '_um_register_use_custom_settings', - 'type' => 'select', - 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ), - 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_use_custom_settings', null, 0 ), - 'options' => array( - 0 => __( 'No', 'ultimate-member' ), - 1 => __( 'Yes', 'ultimate-member' ), + admin_forms( + array( + 'class' => 'um-form-register-customize um-top-label', + 'prefix_id' => 'form', + 'fields' => array( + array( + 'id' => '_um_register_use_custom_settings', + 'type' => 'select', + 'label' => __( 'Apply custom settings to this form', 'ultimate-member' ), + 'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling & appearance', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_use_custom_settings', null, 0 ), + 'options' => array( + 0 => __( 'No', 'ultimate-member' ), + 1 => __( 'Yes', 'ultimate-member' ), + ), + ), + array( + 'id' => '_um_register_role', + 'type' => 'select', + 'label' => __( 'Assign role to form', 'ultimate-member' ), + 'value' => ! empty( $register_role ) ? $register_role : 0, + 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ), + 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ), + ), + array( + 'id' => '_um_register_template', + 'type' => 'select', + 'label' => __( 'Template', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_template', null, UM()->options()->get( 'register_template' ) ), + 'options' => UM()->shortcodes()->get_templates( 'register' ), + 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ), + ), + array( + 'id' => '_um_register_max_width', + 'type' => 'text', + 'label' => __( 'Max. Width (px)', 'ultimate-member' ), + 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_max_width', null, UM()->options()->get( 'register_max_width' ) ), + 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ), + ), + array( + 'id' => '_um_register_icons', + 'type' => 'select', + 'label' => __( 'Field Icons', 'ultimate-member' ), + 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_icons', null, UM()->options()->get( 'register_icons' ) ), + 'options' => array( + 'field' => __( 'Show inside text field', 'ultimate-member' ), + 'label' => __( 'Show with label', 'ultimate-member' ), + 'off' => __( 'Turn off', 'ultimate-member' ), + ), + 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ), + ), + array( + 'id' => '_um_register_primary_btn_word', + 'type' => 'text', + 'label' => __( 'Primary Button Text', 'ultimate-member' ), + 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_primary_btn_word', null, UM()->options()->get( 'register_primary_btn_word' ) ), + 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ), + ), + array( + 'id' => '_um_register_secondary_btn', + 'type' => 'select', + 'label' => __( 'Show Secondary Button', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn', null, UM()->options()->get( 'register_secondary_btn' ) ), + 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ), + 'options' => array( + 0 => __( 'No', 'ultimate-member' ), + 1 => __( 'Yes', 'ultimate-member' ), + ), + ), + array( + 'id' => '_um_register_secondary_btn_word', + 'type' => 'text', + 'label' => __( 'Secondary Button Text', 'ultimate-member' ), + 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn_word', null, UM()->options()->get( 'register_secondary_btn_word' ) ), + 'conditional' => array( '_um_register_secondary_btn', '=', 1 ), ), ), - array( - 'id' => '_um_register_role', - 'type' => 'select', - 'label' => __( 'Assign role to form', 'ultimate-member' ), - 'value' => ! empty( $register_role ) ? $register_role : 0, - 'options' => UM()->roles()->get_roles( __( 'Default', 'ultimate-member' ) ), - 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ) - ), - array( - 'id' => '_um_register_template', - 'type' => 'select', - 'label' => __( 'Template', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_template', null, UM()->options()->get( 'register_template' ) ), - 'options' => UM()->shortcodes()->get_templates( 'register' ), - 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ) - ), - array( - 'id' => '_um_register_max_width', - 'type' => 'text', - 'label' => __( 'Max. Width (px)', 'ultimate-member' ), - 'tooltip' => __( 'The maximum width of shortcode in pixels e.g. 600px', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_register_max_width', null, UM()->options()->get( 'register_max_width' ) ), - 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ) - ), - array( - 'id' => '_um_register_icons', - 'type' => 'select', - 'label' => __( 'Field Icons', 'ultimate-member' ), - 'tooltip' => __( 'Whether to show field icons and where to show them relative to the field', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_icons', null, UM()->options()->get( 'register_icons' ) ) , - 'options' => array( - 'field' => __( 'Show inside text field', 'ultimate-member' ), - 'label' => __( 'Show with label', 'ultimate-member' ), - 'off' => __( 'Turn off', 'ultimate-member' ) - ), - 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ) - ), - array( - 'id' => '_um_register_primary_btn_word', - 'type' => 'text', - 'label' => __( 'Primary Button Text', 'ultimate-member' ), - 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_primary_btn_word', null, UM()->options()->get( 'register_primary_btn_word' ) ), - 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ) - ), - array( - 'id' => '_um_register_secondary_btn', - 'type' => 'select', - 'label' => __( 'Show Secondary Button', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn', null, UM()->options()->get( 'register_secondary_btn' ) ), - 'conditional' => array( '_um_register_use_custom_settings', '=', 1 ), - 'options' => array( - 0 => __( 'No', 'ultimate-member' ), - 1 => __( 'Yes', 'ultimate-member' ), - ), - ), - array( - 'id' => '_um_register_secondary_btn_word', - 'type' => 'text', - 'label' => __( 'Secondary Button Text', 'ultimate-member' ), - 'tooltip' => __( 'Customize the button text', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn_word', null, UM()->options()->get( 'register_secondary_btn_word' ) ), - 'conditional' => array( '_um_register_secondary_btn', '=', 1 ) - ) ) - ) )->render_form(); ?> - + )->render_form(); + ?>
-
\ No newline at end of file + diff --git a/includes/admin/templates/form/register_gdpr.php b/includes/admin/templates/form/register_gdpr.php index 9e134f02..6a296221 100644 --- a/includes/admin/templates/form/register_gdpr.php +++ b/includes/admin/templates/form/register_gdpr.php @@ -1,74 +1,76 @@ - + __( 'Select page', 'ultimate-member' ), +); + +$pages = get_pages(); +foreach ( $pages as $page ) { + $options[ $page->ID ] = $page->post_title; +} ?>
- __( 'Select page', 'ultimate-member' ) - ); - - $pages = get_pages(); - foreach ( $pages as $page ) { - $options[$page->ID] = $page->post_title; - } - - UM()->admin_forms( array( - 'class' => 'um-form-register-gdpr um-top-label', - 'prefix_id' => 'form', - 'fields' => array( - array( - 'id' => '_um_register_use_gdpr', - 'type' => 'select', - 'label' => __( 'Enable on this form', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr', null, '' ), - 'options' => array( - '0' => __( 'No', 'ultimate-member' ), - '1' => __( 'Yes', 'ultimate-member' ) + UM()->admin_forms( + array( + 'class' => 'um-form-register-gdpr um-top-label', + 'prefix_id' => 'form', + 'fields' => array( + array( + 'id' => '_um_register_use_gdpr', + 'type' => 'select', + 'label' => __( 'Enable on this form', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr', null, '' ), + 'options' => array( + '0' => __( 'No', 'ultimate-member' ), + '1' => __( 'Yes', 'ultimate-member' ), + ), + ), + array( + 'id' => '_um_register_use_gdpr_content_id', + 'type' => 'select', + 'label' => __( 'Content', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_content_id', null, '' ), + 'options' => $options, + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ), + ), + array( + 'id' => '_um_register_use_gdpr_toggle_show', + 'type' => 'text', + 'label' => __( 'Toggle Show text', 'ultimate-member' ), + 'placeholder' => __( 'Show privacy policy', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_toggle_show', null, __( 'Show privacy policy', 'ultimate-member' ) ), + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ), + ), + array( + 'id' => '_um_register_use_gdpr_toggle_hide', + 'type' => 'text', + 'label' => __( 'Toggle Hide text', 'ultimate-member' ), + 'placeholder' => __( 'Hide privacy policy', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_toggle_hide', null, __( 'Hide privacy policy', 'ultimate-member' ) ), + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ), + ), + array( + 'id' => '_um_register_use_gdpr_agreement', + 'type' => 'text', + 'label' => __( 'Checkbox agreement description', 'ultimate-member' ), + 'placeholder' => __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_agreement', null, __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ) ), + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ), + ), + array( + 'id' => '_um_register_use_gdpr_error_text', + 'type' => 'text', + 'label' => __( 'Error Text', 'ultimate-member' ), + 'placeholder' => __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ), + 'value' => UM()->query()->get_meta_value( '_um_register_use_gdpr_error_text', null, __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ) ), + 'conditional' => array( '_um_register_use_gdpr', '=', '1' ), ), ), - array( - 'id' => '_um_register_use_gdpr_content_id', - 'type' => 'select', - 'label' => __( 'Content', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_content_id', null, '' ), - 'options' => $options, - 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) - ), - array( - 'id' => '_um_register_use_gdpr_toggle_show', - 'type' => 'text', - 'label' => __( 'Toggle Show text', 'ultimate-member' ), - 'placeholder' => __( 'Show privacy policy', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_toggle_show', null, __( 'Show privacy policy', 'ultimate-member' ) ), - 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) - ), - array( - 'id' => '_um_register_use_gdpr_toggle_hide', - 'type' => 'text', - 'label' => __( 'Toggle Hide text', 'ultimate-member' ), - 'placeholder' => __( 'Hide privacy policy', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_toggle_hide', null, __( 'Hide privacy policy', 'ultimate-member' ) ), - 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) - ), - array( - 'id' => '_um_register_use_gdpr_agreement', - 'type' => 'text', - 'label' => __( 'Checkbox agreement description', 'ultimate-member' ), - 'placeholder' => __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_agreement', null, __( 'Please confirm that you agree to our privacy policy', 'ultimate-member' ) ), - 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) - ), - array( - 'id' => '_um_register_use_gdpr_error_text', - 'type' => 'text', - 'label' => __( 'Error Text', 'ultimate-member' ), - 'placeholder' => __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value('_um_register_use_gdpr_error_text', null, __( 'Please confirm your acceptance of our privacy policy', 'ultimate-member' ) ), - 'conditional' => array( '_um_register_use_gdpr', '=', '1' ) - ) ) - ) )->render_form(); ?> - + )->render_form(); + ?>
-
\ No newline at end of file + diff --git a/includes/admin/templates/role/publish.php b/includes/admin/templates/role/publish.php index c3d57c4b..bdbaf33c 100644 --- a/includes/admin/templates/role/publish.php +++ b/includes/admin/templates/role/publish.php @@ -1,27 +1,33 @@ -
- admin_forms( array( - 'class' => 'um-role-publish um-top-label', - 'prefix_id' => 'role', - 'fields' => array( - array( - 'id' => '_um_priority', - 'type' => 'text', - 'label' => __( 'Role Priority', 'ultimate-member' ), - 'tooltip' => __( 'The higher the number, the higher the priority', 'ultimate-member' ), - 'value' => ! empty( $role['_um_priority'] ) ? $role['_um_priority'] : '', + admin_forms( + array( + 'class' => 'um-role-publish um-top-label', + 'prefix_id' => 'role', + 'fields' => array( + array( + 'id' => '_um_priority', + 'type' => 'text', + 'label' => __( 'Role Priority', 'ultimate-member' ), + 'tooltip' => __( 'The higher the number, the higher the priority', 'ultimate-member' ), + 'value' => ! empty( $role['_um_priority'] ) ? $role['_um_priority'] : '', + ), ), ) - ) )->render_form(); ?> + )->render_form(); + ?>
- +
-
\ No newline at end of file + diff --git a/includes/admin/templates/role/role-edit.php b/includes/admin/templates/role/role-edit.php index 0b2f0312..2450020f 100644 --- a/includes/admin/templates/role/role-edit.php +++ b/includes/admin/templates/role/role-edit.php @@ -1,4 +1,6 @@ -'; } @@ -76,155 +78,9 @@ if ( ! empty( $_POST['role'] ) ) { if ( empty( $error ) ) { - $data = $_POST['role']; + $data = UM()->admin()->sanitize_role_meta( $_POST['role'] ); - $all_roles = array_keys( UM()->roles()->get_roles() ); - - if ( array_key_exists( '_um_priority', $data ) ) { - $data['_um_priority'] = (int) $data['_um_priority']; - } - - if ( array_key_exists( '_um_can_access_wpadmin', $data ) ) { - $data['_um_can_access_wpadmin'] = (bool) $data['_um_can_access_wpadmin']; - } - - if ( array_key_exists( '_um_can_not_see_adminbar', $data ) ) { - $data['_um_can_not_see_adminbar'] = (bool) $data['_um_can_not_see_adminbar']; - } - - if ( array_key_exists( '_um_can_edit_everyone', $data ) ) { - $data['_um_can_edit_everyone'] = (bool) $data['_um_can_edit_everyone']; - } - - if ( array_key_exists( '_um_can_edit_roles', $data ) && ! empty( $data['_um_can_edit_roles'] ) ) { - $data['_um_can_edit_roles'] = array_filter( $data['_um_can_edit_roles'], function( $v, $k ) use ( $all_roles ) { - return in_array( $v, $all_roles ); - }, ARRAY_FILTER_USE_BOTH ); - } - - if ( array_key_exists( '_um_can_delete_everyone', $data ) ) { - $data['_um_can_delete_everyone'] = (bool) $data['_um_can_delete_everyone']; - } - - if ( array_key_exists( '_um_can_delete_roles', $data ) && ! empty( $data['_um_can_delete_roles'] ) ) { - $data['_um_can_delete_roles'] = array_filter( $data['_um_can_delete_roles'], function( $v, $k ) use ( $all_roles ) { - return in_array( $v, $all_roles ); - }, ARRAY_FILTER_USE_BOTH ); - } - - if ( array_key_exists( '_um_can_edit_profile', $data ) ) { - $data['_um_can_edit_profile'] = (bool) $data['_um_can_edit_profile']; - } - - if ( array_key_exists( '_um_can_delete_profile', $data ) ) { - $data['_um_can_delete_profile'] = (bool) $data['_um_can_delete_profile']; - } - - if ( array_key_exists( '_um_can_view_all', $data ) ) { - $data['_um_can_view_all'] = (bool) $data['_um_can_view_all']; - } - - if ( array_key_exists( '_um_can_view_roles', $data ) && ! empty( $data['_um_can_view_roles'] ) ) { - $data['_um_can_view_roles'] = array_filter( $data['_um_can_view_roles'], function( $v, $k ) use ( $all_roles ) { - return in_array( $v, $all_roles ); - }, ARRAY_FILTER_USE_BOTH ); - } - - if ( array_key_exists( '_um_can_make_private_profile', $data ) ) { - $data['_um_can_make_private_profile'] = (bool) $data['_um_can_make_private_profile']; - } - - if ( array_key_exists( '_um_can_access_private_profile', $data ) ) { - $data['_um_can_access_private_profile'] = (bool) $data['_um_can_access_private_profile']; - } - - if ( array_key_exists( '_um_profile_noindex', $data ) ) { - $data['_um_profile_noindex'] = $data['_um_profile_noindex'] !== '' ? (bool) $data['_um_profile_noindex'] : $data['_um_profile_noindex']; - } - - if ( array_key_exists( '_um_default_homepage', $data ) ) { - $data['_um_default_homepage'] = (bool) $data['_um_default_homepage']; - } - - if ( array_key_exists( '_um_redirect_homepage', $data ) ) { - $data['_um_redirect_homepage'] = esc_url_raw( $data['_um_redirect_homepage'] ); - } - - if ( array_key_exists( '_um_status', $data ) ) { - $data['_um_status'] = ! in_array( sanitize_key( $data['_um_status'] ), [ 'approved', 'checkmail', 'pending' ] ) ? 'approved' : sanitize_key( $data['_um_status'] ); - } - - if ( array_key_exists( '_um_auto_approve_act', $data ) ) { - $data['_um_auto_approve_act'] = ! in_array( sanitize_key( $data['_um_auto_approve_act'] ), [ 'redirect_profile', 'redirect_url' ] ) ? 'redirect_profile' : sanitize_key( $data['_um_auto_approve_act'] ); - } - - if ( array_key_exists( '_um_auto_approve_url', $data ) ) { - $data['_um_auto_approve_url'] = esc_url_raw( $data['_um_auto_approve_url'] ); - } - - if ( array_key_exists( '_um_login_email_activate', $data ) ) { - $data['_um_login_email_activate'] = (bool) $data['_um_login_email_activate']; - } - - if ( array_key_exists( '_um_checkmail_action', $data ) ) { - $data['_um_checkmail_action'] = ! in_array( sanitize_key( $data['_um_checkmail_action'] ), [ 'show_message', 'redirect_url' ] ) ? 'show_message' : sanitize_key( $data['_um_checkmail_action'] ); - } - - if ( array_key_exists( '_um_checkmail_message', $data ) ) { - $data['_um_checkmail_message'] = sanitize_textarea_field( $data['_um_checkmail_message'] ); - } - - if ( array_key_exists( '_um_checkmail_url', $data ) ) { - $data['_um_checkmail_url'] = esc_url_raw( $data['_um_checkmail_url'] ); - } - - if ( array_key_exists( '_um_url_email_activate', $data ) ) { - $data['_um_url_email_activate'] = esc_url_raw( $data['_um_url_email_activate'] ); - } - - if ( array_key_exists( '_um_pending_action', $data ) ) { - $data['_um_pending_action'] = ! in_array( sanitize_key( $data['_um_pending_action'] ), [ 'show_message', 'redirect_url' ] ) ? 'show_message' : sanitize_key( $data['_um_pending_action'] ); - } - - if ( array_key_exists( '_um_pending_message', $data ) ) { - $data['_um_pending_message'] = sanitize_textarea_field( $data['_um_pending_message'] ); - } - - if ( array_key_exists( '_um_pending_url', $data ) ) { - $data['_um_pending_url'] = esc_url_raw( $data['_um_pending_url'] ); - } - - if ( array_key_exists( '_um_after_login', $data ) ) { - $data['_um_after_login'] = ! in_array( sanitize_key( $data['_um_after_login'] ), [ 'redirect_profile', 'redirect_url', 'refresh', 'redirect_admin' ] ) ? 'redirect_profile' : sanitize_key( $data['_um_after_login'] ); - } - - if ( array_key_exists( '_um_login_redirect_url', $data ) ) { - $data['_um_login_redirect_url'] = esc_url_raw( $data['_um_login_redirect_url'] ); - } - - if ( array_key_exists( '_um_after_logout', $data ) ) { - $data['_um_after_logout'] = ! in_array( sanitize_key( $data['_um_after_logout'] ), [ 'redirect_home', 'redirect_url' ] ) ? 'redirect_home' : sanitize_key( $data['_um_after_logout'] ); - } - - if ( array_key_exists( '_um_logout_redirect_url', $data ) ) { - $data['_um_logout_redirect_url'] = esc_url_raw( $data['_um_logout_redirect_url'] ); - } - - if ( array_key_exists( '_um_after_delete', $data ) ) { - $data['_um_after_delete'] = ! in_array( sanitize_key( $data['_um_after_delete'] ), [ 'redirect_home', 'redirect_url' ] ) ? 'redirect_home' : sanitize_key( $data['_um_after_delete'] ); - } - - if ( array_key_exists( '_um_delete_redirect_url', $data ) ) { - $data['_um_delete_redirect_url'] = esc_url_raw( $data['_um_delete_redirect_url'] ); - } - - if ( array_key_exists( 'wp_capabilities', $data ) && ! empty( $data['wp_capabilities'] ) ) { - $data['wp_capabilities'] = array_map( 'boolval', array_filter( $data['wp_capabilities'] ) ); - } - - $data = apply_filters( 'um_save_role_meta_sanitize', $data ); - - if ( 'add' == sanitize_key( $_GET['tab'] ) ) { + if ( 'add' === sanitize_key( $_GET['tab'] ) ) { $data['name'] = trim( esc_html( strip_tags( $data['name'] ) ) ); @@ -237,11 +93,11 @@ if ( ! empty( $_POST['role'] ) ) { } else { $auto_increment = UM()->options()->get( 'custom_roles_increment' ); $auto_increment = ! empty( $auto_increment ) ? $auto_increment : 1; - $id = 'custom_role_' . $auto_increment; + $id = 'custom_role_' . $auto_increment; } $redirect = add_query_arg( array( 'page'=>'um_roles', 'tab'=>'edit', 'id'=>$id, 'msg'=>'a' ), admin_url( 'admin.php' ) ); - } elseif ( 'edit' == sanitize_key( $_GET['tab'] ) && ! empty( $_GET['id'] ) ) { + } elseif ( 'edit' === sanitize_key( $_GET['tab'] ) && ! empty( $_GET['id'] ) ) { $id = sanitize_key( $_GET['id'] ); $pre_role_meta = get_option( "um_role_{$id}_meta", array() ); @@ -254,16 +110,16 @@ if ( ! empty( $_POST['role'] ) ) { $all_roles = array_keys( get_editable_roles() ); - if ( 'add' == sanitize_key( $_GET['tab'] ) ) { - if ( in_array( 'um_' . $id, $all_roles ) || in_array( $id, $all_roles ) ) { + if ( 'add' === sanitize_key( $_GET['tab'] ) ) { + if ( in_array( 'um_' . $id, $all_roles, true ) || in_array( $id, $all_roles, true ) ) { $error .= __( 'Role already exists!', 'ultimate-member' ) . '
'; } } - if ( '' == $error ) { + if ( '' === $error ) { - if ( 'add' == sanitize_key( $_GET['tab'] ) ) { - $roles = get_option( 'um_roles', array() ); + if ( 'add' === sanitize_key( $_GET['tab'] ) ) { + $roles = get_option( 'um_roles', array() ); $roles[] = $id; update_option( 'um_roles', $roles ); @@ -297,14 +153,30 @@ $screen_id = $current_screen->id; ?>

- - - - + 'um_roles', + 'tab' => 'add', + ), + admin_url( 'admin.php' ) + ); + ?> + + + +

-

' . __( 'User Role Added Successfully.', 'ultimate-member' ) . '

'; break; @@ -316,13 +188,13 @@ $screen_id = $current_screen->id; ?> if ( ! empty( $error ) ) { ?>
-

+

- + @@ -335,7 +207,7 @@ $screen_id = $current_screen->id; ?>
- + @@ -345,11 +217,18 @@ $screen_id = $current_screen->id; ?>
+ $data, + 'option' => $option, + ); + ?> +
- $data, 'option' => $option ) ); ?> +
- $data, 'option' => $option ) ); ?> +
diff --git a/includes/admin/templates/role/wp-capabilities.php b/includes/admin/templates/role/wp-capabilities.php index 16fb78e8..437a4438 100644 --- a/includes/admin/templates/role/wp-capabilities.php +++ b/includes/admin/templates/role/wp-capabilities.php @@ -51,7 +51,8 @@ - render_form(); ?> - \ No newline at end of file + diff --git a/includes/class-functions.php b/includes/class-functions.php index 441c2ff2..4fd75217 100644 --- a/includes/class-functions.php +++ b/includes/class-functions.php @@ -48,7 +48,7 @@ if ( ! class_exists( 'UM_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-frontend-nonce' : $action; if ( ! wp_verify_nonce( $nonce, $action ) ) { @@ -392,4 +392,4 @@ if ( ! class_exists( 'UM_Functions' ) ) { } } -} \ No newline at end of file +} diff --git a/includes/core/class-access.php b/includes/core/class-access.php index d1ad50b4..3adfe3c7 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -699,7 +699,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { foreach ( $posts as $post ) { //Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page - if ( ! empty( $_GET['wc-ajax'] ) && defined('WC_DOING_AJAX') && WC_DOING_AJAX /*&& $query->is_front_page()*/ ) { + if ( ! empty( $_GET['wc-ajax'] ) && defined( 'WC_DOING_AJAX' ) && WC_DOING_AJAX ) { $filtered_posts[] = $post; continue; } @@ -1464,4 +1464,4 @@ if ( ! class_exists( 'um\core\Access' ) ) { } } -} \ No newline at end of file +} diff --git a/includes/core/class-account.php b/includes/core/class-account.php index ade56be5..bf77e2b5 100644 --- a/includes/core/class-account.php +++ b/includes/core/class-account.php @@ -397,6 +397,8 @@ if ( ! class_exists( 'um\core\Account' ) ) { $this->current_tab = UM()->form()->post_form['_um_account_tab']; } + $this->current_tab = sanitize_key( $this->current_tab ); + if ( ! isset( UM()->form()->errors ) ) { /** * UM hook @@ -971,4 +973,4 @@ if ( ! class_exists( 'um\core\Account' ) ) { return $is_required; } } -} \ No newline at end of file +} diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 50efd958..4d4675f2 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -50,7 +50,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * Set value on form submission */ if ( isset( $_REQUEST[ $id ] ) ) { - $checked = $_REQUEST[ $id ]; + $checked = (bool) $_REQUEST[ $id ]; } $class = $checked ? 'um-icon-android-checkbox-outline' : 'um-icon-android-checkbox-outline-blank'; @@ -60,7 +60,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
-
'; @@ -78,9 +80,9 @@ function um_profile_field_filter_hook__vimeo_video( $value, $data ) { return ''; } - $value = ( !is_numeric( $value ) ) ? (int) substr(parse_url($value, PHP_URL_PATH), 1) : $value; + $value = ! is_numeric( $value ) ? (int) substr( parse_url( $value, PHP_URL_PATH ), 1 ) : $value; $value = '
- +
'; return $value; } @@ -341,10 +343,10 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) { return ''; } - if ( ( isset( $data['validate'] ) && $data['validate'] != '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) { + if ( ( isset( $data['validate'] ) && $data['validate'] !== '' && strstr( $data['validate'], 'url' ) ) || ( isset( $data['type'] ) && $data['type'] == 'url' ) ) { $alt = ( isset( $data['url_text'] ) && !empty( $data['url_text'] ) ) ? $data['url_text'] : $value; $url_rel = ( isset( $data['url_rel'] ) && $data['url_rel'] == 'nofollow' ) ? 'rel="nofollow"' : ''; - if( !strstr( $value, 'http' ) + if ( ! strstr( $value, 'http' ) && !strstr( $value, '://' ) && !strstr( $value, 'www.' ) && !strstr( $value, '.com' ) @@ -363,13 +365,9 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) { } - if ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) { + if ( ! ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) ) { - $value = $value; - - } else { - - if ( strpos($value, 'http://') !== 0 ) { + if ( strpos( $value, 'http://' ) !== 0 ) { $value = 'http://' . $value; } $data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank'; @@ -456,7 +454,7 @@ function um_get_custom_field_array( $array, $fields ) { $condition_metakey = $fields[ $value[1] ]['metakey']; if ( isset( $_POST[ $condition_metakey ] ) ) { - $cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ]; + $cond_value = ( $fields[ $value[1] ]['type'] === 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ]; list( $visibility, $parent_key, $op, $parent_value ) = $value; if ( $visibility == 'hide' ) { @@ -849,4 +847,4 @@ function um_edit_url_field_value( $value, $key ) { $value = esc_attr( $value ); return $value; } -add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 ); \ No newline at end of file +add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 ); diff --git a/includes/core/um-filters-login.php b/includes/core/um-filters-login.php index 3a058378..b5f5da37 100644 --- a/includes/core/um-filters-login.php +++ b/includes/core/um-filters-login.php @@ -1,4 +1,6 @@ -options()->get( 'wpadmin_allow_ips' ); - - if ( !$ips ) + + if ( ! $ips ) { return $allowed; - - $ips = array_map("rtrim", explode("\n", $ips)); + } + + $ips = array_map( 'rtrim', explode( "\n", $ips ) ); $user_ip = um_user_ip(); - if ( in_array( $user_ip, $ips ) ) + if ( in_array( $user_ip, $ips, true ) ) { $allowed = 1; - + } + return $allowed; } add_filter( 'um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access' ); @@ -35,7 +39,7 @@ add_filter( 'um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access' ); function um_custom_wp_err_messages( $message ) { if ( ! empty( $_REQUEST['err'] ) ) { - switch( $_REQUEST['err'] ) { + switch ( sanitize_key( $_REQUEST['err'] ) ) { case 'blocked_email': $err = __( 'This email address has been blocked.', 'ultimate-member' ); break; @@ -126,4 +130,4 @@ function um_lostpassword_url( $lostpassword_url ) { return $lostpassword_url; } -add_filter( 'lostpassword_url', 'um_lostpassword_url', 10, 1 ); \ No newline at end of file +add_filter( 'lostpassword_url', 'um_lostpassword_url', 10, 1 ); diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 4c16b052..2f871f5e 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -1490,7 +1490,7 @@ function um_edit_my_profile_cancel_uri( $url = '' ) { * @return bool */ function um_is_on_edit_profile() { - if ( isset( $_REQUEST['um_action'] ) && $_REQUEST['um_action'] == 'edit' ) { + if ( isset( $_REQUEST['um_action'] ) && sanitize_key( $_REQUEST['um_action'] ) == 'edit' ) { return true; } @@ -2623,15 +2623,15 @@ function um_secure_media_uri( $url ) { */ function um_force_utf8_string( $value ) { - if (is_array( $value )) { + if ( is_array( $value ) ) { $arr_value = array(); - foreach ($value as $key => $value) { - $utf8_decoded_value = utf8_decode( $value ); + foreach ( $value as $key => $v ) { + $utf8_decoded_value = utf8_decode( $v ); - if (mb_check_encoding( $utf8_decoded_value, 'UTF-8' )) { + if ( mb_check_encoding( $utf8_decoded_value, 'UTF-8' ) ) { array_push( $arr_value, $utf8_decoded_value ); } else { - array_push( $arr_value, $value ); + array_push( $arr_value, $v ); } } @@ -2798,4 +2798,4 @@ function um_is_amp( $check_theme_support = true ) { } return apply_filters( 'um_is_amp', $is_amp ); -} \ No newline at end of file +} diff --git a/templates/email/checkmail_email.php b/templates/email/checkmail_email.php index 575e41ef..5cf88f99 100644 --- a/templates/email/checkmail_email.php +++ b/templates/email/checkmail_email.php @@ -25,4 +25,4 @@
- \ No newline at end of file + diff --git a/templates/members.php b/templates/members.php index 8f41a562..e1dc9adf 100644 --- a/templates/members.php +++ b/templates/members.php @@ -95,17 +95,17 @@ if ( ! empty( $args['enable_sorting'] ) ) { } $sorting_options = apply_filters( 'um_member_directory_pre_display_sorting', $sorting_options, $args ); - $sort_from_url = ( ! empty( $_GET[ 'sort_' . $unique_hash ] ) && in_array( $_GET[ 'sort_' . $unique_hash ], array_keys( $sorting_options ) ) ) ? $_GET[ 'sort_' . $unique_hash ] : $default_sorting; + $sort_from_url = ( ! empty( $_GET[ 'sort_' . $unique_hash ] ) && in_array( sanitize_text_field( $_GET[ 'sort_' . $unique_hash ] ), array_keys( $sorting_options ) ) ) ? sanitize_text_field( $_GET[ 'sort_' . $unique_hash ] ) : $default_sorting; } -$current_page = ( ! empty( $_GET[ 'page_' . $unique_hash ] ) && is_numeric( $_GET[ 'page_' . $unique_hash ] ) ) ? (int) $_GET[ 'page_' . $unique_hash ] : 1; +$current_page = ( ! empty( $_GET[ 'page_' . $unique_hash ] ) && is_numeric( $_GET[ 'page_' . $unique_hash ] ) ) ? absint( $_GET[ 'page_' . $unique_hash ] ) : 1; //Search $search = isset( $args['search'] ) ? $args['search'] : false; $show_search = empty( $args['roles_can_search'] ) || ( ! empty( $priority_user_role ) && in_array( $priority_user_role, $args['roles_can_search'] ) ); $search_from_url = ''; if ( $search && $show_search ) { - $search_from_url = ! empty( $_GET[ 'search_' . $unique_hash ] ) ? stripslashes( $_GET[ 'search_' . $unique_hash ] ) : ''; + $search_from_url = ! empty( $_GET[ 'search_' . $unique_hash ] ) ? stripslashes( sanitize_text_field( $_GET[ 'search_' . $unique_hash ] ) ) : ''; } @@ -374,4 +374,4 @@ if ( ( ( $search && $show_search ) || ( $filters && $show_filters && count( $sea */ do_action( 'um_members_directory_footer', $args, $form_id, $not_searched ); ?> - \ No newline at end of file + diff --git a/templates/password-reset.php b/templates/password-reset.php index d8dfa073..437fa184 100644 --- a/templates/password-reset.php +++ b/templates/password-reset.php @@ -1,13 +1,15 @@ - +
- +
- +
@@ -41,9 +43,9 @@
-
@@ -143,4 +145,4 @@ } ?>
-
\ No newline at end of file +
From 0fc2d131ee2d41aa1baf9b5caa013be97e55b46b Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Tue, 29 Jun 2021 21:15:48 +0300 Subject: [PATCH 05/29] - fixed sanitizing functions; --- includes/admin/class-admin.php | 200 +++---- includes/admin/core/class-admin-settings.php | 14 +- includes/core/class-form.php | 528 +++++++++++-------- includes/core/class-member-directory.php | 11 +- 4 files changed, 413 insertions(+), 340 deletions(-) diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index 8a290e75..cb4e2bf6 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -345,10 +345,10 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { 'sanitize' => 'bool', ), '_um_search_filters' => array( - 'sanitize' => array( $this, 'sanitize_md_default_filters' ), + 'sanitize' => array( $this, 'sanitize_filter_fields' ), ), '_um_sortby' => array( - 'sanitize' => array( $this, 'sanitize_sort_by_fields' ), + 'sanitize' => 'text', ), '_um_sortby_custom' => array( 'sanitize' => 'text', @@ -393,7 +393,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { 'sanitize' => 'bool', ), '_um_register_role' => array( - 'sanitize' => array( $this, 'sanitize_existed_role' ), + 'sanitize' => 'key', ), '_um_register_template' => array( 'sanitize' => 'text', @@ -538,58 +538,37 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { */ public function sanitize_md_sorting_fields( $value ) { $filter_fields = array_merge( UM()->member_directory()->sort_fields, array( 'other' => __( 'Other (Custom Field)', 'ultimate-member' ) ) ); + $filter_fields = array_keys( $filter_fields ); if ( '' !== $value ) { $value = array_filter( $value, function( $v, $k ) use ( $filter_fields ) { - return in_array( sanitize_text_field( $v ), $filter_fields, true ); + if ( 'other_data' === $k ) { + return true; + } else { + return in_array( sanitize_text_field( $v ), $filter_fields, true ); + } }, ARRAY_FILTER_USE_BOTH ); - } - return $value; - } + $value = array_map( + function( $item ) { + if ( is_array( $item ) ) { + if ( isset( $item['meta_key'] ) ) { + $item['meta_key'] = sanitize_text_field( $item['meta_key'] ); + } + if ( isset( $item['label'] ) ) { + $item['label'] = sanitize_text_field( $item['label'] ); + } - - /** - * @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 ); + return $item; + } else { + return sanitize_text_field( $item ); + } }, - 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 + $value ); } @@ -603,7 +582,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { * @return array|string */ public function sanitize_filter_fields( $value ) { - $filter_fields = UM()->member_directory()->filter_fields; + $filter_fields = array_keys( UM()->member_directory()->filter_fields ); if ( '' !== $value ) { $value = array_filter( @@ -613,6 +592,8 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { }, ARRAY_FILTER_USE_BOTH ); + + $value = array_map( 'sanitize_text_field', $value ); } return $value; @@ -625,10 +606,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { * @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'] : ''; - } + $user_fields = array_keys( UM()->builtin()->all_user_fields() ); if ( '' !== $value ) { $value = array_filter( @@ -638,6 +616,38 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { }, ARRAY_FILTER_USE_BOTH ); + + $value = array_map( 'sanitize_text_field', $value ); + } + + 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 + ); + $view_types = array_keys( $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 + ); + + $value = array_map( 'sanitize_key', $value ); } return $value; @@ -653,13 +663,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { $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 - ); + $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : ''; } return $value; @@ -671,23 +675,11 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { * * @return array|string */ - public function sanitize_md_view_types( $value ) { - $view_types = array_map( - function( $item ) { - return $item['title']; - }, - UM()->member_directory()->view_types - ); - + public function sanitize_cover_photosize( $value ) { + $sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ); 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 - ); + $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : ''; } return $value; @@ -710,6 +702,8 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { }, ARRAY_FILTER_USE_BOTH ); + + $value = array_map( 'sanitize_key', $value ); } return $value; @@ -732,6 +726,8 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { }, ARRAY_FILTER_USE_BOTH ); + + $value = array_map( 'sanitize_key', $value ); } return $value; @@ -747,13 +743,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { $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 - ); + $value = in_array( absint( $value ), $all_privacy, true ) ? absint( $value ) : ''; } return $value; @@ -783,6 +773,8 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { /** + * Sanitize role meta fields when wp-admin form has been submitted + * * @param array $data * * @return array @@ -841,6 +833,8 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { /** + * Sanitize post restriction meta fields when wp-admin form has been submitted + * * @param array $data * * @return array @@ -892,6 +886,8 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { /** + * Sanitize term restriction meta fields when wp-admin form has been submitted + * * @param array $data * * @return array @@ -943,6 +939,10 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { /** + * Sanitize member directory meta when wp-admin form has been submitted + * + * @todo checking all sanitize types + * * @param array $data * * @return array @@ -997,6 +997,10 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { /** + * Sanitize form meta when wp-admin form has been submitted + * + * @todo checking all sanitize types + * * @param array $data * * @return array @@ -1051,6 +1055,10 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { /** + * Sanitize options when wp-admin form has been submitted + * + * @todo checking all sanitize types + * * @param array $data * * @return array @@ -1076,31 +1084,34 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { switch ( UM()->admin_settings()->settings_map[ $k ]['sanitize'] ) { default: - $sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $data[ $k ] ); + $sanitized[ $k ] = apply_filters( 'um_settings_sanitize_' . $k, $v ); break; case 'int': $sanitized[ $k ] = (int) $v; break; case 'absint': - $sanitized[ $k ] = absint( $v ); - break; - case 'absints_array': - $sanitized[ $k ] = array_map( 'absint', $v ); + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'absint', $v ); + } else { + $sanitized[ $k ] = absint( $v ); + } break; case 'key': - $sanitized[ $k ] = sanitize_key( $v ); - break; - case 'keys_array': - $sanitized[ $k ] = array_map( 'sanitize_key', $v ); + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'sanitize_key', $v ); + } else { + $sanitized[ $k ] = 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 ); + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'esc_url_raw', $v ); + } else { + $sanitized[ $k ] = esc_url_raw( $v ); + } break; case 'wp_kses': $sanitized[ $k ] = wp_kses_post( $v ); @@ -1108,13 +1119,6 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { 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; } } diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index e0b9685b..85a35fc7 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -523,7 +523,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'sanitize' => 'url', ), 'access_exclude_uris' => array( - 'sanitize' => 'urls_array', + 'sanitize' => 'url', ), 'home_page_accessible' => array( 'sanitize' => 'bool', @@ -605,10 +605,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $settings_map, array( 'restricted_access_post_metabox' => array( - 'sanitize' => 'keys_array', + 'sanitize' => 'key', ), 'restricted_access_taxonomy_metabox' => array( - 'sanitize' => 'keys_array', + 'sanitize' => 'key', ), ) ); @@ -715,10 +715,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'sanitize' => 'absint', ), 'photo_thumb_sizes' => array( - 'sanitize' => 'absints_array', + 'sanitize' => 'absint', ), 'cover_thumb_sizes' => array( - 'sanitize' => 'absints_array', + 'sanitize' => 'absint', ), 'image_orientation_by_exif' => array( 'sanitize' => 'bool', @@ -793,7 +793,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'sanitize' => 'bool', ), 'profile_coversize' => array( - 'sanitize' => array( UM()->admin(), 'sanitize_photosize' ), + 'sanitize' => array( UM()->admin(), 'sanitize_cover_photosize' ), ), 'profile_cover_ratio' => array( 'sanitize' => 'text', @@ -850,7 +850,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'sanitize' => 'url', ), 'register_role' => array( - 'sanitize' => array( UM()->admin(), 'sanitize_existed_role' ), + 'sanitize' => 'key', ), 'login_template' => array( 'sanitize' => 'text', diff --git a/includes/core/class-form.php b/includes/core/class-form.php index 61a510d1..ffb0f2ef 100644 --- a/includes/core/class-form.php +++ b/includes/core/class-form.php @@ -104,32 +104,34 @@ if ( ! class_exists( 'um\core\Form' ) ) { /** * */ - function ajax_select_options() { + public function ajax_select_options() { UM()->check_ajax_nonce(); - $arr_options = array(); + $arr_options = array(); $arr_options['status'] = 'success'; - $arr_options['post'] = $_POST; + $arr_options['post'] = $_POST; - UM()->fields()->set_id = absint( $_POST['form_id'] ); + UM()->fields()->set_id = absint( $_POST['form_id'] ); UM()->fields()->set_mode = 'profile'; - $form_fields = UM()->fields()->get_fields(); - $arr_options['fields'] = $form_fields; + $form_fields = UM()->fields()->get_fields(); + $arr_options['fields'] = $form_fields; - if ( isset( $arr_options['post']['members_directory'] ) && $arr_options['post']['members_directory'] == 'yes' ) { + if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) { $ajax_source_func = $_POST['child_callback']; if ( function_exists( $ajax_source_func ) ) { $arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] ); global $wpdb; - $values_array = $wpdb->get_col( $wpdb->prepare( - "SELECT DISTINCT meta_value - FROM $wpdb->usermeta - WHERE meta_key = %s AND - meta_value != ''", - $arr_options['post']['child_name'] - ) ); + $values_array = $wpdb->get_col( + $wpdb->prepare( + "SELECT DISTINCT meta_value + FROM $wpdb->usermeta + WHERE meta_key = %s AND + meta_value != ''", + $arr_options['post']['child_name'] + ) + ); if ( ! empty( $values_array ) ) { $arr_options['items'] = array_intersect( $arr_options['items'], $values_array ); @@ -161,8 +163,8 @@ if ( ! class_exists( 'um\core\Form' ) ) { * } * ?> */ - $debug = apply_filters('um_ajax_select_options__debug_mode', false ); - if( $debug ){ + $debug = apply_filters( 'um_ajax_select_options__debug_mode', false ); + if ( $debug ) { $arr_options['debug'] = array( $_POST, $form_fields, @@ -176,19 +178,17 @@ if ( ! class_exists( 'um\core\Form' ) ) { // If the requested callback function is added in the form or added in the field option, execute it with call_user_func. if ( isset( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) && ! empty( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) && - $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] == $ajax_source_func ) { + $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] === $ajax_source_func ) { $arr_options['field'] = $form_fields[ $_POST['child_name'] ]; if ( function_exists( $ajax_source_func ) ) { $arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] ); } - } else { - $arr_options['status'] = 'error'; + $arr_options['status'] = 'error'; $arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' ); } - } wp_send_json( $arr_options ); @@ -200,10 +200,10 @@ if ( ! class_exists( 'um\core\Form' ) ) { * Count the form errors. * @return integer */ - function count_errors() { + public function count_errors() { $errors = $this->errors; - if( $errors && is_array( $errors ) ) { + if ( $errors && is_array( $errors ) ) { return count( $errors ); } @@ -213,11 +213,12 @@ if ( ! class_exists( 'um\core\Form' ) ) { /** * Appends field errors + * * @param string $key * @param string $error */ - function add_error( $key, $error ) { - if ( ! isset( $this->errors[ $key ] ) ){ + public function add_error( $key, $error ) { + if ( ! isset( $this->errors[ $key ] ) ) { /** * UM hook * @@ -240,8 +241,7 @@ if ( ! class_exists( 'um\core\Form' ) ) { * } * ?> */ - $error = apply_filters( 'um_submit_form_error', $error, $key ); - $this->errors[ $key ] = $error; + $this->errors[ $key ] = apply_filters( 'um_submit_form_error', $error, $key ); } } @@ -250,8 +250,8 @@ if ( ! class_exists( 'um\core\Form' ) ) { * @param string $key * @param string $notice */ - function add_notice( $key, $notice ) { - if ( ! isset( $this->notices[ $key ] ) ){ + public function add_notice( $key, $notice ) { + if ( ! isset( $this->notices[ $key ] ) ) { /** * UM hook * @@ -274,30 +274,32 @@ if ( ! class_exists( 'um\core\Form' ) ) { * } * ?> */ - $notice = apply_filters( 'um_submit_form_notice', $notice, $key ); - $this->notices[ $key ] = $notice; + $this->notices[ $key ] = apply_filters( 'um_submit_form_notice', $notice, $key ); } } /** * If a form has errors + * * @param string $key * @return boolean */ - function has_error( $key ) { + public function has_error( $key ) { if ( isset( $this->errors[ $key ] ) ) { return true; } return false; } + /** * If a form has notices/info + * * @param string $key * @return boolean */ - function has_notice( $key ) { + public function has_notice( $key ) { if ( isset( $this->notices[ $key ] ) ) { return true; } @@ -308,7 +310,7 @@ if ( ! class_exists( 'um\core\Form' ) ) { /** * Declare all fields */ - function field_declare() { + public function field_declare() { if ( isset( UM()->builtin()->custom_fields ) ) { $this->all_fields = UM()->builtin()->custom_fields; } else { @@ -320,23 +322,29 @@ if ( ! class_exists( 'um\core\Form' ) ) { /** * Validate form on submit */ - function form_init() { + public function form_init() { if ( isset( $_SERVER['REQUEST_METHOD'] ) ) { - $http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] ); + $http_post = ( 'POST' === $_SERVER['REQUEST_METHOD'] ); } else { $http_post = 'POST'; } if ( $http_post && ! is_admin() && isset( $_POST['form_id'] ) && is_numeric( $_POST['form_id'] ) ) { + $this->form_id = absint( $_POST['form_id'] ); + $this->form_status = get_post_status( $this->form_id ); + + + if ( 'publish' !== $this->form_status ) { + return; + } + /** * UM hook * * @type action * @title um_before_submit_form_post * @description Before submit form - * @input_vars - * [{"var":"$post","type":"int","desc":"Post data"}] * @change_log * ["Since: 2.0"] * @usage add_action( 'um_before_submit_form_post', 'function_name', 10, 1 ); @@ -348,184 +356,176 @@ if ( ! class_exists( 'um\core\Form' ) ) { * } * ?> */ - do_action( 'um_before_submit_form_post', $_POST ); + do_action( 'um_before_submit_form_post' ); - $this->form_id = absint( $_POST['form_id'] ); - $this->form_status = get_post_status( $this->form_id ); - - - if ( $this->form_status == 'publish' ) { - /* save entire form as global */ - /** - * UM hook - * - * @type filter - * @title um_submit_post_form - * @description Change submitted data on form submit - * @input_vars - * [{"var":"$data","type":"array","desc":"Submitted data"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * - */ - $this->post_form = apply_filters( 'um_submit_post_form', $_POST ); - - if ( isset( $this->post_form[ UM()->honeypot ] ) && $this->post_form[ UM()->honeypot ] != '' ) { - wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) ); - } - - $this->post_form = $this->beautify( $this->post_form ); - $this->post_form['submitted'] = $this->post_form; - - $this->form_data = UM()->query()->post_data( $this->form_id ); - - $this->post_form = array_merge( $this->form_data, $this->post_form ); - - // Remove role from post_form at first if role ! empty and there aren't custom fields with role name - if ( ! empty( $_POST['role'] ) ) { - if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) { - unset( $this->post_form['role'] ); - unset( $this->post_form['submitted']['role'] ); - } - } - - // Secure sanitize of the submitted data - if ( ! empty( $this->post_form ) ) { - $this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) ); - } - if ( ! empty( $this->post_form['submitted'] ) ) { - $this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) ); - } - - // set default role from settings on registration form - if ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'register' ) { - - $role = $this->assigned_role( $this->form_id ); - $this->post_form['role'] = $role; - - } - - if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role - - if ( ! empty( $_POST['role'] ) ) { - - $custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] ); - - if ( ! empty( $custom_field_roles ) ) { - if ( is_array( $_POST['role'] ) ) { - $role = current( $_POST['role'] ); - $role = sanitize_key( $role ); - } else { - $role = sanitize_key( $_POST['role'] ); - } - - global $wp_roles; - $role_keys = array_map( function( $item ) { - return 'um_' . $item; - }, get_option( 'um_roles', array() ) ); - $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) ); - - if ( ! empty( $role ) && - ( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles ) ) ) { - wp_die( __( 'This is not possible for security reasons.', 'ultimate-member' ) ); - } - - $this->post_form['role'] = $role; - $this->post_form['submitted']['role'] = $role; - } else { - unset( $this->post_form['role'] ); - unset( $this->post_form['submitted']['role'] ); - - // set default role for registration form if custom field hasn't proper value - if ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'register' ) { - $role = $this->assigned_role( $this->form_id ); - $this->post_form['role'] = $role; - } - } - } - - } - - /** - * UM hook - * - * @type filter - * @title um_submit_form_data - * @description Change submitted data on form submit - * @input_vars - * [{"var":"$data","type":"array","desc":"Submitted data"}, - * {"var":"$mode","type":"string","desc":"Form mode"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * - */ - $this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] ); - - /* Continue based on form mode - pre-validation */ - - /** - * UM hook - * - * @type action - * @title um_submit_form_errors_hook - * @description Action on submit form - * @input_vars - * [{"var":"$post","type":"int","desc":"Post data"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 ); - * @example - * - */ - do_action( 'um_submit_form_errors_hook', $this->post_form ); - /** - * UM hook - * - * @type action - * @title um_submit_form_{$mode} - * @description Action on submit form - * @input_vars - * [{"var":"$post","type":"int","desc":"Post data"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 ); - * @example - * - */ - do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form ); + /* save entire form as global */ + /** + * UM hook + * + * @type filter + * @title um_submit_post_form + * @description Change submitted data on form submit + * @input_vars + * [{"var":"$data","type":"array","desc":"Submitted data"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ + $this->post_form = apply_filters( 'um_submit_post_form', $_POST ); + if ( isset( $this->post_form[ UM()->honeypot ] ) && '' !== $this->post_form[ UM()->honeypot ] ) { + wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) ); } - } + $this->post_form = $this->beautify( $this->post_form ); + $this->post_form = $this->sanitize( $this->post_form ); + $this->post_form['submitted'] = $this->post_form; + $this->form_data = UM()->query()->post_data( $this->form_id ); + + $this->post_form = array_merge( $this->form_data, $this->post_form ); + + // Remove role from post_form at first if role ! empty and there aren't custom fields with role name + if ( ! empty( $_POST['role'] ) ) { + if ( ! isset( $this->form_data['custom_fields'] ) || ! strstr( $this->form_data['custom_fields'], 'role_' ) ) { + unset( $this->post_form['role'] ); + unset( $this->post_form['submitted']['role'] ); + } + } + + // Secure sanitize of the submitted data + if ( ! empty( $this->post_form ) ) { + $this->post_form = array_diff_key( $this->post_form, array_flip( UM()->user()->banned_keys ) ); + } + if ( ! empty( $this->post_form['submitted'] ) ) { + $this->post_form['submitted'] = array_diff_key( $this->post_form['submitted'], array_flip( UM()->user()->banned_keys ) ); + } + + // set default role from settings on registration form + if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) { + $role = $this->assigned_role( $this->form_id ); + $this->post_form['role'] = $role; + } + + if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role + + if ( ! empty( $_POST['role'] ) ) { + $custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] ); + + if ( ! empty( $custom_field_roles ) ) { + if ( is_array( $_POST['role'] ) ) { + $role = current( $_POST['role'] ); + $role = sanitize_key( $role ); + } else { + $role = sanitize_key( $_POST['role'] ); + } + + global $wp_roles; + $role_keys = array_map( + function( $item ) { + return 'um_' . $item; + }, + get_option( 'um_roles', array() ) + ); + $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) ); + + if ( ! empty( $role ) && + ( ! in_array( $role, $custom_field_roles, true ) || in_array( $role, $exclude_roles, true ) ) ) { + wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) ); + } + + $this->post_form['role'] = $role; + $this->post_form['submitted']['role'] = $role; + } else { + unset( $this->post_form['role'] ); + unset( $this->post_form['submitted']['role'] ); + + // set default role for registration form if custom field hasn't proper value + if ( isset( $this->post_form['mode'] ) && 'register' === $this->post_form['mode'] ) { + $role = $this->assigned_role( $this->form_id ); + $this->post_form['role'] = $role; + } + } + } + } + + /** + * UM hook + * + * @type filter + * @title um_submit_form_data + * @description Change submitted data on form submit + * @input_vars + * [{"var":"$data","type":"array","desc":"Submitted data"}, + * {"var":"$mode","type":"string","desc":"Form mode"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ + $this->post_form = apply_filters( 'um_submit_form_data', $this->post_form, $this->post_form['mode'] ); + + /* Continue based on form mode - pre-validation */ + + /** + * UM hook + * + * @type action + * @title um_submit_form_errors_hook + * @description Action on submit form + * @input_vars + * [{"var":"$post","type":"int","desc":"Post data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_submit_form_errors_hook', 'function_name', 10, 1 ); + * @example + * + */ + do_action( 'um_submit_form_errors_hook', $this->post_form ); + /** + * UM hook + * + * @type action + * @title um_submit_form_{$mode} + * @description Action on submit form + * @input_vars + * [{"var":"$post","type":"int","desc":"Post data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_submit_form_{$mode}', 'function_name', 10, 1 ); + * @example + * + */ + do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form ); + + } } @@ -533,24 +533,82 @@ if ( ! class_exists( 'um\core\Form' ) ) { * Beautify form data * * @param array $form + * * @return array $form */ - function beautify( $form ) { - + public function beautify( $form ) { if ( isset( $form['form_id'] ) ) { - $this->form_suffix = '-' . $form['form_id']; - - $this->processing = $form['form_id']; + $this->processing = $form['form_id']; foreach ( $form as $key => $value ) { if ( strstr( $key, $this->form_suffix ) ) { - $a_key = str_replace( $this->form_suffix, '', $key ); + $a_key = str_replace( $this->form_suffix, '', $key ); $form[ $a_key ] = $value; unset( $form[ $key ] ); } } + } + return $form; + } + + + /** + * Beautify form data + * + * @param array $form + * + * @return array $form + */ + public function sanitize( $form ) { + if ( isset( $form['form_id'] ) ) { + if ( isset( $this->form_data['custom_fields'] ) ) { + $custom_fields = maybe_unserialize( $this->form_data['custom_fields'] ); + + if ( is_array( $custom_fields ) ) { + foreach ( $custom_fields as $k => $field ) { + if ( isset( $field['type'] ) ) { + if ( isset( $form[ $k ] ) ) { + + switch ( $field['type'] ) { + default: + $form[ $k ] = apply_filters( 'um_sanitize_form_field', $form[ $k ], $field ); + break; + case 'number': + $form[ $k ] = (int) $form[ $k ]; + break; + case 'textarea': + $form[ $k ] = sanitize_textarea_field( $form[ $k ] ); + break; + case 'url': + $form[ $k ] = esc_url_raw( $form[ $k ] ); + break; + case 'text': + case 'select': + case 'password': + case 'image': + case 'file': + case 'date': + case 'time': + case 'rating': + case 'googlemap': + case 'youtube_video': + case 'vimeo_video': + case 'soundcloud_track': + $form[ $k ] = sanitize_text_field( $form[ $k ] ); + break; + case 'multiselect': + case 'radio': + case 'checkbox': + $form[ $k ] = array_map( 'sanitize_text_field', $form[ $k ] ); + break; + } + } + } + } + } + } } return $form; @@ -563,17 +621,17 @@ if ( ! class_exists( 'um\core\Form' ) ) { * @param integer $post_id * @return string $output */ - function display_form_type( $mode, $post_id ){ + public function display_form_type( $mode, $post_id ) { $output = null; - switch( $mode ){ + switch ( $mode ) { case 'login': - $output = 'Login'; + $output = __( 'Login', 'ultimate-member' ); break; case 'profile': - $output = 'Profile'; + $output = __( 'Profile', 'ultimate-member' ); break; case 'register': - $output = 'Register'; + $output = __( 'Register', 'ultimate-member' ); break; } return $output; @@ -585,7 +643,7 @@ if ( ! class_exists( 'um\core\Form' ) ) { * @param integer $post_id * @return string $role */ - function assigned_role( $post_id ) { + public function assigned_role( $post_id ) { $global_role = get_option( 'default_role' ); // WP Global settings @@ -617,7 +675,7 @@ if ( ! class_exists( 'um\core\Form' ) ) { * @param integer $post_id * @return string */ - function form_type( $post_id ) { + public function form_type( $post_id ) { $mode = get_post_meta( $post_id, '_um_mode', true ); return $mode; } @@ -625,10 +683,11 @@ if ( ! class_exists( 'um\core\Form' ) ) { /** * Get custom field roles + * * @param string $custom_fields serialized * @return bool|array roles */ - function custom_field_roles( $custom_fields ) { + public function custom_field_roles( $custom_fields ) { $fields = maybe_unserialize( $custom_fields ); if ( ! is_array( $fields ) ) { @@ -637,21 +696,27 @@ if ( ! class_exists( 'um\core\Form' ) ) { // role field global $wp_roles; - $role_keys = array_map( function( $item ) { - return 'um_' . $item; - }, get_option( 'um_roles', array() ) ); + $role_keys = array_map( + function( $item ) { + return 'um_' . $item; + }, + get_option( 'um_roles', array() ) + ); $exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) ); $roles = UM()->roles()->get_roles( false, $exclude_roles ); - $roles = array_map( function( $item ) { - return html_entity_decode( $item, ENT_QUOTES ); - }, $roles ); + $roles = array_map( + function( $item ) { + return html_entity_decode( $item, ENT_QUOTES ); + }, + $roles + ); foreach ( $fields as $field_key => $field_settings ) { if ( strstr( $field_key, 'role_' ) && is_array( $field_settings['options'] ) ) { - if ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'profile' && + if ( isset( $this->post_form['mode'] ) && 'profile' === $this->post_form['mode'] && isset( $field_settings['editable'] ) && $field_settings['editable'] == 0 ) { continue; } @@ -672,7 +737,6 @@ if ( ! class_exists( 'um\core\Form' ) ) { // getting roles only from the first role fields return array_keys( $intersected_options ); } - } return false; diff --git a/includes/core/class-member-directory.php b/includes/core/class-member-directory.php index 529a9fa5..108f9e0f 100644 --- a/includes/core/class-member-directory.php +++ b/includes/core/class-member-directory.php @@ -217,11 +217,14 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { if ( ! empty( $filter_type ) ) { if ( 'slider' === $filter_type ) { if ( ! empty( $_POST[ $k ] ) ) { - $temp_value[ $k ] = $_POST[ $k ]; + $temp_value[ $k ] = (int) $_POST[ $k ]; } } elseif ( 'timepicker' === $filter_type || 'datepicker' === $filter_type ) { if ( ! empty( $_POST[ $k . '_from' ] ) && ! empty( $_POST[ $k . '_to' ] ) ) { - $temp_value[ $k ] = array( $_POST[ $k . '_from' ], $_POST[ $k . '_to' ] ); + $temp_value[ $k ] = array( + sanitize_text_field( $_POST[ $k . '_from' ] ), + sanitize_text_field( $_POST[ $k . '_to' ] ), + ); } } elseif ( 'select' === $filter_type ) { if ( ! empty( $_POST[ $k ] ) ) { @@ -230,10 +233,12 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { } else { $temp_value[ $k ] = array( trim( $_POST[ $k ] ) ); } + + $temp_value[ $k ] = array_map( 'sanitize_text_field', $temp_value[ $k ] ); } } else { if ( ! empty( $_POST[ $k ] ) ) { - $temp_value[ $k ] = trim( $_POST[ $k ] ); + $temp_value[ $k ] = trim( sanitize_text_field( $_POST[ $k ] ) ); } } } From 18dea8f622b45696731d0a91c264df8376c26dec Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Wed, 30 Jun 2021 13:31:51 +0300 Subject: [PATCH 06/29] - fixed sanitizing of the forms and member directories; --- includes/admin/class-admin.php | 40 ++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index cb4e2bf6..6d45cdba 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -977,7 +977,11 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { $sanitized[ $k ] = (bool) $v; break; case 'url': - $sanitized[ $k ] = esc_url_raw( $v ); + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'esc_url_raw', $v ); + } else { + $sanitized[ $k ] = esc_url_raw( $v ); + } break; case 'text': $sanitized[ $k ] = sanitize_text_field( $v ); @@ -985,6 +989,20 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { case 'textarea': $sanitized[ $k ] = sanitize_textarea_field( $v ); break; + case 'key': + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'sanitize_key', $v ); + } else { + $sanitized[ $k ] = sanitize_key( $v ); + } + break; + case 'absint': + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'absint', $v ); + } else { + $sanitized[ $k ] = absint( $v ); + } + break; } } @@ -1035,7 +1053,11 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { $sanitized[ $k ] = (bool) $v; break; case 'url': - $sanitized[ $k ] = esc_url_raw( $v ); + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'esc_url_raw', $v ); + } else { + $sanitized[ $k ] = esc_url_raw( $v ); + } break; case 'text': $sanitized[ $k ] = sanitize_text_field( $v ); @@ -1043,6 +1065,20 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { case 'textarea': $sanitized[ $k ] = sanitize_textarea_field( $v ); break; + case 'key': + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'sanitize_key', $v ); + } else { + $sanitized[ $k ] = sanitize_key( $v ); + } + break; + case 'absint': + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'absint', $v ); + } else { + $sanitized[ $k ] = absint( $v ); + } + break; } } From e351d36666a01f76d4202272f6de80a185f9f0db Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Thu, 1 Jul 2021 09:26:43 +0300 Subject: [PATCH 07/29] - fixed sanitizing; --- includes/admin/class-admin.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index 6d45cdba..1926cb37 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -661,6 +661,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { */ public function sanitize_photosize( $value ) { $sizes = UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ); + $sizes = array_keys( $sizes ); if ( '' !== $value ) { $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : ''; @@ -677,6 +678,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { */ public function sanitize_cover_photosize( $value ) { $sizes = UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ); + $sizes = array_keys( $sizes ); if ( '' !== $value ) { $value = in_array( absint( $value ), $sizes, true ) ? absint( $value ) : ''; @@ -1155,6 +1157,9 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { case 'textarea': $sanitized[ $k ] = sanitize_textarea_field( $v ); break; + case 'text': + $sanitized[ $k ] = sanitize_text_field( $v ); + break; } } From beabc7388f5024098933fca7f9c4906b5e73af74 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Thu, 1 Jul 2021 14:34:39 +0300 Subject: [PATCH 08/29] - fixed sanitizing; --- includes/admin/class-admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index 1926cb37..fa204692 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -264,7 +264,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { 'sanitize' => 'key', ), '_um_roles' => array( - 'sanitize' => array( $this, 'sanitize_existed_role' ), + 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ), ), '_um_has_profile_photo' => array( 'sanitize' => 'bool', @@ -327,13 +327,13 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { 'sanitize' => 'bool', ), '_um_roles_can_search' => array( - 'sanitize' => array( $this, 'sanitize_existed_role' ), + 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ), ), '_um_filters' => array( 'sanitize' => 'bool', ), '_um_roles_can_filter' => array( - 'sanitize' => array( $this, 'sanitize_existed_role' ), + 'sanitize' => array( $this, 'sanitize_restriction_existed_role' ), ), '_um_search_fields' => array( 'sanitize' => array( $this, 'sanitize_filter_fields' ), @@ -694,7 +694,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { * @return array|string */ public function sanitize_restriction_existed_role( $value ) { - $all_roles = UM()->roles()->get_roles( false ); + $all_roles = array_keys( UM()->roles()->get_roles() ); if ( '' !== $value ) { $value = array_filter( From eb486684ac43d79d604c523a793e1de783448512 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Thu, 1 Jul 2021 16:10:22 +0300 Subject: [PATCH 09/29] - fixed default data displaying on the member directory metaboxes; --- includes/admin/templates/directory/profile.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/admin/templates/directory/profile.php b/includes/admin/templates/directory/profile.php index facd94f3..6aaf0193 100644 --- a/includes/admin/templates/directory/profile.php +++ b/includes/admin/templates/directory/profile.php @@ -17,20 +17,20 @@ $fields = array( 'id' => '_um_profile_photo', 'type' => 'checkbox', 'label' => __( 'Enable Profile Photo', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_profile_photo', null, 1 ), + 'value' => UM()->query()->get_meta_value( '_um_profile_photo' ), ), 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 ), + 'value' => UM()->query()->get_meta_value( '_um_cover_photos' ), ), array( 'id' => '_um_show_name', 'type' => 'checkbox', 'label' => __( 'Show display name', 'ultimate-member' ), - 'value' => UM()->query()->get_meta_value( '_um_show_name', null, 1 ), + 'value' => UM()->query()->get_meta_value( '_um_show_name' ), ), array( 'id' => '_um_show_tagline', From 6feebac07f35658f42f4b61fee3f28e0d9e7fe07 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Fri, 2 Jul 2021 17:36:01 +0300 Subject: [PATCH 10/29] - hotfixes for member directory settings and frontend functionality; --- includes/admin/core/class-admin-metabox.php | 2 ++ includes/admin/core/class-admin-settings.php | 12 ++++-------- includes/admin/templates/directory/search.php | 2 +- includes/admin/templates/directory/sorting.php | 2 +- includes/core/class-member-directory-meta.php | 10 +++++++++- includes/core/class-member-directory.php | 14 ++++++++++++-- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index d8a32c7d..79deeaa0 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -1099,6 +1099,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { delete_post_meta( $post_id, '_um_search_filters' ); delete_post_meta( $post_id, '_um_search_filters_gmt' ); + delete_post_meta( $post_id, '_um_sorting_fields' ); + //save metadata $metadata = UM()->admin()->sanitize_member_directory_meta( $_POST['um_metadata'] ); foreach ( $metadata as $k => $v ) { diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 85a35fc7..77b31d4a 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -188,12 +188,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $wp_usermeta_option = get_option( 'um_usermeta_fields', array() ); $count = $wpdb->get_var( - $wpdb->prepare( - "SELECT COUNT(*) - FROM {$wpdb->usermeta} - WHERE meta_key IN (%s)", - implode( "','", $wp_usermeta_option ) - ) + "SELECT COUNT(*) + FROM {$wpdb->usermeta} + WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "')" ); wp_send_json_success( array( 'count' => $count ) ); @@ -211,9 +208,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $wpdb->prepare( "SELECT * FROM {$wpdb->usermeta} - WHERE meta_key IN (%s) + WHERE meta_key IN ('" . implode( "','", $wp_usermeta_option ) . "') LIMIT %d, %d", - implode( "','", $wp_usermeta_option ), ( absint( $_POST['page'] ) - 1 ) * $per_page, $per_page ), diff --git a/includes/admin/templates/directory/search.php b/includes/admin/templates/directory/search.php index 6d140aae..f11e17ac 100644 --- a/includes/admin/templates/directory/search.php +++ b/includes/admin/templates/directory/search.php @@ -63,7 +63,7 @@ $_um_search_filters = get_post_meta( $post_id, '_um_search_filters', true ); ?> 'conditional' => array( '_um_filters', '=', 1 ), 'options' => UM()->member_directory()->filter_fields, 'add_text' => __( 'Add New Custom Field', 'ultimate-member' ), - 'show_default_number' => 1, + 'show_default_number' => 0, 'sorting' => true, ), array( diff --git a/includes/admin/templates/directory/sorting.php b/includes/admin/templates/directory/sorting.php index 81a22dd6..fa601663 100644 --- a/includes/admin/templates/directory/sorting.php +++ b/includes/admin/templates/directory/sorting.php @@ -46,7 +46,7 @@ $fields = array( '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, + 'show_default_number' => 0, 'conditional' => array( '_um_enable_sorting', '=', 1 ), ), ); ?> diff --git a/includes/core/class-member-directory-meta.php b/includes/core/class-member-directory-meta.php index d565a458..66eb62a3 100644 --- a/includes/core/class-member-directory-meta.php +++ b/includes/core/class-member-directory-meta.php @@ -611,7 +611,11 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) { foreach ( $filter_query as $field => $value ) { $field = sanitize_text_field( $field ); - $value = sanitize_text_field( $value ); + if ( is_array( $value ) ) { + $value = array_map( 'sanitize_text_field', $value ); + } else { + $value = sanitize_text_field( $value ); + } $attrs = UM()->fields()->get_field( $field ); // skip private invisible fields @@ -669,6 +673,10 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) { $this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$order} "; + } elseif ( 'username' == $sortby ) { + + $this->sql_order = " ORDER BY u.user_login {$order} "; + } elseif ( 'display_name' == $sortby ) { $display_name = UM()->options()->get( 'display_name' ); diff --git a/includes/core/class-member-directory.php b/includes/core/class-member-directory.php index 108f9e0f..0d0ac949 100644 --- a/includes/core/class-member-directory.php +++ b/includes/core/class-member-directory.php @@ -1255,7 +1255,12 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { } } - if ( 'display_name' == $sortby ) { + if ( 'username' == $sortby ) { + + $this->query_args['orderby'] = 'user_login'; + $this->query_args['order'] = 'ASC'; + + } elseif ( 'display_name' == $sortby ) { $display_name = UM()->options()->get( 'display_name' ); if ( $display_name == 'username' ) { @@ -1539,6 +1544,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { $filter_query = array(); if ( ! empty( $directory_data['search_fields'] ) ) { $search_filters = maybe_unserialize( $directory_data['search_fields'] ); + if ( ! empty( $search_filters ) && is_array( $search_filters ) ) { $filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) ); } @@ -1554,7 +1560,11 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) { $this->is_search = true; foreach ( $filter_query as $field => $value ) { $field = sanitize_text_field( $field ); - $value = sanitize_text_field( $value ); + if ( is_array( $value ) ) { + $value = array_map( 'sanitize_text_field', $value ); + } else { + $value = sanitize_text_field( $value ); + } $attrs = UM()->fields()->get_field( $field ); // skip private invisible fields From 3555a3d2271560d6421bdf7d440045cb1eb81be9 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Mon, 5 Jul 2021 16:34:36 +0300 Subject: [PATCH 11/29] - fixed count of restricted posts; --- includes/core/class-access.php | 38 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 840f8674..37c5e20d 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -51,11 +51,12 @@ if ( ! class_exists( 'um\core\Access' ) ) { $this->redirect_handler = false; $this->allow_access = false; + add_filter( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 ); + //there is posts (Posts/Page/CPT) filtration if site is accessible //there also will be redirects if they need //protect posts types add_filter( 'the_posts', array( &$this, 'filter_protected_posts' ), 99, 2 ); - add_filter( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 ); //protect pages for wp_list_pages func add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 ); //filter menu items @@ -505,9 +506,10 @@ if ( ! class_exists( 'um\core\Access' ) ) { * } * ?> */ - $enable_referer = apply_filters( "um_access_enable_referer", false ); - if ( ! $enable_referer ) + $enable_referer = apply_filters( 'um_access_enable_referer', false ); + if ( ! $enable_referer ) { return $url; + } $url = add_query_arg( 'um_ref', $referer, $url ); return $url; @@ -542,10 +544,14 @@ if ( ! class_exists( 'um\core\Access' ) ) { * return false if post is not private * Restrict content new logic * - * @param $post + * @param \WP_Post|int $post Post ID or object * @return bool|array */ function get_post_privacy_settings( $post ) { + if ( is_numeric( $post ) ) { + $post = get_post( $post ); + } + $exclude = false; //if logged in administrator all pages are visible @@ -1017,26 +1023,28 @@ if ( ! class_exists( 'um\core\Access' ) ) { /** * Exclude posts from query * - * @param $query + * @param \WP_Query $query */ function exclude_posts( $query ) { - if( $query->is_main_query() ){ + if ( $query->is_main_query() ) { global $wpdb; + $exclude_posts = array(); $posts = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'um_content_restriction'"); foreach ( $posts as $post ) { - $content_restriction = get_post_meta( $post, 'um_content_restriction', true ); + $content_restriction = $this->get_post_privacy_settings( $post ); - if ( is_user_logged_in() && $content_restriction['_um_custom_access_settings'] == 1 && $content_restriction['_um_accessible'] == 1 ) { - array_push( $exclude_posts, $post ); + if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) { + if ( $this->is_restricted( $post ) ) { + array_push( $exclude_posts, $post ); + } } - if ( ! is_user_logged_in() && $content_restriction['_um_custom_access_settings'] == 1 && $content_restriction['_um_accessible'] == 2 ) { - array_push( $exclude_posts, $post ); - } - } - $query->set('post__not_in', $exclude_posts ); + if ( ! empty( $exclude_posts ) ) { + $post__not_in = $query->get( 'post__not_in', array() ); + $query->set( 'post__not_in', array_merge( $post__not_in, $exclude_posts ) ); + } } } @@ -1231,7 +1239,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { $restricted = false; } elseif ( '1' == $restriction[ '_um_accessible' ] ) { //if post for not logged in users and user is not logged in - if ( !is_user_logged_in() ) { + if ( ! is_user_logged_in() ) { $restricted = false; } else { From c45ba990d09e2588d9218bb55e76fbbbdb25b6b9 Mon Sep 17 00:00:00 2001 From: ashubawork <43743394+ashubawork@users.noreply.github.com> Date: Tue, 6 Jul 2021 11:26:57 +0300 Subject: [PATCH 12/29] - hide post in navigation to the next/previous post (issue #859) --- includes/core/class-access.php | 62 ++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 37c5e20d..ebaceb87 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -52,6 +52,8 @@ if ( ! class_exists( 'um\core\Access' ) ) { $this->allow_access = false; add_filter( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 ); + add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); + add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); //there is posts (Posts/Page/CPT) filtration if site is accessible //there also will be redirects if they need @@ -1027,20 +1029,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { */ function exclude_posts( $query ) { if ( $query->is_main_query() ) { - global $wpdb; - - $exclude_posts = array(); - $posts = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'um_content_restriction'"); - foreach ( $posts as $post ) { - $content_restriction = $this->get_post_privacy_settings( $post ); - - if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) { - if ( $this->is_restricted( $post ) ) { - array_push( $exclude_posts, $post ); - } - } - } - + $exclude_posts = $this->exclude_posts_array(); if ( ! empty( $exclude_posts ) ) { $post__not_in = $query->get( 'post__not_in', array() ); $query->set( 'post__not_in', array_merge( $post__not_in, $exclude_posts ) ); @@ -1049,6 +1038,51 @@ if ( ! class_exists( 'um\core\Access' ) ) { } + /** + * Exclude posts from next, previous navigation + * + * @param string $where + * @param bool $in_same_term + * @param array $excluded_terms + * @param string $taxonomy. + * @param WP_Post $post + * + * @return string + */ + function exclude_navigation_posts( $where, $in_same_term, $excluded_terms, $taxonomy, $post ){ + $exclude_posts = $this->exclude_posts_array(); + if ( ! empty( $exclude_posts ) ) { + $exclude_string = implode(',', $exclude_posts); + $where .= ' AND ID NOT IN ( ' . $exclude_string . ' )'; + } + + return $where; + } + + + /** + * get array with restricted posts + * + */ + function exclude_posts_array() { + global $wpdb; + + $exclude_posts = array(); + $posts = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'um_content_restriction'"); + foreach ( $posts as $post ) { + $content_restriction = $this->get_post_privacy_settings( $post ); + + if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) { + if ( $this->is_restricted( $post ) ) { + array_push( $exclude_posts, $post ); + } + } + } + + return $exclude_posts; + } + + /** * @param string $single_template * From ef0f9ad946bec122f86f76f833031c728273f751 Mon Sep 17 00:00:00 2001 From: ashubawork <43743394+ashubawork@users.noreply.github.com> Date: Tue, 6 Jul 2021 12:00:00 +0300 Subject: [PATCH 13/29] - hide restricted posts in widgets - hide comments from restricted posts in widgets --- includes/core/class-access.php | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index ebaceb87..c09bef14 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -54,6 +54,8 @@ if ( ! class_exists( 'um\core\Access' ) ) { add_filter( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 ); add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); + add_filter( 'widget_comments_args', array( &$this, 'exclude_comments_resticted_posts_widget' ), 99, 1 ); + add_filter( 'widget_posts_args', array( &$this, 'exclude_resticted_posts_widget' ), 99, 1 ); //there is posts (Posts/Page/CPT) filtration if site is accessible //there also will be redirects if they need @@ -1049,7 +1051,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { * * @return string */ - function exclude_navigation_posts( $where, $in_same_term, $excluded_terms, $taxonomy, $post ){ + function exclude_navigation_posts( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) { $exclude_posts = $this->exclude_posts_array(); if ( ! empty( $exclude_posts ) ) { $exclude_string = implode(',', $exclude_posts); @@ -1060,6 +1062,40 @@ if ( ! class_exists( 'um\core\Access' ) ) { } + /** + * Exclude comments from restricted posts in widgets + * + * @param array $array + * + * @return array + */ + function exclude_comments_resticted_posts_widget( $array ) { + $exclude_posts = $this->exclude_posts_array(); + if ( ! empty( $exclude_posts ) ) { + $array['post__not_in'] = $exclude_posts; + } + + return $array; + } + + + /** + * Exclude restricted posts in widgets + * + * @param array $array + * + * @return array + */ + function exclude_resticted_posts_widget( $array ) { + $exclude_posts = $this->exclude_posts_array(); + if ( ! empty( $exclude_posts ) ) { + $array['post__not_in'] = $exclude_posts; + } + + return $array; + } + + /** * get array with restricted posts * From a5b2e6a7ef02130e01db6beb3abdb73308f70b42 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Tue, 6 Jul 2021 12:31:09 +0300 Subject: [PATCH 14/29] - fixed security issue with email templates content; --- includes/admin/core/class-admin-settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 77b31d4a..fa6183c7 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -3382,7 +3382,7 @@ Use Only Cookies: mail()->get_template_file( 'theme', $template ); From 2712cb760af48a692c45dd5e5a9bee6a111cd6f2 Mon Sep 17 00:00:00 2001 From: ashubawork <43743394+ashubawork@users.noreply.github.com> Date: Tue, 6 Jul 2021 12:55:25 +0300 Subject: [PATCH 15/29] - changed a hook for hide restricted post's comments --- includes/core/class-access.php | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index c09bef14..3e2c311f 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -52,9 +52,9 @@ if ( ! class_exists( 'um\core\Access' ) ) { $this->allow_access = false; add_filter( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 ); + add_filter( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 ); add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); - add_filter( 'widget_comments_args', array( &$this, 'exclude_comments_resticted_posts_widget' ), 99, 1 ); add_filter( 'widget_posts_args', array( &$this, 'exclude_resticted_posts_widget' ), 99, 1 ); //there is posts (Posts/Page/CPT) filtration if site is accessible @@ -1040,6 +1040,20 @@ if ( ! class_exists( 'um\core\Access' ) ) { } + /** + * Exclude comments from restricted posts in widgets + * + * @param \WP_Comment_Query $query + * + */ + function exclude_posts_comments( $query ){ + $exclude_posts = $this->exclude_posts_array(); + if ( ! empty( $exclude_posts ) ) { + $query->query_vars['post__not_in'] = $exclude_posts; + } + } + + /** * Exclude posts from next, previous navigation * @@ -1062,23 +1076,6 @@ if ( ! class_exists( 'um\core\Access' ) ) { } - /** - * Exclude comments from restricted posts in widgets - * - * @param array $array - * - * @return array - */ - function exclude_comments_resticted_posts_widget( $array ) { - $exclude_posts = $this->exclude_posts_array(); - if ( ! empty( $exclude_posts ) ) { - $array['post__not_in'] = $exclude_posts; - } - - return $array; - } - - /** * Exclude restricted posts in widgets * From c11e8bf993ff670d22e6e4f1aeb123dbda1ae906 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Tue, 6 Jul 2021 13:17:53 +0300 Subject: [PATCH 16/29] - fixed saving Access admin settings; --- includes/admin/assets/js/um-admin-forms.js | 5 ++-- includes/admin/core/class-admin-forms.php | 7 +++--- includes/admin/core/class-admin-settings.php | 25 +++++++++++++++++++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/includes/admin/assets/js/um-admin-forms.js b/includes/admin/assets/js/um-admin-forms.js index 1299c920..2040a02a 100644 --- a/includes/admin/assets/js/um-admin-forms.js +++ b/includes/admin/assets/js/um-admin-forms.js @@ -557,7 +557,6 @@ jQuery(document).ready( function() { jQuery( '.um-multi-text-add-option' ).on('click', function() { var list = jQuery(this).siblings( 'ul.um-multi-text-list' ); - var field_id = list.data( 'field_id' ); var k = 0; if ( list.find( 'li:last input.um-forms-field' ).length > 0 ) { k = list.find( 'li:last input.um-forms-field' ).attr('id').split("-"); @@ -566,7 +565,7 @@ jQuery(document).ready( function() { var text_html = jQuery( '
' ).append( list.siblings('.um-hidden-multi-text').clone() ).html(); - var classes = list.find('li:last').attr('class'); + var classes = list.data('item_class'); list.append( '
  • ' + text_html + @@ -986,4 +985,4 @@ jQuery(document).ready( function() { return false; } -}); \ No newline at end of file +}); diff --git a/includes/admin/core/class-admin-forms.php b/includes/admin/core/class-admin-forms.php index 1a0c23e7..fffb49a9 100644 --- a/includes/admin/core/class-admin-forms.php +++ b/includes/admin/core/class-admin-forms.php @@ -1151,8 +1151,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { $class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" '; $data = array( - 'field_id' => $field_data['id'], - 'id_attr' => $id + 'field_id' => $field_data['id'], + 'id_attr' => $id, + 'item_class' => "um-multi-text-option-line {$size}", ); $data_attr = ''; @@ -1604,4 +1605,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { return $value; } } -} \ 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 fa6183c7..a63f4dd7 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -83,6 +83,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) ); add_action( 'um_settings_save', array( $this, 'licenses_save' ) ); + add_filter( 'um_change_settings_before_save', array( $this, 'set_default_if_empty' ), 9, 1 ); add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 ); add_action( 'admin_init', array( &$this, 'um_download_install_info' ) ); @@ -487,7 +488,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { '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, + 'show_default_number' => 0, ), array( 'id' => 'home_page_accessible', @@ -2204,6 +2205,28 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { } + function set_default_if_empty( $settings ) { + $tab = ''; + if ( ! empty( $_GET['tab'] ) ) { + $tab = sanitize_key( $_GET['tab'] ); + } + + $section = ''; + if ( ! empty( $_GET['section'] ) ) { + $section = sanitize_key( $_GET['section'] ); + } + + + if ( 'access' === $tab && empty( $section ) ) { + if ( ! array_key_exists( 'access_exclude_uris', $settings ) ) { + $settings['access_exclude_uris'] = array(); + } + } + + return $settings; + } + + /** * Remove empty values from multi text fields * From b021a2e8812bcd1cab67a28deade8a313b17ddbc Mon Sep 17 00:00:00 2001 From: ashubawork <43743394+ashubawork@users.noreply.github.com> Date: Tue, 6 Jul 2021 13:50:51 +0300 Subject: [PATCH 17/29] - fixed restricted posts for comments --- includes/core/class-access.php | 52 ++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 3e2c311f..4349ee7e 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -1031,7 +1031,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { */ function exclude_posts( $query ) { if ( $query->is_main_query() ) { - $exclude_posts = $this->exclude_posts_array(); + $exclude_posts = $this->exclude_posts_array( true ); if ( ! empty( $exclude_posts ) ) { $post__not_in = $query->get( 'post__not_in', array() ); $query->set( 'post__not_in', array_merge( $post__not_in, $exclude_posts ) ); @@ -1047,13 +1047,38 @@ if ( ! class_exists( 'um\core\Access' ) ) { * */ function exclude_posts_comments( $query ){ - $exclude_posts = $this->exclude_posts_array(); + $exclude_posts = $this->exclude_posts_array( false ); if ( ! empty( $exclude_posts ) ) { $query->query_vars['post__not_in'] = $exclude_posts; } } + /** + * get array with restricted posts + * + * @param boolean $in_query + * + * @return array + */ + function exclude_posts_array( $in_query = false ) { + global $wpdb; + + $exclude_posts = array(); + $posts = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'um_content_restriction'"); + foreach ( $posts as $post ) { + $content_restriction = $this->get_post_privacy_settings( $post ); + if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) || $in_query === false ) { + if ( $this->is_restricted( $post ) ) { + array_push( $exclude_posts, $post ); + } + } + } + + return $exclude_posts; + } + + /** * Exclude posts from next, previous navigation * @@ -1093,29 +1118,6 @@ if ( ! class_exists( 'um\core\Access' ) ) { } - /** - * get array with restricted posts - * - */ - function exclude_posts_array() { - global $wpdb; - - $exclude_posts = array(); - $posts = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'um_content_restriction'"); - foreach ( $posts as $post ) { - $content_restriction = $this->get_post_privacy_settings( $post ); - - if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) { - if ( $this->is_restricted( $post ) ) { - array_push( $exclude_posts, $post ); - } - } - } - - return $exclude_posts; - } - - /** * @param string $single_template * From d7148e820e7c2ff871ba8f9e532ccb946f6189b3 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Tue, 6 Jul 2021 14:07:38 +0300 Subject: [PATCH 18/29] - code review; --- includes/core/class-access.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 4349ee7e..39e38023 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -51,11 +51,11 @@ if ( ! class_exists( 'um\core\Access' ) ) { $this->redirect_handler = false; $this->allow_access = false; - add_filter( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 ); - add_filter( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 ); + add_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 ); + add_action( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 ); add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); - add_filter( 'widget_posts_args', array( &$this, 'exclude_resticted_posts_widget' ), 99, 1 ); + add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99, 1 ); //there is posts (Posts/Page/CPT) filtration if site is accessible //there also will be redirects if they need @@ -1031,7 +1031,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { */ function exclude_posts( $query ) { if ( $query->is_main_query() ) { - $exclude_posts = $this->exclude_posts_array( true ); + $exclude_posts = $this->exclude_posts_array(); if ( ! empty( $exclude_posts ) ) { $post__not_in = $query->get( 'post__not_in', array() ); $query->set( 'post__not_in', array_merge( $post__not_in, $exclude_posts ) ); @@ -1046,7 +1046,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { * @param \WP_Comment_Query $query * */ - function exclude_posts_comments( $query ){ + function exclude_posts_comments( $query ) { $exclude_posts = $this->exclude_posts_array( false ); if ( ! empty( $exclude_posts ) ) { $query->query_vars['post__not_in'] = $exclude_posts; @@ -1057,18 +1057,19 @@ if ( ! class_exists( 'um\core\Access' ) ) { /** * get array with restricted posts * - * @param boolean $in_query + * @param bool $in_query * * @return array */ - function exclude_posts_array( $in_query = false ) { + function exclude_posts_array( $in_query = true ) { global $wpdb; $exclude_posts = array(); $posts = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'um_content_restriction'"); foreach ( $posts as $post ) { $content_restriction = $this->get_post_privacy_settings( $post ); - if ( ! empty( $content_restriction['_um_access_hide_from_queries'] ) || $in_query === false ) { + + if ( false === $in_query || ! empty( $content_restriction['_um_access_hide_from_queries'] ) ) { if ( $this->is_restricted( $post ) ) { array_push( $exclude_posts, $post ); } @@ -1086,14 +1087,14 @@ if ( ! class_exists( 'um\core\Access' ) ) { * @param bool $in_same_term * @param array $excluded_terms * @param string $taxonomy. - * @param WP_Post $post + * @param \WP_Post $post * * @return string */ function exclude_navigation_posts( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) { $exclude_posts = $this->exclude_posts_array(); if ( ! empty( $exclude_posts ) ) { - $exclude_string = implode(',', $exclude_posts); + $exclude_string = implode( ',', $exclude_posts ); $where .= ' AND ID NOT IN ( ' . $exclude_string . ' )'; } @@ -1108,7 +1109,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { * * @return array */ - function exclude_resticted_posts_widget( $array ) { + function exclude_restricted_posts_widget( $array ) { $exclude_posts = $this->exclude_posts_array(); if ( ! empty( $exclude_posts ) ) { $array['post__not_in'] = $exclude_posts; From 249406e826d367df3065546140f403d9bc9c878d Mon Sep 17 00:00:00 2001 From: ashubawork <43743394+ashubawork@users.noreply.github.com> Date: Wed, 7 Jul 2021 13:39:05 +0300 Subject: [PATCH 19/29] - exclude restricted post's comments from a comments feed --- includes/core/class-access.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 39e38023..c53f4ae3 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -56,6 +56,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99, 1 ); + add_filter( 'comment_feed_where', array( &$this, 'exclude_posts_comments_feed' ), 99, 2 ); //there is posts (Posts/Page/CPT) filtration if site is accessible //there also will be redirects if they need @@ -1054,6 +1055,25 @@ if ( ! class_exists( 'um\core\Access' ) ) { } + /** + * Exclude comments from comments feed + * + * @param string $where + * @param \WP_Query $query + * + * @return string + */ + function exclude_posts_comments_feed( $where, $query ){ + $exclude_posts = $this->exclude_posts_array( false ); + if ( ! empty( $exclude_posts ) ) { + $exclude_string = implode( ',', $exclude_posts ); + $where .= ' AND comment_post_ID NOT IN ( ' . $exclude_string . ' )'; + } + + return $where; + } + + /** * get array with restricted posts * From 78c476cbb3c837580bdca2cd28431cbe4070a34b Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Wed, 7 Jul 2021 14:56:36 +0300 Subject: [PATCH 20/29] - changed version; - code review; --- includes/core/class-access.php | 6 +++--- readme.txt | 10 +++++++++- ultimate-member.php | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index c53f4ae3..ddff6cd8 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -1058,12 +1058,12 @@ if ( ! class_exists( 'um\core\Access' ) ) { /** * Exclude comments from comments feed * - * @param string $where - * @param \WP_Query $query + * @param string $where + * @param \WP_Query $query * * @return string */ - function exclude_posts_comments_feed( $where, $query ){ + function exclude_posts_comments_feed( $where, $query ) { $exclude_posts = $this->exclude_posts_array( false ); if ( ! empty( $exclude_posts ) ) { $exclude_string = implode( ',', $exclude_posts ); diff --git a/readme.txt b/readme.txt index dcb1216e..92f1b261 100644 --- a/readme.txt +++ b/readme.txt @@ -155,9 +155,17 @@ The plugin works with popular caching plugins by automatically excluding Ultimat * To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0) * UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin -= 2.1.22: July xx, 2021 = += 2.2.0: July 20, 2021 = +* Enhancements: + - Added: Sanitizing handlers to the Ultimate Member > Settings forms' fields + - Added: Sanitizing handlers to the Ultimate Member > User Role Add/Edit forms' fields + - Added: Sanitizing handlers to the Ultimate Member > Forms forms' fields + - Added: Sanitizing handlers to the Ultimate Member > User Roles forms' fields + - Added: Sanitizing handlers to the Restriction Content forms' fields in the posts/pages/menus additional fields + +* Bugfixes: = 2.1.21: June 17, 2021 = diff --git a/ultimate-member.php b/ultimate-member.php index 4c3967c8..2f8da3c7 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.1.22-alpha +Version: 2.2.0-beta Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From 384ab3b98809ef7af962fd0b89204d3d005b06fe Mon Sep 17 00:00:00 2001 From: ashubawork <43743394+ashubawork@users.noreply.github.com> Date: Thu, 8 Jul 2021 11:26:35 +0300 Subject: [PATCH 21/29] - fixed is_um_screen() function for new a widgets admin area --- includes/admin/class-admin-functions.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/includes/admin/class-admin-functions.php b/includes/admin/class-admin-functions.php index 2796f70b..5d81583b 100644 --- a/includes/admin/class-admin-functions.php +++ b/includes/admin/class-admin-functions.php @@ -44,16 +44,18 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) { */ function is_um_screen() { global $current_screen; - $screen_id = $current_screen->id; $is_um_screen = false; - if ( strstr( $screen_id, 'ultimatemember') || - strstr( $screen_id, 'um_') || - strstr( $screen_id, 'user' ) || - strstr( $screen_id, 'profile' ) || - $screen_id == 'nav-menus' ) { - $is_um_screen = true; + if ( ! empty( $current_screen ) ) { + $screen_id = $current_screen->id; + if ( strstr( $screen_id, 'ultimatemember' ) || + strstr( $screen_id, 'um_' ) || + strstr( $screen_id, 'user' ) || + strstr( $screen_id, 'profile' ) || + $screen_id == 'nav-menus' ) { + $is_um_screen = true; + } } if ( $this->is_plugin_post_type() ) { From a2f8efb412c21ac5309ab4d4bcad192a89f79a6e Mon Sep 17 00:00:00 2001 From: yuriinalivaiko Date: Thu, 8 Jul 2021 12:43:05 +0300 Subject: [PATCH 22/29] =?UTF-8?q?Fix=20placeholder=20for=20the=20=E2=80=9C?= =?UTF-8?q?Confirm=20password=E2=80=9D=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/core/class-fields.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 6011bf5a..b9981db4 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -2389,8 +2389,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $output .= '
    get_atts( $key, $classes, $conditional, $data ) . '>'; if ( ! empty( $data['label_confirm_pass'] ) ) { - $data['label'] = __( $data['label_confirm_pass'], 'ultimate-member' ); - $output .= $this->field_label( $data['label'], $key, $data ); + $label_confirm_pass = __( $data['label_confirm_pass'], 'ultimate-member' ); + $output .= $this->field_label( $label_confirm_pass, $key, $data ); } elseif ( isset( $data['label'] ) ) { $data['label'] = __( $data['label'], 'ultimate-member' ); $output .= $this->field_label( sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ), $key, $data ); @@ -2409,9 +2409,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $name = $key; } - if( ! empty( $placeholder ) && ! isset( $data['label'] ) ){ - $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder ); - }else if( isset( $data['label'] ) ){ + if ( ! empty( $label_confirm_pass ) ) { + $placeholder = $label_confirm_pass; + } elseif( ! empty( $placeholder ) && ! isset( $data['label'] ) ) { + $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $placeholder ); + } elseif( isset( $data['label'] ) ) { $placeholder = sprintf( __( 'Confirm %s', 'ultimate-member' ), $data['label'] ); } From ccd5e09a0fb0812a713044b901d244725f79f1a2 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Thu, 8 Jul 2021 15:13:13 +0300 Subject: [PATCH 23/29] - added fixes for WP5.8 version; --- includes/admin/core/class-admin-enqueue.php | 11 ++++++++--- includes/widgets/class-um-search-widget.php | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/includes/admin/core/class-admin-enqueue.php b/includes/admin/core/class-admin-enqueue.php index bae17427..c6832df4 100644 --- a/includes/admin/core/class-admin-enqueue.php +++ b/includes/admin/core/class-admin-enqueue.php @@ -83,7 +83,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { add_action( 'load-post-new.php', array( &$this, 'enqueue_cpt_scripts' ) ); add_action( 'load-post.php', array( &$this, 'enqueue_cpt_scripts' ) ); - add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 ); + global $wp_version; + if ( version_compare( $wp_version, '5.8-rc.1', '>=' ) ) { + add_filter( 'block_categories_all', array( &$this, 'blocks_category' ), 10, 2 ); + } else { + add_filter( 'block_categories', array( &$this, 'blocks_category' ), 10, 2 ); + } } @@ -527,11 +532,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Add Gutenberg category for UM shortcodes * * @param array $categories - * @param $post + * @param \WP_Block_Editor_Context $context * * @return array */ - function blocks_category( $categories, $post ) { + function blocks_category( $categories, $context ) { $enable_blocks = UM()->options()->get( 'enable_blocks' ); if ( empty( $enable_blocks ) ) { return $categories; diff --git a/includes/widgets/class-um-search-widget.php b/includes/widgets/class-um-search-widget.php index 4ab48476..6c429757 100644 --- a/includes/widgets/class-um-search-widget.php +++ b/includes/widgets/class-um-search-widget.php @@ -41,7 +41,8 @@ class UM_Search_Widget extends \WP_Widget { */ public function widget( $args, $instance ) { - $title = apply_filters( 'widget_title', $instance['title'] ); + $title = array_key_exists( 'title', $instance ) ? $instance['title'] : ''; + $title = apply_filters( 'widget_title', $title ); // before and after widget arguments are defined by themes echo $args['before_widget']; @@ -107,4 +108,4 @@ class UM_Search_Widget extends \WP_Widget { return $instance; } -} \ No newline at end of file +} From 59461fb1139a664b1940884d66982072c577735a Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Mon, 12 Jul 2021 12:04:46 +0300 Subject: [PATCH 24/29] - added changelog; - changed version to 2.2.0 --- assets/js/um-account.min.js | 2 +- assets/js/um-modal.min.js | 2 +- assets/js/um-profile.min.js | 2 +- assets/js/um-raty.min.js | 2 +- assets/js/um-tipsy.min.js | 2 +- readme.txt | 12 ++++++++++++ ultimate-member.php | 2 +- 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/assets/js/um-account.min.js b/assets/js/um-account.min.js index 803c2ab3..3c9d18d0 100644 --- a/assets/js/um-account.min.js +++ b/assets/js/um-account.min.js @@ -1 +1 @@ -jQuery(document).ready(function(){var a=jQuery(".um-account-main").attr("data-current_tab");a&&(jQuery('.um-account-tab[data-tab="'+a+'"]').show(),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0)),jQuery(document.body).on("click",".um-account-side li a",function(a){a.preventDefault();var e=jQuery(this);e.parents("ul").find("li a").removeClass("current"),e.addClass("current");a=jQuery(this).attr("href"),e=jQuery(this).attr("data-tab");return jQuery('input[id="_um_account_tab"]:hidden').val(e),window.history.pushState("","",a),jQuery(".um-account-tab").hide(),jQuery('.um-account-tab[data-tab="'+e+'"]').fadeIn(),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-nav a").removeClass("current"),jQuery('.um-account-nav a[data-tab="'+e+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",e),!1}),jQuery(document.body).on("click",".um-account-nav a",function(a){a.preventDefault();var e=jQuery(this).attr("data-tab"),t=jQuery(this).parents("div"),a=jQuery(this);return jQuery('input[id="_um_account_tab"]:hidden').val(e),jQuery(".um-account-tab").hide(),a.hasClass("current")?(t.next(".um-account-tab").slideUp(),a.removeClass("current")):(t.next(".um-account-tab").slideDown(),a.parents("div").find("a").removeClass("current"),a.addClass("current")),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-side li a").removeClass("current"),jQuery('.um-account-side li a[data-tab="'+e+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",e),!1}),jQuery(document.body).on("click",".um-request-button",function(a){a.preventDefault();var e=jQuery(this).data("action"),t=jQuery("#"+e).val();jQuery(".um-field-area-response."+e).hide(),jQuery("#"+e).length&&""===t?jQuery(".um-field-error."+e).show():(jQuery(".um-field-error."+e).hide(),a={request_action:e,nonce:um_scripts.nonce},jQuery("#"+e).length&&(a.password=t),wp.ajax.send("um_request_user_data",{data:a,success:function(a){jQuery(".um-field-area-response."+e).text(a.answer).show()},error:function(a){console.log(a)}}))})}); \ No newline at end of file +jQuery(document).ready(function(){var a=jQuery(".um-account-main").attr("data-current_tab");a&&(jQuery('.um-account-tab[data-tab="'+a+'"]').show(),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0)),jQuery(document.body).on("click",".um-account-side li a",function(a){a.preventDefault();var e=jQuery(this);e.parents("ul").find("li a").removeClass("current"),e.addClass("current");var t=jQuery(this).attr("href"),u=jQuery(this).attr("data-tab");return jQuery('input[id="_um_account_tab"]:hidden').val(u),window.history.pushState("","",t),jQuery(".um-account-tab").hide(),jQuery('.um-account-tab[data-tab="'+u+'"]').fadeIn(),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-nav a").removeClass("current"),jQuery('.um-account-nav a[data-tab="'+u+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",u),!1}),jQuery(document.body).on("click",".um-account-nav a",function(a){a.preventDefault();var e=jQuery(this).attr("data-tab"),t=jQuery(this).parents("div"),u=jQuery(this);return jQuery('input[id="_um_account_tab"]:hidden').val(e),jQuery(".um-account-tab").hide(),u.hasClass("current")?(t.next(".um-account-tab").slideUp(),u.removeClass("current")):(t.next(".um-account-tab").slideDown(),u.parents("div").find("a").removeClass("current"),u.addClass("current")),jQuery(".um-account-tab:visible").find("input, select, textarea").filter(".um_account_inactive:disabled").removeClass("um_account_inactive").prop("disabled",!1).attr("disabled",!1),jQuery(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),jQuery(".um-account-side li a").removeClass("current"),jQuery('.um-account-side li a[data-tab="'+e+'"]').addClass("current"),wp.hooks.doAction("um_after_account_tab_changed",e),!1}),jQuery(document.body).on("click",".um-request-button",function(a){a.preventDefault();var e=jQuery(this).data("action"),t=jQuery("#"+e).val();if(jQuery(".um-field-area-response."+e).hide(),jQuery("#"+e).length&&""===t)jQuery(".um-field-error."+e).show();else{jQuery(".um-field-error."+e).hide();var u={request_action:e,nonce:um_scripts.nonce};jQuery("#"+e).length&&(u.password=t),wp.ajax.send("um_request_user_data",{data:u,success:function(a){jQuery(".um-field-area-response."+e).text(a.answer).show()},error:function(a){console.log(a)}})}})}); \ No newline at end of file diff --git a/assets/js/um-modal.min.js b/assets/js/um-modal.min.js index a4dbe3f7..980083c0 100644 --- a/assets/js/um-modal.min.js +++ b/assets/js/um-modal.min.js @@ -1 +1 @@ -jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal:not(:has(.um-form)) a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-modal .um-single-file-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-fileinfo a").attr("href"),e=a.find(".um-single-file-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:e,nonce:um_scripts.nonce},success:function(){a.find(".um-single-file-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-modal .um-single-image-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview img").attr("src"),e=a.find(".um-single-image-upload").data("set_mode");return jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:t,mode:e,nonce:um_scripts.nonce},success:function(){jQuery("img.cropper-hidden").cropper("destroy"),a.find(".um-single-image-preview img").attr("src",""),a.find(".um-single-image-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive()}}),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html();um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a);a=jQuery(".um-field[data-key="+e+"]").find(".um-single-fileinfo a").data("file");jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find('input[type="hidden"]').val(a)}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var a=jQuery(this),t=jQuery(this).attr("data-key"),e=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),i=e.find("img").attr("src"),r=e.attr("data-coord"),u=e.find("img").data("file"),m=0;jQuery(this).parents("#um_upload_single").data("user_id")&&(m=jQuery(this).parents("#um_upload_single").data("user_id"));var n=0,o="";1===jQuery('div.um-field-image[data-key="'+t+'"]').length&&(n=(e=jQuery('div.um-field-image[data-key="'+t+'"]').closest(".um-form")).find('input[name="form_id"]').val(),o=e.attr("data-mode")),r?(jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:wp.ajax.settings.url,type:"POST",dataType:"json",data:{action:"um_resize_image",src:i,coord:r,user_id:m,key:t,set_id:n,set_mode:o,nonce:um_scripts.nonce},success:function(e){e.success&&(d=new Date,"profile_photo"===t?jQuery(".um-profile-photo-img img").attr("src",e.data.image.source_url+"?"+d.getTime()):"cover_photo"===t&&(jQuery(".um-cover-e").empty().html(''),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",e.data.image.source_url+"?"+d.getTime()),um_remove_modal(),jQuery("img.cropper-invisible").remove(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find('input[type="hidden"]').val(e.data.image.filename))}})):(d=new Date,jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",i+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find("input[type=hidden]").val(u))}),jQuery(document.body).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";jQuery(this).data("modal-size")&&(t=jQuery(this).data("modal-size")),jQuery(this).data("modal-copy")&&(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),0'),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",e.data.image.source_url+"?"+d.getTime()),um_remove_modal(),jQuery("img.cropper-invisible").remove(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find('input[type="hidden"]').val(e.data.image.filename))}})):(d=new Date,jQuery(".um-single-image-preview[data-key="+t+"]").fadeIn().find("img").attr("src",i+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find(".um-btn-auto-width").html(a.attr("data-change")),jQuery(".um-single-image-preview[data-key="+t+"]").parents(".um-field").find("input[type=hidden]").val(u))}),jQuery(document.body).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal"),t="normal";jQuery(this).data("modal-size")&&(t=jQuery(this).data("modal-size")),jQuery(this).data("modal-copy")&&(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),0'),um_responsive(),user_id=jQuery(this).attr("data-user_id"),metakey="cover_photo",jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_cover_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce},success:function(e){r.hide()}}),UM.dropdown.hideAll(),!1}),jQuery(document.body).on("change, keyup",'textarea[id="um-meta-bio"]',function(){var e;void 0!==jQuery(this).val()&&(e=jQuery(this).attr("data-character-limit")-jQuery(this).val().length,jQuery("span.um-meta-bio-character span.um-bio-limit").text(e),e<5?jQuery("span.um-meta-bio-character").css("color","red"):jQuery("span.um-meta-bio-character").css("color",""))}),jQuery('textarea[id="um-meta-bio"]').trigger("change"),jQuery(".um-profile-edit a.um_delete-item").on("click",function(e){if(e.preventDefault(),!confirm(wp.i18n.__("Are you sure that you want to delete this user?","ultimate-member")))return!1}),jQuery(".um-profile-nav a").on("touchend",function(e){jQuery(e.currentTarget).trigger("click")})}); \ No newline at end of file +jQuery(document).ready(function(){jQuery(".um-profile.um-viewing .um-profile-body .um-row").each(function(){var e=jQuery(this);0==e.find(".um-field").length&&(e.prev(".um-row-heading").remove(),e.remove())}),jQuery(".um-profile.um-viewing .um-profile-body").length&&0==jQuery(".um-profile.um-viewing .um-profile-body").find(".um-field").length&&(jQuery(".um-profile.um-viewing .um-profile-body").find(".um-row-heading,.um-row").remove(),jQuery(".um-profile-note").show()),jQuery(document.body).on("click",".um-profile-save",function(e){return e.preventDefault(),jQuery(this).parents(".um").find("form").trigger("submit"),!1}),jQuery(document.body).on("click",".um-profile-edit-a",function(e){jQuery(this).addClass("active")}),jQuery(document.body).on("click",".um-cover a.um-cover-add, .um-photo a",function(e){e.preventDefault()}),jQuery(document.body).on("click",".um-photo-modal",function(e){e.preventDefault();var r=jQuery(this).attr("data-src");return um_new_modal("um_view_photo","fit",!0,r),!1}),jQuery(document.body).on("click",".um-reset-profile-photo",function(e){return jQuery(".um-profile-photo-img img").attr("src",jQuery(this).attr("data-default_src")),user_id=jQuery(this).attr("data-user_id"),metakey="profile_photo",UM.dropdown.hideAll(),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_profile_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce}}),jQuery(this).parents("li").hide(),!1}),jQuery(document.body).on("click",".um-reset-cover-photo",function(e){var r=jQuery(this);return jQuery(".um-cover-overlay").hide(),jQuery(".um-cover-e").html(''),um_responsive(),user_id=jQuery(this).attr("data-user_id"),metakey="cover_photo",jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_delete_cover_photo",metakey:metakey,user_id:user_id,nonce:um_scripts.nonce},success:function(e){r.hide()}}),UM.dropdown.hideAll(),!1}),jQuery(document.body).on("change, keyup",'textarea[id="um-meta-bio"]',function(){if(void 0!==jQuery(this).val()){var e=jQuery(this).attr("data-character-limit")-jQuery(this).val().length;jQuery("span.um-meta-bio-character span.um-bio-limit").text(e),e<5?jQuery("span.um-meta-bio-character").css("color","red"):jQuery("span.um-meta-bio-character").css("color","")}}),jQuery('textarea[id="um-meta-bio"]').trigger("change"),jQuery(".um-profile-edit a.um_delete-item").on("click",function(e){if(e.preventDefault(),!confirm(wp.i18n.__("Are you sure that you want to delete this user?","ultimate-member")))return!1}),jQuery(".um-profile-nav a").on("touchend",function(e){jQuery(e.currentTarget).trigger("click")})}); \ No newline at end of file diff --git a/assets/js/um-raty.min.js b/assets/js/um-raty.min.js index 22e99ddd..8762e6d4 100644 --- a/assets/js/um-raty.min.js +++ b/assets/js/um-raty.min.js @@ -1 +1 @@ -!function(i){"use strict";var r={init:function(t){return this.each(function(){this.self=i(this),r.destroy.call(this.self),this.opt=i.extend(!0,{},i.fn.um_raty.defaults,t),r._adjustCallback.call(this),r._adjustNumber.call(this),"img"!==this.opt.starType&&r._adjustStarType.call(this),r._adjustPath.call(this),r._createStars.call(this),this.opt.cancel&&r._createCancel.call(this),this.opt.precision&&r._adjustPrecision.call(this),r._createScore.call(this),r._apply.call(this,this.opt.score),r._target.call(this,this.opt.score),this.opt.readOnly?r._lock.call(this):(this.style.cursor="pointer",r._binds.call(this)),this.self.data("options",this.opt)})},_adjustCallback:function(){for(var t=["number","readOnly","score","scoreName","target"],e=0;e",{name:this.opt.scoreName,type:"hidden"}).appendTo(this)},_createCancel:function(){var t=this.opt.path+this.opt.cancelOff,e=i("<"+this.opt.starType+" />",{title:this.opt.cancelHint,class:this.opt.cancelClass});"img"===this.opt.starType?e.attr({src:t,alt:"x"}):e.attr("data-alt","x").addClass(t),"left"===this.opt.cancelPlace?this.self.prepend(" ").prepend(e):this.self.append(" ").append(e),this.cancel=e},_createScore:function(){var t=i(this.opt.targetScore);this.score=t.length?t:r._buildScoreField.call(this)},_createStars:function(){for(var t=1;t<=this.opt.number;t++){var e=r._nameForIndex.call(this,t),e={alt:t,src:this.opt.path+this.opt[e]};(e="img"!==this.opt.starType?{"data-alt":t,class:e.src}:e).title=r._getHint.call(this,t),i("<"+this.opt.starType+" />",e).appendTo(this),this.opt.space&&this.self.append(te?(s=this.opt.iconRange[e],i=r._getRangeIcon.call(this,s,n),a<=s.range&&r._setIcon.call(this,o,i),a===s.range&&e++):(i=this.opt[n?"starOn":"starOff"],r._setIcon.call(this,o,i))}},_getRangeIcon:function(t,e){return e?t.on||this.opt.starOn:t.off||this.opt.starOff},_getScoreByPosition:function(t,e){var a,s=parseInt(e.alt||e.getAttribute("data-alt"),10);return this.opt.half&&(a=r._getSize.call(this),a=parseFloat((t.pageX-i(e).offset().left)/a),s=this.opt.precision?s-1+a:s-1+(.5=t?"starOn":"starOff"},_roundStars:function(t){var e,a=(t%1).toFixed(2);a>this.opt.round.down&&(e="starOn",this.opt.halfShow&&a=e.number&&(t=e.number-1,a=10);e=r._getSize.call(this)/10,t=i(this.stars[t]),a=t.offset().left+e*parseInt(a,10),a=i.Event("mousemove",{pageX:a});t.trigger(a)})},readOnly:function(e){return this.each(function(){var t=i(this);t.data("readonly")!==e&&(e?(t.off(".um_raty").children("img").off(".um_raty"),r._lock.call(this)):(r._binds.call(this),r._unlock.call(this)),t.data("readonly",e))})},reload:function(){return r.set.call(this,{})},score:function(){var t=i(this);return arguments.length?r.setScore.apply(t,arguments):r.getScore.call(t)},set:function(a){return this.each(function(){var t=i(this),e=t.data("options"),e=i.extend({},e,a);t.um_raty(e)})},setScore:function(t){return this.each(function(){!0!==i(this).data("readonly")&&(r._apply.call(this,t),r._target.call(this,t))})}};i.fn.um_raty=function(t){return r[t]?r[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void i.error("Method "+t+" does not exist!"):r.init.apply(this,arguments)},i.fn.um_raty.defaults={cancel:!1,cancelClass:"raty-cancel",cancelHint:wp.i18n.__("Cancel this rating!","ultimate-member"),cancelOff:"cancel-off.png",cancelOn:"cancel-on.png",cancelPlace:"left",click:void 0,half:!1,halfShow:!0,hints:["bad","poor","regular","good","gorgeous"],iconRange:void 0,mouseout:void 0,mouseover:void 0,noRatedMsg:wp.i18n.__("Not rated yet!","ultimate-member"),number:5,numberMax:20,path:void 0,precision:!1,readOnly:!1,round:{down:.25,full:.6,up:.76},score:void 0,scoreName:"score",single:!1,space:!0,starHalf:"star-half.png",starOff:"star-off.png",starOn:"star-on.png",starType:"img",target:void 0,targetFormat:"{score}",targetKeep:!1,targetScore:void 0,targetText:"",targetType:"hint"}}(jQuery); \ No newline at end of file +!function(l){"use strict";var c={init:function(t){return this.each(function(){this.self=l(this),c.destroy.call(this.self),this.opt=l.extend(!0,{},l.fn.um_raty.defaults,t),c._adjustCallback.call(this),c._adjustNumber.call(this),"img"!==this.opt.starType&&c._adjustStarType.call(this),c._adjustPath.call(this),c._createStars.call(this),this.opt.cancel&&c._createCancel.call(this),this.opt.precision&&c._adjustPrecision.call(this),c._createScore.call(this),c._apply.call(this,this.opt.score),c._target.call(this,this.opt.score),this.opt.readOnly?c._lock.call(this):(this.style.cursor="pointer",c._binds.call(this)),this.self.data("options",this.opt)})},_adjustCallback:function(){for(var t=["number","readOnly","score","scoreName","target"],e=0;e",{name:this.opt.scoreName,type:"hidden"}).appendTo(this)},_createCancel:function(){var t=this.opt.path+this.opt.cancelOff,e=l("<"+this.opt.starType+" />",{title:this.opt.cancelHint,class:this.opt.cancelClass});"img"===this.opt.starType?e.attr({src:t,alt:"x"}):e.attr("data-alt","x").addClass(t),"left"===this.opt.cancelPlace?this.self.prepend(" ").prepend(e):this.self.append(" ").append(e),this.cancel=e},_createScore:function(){var t=l(this.opt.targetScore);this.score=t.length?t:c._buildScoreField.call(this)},_createStars:function(){for(var t=1;t<=this.opt.number;t++){var e=c._nameForIndex.call(this,t),a={alt:t,src:this.opt.path+this.opt[e]};"img"!==this.opt.starType&&(a={"data-alt":t,class:a.src}),a.title=c._getHint.call(this,t),l("<"+this.opt.starType+" />",a).appendTo(this),this.opt.space&&this.self.append(te){var r=this.opt.iconRange[e];s=c._getRangeIcon.call(this,r,o),a<=r.range&&c._setIcon.call(this,i,s),a===r.range&&e++}else s=this.opt[o?"starOn":"starOff"],c._setIcon.call(this,i,s)}},_getRangeIcon:function(t,e){return e?t.on||this.opt.starOn:t.off||this.opt.starOff},_getScoreByPosition:function(t,e){var a=parseInt(e.alt||e.getAttribute("data-alt"),10);if(this.opt.half){var s=c._getSize.call(this),i=parseFloat((t.pageX-l(e).offset().left)/s);a=this.opt.precision?a-1+i:a-1+(.5=t?"starOn":"starOff"},_roundStars:function(t){var e=(t%1).toFixed(2);if(e>this.opt.round.down){var a="starOn";this.opt.halfShow&&e=e.number&&(t=e.number-1,a=10);var s=c._getSize.call(this)/10,i=l(this.stars[t]),o=i.offset().left+s*parseInt(a,10),r=l.Event("mousemove",{pageX:o});i.trigger(r)})},readOnly:function(e){return this.each(function(){var t=l(this);t.data("readonly")!==e&&(e?(t.off(".um_raty").children("img").off(".um_raty"),c._lock.call(this)):(c._binds.call(this),c._unlock.call(this)),t.data("readonly",e))})},reload:function(){return c.set.call(this,{})},score:function(){var t=l(this);return arguments.length?c.setScore.apply(t,arguments):c.getScore.call(t)},set:function(s){return this.each(function(){var t=l(this),e=t.data("options"),a=l.extend({},e,s);t.um_raty(a)})},setScore:function(t){return this.each(function(){!0!==l(this).data("readonly")&&(c._apply.call(this,t),c._target.call(this,t))})}};l.fn.um_raty=function(t){return c[t]?c[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void l.error("Method "+t+" does not exist!"):c.init.apply(this,arguments)},l.fn.um_raty.defaults={cancel:!1,cancelClass:"raty-cancel",cancelHint:wp.i18n.__("Cancel this rating!","ultimate-member"),cancelOff:"cancel-off.png",cancelOn:"cancel-on.png",cancelPlace:"left",click:void 0,half:!1,halfShow:!0,hints:["bad","poor","regular","good","gorgeous"],iconRange:void 0,mouseout:void 0,mouseover:void 0,noRatedMsg:wp.i18n.__("Not rated yet!","ultimate-member"),number:5,numberMax:20,path:void 0,precision:!1,readOnly:!1,round:{down:.25,full:.6,up:.76},score:void 0,scoreName:"score",single:!1,space:!0,starHalf:"star-half.png",starOff:"star-off.png",starOn:"star-on.png",starType:"img",target:void 0,targetFormat:"{score}",targetKeep:!1,targetScore:void 0,targetText:"",targetType:"hint"}}(jQuery); \ No newline at end of file diff --git a/assets/js/um-tipsy.min.js b/assets/js/um-tipsy.min.js index 30e79c8a..8a1f530e 100644 --- a/assets/js/um-tipsy.min.js +++ b/assets/js/um-tipsy.min.js @@ -1 +1 @@ -!function(a){function l(t,e){return"function"==typeof t?t.call(e):t}function h(t,e){this.$element=a(t),this.options=e,this.enabled=!0,this.fixTitle()}h.prototype={show:function(){var t=this.getTitle();if(t&&this.enabled){var e=this.tip();e.find(".tipsy-inner")[this.options.html?"html":"text"](t),e[0].className="tipsy",e.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).prependTo(document.body);var i,s=a.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight}),n=e[0].offsetWidth,o=e[0].offsetHeight,t=l(this.options.gravity,this.$element[0]);switch(t.charAt(0)){case"n":i={top:s.top+s.height+this.options.offset,left:s.left+s.width/2-n/2};break;case"s":i={top:s.top-o-this.options.offset,left:s.left+s.width/2-n/2};break;case"e":i={top:s.top+s.height/2-o/2,left:s.left-n-this.options.offset};break;case"w":(extra_gap=0)
    ').html('
    '),this.$tip.data("tipsy-pointee",this.$element[0])),this.$tip},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled}},a.fn.tipsy=function(i){if(!0===i)return this.data("tipsy");if("string"!=typeof i)return(i=a.extend({},a.fn.tipsy.defaults,i)).on||this.each(function(){e(this)}),"manual"!=i.trigger&&(n="hover"==i.trigger?"mouseenter":"focus",o="hover"==i.trigger?"mouseleave":"blur",i.on?a(document).on(n,this.selector,t).on(o,this.selector,s):this.on(n,t).on(o,s)),this;function e(t){var e=a.data(t,"tipsy");return e||(e=new h(t,a.fn.tipsy.elementOptions(t,i)),a.data(t,"tipsy",e)),e}function t(){var t=e(this);t.hoverState="in",0==i.delayIn?t.show():(t.fixTitle(),setTimeout(function(){"in"==t.hoverState&&t.show()},i.delayIn))}function s(){var t=e(this);t.hoverState="out",0==i.delayOut?t.hide():setTimeout(function(){"out"==t.hoverState&&t.hide()},i.delayOut)}var n,o=this.data("tipsy");return o&&o[i](),this},a.fn.tipsy.defaults={className:null,delayIn:0,delayOut:0,fade:!1,fallback:"",gravity:"n",html:!1,live:!1,offset:0,opacity:.8,title:"title",trigger:"hover"},a.fn.tipsy.revalidate=function(){a(".tipsy").each(function(){var t=a.data(this,"tipsy-pointee");t&&function(t){for(;t=t.parentNode;)if(t==document)return 1}(t)||a(this).remove()})},a.fn.tipsy.elementOptions=function(t,e){return a.metadata?a.extend({},e,a(t).metadata()):e},a.fn.tipsy.autoNS=function(){return a(this).offset().top>a(document).scrollTop()+a(window).height()/2?"s":"n"},a.fn.tipsy.autoWE=function(){return a(this).offset().left>a(document).scrollLeft()+a(window).width()/2?"e":"w"},a.fn.tipsy.autoBounds=function(n,o){return function(){var t={ns:o[0],ew:1
  • ').html('
    '),this.$tip.data("tipsy-pointee",this.$element[0])),this.$tip},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled}},l.fn.tipsy=function(i){if(!0===i)return this.data("tipsy");if("string"==typeof i){var t=this.data("tipsy");return t&&t[i](),this}function e(t){var e=l.data(t,"tipsy");return e||(e=new h(t,l.fn.tipsy.elementOptions(t,i)),l.data(t,"tipsy",e)),e}function s(){var t=e(this);t.hoverState="in",0==i.delayIn?t.show():(t.fixTitle(),setTimeout(function(){"in"==t.hoverState&&t.show()},i.delayIn))}function n(){var t=e(this);t.hoverState="out",0==i.delayOut?t.hide():setTimeout(function(){"out"==t.hoverState&&t.hide()},i.delayOut)}if((i=l.extend({},l.fn.tipsy.defaults,i)).on||this.each(function(){e(this)}),"manual"!=i.trigger){var o="hover"==i.trigger?"mouseenter":"focus",a="hover"==i.trigger?"mouseleave":"blur";i.on?l(document).on(o,this.selector,s).on(a,this.selector,n):this.on(o,s).on(a,n)}return this},l.fn.tipsy.defaults={className:null,delayIn:0,delayOut:0,fade:!1,fallback:"",gravity:"n",html:!1,live:!1,offset:0,opacity:.8,title:"title",trigger:"hover"},l.fn.tipsy.revalidate=function(){l(".tipsy").each(function(){var t=l.data(this,"tipsy-pointee");t&&function(t){for(;t=t.parentNode;)if(t==document)return!0;return!1}(t)||l(this).remove()})},l.fn.tipsy.elementOptions=function(t,e){return l.metadata?l.extend({},e,l(t).metadata()):e},l.fn.tipsy.autoNS=function(){return l(this).offset().top>l(document).scrollTop()+l(window).height()/2?"s":"n"},l.fn.tipsy.autoWE=function(){return l(this).offset().left>l(document).scrollLeft()+l(window).width()/2?"e":"w"},l.fn.tipsy.autoBounds=function(n,o){return function(){var t={ns:o[0],ew:1 Forms forms' fields - Added: Sanitizing handlers to the Ultimate Member > User Roles forms' fields - Added: Sanitizing handlers to the Restriction Content forms' fields in the posts/pages/menus additional fields + - Added: Custom placeholder setting for the Confirm Password field * Bugfixes: + - Fixed: Content restriction settings using in Avada theme with active page headers + - Fixed: Content restriction (CPT + Terms). Avoid displaying comments if the post is restricted + - Fixed: Content restriction (CPT + Terms). Avoid displaying comments and posts feed + - Fixed: Content restriction (CPT + Terms). Displaying the proper count of the posts. Restricted are excluded + - Fixed: Saving and displaying settings on the UM > Settings > Access screen + - Fixed: Saving and displaying default Member Directory settings + +* Tweaks: + + - WordPress 5.8 compatibility. Widgets screen changes based on the new features with Legacy Widget block + = 2.1.21: June 17, 2021 = * Enhancements: diff --git a/ultimate-member.php b/ultimate-member.php index 2f8da3c7..bf2e56a3 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.2.0-beta +Version: 2.2.0-rc.1 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From a6fa8ab3ea54c052256fb3728d30e9e736fdbde9 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Thu, 15 Jul 2021 13:50:23 +0300 Subject: [PATCH 25/29] - fixed sanitizing data on submit field data in wp-admin builder; --- includes/admin/class-admin.php | 376 ++++++++++++++++++++ includes/admin/core/class-admin-builder.php | 8 +- includes/core/class-builtin.php | 62 +++- readme.txt | 1 + 4 files changed, 424 insertions(+), 23 deletions(-) diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index fa204692..537cc9d8 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -46,6 +46,12 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { public $form_meta; + /** + * @var array + */ + public $builder_input; + + /** * @var array */ @@ -507,6 +513,300 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { ) ); + $this->builder_input = apply_filters( + 'um_builder_input_map', + array( + '_in_row' => array( + 'sanitize' => 'key', + ), + '_in_sub_row' => array( + 'sanitize' => 'absint', + ), + '_in_column' => array( + 'sanitize' => 'absint', + ), + '_in_group' => array( + 'sanitize' => 'absint', + ), + '_visibility' => array( + 'sanitize' => 'key', + ), + '_conditional_action' => array( + 'sanitize' => 'key', + ), + '_conditional_action1' => array( + 'sanitize' => 'key', + ), + '_conditional_action2' => array( + 'sanitize' => 'key', + ), + '_conditional_action3' => array( + 'sanitize' => 'key', + ), + '_conditional_action4' => array( + 'sanitize' => 'key', + ), + '_conditional_field' => array( + 'sanitize' => 'text', + ), + '_conditional_field1' => array( + 'sanitize' => 'text', + ), + '_conditional_field2' => array( + 'sanitize' => 'text', + ), + '_conditional_field3' => array( + 'sanitize' => 'text', + ), + '_conditional_field4' => array( + 'sanitize' => 'text', + ), + '_conditional_operator' => array( + 'sanitize' => 'text', + ), + '_conditional_operator1' => array( + 'sanitize' => 'text', + ), + '_conditional_operator2' => array( + 'sanitize' => 'text', + ), + '_conditional_operator3' => array( + 'sanitize' => 'text', + ), + '_conditional_operator4' => array( + 'sanitize' => 'text', + ), + '_conditional_value' => array( + 'sanitize' => 'text', + ), + '_conditional_value1' => array( + 'sanitize' => 'text', + ), + '_conditional_value2' => array( + 'sanitize' => 'text', + ), + '_conditional_value3' => array( + 'sanitize' => 'text', + ), + '_conditional_value4' => array( + 'sanitize' => 'text', + ), + '_validate' => array( + 'sanitize' => 'key', + ), + '_custom_validate' => array( + 'sanitize' => 'text', + ), + '_icon' => array( + 'sanitize' => 'key', + ), + '_css_class' => array( + 'sanitize' => 'text', + ), + '_width' => array( + 'sanitize' => 'absint', + ), + '_divider_text' => array( + 'sanitize' => 'text', + ), + '_padding' => array( + 'sanitize' => 'text', + ), + '_margin' => array( + 'sanitize' => 'text', + ), + '_border' => array( + 'sanitize' => 'text', + ), + '_borderstyle' => array( + 'sanitize' => 'key', + ), + '_borderradius' => array( + 'sanitize' => 'text', + ), + '_bordercolor' => array( + 'sanitize' => 'text', + ), + '_heading' => array( + 'sanitize' => 'bool', + ), + '_heading_text' => array( + 'sanitize' => 'text', + ), + '_background' => array( + 'sanitize' => 'text', + ), + '_heading_background_color' => array( + 'sanitize' => 'text', + ), + '_heading_text_color' => array( + 'sanitize' => 'text', + ), + '_text_color' => array( + 'sanitize' => 'text', + ), + '_icon_color' => array( + 'sanitize' => 'text', + ), + '_color' => array( + 'sanitize' => 'text', + ), + '_url_text' => array( + 'sanitize' => 'text', + ), + '_url_target' => array( + 'sanitize' => 'key', + ), + '_url_rel' => array( + 'sanitize' => 'key', + ), + '_force_good_pass' => array( + 'sanitize' => 'bool', + ), + '_force_confirm_pass' => array( + 'sanitize' => 'bool', + ), + '_style' => array( + 'sanitize' => 'key', + ), + '_intervals' => array( + 'sanitize' => 'absint', + ), + '_format' => array( + 'sanitize' => 'text', + ), + '_format_custom' => array( + 'sanitize' => 'text', + ), + '_pretty_format' => array( + 'sanitize' => 'bool', + ), + '_disabled_weekdays' => array( + 'sanitize' => 'absint', + ), + '_years' => array( + 'sanitize' => 'absint', + ), + '_years_x' => array( + 'sanitize' => 'key', + ), + '_range_start' => array( + 'sanitize' => 'text', + ), + '_range_end' => array( + 'sanitize' => 'text', + ), + '_range' => array( + 'sanitize' => 'key', + ), + '_content' => array( + 'sanitize' => 'textarea', + ), + '_crop' => array( + 'sanitize' => 'int', + ), + '_allowed_types' => array( + 'sanitize' => 'key', + ), + '_upload_text' => array( + 'sanitize' => 'text', + ), + '_upload_help_text' => array( + 'sanitize' => 'text', + ), + '_button_text' => array( + 'sanitize' => 'text', + ), + '_max_size' => array( + 'sanitize' => 'absint', + ), + '_height' => array( + 'sanitize' => 'text', + ), + '_spacing' => array( + 'sanitize' => 'text', + ), + '_is_multi' => array( + 'sanitize' => 'bool', + ), + '_max_selections' => array( + 'sanitize' => 'absint', + ), + '_min_selections' => array( + 'sanitize' => 'absint', + ), + '_max_entries' => array( + 'sanitize' => 'absint', + ), + '_max_words' => array( + 'sanitize' => 'absint', + ), + '_min' => array( + 'sanitize' => 'absint', + ), + '_max' => array( + 'sanitize' => 'absint', + ), + '_min_chars' => array( + 'sanitize' => 'absint', + ), + '_max_chars' => array( + 'sanitize' => 'absint', + ), + '_html' => array( + 'sanitize' => 'bool', + ), + '_options' => array( + 'sanitize' => 'textarea', + ), + '_title' => array( + 'sanitize' => 'text', + ), + '_id' => array( + 'sanitize' => 'text', + ), + '_metakey' => array( + 'sanitize' => 'text', + ), + '_help' => array( + 'sanitize' => 'text', + ), + '_default' => array( + 'sanitize' => 'text', + ), + '_label' => array( + 'sanitize' => 'text', + ), + '_label_confirm_pass' => array( + 'sanitize' => 'text', + ), + '_placeholder' => array( + 'sanitize' => 'text', + ), + '_public' => array( + 'sanitize' => 'text', + ), + '_roles' => array( + 'sanitize' => array( $this, 'sanitize_existed_role' ), + ), + '_required' => array( + 'sanitize' => 'bool', + ), + '_editable' => array( + 'sanitize' => 'bool', + ), + '_number' => array( + 'sanitize' => 'absint', + ), + '_custom_dropdown_options_source' => array( + 'sanitize' => 'text', + ), + '_parent_dropdown_relationship' => array( + 'sanitize' => 'text', + ), + ) + ); + add_action( 'admin_init', array( &$this, 'admin_init' ), 0 ); $prefix = is_network_admin() ? 'network_admin_' : ''; @@ -1016,6 +1316,82 @@ if ( ! class_exists( 'um\admin\Admin' ) ) { } + /** + * Sanitize builder field meta when wp-admin form has been submitted + * + * @todo checking all sanitize types + * + * @param array $data + * + * @return array + */ + public function sanitize_builder_field_meta( $data ) { + $sanitized = array(); + foreach ( $data as $k => $v ) { + if ( ! array_key_exists( $k, $this->builder_input ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( ! array_key_exists( 'sanitize', $this->builder_input[ $k ] ) ) { + // @todo remove since 2.2.x and leave only continue + $sanitized[ $k ] = $v; + continue; + } + + if ( is_callable( $this->builder_input[ $k ]['sanitize'], true, $callable_name ) ) { + add_filter( 'um_builder_input_sanitize_' . $k, $this->builder_input[ $k ]['sanitize'], 10, 1 ); + } + + switch ( $this->builder_input[ $k ]['sanitize'] ) { + default: + $sanitized[ $k ] = apply_filters( 'um_builder_input_sanitize_' . $k, $data[ $k ] ); + break; + case 'int': + $sanitized[ $k ] = (int) $v; + break; + case 'bool': + $sanitized[ $k ] = (bool) $v; + break; + case 'url': + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'esc_url_raw', $v ); + } else { + $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; + case 'key': + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'sanitize_key', $v ); + } else { + $sanitized[ $k ] = sanitize_key( $v ); + } + break; + case 'absint': + if ( is_array( $v ) ) { + $sanitized[ $k ] = array_map( 'absint', $v ); + } else { + $sanitized[ $k ] = absint( $v ); + } + break; + } + } + + $data = $sanitized; + + $data = apply_filters( 'um_save_builder_input_sanitize', $data ); + + return $data; + } + + /** * Sanitize form meta when wp-admin form has been submitted * diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php index 451bee1c..8221aaa0 100644 --- a/includes/admin/core/class-admin-builder.php +++ b/includes/admin/core/class-admin-builder.php @@ -615,10 +615,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { $output['error'] = null; $array = array( - 'field_type' => sanitize_key( $_POST['_type'] ), - 'form_id' => absint( $_POST['post_id'] ), - 'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ), - 'post' => $_POST + 'field_type' => sanitize_key( $_POST['_type'] ), + 'form_id' => absint( $_POST['post_id'] ), + 'args' => UM()->builtin()->get_core_field_attrs( sanitize_key( $_POST['_type'] ) ), + 'post' => UM()->admin()->sanitize_builder_field_meta( $_POST ), ); /** diff --git a/includes/core/class-builtin.php b/includes/core/class-builtin.php index 0445586c..f079113f 100644 --- a/includes/core/class-builtin.php +++ b/includes/core/class-builtin.php @@ -36,9 +36,9 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { * Builtin constructor. */ function __construct() { - add_action( 'init', array(&$this, 'set_core_fields'), 1); - add_action( 'init', array(&$this, 'set_predefined_fields'), 1); - add_action( 'init', array(&$this, 'set_custom_fields'), 1); + add_action( 'init', array( &$this, 'set_core_fields' ), 1 ); + add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 ); + add_action( 'init', array( &$this, 'set_custom_fields' ), 1 ); $this->saved_fields = get_option( 'um_fields' ); } @@ -61,13 +61,15 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { */ function is_dropdown_field( $field, $attrs ) { - if ( isset( $attrs['options'] ) ) + if ( isset( $attrs['options'] ) ) { return true; + } $fields = $this->all_user_fields; - if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) ) + if ( isset( $fields[$field]['options'] ) || ! empty( $fields[$field]['custom_dropdown_options_source'] ) ) { return true; + } return false; } @@ -134,14 +136,25 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { * * @param $key * - * @return int|string|void + * @return int|string */ function unique_field_err( $key ) { - if ( empty( $key ) ) return __('Please provide a meta key','ultimate-member'); - if ( isset( $this->core_fields[ $key ] ) ) return __('Your meta key is a reserved core field and cannot be used','ultimate-member'); - if ( isset( $this->predefined_fields[ $key ] ) ) return __('Your meta key is a predefined reserved key and cannot be used','ultimate-member'); - if ( isset( $this->saved_fields[ $key ] ) ) return __('Your meta key already exists in your fields list','ultimate-member'); - if ( ! UM()->validation()->safe_string( $key ) ) return __('Your meta key contains illegal characters. Please correct it.','ultimate-member'); + if ( empty( $key ) ) { + return __( 'Please provide a meta key', 'ultimate-member' ); + } + if ( isset( $this->core_fields[ $key ] ) ) { + return __( 'Your meta key is a reserved core field and cannot be used', 'ultimate-member' ); + } + if ( isset( $this->predefined_fields[ $key ] ) ) { + return __( 'Your meta key is a predefined reserved key and cannot be used', 'ultimate-member' ); + } + if ( isset( $this->saved_fields[ $key ] ) ) { + return __( 'Your meta key already exists in your fields list', 'ultimate-member' ); + } + if ( ! UM()->validation()->safe_string( $key ) ) { + return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' ); + } + return 0; } @@ -151,11 +164,16 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { * * @param $date * - * @return int|string|void + * @return int|string */ function date_range_start_err( $date ) { - if ( empty( $date ) ) return __('Please provide a date range beginning','ultimate-member'); - if ( ! UM()->validation()->validate_date( $date ) ) return __('Please enter a valid start date in the date range','ultimate-member'); + if ( empty( $date ) ) { + return __( 'Please provide a date range beginning', 'ultimate-member' ); + } + if ( ! UM()->validation()->validate_date( $date ) ) { + return __( 'Please enter a valid start date in the date range', 'ultimate-member' ); + } + return 0; } @@ -166,12 +184,18 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { * @param $date * @param $start_date * - * @return int|string|void + * @return int|string */ function date_range_end_err( $date, $start_date ) { - if ( empty( $date ) ) return __('Please provide a date range end','ultimate-member'); - if ( ! UM()->validation()->validate_date( $date ) ) return __('Please enter a valid end date in the date range','ultimate-member'); - if ( strtotime( $date ) <= strtotime( $start_date ) ) return __('The end of date range must be greater than the start of date range','ultimate-member'); + if ( empty( $date ) ) { + return __( 'Please provide a date range end', 'ultimate-member' ); + } + if ( ! UM()->validation()->validate_date( $date ) ) { + return __( 'Please enter a valid end date in the date range', 'ultimate-member' ); + } + if ( strtotime( $date ) <= strtotime( $start_date ) ) { + return __( 'The end of date range must be greater than the start of date range', 'ultimate-member' ); + } return 0; } @@ -1888,4 +1912,4 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { } } -} \ No newline at end of file +} diff --git a/readme.txt b/readme.txt index 5c8effa2..3e8deb9a 100644 --- a/readme.txt +++ b/readme.txt @@ -162,6 +162,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat - Added: Sanitizing handlers to the Ultimate Member > Settings forms' fields - Added: Sanitizing handlers to the Ultimate Member > User Role Add/Edit forms' fields - Added: Sanitizing handlers to the Ultimate Member > Forms forms' fields + - Added: Sanitizing handlers to the Ultimate Member > Forms > Add Field/Edit Field forms' fields - Added: Sanitizing handlers to the Ultimate Member > User Roles forms' fields - Added: Sanitizing handlers to the Restriction Content forms' fields in the posts/pages/menus additional fields - Added: Custom placeholder setting for the Confirm Password field From 415b7a8371533393e60c214986424a992b3da386 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Thu, 15 Jul 2021 15:22:16 +0300 Subject: [PATCH 26/29] - fixed frontend forms sanitizing; --- includes/core/class-form.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/core/class-form.php b/includes/core/class-form.php index ffb0f2ef..19975c1a 100644 --- a/includes/core/class-form.php +++ b/includes/core/class-form.php @@ -333,7 +333,7 @@ if ( ! class_exists( 'um\core\Form' ) ) { $this->form_id = absint( $_POST['form_id'] ); $this->form_status = get_post_status( $this->form_id ); - + $this->form_data = UM()->query()->post_data( $this->form_id ); if ( 'publish' !== $this->form_status ) { return; @@ -390,8 +390,6 @@ if ( ! class_exists( 'um\core\Form' ) ) { $this->post_form = $this->sanitize( $this->post_form ); $this->post_form['submitted'] = $this->post_form; - $this->form_data = UM()->query()->post_data( $this->form_id ); - $this->post_form = array_merge( $this->form_data, $this->post_form ); // Remove role from post_form at first if role ! empty and there aren't custom fields with role name @@ -562,12 +560,14 @@ if ( ! class_exists( 'um\core\Form' ) ) { * @return array $form */ public function sanitize( $form ) { + if ( isset( $form['form_id'] ) ) { if ( isset( $this->form_data['custom_fields'] ) ) { $custom_fields = maybe_unserialize( $this->form_data['custom_fields'] ); if ( is_array( $custom_fields ) ) { foreach ( $custom_fields as $k => $field ) { + if ( isset( $field['type'] ) ) { if ( isset( $form[ $k ] ) ) { @@ -579,7 +579,11 @@ if ( ! class_exists( 'um\core\Form' ) ) { $form[ $k ] = (int) $form[ $k ]; break; case 'textarea': - $form[ $k ] = sanitize_textarea_field( $form[ $k ] ); + if ( ! empty( $field['html'] ) ) { + $form[ $k ] = wp_kses_post( $form[ $k ] ); + } else { + $form[ $k ] = sanitize_textarea_field( $form[ $k ] ); + } break; case 'url': $form[ $k ] = esc_url_raw( $form[ $k ] ); From 8ad07b264f7f83c256654fbf0838c5035660695a Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Thu, 15 Jul 2021 17:09:20 +0300 Subject: [PATCH 27/29] - fixed saving shortcode + content block settings using sanitize; --- includes/admin/core/class-admin-builder.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php index 8221aaa0..8300d00e 100644 --- a/includes/admin/core/class-admin-builder.php +++ b/includes/admin/core/class-admin-builder.php @@ -689,7 +689,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { } } elseif ( strstr( $key, 'um_editor' ) ) { - $save[ $_metakey ]['content'] = $val; + if ( 'block' === $array['post']['_type'] ) { + $save[ $_metakey ]['content'] = wp_kses_post( $val ); + } else { + $save[ $_metakey ]['content'] = sanitize_textarea_field( $val ); + } } } From eeb7c3947145a4ab4b537959d28b5172fe06d89c Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Fri, 16 Jul 2021 01:35:13 +0300 Subject: [PATCH 28/29] - fixed maybe serialized custom fields; - fixed sanitizing; --- includes/admin/core/class-admin-builder.php | 5 +++-- includes/core/class-fields.php | 6 +++++- includes/um-short-functions.php | 9 +++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php index 8300d00e..82c45c5b 100644 --- a/includes/admin/core/class-admin-builder.php +++ b/includes/admin/core/class-admin-builder.php @@ -678,8 +678,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { $save[ $_metakey ] = null; foreach ( $array['post'] as $key => $val ) { - if ( substr( $key, 0, 1 ) === '_' && $val != '' ) { // field attribute - $new_key = ltrim ($key,'_'); + if ( substr( $key, 0, 1 ) === '_' && $val !== '' ) { // field attribute + $new_key = ltrim ( $key, '_' ); if ( $new_key == 'options' ) { //$save[ $_metakey ][$new_key] = explode(PHP_EOL, $val); @@ -689,6 +689,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { } } elseif ( strstr( $key, 'um_editor' ) ) { + if ( 'block' === $array['post']['_type'] ) { $save[ $_metakey ]['content'] = wp_kses_post( $val ); } else { diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index b9981db4..acb1d50c 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -3783,11 +3783,15 @@ if ( ! class_exists( 'um\core\Fields' ) ) { /** * Get fields in row * - * @param integer $row_id + * @param int $row_id * * @return string */ function get_fields_by_row( $row_id ) { + if ( ! isset( $this->get_fields ) ) { + return ''; + } + foreach ( $this->get_fields as $key => $array ) { if ( ! isset( $array['in_row'] ) || ( isset( $array['in_row'] ) && $array['in_row'] == $row_id ) ) { $results[ $key ] = $array; diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 2f871f5e..56f96180 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -697,6 +697,7 @@ function um_user_submitted_registration_formatted( $style = false ) { if ( isset( $submitted_data['form_id'] ) ) { $fields = UM()->query()->get_attr( 'custom_fields', $submitted_data['form_id'] ); + $fields = maybe_unserialize( $fields ); } if ( isset( $fields ) ) { @@ -717,10 +718,10 @@ function um_user_submitted_registration_formatted( $style = false ) { if ( empty( $rows ) ) { $rows = array( '_um_row_1' => array( - 'type' => 'row', - 'id' => '_um_row_1', - 'sub_rows' => 1, - 'cols' => 1 + 'type' => 'row', + 'id' => '_um_row_1', + 'sub_rows' => 1, + 'cols' => 1, ), ); } From 41af9903b884e73f651ad44352584aa69c0f01e6 Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Fri, 16 Jul 2021 17:36:51 +0300 Subject: [PATCH 29/29] - changed readme; - prepared to release; --- README.md | 2 +- readme.txt | 5 ++++- ultimate-member.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5ec46510..e490a2ac 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ GNU Version 2 or Any Later Version ## Releases -[Official Release Version: 2.1.21](https://github.com/ultimatemember/ultimatemember/releases/tag/2.1.21). +[Official Release Version: 2.2.0](https://github.com/ultimatemember/ultimatemember/releases/tag/2.2.0). ## Changelog diff --git a/readme.txt b/readme.txt index 3e8deb9a..072cb463 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Tags: community, member, membership, user-profile, user-registration Requires PHP: 5.6 Requires at least: 5.0 Tested up to: 5.7 -Stable tag: 2.1.21 +Stable tag: 2.2.0 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -165,6 +165,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat - Added: Sanitizing handlers to the Ultimate Member > Forms > Add Field/Edit Field forms' fields - Added: Sanitizing handlers to the Ultimate Member > User Roles forms' fields - Added: Sanitizing handlers to the Restriction Content forms' fields in the posts/pages/menus additional fields + - Added: Sanitizing handlers to the all (Login/Registration/Profile/Account) frontend forms' fields - Added: Custom placeholder setting for the Confirm Password field * Bugfixes: @@ -175,6 +176,8 @@ The plugin works with popular caching plugins by automatically excluding Ultimat - Fixed: Content restriction (CPT + Terms). Displaying the proper count of the posts. Restricted are excluded - Fixed: Saving and displaying settings on the UM > Settings > Access screen - Fixed: Saving and displaying default Member Directory settings + - Fixed: Minor PHP warnings on registration data preview + - Fixed: Member directory slider filter-type query and results * Tweaks: diff --git a/ultimate-member.php b/ultimate-member.php index bf2e56a3..a17c1585 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.2.0-rc.1 +Version: 2.2.0 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member