PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.0.2
GiveWP – Donation Plugin and Fundraising Platform v2.0.2
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / emails / template.php
give / includes / emails Last commit date
actions.php 8 years ago class-give-email-tags.php 8 years ago class-give-emails.php 8 years ago functions.php 8 years ago template.php 8 years ago
template.php
225 lines
1 <?php
2 /**
3 * Email Template
4 *
5 * @package Give
6 * @subpackage Emails
7 * @copyright Copyright (c) 2016, WordImpress
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Gets all the email templates that have been registered. The list is extendable
19 * and more templates can be added.
20 *
21 * This is simply a wrapper to Give_Email_Templates->get_templates()
22 *
23 * @since 1.0
24 * @return array $templates All the registered email templates.
25 */
26 function give_get_email_templates() {
27 $templates = new Give_Emails;
28
29 return $templates->get_templates();
30 }
31
32 /**
33 * Email Template Tags.
34 * @todo Modify this function to remove payment id dependency.
35 *
36 * @since 1.0
37 *
38 * @param string $message Message with the template tags.
39 * @param array $payment_data Payment Data.
40 * @param int $payment_id Payment ID.
41 * @param bool $admin_notice Whether or not this is a notification email.
42 *
43 * @return string $message Fully formatted message
44 */
45 function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
46 return give_do_email_tags( $message, $payment_id );
47 }
48
49 /**
50 * Email Preview Template Tags.
51 *
52 * Provides sample content for the preview email functionality within settings > email.
53 *
54 * @since 1.0
55 *
56 * @param string $message Email message with template tags
57 *
58 * @return string $message Fully formatted message
59 */
60 function give_email_preview_template_tags( $message ) {
61
62 $price = give_currency_filter( give_format_amount( 10.50, array( 'sanitize' => false ) ) );
63
64 $gateway = 'PayPal';
65
66 $receipt_id = strtolower( md5( uniqid() ) );
67
68 $payment_id = rand( 1, 100 );
69 $receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id ), give_get_history_page_uri() ) );
70
71 $receipt_link = sprintf(
72 '<a href="%1$s">%2$s</a>',
73 $receipt_link_url,
74 esc_html__( 'View the receipt in your browser &raquo;', 'give' )
75 );
76
77 // Set user.
78 $user = wp_get_current_user();
79
80 $message = str_replace( '{name}', $user->display_name, $message );
81 $message = str_replace( '{fullname}', $user->display_name, $message );
82 $message = str_replace( '{username}', $user->user_login, $message );
83 $message = str_replace( '{user_email}', $user->user_email, $message );
84 $message = str_replace( '{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message );
85 $message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message );
86 $message = str_replace( '{amount}', $price, $message );
87 $message = str_replace( '{price}', $price, $message );
88 $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
89 $message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message );
90 $message = str_replace( '{receipt_id}', $receipt_id, $message );
91 $message = str_replace( '{payment_method}', $gateway, $message );
92 $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
93 $message = str_replace( '{payment_id}', $payment_id, $message );
94 $message = str_replace( '{receipt_link}', $receipt_link, $message );
95 $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message );
96 $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
97
98 return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
99 }
100
101
102
103 /**
104 * Output Email Template Preview Buttons.
105 *
106 * @access private
107 * @since 1.0
108 * @since 1.8 Field arguments param added.
109 *
110 * @param array $field Field arguments.
111 *
112 * @return array
113 */
114 function give_email_preview_buttons_callback( $field ) {
115 $field_id = str_replace( '_preview_buttons', '', $field['id'] );
116
117 ob_start();
118
119 echo sprintf(
120 '<a href="%1$s" class="button-secondary" target="_blank">%2$s</a>',
121 wp_nonce_url(
122 add_query_arg(
123 array( 'give_action' => 'preview_email', 'email_type' => $field_id ),
124 home_url()
125 ), 'give-preview-email'
126 ),
127 $field['name']
128 );
129
130 echo sprintf(
131 ' <a href="%1$s" aria-label="%2$s" class="button-secondary">%3$s</a>',
132 wp_nonce_url(
133 add_query_arg( array(
134 'give_action' => 'send_preview_email',
135 'email_type' => $field_id,
136 'give-message' => 'sent-test-email',
137 ) ), 'give-send-preview-email' ),
138 esc_attr__( 'Send Test Email.', 'give' ),
139 esc_html__( 'Send Test Email', 'give' )
140 );
141
142 echo ob_get_clean();
143 }
144
145
146 /**
147 * Give Preview Email Header.
148 *
149 * Displays a header bar with the ability to change donations to preview actual data within the preview. Will not display if
150 *
151 * @since 1.6
152 *
153 */
154 function give_get_preview_email_header() {
155
156 //Payment receipt switcher
157 $payment_count = give_count_payments()->publish;
158 $payment_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' );
159
160 if ( $payment_count <= 0 ) {
161 return false;
162 }
163
164 //Get payments.
165 $payments = new Give_Payments_Query( array(
166 'number' => 100,
167 ) );
168 $payments = $payments->get_payments();
169 $options = array();
170
171 // Default option.
172 $options[0] = esc_html__( 'No donations found.', 'give' );
173
174 //Provide nice human readable options.
175 if ( $payments ) {
176 $options[0] = esc_html__( '- Select a donation -', 'give' );
177 foreach ( $payments as $payment ) {
178
179 $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
180
181 }
182 }
183
184 //Start constructing HTML output.
185 $transaction_header = '<div style="margin:0;padding:10px 0;width:100%;background-color:#FFF;border-bottom:1px solid #eee; text-align:center;">';
186
187 // Remove payment id query param if set from request url.
188 $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] );
189 $query = $request_url_data['query'];
190 $query = remove_query_arg( array( 'preview_id' ), $query );
191
192 $request_url = home_url( '/?' . str_replace( '', '', $query ) );
193
194 $transaction_header .= '<script>
195 function change_preview(){
196 var transactions = document.getElementById("give_preview_email_payment_id");
197 var selected_trans = transactions.options[transactions.selectedIndex];
198 if (selected_trans){
199 var url_string = "' . $request_url . '&preview_id=" + selected_trans.value;
200 window.location = url_string;
201 }
202 }
203 </script>';
204
205 $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>';
206
207 //The select field with 100 latest transactions
208 $transaction_header .= Give()->html->select( array(
209 'name' => 'preview_email_payment_id',
210 'selected' => $payment_id,
211 'id' => 'give_preview_email_payment_id',
212 'class' => 'give-preview-email-payment-id',
213 'options' => $options,
214 'chosen' => false,
215 'select_atts' => 'onchange="change_preview()"',
216 'show_option_all' => false,
217 'show_option_none' => false,
218 ) );
219
220 //Closing tag
221 $transaction_header .= '</div>';
222
223 return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
224
225 }