PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.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 All 257 releases
← All changes | includes/admin/shortcodes/abstract-shortcode-generator.php +84 -31 2.3.1 → 4.18.0 View file →
@@ -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
@@ -324,24 +371,27 @@
324 371 * @since 1.0
325 372 */
326 373 protected function generate_textbox( $field ) {
327 374
328 - $textbox = shortcode_atts( array(
329 - 'label' => '',
330 - 'maxLength' => '',
331 - 'minHeight' => '',
332 - 'minWidth' => '',
333 - 'multiline' => false,
334 - 'name' => false,
335 - 'tooltip' => '',
336 - 'type' => '',
337 - 'value' => '',
338 - 'classes' => '',
339 - 'placeholder' => ''
340 - ), $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 + );
341 391
342 392 // Remove empty placeholder.
343 - if( empty( $textbox['placeholder'] ) ) {
393 + if ( empty( $textbox['placeholder'] ) ) {
344 394 unset( $textbox['placeholder'] );
345 395 }
346 396
347 397 if ( $this->validate( $field ) ) {
@@ -375,14 +425,17 @@
375 425 * @since 1.0
376 426 */
377 427 protected function validate( $field ) {
378 428
379 - extract( shortcode_atts(
429 + extract(
430 + shortcode_atts(
380 431 array(
381 432 'name' => false,
382 433 'required' => false,
383 434 'label' => '',
384 - ), $field )
435 + ),
436 + $field
437 + )
385 438 );
386 439
387 440 if ( $name ) {
388 441
@@ -403,12 +456,12 @@
403 456 if ( isset( $required['alert'] ) ) {
404 457
405 458 $alert = $required['alert'];
406 459
407 - } else if ( ! empty( $label ) ) {
460 + } elseif ( ! empty( $label ) ) {
408 461
409 462 $alert = sprintf(
410 - /* translators: %s: option label */
463 + /* translators: %s: option label */
411 464 esc_html__( 'The "%s" option is required.', 'give' ),
412 465 str_replace( ':', '', $label )
413 466 );
414 467 }