PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / trunk
MainWP Dashboard: Self-hosted WordPress Management for Agencies vtrunk
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / modules / logs / includes / functions.php

functions.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies trunk, at modules/logs/includes/functions.php

53 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Defines common functionality used throughout the plugin.
4 *
5 * @package MainWP\Dashboard
6 */
7
8 // Exit.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * Filters a variable with a specified filter.
15 *
16 * This is a polyfill function intended to be used in place of PHP's
17 * filter_var() function, which can occasionally be unreliable.
18 *
19 * @param string $var_value Value to filter.
20 * @param int $filter The ID of the filter to apply.
21 * @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.
22 *
23 * @return Returns the filtered data, or FALSE if the filter fails.
24 */
25 function mainwp_module_log_filter_var( $var_value, $filter = null, $options = array() ) { //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
26 return call_user_func_array( array( '\MainWP\Dashboard\Module\Log\Log_Filter_Input', 'filter' ), func_get_args() );
27 }
28
29
30 /**
31 * Converts a time into an ISO 8601 extended formatted string.
32 *
33 * @param int|bool $time Seconds since unix epoch.
34 * @param int $offset Timezone offset.
35 *
36 * @return string an ISO 8601 extended formatted time
37 */
38 function mainwp_module_log_get_iso_8601_extended_date( $time = false, $offset = 0 ) {
39 if ( $time ) {
40 $microtime = (float) ( $time . '.0000' );
41 } else {
42 $microtime = microtime( true );
43 }
44
45 $micro_seconds = sprintf( '%06d', ( $microtime - floor( $microtime ) ) * 1000000 );
46 $offset_string = sprintf( 'Etc/GMT%s%d', $offset < 0 ? '+' : '-', abs( $offset ) );
47
48 $timezone = new DateTimeZone( $offset_string );
49 $date = new DateTime( gmdate( 'Y-m-d H:i:s.' . $micro_seconds, (int) $microtime ), $timezone );
50
51 return $date->format( 'Y-m-d\TH:i:sO' );
52 }
53