WPML notice: Upgrades to this version are only supported from versions %1$s and above. To upgrade from version %2$s, first, download 2.0.4, do the DB upgrade and then go to this version.', 'sitepress' ),
'1.7.0',
get_option( 'icl_sitepress_version' ),
' href="http://downloads.wordpress.org/plugin/sitepress-multilingual-cms.2.0.4.zip"'
);
?>
prefix . $table_name, DB_NAME );
$sql = $wpdb->prepare( $query, $args );
$column_exists = $wpdb->get_var( $sql );
return (bool) $column_exists;
}
function icl_table_index_exists( $table_name, $index_name ) {
global $wpdb;
$query = '
SELECT count(*) FROM information_schema.STATISTICS
WHERE INDEX_NAME = %s AND TABLE_NAME = %s AND TABLE_SCHEMA = %s;
';
$args = array( $index_name, $wpdb->prefix . $table_name, DB_NAME );
$sql = $wpdb->prepare( $query, $args );
$column_exists = $wpdb->get_var( $sql );
return (bool) $column_exists;
}
function icl_alter_table_columns( $table_name, $column_definitions ) {
global $wpdb;
$result = false;
if ( ! is_array( $column_definitions ) ) {
$column_definitions = array( $column_definitions );
}
$query = 'ALTER TABLE `' . $wpdb->prefix . $table_name . '` ';
$args = array();
$counter = 0;
$query_parts = array();
foreach ( $column_definitions as $column_definition ) {
if ( isset( $column_definition['action'] ) && $column_definition['action'] == 'ADD' ) {
$required_keys = array(
'action',
'name',
'type',
);
} else {
$required_keys = array(
'action',
'name',
);
}
if ( icl_array_has_required_keys( $column_definition, $required_keys ) ) {
if ( $counter > 0 ) {
$query_parts[] = ',';
}
$query_parts[] = $column_definition['action'];
$query_parts[] = '`' . $column_definition['name'] . '`';
if ( isset( $column_definition['type'] ) ) {
$query_parts[] = $column_definition['type'];
}
if ( isset( $column_definition['charset'] ) ) {
$query_parts[] = 'CHARACTER SET ' . $column_definition['charset'];
}
if ( isset( $column_definition['null'] ) ) {
$query_parts[] = $column_definition['null'] ? 'NULL' : 'NOT NULL';
}
if ( isset( $column_definition['default'] ) ) {
$query_parts[] = 'DEFAULT %s';
$args[] = $column_definition['default'];
}
if ( isset( $column_definition['after'] ) ) {
$query_parts[] = 'AFTER `' . $column_definition['after'] . '`';
}
$counter ++;
} else {
$args = array();
break;
}
}
if ( $query_parts ) {
$query .= implode( ' ', $query_parts );
if ( sizeof( $args ) > 0 ) {
$sql = $wpdb->prepare( $query, $args );
} else {
$sql = $query;
}
$result = $wpdb->query( $sql );
}
return $result;
}
function icl_drop_table_index( $table_name, $index_name ) {
global $wpdb;
$query = 'ALTER TABLE `' . $wpdb->prefix . $table_name . '` ';
$query .= 'DROP INDEX `' . $index_name . '`;';
return $wpdb->query( $query );
}
function icl_create_table_index( $table_name, $index_definition ) {
global $wpdb;
$result = false;
$required_keys = array(
'name',
'columns',
);
if ( icl_array_has_required_keys( $index_definition, $required_keys ) && $index_definition['columns'] ) {
$query = 'ALTER TABLE `' . $wpdb->prefix . $table_name . '` ';
$query .= 'ADD ';
if ( isset( $index_definition['choice'] ) ) {
$query .= $index_definition['choice'] . ' ';
}
$query .= '`' . $index_definition['name'] . '` ';
$query .= '(`' . implode( '`, `', $index_definition['columns'] ) . '`) ';
if ( isset( $index_definition['type'] ) ) {
$query .= 'USING ' . $index_definition['type'] . ' ';
}
$result = $wpdb->query( $query );
}
return $result;
}
/**
* @param array