| 75 | 75 | update_user_option($user_id, 'default_password_nag', true, true); |
| 76 | 76 | $email_password = true; |
| 77 | 77 | } else if ( !$user_id ) { |
| 78 | 78 | // Password has been provided |
| 79 | 79 | $message = '<em>'.__('Your chosen password.').'</em>'; |
| 80 | 80 | $user_id = wp_create_user($user_name, $user_password, $user_email); |
| 81 | 81 | } else { |
| 82 | 82 | $message = __('User already exists. Password inherited.'); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $user = new WP_User($user_id); |
| 86 | 86 | $user->set_role('administrator'); |
| 87 | 87 | |
| 88 | 88 | wp_install_defaults($user_id); |
| 89 | 89 | |
| 248 | 250 | |
| 249 | 251 | $user = new WP_User($user_id); |
| 250 | 252 | $wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') ); |
| 251 | 253 | |
| 252 | 254 | // Remove all perms except for the login user. |
| 253 | 255 | $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') ); |
| 254 | 256 | $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') ); |
| 255 | 257 | |
| 256 | 258 | // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id. |
| 257 | 259 | if ( !is_super_admin( $user_id ) && $user_id != 1 ) |
| 258 | 260 | $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); |
| 259 | 261 | } |
| 260 | 262 | } |
| 261 | 263 | endif; |
| 262 | 264 | |
| | 265 | if ( ! function_exists( 'wp_install_maybe_pretty_permalinks' ) ) : |
| | 266 | /** |
| | 267 | * Enable pretty permalinks if available. |
| | 268 | * |
| | 269 | * This function will enable pretty permalinks if it can verify they work. |
| | 270 | * If all pretty permalinks formats fail to work, WordPress will fall back |
| | 271 | * to ugly permalinks by setting an empty permalink structure. |
| | 272 | * |
| | 273 | * @since 4.2.0 |
| | 274 | * |
| | 275 | * @global WP_Rewrite $wp_rewrite WordPress rewrite component. |
| | 276 | */ |
| | 277 | function wp_install_maybe_pretty_permalinks() { |
| | 278 | global $wp_rewrite; |
| | 279 | |
| | 280 | /* |
| | 281 | * Bail if we alredy have permalinks enabled (Multisite) |
| | 282 | */ |
| | 283 | if ( get_option( 'permalink_structure' ) ) { |
| | 284 | return; |
| | 285 | } |
| | 286 | |
| | 287 | /* |
| | 288 | * The Permalink structures which WordPress should attempt to use. |
| | 289 | * The first is designed for mod_rewrite or nginx rewriting. |
| | 290 | * The second is PATHINFO based permalinks offered under configurations without rewrites enabled. |
| | 291 | */ |
| | 292 | $permalink_structures = array( |
| | 293 | '/%year%/%monthnum%/%day%/%postname%/', |
| | 294 | '/index.php/%year%/%monthnum%/%day%/%postname%/' |
| | 295 | ); |
| | 296 | |
| | 297 | foreach ( $permalink_structures as $permalink_structure ) { |
| | 298 | /* |
| | 299 | * Set the desired Permalink structure to try |
| | 300 | */ |
| | 301 | $wp_rewrite->set_permalink_structure( $permalink_structure ); |
| | 302 | |
| | 303 | /* |
| | 304 | * Flush rules with the hard option to force refresh of the web-server's |
| | 305 | * rewrite config file (e.g. .htaccess or web.config). |
| | 306 | */ |
| | 307 | $wp_rewrite->flush_rules( true ); |
| | 308 | |
| | 309 | /* |
| | 310 | * Test against a real WordPress Post, or if none were created, a Page URI |
| | 311 | */ |
| | 312 | $test_url = get_permalink( 1 ); |
| | 313 | if ( ! $test_url ) { |
| | 314 | $test_url = home_url( '/wordpress-check-for-rewrites/' ); |
| | 315 | } |
| | 316 | |
| | 317 | /* |
| | 318 | * Send a HEAD request to a random page on the site, and check whether |
| | 319 | * the 'x-pingback' header is returned as expected. |
| | 320 | */ |
| | 321 | $response = wp_remote_get( $test_url, array( 'timeout' => 5 ) ); |
| | 322 | $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' ); |
| | 323 | $pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' ); |
| | 324 | |
| | 325 | if ( $pretty_permalinks ) { |
| | 326 | return true; |
| | 327 | } |
| | 328 | } |
| | 329 | |
| | 330 | /* |
| | 331 | * If it makes it this far, Pretty Permalinks failed to activate. |
| | 332 | * Reset and allow the user to select it themselves. |
| | 333 | */ |
| | 334 | $wp_rewrite->set_permalink_structure( '' ); |
| | 335 | $wp_rewrite->flush_rules( true ); |
| | 336 | } |
| | 337 | endif; |
| | 338 | |
| 263 | 339 | if ( !function_exists('wp_new_blog_notification') ) : |
| 264 | 340 | /** |
| 265 | 341 | * {@internal Missing Short Description}} |
| 266 | 342 | * |
| 267 | 343 | * {@internal Missing Long Description}} |
| 268 | 344 | * |
| 269 | 345 | * @since 2.1.0 |
| 270 | 346 | * |
| 271 | 347 | * @param string $blog_title Blog title. |
| 272 | 348 | * @param string $blog_url Blog url. |
| 273 | 349 | * @param int $user_id User ID. |
| 274 | 350 | * @param string $password User's Password. |
| 275 | 351 | */ |
| 276 | 352 | function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) { |
| 277 | 353 | $user = new WP_User( $user_id ); |