jQuery plugin not loading

It might be the case that you are using you JS validation before enqueuing this script. You code may be like.. <html> $(“#myForm”).validate(); or JS file that uses validate() jquery.validate.js here </html> Above code is just for demonstrating. So you are using validate() function before it has been enqueued so it is throwing validate() is … Read more

How do I sanitize the str_replace function in javascript variables

esc_js() is intended for escaping data for use within an HTML attribute. If you want to escape data for use within an inline script, wp_json_encode() should be sufficient. For example: var disabledDays = <?php echo wp_json_encode( $iva_disable_days ); ?>; This outputs: var disabledDays = [“4\/7\/2018″,”11\/18\/2017”]; If you check the variable in your dev tools console, … Read more

Using $wpdb | checking entered email against existing emails in db

You shouldn’t be using mysql_num_rows() or mysql_error() when dealing with $wpdb. Even if you weren’t, mysql_error() is for database errors, and an empty result set is not a database error. If you want to know if results were returned, simply check the count() of the results: $duplicateEmail = $wpdb->get_results($emailTest, OBJECT); if ( count( $duplicateEmail ) … Read more

Data Validation in wordpress

Please see this Codex article for further guide, but in your case, you would use esc_attr() to escape the $second_col_class value which is being used in an HTML attribute, namely class: <!– bad –> <div class=”<?php echo $second_col_class; ?>”> <!– good –> <div class=”<?php echo esc_attr( $second_col_class ); ?>”> <!– good –> <div class=”<?php esc_attr_e( … Read more

register_setting & add_settings_error validation issues with multiple fields

If you want your sanitization callback to apply only to a specific settings field (i.e. a database option registered using register_setting()), then you would want to use a different callback for each of your settings fields. E.g. // Sample field HTML: //<input name=”field-1″ value=”<?php esc_attr( get_option( ‘field-1’ ) ); ?>”> function my_settings_field_1_validation( $value ) { … Read more