| 1 |
<?php |
| 2 |
/** |
| 3 |
* Charitable widgets class. |
| 4 |
* |
| 5 |
* Registers custom widgets for Charitable. |
| 6 |
* |
| 7 |
* @version 1.0.0 |
| 8 |
* @package Charitable/Classes/Charitable_Widgets |
| 9 |
* @author David Bisset |
| 10 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 11 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 12 |
*/ |
| 13 |
|
| 14 |
// Exit if accessed directly. |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
if ( ! class_exists( 'Charitable_Widgets' ) ) : |
| 20 |
|
| 21 |
/** |
| 22 |
* Charitable_Widgets |
| 23 |
* |
| 24 |
* @final |
| 25 |
* @since 1.0.0 |
| 26 |
*/ |
| 27 |
final class Charitable_Widgets { |
| 28 |
|
| 29 |
/** |
| 30 |
* The single instance of this class. |
| 31 |
* |
| 32 |
* @var Charitable_Widgets|null |
| 33 |
*/ |
| 34 |
private static $instance = null; |
| 35 |
|
| 36 |
/** |
| 37 |
* Returns and/or create the single instance of this class. |
| 38 |
* |
| 39 |
* @since 1.2.0 |
| 40 |
* |
| 41 |
* @return Charitable_Widgets |
| 42 |
*/ |
| 43 |
public static function get_instance() { |
| 44 |
if ( is_null( self::$instance ) ) { |
| 45 |
self::$instance = new self(); |
| 46 |
} |
| 47 |
|
| 48 |
return self::$instance; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Set up the class. This can only be loaded with the get_instance() method. |
| 53 |
* |
| 54 |
* @since 1.0.0 |
| 55 |
*/ |
| 56 |
private function __construct() { |
| 57 |
add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Register widgets. |
| 62 |
* |
| 63 |
* @see widgets_init hook |
| 64 |
* |
| 65 |
* @since 1.0.0 |
| 66 |
* |
| 67 |
* @return void |
| 68 |
*/ |
| 69 |
public function register_widgets() { |
| 70 |
register_widget( 'Charitable_Campaign_Terms_Widget' ); |
| 71 |
register_widget( 'Charitable_Campaigns_Widget' ); |
| 72 |
register_widget( 'Charitable_Donors_Widget' ); |
| 73 |
register_widget( 'Charitable_Donate_Widget' ); |
| 74 |
register_widget( 'Charitable_Donation_Stats_Widget' ); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
endif; |
| 79 |
|