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 +47 -17 4.2.23.6.1 View file →
@@ -4,12 +4,8 @@
4 4 *
5 5 * @package WP_Stream
6 6 */
7 7
8 -if ( ! defined( 'ABSPATH' ) ) {
9 - exit;
10 -}
11 -
12 8 /**
13 9 * Gets a specific external variable by name and optionally filters it.
14 10 *
15 11 * This is a polyfill function intended to be used in place of PHP's
@@ -19,11 +15,11 @@
19 15 * @param string $variable_name Name of a variable to get.
20 16 * @param int $filter The ID of the filter to apply.
21 17 * @param mixed $options Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array.
22 18 *
23 - * @return mixed|false|null Value of the requested variable on success, FALSE if the filter fails, or NULL if the $variable_name is not set.
19 + * @return Value of the requested variable on success, FALSE if the filter fails, or NULL if the $variable_name is not set.
24 20 */
25 -function wp_stream_filter_input( $type, $variable_name, $filter = null, $options = array() ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
21 +function wp_stream_filter_input( $type, $variable_name, $filter = null, $options = array() ) {
26 22 return call_user_func_array( array( '\WP_Stream\Filter_Input', 'super' ), func_get_args() );
27 23 }
28 24
29 25 /**
@@ -31,15 +27,15 @@
31 27 *
32 28 * This is a polyfill function intended to be used in place of PHP's
33 29 * filter_var() function, which can occasionally be unreliable.
34 30 *
35 - * @param string $value Value to filter.
36 - * @param int $filter The ID of the filter to apply.
37 - * @param mixed $options Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array. For the "callback" filter, callable type should be passed. The callback must accept one argument, the value to be filtered, and return the value after filtering/sanitizing it.
31 + * @param string $var Value to filter.
32 + * @param int $filter The ID of the filter to apply.
33 + * @param mixed $options Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array. For the "callback" filter, callable type should be passed. The callback must accept one argument, the value to be filtered, and return the value after filtering/sanitizing it.
38 34 *
39 35 * @return Returns the filtered data, or FALSE if the filter fails.
40 36 */
41 -function wp_stream_filter_var( $value, $filter = null, $options = array() ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
37 +function wp_stream_filter_var( $var, $filter = null, $options = array() ) {
42 38 return call_user_func_array( array( '\WP_Stream\Filter_Input', 'filter' ), func_get_args() );
43 39 }
44 40
45 41 /**
@@ -66,8 +62,33 @@
66 62 return $date->format( 'Y-m-d\TH:i:sO' );
67 63 }
68 64
69 65 /**
66 + * Encode to JSON in a way that is also backwards compatible
67 + *
68 + * @param mixed $data Data to be encoded.
69 + * @param int $options Compression options (optional).
70 + * @param int $depth Tree depth limit (optional).
71 + *
72 + * @return string
73 + */
74 +function wp_stream_json_encode( $data, $options = 0, $depth = 512 ) {
75 + if ( function_exists( 'wp_json_encode' ) ) {
76 + $json = wp_json_encode( $data, $options, $depth );
77 + } else {
78 + // @codingStandardsIgnoreStart
79 + if ( version_compare( PHP_VERSION, '5.5', '<' ) ) {
80 + $json = json_encode( $data, $options );
81 + } else {
82 + $json = json_encode( $data, $options, $depth );
83 + }
84 + // @codingStandardsIgnoreEnd
85 + }
86 +
87 + return $json;
88 +}
89 +
90 +/**
70 91 * Return an array of sites for a network in a way that is also backwards compatible
71 92 *
72 93 * @param string|array $args Argument to filter results by.
73 94 *
@@ -73,16 +94,9 @@
73 94 *
74 95 * @return array
75 96 */
76 97 function wp_stream_get_sites( $args = array() ) {
77 - if ( empty( $args['limit'] ) ) {
78 - $args['limit'] = 0;
79 - }
80 -
81 98 if ( function_exists( 'get_sites' ) ) {
82 - // Account for get_sites() which uses 'number' while wp_get_sites() uses 'limit'.
83 - $args['number'] = $args['limit'];
84 -
85 99 $sites = get_sites( $args );
86 100 } else {
87 101 $sites = array();
88 102 foreach ( wp_get_sites( $args ) as $site ) { // @codingStandardsIgnoreLine Specifically for old version of WP first, in order to provide backward compatibility
@@ -109,5 +123,21 @@
109 123 * @return bool
110 124 */
111 125 function wp_stream_is_cron_enabled() {
112 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;
113 143 }