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