Completed
Push — master ( 542ae8...a61647 )
by Jamie
03:33
created

FrmTipsHelper::get_form_action_tip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 61
Code Lines 47

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 61
rs 9.5147
cc 1
eloc 47
nc 1
nop 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
class FrmTipsHelper {
4
5
	public static function pro_tip( $callback, $html = '' ) {
6
		if ( FrmAppHelper::pro_is_installed() ) {
7
			return;
8
		}
9
10
		$tips = self::$callback();
11
		$tip = self::get_random_tip( $tips );
12
13
		if ( $html == 'p' ) {
14
			echo '<p>';
15
		}
16
		?>
17
		<a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( $tip['link'] ) ) ?>" target="_blank" class="frm_pro_tip">
18
			<span><i class="frm_icon_font frm_check1_icon"></i>  Pro Tip:</span>
19
			<?php echo $tip['tip'] ?>
0 ignored issues
show
introduced by
Expected next thing to be a escaping function, not '$tip'
Loading history...
20
			<?php if ( isset( $tip['call'] ) ) { ?>
21
				<span><?php echo $tip['call'] ?></span>
0 ignored issues
show
introduced by
Expected next thing to be a escaping function, not '$tip'
Loading history...
22
			<?php } ?>
23
		</a>
24
		<?php
25
		if ( $html == 'p' ) {
26
			echo '</p>';
27
		}
28
	}
29
30
	public static function get_builder_tip() {
31
		$tips = array(
32
			array(
33
				'link' => 'https://formidablepro.com/section-tip',
34
				'tip'  => __( 'Long forms can still be beautiful with sections.', 'formidable' ),
35
				'call' => __( 'Upgrade to Pro.', 'formidable' ),
36
			),
37
			array(
38
				'link' => 'https://formidablepro.com/conditional-logic-tip',
39
				'tip'  => __( 'Use conditional logic to shorten your forms and increase conversions.', 'formidable' ),
40
				'call' => __( 'Upgrade to Pro.', 'formidable' ),
41
			),
42
			array(
43
				'link' => 'https://formidablepro.com/page-break-tip',
44
				'tip'  => __( 'Stop intimidating users with long forms.', 'formidable' ),
45
				'call' => __( 'Use page breaks.', 'formidable' ),
46
			),
47
			array(
48
				'link' => 'https://formidablepro.com/file-upload-tip',
49
				'tip'  => __( 'Cut down on back-and-forth with clients.', 'formidable' ),
50
				'call' => __( 'Allow file uploads in your form.', 'formidable' ),
51
			),
52
			array(
53
				'link' => 'https://formidablepro.com/calculations-total-tip',
54
				'tip'  => __( 'Need to calculate a total?', 'formidable' ),
55
				'call' => __( 'Upgrade to Pro.', 'formidable' ),
56
			),
57
			array(
58
				'link' => 'https://formidablepro.com/prefill-fields',
59
				'tip'  => __( 'Save time.', 'formidable' ),
60
				'call' => __( 'Prefill fields with user info.', 'formidable' ),
61
			),
62
		);
63
		$tips = array_merge( $tips, self::get_form_settings_tip(), self::get_form_action_tip(), self::get_entries_tip() );
64
65
		return $tips;
66
	}
67
68
	public static function get_form_settings_tip() {
69
		$tips = array(
70
			array(
71
				'link' => 'https://formidablepro.com/front-end-editing-tip',
72
				'tip'  => __( 'A site with dynamic, user-generated content is within reach.', 'formidable' ),
73
				'call' => __( 'Add front-end editing.', 'formidable' ),
74
			),
75
			array(
76
				'link' => 'https://formidablepro.com/front-end-editing-b-tip',
77
				'tip'  => __( 'A site with dynamic, user-generated content is within reach.', 'formidable' ),
78
				'call' => __( 'Add front-end editing.', 'formidable' ),
79
			),
80
			array(
81
				'link' => 'https://formidablepro.com/save-drafts-tip',
82
				'tip'  => __( 'Have a long form that takes time to complete?', 'formidable' ),
83
				'call' => __( 'Let logged-in users save a draft and return later.', 'formidable' ),
84
			),
85
		);
86
		return $tips;
87
	}
