| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin actions interface. |
| 4 |
* |
| 5 |
* @package Charitable/Interfaces/Charitable_Admin_Actions_Interface |
| 6 |
* @version 1.5.0 |
| 7 |
* @author Eric Daams |
| 8 |
* @copyright Copyright (c) 2022, Studio 164a |
| 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 ( ! interface_exists( 'Charitable_Admin_Actions_Interface' ) ) : |
| 18 |
|
| 19 |
/** |
| 20 |
* Charitable_Admin_Actions_Interface |
| 21 |
* |
| 22 |
* @since 1.5.0 |
| 23 |
*/ |
| 24 |
interface Charitable_Admin_Actions_Interface { |
| 25 |
|
| 26 |
/** |
| 27 |
* Return the action type. |
| 28 |
* |
| 29 |
* This will be used to construct the hook that runs the actual actions, and is |
| 30 |
* required to differentiate between actions with the same key added by different |
| 31 |
* implementation classes. |
| 32 |
* |
| 33 |
* @since 1.5.0 |
| 34 |
* |
| 35 |
* @return string |
| 36 |
*/ |
| 37 |
public function get_type(); |
| 38 |
|
| 39 |
/** |
| 40 |
* Register a new action. |
| 41 |
* |
| 42 |
* @since 1.5.0 |
| 43 |
* |
| 44 |
* @param string $action The action key. |
| 45 |
* @param array $args { |
| 46 |
* Array of arguments for the action. |
| 47 |
* |
| 48 |
* @type string $label The label to display in the admin. |
| 49 |
* @type callable $callback A callback function to run when the action is processed. |
| 50 |
* @type string $button_text Optional. The text to show in the button when this action is selected. |
| 51 |
* @type callable $active_callback Optional. Any passed callback will receive a donation ID as its only parameter |
| 52 |
* and should return a boolean result: TRUE if the action should be shown for |
| 53 |
* the donation; FALSE if it should not. |
| 54 |
* } |
| 55 |
* @param string $group Optional. If set, action will be added to a group of other related actions, which will be |
| 56 |
* shown as an optgroup. |
| 57 |
* @return boolean True if the action was registerd. False if not. |
| 58 |
*/ |
| 59 |
public function register( $action, $args, $group = 'default' ); |
| 60 |
|
| 61 |
/** |
| 62 |
* Do a particular action. |
| 63 |
* |
| 64 |
* @since 1.5.0 |
| 65 |
* |
| 66 |
* @param string $action The action to do. |
| 67 |
* @param int $object_id The object ID. This could be the ID of the donation, campaign, donor, etc. |
| 68 |
* @param array $args Optional. Mixed set of arguments. |
| 69 |
* @return mixed|WP_Error WP_Error in case of error. Mixed results if the action was performed. |
| 70 |
*/ |
| 71 |
public function do_action( $action, $object_id, $args = array() ); |
| 72 |
} |
| 73 |
|
| 74 |
endif; |
| 75 |
|