Skip to content

Commit

Permalink
Merge branch 'release/2.9.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
benhuson committed Jun 1, 2017
2 parents 5342455 + d806098 commit 29e59b7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.9.1] - 2017-06-01

### Fixed
- Fix preview not rendering correct template and other post meta.

## [2.9] - 2017-05-03

### Added
Expand Down Expand Up @@ -132,7 +137,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added
- First version.

[Unreleased]: https://github.com/benhuson/wp-subtitle/compare/2.9...HEAD
[Unreleased]: https://github.com/benhuson/wp-subtitle/compare/2.9.1...HEAD
[2.9]: https://github.com/benhuson/wp-subtitle/compare/2.9...2.9.1
[2.9]: https://github.com/benhuson/wp-subtitle/compare/2.8.1...2.9
[2.8.1]: https://github.com/benhuson/wp-subtitle/compare/2.8...2.8.1
[2.8]: https://github.com/benhuson/wp-subtitle/compare/2.7.1...2.8
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
Upgrade Notice
--------------

### 2.9.1
Fix preview not rendering correct template and other post meta.

### 2.9
Add support for revisions and fix special character encoding.

Expand Down
14 changes: 14 additions & 0 deletions includes/subtitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ public function get_subtitle( $args = '' ) {
*/
public function get_raw_subtitle() {

if ( is_preview() ) {

if ( isset( $_GET['preview_id'] ) ) {
$p = wp_get_post_autosave( $this->post_id );
return get_post_meta( $p->ID, $this->get_post_meta_key(), true );
}

if ( $revisions = wp_get_post_revisions( $this->post_id ) ) {
$p = array_shift( $revisions );
return get_post_meta( $p->ID, $this->get_post_meta_key(), true );
}

}

return get_post_meta( $this->post_id, $this->get_post_meta_key(), true );

}
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: husobj, husani
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SLZUF4XJTS4E6
Tags: subtitle, content, title, subheading, subhead, alternate title
Requires at least: 3.7
Tested up to: 4.7.4
Stable tag: 2.9
Tested up to: 4.7.5
Stable tag: 2.9.1
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.txt

Expand Down Expand Up @@ -102,6 +102,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu

= Unreleased =

= 2.9.1 =
* Fix preview not rendering correct template and other post meta.

= 2.9 =
* Add support for post revisions. Props [Fabian Marz](https://github.com/fabianmarz).
* As of WordPress 4.3 no need to esc_attr() AND htmlentities() - can mess up special characters.
Expand Down Expand Up @@ -176,6 +179,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu

== Upgrade Notice ==

= 2.9.1 =
Fix preview not rendering correct template and other post meta.

= 2.9 =
Add support for revisions and fix special character encoding.

Expand Down
28 changes: 2 additions & 26 deletions wp-subtitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: WP Subtitle
Plugin URI: http://wordpress.org/plugins/wp-subtitle/
Description: Adds a subtitle field to pages and posts. Possible to add support for custom post types.
Version: 2.9
Version: 2.9.1
Author: Ben Huson, Husani Oakley
Author URI: https://github.com/benhuson/wp-subtitle
License: GPLv2
Expand Down Expand Up @@ -67,35 +67,11 @@ class WPSubtitle {
* @internal
*/
public static function _add_default_post_type_support() {

add_post_type_support( 'page', 'wps_subtitle' );
add_post_type_support( 'post', 'wps_subtitle' );
add_post_type_support( 'revision', 'wps_subtitle' );

add_filter( 'the_preview', array( 'WPSubtitle', 'the_preview' ), 10, 2 );

}

/**
* Returns the autosaved data to make changes visible in preview mode.
*
* @since 2.9
*
* @param object $post Post object.
* @param object $query Query object.
* @return WP_Post|false The autosaved data or false on failure or when no autosave exists.
*/
public static function the_preview( $post, $query ) {

if ( isset( $_GET['preview_id'] ) ) {
return wp_get_post_autosave( $post->ID );
}

if ( $revisions = wp_get_post_revisions( $post->ID ) ) {
return array_shift( $revisions );
}

return $post;

}

/**
Expand Down

0 comments on commit 29e59b7

Please sign in to comment.