oneOf two possible objects in WP REST API?

Aight got it, the crucial missing thing was that you have to provide this part here: ‘type’ => ‘object’ twice; once when declaring the variable’s type, and once again when defining the possibilities. Otherwise, validation fails; so a proper example would be: ‘args’ => [ ‘data’ => [ ‘type’ => ‘object’, ‘oneOf’ => [ [ … Read more

Custom Registration and Login Forms with reCaptcha 2 Validation

First connect the CAPTCHA script (add to: functions.php) function onwp_enqueue_frontend() { wp_enqueue_script(‘ha-recaptcha’, ‘https://www.google.com/recaptcha/api.js’, array(‘jquery’), ‘1.0’, true); } add_action(‘wp_enqueue_scripts’, ‘onwp_enqueue_frontend’); In the form of adding the following html code to display the captcha <div class=”g-recaptcha” data-sitekey=”YOU_SITE_CODE”></div> YOU_SITE_CODE – replaced by your code Next, add the CAPTCHA validation feature $recaptcha = $_POST[‘data’][‘g_recaptcha_response’]; if (!empty($recaptcha)) { $google_url = … Read more

How to do Conact form 7 name field validation? [closed]

According to the documentation you have to create a custom filter to support it – you can do it like this: add_filter( ‘wpcf7_validate_text*’, ‘custom_text_validation_filter’, 20, 2 ); function custom_text_validation_filter( $result, $tag ) { if ( ‘your-name’ == $tag->name ) { // matches any utf words with the first not starting with a number $re=”/^[^\p{N}][\p{L}]*/i”; if … Read more

How to use esc_attr__() function properly to translate a variable that contains string?

If you have static text with dynamic content then you can use. printf( esc_attr___(‘static text goes here with %s’, ‘text-domain’ ), $title ); If you have only $title then no need to translate it. Just escape it. echo esc_attr( $title ); Note esc_attr, esc_attr__ and esc_attr_e used for escaping dynamic values from HTML element attributes. … Read more

jQuery Live Form Validation in WordPress

Your page through javascript errors. Try loading the validation scripts on footer (before closing </body> tag) rather than within header (within <head> tag). If that doesn’t work, then try editing the jquery.validate.js file, and replace the first line (function(jQuery){ with (function($){. It should work.

WP calendar summary attribute validation error

Update to 3.2.2. The summary attribute has been removed. See line 1149 \wp-includes\general-template.php WP v3.1.4: $calendar_output=”<table id=”wp-calendar” summary=”” . esc_attr__(‘Calendar’) . ‘”> WP v3.2.2: $calendar_output=”<table id=”wp-calendar”> Alternatives… To modify the output of the widget, you can duplicate it and rename it. When I did that, I also needed to duplicate the get_calendar() function and adjust … Read more

Form validation on user profile edit

I worked it out. add_action( ‘user_profile_update_errors’, ‘validate_steamid_field’ ); function validate_steamid_field(&$errors, $update = null, &$user = null) { if (!preg_match(“/^STEAM_[0-5]:[01]:\d+$/”, $_POST[‘_bbp_steamid’])) { $errors->add(’empty_steamid’, “<strong>ERROR</strong>: Please Enter a valid SteamID”); } }