50 } |
50 } |
51 |
51 |
52 wp_check_mysql_version(); |
52 wp_check_mysql_version(); |
53 wp_cache_flush(); |
53 wp_cache_flush(); |
54 make_db_current_silent(); |
54 make_db_current_silent(); |
|
55 |
|
56 /* |
|
57 * Ensure update checks are delayed after installation. |
|
58 * |
|
59 * This prevents users being presented with a maintenance mode screen |
|
60 * immediately after installation. |
|
61 */ |
|
62 wp_unschedule_hook( 'wp_version_check' ); |
|
63 wp_unschedule_hook( 'wp_update_plugins' ); |
|
64 wp_unschedule_hook( 'wp_update_themes' ); |
|
65 |
|
66 wp_schedule_event( time() + HOUR_IN_SECONDS, 'twicedaily', 'wp_version_check' ); |
|
67 wp_schedule_event( time() + ( 1.5 * HOUR_IN_SECONDS ), 'twicedaily', 'wp_update_plugins' ); |
|
68 wp_schedule_event( time() + ( 2 * HOUR_IN_SECONDS ), 'twicedaily', 'wp_update_themes' ); |
|
69 |
55 populate_options(); |
70 populate_options(); |
56 populate_roles(); |
71 populate_roles(); |
57 |
72 |
58 update_option( 'blogname', $blog_title ); |
73 update_option( 'blogname', $blog_title ); |
59 update_option( 'admin_email', $user_email ); |
74 update_option( 'admin_email', $user_email ); |
145 * |
160 * |
146 * @since 2.1.0 |
161 * @since 2.1.0 |
147 * |
162 * |
148 * @global wpdb $wpdb WordPress database abstraction object. |
163 * @global wpdb $wpdb WordPress database abstraction object. |
149 * @global WP_Rewrite $wp_rewrite WordPress rewrite component. |
164 * @global WP_Rewrite $wp_rewrite WordPress rewrite component. |
150 * @global string $table_prefix |
165 * @global string $table_prefix The database table prefix. |
151 * |
166 * |
152 * @param int $user_id User ID. |
167 * @param int $user_id User ID. |
153 */ |
168 */ |
154 function wp_install_defaults( $user_id ) { |
169 function wp_install_defaults( $user_id ) { |
155 global $wpdb, $wp_rewrite, $table_prefix; |
170 global $wpdb, $wp_rewrite, $table_prefix; |
157 // Default category. |
172 // Default category. |
158 $cat_name = __( 'Uncategorized' ); |
173 $cat_name = __( 'Uncategorized' ); |
159 /* translators: Default category slug. */ |
174 /* translators: Default category slug. */ |
160 $cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) ); |
175 $cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) ); |
161 |
176 |
162 if ( global_terms_enabled() ) { |
177 $cat_id = 1; |
163 $cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) ); |
|
164 if ( null == $cat_id ) { |
|
165 $wpdb->insert( |
|
166 $wpdb->sitecategories, |
|
167 array( |
|
168 'cat_ID' => 0, |
|
169 'cat_name' => $cat_name, |
|
170 'category_nicename' => $cat_slug, |
|
171 'last_updated' => current_time( 'mysql', true ), |
|
172 ) |
|
173 ); |
|
174 $cat_id = $wpdb->insert_id; |
|
175 } |
|
176 update_option( 'default_category', $cat_id ); |
|
177 } else { |
|
178 $cat_id = 1; |
|
179 } |
|
180 |
178 |
181 $wpdb->insert( |
179 $wpdb->insert( |
182 $wpdb->terms, |
180 $wpdb->terms, |
183 array( |
181 array( |
184 'term_id' => $cat_id, |
182 'term_id' => $cat_id, |
366 if ( is_multisite() ) { |
364 if ( is_multisite() ) { |
367 // Disable by default unless the suggested content is provided. |
365 // Disable by default unless the suggested content is provided. |
368 $privacy_policy_content = get_site_option( 'default_privacy_policy_content' ); |
366 $privacy_policy_content = get_site_option( 'default_privacy_policy_content' ); |
369 } else { |
367 } else { |
370 if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) { |
368 if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) { |
371 include_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php'; |
369 require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php'; |
372 } |
370 } |
373 |
371 |
374 $privacy_policy_content = WP_Privacy_Policy_Content::get_default_content(); |
372 $privacy_policy_content = WP_Privacy_Policy_Content::get_default_content(); |
375 } |
373 } |
376 |
374 |
455 |
453 |
456 // Remove all perms except for the login user. |
454 // Remove all perms except for the login user. |
457 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level' ) ); |
455 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level' ) ); |
458 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities' ) ); |
456 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities' ) ); |
459 |
457 |
460 // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) |
458 /* |
461 // TODO: Get previous_blog_id. |
459 * Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) |
|
460 * TODO: Get previous_blog_id. |
|
461 */ |
462 if ( ! is_super_admin( $user_id ) && 1 != $user_id ) { |
462 if ( ! is_super_admin( $user_id ) && 1 != $user_id ) { |
463 $wpdb->delete( |
463 $wpdb->delete( |
464 $wpdb->usermeta, |
464 $wpdb->usermeta, |
465 array( |
465 array( |
466 'user_id' => $user_id, |
466 'user_id' => $user_id, |
521 $test_url = get_permalink( $first_post->ID ); |
521 $test_url = get_permalink( $first_post->ID ); |
522 } |
522 } |
523 |
523 |
524 /* |
524 /* |
525 * Send a request to the site, and check whether |
525 * Send a request to the site, and check whether |
526 * the 'x-pingback' header is returned as expected. |
526 * the 'X-Pingback' header is returned as expected. |
527 * |
527 * |
528 * Uses wp_remote_get() instead of wp_remote_head() because web servers |
528 * Uses wp_remote_get() instead of wp_remote_head() because web servers |
529 * can block head requests. |
529 * can block head requests. |
530 */ |
530 */ |
531 $response = wp_remote_get( $test_url, array( 'timeout' => 5 ) ); |
531 $response = wp_remote_get( $test_url, array( 'timeout' => 5 ) ); |
532 $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' ); |
532 $x_pingback_header = wp_remote_retrieve_header( $response, 'X-Pingback' ); |
533 $pretty_permalinks = $x_pingback_header && get_bloginfo( 'pingback_url' ) === $x_pingback_header; |
533 $pretty_permalinks = $x_pingback_header && get_bloginfo( 'pingback_url' ) === $x_pingback_header; |
534 |
534 |
535 if ( $pretty_permalinks ) { |
535 if ( $pretty_permalinks ) { |
536 return true; |
536 return true; |
537 } |
537 } |
638 * |
638 * |
639 * @since 2.1.0 |
639 * @since 2.1.0 |
640 * |
640 * |
641 * @global int $wp_current_db_version The old (current) database version. |
641 * @global int $wp_current_db_version The old (current) database version. |
642 * @global int $wp_db_version The new database version. |
642 * @global int $wp_db_version The new database version. |
643 * @global wpdb $wpdb WordPress database abstraction object. |
|
644 */ |
643 */ |
645 function wp_upgrade() { |
644 function wp_upgrade() { |
646 global $wp_current_db_version, $wp_db_version, $wpdb; |
645 global $wp_current_db_version, $wp_db_version; |
647 |
646 |
648 $wp_current_db_version = __get_option( 'db_version' ); |
647 $wp_current_db_version = __get_option( 'db_version' ); |
649 |
648 |
650 // We are up to date. Nothing to do. |
649 // We are up to date. Nothing to do. |
651 if ( $wp_db_version == $wp_current_db_version ) { |
650 if ( $wp_db_version == $wp_current_db_version ) { |
668 |
667 |
669 if ( is_multisite() ) { |
668 if ( is_multisite() ) { |
670 update_site_meta( get_current_blog_id(), 'db_version', $wp_db_version ); |
669 update_site_meta( get_current_blog_id(), 'db_version', $wp_db_version ); |
671 update_site_meta( get_current_blog_id(), 'db_last_updated', microtime() ); |
670 update_site_meta( get_current_blog_id(), 'db_last_updated', microtime() ); |
672 } |
671 } |
|
672 |
|
673 delete_transient( 'wp_core_block_css_files' ); |
673 |
674 |
674 /** |
675 /** |
675 * Fires after a site is fully upgraded. |
676 * Fires after a site is fully upgraded. |
676 * |
677 * |
677 * @since 3.9.0 |
678 * @since 3.9.0 |
1003 $wpdb->query( "UPDATE $wpdb->posts SET post_modified = post_date" ); |
1016 $wpdb->query( "UPDATE $wpdb->posts SET post_modified = post_date" ); |
1004 $wpdb->query( "UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'" ); |
1017 $wpdb->query( "UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'" ); |
1005 $wpdb->query( "UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); |
1018 $wpdb->query( "UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); |
1006 $wpdb->query( "UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); |
1019 $wpdb->query( "UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); |
1007 } |
1020 } |
1008 |
|
1009 } |
1021 } |
1010 |
1022 |
1011 /** |
1023 /** |
1012 * Execute changes made in WordPress 1.5. |
1024 * Execute changes made in WordPress 1.5. |
1013 * |
1025 * |
1301 $term_group = $exists[0]->term_group; |
1313 $term_group = $exists[0]->term_group; |
1302 $id = $exists[0]->term_id; |
1314 $id = $exists[0]->term_id; |
1303 $num = 2; |
1315 $num = 2; |
1304 do { |
1316 do { |
1305 $alt_slug = $slug . "-$num"; |
1317 $alt_slug = $slug . "-$num"; |
1306 $num++; |
1318 ++$num; |
1307 $slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) ); |
1319 $slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) ); |
1308 } while ( $slug_check ); |
1320 } while ( $slug_check ); |
1309 |
1321 |
1310 $slug = $alt_slug; |
1322 $slug = $alt_slug; |
1311 |
1323 |
1653 */ |
1664 */ |
1654 function upgrade_290() { |
1665 function upgrade_290() { |
1655 global $wp_current_db_version; |
1666 global $wp_current_db_version; |
1656 |
1667 |
1657 if ( $wp_current_db_version < 11958 ) { |
1668 if ( $wp_current_db_version < 11958 ) { |
1658 // Previously, setting depth to 1 would redundantly disable threading, |
1669 /* |
1659 // but now 2 is the minimum depth to avoid confusion. |
1670 * Previously, setting depth to 1 would redundantly disable threading, |
|
1671 * but now 2 is the minimum depth to avoid confusion. |
|
1672 */ |
1660 if ( get_option( 'thread_comments_depth' ) == '1' ) { |
1673 if ( get_option( 'thread_comments_depth' ) == '1' ) { |
1661 update_option( 'thread_comments_depth', 2 ); |
1674 update_option( 'thread_comments_depth', 2 ); |
1662 update_option( 'thread_comments', 0 ); |
1675 update_option( 'thread_comments', 0 ); |
1663 } |
1676 } |
1664 } |
1677 } |
1754 $id = strtolower( $name ); |
1766 $id = strtolower( $name ); |
1755 if ( isset( $wp_registered_widgets[ $id ] ) ) { |
1767 if ( isset( $wp_registered_widgets[ $id ] ) ) { |
1756 $_sidebars_widgets[ $index ][ $i ] = $id; |
1768 $_sidebars_widgets[ $index ][ $i ] = $id; |
1757 continue; |
1769 continue; |
1758 } |
1770 } |
|
1771 |
1759 $id = sanitize_title( $name ); |
1772 $id = sanitize_title( $name ); |
1760 if ( isset( $wp_registered_widgets[ $id ] ) ) { |
1773 if ( isset( $wp_registered_widgets[ $id ] ) ) { |
1761 $_sidebars_widgets[ $index ][ $i ] = $id; |
1774 $_sidebars_widgets[ $index ][ $i ] = $id; |
1762 continue; |
1775 continue; |
1763 } |
1776 } |
1764 |
1777 |
1765 $found = false; |
1778 $found = false; |
1766 |
1779 |
1767 foreach ( $wp_registered_widgets as $widget_id => $widget ) { |
1780 foreach ( $wp_registered_widgets as $widget_id => $widget ) { |
1768 if ( strtolower( $widget['name'] ) == strtolower( $name ) ) { |
1781 if ( strtolower( $widget['name'] ) === strtolower( $name ) ) { |
1769 $_sidebars_widgets[ $index ][ $i ] = $widget['id']; |
1782 $_sidebars_widgets[ $index ][ $i ] = $widget['id']; |
1770 $found = true; |
1783 |
|
1784 $found = true; |
1771 break; |
1785 break; |
1772 } elseif ( sanitize_title( $widget['name'] ) == sanitize_title( $name ) ) { |
1786 } elseif ( sanitize_title( $widget['name'] ) === sanitize_title( $name ) ) { |
1773 $_sidebars_widgets[ $index ][ $i ] = $widget['id']; |
1787 $_sidebars_widgets[ $index ][ $i ] = $widget['id']; |
1774 $found = true; |
1788 |
|
1789 $found = true; |
1775 break; |
1790 break; |
1776 } |
1791 } |
1777 } |
1792 } |
1778 |
1793 |
1779 if ( $found ) { |
1794 if ( $found ) { |
1850 } |
1865 } |
1851 |
1866 |
1852 if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { |
1867 if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { |
1853 $meta_keys = array(); |
1868 $meta_keys = array(); |
1854 foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { |
1869 foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { |
1855 if ( false !== strpos( $name, '-' ) ) { |
1870 if ( str_contains( $name, '-' ) ) { |
1856 $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
1871 $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
1857 } |
1872 } |
1858 } |
1873 } |
1859 if ( $meta_keys ) { |
1874 if ( $meta_keys ) { |
1860 $meta_keys = implode( "', '", $meta_keys ); |
1875 $meta_keys = implode( "', '", $meta_keys ); |
2297 function upgrade_600() { |
2317 function upgrade_600() { |
2298 global $wp_current_db_version; |
2318 global $wp_current_db_version; |
2299 |
2319 |
2300 if ( $wp_current_db_version < 53011 ) { |
2320 if ( $wp_current_db_version < 53011 ) { |
2301 wp_update_user_counts(); |
2321 wp_update_user_counts(); |
|
2322 } |
|
2323 } |
|
2324 |
|
2325 /** |
|
2326 * Executes changes made in WordPress 6.3.0. |
|
2327 * |
|
2328 * @ignore |
|
2329 * @since 6.3.0 |
|
2330 * |
|
2331 * @global int $wp_current_db_version The old (current) database version. |
|
2332 */ |
|
2333 function upgrade_630() { |
|
2334 global $wp_current_db_version; |
|
2335 |
|
2336 if ( $wp_current_db_version < 55853 ) { |
|
2337 if ( ! is_multisite() ) { |
|
2338 // Replace non-autoload option can_compress_scripts with autoload option, see #55270 |
|
2339 $can_compress_scripts = get_option( 'can_compress_scripts', false ); |
|
2340 if ( false !== $can_compress_scripts ) { |
|
2341 delete_option( 'can_compress_scripts' ); |
|
2342 add_option( 'can_compress_scripts', $can_compress_scripts, '', 'yes' ); |
|
2343 } |
|
2344 } |
|
2345 } |
|
2346 } |
|
2347 |
|
2348 /** |
|
2349 * Executes changes made in WordPress 6.4.0. |
|
2350 * |
|
2351 * @ignore |
|
2352 * @since 6.4.0 |
|
2353 * |
|
2354 * @global int $wp_current_db_version The old (current) database version. |
|
2355 */ |
|
2356 function upgrade_640() { |
|
2357 global $wp_current_db_version; |
|
2358 |
|
2359 if ( $wp_current_db_version < 56657 ) { |
|
2360 // Enable attachment pages. |
|
2361 update_option( 'wp_attachment_pages_enabled', 1 ); |
|
2362 |
|
2363 // Remove the wp_https_detection cron. Https status is checked directly in an async Site Health check. |
|
2364 $scheduled = wp_get_scheduled_event( 'wp_https_detection' ); |
|
2365 if ( $scheduled ) { |
|
2366 wp_clear_scheduled_hook( 'wp_https_detection' ); |
|
2367 } |
|
2368 } |
|
2369 } |
|
2370 |
|
2371 /** |
|
2372 * Executes changes made in WordPress 6.5.0. |
|
2373 * |
|
2374 * @ignore |
|
2375 * @since 6.5.0 |
|
2376 * |
|
2377 * @global int $wp_current_db_version The old (current) database version. |
|
2378 * @global wpdb $wpdb WordPress database abstraction object. |
|
2379 */ |
|
2380 function upgrade_650() { |
|
2381 global $wp_current_db_version, $wpdb; |
|
2382 |
|
2383 if ( $wp_current_db_version < 57155 ) { |
|
2384 $stylesheet = get_stylesheet(); |
|
2385 |
|
2386 // Set autoload=no for all themes except the current one. |
|
2387 $theme_mods_options = $wpdb->get_col( |
|
2388 $wpdb->prepare( |
|
2389 "SELECT option_name FROM $wpdb->options WHERE autoload = 'yes' AND option_name != %s AND option_name LIKE %s", |
|
2390 "theme_mods_$stylesheet", |
|
2391 $wpdb->esc_like( 'theme_mods_' ) . '%' |
|
2392 ) |
|
2393 ); |
|
2394 |
|
2395 $autoload = array_fill_keys( $theme_mods_options, 'no' ); |
|
2396 wp_set_option_autoload_values( $autoload ); |
2302 } |
2397 } |
2303 } |
2398 } |
2304 |
2399 |
2305 /** |
2400 /** |
2306 * Executes network-level upgrade routines. |
2401 * Executes network-level upgrade routines. |
2459 // |
2554 // |
2460 |
2555 |
2461 /** |
2556 /** |
2462 * Creates a table in the database, if it doesn't already exist. |
2557 * Creates a table in the database, if it doesn't already exist. |
2463 * |
2558 * |
2464 * This method checks for an existing database and creates a new one if it's not |
2559 * This method checks for an existing database table and creates a new one if it's not |
2465 * already present. It doesn't rely on MySQL's "IF NOT EXISTS" statement, but chooses |
2560 * already present. It doesn't rely on MySQL's "IF NOT EXISTS" statement, but chooses |
2466 * to query all tables first and then run the SQL statement creating the table. |
2561 * to query all tables first and then run the SQL statement creating the table. |
2467 * |
2562 * |
2468 * @since 1.0.0 |
2563 * @since 1.0.0 |
2469 * |
2564 * |
2627 * |
2722 * |
2628 * @return stdClass List of options. |
2723 * @return stdClass List of options. |
2629 */ |
2724 */ |
2630 function get_alloptions_110() { |
2725 function get_alloptions_110() { |
2631 global $wpdb; |
2726 global $wpdb; |
2632 $all_options = new stdClass; |
2727 $all_options = new stdClass(); |
2633 $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); |
2728 $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); |
2634 if ( $options ) { |
2729 if ( $options ) { |
2635 foreach ( $options as $option ) { |
2730 foreach ( $options as $option ) { |
2636 if ( 'siteurl' === $option->option_name || 'home' === $option->option_name || 'category_base' === $option->option_name ) { |
2731 if ( 'siteurl' === $option->option_name || 'home' === $option->option_name || 'category_base' === $option->option_name ) { |
2637 $option->option_value = untrailingslashit( $option->option_value ); |
2732 $option->option_value = untrailingslashit( $option->option_value ); |
2711 * Modifies the database based on specified SQL statements. |
2806 * Modifies the database based on specified SQL statements. |
2712 * |
2807 * |
2713 * Useful for creating new tables and updating existing tables to a new structure. |
2808 * Useful for creating new tables and updating existing tables to a new structure. |
2714 * |
2809 * |
2715 * @since 1.5.0 |
2810 * @since 1.5.0 |
|
2811 * @since 6.1.0 Ignores display width for integer data types on MySQL 8.0.17 or later, |
|
2812 * to match MySQL behavior. Note: This does not affect MariaDB. |
2716 * |
2813 * |
2717 * @global wpdb $wpdb WordPress database abstraction object. |
2814 * @global wpdb $wpdb WordPress database abstraction object. |
2718 * |
2815 * |
2719 * @param string[]|string $queries Optional. The query to run. Can be multiple queries |
2816 * @param string[]|string $queries Optional. The query to run. Can be multiple queries |
2720 * in an array, or a string of queries separated by |
2817 * in an array, or a string of queries separated by |
2747 |
2844 |
2748 $cqueries = array(); // Creation queries. |
2845 $cqueries = array(); // Creation queries. |
2749 $iqueries = array(); // Insertion queries. |
2846 $iqueries = array(); // Insertion queries. |
2750 $for_update = array(); |
2847 $for_update = array(); |
2751 |
2848 |
2752 // Create a tablename index for an array ($cqueries) of queries. |
2849 // Create a tablename index for an array ($cqueries) of recognized query types. |
2753 foreach ( $queries as $qry ) { |
2850 foreach ( $queries as $qry ) { |
2754 if ( preg_match( '|CREATE TABLE ([^ ]*)|', $qry, $matches ) ) { |
2851 if ( preg_match( '|CREATE TABLE ([^ ]*)|', $qry, $matches ) ) { |
2755 $cqueries[ trim( $matches[1], '`' ) ] = $qry; |
2852 $cqueries[ trim( $matches[1], '`' ) ] = $qry; |
2756 $for_update[ $matches[1] ] = 'Created table ' . $matches[1]; |
2853 $for_update[ $matches[1] ] = 'Created table ' . $matches[1]; |
2757 } elseif ( preg_match( '|CREATE DATABASE ([^ ]*)|', $qry, $matches ) ) { |
2854 continue; |
|
2855 } |
|
2856 |
|
2857 if ( preg_match( '|CREATE DATABASE ([^ ]*)|', $qry, $matches ) ) { |
2758 array_unshift( $cqueries, $qry ); |
2858 array_unshift( $cqueries, $qry ); |
2759 } elseif ( preg_match( '|INSERT INTO ([^ ]*)|', $qry, $matches ) ) { |
2859 continue; |
|
2860 } |
|
2861 |
|
2862 if ( preg_match( '|INSERT INTO ([^ ]*)|', $qry, $matches ) ) { |
2760 $iqueries[] = $qry; |
2863 $iqueries[] = $qry; |
2761 } elseif ( preg_match( '|UPDATE ([^ ]*)|', $qry, $matches ) ) { |
2864 continue; |
|
2865 } |
|
2866 |
|
2867 if ( preg_match( '|UPDATE ([^ ]*)|', $qry, $matches ) ) { |
2762 $iqueries[] = $qry; |
2868 $iqueries[] = $qry; |
2763 } else { |
2869 continue; |
2764 // Unrecognized query type. |
|
2765 } |
2870 } |
2766 } |
2871 } |
2767 |
2872 |
2768 /** |
2873 /** |
2769 * Filters the dbDelta SQL queries for creating tables and/or databases. |
2874 * Filters the dbDelta SQL queries for creating tables and/or databases. |
2787 */ |
2892 */ |
2788 $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries ); |
2893 $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries ); |
2789 |
2894 |
2790 $text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' ); |
2895 $text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' ); |
2791 $blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' ); |
2896 $blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' ); |
2792 |
2897 $int_fields = array( 'tinyint', 'smallint', 'mediumint', 'int', 'integer', 'bigint' ); |
2793 $global_tables = $wpdb->tables( 'global' ); |
2898 |
|
2899 $global_tables = $wpdb->tables( 'global' ); |
|
2900 $db_version = $wpdb->db_version(); |
|
2901 $db_server_info = $wpdb->db_server_info(); |
|
2902 |
2794 foreach ( $cqueries as $table => $qry ) { |
2903 foreach ( $cqueries as $table => $qry ) { |
2795 // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal. |
2904 // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal. |
2796 if ( in_array( $table, $global_tables, true ) && ! wp_should_upgrade_global_tables() ) { |
2905 if ( in_array( $table, $global_tables, true ) && ! wp_should_upgrade_global_tables() ) { |
2797 unset( $cqueries[ $table ], $for_update[ $table ] ); |
2906 unset( $cqueries[ $table ], $for_update[ $table ] ); |
2798 continue; |
2907 continue; |
2847 * `SHOW INDEX FROM $table_name` query which returns the current table |
2956 * `SHOW INDEX FROM $table_name` query which returns the current table |
2848 * index information. |
2957 * index information. |
2849 */ |
2958 */ |
2850 |
2959 |
2851 // Extract type, name and columns from the definition. |
2960 // Extract type, name and columns from the definition. |
2852 // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation |
|
2853 preg_match( |
2961 preg_match( |
2854 '/^' |
2962 '/^ |
2855 . '(?P<index_type>' // 1) Type of the index. |
2963 (?P<index_type> # 1) Type of the index. |
2856 . 'PRIMARY\s+KEY|(?:UNIQUE|FULLTEXT|SPATIAL)\s+(?:KEY|INDEX)|KEY|INDEX' |
2964 PRIMARY\s+KEY|(?:UNIQUE|FULLTEXT|SPATIAL)\s+(?:KEY|INDEX)|KEY|INDEX |
2857 . ')' |
2965 ) |
2858 . '\s+' // Followed by at least one white space character. |
2966 \s+ # Followed by at least one white space character. |
2859 . '(?:' // Name of the index. Optional if type is PRIMARY KEY. |
2967 (?: # Name of the index. Optional if type is PRIMARY KEY. |
2860 . '`?' // Name can be escaped with a backtick. |
2968 `? # Name can be escaped with a backtick. |
2861 . '(?P<index_name>' // 2) Name of the index. |
2969 (?P<index_name> # 2) Name of the index. |
2862 . '(?:[0-9a-zA-Z$_-]|[\xC2-\xDF][\x80-\xBF])+' |
2970 (?:[0-9a-zA-Z$_-]|[\xC2-\xDF][\x80-\xBF])+ |
2863 . ')' |
2971 ) |
2864 . '`?' // Name can be escaped with a backtick. |
2972 `? # Name can be escaped with a backtick. |
2865 . '\s+' // Followed by at least one white space character. |
2973 \s+ # Followed by at least one white space character. |
2866 . ')*' |
2974 )* |
2867 . '\(' // Opening bracket for the columns. |
2975 \( # Opening bracket for the columns. |
2868 . '(?P<index_columns>' |
2976 (?P<index_columns> |
2869 . '.+?' // 3) Column names, index prefixes, and orders. |
2977 .+? # 3) Column names, index prefixes, and orders. |
2870 . ')' |
2978 ) |
2871 . '\)' // Closing bracket for the columns. |
2979 \) # Closing bracket for the columns. |
2872 . '$/im', |
2980 $/imx', |
2873 $fld, |
2981 $fld, |
2874 $index_matches |
2982 $index_matches |
2875 ); |
2983 ); |
2876 // phpcs:enable |
|
2877 |
2984 |
2878 // Uppercase the index type and normalize space characters. |
2985 // Uppercase the index type and normalize space characters. |
2879 $index_type = strtoupper( preg_replace( '/\s+/', ' ', trim( $index_matches['index_type'] ) ) ); |
2986 $index_type = strtoupper( preg_replace( '/\s+/', ' ', trim( $index_matches['index_type'] ) ) ); |
2880 |
2987 |
2881 // 'INDEX' is a synonym for 'KEY', standardize on 'KEY'. |
2988 // 'INDEX' is a synonym for 'KEY', standardize on 'KEY'. |
2890 |
2997 |
2891 // Normalize columns. |
2998 // Normalize columns. |
2892 foreach ( $index_columns as $id => &$index_column ) { |
2999 foreach ( $index_columns as $id => &$index_column ) { |
2893 // Extract column name and number of indexed characters (sub_part). |
3000 // Extract column name and number of indexed characters (sub_part). |
2894 preg_match( |
3001 preg_match( |
2895 '/' |
3002 '/ |
2896 . '`?' // Name can be escaped with a backtick. |
3003 `? # Name can be escaped with a backtick. |
2897 . '(?P<column_name>' // 1) Name of the column. |
3004 (?P<column_name> # 1) Name of the column. |
2898 . '(?:[0-9a-zA-Z$_-]|[\xC2-\xDF][\x80-\xBF])+' |
3005 (?:[0-9a-zA-Z$_-]|[\xC2-\xDF][\x80-\xBF])+ |
2899 . ')' |
3006 ) |
2900 . '`?' // Name can be escaped with a backtick. |
3007 `? # Name can be escaped with a backtick. |
2901 . '(?:' // Optional sub part. |
3008 (?: # Optional sub part. |
2902 . '\s*' // Optional white space character between name and opening bracket. |
3009 \s* # Optional white space character between name and opening bracket. |
2903 . '\(' // Opening bracket for the sub part. |
3010 \( # Opening bracket for the sub part. |
2904 . '\s*' // Optional white space character after opening bracket. |
3011 \s* # Optional white space character after opening bracket. |
2905 . '(?P<sub_part>' |
3012 (?P<sub_part> |
2906 . '\d+' // 2) Number of indexed characters. |
3013 \d+ # 2) Number of indexed characters. |
2907 . ')' |
3014 ) |
2908 . '\s*' // Optional white space character before closing bracket. |
3015 \s* # Optional white space character before closing bracket. |
2909 . '\)' // Closing bracket for the sub part. |
3016 \) # Closing bracket for the sub part. |
2910 . ')?' |
3017 )? |
2911 . '/', |
3018 /x', |
2912 $index_column, |
3019 $index_column, |
2913 $index_column_matches |
3020 $index_column_matches |
2914 ); |
3021 ); |
2915 |
3022 |
2916 // Escape the column name with backticks. |
3023 // Escape the column name with backticks. |
2944 // For every field in the table. |
3051 // For every field in the table. |
2945 foreach ( $tablefields as $tablefield ) { |
3052 foreach ( $tablefields as $tablefield ) { |
2946 $tablefield_field_lowercased = strtolower( $tablefield->Field ); |
3053 $tablefield_field_lowercased = strtolower( $tablefield->Field ); |
2947 $tablefield_type_lowercased = strtolower( $tablefield->Type ); |
3054 $tablefield_type_lowercased = strtolower( $tablefield->Type ); |
2948 |
3055 |
|
3056 $tablefield_type_without_parentheses = preg_replace( |
|
3057 '/' |
|
3058 . '(.+)' // Field type, e.g. `int`. |
|
3059 . '\(\d*\)' // Display width. |
|
3060 . '(.*)' // Optional attributes, e.g. `unsigned`. |
|
3061 . '/', |
|
3062 '$1$2', |
|
3063 $tablefield_type_lowercased |
|
3064 ); |
|
3065 |
|
3066 // Get the type without attributes, e.g. `int`. |
|
3067 $tablefield_type_base = strtok( $tablefield_type_without_parentheses, ' ' ); |
|
3068 |
2949 // If the table field exists in the field array... |
3069 // If the table field exists in the field array... |
2950 if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) { |
3070 if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) { |
2951 |
3071 |
2952 // Get the field type from the query. |
3072 // Get the field type from the query. |
2953 preg_match( '|`?' . $tablefield->Field . '`? ([^ ]*( unsigned)?)|i', $cfields[ $tablefield_field_lowercased ], $matches ); |
3073 preg_match( '|`?' . $tablefield->Field . '`? ([^ ]*( unsigned)?)|i', $cfields[ $tablefield_field_lowercased ], $matches ); |
2954 $fieldtype = $matches[1]; |
3074 $fieldtype = $matches[1]; |
2955 $fieldtype_lowercased = strtolower( $fieldtype ); |
3075 $fieldtype_lowercased = strtolower( $fieldtype ); |
|
3076 |
|
3077 $fieldtype_without_parentheses = preg_replace( |
|
3078 '/' |
|
3079 . '(.+)' // Field type, e.g. `int`. |
|
3080 . '\(\d*\)' // Display width. |
|
3081 . '(.*)' // Optional attributes, e.g. `unsigned`. |
|
3082 . '/', |
|
3083 '$1$2', |
|
3084 $fieldtype_lowercased |
|
3085 ); |
|
3086 |
|
3087 // Get the type without attributes, e.g. `int`. |
|
3088 $fieldtype_base = strtok( $fieldtype_without_parentheses, ' ' ); |
2956 |
3089 |
2957 // Is actual field type different from the field type in query? |
3090 // Is actual field type different from the field type in query? |
2958 if ( $tablefield->Type != $fieldtype ) { |
3091 if ( $tablefield->Type != $fieldtype ) { |
2959 $do_change = true; |
3092 $do_change = true; |
2960 if ( in_array( $fieldtype_lowercased, $text_fields, true ) && in_array( $tablefield_type_lowercased, $text_fields, true ) ) { |
3093 if ( in_array( $fieldtype_lowercased, $text_fields, true ) && in_array( $tablefield_type_lowercased, $text_fields, true ) ) { |
2967 if ( array_search( $fieldtype_lowercased, $blob_fields, true ) < array_search( $tablefield_type_lowercased, $blob_fields, true ) ) { |
3100 if ( array_search( $fieldtype_lowercased, $blob_fields, true ) < array_search( $tablefield_type_lowercased, $blob_fields, true ) ) { |
2968 $do_change = false; |
3101 $do_change = false; |
2969 } |
3102 } |
2970 } |
3103 } |
2971 |
3104 |
|
3105 if ( in_array( $fieldtype_base, $int_fields, true ) && in_array( $tablefield_type_base, $int_fields, true ) |
|
3106 && $fieldtype_without_parentheses === $tablefield_type_without_parentheses |
|
3107 ) { |
|
3108 /* |
|
3109 * MySQL 8.0.17 or later does not support display width for integer data types, |
|
3110 * so if display width is the only difference, it can be safely ignored. |
|
3111 * Note: This is specific to MySQL and does not affect MariaDB. |
|
3112 */ |
|
3113 if ( version_compare( $db_version, '8.0.17', '>=' ) |
|
3114 && ! str_contains( $db_server_info, 'MariaDB' ) |
|
3115 ) { |
|
3116 $do_change = false; |
|
3117 } |
|
3118 } |
|
3119 |
2972 if ( $do_change ) { |
3120 if ( $do_change ) { |
2973 // Add a query to change the column type. |
3121 // Add a query to change the column type. |
2974 $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ]; |
3122 $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ]; |
2975 |
3123 |
2976 $for_update[ $table . '.' . $tablefield->Field ] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; |
3124 $for_update[ $table . '.' . $tablefield->Field ] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; |
3031 if ( 'primary' === $index_name ) { |
3179 if ( 'primary' === $index_name ) { |
3032 $index_string .= 'PRIMARY '; |
3180 $index_string .= 'PRIMARY '; |
3033 } elseif ( $index_data['unique'] ) { |
3181 } elseif ( $index_data['unique'] ) { |
3034 $index_string .= 'UNIQUE '; |
3182 $index_string .= 'UNIQUE '; |
3035 } |
3183 } |
|
3184 |
3036 if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) { |
3185 if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) { |
3037 $index_string .= 'FULLTEXT '; |
3186 $index_string .= 'FULLTEXT '; |
3038 } |
3187 } |
|
3188 |
3039 if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) { |
3189 if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) { |
3040 $index_string .= 'SPATIAL '; |
3190 $index_string .= 'SPATIAL '; |
3041 } |
3191 } |
|
3192 |
3042 $index_string .= 'KEY '; |
3193 $index_string .= 'KEY '; |
3043 if ( 'primary' !== $index_name ) { |
3194 if ( 'primary' !== $index_name ) { |
3044 $index_string .= '`' . $index_name . '`'; |
3195 $index_string .= '`' . $index_name . '`'; |
3045 } |
3196 } |
|
3197 |
3046 $index_columns = ''; |
3198 $index_columns = ''; |
3047 |
3199 |
3048 // For each column in the index. |
3200 // For each column in the index. |
3049 foreach ( $index_data['columns'] as $column_data ) { |
3201 foreach ( $index_data['columns'] as $column_data ) { |
3050 if ( '' !== $index_columns ) { |
3202 if ( '' !== $index_columns ) { |
3137 * @param string $theme_name The name of the theme. |
3289 * @param string $theme_name The name of the theme. |
3138 * @param string $template The directory name of the theme. |
3290 * @param string $template The directory name of the theme. |
3139 * @return bool |
3291 * @return bool |
3140 */ |
3292 */ |
3141 function make_site_theme_from_oldschool( $theme_name, $template ) { |
3293 function make_site_theme_from_oldschool( $theme_name, $template ) { |
3142 $home_path = get_home_path(); |
3294 $home_path = get_home_path(); |
3143 $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
3295 $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
|
3296 $default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME; |
3144 |
3297 |
3145 if ( ! file_exists( "$home_path/index.php" ) ) { |
3298 if ( ! file_exists( "$home_path/index.php" ) ) { |
3146 return false; |
3299 return false; |
3147 } |
3300 } |
3148 |
3301 |
3165 } |
3318 } |
3166 |
3319 |
3167 // Check to make sure it's not a new index. |
3320 // Check to make sure it's not a new index. |
3168 if ( 'index.php' === $oldfile ) { |
3321 if ( 'index.php' === $oldfile ) { |
3169 $index = implode( '', file( "$oldpath/$oldfile" ) ); |
3322 $index = implode( '', file( "$oldpath/$oldfile" ) ); |
3170 if ( strpos( $index, 'WP_USE_THEMES' ) !== false ) { |
3323 if ( str_contains( $index, 'WP_USE_THEMES' ) ) { |
3171 if ( ! copy( WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile" ) ) { |
3324 if ( ! copy( "$default_dir/$oldfile", "$site_dir/$newfile" ) ) { |
3172 return false; |
3325 return false; |
3173 } |
3326 } |
3174 |
3327 |
3175 // Don't copy anything. |
3328 // Don't copy anything. |
3176 continue; |
3329 continue; |
3192 if ( preg_match( '/require.*wp-blog-header/', $line ) ) { |
3345 if ( preg_match( '/require.*wp-blog-header/', $line ) ) { |
3193 $line = '//' . $line; |
3346 $line = '//' . $line; |
3194 } |
3347 } |
3195 |
3348 |
3196 // Update stylesheet references. |
3349 // Update stylesheet references. |
3197 $line = str_replace( "<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line ); |
3350 $line = str_replace( |
|
3351 "<?php echo __get_option('siteurl'); ?>/wp-layout.css", |
|
3352 "<?php bloginfo('stylesheet_url'); ?>", |
|
3353 $line |
|
3354 ); |
3198 |
3355 |
3199 // Update comments template inclusion. |
3356 // Update comments template inclusion. |
3200 $line = str_replace( "<?php include(ABSPATH . 'wp-comments.php'); ?>", '<?php comments_template(); ?>', $line ); |
3357 $line = str_replace( |
|
3358 "<?php include(ABSPATH . 'wp-comments.php'); ?>", |
|
3359 '<?php comments_template(); ?>', |
|
3360 $line |
|
3361 ); |
3201 |
3362 |
3202 fwrite( $f, "{$line}\n" ); |
3363 fwrite( $f, "{$line}\n" ); |
3203 } |
3364 } |
3204 fclose( $f ); |
3365 fclose( $f ); |
3205 } |
3366 } |
3206 } |
3367 } |
3207 |
3368 |
3208 // Add a theme header. |
3369 // Add a theme header. |
3209 $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option( 'siteurl' ) . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n"; |
3370 $header = "/*\n" . |
|
3371 "Theme Name: $theme_name\n" . |
|
3372 'Theme URI: ' . __get_option( 'siteurl' ) . "\n" . |
|
3373 "Description: A theme automatically created by the update.\n" . |
|
3374 "Version: 1.0\n" . |
|
3375 "Author: Moi\n" . |
|
3376 "*/\n"; |
3210 |
3377 |
3211 $stylelines = file_get_contents( "$site_dir/style.css" ); |
3378 $stylelines = file_get_contents( "$site_dir/style.css" ); |
3212 if ( $stylelines ) { |
3379 if ( $stylelines ) { |
3213 $f = fopen( "$site_dir/style.css", 'w' ); |
3380 $f = fopen( "$site_dir/style.css", 'w' ); |
3214 |
3381 |
3233 */ |
3400 */ |
3234 function make_site_theme_from_default( $theme_name, $template ) { |
3401 function make_site_theme_from_default( $theme_name, $template ) { |
3235 $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
3402 $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
3236 $default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME; |
3403 $default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME; |
3237 |
3404 |
3238 // Copy files from the default theme to the site theme. |
3405 /* |
3239 // $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' ); |
3406 * Copy files from the default theme to the site theme. |
|
3407 * $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' ); |
|
3408 */ |
3240 |
3409 |
3241 $theme_dir = @opendir( $default_dir ); |
3410 $theme_dir = @opendir( $default_dir ); |
3242 if ( $theme_dir ) { |
3411 if ( $theme_dir ) { |
3243 while ( ( $theme_file = readdir( $theme_dir ) ) !== false ) { |
3412 while ( ( $theme_file = readdir( $theme_dir ) ) !== false ) { |
3244 if ( is_dir( "$default_dir/$theme_file" ) ) { |
3413 if ( is_dir( "$default_dir/$theme_file" ) ) { |
3245 continue; |
3414 continue; |
3246 } |
3415 } |
|
3416 |
3247 if ( ! copy( "$default_dir/$theme_file", "$site_dir/$theme_file" ) ) { |
3417 if ( ! copy( "$default_dir/$theme_file", "$site_dir/$theme_file" ) ) { |
3248 return; |
3418 return; |
3249 } |
3419 } |
|
3420 |
3250 chmod( "$site_dir/$theme_file", 0777 ); |
3421 chmod( "$site_dir/$theme_file", 0777 ); |
3251 } |
3422 } |
3252 |
3423 |
3253 closedir( $theme_dir ); |
3424 closedir( $theme_dir ); |
3254 } |
3425 } |
3256 // Rewrite the theme header. |
3427 // Rewrite the theme header. |
3257 $stylelines = explode( "\n", implode( '', file( "$site_dir/style.css" ) ) ); |
3428 $stylelines = explode( "\n", implode( '', file( "$site_dir/style.css" ) ) ); |
3258 if ( $stylelines ) { |
3429 if ( $stylelines ) { |
3259 $f = fopen( "$site_dir/style.css", 'w' ); |
3430 $f = fopen( "$site_dir/style.css", 'w' ); |
3260 |
3431 |
|
3432 $headers = array( |
|
3433 'Theme Name:' => $theme_name, |
|
3434 'Theme URI:' => __get_option( 'url' ), |
|
3435 'Description:' => 'Your theme.', |
|
3436 'Version:' => '1', |
|
3437 'Author:' => 'You', |
|
3438 ); |
|
3439 |
3261 foreach ( $stylelines as $line ) { |
3440 foreach ( $stylelines as $line ) { |
3262 if ( strpos( $line, 'Theme Name:' ) !== false ) { |
3441 foreach ( $headers as $header => $value ) { |
3263 $line = 'Theme Name: ' . $theme_name; |
3442 if ( str_contains( $line, $header ) ) { |
3264 } elseif ( strpos( $line, 'Theme URI:' ) !== false ) { |
3443 $line = $header . ' ' . $value; |
3265 $line = 'Theme URI: ' . __get_option( 'url' ); |
3444 break; |
3266 } elseif ( strpos( $line, 'Description:' ) !== false ) { |
3445 } |
3267 $line = 'Description: Your theme.'; |
3446 } |
3268 } elseif ( strpos( $line, 'Version:' ) !== false ) { |
3447 |
3269 $line = 'Version: 1'; |
|
3270 } elseif ( strpos( $line, 'Author:' ) !== false ) { |
|
3271 $line = 'Author: You'; |
|
3272 } |
|
3273 fwrite( $f, $line . "\n" ); |
3448 fwrite( $f, $line . "\n" ); |
3274 } |
3449 } |
|
3450 |
3275 fclose( $f ); |
3451 fclose( $f ); |
3276 } |
3452 } |
3277 |
3453 |
3278 // Copy the images. |
3454 // Copy the images. |
3279 umask( 0 ); |
3455 umask( 0 ); |
3285 if ( $images_dir ) { |
3461 if ( $images_dir ) { |
3286 while ( ( $image = readdir( $images_dir ) ) !== false ) { |
3462 while ( ( $image = readdir( $images_dir ) ) !== false ) { |
3287 if ( is_dir( "$default_dir/images/$image" ) ) { |
3463 if ( is_dir( "$default_dir/images/$image" ) ) { |
3288 continue; |
3464 continue; |
3289 } |
3465 } |
|
3466 |
3290 if ( ! copy( "$default_dir/images/$image", "$site_dir/images/$image" ) ) { |
3467 if ( ! copy( "$default_dir/images/$image", "$site_dir/images/$image" ) ) { |
3291 return; |
3468 return; |
3292 } |
3469 } |
|
3470 |
3293 chmod( "$site_dir/images/$image", 0777 ); |
3471 chmod( "$site_dir/images/$image", 0777 ); |
3294 } |
3472 } |
3295 |
3473 |
3296 closedir( $images_dir ); |
3474 closedir( $images_dir ); |
3297 } |
3475 } |
3486 maybe_convert_table_to_utf8mb4( $wpdb->termmeta ); |
3664 maybe_convert_table_to_utf8mb4( $wpdb->termmeta ); |
3487 } |
3665 } |
3488 } |
3666 } |
3489 } |
3667 } |
3490 |
3668 |
3491 if ( ! function_exists( 'install_global_terms' ) ) : |
|
3492 /** |
|
3493 * Install global terms. |
|
3494 * |
|
3495 * @since 3.0.0 |
|
3496 * |
|
3497 * @global wpdb $wpdb WordPress database abstraction object. |
|
3498 * @global string $charset_collate |
|
3499 */ |
|
3500 function install_global_terms() { |
|
3501 global $wpdb, $charset_collate; |
|
3502 $ms_queries = " |
|
3503 CREATE TABLE $wpdb->sitecategories ( |
|
3504 cat_ID bigint(20) NOT NULL auto_increment, |
|
3505 cat_name varchar(55) NOT NULL default '', |
|
3506 category_nicename varchar(200) NOT NULL default '', |
|
3507 last_updated timestamp NOT NULL, |
|
3508 PRIMARY KEY (cat_ID), |
|
3509 KEY category_nicename (category_nicename), |
|
3510 KEY last_updated (last_updated) |
|
3511 ) $charset_collate; |
|
3512 "; |
|
3513 // Now create tables. |
|
3514 dbDelta( $ms_queries ); |
|
3515 } |
|
3516 endif; |
|
3517 |
|
3518 /** |
3669 /** |
3519 * Determine if global tables should be upgraded. |
3670 * Determine if global tables should be upgraded. |
3520 * |
3671 * |
3521 * This function performs a series of checks to ensure the environment allows |
3672 * This function performs a series of checks to ensure the environment allows |
3522 * for the safe upgrading of global WordPress database tables. It is necessary |
3673 * for the safe upgrading of global WordPress database tables. It is necessary |