GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — feature/attachment-taxonomies ( 05a68d...355e81 )
by Brad
03:29
created

fs-core-functions.php ➔ _fs_text_inline()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 14 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
    /**
3
     * @package     Freemius
4
     * @copyright   Copyright (c) 2015, Freemius, Inc.
5
     * @license     https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
     * @since       1.0.3
7
     */
8
9
    if ( ! defined( 'ABSPATH' ) ) {
10
        exit;
11
    }
12
13
    if ( ! function_exists( 'fs_dummy' ) ) {
14
        function fs_dummy() {
15
        }
16
    }
17
18
    /* Url.
19
    --------------------------------------------------------------------------------------------*/
20
    if ( ! function_exists( 'fs_get_url_daily_cache_killer' ) ) {
21
        function fs_get_url_daily_cache_killer() {
22
            return date( '\YY\Mm\Dd' );
23
        }
24
    }
25
26
    /* Templates / Views.
27
    --------------------------------------------------------------------------------------------*/
28
    if ( ! function_exists( 'fs_get_template_path' ) ) {
29
        function fs_get_template_path( $path ) {
30
            return WP_FS__DIR_TEMPLATES . '/' . trim( $path, '/' );
31
        }
32
33
        function fs_include_template( $path, &$params = null ) {
34
            $VARS = &$params;
35
            include fs_get_template_path( $path );
36
        }
37
38
        function fs_include_once_template( $path, &$params = null ) {
39
            $VARS = &$params;
40
            include_once fs_get_template_path( $path );
41
        }
42
43
        function fs_require_template( $path, &$params = null ) {
44
            $VARS = &$params;
45
            require fs_get_template_path( $path );
46
        }
47
48
        function fs_require_once_template( $path, &$params = null ) {
49
            $VARS = &$params;
50
            require_once fs_get_template_path( $path );
51
        }
52
53
        function fs_get_template( $path, &$params = null ) {
54
            ob_start();
55
56
            $VARS = &$params;
57
            require fs_get_template_path( $path );
58
59
            return ob_get_clean();
60
        }
61
    }
62
63
    /* Scripts and styles including.
64
    --------------------------------------------------------------------------------------------*/
65
66
    /**
67
     * Generates an absolute URL to the given path. This function ensures that the URL will be correct whether the asset
68
     * is inside a plugin's folder or a theme's folder.
69
     *
70
     * Examples:
71
     * 1. "themes" folder
72
     *    Path: C:/xampp/htdocs/fswp/wp-content/themes/twentytwelve/freemius/assets/css/admin/common.css
73
     *    URL: http://fswp:8080/wp-content/themes/twentytwelve/freemius/assets/css/admin/common.css
74
     *
75
     * 2. "plugins" folder
76
     *    Path: C:/xampp/htdocs/fswp/wp-content/plugins/rating-widget-premium/freemius/assets/css/admin/common.css
77
     *    URL: http://fswp:8080/wp-content/plugins/rating-widget-premium/freemius/assets/css/admin/common.css
78
     *
79
     * @author Leo Fajardo (@leorw)
80
     * @since  1.2.2
81
     *
82
     * @param  string $asset_abs_path Asset's absolute path.
83
     *
84
     * @return string Asset's URL.
85
     */
86
    function fs_asset_url( $asset_abs_path ) {
87
        $wp_content_dir = fs_normalize_path( WP_CONTENT_DIR );
88
        $asset_abs_path = fs_normalize_path( $asset_abs_path );
89
        $asset_rel_path = str_replace( $wp_content_dir, '', $asset_abs_path );
90
91
        $asset_url = content_url( fs_normalize_path( $asset_rel_path ) );
92
93
        return $asset_url;
94
    }
95
96
    function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
97
        wp_enqueue_style( $handle, fs_asset_url( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ), $deps, $ver, $media );
98
    }
99
100
    function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
101
        wp_enqueue_script( $handle, fs_asset_url( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ), $deps, $ver, $in_footer );
102
    }
103
104
    function fs_img_url( $path, $img_dir = WP_FS__DIR_IMG ) {
105
        return ( fs_asset_url( $img_dir . '/' . trim( $path, '/' ) ) );
106
    }
107
108
    #--------------------------------------------------------------------------------
109
    #region Request handlers.
110
    #--------------------------------------------------------------------------------
111
112
    if ( ! function_exists( 'fs_request_get' ) ) {
113
        /**
114
         * @param string      $key
115
         * @param mixed       $def
116
         * @param string|bool $type Since 1.2.1.7 - when set to 'get' will look for the value passed via querystring, when
117
         *                          set to 'post' will look for the value passed via the POST request's body, otherwise,
118
         *                          will check if the parameter was passed in any of the two.
119
         *
120
         * @return mixed
121
         */
122
        function fs_request_get( $key, $def = false, $type = false ) {
0 ignored issues
show
Coding Style introduced by
fs_request_get uses the super-global variable $_POST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
Coding Style introduced by
fs_request_get uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
Coding Style introduced by
fs_request_get uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
123
            if ( is_string( $type ) ) {
124
                $type = strtolower( $type );
125
            }
126
127
            switch ( $type ) {
128
                case 'post':
129
                    $value = isset( $_POST[ $key ] ) ? $_POST[ $key ] : $def;
130
                    break;
131
                case 'get':
132
                    $value = isset( $_GET[ $key ] ) ? $_GET[ $key ] : $def;
133
                    break;
134
                default:
135
                    $value = isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : $def;
136
                    break;
137
            }
138
139
            return $value;
140
        }
141
    }
