| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Charitable Recipients Functions. |
| 5 |
* |
| 6 |
* @package Charitable/Functions/Recipients |
| 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 |
* @since 1.0.0 |
| 11 |
* @version 1.0.0 |
| 12 |
*/ |
| 13 |
|
| 14 |
// Exit if accessed directly. |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Registers a recipient type. |
| 21 |
* |
| 22 |
* @since 1.0.0 |
| 23 |
* |
| 24 |
* @param string $recipient_type The ID of the recipient type we're registering. |
| 25 |
* @param array $args Set of arguments defining that recipient type. |
| 26 |
* @return void |
| 27 |
*/ |
| 28 |
function charitable_register_recipient_type( $recipient_type, $args = array() ) { |
| 29 |
Charitable_Recipient_Types::get_instance()->register( $recipient_type, $args ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Returns the registered recipient types. |
| 34 |
* |
| 35 |
* @since 1.0.0 |
| 36 |
* |
| 37 |
* @return array |
| 38 |
*/ |
| 39 |
function charitable_get_recipient_types() { |
| 40 |
return Charitable_Recipient_Types::get_instance()->get_types(); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Returns a given recipient type, or false if the recipient type is not registered. |
| 45 |
* |
| 46 |
* @since 1.0.0 |
| 47 |
* |
| 48 |
* @param string $recipient_type The recipient type we want to retrieve. |
| 49 |
* @return array|false |
| 50 |
*/ |
| 51 |
function charitable_get_recipient_type( $recipient_type ) { |
| 52 |
$recipient_types = charitable_get_recipient_types(); |
| 53 |
|
| 54 |
if ( ! array_key_exists( $recipient_type, $recipient_types ) ) { |
| 55 |
return false; |
| 56 |
} |
| 57 |
|
| 58 |
return $recipient_types[ $recipient_type ]; |
| 59 |
} |
| 60 |
|