| 1 |
<?php |
| 2 |
/** |
| 3 |
* Contains the class that is used for dedicated troubleshooting/support. |
| 4 |
* |
| 5 |
* @package Charitable/Classes/Charitable_Admin_Support |
| 6 |
* @author David Bisset |
| 7 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.7.0.3 |
| 10 |
* @version 1.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
if ( ! class_exists( 'Charitable_Admin_Support' ) ) : |
| 19 |
|
| 20 |
/** |
| 21 |
* Charitable_Admin_Support |
| 22 |
* |
| 23 |
* @since 1.4.6 |
| 24 |
*/ |
| 25 |
class Charitable_Admin_Support { |
| 26 |
|
| 27 |
/** |
| 28 |
* The single instance of this class. |
| 29 |
* |
| 30 |
* @var Charitable_Admin_Support|null |
| 31 |
*/ |
| 32 |
private static $instance = null; |
| 33 |
|
| 34 |
/** |
| 35 |
* Create class object. A private constructor, so this is used in a singleton context. |
| 36 |
* |
| 37 |
* @since 1.4.6 |
| 38 |
* @since 1.5.4 Access changed to public. |
| 39 |
*/ |
| 40 |
public function __construct() { |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Checks and sees if there is anything being manually passed into the query vars. |
| 45 |
* |
| 46 |
* @since 1.7.0.3 |
| 47 |
* @version 1.8.9.1 |
| 48 |
*/ |
| 49 |
public static function maybe_do_charitable_support_query() { |
| 50 |
// phpcs:disable WordPress.Security.NonceVerification.Recommended |
| 51 |
if ( ! is_admin() || ! isset( $_GET['charitable-support'] ) ) { |
| 52 |
return; |
| 53 |
} |
| 54 |
|
| 55 |
$support_action = sanitize_text_field( wp_unslash( $_GET['charitable-support'] ) ); |
| 56 |
// phpcs:enable WordPress.Security.NonceVerification.Recommended |
| 57 |
|
| 58 |
switch ( $support_action ) { |
| 59 |
case 'clear-notifications': |
| 60 |
delete_option( 'charitable_notifications' ); // delete the entire option in the database. |
| 61 |
if ( charitable_is_debug() ) { |
| 62 |
error_log( 'charitable-support: clear-notification' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
| 63 |
} |
| 64 |
break; |
| 65 |
|
| 66 |
default: |
| 67 |
// code... |
| 68 |
break; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Returns and/or create the single instance of this class. |
| 74 |
* |
| 75 |
* @since 1.7.0.3 |
| 76 |
* |
| 77 |
* @return Charitable_Admin_Support |
| 78 |
*/ |
| 79 |
public static function get_instance() { |
| 80 |
if ( is_null( self::$instance ) ) { |
| 81 |
self::$instance = new self(); |
| 82 |
} |
| 83 |
|
| 84 |
return self::$instance; |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
endif; |
| 89 |
|