142
143
    if ( ! function_exists( 'fs_request_has' ) ) {
144
        function fs_request_has( $key ) {
0 ignored issues
show
Coding Style introduced by
fs_request_has uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
145
            return isset( $_REQUEST[ $key ] );
146
        }
147
    }
148
149
    if ( ! function_exists( 'fs_request_get_bool' ) ) {
150
        function fs_request_get_bool( $key, $def = false ) {
0 ignored issues
show
Coding Style introduced by
fs_request_get_bool uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
151
            if ( ! isset( $_REQUEST[ $key ] ) ) {
152
                return $def;
153
            }
154
155
            if ( 1 == $_REQUEST[ $key ] || 'true' === strtolower( $_REQUEST[ $key ] ) ) {
156
                return true;
157
            }
158
159
            if ( 0 == $_REQUEST[ $key ] || 'false' === strtolower( $_REQUEST[ $key ] ) ) {
160
                return false;
161
            }
162
163
            return $def;
164
        }
165
    }
166
167
    if ( ! function_exists( 'fs_request_is_post' ) ) {
168
        function fs_request_is_post() {
0 ignored issues
show
Coding Style introduced by
fs_request_is_post uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
169
            return ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
170
        }
171
    }
172
173
    if ( ! function_exists( 'fs_request_is_get' ) ) {
174
        function fs_request_is_get() {
0 ignored issues
show
Coding Style introduced by
fs_request_is_get uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
175
            return ( 'get' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
176
        }
177
    }
178
179
    if ( ! function_exists( 'fs_get_action' ) ) {
180
        function fs_get_action( $action_key = 'action' ) {
0 ignored issues
show
Coding Style introduced by
fs_get_action uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
181
            if ( ! empty( $_REQUEST[ $action_key ] ) && is_string( $_REQUEST[ $action_key ] ) ) {
182
                return strtolower( $_REQUEST[ $action_key ] );
183
            }
184
185
            if ( 'action' == $action_key ) {
186
                $action_key = 'fs_action';
187
188
                if ( ! empty( $_REQUEST[ $action_key ] ) && is_string( $_REQUEST[ $action_key ] ) ) {
189
                    return strtolower( $_REQUEST[ $action_key ] );
190
                }
191
            }
192
193
            return false;
194
        }
195
    }
196
197
    if ( ! function_exists( 'fs_request_is_action' ) ) {
198
        function fs_request_is_action( $action, $action_key = 'action' ) {
199
            return ( strtolower( $action ) === fs_get_action( $action_key ) );
200
        }
201
    }
202
203
    if ( ! function_exists( 'fs_request_is_action_secure' ) ) {
204
        /**
205
         * @author Vova Feldman (@svovaf)
206
         * @since  1.0.0
207
         *
208
         * @since  1.2.1.5 Allow nonce verification.
209
         *
210
         * @param string $action
211
         * @param string $action_key
212
         * @param string $nonce_key
213
         *
214
         * @return bool
215
         */
216
        function fs_request_is_action_secure(
0 ignored issues
show
Coding Style introduced by
fs_request_is_action_secure uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
217
            $action,
218
            $action_key = 'action',
219
            $nonce_key = 'nonce'
220
        ) {
221
            if ( strtolower( $action ) !== fs_get_action( $action_key ) ) {
222
                return false;
223
            }
224
225
            $nonce = ! empty( $_REQUEST[ $nonce_key ] ) ?
226
                $_REQUEST[ $nonce_key ] :
227
                '';
228
229
            if ( empty( $nonce ) ||
230
                 ( false === wp_verify_nonce( $nonce, $action ) )
231
            ) {
232
                return false;
233
            }
234
235
            return true;
236
        }
237
    }
238
239
    #endregion
240
241
    if ( ! function_exists( 'fs_is_plugin_page' ) ) {
242
        function fs_is_plugin_page( $page_slug ) {
243
            return ( is_admin() && $page_slug === fs_request_get( 'page' ) );
244
        }
245
    }
246
247
    if ( ! function_exists( 'fs_get_raw_referer' ) ) {
248
        /**
249
         * Retrieves unvalidated referer from '_wp_http_referer' or HTTP referer.
250
         *
251
         * Do not use for redirects, use {@see wp_get_referer()} instead.
252
         *
253
         * @since 1.2.3
254
         *
255
         * @return string|false Referer URL on success, false on failure.
256
         */
257
        function fs_get_raw_referer() {
0 ignored issues
show
Coding Style introduced by
fs_get_raw_referer uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
Coding Style introduced by
fs_get_raw_referer uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
258
            if ( function_exists( 'wp_get_raw_referer' ) ) {
259
                return wp_get_raw_referer();
260
            }
261
            if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
262
                return wp_unslash( $_REQUEST['_wp_http_referer'] );
263
            } else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
264
                return wp_unslash( $_SERVER['HTTP_REFERER'] );
265
            }
266
267
            return false;
268
        }
