| @@ -35,8 +35,9 @@ | ||
| 35 | 35 | * be used. Otherwise, `https://formidableforms.com/{$page}` will be used. |
| 36 | 36 | * @type string $tip Tip text. |
| 37 | 37 | * @type string $call Call to action text. |
| 38 | 38 | * } |
| 39 | + * | |
| 39 | 40 | * @param string $html |
| 40 | 41 | * |
| 41 | 42 | * @return void |
| 42 | 43 | */ |
| @@ -46,10 +47,10 @@ | ||
| 46 | 47 | 'class' => 'frm-mt-0', |
| 47 | 48 | ); |
| 48 | 49 | $tip = array_merge( $defaults, $tip ); |
| 49 | 50 | |
| 50 | - if ( isset( $tip['link'] ) && ! isset( $tip['link']['medium'] ) ) { | |
| 51 | - $tip['link']['medium'] = 'tip'; | |
| 51 | + if ( isset( $tip['link'] ) && ! isset( $tip['link']['medium'] ) && ! isset( $tip['link']['campaign'] ) ) { | |
| 52 | + $tip['link']['campaign'] = 'tip'; | |
| 52 | 53 | } |
| 53 | 54 | |
| 54 | 55 | if ( 'p' === $html ) { |
| 55 | 56 | echo '<p class="frmcenter ' . esc_attr( $tip['class'] ) . '">'; |
| @@ -55,10 +56,11 @@ | ||
| 55 | 56 | echo '<p class="frmcenter ' . esc_attr( $tip['class'] ) . '">'; |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | 59 | $link = self::get_tip_link( $tip ); |
| 60 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 59 | 61 | ?> |
| 60 | - <a href="<?php echo esc_url( $link ); ?>" <?php echo empty( $tip['link'] ) ? '' : 'target="_blank"'; ?> class="frm_pro_tip frm-gradient"> | |
| 62 | + <a href="<?php echo esc_url( $link ); ?>" <?php echo ! empty( $tip['link'] ) ? 'target="_blank"' : ''; ?> class="frm_pro_tip frm-gradient"> | |
| 61 | 63 | <span class="frm-tip-badge"><?php esc_html_e( 'PRO TIP', 'formidable' ); ?></span> |
| 62 | 64 | |
| 63 | 65 | <?php if ( isset( $tip['call'] ) ) { ?> |
| 64 | 66 | <span class="frm-tip-info"> |
| @@ -69,8 +71,9 @@ | ||
| 69 | 71 | <?php echo esc_html( $tip['call'] ? $tip['call'] : $tip['tip'] ); ?> |
| 70 | 72 | </span> |
| 71 | 73 | </a> |
| 72 | 74 | <?php |
| 75 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 73 | 76 | |
| 74 | 77 | if ( 'p' === $html ) { |
| 75 | 78 | echo '</p>'; |
| 76 | 79 | } |
| @@ -79,8 +82,9 @@ | ||
| 79 | 82 | /** |
| 80 | 83 | * @since 6.21 |
| 81 | 84 | * |
| 82 | 85 | * @param array $tip |
| 86 | + * | |
| 83 | 87 | * @return string |
| 84 | 88 | */ |
| 85 | 89 | private static function get_tip_link( $tip ) { |
| 86 | 90 | if ( empty( $tip['tip'] ) ) { |
| @@ -87,12 +91,14 @@ | ||
| 87 | 91 | return $tip['page']; |
| 88 | 92 | } |
| 89 | 93 | |
| 90 | 94 | $cta_link = FrmSalesApi::get_best_sale_value( 'pro_tip_cta_link' ); |
| 95 | + | |
| 91 | 96 | if ( $cta_link ) { |
| 92 | 97 | if ( is_array( $tip['link'] ) ) { |
| 93 | - $cta_link = FrmAppHelper::maybe_add_missing_utm( $cta_link, $tip['link'] ); | |
| 98 | + return FrmAppHelper::maybe_add_missing_utm( $cta_link, $tip['link'] ); | |
| 94 | 99 | } |
| 100 | + | |
| 95 | 101 | return $cta_link; |
| 96 | 102 | } |
| 97 | 103 | |
| 98 | 104 | return FrmAppHelper::admin_upgrade_link( $tip['link'], $tip['page'] ); |
| @@ -106,11 +112,13 @@ | ||
| 106 | 112 | * @return string |
| 107 | 113 | */ |
| 108 | 114 | private static function cta_label() { |
| 109 | 115 | $cta_text = FrmSalesApi::get_best_sale_value( 'pro_tip_cta_text' ); |
| 116 | + | |
| 110 | 117 | if ( $cta_text ) { |
| 111 | 118 | return $cta_text; |
| 112 | 119 | } |
| 120 | + | |
| 113 | 121 | return FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro.', 'formidable' ); |
| 114 | 122 | } |
| 115 | 123 | |
| 116 | 124 | /** |
| @@ -116,9 +124,9 @@ | ||
| 116 | 124 | /** |
| 117 | 125 | * @return array |
| 118 | 126 | */ |
| 119 | 127 | public static function get_builder_tip() { |
| 120 | - $tips = array( | |
| 128 | + return array( | |
| 121 | 129 | array( |
| 122 | 130 | 'link' => array( |
| 123 | 131 | 'content' => 'conditional-logic', |
| 124 | 132 | 'param' => 'conditional-logic-wordpress-forms', |
| @@ -151,16 +159,8 @@ | ||
| 151 | 159 | 'call' => self::cta_label(), |
| 152 | 160 | ), |
| 153 | 161 | array( |
| 154 | 162 | 'link' => array( |
| 155 | - 'content' => 'calculations', | |
| 156 | - 'param' => 'field-calculations-wordpress-form', | |
| 157 | - ), | |
| 158 | - 'tip' => __( 'Need to calculate a total?', 'formidable' ), | |
| 159 | - 'call' => self::cta_label(), | |
| 160 | - ), | |
| 161 | - array( | |
| 162 | - 'link' => array( | |
| 163 | 163 | 'content' => 'prefill-fields', |
| 164 | 164 | 'param' => 'auto-fill-forms', |
| 165 | 165 | ), |
| 166 | 166 | 'tip' => __( 'Save time with autofill forms.', 'formidable' ), |
| @@ -166,10 +166,8 @@ | ||
| 166 | 166 | 'tip' => __( 'Save time with autofill forms.', 'formidable' ), |
| 167 | 167 | 'call' => self::cta_label(), |
| 168 | 168 | ), |
| 169 | 169 | ); |
| 170 | - | |
| 171 | - return $tips; | |
| 172 | 170 | } |
| 173 | 171 | |
| 174 | 172 | /** |
| 175 | 173 | * @return array |
| @@ -174,9 +172,9 @@ | ||
| 174 | 172 | /** |
| 175 | 173 | * @return array |
| 176 | 174 | */ |
| 177 | 175 | public static function get_form_settings_tip() { |
| 178 | - $tips = array( | |
| 176 | + return array( | |
| 179 | 177 | array( |
| 180 | 178 | 'link' => array( |
| 181 | 179 | 'content' => 'front-edit-b', |
| 182 | 180 | 'param' => 'wordpress-front-end-editing', |
| @@ -200,10 +198,8 @@ | ||
| 200 | 198 | 'tip' => __( 'Limit form access with built-in scheduling.', 'formidable' ), |
| 201 | 199 | 'call' => self::cta_label(), |
| 202 | 200 | ), |
| 203 | 201 | ); |
| 204 | - | |
| 205 | - return $tips; | |
| 206 | 202 | } |
| 207 | 203 | |
| 208 | 204 | /** |
| 209 | 205 | * @return array |
| @@ -208,9 +204,9 @@ | ||
| 208 | 204 | /** |
| 209 | 205 | * @return array |
| 210 | 206 | */ |
| 211 | 207 | public static function get_form_action_tip() { |
| 212 | - $tips = array( | |
| 208 | + return array( | |
| 213 | 209 | array( |
| 214 | 210 | 'link' => array( |
| 215 | 211 | 'content' => 'email-routing', |
| 216 | 212 | 'param' => 'virtually-unlimited-emails', |
| @@ -243,24 +239,8 @@ | ||
| 243 | 239 | 'call' => self::cta_label(), |
| 244 | 240 | ), |
| 245 | 241 | array( |
| 246 | 242 | 'link' => array( |
| 247 | - 'content' => 'paypal-revenue', | |
| 248 | - 'page' => 'paypal-increase-revenue-tip', | |
| 249 | - ), | |
| 250 | - 'tip' => __( 'Accept PayPal payments and grow your sales.', 'formidable' ), | |
| 251 | - 'call' => self::cta_label(), | |
| 252 | - ), | |
| 253 | - array( | |
| 254 | - 'link' => array( | |
| 255 | - 'content' => 'paypal-fast', | |
| 256 | - 'page' => 'paypal-save-time-tip', | |
| 257 | - ), | |
| 258 | - 'tip' => __( 'Accept payments now with PayPal integration.', 'formidable' ), | |
| 259 | - 'call' => self::cta_label(), | |
| 260 | - ), | |
| 261 | - array( | |
| 262 | - 'link' => array( | |
| 263 | 243 | 'content' => 'registration', |
| 264 | 244 | 'page' => 'registration-tip', |
| 265 | 245 | ), |
| 266 | 246 | 'tip' => __( 'Automatically create user accounts.', 'formidable' ), |
| @@ -298,10 +278,8 @@ | ||
| 298 | 278 | 'tip' => __( 'Fill Advanced Custom Fields automatically with form entries.', 'formidable' ), |
| 299 | 279 | 'call' => self::cta_label(), |
| 300 | 280 | ), |
| 301 | 281 | ); |
| 302 | - | |
| 303 | - return $tips; | |
| 304 | 282 | } |
| 305 | 283 | |
| 306 | 284 | /** |
| 307 | 285 | * @return array |
| @@ -306,9 +284,9 @@ | ||
| 306 | 284 | /** |
| 307 | 285 | * @return array |
| 308 | 286 | */ |
| 309 | 287 | public static function get_styling_tip() { |
| 310 | - $tips = array( | |
| 288 | + return array( | |
| 311 | 289 | array( |
| 312 | 290 | 'link' => array( |
| 313 | 291 | 'content' => 'style', |
| 314 | 292 | 'param' => 'wordpress-visual-form-styler', |
| @@ -332,10 +310,8 @@ | ||
| 332 | 310 | 'tip' => __( 'Want to duplicate a style?', 'formidable' ), |
| 333 | 311 | 'call' => self::cta_label(), |
| 334 | 312 | ), |
| 335 | 313 | ); |
| 336 | - | |
| 337 | - return $tips; | |
| 338 | 314 | } |
| 339 | 315 | |
| 340 | 316 | /** |
| 341 | 317 | * @return array |
| @@ -366,11 +342,10 @@ | ||
| 366 | 342 | 'tip' => __( 'Turn entries into dynamic content — no code needed.', 'formidable' ), |
| 367 | 343 | 'call' => self::cta_label(), |
| 368 | 344 | ), |
| 369 | 345 | ); |
| 370 | - $tips = array_merge( $tips, self::get_import_tip() ); | |
| 371 | 346 | |
| 372 | - return $tips; | |
| 347 | + return array_merge( $tips, self::get_import_tip() ); | |
| 373 | 348 | } |
| 374 | 349 | |
| 375 | 350 | /** |
| 376 | 351 | * @return array |
| @@ -375,9 +350,9 @@ | ||
| 375 | 350 | /** |
| 376 | 351 | * @return array |
| 377 | 352 | */ |
| 378 | 353 | public static function get_import_tip() { |
| 379 | - $tips = array( | |
| 354 | + return array( | |
| 380 | 355 | array( |
| 381 | 356 | 'link' => array( |
| 382 | 357 | 'content' => 'import', |
| 383 | 358 | 'param' => 'importing-exporting-wordpress-forms', |
| @@ -385,15 +360,23 @@ | ||
| 385 | 360 | 'tip' => __( 'Want to import entries into your forms?', 'formidable' ), |
| 386 | 361 | 'call' => self::cta_label(), |
| 387 | 362 | ), |
| 388 | 363 | ); |
| 389 | - | |
| 390 | - return $tips; | |
| 391 | 364 | } |
| 392 | 365 | |
| 366 | + /** | |
| 367 | + * @param array $tips | |
| 368 | + * | |
| 369 | + * @return array | |
| 370 | + */ | |
| 393 | 371 | public static function get_random_tip( $tips ) { |
| 394 | - $random = random_int( 0, count( $tips ) - 1 ); | |
| 372 | + $count = count( $tips ); | |
| 395 | 373 | |
| 374 | + if ( $count === 0 ) { | |
| 375 | + return array(); | |
| 376 | + } | |
| 377 | + | |
| 378 | + $random = random_int( 0, $count - 1 ); | |
| 396 | 379 | return $tips[ $random ]; |
| 397 | 380 | } |
| 398 | 381 | |
| 399 | 382 | /** |