How do I ensure I can loop through every enqueued script and CSS?

In terms of the basics, I have learned that there are two actions to hook – wp_print_scripts and wp_print_styles which I understand are called just before they are then added to the header. add_action( ‘wp_print_scripts’, ‘my_list_scripts’ ); function my_list_scripts() { global $wp_scripts; $enqueued_scripts = array(); foreach( $wp_scripts->queue as $handle ) { // do something clever … Read more

esc_attr() on hard coded string

All text entered into the database is, in essence, “user entered”. If the site gets hacked a hacker could change every instance of the field “title” to contain javascript, for example. If you just echo out the field then you’re writing the javascript to the page and thus injecting the code into the page. Therefore, … Read more

When does global/main code of plug execute?

Plugins are only loaded once per request. Plugins are loaded with this code: // Load active plugins. foreach ( wp_get_active_and_valid_plugins() as $plugin ) { wp_register_plugin_realpath( $plugin ); include_once( $plugin ); /** * Fires once a single activated plugin has loaded. * * @since 5.1.0 * * @param string $plugin Full path to the plugin’s main … Read more