269
    }
270
271
    /* Core UI.
272
    --------------------------------------------------------------------------------------------*/
273
    /**
274
     * @param number      $module_id
275
     * @param string      $page
276
     * @param string      $action
277
     * @param string      $title
278
     * @param array       $params
279
     * @param bool        $is_primary
280
     * @param string|bool $icon_class   Optional class for an icon (since 1.1.7).
281
     * @param string|bool $confirmation Optional confirmation message before submit (since 1.1.7).
282
     * @param string      $method       Since 1.1.7
283
     *
284
     * @uses fs_ui_get_action_button()
285
     */
286
    function fs_ui_action_button(
287
        $module_id,
288
        $page,
289
        $action,
290
        $title,
291
        $params = array(),
292
        $is_primary = true,
293
        $icon_class = false,
294
        $confirmation = false,
295
        $method = 'GET'
296
    ) {
297
        echo fs_ui_get_action_button(
298
            $module_id,
299
            $page,
300
            $action,
301
            $title,
302
            $params,
303
            $is_primary,
304
            $icon_class,
305
            $confirmation,
306
            $method
307
        );
308
    }
309
310
    /**
311
     * @author Vova Feldman (@svovaf)
312
     * @since  1.1.7
313
     *
314
     * @param number      $module_id
315
     * @param string      $page
316
     * @param string      $action
317
     * @param string      $title
318
     * @param array       $params
319
     * @param bool        $is_primary
320
     * @param string|bool $icon_class   Optional class for an icon.
321
     * @param string|bool $confirmation Optional confirmation message before submit.
322
     * @param string      $method
323
     *
324
     * @return string
325
     */
326
    function fs_ui_get_action_button(
327
        $module_id,
328
        $page,
329
        $action,
330
        $title,
331
        $params = array(),
332
        $is_primary = true,
333
        $icon_class = false,
334
        $confirmation = false,
335
        $method = 'GET'
336
    ) {
337
        // Prepend icon (if set).
338
        $title = ( is_string( $icon_class ) ? '<i class="' . $icon_class . '"></i> ' : '' ) . $title;
339
340
        if ( is_string( $confirmation ) ) {
341
            return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="if (confirm(\'%s\')) this.parentNode.submit(); return false;">%s</a></form>',
342
                freemius( $module_id )->_get_admin_page_url( $page, $params ),
343
                $method,
344
                $action,
345
                wp_nonce_field( $action, '_wpnonce', true, false ),
346
                'button' . ( $is_primary ? ' button-primary' : '' ),
347
                $confirmation,
348
                $title
349
            );
350
        } else if ( 'GET' !== strtoupper( $method ) ) {
351
            return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="this.parentNode.submit(); return false;">%s</a></form>',
352
                freemius( $module_id )->_get_admin_page_url( $page, $params ),
353
                $method,
354
                $action,
355
                wp_nonce_field( $action, '_wpnonce', true, false ),
356
                'button' . ( $is_primary ? ' button-primary' : '' ),
357
                $title
358
            );
359
        } else {
360
            return sprintf( '<a href="%s" class="%s">%s</a></form>',
361
                wp_nonce_url( freemius( $module_id )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ),
362
                'button' . ( $is_primary ? ' button-primary' : '' ),
363
                $title
364
            );
365
        }
366
    }
367
368
    function fs_ui_action_link( $module_id, $page, $action, $title, $params = array() ) {
369
        ?><a class=""
370
             href="<?php echo wp_nonce_url( freemius( $module_id )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ) ?>"><?php echo $title ?></a><?php
371
    }
372
373
    /*function fs_error_handler($errno, $errstr, $errfile, $errline)
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
374
    {
375
        if (false === strpos($errfile, 'freemius/'))
376
        {
377
            // @todo Dump Freemius errors to local log.
378
        }
379
380
//		switch ($errno) {
381
//			case E_USER_ERROR:
382
//				break;
383
//			case E_WARNING:
384
//			case E_USER_WARNING:
385
//				break;
386
//			case E_NOTICE:
387
//			case E_USER_NOTICE:
388
//				break;
389
//			default:
390
//				break;
391
//		}
392
    }
393
394
    set_error_handler('fs_error_handler');*/
