| @@ -117,9 +117,9 @@ | ||
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | if ( ! function_exists( 'fs_enqueue_local_script' ) ) { |
| 121 | - function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) { | |
| 121 | + function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = true ) { | |
| 122 | 122 | wp_enqueue_script( $handle, fs_asset_url( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ), $deps, $ver, $in_footer ); |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| @@ -587,8 +587,35 @@ | ||
| 587 | 587 | return add_query_arg( $name, wp_create_nonce( $action ), $actionurl ); |
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | + if ( ! function_exists( 'fs_parse_url_params' ) ) { | |
| 592 | + /** | |
| 593 | + * Returns the query parameters of the given URL if there are any. | |
| 594 | + * | |
| 595 | + * @param string $url | |
| 596 | + * @param bool $html_entity_decode | |
| 597 | + * | |
| 598 | + * @return array<string, string> Key value pair where key represents the parameter name and value represents the parameter value. | |
| 599 | + */ | |
| 600 | + function fs_parse_url_params( $url, $html_entity_decode = false ) { | |
| 601 | + $query_str = parse_url( $url, PHP_URL_QUERY ); | |
| 602 | + $url_params = array(); | |
| 603 | + | |
| 604 | + if ( empty( $query_str ) ) { | |
| 605 | + return $url_params; | |
| 606 | + } | |
| 607 | + | |
| 608 | + if ( $html_entity_decode ) { | |
| 609 | + $query_str = html_entity_decode( $query_str ); | |
| 610 | + } | |
| 611 | + | |
| 612 | + parse_str( $query_str, $url_params ); | |
| 613 | + | |
| 614 | + return $url_params; | |
| 615 | + } | |
| 616 | + } | |
| 617 | + | |
| 591 | 618 | if ( ! function_exists( 'fs_starts_with' ) ) { |
| 592 | 619 | /** |
| 593 | 620 | * Check if string starts with. |
| 594 | 621 | * |
| @@ -1457,5 +1484,22 @@ | ||
| 1457 | 1484 | array( "fs_{$tag}_{$module_unique_affix}" ), |
| 1458 | 1485 | array_slice( $args, 2 ) ) |
| 1459 | 1486 | ); |
| 1460 | 1487 | } |
| 1461 | - } | |
| 1488 | + } | |
| 1489 | + | |
| 1490 | + if ( ! function_exists( 'fs_get_optional_constant' ) ) { | |
| 1491 | + /** | |
| 1492 | + * Gets the value of an optional constant. If the constant is not defined, the default value will be returned. | |
| 1493 | + * | |
| 1494 | + * @author Swashata Ghosh (@swashata) | |
| 1495 | + * @since 2.5.12.5 | |
| 1496 | + * | |
| 1497 | + * @param string $constant_name | |
| 1498 | + * @param mixed $default_value | |
| 1499 | + * | |
| 1500 | + * @return mixed | |
| 1501 | + */ | |
| 1502 | + function fs_get_optional_constant( $constant_name, $default_value = null ) { | |
| 1503 | + return defined( $constant_name ) ? constant( $constant_name ) : $default_value; | |
| 1504 | + } | |
| 1505 | + } | |