← All changes
|
src/Settings/Sections/Advanced/AdvancedSection.php
+59
-43
6.1.0
→
8.0.2
View file →
| @@ -5,61 +5,57 @@ | ||
| 5 | 5 | use TierPricingTable\Settings\CustomOptions\TPTSwitchOption; |
| 6 | 6 | use TierPricingTable\Settings\Sections\SectionAbstract; |
| 7 | 7 | use TierPricingTable\Settings\Settings; |
| 8 | 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 | + */ | |
| 9 | 13 | class AdvancedSection extends SectionAbstract { |
| 10 | - | |
| 14 | + | |
| 11 | 15 | public function getSettings() { |
| 12 | - | |
| 13 | - $settings = array(); | |
| 14 | - $advanced = apply_filters( 'tiered_pricing_table/settings/advanced_settings', array() ); | |
| 15 | - | |
| 16 | - $sectionTitle = array( | |
| 17 | - 'title' => __( 'Features', 'tier-pricing-table' ), | |
| 18 | - 'desc' => __( 'You can disable or enable specific plugin features.', 'tier-pricing-table' ), | |
| 19 | - 'id' => Settings::SETTINGS_PREFIX . 'advanced', | |
| 20 | - 'type' => 'title', | |
| 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 | 21 | ); |
| 22 | - | |
| 23 | - $sectionEnd = array( | |
| 24 | - 'type' => 'sectionend', | |
| 25 | - 'id' => Settings::SETTINGS_PREFIX . 'advanced', | |
| 26 | - ); | |
| 27 | - | |
| 28 | - $settings[] = $sectionTitle; | |
| 29 | - $settings = array_merge( $settings, $advanced ); | |
| 30 | - $settings[] = $sectionEnd; | |
| 31 | - | |
| 32 | - $settings = array_merge( $settings, $this->getCacheSettings() ); | |
| 33 | - $settings = array_merge( $settings, $this->getDebuggerSettings() ); | |
| 34 | - | |
| 35 | - return $settings; | |
| 36 | 22 | } |
| 37 | - | |
| 23 | + | |
| 38 | 24 | public function getSlug(): string { |
| 39 | 25 | return 'advanced'; |
| 40 | 26 | } |
| 41 | - | |
| 27 | + | |
| 42 | 28 | public function getName(): string { |
| 43 | - return __( 'Feature Flags', 'tier-pricing-table' ); | |
| 29 | + return __( 'Advanced', 'tier-pricing-table' ); | |
| 44 | 30 | } |
| 45 | - | |
| 46 | - public static function deleteOptions() { | |
| 47 | - delete_option( Settings::SETTINGS_PREFIX . 'advanced' ); | |
| 48 | - delete_option( Settings::SETTINGS_PREFIX . '_addon_category-tiered-pricing' ); | |
| 49 | - delete_option( Settings::SETTINGS_PREFIX . '_addon_manual-orders' ); | |
| 50 | - delete_option( Settings::SETTINGS_PREFIX . '_addon_role-based-rules' ); | |
| 51 | - delete_option( Settings::SETTINGS_PREFIX . '_addon_global-tier-pricing' ); | |
| 52 | - delete_option( Settings::SETTINGS_PREFIX . '_addon_minimum-quantity' ); | |
| 53 | - delete_option( Settings::SETTINGS_PREFIX . 'advanced' ); | |
| 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; | |
| 54 | 50 | } |
| 55 | - | |
| 51 | + | |
| 56 | 52 | protected function getCacheSettings(): array { |
| 57 | 53 | return array( |
| 58 | 54 | array( |
| 59 | 55 | 'title' => __( 'Cache', 'tier-pricing-table' ), |
| 60 | - 'desc' => __( 'Cache improves performance making the plugin not calculate data on each request. Disable to debug issues.', | |
| 61 | - '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', | |
| 62 | 58 | 'type' => 'title', |
| 63 | 59 | ), |
| 64 | 60 | array( |
| 65 | 61 | 'title' => __( 'Enabled', 'tier-pricing-table' ), |
| @@ -75,18 +71,19 @@ | ||
| 75 | 71 | 'type' => TPTLinkButton::FIELD_TYPE, |
| 76 | 72 | ), |
| 77 | 73 | array( |
| 78 | 74 | 'type' => 'sectionend', |
| 75 | + 'id' => Settings::SETTINGS_PREFIX . 'cache_section', | |
| 79 | 76 | ), |
| 80 | 77 | ); |
| 81 | 78 | } |
| 82 | - | |
| 83 | - protected function getDebuggerSettings(): array { | |
| 79 | + | |
| 80 | + protected function getDebugSettings(): array { | |
| 84 | 81 | return array( |
| 85 | 82 | array( |
| 86 | 83 | 'title' => __( 'Debug', 'tier-pricing-table' ), |
| 87 | - 'desc' => __( 'Debug mode is useful when you need to track what pricing rule is applying for a cart item.', | |
| 88 | - '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', | |
| 89 | 86 | 'type' => 'title', |
| 90 | 87 | ), |
| 91 | 88 | array( |
| 92 | 89 | 'title' => __( 'Enabled', 'tier-pricing-table' ), |
| @@ -95,8 +92,27 @@ | ||
| 95 | 92 | 'default' => 'no', |
| 96 | 93 | ), |
| 97 | 94 | array( |
| 98 | 95 | 'type' => 'sectionend', |
| 96 | + 'id' => Settings::SETTINGS_PREFIX . 'debug_section', | |
| 99 | 97 | ), |
| 100 | 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' ); | |
| 101 | 117 | } |
| 102 | 118 | } |