diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-10-24 14:21:13 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-10-24 14:21:13 +0000 |
commit | 797aff459d87aa09fe0c0c9a7aaf288752b5bd15 (patch) | |
tree | 9903b14c48e73bf9d77dd0d6a32e81a0deda3bea | |
parent | 8a9ee3b40641ff572b10c53e9aae1a148e1e8a38 (diff) | |
download | wordpress-mu-797aff459d87aa09fe0c0c9a7aaf288752b5bd15.tar.gz wordpress-mu-797aff459d87aa09fe0c0c9a7aaf288752b5bd15.tar.xz wordpress-mu-797aff459d87aa09fe0c0c9a7aaf288752b5bd15.zip |
Massive WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@407 7be80a69-a1ef-0310-a953-fb0f7c49ff36
-rw-r--r-- | wp-inst/wp-admin/admin-functions.php | 2 | ||||
-rw-r--r-- | wp-inst/wp-admin/image-uploading.php | 97 | ||||
-rw-r--r-- | wp-inst/wp-commentsrss2.php | 4 | ||||
-rw-r--r-- | wp-inst/wp-content/themes/default/footer.php | 1 | ||||
-rw-r--r-- | wp-inst/wp-content/themes/default/header.php | 1 | ||||
-rw-r--r-- | wp-inst/wp-includes/classes.php | 126 | ||||
-rw-r--r-- | wp-inst/wp-includes/functions.php | 19 | ||||
-rw-r--r-- | wp-inst/wp-includes/template-functions-links.php | 51 | ||||
-rw-r--r-- | wp-inst/wp-includes/template-functions-post.php | 18 | ||||
-rw-r--r-- | wp-inst/wp-includes/template-loader.php | 10 | ||||
-rw-r--r-- | wp-inst/wp-links-opml.php | 4 | ||||
-rw-r--r-- | wp-inst/wp-mail.php | 20 | ||||
-rw-r--r-- | wp-inst/xmlrpc.php | 12 |
13 files changed, 256 insertions, 109 deletions
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php index 4c4aed8..b2530a5 100644 --- a/wp-inst/wp-admin/admin-functions.php +++ b/wp-inst/wp-admin/admin-functions.php @@ -669,6 +669,8 @@ function wp_create_thumbnail($file, $max_side, $effect = '') { } } + } else { + $error = __('File not found'); } if (!empty ($error)) { diff --git a/wp-inst/wp-admin/image-uploading.php b/wp-inst/wp-admin/image-uploading.php index 9e49ba7..ccc97d1 100644 --- a/wp-inst/wp-admin/image-uploading.php +++ b/wp-inst/wp-admin/image-uploading.php @@ -138,9 +138,16 @@ $imagedata['height'] = $imagesize['1']; list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']); $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'"; $imagedata['file'] = $file; +$imagedata['thumb'] = "thumb-$filename"; -if ( false == add_post_meta($id, 'imagedata', $imagedata) ) - die("failed to add_post_meta"); +add_post_meta($id, 'imagedata', $imagedata); + +if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) { + if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 ) + $error = wp_create_thumbnail($file, 128); + elseif ( $imagedata['height'] > 96 ) + $error = wp_create_thumbnail($file, 96); +} header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&last=true"); die; @@ -195,24 +202,56 @@ $i = 0; $uwidth_sum = 0; $images_html = ''; $images_style = ''; +$images_script = ''; if ( count($images) > 0 ) { $images = array_slice( $images, 0, $num ); + $__delete = __('DELETE'); + $__subpost_on = __('SUBPOST <strong>ON</strong>'); + $__subpost_off = __('SUBPOST <strong>OFF</strong>'); + $__thumbnail_on = __('THUMBNAIL <strong>ON</strong>'); + $__thumbnail_off = __('THUMBNAIL <strong>OFF</strong>'); + $__no_thumbnail = __('<del>THUMBNAIL</del>'); + $__close = __('CLOSE'); + $__confirmdelete = __('Delete this photo from the server?'); + $__nothumb = __('There is no thumbnail associated with this photo.'); + $images_script .= "subposton = '$__subpost_on';\nsubpostoff = '$__subpost_off';\n"; + $images_script .= "thumbnailon = '$__thumbnail_on';\nthumbnailoff = '$__thumbnail_off';\n"; foreach ( $images as $key => $image ) { - $image = array_merge($image, get_post_meta($image['ID'], 'imagedata', true) ); + $meta = get_post_meta($image['ID'], 'imagedata', true); + if (!is_array($meta)) { + wp_delete_object($image['ID']); + continue; + } + $image = array_merge($image, $meta); + if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) { + $src = str_replace(basename($image['guid']), '', $image['guid']) . $image['thumb']; + $images_script .= "src".$i."a = '$src';\nsrc".$i."b = '".$image['guid']."';\n"; + $thumb = 'true'; + $thumbtext = $__thumbnail_on; + } else { + $src = $image['guid']; + $thumb = 'false'; + $thumbtext = $__no_thumbnail; + } list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']); - $uwidth_sum += 128; //$image['uwidth']; + $height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"'; + $uwidth_sum += 128; $xpadding = (128 - $image['uwidth']) / 2; $ypadding = (96 - $image['uheight']) / 2; $object = $image['ID']; $images_style .= "#target$i img { padding: {$ypadding}px {$xpadding}px; }\n"; + $href = get_subpost_link($object); + $images_script .= "href".$i."a = '$href';\nhref".$i."b = '{$image['guid']}';\n"; $images_html .= <<<HERE <div id='target$i' class='imagewrap left'> <div id='popup$i' class='popup'> - <a onclick='return confirm("Delete this photo from the server?")' href='image-uploading.php?action=delete&object=$object&all=$all&start=$start&post=$post'>DELETE</a> - <a onclick="popup.style.display='none';return false;" href="javascript:void()">CANCEL</a> + <a id="L$i" onclick="toggleLink($i);return false;" href="javascript:void();">$__subpost_on</a> + <a id="I$i" onclick="if($thumb)toggleImage($i);else alert('$__nothumb');return false;" href="javascript:void();">$thumbtext</a> + <a onclick="return confirm('$__confirmdelete')" href="image-uploading.php?action=delete&object=$object&all=$all&start=$start&post=$post">$__delete</a> + <a onclick="popup.style.display='none';return false;" href="javascript:void()">$__close</a> </div> - <a id='link$i' class='imagelink' href='{$image['guid']}' onclick='imagePopup($i);return false;' title='{$image['post_title']}'> - <img id='image$i' src='{$image['guid']}' alt='{$image['post_title']}' {$image['hwstring_small']} /> + <a id="link$i" class="imagelink" href="$href" onclick="imagePopup($i);return false;" title="{$image['post_title']}"> + <img id='image$i' src='$src' alt='{$image['post_title']}' $height_width /> </a> </div> HERE; @@ -234,6 +273,9 @@ die('This script was not meant to be called directly.'); <head> <meta http-equiv="imagetoolbar" content="no" /> <script type="text/javascript"> +/* Define any variables we'll need, such as alternate URLs. */ +<?php echo $images_script; ?> + function validateImageName() { /* This is more for convenience than security. Server-side validation is very thorough.*/ obj = document.getElementById('upload'); @@ -261,6 +303,28 @@ popup.style.display = 'block'; function init() { popup = false; } +function toggleLink(n) { + o=document.getElementById('link'+n); + oi=document.getElementById('L'+n); + if ( oi.innerHTML == subposton ) { + o.href = eval('href'+n+'b'); + oi.innerHTML = subpostoff; + } else { + o.href = eval('href'+n+'a'); + oi.innerHTML = subposton; + } +} +function toggleImage(n) { + o = document.getElementById('image'+n); + oi = document.getElementById('I'+n); + if ( oi.innerHTML == thumbnailon ) { + o.src = eval('src'+n+'b'); + oi.innerHTML = thumbnailoff; + } else { + o.src = eval('src'+n+'a'); + oi.innerHTML = thumbnailon; + } +} </script> <style type="text/css"> body { @@ -372,11 +436,11 @@ margin-top: 2px; text-align: right; } .popup { -margin: 23px 9px; -padding: 5px; +margin: 4px 4px; +padding: 3px; position: absolute; -width: 100px; -height: 40px; +width: 114px; +height: 82px; display: none; background-color: rgb(223, 232, 241); opacity: .90; @@ -384,7 +448,6 @@ filter:alpha(opacity=90); text-align: center; } .popup a, .popup a:visited, .popup a:active { -margin-bottom: 3px; background-color: transparent; display: block; width: 100%; @@ -392,7 +455,6 @@ text-decoration: none; color: #246; } .popup a:hover { -margin-bottom: 3px; background-color: #fff; color: #000; } @@ -427,11 +489,10 @@ color: #000; <?php echo $images_html; ?> </div> </div> -<?php elseif ( $action = 'upload' ) : - if( apply_filters( "pre_upload_error", false ) == true ) { +<?php elseif ( $action = 'upload' ) : ?> + <?php if( apply_filters( "pre_upload_error", false ) == true ) { ?><div class="center tip">Sorry, you have used your space allocation. Please delete some files to upload more files.</div><?php - } else { -?> + } else { ?> <div class="center tip">Duplicated filenames will be numbered (photo.jpg, photo1.jpg, etc.)</div> <form enctype="multipart/form-data" id="uploadForm" method="POST" action="image-uploading.php" onsubmit="return validateImageName()"> <label for="upload">Image:</label><input type="file" id="upload" name="image" onchange="validateImageName()" /> diff --git a/wp-inst/wp-commentsrss2.php b/wp-inst/wp-commentsrss2.php index 906d8b9..5198d2d 100644 --- a/wp-inst/wp-commentsrss2.php +++ b/wp-inst/wp-commentsrss2.php @@ -32,14 +32,14 @@ if (have_posts()) : comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id' - AND $wpdb->comments.comment_approved = '1' AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'static') + AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status IN ('publish', 'static', 'object') AND post_date < '".date("Y-m-d H:i:59")."' ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') ); } else { // if no post id passed in, we'll just ue the last 10 comments. $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments - LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'static') + LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status IN ('publish', 'static', 'object') AND $wpdb->comments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."' ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') ); } diff --git a/wp-inst/wp-content/themes/default/footer.php b/wp-inst/wp-content/themes/default/footer.php index 1de4c43..2973ab6 100644 --- a/wp-inst/wp-content/themes/default/footer.php +++ b/wp-inst/wp-content/themes/default/footer.php @@ -15,6 +15,5 @@ <?php /* "Just what do you think you're doing Dave?" */ ?> <?php wp_footer(); ?> - </body> </html> diff --git a/wp-inst/wp-content/themes/default/header.php b/wp-inst/wp-content/themes/default/header.php index 99ff334..c7dcbb0 100644 --- a/wp-inst/wp-content/themes/default/header.php +++ b/wp-inst/wp-content/themes/default/header.php @@ -48,7 +48,6 @@ <?php wp_head(); ?> </head> <body> - <div id="page"> diff --git a/wp-inst/wp-includes/classes.php b/wp-inst/wp-includes/classes.php index cbf4c32..4fdea9a 100644 --- a/wp-inst/wp-includes/classes.php +++ b/wp-inst/wp-includes/classes.php @@ -29,7 +29,7 @@ class WP_Query { var $is_404 = false; var $is_comments_popup = false; var $is_admin = false; - var $is_object = false; + var $is_subpost = false; function init_query_flags() { $this->is_single = false; @@ -49,7 +49,7 @@ class WP_Query { $this->is_404 = false; $this->is_paged = false; $this->is_admin = false; - $this->is_object = false; + $this->is_subpost = false; } function init () { @@ -90,13 +90,18 @@ class WP_Query { $qv['m'] = (int) $qv['m']; $qv['p'] = (int) $qv['p']; + if ( ('' != $qv['subpost']) || $qv['subpost_id'] ) { + $this->is_single = true; + $this->is_subpost = true; + } + if ('' != $qv['name']) { $this->is_single = true; } elseif ( $qv['p'] ) { $this->is_single = true; } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) { // If year, month, day, hour, minute, and second are set, a single - // post is being queried. + // post is being queried. $this->is_single = true; } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) { $this->is_page = true; @@ -208,7 +213,7 @@ class WP_Query { $this->is_admin = true; } - if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) { + if ( ! ($this->is_subpost || $this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) { $this->is_home = true; } @@ -335,9 +340,12 @@ class WP_Query { $q['pagename'] = sanitize_title(basename(str_replace('%2F', '/', urlencode($q['pagename'])))); $q['name'] = $q['pagename']; $where .= " AND post_name = '" . $q['pagename'] . "'"; + } elseif ('' != $q['subpost']) { + $q['subpost'] = sanitize_title($q['subpost']); + $q['name'] = $q['subpost']; + $where .= " AND post_name = '" . $q['subpost'] . "'"; } - if ( (int) $q['w'] ) { $q['w'] = ''.intval($q['w']); $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'"; @@ -346,6 +354,10 @@ class WP_Query { if ( intval($q['comments_popup']) ) $q['p'] = intval($q['comments_popup']); + // If a subpost is requested by number, let it supercede any post number. + if ( ($q['subpost_id'] != '') && (intval($q['subpost_id']) != 0) ) + $q['p'] = (int) $q['subpost_id']; + // If a post number is specified, load that post if (($q['p'] != '') && intval($q['p']) != 0) { $q['p'] = (int) $q['p']; @@ -516,7 +528,9 @@ class WP_Query { $distinct = 'DISTINCT'; } - if ($this->is_page) { + if ( $this->is_subpost ) { + $where .= ' AND (post_status = "object")'; + } elseif ($this->is_page) { $where .= ' AND (post_status = "static")'; } elseif ($this->is_single) { $where .= ' AND (post_status != "static")'; @@ -529,7 +543,7 @@ class WP_Query { $where .= ')'; } - if (! $this->is_object ) + if (! $this->is_subpost ) $where .= ' AND post_status != "object"'; // Apply filters on where and join prior to paging so that any @@ -575,16 +589,17 @@ class WP_Query { // Check post status to determine if post should be displayed. if ($this->is_single) { - if ('publish' != $this->posts[0]->post_status) { + $status = get_post_status($this->posts[0]); + if ('publish' != $status) { if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) { // User must be logged in to view unpublished posts. $this->posts = array(); } else { - if ('draft' == $this->posts[0]->post_status) { + if ('draft' == $status) { // User must have edit permissions on the draft to preview. if (! user_can_edit_post($user_ID, $this->posts[0]->ID)) $this->posts = array(); - } elseif ('private' == $this->posts[0]->post_status) { + } elseif ('private' == $status) { if ($this->posts[0]->post_author != $user_ID) $this->posts = array(); } @@ -821,19 +836,19 @@ class WP_Rewrite { var $queryreplace = array ( - 'year=', - 'monthnum=', - 'day=', - 'hour=', - 'minute=', - 'second=', - 'name=', - 'p=', - 'category_name=', - 'author_name=', - 'pagename=', - 's=' - ); + 'year=', + 'monthnum=', + 'day=', + 'hour=', + 'minute=', + 'second=', + 'name=', + 'p=', + 'category_name=', + 'author_name=', + 'pagename=', + 's=' + ); var $feeds = array ('feed', 'rdf', 'rss', 'rss2', 'atom'); @@ -845,16 +860,16 @@ class WP_Rewrite { } function using_index_permalinks() { - if (empty($this->permalink_structure)) { + if (empty($this->permalink_structure)) { return false; - } + } - // If the index is not in the permalink, we're using mod_rewrite. - if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) { - return true; - } + // If the index is not in the permalink, we're using mod_rewrite. + if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) { + return true; + } - return false; + return false; } function using_mod_rewrite_permalinks() { @@ -865,15 +880,15 @@ class WP_Rewrite { } function preg_index($number) { - $match_prefix = '$'; - $match_suffix = ''; - - if (! empty($this->matches)) { + $match_prefix = '$'; + $match_suffix = ''; + + if (! empty($this->matches)) { $match_prefix = '$' . $this->matches . '['; $match_suffix = ']'; - } - - return "$match_prefix$number$match_suffix"; + } + + return "$match_prefix$number$match_suffix"; } function page_rewrite_rules() { @@ -897,7 +912,7 @@ class WP_Rewrite { return $this->date_structure; } - if (empty($this->permalink_structure)) { + if (empty($this->permalink_structure)) { $this->date_structure = ''; return false; } @@ -973,7 +988,7 @@ class WP_Rewrite { return $this->category_structure; } - if (empty($this->permalink_structure)) { + if (empty($this->permalink_structure)) { $this->category_structure = ''; return false; } @@ -993,7 +1008,7 @@ class WP_Rewrite { return $this->author_structure; } - if (empty($this->permalink_structure)) { + if (empty($this->permalink_structure)) { $this->author_structure = ''; return false; } @@ -1008,7 +1023,7 @@ class WP_Rewrite { return $this->search_structure; } - if (empty($this->permalink_structure)) { + if (empty($this->permalink_structure)) { $this->search_structure = ''; return false; } @@ -1023,7 +1038,7 @@ class WP_Rewrite { return $this->page_structure; } - if (empty($this->permalink_structure)) { + if (empty($this->permalink_structure)) { $this->page_structure = ''; return false; } @@ -1038,7 +1053,7 @@ class WP_Rewrite { return $this->feed_structure; } - if (empty($this->permalink_structure)) { + if (empty($this->permalink_structure)) { $this->feed_structure = ''; return false; } @@ -1053,7 +1068,7 @@ class WP_Rewrite { return $this->comment_feed_structure; } - if (empty($this->permalink_structure)) { + if (empty($this->permalink_structure)) { $this->comment_feed_structure = ''; return false; } @@ -1158,6 +1173,20 @@ class WP_Rewrite { $trackbackmatch = $match . $trackbackregex; $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; $match = rtrim($match, '/'); + $submatchbase = str_replace(array('(',')'),'',$match); + $sub1 = $submatchbase . '/([^/]+)/'; + $sub1tb = $sub1 . $trackbackregex; + $sub1feed = $sub1 . $feedregex; + $sub1feed2 = $sub1 . $feedregex2; + $sub1 .= '?$'; + $sub2 = $submatchbase . '/subpost/([^/]+)/'; + $sub2tb = $sub2 . $trackbackregex; + $sub2feed = $sub2 . $feedregex; + $sub2feed2 = $sub2 . $feedregex2; + $sub2 .= '?$'; + $subquery = $index . '?subpost=' . $this->preg_index(1); + $subtbquery = $subquery . '&tb=1'; + $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); $match = $match . '(/[0-9]+)?/?$'; $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1); } else { @@ -1168,7 +1197,9 @@ class WP_Rewrite { $rewrite = $rewrite + array($match => $query); if ($post) { - $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite; + $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite + + array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery) + + array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery); } } @@ -1231,6 +1262,7 @@ class WP_Rewrite { do_action('generate_rewrite_rules', array(&$this)); $this->rules = apply_filters('rewrite_rules_array', $this->rules); + return $this->rules; } @@ -1329,7 +1361,7 @@ class WP_Rewrite { } class WP { - var $public_query_vars = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence', 'debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup'); + var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'subpost', 'subpost_id'); var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging'); @@ -1397,7 +1429,7 @@ class WP { foreach ($rewrite as $match => $query) { // If the requesting file is the anchor of the match, prepend it // to the path info. - if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) { + if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) { $request_match = $req_uri . '/' . $request; } diff --git a/wp-inst/wp-includes/functions.php b/wp-inst/wp-includes/functions.php index b9a046b..3a07002 100644 --- a/wp-inst/wp-includes/functions.php +++ b/wp-inst/wp-includes/functions.php @@ -1386,6 +1386,12 @@ function is_page ($page = '') { return false; } +function is_subpost () { + global $wp_query; + + return $wp_query->is_subpost; +} + function is_archive () { global $wp_query; @@ -1871,6 +1877,19 @@ function get_single_template() { return get_query_template('single'); } +function get_subpost_template() { + global $posts; + $type = explode('/', $posts[0]->post_type); + if ( $template = get_query_template($type[0]) ) + return $template; + elseif ( $template = get_query_template($type[1]) ) + return $template; + elseif ( $template = get_query_template("$type[0]_$type[1]") ) + return $template; + else + return get_query_template('subpost'); +} + function get_comments_popup_template() { if ( file_exists( TEMPLATEPATH . '/comments-popup.php') ) $template = TEMPLATEPATH . '/comments-popup.php'; diff --git a/wp-inst/wp-includes/template-functions-links.php b/wp-inst/wp-includes/template-functions-links.php index aecc13b..07b3aa5 100644 --- a/wp-inst/wp-includes/template-functions-links.php +++ b/wp-inst/wp-includes/template-functions-links.php @@ -44,6 +44,8 @@ function get_permalink($id = 0) { $post = &get_post($id); if ( $post->post_status == 'static' ) return get_page_link($post->ID); + elseif ($post->post_status == 'object') + return get_subpost_link($post->ID); $permalink = get_settings('permalink_structure'); @@ -100,6 +102,30 @@ function get_page_link($id = false) { return apply_filters('page_link', $link, $id); } +function get_subpost_link($id = false) { + global $post, $wp_rewrite; + + $link = false; + + if (! $id) { + $id = $post->ID; + } + + $object = get_post($id); + if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) ) { + $parent = get_post($object->post_parent); + $parentlink = get_permalink($object->post_parent); + if (! strstr($parentlink, '?') ) + $link = trim($parentlink, '/') . '/' . $object->post_name . '/'; + } + + if (! $link ) { + $link = get_bloginfo('home') . "/?subpost_id=$id"; + } + + return apply_filters('object_link', $link, $id); +} + function get_year_link($year) { global $wp_rewrite; if ( !$year ) @@ -183,8 +209,9 @@ function edit_post_link($link = 'Edit This', $before = '', $after = '') { get_currentuserinfo(); - if ( !user_can_edit_post($user_ID, $post->ID) ) + if ( !user_can_edit_post($user_ID, $post->ID) || is_subpost() ) { return; + } $location = get_settings('siteurl') . "/wp-admin/post.php?action=edit&post=$post->ID"; echo $before . "<a href=\"$location\">$link</a>" . $after; @@ -207,11 +234,11 @@ function edit_comment_link($link = 'Edit This', $before = '', $after = '') { function get_previous_post($in_same_cat = false, $excluded_categories = '') { global $post, $wpdb; - if ( !is_single() ) + if( !is_single() || is_subpost() ) return null; $current_post_date = $post->post_date; - + $join = ''; if ( $in_same_cat ) { $join = " INNER JOIN $wpdb->post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id "; @@ -238,7 +265,7 @@ function get_previous_post($in_same_cat = false, $excluded_categories = '') { function get_next_post($in_same_cat = false, $excluded_categories = '') { global $post, $wpdb; - if ( !is_single() ) + if( !is_single() || is_subpost() ) return null; $current_post_date = $post->post_date; @@ -270,7 +297,13 @@ function get_next_post($in_same_cat = false, $excluded_categories = '') { function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { - $post = get_previous_post($in_same_cat, $excluded_categories); + if ( is_subpost() ) { + $post = & get_post($GLOBALS['post']->post_parent); + $pre = __('Belongs to '); + } else { + $post = get_previous_post($in_same_cat, $excluded_categories); + $pre = ''; + } if ( !$post ) return; @@ -278,10 +311,10 @@ function previous_post_link($format='« %link', $link='%title', $in_same_ca $title = apply_filters('the_title', $post->post_title, $post); $string = '<a href="'.get_permalink($post->ID).'">'; $link = str_replace('%title', $title, $link); - $link = $string . $link . '</a>'; - $format = str_replace('%link', $link, $format); + $link = $pre . $string . $link . '</a>'; - echo $format; + $format = str_replace('%link', $link, $format); + echo $format; } function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { @@ -296,7 +329,7 @@ function next_post_link($format='%link »', $link='%title', $in_same_cat = $link = $string . $link . '</a>'; $format = str_replace('%link', $link, $format); - echo $format; + echo $format; } diff --git a/wp-inst/wp-includes/template-functions-post.php b/wp-inst/wp-includes/template-functions-post.php index 63db111..1f76b03 100644 --- a/wp-inst/wp-includes/template-functions-post.php +++ b/wp-inst/wp-includes/template-functions-post.php @@ -438,4 +438,22 @@ function _page_level_out($parent, $page_tree, $args, $depth = 0, $echo = true) { return $output; } +function prepend_object($content) { + global $post; + + $p = '<p class="subpostobject">'; + + if ( '' != $post->guid ) { + if ( substr($post->post_type, 0, 6) == 'image/' ) + $p .= '<a href="' . $post->guid . '" title="Click for full-size image" ><img class="subpostimage" src="' . $post->guid . '" alt="' . $post->post_title . '" /></a>'; + else + $p .= __('Attachment') . ' (' . $post->post_type . ')'; + } else { + $p .= __('Missing attachment'); + } + + $p .= '</p>'; + + return "$p\n$content"; +} ?> diff --git a/wp-inst/wp-includes/template-loader.php b/wp-inst/wp-includes/template-loader.php index 07bda7c..6678027 100644 --- a/wp-inst/wp-includes/template-loader.php +++ b/wp-inst/wp-includes/template-loader.php @@ -1,5 +1,4 @@ <?php - if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) { do_action('template_redirect'); if ( is_feed() ) { @@ -17,10 +16,17 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) { } else if ( is_home() && get_home_template() ) { include(get_home_template()); exit; + } else if ( is_subpost() && get_subpost_template() ) { + include(get_subpost_template()); + exit; } else if ( is_single() && get_single_template() ) { + if ( is_subpost() ) + add_filter('the_content', 'prepend_object'); include(get_single_template()); exit; } else if ( is_page() && get_page_template() ) { + if ( is_subpost() ) + add_filter('the_content', 'prepend_object'); include(get_page_template()); exit; } else if ( is_category() && get_category_template()) { @@ -56,4 +62,4 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) { } } -?>
\ No newline at end of file +?> diff --git a/wp-inst/wp-links-opml.php b/wp-inst/wp-links-opml.php index 04d4ff0..be4c44d 100644 --- a/wp-inst/wp-links-opml.php +++ b/wp-inst/wp-links-opml.php @@ -48,11 +48,11 @@ FROM $wpdb->links $prev_cat_id = $result->link_category; } // end if new category ?> - <outline title="<?php echo wp_specialchars($result->link_name); ?>" type="link" xmlUrl="<?php echo wp_specialchars($result->link_rss); ?>" htmlUrl="<?php echo wp_specialchars($result->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $result->link_updated) echo $result->link_updated; ?>" /> + <outline text="<?php echo wp_specialchars($result->link_name); ?>" type="link" xmlUrl="<?php echo wp_specialchars($result->link_rss); ?>" htmlUrl="<?php echo wp_specialchars($result->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $result->link_updated) echo $result->link_updated; ?>" /> <?php } // end foreach } // end if ?> </outline> </body> -</opml>
\ No newline at end of file +</opml> diff --git a/wp-inst/wp-mail.php b/wp-inst/wp-mail.php index a106e66..9780848 100644 --- a/wp-inst/wp-mail.php +++ b/wp-inst/wp-mail.php @@ -136,6 +136,7 @@ for ($i=1; $i <= $count; $i++) : $post_status = 'publish'; $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status'); + $post_data = add_magic_quotes($post_data); $post_ID = wp_insert_post($post_data); @@ -150,23 +151,6 @@ for ($i=1; $i <= $count; $i++) : echo "\n<p><b>Posted title:</b> $post_title<br />"; echo "\n<b>Posted content:</b><br /><pre>".$content.'</pre></p>'; - if (!$post_categories) $post_categories[] = 1; - foreach ($post_categories as $post_category) : - $post_category = intval($post_category); - - // Double check it's not there already - $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category"); - - if (!$exists && $result) { - $wpdb->query(" - INSERT INTO $wpdb->post2cat - (post_id, category_id) - VALUES - ($post_ID, $post_category) - "); - } - endforeach; - if(!$pop3->delete($i)) { echo '<p>Oops '.$pop3->ERROR.'</p></div>'; $pop3->reset(); @@ -179,4 +163,4 @@ endfor; $pop3->quit(); -?>
\ No newline at end of file +?> diff --git a/wp-inst/xmlrpc.php b/wp-inst/xmlrpc.php index 279e693..97c5a21 100644 --- a/wp-inst/xmlrpc.php +++ b/wp-inst/xmlrpc.php @@ -379,9 +379,7 @@ class wp_xmlrpc_server extends IXR_Server { $post_title = xmlrpc_getposttitle($content); $post_category = xmlrpc_getpostcategory($content); - - $content = xmlrpc_removepostdata($content); - $post_content = apply_filters( 'content_save_pre', $content ); + $post_content = xmlrpc_removepostdata($content); $post_date = current_time('mysql'); $post_date_gmt = current_time('mysql', 1); @@ -410,7 +408,7 @@ class wp_xmlrpc_server extends IXR_Server { $post_ID = $args[1]; $user_login = $args[2]; $user_pass = $args[3]; - $new_content = $args[4]; + $content = $args[4]; $publish = $args[5]; if (!$this->login_pass_ok($user_login, $user_pass)) { @@ -431,13 +429,9 @@ class wp_xmlrpc_server extends IXR_Server { extract($actual_post); - $content = $newcontent; - $post_title = xmlrpc_getposttitle($content); $post_category = xmlrpc_getpostcategory($content); - - $content = xmlrpc_removepostdata($content); - $post_content = apply_filters( 'content_save_pre', $content ); + $post_content = xmlrpc_removepostdata($content); $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); |