Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Prevent CSS from being enqueued on sub-site plugins & themes screens in multisite. #91

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ function wp_autoupdates_enqueues( $hook ) {
if ( ! in_array( $hook, array( 'plugins.php', 'themes.php', 'update-core.php' ) ) ) {
return;
}

// Don't enqueue CSS & JS on sub-site plugins & themes screens in multisite.
if ( in_array( $hook, array( 'plugins.php', 'themes.php' ) ) && is_multisite() && ! is_network_admin() ) {
return;
}

wp_register_style( 'wp-autoupdates', plugin_dir_url( __FILE__ ) . 'css/wp-autoupdates.css', array(), WP_AUTO_UPDATES_VERSION );
wp_enqueue_style( 'wp-autoupdates' );

Expand Down Expand Up @@ -57,7 +63,7 @@ function wp_autoupdates_enqueues( $hook ) {
wp_add_inline_script( 'jquery', $script );
}

if ( 'themes.php' === $hook && ! is_multisite() ) {
if ( 'themes.php' === $hook ) {
if ( wp_autoupdates_is_themes_auto_update_enabled() ) {
$script = 'jQuery( document ).ready( function() {';

Expand Down Expand Up @@ -113,7 +119,7 @@ function insert_into_template(positioning_text, added_text, insert_before) {
}
}

if ( ( 'themes.php' === $hook || 'plugins.php' === $hook ) && ( ! is_multisite() || is_network_admin() ) ) {
if ( 'themes.php' === $hook || 'plugins.php' === $hook ) {
wp_enqueue_script(
'wp-autoupdates',
plugin_dir_url( __FILE__ ) . 'js/wp-autoupdates.js',
Expand Down