AdvancedTab.php
1 week ago
AppearanceTab.php
1 week ago
DisplayTab.php
1 week ago
GeneralTab.php
1 week ago
LogicTab.php
1 week ago
PricingTab.php
1 week ago
TabAbstract.php
1 week ago
TabIntegration.php
1 week ago
TabInterface.php
1 week ago
TabIntegration.php
60 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FCF\Free\Settings\Tab; |
| 4 | |
| 5 | /** |
| 6 | * Initializes integration for settings tab of field. |
| 7 | */ |
| 8 | class TabIntegration { |
| 9 | |
| 10 | /** |
| 11 | * Class object for field type. |
| 12 | * |
| 13 | * @var TabInterface |
| 14 | */ |
| 15 | private $tab_object; |
| 16 | |
| 17 | /** |
| 18 | * Class constructor. |
| 19 | * |
| 20 | * @param TabInterface $tab_object Class object of field type. |
| 21 | */ |
| 22 | public function __construct( TabInterface $tab_object ) { |
| 23 | $this->tab_object = $tab_object; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * {@inheritdoc} |
| 28 | */ |
| 29 | public function hooks() { |
| 30 | add_filter( 'flexible_checkout_fields/field_settings_tabs', [ $this, 'add_settings_tab' ], 0 ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Adds new tab for field settings. |
| 35 | * |
| 36 | * @param array $tabs List of field settings tabs. |
| 37 | * |
| 38 | * @return array Updated list of settings tabs. |
| 39 | * @internal |
| 40 | */ |
| 41 | public function add_settings_tab( array $tabs ): array { |
| 42 | $tab_name = $this->tab_object->get_tab_name(); |
| 43 | $tabs[ $tab_name ] = $this->get_tab_settings(); |
| 44 | return $tabs; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Returns list of settings for tab. |
| 49 | * |
| 50 | * @return array Settings of tab. |
| 51 | */ |
| 52 | private function get_tab_settings(): array { |
| 53 | return [ |
| 54 | 'name' => $this->tab_object->get_tab_name(), |
| 55 | 'label' => $this->tab_object->get_tab_label(), |
| 56 | 'icon' => $this->tab_object->get_tab_icon(), |
| 57 | ]; |
| 58 | } |
| 59 | } |
| 60 |