Articles of javascript

How to make Isotope and WordPress work together?

I am trying to make my WordPress theme using Isotope plugin. So far, I have such a result after doing that was suggested: I believe that Isotope Masonry should not look like this. I am really puzzled as to what I am doing wrong. Below is my code: functions.php function profolio_scripts () { wp_enqueue_style( […]

TinyMCE Javascript URL Question{ file : url + ‘/shortcode_generator_popup.php’, I would like to move this file one folder above the current one that it’s in. I’m wondering how I can rewrite this so that is points to the folder above. I’ve tried: file : url + ‘../shortcode_generator_popup.php’ but of course it only turns into: /includes/js../shortcode_generator_popup.php Thanks for any […]

Custom JS text area in customizer is being formatted wrong in document

I have created a wordpress theme, in the wordpress theme customizer I have added a couple of text areas where a user can input their own CSS or JS to be added to the head. The placement of the text area is fine, i.e. when a user adds code it is displayed on the right […]

php variable inside javascript code

I placed a javascript inside a .php file $script = “<script type=’text/javascript’> jQuery( document ).ready( function($) { $(document).ready(function() { $(‘#particles’).particleground({ dotColor: ‘<?=json_encode($dotcolor)?>’, lineColor: ‘#5cb9bd’, }); }); } ); </script>”; and tried to use <?=json_encode($dotcolor)?> to echo a variable. But it isn’t working. Any idea what I’m doing wrong?

How to use only scripts from new theme?

I’m a bit new to WordPress so please forgive me if is a duplicate question. I created new theme with simple file structure: functions.php footer.php header.php index.php style.css js/ I’m trying to use only custom scripts that i define here: function mytheme_enqueue_scripts() { wp_register_script(‘underscore’, get_template_directory_uri().’/js/underscore.js’, array(), null, false); wp_register_script(‘backbone-core’, get_template_directory_uri().’/js/backbone.js’, array(‘underscore’), null, false); wp_register_script(‘backbone-app’, get_template_directory_uri().’/js/app.js’, […]

Conditional custom redirect

I want to achieve the following: On a post or a page, I can define an optional custom redirect URL (possibly as an Advanced Custom Field) If I view this post/page with a specific added URL parameter (like “?redirect=true”, send a redirect to the defined custom URL, otherwise do not redirect. My naive approach would […]

Including Styles and JS files to work ON my plugin interface

Hey WordPress community, I’ve been having a couple of issues with trying to add a stylesheet and a JavaScript file which run on my plugin interface. So far i have this: add_action(‘wp_enqueue_scripts’,’dlm_scritps_init’); function dlm_scritps_init() { wp_enqueue_script( ‘dlm-scripts’, plugins_url( ‘data-layer-plugin/js/dlm-window.js’, __FILE__ )); } Esstinally what i need the JavaScript file todo is when this button is […]

Custom JS on a specific page

So, I have the following custom JavaScript in a page. (Written exactly the way it shows, except the img src) <script src=””></script> <script> jQuery(“#first”).click(function(){ jQuery(“#second”).trigger(‘click’); return false; }); </script> <a id=”first” href=”#”> <img src=”demo”> </a> So the by clicking “first” button, it will trigger “Click” on the second button. The functionality itself works (ie. the […]

Include Jquery libraries in wordpress theme?

I have a file in my theme’s JS folder named cycle2.js. How do I include the Jquery from ‘wordpress→includes’ into my theme? How do I load this custom JavaScript file ‘cycle2.js’ into my theme? I have: function watercolor_js_scripts(){ if (!is_admin()) { wp_register_script(‘cycle2’, get_template_directory_uri() . ‘/js/cycle2.js’, ‘jquery’, TRUE); wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘cycle2’ ); } add_action(‘init’, […]

Multiple Media uploader output to input

I’m trying to select multiple images then insert the IDs (comma-seperated) into a text field. Here’s my code, but it picks the first image ID only: jQuery(document).ready(function($){ var custom_uploader; $(‘#media-button’).click(function(e) { e.preventDefault(); //If the uploader object has already been created, reopen the dialog if (custom_uploader) {; return; } //Extend the object custom_uploader = […]