395
396
    if ( ! function_exists( 'fs_nonce_url' ) ) {
397
        /**
398
         * Retrieve URL with nonce added to URL query.
399
         *
400
         * Originally was using `wp_nonce_url()` but the new version
401
         * changed the return value to escaped URL, that's not the expected
402
         * behaviour.
403
         *
404
         * @author Vova Feldman (@svovaf)
405
         * @since  ~1.1.3
406
         *
407
         * @param string     $actionurl URL to add nonce action.
408
         * @param int|string $action    Optional. Nonce action name. Default -1.
409
         * @param string     $name      Optional. Nonce name. Default '_wpnonce'.
410
         *
411
         * @return string Escaped URL with nonce action added.
412
         */
413
        function fs_nonce_url( $actionurl, $action = - 1, $name = '_wpnonce' ) {
414
            return add_query_arg( $name, wp_create_nonce( $action ), $actionurl );
415
        }
416
    }
417
418
    if ( ! function_exists( 'fs_starts_with' ) ) {
419
        /**
420
         * Check if string starts with.
421
         *
422
         * @author Vova Feldman (@svovaf)
423
         * @since  1.1.3
424
         *
425
         * @param string $haystack
426
         * @param string $needle
427
         *
428
         * @return bool
429
         */
430
        function fs_starts_with( $haystack, $needle ) {
431
            $length = strlen( $needle );
432
433
            return ( substr( $haystack, 0, $length ) === $needle );
434
        }
435
    }
436
437
    #region Url Canonization ------------------------------------------------------------------
438
439
    if ( ! function_exists( 'fs_canonize_url' ) ) {
440
        /**
441
         * @author Vova Feldman (@svovaf)
442
         * @since  1.1.3
443
         *
444
         * @param string $url
445
         * @param bool   $omit_host
446
         * @param array  $ignore_params
447
         *
448
         * @return string
449
         */
450
        function fs_canonize_url( $url, $omit_host = false, $ignore_params = array() ) {
451
            $parsed_url = parse_url( strtolower( $url ) );
452
453
//		if ( ! isset( $parsed_url['host'] ) ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
454
//			return $url;
455
//		}
456
457
            $canonical = ( ( $omit_host || ! isset( $parsed_url['host'] ) ) ? '' : $parsed_url['host'] ) . $parsed_url['path'];
458
459
            if ( isset( $parsed_url['query'] ) ) {
460
                parse_str( $parsed_url['query'], $queryString );
461
                $canonical .= '?' . fs_canonize_query_string( $queryString, $ignore_params );
0 ignored issues
show
Bug introduced by
It seems like $queryString can also be of type null; however, fs_canonize_query_string() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
462
            }
463
464
            return $canonical;
465
        }
466
    }
467
468
    if ( ! function_exists( 'fs_canonize_query_string' ) ) {
469
        /**
470
         * @author Vova Feldman (@svovaf)
471
         * @since  1.1.3
472
         *
473
         * @param array $params
474
         * @param array $ignore_params
475
         * @param bool  $params_prefix
476
         *
477
         * @return string
478
         */
479
        function fs_canonize_query_string( array $params, array &$ignore_params, $params_prefix = false ) {
480
            if ( ! is_array( $params ) || 0 === count( $params ) ) {
481
                return '';
482
            }
483
484
            // Url encode both keys and values
485
            $keys   = fs_urlencode_rfc3986( array_keys( $params ) );
486
            $values = fs_urlencode_rfc3986( array_values( $params ) );
487
            $params = array_combine( $keys, $values );
488
489
            // Parameters are sorted by name, using lexicographical byte value ordering.
490
            // Ref: Spec: 9.1.1 (1)
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
491
            uksort( $params, 'strcmp' );
492
493
            $pairs = array();
494
            foreach ( $params as $parameter => $value ) {
495
                $lower_param = strtolower( $parameter );
496
497
                // Skip ignore params.
498
                if ( in_array( $lower_param, $ignore_params ) ||
499
                     ( false !== $params_prefix && fs_starts_with( $lower_param, $params_prefix ) )
0 ignored issues
show
Documentation introduced by
$params_prefix is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
500
                ) {
501
                    continue;
502
                }
503
504
                if ( is_array( $value ) ) {
505
                    // If two or more parameters share the same name, they are sorted by their value
506
                    // Ref: Spec: 9.1.1 (1)
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
507
                    natsort( $value );
508
                    foreach ( $value as $duplicate_value ) {
509
                        $pairs[] = $lower_param . '=' . $duplicate_value;
510
                    }
511
                } else {
512
                    $pairs[] = $lower_param . '=' . $value;
513
                }
514
            }
515
516
            if ( 0 === count( $pairs ) ) {
517
                return '';
518
            }
519
520
            return implode( "&", $pairs );
521
        }
522
    }
523
524
    if ( ! function_exists( 'fs_urlencode_rfc3986' ) ) {
525
        /**
526
         * @author Vova Feldman (@svovaf)
527
         * @since  1.1.3
528
         *
529
         * @param string|string[] $input
530
         *
531
         * @return array|mixed|string
532
         */
533
        function fs_urlencode_rfc3986( $input ) {
534
            if ( is_array( $input ) ) {
535
                return array_map( 'fs_urlencode_rfc3986', $input );
536
            } else if ( is_scalar( $input ) ) {
537
                return str_replace( '+', ' ', str_replace( '%7E', '~', rawurlencode( $input ) ) );
538
            }
539
540
            return '';
541
        }
542
    }
