PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 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 All 256 releases
← All changes | includes/admin/shortcodes/abstract-shortcode-generator.php +87 -33 2.3.04.17.0 View file →
@@ -3,9 +3,9 @@
3 3 * Shortcode Dialog Generator abstract class
4 4 *
5 5 * @package Give/Admin
6 6 * @author Paul Ryley
7 - * @copyright Copyright (c) 2016, WordImpress
7 + * @copyright Copyright (c) 2016, GiveWP
8 8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 9 * @version 1.0
10 10 * @since 1.3
11 11 */
@@ -195,9 +195,53 @@
195 195
196 196 return $generated_fields;
197 197 }
198 198
199 +
199 200 /**
201 + * Generate a TinyMCE docs_link field
202 + *
203 + * @param $field
204 + *
205 + * @return array
206 + */
207 + protected function generate_docs_link( $field ) {
208 + // Add custom style to override mce style.
209 + $dashicon_style = 'width: 20px;
210 + height: 20px;
211 + font-size: 17px;
212 + line-height: 1;
213 + font-family: dashicons;
214 + text-decoration: inherit;
215 + font-weight: normal;
216 + font-style: normal;
217 + vertical-align: top;
218 + text-align: center;
219 + transition: color .1s ease-in 0;';
220 +
221 + $a_style = 'color: #999;
222 + text-decoration: none;
223 + font-style: italic;
224 + font-size: 13px;';
225 +
226 + $p_style = 'text-align:right;';
227 +
228 + return $this->generate_container(
229 + array(
230 + 'type' => 'container',
231 + 'html' => sprintf(
232 + '<p class="give-docs-link" style="%5$s"><a href="%4$s" style="%3$s" target="_blank">%1$s<span class="dashicons dashicons-editor-help" style="%2$s"></a></span></p>',
233 + $field['text'],
234 + $dashicon_style,
235 + $a_style,
236 + esc_url( $field['link'] ),
237 + $p_style
238 + ),
239 + )
240 + );
241 + }
242 +
243 + /**
200 244 * Generate a TinyMCE container field
201 245 *
202 246 * @param array $field
203 247 *
@@ -228,17 +272,20 @@
228 272 * @since 1.0
229 273 */
230 274 protected function generate_listbox( $field ) {
231 275
232 - $listbox = shortcode_atts( array(
233 - 'label' => '',
234 - 'minWidth' => '',
235 - 'name' => false,
236 - 'tooltip' => '',
237 - 'type' => '',
238 - 'value' => '',
239 - 'classes' => ''
240 - ), $field );
276 + $listbox = shortcode_atts(
277 + array(
278 + 'label' => '',
279 + 'minWidth' => '',
280 + 'name' => false,
281 + 'tooltip' => '',
282 + 'type' => '',
283 + 'value' => '',
284 + 'classes' => '',
285 + ),
286 + $field
287 + );
241 288
242 289 if ( $this->validate( $field ) ) {
243 290
244 291 $new_listbox = array();
@@ -246,9 +293,9 @@
246 293 foreach ( $listbox as $key => $value ) {
247 294
248 295 if ( $key == 'value' && empty( $value ) ) {
249 296 $new_listbox[ $key ] = $listbox['name'];
250 - } else if ( $value ) {
297 + } elseif ( $value ) {
251 298 $new_listbox[ $key ] = $value;
252 299 }
253 300 }
254 301
@@ -253,10 +300,10 @@
253 300 }
254 301
255 302 // do not reindex array!
256 303 $field['options'] = array(
257 - '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
258 - ) + $field['options'];
304 + '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
305 + ) + $field['options'];
259 306
260 307 foreach ( $field['options'] as $value => $text ) {
261 308 $new_listbox['values'][] = array(
262 309 'text' => $text,
@@ -288,9 +335,9 @@
288 335 'posts_per_page' => 30,
289 336 'suppress_filters' => false,
290 337 );
291 338
292 - $args = wp_parse_args( (array) $field['query_args'], $args );
339 + $args = wp_parse_args( (array) $field['query_args'], $args );
293 340
294 341 $posts = get_posts( $args );
295 342 $options = array();
296 343
@@ -297,9 +344,10 @@
297 344 if ( ! empty( $posts ) ) {
298 345 foreach ( $posts as $post ) {
299 346 $options[ absint( $post->ID ) ] = empty( $post->post_title )
300 347 ? sprintf( __( 'Untitled (#%s)', 'give' ), $post->ID )
301 - : apply_filters( 'the_title', $post->post_title );
348 + /** This filter is documented in wp-includes/post-template.php */
349 + : apply_filters( 'the_title', $post->post_title, $post->ID );
302 350 }
303 351
304 352 $field['type'] = 'listbox';
305 353 $field['options'] = $options;
@@ -323,24 +371,27 @@
323 371 * @since 1.0
324 372 */
325 373 protected function generate_textbox( $field ) {
326 374
327 - $textbox = shortcode_atts( array(
328 - 'label' => '',
329 - 'maxLength' => '',
330 - 'minHeight' => '',
331 - 'minWidth' => '',
332 - 'multiline' => false,
333 - 'name' => false,
334 - 'tooltip' => '',
335 - 'type' => '',
336 - 'value' => '',
337 - 'classes' => '',
338 - 'placeholder' => ''
339 - ), $field );
375 + $textbox = shortcode_atts(
376 + array(
377 + 'label' => '',
378 + 'maxLength' => '',
379 + 'minHeight' => '',
380 + 'minWidth' => '',
381 + 'multiline' => false,
382 + 'name' => false,
383 + 'tooltip' => '',
384 + 'type' => '',
385 + 'value' => '',
386 + 'classes' => '',
387 + 'placeholder' => '',
388 + ),
389 + $field
390 + );
340 391
341 392 // Remove empty placeholder.
342 - if( empty( $textbox['placeholder'] ) ) {
393 + if ( empty( $textbox['placeholder'] ) ) {
343 394 unset( $textbox['placeholder'] );
344 395 }
345 396
346 397 if ( $this->validate( $field ) ) {
@@ -374,14 +425,17 @@
374 425 * @since 1.0
375 426 */
376 427 protected function validate( $field ) {
377 428
378 - extract( shortcode_atts(
429 + extract(
430 + shortcode_atts(
379 431 array(
380 432 'name' => false,
381 433 'required' => false,
382 434 'label' => '',
383 - ), $field )
435 + ),
436 + $field
437 + )
384 438 );
385 439
386 440 if ( $name ) {
387 441
@@ -402,12 +456,12 @@
402 456 if ( isset( $required['alert'] ) ) {
403 457
404 458 $alert = $required['alert'];
405 459
406 - } else if ( ! empty( $label ) ) {
460 + } elseif ( ! empty( $label ) ) {
407 461
408 462 $alert = sprintf(
409 - /* translators: %s: option label */
463 + /* translators: %s: option label */
410 464 esc_html__( 'The "%s" option is required.', 'give' ),
411 465 str_replace( ':', '', $label )
412 466 );
413 467 }