<?php namespace Webien\Setup;

class OptionPage
{
    static function init()
    {
        self::init_options_page();
        add_action('acf/save_post', [__CLASS__, 'clear_elementor_cache'], 20);

        // Add Button options
        (new \Webien\Elementor\Extensions\Buttons\OptionPage());
        (new \Webien\Setup\Updates())->init();
        (new \Webien\Setup\AdminScripts())->init();
    }

    static function init_options_page()
    {
        if ( function_exists( 'acf_add_options_page' ) ) {
            if ( current_user_can('administrator') ) {
                acf_add_options_page([
                    'page_title'    => 'Webien',
                    'menu_title'    => 'Webien',
                    'capability'    => 'manage_options',
                    'icon_url'      => 'dashicons-admin-settings',
                    'redirect' 		=> false
                ]);
            }
        }
    }


    public static function clear_elementor_cache(){
        (new \Elementor\Core\Files\Manager())->clear_cache();
    }

}