543
544
    #endregion Url Canonization ------------------------------------------------------------------
545
546
    /**
547
     * @author Vova Feldman (@svovaf)
548
     *
549
     * @since  1.2.2 Changed to usage of WP_Filesystem_Direct.
550
     *
551
     * @param string $from URL
552
     * @param string $to   File path.
553
     *
554
     * @return bool Is successfully downloaded.
555
     */
556
    function fs_download_image( $from, $to ) {
557
        $dir = dirname( $to );
558
559
        if ( 'direct' !== get_filesystem_method( array(), $dir ) ) {
560
            return false;
561
        }
562
563
        if ( ! class_exists( 'WP_Filesystem_Direct' ) ) {
564
            require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
565
            require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
566
        }
567
568
        $fs      = new WP_Filesystem_Direct( '' );
569
        $tmpfile = download_url( $from );
570
571
        if ( $tmpfile instanceof WP_Error ) {
0 ignored issues
show
Bug introduced by
The class WP_Error does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
572
            // Issue downloading the file.
573
            return false;
574
        }
575
576
        $fs->copy( $tmpfile, $to );
577
        $fs->delete( $tmpfile );
578
579
        return true;
580
    }
581
582
    /* General Utilities
583
    --------------------------------------------------------------------------------------------*/
584
585
    /**
586
     * Sorts an array by the value of the priority key.
587
     *
588
     * @author Daniel Iser (@danieliser)
589
     * @since  1.1.7
590
     *
591
     * @param $a
592
     * @param $b
593
     *
594
     * @return int
595
     */
596
    function fs_sort_by_priority( $a, $b ) {
597
598
        // If b has a priority and a does not, b wins.
599
        if ( ! isset( $a['priority'] ) && isset( $b['priority'] ) ) {
600
            return 1;
601
        } // If b has a priority and a does not, b wins.
602
        elseif ( isset( $a['priority'] ) && ! isset( $b['priority'] ) ) {
603
            return - 1;
604
        } // If neither has a priority or both priorities are equal its a tie.
605
        elseif ( ( ! isset( $a['priority'] ) && ! isset( $b['priority'] ) ) || $a['priority'] === $b['priority'] ) {
606
            return 0;
607
        }
608
609
        // If both have priority return the winner.
610
        return ( $a['priority'] < $b['priority'] ) ? - 1 : 1;
611
    }
612
613
    #--------------------------------------------------------------------------------
614
    #region Localization
615
    #--------------------------------------------------------------------------------
