Tag Info

New answers tagged

1

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 ...


0

First of all, to resolve the javascript conflict I've set up a simple tl_custom.js under my theme js/ folder, with the following code jQuery(document).ready(function($) { // Remove handler set by themes/Divi/js/custom.js at line 2642 $( 'a[href*=#]:not([href=#])' ).off(); }); Then I add the script with the following code in functions.php ...


0

I might be off track here, but would removing the return false; from the javascript you posted help? return false; in a click function is like saying: event.preventDefault(); event.stopPropagation(); I think this is why your other function is not firing as there is no restriction to having multiple handlers bound to the same event on an element. ...


0

From a purely WordPress perspective, the only solution I see would be to copy the script to your child theme and make edits to it to remove the conflict. If the parent theme uses get_template_directory_uri to reference the path to the script, you'll also have to dequeue the original, and enqueue your modified version. If the script is loaded using ...


0

See this: http://infiniteajaxscroll.com/docs/events.html#rendered So, place all the ad code in an ajax function (http://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_%28action%29) add_action( 'wp_ajax_your_ad_fn', 'your_ad_fn'); add_action( 'wp_ajax_nopriv_your_ad_fn', 'your_ad_fn'); function your_ad_fn(){ // your ad code here // if ...


2

After struggling around for days through the poorly documented media modal source code and using code from the gist (thanks, Fabien), I came up with a solution: JS: wp.media.controller.Custom = wp.media.controller.State.extend({ initialize: function(){ this.props = new Backbone.Model({ custom_data: '' }); this.props.on( ...


0

You could achieve this with a little bit of jQuery: Create this file within THEMEFOLDER/js/ called field-clear.js and replace #formID with the ID of the form you would like to reset: //Code runs when an ajax request succeeds jQuery( document ).ajaxSuccess(function( event, xhr, settings ) { //Check ajax action of request that succeeded ...


0

As far as I know, the save_post hook kicks in, after the post was stored or updated in the database. Any Idea how to prevent this, when a metabox field validation error occurs, i.e. is empty?


2

IMHO, I still think that loading scripts and styles directly in the header is bad practice as it is always a problem removing them and loading them coditionally. The best way to work around this is to create a [child theme] and then copy header.php to your child theme. Wordpress will load your child theme's header instead of the parent theme's header. You ...


1

Your code is wrong. You are confusing wp_enqeue_script function and wp_enqueue_scripts action. It should be: function theme_script(){ wp_deregister_script( 'jquery' ); wp_register_script('jquery',get_template_directory_uri().'/sliderengine/jquery.js'); wp_enqueue_script('jquery'); ...


3

it seems the latter only accepts x-www-form-urlencoded That's not completely true. WordPress admin-ajax.php takes the action from $_REQUEST['action'] and $_REQUEST is equal to: array_merge($_POST, $_GET); But what many people don't realize is that $_GET in PHP is not the data was sent to page using HTTP GET method, in fact, you can use whatever ...


0

admin-ajax.php was designed to work against jQuery, most likely if you do not make the conversion on the JS site you will have to do it on the server side to make it work. Instead you can add your own "end point" that can process json. The biggest problem with this approach is the query that WP runs on "front end" urls.


0

In WordPress you should enqueue your scripts (and styles) using the wp_enqueue_scripts action hook. The main reason for this is to ensure that your script/style is only added once. You can, if you wish, aslo add conditions so that a script/style is only added to certain pages. You say in your question that your script is located at js/file.js - presumabily ...


0

@sam-skirrow just posting here what we did to fix this... WordPress 4.1 requires us to use a sanitize_callback filter when creating settings for the customizer (with good reason). Since you're using the kirki framework to create these customizer settings, kirki detects that this is a textarea field and so it automatically applies the esc_textarea filter. ...


1

Here's a working example: add_action( 'wp_enqueue_scripts', 'menu_scripts' ); function menu_scripts() { wp_enqueue_script( 'responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' ); wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . '/js/custom_script.js', array( 'jquery' ...


0

If the script is there it should work. It's probably failing because you're not declaring the jquery dependency and you're not wrapping it correctly (in no conflict mode). Here's how your script should be enqueued: function custom_scripts() { wp_enqueue_script( 'unique-custom-script', get_stylesheet_directory_uri() . '/custom.js', ...



Top 50 recent answers are included