<?php

/**

 * Plugin Name: ElementSell

 * Plugin URI: https://elementsell.cz

 * Description: ElementSell – český platební formulář pro Elementor. Prodej online produktů a kurzů přes ThePay a Fio banku (QR platba), objednávky, faktury a e-maily.

 * Version: 3.2.74

 * Requires at least: 5.8

 * Requires PHP: 7.4

 * Author: ElementSell

 * Author URI: https://elementsell.cz

 * Text Domain: elementsell

 * License: GPLv2 or later

 * License URI: https://www.gnu.org/licenses/gpl-2.0.html

 * Update URI: https://elementsell.cz/elementsell-update.json
 */



if (!defined('ABSPATH')) {

    exit;

}



define( 'PF_PLUGIN_FILE', __FILE__ );

define( 'PF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );

define( 'PF_PLUGIN_URL', plugin_dir_url( __FILE__ ) );

define( 'PF_VERSION', '3.2.74' );



// Při vypuštění aktualizace se nahradí skutečným tokenem (stejný jako $ELEMENTSELL_SECRET na serveru).

define( 'ELEMENTSELL_DISTRIBUTED_TOKEN', 'cbd87a9b048cf4d125384cc2fbd494a002389e4e34c76cd6' );



require_once PF_PLUGIN_DIR . 'includes/php-version-gate.php';



/**

 * Po WP aktualizaci pluginu vynutí telemetrii na dalším requestu (upgrade hook běží až později).

 *

 * @param WP_Upgrader $upgrader

 * @param array       $options

 * @return void

 */

function elementsell_telemetry_flag_after_plugin_update( $upgrader, $options ) {

    unset( $upgrader );



    if ( ! is_array( $options ) ) {

        return;

    }



    if ( ( $options['type'] ?? '' ) !== 'plugin' || ( $options['action'] ?? '' ) !== 'update' ) {

        return;

    }



    $plugins = isset( $options['plugins'] ) ? (array) $options['plugins'] : [];



    if ( ! in_array( plugin_basename( __FILE__ ), $plugins, true ) ) {

        return;

    }



    set_transient( 'elementsell_telemetry_pending_upgrade', '1', DAY_IN_SECONDS );

}



add_action( 'upgrader_process_complete', 'elementsell_telemetry_flag_after_plugin_update', 10, 2 );



/**

 * @return void

 */

function elementsell_activation_check_environment() {

    if ( elementsell_php_version_is_supported() ) {

        return;

    }



    elementsell_php_version_debug_log(

        'activation_blocked',

        [

            'supported' => false,

        ]

    );



    if ( ! function_exists( 'deactivate_plugins' ) ) {

        require_once ABSPATH . 'wp-admin/includes/plugin.php';

    }



    deactivate_plugins( plugin_basename( __FILE__ ) );



    wp_die(

        sprintf(

            'ElementSell vyžaduje PHP %1$s nebo novější. Na tomto serveru běží PHP %2$s. Požádejte hosting o upgrade PHP.',

            ELEMENTSELL_MIN_PHP_VERSION,

            PHP_VERSION

        ),

        'ElementSell – nekompatibilní PHP',

        [

            'back_link' => true,

        ]

    );

}



register_activation_hook( __FILE__, 'elementsell_activation_check_environment' );



/**

 * Po aktivaci nenechat uživatele na prázdném seznamu pluginů.

 * Po update / reaktivaci už nenutit onboarding, pokud je web nastavený.

 *

 * @return void

 */

function elementsell_onboarding_flag_after_activation() {

    if ( get_option( 'elementsell_onboarding_dismissed', '' ) === '1' ) {

        return;

    }



    global $wpdb;



    $orders_table = $wpdb->prefix . 'elementsell_orders';

    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching

    $table_exists = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $orders_table ) );



    if ( $table_exists === $orders_table ) {

        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared

        $order_id = $wpdb->get_var( "SELECT id FROM {$orders_table} LIMIT 1" );



        if ( (int) $order_id > 0 ) {

            update_option( 'elementsell_onboarding_dismissed', '1', false );

            delete_option( 'elementsell_onboarding_pending' );



            return;

        }

    }



    set_transient( 'elementsell_activation_redirect', '1', 5 * MINUTE_IN_SECONDS );

    update_option( 'elementsell_onboarding_pending', '1', false );

}



register_activation_hook( __FILE__, 'elementsell_onboarding_flag_after_activation' );



/**

 * @return void

 */

