Make WordPress Core

Ticket #26410: patch.diff

File patch.diff, 1.9 KB (added by codix, 11 years ago)
  • wp-includes/ms-blogs.php

    From 5d449e074cd7af08f73577bda372c1e4d1fa3028 Mon Sep 17 00:00:00 2001
    From: S H Mohanjith <moha@mohanjith.net>
    Date: Wed, 4 Dec 2013 22:06:02 +0200
    Subject: [PATCH] - Update site options and refresh blog details when options
     are updated using update_option() - Delete site options
     when options are updated using delete_option()
    
    ---
     wp-includes/ms-blogs.php | 40 ++++++++++++++++++++++++++++++++++++++++
     1 file changed, 40 insertions(+)
    
    diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php
    index 8d05f10..f343759 100644
    a b function clean_blog_cache( $blog ) { 
    424424}
    425425
    426426/**
     427 * Update site options and refresh blog details when options are updated using
     428 * update_option();
     429 *
     430 * @since 3.9
     431 *
     432 * @param string $option The option key
     433 * @param mixed $old_value The old option value
     434 * @param mixed $newvalue The new option value
     435 */
     436function update_any_blog_option( $option, $old_value, $new_value ) {
     437    global $wpdb;
     438
     439        if ( defined( 'WP_INSTALLING' ) )
     440                return;
     441
     442    wp_cache_set( $wpdb->blogid . '-' . $option . '-blog_option', $new_value, 'site-options' );
     443    if ( in_array( $option, array( 'blogname', 'siteurl', 'post_count' ) ) ) {
     444        refresh_blog_details( $wpdb->blogid );
     445    }
     446}
     447add_action( 'updated_option', 'update_any_blog_option', 10, 3 );
     448
     449/**
     450 * Delete site options when options are updated using delete_option();
     451 *
     452 * @since 3.9
     453 *
     454 * @param string $option The option key
     455 */
     456function delete_any_blog_option( $option ) {
     457    global $wpdb;
     458
     459        if ( defined( 'WP_INSTALLING' ) )
     460                return;
     461
     462    wp_cache_delete( $wpdb->blogid . '-' . $option . '-blog_option', 'site-options' );
     463}
     464add_action( 'deleted_option', 'delete_any_blog_option', 10, 1 );
     465
     466/**
    427467 * Retrieve option value for a given blog id based on name of option.
    428468 *
    429469 * If the option does not exist or does not have a value, then the return value