Test Failed
Push — release/2.1.2 ( 904adf )
by Ravinder
05:45
created

Give_Shortcode_Donation_Grid::define_fields()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 76
Code Lines 60

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 60
nc 1
nop 0
dl 0
loc 76
rs 8.9667
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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