function render_field_settings()

in web/wp-content/plugins/acf-extended/includes/fields-settings/validation.php [93:404]


    function render_field_settings($field){
    
        $functions = array(
        
            'General' => array(
                'value'                 => 'If value',
                'strlen'                => 'If value length - strlen(value)',
                'count'                 => 'If count value - count(value)',
            ),
        
            'Exists' => array(
                'email_exists'          => 'If email exists - email_exists(value)',
                'post_type_exists'      => 'If post type exists - post_type_exists(value)',
                'taxonomy_exists'       => 'If taxonomy exists - taxonomy_exists(value)',
                'term_exists'           => 'If term exists - term_exists(value)',
                'username_exists'       => 'If username exists - username_exists(value)',
            ),
        
            'Is' => array(
                'is_email'              => 'If is email - is_email(value)',
                'is_user_logged_in'     => 'If is user logged in - is_user_logged_in()',
                'is_array'              => 'If is array - is_array(value)',
                'is_string'             => 'If is string - is_string(value)',
                'is_numeric'            => 'If is numeric - is_numeric(value)',
            ),
        
            'Post' => array(
                'get_post_type'         => 'If get post type - get_post_type(value)',
                'get_post_by_id'        => 'If post id exists - get_post_by_id(value)',
                'get_post_by_slug'      => 'If post slug exists - get_post_by_slug(value)',
                'get_post_by_title'     => 'If post title exists - get_post_by_title(value)',
            ),
        
            'Sanitize' => array(
                'sanitize_email'        => 'If sanitize email - sanitize_email(value)',
                'sanitize_file_name'    => 'If sanitize file name - sanitize_file_name(value)',
                'sanitize_html_class'   => 'If sanitize html class - sanitize_html_class(value)',
                'sanitize_key'          => 'If sanitize key - sanitize_key(value)',
                'sanitize_meta'         => 'If sanitize meta - sanitize_meta(value)',
                'sanitize_mime_type'    => 'If sanitize mime type - sanitize_mime_type(value)',
                'sanitize_option'       => 'If sanitize option - sanitize_option(value)',
                'sanitize_text_field'   => 'If sanitize text field - sanitize_text_field(value)',
                'sanitize_title'        => 'If sanitize title - sanitize_title(value)',
                'sanitize_user'         => 'If sanitize user - sanitize_user(value)',
            ),
        
            'User' => array(
                'get_user_by_id'        => 'If get user by id - get_user_by(\'id\', value)',
                'get_user_by_slug'      => 'If get user by slug - get_user_by(\'slug\', value)',
                'get_user_by_email'     => 'If get user by email - get_user_by(\'email\', value)',
                'get_user_by_login'     => 'If get user by login - get_user_by(\'login\', value)',
            )
    
        );
        
        $choices = apply_filters('acfe/validate/functions', $functions, $field);
        
        if(empty($choices)){
            return;
        }
        
        // settings
        acf_render_field_setting($field, array(
            'label'         => __('Advanced Validation'),
            'name'          => 'acfe_validate',
            'key'           => 'acfe_validate',
            'instructions'  => __('Validate value against rules'),
            'type'          => 'repeater',
            'button_label'  => __('Add validation'),
            'required'      => false,
            'layout'        => 'row',
            'wrapper'       => array(
                'data-enable-switch' => true
            ),
            'sub_fields'    => array(
                array(
                    'label'             => 'Location',
                    'name'              => 'acfe_validate_location',
                    'key'               => 'acfe_validate_location',
                    'type'              => 'select',
                    'instructions'      => '',
                    'required'          => 0,
                    'conditional_logic' => 0,
                    'wrapper'           => array(
                        'width' => '',
                        'class' => '',
                        'id'    => '',
                    ),
                    'choices'           => array(
                        'admin' => 'Administration',
                        'front' => 'Front-end',
                    ),
                    'allow_null'        => true,
                    'multiple'          => 0,
                    'ui'                => 0,
                    'return_format'     => 'value',
                    'ajax'              => 0,
                    'placeholder'       => 'Everywhere',
                ),
                array(
                    'label'         => __('Rules'),
                    'name'          => 'acfe_validate_rules_and',
                    'key'           => 'acfe_validate_rules_and',
                    'instructions'  => '',
                    'type'          => 'repeater',
                    'button_label'  => __('+ AND'),
                    'required'      => false,
                    'layout'        => 'table',
                    'sub_fields'    => array(
                        array(
                            'ID'            => false,
                            'label'         => 'Function',
                            'name'          => 'acfe_validate_function',
                            'key'           => 'acfe_validate_function',
                            'prefix'        => '',
                            '_name'         => '',
                            '_prepare'      => '',
                            'type'          => 'select',
                            'choices'       => $choices,
                            'instructions'  => false,
                            'required'      => false,
                            'wrapper'       => array(
                                'width' => '',
                                'class' => '',
                                'id'    => '',
                            ),
                        ),
                        array(
                            'ID'            => false,
                            'label'         => 'Operator / Value',
                            'name'          => 'acfe_validate_operator',
                            'key'           => 'acfe_validate_operator',
                            'prefix'        => '',
                            '_name'         => '',
                            '_prepare'      => '',
                            'type'          => 'select',
                            'choices'       => array(
                                'Operators' => array(
                                    '=='        => '==',
                                    '!='        => '!=',
                                    '>'         => '>',
                                    '>='        => '>=',
                                    '<'         => '<',
                                    '<='        => '<=',
                                    'contains'  => 'Contains',
                                    '!contains' => 'Doesn\'t contain',
                                    'starts'    => 'Starts with',
                                    '!starts'   => 'Doesn\'t start with',
                                    'ends'      => 'Ends with',
                                    '!ends'     => 'Doesn\'t end with',
                                    'regex'     => 'Matches regex',
                                    '!regex'    => 'Doesn\'t matches regex',
                                ),
                                'Values'     => array(
                                    'true'  => '== true',
                                    '!true' => '!= true',
                                    'false' => '== false',
                                    '!false'=> '!= false',
                                    'null'  => '== null',
                                    '!null' => '!= null',
                                    'empty' => '== (empty)',
                                    '!empty'=> '!= (empty)',
                                )
                            ),
                            'instructions'  => false,
                            'required'      => false,
                            'wrapper'       => array(
                                'width' => '',
                                'class' => '',
                                'id'    => '',
                            ),
                        ),
                        array(
                            'ID'            => false,
                            'label'         => 'Value',
                            'name'          => 'acfe_validate_match',
                            'key'           => 'acfe_validate_match',
                            'prefix'        => '',
                            '_name'         => '',
                            '_prepare'      => '',
                            'type'          => 'text',
                            'instructions'  => false,
                            'placeholder'   => '',
                            'required'      => false,
                            'wrapper'       => array(
                                'width' => '',
                                'class' => '',
                                'id'    => '',
                            ),
                            'conditional_logic' => array(
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '==',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '!=',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '>',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '>=',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '<',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '<=',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => 'contains',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '!contains',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => 'starts',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '!starts',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => 'ends',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '!ends',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => 'regex',
                                    )
                                ),
                                array(
                                    array(
                                        'field'     => 'acfe_validate_operator',
                                        'operator'  => '==',
                                        'value'     => '!regex',
                                    )
                                ),
                            )
                        ),
                    )
                ),
                array(
                    'label'         => 'Error',
                    'name'          => 'acfe_validate_error',
                    'key'           => 'acfe_validate_error',
                    'prefix'        => '',
                    '_name'         => '',
                    '_prepare'      => '',
                    'type'          => 'text',
                    'instructions'  => false,
                    'required'      => false,
                    'wrapper'       => array(
                        'width' => '',
                        'class' => '',
                        'id'    => '',
                    ),
                ),
            )
        ));
        
    }