<?php

/**
 * Plugin Name:       Redirect Cleanup
 * Description:       Scan and fix redirect chains and homepage redirects from Yoast SEO Premium
 * Plugin URI:        https://aleksandrsamokhin.com/redirect-cleanup
 * Version:           1.0.8
 * Author:            Aleksandr Samokhin
 * Author URI:        https://aleksandrsamokhin.com
 * Text Domain:       redirect-cleanup
 * Requires at least: 5.0
 * Requires PHP:      7.4
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 *
 * @package           Redicl
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
    // Exit if accessed directly.
}
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
    require_once __DIR__ . '/vendor/autoload.php';
}
// Plugin version.
if ( !defined( 'REDICL_VERSION' ) ) {
    define( 'REDICL_VERSION', '1.0.8' );
}
// Define REDICL_PLUGIN_FILE.
if ( !defined( 'REDICL_PLUGIN_FILE' ) ) {
    define( 'REDICL_PLUGIN_FILE', __FILE__ );
}
// Plugin directory.
if ( !defined( 'REDICL_DIR' ) ) {
    define( 'REDICL_DIR', plugin_dir_path( __FILE__ ) );
}
// Plugin url.
if ( !defined( 'REDICL_URL' ) ) {
    define( 'REDICL_URL', plugin_dir_url( __FILE__ ) );
}
// Assets url.
if ( !defined( 'REDICL_ASSETS_URL' ) ) {
    define( 'REDICL_ASSETS_URL', REDICL_URL . 'build' );
}
if ( function_exists( 'redicl_fs' ) ) {
    redicl_fs()->set_basename( false, __FILE__ );
} else {
    /**
     * DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE
     * `function_exists` CALL ABOVE TO PROPERLY WORK.
     */
    if ( !function_exists( 'redicl_fs' ) ) {
        // Create a helper function for easy SDK access.
        function redicl_fs() {
            global $redicl_fs;
            if ( !isset( $redicl_fs ) ) {
                // Include Freemius SDK.
                // SDK is auto-loaded through Composer
                $redicl_fs = fs_dynamic_init( array(
                    'id'             => '22748',
                    'slug'           => 'redirect-cleanup',
                    'premium_slug'   => 'redirect-cleanup-pro',
                    'type'           => 'plugin',
                    'public_key'     => 'pk_3c98c54cf299966ab8d67031f27f0',
                    'is_premium'     => false,
                    'has_addons'     => false,
                    'has_paid_plans' => true,
                    'is_org_compliant' => true,
                    'menu'           => array(
                        'slug'    => 'redicl',
                        'support' => false,
                        'parent'  => array(
                            'slug' => 'tools.php',
                        ),
                    ),
                    'is_live'        => true,
                ) );
            }
            return $redicl_fs;
        }

        // Init Freemius.
        redicl_fs();
        // Signal that SDK was initiated.
        do_action( 'redicl_fs_loaded' );
    }
    /**
     * Plugin admin icon
     */
    function redicl_fs_custom_icon() {
        return __DIR__ . '/assets/admin/icon.png';
    }

    redicl_fs()->add_filter( 'plugin_icon', 'redicl_fs_custom_icon' );
    // Load the main plugin class.
    require_once REDICL_DIR . 'includes/class-redicl.php';
    // Init the plugin and load the plugin instance for the first time.
    add_action( 'init', function () {
        Redicl::get_instance()->load();
    }, 9 );
}