25 |
25 |
26 <?php |
26 <?php |
27 |
27 |
28 if ( ! defined( 'WP_ALLOW_REPAIR' ) || ! WP_ALLOW_REPAIR ) { |
28 if ( ! defined( 'WP_ALLOW_REPAIR' ) || ! WP_ALLOW_REPAIR ) { |
29 |
29 |
30 echo '<h1 class="screen-reader-text">' . __( 'Allow automatic database repair' ) . '</h1>'; |
30 echo '<h1 class="screen-reader-text">' . |
|
31 /* translators: Hidden accessibility text. */ |
|
32 __( 'Allow automatic database repair' ) . |
|
33 '</h1>'; |
31 |
34 |
32 echo '<p>'; |
35 echo '<p>'; |
33 printf( |
36 printf( |
34 /* translators: %s: wp-config.php */ |
37 /* translators: %s: wp-config.php */ |
35 __( 'To allow use of this page to automatically repair database problems, please add the following line to your %s file. Once this line is added to your config, reload this page.' ), |
38 __( 'To allow use of this page to automatically repair database problems, please add the following line to your %s file. Once this line is added to your config, reload this page.' ), |
36 '<code>wp-config.php</code>' |
39 '<code>wp-config.php</code>' |
37 ); |
40 ); |
38 echo "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>"; |
41 echo "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>"; |
39 |
42 |
40 $default_key = 'put your unique phrase here'; |
43 $default_keys = array_unique( |
|
44 array( |
|
45 'put your unique phrase here', |
|
46 /* |
|
47 * translators: This string should only be translated if wp-config-sample.php is localized. |
|
48 * You can check the localized release package or |
|
49 * https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php |
|
50 */ |
|
51 __( 'put your unique phrase here' ), |
|
52 ) |
|
53 ); |
41 $missing_key = false; |
54 $missing_key = false; |
42 $duplicated_keys = array(); |
55 $duplicated_keys = array(); |
43 |
56 |
44 foreach ( array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT' ) as $key ) { |
57 foreach ( array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT' ) as $key ) { |
45 if ( defined( $key ) ) { |
58 if ( defined( $key ) ) { |
49 // If a constant is not defined, it's missing. |
62 // If a constant is not defined, it's missing. |
50 $missing_key = true; |
63 $missing_key = true; |
51 } |
64 } |
52 } |
65 } |
53 |
66 |
54 // If at least one key uses the default value, consider it duplicated. |
67 // If at least one key uses a default value, consider it duplicated. |
55 if ( isset( $duplicated_keys[ $default_key ] ) ) { |
68 foreach ( $default_keys as $default_key ) { |
56 $duplicated_keys[ $default_key ] = true; |
69 if ( isset( $duplicated_keys[ $default_key ] ) ) { |
|
70 $duplicated_keys[ $default_key ] = true; |
|
71 } |
57 } |
72 } |
58 |
73 |
59 // Weed out all unique, non-default values. |
74 // Weed out all unique, non-default values. |
60 $duplicated_keys = array_filter( $duplicated_keys ); |
75 $duplicated_keys = array_filter( $duplicated_keys ); |
61 |
76 |
62 if ( $duplicated_keys || $missing_key ) { |
77 if ( $duplicated_keys || $missing_key ) { |
63 |
78 |
64 echo '<h2 class="screen-reader-text">' . __( 'Check secret keys' ) . '</h2>'; |
79 echo '<h2 class="screen-reader-text">' . |
|
80 /* translators: Hidden accessibility text. */ |
|
81 __( 'Check secret keys' ) . |
|
82 '</h2>'; |
65 |
83 |
66 /* translators: 1: wp-config.php, 2: Secret key service URL. */ |
84 /* translators: 1: wp-config.php, 2: Secret key service URL. */ |
67 echo '<p>' . sprintf( __( 'While you are editing your %1$s file, take a moment to make sure you have all 8 keys and that they are unique. You can generate these using the <a href="%2$s">WordPress.org secret key service</a>.' ), '<code>wp-config.php</code>', 'https://api.wordpress.org/secret-key/1.1/salt/' ) . '</p>'; |
85 echo '<p>' . sprintf( __( 'While you are editing your %1$s file, take a moment to make sure you have all 8 keys and that they are unique. You can generate these using the <a href="%2$s">WordPress.org secret key service</a>.' ), '<code>wp-config.php</code>', 'https://api.wordpress.org/secret-key/1.1/salt/' ) . '</p>'; |
68 } |
86 } |
69 } elseif ( isset( $_GET['repair'] ) ) { |
87 } elseif ( isset( $_GET['repair'] ) ) { |
70 |
88 |
71 echo '<h1 class="screen-reader-text">' . __( 'Database repair results' ) . '</h1>'; |
89 echo '<h1 class="screen-reader-text">' . |
|
90 /* translators: Hidden accessibility text. */ |
|
91 __( 'Database repair results' ) . |
|
92 '</h1>'; |
72 |
93 |
73 $optimize = 2 == $_GET['repair']; |
94 $optimize = '2' === $_GET['repair']; |
74 $okay = true; |
95 $okay = true; |
75 $problems = array(); |
96 $problems = array(); |
76 |
97 |
77 $tables = $wpdb->tables(); |
98 $tables = $wpdb->tables(); |
78 |
|
79 // Sitecategories may not exist if global terms are disabled. |
|
80 $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->sitecategories ) ); |
|
81 if ( is_multisite() && ! $wpdb->get_var( $query ) ) { |
|
82 unset( $tables['sitecategories'] ); |
|
83 } |
|
84 |
99 |
85 /** |
100 /** |
86 * Filters additional database tables to repair. |
101 * Filters additional database tables to repair. |
87 * |
102 * |
88 * @since 3.0.0 |
103 * @since 3.0.0 |
154 } else { |
169 } else { |
155 echo '<p>' . __( 'Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.' ) . "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>"; |
170 echo '<p>' . __( 'Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.' ) . "</p><p><code>define('WP_ALLOW_REPAIR', true);</code></p>"; |
156 } |
171 } |
157 } else { |
172 } else { |
158 |
173 |
159 echo '<h1 class="screen-reader-text">' . __( 'WordPress database repair' ) . '</h1>'; |
174 echo '<h1 class="screen-reader-text">' . |
|
175 /* translators: Hidden accessibility text. */ |
|
176 __( 'WordPress database repair' ) . |
|
177 '</h1>'; |
160 |
178 |
161 if ( isset( $_GET['referrer'] ) && 'is_blog_installed' === $_GET['referrer'] ) { |
179 if ( isset( $_GET['referrer'] ) && 'is_blog_installed' === $_GET['referrer'] ) { |
162 echo '<p>' . __( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the “Repair Database” button. Repairing can take a while, so please be patient.' ) . '</p>'; |
180 echo '<p>' . __( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the “Repair Database” button. Repairing can take a while, so please be patient.' ) . '</p>'; |
163 } else { |
181 } else { |
164 echo '<p>' . __( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '</p>'; |
182 echo '<p>' . __( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '</p>'; |