upgrade_130()
Execute changes made in WordPress 1.5.
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
upgrade_130();
Заметки
- Global. wpdb. $wpdb WordPress database abstraction object.
Список изменений
С версии 1.5.0 | Введена. |
Код upgrade_130() upgrade 130 WP 6.7.1
function upgrade_130() { global $wpdb; // Remove extraneous backslashes. $posts = $wpdb->get_results( "SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts" ); if ( $posts ) { foreach ( $posts as $post ) { $post_content = addslashes( deslash( $post->post_content ) ); $post_title = addslashes( deslash( $post->post_title ) ); $post_excerpt = addslashes( deslash( $post->post_excerpt ) ); if ( empty( $post->guid ) ) { $guid = get_permalink( $post->ID ); } else { $guid = $post->guid; } $wpdb->update( $wpdb->posts, compact( 'post_title', 'post_content', 'post_excerpt', 'guid' ), array( 'ID' => $post->ID ) ); } } // Remove extraneous backslashes. $comments = $wpdb->get_results( "SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments" ); if ( $comments ) { foreach ( $comments as $comment ) { $comment_content = deslash( $comment->comment_content ); $comment_author = deslash( $comment->comment_author ); $wpdb->update( $wpdb->comments, compact( 'comment_content', 'comment_author' ), array( 'comment_ID' => $comment->comment_ID ) ); } } // Remove extraneous backslashes. $links = $wpdb->get_results( "SELECT link_id, link_name, link_description FROM $wpdb->links" ); if ( $links ) { foreach ( $links as $link ) { $link_name = deslash( $link->link_name ); $link_description = deslash( $link->link_description ); $wpdb->update( $wpdb->links, compact( 'link_name', 'link_description' ), array( 'link_id' => $link->link_id ) ); } } $active_plugins = __get_option( 'active_plugins' ); /* * If plugins are not stored in an array, they're stored in the old * newline separated format. Convert to new format. */ if ( ! is_array( $active_plugins ) ) { $active_plugins = explode( "\n", trim( $active_plugins ) ); update_option( 'active_plugins', $active_plugins ); } // Obsolete tables. $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues' ); $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes' ); $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups' ); $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options' ); // Update comments table to use comment_type. $wpdb->query( "UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'" ); $wpdb->query( "UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'" ); // Some versions have multiple duplicate option_name rows with the same values. $options = $wpdb->get_results( "SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name" ); foreach ( $options as $option ) { if ( $option->dupes > 1 ) { // Could this be done in the query? $limit = $option->dupes - 1; $dupe_ids = $wpdb->get_col( $wpdb->prepare( "SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit ) ); if ( $dupe_ids ) { $dupe_ids = implode( ',', $dupe_ids ); $wpdb->query( "DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)" ); } } } make_site_theme(); }