/var/www/html_nl/wp-content/plugins/wp-smtp/vendor/stellarwp/assets/src/Assets/Utils.php


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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php

namespace StellarWP\Assets;

class 
Utils {
    
/**
     * Stores all the Bases for the request.
     *
     * @since 1.2.3
     *
     * @var array
     */
    
protected static array $bases = [];

    
/**
     * Determines if the provided value should be regarded as 'true'.
     *
     * @since 1.0.0
     *
     * @param mixed $var
     *
     * @return bool
     */
    
public static function is_truthy$var ) : bool {
        if ( 
is_bool$var ) ) {
            return 
$var;
        }

        
$hook_prefix Config::get_hook_prefix();

        
/**
         * Provides an opportunity to modify strings that will be
         * deemed to evaluate to true.
         *
         * @param array $truthy_strings
         */
        
$truthy_strings = (array) apply_filters"stellarwp/assets/{$hook_prefix}/is_truthy_strings", [
            
'1',
            
'enable',
            
'enabled',
            
'on',
            
'y',
            
'yes',
            
'true',
        ] );

        
// Makes sure we are dealing with lowercase for testing
        
if ( is_string$var ) ) {
            
$var strtolower$var );
        }

        
// If $var is a string, it is only true if it is contained in the above array
        
if ( in_array$var$truthy_stringstrue ) ) {
            return 
true;
        }

        
// All other strings will be treated as false
        
if ( is_string$var ) ) {
            return 
false;
        }

        
// For other types (ints, floats etc) cast to bool
        
return (bool) $var;
    }

    
/**
     * Gets the asset bases for the request, both directory and URL.
     *
     * @since 1.2.3
     *
     * @return array
     */
    
public static function get_bases(): array {
        
$key self::get_runtime_cache_key();

        if ( empty( static::
$bases$key ] ) ) {
            static::
$bases$key ] = [
                
'wpmu_plugin' => [
                    
'base_dir' => wp_normalize_pathWPMU_PLUGIN_DIR ),
                    
'base_url' => set_url_schemeWPMU_PLUGIN_URL ),
                ],
                
'wp_plugin'   => [
                    
'base_dir' => wp_normalize_pathWP_PLUGIN_DIR ),
                    
'base_url' => set_url_schemeWP_PLUGIN_URL ),
                ],
                
'wp_content'  => [
                    
'base_dir' => wp_normalize_pathWP_CONTENT_DIR ),
                    
'base_url' => set_url_schemeWP_CONTENT_URL ),
                ],
                
'plugins'     => [
                    
'base_dir' => wp_normalize_pathWP_PLUGIN_DIR ),
                    
'base_url' => plugins_url(),
                ],
                
'stylesheet'  => [
                    
'base_dir' => wp_normalize_pathget_stylesheet_directory() ),
                    
'base_url' => get_stylesheet_directory_uri(),
                ],
            ];
        }

        return static::
$bases$key ];
    }

    
/**
     * Clears the runtime cache.
     *
     * @since 1.4.1
     *
     * @return void
     */
    
public static function clear_runtime_cache() {
        static::
$bases = [];
    }

    
/**
     * Get the runtime cache key.
     *
     * @since 1.2.3
     *
     * @param array $extra Extra data to include in the cache key.
     *
     * @return string
     */
    
public static function get_runtime_cache_key( array $extra = [] ): string {
        return 
md5(
            
serialize(
                
array_merge(
                    [
                        
WPMU_PLUGIN_DIR,
                        
WPMU_PLUGIN_URL,
                        
WP_PLUGIN_DIR,
                        
WP_PLUGIN_URL,
                        
WP_CONTENT_DIR,
                        
WP_CONTENT_URL,
                        
plugins_url(),
                        
get_stylesheet_directory(),
                        
get_stylesheet_directory_uri(),
                    ],
                    
$extra
                
)
            )
        );
    }
}