| @@ -56,9 +56,9 @@ | ||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $link = empty( $tip['link'] ) ? $tip['page'] : FrmAppHelper::admin_upgrade_link( $tip['link'], $tip['page'] ); |
| 59 | 59 | ?> |
| 60 | - <a href="<?php echo esc_url( $link ); ?>" <?php echo empty( $tip['link'] ) ? '' : 'target="_blank"'; ?> class="frm_pro_tip"> | |
| 60 | + <span class="frm_pro_tip"> | |
| 61 | 61 | <?php FrmAppHelper::icon_by_class( 'frmfont frm_lightning', array( 'aria-hidden' => 'true' ) ); ?> |
| 62 | 62 | |
| 63 | 63 | <?php if ( isset( $tip['call'] ) ) { ?> |
| 64 | 64 | <span class="frm-tip-info"> |
| @@ -63,17 +63,13 @@ | ||
| 63 | 63 | <?php if ( isset( $tip['call'] ) ) { ?> |
| 64 | 64 | <span class="frm-tip-info"> |
| 65 | 65 | <?php echo esc_html( $tip['tip'] ); ?> |
| 66 | 66 | </span> |
| 67 | - <span class="frm-tip-cta"> | |
| 68 | - <?php echo esc_html( $tip['call'] ); ?> | |
| 69 | - </span> | |
| 70 | - <?php } else { ?> | |
| 71 | - <span class="frm-tip-cta"> | |
| 72 | - <?php echo esc_html( $tip['tip'] ); ?> | |
| 73 | - </span> | |
| 74 | 67 | <?php } ?> |
| 75 | - </a> | |
| 68 | + <a href="<?php echo esc_url( $link ); ?>" <?php echo empty( $tip['link'] ) ? '' : 'target="_blank"'; ?> class="frm-tip-cta"> | |
| 69 | + <?php echo esc_html( $tip['call'] ? $tip['call'] : $tip['tip'] ); ?> | |
| 70 | + </a> | |
| 71 | + </span> | |
| 76 | 72 | <?php |
| 77 | 73 | |
| 78 | 74 | if ( 'p' === $html ) { |
| 79 | 75 | echo '</p>'; |
| @@ -408,6 +404,52 @@ | ||
| 408 | 404 | public static function get_random_tip( $tips ) { |
| 409 | 405 | $random = rand( 0, count( $tips ) - 1 ); |
| 410 | 406 | |
| 411 | 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; // Return early if the user doesn't have the required capability | |
| 432 | + } | |
| 433 | + | |
| 434 | + $defaults = array( | |
| 435 | + 'title' => '', | |
| 436 | + 'description' => '', | |
| 437 | + 'link_text' => '', | |
| 438 | + 'link_url' => '#', | |
| 439 | + 'class' => '', | |
| 440 | + 'id' => '', | |
| 441 | + ); | |
| 442 | + | |
| 443 | + $args = wp_parse_args( $args, $defaults ); | |
| 444 | + | |
| 445 | + $attributes = array( | |
| 446 | + 'class' => trim( 'frm-cta frm-flex frm-p-sm ' . $args['class'] ), | |
| 447 | + ); | |
| 448 | + | |
| 449 | + if ( $args['id'] ) { | |
| 450 | + $attributes['id'] = $args['id']; | |
| 451 | + } | |
| 452 | + | |
| 453 | + require FrmAppHelper::plugin_path() . '/classes/views/shared/admin-cta.php'; | |
| 412 | 454 | } |
| 413 | 455 | } |