format( 'Y-m-d\TH:i:sO' ); } /** * Encode to JSON in a way that is also backwards compatible * * @param mixed $data Data to be encoded. * @param int $options Compression options (optional). * @param int $depth Tree depth limit (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 Argument to filter results by. * * @return array */ function wp_stream_get_sites( $args = array() ) { if ( empty( $args['limit'] ) ) { $args['limit'] = 0; } if ( function_exists( 'get_sites' ) ) { // Account for get_sites() which uses 'number' while wp_get_sites() uses 'limit'. $args['number'] = $args['limit']; $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' ); } /** * Check if the default front-end WP Cron is enabled. It doesn't * mean that the Cron is disabled in general. * * @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 = ''; $is_script_debugging = ! defined( 'SCRIPT_DEBUG' ) || false === SCRIPT_DEBUG; if ( apply_filters( 'wp_stream_load_min_assets', $is_script_debugging ) ) { $min = 'min.'; } return $min; }