From 72a1e9a7c3670bdab724dd34c4ab8655e8b610c7 Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Mon, 2 Mar 2020 16:47:56 +0200 Subject: [PATCH] - small code formatting; --- includes/core/class-fields.php | 2 +- includes/core/class-files.php | 4 +-- includes/core/class-form.php | 10 +++---- includes/core/class-password.php | 2 +- includes/core/class-permalinks.php | 15 ++++++----- includes/core/class-user.php | 12 ++++----- includes/core/um-actions-ajax.php | 2 +- includes/core/um-actions-core.php | 8 +++--- includes/core/um-actions-login.php | 6 ++--- includes/core/um-actions-misc.php | 43 +++++++++++++++--------------- includes/core/um-filters-login.php | 8 +++--- includes/um-short-functions.php | 3 ++- 12 files changed, 59 insertions(+), 56 deletions(-) diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 8422e6e9..d7bb491f 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -49,7 +49,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { /** * Set value on form submission */ - if( isset( $_REQUEST[ $id ] ) ){ + if ( isset( $_REQUEST[ $id ] ) ) { $checked = $_REQUEST[ $id ]; } diff --git a/includes/core/class-files.php b/includes/core/class-files.php index d6eec878..2d7f236f 100644 --- a/includes/core/class-files.php +++ b/includes/core/class-files.php @@ -361,7 +361,7 @@ if ( ! class_exists( 'um\core\Files' ) ) { $id = $_POST['key']; $timestamp = $_POST['timestamp']; $nonce = $_POST['_wpnonce']; - $user_id = empty( $_POST['user_id'] ) ? get_current_user_id() : $_POST['user_id']; + $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']; @@ -481,7 +481,7 @@ if ( ! class_exists( 'um\core\Files' ) ) { if ( ! is_array( $_FILES[ $id ]['name'] ) ) { - $user_id = $_POST['user_id']; + $user_id = absint( $_POST['user_id'] ); UM()->uploader()->replace_upload_dir = true; $uploaded = UM()->uploader()->upload_file( $_FILES[ $id ], $user_id, $id ); diff --git a/includes/core/class-form.php b/includes/core/class-form.php index a2c37d66..dcf7be4b 100644 --- a/includes/core/class-form.php +++ b/includes/core/class-form.php @@ -156,7 +156,7 @@ if ( ! class_exists( 'um\core\Form' ) ) { ); } - if ( isset( $_POST['child_callback'] ) && ! empty( $_POST['child_callback'] ) && isset( $form_fields[ $_POST['child_name'] ] ) ){ + if ( ! empty( $_POST['child_callback'] ) && isset( $form_fields[ $_POST['child_name'] ] ) ) { $ajax_source_func = $_POST['child_callback']; @@ -167,13 +167,13 @@ if ( ! class_exists( 'um\core\Form' ) ) { $arr_options['field'] = $form_fields[ $_POST['child_name'] ]; - if( function_exists( $ajax_source_func ) ){ - $arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] ); + if ( function_exists( $ajax_source_func ) ) { + $arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] ); } } else { $arr_options['status'] = 'error'; - $arr_options['message'] = __( 'This is not possible for security reasons.','ultimate-member'); + $arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' ); } } @@ -335,7 +335,7 @@ if ( ! class_exists( 'um\core\Form' ) ) { * } * ?> */ - do_action( "um_before_submit_form_post", $_POST ); + do_action( 'um_before_submit_form_post', $_POST ); $this->form_id = $_POST['form_id']; $this->form_status = get_post_status( $this->form_id ); diff --git a/includes/core/class-password.php b/includes/core/class-password.php index ee6c759c..dfd71899 100644 --- a/includes/core/class-password.php +++ b/includes/core/class-password.php @@ -286,7 +286,7 @@ if ( ! class_exists( 'um\core\Password' ) ) { $rp_cookie = 'wp-resetpass-' . COOKIEHASH; if ( isset( $_GET['hash'] ) ) { - $userdata = get_userdata( wp_unslash( $_GET['user_id'] ) ); + $userdata = get_userdata( wp_unslash( absint( $_GET['user_id'] ) ) ); if ( ! $userdata || is_wp_error( $userdata ) ) { wp_redirect( add_query_arg( array( 'act' => 'reset_password', 'error' => 'invalidkey' ), get_permalink() ) ); exit; diff --git a/includes/core/class-permalinks.php b/includes/core/class-permalinks.php index 36bece7f..c7cd6048 100644 --- a/includes/core/class-permalinks.php +++ b/includes/core/class-permalinks.php @@ -179,24 +179,25 @@ 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 && - isset($_REQUEST['user_id']) && is_numeric($_REQUEST['user_id']) ) { // valid token + if ( isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'activate_via_email' && 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}" ); um_fetch_user( $user_id ); - if ( strtolower($_REQUEST['hash']) !== strtolower( um_user('account_secret_hash') ) ) - wp_die( __( 'This activation link is expired or have already been used.','ultimate-member' ) ); + if ( strtolower( $_REQUEST['hash'] ) !== strtolower( um_user( 'account_secret_hash' ) ) ) { + wp_die( __( 'This activation link is expired or have already been used.', 'ultimate-member' ) ); + } UM()->user()->approve(); - $redirect = ( um_user('url_email_activate') ) ? um_user('url_email_activate') : um_get_core_page('login', 'account_active'); - $login = (bool) um_user('login_email_activate'); + $redirect = ( um_user( 'url_email_activate' ) ) ? um_user( 'url_email_activate' ) : um_get_core_page( 'login', 'account_active' ); + $login = (bool) um_user( 'login_email_activate' ); // log in automatically if ( ! is_user_logged_in() && $login ) { - $user = get_userdata($user_id); + $user = get_userdata( $user_id ); $user_id = $user->ID; // update wp user diff --git a/includes/core/class-user.php b/includes/core/class-user.php index abb0e722..fe99128c 100644 --- a/includes/core/class-user.php +++ b/includes/core/class-user.php @@ -387,14 +387,14 @@ if ( ! class_exists( 'um\core\User' ) ) { $args = array( 'fields' => 'ID', 'number' => 1 ); $args['meta_query']['relation'] = 'OR'; $args['meta_query'][] = array( - 'key' => 'account_status', - 'value' => 'awaiting_email_confirmation', - 'compare' => '=' + 'key' => 'account_status', + 'value' => 'awaiting_email_confirmation', + 'compare' => '=' ); $args['meta_query'][] = array( - 'key' => 'account_status', - 'value' => 'awaiting_admin_review', - 'compare' => '=' + 'key' => 'account_status', + 'value' => 'awaiting_admin_review', + 'compare' => '=' ); /** diff --git a/includes/core/um-actions-ajax.php b/includes/core/um-actions-ajax.php index d8d82ba7..3bc5969f 100644 --- a/includes/core/um-actions-ajax.php +++ b/includes/core/um-actions-ajax.php @@ -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'] ) ? $_REQUEST['username'] : ''; $exists = username_exists( $username ); /** diff --git a/includes/core/um-actions-core.php b/includes/core/um-actions-core.php index 70b0c4bd..65b2e0cd 100644 --- a/includes/core/um-actions-core.php +++ b/includes/core/um-actions-core.php @@ -18,7 +18,7 @@ function um_action_request_process() { return; } - if ( isset( $_REQUEST['uid'] ) && ! UM()->user()->user_exists_by_id( $_REQUEST['uid'] ) ) { + if ( isset( $_REQUEST['uid'] ) && ! UM()->user()->user_exists_by_id( absint( $_REQUEST['uid'] ) ) ) { return; } @@ -32,13 +32,13 @@ function um_action_request_process() { // wp_die( __( 'You do not have enough permissions to do that.','ultimate-member') ); // } + $uid = 0; if ( isset( $_REQUEST['uid'] ) ) { - $uid = $_REQUEST['uid']; + $uid = absint( $_REQUEST['uid'] ); } switch ( $_REQUEST['um_action'] ) { default: - $uid = isset( $_REQUEST['uid'] ) ? $_REQUEST['uid'] : 0; /** * UM hook * @@ -80,7 +80,7 @@ function um_action_request_process() { if ( ! current_user_can( 'delete_users' ) ) { return; } - UM()->user()->auto_login( $_REQUEST['uid'] ); + UM()->user()->auto_login( $uid ); exit( wp_redirect( UM()->permalinks()->get_current_url( true ) ) ); break; diff --git a/includes/core/um-actions-login.php b/includes/core/um-actions-login.php index 1ef97c6d..48ed5cef 100644 --- a/includes/core/um-actions-login.php +++ b/includes/core/um-actions-login.php @@ -140,7 +140,7 @@ function um_submit_form_errors_hook_logincheck( $args ) { } if ( isset( $args['form_id'] ) && $args['form_id'] == UM()->shortcodes()->core_login_form() && UM()->form()->errors && ! isset( $_POST[ UM()->honeypot ] ) ) { - exit( wp_redirect( um_get_core_page('login') ) ); + exit( wp_redirect( um_get_core_page( 'login' ) ) ); } } @@ -179,8 +179,8 @@ function um_user_login( $args ) { $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') ); + 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' ) ); } UM()->user()->auto_login( um_user( 'ID' ), $rememberme ); diff --git a/includes/core/um-actions-misc.php b/includes/core/um-actions-misc.php index 2def15d0..5224d7ea 100644 --- a/includes/core/um-actions-misc.php +++ b/includes/core/um-actions-misc.php @@ -75,11 +75,11 @@ add_action( 'um_after_form_fields', 'um_browser_url_redirect_to' ); function um_add_update_notice( $args ) { extract( $args ); - $output = ''; - $err = ''; - $success = ''; + $output = ''; + $err = ''; + $success = ''; - if ( isset( $_REQUEST['updated'] ) && !empty( $_REQUEST['updated'] ) && ! UM()->form()->errors ) { + if ( ! empty( $_REQUEST['updated'] ) && ! UM()->form()->errors ) { switch ( $_REQUEST['updated'] ) { default: /** @@ -104,25 +104,25 @@ 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, $_REQUEST['updated'] ); break; case 'account': - $success = __('Your account was updated successfully.','ultimate-member'); + $success = __( 'Your account was updated successfully.', 'ultimate-member' ); break; case 'password_changed': - $success = __('You have successfully changed your password.','ultimate-member'); + $success = __( 'You have successfully changed your password.', 'ultimate-member' ); break; case 'account_active': - $success = __('Your account is now active! You can login.','ultimate-member'); + $success = __( 'Your account is now active! You can login.', 'ultimate-member' ); break; } } - if ( isset( $_REQUEST['err'] ) && !empty( $_REQUEST['err'] ) && ! UM()->form()->errors ) { + if ( ! empty( $_REQUEST['err'] ) && ! UM()->form()->errors ) { switch( $_REQUEST['err'] ) { default: @@ -148,51 +148,52 @@ function um_add_update_notice( $args ) { * } * ?> */ - $err = apply_filters( "um_custom_error_message_handler", $err, $_REQUEST['err'] ); - if ( !$err ) + $err = apply_filters( 'um_custom_error_message_handler', $err, $_REQUEST['err'] ); + if ( ! $err ) { $err = __( 'An error has been encountered', 'ultimate-member' ); + } break; case 'registration_disabled': - $err = __('Registration is currently disabled','ultimate-member'); + $err = __( 'Registration is currently disabled', 'ultimate-member' ); break; case 'blocked_email': - $err = __('This email address has been blocked.','ultimate-member'); + $err = __( 'This email address has been blocked.', 'ultimate-member' ); break; case 'blocked_domain': - $err = __('We do not accept registrations from that domain.','ultimate-member'); + $err = __( 'We do not accept registrations from that domain.', 'ultimate-member' ); break; case 'blocked_ip': - $err = __('Your IP address has been blocked.','ultimate-member'); + $err = __( 'Your IP address has been blocked.', 'ultimate-member' ); break; case 'inactive': - $err = __('Your account has been disabled.','ultimate-member'); + $err = __( 'Your account has been disabled.', 'ultimate-member' ); break; case 'awaiting_admin_review': - $err = __('Your account has not been approved yet.','ultimate-member'); + $err = __( 'Your account has not been approved yet.', 'ultimate-member' ); break; case 'awaiting_email_confirmation': - $err = __('Your account is awaiting e-mail verification.','ultimate-member'); + $err = __( 'Your account is awaiting e-mail verification.', 'ultimate-member' ); break; case 'rejected': - $err = __('Your membership request has been rejected.','ultimate-member'); + $err = __( 'Your membership request has been rejected.', 'ultimate-member' ); break; } } - if ( isset( $err ) && !empty( $err ) ) { + if ( ! empty( $err ) ) { $output .= '

' . $err . '

'; } - if ( isset( $success ) && !empty( $success ) ) { + if ( ! empty( $success ) ) { $output .= '

' . $success . '

'; } diff --git a/includes/core/um-filters-login.php b/includes/core/um-filters-login.php index d82f4e8a..515fea55 100644 --- a/includes/core/um-filters-login.php +++ b/includes/core/um-filters-login.php @@ -34,19 +34,19 @@ add_filter( 'um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access' ); */ function um_custom_wp_err_messages( $message ) { - if ( isset( $_REQUEST['err'] ) && !empty( $_REQUEST['err'] ) ) { + if ( ! empty( $_REQUEST['err'] ) ) { switch( $_REQUEST['err'] ) { case 'blocked_email': - $err = __('This email address has been blocked.','ultimate-member'); + $err = __( 'This email address has been blocked.', 'ultimate-member' ); break; case 'blocked_ip': - $err = __('Your IP address has been blocked.','ultimate-member'); + $err = __( 'Your IP address has been blocked.', 'ultimate-member' ); break; } } if ( isset( $err ) ) { - $message = '
'.$err.'
'; + $message = '
' . $err . '
'; } return $message; diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index b0b723ec..2777a4c8 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -1427,8 +1427,9 @@ function um_get_metadefault( $id ) { * @return bool */ function um_submitting_account_page() { - if (isset( $_POST['_um_account'] ) && $_POST['_um_account'] == 1 && is_user_logged_in()) + if ( isset( $_POST['_um_account'] ) && $_POST['_um_account'] == 1 && is_user_logged_in() ) { return true; + } return false; }