| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Renders the donation details meta box for the Donation post type. |
| 10 |
* |
| 11 |
* @author David Bisset |
| 12 |
* @package Charitable/Admin View/Donations Page |
| 13 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 14 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 15 |
* @since 1.5.0 |
| 16 |
* @version 1.6.0 |
| 17 |
* @version 1.8.8.6 |
| 18 |
*/ |
| 19 |
|
| 20 |
global $post; |
| 21 |
|
| 22 |
$charitable_helper = array_key_exists( 'actions', $view_args ) ? $view_args['actions'] : charitable_get_donation_actions(); |
| 23 |
$charitable_actions = $charitable_helper->get_available_actions( $post->ID ); |
| 24 |
$charitable_groups = $charitable_helper->get_available_groups( $post->ID ); |
| 25 |
$type = esc_attr( $charitable_helper->get_type() ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 26 |
|
| 27 |
if ( empty( $charitable_actions ) ) { |
| 28 |
return; |
| 29 |
} |
| 30 |
?> |
| 31 |
<div id="charitable-<?php echo esc_attr( $type ); ?>-actions-metabox-wrapper" class="charitable-metabox charitable-actions-form-wrapper"> |
| 32 |
|
| 33 |
<div id="charitable-<?php echo esc_attr( $type ); ?>-actions-form" class="charitable-actions-form"> |
| 34 |
<?php |
| 35 |
/** |
| 36 |
* Do something at the top of the actions form. |
| 37 |
* |
| 38 |
* @since 1.6.0 |
| 39 |
* |
| 40 |
* @param int $post_id The current post ID. |
| 41 |
*/ |
| 42 |
do_action( 'charitable_' . $type . '_actions_start', $post->ID ); |
| 43 |
?> |
| 44 |
<select id="charitable_<?php echo esc_attr( $type ); ?>_actions" name="charitable_<?php echo esc_attr( $type ); ?>_action" class="charitable-action-select"> |
| 45 |
<option value=""><?php esc_html_e( 'Select an action', 'charitable' ); ?></option> |
| 46 |
<?php |
| 47 |
foreach ( $charitable_groups as $charitable_label => $charitable_group_actions ) : |
| 48 |
|
| 49 |
if ( ! empty( $charitable_label ) && 'default' != $charitable_label ) : // phpcs:ignore |
| 50 |
?> |
| 51 |
<optgroup label="<?php echo esc_attr( $charitable_label ); ?>"> |
| 52 |
<?php |
| 53 |
endif; |
| 54 |
foreach ( $charitable_group_actions as $action ) : // phpcs:ignore |
| 55 |
if ( array_key_exists( $action, $charitable_actions ) ) : |
| 56 |
?> |
| 57 |
<option value="<?php echo esc_attr( $action ); ?>" data-button-text="<?php echo esc_attr( $charitable_actions[ $action ]['button_text'] ); ?>"><?php echo esc_html( $charitable_actions[ $action ]['label'] ); ?></option> |
| 58 |
<?php |
| 59 |
endif; |
| 60 |
endforeach; |
| 61 |
if ( ! empty( $charitable_label ) ) : |
| 62 |
?> |
| 63 |
</optgroup> |
| 64 |
<?php |
| 65 |
endif; |
| 66 |
endforeach; |
| 67 |
?> |
| 68 |
</select> |
| 69 |
<?php |
| 70 |
foreach ( $charitable_groups as $charitable_group_actions ) : |
| 71 |
foreach ( $charitable_group_actions as $action ) : // phpcs:ignore |
| 72 |
$charitable_helper->add_action_fields( $post->ID, $action ); |
| 73 |
endforeach; |
| 74 |
endforeach; |
| 75 |
/** |
| 76 |
* Do something at the end of the actions form. |
| 77 |
* |
| 78 |
* @since 1.6.0 |
| 79 |
* |
| 80 |
* @param int $post_id The current post ID. |
| 81 |
*/ |
| 82 |
do_action( 'charitable_' . $type . '_actions_end', $post->ID ); |
| 83 |
?> |
| 84 |
</div><!-- #charitable-<?php echo esc_html( $type ); ?>-actions-form --> |
| 85 |
<div id="charitable-<?php echo esc_html( $type ); ?>-actions-submit" class="charitable-actions-submit"> |
| 86 |
<button type="submit" class="button-primary" title="<?php esc_attr_e( 'Submit', 'charitable' ); ?>"><?php esc_html_e( 'Submit', 'charitable' ); ?></button> |
| 87 |
<div class="clear"></div> |
| 88 |
</div><!-- #charitble-<?php echo esc_html( $type ); ?>-actions-submit --> |
| 89 |
</div><!-- #charitable-<?php echo esc_html( $type ); ?>-actions-metabox-wrapper --> |
| 90 |
|