PluginProbe
Tiered Pricing Table for WooCommerce / 6.4.0
Tiered Pricing Table for WooCommerce v6.4.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 / Integrations / Plugins / PluginIntegrationAbstract.php

PluginIntegrationAbstract.php in Tiered Pricing Table for WooCommerce 6.4.0, at src/Integrations/Plugins/PluginIntegrationAbstract.php

70 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Integrations\Plugins;
2
3 use TierPricingTable\Core\ServiceContainerTrait;
4 use TierPricingTable\Settings\CustomOptions\TPTIntegrationOption;
5 use TierPricingTable\Settings\Settings;
6
7 abstract class PluginIntegrationAbstract {
8
9 use ServiceContainerTrait;
10
11 abstract public function getTitle(): string;
12
13 abstract public function getDescription(): string;
14
15 abstract public function getSlug(): string;
16
17 abstract public function run();
18
19 public function __construct() {
20
21 add_filter( 'tiered_pricing_table/settings/integrations_settings', array(
22 $this,
23 'addToIntegrationsSettings',
24 ) );
25
26 if ( $this->isEnabled() ) {
27 $this->run();
28 }
29 }
30
31 public function addToIntegrationsSettings( $integrations ) {
32 $integrations[] = array(
33 'title' => $this->getTitle(),
34 'id' => Settings::SETTINGS_PREFIX . '_integration_' . $this->getSlug(),
35 'default' => $this->isActiveByDefault() ? 'yes' : 'no',
36 'desc' => $this->getDescription(),
37 'type' => TPTIntegrationOption::FIELD_TYPE,
38 'icon_url' => $this->getIconURL(),
39 'author_url' => $this->getAuthorURL(),
40 'integration_category' => $this->getIntegrationCategory(),
41 );
42
43 return $integrations;
44 }
45
46 public function getIconURL(): ?string {
47 return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/placeholder.png' );
48 }
49
50 public function getAuthorURL(): ?string {
51 return null;
52 }
53
54 public function isEnabled(): bool {
55
56 $isEnabledByDefault = $this->isActiveByDefault() ? 'yes' : 'no';
57
58 return $this->getContainer()->getSettings()->get( '_integration_' . $this->getSlug(),
59 $isEnabledByDefault ) === 'yes';
60 }
61
62 protected function isActiveByDefault(): bool {
63 return true;
64 }
65
66 public function getIntegrationCategory(): string {
67 return 'other';
68 }
69 }
70