PluginProbe
Order Tracking – WordPress Status Tracking Plugin / 3.2.2
Order Tracking – WordPress Status Tracking Plugin v3.2.2
3.5.4 3.5.3 3.5.2 3.5.1 3.5.0 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.3.0 3.3.1 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 All 235 releases
order-tracking / includes / Helper.class.php

Helper.class.php in Order Tracking – WordPress Status Tracking Plugin 3.2.2, at includes/Helper.class.php

94 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( !defined( 'ABSPATH' ) ) exit;
3
4 if ( !class_exists( 'ewdotpHelper' ) ) {
5 /**
6 * Class to to provide helper functions
7 *
8 * @since 3.0.17
9 */
10 class ewdotpHelper {
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 ewdotpHelper();
31 }
32
33 return self::$instance;
34 }
35
36 /**
37 * Handle ajax requests in admin area for logged out users
38 * @since 3.0.17
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.', 'order-tracking' ), '<a href="' . wp_login_url( admin_url( 'admin.php?page=ewd-otp-dashboard' ) ) . '">', '</a>' ),
46 )
47 );
48 }
49
50 /**
51 * Handle ajax requests where an invalid nonce is passed with the request
52 * @since 3.0.17
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.', 'order-tracking' ),
60 )
61 );
62 }
63
64 /**
65 * Escapes PHP data being passed to JS, recursively
66 * @since 3.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 = ewdotpHelper::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 }