<?php

namespace Fab\Controller;

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

use Fab\Interfaces\Model_Interface;
use Fab\View;

/**
 * Metabox Upgrade
 *
 * @package    Fab
 * @subpackage Fab/Controller
 */
class Metabox_Upgrade extends Base implements Model_Interface {

    /**
     * Add metabox upgrade
     *
     * @return void
     */
    public function metabox_upgrade() {
        add_meta_box(
            'fab-metabox-upgrade',
            __( 'Upgrade to Pro', 'floating-awesome-button' ),
            array( $this, 'metabox_upgrade_callback' ),
            'fab',
            'side',
        );
    }

    /**
     * Metabox upgrade callback
     *
     * @return void
     */
    public function metabox_upgrade_callback() {
        View::RenderStatic(
            'Backend.Metabox.upgrade',
            array(
                'plugin_url'   => FAB_PLUGIN_URL,
                'upgrade_url'  => \FAB()->Helper->getUpgradeURL(),
                'labels'       => array(
                    'upgrade_to_pro'   => __( 'Upgrade to Pro', 'floating-awesome-button' ),
                    'get_pro_features' => __( 'Get PRO Features Now →', 'floating-awesome-button' ),
                ),
                'pro_features' => array(
                    __( 'Filter by Custom Post Types, Pages, or Posts', 'floating-awesome-button' ),
                    __( 'Filter by Taxonomies (Categories, Tags, etc.)', 'floating-awesome-button' ),
                    __( 'User Session detection (Logged in/out)', 'floating-awesome-button' ),
                    __( 'Filter by User Roles', 'floating-awesome-button' ),
                    __( 'Device detection (Desktop, Tablet, Mobile)', 'floating-awesome-button' ),
                    __( '25+ Animations (Fade, Bounce, Zoom, Flip)', 'floating-awesome-button' ),
                    __( '258+ Custom Hotkey combinations', 'floating-awesome-button' ),
                    __( 'Auto Triggers (Adblock, Exit Intent, Time Delay)', 'floating-awesome-button' ),
                ),
            )
        );
    }

    /*
    |--------------------------------------------------------------------------
    | Fulfill implemented interface contracts
    |--------------------------------------------------------------------------
     */

    /**
     * Execute Class.
     *
     * @return void
     */
    public function run() {
        // Add metabox upgrade to Fab CPT.
        if ( ! \FAB()->Helper->isPremiumPlan() ) {
            add_action( 'add_meta_boxes', array( $this, 'metabox_upgrade' ), 10, 0 );
        }
    }
}
