Skip to content

Commit

Permalink
Fix bug where post_id was not being auto-populated in the loop.
Browse files Browse the repository at this point in the history
Fixes issue #10
  • Loading branch information
jbeales committed Sep 25, 2012
1 parent 5dbef00 commit ac593c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions deadtrees.php
Expand Up @@ -151,6 +151,7 @@ protected function _get_image_url($asin) {

$result = wp_remote_request($url);


if(200 == $result['response']['code']) {

$result_obj = new SimpleXMLElement($result['body']);
Expand Down Expand Up @@ -648,7 +649,8 @@ public function save_bookbox_metabox($post_id) {

// we're assuming that this is a jpeg for now. Hopefully it is.
$filename = $filename['path'] . '/' . sprintf(__('book-%d-cover.jpg', 'deadtree'), $post_id);
file_put_contents($filename, $cover['body']);

$file_result = file_put_contents($filename, $cover['body']);

$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
Expand Down Expand Up @@ -751,12 +753,13 @@ public function get_bookbox_info($post_id = NULL ) {
static $datacache = array();


if(is_null($post_id)) {
if(empty($post_id)) {
$post_id = get_the_ID();
}

$cachekey = 'P' . $post_id;


// check for data in the cache, and return it if it's there.
if(isset($datacache[$cachekey])) {
return $datacache[$cachekey];
Expand Down
3 changes: 2 additions & 1 deletion template_tags.php
@@ -1,7 +1,7 @@
<?php


function dt_get_bookbox_item($item, $post_id = NULL) {
function dt_get_bookbox_item($item, $post_id = 0) {
$deadtree = DeadTrees::get_dt();

$postmeta = $deadtree->get_bookbox_info($post_id);
Expand Down Expand Up @@ -34,6 +34,7 @@ function dt_get_bookbox_comment($post_id = 0) {

function dt_get_bookbox_image($post_id = 0) {
$attachment_id = dt_get_bookbox_item('cover_image_attachment_id', $post_id);

if(!empty($attachment_id)) {
return wp_get_attachment_image($attachment_id, 'dt_book_cover_thumb');
}
Expand Down

0 comments on commit ac593c4

Please sign in to comment.