My scripts-bundle.js file is getting sent to the browser as a stylesheet css file. Help!

Ok, I managed to solve this issue because I was using the wrong WP functions to point my child themes directory and thus my bundled javascript script. I cleared out my functions.php file and added the below and it all works now: function load_js_files() { wp_enqueue_script( ‘script’, get_stylesheet_directory_uri() . ‘/js/scripts-bundled.js’, array ( ‘jquery’ ), 1.1, … Read more

Retrieve URL of Script/Style and Dependencies

wp_enqueue_script() and wp_enqueue_style() both use WP_Dependencies::add() which initializes a new instance of _WP_Dependency (see wp_scripts() and wp_styles()), so all the script’s dependencies are stored in the deps property of the class instance. However, that property only stores the handle names of the script’s dependencies, e.g. jquery-migrate and jquery-core for the default/core jQuery script (handle name: … Read more

wp_add_inline_script not adding when script_loader_tag filtered

The reason this is happening is because the markup that is filtered by script_loader_tag includes the inline scripts. So when you filter it and replace all the HTML tag for a particular script, your filter is removing those inline script tags. If you print out the original value of $tag from within your filter you … Read more

How do I enqueue a JavaScript in my footer via the functions.php file?

First, create a static js file with those inline codes.. !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0]; if(!d.getElementById(id)){js=d.createElement(s);js.id=id; js.src=”https://platform.twitter.com/widgets.js”; fjs.parentNode.insertBefore(js,fjs);} }(document,”script”,”twitter-wjs”); var options = { “url”: “/my-styles.css” }; CustomizeTwitterWidget(options); Then enqueue it at footer as the dependent of twitter-customize script which you already enqueued. function my_footer_enqueue() { wp_register_script( ‘twitter-customize’, get_template_directory_uri() . ‘/js/customize-twitter-1.1.min.js’, array(), ‘1.0’, true ); wp_enqueue_script( ‘twitter-customize’ ); wp_enqueue_script( … Read more

WP CLI theme install. Install a private repo?

I actually figured out a way to do this. First you use wget like this: wget –user username –ask-password -O path/to/output.zip https://bitbucket.org/path/to/file.zip the -O flag specifies output and output.zip is where you want it to download to. Then you can run: wp theme install path/to/output.zip –activate Happy days

How to cancel `wp_print_scripts`?

There is a way, but it’s not recommended since there might be some other inline scripts attached to the enqueued scripts. You can hook to the wp_enqueue_scripts action and empty the global $wp_scripts as follows: add_action( ‘wp_enqueue_scripts’, ‘remove_all_scripts’, 1000 ); function remove_all_scripts() { global $wp_scripts; $wp_scripts->queue = array(); } You can then run a loop … Read more

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