AboutUs.class.php
3 years ago
BackwardsCompatibility.class.php
4 years ago
Blocks.class.php
4 years ago
CustomPostTypes.class.php
1 year ago
Dashboard.class.php
3 years ago
DeactivationSurvey.class.php
4 years ago
Helper.class.php
4 years ago
InstallationWalkthrough.class.php
4 years ago
Permissions.class.php
4 years ago
ReviewAsk.class.php
4 years ago
Settings.class.php
1 year ago
Widgets.class.php
4 years ago
WooCommerceIntegration.class.php
4 years ago
template-functions.php
1 year ago
Helper.class.php
94 lines
| 1 | <?php |
| 2 | if ( !defined( 'ABSPATH' ) ) exit; |
| 3 | |
| 4 | if ( !class_exists( 'ewdusHelper' ) ) { |
| 5 | /** |
| 6 | * Class to to provide helper functions |
| 7 | * |
| 8 | * @since 2.0.9 |
| 9 | */ |
| 10 | class ewdusHelper { |
| 11 | |
| 12 | // Hold the class instance. |
| 13 | private static $instance = null; |
| 14 | |
| 15 | /** |
| 16 | * The constructor is private |
| 17 | * to prevent initiation with outer code. |
| 18 | * |
| 19 | **/ |
| 20 | private function __construct() {} |
| 21 | |
| 22 | /** |
| 23 | * The object is created from within the class itself |
| 24 | * only if the class has no instance. |
| 25 | */ |
| 26 | public static function getInstance() { |
| 27 | |
| 28 | if ( self::$instance == null ) { |
| 29 | |
| 30 | self::$instance = new ewdusHelper(); |
| 31 | } |
| 32 | |
| 33 | return self::$instance; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Handle ajax requests in admin area for logged out users |
| 38 | * @since 2.0.9 |
| 39 | */ |
| 40 | public static function admin_nopriv_ajax() { |
| 41 | |
| 42 | wp_send_json_error( |
| 43 | array( |
| 44 | 'error' => 'loggedout', |
| 45 | 'msg' => sprintf( __( 'You have been logged out. Please %slogin again%s.', 'ultimate-slider' ), '<a href="' . wp_login_url( admin_url( 'admin.php?page=ewd-us-dashboard' ) ) . '">', '</a>' ), |
| 46 | ) |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Handle ajax requests where an invalid nonce is passed with the request |
| 52 | * @since 2.0.9 |
| 53 | */ |
| 54 | public static function bad_nonce_ajax() { |
| 55 | |
| 56 | wp_send_json_error( |
| 57 | array( |
| 58 | 'error' => 'badnonce', |
| 59 | 'msg' => __( 'The request has been rejected because it does not appear to have come from this site.', 'ultimate-slider' ), |
| 60 | ) |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Escapes PHP data being passed to JS, recursively |
| 66 | * @since 2.1.0 |
| 67 | */ |
| 68 | public static function escape_js_recursive( $values ) { |
| 69 | |
| 70 | $return_values = array(); |
| 71 | |
| 72 | foreach ( (array) $values as $key => $value ) { |
| 73 | |
| 74 | if ( is_array( $value ) ) { |
| 75 | |
| 76 | $value = ewdusHelper::escape_js_recursive( $value ); |
| 77 | } |
| 78 | elseif ( ! is_scalar( $value ) ) { |
| 79 | |
| 80 | continue; |
| 81 | } |
| 82 | else { |
| 83 | |
| 84 | $value = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
| 85 | } |
| 86 | |
| 87 | $return_values[ $key ] = $value; |
| 88 | } |
| 89 | |
| 90 | return $return_values; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | } |