changeset 204 | 09a1c134465b |
parent 194 | 32102edaa81b |
203:f507feede89a | 204:09a1c134465b |
---|---|
30 * @return mixed Value set for the option. |
30 * @return mixed Value set for the option. |
31 */ |
31 */ |
32 function get_option( $option, $default = false ) { |
32 function get_option( $option, $default = false ) { |
33 global $wpdb; |
33 global $wpdb; |
34 |
34 |
35 $option = trim( $option ); |
|
36 if ( empty( $option ) ) |
|
37 return false; |
|
38 |
|
35 // Allow plugins to short-circuit options. |
39 // Allow plugins to short-circuit options. |
36 $pre = apply_filters( 'pre_option_' . $option, false ); |
40 $pre = apply_filters( 'pre_option_' . $option, false ); |
37 if ( false !== $pre ) |
41 if ( false !== $pre ) |
38 return $pre; |
42 return $pre; |
39 |
|
40 $option = trim($option); |
|
41 if ( empty($option) ) |
|
42 return false; |
|
43 |
43 |
44 if ( defined( 'WP_SETUP_CONFIG' ) ) |
44 if ( defined( 'WP_SETUP_CONFIG' ) ) |
45 return false; |
45 return false; |
46 |
46 |
47 if ( ! defined( 'WP_INSTALLING' ) ) { |
47 if ( ! defined( 'WP_INSTALLING' ) ) { |
172 return; |
172 return; |
173 |
173 |
174 if ( empty($site_id) ) |
174 if ( empty($site_id) ) |
175 $site_id = $wpdb->siteid; |
175 $site_id = $wpdb->siteid; |
176 |
176 |
177 $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled' ); |
177 $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' ); |
178 |
178 |
179 $core_options_in = "'" . implode("', '", $core_options) . "'"; |
179 $core_options_in = "'" . implode("', '", $core_options) . "'"; |
180 $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) ); |
180 $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) ); |
181 |
181 |
182 foreach ( $options as $option ) { |
182 foreach ( $options as $option ) { |
538 return; |
538 return; |
539 |
539 |
540 if ( ! $user = wp_get_current_user() ) |
540 if ( ! $user = wp_get_current_user() ) |
541 return; |
541 return; |
542 |
542 |
543 if ( is_super_admin( $user->ID ) && |
|
544 ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user->ID ) ) ) |
|
545 ) |
|
546 return; |
|
547 |
|
543 $settings = get_user_option( 'user-settings', $user->ID ); |
548 $settings = get_user_option( 'user-settings', $user->ID ); |
544 |
549 |
545 if ( isset( $_COOKIE['wp-settings-' . $user->ID] ) ) { |
550 if ( isset( $_COOKIE['wp-settings-' . $user->ID] ) ) { |
546 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user->ID] ); |
551 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user->ID] ); |
547 |
552 |
558 return; |
563 return; |
559 } |
564 } |
560 } |
565 } |
561 } |
566 } |
562 |
567 |
563 setcookie( 'wp-settings-' . $user->ID, $settings, time() + 31536000, SITECOOKIEPATH ); |
568 setcookie( 'wp-settings-' . $user->ID, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH ); |
564 setcookie( 'wp-settings-time-' . $user->ID, time(), time() + 31536000, SITECOOKIEPATH ); |
569 setcookie( 'wp-settings-time-' . $user->ID, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH ); |
565 $_COOKIE['wp-settings-' . $user->ID] = $settings; |
570 $_COOKIE['wp-settings-' . $user->ID] = $settings; |
566 } |
571 } |
567 |
572 |
568 /** |
573 /** |
569 * Retrieve user interface setting value based on setting name. |
574 * Retrieve user interface setting value based on setting name. |
694 function wp_set_all_user_settings($all) { |
699 function wp_set_all_user_settings($all) { |
695 global $_updated_user_settings; |
700 global $_updated_user_settings; |
696 |
701 |
697 if ( ! $user = wp_get_current_user() ) |
702 if ( ! $user = wp_get_current_user() ) |
698 return false; |
703 return false; |
704 |
|
705 if ( is_super_admin( $user->ID ) && |
|
706 ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user->ID ) ) ) |
|
707 ) |
|
708 return; |
|
699 |
709 |
700 $_updated_user_settings = $all; |
710 $_updated_user_settings = $all; |
701 $settings = ''; |
711 $settings = ''; |
702 foreach ( $all as $k => $v ) { |
712 foreach ( $all as $k => $v ) { |
703 $v = preg_replace( '/[^A-Za-z0-9_]+/', '', $v ); |
713 $v = preg_replace( '/[^A-Za-z0-9_]+/', '', $v ); |
722 function delete_all_user_settings() { |
732 function delete_all_user_settings() { |
723 if ( ! $user = wp_get_current_user() ) |
733 if ( ! $user = wp_get_current_user() ) |
724 return; |
734 return; |
725 |
735 |
726 update_user_option( $user->ID, 'user-settings', '', false ); |
736 update_user_option( $user->ID, 'user-settings', '', false ); |
727 setcookie('wp-settings-' . $user->ID, ' ', time() - 31536000, SITECOOKIEPATH); |
737 setcookie('wp-settings-' . $user->ID, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH); |
728 } |
738 } |
729 |
739 |
730 /** |
740 /** |
731 * Retrieve site option value based on name of option. |
741 * Retrieve site option value based on name of option. |
732 * |
742 * |