PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
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 / Tools / Settings / Settings.php

Settings.php in Tiered Pricing Table for WooCommerce 8.0.2, at src/Addons/Tools/Settings/Settings.php

75 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Addons\Tools\Settings;
2
3 use TierPricingTable\Settings\Settings as MainSettings;
4
5 class Settings {
6
7 public function __construct() {
8
9 // the utilities panel on the Advanced tab, between the modules and the cache settings
10 add_filter( 'tiered_pricing_table/settings/tools_settings', function ( $settings ) {
11 return array_merge( array(
12 array(
13 // #roles: the "Manage roles" links land here, above the Utilities heading; the app also reads the hash as its tab
14 'type' => 'tiered-pricing_tools-anchor',
15 ),
16 array(
17 'title' => __( 'Utilities', 'tier-pricing-table' ),
18 'desc' => __( 'Manage roles and clean up tiered pricing data.', 'tier-pricing-table' ),
19 'id' => MainSettings::SETTINGS_PREFIX . 'tools_utilities',
20 'type' => 'title',
21 ),
22 array(
23 'type' => 'tiered-pricing_tools-ui',
24 ),
25 array(
26 'type' => 'sectionend',
27 'id' => MainSettings::SETTINGS_PREFIX . 'tools_utilities',
28 ),
29 ), $settings );
30 } );
31
32 add_action( 'woocommerce_admin_field_tiered-pricing_tools-anchor', function () {
33 // printed between two settings tables, so it is not a table row; the scroll margin keeps the heading below the sticky bars
34 ?>
35 <div id="roles" style="scroll-margin-top: 90px;"></div>
36 <?php
37 } );
38
39 add_action( 'woocommerce_admin_field_tiered-pricing_tools-ui', function () {
40 ?>
41 <tr valign="top">
42 <td colspan="2" class="forminp">
43 <div id="tiered-pricing__feature__tools"></div>
44 </td>
45 </tr>
46 <?php
47 } );
48
49 add_action( 'admin_enqueue_scripts', function () {
50
51 $settingsTab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : '';
52 $section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : '';
53
54 if ( MainSettings::SETTINGS_PAGE !== $settingsTab ) {
55 return;
56 }
57
58 if ( ! in_array( $section, array( 'advanced', 'tools' ), true ) ) { // 'tools' is the pre-7.2.1 link
59 return;
60 }
61
62 $assetFile = include( plugin_dir_path( __FILE__ ) . '../build/index.asset.php' );
63
64 wp_enqueue_script( 'tiered-pricing/feature/tools',
65 plugins_url( 'build/index.js', dirname( __FILE__ . '../' ) ), $assetFile['dependencies'],
66 $assetFile['version'], true );
67
68 wp_set_script_translations( 'tiered-pricing/feature/tools', 'tier-pricing-table',
69 dirname( __FILE__, 5 ) . '/languages' );
70
71 wp_enqueue_style( 'wp-components' );
72 } );
73 }
74 }
75