PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 4.16.3
GiveWP – Donation Plugin and Fundraising Platform v4.16.3
4.16.3 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 / src / ThirdPartySupport / Elementor / Widgets / V1 / DonationReceiptWidget.php
give / src / ThirdPartySupport / Elementor / Widgets / V1 Last commit date
resources 10 months ago DonationHistoryWidget.php 10 months ago DonationReceiptWidget.php 10 months ago GiveDonorWallWidget.php 10 months ago GiveFormGridWidget.php 9 months ago GiveFormWidget.php 10 months ago GiveGoalWidget.php 10 months ago GiveLoginWidget.php 10 months ago GiveMultiFormGoalWidget.php 10 months ago GiveProfileEditorWidget.php 10 months ago GiveRegisterWidget.php 10 months ago GiveSubscriptionsWidget.php 10 months ago GiveTotalsWidget.php 10 months ago
DonationReceiptWidget.php
422 lines
1 <?php
2
3 namespace Give\ThirdPartySupport\Elementor\Widgets\V1;
4
5 use Elementor\Widget_Base;
6
7 /**
8 * Elementor Donation Receipt Widget.
9 *
10 * Elementor widget that inserts the GiveWP [give_receipt] shortcode to output a donor's full Donation Receipt table.
11 *
12 * @since 4.7.0 migrated from givewp-elementor-widgets
13 */
14
15 class DonationReceiptWidget extends Widget_Base
16 {
17 /**
18 * Get widget name.
19 *
20 * Retrieve Donation Receipt widget name.
21 *
22 * @since 4.7.0 migrated from givewp-elementor-widgets
23 * @access public
24 *
25 * @return string Widget name.
26 */
27 public function get_name()
28 {
29 return 'Donation Receipt';
30 }
31
32 /**
33 * Get widget title.
34 *
35 * Retrieve Donation Receipt widget title.
36 *
37 * @since 4.7.0 migrated from givewp-elementor-widgets
38 * @access public
39 *
40 * @return string Widget title.
41 */
42 public function get_title()
43 {
44 return __('Give Donation Receipt (Legacy)', 'give');
45 }
46
47 /**
48 * Get widget icon.
49 *
50 * Retrieve Donation Receipt widget icon.
51 *
52 * @since 4.7.0 migrated from givewp-elementor-widgets
53 * @access public
54 *
55 * @return string Widget icon.
56 */
57 public function get_icon()
58 {
59 return 'give-icon';
60 }
61
62 /**
63 * Get widget categories.
64 *
65 * Retrieve the list of categories the Donation Receipt widget belongs to.
66 *
67 * @since 4.7.0 migrated from givewp-elementor-widgets
68 * @access public
69 *
70 * @return array Widget categories.
71 */
72 public function get_categories()
73 {
74 return ['givewp-category-legacy'];
75 }
76
77 /**
78 * Widget inner wrapper.
79 *
80 * Use optimized DOM structure, without the inner wrapper.
81 *
82 * @since 4.7.0 migrated from givewp-elementor-widgets
83 * @access public
84 */
85 public function has_widget_inner_wrapper(): bool
86 {
87 return false;
88 }
89
90 /**
91 * Register Donation Receipt widget controls.
92 *
93 * Adds different input fields to allow the user to change and customize the widget settings.
94 *
95 * @since 4.7.0 migrated from givewp-elementor-widgets
96 * @access protected
97 */
98 protected function register_controls()
99 {
100 $this->start_controls_section(
101 'content_section',
102 [
103 'label' => __('GiveWP Donation Receipt Widget', 'give'),
104 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
105 ]
106 );
107
108 $this->add_control(
109 'error',
110 [
111 'label' => __('Error Message', 'give'),
112 'type' => \Elementor\Controls_Manager::TEXTAREA,
113 'description' => __('Custom text to show if there is an error showing the receipt table.', 'give'),
114 'default' => __('You are missing the donation id to view this donation receipt.', 'give'),
115 'placeholder' => __('You are missing the donation id to view this donation receipt.', 'give'),
116 ]
117 );
118
119 $this->add_control(
120 'success',
121 [
122 'label' => __('Success Message', 'give'),
123 'type' => \Elementor\Controls_Manager::TEXTAREA,
124 'description' => __('Custom text to show if the donation was successful.', 'give'),
125 'default' => __('Thank you for your donation.', 'give'),
126 'placeholder' => __('Thank you for your donation.', 'give'),
127 ]
128 );
129
130 $this->add_control(
131 'price',
132 [
133 'label' => __('Donation Total', 'give'),
134 'type' => \Elementor\Controls_Manager::SWITCHER,
135 'description' => __('Show or hide a row with the total donation amount.', 'give'),
136 'label_on' => __('Show', 'give'),
137 'label_off' => __('Hide', 'give'),
138 'default' => 'yes'
139 ]
140 );
141
142 $this->add_control(
143 'donor',
144 [
145 'label' => __('Donor', 'give'),
146 'type' => \Elementor\Controls_Manager::SWITCHER,
147 'description' => __('Show or hide a row with the donors full name.', 'give'),
148 'label_on' => __('Show', 'give'),
149 'label_off' => __('Hide', 'give'),
150 'default' => 'yes'
151 ]
152 );
153
154 $this->add_control(
155 'date',
156 [
157 'label' => __('Date', 'give'),
158 'type' => \Elementor\Controls_Manager::SWITCHER,
159 'description' => __('Show or hide a row with the date of the donation.', 'give'),
160 'label_on' => __('Show', 'give'),
161 'label_off' => __('Hide', 'give'),
162 'default' => 'yes'
163 ]
164 );
165
166 $this->add_control(
167 'method',
168 [
169 'label' => __('Payment Method', 'give'),
170 'type' => \Elementor\Controls_Manager::SWITCHER,
171 'description' => __('Show or hide a row with the name of the payment type (credit card, offline, etc).', 'give'),
172 'label_on' => __('Show', 'give'),
173 'label_off' => __('Hide', 'give'),
174 'default' => 'yes'
175 ]
176 );
177
178 $this->add_control(
179 'payment_id',
180 [
181 'label' => __('Payment ID', 'give'),
182 'type' => \Elementor\Controls_Manager::SWITCHER,
183 'description' => __('Show or hide a row with the ID of the donation.', 'give'),
184 'label_on' => __('Show', 'give'),
185 'label_off' => __('Hide', 'give'),
186 'default' => 'yes'
187 ]
188 );
189
190 $this->add_control(
191 'status',
192 [
193 'label' => __('Status', 'give'),
194 'type' => \Elementor\Controls_Manager::SWITCHER,
195 'description' => __('Show or hide a row with the status of the payment.', 'give'),
196 'label_on' => __('Show', 'give'),
197 'label_off' => __('Hide', 'give'),
198 'default' => 'no'
199 ]
200 );
201
202 $this->add_control(
203 'company',
204 [
205 'label' => __('Company Name', 'give'),
206 'type' => \Elementor\Controls_Manager::SWITCHER,
207 'description' => __('Show or hide a row with the company name the donor provided.', 'give'),
208 'label_on' => __('Show', 'give'),
209 'label_off' => __('Hide', 'give'),
210 'default' => 'no'
211 ]
212 );
213
214 $this->add_control(
215 'status_notice',
216 [
217 'label' => __('Payment Status Notice', 'give'),
218 'type' => \Elementor\Controls_Manager::SWITCHER,
219 'description' => __('Show or hide an alert above the receipt table showing the status of the donation payment.', 'give'),
220 'label_on' => __('Show', 'give'),
221 'label_off' => __('Hide', 'give'),
222 'default' => 'yes'
223 ]
224 );
225
226 $this->add_control(
227 'give_receipt_info',
228 [
229 'label' => '',
230 'type' => \Elementor\Controls_Manager::RAW_HTML,
231 'content_classes' => 'give-info',
232 'raw' => '
233 <div class="give">
234 <p class="info-head">
235 ' . __('GIVEWP RECEIPT WIDGET', 'give') . '</p>
236 <p class="info-message">' . __('This is the GiveWP Receipt widget. Choose the columns you want to have appear for your donor receipts.', 'give') . '</p>
237 <p class="info-message"><strong>' . __('NOTE:', 'give') . '</strong> ' . __('This is a sample receipt with all fields exposed. The alerts and info will show correctly for your donors. This receipt is just for preview/editing purposes.', 'give') . '</p>
238 <p class="give-docs-links">
239 <a href="https://givewp.com/documentation/core/shortcodes/give_receipt/?utm_source=plugin_settings&utm_medium=referral&utm_campaign=Free_Addons&utm_content=givelementor" rel="noopener noreferrer" target="_blank"><i class="fa fa-book" aria-hidden="true"></i>' . __('Visit the GiveWP Docs for more info on the GiveWP Donation Receipt.', 'give') . '</a>
240 </p>
241 </div>'
242 ]
243 );
244
245 $this->end_controls_section();
246 }
247
248 /**
249 * Render the [give_receipt] output on the frontend.
250 *
251 * Written in PHP and used to generate the final HTML.
252 *
253 * @since 4.7.0 migrated from givewp-elementor-widgets
254 * @access protected
255 */
256 protected function render()
257 {
258 $settings = $this->get_settings_for_display();
259
260 $error = esc_html($settings['error']);
261 $success = esc_html($settings['success']);
262 $price = ('yes' === $settings['price'] ? '' : 'price="false"');
263 $donor = ('yes' === $settings['donor'] ? '' : 'donor="false"');
264 $date = ('yes' === $settings['date'] ? '' : 'date="false"');
265 $method = ('yes' === $settings['method'] ? '' : 'payment_method="false"');
266 $id = ('yes' === $settings['payment_id'] ? '' : 'payment_id="false"');
267 $status = ('yes' === $settings['status'] ? 'payment_status="true"' : '');
268 $company = ('yes' === $settings['company'] ? 'company_name="true"' : '');
269 $notice = ('yes' === $settings['status_notice'] ? '' : 'status_notice="false"');
270
271 // Add-on compatibility
272 // Adding PDF Receipt row, and Subscription table
273 $pdfreceipts = (class_exists('Give_PDF_Receipts')) ? "true" : "false";
274 $recurring = (class_exists('Give_Recurring')) ? "true" : "false";
275
276 if (!\Elementor\Plugin::$instance->editor->is_edit_mode()) {
277 $html = do_shortcode('
278 [give_receipt '
279 . $error . ' '
280 . $price . ' '
281 . $donor . ' '
282 . $date . ' '
283 . $method . ' '
284 . $id . ' '
285 . $status . ' '
286 . $company . ' '
287 . $notice .
288 ']'
289 );
290
291 echo '<div class="givewp-elementor-widget give_receipt">';
292
293 echo $html;
294
295 echo '</div>';
296 } else {
297 ?>
298 <div id="give-receipt">
299 <div class="give_notices give_errors" id="give_error_fail">
300 <p class="give_notice give_error">
301 <?php echo (!empty($error) ? $error : __('You are missing the donation ID to view this donation receipt.', 'give')); ?>
302 </p>
303 </div>
304 <?php if ('yes' == $settings['status_notice']) : ?>
305 <div class="give_notices give_errors" id="give_error_success">
306 <p class="give_notice give_success">
307 <?php echo (!empty($success) ? $success : __('Thank you for your donation.', 'give')); ?>
308 </p>
309 </div>
310 <?php endif; ?>
311 <table id="give_donation_receipt" class="give-table">
312 <thead>
313 <tr>
314 <th scope="colgroup" colspan="2">
315 <span class="give-receipt-thead-text"><?php _e('Donation Receipt', 'give'); ?></span>
316 </th>
317 </tr>
318 </thead>
319
320 <tbody>
321 <?php
322 if ('yes' == $settings['donor']) : ?>
323 <tr>
324 <td scope="row"><strong><?php _e('Donor', 'give'); ?></strong></td>
325 <td><?php _e('Test Donor', 'give'); ?></td>
326 </tr>
327 <?php endif;
328 if ('yes' == $settings['company']) : ?>
329 <tr>
330 <td scope="row"><strong><?php _e('Company Name', 'give') ;?></strong></td>
331 <td>Impress.org</td>
332 </tr>
333 <?php endif;
334 if ('yes' == $settings['date']) : ?>
335 <tr>
336 <td scope="row"><strong><?php _e('Date', 'give'); ?></strong></td>
337 <td><?php _e('April 18, 2020' , 'give') ;?></td>
338 </tr>
339 <?php endif;
340 if ('yes' == $settings['price']) : ?>
341 <tr>
342 <td scope="row"><strong><?php _e('Total Donation' ,'give'); ?></strong></td>
343 <td>$25.00</td>
344 </tr>
345 <?php endif; ?>
346 <tr>
347 <td scope="row"><strong><?php _e('Donation' , 'give'); ?></strong></td>
348 <td><?php _e('First Form', 'give'); ?><span class="donation-level-text-wrap"></span></td>
349 </tr>
350 <?php
351 if ('yes' == $settings['status']) : ?>
352 <tr>
353 <td scope="row"><strong><?php _e('Donation Status', 'give'); ?></strong></td>
354 <td><?php _e('Complete', 'give'); ?></td>
355 </tr>
356 <?php endif;
357 if ('yes' == $settings['payment_id']) : ?>
358 <tr>
359 <td scope="row"><strong><?php _e('Donation ID', 'give');?></strong></td>
360 <td>3</td>
361 </tr>
362 <?php endif;
363 if ('yes' == $settings['method']) : ?>
364 <tr>
365 <td scope="row"><strong><?php _e('Payment Method' , 'give'); ?></strong></td>
366 <td><?php _e('Test Donation', 'give'); ?></td>
367 </tr>
368 <?php endif;
369 if ('true' == $pdfreceipts) : ?>
370 <tr>
371 <td><strong><?php _e('Receipt', 'give'); ?>:</strong></td>
372 <td><a class="give_receipt_link" title="Download Receipt" href="#"><?php _e('Download Receipt', 'give');?> »</a></td>
373 </tr>
374 <?php endif;?>
375 </tbody>
376 </table>
377
378 <?php if ('true' == $recurring) : ?>
379 <table id="give-subscription-receipt" class="give-table">
380
381 <thead>
382 <tr>
383 <th scope="colgroup" colspan="2">
384 <span class="give-receipt-thead-text"><?php _e('Subscription Details', 'give'); ?></span>
385 </th>
386 </tr>
387 </thead>
388
389 <tbody>
390
391 <tr>
392 <td scope="row"><strong><?php _e('Subscription:', 'give'); ?></strong></td>
393 <td>
394 <span class="give-subscription-billing-cycle">$25.00 / <?php _e('Monthly', 'give'); ?></span>
395 </td>
396 </tr>
397 <tr>
398 <td scope="row"><strong><?php _e('Status:', 'give'); ?></strong></td>
399 <td>
400 <span class="give-subscription-status"><span class="give-donation-status status-active"><span class="give-donation-status-icon"></span> <?php _e('Active', 'give'); ?></span></span>
401 </td>
402 </tr>
403 <tr>
404 <td scope="row"><strong><?php _e('Renewal Date:', 'give'); ?></strong></td>
405 <td><span class="give-subscription-renewal-date"><?php _e('June 4, 2020', 'give'); ?></span></td>
406 </tr>
407 <tr>
408 <td scope="row"><strong><?php _e('Progress:', 'give'); ?></strong></td>
409 <td><span class="give-subscription-times-billed">1 / <?php _e('Ongoing', 'give'); ?></span>
410 </td>
411 </tr>
412
413 </tbody>
414 </table>
415 <a href="#" class="give-recurring-manage-subscriptions-receipt-link"><?php _e('Manage Subscriptions', 'give'); ?> »</a>
416 </div>
417 <?php
418 endif; // End if Recurring Donations is active.
419 }
420 }
421 }
422