| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main class for setting up the Charitable Recipients Addon, which is programatically activated by child themes. |
| 4 |
* |
| 5 |
* @package Charitable/Classes/Charitable_Recipients |
| 6 |
* @author David Bisset |
| 7 |
* @copyright Copyright (c) 2022, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.0.0 |
| 10 |
* @version 1.0.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
if ( ! class_exists( 'Charitable_Recipients' ) ) : |
| 19 |
|
| 20 |
/** |
| 21 |
* Charitable_Recipients |
| 22 |
* |
| 23 |
* @since 1.0.0 |
| 24 |
*/ |
| 25 |
class Charitable_Recipients implements Charitable_Addon_Interface { |
| 26 |
|
| 27 |
/** |
| 28 |
* Responsible for creating class instances. |
| 29 |
* |
| 30 |
* @since 1.0.0 |
| 31 |
* |
| 32 |
* @return void |
| 33 |
*/ |
| 34 |
public static function load() { |
| 35 |
$object = new Charitable_Recipients(); |
| 36 |
|
| 37 |
do_action( 'charitable_recipients_addon_loaded', $object ); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Create class instance. |
| 42 |
* |
| 43 |
* @since 1.0.0 |
| 44 |
*/ |
| 45 |
private function __construct() { |
| 46 |
$this->load_dependencies(); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Include required files. |
| 51 |
* |
| 52 |
* @since 1.0.0 |
| 53 |
* |
| 54 |
* @return void |
| 55 |
*/ |
| 56 |
private function load_dependencies() { |
| 57 |
require_once( 'charitable-recipients-functions.php' ); |
| 58 |
require_once( 'class-charitable-recipient-types.php' ); |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Activate the addon. |
| 63 |
* |
| 64 |
* @since 1.0.0 |
| 65 |
* |
| 66 |
* @return boolean Whether the add-on was activated. |
| 67 |
*/ |
| 68 |
public static function activate() { |
| 69 |
if ( 'charitable_activate_addon' !== current_filter() ) { |
| 70 |
return false; |
| 71 |
} |
| 72 |
|
| 73 |
self::load(); |
| 74 |
|
| 75 |
return true; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
endif; |
| 80 |
|