| Server IP : 87.229.120.60 / Your IP : 216.73.216.245 Web Server : Apache System : Linux outside 5.4.8_Algonet_ZeroMAC_0.9.4.8 #6 SMP Mon Feb 3 20:36:07 CET 2020 x86_64 User : server ( 1002) PHP Version : 8.3.20 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,curl_multi_exec,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/faktorteam/www/wp-content/plugins/wpforms-lite/src/ |
Upload File : |
<?php
namespace WPForms;
/**
* Class Migrations handles both Lite and Pro plugin upgrade routines.
*
* @since 1.5.9
*/
class Migrations {
/**
* WP option name to store the migration version.
*
* @since 1.5.9
*/
const OPTION_NAME = 'wpforms_version_lite';
/**
* Have we migrated?
*
* @since 1.5.9
*
* @var bool
*/
private $is_migrated = false;
/**
* Class init.
*
* @since 1.5.9
*/
public function init() {
$this->hooks();
}
/**
* General hooks.
*
* @since 1.5.9
*/
private function hooks() {
add_action( 'wpforms_loaded', array( $this, 'maybe_migrate' ), -9999 );
add_action( 'wpforms_loaded', array( $this, 'update_version' ), -9998 );
}
/**
* Run the migration if needed.
*
* @since 1.5.9
*/
public function maybe_migrate() {
if ( ! is_admin() ) {
return;
}
// Retrieve the last known version.
$version = get_option( self::OPTION_NAME );
if ( empty( $version ) ) {
$version = '0.0.1';
}
$this->migrate( $version );
}
/**
* Run the migrations for a specific version.
*
* @since 1.5.9
*
* @param string $version Version to run the migrations for.
*/
private function migrate( $version ) {
if ( version_compare( $version, '1.5.9', '<' ) ) {
$this->v159_upgrade();
}
if ( version_compare( $version, '1.6.7.2', '<' ) ) {
$this->v1672_upgrade();
}
}
/**
* If upgrade has occurred, update version options in database.
*
* @since 1.5.9
*/
public function update_version() {
if ( ! is_admin() ) {
return;
}
if ( ! $this->is_migrated ) {
return;
}
update_option( self::OPTION_NAME, WPFORMS_VERSION );
}
/**
* Do all the required migrations for WPForms v1.5.9.
*
* @since 1.5.9
*/
private function v159_upgrade() {
$meta = wpforms()->get( 'tasks_meta' );
// Create the table if it doesn't exist.
if ( $meta && ! $meta->table_exists() ) {
$meta->create_table();
}
$this->is_migrated = true;
}
/**
* Do all the required migrations for WPForms v1.6.7.2.
*
* @since 1.6.7.2
*/
private function v1672_upgrade() {
$review = get_option( 'wpforms_review' );
if ( empty( $review ) ) {
return;
}
$notices = get_option( 'wpforms_admin_notices', [] );
if ( isset( $notices['review_request'] ) ) {
return;
}
$notices['review_request'] = $review;
update_option( 'wpforms_admin_notices', $notices, true );
delete_option( 'wpforms_review' );
}
}