debug
9 years ago
entities
9 years ago
managers
9 years ago
sdk
9 years ago
supplements
9 years ago
class-freemius-abstract.php
9 years ago
class-freemius.php
9 years ago
class-fs-api.php
9 years ago
class-fs-logger.php
9 years ago
class-fs-plugin-updater.php
9 years ago
class-fs-security.php
9 years ago
fs-core-functions.php
9 years ago
fs-essential-functions.php
9 years ago
fs-plugin-info-dialog.php
9 years ago
i18n.php
9 years ago
index.php
9 years ago
l10n.php
9 years ago
fs-core-functions.php
630 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package Freemius |
| 4 | * @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 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 | function fs_get_url_daily_cache_killer() { |
| 21 | return date( '\YY\Mm\Dd' ); |
| 22 | } |
| 23 | |
| 24 | /* Templates / Views. |
| 25 | --------------------------------------------------------------------------------------------*/ |
| 26 | if ( ! function_exists( 'fs_get_template_path' ) ) { |
| 27 | function fs_get_template_path( $path ) { |
| 28 | return WP_FS__DIR_TEMPLATES . '/' . trim( $path, '/' ); |
| 29 | } |
| 30 | |
| 31 | function fs_include_template( $path, &$params = null ) { |
| 32 | $VARS = &$params; |
| 33 | include fs_get_template_path( $path ); |
| 34 | } |
| 35 | |
| 36 | function fs_include_once_template( $path, &$params = null ) { |
| 37 | $VARS = &$params; |
| 38 | include_once fs_get_template_path( $path ); |
| 39 | } |
| 40 | |
| 41 | function fs_require_template( $path, &$params = null ) { |
| 42 | $VARS = &$params; |
| 43 | require fs_get_template_path( $path ); |
| 44 | } |
| 45 | |
| 46 | function fs_require_once_template( $path, &$params = null ) { |
| 47 | $VARS = &$params; |
| 48 | require_once fs_get_template_path( $path ); |
| 49 | } |
| 50 | |
| 51 | function fs_get_template( $path, &$params = null ) { |
| 52 | ob_start(); |
| 53 | |
| 54 | $VARS = &$params; |
| 55 | require fs_get_template_path( $path ); |
| 56 | |
| 57 | return ob_get_clean(); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /* Scripts and styles including. |
| 62 | --------------------------------------------------------------------------------------------*/ |
| 63 | function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) { |
| 64 | wp_enqueue_style( $handle, plugins_url( plugin_basename( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $media ); |
| 65 | } |
| 66 | |
| 67 | function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) { |
| 68 | wp_enqueue_script( $handle, plugins_url( plugin_basename( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $in_footer ); |
| 69 | } |
| 70 | |
| 71 | function fs_img_url( $path, $img_dir = WP_FS__DIR_IMG ) { |
| 72 | return plugins_url( plugin_basename( $img_dir . '/' . trim( $path, '/' ) ) ); |
| 73 | } |
| 74 | |
| 75 | /* Request handlers. |
| 76 | --------------------------------------------------------------------------------------------*/ |
| 77 | /** |
| 78 | * @param string $key |
| 79 | * @param mixed $def |
| 80 | * @param string|bool $type Since 1.2.1.7 - when set to 'get' will look for the value passed via querystring, when |
| 81 | * set to 'post' will look for the value passed via the POST request's body, otherwise, |
| 82 | * will check if the parameter was passed in any of the two. |
| 83 | * |
| 84 | * @return mixed |
| 85 | */ |
| 86 | function fs_request_get( $key, $def = false, $type = false ) { |
| 87 | if ( is_string( $type ) ) { |
| 88 | $type = strtolower( $type ); |
| 89 | } |
| 90 | |
| 91 | switch ( $type ) { |
| 92 | case 'post': |
| 93 | $value = isset( $_POST[ $key ] ) ? $_POST[ $key ] : $def; |
| 94 | break; |
| 95 | case 'get': |
| 96 | $value = isset( $_GET[ $key ] ) ? $_GET[ $key ] : $def; |
| 97 | break; |
| 98 | default: |
| 99 | $value = isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : $def; |
| 100 | break; |
| 101 | } |
| 102 | |
| 103 | return $value; |
| 104 | } |
| 105 | |
| 106 | function fs_request_has( $key ) { |
| 107 | return isset( $_REQUEST[ $key ] ); |
| 108 | } |
| 109 | |
| 110 | function fs_request_get_bool( $key, $def = false ) { |
| 111 | if ( ! isset( $_REQUEST[ $key ] ) ) { |
| 112 | return $def; |
| 113 | } |
| 114 | |
| 115 | if ( 1 == $_REQUEST[ $key ] || 'true' === strtolower( $_REQUEST[ $key ] ) ) { |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | if ( 0 == $_REQUEST[ $key ] || 'false' === strtolower( $_REQUEST[ $key ] ) ) { |
| 120 | return false; |
| 121 | } |
| 122 | |
| 123 | return $def; |
| 124 | } |
| 125 | |
| 126 | function fs_request_is_post() { |
| 127 | return ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) ); |
| 128 | } |
| 129 | |
| 130 | function fs_request_is_get() { |
| 131 | return ( 'get' === strtolower( $_SERVER['REQUEST_METHOD'] ) ); |
| 132 | } |
| 133 | |
| 134 | function fs_get_action( $action_key = 'action' ) { |
| 135 | if ( ! empty( $_REQUEST[ $action_key ] ) ) { |
| 136 | return strtolower( $_REQUEST[ $action_key ] ); |
| 137 | } |
| 138 | |
| 139 | if ( 'action' == $action_key ) { |
| 140 | $action_key = 'fs_action'; |
| 141 | |
| 142 | if ( ! empty( $_REQUEST[ $action_key ] ) ) { |
| 143 | return strtolower( $_REQUEST[ $action_key ] ); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | return false; |
| 148 | } |
| 149 | |
| 150 | function fs_request_is_action( $action, $action_key = 'action' ) { |
| 151 | return ( strtolower( $action ) === fs_get_action( $action_key ) ); |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * @author Vova Feldman (@svovaf) |
| 156 | * @since 1.0.0 |
| 157 | * |
| 158 | * @since 1.2.1.5 Allow nonce verification. |
| 159 | * |
| 160 | * @param string $action |
| 161 | * @param string $action_key |
| 162 | * @param string $nonce_key |
| 163 | * |
| 164 | * @return bool |
| 165 | */ |
| 166 | function fs_request_is_action_secure( |
| 167 | $action, |
| 168 | $action_key = 'action', |
| 169 | $nonce_key = 'nonce' |
| 170 | ) { |
| 171 | if ( strtolower( $action ) !== fs_get_action( $action_key ) ) { |
| 172 | return false; |
| 173 | } |
| 174 | |
| 175 | $nonce = ! empty( $_REQUEST[ $nonce_key ] ) ? |
| 176 | $_REQUEST[ $nonce_key ] : |
| 177 | ''; |
| 178 | |
| 179 | if ( empty( $nonce ) || |
| 180 | ( false === wp_verify_nonce( $nonce, $action ) ) |
| 181 | ) { |
| 182 | return false; |
| 183 | } |
| 184 | |
| 185 | return true; |
| 186 | } |
| 187 | |
| 188 | function fs_is_plugin_page( $page_slug ) { |
| 189 | return ( is_admin() && $page_slug === fs_request_get('page') ); |
| 190 | } |
| 191 | |
| 192 | /* Core UI. |
| 193 | --------------------------------------------------------------------------------------------*/ |
| 194 | /** |
| 195 | * @param string $slug |
| 196 | * @param string $page |
| 197 | * @param string $action |
| 198 | * @param string $title |
| 199 | * @param array $params |
| 200 | * @param bool $is_primary |
| 201 | * @param string|bool $icon_class Optional class for an icon (since 1.1.7). |
| 202 | * @param string|bool $confirmation Optional confirmation message before submit (since 1.1.7). |
| 203 | * @param string $method Since 1.1.7 |
| 204 | * |
| 205 | * @uses fs_ui_get_action_button() |
| 206 | */ |
| 207 | function fs_ui_action_button( |
| 208 | $slug, |
| 209 | $page, |
| 210 | $action, |
| 211 | $title, |
| 212 | $params = array(), |
| 213 | $is_primary = true, |
| 214 | $icon_class = false, |
| 215 | $confirmation = false, |
| 216 | $method = 'GET' |
| 217 | ) { |
| 218 | echo fs_ui_get_action_button( |
| 219 | $slug, |
| 220 | $page, |
| 221 | $action, |
| 222 | $title, |
| 223 | $params, |
| 224 | $is_primary, |
| 225 | $icon_class, |
| 226 | $confirmation, |
| 227 | $method |
| 228 | ); |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * @author Vova Feldman (@svovaf) |
| 233 | * @since 1.1.7 |
| 234 | * |
| 235 | * @param string $slug |
| 236 | * @param string $page |
| 237 | * @param string $action |
| 238 | * @param string $title |
| 239 | * @param array $params |
| 240 | * @param bool $is_primary |
| 241 | * @param string|bool $icon_class Optional class for an icon. |
| 242 | * @param string|bool $confirmation Optional confirmation message before submit. |
| 243 | * @param string $method |
| 244 | * |
| 245 | * @return string |
| 246 | */ |
| 247 | function fs_ui_get_action_button( |
| 248 | $slug, |
| 249 | $page, |
| 250 | $action, |
| 251 | $title, |
| 252 | $params = array(), |
| 253 | $is_primary = true, |
| 254 | $icon_class = false, |
| 255 | $confirmation = false, |
| 256 | $method = 'GET' |
| 257 | ) { |
| 258 | // Prepend icon (if set). |
| 259 | $title = ( is_string( $icon_class ) ? '<i class="' . $icon_class . '"></i> ' : '' ) . $title; |
| 260 | |
| 261 | if ( is_string( $confirmation ) ) { |
| 262 | 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>', |
| 263 | freemius( $slug )->_get_admin_page_url( $page, $params ), |
| 264 | $method, |
| 265 | $action, |
| 266 | wp_nonce_field( $action, '_wpnonce', true, false ), |
| 267 | 'button' . ( $is_primary ? ' button-primary' : '' ), |
| 268 | $confirmation, |
| 269 | $title |
| 270 | ); |
| 271 | } else if ( 'GET' !== strtoupper( $method ) ) { |
| 272 | 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>', |
| 273 | freemius( $slug )->_get_admin_page_url( $page, $params ), |
| 274 | $method, |
| 275 | $action, |
| 276 | wp_nonce_field( $action, '_wpnonce', true, false ), |
| 277 | 'button' . ( $is_primary ? ' button-primary' : '' ), |
| 278 | $title |
| 279 | ); |
| 280 | } else { |
| 281 | return sprintf( '<a href="%s" class="%s">%s</a></form>', |
| 282 | wp_nonce_url( freemius( $slug )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ), |
| 283 | 'button' . ( $is_primary ? ' button-primary' : '' ), |
| 284 | $title |
| 285 | ); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | function fs_ui_action_link( $slug, $page, $action, $title, $params = array() ) { |
| 290 | ?><a class="" |
| 291 | href="<?php echo wp_nonce_url( freemius( $slug )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ) ?>"><?php echo $title ?></a><?php |
| 292 | } |
| 293 | |
| 294 | /*function fs_error_handler($errno, $errstr, $errfile, $errline) |
| 295 | { |
| 296 | if (false === strpos($errfile, 'freemius/')) |
| 297 | { |
| 298 | // @todo Dump Freemius errors to local log. |
| 299 | } |
| 300 | |
| 301 | // switch ($errno) { |
| 302 | // case E_USER_ERROR: |
| 303 | // break; |
| 304 | // case E_WARNING: |
| 305 | // case E_USER_WARNING: |
| 306 | // break; |
| 307 | // case E_NOTICE: |
| 308 | // case E_USER_NOTICE: |
| 309 | // break; |
| 310 | // default: |
| 311 | // break; |
| 312 | // } |
| 313 | } |
| 314 | |
| 315 | set_error_handler('fs_error_handler');*/ |
| 316 | |
| 317 | if ( ! function_exists( 'fs_nonce_url' ) ) { |
| 318 | /** |
| 319 | * Retrieve URL with nonce added to URL query. |
| 320 | * |
| 321 | * Originally was using `wp_nonce_url()` but the new version |
| 322 | * changed the return value to escaped URL, that's not the expected |
| 323 | * behaviour. |
| 324 | * |
| 325 | * @author Vova Feldman (@svovaf) |
| 326 | * @since ~1.1.3 |
| 327 | * |
| 328 | * @param string $actionurl URL to add nonce action. |
| 329 | * @param int|string $action Optional. Nonce action name. Default -1. |
| 330 | * @param string $name Optional. Nonce name. Default '_wpnonce'. |
| 331 | * |
| 332 | * @return string Escaped URL with nonce action added. |
| 333 | */ |
| 334 | function fs_nonce_url( $actionurl, $action = - 1, $name = '_wpnonce' ) { |
| 335 | return add_query_arg( $name, wp_create_nonce( $action ), $actionurl ); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | if ( ! function_exists( 'fs_starts_with' ) ) { |
| 340 | /** |
| 341 | * Check if string starts with. |
| 342 | * |
| 343 | * @author Vova Feldman (@svovaf) |
| 344 | * @since 1.1.3 |
| 345 | * |
| 346 | * @param string $haystack |
| 347 | * @param string $needle |
| 348 | * |
| 349 | * @return bool |
| 350 | */ |
| 351 | function fs_starts_with( $haystack, $needle ) { |
| 352 | $length = strlen( $needle ); |
| 353 | |
| 354 | return ( substr( $haystack, 0, $length ) === $needle ); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | #region Url Canonization ------------------------------------------------------------------ |
| 359 | |
| 360 | if ( ! function_exists( 'fs_canonize_url' ) ) { |
| 361 | /** |
| 362 | * @author Vova Feldman (@svovaf) |
| 363 | * @since 1.1.3 |
| 364 | * |
| 365 | * @param string $url |
| 366 | * @param bool $omit_host |
| 367 | * @param array $ignore_params |
| 368 | * |
| 369 | * @return string |
| 370 | */ |
| 371 | function fs_canonize_url( $url, $omit_host = false, $ignore_params = array() ) { |
| 372 | $parsed_url = parse_url( strtolower( $url ) ); |
| 373 | |
| 374 | // if ( ! isset( $parsed_url['host'] ) ) { |
| 375 | // return $url; |
| 376 | // } |
| 377 | |
| 378 | $canonical = ( ( $omit_host || ! isset( $parsed_url['host'] ) ) ? '' : $parsed_url['host'] ) . $parsed_url['path']; |
| 379 | |
| 380 | if ( isset( $parsed_url['query'] ) ) { |
| 381 | parse_str( $parsed_url['query'], $queryString ); |
| 382 | $canonical .= '?' . fs_canonize_query_string( $queryString, $ignore_params ); |
| 383 | } |
| 384 | |
| 385 | return $canonical; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | if ( ! function_exists( 'fs_canonize_query_string' ) ) { |
| 390 | /** |
| 391 | * @author Vova Feldman (@svovaf) |
| 392 | * @since 1.1.3 |
| 393 | * |
| 394 | * @param array $params |
| 395 | * @param array $ignore_params |
| 396 | * @param bool $params_prefix |
| 397 | * |
| 398 | * @return string |
| 399 | */ |
| 400 | function fs_canonize_query_string( array $params, array &$ignore_params, $params_prefix = false ) { |
| 401 | if ( ! is_array( $params ) || 0 === count( $params ) ) { |
| 402 | return ''; |
| 403 | } |
| 404 | |
| 405 | // Url encode both keys and values |
| 406 | $keys = fs_urlencode_rfc3986( array_keys( $params ) ); |
| 407 | $values = fs_urlencode_rfc3986( array_values( $params ) ); |
| 408 | $params = array_combine( $keys, $values ); |
| 409 | |
| 410 | // Parameters are sorted by name, using lexicographical byte value ordering. |
| 411 | // Ref: Spec: 9.1.1 (1) |
| 412 | uksort( $params, 'strcmp' ); |
| 413 | |
| 414 | $pairs = array(); |
| 415 | foreach ( $params as $parameter => $value ) { |
| 416 | $lower_param = strtolower( $parameter ); |
| 417 | |
| 418 | // Skip ignore params. |
| 419 | if ( in_array( $lower_param, $ignore_params ) || |
| 420 | ( false !== $params_prefix && fs_starts_with( $lower_param, $params_prefix ) ) |
| 421 | ) { |
| 422 | continue; |
| 423 | } |
| 424 | |
| 425 | if ( is_array( $value ) ) { |
| 426 | // If two or more parameters share the same name, they are sorted by their value |
| 427 | // Ref: Spec: 9.1.1 (1) |
| 428 | natsort( $value ); |
| 429 | foreach ( $value as $duplicate_value ) { |
| 430 | $pairs[] = $lower_param . '=' . $duplicate_value; |
| 431 | } |
| 432 | } else { |
| 433 | $pairs[] = $lower_param . '=' . $value; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | if ( 0 === count( $pairs ) ) { |
| 438 | return ''; |
| 439 | } |
| 440 | |
| 441 | return implode( "&", $pairs ); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | if ( ! function_exists( 'fs_urlencode_rfc3986' ) ) { |
| 446 | /** |
| 447 | * @author Vova Feldman (@svovaf) |
| 448 | * @since 1.1.3 |
| 449 | * |
| 450 | * @param string|string[] $input |
| 451 | * |
| 452 | * @return array|mixed|string |
| 453 | */ |
| 454 | function fs_urlencode_rfc3986( $input ) { |
| 455 | if ( is_array( $input ) ) { |
| 456 | return array_map( 'fs_urlencode_rfc3986', $input ); |
| 457 | } else if ( is_scalar( $input ) ) { |
| 458 | return str_replace( '+', ' ', str_replace( '%7E', '~', rawurlencode( $input ) ) ); |
| 459 | } |
| 460 | |
| 461 | return ''; |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | #endregion Url Canonization ------------------------------------------------------------------ |
| 466 | |
| 467 | function fs_download_image( $from, $to ) { |
| 468 | $ch = curl_init( $from ); |
| 469 | $fp = fopen( fs_normalize_path( $to ), 'wb' ); |
| 470 | curl_setopt( $ch, CURLOPT_FILE, $fp ); |
| 471 | curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false ); |
| 472 | curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); |
| 473 | curl_setopt( $ch, CURLOPT_HEADER, 0 ); |
| 474 | curl_exec( $ch ); |
| 475 | curl_close( $ch ); |
| 476 | fclose( $fp ); |
| 477 | } |
| 478 | |
| 479 | /* General Utilities |
| 480 | --------------------------------------------------------------------------------------------*/ |
| 481 | |
| 482 | /** |
| 483 | * Sorts an array by the value of the priority key. |
| 484 | * |
| 485 | * @author Daniel Iser (@danieliser) |
| 486 | * @since 1.1.7 |
| 487 | * |
| 488 | * @param $a |
| 489 | * @param $b |
| 490 | * |
| 491 | * @return int |
| 492 | */ |
| 493 | function fs_sort_by_priority( $a, $b ) { |
| 494 | |
| 495 | // If b has a priority and a does not, b wins. |
| 496 | if ( ! isset( $a['priority'] ) && isset( $b['priority'] ) ) { |
| 497 | return 1; |
| 498 | } // If b has a priority and a does not, b wins. |
| 499 | elseif ( isset( $a['priority'] ) && ! isset( $b['priority'] ) ) { |
| 500 | return - 1; |
| 501 | } // If neither has a priority or both priorities are equal its a tie. |
| 502 | elseif ( ( ! isset( $a['priority'] ) && ! isset( $b['priority'] ) ) || $a['priority'] === $b['priority'] ) { |
| 503 | return 0; |
| 504 | } |
| 505 | |
| 506 | // If both have priority return the winner. |
| 507 | return ( $a['priority'] < $b['priority'] ) ? - 1 : 1; |
| 508 | } |
| 509 | |
| 510 | #-------------------------------------------------------------------------------- |
| 511 | #region Localization |
| 512 | #-------------------------------------------------------------------------------- |
| 513 | |
| 514 | if ( ! function_exists( 'fs_text' ) ) { |
| 515 | /** |
| 516 | * Retrieve a translated text by key. |
| 517 | * |
| 518 | * @author Vova Feldman (@svovaf) |
| 519 | * @since 1.2.1.7 |
| 520 | * |
| 521 | * @param string $key |
| 522 | * @param string $slug |
| 523 | * |
| 524 | * @return string |
| 525 | * |
| 526 | * @global $fs_text, $fs_text_overrides |
| 527 | */ |
| 528 | function fs_text( $key, $slug = 'freemius' ) { |
| 529 | return __fs( $key, $slug ); |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Output a translated text by key. |
| 534 | * |
| 535 | * @author Vova Feldman (@svovaf) |
| 536 | * @since 1.2.1.7 |
| 537 | * |
| 538 | * @param string $key |
| 539 | * @param string $slug |
| 540 | */ |
| 541 | function fs_echo( $key, $slug = 'freemius' ) { |
| 542 | echo fs_text( $key, $slug ); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * @author Vova Feldman |
| 548 | * @since 1.2.1.6 |
| 549 | * |
| 550 | * @param string $key |
| 551 | * @param string $slug |
| 552 | * |
| 553 | * @return string |
| 554 | */ |
| 555 | function fs_esc_attr( $key, $slug ) { |
| 556 | return esc_attr( fs_text( $key, $slug ) ); |
| 557 | } |
| 558 | |
| 559 | /** |
| 560 | * @author Vova Feldman |
| 561 | * @since 1.2.1.6 |
| 562 | * |
| 563 | * @param string $key |
| 564 | * @param string $slug |
| 565 | */ |
| 566 | function fs_esc_attr_echo( $key, $slug ) { |
| 567 | echo esc_attr( fs_text( $key, $slug ) ); |
| 568 | } |
| 569 | |
| 570 | /** |
| 571 | * @author Vova Feldman |
| 572 | * @since 1.2.1.6 |
| 573 | * |
| 574 | * @param string $key |
| 575 | * @param string $slug |
| 576 | * |
| 577 | * @return string |
| 578 | */ |
| 579 | function fs_esc_js( $key, $slug ) { |
| 580 | return esc_js( fs_text( $key, $slug ) ); |
| 581 | } |
| 582 | |
| 583 | /** |
| 584 | * @author Vova Feldman |
| 585 | * @since 1.2.1.6 |
| 586 | * |
| 587 | * @param string $key |
| 588 | * @param string $slug |
| 589 | */ |
| 590 | function fs_esc_js_echo( $key, $slug ) { |
| 591 | echo esc_js( fs_text( $key, $slug ) ); |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * @author Vova Feldman |
| 596 | * @since 1.2.1.6 |
| 597 | * |
| 598 | * @param string $key |
| 599 | * @param string $slug |
| 600 | */ |
| 601 | function fs_json_encode_echo( $key, $slug ) { |
| 602 | echo json_encode( fs_text( $key, $slug ) ); |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * @author Vova Feldman |
| 607 | * @since 1.2.1.6 |
| 608 | * |
| 609 | * @param string $key |
| 610 | * @param string $slug |
| 611 | * |
| 612 | * @return string |
| 613 | */ |
| 614 | function fs_esc_html( $key, $slug ) { |
| 615 | return esc_html( fs_text( $key, $slug ) ); |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * @author Vova Feldman |
| 620 | * @since 1.2.1.6 |
| 621 | * |
| 622 | * @param string $key |
| 623 | * @param string $slug |
| 624 | */ |
| 625 | function fs_esc_html_echo( $key, $slug ) { |
| 626 | echo esc_html( fs_text( $key, $slug ) ); |
| 627 | } |
| 628 | |
| 629 | #endregion |
| 630 |