wpdb = $wpdb; } public function run() { return $this->create_table() && $this->add_mo_value_field_if_does_not_exist(); } private function create_table() { $table_name = $this->wpdb->prefix . 'icl_mo_files_domains'; $this->wpdb->query( "DROP TABLE IF EXISTS `{$table_name}`" ); $sql = str_replace( 'PREFIX', $this->wpdb->prefix, self::$sql ); $sql = $this->wpdb->prepare( $sql, array( WPML_ST_MO_File::NOT_IMPORTED ) ); $sql .= $this->get_charset_collate(); return false !== $this->wpdb->query( $sql ); } private function add_mo_value_field_if_does_not_exist() { $result = true; $table_name = $this->wpdb->prefix . 'icl_string_translations'; if ( 0 === count( $this->wpdb->get_results( "SHOW COLUMNS FROM `{$table_name}` LIKE 'mo_string'" ) ) ) { $sql = " ALTER TABLE {$table_name} ADD COLUMN `mo_string` TEXT NULL DEFAULT NULL AFTER `value`; "; $result = false !== $this->wpdb->query( $sql ); } return $result; } public function run_ajax() { return $this->run(); } public function run_frontend() { return $this->run(); } public static function get_command_id() { return __CLASS__ . '_3' ; } /** * @return string */ private function get_charset_collate() { $charset_collate = ''; if ( method_exists( $this->wpdb, 'has_cap' ) && $this->wpdb->has_cap( 'collation' ) ) { $charset_collate = $this->wpdb->get_charset_collate(); } return $charset_collate; } }