Make WordPress Core

Ticket #25229: ms.2.diff

File ms.2.diff, 10.4 KB (added by enej, 11 years ago)

Second pass at ms.php

  • ms.php

     
    6161        }
    6262
    6363        $blog = get_blog_details( $blog_id );
    64 
     64        /**
     65         * Fires before a blog is deleted.
     66         *
     67         * @since 3.0.0
     68         *
     69         * @param int $blog_id Blog ID.
     70         * @param bool $drop True if blog's table should be dropped. Default is false.
     71         */
    6572        do_action( 'delete_blog', $blog_id, $drop );
    6673
    6774        $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) );
     
    8087                $drop = false;
    8188
    8289        if ( $drop ) {
     90                /**
     91                 * Filter the tables to drop when the blog is deleted.
     92                 *
     93                 * @since 3.0.0
     94                 *
     95                 * @param array Blog tables that you want to be dropped.
     96                 * @param int $blog_id Blog ID of the blog which tables are going to be dropped.
     97                 */
    8398                $drop_tables = apply_filters( 'wpmu_drop_tables', $wpdb->tables( 'blog' ), $blog_id );
    8499
    85100                foreach ( (array) $drop_tables as $table ) {
     
    89104                $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
    90105
    91106                $uploads = wp_upload_dir();
     107                /**
     108                 * Filter the upload base directory to delete when the blog is deleted.
     109                 *
     110                 * @since 3.0.0
     111                 *
     112                 * @param string $uploads['basedir'] uploads path without subdirectory. see wp_upload_dir().
     113                 * @param int $blog_id Blog ID.
     114                 */
    92115                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
    93116                $dir = rtrim( $dir, DIRECTORY_SEPARATOR );
    94117                $top_dir = $dir;
     
    137160
    138161        if ( !$user->exists() )
    139162                return false;
    140 
     163        /**
     164         * Fires when a user is deleted from the network
     165         *
     166         * Long description.
     167         *
     168         * @since 3.0.0
     169         *
     170         * @param int $id User ID of the user about to be deleted from the network.
     171         *
     172         */
    141173        do_action( 'wpmu_delete_user', $id );
    142174
    143175        $blogs = get_blogs_of_user( $id );
     
    172204
    173205        clean_user_cache( $user );
    174206
    175         // allow for commit transaction
     207       
     208        /**
     209         * Fires after the user is deleted. Allow for commit transaction.
     210         *
     211         * This hook also occures in /wp-admin/includes/user.php
     212         *
     213         * @since 2.8.0
     214         *
     215         * @param int $id User ID of the user about to be deleted from the network.
     216         */
    176217        do_action( 'deleted_user', $id );
    177218
    178219        return true;
     
    189230                'newemail' => $value
    190231        );
    191232        update_option( 'adminhash', $new_admin_email );
     233       
     234        $email_text = "Dear user,
    192235
    193         $content = apply_filters( 'new_admin_email_content', __( "Dear user,
    194 
    195236You recently requested to have the administration email address on
    196237your site changed.
    197238If this is correct, please click on the following link to change it:
     
    204245
    205246Regards,
    206247All at ###SITENAME###
    207 ###SITEURL### "), $new_admin_email );
     248###SITEURL### ";
    208249
     250        /**
     251         * Filter the email text that gets sent out when the site admin email is requested to be changed.
     252         *
     253         * The Following string have a special meaning and will get replaced dynamically.
     254         * ###ADMIN_URL### The link to click on to confirm the email change. Required otherwise this functunalty is will break.
     255         * ###EMAIL### The new email.
     256         * ###SITENAME### The name of the site.
     257         * ###SITEURL### The url to the site.
     258         *
     259         * @since 3.0.0
     260         *
     261         * @param string $email_text Text in the email.
     262         * @param string $new_admin_email New admin email that the current administration email was changed to.
     263         */
     264        $content = apply_filters( 'new_admin_email_content', __( $email_text), $new_admin_email );
     265
    209266        $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content );
    210267        $content = str_replace( '###EMAIL###', $value, $content );
    211268        $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
     
    243300                                'newemail' => $_POST['email']
    244301                                );
    245302                update_option( $current_user->ID . '_new_email', $new_user_email );
     303               
     304                $email_text = "Dear user,
    246305
    247                 $content = apply_filters( 'new_user_email_content', __( "Dear user,
    248 
    249306You recently requested to have the email address on your account changed.
    250307If this is correct, please click on the following link to change it:
    251308###ADMIN_URL###
     
    257314
    258315Regards,
    259316All at ###SITENAME###
    260 ###SITEURL###" ), $new_user_email );
     317###SITEURL###";
    261318
     319                /**
     320                 * Filter the email text that gets sent out when a user changes emails.
     321                 *
     322                 * The Following string have a special meaning and will get replaced dynamically.
     323                 * ###ADMIN_URL### The link to click on to confirm the email change. Required otherwise this functunalty is will break.
     324                 * ###EMAIL### The new email.
     325                 * ###SITENAME### The name of the site.
     326                 * ###SITEURL### The url to the site.
     327                 *
     328                 * @since 3.0.0
     329                 *
     330                 * @param string $email_text Text in the email.
     331                 * @param string $new_user_email New user email that the current user has changed to.
     332                 */
     333                $content = apply_filters( 'new_user_email_content', __( $email_text ), $new_user_email );
     334
    262335                $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content );
    263336                $content = str_replace( '###EMAIL###', $_POST['email'], $content);
    264337                $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
     
    377450        clean_user_cache( $user );
    378451
    379452        if ( $pref == 'spam' ) {
    380                 if ( $value == 1 )
     453                if ( $value == 1 ) {
     454                        /**
     455                         * Fires when the user is marked as a SPAM user.
     456                         *
     457                         * @since 3.0.0
     458                         *
     459                         * @param int $id User ID of the user marked as spam.
     460                         */
    381461                        do_action( 'make_spam_user', $id );
    382                 else
     462                } else {
     463                        /**
     464                         * Fires when the user is marked as a HAM user. Opposite of SPAM.
     465                         *
     466                         * @since 3.0.0
     467                         *
     468                         * @param int $id User ID of the user marked as ham.
     469                         */
    383470                        do_action( 'make_ham_user', $id );
     471                }
    384472        }
    385473
    386474        return $value;
     
    411499                'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili',
    412500                'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek',
    413501                've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
     502       
     503        /**
     504         * Filter allows the ability to modify langage codes.
     505         *
     506         * This could be used if you want to changed the long form of a specific code.
     507         *
     508         * @since 3.0.0
     509         *
     510         * @param array $lang_codes. Key Value Pair of Language Codes where key is the short version.
     511         * @param string $code is a 2 letter desigantion of the language.
     512         */
    414513        $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code );
    415514        return strtr( $code, $lang_codes );
    416515}
     
    498597
    499598        // Order by name
    500599        uksort( $output, 'strnatcasecmp' );
    501 
     600        /**
     601         * Filter the langage dropdown of the available langages.
     602         *
     603         * @since 3.0.0
     604         *
     605         * @param array $output HTML output of the dropdown.
     606         * @param array $lang_files of langage files that are available.
     607         * @param string $current The current langage code.
     608         */
    502609        $output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
    503610        echo implode( "\n\t", $output );
    504611}
     
    575682        <?php if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) : ?>
    576683                <tr>
    577684                        <th scope="row" colspan="2" class="th-full">
    578                                 <a href="<?php echo apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); ?>"><?php _e( 'Create a New Site' ); ?></a>
     685                                <a href="<?php
     686                                /**
     687                                 * Filter the url to the site creation location.
     688                                 *
     689                                 * The url that the user goes to create a new site on the network.
     690                                 *
     691                                 * Also found in wp-login.php and wp-includes/canonical.php.
     692                                 *
     693                                 * @since 3.0.0
     694                                 *
     695                                 * @param string Url to the site creation location.
     696                                 */
     697                                echo apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); ?>"><?php _e( 'Create a New Site' ); ?></a>
    579698                        </th>
    580699                </tr>
    581700        <?php endif; ?>
     
    595714        // If global super_admins override is defined, there is nothing to do here.
    596715        if ( isset($super_admins) )
    597716                return false;
    598 
     717       
     718        /**
     719         * Fires before the user is being made a super admin.
     720         *
     721         * @since 3.0.0
     722         *
     723         * @param int $user_id User ID of the user made super admin
     724         */
    599725        do_action( 'grant_super_admin', $user_id );
    600726
    601727        // Directly fetch site_admins instead of using get_super_admins()
     
    605731        if ( $user && ! in_array( $user->user_login, $super_admins ) ) {
    606732                $super_admins[] = $user->user_login;
    607733                update_site_option( 'site_admins' , $super_admins );
     734               
     735                /**
     736                 * Fires after the user is made a super admin.
     737                 *
     738                 * @since 3.0.0
     739                 *
     740                 * @param int $user_id User ID of the user made super admin
     741                 */
    608742                do_action( 'granted_super_admin', $user_id );
    609743                return true;
    610744        }
     
    623757        // If global super_admins override is defined, there is nothing to do here.
    624758        if ( isset($super_admins) )
    625759                return false;
    626 
     760        /**
     761         * Fires before the user is removed as a super admin.
     762         *
     763         * @since 3.0.0
     764         *
     765         * @param int $user_id User ID of the user removed as a super admin.
     766         */
    627767        do_action( 'revoke_super_admin', $user_id );
    628768
    629769        // Directly fetch site_admins instead of using get_super_admins()
     
    634774                if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
    635775                        unset( $super_admins[$key] );
    636776                        update_site_option( 'site_admins', $super_admins );
     777                       
     778                        /**
     779                         * Fires after the user is removed as a super admin.
     780                         *
     781                         * @since 3.0.0
     782                         *
     783                         * @param int $user_id User ID of the user removed as a super admin.
     784                         */
    637785                        do_action( 'revoked_super_admin', $user_id );
    638786                        return true;
    639787                }
     
    656804                $result = true;
    657805        else
    658806                $result = false;
    659 
     807        /**
     808         * Filter whether or not we can edit this network from this page.
     809         *
     810         * @since 3.1.0
     811         *
     812         * @param bool $result Can you edit this network from this page?
     813         * @param int $site_id The network/site id to check. Different from blog id.
     814         */
    660815        return apply_filters( 'can_edit_network', $result, $site_id );
    661816}
    662817