Trouble adding JavaScript in visual editor (Sharpspring embed code)

You need the unfiltered_html capability to write JavaScript in post content. This is granted by default to administrators and editors. The better way would be to write a small plugin that provides you a shortcode: <?php /** * Plugin Name: WPSE 234978 – Provide shortcode for Sharpspring embed * Plugin URL: http://wordpress.stackexchange.com/q/234978/31323 * License: MIT … Read more

Customizer Show/Hide

get_theme_mod() has a second parameter where you can set the default value, the value to use if the option is not set. So, if the default value is “1”, you can use: get_theme_mod( ‘display_header_image_title’, ‘1’ ) Then, if there is not value for display_header_image_title (no value in database), “1” is used. So, you could check … Read more

Pass javascript array to shortcode

You’re going to have other problems than the brackets because shortcode_parse_atts will have already parsed your attributes, and the various single and double quotes will confuse the regular expression used to do that. If you need the exact string, perhaps you could get it from a custom field. Alternatively, and better, you could specify a … Read more

JQuery not working on WordPress Admin page [closed]

There are this type of problem occure. In case- 1- jQuery function conflict to other jquery function. To remove this type of problem, define below script in wp-config.php file. define(‘CONCATENATE_SCRIPTS’, false); 2- jQuery liberaray file are not include in frontend. 3- Jquery same file defined more than one time. then this type of issue show … Read more

WordPress audio player causing js error, mediaelementplayer is not a function

I can think of two possible options – although I am not been able to test either right now. Option 1 In theory the cleaner one, as you detect if the mediaelementplayer plugin has loaded itself in the jQuery namespace: <!–Change WordPress Audio Player Default Volume–> <script type=”text/javascript”> jQuery(document).ready(function ($) { if($.fn.mediaelementplayer) { $(“audio”).mediaelementplayer({ success: … Read more

Admin Ajax and HTML5 Formdata

So it turns out the only problem was the header content type. By removing request.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded; charset=UTF-8′); and just leaving it out, it worked fine. That’s also with the form action being grabbed and appended. Ajax call: var formData = new FormData(form); formData.append(‘security’, WP.nonce); formData.append(‘action’, form.getAttribute(‘action’)); u.jax.post(WP.ajax, formData, onSent); Ajax Function: u.jax.post = function(url, data, … Read more

How to add a custom.js file for a child-theme in a swift way?

That worked for me: wp_enqueue_script( ‘YOUR_SCRIPT_NAME’, get_stylesheet_directory_uri() . ‘/YOUR_SCRIPT_FILE.js’, array(), ‘4.7.3’, true ); Notes: I usually name the script just as its file name. You don’t have to use the version number 4.7.3, but you do need to write some plausible version number (like of your WordPress core version) or the keyword null instead.