Changeset 42343 for trunk/src/wp-admin/includes/schema.php
- Timestamp:
- 11/30/2017 11:09:33 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/schema.php (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/schema.php
r42228 r42343 39 39 $charset_collate = $wpdb->get_charset_collate(); 40 40 41 if ( $blog_id && $blog_id != $wpdb->blogid ) 41 if ( $blog_id && $blog_id != $wpdb->blogid ) { 42 42 $old_blog_id = $wpdb->set_blog_id( $blog_id ); 43 } 43 44 44 45 // Engage multisite if in the middle of turning it on from network.php. … … 236 237 237 238 // Global tables 238 if ( $is_multisite ) 239 if ( $is_multisite ) { 239 240 $global_tables = $users_multi_table . $usermeta_table; 240 else241 } else { 241 242 $global_tables = $users_single_table . $usermeta_table; 243 } 242 244 243 245 // Multisite global tables. … … 311 313 312 314 switch ( $scope ) { 313 case 'blog' :315 case 'blog': 314 316 $queries = $blog_tables; 315 317 break; 316 case 'global' :318 case 'global': 317 319 $queries = $global_tables; 318 if ( $is_multisite ) 320 if ( $is_multisite ) { 319 321 $queries .= $ms_global_tables; 322 } 320 323 break; 321 case 'ms_global' :324 case 'ms_global': 322 325 $queries = $ms_global_tables; 323 326 break; 324 case 'all' :327 case 'all': 325 328 default: 326 329 $queries = $global_tables . $blog_tables; 327 if ( $is_multisite ) 330 if ( $is_multisite ) { 328 331 $queries .= $ms_global_tables; 332 } 329 333 break; 330 334 } 331 335 332 if ( isset( $old_blog_id ) ) 336 if ( isset( $old_blog_id ) ) { 333 337 $wpdb->set_blog_id( $old_blog_id ); 338 } 334 339 335 340 return $queries; … … 359 364 do_action( 'populate_options' ); 360 365 361 if ( ini_get( 'safe_mode') ) {366 if ( ini_get( 'safe_mode' ) ) { 362 367 // Safe mode can break mkdir() so use a flat structure by default. 363 368 $uploads_use_yearmonth_folders = 0; … … 368 373 // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme. 369 374 $stylesheet = $template = WP_DEFAULT_THEME; 370 $theme = wp_get_theme( WP_DEFAULT_THEME );375 $theme = wp_get_theme( WP_DEFAULT_THEME ); 371 376 if ( ! $theme->exists() ) { 372 377 $theme = WP_Theme::get_core_default_theme(); … … 380 385 381 386 $timezone_string = ''; 382 $gmt_offset = 0;387 $gmt_offset = 0; 383 388 /* 384 389 * translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14) … … 387 392 */ 388 393 $offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); 389 if ( is_numeric( $offset_or_tz ) ) 394 if ( is_numeric( $offset_or_tz ) ) { 390 395 $gmt_offset = $offset_or_tz; 391 elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) )396 } elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) { 392 397 $timezone_string = $offset_or_tz; 398 } 393 399 394 400 $options = array( 395 'siteurl'=> $guessurl,396 'home'=> $guessurl,397 'blogname' => __('My Site'),398 /* translators: site tagline */399 'blogdescription' => __('Just another WordPress site'),400 'users_can_register'=> 0,401 'admin_email'=> 'you@example.com',402 /* translators: default start of the week. 0 = Sunday, 1 = Monday */403 'start_of_week'=> _x( '1', 'start of week' ),404 'use_balanceTags'=> 0,405 'use_smilies'=> 1,406 'require_name_email'=> 1,407 'comments_notify'=> 1,408 'posts_per_rss'=> 10,409 'rss_use_excerpt'=> 0,410 'mailserver_url'=> 'mail.example.com',411 'mailserver_login'=> 'login@example.com',412 'mailserver_pass'=> 'password',413 'mailserver_port'=> 110,414 'default_category'=> 1,415 'default_comment_status'=> 'open',416 'default_ping_status'=> 'open',417 'default_pingback_flag'=> 1,418 'posts_per_page'=> 10,419 /* translators: default date format, see https://secure.php.net/date */420 'date_format' => __('F j, Y'),421 /* translators: default time format, see https://secure.php.net/date */422 'time_format' => __('g:i a'),423 /* translators: links last updated date format, see https://secure.php.net/date */424 'links_updated_date_format' => __('F j, Y g:i a'),425 'comment_moderation'=> 0,426 'moderation_notify'=> 1,427 'permalink_structure'=> '',428 'rewrite_rules'=> '',429 'hack_file'=> 0,430 'blog_charset'=> 'UTF-8',431 'moderation_keys'=> '',432 'active_plugins'=> array(),433 'category_base'=> '',434 'ping_sites'=> 'http://rpc.pingomatic.com/',435 'comment_max_links'=> 2,436 'gmt_offset'=> $gmt_offset,437 438 // 1.5439 'default_email_category'=> 1,440 'recently_edited'=> '',441 'template'=> $template,442 'stylesheet'=> $stylesheet,443 'comment_whitelist'=> 1,444 'blacklist_keys'=> '',445 'comment_registration'=> 0,446 'html_type'=> 'text/html',447 448 // 1.5.1449 'use_trackback'=> 0,450 451 // 2.0452 'default_role'=> 'subscriber',453 'db_version'=> $wp_db_version,454 455 // 2.0.1456 'uploads_use_yearmonth_folders'=> $uploads_use_yearmonth_folders,457 'upload_path'=> '',458 459 // 2.1460 'blog_public'=> '1',461 'default_link_category'=> 2,462 'show_on_front'=> 'posts',463 464 // 2.2465 'tag_base'=> '',466 467 // 2.5468 'show_avatars'=> '1',469 'avatar_rating'=> 'G',470 'upload_url_path'=> '',471 'thumbnail_size_w'=> 150,472 'thumbnail_size_h'=> 150,473 'thumbnail_crop'=> 1,474 'medium_size_w'=> 300,475 'medium_size_h'=> 300,476 477 // 2.6478 'avatar_default'=> 'mystery',479 480 // 2.7481 'large_size_w'=> 1024,482 'large_size_h'=> 1024,483 'image_default_link_type'=> 'none',484 'image_default_size'=> '',485 'image_default_align'=> '',486 'close_comments_for_old_posts'=> 0,487 'close_comments_days_old'=> 14,488 'thread_comments'=> 1,489 'thread_comments_depth'=> 5,490 'page_comments'=> 0,491 'comments_per_page'=> 50,492 'default_comments_page'=> 'newest',493 'comment_order'=> 'asc',494 'sticky_posts'=> array(),495 'widget_categories'=> array(),496 'widget_text'=> array(),497 'widget_rss'=> array(),498 'uninstall_plugins'=> array(),499 500 // 2.8501 'timezone_string'=> $timezone_string,502 503 // 3.0504 'page_for_posts'=> 0,505 'page_on_front'=> 0,506 507 // 3.1508 'default_post_format'=> 0,509 510 // 3.5511 'link_manager_enabled'=> 0,512 513 // 4.3.0514 'finished_splitting_shared_terms' => 1,515 'site_icon'=> 0,516 517 // 4.4.0518 'medium_large_size_w'=> 768,519 'medium_large_size_h'=> 0,401 'siteurl' => $guessurl, 402 'home' => $guessurl, 403 'blogname' => __( 'My Site' ), 404 /* translators: site tagline */ 405 'blogdescription' => __( 'Just another WordPress site' ), 406 'users_can_register' => 0, 407 'admin_email' => 'you@example.com', 408 /* translators: default start of the week. 0 = Sunday, 1 = Monday */ 409 'start_of_week' => _x( '1', 'start of week' ), 410 'use_balanceTags' => 0, 411 'use_smilies' => 1, 412 'require_name_email' => 1, 413 'comments_notify' => 1, 414 'posts_per_rss' => 10, 415 'rss_use_excerpt' => 0, 416 'mailserver_url' => 'mail.example.com', 417 'mailserver_login' => 'login@example.com', 418 'mailserver_pass' => 'password', 419 'mailserver_port' => 110, 420 'default_category' => 1, 421 'default_comment_status' => 'open', 422 'default_ping_status' => 'open', 423 'default_pingback_flag' => 1, 424 'posts_per_page' => 10, 425 /* translators: default date format, see https://secure.php.net/date */ 426 'date_format' => __( 'F j, Y' ), 427 /* translators: default time format, see https://secure.php.net/date */ 428 'time_format' => __( 'g:i a' ), 429 /* translators: links last updated date format, see https://secure.php.net/date */ 430 'links_updated_date_format' => __( 'F j, Y g:i a' ), 431 'comment_moderation' => 0, 432 'moderation_notify' => 1, 433 'permalink_structure' => '', 434 'rewrite_rules' => '', 435 'hack_file' => 0, 436 'blog_charset' => 'UTF-8', 437 'moderation_keys' => '', 438 'active_plugins' => array(), 439 'category_base' => '', 440 'ping_sites' => 'http://rpc.pingomatic.com/', 441 'comment_max_links' => 2, 442 'gmt_offset' => $gmt_offset, 443 444 // 1.5 445 'default_email_category' => 1, 446 'recently_edited' => '', 447 'template' => $template, 448 'stylesheet' => $stylesheet, 449 'comment_whitelist' => 1, 450 'blacklist_keys' => '', 451 'comment_registration' => 0, 452 'html_type' => 'text/html', 453 454 // 1.5.1 455 'use_trackback' => 0, 456 457 // 2.0 458 'default_role' => 'subscriber', 459 'db_version' => $wp_db_version, 460 461 // 2.0.1 462 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, 463 'upload_path' => '', 464 465 // 2.1 466 'blog_public' => '1', 467 'default_link_category' => 2, 468 'show_on_front' => 'posts', 469 470 // 2.2 471 'tag_base' => '', 472 473 // 2.5 474 'show_avatars' => '1', 475 'avatar_rating' => 'G', 476 'upload_url_path' => '', 477 'thumbnail_size_w' => 150, 478 'thumbnail_size_h' => 150, 479 'thumbnail_crop' => 1, 480 'medium_size_w' => 300, 481 'medium_size_h' => 300, 482 483 // 2.6 484 'avatar_default' => 'mystery', 485 486 // 2.7 487 'large_size_w' => 1024, 488 'large_size_h' => 1024, 489 'image_default_link_type' => 'none', 490 'image_default_size' => '', 491 'image_default_align' => '', 492 'close_comments_for_old_posts' => 0, 493 'close_comments_days_old' => 14, 494 'thread_comments' => 1, 495 'thread_comments_depth' => 5, 496 'page_comments' => 0, 497 'comments_per_page' => 50, 498 'default_comments_page' => 'newest', 499 'comment_order' => 'asc', 500 'sticky_posts' => array(), 501 'widget_categories' => array(), 502 'widget_text' => array(), 503 'widget_rss' => array(), 504 'uninstall_plugins' => array(), 505 506 // 2.8 507 'timezone_string' => $timezone_string, 508 509 // 3.0 510 'page_for_posts' => 0, 511 'page_on_front' => 0, 512 513 // 3.1 514 'default_post_format' => 0, 515 516 // 3.5 517 'link_manager_enabled' => 0, 518 519 // 4.3.0 520 'finished_splitting_shared_terms' => 1, 521 'site_icon' => 0, 522 523 // 4.4.0 524 'medium_large_size_w' => 768, 525 'medium_large_size_h' => 0, 520 526 ); 521 527 … … 529 535 if ( is_multisite() ) { 530 536 /* translators: site tagline */ 531 $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_network()->site_name );532 $options[ 'permalink_structure'] = '/%year%/%monthnum%/%day%/%postname%/';537 $options['blogdescription'] = sprintf( __( 'Just another %s site' ), get_network()->site_name ); 538 $options['permalink_structure'] = '/%year%/%monthnum%/%day%/%postname%/'; 533 539 } 534 540 … … 536 542 $fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' ); 537 543 538 $keys = "'" . implode( "', '", array_keys( $options ) ) . "'";544 $keys = "'" . implode( "', '", array_keys( $options ) ) . "'"; 539 545 $existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" ); 540 546 541 547 $insert = ''; 542 548 foreach ( $options as $option => $value ) { 543 if ( in_array( $option, $existing_options) )549 if ( in_array( $option, $existing_options ) ) { 544 550 continue; 545 if ( in_array($option, $fat_options) ) 551 } 552 if ( in_array( $option, $fat_options ) ) { 546 553 $autoload = 'no'; 547 else554 } else { 548 555 $autoload = 'yes'; 549 550 if ( is_array($value) ) 551 $value = serialize($value); 552 if ( !empty($insert) ) 556 } 557 558 if ( is_array( $value ) ) { 559 $value = serialize( $value ); 560 } 561 if ( ! empty( $insert ) ) { 553 562 $insert .= ', '; 554 $insert .= $wpdb->prepare( "(%s, %s, %s)", $option, $value, $autoload ); 555 } 556 557 if ( !empty($insert) ) 558 $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert); 563 } 564 $insert .= $wpdb->prepare( '(%s, %s, %s)', $option, $value, $autoload ); 565 } 566 567 if ( ! empty( $insert ) ) { 568 $wpdb->query( "INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert ); 569 } 559 570 560 571 // In case it is set, but blank, update "home". 561 if ( !__get_option('home') ) update_option('home', $guessurl); 572 if ( ! __get_option( 'home' ) ) { 573 update_option( 'home', $guessurl ); 574 } 562 575 563 576 // Delete unused options. 564 577 $unusedoptions = array( 565 'blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 566 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 567 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 568 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 569 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 570 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 571 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 572 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 573 'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append', 574 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 575 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', 576 '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 577 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 578 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 579 'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app', 580 'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit' 578 'blodotgsping_url', 579 'bodyterminator', 580 'emailtestonly', 581 'phoneemail_separator', 582 'smilies_directory', 583 'subjectprefix', 584 'use_bbcode', 585 'use_blodotgsping', 586 'use_phoneemail', 587 'use_quicktags', 588 'use_weblogsping', 589 'weblogs_cache_file', 590 'use_preview', 591 'use_htmltrans', 592 'smilies_directory', 593 'fileupload_allowedusers', 594 'use_phoneemail', 595 'default_post_status', 596 'default_post_category', 597 'archive_mode', 598 'time_difference', 599 'links_minadminlevel', 600 'links_use_adminlevels', 601 'links_rating_type', 602 'links_rating_char', 603 'links_rating_ignore_zero', 604 'links_rating_single_image', 605 'links_rating_image0', 606 'links_rating_image1', 607 'links_rating_image2', 608 'links_rating_image3', 609 'links_rating_image4', 610 'links_rating_image5', 611 'links_rating_image6', 612 'links_rating_image7', 613 'links_rating_image8', 614 'links_rating_image9', 615 'links_recently_updated_time', 616 'links_recently_updated_prepend', 617 'links_recently_updated_append', 618 'weblogs_cacheminutes', 619 'comment_allowed_tags', 620 'search_engine_friendly_urls', 621 'default_geourl_lat', 622 'default_geourl_lon', 623 'use_default_geourl', 624 'weblogs_xml_url', 625 'new_users_can_blog', 626 '_wpnonce', 627 '_wp_http_referer', 628 'Update', 629 'action', 630 'rich_editing', 631 'autosave_interval', 632 'deactivated_plugins', 633 'can_compress_scripts', 634 'page_uris', 635 'update_core', 636 'update_plugins', 637 'update_themes', 638 'doing_cron', 639 'random_seed', 640 'rss_excerpt_length', 641 'secret', 642 'use_linksupdate', 643 'default_comment_status_page', 644 'wporg_popular_tags', 645 'what_to_show', 646 'rss_language', 647 'language', 648 'enable_xmlrpc', 649 'enable_app', 650 'embed_autourls', 651 'default_post_edit_rows', 652 'gzipcompression', 653 'advanced_edit', 581 654 ); 582 foreach ( $unusedoptions as $option ) 583 delete_option($option); 655 foreach ( $unusedoptions as $option ) { 656 delete_option( $option ); 657 } 584 658 585 659 // Delete obsolete magpie stuff. 586 $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");660 $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'" ); 587 661 588 662 // Clear expired transients … … 616 690 // Dummy gettext calls to get strings in the catalog. 617 691 /* translators: user role */ 618 _x( 'Administrator', 'User role');692 _x( 'Administrator', 'User role' ); 619 693 /* translators: user role */ 620 _x( 'Editor', 'User role');694 _x( 'Editor', 'User role' ); 621 695 /* translators: user role */ 622 _x( 'Author', 'User role');696 _x( 'Author', 'User role' ); 623 697 /* translators: user role */ 624 _x( 'Contributor', 'User role');698 _x( 'Contributor', 'User role' ); 625 699 /* translators: user role */ 626 _x( 'Subscriber', 'User role');627 628 add_role( 'administrator', 'Administrator');629 add_role( 'editor', 'Editor');630 add_role( 'author', 'Author');631 add_role( 'contributor', 'Contributor');632 add_role( 'subscriber', 'Subscriber');700 _x( 'Subscriber', 'User role' ); 701 702 add_role( 'administrator', 'Administrator' ); 703 add_role( 'editor', 'Editor' ); 704 add_role( 'author', 'Author' ); 705 add_role( 'contributor', 'Contributor' ); 706 add_role( 'subscriber', 'Subscriber' ); 633 707 634 708 // Add caps for Administrator role 635 $role = get_role( 'administrator');636 $role->add_cap( 'switch_themes');637 $role->add_cap( 'edit_themes');638 $role->add_cap( 'activate_plugins');639 $role->add_cap( 'edit_plugins');640 $role->add_cap( 'edit_users');641 $role->add_cap( 'edit_files');642 $role->add_cap( 'manage_options');643 $role->add_cap( 'moderate_comments');644 $role->add_cap( 'manage_categories');645 $role->add_cap( 'manage_links');646 $role->add_cap( 'upload_files');647 $role->add_cap( 'import');648 $role->add_cap( 'unfiltered_html');649 $role->add_cap( 'edit_posts');650 $role->add_cap( 'edit_others_posts');651 $role->add_cap( 'edit_published_posts');652 $role->add_cap( 'publish_posts');653 $role->add_cap( 'edit_pages');654 $role->add_cap( 'read');655 $role->add_cap( 'level_10');656 $role->add_cap( 'level_9');657 $role->add_cap( 'level_8');658 $role->add_cap( 'level_7');659 $role->add_cap( 'level_6');660 $role->add_cap( 'level_5');661 $role->add_cap( 'level_4');662 $role->add_cap( 'level_3');663 $role->add_cap( 'level_2');664 $role->add_cap( 'level_1');665 $role->add_cap( 'level_0');709 $role = get_role( 'administrator' ); 710 $role->add_cap( 'switch_themes' ); 711 $role->add_cap( 'edit_themes' ); 712 $role->add_cap( 'activate_plugins' ); 713 $role->add_cap( 'edit_plugins' ); 714 $role->add_cap( 'edit_users' ); 715 $role->add_cap( 'edit_files' ); 716 $role->add_cap( 'manage_options' ); 717 $role->add_cap( 'moderate_comments' ); 718 $role->add_cap( 'manage_categories' ); 719 $role->add_cap( 'manage_links' ); 720 $role->add_cap( 'upload_files' ); 721 $role->add_cap( 'import' ); 722 $role->add_cap( 'unfiltered_html' ); 723 $role->add_cap( 'edit_posts' ); 724 $role->add_cap( 'edit_others_posts' ); 725 $role->add_cap( 'edit_published_posts' ); 726 $role->add_cap( 'publish_posts' ); 727 $role->add_cap( 'edit_pages' ); 728 $role->add_cap( 'read' ); 729 $role->add_cap( 'level_10' ); 730 $role->add_cap( 'level_9' ); 731 $role->add_cap( 'level_8' ); 732 $role->add_cap( 'level_7' ); 733 $role->add_cap( 'level_6' ); 734 $role->add_cap( 'level_5' ); 735 $role->add_cap( 'level_4' ); 736 $role->add_cap( 'level_3' ); 737 $role->add_cap( 'level_2' ); 738 $role->add_cap( 'level_1' ); 739 $role->add_cap( 'level_0' ); 666 740 667 741 // Add caps for Editor role 668 $role = get_role( 'editor');669 $role->add_cap( 'moderate_comments');670 $role->add_cap( 'manage_categories');671 $role->add_cap( 'manage_links');672 $role->add_cap( 'upload_files');673 $role->add_cap( 'unfiltered_html');674 $role->add_cap( 'edit_posts');675 $role->add_cap( 'edit_others_posts');676 $role->add_cap( 'edit_published_posts');677 $role->add_cap( 'publish_posts');678 $role->add_cap( 'edit_pages');679 $role->add_cap( 'read');680 $role->add_cap( 'level_7');681 $role->add_cap( 'level_6');682 $role->add_cap( 'level_5');683 $role->add_cap( 'level_4');684 $role->add_cap( 'level_3');685 $role->add_cap( 'level_2');686 $role->add_cap( 'level_1');687 $role->add_cap( 'level_0');742 $role = get_role( 'editor' ); 743 $role->add_cap( 'moderate_comments' ); 744 $role->add_cap( 'manage_categories' ); 745 $role->add_cap( 'manage_links' ); 746 $role->add_cap( 'upload_files' ); 747 $role->add_cap( 'unfiltered_html' ); 748 $role->add_cap( 'edit_posts' ); 749 $role->add_cap( 'edit_others_posts' ); 750 $role->add_cap( 'edit_published_posts' ); 751 $role->add_cap( 'publish_posts' ); 752 $role->add_cap( 'edit_pages' ); 753 $role->add_cap( 'read' ); 754 $role->add_cap( 'level_7' ); 755 $role->add_cap( 'level_6' ); 756 $role->add_cap( 'level_5' ); 757 $role->add_cap( 'level_4' ); 758 $role->add_cap( 'level_3' ); 759 $role->add_cap( 'level_2' ); 760 $role->add_cap( 'level_1' ); 761 $role->add_cap( 'level_0' ); 688 762 689 763 // Add caps for Author role 690 $role = get_role( 'author');691 $role->add_cap( 'upload_files');692 $role->add_cap( 'edit_posts');693 $role->add_cap( 'edit_published_posts');694 $role->add_cap( 'publish_posts');695 $role->add_cap( 'read');696 $role->add_cap( 'level_2');697 $role->add_cap( 'level_1');698 $role->add_cap( 'level_0');764 $role = get_role( 'author' ); 765 $role->add_cap( 'upload_files' ); 766 $role->add_cap( 'edit_posts' ); 767 $role->add_cap( 'edit_published_posts' ); 768 $role->add_cap( 'publish_posts' ); 769 $role->add_cap( 'read' ); 770 $role->add_cap( 'level_2' ); 771 $role->add_cap( 'level_1' ); 772 $role->add_cap( 'level_0' ); 699 773 700 774 // Add caps for Contributor role 701 $role = get_role( 'contributor');702 $role->add_cap( 'edit_posts');703 $role->add_cap( 'read');704 $role->add_cap( 'level_1');705 $role->add_cap( 'level_0');775 $role = get_role( 'contributor' ); 776 $role->add_cap( 'edit_posts' ); 777 $role->add_cap( 'read' ); 778 $role->add_cap( 'level_1' ); 779 $role->add_cap( 'level_0' ); 706 780 707 781 // Add caps for Subscriber role 708 $role = get_role( 'subscriber');709 $role->add_cap( 'read');710 $role->add_cap( 'level_0');782 $role = get_role( 'subscriber' ); 783 $role->add_cap( 'read' ); 784 $role->add_cap( 'level_0' ); 711 785 } 712 786 … … 717 791 */ 718 792 function populate_roles_210() { 719 $roles = array( 'administrator', 'editor');720 foreach ( $roles as $role) {721 $role = get_role( $role);722 if ( empty( $role) )793 $roles = array( 'administrator', 'editor' ); 794 foreach ( $roles as $role ) { 795 $role = get_role( $role ); 796 if ( empty( $role ) ) { 723 797 continue; 724 725 $role->add_cap('edit_others_pages'); 726 $role->add_cap('edit_published_pages'); 727 $role->add_cap('publish_pages'); 728 $role->add_cap('delete_pages'); 729 $role->add_cap('delete_others_pages'); 730 $role->add_cap('delete_published_pages'); 731 $role->add_cap('delete_posts'); 732 $role->add_cap('delete_others_posts'); 733 $role->add_cap('delete_published_posts'); 734 $role->add_cap('delete_private_posts'); 735 $role->add_cap('edit_private_posts'); 736 $role->add_cap('read_private_posts'); 737 $role->add_cap('delete_private_pages'); 738 $role->add_cap('edit_private_pages'); 739 $role->add_cap('read_private_pages'); 740 } 741 742 $role = get_role('administrator'); 743 if ( ! empty($role) ) { 744 $role->add_cap('delete_users'); 745 $role->add_cap('create_users'); 746 } 747 748 $role = get_role('author'); 749 if ( ! empty($role) ) { 750 $role->add_cap('delete_posts'); 751 $role->add_cap('delete_published_posts'); 752 } 753 754 $role = get_role('contributor'); 755 if ( ! empty($role) ) { 756 $role->add_cap('delete_posts'); 798 } 799 800 $role->add_cap( 'edit_others_pages' ); 801 $role->add_cap( 'edit_published_pages' ); 802 $role->add_cap( 'publish_pages' ); 803 $role->add_cap( 'delete_pages' ); 804 $role->add_cap( 'delete_others_pages' ); 805 $role->add_cap( 'delete_published_pages' ); 806 $role->add_cap( 'delete_posts' ); 807 $role->add_cap( 'delete_others_posts' ); 808 $role->add_cap( 'delete_published_posts' ); 809 $role->add_cap( 'delete_private_posts' ); 810 $role->add_cap( 'edit_private_posts' ); 811 $role->add_cap( 'read_private_posts' ); 812 $role->add_cap( 'delete_private_pages' ); 813 $role->add_cap( 'edit_private_pages' ); 814 $role->add_cap( 'read_private_pages' ); 815 } 816 817 $role = get_role( 'administrator' ); 818 if ( ! empty( $role ) ) { 819 $role->add_cap( 'delete_users' ); 820 $role->add_cap( 'create_users' ); 821 } 822 823 $role = get_role( 'author' ); 824 if ( ! empty( $role ) ) { 825 $role->add_cap( 'delete_posts' ); 826 $role->add_cap( 'delete_published_posts' ); 827 } 828 829 $role = get_role( 'contributor' ); 830 if ( ! empty( $role ) ) { 831 $role->add_cap( 'delete_posts' ); 757 832 } 758 833 } … … 766 841 $role = get_role( 'administrator' ); 767 842 768 if ( ! empty( $role ) ) {843 if ( ! empty( $role ) ) { 769 844 $role->add_cap( 'unfiltered_upload' ); 770 845 } … … 779 854 $role = get_role( 'administrator' ); 780 855 781 if ( ! empty( $role ) ) {856 if ( ! empty( $role ) ) { 782 857 $role->add_cap( 'edit_dashboard' ); 783 858 } … … 792 867 $role = get_role( 'administrator' ); 793 868 794 if ( ! empty( $role ) ) {869 if ( ! empty( $role ) ) { 795 870 $role->add_cap( 'update_plugins' ); 796 871 $role->add_cap( 'delete_plugins' ); … … 806 881 $role = get_role( 'administrator' ); 807 882 808 if ( ! empty( $role ) ) {883 if ( ! empty( $role ) ) { 809 884 $role->add_cap( 'install_plugins' ); 810 885 $role->add_cap( 'update_themes' ); … … 820 895 $role = get_role( 'administrator' ); 821 896 822 if ( ! empty( $role ) ) {897 if ( ! empty( $role ) ) { 823 898 $role->add_cap( 'install_themes' ); 824 899 } … … 833 908 $role = get_role( 'administrator' ); 834 909 835 if ( ! empty( $role ) ) {910 if ( ! empty( $role ) ) { 836 911 $role->add_cap( 'update_core' ); 837 912 $role->add_cap( 'list_users' ); … … 844 919 } 845 920 846 if ( !function_exists( 'install_network' ) ) : 847 /** 848 * Install Network. 849 * 850 * @since 3.0.0 851 */ 852 function install_network() { 853 if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) 854 define( 'WP_INSTALLING_NETWORK', true ); 855 856 dbDelta( wp_get_db_schema( 'global' ) ); 857 } 921 if ( ! function_exists( 'install_network' ) ) : 922 /** 923 * Install Network. 924 * 925 * @since 3.0.0 926 */ 927 function install_network() { 928 if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) { 929 define( 'WP_INSTALLING_NETWORK', true ); 930 } 931 932 dbDelta( wp_get_db_schema( 'global' ) ); 933 } 858 934 endif; 859 935 … … 882 958 883 959 $errors = new WP_Error(); 884 if ( '' == $domain ) 960 if ( '' == $domain ) { 885 961 $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); 886 if ( '' == $site_name ) 962 } 963 if ( '' == $site_name ) { 887 964 $errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) ); 965 } 888 966 889 967 // Check for network collision. … … 899 977 } 900 978 901 if ( ! is_email( $email ) ) 979 if ( ! is_email( $email ) ) { 902 980 $errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) ); 903 904 if ( $errors->get_error_code() ) 981 } 982 983 if ( $errors->get_error_code() ) { 905 984 return $errors; 985 } 906 986 907 987 // If a user with the provided email does not exist, default to the current user as the new network admin. … … 912 992 913 993 // Set up site tables. 914 $template = get_option( 'template' );915 $stylesheet = get_option( 'stylesheet' );994 $template = get_option( 'template' ); 995 $stylesheet = get_option( 'stylesheet' ); 916 996 $allowed_themes = array( $stylesheet => true ); 917 997 … … 932 1012 933 1013 if ( 1 == $network_id ) { 934 $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) ); 1014 $wpdb->insert( 1015 $wpdb->site, array( 1016 'domain' => $domain, 1017 'path' => $path, 1018 ) 1019 ); 935 1020 $network_id = $wpdb->insert_id; 936 1021 } else { 937 $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) ); 1022 $wpdb->insert( 1023 $wpdb->site, array( 1024 'domain' => $domain, 1025 'path' => $path, 1026 'id' => $network_id, 1027 ) 1028 ); 938 1029 } 939 1030 940 1031 wp_cache_delete( 'networks_have_paths', 'site-options' ); 941 1032 942 if ( ! is_multisite() ) {1033 if ( ! is_multisite() ) { 943 1034 $site_admins = array( $site_user->user_login ); 944 $users = get_users( array( 945 'fields' => array( 'user_login' ), 946 'role' => 'administrator', 947 ) ); 1035 $users = get_users( 1036 array( 1037 'fields' => array( 'user_login' ), 1038 'role' => 'administrator', 1039 ) 1040 ); 948 1041 if ( $users ) { 949 1042 foreach ( $users as $user ) { … … 958 1051 959 1052 /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */ 960 $welcome_email = __( 'Howdy USERNAME, 1053 $welcome_email = __( 1054 'Howdy USERNAME, 961 1055 962 1056 Your new SITE_NAME site has been successfully set up at: … … 971 1065 We hope you enjoy your new site. Thanks! 972 1066 973 --The Team @ SITE_NAME' ); 1067 --The Team @ SITE_NAME' 1068 ); 974 1069 975 1070 $misc_exts = array( 976 1071 // Images. 977 'jpg', 'jpeg', 'png', 'gif', 1072 'jpg', 1073 'jpeg', 1074 'png', 1075 'gif', 978 1076 // Video. 979 'mov', 'avi', 'mpg', '3gp', '3g2', 1077 'mov', 1078 'avi', 1079 'mpg', 1080 '3gp', 1081 '3g2', 980 1082 // "audio". 981 'midi', 'mid', 1083 'midi', 1084 'mid', 982 1085 // Miscellaneous. 983 'pdf', 'doc', 'ppt', 'odt', 'pptx', 'docx', 'pps', 'ppsx', 'xls', 'xlsx', 'key', 1086 'pdf', 1087 'doc', 1088 'ppt', 1089 'odt', 1090 'pptx', 1091 'docx', 1092 'pps', 1093 'ppsx', 1094 'xls', 1095 'xlsx', 1096 'key', 984 1097 ); 985 $audio_exts = wp_get_audio_extensions();986 $video_exts = wp_get_video_extensions();1098 $audio_exts = wp_get_audio_extensions(); 1099 $video_exts = wp_get_video_extensions(); 987 1100 $upload_filetypes = array_unique( array_merge( $misc_exts, $audio_exts, $video_exts ) ); 988 1101 989 1102 $sitemeta = array( 990 'site_name' => $site_name,991 'admin_email' => $email,992 'admin_user_id' => $site_user->ID,993 'registration' => 'none',994 'upload_filetypes' => implode( ' ', $upload_filetypes ),995 'blog_upload_space' => 100,996 'fileupload_maxk' => 1500,997 'site_admins' => $site_admins,998 'allowedthemes' => $allowed_themes,999 'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ),1000 'wpmu_upgrade_site' => $wp_db_version,1001 'welcome_email' => $welcome_email,1103 'site_name' => $site_name, 1104 'admin_email' => $email, 1105 'admin_user_id' => $site_user->ID, 1106 'registration' => 'none', 1107 'upload_filetypes' => implode( ' ', $upload_filetypes ), 1108 'blog_upload_space' => 100, 1109 'fileupload_maxk' => 1500, 1110 'site_admins' => $site_admins, 1111 'allowedthemes' => $allowed_themes, 1112 'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ), 1113 'wpmu_upgrade_site' => $wp_db_version, 1114 'welcome_email' => $welcome_email, 1002 1115 /* translators: %s: site link */ 1003 'first_post' => __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' ),1116 'first_post' => __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' ), 1004 1117 // @todo - network admins should have a method of editing the network siteurl (used for cookie hash) 1005 'siteurl' => get_option( 'siteurl' ) . '/',1006 'add_new_users' => '0',1118 'siteurl' => get_option( 'siteurl' ) . '/', 1119 'add_new_users' => '0', 1007 1120 'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1', 1008 'subdomain_install' => intval( $subdomain_install ),1009 'global_terms_enabled' => global_terms_enabled() ? '1' : '0',1010 'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0',1011 'initial_db_version' => get_option( 'initial_db_version' ),1012 'active_sitewide_plugins' => array(),1013 'WPLANG' => get_locale(),1121 'subdomain_install' => intval( $subdomain_install ), 1122 'global_terms_enabled' => global_terms_enabled() ? '1' : '0', 1123 'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0', 1124 'initial_db_version' => get_option( 'initial_db_version' ), 1125 'active_sitewide_plugins' => array(), 1126 'WPLANG' => get_locale(), 1014 1127 ); 1015 if ( ! $subdomain_install ) 1128 if ( ! $subdomain_install ) { 1016 1129 $sitemeta['illegal_names'][] = 'blog'; 1130 } 1017 1131 1018 1132 /** … … 1028 1142 $insert = ''; 1029 1143 foreach ( $sitemeta as $meta_key => $meta_value ) { 1030 if ( is_array( $meta_value ) ) 1144 if ( is_array( $meta_value ) ) { 1031 1145 $meta_value = serialize( $meta_value ); 1032 if ( !empty( $insert ) ) 1146 } 1147 if ( ! empty( $insert ) ) { 1033 1148 $insert .= ', '; 1034 $insert .= $wpdb->prepare( "( %d, %s, %s)", $network_id, $meta_key, $meta_value ); 1149 } 1150 $insert .= $wpdb->prepare( '( %d, %s, %s)', $network_id, $meta_key, $meta_value ); 1035 1151 } 1036 1152 $wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert ); … … 1044 1160 */ 1045 1161 if ( ! is_multisite() ) { 1046 $current_site = new stdClass;1047 $current_site->domain = $domain;1048 $current_site->path = $path;1162 $current_site = new stdClass; 1163 $current_site->domain = $domain; 1164 $current_site->path = $path; 1049 1165 $current_site->site_name = ucfirst( $domain ); 1050 $wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'blog_id' => 1, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) ); 1166 $wpdb->insert( 1167 $wpdb->blogs, array( 1168 'site_id' => $network_id, 1169 'blog_id' => 1, 1170 'domain' => $domain, 1171 'path' => $path, 1172 'registered' => current_time( 'mysql' ), 1173 ) 1174 ); 1051 1175 $current_site->blog_id = $blog_id = $wpdb->insert_id; 1052 1176 update_user_meta( $site_user->ID, 'source_domain', $domain ); 1053 1177 update_user_meta( $site_user->ID, 'primary_blog', $blog_id ); 1054 1178 1055 if ( $subdomain_install ) 1179 if ( $subdomain_install ) { 1056 1180 $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 1057 else1181 } else { 1058 1182 $wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' ); 1183 } 1059 1184 1060 1185 flush_rewrite_rules(); 1061 1186 1062 if ( ! $subdomain_install ) 1187 if ( ! $subdomain_install ) { 1063 1188 return true; 1189 } 1064 1190 1065 1191 $vhost_ok = false; 1066 $errstr = '';1192 $errstr = ''; 1067 1193 $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname! 1068 $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); 1069 if ( is_wp_error( $page ) ) 1194 $page = wp_remote_get( 1195 'http://' . $hostname, array( 1196 'timeout' => 5, 1197 'httpversion' => '1.1', 1198 ) 1199 ); 1200 if ( is_wp_error( $page ) ) { 1070 1201 $errstr = $page->get_error_message(); 1071 elseif ( 200 == wp_remote_retrieve_response_code( $page ) )1202 } elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) { 1072 1203 $vhost_ok = true; 1204 } 1073 1205 1074 1206 if ( ! $vhost_ok ) { … … 1080 1212 '<code>' . $hostname . '</code>' 1081 1213 ); 1082 if ( ! empty ( $errstr ) ) {1214 if ( ! empty( $errstr ) ) { 1083 1215 /* translators: %s: error message */ 1084 1216 $msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' );
Note: See TracChangeset
for help on using the changeset viewer.