Skip to content

Commit

Permalink
Add some changes for cached_content automation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ringmaster committed Apr 11, 2013
1 parent 7b32f68 commit e460d55
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions classes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,11 @@ public function update( $minor = true )
}
}

// If content has changed, update cached_content with prerendered content
if(isset($this->newfields['content']) && $this->fields['content'] != $this->newfields['content']) {
$this->newfields['cached_content'] = Plugins::filter( 'post_prerender_content', $this->newfields['content'], $this );
}

// invoke plugins for all fields which have been changed
// For example, a plugin action "post_update_status" would be
// triggered if the post has a new status value
Expand Down Expand Up @@ -834,6 +839,19 @@ public function __get( $name )
}

switch ( $name ) {
case 'content':
if($filter == 'internal') {
$out = parent::__get( 'content' );
}
else {
$out = parent::__get( 'cached_content' );
// Didn't bother to store a cached version? Run the prerender filter on the raw version.
if(empty($out)) {
$out = Plugins::filter( "post_prerender_content", parent::__get( 'content' ), $this );
// Queue rendered content for writing to cached_content field?
}
}
break;
case 'statusname':
$out = self::status_name( $this->status );
break;
Expand Down

0 comments on commit e460d55

Please sign in to comment.