function elementsell_admin_notice_php_version() {

    if ( ! current_user_can( 'activate_plugins' ) ) {

        return;

    }



    // Bez této kontroly se hláška ukazovala vždy (admin-menu strip notices).

    if ( elementsell_php_version_is_supported() ) {

        return;

    }



    printf(

        '<div class="notice notice-error elementsell-notice"><p><strong>ElementSell</strong> vyžaduje PHP %1$s nebo novější. Aktuální verze: %2$s. Plugin se nenačetl.</p></div>',

        esc_html( ELEMENTSELL_MIN_PHP_VERSION ),

        esc_html( PHP_VERSION )

    );

}



if ( elementsell_php_version_should_block_plugin() ) {

    elementsell_php_version_debug_log( 'bootstrap_blocked' );

    add_action( 'admin_notices', 'elementsell_admin_notice_php_version' );

    return;

}



function elementsell_sanitize_invoice_vat_rate( $value ) {

    if ( '' === $value ) {

        return '';

    }



    $rate = floatval( $value );



    if ( $rate < 0 ) {

        return 0;

    }



    if ( $rate > 100 ) {

        return 100;

    }



    return $rate;

}



/**

 * @param mixed $value

 * @return int

 */

function elementsell_sanitize_checkbox_option( $value ) {

    return ! empty( $value ) ? 1 : 0;

}



/**

 * @param string $value

 * @return string

 */

function elementsell_sanitize_gmail_app_password( $value ) {

    $value = preg_replace( '/\s+/', '', (string) $value );



    if ( $value === '' ) {

        $existing = get_option( 'elementsell_gmail_app_password', '' );



        return is_string( $existing ) ? $existing : '';

    }



    return $value;

}



function elementsell_register_invoice_settings() {

    register_setting(

        'elementsell_gmail_settings',

        'elementsell_gmail_address',

        [

            'type'              => 'string',

            'sanitize_callback' => 'sanitize_email',

            'show_in_rest'      => false,

        ]

    );

    register_setting(

        'elementsell_gmail_settings',

        'elementsell_gmail_app_password',

        [

            'type'              => 'string',

            'sanitize_callback' => 'elementsell_sanitize_gmail_app_password',

            'show_in_rest'      => false,

            'autoload'          => false,

        ]

    );

    register_setting(

        'elementsell_gmail_settings',

        'elementsell_gmail_disable_paid_notifications',

        [

            'type'              => 'boolean',

            'sanitize_callback' => 'elementsell_sanitize_checkbox_option',

            'show_in_rest'      => false,

            'autoload'          => false,

            'default'           => false,

        ]

    );



    register_setting('elementsell_invoice_settings', 'faktury_platce_dph');

    register_setting(

        'elementsell_invoice_settings',

        'faktury_dph_sazba',

        [

            'sanitize_callback' => 'elementsell_sanitize_invoice_vat_rate',

        ]

    );

    register_setting('elementsell_invoice_settings', 'faktury_jmeno');

    register_setting('elementsell_invoice_settings', 'faktury_adresa');

    register_setting('elementsell_invoice_settings', 'faktury_ico');

    register_setting('elementsell_invoice_settings', 'faktury_dic');

    register_setting('elementsell_invoice_settings', 'faktury_logo');

    register_setting('elementsell_invoice_settings', 'faktury_podpis');



    register_setting(

        'elementsell_payment_settings',

        'fio_account_number',

        [

            'type'              => 'string',

            'sanitize_callback' => 'elementsell_sanitize_fio_account_number',

            'show_in_rest'      => false,

            'default'           => '',

        ]

    );

    register_setting(

        'elementsell_payment_settings',

        'elementsell_last_payment_method',

        [

            'type'              => 'string',

            'sanitize_callback' => static function ( $value ) {

                $value = sanitize_key( (string) $value );



                return in_array( $value, [ 'fio', 'thepay' ], true ) ? $value : 'fio';

            },

            'show_in_rest'      => false,

            'default'           => 'fio',

        ]

    );

}



if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {

    ini_set( 'log_errors', '1' );

}



require_once PF_PLUGIN_DIR . 'includes/payments/payment-fio-account.php';



/**

 * Emailing / automation — kód zůstává v repu, výchozí vypnuto (bez menu v adminu).

 * Zapnutí: define( 'ELEMENTSELL_AUTOMATION_ENABLED', true ); ve wp-config.php

 * Do zákaznického ZIP se složka includes/automation/ stejně nebalí.

 */

if ( ! defined( 'ELEMENTSELL_AUTOMATION_ENABLED' ) ) {

    define( 'ELEMENTSELL_AUTOMATION_ENABLED', false );

}