616
617
    if ( ! function_exists( 'fs_text' ) ) {
618
        /**
619
         * Retrieve a translated text by key.
620
         *
621
         * @author Vova Feldman (@svovaf)
622
         * @since  1.2.1.7
623
         *
624
         * @param string $key
625
         * @param string $slug
626
         *
627
         * @return string
628
         *
629
         * @global       $fs_text , $fs_text_overrides
630
         */
631
        function fs_text( $key, $slug = 'freemius' ) {
632
            return __fs( $key, $slug );
0 ignored issues
show
Deprecated Code introduced by
The function __fs() has been deprecated with message: Use `fs_text()` instead since methods starting with `__` trigger warnings in Php 7.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
633
        }
634
635
        /**
636
         * Get a translatable text override if exists, or `false`.
637
         *
638
         * @author Vova Feldman (@svovaf)
639
         * @since  1.2.1.7
640
         *
641
         * @param string $text Translatable string.
642
         * @param string $key  String key for overrides.
643
         * @param string $slug Module slug for overrides.
644
         *
645
         * @return string|false
646
         */
647
        function fs_text_override( $text, $key, $slug ) {
648
            global $fs_text_overrides;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
649
650
            /**
651
             * Check if string is overridden.
652
             */
653
            if ( ! isset( $fs_text_overrides[ $slug ] ) ) {
654
                return false;
655
            }
656
657
            if ( empty( $key ) ) {
658
                $key = strtolower( str_replace( ' ', '-', $text ) );
659
            }
660
661
            if ( isset( $fs_text_overrides[ $slug ][ $key ] ) ) {
662
                return $fs_text_overrides[ $slug ][ $key ];
663
            }
664
665
            $lower_key = strtolower( $key );
666
            if ( isset( $fs_text_overrides[ $slug ][ $lower_key ] ) ) {
667
                return $fs_text_overrides[ $slug ][ $lower_key ];
668
            }
669
670
            return false;
671
        }
672
673
        /**
674
         * Get a translatable text and its text domain.
675
         *
676
         * When the text is overridden by the module, returns the overridden text and the text domain of the module. Otherwise, returns the original text and 'freemius' as the text domain.
677
         *
678
         * @author Vova Feldman (@svovaf)
679
         * @since  1.2.1.7
680
         *
681
         * @param string $text Translatable string.
682
         * @param string $key  String key for overrides.
683
         * @param string $slug Module slug for overrides.
684
         *
685
         * @return string[]
686
         */
687
        function fs_text_and_domain( $text, $key, $slug ) {
688
            $override = fs_text_override( $text, $key, $slug );
689
690
            if ( false === $override ) {
691
                // No override, use FS text domain.
692
                $text_domain = 'freemius';
693
            } else {
694
                // Found an override.
695
                $text = $override;
696
                // Use the module's text domain.
697
                $text_domain = $slug;
698
            }
699
700
            return array( $text, $text_domain );
701
        }
702
703
        #region Private
704
705
        /**
706
         * Retrieve an inline translated text by key.
707
         *
708
         * @author Vova Feldman (@svovaf)
709
         * @since  1.2.3
710
         *
711
         * @param string $text Translatable string.
712
         * @param string $key  String key for overrides.
713
         * @param string $slug Module slug for overrides.
714
         *
715
         * @return string
716
         *
717
         * @global       $fs_text_overrides
718
         */
719
        function _fs_text_inline( $text, $key = '', $slug = 'freemius' ) {
720
            list( $text, $text_domain ) = fs_text_and_domain( $text, $key, $slug );
721
722
            // Avoid misleading Theme Check warning.
723
            $fn = 'translate';
724
725
            return $fn( $text, $text_domain );
726
        }
727
728
        /**
729
         * Retrieve an inline translated text by key with a context.
730
         *
731
         * @author Vova Feldman (@svovaf)
732
         * @since  1.2.3
733
         *
734
         * @param string $text    Translatable string.
735
         * @param string $context Context information for the translators.
736
         * @param string $key     String key for overrides.
737
         * @param string $slug    Module slug for overrides.
738
         *
739
         * @return string
740
         *
741
         * @global       $fs_text_overrides
742
         */
743
        function _fs_text_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
744
            list( $text, $text_domain ) = fs_text_and_domain( $text, $key, $slug );
745
746
            // Avoid misleading Theme Check warning.
747
            $fn = 'translate_with_gettext_context';
748
749
            return $fn( $text, $context, $text_domain );
750
        }
751
752
        #endregion
753
754
        /**
755
         * Retrieve an inline translated text by key.
756
         *
757
         * @author Vova Feldman (@svovaf)
758
         * @since  1.2.3
759
         *
760
         * @param string $text Translatable string.
761
         * @param string $key  String key for overrides.
762
         * @param string $slug Module slug for overrides.
763
         *
764
         * @return string
765
         *
766
         * @global       $fs_text_overrides
767
         */
768
        function fs_text_inline( $text, $key = '', $slug = 'freemius' ) {
769
            return _fs_text_inline( $text, $key, $slug );
770
        }
771
772
        /**
773
         * Retrieve an inline translated text by key with a context.
774
         *
775
         * @author Vova Feldman (@svovaf)
776
         * @since  1.2.3
777
         *
778
         * @param string $text    Translatable string.
779
         * @param string $context Context information for the translators.
780
         * @param string $key     String key for overrides.
781
         * @param string $slug    Module slug for overrides.
782
         *
783
         * @return string
784
         *
785
         * @global       $fs_text_overrides
786
         */
787
        function fs_text_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
788
            return _fs_text_x_inline( $text, $context, $key, $slug );
789
        }
790
791
        /**
792
         * Output a translated text by key.
793
         *
794
         * @author Vova Feldman (@svovaf)
795
         * @since  1.2.1.7
796
         *
797
         * @param string $key
798
         * @param string $slug
799
         */
800
        function fs_echo( $key, $slug = 'freemius' ) {
801
            echo fs_text( $key, $slug );
802
        }
803
804
        /**
805
         * Output an inline translated text.
806
         *
807
         * @author Vova Feldman (@svovaf)
808
         * @since  1.2.3
809
         *
810
         * @param string $text Translatable string.
811
         * @param string $key  String key for overrides.
812
         * @param string $slug Module slug for overrides.
813
         */
814
        function fs_echo_inline( $text, $key = '', $slug = 'freemius' ) {
815
            echo _fs_text_inline( $text, $key, $slug );
816
        }
817
818
        /**
819
         * Output an inline translated text with a context.
820
         *
821
         * @author Vova Feldman (@svovaf)
822
         * @since  1.2.3
823
         *
824
         * @param string $text    Translatable string.
825
         * @param string $context Context information for the translators.
826
         * @param string $key     String key for overrides.
827
         * @param string $slug    Module slug for overrides.
828
         */
829
        function fs_echo_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
830
            echo _fs_text_x_inline( $text, $context, $key, $slug );
831
        }
832
    }
