How to set cookies to switch style sheets when a link is clicked and set it till another particular link is clicked?

You can use init action to set cookie, and other init action to read it. However due its a cookie… you will need also to check GET variable. add_action(‘init’, ‘is_it_mobile_or_desktop’, 1); function is_it_mobile_or_desktop(){ if (isset($_GET[‘site’]) && in_array($_GET[‘site’], array(‘mobile’, ‘desktop’)) ) { setcookie( ‘site’, $_GET[‘site’], time() – YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); } } add_action(‘init’, ‘who_am_i’, 2); … Read more

Use wp_enqueue_scripts from included php file

I found the problem…. I ran main.php like: function run_this(){ include’path/to/other.php’; } add_shortcode(‘shortcode’, ‘run_this’); And most of the content of other.php came up exept the hooks did’nt work then i tried using add_action(‘init’, ‘run_this’); and then it worked…. exept that i get a fatal error that i cant redeclare some functions twice 😀

Enqueueing a script and a style sheet not working

In the context of parent – child themes, be aware that: The get_template_directory_uri() will give you the parent theme directory uri: https://codex.wordpress.org/Function_Reference/get_template_directory_uri. The get_stylesheet_directory_uri() will give you the child theme directory uri: https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri You are enqueueing parent-style with get_stylesheet_directory_uri(), which will give you the child theme directory uri. You are enqueueing child-css and child-js using … Read more

Move scripts to footer, but exclude one script?

To stop enqueueing a script We’re dequeueing the scripts completely (regardless from header or footer) with a higher priority (10+): function dequeue_my_scripts() { wp_dequeue_script(‘script-handle-here’); } add_action( ‘wp_print_scripts’, ‘dequeue_my_scripts’, 11 ); To put the script to footer function enqueue_scripts_to_footer() { wp_enqueue_script(‘script-handle-here’); } add_action( ‘wp_footer’, ‘enqueue_scripts_to_footer’ ); Right way doing this But the right way enqueueing the … Read more

Enqueue js script to footer

Have you looked at wp_enqueue_script in the WordPress codex? You’ll most likely need to add this to functions.php in your theme’s directory. Also, where are you enqueuing the startapp_js dependency? function prefix_enqueue_scripts() { wp_enqueue_script( ‘startapp-js’, get_template_directory_uri() . ‘/scripts/Startapp.js’, array(), ”, true ); wp_enqueue_script( ‘app-js’, get_template_directory_uri() . ‘/scripts/App.js’, array( ‘startapp-js’ ), ”, true ); } add_action( … Read more

Script Localization doesn’t work

Copying from the answer here regarding variable scope Variables inside a function are only available inside that function. Variables outside of functions are available anywhere outside of functions, but not inside any function. Because of that, you need to add your $translations array within the kvkoolitus_load_comment_validation function, like function kvkoolitus_load_comment_validation(){ $translations = array( ‘value1’ =>’This … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)