WordPress.org

Make WordPress Core

Ticket #30483: 30483.2.diff

File 30483.2.diff, 9.3 KB (added by dustyf, 7 years ago)

New patch including feedback from jeremyfelt

  • wp-admin/includes/ms.php

     
    4848 *
    4949 * @since 3.0.0
    5050 *
    51  * @param int $blog_id Blog ID
    52  * @param bool $drop True if blog's table should be dropped. Default is false.
     51 * @param int  $blog_id Blog ID
     52 * @param bool $drop    True if blog's table should be dropped. Default is false.
    5353 * @return void
    5454 */
    5555function wpmu_delete_blog( $blog_id, $drop = false ) {
     
    169169                restore_current_blog();
    170170}
    171171
    172 // @todo Merge with wp_delete_user() ?
     172/**
     173 * Delete a user from the network and remove from all sites.
     174 *
     175 * @since 3.0.0
     176 * @todo Merge with wp_delete_user() ?
     177 *
     178 * @param int $id The ID of the user.
     179 * @return bool True if the user was deleted, otherwise false.
     180 */
    173181function wpmu_delete_user( $id ) {
    174182        global $wpdb;
    175183
     
    225233        return true;
    226234}
    227235
     236/**
     237 * Sends an email when a site administrator email address is changed.
     238 *
     239 * @since 3.0.0
     240 *
     241 * @param string $old_value The old email address. Not currently used.
     242 * @param string $value     The new email address.
     243 */
    228244function update_option_new_admin_email( $old_value, $value ) {
    229245        if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
    230246                return;
     
    278294add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
    279295add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
    280296
     297/**
     298 * Sends an email when an email address change is requested.
     299 *
     300 * @since 3.0.0
     301 */
    281302function send_confirmation_on_profile_email() {
    282303        global $errors, $wpdb;
    283304        $current_user = wp_get_current_user();
     
    348369}
    349370add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
    350371
     372/**
     373 * Adds an admin notice alterting the user to check for confirmation email after email address change.
     374 *
     375 * @since 3.0.0
     376 */
    351377function new_user_email_admin_notice() {
    352378        if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
    353379                echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
     
    360386 * @since MU
    361387 *
    362388 * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
    363  * @return int
     389 * @return bool True if user is over upload space quota, otherwise false.
    364390 */
    365391function upload_is_user_over_quota( $echo = true ) {
    366392        if ( get_site_option( 'upload_space_check_disabled' ) )
     
    422448        return min( $size, $available );
    423449}
    424450
    425 // Edit blog upload space setting on Edit Blog page
     451/**
     452 * Displays the edit blog upload space setting form on Edit Blog page.
     453 *
     454 * @since 3.0.0
     455 *
     456 * @param int $id The ID of the blog to display the setting for.
     457 */
    426458function upload_space_setting( $id ) {
    427459        switch_to_blog( $id );
    428460        $quota = get_option( 'blog_upload_space' );
     
    440472}
    441473add_action( 'wpmueditblogaction', 'upload_space_setting' );
    442474
     475/**
     476 * Update the status of a user in the database.
     477 *
     478 * Used in core to mark a user as spam or "ham" (not spam) on multisite installs.
     479 *
     480 * @since 3.0.0
     481 *
     482 * @param int    $id         The ID of the user.
     483 * @param string $pref       The column in the wp_users table to update the user's status in (presumably
     484 *                           user_status, spam or deleted).
     485 * @param int    $value      The new status for the user.
     486 * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
     487 * @return int   THe initially passed $value.
     488 */
    443489function update_user_status( $id, $pref, $value, $deprecated = null ) {
    444490        global $wpdb;
    445491
     
    476522        return $value;
    477523}
    478524
     525/**
     526 * Cleans the user cache for a specific user.
     527 *
     528 * @since 3.0.0
     529 *
     530 * @param $id The user ID.
     531 * @return bool|int The ID of the refreshed user or false if user does not exist.
     532 */
    479533function refresh_user_details( $id ) {
    480534        $id = (int) $id;
    481535
     
    487541        return $id;
    488542}
    489543
     544/**
     545 * Returns the language for a language code.
     546 *
     547 * @since 3.0.0
     548 *
     549 * @param string $code Optional. The two-letter language code.
     550 * @return string The language corresponding to $code if it exists. If it does not exist, then the first
     551 *                two letters of $code is returned.
     552 */
    490553function format_code_lang( $code = '' ) {
    491554        $code = strtolower( substr( $code, 0, 2 ) );
    492555        $lang_codes = array(
     
    514577        return strtr( $code, $lang_codes );
    515578}
    516579
     580/**
     581 * Synchronize category and post tag slugs when global terms are enabled.
     582 *
     583 * @since 3.0.0
     584 *
     585 * @param $term     The term.
     586 * @param $taxonomy The taxonomy for $term. Should be 'category' or 'post_tag', as these are the only
     587 *                  taxonomies which are processed by this function; anything else will be returned untouched.
     588 * @return object|array Returns $term, after filtering the 'slug' field with sanitize_title() if $taxonomy
     589 *                      is 'category' or 'post_tag'.
     590 */
    517591function sync_category_tag_slugs( $term, $taxonomy ) {
    518592        if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
    519593                if ( is_object( $term ) ) {
     
    526600}
    527601add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
    528602
     603/**
     604 * Displays an access denied message when a user tries to view a site's dashboard they do not have access to.
     605 *
     606 * @since 3.2.0
     607 */
    529608function _access_denied_splash() {
    530609        if ( ! is_user_logged_in() || is_network_admin() )
    531610                return;
     
    560639}
    561640add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
    562641
     642/**
     643 * Checks if the current user has permissions to import new users.
     644 *
     645 * @since 3.0.0
     646 *
     647 * @param $permission A permission to be checked. Currently not used.
     648 * @return bool True if the user has proper permissions, false if they do not.
     649 */
    563650function check_import_new_users( $permission ) {
    564651        if ( !is_super_admin() )
    565652                return false;
     
    568655add_filter( 'import_allow_create_users', 'check_import_new_users' );
    569656// See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too.
    570657
     658/**
     659 * Display a dropdown of available languages.
     660 *
     661 * @since 3.0.0
     662 *
     663 * @param array  $lang_files An array of the language files.
     664 * @param string $current    The current language code.
     665 */
    571666function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
    572667        $flag = false;
    573668        $output = array();
     
    608703        echo implode( "\n\t", $output );
    609704}
    610705
     706/**
     707 * Displays an admin notice to upgrade all sites after a WordPress Core Upgrade.
     708 *
     709 * @since 3.0.0
     710 */
    611711function site_admin_notice() {
    612712        global $wp_db_version;
    613713        if ( !is_super_admin() )
     
    618718add_action( 'admin_notices', 'site_admin_notice' );
    619719add_action( 'network_admin_notices', 'site_admin_notice' );
    620720
     721/**
     722 * Avoids a collision between a site slug and a permalink slug.
     723 *
     724 * In a subdirectory install this will make sure that a site and a post do not use the same subdirectory by checking
     725 * for a site with the same name as a new post.
     726 *
     727 * @since 3.0.0
     728 *
     729 * @param array $data    An array of post data.
     730 * @param array $postarr An array of posts. Not currently used.
     731 * @return array The new array of post data after checking for collisions.
     732 */
    621733function avoid_blog_page_permalink_collision( $data, $postarr ) {
    622734        if ( is_subdomain_install() )
    623735                return $data;
     
    641753}
    642754add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
    643755
     756/**
     757 * Handles the display of choosing a users primary site.
     758 *
     759 * This displays the user's primary site and allows the user to choose which site is primary.
     760 * Used in wp-admin/my-sites.php.
     761 *
     762 * @since 3.0.0
     763 */
    644764function choose_primary_blog() {
    645765        ?>
    646766        <table class="form-table">
     
    696816 * Grants Super Admin privileges.
    697817 *
    698818 * @since 3.0.0
     819 *
    699820 * @param int $user_id ID of the user to be granted Super Admin privileges.
    700821 * @return bool True on success, false on failure. This can fail when the user is
    701822 *              already a super admin or when the $super_admins global is defined.
     
    740861 * Revokes Super Admin privileges.
    741862 *
    742863 * @since 3.0.0
     864 *
    743865 * @param int $user_id ID of the user Super Admin privileges to be revoked from.
    744866 * @return bool True on success, false on failure. This can fail when the user's email
    745867 *              is the network admin email or when the $super_admins global is defined.
     
    783905}
    784906
    785907/**
    786  * Whether or not we can edit this network from this page
     908 * Whether or not we can edit this network from this page.
    787909 *
    788  * By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden
     910 * By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden.
    789911 *
    790912 * @since 3.1.0
    791  * @param integer $site_id The network/site ID to check.
     913 *
     914 * @param  int  $site_id The network/site ID to check.
     915 * @return bool True if network can be edited, otherwise false.
    792916 */
    793917function can_edit_network( $site_id ) {
    794918        global $wpdb;
     
    813937 * Thickbox image paths for Network Admin.
    814938 *
    815939 * @since 3.1.0
     940 *
    816941 * @access private
    817942 */
    818943function _thickbox_path_admin_subfolder() {