format( 'Y-m-d\TH:i:s.' ), floor( $date->format( 'u' ) / 1000 ), $date->format( 'O' ) ); } /** * Encode to JSON in a way that is also backwards compatible * * @param mixed $data * @param int $options (optional) * @param int $depth (optional) * * @return string */ function wp_stream_json_encode( $data, $options = 0, $depth = 512 ) { if ( function_exists( 'wp_json_encode' ) ) { $json = wp_json_encode( $data, $options, $depth ); } else { // @codingStandardsIgnoreStart if ( version_compare( PHP_VERSION, '5.5', '<' ) ) { $json = json_encode( $data, $options ); } else { $json = json_encode( $data, $options, $depth ); } // @codingStandardsIgnoreEnd } return $json; } /** * Return an array of sites for a network in a way that is also backwards compatible * * @param string|array $args * * @return array */ function wp_stream_get_sites( $args = array() ) { if ( function_exists( 'get_sites' ) ) { $sites = get_sites( $args ); } else { $sites = array(); foreach ( wp_get_sites( $args ) as $site ) { // @codingStandardsIgnoreLine Specifically for old version of WP first, in order to provide backward compatibility $sites[] = WP_Site::get_instance( $site['blog_id'] ); } } return $sites; } /** * Check if Stream is running on WordPress.com VIP * * @return bool */ function wp_stream_is_vip() { return function_exists( 'wpcom_vip_load_plugin' ); } /** * True if native WP Cron is enabled, otherwise false * * @return bool */ function wp_stream_is_cron_enabled() { return ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ? false : true; } /** * Get the asset min suffix if defined. * * @return string */ function wp_stream_min_suffix() { $min = ''; if ( ! defined( 'SCRIPT_DEBUG' ) || false === SCRIPT_DEBUG ) { $min = 'min.'; } return $min; }