PK     Qz,]P  P    LoadReviewxCreateSiteTable.phpnu         <?php

namespace Rvx\Handlers\RvxInit;

class LoadReviewxCreateSiteTable
{
    /**
     * Invokes the process to ensure the table exists.
     */
    public function init()
    {
        if (!$this->is_table_exists()) {
            $this->create_table();
        }
    }
    /**
     * Checks if the table exists in the database.
     *
     * @return bool True if the table exists, false otherwise.
     */
    private function is_table_exists()
    {
        global $wpdb;
        $table_name = $this->get_table_name();
        return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table_name)) === $table_name;
    }
    /**
     * Creates the database table if it does not exist.
     */
    private function create_table()
    {
        global $wpdb;
        $table_name = $this->get_table_name();
        $charset_collate = $wpdb->get_charset_collate();
        $sql = "CREATE TABLE {$table_name} (\n            id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n            name VARCHAR(255) NOT NULL,\n            site_id INT(11) NOT NULL,\n            uid VARCHAR(32) NOT NULL,\n            domain VARCHAR(255) NOT NULL,\n            url VARCHAR(255) NOT NULL,\n            locale CHAR(10) NOT NULL,\n            email VARCHAR(100) NOT NULL,\n            secret VARCHAR(100) NOT NULL,\n            is_saas_sync TINYINT(1) DEFAULT 0,\n            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n            updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n            PRIMARY KEY (id)\n        ) {$charset_collate};";
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        dbDelta($sql);
    }
    /**
     * Returns the table name.
     *
     * @return string Fully qualified table name.
     */
    private function get_table_name()
    {
        global $wpdb;
        return $wpdb->prefix . 'rvx_sites';
    }
}
PK     Qz,]ЧB  B  %  ReviewXoldPluginDeactivateHandler.phpnu         <?php

namespace Rvx\Handlers\RvxInit;

class ReviewXoldPluginDeactivateHandler
{
    /**
     * Handle the deactivation of the old ReviewX Pro plugin.
     *
     * This checks if the old ReviewX Pro plugin is active and deactivates it.
     */
    public function __invoke()
    {
        $reviewxProPath = 'reviewx-pro/reviewx-pro.php';
        // Path to the plugin to deactivate
        // Check if the plugin is active
        if (is_plugin_active($reviewxProPath)) {
            deactivate_plugins($reviewxProPath);
            // Deactivate the plugin
        }
    }
}
PK     Qz,]%2S        ResetProductMetaHandler.phpnu         <?php

namespace Rvx\Handlers\RvxInit;

use Rvx\Services\Api\LoginService;
class ResetProductMetaHandler
{
    public function __invoke($upgrader_object, $options)
    {
        (new LoginService())->resetPostMeta();
    }
}
PK     Qz,]`'H?    $  UpgradeReviewxDeactiveProHandler.phpnu         <?php

namespace Rvx\Handlers\RvxInit;

use Rvx\Api\AuthApi;
class UpgradeReviewxDeactiveProHandler
{
    public function __invoke($upgrader_object, $options)
    {
        if ($options['type'] === 'plugin' && isset($options['plugins'])) {
            // Your plugin's main file
            $reviewxFilePath = plugin_basename(__FILE__);
            // Check if your plugin is being updated
            if (\in_array($reviewxFilePath, $options['plugins'], \true)) {
                $reviewxProDeactive = 'reviewx-pro/reviewx-pro.php';
                // Path to the plugin to deactivate
                // Check if the target plugin is active
                if (is_plugin_active($reviewxProDeactive)) {
                    deactivate_plugins($reviewxProDeactive);
                    // Deactivate the plugin
                }
            }
            $response = wp_remote_get("https://api.wordpress.org/plugins/info/1.0/reviewx.json");
            if (!\is_wp_error($response)) {
                $plugin_data = \json_decode(wp_remote_retrieve_body($response));
                if ($plugin_data && isset($plugin_data->version)) {
                    global $wpdb;
                    $rvxSites = $wpdb->prefix . 'rvx_sites';
                    $uid = $wpdb->get_var("SELECT uid FROM {$rvxSites} ORDER BY id DESC LIMIT 1");
                    $plugin_version = $plugin_data->version;
                    if ($uid) {
                        (new AuthApi())->changePluginStatus(['site_uid' => $uid, 'status' => 1, 'plugin_version' => $plugin_version ?? RVX_VERSION, 'wp_version' => get_bloginfo('version')]);
                    }
                }
            }
        }
    }
}
PK     Qz,]Jn|        PageBuilderHandler.phpnu         <?php

namespace Rvx\Handlers\RvxInit;

class PageBuilderHandler
{
    public function __invoke()
    {
        if (\class_exists('\\Elementor\\Plugin')) {
            \Rvx\Elementor\Classes\Starter::instance();
        }
    }
}
PK       Qz,]P  P                  LoadReviewxCreateSiteTable.phpnu         PK       Qz,]ЧB  B  %              ReviewXoldPluginDeactivateHandler.phpnu         PK       Qz,]%2S                  5
  ResetProductMetaHandler.phpnu         PK       Qz,]`'H?    $            a  UpgradeReviewxDeactiveProHandler.phpnu         PK       Qz,]Jn|                  G  PageBuilderHandler.phpnu         PK        s 