if ( ! defined( 'ELEMENTSELL_DEMO_COURSES_ENABLED' ) ) {

    define( 'ELEMENTSELL_DEMO_COURSES_ENABLED', false );

}



/**

 * Landing jen v plné instalaci (vlastní web). V distribučním ZIP soubory chybí.

 */

if ( ! function_exists( 'elementsell_is_landing_enabled' ) ) {

    /**

     * Marketingová landing je jen pro elementsell.cz (ne pro zákaznické weby).

     *

     * @return bool

     */

    function elementsell_is_landing_enabled() {

        if ( defined( 'ELEMENTSELL_LANDING_ENABLED' ) ) {

            return (bool) ELEMENTSELL_LANDING_ENABLED;

        }



        if ( ! file_exists( PF_PLUGIN_DIR . 'includes/pages/landing-page.php' )

            || ! file_exists( PF_PLUGIN_DIR . 'templates/elementsell-landing.php' ) ) {

            return false;

        }



        $host = wp_parse_url( home_url(), PHP_URL_HOST );

        $host = is_string( $host ) ? strtolower( $host ) : '';



        return in_array( $host, [ 'elementsell.cz', 'www.elementsell.cz' ], true );

    }

}



if ( ! defined( 'ELEMENTSELL_ELEMENTOR_STUB_MODE' ) ) {

    define( 'ELEMENTSELL_ELEMENTOR_STUB_MODE', true );

}



/**

 * Stub = lehký boot editoru (bez database/automation/sync) + plné widget controls v jednom requestu.

 * Výchozí true — rychlý start editoru bez 503.

 */

if ( ! defined( 'ELEMENTSELL_ELEMENTOR_DEFERRED_RELOAD' ) ) {

    define( 'ELEMENTSELL_ELEMENTOR_DEFERRED_RELOAD', false );

}



/**

 * Panelové widgety (widget-panel.php) místo plných — záloha při problémech s pamětí.

 * Výchozí false — stub režim registruje widget.php se všemi controls bez reloadu.

 */

if ( ! defined( 'ELEMENTSELL_ELEMENTOR_PANEL_WIDGETS' ) ) {

    define( 'ELEMENTSELL_ELEMENTOR_PANEL_WIDGETS', false );

}



require_once PF_PLUGIN_DIR . 'includes/elementor-compat.php';



if ( ELEMENTSELL_AUTOMATION_ENABLED ) {

    elementsell_boot_debug_require( 'includes/automation/automation-webinarjam.php' );

}



elementsell_boot_debug_require( 'includes/updates/plugin-updater.php' );



elementsell_boot_debug_log(

    'plugin.php loaded uri=' . ( isset( $_SERVER['REQUEST_URI'] ) ? (string) wp_unslash( $_SERVER['REQUEST_URI'] ) : '' )

);



if ( elementsell_is_elementor_context() && ! defined( 'ELEMENTSELL_EDITOR_MINIMAL_BOOT' ) ) {

    define( 'ELEMENTSELL_EDITOR_MINIMAL_BOOT', true );

}



// Deferred ready MUSÍ být vyhodnoceno před stub_mode — cookie/transient rozhoduje o plném bootu.

$elementsell_deferred_ready = function_exists( 'elementsell_has_editor_deferred_ready' )

    && elementsell_has_editor_deferred_ready();



elementsell_boot_debug_log(

    'deferred ready check: yes=' . ( $elementsell_deferred_ready ? 'yes' : 'no' )

    . ' cookie_raw=' . ( isset( $_COOKIE['elementsell_editor_deferred'] ) ? 'yes' : 'no' )

    . ' transient=' . ( function_exists( 'elementsell_has_editor_deferred_transient' ) && elementsell_has_editor_deferred_transient() ? 'yes' : 'no' )

    . ' user_meta=' . ( function_exists( 'elementsell_has_editor_deferred_user_meta' ) && elementsell_has_editor_deferred_user_meta() ? 'yes' : 'no' )

    . ' boot_user_id=' . ( function_exists( 'elementsell_get_boot_user_id' ) ? elementsell_get_boot_user_id() : 0 )

    . ' logged_in_cookie=' . ( function_exists( 'elementsell_get_logged_in_cookie_name' ) && elementsell_get_logged_in_cookie_name() !== '' ? 'yes' : 'no' )

    . ' cookie_username=' . ( function_exists( 'elementsell_parse_logged_in_cookie_parts' ) ? elementsell_parse_logged_in_cookie_parts()['username'] : '' )

    . ' cookie_token=' . ( function_exists( 'elementsell_parse_logged_in_cookie_parts' ) && elementsell_parse_logged_in_cookie_parts()['token'] !== '' ? 'yes' : 'no' )

);



