Base64 & JSON Encode array in PHP, use as HTML data attribute, decode and parse in JavaScript …. with proper Escaping

The possible output of base64_encode() contains a-zA-Z0-9+/ and possibly = or == appended. Testing with $str=”abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=”; we find that: esc_attr( $str ) === $str is true, so it looks like esc_attr() preserves base64 encoded strings. There are possible regexes to help with validation, but according to this answer by @BoltClock, we could check it with … Read more

How Can I Add OnClick Event To A Specific WordPress Menu Link

This is not really a WordPress specific question, but since WordPress does not provide customization for menu items, I think you’re gonna need this. You can use .bind() in jQuery to add an event to user’s click on an specific item. Take a look at this: jQuery(document).ready(function(){ jQuery( “#menu-item-57” ).bind( “click”, function() { goog_report_conversion (‘tel:800-123-4567’); … Read more

404 Error Contact Form 7 on WordPress

this is quite a common issue with htaccess file blocking malformed un-shlashed url such as cf7 wp-json requests. Therefore check your .htaccess file in your root folder to see if this is the case with your server too, find the section in your .htaccess that is adding a “https://wordpress.stackexchange.com/” at the end of requests # … Read more

Detect When User Reads Full Article? [closed]

Haven’t seen a plugin that does this, since each theme would differ. But for a custom solution that would work with Google Analytics events see #9 here: https://searchenginewatch.com/sew/how-to/2287906/10-google-analytics-custom-events-that-track-the-untrackable OP also found this more specific article: http://cutroni.com/blog/2014/02/12/advanced-content-tracking-with-universal-analytics/ (These are in comments above, just posted to make it faster for those looking for something similar to find … Read more

Why my javascript code not working for the dashboard of wordpress admin?

You need to add your script into your functions.php function my_theme_scripts() { wp_enqueue_script( ‘my-great-script’, get_site_url() . ‘/js/my-great-script.js’, array( ‘jquery’ ), ‘1.0.0’, true ); } add_action( ‘admin_enqueue_scripts’, ‘my_theme_scripts’ ); Then, in your file (my-great-script.js), you will have to have something like this: jQuery(‘.dash_appoint_r’).on(‘click’, function(){ alert(‘hello’); });