| @@ -18,9 +18,9 @@ | ||
| 18 | 18 | |
| 19 | 19 | $tips = self::$callback(); |
| 20 | 20 | $tip = self::get_random_tip( $tips ); |
| 21 | 21 | |
| 22 | - self::show_tip( $tip ); | |
| 22 | + self::show_tip( $tip, $html ); | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Shows tip. |
| @@ -26,10 +26,10 @@ | ||
| 26 | 26 | * Shows tip. |
| 27 | 27 | * |
| 28 | 28 | * @since 6.0 |
| 29 | 29 | * |
| 30 | - * @param array $tip { | |
| 31 | - * Tip args | |
| 30 | + * @param array $tip { | |
| 31 | + * Tip args. | |
| 32 | 32 | * |
| 33 | 33 | * @type array $link Tip link data. See the first parameter of {@see FrmAppHelper::admin_upgrade_link()} for more details. |
| 34 | 34 | * @type string $page The based link of the tip. If this is empty, `https://formidableforms.com/lite-upgrade/` will |
| 35 | 35 | * be used. Otherwise, `https://formidableforms.com/{$page}` will be used. |
| @@ -40,36 +40,35 @@ | ||
| 40 | 40 | * |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | 43 | public static function show_tip( $tip, $html = '' ) { |
| 44 | - if ( ! isset( $tip['page'] ) ) { | |
| 45 | - $tip['page'] = ''; | |
| 46 | - } | |
| 44 | + $defaults = array( | |
| 45 | + 'page' => '', | |
| 46 | + 'class' => 'frm-mt-0', | |
| 47 | + ); | |
| 48 | + $tip = array_merge( $defaults, $tip ); | |
| 49 | + | |
| 47 | 50 | if ( isset( $tip['link'] ) && ! isset( $tip['link']['medium'] ) ) { |
| 48 | 51 | $tip['link']['medium'] = 'tip'; |
| 49 | 52 | } |
| 50 | 53 | |
| 51 | 54 | if ( 'p' === $html ) { |
| 52 | - echo '<p class="frmcenter frm-mt-0">'; | |
| 55 | + echo '<p class="frmcenter ' . esc_attr( $tip['class'] ) . '">'; | |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | 58 | $link = empty( $tip['link'] ) ? $tip['page'] : FrmAppHelper::admin_upgrade_link( $tip['link'], $tip['page'] ); |
| 56 | 59 | ?> |
| 57 | - <a href="<?php echo esc_url( $link ); ?>" <?php echo empty( $tip['link'] ) ? '' : 'target="_blank"'; ?> class="frm_pro_tip"> | |
| 58 | - <?php FrmAppHelper::icon_by_class( 'frmfont frm_lightning', array( 'aria-hidden' => 'true' ) ); ?> | |
| 60 | + <a href="<?php echo esc_url( $link ); ?>" <?php echo empty( $tip['link'] ) ? '' : 'target="_blank"'; ?> class="frm_pro_tip frm-gradient"> | |
| 61 | + <span class="frm-tip-badge"><?php esc_html_e( 'PRO TIP', 'formidable' ); ?></span> | |
| 59 | 62 | |
| 60 | 63 | <?php if ( isset( $tip['call'] ) ) { ?> |
| 61 | 64 | <span class="frm-tip-info"> |
| 62 | 65 | <?php echo esc_html( $tip['tip'] ); ?> |
| 63 | 66 | </span> |
| 64 | - <span class="frm-tip-cta"> | |
| 65 | - <?php echo esc_html( $tip['call'] ); ?> | |
| 66 | - </span> | |
| 67 | - <?php } else { ?> | |
| 68 | - <span class="frm-tip-cta"> | |
| 69 | - <?php echo esc_html( $tip['tip'] ); ?> | |
| 70 | - </span> | |
| 71 | 67 | <?php } ?> |
| 68 | + <span class="frm-tip-cta"> | |
| 69 | + <?php echo esc_html( $tip['call'] ? $tip['call'] : $tip['tip'] ); ?> | |
| 70 | + </span> | |
| 72 | 71 | </a> |
| 73 | 72 | <?php |
| 74 | 73 | |
| 75 | 74 | if ( 'p' === $html ) { |
| @@ -77,8 +76,19 @@ | ||
| 77 | 76 | } |
| 78 | 77 | } |
| 79 | 78 | |
| 80 | 79 | /** |
| 80 | + * Use the correct label for the license. | |
| 81 | + * | |
| 82 | + * @since 6.5.1 | |
| 83 | + * | |
| 84 | + * @return string | |
| 85 | + */ | |
| 86 | + private static function cta_label() { | |
| 87 | + return FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro.', 'formidable' ); | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 81 | 91 | * @return array |
| 82 | 92 | */ |
| 83 | 93 | public static function get_builder_tip() { |
| 84 | 94 | $tips = array( |
| @@ -87,9 +97,9 @@ | ||
| 87 | 97 | 'content' => 'conditional-logic', |
| 88 | 98 | 'param' => 'conditional-logic-wordpress-forms', |
| 89 | 99 | ), |
| 90 | 100 | 'tip' => __( 'Use conditional logic to shorten your forms and increase conversions.', 'formidable' ), |
| 91 | - 'call' => __( 'Upgrade to Pro.', 'formidable' ), | |
| 101 | + 'call' => self::cta_label(), | |
| 92 | 102 | ), |
| 93 | 103 | array( |
| 94 | 104 | 'link' => array( |
| 95 | 105 | 'content' => 'confirmation-fields', |
| @@ -103,9 +113,9 @@ | ||
| 103 | 113 | 'content' => 'page-breaks', |
| 104 | 114 | 'param' => 'wordpress-multi-page-forms', |
| 105 | 115 | ), |
| 106 | 116 | 'tip' => __( 'Use page breaks for easier forms.', 'formidable' ), |
| 107 | - 'call' => __( 'Upgrade to Pro.', 'formidable' ), | |
| 117 | + 'call' => self::cta_label(), | |
| 108 | 118 | ), |
| 109 | 119 | array( |
| 110 | 120 | 'link' => array( |
| 111 | 121 | 'content' => 'file-uploads', |
| @@ -119,9 +129,9 @@ | ||
| 119 | 129 | 'content' => 'calculations', |
| 120 | 130 | 'param' => 'field-calculations-wordpress-form', |
| 121 | 131 | ), |
| 122 | 132 | 'tip' => __( 'Need to calculate a total?', 'formidable' ), |
| 123 | - 'call' => __( 'Upgrade to Pro.', 'formidable' ), | |
| 133 | + 'call' => self::cta_label(), | |
| 124 | 134 | ), |
| 125 | 135 | array( |
| 126 | 136 | 'link' => array( |
| 127 | 137 | 'content' => 'prefill-fields', |
| @@ -187,9 +197,9 @@ | ||
| 187 | 197 | 'content' => 'create-posts', |
| 188 | 198 | 'param' => 'create-posts-pages-wordpress-forms', |
| 189 | 199 | ), |
| 190 | 200 | 'tip' => __( 'Create blog posts or pages from the front-end.', 'formidable' ), |
| 191 | - 'call' => __( 'Upgrade to Pro.', 'formidable' ), | |
| 201 | + 'call' => self::cta_label(), | |
| 192 | 202 | ), |
| 193 | 203 | array( |
| 194 | 204 | 'link' => array( |
| 195 | 205 | 'content' => 'user-submit', |
| @@ -195,9 +205,9 @@ | ||
| 195 | 205 | 'content' => 'user-submit', |
| 196 | 206 | 'param' => 'create-posts-pages-wordpress-forms', |
| 197 | 207 | ), |
| 198 | 208 | 'tip' => __( 'Let your users submit posts on the front-end.', 'formidable' ), |
| 199 | - 'call' => __( 'Upgrade to Pro.', 'formidable' ), | |
| 209 | + 'call' => self::cta_label(), | |
| 200 | 210 | ), |
| 201 | 211 | array( |
| 202 | 212 | 'link' => array( |
| 203 | 213 | 'content' => 'mailchimp', |
| @@ -285,9 +295,9 @@ | ||
| 285 | 295 | 'content' => 'style', |
| 286 | 296 | 'param' => 'bg-image-style-settings', |
| 287 | 297 | ), |
| 288 | 298 | 'tip' => __( 'Want to add a background image?', 'formidable' ), |
| 289 | - 'call' => __( 'Upgrade to Pro.', 'formidable' ), | |
| 299 | + 'call' => self::cta_label(), | |
| 290 | 300 | ), |
| 291 | 301 | array( |
| 292 | 302 | 'link' => array( |
| 293 | 303 | 'content' => 'style', |
| @@ -293,9 +303,9 @@ | ||
| 293 | 303 | 'content' => 'style', |
| 294 | 304 | 'param' => 'duplicate-style', |
| 295 | 305 | ), |
| 296 | 306 | 'tip' => __( 'Want to duplicate a style?', 'formidable' ), |
| 297 | - 'call' => __( 'Upgrade to Pro.', 'formidable' ), | |
| 307 | + 'call' => self::cta_label(), | |
| 298 | 308 | ), |
| 299 | 309 | ); |
| 300 | 310 | |
| 301 | 311 | return $tips; |
| @@ -319,9 +329,9 @@ | ||
| 319 | 329 | 'content' => 'entries-search', |
| 320 | 330 | 'param' => 'form-entry-management-wordpress', |
| 321 | 331 | ), |
| 322 | 332 | 'tip' => __( 'Want to search submitted entries?', 'formidable' ), |
| 323 | - 'call' => __( 'Upgrade to Pro.', 'formidable' ), | |
| 333 | + 'call' => self::cta_label(), | |
| 324 | 334 | ), |
| 325 | 335 | array( |
| 326 | 336 | 'link' => array( |
| 327 | 337 | 'content' => 'views', |
| @@ -346,9 +356,9 @@ | ||
| 346 | 356 | 'content' => 'import', |
| 347 | 357 | 'param' => 'importing-exporting-wordpress-forms', |
| 348 | 358 | ), |
| 349 | 359 | 'tip' => __( 'Want to import entries into your forms?', 'formidable' ), |
| 350 | - 'call' => __( 'Upgrade to Pro.', 'formidable' ), | |
| 360 | + 'call' => self::cta_label(), | |
| 351 | 361 | ), |
| 352 | 362 | ); |
| 353 | 363 | |
| 354 | 364 | return $tips; |
| @@ -394,6 +404,54 @@ | ||
| 394 | 404 | public static function get_random_tip( $tips ) { |
| 395 | 405 | $random = rand( 0, count( $tips ) - 1 ); |
| 396 | 406 | |
| 397 | 407 | return $tips[ $random ]; |
| 408 | + } | |
| 409 | + | |
| 410 | + /** | |
| 411 | + * Displays a call-to-action section in the admin area. | |
| 412 | + * | |
| 413 | + * @since 6.7 | |
| 414 | + * | |
| 415 | + * @param array $args { | |
| 416 | + * An array of arguments to configure the call-to-action section. | |
| 417 | + * | |
| 418 | + * @type string $title The title of the section. | |
| 419 | + * @type string $description The description of the section. | |
| 420 | + * @type string $link_text The text for the link. | |
| 421 | + * @type string $link_url The URL for the link. | |
| 422 | + * @type string $role The required user role to view the section. Default 'administrator'. | |
| 423 | + * } | |
| 424 | + * | |
| 425 | + * @return void | |
| 426 | + */ | |
| 427 | + public static function show_admin_cta( $args ) { | |
| 428 | + $role = ! empty( $args['role'] ) ? $args['role'] : 'administrator'; | |
| 429 | + | |
| 430 | + if ( ! current_user_can( $role ) ) { | |
| 431 | + // Return early if the user doesn't have the required capability. | |
| 432 | + return; | |
| 433 | + } | |
| 434 | + | |
| 435 | + $defaults = array( | |
| 436 | + 'title' => '', | |
| 437 | + 'description' => '', | |
| 438 | + 'link_text' => '', | |
| 439 | + 'link_url' => '#', | |
| 440 | + 'class' => '', | |
| 441 | + 'id' => '', | |
| 442 | + 'target' => '_blank', | |
| 443 | + ); | |
| 444 | + | |
| 445 | + $args = wp_parse_args( $args, $defaults ); | |
| 446 | + | |
| 447 | + $attributes = array( | |
| 448 | + 'class' => trim( 'frm-cta frm-flex frm-p-sm ' . $args['class'] ), | |
| 449 | + ); | |
| 450 | + | |
| 451 | + if ( $args['id'] ) { | |
| 452 | + $attributes['id'] = $args['id']; | |
| 453 | + } | |
| 454 | + | |
| 455 | + require FrmAppHelper::plugin_path() . '/classes/views/shared/admin-cta.php'; | |
| 398 | 456 | } |
| 399 | 457 | } |