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 / GiveFormGridWidget.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
GiveFormGridWidget.php
485 lines
1 <?php
2
3 namespace Give\ThirdPartySupport\Elementor\Widgets\V1;
4
5 use Elementor\Widget_Base;
6
7 /**
8 * Elementor Give Form Grid Widget.
9 *
10 * Elementor widget that inserts the GiveWP [give_form_grid] shortcode to output a form total with options.
11 *
12 * @since 4.7.0 migrated from givewp-elementor-widgets
13 */
14
15 class GiveFormGridWidget extends Widget_Base
16 {
17 /**
18 * Get widget name.
19 *
20 * Retrieve Give Form Grid 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 'GiveWP_Form_Grid';
30 }
31
32 /**
33 * Get widget title.
34 *
35 * Retrieve Give Form Grid 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 Form Grid (Legacy)', 'give');
45 }
46
47 /**
48 * Get widget icon.
49 *
50 * Retrieve Give Form Grid 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 Give Form Grid 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 Give Form Grid 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 'give_form_grid_settings',
102 [
103 'label' => __('GiveWP Form Grid Widget', 'give'),
104 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
105 ]
106 );
107
108 $this->add_control(
109 'forms_cats_tags',
110 [
111 'label' => __('Collection Method', 'give'),
112 'type' => \Elementor\Controls_Manager::SELECT,
113 'description' => __('Would you like to show forms by ID, by their Categories, or by their Tags?', 'give'),
114 'options' => [
115 'forms' => __('Forms', 'give'),
116 'cats' => __('Categories', 'give'),
117 'tags' => __('Tags', 'give'),
118 ],
119 'default' => 'forms',
120 ]
121 );
122
123 $this->add_control(
124 'all_forms',
125 [
126 'label' => __('Show All Forms?', 'give'),
127 'type' => \Elementor\Controls_Manager::CHOOSE,
128 'description' => __('Do you want to show all forms in your grid?', 'give'),
129 'options' => [
130 'yes' => [
131 'title' => __('Yes', 'give'),
132 'icon' => 'fa fa-check',
133 ],
134 'no' => [
135 'title' => __('No', 'give'),
136 'icon' => 'fa fa-times-circle',
137 ],
138 ],
139 'default' => 'yes',
140 'toggle' => true,
141 'condition' => [
142 'forms_cats_tags' => 'forms'
143 ]
144 ]
145 );
146
147 $this->add_control(
148 'form_ids',
149 [
150 'label' => __('Show by Form IDs', 'give'),
151 'type' => \Elementor\Controls_Manager::TEXT,
152 'description' => __('Place the form IDs you\'d like to show in your grid here, separated by commas.', 'give'),
153 'condition' => [
154 'all_forms' => 'no',
155 'forms_cats_tags' => 'forms'
156 ]
157 ]
158 );
159
160 $this->add_control(
161 'cats',
162 [
163 'label' => __('Show by Form Categories', 'give'),
164 'type' => \Elementor\Controls_Manager::TEXT,
165 'description' => __('Place the form category IDs you\'d like to show in your grid here, separated by commas.', 'give'),
166 'condition' => [
167 'forms_cats_tags' => 'cats'
168 ]
169 ]
170 );
171
172 $this->add_control(
173 'tags',
174 [
175 'label' => __('Show by Form Tags', 'give'),
176 'type' => \Elementor\Controls_Manager::TEXT,
177 'description' => __('Place the form category IDs you\'d like to show in your grid here, separated by commas.', 'give'),
178 'condition' => [
179 'forms_cats_tags' => 'tags'
180 ]
181 ]
182 );
183
184 $this->add_control(
185 'exclude',
186 [
187 'label' => __('Exclude Forms', 'give'),
188 'type' => \Elementor\Controls_Manager::TEXT,
189 'description' => __('List the form IDs that you want excluded from this Form Grid.', 'give'),
190 ]
191 );
192
193 $this->add_control(
194 'forms_per_page',
195 [
196 'label' => __('Forms Per Page', 'give'),
197 'type' => \Elementor\Controls_Manager::SELECT,
198 'description' => __('The number of forms to show in the grid before the "Load More" button appears.', 'give'),
199 'options' => [
200 '1' => '1',
201 '2' => '2',
202 '3' => '3',
203 '4' => '4',
204 '5' => '5',
205 '6' => '6',
206 '7' => '7',
207 '8' => '8',
208 '9' => '9',
209 '10' => '10',
210 '11' => '11',
211 '12' => '12',
212 ],
213 'default' => '12'
214 ]
215 );
216
217 $this->add_control(
218 'paged',
219 [
220 'label' => __('Show Pagination', 'give'),
221 'type' => \Elementor\Controls_Manager::SWITCHER,
222 'label_on' => __('Show', 'give'),
223 'label_off' => __('Hide', 'give'),
224 'default' => 'yes',
225 ]
226 );
227
228 $this->add_control(
229 'orderby',
230 [
231 'label' => __('Order By', 'give'),
232 'type' => \Elementor\Controls_Manager::SELECT,
233 'description' => __('The element which the order will be determined by.', 'give'),
234 'options' => [
235 'date' => __('Date Created', 'give'),
236 'title' => __('Form Name', 'give'),
237 'amount_donated' => __('Amount Donated', 'give'),
238 'number_donations' => __('Number of Donations', 'give'),
239 'menu_order' => __('Menu Order', 'give'),
240 'post__in' => __('Form ID', 'give'),
241 'closest_to_goal' => __('Closest to Goal', 'give'),
242 ],
243 'default' => 'date'
244 ]
245 );
246
247 $this->add_control(
248 'order',
249 [
250 'label' => __('Order By', 'give'),
251 'type' => \Elementor\Controls_Manager::SELECT,
252 'description' => __('The order the donors will be displayed in according to the "Order By" field chosen.', 'give'),
253 'options' => [
254 'desc' => __('Descending', 'give'),
255 'asc' => __('Ascending', 'give')
256 ],
257 'default' => 'desc'
258 ]
259 );
260
261 $this->add_control(
262 'columns',
263 [
264 'label' => __('Number of Columns', 'give'),
265 'type' => \Elementor\Controls_Manager::SELECT,
266 'description' => __('The number of columns to display. Note that "Best Fit" will always stretch to fill the available width that the donor wall is placed within.', 'give'),
267 'options' => [
268 'best-fit' => __('Best Fit', 'give'),
269 '1' => '1',
270 '2' => '2',
271 '3' => '3',
272 '4' => '4',
273 ],
274 'default' => 'best-fit'
275 ]
276 );
277
278 $this->add_control(
279 'show_title',
280 [
281 'label' => __('Show Form Title', 'give'),
282 'type' => \Elementor\Controls_Manager::SWITCHER,
283 'description' => __('Show/Hide the form title.', 'give'),
284 'label_on' => __('Show', 'give'),
285 'label_off' => __('Hide', 'give'),
286 'default' => 'yes',
287 ]
288 );
289
290 $this->add_control(
291 'show_excerpt',
292 [
293 'label' => __('Show Form Excerpt', 'give'),
294 'type' => \Elementor\Controls_Manager::SWITCHER,
295 'description' => __('Show/Hide the form excerpt.', 'give'),
296 'label_on' => __('Show', 'give'),
297 'label_off' => __('Hide', 'give'),
298 'default' => 'yes',
299 ]
300 );
301
302 $this->add_control(
303 'excerpt_length',
304 [
305 'label' => __('Excerpt Length', 'give'),
306 'type' => \Elementor\Controls_Manager::TEXT,
307 'description' => __('Excerpt Length.', 'give'),
308 'condition' => [
309 'show_excerpt' => 'yes'
310 ]
311 ]
312 );
313
314 $this->add_control(
315 'show_goal',
316 [
317 'label' => __('Show Form Goal', 'give'),
318 'type' => \Elementor\Controls_Manager::SWITCHER,
319 'description' => __('Show/Hide the form goal.', 'give'),
320 'label_on' => __('Show', 'give'),
321 'label_off' => __('Hide', 'give'),
322 'default' => 'yes',
323 ]
324 );
325
326 $this->add_control(
327 'show_featured_image',
328 [
329 'label' => __('Show Form Featured Image', 'give'),
330 'type' => \Elementor\Controls_Manager::SWITCHER,
331 'description' => __('Show/Hide the form featured image.', 'give'),
332 'label_on' => __('Show', 'give'),
333 'label_off' => __('Hide', 'give'),
334 'default' => 'yes',
335 ]
336 );
337
338 $this->add_control(
339 'image_size',
340 [
341 'label' => __('Image Size', 'give'),
342 'type' => \Elementor\Controls_Manager::TEXT,
343 'description' => __('Featured image size. Default "medium". Accepts WordPress image sizes.', 'give'),
344 'condition' => [
345 'show_featured_image' => 'yes'
346 ]
347 ]
348 );
349
350 $this->add_control(
351 'image_height',
352 [
353 'label' => __('Image Height', 'give'),
354 'type' => \Elementor\Controls_Manager::TEXT,
355 'description' => __('Featured image height. Default "auto". Accepts valid CSS heights', 'give'),
356 'condition' => [
357 'show_featured_image' => 'yes'
358 ]
359 ]
360 );
361
362 $this->add_control(
363 'show_donate_button',
364 [
365 'label' => __('Show Donate Button', 'give'),
366 'type' => \Elementor\Controls_Manager::SWITCHER,
367 'label_on' => __('Show', 'give'),
368 'label_off' => __('Hide', 'give'),
369 'default' => 'yes',
370 ]
371 );
372
373 $this->add_control(
374 'donate_button_text_color',
375 [
376 'label' => __('Donate Button Text Color', 'give'),
377 'type' => \Elementor\Controls_Manager::COLOR,
378 'default' => '#69B86B',
379 'condition' => [
380 'show_donate_button' => 'yes'
381 ],
382 ]
383 );
384
385 $this->add_control(
386 'display_style',
387 [
388 'label' => __('Display Type', 'give'),
389 'type' => \Elementor\Controls_Manager::SELECT,
390 'description' => __('Choose the behavior when a form is clicked on within the grid.', 'give'),
391 'options' => [
392 'redirect' => __('Redirect to the single Form Page.', 'give'),
393 'modal_reveal' => __('Open the form in a modal window.', 'give'),
394 ],
395 'default' => 'redirect'
396 ]
397 );
398
399 $this->add_control(
400 'give_form_grid_info',
401 [
402 'label' => '',
403 'type' => \Elementor\Controls_Manager::RAW_HTML,
404 'content_classes' => 'give-info',
405 'raw' => '
406 <div class="give">
407 <p class="info-head">
408 ' . __('GIVEWP FORM GRID WIDGET', 'give') . '</p>
409 <p class="info-message">' . __('This is the GiveWP Form Grid widget. Choose the elements you want to see appear in the form grid.', 'give') . '</p>
410 <p class="give-docs-links">
411 <a href="https://givewp.com/documentation/core/shortcodes/give_form_grid/?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 Form Grid.', 'give') . '</a>
412 </p>
413 </div>'
414 ]
415 );
416
417 $this->end_controls_section();
418 }
419
420 /**
421 * Render the [give_form_grid] output on the frontend.
422 *
423 * Written in PHP and used to generate the final HTML.
424 *
425 * @since 4.7.0 migrated from givewp-elementor-widgets
426 * @access protected
427 */
428 protected function render()
429 {
430 global $give_receipt_args, $donation;
431
432 $settings = $this->get_settings_for_display();
433
434 $forms = ('yes' === $settings['all_forms'] ? '' : $settings['form_ids']);
435 $formsPerPage = esc_html($settings['forms_per_page']);
436 $paged = esc_html($settings['paged']);
437 $columns = esc_html($settings['columns']);
438 $orderby = esc_html($settings['orderby']);
439 $order = esc_html($settings['order']);
440 $exclude = esc_html($settings['exclude']);
441 $cats = esc_html($settings['cats']);
442 $tags = esc_html($settings['tags']);
443 $showTitle = esc_html($settings['show_title']);
444 $showGoal = esc_html($settings['show_goal']);
445 $showExcerpt = esc_html($settings['show_excerpt']);
446 $excerptLength = esc_html($settings['excerpt_length']);
447 $showFeaturedImage = esc_html($settings['show_featured_image']);
448 $displayStyle = esc_html($settings['display_style']);
449 $imageSize = esc_html($settings['image_size']);
450 $imageHeight = esc_html($settings['image_height']);
451 $showDonateButton = esc_html($settings['show_donate_button']);
452 $buttonTextColor = esc_html($settings['donate_button_text_color']);
453
454 $html = do_shortcode('
455 [give_form_grid
456 forms_per_page="' . $formsPerPage . '"
457 paged="' . $paged . '"
458 ids="' . $forms . '"
459 columns="' . $columns . '"
460 order="' . $order . '"
461 exclude="' . $exclude . '"
462 cats="' . $cats . '"
463 tags="' . $tags . '"
464 show_title="' . $showTitle . '"
465 show_goal="' . $showGoal . '"
466 show_excerpt="' . $showExcerpt . '"
467 excerpt_length="' . $excerptLength . '"
468 show_featured_image="' . $showFeaturedImage . '"
469 image_size="' . $imageSize . '"
470 image_height="' . $imageHeight . '"
471 show_donate_button="' . $showDonateButton . '"
472 donate_button_text_color="' . $buttonTextColor . '"
473 display_style="' . $displayStyle . '"
474 orderby="' . $orderby .
475 '"]'
476 );
477
478 echo '<div class="givewp-elementor-widget give-form-grid-shortcode-wrap">';
479
480 echo $html;
481
482 echo '</div>';
483 }
484 }
485