- intermediate results with sanitizing form handlers;

This commit is contained in:
Nikita Sinelnikov
2021-06-29 02:51:54 +03:00
parent 23d1b982a4
commit 07e664be80
63 changed files with 4337 additions and 2812 deletions
+3 -3
View File
@@ -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;
}
}
}
}
File diff suppressed because it is too large Load Diff
+16 -4
View File
@@ -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' ) ) {
}
}
}
}
+25 -20
View File
@@ -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' ) ) {
}
}
}
}
+6 -6
View File
@@ -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;
}
+2 -2
View File
@@ -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' ) ) {
}
}
}
}
+21 -10
View File
@@ -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' ) ) {
}
}
}
}
+4 -4
View File
@@ -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;
}
+3 -3
View File
@@ -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' => '<p>' . __( 'Settings successfully upgraded', 'ultimate-member' ) . '</p>',
@@ -697,4 +697,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
wp_send_json_success();
}
}
}
}
File diff suppressed because it is too large Load Diff
+24 -25
View File
@@ -306,13 +306,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
* @param $query
* @return mixed
*/
function sort_by_newest( $query ) {
public function sort_by_newest( $query ) {
global $pagenow;
if ( is_admin() && $pagenow == 'users.php' ) {
if ( is_admin() && 'users.php' === $pagenow ) {
if ( ! isset( $_REQUEST['orderby'] ) ) {
$query->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' ) ) {
}
}
}
}
@@ -1,11 +1,13 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $wpdb;
if ( isset( $_REQUEST['_wp_http_referer'] ) ) {
$redirect = remove_query_arg( array( '_wp_http_referer' ), wp_unslash( $_REQUEST['_wp_http_referer'] ) );
} else {
$redirect = get_admin_url(). 'admin.php?page=um_roles';
$redirect = get_admin_url() . 'admin.php?page=um_roles';
}
global $wp_roles;
@@ -16,9 +18,9 @@ if ( isset( $_GET['action'] ) ) {
case 'delete': {
$role_keys = array();
if ( isset( $_REQUEST['id'] ) ) {
check_admin_referer( 'um_role_delete' . sanitize_key( $_REQUEST['id'] ) . get_current_user_id() );
check_admin_referer( 'um_role_delete' . 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'] );
}
@@ -40,7 +42,7 @@ if ( isset( $_GET['action'] ) ) {
delete_option( "um_role_{$role_key}_meta" );
$um_roles = array_diff( $um_roles, array( $role_key ) );
$roleID = 'um_' . $role_key;
$roleID = 'um_' . $role_key;
$um_custom_roles[] = $roleID;
//check if role exist before removing it
@@ -51,11 +53,11 @@ if ( isset( $_GET['action'] ) ) {
//set for users with deleted roles role "Subscriber"
$args = array(
'blog_id' => 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'] = '<a href="admin.php?page=um_roles&tab=edit&id=' . $item['key'] . '">' . __( 'Edit', 'ultimate-member' ). '</a>';
$actions['edit'] = '<a href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $item['key'] ) . '">' . __( 'Edit', 'ultimate-member' ) . '</a>';
if ( ! empty( $item['_um_is_custom'] ) ) {
$actions['delete'] = '<a href="admin.php?page=um_roles&action=delete&id=' . $item['key'] . '&_wpnonce=' . wp_create_nonce( 'um_role_delete' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to delete this role?', 'ultimate-member' ) . '\' );">' . __( 'Delete', 'ultimate-member' ). '</a>';
$actions['delete'] = '<a href="admin.php?page=um_roles&action=delete&id=' . esc_attr( $item['key'] ) . '&_wpnonce=' . wp_create_nonce( 'um_role_delete' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to delete this role?', 'ultimate-member' ) . '\' );">' . __( 'Delete', 'ultimate-member' ) . '</a>';
} else {
$role_meta = get_option( "um_role_{$item['key']}_meta" );
if ( ! empty( $role_meta ) ) {
$actions['reset'] = '<a href="admin.php?page=um_roles&action=reset&id=' . $item['key'] . '&_wpnonce=' . wp_create_nonce( 'um_role_reset' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to reset UM role meta?', 'ultimate-member' ) . '\' );">' . __( 'Reset UM Role meta', 'ultimate-member' ). '</a>';
$actions['reset'] = '<a href="admin.php?page=um_roles&action=reset&id=' . esc_attr( $item['key'] ) . '&_wpnonce=' . wp_create_nonce( 'um_role_reset' . $item['key'] . get_current_user_id() ) . '" onclick="return confirm( \'' . __( 'Are you sure you want to reset UM role meta?', 'ultimate-member' ) . '\' );">' . __( 'Reset UM Role meta', 'ultimate-member' ) . '</a>';
}
}
return sprintf('%1$s %2$s', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . $item['key'] . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
return sprintf('%1$s %2$s', '<strong><a class="row-title" href="admin.php?page=um_roles&tab=edit&id=' . esc_attr( $item['key'] ) . '">' . stripslashes( $item['name'] ) . '</a></strong>', $this->row_actions( $actions ) );
}
@@ -487,7 +494,7 @@ $ListTable->um_set_pagination_args( array( 'total_items' => count( $roles ), 'pe
</h2>
<?php if ( ! empty( $_GET['msg'] ) ) {
switch( sanitize_key( $_GET['msg'] ) ) {
switch ( sanitize_key( $_GET['msg'] ) ) {
case 'd':
echo '<div id="message" class="updated fade"><p>' . __( 'User Role <strong>Deleted</strong> Successfully.', 'ultimate-member' ) . '</p></div>';
break;
@@ -498,4 +505,4 @@ $ListTable->um_set_pagination_args( array( 'total_items' => count( $roles ), 'pe
<input type="hidden" name="page" value="um_roles" />
<?php $ListTable->display(); ?>
</form>
</div>
</div>
@@ -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' ) ) );
}
}
@@ -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' ) ) );
}
}
@@ -1,18 +1,23 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
} ?>
<div class="um-admin-metabox">
<?php UM()->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' ),
)
<?php
UM()->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(); ?>
</div>
)->render_form();
?>
</div>
+105 -97
View File
@@ -1,4 +1,6 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $post_id;
@@ -7,117 +9,123 @@ $_um_roles_value = empty( $_um_roles_value ) ? array() : $_um_roles_value;
$show_these_users = get_post_meta( get_the_ID(), '_um_show_these_users', true );
if ( $show_these_users ) {
$show_these_users = implode( "\n", str_replace( "\r", "", $show_these_users ) );
$show_these_users = implode( "\n", str_replace( "\r", '', $show_these_users ) );
}
$exclude_these_users = get_post_meta( get_the_ID(), '_um_exclude_these_users', true );
if ( $exclude_these_users ) {
$exclude_these_users = implode( "\n", str_replace( "\r", "", $exclude_these_users ) );
$exclude_these_users = implode( "\n", str_replace( "\r", '', $exclude_these_users ) );
}
$_um_view_types_value = get_post_meta( $post_id, '_um_view_types', true );
$_um_view_types_value = empty( $_um_view_types_value ) ? array( 'grid', 'list' ) : $_um_view_types_value;
$view_types_options = array_map( function( $item ) {
return $item['title'];
}, UM()->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
* <?php
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
* function my_directory_sort_users_select( $sort_types ) {
* // your code here
* return $sort_types;
* }
* ?>
*/
$fields = apply_filters( 'um_admin_extend_directory_options_general', $fields ); ?>
<div class="um-admin-metabox">
<?php $fields = array(
<?php
UM()->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
* <?php
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
* function my_directory_sort_users_select( $sort_types ) {
* // your code here
* return $sort_types;
* }
* ?>
*/
$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();
?>
<div class="um-admin-clear"></div>
</div>
</div>
@@ -1,68 +1,72 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
} ?>
<div class="um-admin-metabox">
<?php UM()->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' ),
<?php
UM()->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();
?>
<div class="um-admin-clear"></div>
</div>
</div>
+115 -112
View File
@@ -1,117 +1,120 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$user_fields = array();
foreach ( UM()->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
* <?php
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
* function my_directory_sort_users_select( $sort_types ) {
* // your code here
* return $sort_types;
* }
* ?>
*/
$fields = apply_filters( 'um_admin_extend_directory_options_profile', $fields ); ?>
<div class="um-admin-metabox">
<?php $user_fields = array();
foreach ( UM()->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(
<?php
UM()->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
* <?php
* add_filter( 'um_admin_directory_sort_users_select', 'my_directory_sort_users_select', 10, 1 );
* function my_directory_sort_users_select( $sort_types ) {
* // your code here
* return $sort_types;
* }
* ?>
*/
$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();
?>
<div class="um-admin-clear"></div>
</div>
</div>
+92 -89
View File
@@ -1,97 +1,100 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $post_id; ?>
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 ); ?>
<div class="um-admin-metabox">
<?php
$_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 );
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,
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();
?>
<div class="um-admin-clear"></div>
</div>
</div>
@@ -1,4 +1,6 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
} ?>
<div class="um-admin-metabox">
@@ -24,4 +26,4 @@
<p><?php echo UM()->shortcodes()->get_shortcode( get_the_ID() ); ?></p>
<!-- <p>--><?php //echo UM()->shortcodes()->get_default_shortcode( get_the_ID() ); ?><!--</p>-->
</div>
</div>
+56 -53
View File
@@ -1,62 +1,65 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $post_id;
$_um_sorting_fields = get_post_meta( $post_id, '_um_sorting_fields', true );
$_um_sorting_fields = empty( $_um_sorting_fields ) ? array() : $_um_sorting_fields; ?>
$_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 ),
),
); ?>
<div class="um-admin-metabox">
<?php $fields = array(
<?php
UM()->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();
?>
<div class="um-admin-clear"></div>
</div>
</div>
+8 -7
View File
@@ -1,5 +1,6 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( empty( UM()->builder()->form_id ) ) {
UM()->builder()->form_id = $this->form_id;
@@ -9,8 +10,10 @@ if ( empty( UM()->builder()->form_id ) ) {
<div class="um-admin-drag-ctrls-demo um-admin-drag-ctrls">
<a href="javascript:void(0);" class="active" data-modal="UM_preview_form" data-modal-size="smaller" data-dynamic-content="um_admin_preview_form"
data-arg1="<?php esc_attr( the_ID() ); ?>" data-arg2=""><?php _e('Live Preview','ultimate-member'); ?></a>
<a href="javascript:void(0);" class="active" data-modal="UM_preview_form" data-modal-size="smaller"
data-dynamic-content="um_admin_preview_form" data-arg1="<?php echo esc_attr( get_the_ID() ); ?>" data-arg2="">
<?php esc_html_e( 'Live Preview', 'ultimate-member' ); ?>
</a>
</div>
@@ -19,9 +22,7 @@ if ( empty( UM()->builder()->form_id ) ) {
<div class="um-admin-drag">
<div class="um-admin-drag-ajax" data-form_id="<?php echo esc_attr( UM()->builder()->form_id ); ?>">
<?php UM()->builder()->show_builder(); ?>
</div>
<div class="um-admin-drag-addrow um-admin-tipsy-n" title="<?php esc_attr_e( 'Add Master Row', 'ultimate-member' ); ?>"
@@ -31,4 +32,4 @@ if ( empty( UM()->builder()->form_id ) ) {
</div>
</div>
</div>
@@ -1,102 +1,106 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
} ?>
<div class="um-admin-metabox">
<?php UM()->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 &amp; 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' ),
<?php
UM()->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 &amp; 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();
?>
<div class="um-admin-clear"></div>
</div>
</div>
@@ -1,34 +1,38 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
} ?>
<div class="um-admin-metabox">
<?php UM()->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' ),
<?php
UM()->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();
?>
<div class="um-admin-clear"></div>
</div>
</div>
+17 -9
View File
@@ -1,21 +1,29 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$is_core = get_post_meta( get_the_ID(), '_um_core', true ); ?>
<div class="um-admin-boxed-links um-admin-ajaxlink <?php if ( $is_core ) echo 'is-core-form'; ?>">
<div class="um-admin-boxed-links um-admin-ajaxlink<?php echo $is_core ? ' is-core-form' : ''; ?>">
<?php if ( $is_core ) { ?>
<p><?php _e( '<strong>Note:</strong> Form type cannot be changed for the default forms.', 'ultimate-member' ); ?></p>
<p>
<strong><?php esc_html_e( 'Note: ', 'ultimate-member' ); ?></strong><?php esc_html_e( 'Form type cannot be changed for the default forms.', 'ultimate-member' ); ?>
</p>
<?php } ?>
<a href="javascript:void(0);" data-role="register"><?php _e( 'Registration Form', 'ultimate-member' ); ?></a>
<a href="javascript:void(0);" data-role="register">
<?php esc_html_e( 'Registration Form', 'ultimate-member' ); ?>
</a>
<a href="javascript:void(0);" data-role="profile"><?php _e('Profile Form', 'ultimate-member' ); ?></a>
<a href="javascript:void(0);" data-role="profile">
<?php esc_html_e( 'Profile Form', 'ultimate-member' ); ?>
</a>
<a href="javascript:void(0);" data-role="login"><?php _e( 'Login Form', 'ultimate-member' ); ?></a>
<a href="javascript:void(0);" data-role="login">
<?php esc_html_e( 'Login Form', 'ultimate-member' ); ?>
</a>
<input type="hidden" name="form[_um_mode]" id="form__um_mode" value="<?php echo esc_attr( UM()->query()->get_meta_value( '_um_mode', null, 'register' ) ); ?>" />
</div>
<div class="um-admin-clear"></div>
<div class="um-admin-clear"></div>
@@ -1,208 +1,211 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$profile_role_array = array();
foreach ( UM()->roles()->get_roles() as $key => $value ) {
$_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
if ( ! empty( $_um_profile_role ) ) {
$profile_role_array[] = $_um_profile_role;
}
} ?>
<div class="um-admin-metabox">
<?php $profile_role_array = array();
foreach ( UM()->roles()->get_roles() as $key => $value ) {
$_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
if ( ! empty( $_um_profile_role ) ) {
$profile_role_array[] = $_um_profile_role;
}
}
UM()->admin_forms( array(
'class' => 'um-form-profile-customize um-top-label',
'prefix_id' => 'form',
'fields' => array(
array(
'id' => '_um_profile_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 &amp; appearance', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_use_custom_settings', null, 0 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
<?php
UM()->admin_forms(
array(
'class' => 'um-form-profile-customize um-top-label',
'prefix_id' => 'form',
'fields' => array(
array(
'id' => '_um_profile_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 &amp; appearance', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_use_custom_settings', null, 0 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_role',
'type' => 'select',
'multi' => true,
'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
'value' => $profile_role_array,
'options' => UM()->roles()->get_roles(),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
),
array(
'id' => '_um_profile_template',
'type' => 'select',
'label' => __( 'Template', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_template', null, UM()->options()->get( 'profile_template' ) ),
'options' => UM()->shortcodes()->get_templates( 'profile' ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
),
array(
'id' => '_um_profile_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_profile_max_width', null, UM()->options()->get( 'profile_max_width' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
),
array(
'id' => '_um_profile_area_max_width',
'type' => 'text',
'label' => __( 'Profile Area Max. Width (px)', 'ultimate-member' ),
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_area_max_width', null, UM()->options()->get( 'profile_area_max_width' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
),
array(
'id' => '_um_profile_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_profile_icons', null, UM()->options()->get( 'profile_icons' ) ),
'options' => array(
'field' => __( 'Show inside text field', 'ultimate-member' ),
'label' => __( 'Show with label', 'ultimate-member' ),
'off' => __( 'Turn off', 'ultimate-member' ),
),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
),
array(
'id' => '_um_profile_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_profile_primary_btn_word', null, UM()->options()->get( 'profile_primary_btn_word' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
),
array(
'id' => '_um_profile_secondary_btn',
'type' => 'select',
'label' => __( 'Show Secondary Button', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn', null, UM()->options()->get( 'profile_secondary_btn' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_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_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ),
'conditional' => array( '_um_profile_secondary_btn', '=', 1 ),
),
array(
'id' => '_um_profile_cover_enabled',
'type' => 'select',
'label' => __( 'Enable Cover Photos', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_cover_enabled', null, 1 ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_coversize',
'type' => 'select',
'label' => __( 'Cover Photo Size', 'ultimate-member' ),
'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_coversize', null, UM()->options()->get( 'profile_coversize' ) ),
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
'conditional' => array( '_um_profile_cover_enabled', '=', 1 ),
),
array(
'id' => '_um_profile_cover_ratio',
'type' => 'select',
'label' => __( 'Cover photo ratio', 'ultimate-member' ),
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, UM()->options()->get( '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( '_um_profile_cover_enabled', '=', 1 ),
),
array(
'id' => '_um_profile_disable_photo_upload',
'type' => 'select',
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_disable_photo_upload', null, UM()->options()->get( 'disable_profile_photo_upload' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_photosize',
'type' => 'select',
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_photosize', null, UM()->options()->get( 'profile_photosize' ) ),
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
),
array(
'id' => '_um_profile_photo_required',
'type' => 'select',
'label' => __( 'Make Profile Photo Required', 'ultimate-member' ),
'tooltip' => __( 'Require user to update a profile photo when updating their profile', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_photo_required' ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_show_name',
'type' => 'select',
'label' => __( 'Show display name in profile header?', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_show_name', null, 1 ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_show_social_links',
'type' => 'select',
'label' => __( 'Show social links in profile header?', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_show_social_links', null, UM()->options()->get( 'profile_show_social_links' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_show_bio',
'type' => 'select',
'label' => __( 'Show user description in profile header?', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_show_bio', null, 1 ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
),
array(
'id' => '_um_profile_role',
'type' => 'select',
'multi' => true,
'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
'value' => $profile_role_array,
'options' => UM()->roles()->get_roles(),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
),
array(
'id' => '_um_profile_template',
'type' => 'select',
'label' => __( 'Template', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_template', null, UM()->options()->get( 'profile_template' ) ),
'options' => UM()->shortcodes()->get_templates( 'profile' ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
),
array(
'id' => '_um_profile_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_profile_max_width', null, UM()->options()->get( 'profile_max_width' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
),
array(
'id' => '_um_profile_area_max_width',
'type' => 'text',
'label' => __( 'Profile Area Max. Width (px)', 'ultimate-member' ),
'tooltip' => __( 'The maximum width of the profile area inside profile (below profile header)', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value('_um_profile_area_max_width', null, UM()->options()->get( 'profile_area_max_width' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
),
array(
'id' => '_um_profile_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_profile_icons', null, UM()->options()->get( 'profile_icons' ) ) ,
'options' => array(
'field' => __( 'Show inside text field', 'ultimate-member' ),
'label' => __( 'Show with label', 'ultimate-member' ),
'off' => __( 'Turn off', 'ultimate-member' )
),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
),
array(
'id' => '_um_profile_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_profile_primary_btn_word', null, UM()->options()->get( 'profile_primary_btn_word' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
),
array(
'id' => '_um_profile_secondary_btn',
'type' => 'select',
'label' => __( 'Show Secondary Button', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn', null, UM()->options()->get( 'profile_secondary_btn' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_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_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ),
'conditional' => array( '_um_profile_secondary_btn', '=', 1 )
),
array(
'id' => '_um_profile_cover_enabled',
'type' => 'select',
'label' => __( 'Enable Cover Photos', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_cover_enabled', null, 1 ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_coversize',
'type' => 'select',
'label' => __( 'Cover Photo Size', 'ultimate-member' ),
'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_coversize', null, UM()->options()->get( 'profile_coversize' ) ),
'options' => UM()->files()->get_profile_photo_size( 'cover_thumb_sizes' ),
'conditional' => array( '_um_profile_cover_enabled', '=', 1 )
),
array(
'id' => '_um_profile_cover_ratio',
'type' => 'select',
'label' => __( 'Cover photo ratio', 'ultimate-member' ),
'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_cover_ratio', null, UM()->options()->get( '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( '_um_profile_cover_enabled', '=', 1 )
),
array(
'id' => '_um_profile_disable_photo_upload',
'type' => 'select',
'label' => __( 'Disable Profile Photo Upload', 'ultimate-member' ),
'tooltip' => __( 'Switch on/off the profile photo uploader', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_disable_photo_upload', null, UM()->options()->get( 'disable_profile_photo_upload' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_photosize',
'type' => 'select',
'label' => __( 'Profile Photo Size', 'ultimate-member' ),
'tooltip' => __( 'Set the profile photo size in pixels here', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_photosize', null, UM()->options()->get( 'profile_photosize' ) ),
'options' => UM()->files()->get_profile_photo_size( 'photo_thumb_sizes' ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
),
array(
'id' => '_um_profile_photo_required',
'type' => 'select',
'label' => __( 'Make Profile Photo Required', 'ultimate-member' ),
'tooltip' => __( 'Require user to update a profile photo when updating their profile', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_photo_required' ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_show_name',
'type' => 'select',
'label' => __( 'Show display name in profile header?', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_show_name', null, 1 ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_show_social_links',
'type' => 'select',
'label' => __( 'Show social links in profile header?', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_show_social_links', null, UM()->options()->get( 'profile_show_social_links' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
array(
'id' => '_um_profile_show_bio',
'type' => 'select',
'label' => __( 'Show user description in profile header?', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_show_bio', null, 1 ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
1 => __( 'Yes', 'ultimate-member' ),
),
),
)
) )->render_form(); ?>
)->render_form();
?>
<div class="um-admin-clear"></div>
</div>
</div>
@@ -1,32 +1,37 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$user_fields = array();
foreach ( UM()->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; ?>
<div class="um-admin-metabox">
<?php $user_fields = array();
foreach ( UM()->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,
)
<?php
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,
),
),
)
) )->render_form(); ?>
)->render_form();
?>
<div class="um-admin-clear"></div>
</div>
</div>
@@ -1,95 +1,99 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
foreach ( UM()->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;
}
} ?>
<div class="um-admin-metabox">
<?php foreach ( UM()->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 &amp; 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' ),
<?php
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 &amp; 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();
?>
<div class="um-admin-clear"></div>
</div>
</div>
+68 -66
View File
@@ -1,74 +1,76 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$options = array(
'' => __( 'Select page', 'ultimate-member' ),
);
$pages = get_pages();
foreach ( $pages as $page ) {
$options[ $page->ID ] = $page->post_title;
} ?>
<div class="um-admin-metabox">
<?php
$options = array(
'' => __( '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();
?>
<div class="um-admin-clear"></div>
</div>
</div>
+20 -14
View File
@@ -1,27 +1,33 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$role = $object['data']; ?>
<div class="um-admin-metabox">
<?php UM()->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'] : '',
<?php
UM()->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();
?>
</div>
<div class="submitbox" id="submitpost">
<div id="major-publishing-actions">
<input type="submit" value="<?php echo ! empty( $_GET['id'] ) ? esc_attr__( 'Update Role', 'ultimate-member' ) : esc_attr__( 'Create Role', 'ultimate-member' ) ?>" class="button-primary" id="create_role" name="create_role">
<input type="submit" value="<?php echo ! empty( $_GET['id'] ) ? esc_attr__( 'Update Role', 'ultimate-member' ) : esc_attr__( 'Create Role', 'ultimate-member' ) ?>" class="button-primary" id="create_role" name="create_role" />
<input type="button" class="cancel_popup button" value="<?php esc_attr_e( 'Cancel', 'ultimate-member' ) ?>" onclick="window.location = '<?php echo add_query_arg( array( 'page' => 'um_roles' ), admin_url( 'admin.php' ) ) ?>';" />
<div class="clear"></div>
</div>
</div>
</div>
+50 -171
View File
@@ -1,4 +1,6 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
wp_enqueue_script( 'postbox' );
wp_enqueue_media();
@@ -42,7 +44,7 @@ do_action( 'um_roles_add_meta_boxes', 'um_role_meta' );
*/
do_action( 'um_roles_add_meta_boxes_um_role_meta' );
$data = array();
$data = array();
$option = array();
global $wp_roles;
@@ -60,11 +62,11 @@ if ( ! empty( $_GET['id'] ) ) {
if ( ! empty( $_POST['role'] ) ) {
$id = '';
$id = '';
$redirect = '';
$error = '';
$error = '';
if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
if ( ! wp_verify_nonce( $_POST['um_nonce'], 'um-add-role' ) ) {
$error = __( 'Security Issue', 'ultimate-member' ) . '<br />';
}
@@ -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' ) . '<br />';
}
}
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; ?>
<div class="wrap">
<h2>
<?php echo ( 'add' == sanitize_key( $_GET['tab'] ) ) ? __( 'Add New Role', 'ultimate-member' ) : __( 'Edit Role', 'ultimate-member' ) ?>
<?php if ( 'edit' == sanitize_key( $_GET['tab'] ) ) { ?>
<a class="add-new-h2" href="<?php echo esc_url( add_query_arg( array( 'page' => 'um_roles', 'tab' => 'add' ), admin_url( 'admin.php' ) ) ) ?>"><?php _e( 'Add New', 'ultimate-member' ) ?></a>
<?php } ?>
<?php
if ( 'add' === sanitize_key( $_GET['tab'] ) ) {
esc_html_e( 'Add New Role', 'ultimate-member' );
} elseif ( 'edit' === sanitize_key( $_GET['tab'] ) ) {
esc_html_e( 'Edit Role', 'ultimate-member' );
$add_new_link = add_query_arg(
array(
'page' => 'um_roles',
'tab' => 'add',
),
admin_url( 'admin.php' )
);
?>
<a class="add-new-h2" href="<?php echo esc_url( $add_new_link ); ?>">
<?php esc_html_e( 'Add New', 'ultimate-member' ); ?>
</a>
<?php
}
?>
</h2>
<?php if ( ! empty( $_GET['msg'] ) ) {
switch( sanitize_key( $_GET['msg'] ) ) {
<?php
if ( ! empty( $_GET['msg'] ) ) {
switch ( sanitize_key( $_GET['msg'] ) ) {
case 'a':
echo '<div id="message" class="updated fade"><p>' . __( 'User Role <strong>Added</strong> Successfully.', 'ultimate-member' ) . '</p></div>';
break;
@@ -316,13 +188,13 @@ $screen_id = $current_screen->id; ?>
if ( ! empty( $error ) ) { ?>
<div id="message" class="error fade">
<p><?php echo $error ?></p>
<p><?php echo $error; ?></p>
</div>
<?php } ?>
<form id="um_edit_role" action="" method="post">
<input type="hidden" name="role[id]" value="<?php echo isset( $_GET['id'] ) ? esc_attr( sanitize_key( $_GET['id'] ) ) : '' ?>" />
<?php if ( 'add' == sanitize_key( $_GET['tab'] ) ) { ?>
<?php if ( 'add' === sanitize_key( $_GET['tab'] ) ) { ?>
<input type="hidden" name="role[_um_is_custom]" value="1" />
<input type="hidden" name="um_nonce" value="<?php echo esc_attr( wp_create_nonce( 'um-add-role' ) ) ?>" />
<?php } else { ?>
@@ -335,7 +207,7 @@ $screen_id = $current_screen->id; ?>
<div id="post-body-content">
<div id="titlediv">
<div id="titlewrap">
<?php if ( 'add' == sanitize_key( $_GET['tab'] ) ) { ?>
<?php if ( 'add' === sanitize_key( $_GET['tab'] ) ) { ?>
<label for="title" class="screen-reader-text"><?php _e( 'Title', 'ultimate-member' ) ?></label>
<input type="text" name="role[name]" placeholder="<?php esc_attr_e( 'Enter Title Here', 'ultimate-member' ) ?>" id="title" value="<?php echo isset( $data['name'] ) ? $data['name'] : '' ?>" />
<?php } else { ?>
@@ -345,11 +217,18 @@ $screen_id = $current_screen->id; ?>
</div>
</div>
<?php
$object = array(
'data' => $data,
'option' => $option,
);
?>
<div id="postbox-container-1" class="postbox-container">
<?php do_meta_boxes( 'um_role_meta', 'side', array( 'data' => $data, 'option' => $option ) ); ?>
<?php do_meta_boxes( 'um_role_meta', 'side', $object ); ?>
</div>
<div id="postbox-container-2" class="postbox-container">
<?php do_meta_boxes( 'um_role_meta', 'normal', array( 'data' => $data, 'option' => $option ) ); ?>
<?php do_meta_boxes( 'um_role_meta', 'normal', $object ); ?>
</div>
</div>
</div>
@@ -51,7 +51,8 @@
</span>
<?php $role = $object['data'];
<?php
$role = $object['data'];
$role_capabilities = ! empty( $role['wp_capabilities'] ) ? array_keys( $role['wp_capabilities'] ) : array( 'read' );
if ( ! empty( $_GET['id'] ) ) {
@@ -89,4 +90,4 @@
)
)
) )->render_form(); ?>
</div>
</div>
+2 -2
View File
@@ -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' ) ) {
}
}
}
}
+2 -2
View File
@@ -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' ) ) {
}
}
}
}
+3 -1
View File
@@ -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;
}
}
}
}
+3 -3
View File
@@ -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' ) ) {
<div class="um-field um-field-c">
<div class="um-field-area">
<label class="um-field-checkbox <?php echo ( $checked ) ? 'active' : '' ?>">
<label class="um-field-checkbox<?php echo $checked ? ' active' : '' ?>">
<input type="checkbox" name="<?php echo esc_attr( $id ); ?>" value="1" <?php checked( $checked ) ?> />
<span class="um-field-checkbox-state"><i class="<?php echo esc_attr( $class ) ?>"></i></span>
<span class="um-field-checkbox-option"> <?php echo esc_html( $title ); ?></span>
@@ -4761,4 +4761,4 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
return $html_atts;
}
}
}
}
+17 -15
View File
@@ -261,7 +261,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
wp_send_json_error( __( 'Wrong mode', 'ultimate-member' ) );
}
$src = $_POST['src'];
$src = esc_url_raw( $_POST['src'] );
if ( strstr( $src, '?' ) ) {
$splitted = explode( '?', $src );
$src = $splitted[0];
@@ -286,7 +286,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
$is_temp = um_is_temp_upload( $src );
if ( ! $is_temp ) {
if ( ! empty( $_POST['filename'] ) && file_exists( UM()->uploader()->get_upload_user_base_dir( $user_id ) . DIRECTORY_SEPARATOR . $_POST['filename'] ) ) {
if ( ! empty( $_POST['filename'] ) && file_exists( UM()->uploader()->get_upload_user_base_dir( $user_id ) . DIRECTORY_SEPARATOR . sanitize_file_name( $_POST['filename'] ) ) ) {
wp_send_json_success();
}
}
@@ -324,7 +324,7 @@ if ( ! class_exists( 'um\core\Files' ) ) {
wp_send_json_error( esc_js( __( 'Invalid coordinates', 'ultimate-member' ) ) );
}
$user_id = empty( $_REQUEST['user_id'] ) ? get_current_user_id() : $_REQUEST['user_id'];
$user_id = empty( $_REQUEST['user_id'] ) ? get_current_user_id() : absint( $_REQUEST['user_id'] );
UM()->fields()->set_id = filter_input( INPUT_POST, 'set_id', FILTER_SANITIZE_NUMBER_INT );
UM()->fields()->set_mode = filter_input( INPUT_POST, 'set_mode', FILTER_SANITIZE_STRING );
@@ -334,13 +334,15 @@ if ( ! class_exists( 'um\core\Files' ) ) {
wp_send_json_error( $ret );
}
$src = esc_url_raw( $src );
$image_path = um_is_file_owner( $src, $user_id, true );
if ( ! $image_path ) {
wp_send_json_error( esc_js( __( 'Invalid file ownership', 'ultimate-member' ) ) );
}
UM()->uploader()->replace_upload_dir = true;
$output = UM()->uploader()->resize_image( $image_path, $src, $key, $user_id, $coord );
$output = UM()->uploader()->resize_image( $image_path, $src, sanitize_text_field( $key ), $user_id, sanitize_text_field( $coord ) );
UM()->uploader()->replace_upload_dir = false;
delete_option( "um_cache_userdata_{$user_id}" );
@@ -358,13 +360,13 @@ if ( ! class_exists( 'um\core\Files' ) ) {
$ret['error'] = null;
$ret = array();
$id = $_POST['key'];
$timestamp = $_POST['timestamp'];
$nonce = $_POST['_wpnonce'];
$id = sanitize_text_field( $_POST['key'] );
$timestamp = absint( $_POST['timestamp'] );
$nonce = sanitize_text_field( $_POST['_wpnonce'] );
$user_id = empty( $_POST['user_id'] ) ? get_current_user_id() : absint( $_POST['user_id'] );
UM()->fields()->set_id = $_POST['set_id'];
UM()->fields()->set_mode = $_POST['set_mode'];
UM()->fields()->set_id = absint( $_POST['set_id'] );
UM()->fields()->set_mode = sanitize_key( $_POST['set_mode'] );
if ( UM()->fields()->set_mode != 'register' && ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
$ret['error'] = __( 'You have no permission to edit this user', 'ultimate-member' );
@@ -437,12 +439,12 @@ if ( ! class_exists( 'um\core\Files' ) ) {
die( json_encode( $ret ) );
}*/
$nonce = $_POST['_wpnonce'];
$id = $_POST['key'];
$timestamp = $_POST['timestamp'];
$nonce = sanitize_text_field( $_POST['_wpnonce'] );
$id = sanitize_text_field( $_POST['key'] );
$timestamp = absint( $_POST['timestamp'] );
UM()->fields()->set_id = $_POST['set_id'];
UM()->fields()->set_mode = $_POST['set_mode'];
UM()->fields()->set_id = absint( $_POST['set_id'] );
UM()->fields()->set_mode = sanitize_key( $_POST['set_mode'] );
/**
* UM hook
@@ -1296,4 +1298,4 @@ if ( ! class_exists( 'um\core\Files' ) ) {
}
}
}
+22 -8
View File
@@ -53,15 +53,28 @@ if ( ! class_exists( 'um\core\Form' ) ) {
/**
*
*/
function ajax_muted_action() {
public function ajax_muted_action() {
UM()->check_ajax_nonce();
/**
* @var $user_id
* @var $hook
*/
extract( $_REQUEST );
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) )
die( __( 'You can not edit this user' ) );
if ( isset( $user_id ) ) {
$user_id = absint( $user_id );
}
switch( $hook ) {
if ( isset( $hook ) ) {
$hook = sanitize_key( $hook );
}
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
}
switch ( $hook ) {
default:
/**
* UM hook
@@ -337,7 +350,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
*/
do_action( 'um_before_submit_form_post', $_POST );
$this->form_id = $_POST['form_id'];
$this->form_id = absint( $_POST['form_id'] );
$this->form_status = get_post_status( $this->form_id );
@@ -408,10 +421,11 @@ if ( ! class_exists( 'um\core\Form' ) ) {
$custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
if ( ! empty( $custom_field_roles ) ) {
$role = $_POST['role'];
if ( is_array( $_POST['role'] ) ) {
$role = current( $_POST['role'] );
$role = sanitize_key( $role );
} else {
$role = sanitize_key( $_POST['role'] );
}
global $wp_roles;
@@ -664,4 +678,4 @@ if ( ! class_exists( 'um\core\Form' ) ) {
return false;
}
}
}
}
+4 -4
View File
@@ -70,12 +70,12 @@ if ( ! class_exists( 'um\core\Logout' ) ) {
add_filter( 'wp_safe_redirect_fallback', array( &$this, 'safe_redirect_default' ), 10, 2 );
if ( isset( $_REQUEST['redirect_to'] ) && $_REQUEST['redirect_to'] !== '' ) {
if ( isset( $_REQUEST['redirect_to'] ) && '' !== $_REQUEST['redirect_to'] ) {
wp_destroy_current_session();
wp_logout();
session_unset();
exit( wp_safe_redirect( $_REQUEST['redirect_to'] ) );
} else if ( um_user('after_logout') == 'redirect_home' ) {
exit( wp_safe_redirect( esc_url_raw( $_REQUEST['redirect_to'] ) ) );
} else if ( 'redirect_home' === um_user( 'after_logout' ) ) {
wp_destroy_current_session();
wp_logout();
session_unset();
@@ -120,4 +120,4 @@ if ( ! class_exists( 'um\core\Logout' ) ) {
}
}
}
}
@@ -571,7 +571,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
if ( ! empty( $_POST['search'] ) ) {
$search_line = trim( stripslashes( $_POST['search'] ) );
$search_line = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
$searches = array();
foreach ( $this->core_search_fields as $field ) {
@@ -582,7 +582,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_search ON umm_search.user_id = u.ID";
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( $_POST['search'] ) );
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', stripslashes( sanitize_text_field( $_POST['search'] ) ) );
$search_like_string = apply_filters( 'um_member_directory_meta_search_like_type', '%' . $search_line . '%', $search_line );
@@ -610,6 +610,9 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$i = 1;
foreach ( $filter_query as $field => $value ) {
$field = sanitize_text_field( $field );
$value = sanitize_text_field( $value );
$attrs = UM()->fields()->get_field( $field );
// skip private invisible fields
if ( ! um_can_view_field( $attrs ) ) {
@@ -642,7 +645,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
//}
$order = 'ASC';
$sortby = ! empty( $_POST['sorting'] ) ? $_POST['sorting'] : $directory_data['sortby'];
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
$custom_sort = array();
@@ -755,7 +758,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
}
$query_number = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
$query_paged = ! empty( $_POST['page'] ) ? $_POST['page'] : 1;
$query_paged = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
$number = $query_number;
if ( ! empty( $directory_data['max_users'] ) && $query_paged*$query_number > $directory_data['max_users'] ) {
@@ -850,4 +853,4 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
wp_send_json_success( $member_directory_response );
}
}
}
}
+24 -22
View File
@@ -199,31 +199,31 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
*
* @return array
*/
function before_save_data( $value, $key, $post_id ) {
public function before_save_data( $value, $key, $post_id ) {
$post = get_post( $post_id );
if ( $post->post_type == 'um_directory' ) {
if ( 'um_directory' === $post->post_type ) {
if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ) ) ) {
if ( ! empty( $value ) && in_array( $key, array( '_um_view_types', '_um_roles', '_um_roles_can_search', '_um_roles_can_filter' ), true ) ) {
$value = array_keys( $value );
} elseif ( $key == '_um_search_filters' ) {
} elseif ( '_um_search_filters' === $key ) {
$temp_value = array();
if ( ! empty( $value ) ) {
foreach ( $value as $k ) {
$filter_type = $this->filter_types[ $k ];
if ( ! empty( $filter_type ) ) {
if ( $filter_type == 'slider' ) {
if ( ! empty( $filter_type ) ) {
if ( 'slider' === $filter_type ) {
if ( ! empty( $_POST[ $k ] ) ) {
$temp_value[ $k ] = $_POST[ $k ];
}
} elseif ( $filter_type == 'timepicker' || $filter_type == 'datepicker' ) {
} 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' ] );
}
} elseif ( $filter_type == 'select' ) {
} elseif ( 'select' === $filter_type ) {
if ( ! empty( $_POST[ $k ] ) ) {
if ( is_array( $_POST[ $k ] ) ) {
$temp_value[ $k ] = array_map( 'trim', $_POST[ $k ] );
@@ -241,7 +241,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
}
$value = $temp_value;
} elseif ( $key == '_um_sorting_fields' ) {
} elseif ( '_um_sorting_fields' === $key ) {
if ( ! empty( $value['other_data'] ) ) {
$other_data = $value['other_data'];
unset( $value['other_data'] );
@@ -254,15 +254,15 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$metalabel = wp_strip_all_tags( $other_data[ $k ]['label'] );
}
$row = array(
$metakey => ! empty( $metalabel ) ? $metalabel : $metakey
$metakey => ! empty( $metalabel ) ? $metalabel : $metakey,
);
}
}
}
}
} elseif ( $key == '_um_sortby_custom' ) {
} elseif ( '_um_sortby_custom' === $key ) {
$value = sanitize_text_field( $value );
} elseif ( $key == '_um_sortby_custom_label' ) {
} elseif ( '_um_sortby_custom_label' === $key ) {
$value = wp_strip_all_tags( $value );
}
}
@@ -518,7 +518,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
break;
}
case 'text': {
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? $_GET[ 'filter_' . $filter . '_' . $unique_hash ] : $default_value; ?>
$filter_from_url = ! empty( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) ? sanitize_text_field( $_GET[ 'filter_' . $filter . '_' . $unique_hash ] ) : $default_value; ?>
<input type="text" autocomplete="off" id="<?php echo $filter; ?>" name="<?php echo $filter; ?>"
placeholder="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>"
value="<?php echo esc_attr( $filter_from_url ) ?>" class="um-form-field"
@@ -1224,7 +1224,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
}
$this->query_args['number'] = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
$this->query_args['paged'] = ! empty( $_POST['page'] ) ? $_POST['page'] : 1;
$this->query_args['paged'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
}
@@ -1236,7 +1236,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
function sorting_query( $directory_data ) {
// sort members by
$this->query_args['order'] = 'ASC';
$sortby = ! empty( $_POST['sorting'] ) ? $_POST['sorting'] : $directory_data['sortby'];
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
$custom_sort = array();
@@ -1428,7 +1428,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
if ( ! empty( $_POST['search'] ) ) {
// complex using with change_meta_sql function
$search = trim( stripslashes( $_POST['search'] ) );
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
$meta_query = array(
'relation' => 'OR',
@@ -1446,7 +1446,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
),
);
$meta_query = apply_filters( 'um_member_directory_general_search_meta_query', $meta_query, stripslashes( $_POST['search'] ) );
$meta_query = apply_filters( 'um_member_directory_general_search_meta_query', $meta_query, stripslashes( sanitize_text_field( $_POST['search'] ) ) );
$this->query_args['meta_query'][] = $meta_query;
@@ -1471,7 +1471,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
function change_meta_sql( $sql, $queries, $type, $primary_table, $primary_id_column, $context ) {
if ( ! empty( $_POST['search'] ) ) {
global $wpdb;
$search = trim( stripslashes( $_POST['search'] ) );
$search = trim( stripslashes( sanitize_text_field( $_POST['search'] ) ) );
if ( ! empty( $search ) ) {
$meta_value = '%' . $wpdb->esc_like( $search ) . '%';
@@ -1548,6 +1548,8 @@ 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 );
$attrs = UM()->fields()->get_field( $field );
// skip private invisible fields
@@ -2066,7 +2068,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
*/
function calculate_pagination( $directory_data, $total_users ) {
$current_page = ! empty( $_POST['page'] ) ? $_POST['page'] : 1;
$current_page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
$total_users = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $total_users ) ? $directory_data['max_users'] : $total_users;
@@ -2320,7 +2322,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
function pagination_changes( $user_query ) {
global $wpdb;
$directory_id = $this->get_directory_by_hash( $_POST['directory_id'] );
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
$directory_data = UM()->query()->post_data( $directory_id );
$qv = $user_query->query_vars;
@@ -2367,7 +2369,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
global $wpdb;
$directory_id = $this->get_directory_by_hash( $_POST['directory_id'] );
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
$directory_data = UM()->query()->post_data( $directory_id );
//predefined result for user without capabilities to see other members
@@ -2619,4 +2621,4 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
wp_send_json_success( array( 'field_html' => $html ) );
}
}
}
}
+3 -2
View File
@@ -100,8 +100,9 @@ if ( ! class_exists( 'um\core\Options' ) ) {
* @param $option_id
*/
function remove( $option_id ) {
if ( ! empty( $this->options[ $option_id ] ) )
if ( ! empty( $this->options[ $option_id ] ) ) {
unset( $this->options[ $option_id ] );
}
update_option( 'um_options', $this->options );
}
@@ -157,4 +158,4 @@ if ( ! class_exists( 'um\core\Options' ) ) {
}
}
}
}
+45 -46
View File
@@ -247,7 +247,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
* @return bool
*/
function is_reset_request() {
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) == 1 ) {
if ( um_is_core_page( 'password-reset' ) && isset( $_POST['_um_password_reset'] ) ) {
return true;
}
@@ -262,7 +262,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
* @return bool
*/
function is_change_request() {
if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && $_POST['_um_account_tab'] == 'password' ) {
if ( isset( $_POST['_um_account'] ) == 1 && isset( $_POST['_um_account_tab'] ) && sanitize_key( $_POST['_um_account_tab'] ) === 'password' ) {
return true;
} elseif ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
return true;
@@ -275,12 +275,12 @@ if ( ! class_exists( 'um\core\Password' ) ) {
/**
* Password page form
*/
function form_init() {
public function form_init() {
if ( um_is_core_page( 'password-reset' ) ) {
UM()->fields()->set_mode = 'password';
}
if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'reset_password' ) {
if ( um_is_core_page( 'password-reset' ) && isset( $_REQUEST['act'] ) && 'reset_password' === sanitize_key( $_REQUEST['act'] ) ) {
wp_fix_server_vars();
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
@@ -292,7 +292,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
exit;
}
$rp_login = $userdata->user_login;
$rp_key = wp_unslash( $_GET['hash'] );
$rp_key = wp_unslash( sanitize_text_field( $_GET['hash'] ) );
$user = check_password_reset_key( $rp_key, $rp_login );
@@ -300,11 +300,11 @@ if ( ! class_exists( 'um\core\Password' ) ) {
$this->setcookie( $rp_cookie, false );
wp_redirect( add_query_arg( array( 'updated' => 'invalidkey' ), get_permalink() ) );
} else {
$value = sprintf( '%s:%s', $rp_login, wp_unslash( $_GET['hash'] ) );
$value = sprintf( '%s:%s', $rp_login, wp_unslash( sanitize_text_field( $_GET['hash'] ) ) );
$this->setcookie( $rp_cookie, $value );
wp_safe_redirect( remove_query_arg( array( 'hash', 'user_id' ) ) );
}
exit;
}
@@ -381,7 +381,6 @@ if ( ! class_exists( 'um\core\Password' ) ) {
do_action( 'um_reset_password_process_hook', UM()->form()->post_form );
}
}
if ( $this->is_change_request() ) {
@@ -432,7 +431,6 @@ if ( ! class_exists( 'um\core\Password' ) ) {
do_action( 'um_change_password_process_hook', UM()->form()->post_form );
}
}
}
@@ -442,26 +440,25 @@ if ( ! class_exists( 'um\core\Password' ) ) {
*
* @param $args
*/
function um_reset_password_errors_hook( $args ) {
if ( $_POST[ UM()->honeypot ] != '' ) {
wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
public function um_reset_password_errors_hook( $args ) {
if ( '' !== $args[ UM()->honeypot ] ) {
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
}
$user = "";
$user = '';
foreach ( $_POST as $key => $val ) {
if ( strstr( $key, "username_b") ) {
$user = trim( $val );
foreach ( $args as $key => $val ) {
if ( strstr( $key, 'username_b' ) ) {
$user = trim( sanitize_text_field( $val ) );
}
}
if ( empty( $user ) ) {
UM()->form()->add_error('username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
UM()->form()->add_error( 'username_b', __( 'Please provide your username or email', 'ultimate-member' ) );
}
if ( ( ! is_email( $user ) && ! username_exists( $user ) ) || ( is_email( $user ) && ! email_exists( $user ) ) ) {
UM()->form()->add_error('username_b', __( 'We can\'t find an account registered with that address or username','ultimate-member') );
UM()->form()->add_error( 'username_b', __( 'We can\'t find an account registered with that address or username', 'ultimate-member' ) );
} else {
if ( is_email( $user ) ) {
@@ -471,21 +468,19 @@ if ( ! class_exists( 'um\core\Password' ) ) {
}
$attempts = (int) get_user_meta( $user_id, 'password_rst_attempts', true );
$is_admin = user_can( absint( $user_id ),'manage_options' );
$is_admin = user_can( absint( $user_id ), 'manage_options' );
if ( UM()->options()->get( 'enable_reset_password_limit' ) ) { // if reset password limit is set
if ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) {
// Triggers this when a user has admin capabilities and when reset password limit is disabled for admins
} else {
if ( ! ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) ) {
// Doesn't trigger this when a user has admin capabilities and when reset password limit is disabled for admins
$limit = UM()->options()->get( 'reset_password_limit_number' );
if ( $attempts >= $limit ) {
UM()->form()->add_error( 'username_b', __( 'You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email','ultimate-member') );
UM()->form()->add_error( 'username_b', __( 'You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email', 'ultimate-member' ) );
} else {
update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 );
}
}
}
}
@@ -497,12 +492,12 @@ if ( ! class_exists( 'um\core\Password' ) ) {
*
* @param $args
*/
function um_reset_password_process_hook( $args ) {
public function um_reset_password_process_hook( $args ) {
$user = null;
foreach ( $_POST as $key => $val ) {
if ( strstr( $key, "username_b" ) ) {
$user = trim( $val );
foreach ( $args as $key => $val ) {
if ( strstr( $key, 'username_b' ) ) {
$user = trim( sanitize_text_field( $val ) );
}
}
@@ -525,20 +520,27 @@ if ( ! class_exists( 'um\core\Password' ) ) {
*
* @param $args
*/
function um_change_password_errors_hook( $args ) {
if ( isset( $_POST[ UM()->honeypot ] ) && $_POST[ UM()->honeypot ] != '' ) {
wp_die( __( 'Hello, spam bot!', 'ultimate-member' ) );
public function um_change_password_errors_hook( $args ) {
if ( isset( $args[ UM()->honeypot ] ) && '' !== $args[ UM()->honeypot ] ) {
wp_die( esc_html__( 'Hello, spam bot!', 'ultimate-member' ) );
}
if ( ! is_user_logged_in() && isset( $args ) && ! um_is_core_page( 'password-reset' ) ||
is_user_logged_in() && isset( $args['user_id'] ) && $args['user_id'] != get_current_user_id() ) {
wp_die( __( 'This is not possible for security reasons.', 'ultimate-member' ) );
is_user_logged_in() && isset( $args['user_id'] ) && absint( $args['user_id'] ) !== get_current_user_id() ) {
wp_die( esc_html__( 'This is not possible for security reasons.', 'ultimate-member' ) );
}
if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) {
UM()->form()->add_error( 'user_password', __( 'You must enter a new password', 'ultimate-member' ) );
}
if ( isset( $args['user_password'] ) ) {
$args['user_password'] = sanitize_text_field( $args['user_password'] );
}
if ( isset( $args['confirm_user_password'] ) ) {
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
}
if ( UM()->options()->get( 'reset_require_strongpass' ) ) {
if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
@@ -552,14 +554,13 @@ if ( ! class_exists( 'um\core\Password' ) ) {
if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
}
}
if ( isset( $args['confirm_user_password'] ) && empty( $args['confirm_user_password'] ) ) {
UM()->form()->add_error( 'confirm_user_password', __( 'You must confirm your new password', 'ultimate-member' ) );
}
if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] != $args['confirm_user_password'] ) {
if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] !== $args['confirm_user_password'] ) {
UM()->form()->add_error( 'confirm_user_password', __( 'Your passwords do not match', 'ultimate-member' ) );
}
@@ -571,13 +572,11 @@ if ( ! class_exists( 'um\core\Password' ) ) {
*
* @param $args
*/
function um_change_password_process_hook( $args ) {
extract( $args );
if ( isset( $_POST['_um_password_change'] ) && $_POST['_um_password_change'] == 1 ) {
public function um_change_password_process_hook( $args ) {
if ( isset( $args['_um_password_change'] ) && $args['_um_password_change'] == 1 ) {
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
$user = get_userdata( $args['user_id'] );
$user = get_userdata( absint( $args['user_id'] ) );
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
@@ -586,7 +585,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
$user = false;
} else {
$user = check_password_reset_key( $rp_key, $rp_login );
if ( isset( $_POST['user_password'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
if ( isset( $args['user_password'] ) && ! hash_equals( $rp_key, $args['rp_key'] ) ) {
$user = false;
}
}
@@ -617,7 +616,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
do_action( 'validate_password_reset', $errors, $user );
if ( ( ! $errors->get_error_code() ) ) {
reset_password( $user, $args['user_password'] );
reset_password( $user, sanitize_text_field( $args['user_password'] ) );
// send the Password Changed Email
UM()->user()->password_changed();
@@ -653,9 +652,9 @@ if ( ! class_exists( 'um\core\Password' ) ) {
* }
* ?>
*/
do_action( 'um_after_changing_user_password', $args['user_id'] );
do_action( 'um_after_changing_user_password', absint( $args['user_id'] ) );
exit( wp_redirect( um_get_core_page('login', 'password_changed' ) ) );
exit( wp_redirect( um_get_core_page( 'login', 'password_changed' ) ) );
}
}
}
@@ -714,4 +713,4 @@ if ( ! class_exists( 'um\core\Password' ) ) {
return $replace_placeholders;
}
}
}
}
+4 -4
View File
@@ -175,15 +175,15 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
/**
* Activates an account via email
*/
function activate_account_via_email_link() {
if ( isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'activate_via_email' && isset( $_REQUEST['hash'] ) && is_string( $_REQUEST['hash'] ) && strlen( $_REQUEST['hash'] ) == 40 &&
public function activate_account_via_email_link() {
if ( isset( $_REQUEST['act'] ) && 'activate_via_email' === sanitize_key( $_REQUEST['act'] ) && isset( $_REQUEST['hash'] ) && is_string( $_REQUEST['hash'] ) && strlen( $_REQUEST['hash'] ) == 40 &&
isset( $_REQUEST['user_id'] ) && is_numeric( $_REQUEST['user_id'] ) ) { // valid token
$user_id = absint( $_REQUEST['user_id'] );
delete_option( "um_cache_userdata_{$user_id}" );
$account_secret_hash = get_user_meta( $user_id, 'account_secret_hash', true );
if ( empty( $account_secret_hash ) || strtolower( $_REQUEST['hash'] ) !== strtolower( $account_secret_hash ) ) {
if ( empty( $account_secret_hash ) || strtolower( sanitize_text_field( $_REQUEST['hash'] ) ) !== strtolower( $account_secret_hash ) ) {
wp_die( __( 'This activation link is expired or have already been used.', 'ultimate-member' ) );
}
@@ -536,4 +536,4 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
return $url;
}
}
}
}
+27 -22
View File
@@ -55,16 +55,17 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
/**
* Delete profile avatar AJAX handler
*/
function ajax_delete_profile_photo() {
public function ajax_delete_profile_photo() {
UM()->check_ajax_nonce();
/**
* @var $user_id
*/
extract( $_REQUEST );
if ( ! array_key_exists( 'user_id', $_REQUEST ) ) {
wp_send_json_error( __( 'Invalid data', 'ultimate-member' ) );
}
$user_id = absint( $_REQUEST['user_id'] );
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
die( __( 'You can not edit this user' ) );
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
}
UM()->files()->delete_core_user_photo( $user_id, 'profile_photo' );
@@ -74,16 +75,17 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
/**
* Delete cover photo AJAX handler
*/
function ajax_delete_cover_photo() {
public function ajax_delete_cover_photo() {
UM()->check_ajax_nonce();
/**
* @var $user_id
*/
extract( $_REQUEST );
if ( ! array_key_exists( 'user_id', $_REQUEST ) ) {
wp_send_json_error( __( 'Invalid data', 'ultimate-member' ) );
}
$user_id = absint( $_REQUEST['user_id'] );
if ( ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
die( __( 'You can not edit this user' ) );
die( esc_html__( 'You can not edit this user', 'ultimate-member' ) );
}
UM()->files()->delete_core_user_photo( $user_id, 'cover_photo' );
@@ -95,15 +97,18 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
*
* @return array
*/
function tabs_privacy() {
$privacy = apply_filters( 'um_profile_tabs_privacy_list', array(
0 => __( 'Anyone', 'ultimate-member' ),
1 => __( 'Guests only', 'ultimate-member' ),
2 => __( 'Members only', 'ultimate-member' ),
3 => __( 'Only the owner', 'ultimate-member' ),
4 => __( 'Only specific roles', 'ultimate-member' ),
5 => __( 'Owner and specific roles', 'ultimate-member' ),
) );
public function tabs_privacy() {
$privacy = apply_filters(
'um_profile_tabs_privacy_list',
array(
0 => __( 'Anyone', 'ultimate-member' ),
1 => __( 'Guests only', 'ultimate-member' ),
2 => __( 'Members only', 'ultimate-member' ),
3 => __( 'Only the owner', 'ultimate-member' ),
4 => __( 'Only specific roles', 'ultimate-member' ),
5 => __( 'Owner and specific roles', 'ultimate-member' ),
)
);
return $privacy;
}
@@ -505,4 +510,4 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
}
}
}
}
+2 -2
View File
@@ -29,7 +29,7 @@ if ( ! class_exists( 'um\core\Query' ) ) {
/**
* Query constructor.
*/
function __construct() {
public function __construct() {
}
@@ -38,7 +38,7 @@ if ( ! class_exists( 'um\core\Query' ) ) {
/**
* Ajax pagination for posts
*/
function ajax_paginate() {
public function ajax_paginate() {
UM()->check_ajax_nonce();
/**
+10 -6
View File
@@ -382,21 +382,25 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
function get_priority_user_role( $user_id ) {
$user = get_userdata( $user_id );
if ( empty( $user->roles ) )
if ( empty( $user->roles ) ) {
return false;
}
// User has roles so look for a UM Role one
$um_roles_keys = get_option( 'um_roles', array() );
if ( ! empty( $um_roles_keys ) ) {
$um_roles_keys = array_map( function( $item ) {
return 'um_' . $item;
}, $um_roles_keys );
$um_roles_keys = array_map(
function( $item ) {
return 'um_' . $item;
},
$um_roles_keys
);
}
$orders = array();
foreach ( array_values( $user->roles ) as $userrole ) {
if ( ! empty( $um_roles_keys ) && in_array( $userrole, $um_roles_keys ) ) {
if ( ! empty( $um_roles_keys ) && in_array( $userrole, $um_roles_keys, true ) ) {
$userrole_metakey = substr( $userrole, 3 );
} else {
$userrole_metakey = $userrole;
@@ -727,4 +731,4 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
return false;
}
}
}
}
+5 -7
View File
@@ -161,18 +161,16 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
*/
function parse_shortcode_args( $args ) {
if ( $this->message_mode == true ) {
if ( ! empty( $_REQUEST['um_role'] ) ) {
$args['template'] = 'message';
$roleID = esc_attr( $_REQUEST['um_role'] );
$roleID = sanitize_key( $_REQUEST['um_role'] );
$role = UM()->roles()->role_data( $roleID );
if ( ! empty( $role ) && ! empty( $role["status"] ) ) {
$message_key = $role["status"] . '_message';
if ( ! empty( $role ) && ! empty( $role['status'] ) ) {
$message_key = $role['status'] . '_message';
$this->custom_message = ! empty( $role[ $message_key ] ) ? stripslashes( $role[ $message_key ] ) : '';
}
}
}
foreach ( $args as $k => $v ) {
@@ -676,7 +674,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
extract( $args, EXTR_SKIP );
//not display on admin preview
if ( empty( $_POST['act_id'] ) || $_POST['act_id'] != 'um_admin_preview_form' ) {
if ( empty( $_POST['act_id'] ) || sanitize_key( $_POST['act_id'] ) !== 'um_admin_preview_form' ) {
$enable_loggedin_registration = apply_filters( 'um_registration_for_loggedin_users', false, $args );
@@ -1266,7 +1264,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$hash = UM()->member_directory()->get_directory_hash( $directory_id );
$query[ 'search_' . $hash ] = ! empty( $_GET[ 'search_' . $hash ] ) ? $_GET[ 'search_' . $hash ] : '';
$query[ 'search_' . $hash ] = ! empty( $_GET[ 'search_' . $hash ] ) ? sanitize_text_field( $_GET[ 'search_' . $hash ] ) : '';
}
if ( empty( $query ) ) {
+3 -3
View File
@@ -103,8 +103,8 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
function load_posts() {
UM()->check_ajax_nonce();
$author = ! empty( $_POST['author'] ) ? $_POST['author'] : get_current_user_id();
$page = ! empty( $_POST['page'] ) ? $_POST['page'] : 0;
$author = ! empty( $_POST['author'] ) ? absint( $_POST['author'] ) : get_current_user_id();
$page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 0;
$args = array(
'post_type' => 'post',
@@ -244,4 +244,4 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
}
}
}
}
+10 -10
View File
@@ -347,8 +347,8 @@ if ( ! class_exists( 'um\core\User' ) ) {
}
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
}
}
@@ -368,8 +368,8 @@ if ( ! class_exists( 'um\core\User' ) ) {
}
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
}
}
@@ -383,7 +383,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
function get_pending_users_count() {
$cached_users_queue = get_option( 'um_cached_users_queue' );
if ( $cached_users_queue > 0 && ! isset( $_REQUEST['delete_count'] ) ){
if ( $cached_users_queue > 0 && ! isset( $_REQUEST['delete_count'] ) ) {
return $cached_users_queue;
}
@@ -592,8 +592,8 @@ if ( ! class_exists( 'um\core\User' ) ) {
//if there custom 2 role not empty
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
$user = get_userdata( $user_id );
$user->add_role( $_POST['um-role'] );
UM()->user()->profile['role'] = $_POST['um-role'];
$user->add_role( sanitize_key( $_POST['um-role'] ) );
UM()->user()->profile['role'] = sanitize_key( $_POST['um-role'] );
UM()->user()->update_usermeta_info( 'role' );
}
@@ -641,9 +641,9 @@ if ( ! class_exists( 'um\core\User' ) ) {
if ( is_admin() ) {
if ( ! empty( $_POST['um-role'] ) && current_user_can( 'promote_users' ) ) {
$new_roles = array_merge( $new_roles, array( $_POST['um-role'] ) );
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
$new_roles = array_merge( $new_roles, array( sanitize_key( $_POST['um-role'] ) ) );
if ( ! user_can( $user_id, sanitize_key( $_POST['um-role'] ) ) ) {
UM()->roles()->set_role( $user_id, sanitize_key( $_POST['um-role'] ) );
}
}
}
+206 -164
View File
@@ -1,4 +1,6 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
@@ -7,161 +9,182 @@
* @param array $args
*/
function um_submit_account_errors_hook( $args ) {
if ( ! isset( $_POST['_um_account'] ) && ! isset( $_POST['_um_account_tab'] ) ) {
if ( ! isset( $args['_um_account'] ) && ! isset( $args['_um_account_tab'] ) ) {
return;
}
if ( ! wp_verify_nonce( $_POST[ 'um_account_nonce_' . $_POST['_um_account_tab'] ], 'um_update_account_' . $_POST['_um_account_tab'] ) ) {
UM()->form()->add_error('um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
$tab = sanitize_key( $args['_um_account_tab'] );
if ( ! wp_verify_nonce( $args[ 'um_account_nonce_' . $tab ], 'um_update_account_' . $tab ) ) {
UM()->form()->add_error( 'um_account_security', __( 'Are you hacking? Please try again!', 'ultimate-member' ) );
}
$user = get_user_by( 'login', um_user( 'user_login' ) );
if ( isset( $_POST['_um_account_tab'] ) ) {
switch ( $_POST['_um_account_tab'] ) {
case 'delete': {
// delete account
if ( UM()->account()->current_password_is_required( 'delete' ) ) {
if ( strlen( trim( $_POST['single_user_password'] ) ) == 0 ) {
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
} else {
if ( ! wp_check_password( $_POST['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
}
switch ( $tab ) {
case 'delete': {
// delete account
if ( UM()->account()->current_password_is_required( 'delete' ) ) {
if ( strlen( trim( sanitize_text_field( $args['single_user_password'] ) ) ) === 0 ) {
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
} else {
if ( ! wp_check_password( sanitize_text_field( $args['single_user_password'] ), $user->data->user_pass, $user->data->ID ) ) {
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
}
}
UM()->account()->current_tab = 'delete';
break;
}
case 'password': {
UM()->account()->current_tab = 'delete';
// change password
UM()->account()->current_tab = 'password';
if ( empty( $_POST['user_password'] ) ) {
UM()->form()->add_error('user_password', __( 'Password is required', 'ultimate-member' ) );
return;
}
if ( empty( $_POST['confirm_user_password'] ) ) {
UM()->form()->add_error('user_password', __( 'Password confirmation is required', 'ultimate-member' ) );
return;
}
if ( ! empty( $_POST['user_password'] ) && ! empty( $_POST['confirm_user_password'] ) ) {
if ( UM()->account()->current_password_is_required( 'password' ) ) {
if ( empty( $_POST['current_user_password'] ) ) {
UM()->form()->add_error('current_user_password', __( 'This is not your password', 'ultimate-member' ) );
return;
} else {
if ( ! wp_check_password( $_POST['current_user_password'], $user->data->user_pass, $user->data->ID ) ) {
UM()->form()->add_error('current_user_password', __( 'This is not your password', 'ultimate-member' ) );
return;
}
}
}
if ( $_POST['user_password'] != $_POST['confirm_user_password'] && $_POST['user_password'] ) {
UM()->form()->add_error('user_password', __( 'Your new password does not match', 'ultimate-member' ) );
return;
}
if ( UM()->options()->get( 'account_require_strongpass' ) ) {
if ( strlen( utf8_decode( $_POST['user_password'] ) ) < 8 ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least 8 characters', 'ultimate-member' ) );
}
if ( strlen( utf8_decode( $_POST['user_password'] ) ) > 30 ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain less than 30 characters', 'ultimate-member' ) );
}
if ( ! UM()->validation()->strong_pass( $_POST['user_password'] ) ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
}
}
}
break;
}
case 'account':
case 'general': {
// errors on general tab
$account_name_require = UM()->options()->get( 'account_name_require' );
if ( ! empty( $_POST['user_login'] ) && ! validate_username( $_POST['user_login'] ) ) {
UM()->form()->add_error('user_login', __( 'Your username is invalid', 'ultimate-member' ) );
return;
}
if ( isset( $_POST['first_name'] ) && ( strlen( trim( $_POST['first_name'] ) ) == 0 && $account_name_require ) ) {
UM()->form()->add_error( 'first_name', __( 'You must provide your first name', 'ultimate-member' ) );
}
if ( isset( $_POST['last_name'] ) && ( strlen( trim( $_POST['last_name'] ) ) == 0 && $account_name_require ) ) {
UM()->form()->add_error( 'last_name', __( 'You must provide your last name', 'ultimate-member' ) );
}
if ( isset( $_POST['user_email'] ) ) {
if ( strlen( trim( $_POST['user_email'] ) ) == 0 ) {
UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
}
if ( ! is_email( $_POST['user_email'] ) ) {
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
}
if ( email_exists( $_POST['user_email'] ) && email_exists( $_POST['user_email'] ) != get_current_user_id() ) {
UM()->form()->add_error( 'user_email', __( 'Email already linked to another account', 'ultimate-member' ) );
}
}
// check account password
if ( UM()->account()->current_password_is_required( 'general' ) ) {
if ( strlen( trim( $_POST['single_user_password'] ) ) == 0 ) {
UM()->form()->add_error('single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
} else {
if ( ! wp_check_password( $_POST['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
UM()->form()->add_error('single_user_password', __( 'This is not your password', 'ultimate-member' ) );
}
}
}
break;
}
default:
/**
* UM hook
*
* @type action
* @title um_submit_account_{$tab}_tab_errors_hook
* @description On submit account current $tab validation
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'function_name', 10 );
* @example
* <?php
* add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'my_submit_account_tab_errors', 10 );
* function my_submit_account_tab_errors() {
* // your code here
* }
* ?>
*/
do_action( 'um_submit_account_' . $_POST['_um_account_tab'] . '_tab_errors_hook' );
break;
break;
}
UM()->account()->current_tab = $_POST['_um_account_tab'];
case 'password': {
// change password
UM()->account()->current_tab = 'password';
if ( isset( $args['user_password'] ) ) {
$args['user_password'] = sanitize_text_field( $args['user_password'] );
}
if ( isset( $args['confirm_user_password'] ) ) {
$args['confirm_user_password'] = sanitize_text_field( $args['confirm_user_password'] );
}
if ( empty( $args['user_password'] ) ) {
UM()->form()->add_error( 'user_password', __( 'Password is required', 'ultimate-member' ) );
return;
}
if ( empty( $args['confirm_user_password'] ) ) {
UM()->form()->add_error( 'user_password', __( 'Password confirmation is required', 'ultimate-member' ) );
return;
}
if ( ! empty( $args['user_password'] ) && ! empty( $args['confirm_user_password'] ) ) {
if ( UM()->account()->current_password_is_required( 'password' ) ) {
if ( empty( $args['current_user_password'] ) ) {
UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
return;
} else {
if ( ! wp_check_password( $args['current_user_password'], $user->data->user_pass, $user->data->ID ) ) {
UM()->form()->add_error( 'current_user_password', __( 'This is not your password', 'ultimate-member' ) );
return;
}
}
}
if ( $args['user_password'] && $args['user_password'] !== $args['confirm_user_password'] ) {
UM()->form()->add_error( 'user_password', __( 'Your new password does not match', 'ultimate-member' ) );
return;
}
if ( UM()->options()->get( 'account_require_strongpass' ) ) {
if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least 8 characters', 'ultimate-member' ) );
}
if ( strlen( utf8_decode( $args['user_password'] ) ) > 30 ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain less than 30 characters', 'ultimate-member' ) );
}
if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) {
UM()->form()->add_error( 'user_password', __( 'Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimate-member' ) );
}
}
}
break;
}
case 'account':
case 'general': {
// errors on general tab
$account_name_require = UM()->options()->get( 'account_name_require' );
if ( isset( $args['user_login'] ) ) {
$args['user_login'] = sanitize_text_field( $args['user_login'] );
}
if ( isset( $args['first_name'] ) ) {
$args['first_name'] = sanitize_text_field( $args['first_name'] );
}
if ( isset( $args['last_name'] ) ) {
$args['last_name'] = sanitize_text_field( $args['last_name'] );
}
if ( isset( $args['user_email'] ) ) {
$args['user_email'] = sanitize_email( $args['user_email'] );
}
if ( isset( $args['single_user_password'] ) ) {
$args['single_user_password'] = sanitize_text_field( $args['single_user_password'] );
}
if ( ! empty( $args['user_login'] ) && ! validate_username( $args['user_login'] ) ) {
UM()->form()->add_error( 'user_login', __( 'Your username is invalid', 'ultimate-member' ) );
return;
}
if ( isset( $args['first_name'] ) && ( strlen( trim( $args['first_name'] ) ) === 0 && $account_name_require ) ) {
UM()->form()->add_error( 'first_name', __( 'You must provide your first name', 'ultimate-member' ) );
}
if ( isset( $args['last_name'] ) && ( strlen( trim( $args['last_name'] ) ) === 0 && $account_name_require ) ) {
UM()->form()->add_error( 'last_name', __( 'You must provide your last name', 'ultimate-member' ) );
}
if ( isset( $args['user_email'] ) ) {
if ( strlen( trim( $args['user_email'] ) ) === 0 ) {
UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
}
if ( ! is_email( $args['user_email'] ) ) {
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
}
if ( email_exists( $args['user_email'] ) && email_exists( $args['user_email'] ) !== get_current_user_id() ) {
UM()->form()->add_error( 'user_email', __( 'Email already linked to another account', 'ultimate-member' ) );
}
}
// check account password
if ( UM()->account()->current_password_is_required( 'general' ) ) {
if ( strlen( trim( $args['single_user_password'] ) ) === 0 ) {
UM()->form()->add_error( 'single_user_password', __( 'You must enter your password', 'ultimate-member' ) );
} else {
if ( ! wp_check_password( $args['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
UM()->form()->add_error( 'single_user_password', __( 'This is not your password', 'ultimate-member' ) );
}
}
}
break;
}
default:
/**
* UM hook
*
* @type action
* @title um_submit_account_{$tab}_tab_errors_hook
* @description On submit account current $tab validation
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'function_name', 10 );
* @example
* <?php
* add_action( 'um_submit_account_{$tab}_tab_errors_hook', 'my_submit_account_tab_errors', 10 );
* function my_submit_account_tab_errors() {
* // your code here
* }
* ?>
*/
do_action( 'um_submit_account_' . $tab . '_tab_errors_hook' );
break;
}
UM()->account()->current_tab = $tab;
}
add_action( 'um_submit_account_errors_hook', 'um_submit_account_errors_hook' );
@@ -172,16 +195,16 @@ add_action( 'um_submit_account_errors_hook', 'um_submit_account_errors_hook' );
* @param $args
*/
function um_submit_account_details( $args ) {
$tab = ( get_query_var('um_tab') ) ? get_query_var('um_tab') : 'general';
$tab = ( get_query_var( 'um_tab' ) ) ? get_query_var( 'um_tab' ) : 'general';
$current_tab = isset( $_POST['_um_account_tab'] ) ? $_POST['_um_account_tab']: '';
$current_tab = isset( $args['_um_account_tab'] ) ? sanitize_key( $args['_um_account_tab'] ) : '';
$user_id = um_user('ID');
$user_id = um_user( 'ID' );
//change password account's tab
if ( 'password' == $current_tab && $_POST['user_password'] && $_POST['confirm_user_password'] ) {
if ( 'password' === $current_tab && $args['user_password'] && $args['confirm_user_password'] ) {
$changes['user_pass'] = $_POST['user_password'];
$changes['user_pass'] = sanitize_text_field( $args['user_password'] );
$args['user_id'] = $user_id;
@@ -195,16 +218,20 @@ function um_submit_account_details( $args ) {
wp_set_password( $changes['user_pass'], $user_id );
wp_signon( array( 'user_login' => um_user( 'user_login' ), 'user_password' => $changes['user_pass'] ) );
wp_signon(
array(
'user_login' => um_user( 'user_login' ),
'user_password' => $changes['user_pass'],
)
);
}
// delete account
if ( 'delete' == $current_tab ) {
if ( 'delete' === $current_tab ) {
if ( current_user_can( 'delete_users' ) || um_user( 'can_delete_profile' ) ) {
UM()->user()->delete();
if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) == 'redirect_home' ) {
if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) === 'redirect_home' ) {
um_redirect_home();
} elseif ( um_user( 'delete_redirect_url' ) ) {
/**
@@ -271,26 +298,40 @@ function um_submit_account_details( $args ) {
}
$changes = array();
foreach ( $_POST as $k => $v ) {
if ( ! in_array( $k, $arr_fields ) ) {
foreach ( $args as $k => $v ) {
if ( ! in_array( $k, $arr_fields, true ) ) {
continue;
}
if ( $k == 'single_user_password' ) {
if ( 'single_user_password' === $k ) {
continue;
}
if ( 'user_login' === $k ) {
$v = sanitize_user( $v );
} elseif ( 'first_name' === $k ) {
$v = sanitize_text_field( $v );
} elseif ( 'last_name' === $k ) {
$v = sanitize_text_field( $v );
} elseif ( 'user_email' === $k ) {
$v = sanitize_email( $v );
} elseif ( 'user_password' === $k ) {
$v = sanitize_text_field( $v );
} elseif ( 'hide_in_members' === $k ) {
$v = array_map( 'sanitize_text_field', $v );
}
$changes[ $k ] = $v;
}
if ( isset( $changes['hide_in_members'] ) ) {
if ( UM()->member_directory()->get_hide_in_members_default() ) {
if ( $changes['hide_in_members'] == __( 'Yes', 'ultimate-member' ) || $changes['hide_in_members'] == 'Yes' || array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
if ( __( 'Yes', 'ultimate-member' ) === $changes['hide_in_members'] || 'Yes' === $changes['hide_in_members'] || array_intersect( array( 'Yes', __( 'Yes', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
delete_user_meta( $user_id, 'hide_in_members' );
unset( $changes['hide_in_members'] );
}
} else {
if ( $changes['hide_in_members'] == __( 'No', 'ultimate-member' ) || $changes['hide_in_members'] == 'No' || array_intersect( array( 'No', __( 'No', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
if ( __( 'No', 'ultimate-member' ) === $changes['hide_in_members'] || 'No' === $changes['hide_in_members'] || array_intersect( array( 'No', __( 'No', 'ultimate-member' ) ), $changes['hide_in_members'] ) ) {
delete_user_meta( $user_id, 'hide_in_members' );
unset( $changes['hide_in_members'] );
}
@@ -667,19 +708,20 @@ function um_request_user_data() {
wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
}
$user_id = get_current_user_id();
$password = ! empty( $_POST['password'] ) ? $_POST['password'] : '';
$user = get_userdata( $user_id );
$hash = $user->data->user_pass;
$user_id = get_current_user_id();
$password = ! empty( $_POST['password'] ) ? sanitize_text_field( $_POST['password'] ) : '';
$user = get_userdata( $user_id );
$hash = $user->data->user_pass;
$request_action = sanitize_key( $_POST['request_action'] );
if ( $_POST['request_action'] == 'um-export-data' ) {
if ( 'um-export-data' === $request_action ) {
if ( UM()->account()->current_password_is_required( 'privacy_download_data' ) ) {
if ( ! wp_check_password( $password, $hash ) ) {
$answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
wp_send_json_success( array( 'answer' => $answer ) );
}
}
} elseif ( $_POST['request_action'] == 'um-erase-data' ) {
} elseif ( 'um-erase-data' === $request_action ) {
if ( UM()->account()->current_password_is_required( 'privacy_erase_data' ) ) {
if ( ! wp_check_password( $password, $hash ) ) {
$answer = esc_html__( 'The password you entered is incorrect.', 'ultimate-member' );
@@ -688,13 +730,13 @@ function um_request_user_data() {
}
}
if ( $_POST['request_action'] == 'um-export-data' ) {
if ( 'um-export-data' === $request_action ) {
$request_id = wp_create_user_request( $user->data->user_email, 'export_personal_data' );
} elseif ( $_POST['request_action'] == 'um-erase-data' ) {
} elseif ( 'um-erase-data' === $request_action ) {
$request_id = wp_create_user_request( $user->data->user_email, 'remove_personal_data' );
}
if ( ! isset( $request_id ) || empty( $request_id ) ) {
if ( ! isset( $request_id ) || empty( $request_id ) ) {
wp_send_json_error( __( 'Wrong request.', 'ultimate-member' ) );
}
@@ -707,4 +749,4 @@ function um_request_user_data() {
wp_send_json_success( array( 'answer' => $answer ) );
}
add_action( 'wp_ajax_um_request_user_data', 'um_request_user_data' );
add_action( 'wp_ajax_um_request_user_data', 'um_request_user_data' );
+2 -2
View File
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
function ultimatemember_check_username_exists() {
UM()->check_ajax_nonce();
$username = isset( $_REQUEST['username'] ) ? $_REQUEST['username'] : '';
$username = isset( $_REQUEST['username'] ) ? sanitize_user( $_REQUEST['username'] ) : '';
$exists = username_exists( $username );
/**
@@ -46,4 +46,4 @@ function ultimatemember_check_username_exists() {
die();
}
add_action('wp_ajax_nopriv_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
add_action('wp_ajax_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
add_action('wp_ajax_ultimatemember_check_username_exists', 'ultimatemember_check_username_exists');
+22 -25
View File
@@ -1,5 +1,6 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Processes the requests of UM actions
@@ -18,29 +19,25 @@ function um_action_request_process() {
return;
}
if ( isset( $_REQUEST['uid'] ) && ! UM()->user()->user_exists_by_id( absint( $_REQUEST['uid'] ) ) ) {
return;
}
if ( isset( $_REQUEST['uid'] ) ) {
if ( is_super_admin( $_REQUEST['uid'] ) ) {
wp_die( __( 'Super administrators can not be modified.', 'ultimate-member' ) );
}
}
// if ( isset( $_REQUEST['um_action'] ) && $_REQUEST['um_action'] != "edit" && ! current_user_can( 'edit_users' ) ) {
// wp_die( __( 'You do not have enough permissions to do that.','ultimate-member') );
// }
$action = sanitize_key( $_REQUEST['um_action'] );
$uid = 0;
if ( isset( $_REQUEST['uid'] ) ) {
$uid = absint( $_REQUEST['uid'] );
}
$role = get_role( UM()->roles()->get_priority_user_role( get_current_user_id() ) );
if ( ! empty( $uid ) && ! UM()->user()->user_exists_by_id( $uid ) ) {
return;
}
if ( ! empty( $uid ) && is_super_admin( $uid ) ) {
wp_die( esc_html__( 'Super administrators can not be modified.', 'ultimate-member' ) );
}
$role = get_role( UM()->roles()->get_priority_user_role( get_current_user_id() ) );
$can_edit_users = current_user_can( 'edit_users' ) && $role->has_cap( 'edit_users' );
switch ( $_REQUEST['um_action'] ) {
switch ( $action ) {
default:
/**
* UM hook
@@ -62,7 +59,7 @@ function um_action_request_process() {
* }
* ?>
*/
do_action( 'um_action_user_request_hook', $_REQUEST['um_action'], $uid );
do_action( 'um_action_user_request_hook', $action, $uid );
break;
case 'edit':
@@ -89,7 +86,7 @@ function um_action_request_process() {
case 'um_reject_membership':
if ( ! $can_edit_users ) {
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
}
um_fetch_user( $uid );
@@ -100,7 +97,7 @@ function um_action_request_process() {
case 'um_approve_membership':
case 'um_reenable':
if ( ! $can_edit_users ) {
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
}
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
@@ -113,7 +110,7 @@ function um_action_request_process() {
case 'um_put_as_pending':
if ( ! $can_edit_users ) {
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
}
um_fetch_user( $uid );
@@ -123,7 +120,7 @@ function um_action_request_process() {
case 'um_resend_activation':
if ( ! $can_edit_users ) {
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
}
add_filter( 'um_template_tags_patterns_hook', array( UM()->user(), 'add_activation_placeholder' ), 10, 1 );
@@ -136,7 +133,7 @@ function um_action_request_process() {
case 'um_deactivate':
if ( ! $can_edit_users ) {
wp_die( __( 'You do not have permission to make this action.', 'ultimate-member' ) );
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
}
um_fetch_user( $uid );
@@ -146,7 +143,7 @@ function um_action_request_process() {
case 'um_delete':
if ( ! UM()->roles()->um_current_user_can( 'delete', $uid ) ) {
wp_die( __( 'You do not have permission to delete this user.', 'ultimate-member' ) );
wp_die( esc_html__( 'You do not have permission to delete this user.', 'ultimate-member' ) );
}
um_fetch_user( $uid );
@@ -156,4 +153,4 @@ function um_action_request_process() {
}
}
add_action( 'template_redirect', 'um_action_request_process', 10000 );
add_action( 'template_redirect', 'um_action_request_process', 10000 );
+5 -5
View File
@@ -127,7 +127,7 @@ function um_submit_form_errors_hook_logincheck( $args ) {
um_fetch_user( $user_id );
$status = um_user( 'account_status' ); // account status
switch( $status ) {
switch ( $status ) {
// If user can't login to site...
case 'inactive':
@@ -135,7 +135,7 @@ function um_submit_form_errors_hook_logincheck( $args ) {
case 'awaiting_email_confirmation':
case 'rejected':
um_reset_user();
exit( wp_redirect( add_query_arg( 'err', esc_attr( $status ), UM()->permalinks()->get_current_url() ) ) );
exit( wp_redirect( add_query_arg( 'err', esc_attr( $status ), UM()->permalinks()->get_current_url() ) ) );
break;
}
@@ -183,10 +183,10 @@ add_action( 'wp_login', 'um_store_lastlogin_timestamp_' );
function um_user_login( $args ) {
extract( $args );
$rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
$rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0;
if ( ( UM()->options()->get( 'deny_admin_frontend_login' ) && ! isset( $_GET['provider'] ) ) && strrpos( um_user('wp_roles' ), 'administrator' ) !== false ) {
wp_die( __( 'This action has been prevented for security measures.', 'ultimate-member' ) );
wp_die( esc_html__( 'This action has been prevented for security measures.', 'ultimate-member' ) );
}
UM()->user()->auto_login( um_user( 'ID' ), $rememberme );
@@ -475,4 +475,4 @@ add_action( 'um_after_login_fields', 'um_after_login_submit', 1001 );
function um_add_login_fields( $args ) {
echo UM()->fields()->display( 'login', $args );
}
add_action( 'um_main_login_fields', 'um_add_login_fields', 100 );
add_action( 'um_main_login_fields', 'um_add_login_fields', 100 );
+11 -11
View File
@@ -1,6 +1,6 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
@@ -13,7 +13,7 @@ function um_browser_url_redirect_to( $args ) {
if ( ! empty( $_REQUEST['redirect_to'] ) ) {
$url = $_REQUEST['redirect_to'];
$url = esc_url_raw( $_REQUEST['redirect_to'] );
} elseif ( ! empty( $args['after_login'] ) ) {
@@ -75,12 +75,12 @@ add_action( 'um_after_form_fields', 'um_browser_url_redirect_to' );
function um_add_update_notice( $args ) {
extract( $args );
$output = '';
$err = '';
$output = '';
$err = '';
$success = '';
if ( ! empty( $_REQUEST['updated'] ) && ! UM()->form()->errors ) {
switch ( $_REQUEST['updated'] ) {
switch ( sanitize_key( $_REQUEST['updated'] ) ) {
default:
/**
* UM hook
@@ -104,7 +104,7 @@ function um_add_update_notice( $args ) {
* }
* ?>
*/
$success = apply_filters( 'um_custom_success_message_handler', $success, $_REQUEST['updated'] );
$success = apply_filters( 'um_custom_success_message_handler', $success, sanitize_key( $_REQUEST['updated'] ) );
break;
case 'account':
@@ -123,7 +123,7 @@ function um_add_update_notice( $args ) {
}
if ( ! empty( $_REQUEST['err'] ) && ! UM()->form()->errors ) {
switch( $_REQUEST['err'] ) {
switch( sanitize_key( $_REQUEST['err'] ) ) {
default:
/**
@@ -148,7 +148,7 @@ function um_add_update_notice( $args ) {
* }
* ?>
*/
$err = apply_filters( 'um_custom_error_message_handler', $err, $_REQUEST['err'] );
$err = apply_filters( 'um_custom_error_message_handler', $err, sanitize_key( $_REQUEST['err'] ) );
if ( ! $err ) {
$err = __( 'An error has been encountered', 'ultimate-member' );
}
@@ -203,4 +203,4 @@ function um_add_update_notice( $args ) {
echo $output;
}
add_action( 'um_before_form', 'um_add_update_notice', 500 );
add_action( 'um_before_form', 'um_add_update_notice', 500 );
+5 -5
View File
@@ -168,16 +168,16 @@ function um_profile_content_main( $args ) {
*/
do_action( 'um_after_form', $args );
} else { ?>
} else {
?>
<div class="um-profile-note">
<span>
<i class="um-faicon-lock"></i>
<?php echo $can_view; ?>
</span>
</div>
<?php }
<?php
}
}
add_action( 'um_profile_content_main', 'um_profile_content_main' );
@@ -1732,4 +1732,4 @@ function um_profile_menu( $args ) {
}
}
add_action( 'um_profile_menu', 'um_profile_menu', 9 );
add_action( 'um_profile_menu', 'um_profile_menu', 9 );
+4 -5
View File
@@ -1,13 +1,12 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Checks if user can access the backend
*/
function um_block_wpadmin_by_user_role() {
global $pagenow;
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
@@ -49,4 +48,4 @@ add_filter( 'show_admin_bar', 'um_control_admin_bar', 9999, 1 );
function um_force_admin_bar() {
um_reset_user();
}
add_action( 'wp_footer', 'um_force_admin_bar' );
add_action( 'wp_footer', 'um_force_admin_bar' );
+12 -14
View File
@@ -1,4 +1,6 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
@@ -55,7 +57,7 @@ function um_profile_field_filter_hook__youtube_video( $value, $data ) {
if ( empty( $value ) ) {
return '';
}
$value = ( strstr( $value, 'http') || strstr( $value, '://' ) ) ? um_youtube_id_from_url( $value ) : $value;
$value = ( strstr( $value, 'http' ) || strstr( $value, '://' ) ) ? um_youtube_id_from_url( $value ) : $value;
$value = '<div class="um-youtube">
<iframe width="600" height="450" src="https://www.youtube.com/embed/' . $value . '" frameborder="0" allowfullscreen></iframe>
</div>';
@@ -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 = '<div class="um-vimeo">
<iframe src="https://player.vimeo.com/video/'. $value . '" width="600" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://player.vimeo.com/video/' . $value . '" width="600" height="450" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>';
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 );
add_filter( 'um_edit_url_field_value', 'um_edit_url_field_value', 10, 2 );
+13 -9
View File
@@ -1,4 +1,6 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
@@ -10,16 +12,18 @@
*/
function um_whitelisted_wpadmin_access( $allowed ) {
$ips = UM()->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 );
add_filter( 'lostpassword_url', 'um_lostpassword_url', 10, 1 );
+7 -7
View File
@@ -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 );
}
}
+1 -1
View File
@@ -25,4 +25,4 @@
</div>
</div>
</div>
+4 -4
View File
@@ -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 ); ?>
</div>
</div>
+8 -6
View File
@@ -1,13 +1,15 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
} ?>
<div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?>">
<div class="um-form">
<form method="post" action="">
<?php if ( isset( $_GET['updated'] ) && 'checkemail' == $_GET['updated'] ) { ?>
<?php if ( isset( $_GET['updated'] ) && 'checkemail' === sanitize_key( $_GET['updated'] ) ) { ?>
<div class="um-field um-field-block um-field-type_block">
<div class="um-field-block">
<div style="text-align:center;">
<?php _e( 'We have sent you a password reset link to your e-mail. Please check your inbox.', 'ultimate-member' ); ?>
<?php esc_html_e( 'We have sent you a password reset link to your e-mail. Please check your inbox.', 'ultimate-member' ); ?>
</div>
</div>
</div>
@@ -41,9 +43,9 @@
<div class="um-field um-field-block um-field-type_block">
<div class="um-field-block">
<div style="text-align:center;">
<?php if ( 'expiredkey' == $_GET['updated'] ) {
<?php if ( 'expiredkey' === sanitize_key( $_GET['updated'] ) ) {
_e( 'Your password reset link has expired. Please request a new link below.', 'ultimate-member' );
} elseif ( 'invalidkey' == $_GET['updated'] ) {
} elseif ( 'invalidkey' === sanitize_key( $_GET['updated'] ) ) {
_e( 'Your password reset link appears to be invalid. Please request a new link below.', 'ultimate-member' );
} ?>
</div>
@@ -143,4 +145,4 @@
} ?>
</form>
</div>
</div>
</div>