PluginProbe
Tiered Pricing Table for WooCommerce / 7.1.1
Tiered Pricing Table for WooCommerce v7.1.1
8.0.2 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 All 91 releases
tier-pricing-table / src / Settings / CustomOptions / TPTIntegrationOption.php

TPTIntegrationOption.php in Tiered Pricing Table for WooCommerce 7.1.1, at src/Settings/CustomOptions/TPTIntegrationOption.php

92 lines 2.7 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 TPTIntegrationOption {
4
5 const FIELD_TYPE = 'tpt_integration_option';
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 if ( ! isset( $value['default'] ) ) {
29 $value['default'] = '';
30 }
31
32 if ( ! isset( $value['value'] ) ) {
33 $value['value'] = \WC_Admin_Settings::get_option( $value['id'], $value['default'] );
34 }
35
36 if ( ! isset( $value['on_label'] ) ) {
37 $value['on_label'] = __( 'On', 'role-and-customer-based-pricing-for-woocommerce' );
38 }
39
40 if ( ! isset( $value['off_label'] ) ) {
41 $value['off_label'] = __( 'Off', 'role-and-customer-based-pricing-for-woocommerce' );
42 }
43 if ( ! isset( $value['desc'] ) ) {
44 $value['desc'] = '';
45 }
46
47 $option_value = $value['value'];
48 ?>
49 <tr class="tpt-integration-item">
50 <td>
51 <div class="tpt-integration-wrapper">
52 <div class="tpt-integration-item__image">
53 <img src="<?php echo esc_attr( $value['icon_url'] ); ?>"
54 alt="<?php echo esc_attr( $value['title'] ); ?>">
55 </div>
56 <div class="tpt-integration-item__description">
57
58 <?php if ( $value['author_url'] ) : ?>
59 <a target="_blank" href="<?php echo esc_attr( $value['author_url'] ); ?>">
60 <h4><?php echo esc_html( $value['title'] ); ?></h4>
61 </a>
62 <?php else : ?>
63 <h4><?php echo esc_html( $value['title'] ); ?></h4>
64 <?php endif; ?>
65
66 <p class="description">
67 <?php
68 echo wp_kses_post( $value['desc'] ); // audit.php.wp.security.xss.shortcode-attr ignore
69 ?>
70 </p>
71 <div class="tpt-integration-item-checkbox">
72 <input
73 name="<?php echo esc_attr( $value['id'] ); ?>"
74 id="<?php echo esc_attr( $value['id'] ); ?>"
75 type="checkbox"
76 value="1"
77 <?php checked( $option_value, 'yes' ); ?>
78 class="tpt-toggle-switch"
79 />
80 <label for="<?php echo esc_attr( $value['id'] ); ?>">
81 <span data-tpt-toggle-switch-on><?php echo esc_attr( $value['on_label'] ); ?></span>
82 <span data-tpt-toggle-switch-off><?php echo esc_attr( $value['off_label'] ); ?></span>
83 </label>
84 </div>
85 </div>
86 </div>
87 </td>
88 </tr>
89 <?php
90 }
91 }
92