| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template used to display a simple donation button/link. |
| 4 |
* |
| 5 |
* Override this template by copying it to yourtheme/charitable/shortcodes/donate-button.php |
| 6 |
* |
| 7 |
* @author David Bisset |
| 8 |
* @package Charitable/Templates/Shortcodes |
| 9 |
* @since 1.8.2 |
| 10 |
* @version 1.8.8.6 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
$charitable_target_for_link = $view_args['new_tab'] ? ' target="_blank"' : ''; |
| 19 |
$charitable_target_for_button = $view_args['new_tab'] ? ' onclick="window.open(\'' . esc_url( $view_args['url'] ) . '\')" ' : ' onclick="location.href=\'' . esc_url( $view_args['url'] ) . '\'" '; |
| 20 |
|
| 21 |
// if the type is a button, use a button element, otherwise use a link. |
| 22 |
if ( 'link' === $view_args['type'] ) : |
| 23 |
|
| 24 |
// filter esc_attr but prevent quotes from being encoded. |
| 25 |
$charitable_target_for_link = str_replace( '"', '"', esc_attr( $charitable_target_for_link ) ); |
| 26 |
$charitable_target_for_button = str_replace( '"', '"', esc_attr( $charitable_target_for_button ) ); |
| 27 |
?> |
| 28 |
|
| 29 |
<a <?php echo $charitable_target_for_link; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> href="<?php echo esc_url( $view_args['url'] ); ?>" class="<?php echo esc_attr( $view_args['css'] ); ?>"><?php echo esc_html( $view_args['label'] ); ?></a> |
| 30 |
|
| 31 |
<?php else : ?> |
| 32 |
|
| 33 |
<input <?php echo $charitable_target_for_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> id="charitable-donate-button-<?php echo intval( $view_args['campaign'] ); ?>" class="<?php echo esc_attr( $view_args['css'] ); ?>" type="button" value="<?php echo esc_html( $view_args['label'] ); ?>" /> |
| 34 |
|
| 35 |
<?php endif; ?> |
| 36 |
|