How to retrieve a value from an input field in a media view template

After digging through the media modal code, I came up with the answer to my question: wp.media.controller.Custom = wp.media.controller.State.extend({ initialize: function(){ this.props = new Backbone.Model(); }, // called when the toolbar button is clicked customAction: function( controller ){ // get the value of a media view template form field using // this.props.get(‘key’), where ‘key’ is … Read more

AngularJS with route and JSON API

Doublecheck if there’s a “nobase” error in your console. If so, according to the AngularJS documentation, and fix.io (credits for this answer go to the author of that post) the base tag is to the rescue. <html ng-app=”app”> <head> <base href=”https://wordpress.stackexchange.com/angular-wp/”> <title>AngularJS Demo Theme</title> <?php wp_head(); ?> Please note the “/angular-wp/” is the sub-context in … Read more

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