88
89
	public static function get_form_action_tip() {
90
		$tips = array(
91
			array(
92
				'link' => 'https://formidablepro.com/email-routing-tip',
93
				'tip'  => __( 'Save time by sending the email to the right person automatically.', 'formidable' ),
94
				'call' => __( 'Add email routing.', 'formidable' ),
95
			),
96
			array(
97
				'link' => 'https://formidablepro.com/create-posts-tip',
98
				'tip'  => __( 'Create blog posts or pages from the front-end.', 'formidable' ),
99
				'call' => __( 'Upgrade to Pro.', 'formidable' ),
100
			),
101
			array(
102
				'link' => 'https://formidablepro.com/front-end-posting-tip',
103
				'tip'  => __( 'Make front-end posting easy.', 'formidable' ),
104
				'call' => __( 'Upgrade to Pro.', 'formidable' ),
105
			),
106
			array(
107
				'link' => 'https://formidablepro.com/mailchimp-tip',
108
				'tip'  => __( 'Grow your business with automated email follow-up.', 'formidable' ),
109
				'call' => __( 'Send leads straight to MailChimp.', 'formidable' ),
110
			),
111
			array(
112
				'link' => 'https://formidablepro.com/paypal-tip',
113
				'tip'  => __( 'Save hours and increase revenue by collecting payments with every submission.', 'formidable' ),
114
				'call' => __( 'Use PayPal with this form.', 'formidable' ),
115
			),
116
			array(
117
				'link' => 'https://formidablepro.com/paypal-increase-revenue-tip',
118
				'tip'  => __( 'Increase revenue.', 'formidable' ),
119
				'call' => __( 'Use PayPal with this form.', 'formidable' ),
120
			),
121
			array(
122
				'link' => 'https://formidablepro.com/paypal-save-time-tip',
123
				'tip'  => __( 'Get paid more quickly.', 'formidable' ),
124
				'call' => __( 'Use Paypal with this form.', 'formidable' ),
125
			),
126
			array(
127
				'link' => 'https://formidablepro.com/registration-tip',
128
				'tip'  => __( 'Boost your site membership.', 'formidable' ),
129
				'call' => __( 'Automatically create user accounts.', 'formidable' ),
130
			),
131
			array(
132
				'link' => 'https://formidablepro.com/registration-profile-editing-tip',
133
				'tip'  => __( 'Make front-end profile editing possible.', 'formidable' ),
134
				'call' => __( 'Add user registration.', 'formidable' ),
135
			),
136
			array(
137
				'link' => 'https://formidablepro.com/twilio-tip',
138
				'tip'  => __( 'Want a text when this form is submitted or when a payment is received?', 'formidable' ),
139
				'call' => __( 'Use Twilio with this form.', 'formidable' ),
140
			),
141
			array(
142
				'link' => 'https://formidablepro.com/twilio-send-tip',
143
				'tip'  => __( 'Send a text when this form is submitted.', 'formidable' ),
144
				'call' => __( 'Get Twilio.', 'formidable' ),
145
			),
146
		);
147
148
		return $tips;
149
	}
150
151 View Code Duplication
	public static function get_styling_tip() {
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...
152
		$tips = array(
153
			array(
154
				'link' => 'https://formidablepro.com/visual-styling-tip',
155
				'tip'  => __( 'Make your sidebar or footer form stand out.', 'formidable' ),
156
				'call' => __( 'Use multiple style templates.', 'formidable' ),
157
			),
158
		);
159
		return $tips;
160
	}
161
162
	public static function get_entries_tip() {
163
		$tips = array(
164
			array(
165
				'link' => 'https://formidablepro.com/manage-entries-tip',
166
				'tip'  => __( 'Want to edit or delete form submissions?', 'formidable' ),
167
				'call' => __( 'Add entry management.', 'formidable' ),
168
			),
169
			array(
170
				'link' => 'https://formidablepro.com/search-entries-tip',
171
				'tip'  => __( 'Want to search submitted entries?', 'formidable' ),
172
				'call' => __( 'Upgrade to Pro.', 'formidable' ),
173
			),
174
		);
175
		$tips = array_merge( $tips, self::get_import_tip() );
176
		return $tips;
177
	}
178
179 View Code Duplication
	public static function get_import_tip() {
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...
180
		$tips = array(
181
			array(
182
				'link' => 'https://formidablepro.com/import-entries-tip/',
183
				'tip'  => __( 'Want to import entries into your forms?', 'formidable' ),
184
				'call' => __( 'Upgrade to Pro.', 'formidable' ),
185
			),
186
		);
187
		return $tips;
188
	}
189
190
	public static function get_banner_tip() {
191
		$tips = array(
192
			array(
193
				'link' => 'https://formidablepro.com/',
194
				'tip'  => __( 'Looking for more options to get professional results?', 'formidable' ),
195
				'call' => __( 'Take your forms to the next level.', 'formidable' ),
196
			),
197
			array(
198
				'link' => 'https://formidablepro.com/',
199
				'tip'  => __( 'Increase conversions in your long forms.', 'formidable' ),
200
				'call' => __( 'Add conditional logic, page breaks, and section headings.', 'formidable' ),
201
			),
202
			array(
203
				'link' => 'https://formidablepro.com/',
204
				'tip'  => __( 'Automate your business and increase revenue.', 'formidable' ),
205
				'call' => __( 'Collect instant payments, and send leads to MailChimp.', 'formidable' ),
206
			),
207
		);
208
		$random = rand( 0, count( $tips ) - 1 );
209
		$tip = $tips[ $random ];
210
		$tip['num'] = $random;
211
		return $tip;
212
	}
213
214
	public static function get_random_tip( $tips ) {
215
		$random = rand( 0, count( $tips ) - 1 );
216
		return $tips[ $random ];
217
	}
218
}
219