class-wpml-st-upgrade-db-longtext-string-value.php
1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* WPML_ST_Upgrade_DB_Longtext_String_Value class file.
*
* @package wpml-string-translation
*/
/**
* Class WPML_ST_Upgrade_DB_Longtext_String_Value
*/
class WPML_ST_Upgrade_DB_Longtext_String_Value implements IWPML_St_Upgrade_Command {
/**
* WP db instance.
*
* @var wpdb
*/
private $wpdb;
/**
* WPML_ST_Upgrade_DB_Longtext_String_Value constructor.
*
* @param wpdb $wpdb WP db instance.
*/
public function __construct( wpdb $wpdb ) {
$this->wpdb = $wpdb;
}
/**
* Run upgrade.
*
* @return bool
*/
public function run() {
$result = true;
$table_name = $this->wpdb->prefix . 'icl_strings';
if ( count( (array) $this->wpdb->get_results( "SHOW TABLES LIKE '{$table_name}'" ) ) ) {
$sql = "
ALTER TABLE {$table_name}
MODIFY COLUMN `value` LONGTEXT NOT NULL;
";
$result = false !== $this->wpdb->query( $sql );
}
$table_name = $this->wpdb->prefix . 'icl_string_translations';
if ( count( (array) $this->wpdb->get_results( "SHOW TABLES LIKE '{$table_name}'" ) ) ) {
$sql = "
ALTER TABLE {$table_name}
MODIFY COLUMN `value` LONGTEXT NULL DEFAULT NULL,
MODIFY COLUMN `mo_string` LONGTEXT NULL DEFAULT NULL;
";
$result = ( false !== $this->wpdb->query( $sql ) ) && $result;
}
return $result;
}
/**
* Run upgrade in ajax.
*
* @return bool
*/
public function run_ajax() {
return $this->run();
}
/**
* Run upgrade on frontend.
*
* @return bool
*/
public function run_frontend() {
return $this->run();
}
/**
* Get command id.
*
* @return string
*/
public static function get_command_id() {
return __CLASS__;
}
}