| 1 |
<?php |
| 2 |
if ( !defined( 'ABSPATH' ) ) exit; |
| 3 |
|
| 4 |
if ( !class_exists( 'ewdulbHelper' ) ) { |
| 5 |
/** |
| 6 |
* Class to to provide helper functions |
| 7 |
* |
| 8 |
* @since 1.0.5 |
| 9 |
*/ |
| 10 |
class ewdulbHelper { |
| 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 ewdulbHelper(); |
| 31 |
} |
| 32 |
|
| 33 |
return self::$instance; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Handle ajax requests in admin area for logged out users |
| 38 |
* @since 1.0.5 |
| 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-lightbox' ), '<a href="' . wp_login_url( admin_url( 'admin.php?page=ewd-ulb-dashboard' ) ) . '">', '</a>' ), |
| 46 |
) |
| 47 |
); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Handle ajax requests where an invalid nonce is passed with the request |
| 52 |
* @since 1.0.5 |
| 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-lightbox' ), |
| 60 |
) |
| 61 |
); |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
} |