Renaming the ‘build’ directory generated by @wordpress/scripts for React development

I am writing this answer after testing the suggestion given by @SallyCJ (thank you for pointing me towards the right direction) Writing the following entry into the scripts section of package.json will change both the source and destination of the React code. “scripts”: { “build”: “wp-scripts build –webpack-src-dir=path/to/source/dir/ –output-path=path/to/destination/dir/”, “test”: “echo \”Error: no test specified\” … Read more

Script dependencies generates different outputs

I think the for each loop is a little wonky, if I’m understanding your question, you can try the following.👌 // Generate a list of dependencies for a given handle. function get_deps() { global $wp_scripts; $deps = array(); foreach ( $wp_scripts->registered as $handle => $script ) { if ( in_array( ‘jquery’, $script->deps, true ) ) … Read more

Socialite not displaying icons [closed]

kaiser pointed me to firebug (FF addon) which confirmed what I thought, the css/js files were not being loaded correctly. But everthing seemed ok. I copied the css into my main styles sheet and things started to look better (however, some things still didnt work). I re-did the tutorial (for the fourth time), but this … Read more

Disable load scripts and styles not working

Try the following: function mytheme_deregister_scripts_and_styles(){ $unwanted_scripts = array( ‘photocrati_ajax’, ‘photocrati-nextgen_basic_thumbnails’, ‘photocrati-nextgen_basic_extended_album’ ); foreach ( $unwanted as $script ) { wp_dequeue_script( $script ); wp_deregister_script( $script ); } $unwanted_styles = array( ‘style_1’, ‘style_2’ ); foreach ( $unwanted_styles as $style ) { wp_dequeue_style( $style ); wp_deregister_style( $style ); } } add_action( ‘wp_enqueue_scripts’, ‘mytheme_deregister_scripts_and_styles’, 99 ); It looks like … Read more

Generating a static page from a script

I don’t know how one would define “best”, but a possible approach would be to make your rankings page an actual page within WordPress, then add either a shortcode or a filter on the_content to populate/fetch a transient from the database. You could alternately save it in an option or as post meta and cron … Read more

How to add GET variable after script url?

Filter script_loader_src and use add_query_arg(). You can use parse_url() or the second argument $handle to target specific scripts… I have included multiple redundant options here: add_filter( ‘script_loader_src’, ‘wpse_99842_add_get_var_to_url’, 10, 2 ); function wpse_99842_add_get_var_to_url( $url, $handle ) { if ( ‘my_handle’ !== $handle ) return $url; if ( empty ( $_GET[‘myvar’] ) ) return $url; $parts … Read more

Register scripts located in child theme?

I think that none the options you has posted actually works. You are only registering the script, you need to enqeue them. Also, you should use wp_enqueue_scripts() action hook instead of init(). function register_scripts() { wp_register_script( ‘newsletter’, get_stylesheet_directory_uri() . ‘/scripts/scripts.js’, array( ‘jquery-migrate’ ), null ); wp_enqeue(‘newsletter’); } add_action( ‘wp_enqueue_scripts’, ‘register_scripts’ );