diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-10-11 11:37:25 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-10-11 11:37:25 +0000 |
commit | 69f836f072daf4553db3a76429581ddbc2742f98 (patch) | |
tree | 83a41f870824fe5cbc30a2784c9f917daeca0d74 /wp-includes | |
parent | ee66b743ce7a5df18d37b4deb34d469aac1d2b5f (diff) | |
download | wordpress-mu-69f836f072daf4553db3a76429581ddbc2742f98.tar.gz wordpress-mu-69f836f072daf4553db3a76429581ddbc2742f98.tar.xz wordpress-mu-69f836f072daf4553db3a76429581ddbc2742f98.zip |
WP Merge to rev 4376
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@802 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes')
-rw-r--r-- | wp-includes/bookmark-template.php | 2 | ||||
-rw-r--r-- | wp-includes/functions.php | 2 | ||||
-rw-r--r-- | wp-includes/general-template.php | 2 | ||||
-rw-r--r-- | wp-includes/post-template.php | 2 | ||||
-rw-r--r-- | wp-includes/post.php | 54 |
5 files changed, 33 insertions, 29 deletions
diff --git a/wp-includes/bookmark-template.php b/wp-includes/bookmark-template.php index c5c2505..601e4b8 100644 --- a/wp-includes/bookmark-template.php +++ b/wp-includes/bookmark-template.php @@ -333,7 +333,7 @@ function wp_list_bookmarks($args = '') { $cats = get_categories("type=link&category_name=$category_name&include=$category&orderby=$category_orderby&order=$category_order&hierarchical=0"); foreach ( (array) $cats as $cat ) { - $bookmarks = get_bookmarks("limit=$limit&category={$cat->cat_ID}&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_inivisible&show_updated=$show_updated"); + $bookmarks = get_bookmarks("limit=$limit&category={$cat->cat_ID}&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_invisible&show_updated=$show_updated"); if ( empty($bookmarks) ) continue; $output .= "<li id='linkcat-$cat->cat_ID' class='$class'>$title_before$cat->cat_name$title_after\n\t<ul>\n"; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 6dc1f7f..a3f4994 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -573,7 +573,7 @@ function update_post_caches(&$posts) { // Change from flat structure to hierarchical: $post_meta_cache[$blog_id] = array(); foreach ($meta_list as $metarow) { - $mpid = $metarow['post_id']; + $mpid = (int) $metarow['post_id']; $mkey = $metarow['meta_key']; $mval = $metarow['meta_value']; diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index d5c2e49..0e80761 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -3,6 +3,7 @@ /* Note: these tags go anywhere in the template */ function get_header() { + do_action( 'get_header' ); if ( file_exists( TEMPLATEPATH . '/header.php') ) load_template( TEMPLATEPATH . '/header.php'); else @@ -11,6 +12,7 @@ function get_header() { function get_footer() { + do_action( 'get_footer' ); if ( file_exists( TEMPLATEPATH . '/footer.php') ) load_template( TEMPLATEPATH . '/footer.php'); else diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 32006b8..2a4795c 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -211,7 +211,7 @@ function post_custom( $key = '' ) { // this will probably change at some point... function the_meta() { - global $id, $post_meta_cache; + global $id; if ( $keys = get_post_custom_keys() ) { echo "<ul class='post-meta'>\n"; diff --git a/wp-includes/post.php b/wp-includes/post.php index 04f104e..ed1eefb 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -221,9 +221,10 @@ function get_posts($args) { function add_post_meta($post_id, $key, $value, $unique = false) { global $wpdb, $post_meta_cache, $blog_id; + $post_id = (int) $post_id; + if ( $unique ) { - if ( $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key -= '$key' AND post_id = '$post_id'") ) { + if ( $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key = '$key' AND post_id = '$post_id'") ) { return false; } } @@ -234,7 +235,7 @@ function add_post_meta($post_id, $key, $value, $unique = false) { $wpdb->query("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) VALUES ('$post_id','$key','$value')"); - $post_meta_cache[$blog_id]['$post_id'][$key][] = $original; + $post_meta_cache[$blog_id][$post_id][$key][] = $original; return true; } @@ -242,31 +243,29 @@ function add_post_meta($post_id, $key, $value, $unique = false) { function delete_post_meta($post_id, $key, $value = '') { global $wpdb, $post_meta_cache, $blog_id; + $post_id = (int) $post_id; + if ( empty($value) ) { - $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE -post_id = '$post_id' AND meta_key = '$key'"); + $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key'"); } else { - $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE -post_id = '$post_id' AND meta_key = '$key' AND meta_value = '$value'"); + $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key' AND meta_value = '$value'"); } if ( !$meta_id ) return false; if ( empty($value) ) { - $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' -AND meta_key = '$key'"); - unset($post_meta_cache[$blog_id]['$post_id'][$key]); + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key'"); + unset($post_meta_cache[$blog_id][$post_id][$key]); } else { - $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' -AND meta_key = '$key' AND meta_value = '$value'"); - $cache_key = $post_meta_cache[$blog_id]['$post_id'][$key]; + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key' AND meta_value = '$value'"); + $cache_key = $post_meta_cache[$blog_id][$post_id][$key]; if ($cache_key) foreach ( $cache_key as $index => $data ) if ( $data == $value ) - unset($post_meta_cache[$blog_id]['$post_id'][$key][$index]); + unset($post_meta_cache[$blog_id][$post_id][$key][$index]); } - unset($post_meta_cache[$blog_id]['$post_id'][$key]); + unset($post_meta_cache[$blog_id][$post_id][$key]); return true; } @@ -274,6 +273,8 @@ AND meta_key = '$key' AND meta_value = '$value'"); function get_post_meta($post_id, $key, $single = false) { global $wpdb, $post_meta_cache, $blog_id; + $post_id = (int) $post_id; + if ( isset($post_meta_cache[$blog_id][$post_id][$key]) ) { if ( $single ) { return maybe_unserialize( $post_meta_cache[$blog_id][$post_id][$key][0] ); @@ -307,6 +308,8 @@ function get_post_meta($post_id, $key, $single = false) { function update_post_meta($post_id, $key, $value, $prev_value = '') { global $wpdb, $post_meta_cache, $blog_id; + $post_id = (int) $post_id; + $original_value = $value; if ( is_array($value) || is_object($value) ) $value = $wpdb->escape(serialize($value)); @@ -315,26 +318,23 @@ function update_post_meta($post_id, $key, $value, $prev_value = '') { if ( is_array($prev_value) || is_object($prev_value) ) $prev_value = $wpdb->escape(serialize($prev_value)); - if (! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key -= '$key' AND post_id = '$post_id'") ) { + if (! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key = '$key' AND post_id = '$post_id'") ) { return false; } if ( empty($prev_value) ) { - $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE -meta_key = '$key' AND post_id = '$post_id'"); - $cache_key = $post_meta_cache[$blog_id]['$post_id'][$key]; + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE meta_key = '$key' AND post_id = '$post_id'"); + $cache_key = $post_meta_cache[$blog_id][$post_id][$key]; if ( !empty($cache_key) ) foreach ($cache_key as $index => $data) - $post_meta_cache[$blog_id]['$post_id'][$key][$index] = $original_value; + $post_meta_cache[$blog_id][$post_id][$key][$index] = $original_value; } else { - $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE -meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'"); - $cache_key = $post_meta_cache[$blog_id]['$post_id'][$key]; + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'"); + $cache_key = $post_meta_cache[$blog_id][$post_id][$key]; if ( !empty($cache_key) ) foreach ($cache_key as $index => $data) if ( $data == $original_prev ) - $post_meta_cache[$blog_id]['$post_id'][$key][$index] = $original_value; + $post_meta_cache[$blog_id][$post_id][$key][$index] = $original_value; } return true; @@ -347,6 +347,8 @@ function get_post_custom( $post_id = 0 ) { if ( ! $post_id ) $post_id = $id; + $post_id = (int) $post_id; + if ( isset($post_meta_cache[$blog_id][$post_id]) ) return $post_meta_cache[$blog_id][$post_id]; @@ -354,7 +356,7 @@ function get_post_custom( $post_id = 0 ) { // Change from flat structure to hierarchical: $post_meta_cache = array(); foreach ( $meta_list as $metarow ) { - $mpid = $metarow['post_id']; + $mpid = (int) $metarow['post_id']; $mkey = $metarow['meta_key']; $mval = $metarow['meta_value']; |