- review edit_field();

This commit is contained in:
Mykyta Synelnikov
2023-06-28 20:56:09 +03:00
parent fcd5854424
commit 6f9109adca
4 changed files with 296 additions and 324 deletions
+13 -5
View File
@@ -171,14 +171,23 @@ if ( ! class_exists( 'UM_Functions' ) ) {
*
* @return string|void
*/
function get_template( $template_name, $basename = '', $t_args = array(), $echo = false ) {
public function get_template( $template_name, $basename = '', $t_args = array(), $echo = false ) {
if ( ! empty( $t_args ) && is_array( $t_args ) ) {
extract( $t_args );
/*
* This use of extract() cannot be removed. There are many possible ways that
* templates could depend on variables that it creates existing, and no way to
* detect and deprecate it.
*
* Passing the EXTR_SKIP flag is the safest option, ensuring globals and
* function variables cannot be overwritten.
*/
// phpcs:ignore WordPress.PHP.DontExtract.extract_extract
extract( $t_args, EXTR_SKIP );
}
$path = '';
if ( $basename ) {
// use '/' instead of "DIRECTORY_SEPARATOR", because wp_normalize_path makes the correct replace
// use '/' instead of "DIRECTORY_SEPARATOR", because wp_normalize_path makes the correct replacement
$array = explode( '/', wp_normalize_path( trim( $basename ) ) );
$path = $array[0];
}
@@ -189,7 +198,6 @@ if ( ! class_exists( 'UM_Functions' ) ) {
return;
}
/**
* UM hook
*
@@ -240,7 +248,7 @@ if ( ! class_exists( 'UM_Functions' ) ) {
* ?>
*/
do_action( 'um_before_template_part', $template_name, $path, $located, $t_args );
include( $located );
include $located;
/**
* UM hook
File diff suppressed because it is too large Load Diff
+12 -5
View File
@@ -297,16 +297,23 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
if ( isset( $this->set_args ) && is_array( $this->set_args ) ) {
$args = $this->set_args;
unset( $args['file'] );
unset( $args['theme_file'] );
unset( $args['tpl'] );
unset( $args['file'], $args['theme_file'], $args['tpl'] );
$args = apply_filters( 'um_template_load_args', $args, $tpl );
extract( $args );
/*
* This use of extract() cannot be removed. There are many possible ways that
* templates could depend on variables that it creates existing, and no way to
* detect and deprecate it.
*
* Passing the EXTR_SKIP flag is the safest option, ensuring globals and
* function variables cannot be overwritten.
*/
// phpcs:ignore WordPress.PHP.DontExtract.extract_extract
extract( $args, EXTR_SKIP );
}
$file = um_path . "templates/{$tpl}.php";
$file = UM_PATH . "templates/{$tpl}.php";
$theme_file = get_stylesheet_directory() . "/ultimate-member/templates/{$tpl}.php";
if ( file_exists( $theme_file ) ) {
$file = $theme_file;
+9 -10
View File
@@ -416,8 +416,8 @@ function um_check_conditions_on_submit( $condition, $fields, $args, $reset = fal
*/
function um_submit_form_errors_hook_( $args ) {
$form_id = $args['form_id'];
$mode = $args['mode'];
$fields = unserialize( $args['custom_fields'] );
$mode = $args['mode'];
$fields = unserialize( $args['custom_fields'] );
$um_profile_photo = um_profile('profile_photo');
if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && ( empty( $args['profile_photo'] ) && empty( $um_profile_photo ) ) ) {
@@ -425,12 +425,12 @@ function um_submit_form_errors_hook_( $args ) {
}
if ( ! empty( $fields ) ) {
$can_edit = false;
$current_user_roles = [];
$can_edit = false;
$current_user_roles = array();
if ( is_user_logged_in() ) {
$can_edit = UM()->roles()->um_current_user_can( 'edit', $args['user_id'] );
if ( array_key_exists( 'user_id', $args ) ) {
$can_edit = UM()->roles()->um_current_user_can( 'edit', $args['user_id'] );
}
um_fetch_user( get_current_user_id() );
$current_user_roles = um_user( 'roles' );
@@ -439,7 +439,7 @@ function um_submit_form_errors_hook_( $args ) {
foreach ( $fields as $key => $array ) {
if ( $mode == 'profile' ) {
if ( 'profile' === $mode ) {
$restricted_fields = UM()->fields()->get_restricted_fields_for_edit();
if ( is_array( $restricted_fields ) && in_array( $key, $restricted_fields ) ) {
continue;
@@ -447,7 +447,7 @@ function um_submit_form_errors_hook_( $args ) {
}
$can_view = true;
if ( isset( $array['public'] ) && $mode != 'register' ) {
if ( isset( $array['public'] ) && 'register' !== $mode ) {
switch ( $array['public'] ) {
case '1': // Everyone
@@ -491,7 +491,6 @@ function um_submit_form_errors_hook_( $args ) {
continue;
}
/**
* UM hook
*