833
834
    if ( ! function_exists( 'fs_esc_attr' ) ) {
835
        /**
836
         * @author Vova Feldman
837
         * @since  1.2.1.6
838
         *
839
         * @param string $key
840
         * @param string $slug
841
         *
842
         * @return string
843
         */
844
        function fs_esc_attr( $key, $slug ) {
845
            return esc_attr( fs_text( $key, $slug ) );
846
        }
847
    }
848
849
    if ( ! function_exists( 'fs_esc_attr_inline' ) ) {
850
        /**
851
         * @author Vova Feldman (@svovaf)
852
         * @since  1.2.3
853
         *
854
         * @param string $text Translatable string.
855
         * @param string $key  String key for overrides.
856
         * @param string $slug Module slug for overrides.
857
         *
858
         * @return string
859
         */
860
        function fs_esc_attr_inline( $text, $key = '', $slug = 'freemius' ) {
861
            return esc_attr( _fs_text_inline( $text, $key, $slug ) );
862
        }
863
    }
864
865
    if ( ! function_exists( 'fs_esc_attr_x_inline' ) ) {
866
        /**
867
         * @author Vova Feldman (@svovaf)
868
         * @since  1.2.3
869
         *
870
         * @param string $text    Translatable string.
871
         * @param string $context Context information for the translators.
872
         * @param string $key     String key for overrides.
873
         * @param string $slug    Module slug for overrides.
874
         *
875
         * @return string
876
         */
877
        function fs_esc_attr_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
878
            return esc_attr( _fs_text_x_inline( $text, $context, $key, $slug ) );
879
        }
880
    }
881
882
    if ( ! function_exists( 'fs_esc_attr_echo' ) ) {
883
        /**
884
         * @author Vova Feldman
885
         * @since  1.2.1.6
886
         *
887
         * @param string $key
888
         * @param string $slug
889
         */
890
        function fs_esc_attr_echo( $key, $slug ) {
891
            echo esc_attr( fs_text( $key, $slug ) );
892
        }
893
    }
894
895
    if ( ! function_exists( 'fs_esc_attr_echo_inline' ) ) {
896
        /**
897
         * @author Vova Feldman (@svovaf)
898
         * @since  1.2.3
899
         *
900
         * @param string $text Translatable string.
901
         * @param string $key  String key for overrides.
902
         * @param string $slug Module slug for overrides.
903
         */
904
        function fs_esc_attr_echo_inline( $text, $key = '', $slug = 'freemius' ) {
905
            echo esc_attr( _fs_text_inline( $text, $key, $slug ) );
906
        }
907
    }
908
909
    if ( ! function_exists( 'fs_esc_js' ) ) {
910
        /**
911
         * @author Vova Feldman
912
         * @since  1.2.1.6
913
         *
914
         * @param string $key
915
         * @param string $slug
916
         *
917
         * @return string
918
         */
919
        function fs_esc_js( $key, $slug ) {
920
            return esc_js( fs_text( $key, $slug ) );
921
        }
922
    }
923
924
    if ( ! function_exists( 'fs_esc_js_inline' ) ) {
925
        /**
926
         * @author Vova Feldman (@svovaf)
927
         * @since  1.2.3
928
         *
929
         * @param string $text Translatable string.
930
         * @param string $key  String key for overrides.
931
         * @param string $slug Module slug for overrides.
932
         *
933
         * @return string
934
         */
935
        function fs_esc_js_inline( $text, $key = '', $slug = 'freemius' ) {
936
            return esc_js( _fs_text_inline( $text, $key, $slug ) );
937
        }
938
    }
939
940
    if ( ! function_exists( 'fs_esc_js_x_inline' ) ) {
941
        /**
942
         * @author Vova Feldman (@svovaf)
943
         * @since  1.2.3
944
         *
945
         * @param string $text    Translatable string.
946
         * @param string $context Context information for the translators.
947
         * @param string $key     String key for overrides.
948
         * @param string $slug    Module slug for overrides.
949
         *
950
         * @return string
951
         */
952
        function fs_esc_js_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
953
            return esc_js( _fs_text_x_inline( $text, $context, $key, $slug ) );
954
        }
955
    }
956
957
    if ( ! function_exists( 'fs_esc_js_echo_x_inline' ) ) {
958
        /**
959
         * @author Vova Feldman (@svovaf)
960
         * @since  1.2.3
961
         *
962
         * @param string $text    Translatable string.
963
         * @param string $context Context information for the translators.
964
         * @param string $key     String key for overrides.
965
         * @param string $slug    Module slug for overrides.
966
         *
967
         * @return string
968
         */
969
        function fs_esc_js_echo_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
970
            echo esc_js( _fs_text_x_inline( $text, $context, $key, $slug ) );
971
        }
972
    }
973
974
    if ( ! function_exists( 'fs_esc_js_echo' ) ) {
975
        /**
976
         * @author Vova Feldman
977
         * @since  1.2.1.6
978
         *
979
         * @param string $key
980
         * @param string $slug
981
         */
982
        function fs_esc_js_echo( $key, $slug ) {
983
            echo esc_js( fs_text( $key, $slug ) );
984
        }
985
    }
