Tag Info

Hot answers tagged

6

First of all this is what I use and for me and it works. I'm not saying that my code is 100% correct but Pingdom as well GTmetrix show a positive effect and WP is satisfied also, so it can't be that wrong as I do. The versions showing (?ver=x.x.x) can be debet when those files need to be cached so stripping(filter) that is already a first step. The code ...


3

You need to enqueue the scripts as well, not only register them. You can, however, just simply enqueue a script without registering it if you are not going to enqueue it conditionally. I would try something like this: (Untested and requires PHP5.4+) add_action( 'wp_enqueue_scripts', enqueue_scripts, 11 ); function enqueue_scripts() { /** * Build ...


2

Thank you for your post, mrwweb. I found another solution to this, by creating a very simple plugin you can deactive when the site is no longer under development. <?php /* Plugin name: Strip WP Version in Stylesheets/Scripts */ function switch_stylesheet_src( $src, $handle ) { $src = remove_query_arg( 'ver', $src ); return $src; } ...


1

Building on the accepted answer and filling in some details... You need to call wp_localize script right after wp_enqueue_script. So, something like this: function my_enqueue_scripts() { wp_enqueue_script( 'myjs', plugins_url( 'js/my.js', __FILE__) ); $options = get_option( 'my_settings' ); $scriptData = array( ...


1

EDIT: If you use $post in a function, you have to define it of course: function xyz(){ global $post; //Your code } Initial answer, might help others: It appears to me, you do not use it inside an action or if so, you use it to early. It should work inside the 'init' action. So you could do something like <?php add_action( 'init', ...


1

01. Change if (($site == 'desktop'){ // code line } TO if (($site == 'desktop') && (wp_is_mobile())) { // code line } 02. and for unset the cookie while the browser is closed give the time as 0 (zero) or blank. some thing like this. setcookie( 'button_clicked', $_GET['button_clicked'], 0, COOKIEPATH, COOKIE_DOMAIN);


1

Well after a bit of better searching i found the answer, function my_enqueue($hook) { if ( 'settings_page_data-layer-management' != $hook ) { return; } wp_enqueue_script( 'my_custom_script', plugins_url( 'js/dlm-window.js', __FILE__ )); } add_action( 'admin_enqueue_scripts', 'my_enqueue' ); to explain just incase anyone has this ...


1

Here was the problem. I just didn't add the <?php wp_footer(); ?> in my footer.php file. so simple but important. I guess woocommerce group should check if wp_footer() doesn't exists add the scripts in header instead because I have wp_head() set up in my header.php



Only top voted, non community-wiki answers of a minimum length are eligible