mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- reviewd #1237;
This commit is contained in:
@@ -1381,8 +1381,9 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
if ( $has_custom_source ) {
|
||||
|
||||
/** This filter is documented in includes/core/class-fields.php */
|
||||
$opts = apply_filters( "um_get_field__{$data['metakey']}", array() );
|
||||
$arr_options = $opts['options'];
|
||||
$arr_options = array_key_exists( 'options', $opts ) ? $opts['options'] : array();
|
||||
|
||||
} elseif ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
||||
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
||||
@@ -1627,7 +1628,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
|
||||
|
||||
if ( ! in_array( $array['type'], $fields_without_metakey ) ) {
|
||||
if ( ! in_array( $array['type'], $fields_without_metakey, true ) ) {
|
||||
$array['classes'] .= ' um-field-' . esc_attr( $key );
|
||||
}
|
||||
$array['classes'] .= ' um-field-' . esc_attr( $array['type'] );
|
||||
@@ -1647,8 +1648,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
case 'text':
|
||||
|
||||
$array['disabled'] = '';
|
||||
|
||||
if ( $key == 'user_login' && isset( $this->set_mode ) && $this->set_mode == 'account' ) {
|
||||
if ( 'user_login' === $key && 'account' === $this->set_mode ) {
|
||||
$array['disabled'] = ' disabled="disabled" ';
|
||||
}
|
||||
|
||||
@@ -1759,37 +1759,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
$array['date_min'] = $past;
|
||||
$array['date_max'] = $future;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_get_field_date
|
||||
* @description Extend field date
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Field Date Data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.5.4"]
|
||||
* @usage add_filter( 'um_get_field_date', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_get_field_date', 'my_get_field_date', 10, 1 );
|
||||
* function my_get_field_date( $data ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$array = apply_filters( 'um_get_field_date', $array );
|
||||
|
||||
break;
|
||||
|
||||
case 'time':
|
||||
|
||||
$array['input'] = 'text';
|
||||
|
||||
if ( ! isset( $array['format'] ) ) {
|
||||
@@ -2019,31 +1992,45 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
* Filters the field data by the field type. Where $type is the field's type.
|
||||
*
|
||||
* @type filter
|
||||
* @title um_get_field__{$key}
|
||||
* @description Extend field data by field $key
|
||||
* @input_vars
|
||||
* [{"var":"$data","type":"array","desc":"Field Data"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_get_field__{$key}', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_get_field__{$key}', 'my_get_field', 10, 1 );
|
||||
* function my_get_field( $data ) {
|
||||
* // your code here
|
||||
* return $data;
|
||||
* @param {array} $field_data Field data.
|
||||
*
|
||||
* @return {array} Field data.
|
||||
*
|
||||
* @since 2.0 First hook version applied only for the date type.
|
||||
* @since 2.6.8 Added support for all field type.
|
||||
*
|
||||
* @hook um_get_field_{$type}
|
||||
*
|
||||
* @example <caption>Disable all date-type fields.</caption>
|
||||
* function my_custom_get_field_date( $field_data ) {
|
||||
* $field_data['disabled'] = ' disabled="disabled" ';
|
||||
* return $field_data;
|
||||
* }
|
||||
* ?>
|
||||
* add_filter( 'um_get_field_date', 'my_custom_get_field_date' );
|
||||
*/
|
||||
$array = apply_filters( "um_get_field__{$key}", $array );
|
||||
|
||||
return $array;
|
||||
$array = apply_filters( "um_get_field_{$array['type']}", $array );
|
||||
/**
|
||||
* Filters the field data by the metakey. Where $key is the field's metakey.
|
||||
*
|
||||
* @param {array} $field_data Field data.
|
||||
*
|
||||
* @return {array} Field data.
|
||||
*
|
||||
* @since 1.3.x
|
||||
* @hook um_get_field__{$key}
|
||||
*
|
||||
* @example <caption>Disable 'first_name' field.</caption>
|
||||
* function my_custom_disable_first_name( $field_data ) {
|
||||
* $field_data['disabled'] = ' disabled="disabled" ';
|
||||
* return $field_data;
|
||||
* }
|
||||
* add_filter( 'um_get_field__first_name', 'my_custom_disable_first_name' );
|
||||
*/
|
||||
return apply_filters( "um_get_field__{$key}", $array );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $option_value
|
||||
*
|
||||
@@ -2110,7 +2097,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
}
|
||||
|
||||
$output = '';
|
||||
$disabled = '';
|
||||
|
||||
if ( empty( $_um_profile_id ) ) {
|
||||
$_um_profile_id = um_user( 'ID' );
|
||||
}
|
||||
@@ -2133,6 +2120,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
}
|
||||
$type = $data['type'];
|
||||
|
||||
$disabled = '';
|
||||
if ( isset( $data['disabled'] ) ) {
|
||||
$disabled = $data['disabled'];
|
||||
}
|
||||
|
||||
if ( isset( $data['in_group'] ) && '' !== $data['in_group'] && 'group' !== $rule ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -90,13 +90,16 @@ if ( ! class_exists( 'um\core\Validation' ) ) {
|
||||
|
||||
// Dynamic dropdown options population
|
||||
$has_custom_source = apply_filters("um_has_dropdown_options_source__{$key}", false );
|
||||
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ) ) && $has_custom_source ){
|
||||
$arr_options = apply_filters("um_get_field__{$key}", $fields[ $key ]['options'] );
|
||||
$fields[ $key ]['options'] = array_keys( $arr_options['options'] );
|
||||
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ), true ) && $has_custom_source ) {
|
||||
/** This filter is documented in includes/core/class-fields.php */
|
||||
$fields[ $key ] = apply_filters( "um_get_field__{$key}", $fields[ $key ] );
|
||||
if ( is_array( $fields[ $key ] ) && array_key_exists( 'options', $fields[ $key ] ) ) {
|
||||
$fields[ $key ]['options'] = array_keys( $fields[ $key ]['options'] );
|
||||
}
|
||||
}
|
||||
|
||||
// Dropdown options source from callback function
|
||||
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ) ) &&
|
||||
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ), true ) &&
|
||||
isset( $fields[ $key ]['custom_dropdown_options_source'] ) &&
|
||||
! empty( $fields[ $key ]['custom_dropdown_options_source'] ) &&
|
||||
function_exists( $fields[ $key ]['custom_dropdown_options_source'] ) ) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables first and last name fields in account page
|
||||
* Disables first and last name fields in account page.
|
||||
*
|
||||
* @param array $fields
|
||||
* @return array
|
||||
* @uses um_get_field__first_name, um_get_field__last_name
|
||||
*/
|
||||
function um_account_disable_name_fields( $fields ) {
|
||||
if ( ! UM()->options()->get( 'account_name_disable' ) ) {
|
||||
@@ -18,12 +20,11 @@ function um_account_disable_name_fields( $fields ){
|
||||
|
||||
return $fields;
|
||||
}
|
||||
add_filter( 'um_get_field__first_name', 'um_account_disable_name_fields', 10 ,1 );
|
||||
add_filter( 'um_get_field__last_name', 'um_account_disable_name_fields', 10 ,1 );
|
||||
|
||||
add_filter( 'um_get_field__first_name', 'um_account_disable_name_fields' );
|
||||
add_filter( 'um_get_field__last_name', 'um_account_disable_name_fields' );
|
||||
|
||||
/**
|
||||
* Sanitize inputs on Account update
|
||||
* Sanitize inputs on Account update.
|
||||
*
|
||||
* @param $data
|
||||
*
|
||||
@@ -32,12 +33,15 @@ add_filter( 'um_get_field__last_name', 'um_account_disable_name_fields', 10 ,1 )
|
||||
function um_account_sanitize_data( $data ) {
|
||||
foreach ( $data as $key => $value ) {
|
||||
if ( is_array( $value ) ) {
|
||||
$data[ $key ] = array_filter( $value, function( $var ) {
|
||||
$var = trim( esc_html( strip_tags( $var ) ) );
|
||||
$data[ $key ] = array_filter(
|
||||
$value,
|
||||
function( $var ) {
|
||||
$var = trim( esc_html( wp_strip_all_tags( $var ) ) );
|
||||
return $var;
|
||||
});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$data[ $key ] = trim( esc_html( strip_tags( $value ) ) );
|
||||
$data[ $key ] = trim( esc_html( wp_strip_all_tags( $value ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +49,11 @@ function um_account_sanitize_data( $data ) {
|
||||
}
|
||||
add_filter( 'um_account_pre_updating_profile_array', 'um_account_sanitize_data', 10, 1 );
|
||||
|
||||
|
||||
/**
|
||||
* Fix for the account field "Avoid indexing my profile by search engines"
|
||||
* Fix for the account field "Avoid indexing my profile by search engines".
|
||||
*
|
||||
* @since 2.1.16
|
||||
* @param bool $value
|
||||
* @param mixed|int $value
|
||||
* @return int
|
||||
*/
|
||||
function um_account_profile_noindex_value( $value ) {
|
||||
|
||||
Reference in New Issue
Block a user