Make WordPress Core

Changeset 22185


Ignore:
Timestamp:
10/11/2012 12:37:46 PM (12 years ago)
Author:
ryan
Message:

Sync actions between update_blog_details() and update_blog_status(). Add make_delete_blog and make_undelete_blog actions.

Props Kyrylo, wonderboymusic
fixes #20305

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-blogs.php

    r22108 r22185  
    293293        $update_details[$field] = $details[$field];
    294294
    295     $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
     295    $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
     296
     297    if ( false === $result )
     298        return false;
    296299
    297300    // If spam status changed, issue actions.
    298301    if ( $details[ 'spam' ] != $current_details[ 'spam' ] ) {
    299302        if ( $details[ 'spam' ] == 1 )
    300             do_action( "make_spam_blog", $blog_id );
     303            do_action( 'make_spam_blog', $blog_id );
    301304        else
    302             do_action( "make_ham_blog", $blog_id );
    303     }
    304 
    305     if ( isset($details[ 'public' ]) ) {
     305            do_action( 'make_ham_blog', $blog_id );
     306    }
     307
     308    // If mature status changed, issue actions.
     309    if ( $details[ 'mature' ] != $current_details[ 'mature' ] ) {
     310        if ( $details[ 'mature' ] == 1 )
     311            do_action( 'mature_blog', $blog_id );
     312        else
     313            do_action( 'unmature_blog', $blog_id );
     314    }
     315
     316    // If archived status changed, issue actions.
     317    if ( $details[ 'archived' ] != $current_details[ 'archived' ] ) {
     318        if ( $details[ 'archived' ] == 1 )
     319            do_action( 'archive_blog', $blog_id );
     320        else
     321            do_action( 'unarchive_blog', $blog_id );
     322    }
     323
     324    // If deleted status changed, issue actions.
     325    if ( $details[ 'deleted' ] != $current_details[ 'deleted' ] ) {
     326        if ( $details[ 'deleted' ] == 1 )
     327            do_action( 'make_delete_blog', $blog_id );
     328        else
     329            do_action( 'make_undelete_blog', $blog_id );
     330    }   
     331   
     332    if ( isset( $details[ 'public' ] ) ) {
    306333        switch_to_blog( $blog_id );
    307334        update_option( 'blog_public', $details[ 'public' ] );
     
    643670        _deprecated_argument( __FUNCTION__, '3.1' );
    644671
    645     if ( !in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
     672    if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
    646673        return $value;
    647674
    648     $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
    649 
    650     refresh_blog_details($blog_id);
     675    $result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
     676
     677    if ( false === $result )
     678        return false;
     679
     680    refresh_blog_details( $blog_id );
    651681
    652682    if ( 'spam' == $pref )
     
    656686    elseif ( 'archived' == $pref )
    657687        ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id );
    658     elseif ( 'archived' == $pref )
    659         ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id );
     688    elseif ( 'deleted' == $pref )
     689        ( $value == 1 ) ? do_action( 'make_delete_blog', $blog_id ) : do_action( 'make_undelete_blog', $blog_id );
    660690
    661691    return $value;
Note: See TracChangeset for help on using the changeset viewer.