get_col( "SELECT blog_id FROM ".$wpdb->prefix."blogs" ); if ( is_array( $site_blog_ids ) ) { $global_opt_keys = array_keys( $options ); foreach( $site_blog_ids AS $site_blog_id ) { if ( !is_array( $options[$site_blog_id] ) ) { $options[$site_blog_id] = array(); } foreach( $global_opt_keys as $global_opt_key ) { if ( !is_numeric( $global_opt_key ) && $global_opt_key != 'site_specific_settings' && !isset( $options[$site_blog_id][$global_opt_key] ) ) { $options[$site_blog_id][$global_opt_key] = $options[$global_opt_key]; } } if ( in_array( $routine, self::$force_enabled ) && $options[$site_blog_id]['log_level'] == 'ignore' ) { $options[$site_blog_id]['log_level'] = 'notice'; } } } } else { if ( in_array( $routine, self::$force_enabled ) && $options['log_level'] == 'ignore' ) { $options['log_level'] = 'notice'; } } return $options; } public static function remove_options($routine) { if (empty($routine)) { return false; } $options_key = self::routine_options_key($routine); } public static function force_enable( $routine = "" ) { if ( !empty( $routine ) ) { self::$force_enabled = array_merge( self::$force_enabled, array( $routine ) ); } } public static function release_tier_aware() { if ( defined( 'SITE_RELEASE_TIER' ) ) { return true; } return false; } public static function get_release_tier() { if ( defined( 'SITE_RELEASE_TIER' ) && in_array( SITE_RELEASE_TIER, array( 'local', 'development', 'integration', 'test', 'stage', 'production' ) ) ) { return SITE_RELEASE_TIER; } return false; } public static function is_release_tier( $tier ) { if ( defined( 'SITE_RELEASE_TIER' ) && !empty( $tier ) && $tier == SITE_RELEASE_TIER ) { return true; } return false; } public static function add( $routine, $options = array(), $action = "ac_inspection", $priority = 10, $accepted_args = 1 ) { $inspection_method = self::get_inspection_method( $routine, $options ); if ( empty( $inspection_method ) ) { return false; } if ( empty( $action ) ) { $action = "ac_inspection"; } if ( !array_key_exists( $routine, self::$routine_events ) || !is_array( self::$routine_events[$routine] ) ) { self::$routine_events[$routine] = array(); } if ( in_array( $action, self::$routine_events[$routine] ) ) { return false; } self::$routine_events[$routine][] = $action; if ( has_action( $action, $inspection_method ) === $priority ) { return false; } $saved_options = self::get_options( $routine ); if ( isset( $saved_options['description'] ) && ( !isset($options['description']) || $saved_options['description'] != $options['description'] ) ) { unset( $saved_options['description'] ); } if ( !empty( $options ) && is_array( $options ) ) { if ( is_array( $saved_options ) ) { foreach( $saved_options as $opt_key => $saved_val ) { if ( !isset( $options[$opt_key] ) || $options[$opt_key] != $saved_val ) { $options[$opt_key] = $saved_val; } } } if ( !is_array( $saved_options ) || ( count( $options ) != count( $saved_options ) ) ) { self::set_options( $routine, $options ); } } if ( !empty( $options['site_specific_settings'] ) && is_multisite() && is_plugin_active_for_network( ACI_PLUGIN_BASENAME ) ) { $current_site_id = get_current_blog_id(); if ( $options[$current_site_id]['log_level'] == 'ignore' ) { return true; } } else if ( $options['log_level'] == 'ignore' ) { return true; } add_action( $action, $inspection_method, $priority, $accepted_args ); return true; } public static function remove($routine, $action = "", $priority = 10) { if ( empty( $routine ) ) { return false; } if ( !is_array(self::$routine_events[$routine]) || count(self::$routine_events[$routine]) == 0 ) { return false; } if ( $action_key = array_search( $action, self::$routine_events[$routine] ) ) { remove_action( $routine_events[$routine][$action_key], $routine, $priority ); } unset( self::$routine_events[$routine] ); return true; } public static function get_event_routines($event) { if ( empty( $event) ) { return false; } $event_routines = array(); foreach( array_keys( self::$routine_events ) as $routine ) { if ( in_array( $event, self::$routine_events[$routine] ) ) { $event_routines[] = $routine; } } return $event_routines; } public static function get_routine_events($routine) { if (empty($routine)) { return false; } return self::$routine_events[$routine]; } public static function get_events() { $events = array(); foreach(array_keys(self::$routine_events) as $routine) { foreach(self::$routine_events[$routine] as $event) { if (!in_array($event, $events)) { $events[] = $event; } } } return $events; } public static function get_inspection_routines() { return self::get_event_routines('ac_inspection'); } public static function get_wp_hook_routines() { $wp_hook_routines = array(); foreach(array_keys(self::$routine_events) as $routine) { foreach(self::$routine_events[$routine] as $event) { if ($event != 'ac_inspection' && !in_array($routine, $wp_hook_routines)) { $wp_hook_routines[] = $routine; break; } } } return $wp_hook_routines; } public static function get_all() { return self::$routine_events; } } }