<?php

namespace Fab\Metabox\Setting;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * FAB Metabox Setting.
 *
 * @package    Fab
 * @subpackage Fab/Controller
 */
class Setting {

    // Load trait.
    use Tab_Button;
    use Tab_Cookie;
    use Tab_Modal;
    use Tab_Toast;
    use Tab_Setting;

    /**
     * FAB object
     *
     * @var array
     */
    private $fab;

    /**
     * Constructor
     *
     * @param array $fab global $post object.
     */
    public function __construct( $fab ) {
        $this->fab = $fab;
    }

    /**
     * Get tabs and fields
     *
     * @return array
     */
    public function get_tabs() {
        // Get tabs.
        $tabs = array_merge(
            $this->get_tab_setting(),
            $this->get_tab_button(),
            $this->get_tab_modal(),
            $this->get_tab_toast(),
            $this->get_tab_cookie(),
        );

        // Filter tabs.
        $tabs = apply_filters( 'fab_metabox_setting_tabs', $tabs, $this->fab );

        // Order tabs by place_after.
        foreach ( $tabs as &$tab ) {
            $tab['fields'] = \Fab()->Helper->order_array_by_place( $tab['fields'] );
        }

        return $tabs;
    }
}
