New answers tagged

-1

wp_send_json( $result ); if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { wp_die(); } UPD The besat way to use ajax requests with wp is to use wp native ajax actions add_action( 'wp_ajax_my_action', 'my_action_callback' ); add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' ); https://codex.wordpress.org/AJAX_in_Plugins so you ...


2

How can i return a PHP value from a WordPress page to a JQuery function? Use wp_localize_script to create an object and pass it to the JavaScript.


0

Since wordpress 4.5 you can add inline script by wp_add_inline_script(). To add a javascript snippet to the footer that requires jQuery, this code helps you function enqueue_jquery_in_footer( &$scripts ) { if ( ! is_admin() ) $scripts->add_data( 'jquery', 'group', 1 ); } add_action( 'wp_default_scripts', 'enqueue_jquery_in_footer' ); ...


0

Try using Autoptimize WordPress plugin or W3 Total Cache WordPress plugin, with W3 Total cache enable minify option. They both support combining and minifying all enqueued Scripts (JS) and Stylesheet (CSS)


-2

Now, without your code is difficult to answer; however, I will give you some code you can adapt to your own classes to make that effect. First you need to tell your element how long the transition should take: -webkit-transition: all 0.5s ease-in-out; -moz-transition: all 0.5s ease-in-out; transition: all 0.5s ease-in-out; Then you can make your ...


0

Try This one : wp_register_script('cycleall', plugins_url('/assets/scripts/jquery.cycle.all.js', __FILE__), array('jquery'),'1.1', true); wp_enqueue_script('cycleall'); change script to scripts in add_action() should be add_action ('wp_enqueue_scripts', 'theme_add_cycle_slide' );


0

Problem was a simple misspelling. The add_action should be add_action ('wp_enqueue_scripts', 'theme_add_cycle_slide' ); I wrote 'script'


0

For current Wordpress version (4.5.3) I come up with the following solution which removes closing metaboxes handler and opens all previously closed metaboxes. php (plugin.php) function add_admin_scripts( $hook ) { wp_register_script( 'disable_metabox_toggling', plugin_dir_url(__FILE__) . 'index.js', 'jquery', '1.0.0', true); wp_enqueue_script( '...


0

It's jQuery not JQuery. Try jQuery('div').raty({ score: 3 });


0

You can pass a priority parameter to add_action. I don't actually know what priority Akismet has (default is 10), but you could start by trying this: add_action( 'wp_default_scripts', 'pwcc_jquery_to_footer', 9);


0

This kind of questions is better asked on StackOverflow community. Maybe this JS hack would help: var elem = document.querySelector('.search-form input[name="search_keywords"]'); if ( null !== elem ) { elem.onchange = function() { var e = this , v = e.value; if ( ! v ) return; v = v.toString(); if ( 0 === v....


0

FTP into your site and open up your wp-config.php file. Add this line: define('CONCATENATE_SCRIPTS', false); Make sure you add this before: /** Absolute path to the WordPress directory. */ if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/');


0

You second JS setting is more in the right direction, your biggest failure seems in misunderstanding how ajax requests are handled on the WP PHP/server side. On the PHP side, an action is being triggered based on the action parameter in your AJAX request. Since this is a generic mechanism it doesn't have any facilities to "guess" how many parameters are ...


0

I found this approach to solve the problem of validate metabox fields using PHP code https://tommcfarlin.com/post-meta-data-error-messages/ Hope this help you (works for me in a similar scenario)


0

You can parse the data value to a variable ($formdata) then can access the data you like as: parse_str( $_POST[ 'data' ], $formdata ); $category = $formdata[ 'category' ];


0

The enqueue_parent_theme_style() and my_jquery_enqueue() functions do not have closing brackets. Does the above code run? Otherwise the code looks okay. Are running WordPress with WP_DEBUG set to true? https://codex.wordpress.org/Debugging_in_WordPress I use the following in my wp-config.php file: if ($_SERVER['REMOTE_ADDR'] == '123.456.789.123') { ...


1

If you had for example, <img src="rdp_banner.jpg" id="logoimage"> You could just do... add_action('init','checkvisitcookie'); function checkvisitcookie() { if (isset($_COOKIE['firsttimevisit'])) {return;} setCookie('firsttimevisit','1',100*365*24*60*60); add_action('wp_footer','fadelogoout'); } function fadelogoout() { echo "<...


1

The issue very well may be noConflict. By default whenever WordPress enqueues jquery it runs in a noConflict mode which means that it doesn't provide an alias for jQuery where the default is $ as you have in your question. See this Dev Resource comment: When you enqueue script that is dependent on jQuery, note that the jQuery in WordPress runs in ...



Top 50 recent answers are included