<?php

/**
 * Plugin Name:       Relatedly
 * Plugin URI:        https://kraftysprouts.com/portfolio/relatedly/
 * Description:       Advanced related posts engine with inline display, end-of-content lists, RSS integration, floating sidebar, and multiple themes with intelligent matching.
 * Version: 2.3.3
 * Author:            Krafty Sprouts Media, LLC
 * Author URI:        https://kraftysprouts.com
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       relatedly
 * Domain Path:       /languages
 * Requires at least: 5.0
 * Tested up to:      7.0
 * Requires PHP:      7.4
 *
 * @package Relatedly
 * @since   2.0.0
 */
defined( 'ABSPATH' ) || exit;
if ( function_exists( 'rel_fs' ) ) {
    rel_fs()->set_basename( true, __FILE__ );
    return;
}
if ( function_exists( 'relatedly_fs' ) ) {
    relatedly_fs()->set_basename( false, __FILE__ );
    return;
}
// PHP version guard — bail silently so WordPress can show the "requires PHP" notice.
if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
    return;
}
// Plugin constants.
define( 'RELATEDLY_VERSION', '2.3.3' );
define( 'RELATEDLY_PLUGIN_FILE', __FILE__ );
define( 'RELATEDLY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'RELATEDLY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'RELATEDLY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
// Composer PSR-4 autoloader.
if ( file_exists( RELATEDLY_PLUGIN_DIR . 'vendor/autoload.php' ) ) {
    require_once RELATEDLY_PLUGIN_DIR . 'vendor/autoload.php';
}
// Freemius SDK integration.
if ( !function_exists( 'rel_fs' ) && file_exists( RELATEDLY_PLUGIN_DIR . 'vendor/freemius/wordpress-sdk/start.php' ) ) {
    /**
     * Initialise or retrieve the Freemius SDK instance.
     *
     * @since 2.1.0
     * @return \Freemius
     */
    function rel_fs() {
        // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Freemius requires this SDK accessor name.
        global $rel_fs;
        // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Freemius stores the SDK instance in a matching global.
        if ( !isset( $rel_fs ) ) {
            require_once RELATEDLY_PLUGIN_DIR . 'vendor/freemius/wordpress-sdk/start.php';
            $rel_fs = fs_dynamic_init( 
                // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Freemius stores the SDK instance in a matching global.
                array(
                    'id'               => '32038',
                    'slug'             => 'relatedly',
                    'premium_slug'     => 'relatedly-premium',
                    'type'             => 'plugin',
                    'public_key'       => 'pk_e0c6ebece365bbe5bcc7cf3b99c10',
                    'is_premium'       => false,
                    'has_addons'       => false,
                    'has_paid_plans'   => true,
                    'is_org_compliant' => true,
                    'premium_suffix'   => '(Premium)',
                    'menu'             => array(
                        'slug'       => 'relatedly',
                        'first-path' => 'admin.php?page=relatedly',
                        'account'    => true,
                    ),
                    'is_live'          => true,
                )
             );
        }
        return $rel_fs;
    }

    /**
     * Retrieve the Freemius SDK instance using the plugin's internal accessor.
     *
     * @since 2.1.0
     * @return \Freemius
     */
    function relatedly_fs() {
        return rel_fs();
    }

    rel_fs();
    // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Freemius convention for the SDK-loaded hook.
    do_action( 'rel_fs_loaded' );
    do_action( 'relatedly_fs_loaded' );
}
// Lifecycle hooks — must be registered before plugins_loaded fires.
register_activation_hook( __FILE__, array('Relatedly\\Core\\Installer', 'activate') );
register_deactivation_hook( __FILE__, array('Relatedly\\Core\\Installer', 'deactivate') );
// Boot on plugins_loaded so all plugins are available when we wire services.
add_action( 'plugins_loaded', static function () {
    \Relatedly\Core\Plugin::boot( __FILE__ );
} );