'', 'service_enabled'=> false, 'cache_duration' => 24, 'cf7_forms' => [], 'wc_enable' => true, 'reg_enable' => true, 'gf_forms' => [], 'wpf_forms' => [], 'nf_forms' => [], ] ); } self::create_cache_table(); } /** Create or update the {prefix}zbounce_eval_email_cache table. */ public static function create_cache_table() { global $wpdb; $table = $wpdb->prefix . 'zbounce_eval_email_cache'; $charset = $wpdb->get_charset_collate(); $sql = " CREATE TABLE {$table} ( id mediumint(9) NOT NULL AUTO_INCREMENT, email_hash varchar(64) NOT NULL, validation_data longtext NOT NULL, created datetime NOT NULL, PRIMARY KEY (id), UNIQUE KEY email_hash (email_hash) ) {$charset}; "; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $sql ); } /** * One-time upgrade steps, keyed by the stored schema version. * 1.2.6 renamed the settings option and the cache table to the zbounce_eval_ prefix. */ public static function maybe_upgrade() { if ( self::DB_VERSION === get_option( 'zbounce_eval_db_version' ) ) { return; } $legacy = get_option( 'zb_email_validator_settings' ); if ( is_array( $legacy ) && false === get_option( Settings::OPTION_KEY ) ) { add_option( Settings::OPTION_KEY, $legacy ); delete_option( 'zb_email_validator_settings' ); } global $wpdb; // Identifiers are built from the trusted WordPress prefix only. $old_table = esc_sql( $wpdb->prefix . 'zb_email_cache' ); $new_table = esc_sql( $wpdb->prefix . 'zbounce_eval_email_cache' ); // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $has_old = $old_table === $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $old_table ) ); $has_new = $new_table === $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $new_table ) ); if ( $has_old && ! $has_new ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $wpdb->query( "RENAME TABLE {$old_table} TO {$new_table}" ); } // phpcs:enable self::create_cache_table(); update_option( 'zbounce_eval_db_version', self::DB_VERSION, true ); } public static function deactivate() { // Ничего не удаляем, чтобы не потерять кэш и настройки } public static function add_admin_menu() { add_options_page( __( 'ZBounce Email Validator', 'zbounce-email-validator' ), __( 'ZBounce Email', 'zbounce-email-validator' ), 'manage_options', 'zbounce-email-validator', [ __CLASS__, 'render_settings_page' ] ); } public static function render_settings_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } require ZBOUNCE_EVAL_PATH . 'templates/settings-page.php'; } }