|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* The [give_donation_grid] Shortcode Generator class |
|
4
|
|
|
* |
|
5
|
|
|
* @package Give/Admin/Shortcodes |
|
6
|
|
|
* @copyright Copyright (c) 2016, WordImpress |
|
7
|
|
|
* @license https://opensource.org/licenses/gpl-license GNU Public License |
|
8
|
|
|
* @since 2.1 |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
// Exit if accessed directly. |
|
12
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
13
|
|
|
exit; |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class Give_Shortcode_Donation_Form_Goal |
|
18
|
|
|
*/ |
|
19
|
|
|
class Give_Shortcode_Donation_Grid extends Give_Shortcode_Generator { |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class constructor |
|
23
|
|
|
*/ |
|
24
|
|
View Code Duplication |
public function __construct() { |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
$this->shortcode['title'] = esc_html__( 'Donation Form Grid', 'give' ); |
|
27
|
|
|
$this->shortcode['label'] = esc_html__( 'Donation Form Grid', 'give' ); |
|
28
|
|
|
|
|
29
|
|
|
parent::__construct( 'give_form_grid' ); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Define the shortcode attribute fields |
|
34
|
|
|
* |
|
35
|
|
|
* @return array |
|
36
|
|
|
*/ |
|
37
|
|
|
public function define_fields() { |
|
38
|
|
|
|
|
39
|
|
|
return array( |
|
40
|
|
|
array( |
|
41
|
|
|
'type' => 'container', |
|
42
|
|
|
'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
43
|
|
|
), |
|
44
|
|
|
array( |
|
45
|
|
|
'type' => 'textbox', |
|
46
|
|
|
'name' => 'ids', |
|
47
|
|
|
'label' => esc_attr__( 'Form IDs:', 'give' ), |
|
48
|
|
|
'tooltip' => esc_attr__( 'Enter a comma-separated list of form IDs. If empty, all published forms are displayed.', 'give' ), |
|
49
|
|
|
'placeholder' => esc_html__( 'All Forms', 'give' ) |
|
50
|
|
|
), |
|
51
|
|
|
array( |
|
52
|
|
|
'type' => 'listbox', |
|
53
|
|
|
'name' => 'columns', |
|
54
|
|
|
'label' => esc_attr__( 'Columns:', 'give' ), |
|
55
|
|
|
'tooltip' => esc_attr__( 'Sets the number of donations per row.', 'give' ), |
|
56
|
|
|
'options' => array( |
|
57
|
|
|
'1' => esc_html__( '1', 'give' ), |
|
58
|
|
|
'2' => esc_html__( '2', 'give' ), |
|
59
|
|
|
'3' => esc_html__( '3', 'give' ), |
|
60
|
|
|
'4' => esc_html__( '4', 'give' ), |
|
61
|
|
|
), |
|
62
|
|
|
'placeholder' => esc_html__( 'Best Fit', 'give' ) |
|
63
|
|
|
), |
|
64
|
|
|
array( |
|
65
|
|
|
'type' => 'listbox', |
|
66
|
|
|
'name' => 'show_goal', |
|
67
|
|
|
'label' => esc_attr__( 'Show Goal:', 'give' ), |
|
68
|
|
|
'tooltip' => __( 'Do you want to display the goal\'s progress bar?', 'give' ), |
|
69
|
|
|
'options' => array( |
|
70
|
|
|
'true' => esc_html__( 'Show', 'give' ), |
|
71
|
|
|
'false' => esc_html__( 'Hide', 'give' ), |
|
72
|
|
|
), |
|
73
|
|
|
), |
|
74
|
|
|
array( |
|
75
|
|
|
'type' => 'listbox', |
|
76
|
|
|
'name' => 'show_excerpt', |
|
77
|
|
|
'label' => esc_attr__( 'Show Excerpt:', 'give' ), |
|
78
|
|
|
'tooltip' => esc_attr__( 'Do you want to display the excerpt?', 'give' ), |
|
79
|
|
|
'options' => array( |
|
80
|
|
|
'true' => esc_html__( 'Show', 'give' ), |
|
81
|
|
|
'false' => esc_html__( 'Hide', 'give' ), |
|
82
|
|
|
), |
|
83
|
|
|
), |
|
84
|
|
|
array( |
|
85
|
|
|
'type' => 'listbox', |
|
86
|
|
|
'name' => 'show_featured_image', |
|
87
|
|
|
'label' => esc_attr__( 'Show Featured Image:', 'give' ), |
|
88
|
|
|
'tooltip' => esc_attr__( 'Do you want to display the featured image?', 'give' ), |
|
89
|
|
|
'options' => array( |
|
90
|
|
|
'true' => esc_html__( 'Show', 'give' ), |
|
91
|
|
|
'false' => esc_html__( 'Hide', 'give' ), |
|
92
|
|
|
), |
|
93
|
|
|
), |
|
94
|
|
|
array( |
|
95
|
|
|
'type' => 'listbox', |
|
96
|
|
|
'name' => 'display_style', |
|
97
|
|
|
'label' => esc_attr__( 'Display Style:', 'give' ), |
|
98
|
|
|
'tooltip' => esc_attr__( 'Show form as modal window or redirect to a new page?', 'give' ), |
|
99
|
|
|
'options' => array( |
|
100
|
|
|
'redirect' => esc_html__( 'Redirect', 'give' ), |
|
101
|
|
|
'modal_reveal' => esc_html__( 'Modal', 'give' ), |
|
102
|
|
|
), |
|
103
|
|
|
), |
|
104
|
|
|
array( |
|
105
|
|
|
'type' => 'textbox', |
|
106
|
|
|
'name' => 'forms_per_page', |
|
107
|
|
|
'label' => esc_attr__( 'Forms Per Page:', 'give' ), |
|
108
|
|
|
'tooltip' => esc_attr__( 'Sets the number of donations form per row.', 'give' ), |
|
109
|
|
|
'value' => 12, |
|
110
|
|
|
), |
|
111
|
|
|
); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
new Give_Shortcode_Donation_Grid(); |
|
116
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.