<?php

namespace Fab\Controller;

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

use Fab\Interfaces\JIT_Interface;

/**
 * Custom footer.
 *
 * @package    Fab
 * @subpackage Fab/Controller
 */
class Custom_Footer extends Base implements JIT_Interface {

    /**
     * Get custom admin footer text.
     *
     * @return string
     */
    public function get_admin_footer_text() {
        return sprintf(
            '%s <a href="%s" target="_blank">%s</a> %s',
            __( '❤️ Your support means the world to us. Please rate us', 'floating-awesome-button' ),
            'https://wordpress.org/support/plugin/floating-awesome-button/reviews/#new-post',
            __( '⭐⭐⭐⭐⭐', 'floating-awesome-button' ),
            __( 'to help us grow! 🥳', 'floating-awesome-button' ),
        );
    }

    /**
     * Add custom thank you page.
     *
     * @param string $text
     * @return string
     */
    public function fab_admin_footer_text( $text ) {
        $screen = get_current_screen();

        // Check if the current screen is the FAB post type.
        if ( ! $screen || 'edit.php?post_type=fab' !== $screen->parent_file ) {
            return $text;
        }

        return $this->get_admin_footer_text();
    }

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

    /**
     * Just In Time (JIT) loading.
     *
     * @return void
     */
    public static function jit() {
        add_filter( 'admin_footer_text', array( __CLASS__, 'jit_fab_admin_footer_text' ), 10, 1 );
    }
}
