Ticket #607: various_tweak.patch
| File various_tweak.patch, 6.1 kB (added by momo360modena, 4 months ago) |
|---|
-
.
old new 233 233 $safe_key = $wpdb->escape( $key ); 234 234 235 235 if ( $value == get_site_option( $key ) ) 236 return ;236 return false; 237 237 238 238 $exists = $wpdb->get_row("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = '$safe_key' AND site_id = '{$wpdb->siteid}'"); 239 239 … … 245 245 246 246 $wpdb->query( "UPDATE $wpdb->sitemeta SET meta_value = '" . $wpdb->escape( $value ) . "' WHERE site_id='{$wpdb->siteid}' AND meta_key = '$safe_key'" ); 247 247 wp_cache_delete( $wpdb->siteid . $key, 'site-options' ); 248 return true; 248 249 } 249 250 250 251 /* … … 311 312 312 313 function update_blog_option( $id, $key, $value, $refresh = true ) { 313 314 switch_to_blog($id); 314 $opt =update_option( $key, $value );315 update_option( $key, $value ); 315 316 restore_current_blog(); 316 if( $refresh == true ) 317 318 if( $refresh == true ) { 317 319 refresh_blog_details( $id ); 318 $opt = $id."-".$key."-blog_option";319 wp_cache_set( $opt, $value, 'site-options');320 } 321 wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options'); 320 322 } 321 323 322 324 function switch_to_blog( $new_blog ) { … … 430 432 if ( !$user ) 431 433 return false; 432 434 433 $blogs = array(); 434 435 $i = 0; 435 $blogs = $match = array(); 436 436 foreach ( (array) $user as $key => $value ) { 437 437 if ( strstr( $key, '_capabilities') && strstr( $key, 'wp_') ) { 438 438 preg_match('/' . $wpdb->base_prefix . '(\d+)_capabilities/', $key, $match); … … 536 536 } 537 537 538 538 function get_most_active_blogs( $num = 10, $display = true ) { 539 global $wpdb;540 539 $most_active = get_site_option( "most_active" ); 541 540 $update = false; 542 541 if( is_array( $most_active ) ) { … … 596 595 unset( $blogs ); 597 596 $blogs = $wpdb->get_results( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = '$wpdb->siteid' AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", ARRAY_A ); 598 597 599 foreach ( (array) $blogs as $ key => $details ) {598 foreach ( (array) $blogs as $details ) { 600 599 $blog_list[ $details['blog_id'] ] = $details; 601 600 $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT count(*) FROM " . $wpdb->base_prefix . $details['blog_id'] . "_posts WHERE post_status='publish' AND post_type='post'" ); 602 601 } … … 663 662 do_action('add_user_to_blog', $user_id, $role, $blog_id); 664 663 wp_cache_delete( $user_id, 'users' ); 665 664 restore_current_blog(); 665 return true; 666 666 } 667 667 668 668 function remove_user_from_blog($user_id, $blog_id = '') { 669 global $wpdb;670 671 669 switch_to_blog($blog_id); 672 673 670 $user_id = (int) $user_id; 674 675 671 do_action('remove_user_from_blog', $user_id, $blog_id); 676 672 677 673 // If being removed from the primary blog, set a new primary if the user is assigned … … 705 701 } 706 702 707 703 function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) { 708 global $wpdb;709 710 704 $domain = addslashes( $domain ); 711 705 $weblog_title = addslashes( $weblog_title ); 712 706 … … 844 838 } 845 839 846 840 function wpmu_validate_user_signup($user_name, $user_email) { 847 global $wpdb , $current_site;841 global $wpdb; 848 842 849 843 $errors = new WP_Error(); 850 844 … … 854 848 if ( empty( $user_name ) ) 855 849 $errors->add('user_name', __("Please enter a username")); 856 850 851 $maybe = array(); 857 852 preg_match( "/[a-z0-9]+/", $user_name, $maybe ); 858 853 859 854 if( $user_name != $maybe[0] ) { … … 880 875 $errors->add('user_name', __("Sorry, usernames may not contain the character '_'!")); 881 876 882 877 // all numeric? 878 $match = array(); 883 879 preg_match( '/[0-9]*/', $user_name, $match ); 884 880 if ( $match[0] == $user_name ) 885 881 $errors->add('user_name', __("Sorry, usernames must have letters too!")); … … 957 953 if ( empty( $blog_id ) ) 958 954 $errors->add('blog_id', __("Please enter a blog name")); 959 955 956 $maybe = array(); 960 957 preg_match( "/[a-z0-9]+/", $blog_id, $maybe ); 961 958 if( $blog_id != $maybe[0] ) { 962 959 $errors->add('blog_id', __("Only lowercase letters and numbers allowed")); … … 972 969 $errors->add('blog_id', __("Sorry, blog names may not contain the character '_'!")); 973 970 974 971 // all numeric? 972 $match = array(); 975 973 preg_match( '/[0-9]*/', $blog_id, $match ); 976 974 if ( $match[0] == $blog_id ) 977 975 $errors->add('blog_id', __("Sorry, blog names must have letters too!")); … … 1098 1096 function wpmu_activate_signup($key) { 1099 1097 global $wpdb; 1100 1098 1101 $result = array();1102 1099 $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE activation_key = '$key'"); 1103 1100 1104 1101 if ( empty($signup) ) … … 1256 1253 function newuser_notify_siteadmin( $user_id ) { 1257 1254 global $current_site; 1258 1255 if( get_site_option( 'registrationnotification' ) != 'yes' ) 1259 return ;1256 return false; 1260 1257 1261 1258 $email = get_site_option( 'admin_email' ); 1262 1259 if( is_email($email) == false ) … … 1271 1268 1272 1269 $msg = apply_filters( 'newuser_notify_siteadmin', $msg ); 1273 1270 wp_mail( $email, sprintf(__("New User Registration: %s"), $user->user_login), $msg ); 1271 return true; 1274 1272 } 1275 1273 add_action( "wpmu_new_user", "newuser_notify_siteadmin" ); 1276 1274 … … 1568 1566 } 1569 1567 1570 1568 function upload_is_user_over_quota( $echo = true ) { 1571 global $wpdb;1572 1573 1569 // Default space allowed is 10 MB 1574 1570 $spaceAllowed = get_space_allowed(); 1575 1571 if(empty($spaceAllowed) || !is_numeric($spaceAllowed)) $spaceAllowed = 10; … … 1688 1684 } 1689 1685 1690 1686 function plugin_content() { 1691 global $ wpdb, $current_blog, $current_site;1687 global $current_blog, $current_site; 1692 1688 $this->delete_blog_hash = get_settings('delete_blog_hash'); 1693 1689 echo '<div class="wrap"><h2>' . __('Delete Blog') . '</h2>'; 1694 1690 if( $_POST['action'] == "deleteblog" && $_POST['confirmdelete'] == '1' ) { … … 1869 1865 XMLRPC getUsersBlogs() for a multiblog environment 1870 1866 http://trac.mu.wordpress.org/attachment/ticket/551/xmlrpc-mu.php 1871 1867 */ 1872 1873 1868 function wpmu_blogger_getUsersBlogs($args) { 1874 1869 $site_details = get_blog_details( 1, true ); 1875 1870 $domain = $site_details->domain; … … 1886 1881 if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) { 1887 1882 return $blogs; 1888 1883 } else { 1889 foreach ( (array) $blogs as $blog _num => $blog) {1884 foreach ( (array) $blogs as $blog ) { 1890 1885 if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) ) 1891 1886 return array($blog); 1892 1887 }
