Ticket #21432: 21432.diff
File 21432.diff, 12.1 KB (added by , 13 years ago) |
---|
-
class-wp-theme.php
1109 1109 1110 1110 $current = $blog_id == get_current_blog_id(); 1111 1111 1112 if ( $current ) 1112 if ( $current ) { 1113 1113 $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); 1114 else 1115 $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowedthemes' ); 1114 } else { 1115 switch_to_blog( $blog_id ); 1116 $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); 1117 restore_current_blog(); 1118 } 1116 1119 1117 1120 // This is all super old MU back compat joy. 1118 1121 // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. 1119 1122 if ( false === $allowed_themes[ $blog_id ] ) { 1120 if ( $current ) 1123 if ( $current ) { 1121 1124 $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); 1122 else 1123 $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowed_themes' ); 1125 } else { 1126 switch_to_blog( $blog_id ); 1127 $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); 1128 restore_current_blog(); 1129 } 1124 1130 1125 1131 if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) { 1126 1132 $allowed_themes[ $blog_id ] = array(); … … 1139 1145 update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); 1140 1146 delete_option( 'allowed_themes' ); 1141 1147 } else { 1142 update_blog_option( $blog_id, 'allowedthemes', $allowed_themes[ $blog_id ] ); 1143 delete_blog_option( $blog_id, 'allowed_themes' ); 1148 switch_to_blog( $blog_id ); 1149 update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); 1150 delete_option( 'allowed_themes' ); 1151 restore_current_blog(); 1144 1152 } 1145 1153 } 1146 1154 } -
ms-blogs.php
222 222 return $details; 223 223 } 224 224 225 $details->blogname = get_blog_option( $blog_id, 'blogname' ); 226 $details->siteurl = get_blog_option( $blog_id, 'siteurl' ); 227 $details->post_count = get_blog_option( $blog_id, 'post_count' ); 225 switch_to_blog( $blog_id ); 226 $details->blogname = get_option( 'blogname' ); 227 $details->siteurl = get_option( 'siteurl' ); 228 $details->post_count = get_option( 'post_count' ); 229 restore_current_blog(); 228 230 229 231 $details = apply_filters( 'blog_details', $details ); 230 232 … … 307 309 } 308 310 309 311 /** 310 * Retrieve option value for a given blog id based on name of option.311 *312 * If the option does not exist or does not have a value, then the return value313 * will be false. This is useful to check whether you need to install an option314 * and is commonly used during installation of plugin options and to test315 * whether upgrading is required.316 *317 * If the option was serialized then it will be unserialized when it is returned.318 *319 * @since MU320 *321 * @param int $id A blog ID. Can be null to refer to the current blog.322 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.323 * @param mixed $default Optional. Default value to return if the option does not exist.324 * @return mixed Value set for the option.325 */326 function get_blog_option( $id, $option, $default = false ) {327 $id = (int) $id;328 329 if ( empty( $id ) )330 $id = get_current_blog_id();331 332 if ( $id == get_current_blog_id() )333 return get_option( $option, $default );334 335 switch_to_blog( $id );336 $option = get_option( $option, $default );337 restore_current_blog();338 339 return $option;340 }341 342 /**343 * Add a new option for a given blog id.344 *345 * You do not need to serialize values. If the value needs to be serialized, then346 * it will be serialized before it is inserted into the database. Remember,347 * resources can not be serialized or added as an option.348 *349 * You can create options without values and then update the values later.350 * Existing options will not be updated and checks are performed to ensure that you351 * aren't adding a protected WordPress option. Care should be taken to not name352 * options the same as the ones which are protected.353 *354 * @since MU355 *356 * @param int $id A blog ID. Can be null to refer to the current blog.357 * @param string $option Name of option to add. Expected to not be SQL-escaped.358 * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped.359 * @return bool False if option was not added and true if option was added.360 */361 function add_blog_option( $id, $option, $value ) {362 $id = (int) $id;363 364 if ( empty( $id ) )365 $id = get_current_blog_id();366 367 if ( $id == get_current_blog_id() )368 return add_option( $option, $value );369 370 switch_to_blog( $id );371 $return = add_option( $option, $value );372 restore_current_blog();373 374 return $return;375 }376 377 /**378 * Removes option by name for a given blog id. Prevents removal of protected WordPress options.379 *380 * @since MU381 *382 * @param int $id A blog ID. Can be null to refer to the current blog.383 * @param string $option Name of option to remove. Expected to not be SQL-escaped.384 * @return bool True, if option is successfully deleted. False on failure.385 */386 function delete_blog_option( $id, $option ) {387 $id = (int) $id;388 389 if ( empty( $id ) )390 $id = get_current_blog_id();391 392 if ( $id == get_current_blog_id() )393 return delete_option( $option );394 395 switch_to_blog( $id );396 $return = delete_option( $option );397 restore_current_blog();398 399 return $return;400 }401 402 /**403 * Update an option for a particular blog.404 *405 * @since MU406 *407 * @param int $id The blog id408 * @param string $option The option key409 * @param mixed $value The option value410 * @return bool True on success, false on failrue.411 */412 function update_blog_option( $id, $option, $value, $deprecated = null ) {413 $id = (int) $id;414 415 if ( null !== $deprecated )416 _deprecated_argument( __FUNCTION__, '3.1' );417 418 if ( $id == get_current_blog_id() )419 return update_option( $option, $value );420 421 switch_to_blog( $id );422 $return = update_option( $option, $value );423 restore_current_blog();424 425 refresh_blog_details( $id );426 427 return $return;428 }429 430 /**431 312 * Switch the current blog. 432 313 * 433 314 * This function is useful if you need to pull posts, or other information, -
class-wp-xmlrpc-server.php
475 475 $blog_id = $blog->userblog_id; 476 476 $is_admin = current_user_can_for_blog( $blog_id, 'manage_options' ); 477 477 478 switch_to_blog( $blog_id ); 478 479 $struct[] = array( 479 480 'isAdmin' => $is_admin, 480 'url' => get_home_url( $blog_id,'/' ),481 'url' => home_url( '/' ), 481 482 'blogid' => (string) $blog_id, 482 'blogName' => get_ blog_option( $blog_id,'blogname' ),483 'xmlrpc' => get_site_url( $blog_id,'xmlrpc.php' )483 'blogName' => get_option( 'blogname' ), 484 'xmlrpc' => site_url( 'xmlrpc.php' ) 484 485 ); 486 restore_current_blog(); 485 487 } 486 488 487 489 return $struct; -
link-template.php
1896 1896 if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) 1897 1897 $scheme = is_ssl() && !is_admin() ? 'https' : 'http'; 1898 1898 1899 if ( empty( $blog_id ) || !is_multisite() ) 1899 if ( empty( $blog_id ) || !is_multisite() ) { 1900 1900 $url = get_option( 'home' ); 1901 else 1902 $url = get_blog_option( $blog_id, 'home' ); 1901 } else { 1902 switch_to_blog( $blog_id ); 1903 $url = get_option( 'home' ); 1904 restore_current_blog(); 1905 } 1903 1906 1904 1907 if ( 'relative' == $scheme ) 1905 1908 $url = preg_replace( '#^.+://[^/]*#', '', $url ); … … 1961 1964 $scheme = ( is_ssl() ? 'https' : 'http' ); 1962 1965 } 1963 1966 1964 if ( empty( $blog_id ) || !is_multisite() ) 1967 if ( empty( $blog_id ) || !is_multisite() ) { 1965 1968 $url = get_option( 'siteurl' ); 1966 else 1967 $url = get_blog_option( $blog_id, 'siteurl' ); 1969 } else { 1970 switch_to_blog( $blog_id ); 1971 $url = get_option( 'siteurl' ); 1972 restore_current_blog(); 1973 } 1968 1974 1969 1975 if ( 'relative' == $scheme ) 1970 1976 $url = preg_replace( '#^.+://[^/]*#', '', $url ); -
ms-deprecated.php
270 270 } 271 271 return $url; 272 272 } 273 274 /** 275 * Retrieve option value for a given blog id based on name of option. 276 * 277 * If the option does not exist or does not have a value, then the return value 278 * will be false. This is useful to check whether you need to install an option 279 * and is commonly used during installation of plugin options and to test 280 * whether upgrading is required. 281 * 282 * If the option was serialized then it will be unserialized when it is returned. 283 * 284 * @since MU 285 * @deprecated 3.5.0 286 * 287 * @param int $id A blog ID. Can be null to refer to the current blog. 288 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped. 289 * @param mixed $default Optional. Default value to return if the option does not exist. 290 * @return mixed Value set for the option. 291 */ 292 function get_blog_option( $id, $option, $default = false ) { 293 _deprecated_function( __FUNCTION__, '3.5' ); 294 295 $id = (int) $id; 296 297 if ( empty( $id ) ) 298 $id = get_current_blog_id(); 299 300 if ( $id == get_current_blog_id() ) 301 return get_option( $option, $default ); 302 303 switch_to_blog( $id ); 304 $option = get_option( $option, $default ); 305 restore_current_blog(); 306 307 return $option; 308 } 309 310 /** 311 * Add a new option for a given blog id. 312 * 313 * You do not need to serialize values. If the value needs to be serialized, then 314 * it will be serialized before it is inserted into the database. Remember, 315 * resources can not be serialized or added as an option. 316 * 317 * You can create options without values and then update the values later. 318 * Existing options will not be updated and checks are performed to ensure that you 319 * aren't adding a protected WordPress option. Care should be taken to not name 320 * options the same as the ones which are protected. 321 * 322 * @since MU 323 * @deprecated 3.5.0 324 * 325 * @param int $id A blog ID. Can be null to refer to the current blog. 326 * @param string $option Name of option to add. Expected to not be SQL-escaped. 327 * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped. 328 * @return bool False if option was not added and true if option was added. 329 */ 330 function add_blog_option( $id, $option, $value ) { 331 _deprecated_function( __FUNCTION__, '3.5' ); 332 333 $id = (int) $id; 334 335 if ( empty( $id ) ) 336 $id = get_current_blog_id(); 337 338 if ( $id == get_current_blog_id() ) 339 return add_option( $option, $value ); 340 341 switch_to_blog( $id ); 342 $return = add_option( $option, $value ); 343 restore_current_blog(); 344 345 return $return; 346 } 347 348 /** 349 * Removes option by name for a given blog id. Prevents removal of protected WordPress options. 350 * 351 * @since MU 352 * @deprecated 3.5.0 353 * 354 * @param int $id A blog ID. Can be null to refer to the current blog. 355 * @param string $option Name of option to remove. Expected to not be SQL-escaped. 356 * @return bool True, if option is successfully deleted. False on failure. 357 */ 358 function delete_blog_option( $id, $option ) { 359 _deprecated_function( __FUNCTION__, '3.5' ); 360 361 $id = (int) $id; 362 363 if ( empty( $id ) ) 364 $id = get_current_blog_id(); 365 366 if ( $id == get_current_blog_id() ) 367 return delete_option( $option ); 368 369 switch_to_blog( $id ); 370 $return = delete_option( $option ); 371 restore_current_blog(); 372 373 return $return; 374 } 375 376 /** 377 * Update an option for a particular blog. 378 * 379 * @since MU 380 * @deprecated 3.5.0 381 * 382 * @param int $id The blog id 383 * @param string $option The option key 384 * @param mixed $value The option value 385 * @return bool True on success, false on failrue. 386 */ 387 function update_blog_option( $id, $option, $value, $deprecated = null ) { 388 _deprecated_function( __FUNCTION__, '3.5' ); 389 390 $id = (int) $id; 391 392 if ( null !== $deprecated ) 393 _deprecated_argument( __FUNCTION__, '3.1' ); 394 395 if ( $id == get_current_blog_id() ) 396 return update_option( $option, $value ); 397 398 switch_to_blog( $id ); 399 $return = update_option( $option, $value ); 400 restore_current_blog(); 401 402 refresh_blog_details( $id ); 403 404 return $return; 405 }