| 1 |
<?php namespace TierPricingTable\Settings\Sections\Integrations; |
| 2 |
|
| 3 |
use TierPricingTable\Core\ServiceContainerTrait; |
| 4 |
use TierPricingTable\Settings\Sections\SectionAbstract; |
| 5 |
use TierPricingTable\Settings\Settings; |
| 6 |
|
| 7 |
class IntegrationSection extends SectionAbstract { |
| 8 |
|
| 9 |
use ServiceContainerTrait; |
| 10 |
|
| 11 |
|
| 12 |
public function getSettings(): array { |
| 13 |
|
| 14 |
$settings = array(); |
| 15 |
|
| 16 |
$categories = array( |
| 17 |
'u2code' => array( |
| 18 |
'title' => __( 'U2Code plugins', 'tier-pricing-table' ), |
| 19 |
'description' => __( 'Plugins by the makers of Tiered Pricing Table — built to work together with deep, first-party integrations.', |
| 20 |
'tier-pricing-table' ), |
| 21 |
), |
| 22 |
'other' => array( |
| 23 |
'title' => __( 'General integrations', 'tier-pricing-table' ), |
| 24 |
'description' => __( 'Integrations with most popular plugins that are not related to a specific category.' ), |
| 25 |
'tier-pricing-table', |
| 26 |
), |
| 27 |
'multicurrency' => array( |
| 28 |
'title' => __( 'Multicurrency integrations', 'tier-pricing-table' ), |
| 29 |
'description' => __( 'Integrations with multicurrency plugins.', 'tier-pricing-table' ), |
| 30 |
), |
| 31 |
'product_addons' => array( |
| 32 |
'title' => __( 'Product Addons', 'tier-pricing-table' ), |
| 33 |
'description' => __( 'Integrations with product add-ons (custom fields) plugins.', |
| 34 |
'tier-pricing-table' ), |
| 35 |
), |
| 36 |
'seo' => array( |
| 37 |
'title' => __( 'SEO', 'tier-pricing-table' ), |
| 38 |
'description' => __( 'Integrations with SEO plugins.', 'tier-pricing-table' ), |
| 39 |
), |
| 40 |
'custom_product_types' => array( |
| 41 |
'title' => __( 'Custom Product Types', 'tier-pricing-table' ), |
| 42 |
'description' => __( 'Integrations plugins that provides custom product types.', 'tier-pricing-table' ), |
| 43 |
), |
| 44 |
); |
| 45 |
|
| 46 |
/** |
| 47 |
* Integration categories |
| 48 |
* |
| 49 |
* @since 5.5.0 |
| 50 |
*/ |
| 51 |
$categories = apply_filters( 'tiered_pricing_table/settings/integrations_categories', $categories ); |
| 52 |
|
| 53 |
/** |
| 54 |
* Integration section settings |
| 55 |
*/ |
| 56 |
$_integrations = apply_filters( 'tiered_pricing_table/settings/integrations_settings', array() ); |
| 57 |
$integrations = []; |
| 58 |
|
| 59 |
foreach ( $_integrations as $integration ) { |
| 60 |
// Official (U2Code) integrations are shown in their own section at the top of the page. |
| 61 |
$categoryID = ! empty( $integration['official'] ) ? 'u2code' : $integration['integration_category']; |
| 62 |
|
| 63 |
$integrations[ $categoryID ][] = $integration; |
| 64 |
} |
| 65 |
|
| 66 |
foreach ( $categories as $categoryID => $category ) { |
| 67 |
|
| 68 |
if ( empty( $integrations[ $categoryID ] ) ) { |
| 69 |
continue; |
| 70 |
} |
| 71 |
|
| 72 |
$settings[] = array( |
| 73 |
'title' => $category['title'], |
| 74 |
'desc' => $category['description'], |
| 75 |
'id' => Settings::SETTINGS_PREFIX . $categoryID . '__integration_section', |
| 76 |
'type' => 'title', |
| 77 |
); |
| 78 |
|
| 79 |
foreach ( $integrations[ $categoryID ] as $integration ) { |
| 80 |
$settings[] = $integration; |
| 81 |
} |
| 82 |
|
| 83 |
$settings[] = array( |
| 84 |
'type' => 'sectionend', |
| 85 |
'id' => Settings::SETTINGS_PREFIX . $categoryID . '__integration_section_end', |
| 86 |
); |
| 87 |
} |
| 88 |
|
| 89 |
return $settings; |
| 90 |
} |
| 91 |
|
| 92 |
public function getSectionCSS(): string { |
| 93 |
return '.form-table tbody { display: flex; flex-wrap: wrap; margin: 10px 0 20px 0; }'; |
| 94 |
} |
| 95 |
|
| 96 |
public function getSlug(): string { |
| 97 |
return 'integrations'; |
| 98 |
} |
| 99 |
|
| 100 |
public function getName(): string { |
| 101 |
return __( 'Integrations', 'tier-pricing-table' ); |
| 102 |
} |
| 103 |
|
| 104 |
public static function deleteOptions() { |
| 105 |
delete_option( Settings::SETTINGS_PREFIX . 'table_integrations' ); |
| 106 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_elementor' ); |
| 107 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_wpallimport' ); |
| 108 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_mix-match-for-woocommerce' ); |
| 109 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_product-add-ons' ); |
| 110 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_woocommerce-deposits' ); |
| 111 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_product-bundles-for-woocommerce' ); |
| 112 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_aelia-multicurrency' ); |
| 113 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_wcpa' ); |
| 114 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_u2code-product-addons' ); |
| 115 |
delete_option( Settings::SETTINGS_PREFIX . '_integration_u2code-multicurrency' ); |
| 116 |
delete_option( 'tpt_integrations_badge_seen' ); |
| 117 |
delete_option( 'tpt_section_badge_seen_multicurrency' ); |
| 118 |
delete_option( 'tpt_section_badge_seen_product-addons' ); |
| 119 |
delete_option( Settings::SETTINGS_PREFIX . 'integrations' ); |
| 120 |
} |
| 121 |
} |
| 122 |
|