986
987
    if ( ! function_exists( 'fs_esc_js_echo_inline' ) ) {
988
        /**
989
         * @author Vova Feldman (@svovaf)
990
         * @since  1.2.3
991
         *
992
         * @param string $text Translatable string.
993
         * @param string $key  String key for overrides.
994
         * @param string $slug Module slug for overrides.
995
         */
996
        function fs_esc_js_echo_inline( $text, $key = '', $slug = 'freemius' ) {
997
            echo esc_js( _fs_text_inline( $text, $key, $slug ) );
998
        }
999
    }
1000
1001
    if ( ! function_exists( 'fs_json_encode_echo' ) ) {
1002
        /**
1003
         * @author Vova Feldman
1004
         * @since  1.2.1.6
1005
         *
1006
         * @param string $key
1007
         * @param string $slug
1008
         */
1009
        function fs_json_encode_echo( $key, $slug ) {
1010
            echo json_encode( fs_text( $key, $slug ) );
1011
        }
1012
    }
1013
1014
    if ( ! function_exists( 'fs_json_encode_echo_inline' ) ) {
1015
        /**
1016
         * @author Vova Feldman (@svovaf)
1017
         * @since  1.2.3
1018
         *
1019
         * @param string $text Translatable string.
1020
         * @param string $key  String key for overrides.
1021
         * @param string $slug Module slug for overrides.
1022
         */
1023
        function fs_json_encode_echo_inline( $text, $key = '', $slug = 'freemius' ) {
1024
            echo json_encode( _fs_text_inline( $text, $key, $slug ) );
1025
        }
1026
    }
1027
1028
    if ( ! function_exists( 'fs_esc_html' ) ) {
1029
        /**
1030
         * @author Vova Feldman
1031
         * @since  1.2.1.6
1032
         *
1033
         * @param string $key
1034
         * @param string $slug
1035
         *
1036
         * @return string
1037
         */
1038
        function fs_esc_html( $key, $slug ) {
1039
            return esc_html( fs_text( $key, $slug ) );
1040
        }
1041
    }
1042
1043
    if ( ! function_exists( 'fs_esc_html_inline' ) ) {
1044
        /**
1045
         * @author Vova Feldman (@svovaf)
1046
         * @since  1.2.3
1047
         *
1048
         * @param string $text Translatable string.
1049
         * @param string $key  String key for overrides.
1050
         * @param string $slug Module slug for overrides.
1051
         *
1052
         * @return string
1053
         */
1054
        function fs_esc_html_inline( $text, $key = '', $slug = 'freemius' ) {
1055
            return esc_html( _fs_text_inline( $text, $key, $slug ) );
1056
        }
1057
    }
1058
1059
    if ( ! function_exists( 'fs_esc_html_x_inline' ) ) {
1060
        /**
1061
         * @author Vova Feldman (@svovaf)
1062
         * @since  1.2.3
1063
         *
1064
         * @param string $text    Translatable string.
1065
         * @param string $context Context information for the translators.
1066
         * @param string $key     String key for overrides.
1067
         * @param string $slug    Module slug for overrides.
1068
         *
1069
         * @return string
1070
         */
1071
        function fs_esc_html_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
1072
            return esc_html( _fs_text_x_inline( $text, $context, $key, $slug ) );
1073
        }
1074
    }
1075
1076
    if ( ! function_exists( 'fs_esc_html_echo_x_inline' ) ) {
1077
        /**
1078
         * @author Vova Feldman (@svovaf)
1079
         * @since  1.2.3
1080
         *
1081
         * @param string $text    Translatable string.
1082
         * @param string $context Context information for the translators.
1083
         * @param string $key     String key for overrides.
1084
         * @param string $slug    Module slug for overrides.
1085
         */
1086
        function fs_esc_html_echo_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
1087
            echo esc_html( _fs_text_x_inline( $text, $context, $key, $slug ) );
1088
        }
1089
    }
1090
1091
    if ( ! function_exists( 'fs_esc_html_echo' ) ) {
1092
        /**
1093
         * @author Vova Feldman
1094
         * @since  1.2.1.6
1095
         *
1096
         * @param string $key
1097
         * @param string $slug
1098
         */
1099
        function fs_esc_html_echo( $key, $slug ) {
1100
            echo esc_html( fs_text( $key, $slug ) );
1101
        }
1102
    }
1103
1104
    if ( ! function_exists( 'fs_esc_html_echo_inline' ) ) {
1105
        /**
1106
         * @author Vova Feldman (@svovaf)
1107
         * @since  1.2.3
1108
         *
1109
         * @param string $text Translatable string.
1110
         * @param string $key  String key for overrides.
1111
         * @param string $slug Module slug for overrides.
1112
         */
1113
        function fs_esc_html_echo_inline( $text, $key = '', $slug = 'freemius' ) {
1114
            echo esc_html( _fs_text_inline( $text, $key, $slug ) );
1115
        }
1116
    }
1117
1118
#endregion
1119