$elementsell_boot_mode = 'full';



if ( elementsell_is_elementor_context() ) {

    if ( elementsell_is_elementor_stub_mode() ) {

        $elementsell_boot_mode = 'stub_mode';

    } elseif ( elementsell_elementor_boot_needs_sync() ) {

        $elementsell_boot_mode = 'minimal_widgets';

    } else {

        $elementsell_boot_mode = 'ultra_minimal';

    }

} elseif ( ! elementsell_is_heavy_full_boot_allowed() ) {

    $elementsell_boot_mode = 'ultra_minimal';

}



elementsell_boot_debug_log(

    'deferred cookie check: present=' . ( $elementsell_deferred_ready ? 'yes' : 'no' )

    . ' transient=' . ( function_exists( 'elementsell_has_editor_deferred_transient' ) && elementsell_has_editor_deferred_transient() ? 'yes' : 'no' )

);



elementsell_boot_debug_log(

    'boot decision: ' . $elementsell_boot_mode

    . ( elementsell_is_elementor_stub_mode() ? ' stub_mode=yes' : '' )

    . ( $elementsell_deferred_ready ? ' deferred_ready=yes' : '' )

    . ' reason=' . elementsell_get_elementor_context_reason()

    . ' editor_cookie=' . ( elementsell_has_editor_session_cookie() ? 'yes' : 'no' )

    . ' heavy_full_boot=' . ( elementsell_is_heavy_full_boot_allowed() ? 'allowed' : 'blocked' )

);



if ( ! elementsell_is_elementor_stub_mode() ) {

    elementsell_boot_debug_require( 'includes/database.php' );

    register_activation_hook( __FILE__, 'elementsell_create_database_tables' );

} else {

    elementsell_boot_debug_log( 'stub mode: database.php skipped' );

}



/**

 * Plné načtení pluginu (admin, platby, automation, demo, …).

 *

 * @return void

 */

function elementsell_boot_full_plugin() {

    if ( ! elementsell_is_heavy_full_boot_allowed() ) {

        elementsell_boot_debug_log( 'full boot aborted: heavy modules blocked for parallel editor request' );



        return;

    }



    $elementsell_automation_bootstrap = PF_PLUGIN_DIR . 'includes/automation/bootstrap-automation.php';



    if ( ELEMENTSELL_AUTOMATION_ENABLED && file_exists( $elementsell_automation_bootstrap ) ) {

        elementsell_boot_debug_require( 'includes/automation/bootstrap-automation.php' );

    }



    $elementsell_demo_courses_bootstrap = PF_PLUGIN_DIR . 'demo-guitar-courses/bootstrap-demo.php';



    if (

        ELEMENTSELL_DEMO_COURSES_ENABLED

        && ! elementsell_is_elementor_context()

        && elementsell_is_heavy_full_boot_allowed()

        && file_exists( $elementsell_demo_courses_bootstrap )

    ) {

        elementsell_boot_debug_require( 'demo-guitar-courses/bootstrap-demo.php' );

    }



    add_action(

        'plugins_loaded',

        static function () {

            if ( elementsell_is_elementor_context() ) {

                return;

            }



            elementsell_maybe_upgrade_database_tables();

        },

        20

    );



    elementsell_boot_debug_require( 'includes/mailing/mailing-functions.php' );

    elementsell_boot_debug_require( 'includes/updates/publish-endpoint-sync.php' );

    elementsell_boot_debug_require( 'includes/billing/billing-functions.php' );

    elementsell_boot_debug_require( 'includes/pages/privacy-page.php' );

    elementsell_boot_debug_require( 'includes/pages/unsubscribe-page.php' );

    elementsell_boot_debug_require( 'includes/pages/course-roles.php' );

    elementsell_boot_debug_require( 'includes/widget-custom-fields.php' );

    elementsell_boot_debug_require( 'includes/upsell/upsell-functions.php' );

    elementsell_boot_debug_require( 'includes/pages/page-access.php' );

    elementsell_boot_debug_require( 'includes/pages/widget-page-ensure.php' );

    elementsell_boot_debug_require( 'includes/payments/payment-widget-credentials.php' );

    elementsell_boot_debug_require( 'includes/bootstrap.php' );



    PF_Bootstrap::init();



    add_action(

        'plugins_loaded',

        static function () {

            if ( ! elementsell_is_elementor_context() ) {

                elementsell_load_runtime_modules();

            }

        },

        5

    );

}



