field-validation.php (7889B)
1 <?php 2 /** 3 * Redux Framework field validation config. 4 * For full documentation, please visit: http://devs.redux.io/ 5 * 6 * @package Redux Framework 7 */ 8 9 defined( 'ABSPATH' ) || exit; 10 11 Redux::set_section( 12 $opt_name, 13 array( 14 'title' => esc_html__( 'Field Validation', 'your-textdomain-here' ), 15 'id' => 'validation', 16 'desc' => esc_html__( 'For full documentation on validation, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/configuration/fields/validate.html" target="_blank">https://devs.redux.io/configuration/fields/validate.html</a>', 17 'subsection' => true, 18 'fields' => array( 19 array( 20 'id' => 'opt-text-email', 21 'type' => 'text', 22 'title' => esc_html__( 'Text Option - Email Validated', 'your-textdomain-here' ), 23 'subtitle' => esc_html__( 'This is a little space under the Field Title in the Options table, additional info is good in here.', 'your-textdomain-here' ), 24 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 25 'validate' => 'email', 26 'msg' => 'An error message you could customize via your option array!', 27 'default' => 'test@test.com', 28 ), 29 array( 30 'id' => 'opt-text-post-type', 31 'type' => 'text', 32 'title' => esc_html__( 'Text Option with Data Attributes', 'your-textdomain-here' ), 33 'subtitle' => esc_html__( 'You can also pass an options array if you want. Set the default to whatever you like.', 'your-textdomain-here' ), 34 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 35 'data' => 'post_type', 36 ), 37 array( 38 'id' => 'opt-multi-text', 39 'type' => 'multi_text', 40 'title' => esc_html__( 'Multi Text Option - Color Validated', 'your-textdomain-here' ), 41 'validate' => 'color', 42 'subtitle' => esc_html__( 'If you enter an invalid color it will be removed. Try using the text "blue" as a color. ;)', 'your-textdomain-here' ), 43 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 44 ), 45 array( 46 'id' => 'opt-text-url', 47 'type' => 'text', 48 'title' => esc_html__( 'Text Option - URL Validated', 'your-textdomain-here' ), 49 'subtitle' => esc_html__( 'This must be a URL.', 'your-textdomain-here' ), 50 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 51 'validate' => 'url', 52 'default' => 'https://redux.io', 53 ), 54 array( 55 'id' => 'opt-text-numeric', 56 'type' => 'text', 57 'title' => esc_html__( 'Text Option - Numeric Validated', 'your-textdomain-here' ), 58 'subtitle' => esc_html__( 'This must be numeric.', 'your-textdomain-here' ), 59 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 60 'validate' => array( 'numeric', 'not_empty' ), 61 'default' => '0', 62 ), 63 array( 64 'id' => 'opt-text-comma-numeric', 65 'type' => 'text', 66 'title' => esc_html__( 'Text Option - Comma Numeric Validated', 'your-textdomain-here' ), 67 'subtitle' => esc_html__( 'This must be a comma separated string of numerical values.', 'your-textdomain-here' ), 68 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 69 'validate' => 'comma_numeric', 70 'default' => '0', 71 ), 72 array( 73 'id' => 'opt-text-no-special-chars', 74 'type' => 'text', 75 'title' => __( 'Text Option - No Special Chars Validated', 'your-textdomain-here' ), 76 'subtitle' => __( 'This must be a alpha numeric only.', 'your-textdomain-here' ), 77 'desc' => __( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 78 'validate' => 'no_special_chars', 79 'default' => '0', 80 ), 81 array( 82 'id' => 'opt-text-str_replace', 83 'type' => 'text', 84 'title' => esc_html__( 'Text Option - Str Replace Validated', 'your-textdomain-here' ), 85 'subtitle' => esc_html__( 'You decide.', 'your-textdomain-here' ), 86 'desc' => esc_html__( 'This field\'s default value was changed by a filter hook!', 'your-textdomain-here' ), 87 'validate' => 'str_replace', 88 'str' => array( 89 'search' => ' ', 90 'replacement' => '-thisisaspace-', 91 ), 92 'default' => 'This is the default.', 93 ), 94 array( 95 'id' => 'opt-text-preg_replace', 96 'type' => 'text', 97 'title' => esc_html__( 'Text Option - Preg Replace Validated', 'your-textdomain-here' ), 98 'subtitle' => esc_html__( 'You decide.', 'your-textdomain-here' ), 99 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 100 'validate' => 'preg_replace', 101 'preg' => array( 102 'pattern' => '/.*?\\d.*?\\d(\\d)/is', 103 'replacement' => 'no numbers', 104 ), 105 'default' => '0', 106 ), 107 array( 108 'id' => 'opt-text-custom_validate', 109 'type' => 'text', 110 'title' => esc_html__( 'Text Option - Custom Callback Validated', 'your-textdomain-here' ), 111 'subtitle' => esc_html__( 'You decide.', 'your-textdomain-here' ), 112 'desc' => wp_kses( __( 'Enter <code>1</code> and click <strong>Save Changes</strong> for an error message, or enter <code>2</code> and click <strong>Save Changes</strong> for a warning message.', 'your-textdomain-here' ), $kses_exceptions ), 113 'validate_callback' => 'redux_validate_callback_function', 114 'default' => '0', 115 ), 116 array( 117 'id' => 'opt-textarea-no-html', 118 'type' => 'textarea', 119 'title' => esc_html__( 'Textarea Option - No HTML Validated', 'your-textdomain-here' ), 120 'subtitle' => esc_html__( 'All HTML will be stripped', 'your-textdomain-here' ), 121 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 122 'validate' => 'no_html', 123 'default' => 'No HTML is allowed in here.', 124 ), 125 array( 126 'id' => 'opt-textarea-html', 127 'type' => 'textarea', 128 'title' => esc_html__( 'Textarea Option - HTML Validated', 'your-textdomain-here' ), 129 'subtitle' => esc_html__( 'HTML Allowed (wp_kses)', 'your-textdomain-here' ), 130 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 131 'validate' => 'html', // See http://codex.wordpress.org/Function_Reference/wp_kses_post. 132 'default' => 'HTML is allowed in here.', 133 ), 134 array( 135 'id' => 'opt-textarea-some-html', 136 'type' => 'textarea', 137 'title' => esc_html__( 'Textarea Option - HTML Validated Custom', 'your-textdomain-here' ), 138 'subtitle' => esc_html__( 'Custom HTML Allowed (wp_kses)', 'your-textdomain-here' ), 139 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 140 'validate' => 'html_custom', 141 'default' => '<p>Some HTML is allowed in here.</p>', 142 143 // See http://codex.wordpress.org/Function_Reference/wp_kses. 144 'allowed_html' => array( 145 'a' => array( 146 'href' => array(), 147 'title' => array(), 148 ), 149 'br' => array(), 150 'em' => array(), 151 'strong' => array(), 152 ), 153 ), 154 array( 155 'id' => 'opt-textarea-js', 156 'type' => 'textarea', 157 'title' => esc_html__( 'Textarea Option - JS Validated', 'your-textdomain-here' ), 158 'subtitle' => esc_html__( 'JS will be escaped', 'your-textdomain-here' ), 159 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), 160 'validate' => 'js', 161 ), 162 ), 163 ) 164 );