PluginProbe
Stream – Activity Log & Audit Trail / 3.6.1
Stream – Activity Log & Audit Trail v3.6.1
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
← All changes | includes/functions.php +34 -16 3.2.23.6.1 View file →
@@ -1,6 +1,12 @@
1 1 <?php
2 2 /**
3 + * Defines common functionality used throughout the plugin.
4 + *
5 + * @package WP_Stream
6 + */
7 +
8 +/**
3 9 * Gets a specific external variable by name and optionally filters it.
4 10 *
5 11 * This is a polyfill function intended to be used in place of PHP's
6 12 * filter_input() function, which can occasionally be unreliable.
@@ -34,10 +40,10 @@
34 40
35 41 /**
36 42 * Converts a time into an ISO 8601 extended formatted string.
37 43 *
38 - * @param int|bool $time Seconds since unix epoc
39 - * @param int $offset Hour offset
44 + * @param int|bool $time Seconds since unix epoch.
45 + * @param int $offset Timezone offset.
40 46 *
41 47 * @return string an ISO 8601 extended formatted time
42 48 */
43 49 function wp_stream_get_iso_8601_extended_date( $time = false, $offset = 0 ) {
@@ -47,27 +53,22 @@
47 53 $microtime = microtime( true );
48 54 }
49 55
50 56 $micro_seconds = sprintf( '%06d', ( $microtime - floor( $microtime ) ) * 1000000 );
51 - $offset_string = sprintf( 'Etc/GMT%s%s', $offset < 0 ? '+' : '-', abs( $offset ) );
57 + $offset_string = sprintf( 'Etc/GMT%s%d', $offset < 0 ? '+' : '-', abs( $offset ) );
52 58
53 59 $timezone = new DateTimeZone( $offset_string );
54 - $date = new DateTime( date( 'Y-m-d H:i:s.' . $micro_seconds, $microtime ), $timezone );
60 + $date = new DateTime( gmdate( 'Y-m-d H:i:s.' . $micro_seconds, $microtime ), $timezone );
55 61
56 - return sprintf(
57 - '%s%03d%s',
58 - $date->format( 'Y-m-d\TH:i:s.' ),
59 - floor( $date->format( 'u' ) / 1000 ),
60 - $date->format( 'O' )
61 - );
62 + return $date->format( 'Y-m-d\TH:i:sO' );
62 63 }
63 64
64 65 /**
65 66 * Encode to JSON in a way that is also backwards compatible
66 67 *
67 - * @param mixed $data
68 - * @param int $options (optional)
69 - * @param int $depth (optional)
68 + * @param mixed $data Data to be encoded.
69 + * @param int $options Compression options (optional).
70 + * @param int $depth Tree depth limit (optional).
70 71 *
71 72 * @return string
72 73 */
73 74 function wp_stream_json_encode( $data, $options = 0, $depth = 512 ) {
@@ -88,9 +89,9 @@
88 89
89 90 /**
90 91 * Return an array of sites for a network in a way that is also backwards compatible
91 92 *
92 - * @param string|array $args
93 + * @param string|array $args Argument to filter results by.
93 94 *
94 95 * @return array
95 96 */
96 97 function wp_stream_get_sites( $args = array() ) {
@@ -97,9 +98,9 @@
97 98 if ( function_exists( 'get_sites' ) ) {
98 99 $sites = get_sites( $args );
99 100 } else {
100 101 $sites = array();
101 - foreach ( wp_get_sites( $args ) as $site ) {
102 + foreach ( wp_get_sites( $args ) as $site ) { // @codingStandardsIgnoreLine Specifically for old version of WP first, in order to provide backward compatibility
102 103 $sites[] = WP_Site::get_instance( $site['blog_id'] );
103 104 }
104 105 }
105 106
@@ -115,11 +116,28 @@
115 116 return function_exists( 'wpcom_vip_load_plugin' );
116 117 }
117 118
118 119 /**
119 - * True if native WP Cron is enabled, otherwise false
120 + * Check if the default front-end WP Cron is enabled. It doesn't
121 + * mean that the Cron is disabled in general.
120 122 *
121 123 * @return bool
122 124 */
123 125 function wp_stream_is_cron_enabled() {
124 126 return ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ? false : true;
127 +}
128 +
129 +/**
130 + * Get the asset min suffix if defined.
131 + *
132 + * @return string
133 + */
134 +function wp_stream_min_suffix() {
135 + $min = '';
136 + $is_script_debugging = ! defined( 'SCRIPT_DEBUG' ) || false === SCRIPT_DEBUG;
137 +
138 + if ( apply_filters( 'wp_stream_load_min_assets', $is_script_debugging ) ) {
139 + $min = 'min.';
140 + }
141 +
142 + return $min;
125 143 }