PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
charitable / templates / shortcodes / donate-button.php

donate-button.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at templates/shortcodes/donate-button.php

44 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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.13
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /*
19 * The destination URL is carried in a data attribute and read back by the click
20 * handler rather than being interpolated into the inline JavaScript.
21 *
22 * esc_url() is a URL escaper, not a JavaScript string escaper. It encodes a literal
23 * apostrophe as `&#039;` and leaves named entities such as `&apos;` intact -- correct
24 * inside href="", but both are decoded back into a real apostrophe by the HTML parser
25 * when it reads an attribute value, which would close a single-quoted JS string and
26 * let the remainder of the URL run as script. Keeping the handler free of any
27 * user-controlled data removes that context altogether.
28 */
29 $charitable_button_onclick = $view_args['new_tab']
30 ? "window.open(this.getAttribute('data-charitable-url'));"
31 : "location.href=this.getAttribute('data-charitable-url');";
32
33 // if the type is a button, use a button element, otherwise use a link.
34 if ( 'link' === $view_args['type'] ) :
35 ?>
36
37 <a<?php echo $view_args['new_tab'] ? ' target="_blank"' : ''; ?> href="<?php echo esc_url( $view_args['url'] ); ?>" class="<?php echo esc_attr( $view_args['css'] ); ?>"><?php echo esc_html( $view_args['label'] ); ?></a>
38
39 <?php else : ?>
40
41 <input onclick="<?php echo esc_attr( $charitable_button_onclick ); ?>" data-charitable-url="<?php echo esc_url( $view_args['url'] ); ?>" id="charitable-donate-button-<?php echo intval( $view_args['campaign'] ); ?>" class="<?php echo esc_attr( $view_args['css'] ); ?>" type="button" value="<?php echo esc_attr( $view_args['label'] ); ?>" />
42
43 <?php endif; ?>
44