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 / Settings / Sections / Advanced / AdvancedSection.php

AdvancedSection.php in Tiered Pricing Table for WooCommerce 8.0.2, at src/Settings/Sections/Advanced/AdvancedSection.php

119 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Settings\Sections\Advanced;
2
3 use TierPricingTable\Core\ServiceContainer;
4 use TierPricingTable\Settings\CustomOptions\TPTLinkButton;
5 use TierPricingTable\Settings\CustomOptions\TPTSwitchOption;
6 use TierPricingTable\Settings\Sections\SectionAbstract;
7 use TierPricingTable\Settings\Settings;
8
9 /**
10 * The "Advanced" tab: the module switches, the Tools add-on's utilities (roles, data clean-up),
11 * the cache and the debug mode. The former "Tools" tab lives here since 7.2.1; its old links still work.
12 */
13 class AdvancedSection extends SectionAbstract {
14
15 public function getSettings() {
16 return array_merge(
17 $this->getModulesSettings(),
18 (array) apply_filters( 'tiered_pricing_table/settings/tools_settings', array() ),
19 $this->getCacheSettings(),
20 $this->getDebugSettings()
21 );
22 }
23
24 public function getSlug(): string {
25 return 'advanced';
26 }
27
28 public function getName(): string {
29 return __( 'Advanced', 'tier-pricing-table' );
30 }
31
32 protected function getModulesSettings(): array {
33 $settings = array(
34 array(
35 'title' => __( 'Modules', 'tier-pricing-table' ),
36 'desc' => __( 'You can disable or enable specific plugin features.', 'tier-pricing-table' ),
37 'id' => Settings::SETTINGS_PREFIX . 'advanced',
38 'type' => 'title',
39 ),
40 );
41
42 $settings = array_merge( $settings, (array) apply_filters( 'tiered_pricing_table/settings/advanced_settings', array() ) );
43
44 $settings[] = array(
45 'type' => 'sectionend',
46 'id' => Settings::SETTINGS_PREFIX . 'advanced',
47 );
48
49 return $settings;
50 }
51
52 protected function getCacheSettings(): array {
53 return array(
54 array(
55 'title' => __( 'Cache', 'tier-pricing-table' ),
56 'desc' => __( 'Cache improves performance making the plugin not calculate data on each request. Disable to debug issues.', 'tier-pricing-table' ),
57 'id' => Settings::SETTINGS_PREFIX . 'cache_section',
58 'type' => 'title',
59 ),
60 array(
61 'title' => __( 'Enabled', 'tier-pricing-table' ),
62 'id' => Settings::SETTINGS_PREFIX . 'cache_enabled',
63 'type' => TPTSwitchOption::FIELD_TYPE,
64 'default' => 'yes',
65 ),
66 array(
67 'title' => __( 'Purge', 'tier-pricing-table' ),
68 'button_text' => __( 'Purge cache', 'tier-pricing-table' ),
69 'button_class' => 'button button-large',
70 'button_link' => ServiceContainer::getInstance()->getCache()->getPurgeURL(),
71 'type' => TPTLinkButton::FIELD_TYPE,
72 ),
73 array(
74 'type' => 'sectionend',
75 'id' => Settings::SETTINGS_PREFIX . 'cache_section',
76 ),
77 );
78 }
79
80 protected function getDebugSettings(): array {
81 return array(
82 array(
83 'title' => __( 'Debug', 'tier-pricing-table' ),
84 'desc' => __( 'Debug mode is useful when you need to track what pricing rule is applying for a cart item.', 'tier-pricing-table' ),
85 'id' => Settings::SETTINGS_PREFIX . 'debug_section',
86 'type' => 'title',
87 ),
88 array(
89 'title' => __( 'Enabled', 'tier-pricing-table' ),
90 'id' => Settings::SETTINGS_PREFIX . 'debug_enabled',
91 'type' => TPTSwitchOption::FIELD_TYPE,
92 'default' => 'no',
93 ),
94 array(
95 'type' => 'sectionend',
96 'id' => Settings::SETTINGS_PREFIX . 'debug_section',
97 ),
98 );
99 }
100
101 public function getSectionCSS(): string {
102 // only the modules table (the first one) is a grid; the utilities, cache and debug tables keep the default rows
103 return '.form-table:first-of-type tbody { display: flex; flex-wrap: wrap; margin: 10px 0 20px 0; }
104 .form-table:first-of-type tr { display: block; border-bottom: none; padding-bottom: 0; }
105 .form-table:first-of-type th { display: none; }
106 .form-table:first-of-type td { padding: 0 !important; width: 100%; }';
107 }
108
109 public static function deleteOptions() {
110 delete_option( Settings::SETTINGS_PREFIX . 'advanced' );
111 delete_option( Settings::SETTINGS_PREFIX . '_addon_category-tiered-pricing' );
112 delete_option( Settings::SETTINGS_PREFIX . '_addon_manual-orders' );
113 delete_option( Settings::SETTINGS_PREFIX . '_addon_role-based-rules' );
114 delete_option( Settings::SETTINGS_PREFIX . '_addon_global-tier-pricing' );
115 delete_option( Settings::SETTINGS_PREFIX . '_addon_minimum-quantity' );
116 delete_option( Settings::SETTINGS_PREFIX . 'advanced' );
117 }
118 }
119