Code Duplication    Length = 13-15 lines in 2 locations

classes/autoptimizeOption.php 2 locations

@@ 69-81 (lines=13) @@
66
     *				                the default value is 'yes'. Default null.
67
     * @return bool False if value was not updated and true if value was updated.
68
	 */
69
    public static function update_option( $option, $value, $autoload = null )
70
    {
71
		
72
		// Ensure that is_plugin_active_for_network function is declared.
73
		self::maybe_include_plugin_functions();
74
		$blog_id = get_current_blog_id();
75
		
76
		if ( is_plugin_active_for_network( 'autoptimize/autoptimize.php' ) && 1 === $blog_id ) {
77
			return update_network_option( get_main_network_id(), $option, $value );
78
		} else {
79
			return update_option( $option, $value, $autoload );
80
		}
81
    }
82
83
	/**
84
	 * Use the pre_update_option filter to check if the option to be saved if from autoptimize and
@@ 98-112 (lines=15) @@
95
		}
96
	}
97
98
	public static function update_autoptimize_option_on_network( $value, $option, $old_value ) {
99
		if( strpos( $option, 'autoptimize_' ) === 0 ) {
100
			
101
			// Ensure that is_plugin_active_for_network function is declared.
102
			self::maybe_include_plugin_functions();
103
			$blog_id = get_current_blog_id();
104
		
105
			if ( is_plugin_active_for_network( 'autoptimize/autoptimize.php' ) && 1 === $blog_id ) {
106
				 update_network_option( get_main_network_id(), $option, $value );
107
				 // Return old value, to stop update_option logic.
108
				 return $old_value;
109
			}
110
		}
111
		return $value;
112
	}
113
}
114
new autoptimizeOption();
115