PluginProbe
Tiered Pricing Table for WooCommerce / trunk
Tiered Pricing Table for WooCommerce vtrunk
7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 All 90 releases
tier-pricing-table / src / Settings / CustomOptions / TPTLinkButton.php

TPTLinkButton.php in Tiered Pricing Table for WooCommerce trunk, at src/Settings/CustomOptions/TPTLinkButton.php

43 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Settings\CustomOptions;
2
3 class TPTLinkButton {
4
5 const FIELD_TYPE = 'tpt_link_button';
6
7 public function __construct() {
8 add_action( 'woocommerce_admin_field_' . self::FIELD_TYPE, array( $this, 'render' ) );
9
10 add_action( 'woocommerce_admin_settings_sanitize_option', function ( $value, $option, $rawValue ) {
11
12 if ( self::FIELD_TYPE === $option['type'] ) {
13 $value = in_array( $value, array( 1, 'yes' ) ) ? 'yes' : 'no';
14 }
15
16 return $value;
17 }, 10, 3 );
18 }
19
20 public function render( $value ) {
21 if ( ! isset( $value['id'] ) ) {
22 $value['id'] = '';
23 }
24
25 if ( ! isset( $value['title'] ) ) {
26 $value['title'] = isset( $value['name'] ) ? $value['name'] : '';
27 }
28
29 ?>
30 <tr valign="top">
31 <th scope="row" class="titledesc">
32 <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
33 </th>
34 <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>">
35 <a href="<?php echo esc_attr( $value['button_link'] ); ?>"
36 class="<?php echo esc_attr( $value['button_class'] ); ?>">
37 <?php echo esc_html( $value['button_text'] ); ?>
38 </a>
39 </td>
40 </tr>
41 <?php
42 }
43 }