1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php /** * Function include all files in folder * * @param $path Directory address * @param $ext array file extension what will include * @param $prefix string Class prefix */ if ( ! defined( 'ABSPATH' ) ) { exit; } if ( ! function_exists( 'vi_include_folder' ) ) { function vi_include_folder( $path, $prefix = '', $ext = array( 'php' ) ) { /*Include all files in payment folder*/ if ( ! is_array( $ext ) ) { $ext = explode( ',', $ext ); $ext = array_map( 'trim', $ext ); } $sfiles = scandir( $path ); foreach ( $sfiles as $sfile ) { if ( $sfile != '.' && $sfile != '..' ) { if ( is_file( $path . "/" . $sfile ) ) { $ext_file = pathinfo( $path . "/" . $sfile ); $file_name = $ext_file['filename']; if ( $ext_file['extension'] ) { if ( in_array( $ext_file['extension'], $ext ) ) { $class = preg_replace( '/\W/i', '_', $prefix . ucfirst( $file_name ) );
if ( ! class_exists( $class ) ) { require_once $path . $sfile; if ( class_exists( $class ) ) { new $class; } } } } } } } } } if ( ! function_exists( 'vi_wot_set_time_limit' ) ) { function vi_wot_set_time_limit( $limit = 0 ) { if ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved set_time_limit( $limit ); } } } if ( ! function_exists( 'vi_wot_json_decode' ) ) { function vi_wot_json_decode( $json, $assoc = true, $depth = 512, $options = 2 ) { if (is_array($json)){ return $json; } if ( function_exists( 'mb_convert_encoding' ) ) { $json = mb_convert_encoding( $json, 'UTF-8', 'UTF-8' ); }
return json_decode( $json, $assoc, $depth, $options ); } } if ( ! function_exists( 'vi_wot_json_encode' ) ) { function vi_wot_json_encode( $value, $options = 256, $depth = 512 ) { return wp_json_encode( $value, $options, $depth ); } }
|