PluginProbe
Tiered Pricing Table for WooCommerce / 6.5.0
Tiered Pricing Table for WooCommerce v6.5.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 / Addons / CustomColumns / Admin / CustomColumnsAdmin.php

CustomColumnsAdmin.php in Tiered Pricing Table for WooCommerce 6.5.0, at src/Addons/CustomColumns/Admin/CustomColumnsAdmin.php

81 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Addons\CustomColumns\Admin;
2
3 use TierPricingTable\Settings\Settings as MainSettings;
4
5 class CustomColumnsAdmin {
6
7 public function __construct() {
8 add_action( 'tiered_pricing_table/settings/table_columns/after_fields', function () {
9 $columnsManager = \TierPricingTable\Addons\CustomColumns\CustomColumnsManager::getInstance();
10 $hasColumns = ! empty( $columnsManager->getRawColumns() );
11
12 if ( $hasColumns ) {
13 return;
14 }
15 ?>
16 <div style="height:0; width:100%"></div>
17 <div id="tpt-custom-columns-promo-block" style="margin-top: 15px; padding: 15px; background: #f9f9f9; border-left: 4px solid #2271b1; border-radius: 4px; max-width: 575px;">
18 <p style="margin-top: 0; margin-bottom: 5px;"><strong><?php esc_html_e( 'Show More Info Next to Prices?', 'tier-pricing-table' ); ?></strong></p>
19 <p style="margin-bottom: 15px; font-size: 13px; color: #646970;"><?php esc_html_e( 'Create additional columns to show exactly how much your customers save, total prices, or per-unit costs alongside each tier.', 'tier-pricing-table' ); ?></p>
20 <button type="button" id="tpt-toggle-custom-columns" class="button button-primary" style="display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 14px 4px 10px; font-weight: 600;">
21 <span class="dashicons dashicons-plus" style=" margin-top: 4px; display: flex; align-items: center;"></span>
22 <?php esc_html_e( 'Add Custom Columns', 'tier-pricing-table' ); ?>
23 </button>
24 </div>
25 <script>
26 document.addEventListener('DOMContentLoaded', function() {
27 var toggleBtn = document.getElementById('tpt-toggle-custom-columns');
28 var customColumnsDiv = document.getElementById('tiered-pricing__feature__custom-columns');
29 var promoBlock = document.getElementById('tpt-custom-columns-promo-block');
30 if (toggleBtn && customColumnsDiv) {
31 customColumnsDiv.style.display = 'none';
32 toggleBtn.addEventListener('click', function(e) {
33 e.preventDefault();
34 if (promoBlock) {
35 promoBlock.style.display = 'none';
36 }
37 customColumnsDiv.style.display = 'block';
38 });
39 }
40 });
41 </script>
42 <?php
43 } );
44
45 add_action( 'tiered_pricing_table/settings/table_columns/end', function () {
46 ?>
47 <div id="tiered-pricing__feature__custom-columns"></div>
48 <?php
49 } );
50
51 add_action( 'admin_enqueue_scripts', function () {
52
53 $settingsTab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : '';
54
55 if ( MainSettings::SETTINGS_PAGE !== $settingsTab ) {
56 return;
57 }
58
59 $buildDir = dirname( __FILE__, 2 ) . '/build';
60
61 if ( ! file_exists( $buildDir . '/index.asset.php' ) ) {
62 return;
63 }
64
65 $assetFile = include( $buildDir . '/index.asset.php' );
66
67 wp_enqueue_script( 'tiered-pricing/feature/custom-columns',
68 plugins_url( 'build/index.js', dirname( __FILE__ ) ), $assetFile['dependencies'],
69 $assetFile['version'], true );
70
71 wp_localize_script( 'tiered-pricing/feature/custom-columns', 'tptCustomColumns', array(
72 'isPremium' => function_exists( 'tpt_fs' ) && tpt_fs()->can_use_premium_code(),
73 'upgradeUrl' => function_exists( 'tpt_fs' ) ? tpt_fs()->get_upgrade_url() : '#',
74 ) );
75
76 wp_set_script_translations( 'tiered-pricing/feature/custom-columns', 'tier-pricing-table',
77 dirname( __FILE__, 5 ) . '/languages' );
78 } );
79 }
80 }
81