options ) ) { return array(); } $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM {$wpdb->options} WHERE option_name=%s LIMIT 1", self::OPTION ) ); return null === $value ? array() : maybe_unserialize( $value ); } public static function withSite( $site_id, callable $callback ) { $site_id = (int) $site_id; if ( $site_id <= 0 || ! function_exists( 'get_current_blog_id' ) ) { return WaicWorkflowPhase0Result::blocked( 'WF-CTRL-003', 'workflow_site_context_invalid', 'review_workflow' ); } $current = (int) get_current_blog_id(); $switched = false; if ( $current !== $site_id ) { if ( ! is_multisite() || ! switch_to_blog( $site_id ) ) { return WaicWorkflowPhase0Result::blocked( 'WF-CTRL-003', 'workflow_site_context_invalid', 'review_workflow' ); } $switched = true; } try { return call_user_func( $callback, $site_id ); } finally { if ( $switched ) { restore_current_blog(); } } } }