/**

 * Stub boot — lehký start editoru: compat + minimální deps + plné widgety (bez database, sync, reload).

 *

 * @return void

 */

function elementsell_boot_elementor_stub_plugin() {

    $widget_mode = function_exists( 'elementsell_is_elementor_panel_widgets_fallback' )

        && elementsell_is_elementor_panel_widgets_fallback()

        ? 'panel'

        : 'full';



    elementsell_boot_debug_log(

        'stub mode active: light boot + widget controls mode=' . $widget_mode

        . ' (no database, automation, sync, or page reload)'

    );



    if ( 'full' === $widget_mode ) {

        elementsell_boot_debug_require( 'includes/elementor-editor-deps.php' );

        elementsell_boot_elementor_editor_dependencies();

    }

}



/**

 * Minimální závislosti pro plné widget controls v editoru (non-stub cesty).

 *

 * @return void

 */

function elementsell_boot_elementor_widget_dependencies() {

    if ( ! function_exists( 'elementsell_boot_elementor_editor_dependencies' ) ) {

        elementsell_boot_debug_require( 'includes/elementor-editor-deps.php' );

    }



    elementsell_boot_elementor_editor_dependencies();

}



/**

 * Minimální boot v Elementor editoru — úrovně:

 * 0 ultra_minimal: compat + database + lehká registrace widgetů (compat hook)

 * 1 minimal_widgets: navíc elementor-sync (jen post.php?action=elementor)

 *

 * @return void

 */

function elementsell_boot_elementor_editor_plugin() {

    if ( elementsell_is_elementor_stub_mode() ) {

        elementsell_boot_elementor_stub_plugin();



        return;

    }



    elementsell_boot_elementor_widget_dependencies();



    if ( elementsell_has_editor_deferred_cookie() ) {

        elementsell_boot_debug_log(

            'deferred boot: full widgets + full controls enabled'

        );

    }



    if ( ! elementsell_elementor_boot_needs_sync() ) {

        elementsell_boot_debug_log( 'minimal boot level 0 (ultra_minimal: compat + database only)' );



        return;

    }



    if ( function_exists( 'elementsell_should_register_elementor_widgets' ) ) {

        elementsell_boot_debug_log(

            'minimal boot widgets: '

            . ( elementsell_should_register_elementor_widgets() ? 'enabled via compat' : 'skipped_by_test_mode' )

        );

    }



    elementsell_boot_debug_log( 'minimal boot chain start (sync — post.php editor only)' );



    if ( ! ( defined( 'ELEMENTSELL_ELEMENTOR_SAFE_MODE' ) && ELEMENTSELL_ELEMENTOR_SAFE_MODE ) ) {

        elementsell_boot_debug_require( 'includes/elementor-sync.php' );

    }



    elementsell_boot_debug_log( 'minimal boot chain complete' );

}



if ( elementsell_is_elementor_context() ) {

    if ( elementsell_is_elementor_stub_mode() ) {

        elementsell_boot_elementor_stub_plugin();

    } else {

        elementsell_boot_elementor_editor_plugin();

    }

} elseif ( ! elementsell_is_heavy_full_boot_allowed() ) {

    elementsell_boot_debug_log( 'parallel editor request: ultra_minimal only (compat + database)' );

} else {

    elementsell_boot_full_plugin();

}



/*

 * Landing načíst hned při bootu (ne až v runtime modules).

 * Jinak po migraci / při block theme zůstane jen prázdná stránka TT4.

 */

if ( ! elementsell_is_elementor_context() && elementsell_is_landing_enabled() ) {

    require_once PF_PLUGIN_DIR . 'includes/pages/landing-page.php';

}



/**

 * Plné načtení modulů mimo Elementor editor.

 *

 * @return void

 */

