← All changes
|
src/Settings/CustomOptions/TPTIntegrationOption.php
+38
-5
7.1.4
→
8.0.2
View file →
| @@ -17,8 +17,10 @@ | ||
| 17 | 17 | }, 10, 3 ); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function render( $value ) { |
| 21 | + // the description is plugin-defined text (settings arrays), read once for output | |
| 22 | + $description = (string) ( $value['desc'] ?? '' ); | |
| 21 | 23 | if ( ! isset( $value['id'] ) ) { |
| 22 | 24 | $value['id'] = ''; |
| 23 | 25 | } |
| 24 | 26 | |
| @@ -44,31 +46,61 @@ | ||
| 44 | 46 | $value['desc'] = ''; |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | 49 | $option_value = $value['value']; |
| 50 | + $is_official = ! empty( $value['official'] ); | |
| 51 | + $action_links = isset( $value['action_links'] ) && is_array( $value['action_links'] ) ? $value['action_links'] : array(); | |
| 52 | + $meta_pills = isset( $value['meta_pills'] ) && is_array( $value['meta_pills'] ) ? $value['meta_pills'] : array(); | |
| 48 | 53 | ?> |
| 49 | - <tr class="tpt-integration-item"> | |
| 54 | + <tr class="tpt-integration-item <?php echo $is_official ? 'tpt-integration-item--official' : ''; ?>"> | |
| 50 | 55 | <td> |
| 51 | - <div class="tpt-integration-wrapper"> | |
| 56 | + <div class="tpt-integration-wrapper <?php echo $is_official ? 'tpt-integration-wrapper--official' : ''; ?>"> | |
| 52 | 57 | <div class="tpt-integration-item__image"> |
| 53 | 58 | <img src="<?php echo esc_attr( $value['icon_url'] ); ?>" |
| 54 | 59 | alt="<?php echo esc_attr( $value['title'] ); ?>"> |
| 55 | 60 | </div> |
| 56 | 61 | <div class="tpt-integration-item__description"> |
| 62 | + <div class="tpt-integration-item__content"> | |
| 57 | 63 | |
| 64 | + <?php $official_badge = $is_official ? ' <span class="tpt-integration-item__official-badge">' . esc_html__( 'By U2Code', 'tier-pricing-table' ) . '</span>' : ''; ?> | |
| 58 | 65 | <?php if ( $value['author_url'] ) : ?> |
| 59 | 66 | <a target="_blank" href="<?php echo esc_attr( $value['author_url'] ); ?>"> |
| 60 | - <h4><?php echo esc_html( $value['title'] ); ?></h4> | |
| 67 | + <h4><?php echo esc_html( $value['title'] ) . wp_kses_post( $official_badge ); ?></h4> | |
| 61 | 68 | </a> |
| 62 | 69 | <?php else : ?> |
| 63 | - <h4><?php echo esc_html( $value['title'] ); ?></h4> | |
| 70 | + <h4><?php echo esc_html( $value['title'] ) . wp_kses_post( $official_badge ); ?></h4> | |
| 64 | 71 | <?php endif; ?> |
| 65 | 72 | |
| 73 | + <?php if ( $meta_pills ) : ?> | |
| 74 | + <div class="tpt-integration-item__pills"> | |
| 75 | + <?php foreach ( $meta_pills as $pill ) : ?> | |
| 76 | + <span class="tpt-integration-item__pill"><?php echo esc_html( $pill ); ?></span> | |
| 77 | + <?php endforeach; ?> | |
| 78 | + </div> | |
| 79 | + <?php endif; ?> | |
| 80 | + | |
| 66 | 81 | <p class="description"> |
| 67 | 82 | <?php |
| 68 | - echo wp_kses_post( $value['desc'] ); // audit.php.wp.security.xss.shortcode-attr ignore | |
| 83 | + echo wp_kses_post( $description ); // nosemgrep | |
| 69 | 84 | ?> |
| 70 | 85 | </p> |
| 86 | + | |
| 87 | + </div> | |
| 88 | + | |
| 89 | + <div class="tpt-integration-item__actions"> | |
| 90 | + <?php if ( $action_links ) : ?> | |
| 91 | + <div class="tpt-integration-item__action-links"> | |
| 92 | + <?php foreach ( $action_links as $action_link ) : ?> | |
| 93 | + <?php if ( empty( $action_link['url'] ) || empty( $action_link['label'] ) ) { continue; } ?> | |
| 94 | + <a class="tpt-integration-item__action-link" | |
| 95 | + target="<?php echo esc_attr( $action_link['target'] ?? '_blank' ); ?>" | |
| 96 | + <?php echo ( $action_link['target'] ?? '_blank' ) === '_blank' ? 'rel="noopener"' : ''; ?> | |
| 97 | + href="<?php echo esc_url( $action_link['url'] ); ?>"> | |
| 98 | + <?php echo esc_html( $action_link['label'] ); ?> → | |
| 99 | + </a> | |
| 100 | + <?php endforeach; ?> | |
| 101 | + </div> | |
| 102 | + <?php endif; ?> | |
| 71 | 103 | <div class="tpt-integration-item-checkbox"> |
| 72 | 104 | <input |
| 73 | 105 | name="<?php echo esc_attr( $value['id'] ); ?>" |
| 74 | 106 | id="<?php echo esc_attr( $value['id'] ); ?>" |
| @@ -80,8 +112,9 @@ | ||
| 80 | 112 | <label for="<?php echo esc_attr( $value['id'] ); ?>"> |
| 81 | 113 | <span data-tpt-toggle-switch-on><?php echo esc_attr( $value['on_label'] ); ?></span> |
| 82 | 114 | <span data-tpt-toggle-switch-off><?php echo esc_attr( $value['off_label'] ); ?></span> |
| 83 | 115 | </label> |
| 116 | + </div> | |
| 84 | 117 | </div> |
| 85 | 118 | </div> |
| 86 | 119 | </div> |
| 87 | 120 | </td> |