Merge pull request #1219 from ultimatemember/fix/remove_extract_frontend

Remove extract() frontend
This commit is contained in:
Mykyta Synelnikov
2023-06-28 21:41:00 +03:00
committed by GitHub
22 changed files with 2002 additions and 2635 deletions
+27 -44
View File
@@ -63,58 +63,43 @@ if ( ! class_exists( 'um\core\Form' ) ) {
add_action( 'init', array( &$this, 'field_declare' ), 10 );
}
/**
*
*/
public function ajax_muted_action() {
UM()->check_ajax_nonce();
// phpcs:disable WordPress.Security.NonceVerification
if ( ! isset( $_REQUEST['hook'] ) ) {
die( esc_html__( 'Invalid hook', 'ultimate-member' ) );
}
if ( isset( $_REQUEST['user_id'] ) ) {
$user_id = absint( $_REQUEST['user_id'] );
}
if ( ! isset( $user_id ) || ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
die( esc_html__( 'You can not edit this user.', 'ultimate-member' ) );
}
$hook = sanitize_key( $_REQUEST['hook'] );
/**
* @var $user_id
* @var $hook
* Fires on AJAX muted action.
*
* @since 1.3.x
* @hook um_run_ajax_function__{$hook}
*
* @param {array} $request Request.
*
* @example <caption>Make any custom action on AJAX muted action.</caption>
* function my_run_ajax_function( $request ) {
* // your code here
* }
* add_action( 'um_run_ajax_function__{$hook}', 'my_run_ajax_function', 10, 1 );
*/
extract( $_REQUEST );
if ( isset( $user_id ) ) {
$user_id = absint( $user_id );
}
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
*
* @type action
* @title um_run_ajax_function__{$hook}
* @description Action on AJAX muted action
* @input_vars
* [{"var":"$request","type":"int","desc":"Request"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_run_ajax_function__{$hook}', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_run_ajax_function__{$hook}', 'my_run_ajax_function', 10, 1 );
* function my_run_ajax_function( $request ) {
* // your code here
* }
* ?>
*/
do_action( "um_run_ajax_function__{$hook}", $_REQUEST );
break;
}
do_action( "um_run_ajax_function__{$hook}", $_REQUEST );
// phpcs:enable WordPress.Security.NonceVerification
}
/**
*
*/
@@ -608,11 +593,9 @@ if ( ! class_exists( 'um\core\Form' ) ) {
* ?>
*/
do_action( "um_submit_form_{$this->post_form['mode']}", $this->post_form );
}
}
/**
* Beautify form data
*