<?php

namespace Fab\Controller;

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

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

/**
 * Freemius Notice.
 *
 * @package    Fab
 * @subpackage Fab/Controller
 */
class Freemius_Notice extends Notice implements Model_Interface {

    /**
     * Overrides the Freemius admin notice.
     *
     * @param bool|null $show Whether to show the default notice.
     * @param string    $msg  The message to display in the notice.
     * @return bool Always returns false to prevent the default notice from showing.
     */
    public function fs_show_admin_notice( $show, $msg ) {
        add_action( 'admin_footer', array( 'FS_Admin_Notice_Manager', '_add_sticky_dismiss_javascript' ) );
        View::RenderStatic( 'Backend.freemius-notice', $msg );

        return false;
    }

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

    /**
     * Execute Class.
     *
     * @return void
     */
    public function run() {
        fab_freemius()->add_filter( 'show_admin_notice', array( $this, 'fs_show_admin_notice' ), 10, 2 );
    }
}
