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