PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.7.0
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.7.0
1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 1.8.0 All 210 releases
charitable / includes / addons / charitable-recipients / class-charitable-recipient-types.php

class-charitable-recipient-types.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.7.0, at includes/addons/charitable-recipients/class-charitable-recipient-types.php

94 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Singleton class that stores registered recipient types.
4 *
5 * @package Charitable/Classes/Charitable_Recipient_Types
6 * @version 1.0.0
7 * @author David Bisset
8 * @copyright Copyright (c) 2022, WP Charitable LLC
9 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Recipient_Types' ) ) :
18
19 /**
20 * Charitable_Recipient_Types
21 *
22 * @since 1.0.0
23 */
24 class Charitable_Recipient_Types {
25
26 /**
27 * @var Charitable_Recipient_Types
28 */
29 private static $instance = null;
30
31 /**
32 * @var array
33 */
34 private $types = array();
35
36 /**
37 * Create class object.
38 *
39 * @since 1.0.0
40 */
41 private function __construct() {}
42
43 /**
44 * Returns the single instance of this class.
45 *
46 * @since 1.0.0
47 *
48 * @return Charitable_Recipient_Types
49 */
50 public static function get_instance() {
51 if ( is_null( self::$instance ) ) {
52 self::$instance = new self();
53 }
54
55 return self::$instance;
56 }
57
58 /**
59 * Registers a new recipient type.
60 *
61 * @since 1.0.0
62 *
63 * @return Charitable_Recipient_Types
64 */
65 public function register( $recipient_type, $args = array() ) {
66 $defaults = array(
67 'label' => '',
68 'description' => '',
69 'admin_label' => '',
70 'admin_description' => '',
71 'searchable' => false,
72 'search_placeholder' => '',
73 'options' => array(),
74 );
75
76 $args = wp_parse_args( $args, $defaults );
77
78 $this->types[ $recipient_type ] = $args;
79 }
80
81 /**
82 * Returns all registered recipient types.
83 *
84 * @since 1.0.0
85 *
86 * @return array
87 */
88 public function get_types() {
89 return $this->types;
90 }
91 }
92
93 endif;
94