Changeset 579
- Timestamp:
- 06/20/06 10:39:28 (2 years ago)
- Files:
-
- trunk/wp-inst/wp-admin/admin-functions.php (modified) (1 diff)
- trunk/wp-inst/wp-includes/comment.php (modified) (3 diffs)
- trunk/wp-inst/wp-includes/functions.php (modified) (3 diffs)
- trunk/wp-inst/wp-includes/plugin.php (added)
- trunk/wp-inst/wp-includes/query.php (modified) (2 diffs)
- trunk/wp-inst/wp-includes/vars.php (modified) (1 diff)
- trunk/wp-inst/wp-settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-inst/wp-admin/admin-functions.php
r567 r579 1896 1896 } 1897 1897 $filename = str_replace($ext, '', $filename); 1898 $filename = sanitize_title ($filename) . $ext;1898 $filename = sanitize_title_with_dashes($filename) . $ext; 1899 1899 } 1900 1900 trunk/wp-inst/wp-includes/comment.php
r559 r579 253 253 $post_id = $comment->comment_post_ID; 254 254 if ( $post_id && $comment->comment_approved == 1 ) 255 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count - 1 WHERE ID = '$post_id'");255 wp_update_comment_count($post_id); 256 256 257 257 do_action('wp_set_comment_status', $comment_id, 'delete'); … … 301 301 $id = $wpdb->insert_id; 302 302 303 if ( $comment_approved == 1) { 304 $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'"); 305 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$comment_post_ID'" ); 306 } 303 if ( $comment_approved == 1) 304 wp_update_comment_count($comment_post_ID); 305 307 306 return $id; 308 307 } … … 420 419 $rval = $wpdb->rows_affected; 421 420 422 $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" ); 423 if( is_object( $c ) ) 424 $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" ); 421 wp_update_comment_count($comment_post_ID); 425 422 426 423 do_action('edit_comment', $comment_ID); 427 424 428 425 return $rval; 426 } 427 428 function wp_update_comment_count($post_id) { 429 global $wpdb, $comment_count_cache; 430 $post_id = (int) $post_id; 431 if ( !$post_id ) 432 return false; 433 $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'"); 434 $wpdb->query("UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$post_id'"); 435 $comment_count_cache[$post_id] = $count; 436 return true; 429 437 } 430 438 trunk/wp-inst/wp-includes/functions.php
r571 r579 579 579 } 580 580 581 // Filters: these are the core of WP's plugin architecture582 583 function merge_filters($tag) {584 global $wp_filter;585 if ( isset($wp_filter['all']) ) {586 foreach ($wp_filter['all'] as $priority => $functions) {587 if ( isset($wp_filter[$tag][$priority]) )588 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);589 else590 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], array());591 $wp_filter[$tag][$priority] = array_unique($wp_filter[$tag][$priority]);592 }593 }594 595 if ( isset($wp_filter[$tag]) )596 ksort( $wp_filter[$tag] );597 }598 599 function apply_filters($tag, $string) {600 global $wp_filter;601 602 $args = array_slice(func_get_args(), 2);603 604 merge_filters($tag);605 606 if ( !isset($wp_filter[$tag]) ) {607 return $string;608 }609 foreach ($wp_filter[$tag] as $priority => $functions) {610 if ( !is_null($functions) ) {611 foreach($functions as $function) {612 613 $all_args = array_merge(array($string), $args);614 $function_name = $function['function'];615 $accepted_args = $function['accepted_args'];616 617 if ( $accepted_args == 1 )618 $the_args = array($string);619 elseif ( $accepted_args > 1 )620 $the_args = array_slice($all_args, 0, $accepted_args);621 elseif ( $accepted_args == 0 )622 $the_args = NULL;623 else624 $the_args = $all_args;625 626 $string = call_user_func_array($function_name, $the_args);627 }628 }629 }630 return $string;631 }632 633 function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {634 global $wp_filter;635 636 // check that we don't already have the same filter at the same priority637 if ( isset($wp_filter[$tag]["$priority"]) ) {638 foreach($wp_filter[$tag]["$priority"] as $filter) {639 // uncomment if we want to match function AND accepted_args640 // if ( $filter == array($function, $accepted_args) ) {641 if ( $filter['function'] == $function_to_add ) {642 return true;643 }644 }645 }646 647 // So the format is wp_filter['tag']['array of priorities']['array of ['array (functions, accepted_args)]']648 $wp_filter[$tag]["$priority"][] = array('function'=>$function_to_add, 'accepted_args'=>$accepted_args);649 return true;650 }651 652 function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {653 global $wp_filter;654 655 // rebuild the list of filters656 if ( isset($wp_filter[$tag]["$priority"]) ) {657 $new_function_list = array();658 foreach($wp_filter[$tag]["$priority"] as $filter) {659 if ( $filter['function'] != $function_to_remove ) {660 $new_function_list[] = $filter;661 }662 }663 $wp_filter[$tag]["$priority"] = $new_function_list;664 }665 return true;666 }667 668 // The *_action functions are just aliases for the *_filter functions, they take special strings instead of generic content669 670 function do_action($tag, $arg = '') {671 global $wp_filter;672 $extra_args = array_slice(func_get_args(), 2);673 if ( is_array($arg) )674 $args = array_merge($arg, $extra_args);675 else676 $args = array_merge(array($arg), $extra_args);677 678 merge_filters($tag);679 680 if ( !isset($wp_filter[$tag]) ) {681 return;682 }683 foreach ($wp_filter[$tag] as $priority => $functions) {684 if ( !is_null($functions) ) {685 foreach($functions as $function) {686 687 $function_name = $function['function'];688 $accepted_args = $function['accepted_args'];689 690 if ( $accepted_args == 1 ) {691 if ( is_array($arg) )692 $the_args = $arg;693 else694 $the_args = array($arg);695 } elseif ( $accepted_args > 1 ) {696 $the_args = array_slice($args, 0, $accepted_args);697 } elseif ( $accepted_args == 0 ) {698 $the_args = NULL;699 } else {700 $the_args = $args;701 }702 703 $string = call_user_func_array($function_name, $the_args);704 }705 }706 }707 }708 709 function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {710 add_filter($tag, $function_to_add, $priority, $accepted_args);711 }712 713 function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {714 remove_filter($tag, $function_to_remove, $priority, $accepted_args);715 }716 717 581 function update_post_cache(&$posts) { 718 582 global $post_cache; … … 973 837 } 974 838 975 function register_activation_hook($file, $function) {976 $file = plugin_basename($file);977 978 add_action('activate_' . $file, $function);979 }980 981 function register_deactivation_hook($file, $function) {982 $file = plugin_basename($file);983 984 add_action('deactivate_' . $file, $function);985 }986 987 function plugin_basename($file) {988 $file = preg_replace('|\\\\+|', '\\\\', $file);989 $file = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);990 return $file;991 }992 993 839 function get_num_queries() { 994 840 global $wpdb; … … 996 842 } 997 843 998 function privacy_ping_filter( ) {844 function privacy_ping_filter( $sites ) { 999 845 global $current_blog; 1000 if ( $current_blog->public )1001 return "http://rpc.pingomatic.com/\n";846 if ( '0' != $current_blog->public ) 847 return $sites; 1002 848 else 1003 849 return ''; trunk/wp-inst/wp-includes/query.php
r562 r579 709 709 $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) "; 710 710 $cat_array = preg_split('/[,\s]+/', $q['cat']); 711 $in_cats = $out_cats = '';711 $in_cats = $out_cats = $out_posts = ''; 712 712 foreach ( $cat_array as $cat ) { 713 713 $cat = intval($cat); … … 723 723 if ( strlen($in_cats) > 0 ) 724 724 $in_cats = " AND category_id IN ($in_cats)"; 725 if ( strlen($out_cats) > 0 ) 726 $out_cats = " AND category_id NOT IN ($out_cats)"; 725 if ( strlen($out_cats) > 0 ) { 726 $ids = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id IN ($out_cats)"); 727 if ( is_array($ids) && count($ids > 0) ) { 728 foreach ( $ids as $id ) 729 $out_posts .= "$id, "; 730 $out_posts = substr($out_posts, 0, -2); 731 } 732 if ( strlen($out_posts) > 0 ) 733 $out_cats = " AND ID NOT IN ($out_posts)"; 734 } 727 735 $whichcat = $in_cats . $out_cats; 728 736 $distinct = 'DISTINCT'; trunk/wp-inst/wp-includes/vars.php
r543 r579 43 43 if (!isset($wpsmiliestrans)) { 44 44 $wpsmiliestrans = array( 45 ' :)' => 'icon_smile.gif', 46 ' :D' => 'icon_biggrin.gif', 47 ' :-D' => 'icon_biggrin.gif', 48 ':grin:' => 'icon_biggrin.gif', 49 ' :)' => 'icon_smile.gif', 50 ' :-)' => 'icon_smile.gif', 51 ':smile:' => 'icon_smile.gif', 52 ' :(' => 'icon_sad.gif', 53 ' :-(' => 'icon_sad.gif', 54 ':sad:' => 'icon_sad.gif', 55 ' :o' => 'icon_surprised.gif', 56 ' :-o' => 'icon_surprised.gif', 57 ':eek:' => 'icon_surprised.gif', 58 ' 8O' => 'icon_eek.gif', 59 ' 8-O' => 'icon_eek.gif', 60 ':shock:' => 'icon_eek.gif', 61 ' :?' => 'icon_confused.gif', 62 ' :-?' => 'icon_confused.gif', 63 ' :???:' => 'icon_confused.gif', 64 ' 8)' => 'icon_cool.gif', 65 ' 8-)' => 'icon_cool.gif', 66 ':cool:' => 'icon_cool.gif', 67 ':lol:' => 'icon_lol.gif', 68 ' :x' => 'icon_mad.gif', 69 ' :-x' => 'icon_mad.gif', 70 ':mad:' => 'icon_mad.gif', 71 ' :P' => 'icon_razz.gif', 72 ' :-P' => 'icon_razz.gif', 73 ':razz:' => 'icon_razz.gif', 74 ':oops:' => 'icon_redface.gif', 75 ':cry:' => 'icon_cry.gif', 76 ':evil:' => 'icon_evil.gif', 77 ':twisted:' => 'icon_twisted.gif', 78 ':roll:' => 'icon_rolleyes.gif', 79 ':wink:' => 'icon_wink.gif', 80 ' ;)' => 'icon_wink.gif', 81 ' ;-)' => 'icon_wink.gif', 82 ':!:' => 'icon_exclaim.gif', 83 ':?:' => 'icon_question.gif', 84 ':idea:' => 'icon_idea.gif', 85 ':arrow:' => 'icon_arrow.gif', 86 ' :|' => 'icon_neutral.gif', 87 ' :-|' => 'icon_neutral.gif', 88 ':neutral:' => 'icon_neutral.gif', 89 ':mrgreen:' => 'icon_mrgreen.gif', 45 ':mrgreen:' => 'icon_mrgreen.gif', 46 ':neutral:' => 'icon_neutral.gif', 47 ':twisted:' => 'icon_twisted.gif', 48 ':arrow:' => 'icon_arrow.gif', 49 ':shock:' => 'icon_eek.gif', 50 ':smile:' => 'icon_smile.gif', 51 ' :???:' => 'icon_confused.gif', 52 ':cool:' => 'icon_cool.gif', 53 ':evil:' => 'icon_evil.gif', 54 ':grin:' => 'icon_biggrin.gif', 55 ':idea:' => 'icon_idea.gif', 56 ':oops:' => 'icon_redface.gif', 57 ':razz:' => 'icon_razz.gif', 58 ':roll:' => 'icon_rolleyes.gif', 59 ':wink:' => 'icon_wink.gif', 60 ':cry:' => 'icon_cry.gif', 61 ':eek:' => 'icon_surprised.gif', 62 ':lol:' => 'icon_lol.gif', 63 ':mad:' => 'icon_mad.gif', 64 ':sad:' => 'icon_sad.gif', 65 ' 8-)' => 'icon_cool.gif', 66 ' 8-O' => 'icon_eek.gif', 67 ' :-(' => 'icon_sad.gif', 68 ' :-)' => 'icon_smile.gif', 69 ' :-?' => 'icon_confused.gif', 70 ' :-D' => 'icon_biggrin.gif', 71 ' :-P' => 'icon_razz.gif', 72 ' :-o' => 'icon_surprised.gif', 73 ' :-x' => 'icon_mad.gif', 74 ' :-|' => 'icon_neutral.gif', 75 ' ;-)' => 'icon_wink.gif', 76 ' 8)' => 'icon_cool.gif', 77 ' 8O' => 'icon_eek.gif', 78 ' :(' => 'icon_sad.gif', 79 ' :)' => 'icon_smile.gif', 80 ' :?' => 'icon_confused.gif', 81 ' :D' => 'icon_biggrin.gif', 82 ' :P' => 'icon_razz.gif', 83 ' :o' => 'icon_surprised.gif', 84 ' :x' => 'icon_mad.gif', 85 ' :|' => 'icon_neutral.gif', 86 ' ;)' => 'icon_wink.gif', 87 ':!:' => 'icon_exclaim.gif', 88 ':?:' => 'icon_question.gif', 90 89 ); 91 90 } trunk/wp-inst/wp-settings.php
r577 r579 132 132 133 133 require (ABSPATH . WPINC . '/functions.php'); 134 require (ABSPATH . WPINC . '/plugin.php'); 134 135 require (ABSPATH . WPINC . '/default-filters.php'); 135 136 require_once (ABSPATH . WPINC . '/l10n.php');
