<?php
namespace NeoLibraryFull\NeoProInstaller; if (!defined("ABSPATH")) { die("neoWP direct access not allowed"); }



// Enable downloading of Pro content as a ZIP file when the user explicitly requests it via a button



\NeoLibraryFull\NeoGlobal\add_action_hook("current_screen", function () {

    if (!(\NeoLibraryFull\NeoGlobal\query_param("page") === \NeoLibraryFull\NeoGlobal\plugin_settings_page_slug() || \NeoLibraryFull\NeoGlobal\query_param("page") === \NeoLibraryFull\NeoGlobal\plugin_settings_page_slug() . "-account")) { return; }

    foreach (\NeoLibraryFull\NeoEntrypoint\get_neo_active_plugins() as $active_plugin) {
        if (in_array($active_plugin["edition"], ["pro", "beta"])) { return; }
    }

    [$license_key, $interface_ok] = \NeoLibraryFull\NeoGlobal\call_interface_func_implemented('\NeoLibraryFull\NeoFreemius\interface_freemius_license_secret_key_20260211')();
    if (!$interface_ok || $license_key === null) { return; }

    if (\NeoLibraryFull\NeoGlobal\plugin_edition() === "dev") { return; }

    $is_pro_installer_allowed = !(\NeoLibraryFull\NeoGlobal\plugin_edition() === "wporg");

    \NeoLibraryFull\NeoGlobal\enqueue_js_variable_backend("neoProInstallerIsProInstallerAllowed", $is_pro_installer_allowed);
    \NeoLibraryFull\NeoGlobal\enqueue_js_variable_backend("neoProInstallerPluginsUrl",            admin_url("plugins.php"));
    \NeoLibraryFull\NeoGlobal\enqueue_js_variable_backend("neoProInstallerNeoMediaProZipUrl",     \NeoLibraryFull\NeoGlobal\add_query_param(\NeoLibraryFull\NeoGlobal\get_plugin_download_zip_file_url_without_version("neo-media", "pro"), "license-key", $license_key));
    \NeoLibraryFull\NeoGlobal\enqueue_js_variable_backend("neoProInstallerSettingsPageUrl",       admin_url("admin.php?page=" . \NeoLibraryFull\NeoGlobal\plugin_settings_page_slug()));
    \NeoLibraryFull\NeoGlobal\enqueue_js("neo-pro-installer.js");
});


if (function_exists('\NeoLibraryFull\NeoGlobal\register_install_neo_media_pro_rest_endpoint')) { \NeoLibraryFull\NeoGlobal\register_install_neo_media_pro_rest_endpoint(); }


\NeoLibraryFull\NeoGlobal\register_rest_endpoint("/wp-json/neo/neo-pro-installer--remove-license-key", "POST", fn () => \NeoLibraryFull\NeoGlobal\current_user_can__neo_pro_installer(), function ($get_param) {
    \NeoLibraryFull\NeoGlobal\call_interface_func_implemented('\NeoLibraryFull\NeoFreemius\interface_freemius_delete_account_event_20260211', throw_if_interface_not_ok: true)();
    return "OKAY";
});
