PluginProbe
Autoptimize / trunk
Autoptimize vtrunk
3.1.16 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 All 108 releases
← All changes | classes/autoptimizeOptionWrapper.php +16 -3 2.7.6 → trunk View file →
@@ -33,16 +33,29 @@
33 33 * @param mixed $default Optional. Default value to return if the option does not exist.
34 34 * @return mixed Value set for the option.
35 35 */
36 36 public static function get_option( $option, $default = false ) {
37 + if ( is_multisite() && self::is_ao_active_for_network() ) {
38 + static $configuration_per_site = null;
39 + if ( null === $configuration_per_site || defined( 'TEST_MULTISITE_FORCE_AO_ON_NETWORK' ) ) {
40 + $configuration_per_site = get_network_option( get_main_network_id(), 'autoptimize_enable_site_config', 'on' );
41 + if ( null === $configuration_per_site ) {
42 + // Config per site is off, set as empty string to make sure the var it is not null any more so it can be cached.
43 + $configuration_per_site = '';
44 + }
45 + }
46 + } else {
47 + // Kind of dummy value as when not on multisite or if AO not network enabled, config is always on site-level.
48 + $configuration_per_site = 'on';
49 + }
50 +
37 51 // This is always a network setting, it is on by default to ensure settings are available at site level unless explicitly turned off.
38 52 if ( 'autoptimize_enable_site_config' === $option ) {
39 - return get_network_option( get_main_network_id(), $option, 'on' );
53 + return $configuration_per_site;
40 54 }
41 55
42 56 // If the plugin is network activated and our per site setting is not on, use the network configuration.
43 - $configuration_per_site = get_network_option( get_main_network_id(), 'autoptimize_enable_site_config', 'on' );
44 - if ( self::is_ao_active_for_network() && ( 'on' !== $configuration_per_site || is_network_admin() ) ) {
57 + if ( is_multisite() && self::is_ao_active_for_network() && ( 'on' !== $configuration_per_site || is_network_admin() ) ) {
45 58 return get_network_option( get_main_network_id(), $option, $default );
46 59 }
47 60
48 61 return get_option( $option, $default );