Image fu from Andy. fixes #1776

git-svn-id: http://svn.automattic.com/wordpress/trunk@2958 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-10-20 20:48:32 +00:00
parent 183593f333
commit 45fc6c1664
10 changed files with 252 additions and 79 deletions

View File

@ -669,6 +669,8 @@ function wp_create_thumbnail($file, $max_side, $effect = '') {
}
}
} else {
$error = __('File not found');
}
if (!empty ($error)) {

View File

@ -135,9 +135,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;
@ -192,24 +199,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&amp;object=$object&amp;all=$all&amp;start=$start&amp;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&amp;object=$object&amp;all=$all&amp;start=$start&amp;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;
@ -231,6 +270,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');
@ -258,6 +300,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 {
@ -369,11 +433,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;
@ -381,7 +445,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%;
@ -389,7 +452,6 @@ text-decoration: none;
color: #246;
}
.popup a:hover {
margin-bottom: 3px;
background-color: #fff;
color: #000;
}

View File

@ -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') );
}

View File

@ -15,6 +15,6 @@
<?php /* "Just what do you think you're doing Dave?" */ ?>
<?php wp_footer(); ?>
<?php echo $GLOBALS['dump_bot']; ?>
</body>
</html>
</html>

View File

@ -48,7 +48,7 @@
<?php wp_head(); ?>
</head>
<body>
<?php echo $GLOBALS['dump_top']; ?>
<div id="page">

View File

@ -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,8 +1429,9 @@ 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;
die("$request_match $match<br />");
}
if (preg_match("!^$match!", $request_match, $matches)) {

View File

@ -1384,6 +1384,12 @@ function is_page ($page = '') {
return false;
}
function is_subpost () {
global $wp_query;
return $wp_query->is_subpost;
}
function is_archive () {
global $wp_query;
@ -1869,6 +1875,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';

View File

@ -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&amp;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='&laquo; %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='&laquo; %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 &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
@ -296,7 +329,7 @@ function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat =
$link = $string . $link . '</a>';
$format = str_replace('%link', $link, $format);
echo $format;
echo $format;
}
@ -491,4 +524,4 @@ function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nx
}
}
?>
?>

View File

@ -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";
}
?>

View File

@ -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') ) {
}
}
?>
?>