Make WordPress Core

Changeset 2958


Ignore:
Timestamp:
10/20/2005 08:48:32 PM (19 years ago)
Author:
ryan
Message:

Image fu from Andy. fixes #1776

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r2937 r2958  
    670670
    671671        }
     672    } else {
     673        $error = __('File not found');
    672674    }
    673675
  • trunk/wp-admin/image-uploading.php

    r2936 r2958  
    136136$imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
    137137$imagedata['file'] = $file;
    138 
    139 if ( false == add_post_meta($id, 'imagedata', $imagedata) )
    140     die("failed to add_post_meta");
     138$imagedata['thumb'] = "thumb-$filename";
     139
     140add_post_meta($id, 'imagedata', $imagedata);
     141
     142if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
     143    if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
     144        $error = wp_create_thumbnail($file, 128);
     145    elseif ( $imagedata['height'] > 96 )
     146        $error = wp_create_thumbnail($file, 96);
     147}
    141148
    142149header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&last=true");
     
    193200$images_html = '';
    194201$images_style = '';
     202$images_script = '';
    195203if ( count($images) > 0 ) {
    196204    $images = array_slice( $images, 0, $num );
     205    $__delete = __('DELETE');
     206    $__subpost_on = __('SUBPOST <strong>ON</strong>');
     207    $__subpost_off = __('SUBPOST <strong>OFF</strong>');
     208    $__thumbnail_on = __('THUMBNAIL <strong>ON</strong>');
     209    $__thumbnail_off = __('THUMBNAIL <strong>OFF</strong>');
     210    $__no_thumbnail = __('<del>THUMBNAIL</del>');
     211    $__close = __('CLOSE');
     212    $__confirmdelete = __('Delete this photo from the server?');
     213    $__nothumb = __('There is no thumbnail associated with this photo.');
     214    $images_script .= "subposton = '$__subpost_on';\nsubpostoff = '$__subpost_off';\n";
     215    $images_script .= "thumbnailon = '$__thumbnail_on';\nthumbnailoff = '$__thumbnail_off';\n";
    197216    foreach ( $images as $key => $image ) {
    198         $image = array_merge($image, get_post_meta($image['ID'], 'imagedata', true) );
     217        $meta = get_post_meta($image['ID'], 'imagedata', true);
     218        if (!is_array($meta)) {
     219            wp_delete_object($image['ID']);
     220            continue;
     221        }
     222        $image = array_merge($image, $meta);
     223        if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
     224            $src = str_replace(basename($image['guid']), '', $image['guid']) . $image['thumb'];
     225            $images_script .= "src".$i."a = '$src';\nsrc".$i."b = '".$image['guid']."';\n";
     226            $thumb = 'true';
     227            $thumbtext = $__thumbnail_on;
     228        } else {
     229            $src = $image['guid'];
     230            $thumb = 'false';
     231            $thumbtext = $__no_thumbnail;
     232        }
    199233        list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']);
    200         $uwidth_sum += 128; //$image['uwidth'];
     234        $height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"';
     235        $uwidth_sum += 128;
    201236        $xpadding = (128 - $image['uwidth']) / 2;
    202237        $ypadding = (96 - $image['uheight']) / 2;
    203238        $object = $image['ID'];
    204239        $images_style .= "#target$i img { padding: {$ypadding}px {$xpadding}px; }\n";
     240        $href = get_subpost_link($object);
     241        $images_script .= "href".$i."a = '$href';\nhref".$i."b = '{$image['guid']}';\n";
    205242        $images_html .= <<<HERE
    206243<div id='target$i' class='imagewrap left'>
    207244    <div id='popup$i' class='popup'>
    208         <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>
    209         <a onclick="popup.style.display='none';return false;" href="javascript:void()">CANCEL</a>
     245        <a id="L$i" onclick="toggleLink($i);return false;" href="javascript:void();">$__subpost_on</a>
     246        <a id="I$i" onclick="if($thumb)toggleImage($i);else alert('$__nothumb');return false;" href="javascript:void();">$thumbtext</a>
     247        <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>
     248        <a onclick="popup.style.display='none';return false;" href="javascript:void()">$__close</a>
    210249    </div>
    211     <a id='link$i' class='imagelink' href='{$image['guid']}' onclick='imagePopup($i);return false;' title='{$image['post_title']}'>
    212         <img id='image$i' src='{$image['guid']}' alt='{$image['post_title']}' {$image['hwstring_small']} />
     250    <a id="link$i" class="imagelink" href="$href" onclick="imagePopup($i);return false;" title="{$image['post_title']}">
     251        <img id='image$i' src='$src' alt='{$image['post_title']}' $height_width />
    213252    </a>
    214253</div>
     
    232271<meta http-equiv="imagetoolbar" content="no" />
    233272<script type="text/javascript">
     273/* Define any variables we'll need, such as alternate URLs. */
     274<?php echo $images_script; ?>
     275
    234276function validateImageName() {
    235277/* This is more for convenience than security. Server-side validation is very thorough.*/
     
    259301popup = false;
    260302}
     303function toggleLink(n) {
     304    o=document.getElementById('link'+n);
     305    oi=document.getElementById('L'+n);
     306    if ( oi.innerHTML == subposton ) {
     307        o.href = eval('href'+n+'b');
     308        oi.innerHTML = subpostoff;
     309    } else {
     310        o.href = eval('href'+n+'a');
     311        oi.innerHTML = subposton;
     312    }
     313}
     314function toggleImage(n) {
     315    o = document.getElementById('image'+n);
     316    oi = document.getElementById('I'+n);
     317    if ( oi.innerHTML == thumbnailon ) {
     318        o.src = eval('src'+n+'b');
     319        oi.innerHTML = thumbnailoff;
     320    } else {
     321        o.src = eval('src'+n+'a');
     322        oi.innerHTML = thumbnailon;
     323    }
     324}
    261325</script>
    262326<style type="text/css">
     
    370434}
    371435.popup {
    372 margin: 23px 9px;
    373 padding: 5px;
     436margin: 4px 4px;
     437padding: 3px;
    374438position: absolute;
    375 width: 100px;
    376 height: 40px;
     439width: 114px;
     440height: 82px;
    377441display: none;
    378442background-color: rgb(223, 232, 241);
     
    382446}
    383447.popup a, .popup a:visited, .popup a:active {
    384 margin-bottom: 3px;
    385448background-color: transparent;
    386449display: block;
     
    390453}
    391454.popup a:hover {
    392 margin-bottom: 3px;
    393455background-color: #fff;
    394456color: #000;
  • trunk/wp-commentsrss2.php

    r2627 r2958  
    3333            $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
    3434            LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
    35             AND $wpdb->comments.comment_approved = '1' AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'static')
     35            AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status IN ('publish', 'static', 'object')
    3636            AND post_date < '".date("Y-m-d H:i:59")."'
    3737            ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') );
     
    4040            comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
    4141            $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
    42             LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'static')
     42            LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status IN ('publish', 'static', 'object')
    4343            AND $wpdb->comments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."' 
    4444            ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') );
  • trunk/wp-content/themes/default/footer.php

    r2945 r2958  
    1616
    1717        <?php wp_footer(); ?>
    18 
     18<?php echo $GLOBALS['dump_bot']; ?>
    1919</body>
    2020</html>
  • trunk/wp-content/themes/default/header.php

    r2615 r2958  
    4949</head>
    5050<body>
    51 
     51<?php echo $GLOBALS['dump_top']; ?>
    5252<div id="page">
    5353
  • trunk/wp-includes/classes.php

    r2938 r2958  
    3030    var $is_comments_popup = false;
    3131    var $is_admin = false;
    32     var $is_object = false;
     32    var $is_subpost = false;
    3333
    3434    function init_query_flags() {
     
    5050        $this->is_paged = false;
    5151        $this->is_admin = false;
    52         $this->is_object = false;
     52        $this->is_subpost = false;
    5353    }
    5454   
     
    9191        $qv['p'] =  (int) $qv['p'];
    9292
     93        if ( ('' != $qv['subpost']) || $qv['subpost_id'] ) {
     94            $this->is_single = true;
     95            $this->is_subpost = true;
     96        }
     97
    9398        if ('' != $qv['name']) {
    9499            $this->is_single = true;
     
    97102        } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
    98103            // If year, month, day, hour, minute, and second are set, a single
    99           // post is being queried.       
     104            // post is being queried.       
    100105            $this->is_single = true;
    101106        } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
     
    209214        }
    210215
    211         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)) {
     216        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)) {
    212217            $this->is_home = true;
    213218        }
     
    336341            $q['name'] = $q['pagename'];
    337342            $where .= " AND post_name = '" . $q['pagename'] . "'";
    338         }
    339 
     343        } elseif ('' != $q['subpost']) {
     344            $q['subpost'] = sanitize_title($q['subpost']);
     345            $q['name'] = $q['subpost'];
     346            $where .= " AND post_name = '" . $q['subpost'] . "'";
     347        }
    340348
    341349        if ( (int) $q['w'] ) {
     
    346354        if ( intval($q['comments_popup']) )
    347355            $q['p'] = intval($q['comments_popup']);
     356
     357        // If a subpost is requested by number, let it supercede any post number.
     358        if ( ($q['subpost_id'] != '') && (intval($q['subpost_id']) != 0) )
     359            $q['p'] = (int) $q['subpost_id'];
    348360
    349361        // If a post number is specified, load that post
     
    517529        }
    518530
    519         if ($this->is_page) {
     531        if ( $this->is_subpost ) {
     532            $where .= ' AND (post_status = "object")';
     533        } elseif ($this->is_page) {
    520534            $where .= ' AND (post_status = "static")';
    521535        } elseif ($this->is_single) {
     
    530544        }
    531545
    532         if (! $this->is_object )
     546        if (! $this->is_subpost )
    533547            $where .= ' AND post_status != "object"';
    534548
     
    576590        // Check post status to determine if post should be displayed.
    577591        if ($this->is_single) {
    578             if ('publish' != $this->posts[0]->post_status) {
     592            $status = get_post_status($this->posts[0]);
     593            if ('publish' != $status) {
    579594                if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
    580595                    // User must be logged in to view unpublished posts.
    581596                    $this->posts = array();
    582597                } else {
    583                     if ('draft' == $this->posts[0]->post_status) {
     598                    if ('draft' == $status) {
    584599                        // User must have edit permissions on the draft to preview.
    585600                        if (! user_can_edit_post($user_ID, $this->posts[0]->ID))
    586601                            $this->posts = array();
    587                     } elseif ('private' == $this->posts[0]->post_status) {
     602                    } elseif ('private' == $status) {
    588603                        if ($this->posts[0]->post_author != $user_ID)
    589604                            $this->posts = array();
     
    822837    var $queryreplace =
    823838        array (
    824                      'year=',
    825                      'monthnum=',
    826                      'day=',
    827                      'hour=',
    828                      'minute=',
    829                      'second=',
    830                      'name=',
    831                      'p=',
    832                      'category_name=',
    833                      'author_name=',
    834                      'pagename=',
    835                      's='
    836                      );
     839                    'year=',
     840                    'monthnum=',
     841                    'day=',
     842                    'hour=',
     843                    'minute=',
     844                    'second=',
     845                    'name=',
     846                    'p=',
     847                    'category_name=',
     848                    'author_name=',
     849                    'pagename=',
     850                    's='
     851                    );
    837852
    838853    var $feeds = array ('feed', 'rdf', 'rss', 'rss2', 'atom');
     
    846861
    847862    function using_index_permalinks() {
    848     if (empty($this->permalink_structure)) {
     863        if (empty($this->permalink_structure)) {
    849864            return false;
    850     }
    851 
    852     // If the index is not in the permalink, we're using mod_rewrite.
    853     if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
    854       return true;
    855     }
     865        }
     866
     867        // If the index is not in the permalink, we're using mod_rewrite.
     868        if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
     869            return true;
     870        }
    856871   
    857     return false;
     872        return false;
    858873    }
    859874
     
    866881
    867882    function preg_index($number) {
    868     $match_prefix = '$';
    869     $match_suffix = '';
    870    
    871     if (! empty($this->matches)) {
     883        $match_prefix = '$';
     884        $match_suffix = '';
     885
     886        if (! empty($this->matches)) {
    872887            $match_prefix = '$' . $this->matches . '[';
    873888            $match_suffix = ']';
    874     }       
    875    
    876     return "$match_prefix$number$match_suffix";       
     889        }       
     890
     891        return "$match_prefix$number$match_suffix";       
    877892    }
    878893
     
    898913        }
    899914
    900     if (empty($this->permalink_structure)) {
     915        if (empty($this->permalink_structure)) {
    901916            $this->date_structure = '';
    902917            return false;
     
    974989        }
    975990
    976     if (empty($this->permalink_structure)) {
     991        if (empty($this->permalink_structure)) {
    977992            $this->category_structure = '';
    978993            return false;
     
    9941009        }
    9951010
    996     if (empty($this->permalink_structure)) {
     1011        if (empty($this->permalink_structure)) {
    9971012            $this->author_structure = '';
    9981013            return false;
     
    10091024        }
    10101025
    1011     if (empty($this->permalink_structure)) {
     1026        if (empty($this->permalink_structure)) {
    10121027            $this->search_structure = '';
    10131028            return false;
     
    10241039        }
    10251040
    1026     if (empty($this->permalink_structure)) {
     1041        if (empty($this->permalink_structure)) {
    10271042            $this->page_structure = '';
    10281043            return false;
     
    10391054        }
    10401055
    1041     if (empty($this->permalink_structure)) {
     1056        if (empty($this->permalink_structure)) {
    10421057            $this->feed_structure = '';
    10431058            return false;
     
    10541069        }
    10551070
    1056     if (empty($this->permalink_structure)) {
     1071        if (empty($this->permalink_structure)) {
    10571072            $this->comment_feed_structure = '';
    10581073            return false;
     
    11591174                    $trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
    11601175                    $match = rtrim($match, '/');
     1176                    $submatchbase = str_replace(array('(',')'),'',$match);
     1177                    $sub1 = $submatchbase . '/([^/]+)/';
     1178                    $sub1tb = $sub1 . $trackbackregex;
     1179                    $sub1feed = $sub1 . $feedregex;
     1180                    $sub1feed2 = $sub1 . $feedregex2;
     1181                    $sub1 .= '?$';
     1182                    $sub2 = $submatchbase . '/subpost/([^/]+)/';
     1183                    $sub2tb = $sub2 . $trackbackregex;
     1184                    $sub2feed = $sub2 . $feedregex;
     1185                    $sub2feed2 = $sub2 . $feedregex2;
     1186                    $sub2 .= '?$';
     1187                    $subquery = $index . '?subpost=' . $this->preg_index(1);
     1188                    $subtbquery = $subquery . '&tb=1';
     1189                    $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
    11611190                    $match = $match . '(/[0-9]+)?/?$';
    11621191                    $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
     
    11691198
    11701199                if ($post) {
    1171                     $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite;
     1200                    $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite +
     1201                        array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery) +
     1202                        array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery);
    11721203                }
    11731204            }
     
    12321263        do_action('generate_rewrite_rules', array(&$this));
    12331264        $this->rules = apply_filters('rewrite_rules_array', $this->rules);
     1265
    12341266        return $this->rules;
    12351267    }
     
    13301362
    13311363class WP {
    1332     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');
     1364    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');
    13331365
    13341366    var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging');
     
    13981430                    // If the requesting file is the anchor of the match, prepend it
    13991431                    // to the path info.
    1400                     if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) {
     1432                    if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) {
    14011433                        $request_match = $req_uri . '/' . $request;
     1434die("$request_match $match<br />");
    14021435                    }
    14031436
  • trunk/wp-includes/functions.php

    r2956 r2958  
    13851385}
    13861386
     1387function is_subpost () {
     1388    global $wp_query;
     1389
     1390    return $wp_query->is_subpost;
     1391}
     1392
    13871393function is_archive () {
    13881394    global $wp_query;
     
    18701876}
    18711877
     1878function get_subpost_template() {
     1879    global $posts;
     1880    $type = explode('/', $posts[0]->post_type);
     1881    if ( $template = get_query_template($type[0]) )
     1882        return $template;
     1883    elseif ( $template = get_query_template($type[1]) )
     1884        return $template;
     1885    elseif ( $template = get_query_template("$type[0]_$type[1]") )
     1886        return $template;
     1887    else
     1888        return get_query_template('subpost');
     1889}
     1890
    18721891function get_comments_popup_template() {
    18731892    if ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
  • trunk/wp-includes/template-functions-links.php

    r2952 r2958  
    4545    if ( $post->post_status == 'static' )
    4646        return get_page_link($post->ID);
     47    elseif ($post->post_status == 'object')
     48        return get_subpost_link($post->ID);
    4749
    4850    $permalink = get_settings('permalink_structure');
     
    101103}
    102104
     105function get_subpost_link($id = false) {
     106    global $post, $wp_rewrite;
     107
     108    $link = false;
     109
     110    if (! $id) {
     111        $id = $post->ID;
     112    }
     113
     114    $object = get_post($id);
     115    if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) ) {
     116        $parent = get_post($object->post_parent);
     117        $parentlink = get_permalink($object->post_parent);
     118        if (! strstr($parentlink, '?') )
     119            $link = trim($parentlink, '/') . '/' . $object->post_name . '/';
     120    }
     121
     122    if (! $link ) {
     123        $link = get_bloginfo('home') . "/?subpost_id=$id";
     124    }
     125
     126    return apply_filters('object_link', $link, $id);
     127}
     128
    103129function get_year_link($year) {
    104130    global $wp_rewrite;
     
    184210    get_currentuserinfo();
    185211
    186     if ( !user_can_edit_post($user_ID, $post->ID) )
     212    if ( !user_can_edit_post($user_ID, $post->ID) || is_subpost() ) {
    187213        return;
     214    }
    188215
    189216    $location = get_settings('siteurl') . "/wp-admin/post.php?action=edit&amp;post=$post->ID";
     
    208235    global $post, $wpdb;
    209236
    210     if ( !is_single() )
     237    if( !is_single() || is_subpost() )
     238        return null;
     239
     240    $current_post_date = $post->post_date;
     241
     242    $join = '';
     243    if ( $in_same_cat ) {
     244        $join = " INNER JOIN $wpdb->post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id ";
     245        $cat_array = get_the_category($post->ID);
     246        $join .= ' AND (category_id = ' . intval($cat_array[0]->cat_ID);
     247        for ( $i = 1; $i < (count($cat_array)); $i++ ) {
     248            $join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
     249        }
     250        $join .= ')';
     251    }
     252
     253    $sql_exclude_cats = '';
     254    if ( !empty($excluded_categories) ) {
     255        $blah = explode('and', $excluded_categories);
     256        foreach ( $blah as $category ) {
     257            $category = intval($category);
     258            $sql_exclude_cats .= " AND post_category != $category";
     259        }
     260    }
     261
     262    return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT 1");
     263}
     264
     265function get_next_post($in_same_cat = false, $excluded_categories = '') {
     266    global $post, $wpdb;
     267
     268    if( !is_single() || is_subpost() )
    211269        return null;
    212270
     
    233291    }
    234292
    235     return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT 1");
    236 }
    237 
    238 function get_next_post($in_same_cat = false, $excluded_categories = '') {
    239     global $post, $wpdb;
    240 
    241     if ( !is_single() )
    242         return null;
    243 
    244     $current_post_date = $post->post_date;
    245    
    246     $join = '';
    247     if ( $in_same_cat ) {
    248         $join = " INNER JOIN $wpdb->post2cat ON $wpdb->posts.ID= $wpdb->post2cat.post_id ";
    249         $cat_array = get_the_category($post->ID);
    250         $join .= ' AND (category_id = ' . intval($cat_array[0]->cat_ID);
    251         for ( $i = 1; $i < (count($cat_array)); $i++ ) {
    252             $join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
    253         }
    254         $join .= ')';
    255     }
    256 
    257     $sql_exclude_cats = '';
    258     if ( !empty($excluded_categories) ) {
    259         $blah = explode('and', $excluded_categories);
    260         foreach ( $blah as $category ) {
    261             $category = intval($category);
    262             $sql_exclude_cats .= " AND post_category != $category";
    263         }
    264     }
    265 
    266293    $now = current_time('mysql');
    267294   
     
    271298
    272299function previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    273     $post = get_previous_post($in_same_cat, $excluded_categories);
     300    if ( is_subpost() ) {
     301        $post = & get_post($GLOBALS['post']->post_parent);
     302        $pre = __('Belongs to ');
     303    } else {
     304        $post = get_previous_post($in_same_cat, $excluded_categories);
     305        $pre = '';
     306    }
     307
     308    if ( !$post )
     309        return;
     310
     311    $title = apply_filters('the_title', $post->post_title, $post);
     312    $string = '<a href="'.get_permalink($post->ID).'">';
     313    $link = str_replace('%title', $title, $link);
     314    $link = $pre . $string . $link . '</a>';
     315
     316    $format = str_replace('%link', $link, $format);
     317    echo $format;       
     318}
     319
     320function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
     321    $post = get_next_post($in_same_cat, $excluded_categories);
    274322
    275323    if ( !$post )
     
    282330    $format = str_replace('%link', $link, $format);
    283331
    284     echo $format;
    285 }
    286 
    287 function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    288     $post = get_next_post($in_same_cat, $excluded_categories);
    289 
    290     if ( !$post )
    291         return;
    292 
    293     $title = apply_filters('the_title', $post->post_title, $post);
    294     $string = '<a href="'.get_permalink($post->ID).'">';
    295     $link = str_replace('%title', $title, $link);
    296     $link = $string . $link . '</a>';
    297     $format = str_replace('%link', $link, $format);
    298 
    299     echo $format;
     332    echo $format;       
    300333}
    301334
  • trunk/wp-includes/template-functions-post.php

    r2955 r2958  
    439439}
    440440
     441function prepend_object($content) {
     442    global $post;
     443
     444    $p = '<p class="subpostobject">';
     445
     446    if ( '' != $post->guid ) {
     447        if ( substr($post->post_type, 0, 6) == 'image/' )
     448            $p .= '<a href="' . $post->guid . '" title="Click for full-size image" ><img class="subpostimage" src="' . $post->guid . '" alt="' . $post->post_title . '" /></a>';
     449        else
     450            $p .= __('Attachment') . ' (' . $post->post_type . ')';
     451    } else {
     452        $p .= __('Missing attachment');
     453    }
     454
     455    $p .= '</p>';
     456
     457    return "$p\n$content";
     458}
    441459?>
  • trunk/wp-includes/template-loader.php

    r2735 r2958  
    11<?php
    2 
    32if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
    43    do_action('template_redirect');
     
    1817        include(get_home_template());
    1918        exit;
     19    } else if ( is_subpost() && get_subpost_template() ) {
     20        include(get_subpost_template());
     21        exit;
    2022    } else if ( is_single() && get_single_template() ) {
     23        if ( is_subpost() )
     24            add_filter('the_content', 'prepend_object');
    2125        include(get_single_template());
    2226        exit;
    2327    } else if ( is_page() && get_page_template() ) {
     28        if ( is_subpost() )
     29            add_filter('the_content', 'prepend_object');
    2430        include(get_page_template());
    2531        exit;
Note: See TracChangeset for help on using the changeset viewer.