function elementsell_load_runtime_modules() {

    static $loaded = false;



    if ( $loaded ) {

        return;

    }



    $loaded = true;



    require_once PF_PLUGIN_DIR . 'includes/storage/sales-stats-cache.php';

    require_once PF_PLUGIN_DIR . 'includes/storage/order-archive.php';

    require_once PF_PLUGIN_DIR . 'includes/storage/landing-leads.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-statistics.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-sales-statistics.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-landing-leads.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-record-search.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-mailing-list.php';

    require_once PF_PLUGIN_DIR . 'includes/integrations/petan-contacts-bridge.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-styles.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-invoice-settings.php';

    add_action('admin_init', 'elementsell_register_invoice_settings');

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-email-log.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-orders.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-order-reminder.php';

    require_once PF_PLUGIN_DIR . 'includes/updates/plugin-release.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-release-publish.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-menu.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-onboarding.php';



    if ( function_exists( 'elementsell_should_sync_publish_endpoint' ) && elementsell_should_sync_publish_endpoint() ) {

        if ( function_exists( 'elementsell_force_sync_publish_endpoint_to_webroot' ) ) {

            elementsell_force_sync_publish_endpoint_to_webroot();

        }



        $simple_publish_bootstrap = PF_PLUGIN_DIR . 'remote-server/platebniformular-publish.php';



        if ( ! is_readable( $simple_publish_bootstrap ) ) {

            $simple_publish_bootstrap = trailingslashit( ABSPATH ) . 'platebniformular-publish.php';

        }



        if ( is_readable( $simple_publish_bootstrap ) ) {

            require_once $simple_publish_bootstrap;

        }

    }

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-updater-diagnostics.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-telemetry-diagnostics.php';

    require_once PF_PLUGIN_DIR . 'includes/elementor-widget-migration.php';

    require_once PF_PLUGIN_DIR . 'includes/billing/billing-thepay.php';

    require_once PF_PLUGIN_DIR . 'includes/telemetry/telemetry-setup-health.php';

    require_once PF_PLUGIN_DIR . 'includes/telemetry/telemetry.php';

    require_once PF_PLUGIN_DIR . 'includes/billing/billing-handlers.php';

    require_once PF_PLUGIN_DIR . 'includes/billing/billing-charge.php';

    require_once PF_PLUGIN_DIR . 'includes/billing/billing-cron.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-cron-log.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-billing.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-billing-invoices.php';

    require_once PF_PLUGIN_DIR . 'includes/orders/order-functions.php';

    require_once PF_PLUGIN_DIR . 'includes/orders/order-spam.php';

    require_once PF_PLUGIN_DIR . 'includes/integrations/meta-capi.php';

    require_once PF_PLUGIN_DIR . 'includes/integrations/meta-pixel.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-meta-capi.php';

    require_once PF_PLUGIN_DIR . 'includes/invoices/invoice-functions.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-issued-invoices.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-invoice-links.php';

    require_once PF_PLUGIN_DIR . 'includes/orders/order-profile.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-user-roles.php';

    require_once PF_PLUGIN_DIR . 'includes/orders/order-access.php';

    require_once PF_PLUGIN_DIR . 'includes/pages/thank-you-page.php';



    if ( elementsell_is_landing_enabled() && ! function_exists( 'elementsell_load_landing_page_template' ) ) {

        require_once PF_PLUGIN_DIR . 'includes/pages/landing-page.php';

    }



    require_once PF_PLUGIN_DIR . 'includes/pages/login-page.php';

    require_once PF_PLUGIN_DIR . 'includes/security/restrict-admin.php';

    require_once PF_PLUGIN_DIR . 'includes/invoices/invoice-export.php';

    require_once PF_PLUGIN_DIR . 'includes/invoices/invoice-zip-export.php';

    require_once PF_PLUGIN_DIR . 'includes/invoices/invoice-pdf.php';

    require_once PF_PLUGIN_DIR . 'includes/billing/billing-invoice.php';

    require_once PF_PLUGIN_DIR . 'includes/emails/email-template.php';

    require_once PF_PLUGIN_DIR . 'includes/emails/email-send.php';

    require_once PF_PLUGIN_DIR . 'includes/emails/email-osloveni.php';

    require_once PF_PLUGIN_DIR . 'includes/emails/email-variables.php';

    require_once PF_PLUGIN_DIR . 'includes/emails/email-log.php';

    require_once PF_PLUGIN_DIR . 'includes/emails/email-paid.php';

    require_once PF_PLUGIN_DIR . 'includes/emails/email-reminders.php';

    require_once PF_PLUGIN_DIR . 'includes/emails/email-reminders-cron.php';

    require_once PF_PLUGIN_DIR . 'includes/billing/billing-card-email.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-verify-thepay.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-status.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-return.php';

    require_once PF_PLUGIN_DIR . 'includes/admin/admin-invoice-detail.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-validate.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-handler.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-save.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-fio.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-fio-verify.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-thepay.php';

    require_once PF_PLUGIN_DIR . 'includes/payments/payment-thepay-methods.php';

}

