Version Description
- Make
wps_subtitleavailable via WordPress REST API.
Download this release
Release Info
| Developer | husobj |
| Plugin | |
| Version | 3.0 |
| Comparing to | |
| See all releases | |
Code changes from version 2.9.1 to 3.0
- CHANGELOG.md +7 -1
- README.md +3 -0
- includes/rest.php +68 -0
- readme.txt +8 -2
- wp-subtitle.php +23 -1
CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
| 4 |
|
| 5 |
## [Unreleased]
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
## [2.9.1] - 2017-06-01
|
| 8 |
|
| 9 |
### Fixed
|
|
@@ -137,7 +142,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
| 137 |
### Added
|
| 138 |
- First version.
|
| 139 |
|
| 140 |
-
[Unreleased]: https://github.com/benhuson/wp-subtitle/compare/
|
|
|
|
| 141 |
[2.9.1]: https://github.com/benhuson/wp-subtitle/compare/2.9...2.9.1
|
| 142 |
[2.9]: https://github.com/benhuson/wp-subtitle/compare/2.8.1...2.9
|
| 143 |
[2.8.1]: https://github.com/benhuson/wp-subtitle/compare/2.8...2.8.1
|
| 4 |
|
| 5 |
## [Unreleased]
|
| 6 |
|
| 7 |
+
## [3.0] - 2017-09-05
|
| 8 |
+
|
| 9 |
+
### Added
|
| 10 |
+
- Make `wps_subtitle` available via WordPress REST API.
|
| 11 |
+
|
| 12 |
## [2.9.1] - 2017-06-01
|
| 13 |
|
| 14 |
### Fixed
|
| 142 |
### Added
|
| 143 |
- First version.
|
| 144 |
|
| 145 |
+
[Unreleased]: https://github.com/benhuson/wp-subtitle/compare/3.0...HEAD
|
| 146 |
+
[3.0]: https://github.com/benhuson/wp-subtitle/compare/2.9.2...3.0
|
| 147 |
[2.9.1]: https://github.com/benhuson/wp-subtitle/compare/2.9...2.9.1
|
| 148 |
[2.9]: https://github.com/benhuson/wp-subtitle/compare/2.8.1...2.9
|
| 149 |
[2.8.1]: https://github.com/benhuson/wp-subtitle/compare/2.8...2.8.1
|
README.md
CHANGED
|
@@ -88,6 +88,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 88 |
Upgrade Notice
|
| 89 |
--------------
|
| 90 |
|
|
|
|
|
|
|
|
|
|
| 91 |
### 2.9.1
|
| 92 |
Fix preview not rendering correct template and other post meta.
|
| 93 |
|
| 88 |
Upgrade Notice
|
| 89 |
--------------
|
| 90 |
|
| 91 |
+
### 3.0
|
| 92 |
+
Make `wps_subtitle` available via WordPress REST API.
|
| 93 |
+
|
| 94 |
### 2.9.1
|
| 95 |
Fix preview not rendering correct template and other post meta.
|
| 96 |
|
includes/rest.php
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* @package WP Subtitle
|
| 5 |
+
* @subpackage REST API
|
| 6 |
+
*
|
| 7 |
+
* @since 3.0
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
class WPSubtitle_REST {
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Constructor
|
| 14 |
+
*
|
| 15 |
+
* @since 3.0
|
| 16 |
+
*
|
| 17 |
+
* @internal Do not create multiple instances.
|
| 18 |
+
*/
|
| 19 |
+
public function __construct() {
|
| 20 |
+
|
| 21 |
+
add_action( 'rest_api_init', array( $this, 'register_rest_field' ) );
|
| 22 |
+
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Register REST Field
|
| 27 |
+
*
|
| 28 |
+
* @since 3.0
|
| 29 |
+
*
|
| 30 |
+
* @internal Called via the `rest_api_init` action.
|
| 31 |
+
*/
|
| 32 |
+
public function register_rest_field() {
|
| 33 |
+
|
| 34 |
+
$post_types = WPSubtitle::get_supported_post_types();
|
| 35 |
+
|
| 36 |
+
foreach ( $post_types as $post_type ) {
|
| 37 |
+
|
| 38 |
+
register_rest_field( $post_types, 'wps_subtitle', array(
|
| 39 |
+
'get_callback' => array( $this, 'get_rest_field' ),
|
| 40 |
+
'update_callback' => null,
|
| 41 |
+
'schema' => null
|
| 42 |
+
) );
|
| 43 |
+
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Get REST Field
|
| 50 |
+
*
|
| 51 |
+
* @since 3.0
|
| 52 |
+
*
|
| 53 |
+
* @internal Called via register_rest_field() callback.
|
| 54 |
+
*
|
| 55 |
+
* @param array $object Current post details.
|
| 56 |
+
* @param string $field_name Name of field.
|
| 57 |
+
* @param WP_REST_Request $request Current request.
|
| 58 |
+
* @return string Subtitle
|
| 59 |
+
*/
|
| 60 |
+
public function get_rest_field( $object, $field_name, $request ) {
|
| 61 |
+
|
| 62 |
+
$subtitle = new WP_Subtitle( $object['id'] );
|
| 63 |
+
|
| 64 |
+
return $subtitle->get_raw_subtitle();
|
| 65 |
+
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
}
|
readme.txt
CHANGED
|
@@ -3,8 +3,8 @@ Contributors: husobj, husani
|
|
| 3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SLZUF4XJTS4E6
|
| 4 |
Tags: subtitle, content, title, subheading, subhead, alternate title
|
| 5 |
Requires at least: 3.7
|
| 6 |
-
Tested up to: 4.
|
| 7 |
-
Stable tag:
|
| 8 |
License: GPLv2
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
| 10 |
|
|
@@ -102,6 +102,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 102 |
|
| 103 |
= Unreleased =
|
| 104 |
|
|
|
|
|
|
|
|
|
|
| 105 |
= 2.9.1 =
|
| 106 |
* Fix preview not rendering correct template and other post meta.
|
| 107 |
|
|
@@ -179,6 +182,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 179 |
|
| 180 |
== Upgrade Notice ==
|
| 181 |
|
|
|
|
|
|
|
|
|
|
| 182 |
= 2.9.1 =
|
| 183 |
Fix preview not rendering correct template and other post meta.
|
| 184 |
|
| 3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SLZUF4XJTS4E6
|
| 4 |
Tags: subtitle, content, title, subheading, subhead, alternate title
|
| 5 |
Requires at least: 3.7
|
| 6 |
+
Tested up to: 4.8.1
|
| 7 |
+
Stable tag: 3.0
|
| 8 |
License: GPLv2
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
| 10 |
|
| 102 |
|
| 103 |
= Unreleased =
|
| 104 |
|
| 105 |
+
= 3.0 =
|
| 106 |
+
* Make `wps_subtitle` available via WordPress REST API.
|
| 107 |
+
|
| 108 |
= 2.9.1 =
|
| 109 |
* Fix preview not rendering correct template and other post meta.
|
| 110 |
|
| 182 |
|
| 183 |
== Upgrade Notice ==
|
| 184 |
|
| 185 |
+
= 3.0 =
|
| 186 |
+
* Make `wps_subtitle` available via WordPress REST API.
|
| 187 |
+
|
| 188 |
= 2.9.1 =
|
| 189 |
Fix preview not rendering correct template and other post meta.
|
| 190 |
|
wp-subtitle.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
Plugin Name: WP Subtitle
|
| 5 |
Plugin URI: http://wordpress.org/plugins/wp-subtitle/
|
| 6 |
Description: Adds a subtitle field to pages and posts. Possible to add support for custom post types.
|
| 7 |
-
Version:
|
| 8 |
Author: Ben Huson, Husani Oakley
|
| 9 |
Author URI: https://github.com/benhuson/wp-subtitle
|
| 10 |
License: GPLv2
|
|
@@ -41,6 +41,7 @@ define( 'WPSUBTITLE_DIR', plugin_dir_path( __FILE__ ) );
|
|
| 41 |
include_once( WPSUBTITLE_DIR . 'includes/subtitle.php' );
|
| 42 |
include_once( WPSUBTITLE_DIR . 'includes/deprecated.php' );
|
| 43 |
include_once( WPSUBTITLE_DIR . 'includes/shortcode.php' );
|
|
|
|
| 44 |
|
| 45 |
// Include admin-only functionality
|
| 46 |
if ( is_admin() ) {
|
|
@@ -52,6 +53,7 @@ if ( is_admin() ) {
|
|
| 52 |
}
|
| 53 |
}
|
| 54 |
|
|
|
|
| 55 |
add_action( 'init', array( 'WPSubtitle', '_add_default_post_type_support' ), 5 );
|
| 56 |
|
| 57 |
// Default subtitle filters
|
|
@@ -60,6 +62,26 @@ add_filter( 'wps_subtitle', 'trim' );
|
|
| 60 |
|
| 61 |
class WPSubtitle {
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
/**
|
| 64 |
* Add Default Post Type Support
|
| 65 |
*
|
| 4 |
Plugin Name: WP Subtitle
|
| 5 |
Plugin URI: http://wordpress.org/plugins/wp-subtitle/
|
| 6 |
Description: Adds a subtitle field to pages and posts. Possible to add support for custom post types.
|
| 7 |
+
Version: 3.0
|
| 8 |
Author: Ben Huson, Husani Oakley
|
| 9 |
Author URI: https://github.com/benhuson/wp-subtitle
|
| 10 |
License: GPLv2
|
| 41 |
include_once( WPSUBTITLE_DIR . 'includes/subtitle.php' );
|
| 42 |
include_once( WPSUBTITLE_DIR . 'includes/deprecated.php' );
|
| 43 |
include_once( WPSUBTITLE_DIR . 'includes/shortcode.php' );
|
| 44 |
+
include_once( WPSUBTITLE_DIR . 'includes/rest.php' );
|
| 45 |
|
| 46 |
// Include admin-only functionality
|
| 47 |
if ( is_admin() ) {
|
| 53 |
}
|
| 54 |
}
|
| 55 |
|
| 56 |
+
add_action( 'plugins_loaded', array( 'WPSubtitle', 'load' ) );
|
| 57 |
add_action( 'init', array( 'WPSubtitle', '_add_default_post_type_support' ), 5 );
|
| 58 |
|
| 59 |
// Default subtitle filters
|
| 62 |
|
| 63 |
class WPSubtitle {
|
| 64 |
|
| 65 |
+
/**
|
| 66 |
+
* REST API
|
| 67 |
+
*
|
| 68 |
+
* @since 3.0
|
| 69 |
+
*
|
| 70 |
+
* @var WPSubtitle_REST|null
|
| 71 |
+
*/
|
| 72 |
+
private static $rest = null;
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Load
|
| 76 |
+
*
|
| 77 |
+
* @since 3.0
|
| 78 |
+
*/
|
| 79 |
+
public static function load() {
|
| 80 |
+
|
| 81 |
+
self::$rest = new WPSubtitle_REST();
|
| 82 |
+
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
/**
|
| 86 |
* Add Default Post Type Support
|
| 87 |
*
|
