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
← All changes | includes/widgets/class-charitable-donors-widget.php +85 -77 1.6.7 → 1.8.13 View file →
@@ -3,13 +3,15 @@
3 3 * Campaign donors widget class.
4 4 *
5 5 * @version 1.0.0
6 6 * @package Charitable/Widgets/Donors
7 - * @author Eric Daams
7 + * @author David Bisset
8 8 */
9 9
10 10 // Exit if accessed directly.
11 -if ( ! defined( 'ABSPATH' ) ) { exit; }
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
12 14
13 15 if ( ! class_exists( 'Charitable_Donors_Widget' ) ) :
14 16
15 17 /**
@@ -28,9 +30,9 @@
28 30 parent::__construct(
29 31 'charitable_donors_widget',
30 32 __( 'Donors', 'charitable' ),
31 33 array(
32 - 'description' => __( 'Display a list of donors.', 'charitable' ),
34 + 'description' => __( 'Display a list of donors.', 'charitable' ),
33 35 'customize_selective_refresh' => true,
34 36 )
35 37 );
36 38 }
@@ -37,13 +39,13 @@
37 39
38 40 /**
39 41 * Display the widget contents on the front-end.
40 42 *
41 - * @since 1.0.0
43 + * @since 1.0.0
42 44 *
43 - * @param array $args Display arguments including 'before_title', 'after_title', 'before_widget' and 'after_widget'.
44 - * @param array $instance The settings for the particular instance of the widget.
45 - * @return void
45 + * @param array $args Display arguments including 'before_title', 'after_title', 'before_widget' and 'after_widget'.
46 + * @param array $instance The settings for the particular instance of the widget.
47 + * @return void
46 48 */
47 49 public function widget( $args, $instance ) {
48 50 $instance = $this->get_parsed_args( $instance );
49 51 $view_args = array_merge( $args, $instance );
@@ -58,12 +60,12 @@
58 60
59 61 /**
60 62 * Display the widget form in the admin.
61 63 *
62 - * @since 1.0.0
64 + * @since 1.0.0
63 65 *
64 - * @param array $instance The current settings for the widget options.
65 - * @return void
66 + * @param array $instance The current settings for the widget options.
67 + * @return void
66 68 */
67 69 public function form( $instance ) {
68 70 $args = $this->get_parsed_args( $instance );
69 71 $campaigns = Charitable_Campaigns::query( array( 'posts_per_page' => -1 ) );
@@ -68,64 +70,64 @@
68 70 $args = $this->get_parsed_args( $instance );
69 71 $campaigns = Charitable_Campaigns::query( array( 'posts_per_page' => -1 ) );
70 72 ?>
71 73 <p>
72 - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ) ?>"><?php _e( 'Title', 'charitable' ) ?>:</label>
73 - <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ) ?>" value="<?php echo esc_attr( $args['title'] ) ?>" class="widefat" />
74 + <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'charitable' ); ?>:</label>
75 + <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $args['title'] ); ?>" class="widefat" />
74 76 </p>
75 77 <p>
76 - <label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ) ?>"><?php _e( 'Number of donors to display', 'charitable' ) ?>:</label>
77 - <input type="number" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ) ?>" value="<?php echo intval( $args['number'] ) ?>" min="1" size="3" />
78 + <label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of donors to display', 'charitable' ); ?>:</label>
79 + <input type="number" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" value="<?php echo intval( $args['number'] ); ?>" min="1" size="3" />
78 80 </p>
79 81 <p>
80 - <label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ) ?>"><?php _e( 'Order by', 'charitable' ) ?>:</label>
81 - <select name="<?php echo esc_attr( $this->get_field_name( 'order' ) ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ) ?>">
82 - <option value="recent" <?php selected( 'recent', $args['order'] ) ?>><?php _e( 'Most recent', 'charitable' ) ?></option>
83 - <option value="amount" <?php selected( 'amount', $args['order'] ) ?>><?php _e( 'Amount donated', 'charitable' ) ?></option>
82 + <label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php esc_html_e( 'Order by', 'charitable' ); ?>:</label>
83 + <select name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>">
84 + <option value="recent" <?php selected( 'recent', $args['order'] ); ?>><?php esc_html_e( 'Most recent', 'charitable' ); ?></option>
85 + <option value="amount" <?php selected( 'amount', $args['order'] ); ?>><?php esc_html_e( 'Amount donated', 'charitable' ); ?></option>
84 86 </select>
85 87 </p>
86 88 <p>
87 - <label for="<?php echo esc_attr( $this->get_field_id( 'campaign_id' ) ) ?>"><?php _e( 'Show donors by campaign', 'charitable' ) ?>:</label>
88 - <select name="<?php echo esc_attr( $this->get_field_name( 'campaign_id' ) ) ?>">
89 - <option value="all" <?php selected( 'all', $args['campaign_id'] ) ?>><?php _e( 'Include all campaigns' ) ?></option>
90 - <option value="current" <?php selected( 'current', $args['campaign_id'] ) ?>><?php _e( 'Campaign currently viewed', 'charitable' ) ?></option>
91 - <optgroup label="<?php _e( 'Specific campaign', 'charitable' ) ?>">
89 + <label for="<?php echo esc_attr( $this->get_field_id( 'campaign_id' ) ); ?>"><?php esc_html_e( 'Show donors by campaign', 'charitable' ); ?>:</label>
90 + <select name="<?php echo esc_attr( $this->get_field_name( 'campaign_id' ) ); ?>">
91 + <option value="all" <?php selected( 'all', $args['campaign_id'] ); ?>><?php esc_html_e( 'Include all campaigns', 'charitable' ); ?></option>
92 + <option value="current" <?php selected( 'current', $args['campaign_id'] ); ?>><?php esc_html_e( 'Campaign currently viewed', 'charitable' ); ?></option>
93 + <optgroup label="<?php esc_html_e( 'Specific campaign', 'charitable' ); ?>">
92 94 <?php foreach ( $campaigns->posts as $campaign ) : ?>
93 - <option value="<?php echo intval( $campaign->ID ) ?>" <?php selected( $campaign->ID, $args['campaign_id'] ) ?>><?php echo $campaign->post_title ?></option>
95 + <option value="<?php echo intval( $campaign->ID ); ?>" <?php selected( $campaign->ID, $args['campaign_id'] ); ?>><?php echo esc_html( $campaign->post_title ); ?></option>
94 96 <?php endforeach ?>
95 97 </optgroup>
96 - </select>
98 + </select>
97 99 </p>
98 100 <p>
99 - <input id="<?php echo esc_attr( $this->get_field_id( 'show_distinct' ) ) ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_distinct' ) ); ?>" <?php checked( $args['show_distinct'] ) ?>>
100 - <label for="<?php echo esc_attr( $this->get_field_id( 'show_distinct' ) ) ?>"><?php _e( 'Group donations by the same person', 'charitable' ) ?></label>
101 + <input id="<?php echo esc_attr( $this->get_field_id( 'show_distinct' ) ); ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_distinct' ) ); ?>" <?php checked( $args['show_distinct'] ); ?>>
102 + <label for="<?php echo esc_attr( $this->get_field_id( 'show_distinct' ) ); ?>"><?php esc_html_e( 'Group donations by the same person', 'charitable' ); ?></label>
101 103 </p>
102 104 <p>
103 - <input id="<?php echo esc_attr( $this->get_field_id( 'show_avatar' ) ) ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_avatar' ) ); ?>" <?php checked( $args['show_avatar'] ) ?>>
104 - <label for="<?php echo esc_attr( $this->get_field_id( 'show_avatar' ) ) ?>"><?php _e( 'Show donor\'s avatar', 'charitable' ) ?></label>
105 + <input id="<?php echo esc_attr( $this->get_field_id( 'show_avatar' ) ); ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_avatar' ) ); ?>" <?php checked( $args['show_avatar'] ); ?>>
106 + <label for="<?php echo esc_attr( $this->get_field_id( 'show_avatar' ) ); ?>"><?php esc_html_e( 'Show donor\'s avatar', 'charitable' ); ?></label>
105 107 </p>
106 108 <p>
107 - <input id="<?php echo esc_attr( $this->get_field_id( 'show_name' ) ) ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_name' ) ); ?>" <?php checked( $args['show_name'] ) ?>>
108 - <label for="<?php echo esc_attr( $this->get_field_id( 'show_name' ) ) ?>"><?php _e( 'Show donor\'s name', 'charitable' ) ?></label>
109 + <input id="<?php echo esc_attr( $this->get_field_id( 'show_name' ) ); ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_name' ) ); ?>" <?php checked( $args['show_name'] ); ?>>
110 + <label for="<?php echo esc_attr( $this->get_field_id( 'show_name' ) ); ?>"><?php esc_html_e( 'Show donor\'s name', 'charitable' ); ?></label>
109 111 </p>
110 112 <p>
111 - <input id="<?php echo esc_attr( $this->get_field_id( 'show_amount' ) ) ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_amount' ) ); ?>" <?php checked( $args['show_amount'] ) ?>>
112 - <label for="<?php echo esc_attr( $this->get_field_id( 'show_amount' ) ) ?>"><?php _e( 'Show donor\'s donation amount', 'charitable' ) ?></label>
113 + <input id="<?php echo esc_attr( $this->get_field_id( 'show_amount' ) ); ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_amount' ) ); ?>" <?php checked( $args['show_amount'] ); ?>>
114 + <label for="<?php echo esc_attr( $this->get_field_id( 'show_amount' ) ); ?>"><?php esc_html_e( 'Show donor\'s donation amount', 'charitable' ); ?></label>
113 115 </p>
114 - <p>
115 - <input id="<?php echo esc_attr( $this->get_field_id( 'show_location' ) ) ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_location' ) ); ?>" <?php checked( $args['show_location'] ) ?>>
116 - <label for="<?php echo esc_attr( $this->get_field_id( 'show_location' ) ) ?>"><?php _e( 'Show donor\'s location', 'charitable' ) ?></label>
116 + <p>
117 + <input id="<?php echo esc_attr( $this->get_field_id( 'show_location' ) ); ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_location' ) ); ?>" <?php checked( $args['show_location'] ); ?>>
118 + <label for="<?php echo esc_attr( $this->get_field_id( 'show_location' ) ); ?>"><?php esc_html_e( 'Show donor\'s location', 'charitable' ); ?></label>
117 119 </p>
118 - <p>
119 - <input id="<?php echo esc_attr( $this->get_field_id( 'hide_if_no_donors' ) ) ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'hide_if_no_donors' ) ); ?>" <?php checked( $args['hide_if_no_donors'] ) ?>>
120 - <label for="<?php echo esc_attr( $this->get_field_id( 'hide_if_no_donors' ) ) ?>"><?php _e( 'Hide if there are no donors', 'charitable' ) ?></label>
120 + <p>
121 + <input id="<?php echo esc_attr( $this->get_field_id( 'hide_if_no_donors' ) ); ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'hide_if_no_donors' ) ); ?>" <?php checked( $args['hide_if_no_donors'] ); ?>>
122 + <label for="<?php echo esc_attr( $this->get_field_id( 'hide_if_no_donors' ) ); ?>"><?php esc_html_e( 'Hide if there are no donors', 'charitable' ); ?></label>
121 123 </p>
122 124 <?php
123 125 /**
124 126 * Add extra settings for the widget.
125 127 *
126 - * @param array $args Widget instance arguments.
127 - * @param Charitable_Donors_Widget $this This widget instance.
128 + * @param array $args Widget instance arguments.
129 + * @param Charitable_Donors_Widget $this This widget instance.
128 130 */
129 131 do_action( 'charitable_donor_widget_settings_bottom', $args, $this );
130 132 }
131 133
@@ -132,12 +134,13 @@
132 134 /**
133 135 * Update the widget settings in the admin.
134 136 *
135 137 * @since 1.0.0
138 + * @version 1.8.5.3
136 139 *
137 - * @param array $new_instance The updated settings.
138 - * @param array $old_instance The old settings.
139 - * @return array
140 + * @param array $new_instance The updated settings.
141 + * @param array $old_instance The old settings.
142 + * @return array
140 143 */
141 144 public function update( $new_instance, $old_instance ) {
142 145 $instance = $new_instance;
143 146
@@ -146,18 +149,21 @@
146 149 ? charitable_sanitize_checkbox( $instance[ $key ] )
147 150 : 0;
148 151 }
149 152
153 + $instance['title'] = sanitize_text_field( $instance['title'] );
154 + $instance['campaign_id'] = sanitize_text_field( $instance['campaign_id'] );
155 + $instance['order'] = sanitize_text_field( $instance['order'] );
156 +
150 157 /**
151 158 * Filter the instance arguments.
152 159 *
153 - * @since 1.0.0
160 + * @since 1.0.0
154 161 *
155 - * @param array $instance The parsed instance settings.
156 - * @param array $new_instance The updated settings.
157 - * @param array $old_instance The old settings.
158 - * @return array
159 - */
162 + * @param array $instance The parsed instance settings.
163 + * @param array $new_instance The updated settings.
164 + * @param array $old_instance The old settings.
165 + */
160 166 return apply_filters( 'charitable_donors_widget_update_instance', $instance, $new_instance, $old_instance );
161 167 }
162 168
163 169 /**
@@ -162,35 +168,38 @@
162 168
163 169 /**
164 170 * Return parsed array of arguments.
165 171 *
166 - * @since 1.0.0
172 + * @since 1.0.0
167 173 *
168 - * @param array $instance The settings for the particular instance of the widget.
169 - * @return mixed[]
174 + * @param array $instance The settings for the particular instance of the widget.
175 + * @return mixed[]
170 176 */
171 177 protected function get_parsed_args( $instance ) {
172 178 /**
173 179 * Filter the default widget arguments.
174 180 *
175 - * @since 1.0.0
181 + * @since 1.0.0
176 182 *
177 - * @param array $args The default arguments.
178 - * @param array $instance The widget instance settings.
179 - * @return array
180 - */
181 - $defaults = apply_filters( 'charitable_donors_widget_default_args', array(
182 - 'title' => '',
183 - 'number' => 10,
184 - 'order' => 'recent',
185 - 'campaign_id' => 'all',
186 - 'show_distinct' => 1,
187 - 'show_avatar' => 1,
188 - 'show_location' => 0,
189 - 'show_amount' => 0,
190 - 'show_name' => 0,
191 - 'hide_if_no_donors' => 0,
192 - ), $instance );
183 + * @param array $args The default arguments.
184 + * @param array $instance The widget instance settings.
185 + */
186 + $defaults = apply_filters(
187 + 'charitable_donors_widget_default_args',
188 + array(
189 + 'title' => '',
190 + 'number' => 10,
191 + 'order' => 'recent',
192 + 'campaign_id' => 'all',
193 + 'show_distinct' => 1,
194 + 'show_avatar' => 1,
195 + 'show_location' => 0,
196 + 'show_amount' => 0,
197 + 'show_name' => 0,
198 + 'hide_if_no_donors' => 0,
199 + ),
200 + $instance
201 + );
193 202
194 203 return wp_parse_args( $instance, $defaults );
195 204 }
196 205
@@ -196,12 +205,12 @@
196 205
197 206 /**
198 207 * Return the donors to display in the widget.
199 208 *
200 - * @since 1.0.0
209 + * @since 1.0.0
201 210 *
202 - * @param mixed[] $instance The widget instance.
203 - * @return Charitable_Donor_Query
211 + * @param mixed[] $instance The widget instance.
212 + * @return Charitable_Donor_Query
204 213 */
205 214 protected function get_widget_donors( $instance ) {
206 215 $query_args = charitable_array_subset( $instance, array( 'number', 'campaign' ) );
207 216
@@ -213,13 +222,12 @@
213 222
214 223 /**
215 224 * Filter the arguments passed to Charitable_Donor_Query.
216 225 *
217 - * @since 1.0.0
226 + * @since 1.0.0
218 227 *
219 - * @param array $query_args The arguments to be passed to Charitable_Donor_Query::__construct.
220 - * @param array $args All the parsed arguments.
221 - * @return array
228 + * @param array $query_args The arguments to be passed to Charitable_Donor_Query::__construct.
229 + * @param array $args All the parsed arguments.
222 230 */
223 231 $query_args = apply_filters( 'charitable_donors_widget_donor_query_args', $query_args, $instance );
224 232
225 233 return new Charitable_Donor_Query( $query_args );