Enqueueing a script and a style sheet not working

In the context of parent – child themes, be aware that: The get_template_directory_uri() will give you the parent theme directory uri: https://codex.wordpress.org/Function_Reference/get_template_directory_uri. The get_stylesheet_directory_uri() will give you the child theme directory uri: https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri You are enqueueing parent-style with get_stylesheet_directory_uri(), which will give you the child theme directory uri. You are enqueueing child-css and child-js using … Read more

Enqueue js script to footer

Have you looked at wp_enqueue_script in the WordPress codex? You’ll most likely need to add this to functions.php in your theme’s directory. Also, where are you enqueuing the startapp_js dependency? function prefix_enqueue_scripts() { wp_enqueue_script( ‘startapp-js’, get_template_directory_uri() . ‘/scripts/Startapp.js’, array(), ”, true ); wp_enqueue_script( ‘app-js’, get_template_directory_uri() . ‘/scripts/App.js’, array( ‘startapp-js’ ), ”, true ); } add_action( … Read more

Script Localization doesn’t work

Copying from the answer here regarding variable scope Variables inside a function are only available inside that function. Variables outside of functions are available anywhere outside of functions, but not inside any function. Because of that, you need to add your $translations array within the kvkoolitus_load_comment_validation function, like function kvkoolitus_load_comment_validation(){ $translations = array( ‘value1’ =>’This … Read more

Trying to integrate Zoho Campaign Form [closed]

You can add inline JavaScript using the wp_head action like so: add_action(‘wp_head’,’zoho’); function zoho() { $output=”<script type=”text/javascript”> var $ZC = jQuery.noConflict(); var trackingText=”ZCFORMVIEW’; $ZC(document).ready( function($) { $ZC(“#zc_trackCode”).val(trackingText); $ZC(“#fieldBorder”).val($ZC([changeItem=’SIGNUP_FORM_FIELD’]”).css(“border-color”)); _setOptin(false,function(th){ /*Before submit, if you want to trigger your event, “include your code here”*/ }); /*Load Captcha For this*/ loadCaptcha(‘https://campaigns.zoho.com/campaigns/CaptchaVerify.zc?mode=generate’); /*Tracking Enabled*/ trackSignupEvent(trackingText); }); </script>’; echo $output; … Read more

Preloader for a WordPress Site

You will want to put the code in the child theme, otherwise an update to the parent theme will erase it. You want the loader to be a part of the page as the document is first loaded by the browser, then use javascript to detect when the images are finished loading and remove the … Read more

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