PluginProbe
Tiered Pricing Table for WooCommerce / 6.1.0
Tiered Pricing Table for WooCommerce v6.1.0
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 6.1.0, at src/Settings/CustomOptions/TPTIntegrationOption.php

94 lines 2.9 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 ?>
50
51 <tr class="tpt-integration-item" style="display: flex; width: 50%; min-width: 400px;">
52 <td>
53 <div style="display: flex; gap: 20px;">
54 <div class="tpt-integration-item__image" style="width:100px;">
55 <img src="<?php echo esc_attr( $value['icon_url'] ); ?>" width="100px" height="100px"
56 alt="<?php echo esc_html( $value['title'] ); ?>">
57 </div>
58 <div class="tpt-integration-item__description">
59
60 <?php if ( $value['author_url'] ) : ?>
61 <a target="_blank" href="<?php echo esc_attr( $value['author_url'] ); ?>">
62 <h4 style="margin-top: 0; margin-bottom: 10px"><?php echo esc_html( $value['title'] ); ?></h4>
63 </a>
64 <?php else : ?>
65 <h4 style="margin-top: 0; margin-bottom: 10px"><?php echo esc_html( $value['title'] ); ?></h4>
66 <?php endif; ?>
67
68 <p class="description">
69 <?php
70 echo wp_kses_post( $value['desc'] ); // audit.php.wp.security.xss.shortcode-attr ignore
71 ?>
72 </p>
73 <div class="tpt-integration-item-checkbox" style="margin-top: 10px">
74 <input
75 name="<?php echo esc_attr( $value['id'] ); ?>"
76 id="<?php echo esc_attr( $value['id'] ); ?>"
77 type="checkbox"
78 value="1"
79 <?php checked( $option_value, 'yes' ); ?>
80 class="tpt-toggle-switch"
81 />
82 <label for="<?php echo esc_attr( $value['id'] ); ?>">
83 <span data-tpt-toggle-switch-on><?php echo esc_attr( $value['on_label'] ); ?></span>
84 <span data-tpt-toggle-switch-off><?php echo esc_attr( $value['off_label'] ); ?></span>
85 </label>
86 </div>
87 </div>
88 </div>
89 </td>
90 </tr>
91 <?php
92 }
93 }
94