Version Description
- Added
%%wps_subtitle%%placeholders for Yoast SEO compatibility. - WooCommerce compatibility. Go to
WooCommerce > Settings > Products > Displayfor settings. - Added
wps_subtitle_field_positionfilter to show subtitle admin fieldbefore_title,after_titleor in meta box. - Use metabox UI if editing in Gutenberg.
Download this release
Release Info
| Developer | husobj |
| Plugin | |
| Version | 3.1 |
| Comparing to | |
| See all releases | |
Code changes from version 3.0 to 3.1
- CHANGELOG.md +12 -2
- README.md +5 -0
- admin/admin.php +71 -3
- includes/compat/woocommerce.php +138 -0
- includes/compat/wordpress-seo.php +81 -0
- includes/rest.php +4 -4
- languages/wp-subtitle.pot +32 -6
- readme.txt +12 -3
- wp-subtitle.php +25 -3
CHANGELOG.md
CHANGED
|
@@ -4,10 +4,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
| 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 |
|
|
@@ -20,7 +29,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
| 20 |
- Add support for post revisions. Props [Fabian Marz](https://github.com/fabianmarz).
|
| 21 |
|
| 22 |
### Fixed
|
| 23 |
-
- As of WordPress 4.3 no need to esc_attr() AND htmlentities() - can mess up special characters.
|
| 24 |
|
| 25 |
## [2.8.1] - 2016-09-14
|
| 26 |
|
|
@@ -142,7 +151,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
| 142 |
### Added
|
| 143 |
- First version.
|
| 144 |
|
| 145 |
-
[Unreleased]: https://github.com/benhuson/wp-subtitle/compare/3.
|
|
|
|
| 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
|
| 4 |
|
| 5 |
## [Unreleased]
|
| 6 |
|
| 7 |
+
## [3.1] - 2018-09-04
|
| 8 |
+
|
| 9 |
+
### Added
|
| 10 |
+
- `%%wps_subtitle%%` placeholders for Yoast SEO compatibility.
|
| 11 |
+
- WooCommerce compatibility. Go to `WooCommerce > Settings > Products > Display` for settings.
|
| 12 |
+
- `wps_subtitle_field_position` filter to position admin field `after_title`, `before_title` or otherwise in a meta box.
|
| 13 |
+
- Use metabox UI if editing in Gutenberg.
|
| 14 |
+
|
| 15 |
## [3.0] - 2017-09-05
|
| 16 |
|
| 17 |
### Added
|
| 18 |
- Make `wps_subtitle` available via WordPress REST API.
|
| 19 |
+
- Added `wps_subtitle_field_position` filter to show subtitle admin field `before_title`, `after_title` or in meta box.
|
| 20 |
|
| 21 |
## [2.9.1] - 2017-06-01
|
| 22 |
|
| 29 |
- Add support for post revisions. Props [Fabian Marz](https://github.com/fabianmarz).
|
| 30 |
|
| 31 |
### Fixed
|
| 32 |
+
- As of WordPress 4.3 no need to `esc_attr()` AND `htmlentities()` - can mess up special characters.
|
| 33 |
|
| 34 |
## [2.8.1] - 2016-09-14
|
| 35 |
|
| 151 |
### Added
|
| 152 |
- First version.
|
| 153 |
|
| 154 |
+
[Unreleased]: https://github.com/benhuson/wp-subtitle/compare/3.1...HEAD
|
| 155 |
+
[3.1]: https://github.com/benhuson/wp-subtitle/compare/3.0...3.1
|
| 156 |
[3.0]: https://github.com/benhuson/wp-subtitle/compare/2.9.2...3.0
|
| 157 |
[2.9.1]: https://github.com/benhuson/wp-subtitle/compare/2.9...2.9.1
|
| 158 |
[2.9]: https://github.com/benhuson/wp-subtitle/compare/2.8.1...2.9
|
README.md
CHANGED
|
@@ -88,6 +88,11 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 88 |
Upgrade Notice
|
| 89 |
--------------
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
### 3.0
|
| 92 |
Make `wps_subtitle` available via WordPress REST API.
|
| 93 |
|
| 88 |
Upgrade Notice
|
| 89 |
--------------
|
| 90 |
|
| 91 |
+
### Unreleased
|
| 92 |
+
|
| 93 |
+
### 3.1
|
| 94 |
+
WooCommerce compatibility: Go to `WooCommerce > Settings > Products > Display` for settings. Yoast SEO compatibility: Added `%%wps_subtitle%%` placeholders. Gutenberg compatibility: Use metabox UI.
|
| 95 |
+
|
| 96 |
### 3.0
|
| 97 |
Make `wps_subtitle` available via WordPress REST API.
|
| 98 |
|
admin/admin.php
CHANGED
|
@@ -53,9 +53,15 @@ class WPSubtitle_Admin {
|
|
| 53 |
|
| 54 |
// Setup Field / Meta Box
|
| 55 |
if ( WPSubtitle::is_supported_post_type( $post_type ) ) {
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
add_action( 'admin_head', array( 'WPSubtitle_Admin', '_add_admin_styles' ) );
|
| 58 |
add_action( 'edit_form_after_title', array( 'WPSubtitle_Admin', '_add_subtitle_field' ) );
|
|
|
|
|
|
|
|
|
|
| 59 |
} else {
|
| 60 |
add_action( 'add_meta_boxes', array( 'WPSubtitle_Admin', '_add_meta_boxes' ) );
|
| 61 |
}
|
|
@@ -63,6 +69,7 @@ class WPSubtitle_Admin {
|
|
| 63 |
add_filter( 'manage_edit-' . $post_type . '_columns', array( 'WPSubtitle_Admin', 'manage_subtitle_columns' ) );
|
| 64 |
add_action( 'manage_' . $post_type . '_posts_custom_column', array( 'WPSubtitle_Admin', 'manage_subtitle_columns_content' ), 10, 2 );
|
| 65 |
add_action( 'quick_edit_custom_box', array( 'WPSubtitle_Admin', 'quick_edit_custom_box' ), 10, 2 );
|
|
|
|
| 66 |
}
|
| 67 |
|
| 68 |
}
|
|
@@ -110,9 +117,24 @@ class WPSubtitle_Admin {
|
|
| 110 |
|
| 111 |
$new_columns = array();
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
foreach ( $columns as $column => $value ) {
|
| 114 |
$new_columns[ $column ] = $value;
|
| 115 |
-
if (
|
| 116 |
$new_columns['wps_subtitle'] = __( 'Subtitle', 'wp-subtitle' );
|
| 117 |
}
|
| 118 |
}
|
|
@@ -253,7 +275,11 @@ class WPSubtitle_Admin {
|
|
| 253 |
public static function _add_meta_boxes() {
|
| 254 |
$post_types = WPSubtitle::get_supported_post_types();
|
| 255 |
foreach ( $post_types as $post_type ) {
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
}
|
| 258 |
}
|
| 259 |
|
|
@@ -439,4 +465,46 @@ class WPSubtitle_Admin {
|
|
| 439 |
return ! apply_filters( 'wps_subtitle_use_meta_box', false, $post_type );
|
| 440 |
}
|
| 441 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 442 |
}
|
| 53 |
|
| 54 |
// Setup Field / Meta Box
|
| 55 |
if ( WPSubtitle::is_supported_post_type( $post_type ) ) {
|
| 56 |
+
|
| 57 |
+
$position = self::subtitle_field_position( $post_type );
|
| 58 |
+
|
| 59 |
+
if ( 'after_title' == $position ) {
|
| 60 |
add_action( 'admin_head', array( 'WPSubtitle_Admin', '_add_admin_styles' ) );
|
| 61 |
add_action( 'edit_form_after_title', array( 'WPSubtitle_Admin', '_add_subtitle_field' ) );
|
| 62 |
+
} elseif ( 'before_title' == $position ) {
|
| 63 |
+
add_action( 'admin_head', array( 'WPSubtitle_Admin', '_add_admin_styles' ) );
|
| 64 |
+
add_action( 'edit_form_top', array( 'WPSubtitle_Admin', '_add_subtitle_field' ) );
|
| 65 |
} else {
|
| 66 |
add_action( 'add_meta_boxes', array( 'WPSubtitle_Admin', '_add_meta_boxes' ) );
|
| 67 |
}
|
| 69 |
add_filter( 'manage_edit-' . $post_type . '_columns', array( 'WPSubtitle_Admin', 'manage_subtitle_columns' ) );
|
| 70 |
add_action( 'manage_' . $post_type . '_posts_custom_column', array( 'WPSubtitle_Admin', 'manage_subtitle_columns_content' ), 10, 2 );
|
| 71 |
add_action( 'quick_edit_custom_box', array( 'WPSubtitle_Admin', 'quick_edit_custom_box' ), 10, 2 );
|
| 72 |
+
|
| 73 |
}
|
| 74 |
|
| 75 |
}
|
| 117 |
|
| 118 |
$new_columns = array();
|
| 119 |
|
| 120 |
+
// Subtitle column after...
|
| 121 |
+
$after_column = '';
|
| 122 |
+
if ( array_key_exists( 'title', $columns ) ) {
|
| 123 |
+
$after_column = 'title';
|
| 124 |
+
} elseif ( array_key_exists( 'name', $columns ) ) {
|
| 125 |
+
$after_column = 'name';
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
// Add column
|
| 129 |
+
if ( empty( $after_column ) ) {
|
| 130 |
+
$columns['wps_subtitle'] = __( 'Subtitle', 'wp-subtitle' );
|
| 131 |
+
return $columns;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
// Insert column
|
| 135 |
foreach ( $columns as $column => $value ) {
|
| 136 |
$new_columns[ $column ] = $value;
|
| 137 |
+
if ( $after_column == $column ) {
|
| 138 |
$new_columns['wps_subtitle'] = __( 'Subtitle', 'wp-subtitle' );
|
| 139 |
}
|
| 140 |
}
|
| 275 |
public static function _add_meta_boxes() {
|
| 276 |
$post_types = WPSubtitle::get_supported_post_types();
|
| 277 |
foreach ( $post_types as $post_type ) {
|
| 278 |
+
|
| 279 |
+
$positiom = self::gutenberg_supported( $post_type ) ? 'side' : 'normal';
|
| 280 |
+
|
| 281 |
+
add_meta_box( 'wps_subtitle_panel', self::get_meta_box_title( $post_type ), array( 'WPSubtitle_Admin', '_add_subtitle_meta_box' ), $post_type, $positiom, 'high' );
|
| 282 |
+
|
| 283 |
}
|
| 284 |
}
|
| 285 |
|
| 465 |
return ! apply_filters( 'wps_subtitle_use_meta_box', false, $post_type );
|
| 466 |
}
|
| 467 |
|
| 468 |
+
/**
|
| 469 |
+
* Gutenberg Supported
|
| 470 |
+
*
|
| 471 |
+
* @since 3.1
|
| 472 |
+
*
|
| 473 |
+
* @param string $post_type Post type.
|
| 474 |
+
* @return bool
|
| 475 |
+
*/
|
| 476 |
+
private static function gutenberg_supported( $post_type = '' ) {
|
| 477 |
+
|
| 478 |
+
if ( function_exists( 'gutenberg_can_edit_post_type' ) && gutenberg_can_edit_post_type( $post_type ) && ! isset( $_GET['classic-editor'] ) ) {
|
| 479 |
+
return true;
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
return false;
|
| 483 |
+
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
/**
|
| 487 |
+
* Subtitle Field Position
|
| 488 |
+
*
|
| 489 |
+
* @since 3.1
|
| 490 |
+
*
|
| 491 |
+
* @param string $post_type Post type.
|
| 492 |
+
* @param string Position.
|
| 493 |
+
*/
|
| 494 |
+
private static function subtitle_field_position( $post_type = '' ) {
|
| 495 |
+
|
| 496 |
+
$position = apply_filters( 'wps_subtitle_field_position', 'after_title', $post_type );
|
| 497 |
+
|
| 498 |
+
if ( self::gutenberg_supported( $post_type ) ) {
|
| 499 |
+
return '';
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
if ( ! self::edit_form_after_title_supported( $post_type ) ) {
|
| 503 |
+
return '';
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
return $position;
|
| 507 |
+
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
}
|
includes/compat/woocommerce.php
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* @package WP Subtitle
|
| 5 |
+
* @subpackage WooCommerce
|
| 6 |
+
*
|
| 7 |
+
* @since 3.1
|
| 8 |
+
*
|
| 9 |
+
* Compatibility for the WooCommerce plugin:
|
| 10 |
+
* https://wordpress.org/plugins/woocommerce/
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
class WPSubtitle_WooCommerce {
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Constructor
|
| 17 |
+
*
|
| 18 |
+
* @since 3.1
|
| 19 |
+
*
|
| 20 |
+
* @internal Do not create multiple instances.
|
| 21 |
+
*/
|
| 22 |
+
public function __construct() {
|
| 23 |
+
|
| 24 |
+
if ( 'yes' == get_option( 'wp_subtitle_woocommerce_enabled' ) ) {
|
| 25 |
+
|
| 26 |
+
add_action( 'init', array( $this, 'add_product_post_type_support' ) );
|
| 27 |
+
|
| 28 |
+
if ( 'yes' == get_option( 'wp_subtitle_woocommerce_show_on_single' ) ) {
|
| 29 |
+
add_action( 'woocommerce_single_product_summary' , array( $this, 'single_product_summary' ), 6 );
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
if ( 'yes' == get_option( 'wp_subtitle_woocommerce_show_in_loop' ) ) {
|
| 33 |
+
add_action( 'woocommerce_shop_loop_item_title' , array( $this, 'shop_loop_item_title' ) );
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
add_filter( 'woocommerce_product_settings' , array( $this, 'product_settings' ) );
|
| 39 |
+
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Add Product Post Type Support
|
| 44 |
+
*
|
| 45 |
+
* @since 3.1
|
| 46 |
+
*
|
| 47 |
+
* @internal Private. Called via the `init` action.
|
| 48 |
+
*/
|
| 49 |
+
public function add_product_post_type_support() {
|
| 50 |
+
|
| 51 |
+
add_post_type_support( 'product', 'wps_subtitle' );
|
| 52 |
+
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Single Product Summary
|
| 57 |
+
*
|
| 58 |
+
* @since 3.1
|
| 59 |
+
*
|
| 60 |
+
* @internal Private. Called via the `woocommerce_single_product_summary` action.
|
| 61 |
+
*/
|
| 62 |
+
public function single_product_summary() {
|
| 63 |
+
|
| 64 |
+
the_subtitle( '<h2 class="product_subtitle entry-subtitle wp-subtitle">', '</h2>' );
|
| 65 |
+
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Shop Loop Item Title
|
| 70 |
+
*
|
| 71 |
+
* @since 3.1
|
| 72 |
+
*
|
| 73 |
+
* @internal Private. Called via the `woocommerce_shop_loop_item_title` action.
|
| 74 |
+
*/
|
| 75 |
+
public function shop_loop_item_title() {
|
| 76 |
+
|
| 77 |
+
the_subtitle( '<p class="woocommerce-loop-product__subtitle wp-subtitle">', '</p>' );
|
| 78 |
+
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Product Settings
|
| 83 |
+
*
|
| 84 |
+
* @since 3.1
|
| 85 |
+
*
|
| 86 |
+
* @param array $settings Settings.
|
| 87 |
+
* @return array Settings.
|
| 88 |
+
*
|
| 89 |
+
* @internal Private. Called via the `woocommerce_product_settings` filter.
|
| 90 |
+
*/
|
| 91 |
+
public function product_settings( $settings ) {
|
| 92 |
+
|
| 93 |
+
$subtitle_settings = array(
|
| 94 |
+
|
| 95 |
+
array(
|
| 96 |
+
'title' => __( 'WP Subtitle', 'wp-subtitle' ),
|
| 97 |
+
'type' => 'title',
|
| 98 |
+
'desc' => '',
|
| 99 |
+
'id' => 'wp_subtitle_options'
|
| 100 |
+
),
|
| 101 |
+
|
| 102 |
+
array(
|
| 103 |
+
'title' => __( 'Enable Product Subtitles', 'wp-subtitle' ),
|
| 104 |
+
'desc' => __( 'Add subtitle field to product edit screen', 'wp-subtitle' ),
|
| 105 |
+
'id' => 'wp_subtitle_woocommerce_enabled',
|
| 106 |
+
'default' => 'no',
|
| 107 |
+
'type' => 'checkbox',
|
| 108 |
+
),
|
| 109 |
+
|
| 110 |
+
array(
|
| 111 |
+
'title' => __( 'Subtitle Display', 'wp-subtitle' ),
|
| 112 |
+
'desc' => __( 'Show on single product pages', 'wp-subtitle' ),
|
| 113 |
+
'id' => 'wp_subtitle_woocommerce_show_on_single',
|
| 114 |
+
'default' => 'yes',
|
| 115 |
+
'type' => 'checkbox',
|
| 116 |
+
'checkboxgroup' => 'start'
|
| 117 |
+
),
|
| 118 |
+
|
| 119 |
+
array(
|
| 120 |
+
'desc' => __( 'Show on product archives', 'wp-subtitle' ),
|
| 121 |
+
'id' => 'wp_subtitle_woocommerce_show_in_loop',
|
| 122 |
+
'default' => 'yes',
|
| 123 |
+
'type' => 'checkbox',
|
| 124 |
+
'checkboxgroup' => 'end'
|
| 125 |
+
),
|
| 126 |
+
|
| 127 |
+
array(
|
| 128 |
+
'type' => 'sectionend',
|
| 129 |
+
'id' => 'wp_subtitle_options'
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
);
|
| 133 |
+
|
| 134 |
+
return array_merge( $settings, $subtitle_settings );
|
| 135 |
+
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
}
|
includes/compat/wordpress-seo.php
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* @package WP Subtitle
|
| 5 |
+
* @subpackage WordPress SEO
|
| 6 |
+
*
|
| 7 |
+
* @since 3.1
|
| 8 |
+
*
|
| 9 |
+
* Compatibility for the Yoast SEO plugin:
|
| 10 |
+
* https://wordpress.org/plugins/wordpress-seo/
|
| 11 |
+
*
|
| 12 |
+
* Adds support for a `%%wps_subtitle%%` placeholder to include
|
| 13 |
+
* the subtitle in browser titles and meta descriptions.
|
| 14 |
+
*
|
| 15 |
+
* Also adds `%%wps_subtitle_before_sep%%` and `%%wps_subtitle_after_sep%%`.
|
| 16 |
+
* These can be used to add seperators before/after the subtitle. If there
|
| 17 |
+
* is no subtitle set these placeholders will not be output.
|
| 18 |
+
*
|
| 19 |
+
* The seperator placeholders can be customized using the `wps_subtitle_seo_before_sep`
|
| 20 |
+
* and `wps_subtitle_seo_after_sep` filters.
|
| 21 |
+
*
|
| 22 |
+
* The seperator placeholders include a 'space' either side by default. This means that
|
| 23 |
+
* you should create your title template with no whitespace around the seperator placeholders.
|
| 24 |
+
* It allows you to customize the seperators to include commas and butt the seperator up to
|
| 25 |
+
* the preceding/following text.
|
| 26 |
+
*
|
| 27 |
+
* e.g. If '%%wps_subtitle_before_sep%%' is set to ', ':
|
| 28 |
+
* `%%title%%%%wps_subtitle_before_sep%%%%wps_subtitle%% %%sep%% %%sitename%%`
|
| 29 |
+
* "Title, Subtitle - Sitename"
|
| 30 |
+
*/
|
| 31 |
+
|
| 32 |
+
class WPSubtitle_WPSEO {
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Constructor
|
| 36 |
+
*
|
| 37 |
+
* @since 3.1
|
| 38 |
+
*
|
| 39 |
+
* @internal Do not create multiple instances.
|
| 40 |
+
*/
|
| 41 |
+
public function __construct() {
|
| 42 |
+
|
| 43 |
+
add_filter( 'wpseo_replacements', array( $this, 'add_wpseo_replacements' ) );
|
| 44 |
+
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Add SEO Replacements
|
| 49 |
+
*
|
| 50 |
+
* @since 3.1
|
| 51 |
+
*
|
| 52 |
+
* @param array $replacements SEO replacements.
|
| 53 |
+
* @return array Filtered replacements.
|
| 54 |
+
*
|
| 55 |
+
* @internal Called via the `wpseo_replacements` filter.
|
| 56 |
+
*/
|
| 57 |
+
public function add_wpseo_replacements( $replacements ) {
|
| 58 |
+
|
| 59 |
+
global $post;
|
| 60 |
+
|
| 61 |
+
$wp_subtitle = new WP_Subtitle( $post );
|
| 62 |
+
$subtitle = $wp_subtitle->get_subtitle();
|
| 63 |
+
|
| 64 |
+
$replacements['%%wps_subtitle%%'] = $subtitle;
|
| 65 |
+
$replacements['%%wps_subtitle_before_sep%%'] = '';
|
| 66 |
+
$replacements['%%wps_subtitle_after_sep%%'] = '';
|
| 67 |
+
|
| 68 |
+
if ( ! empty( $subtitle ) ) {
|
| 69 |
+
|
| 70 |
+
$sep = isset( $replacements['%%sep%%'] ) ? ' ' . $replacements['%%sep%%'] . ' ' : ' - ';
|
| 71 |
+
|
| 72 |
+
$replacements['%%wps_subtitle_before_sep%%'] = apply_filters( 'wps_subtitle_seo_before_sep', $sep );
|
| 73 |
+
$replacements['%%wps_subtitle_after_sep%%'] = apply_filters( 'wps_subtitle_seo_after_sep', $sep );
|
| 74 |
+
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
return $replacements;
|
| 78 |
+
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
}
|
includes/rest.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
* @package WP Subtitle
|
| 5 |
* @subpackage REST API
|
| 6 |
*
|
| 7 |
-
* @since 3.
|
| 8 |
*/
|
| 9 |
|
| 10 |
class WPSubtitle_REST {
|
|
@@ -12,7 +12,7 @@ class WPSubtitle_REST {
|
|
| 12 |
/**
|
| 13 |
* Constructor
|
| 14 |
*
|
| 15 |
-
* @since 3.
|
| 16 |
*
|
| 17 |
* @internal Do not create multiple instances.
|
| 18 |
*/
|
|
@@ -25,7 +25,7 @@ class WPSubtitle_REST {
|
|
| 25 |
/**
|
| 26 |
* Register REST Field
|
| 27 |
*
|
| 28 |
-
* @since 3.
|
| 29 |
*
|
| 30 |
* @internal Called via the `rest_api_init` action.
|
| 31 |
*/
|
|
@@ -48,7 +48,7 @@ class WPSubtitle_REST {
|
|
| 48 |
/**
|
| 49 |
* Get REST Field
|
| 50 |
*
|
| 51 |
-
* @since 3.
|
| 52 |
*
|
| 53 |
* @internal Called via register_rest_field() callback.
|
| 54 |
*
|
| 4 |
* @package WP Subtitle
|
| 5 |
* @subpackage REST API
|
| 6 |
*
|
| 7 |
+
* @since 3.1
|
| 8 |
*/
|
| 9 |
|
| 10 |
class WPSubtitle_REST {
|
| 12 |
/**
|
| 13 |
* Constructor
|
| 14 |
*
|
| 15 |
+
* @since 3.1
|
| 16 |
*
|
| 17 |
* @internal Do not create multiple instances.
|
| 18 |
*/
|
| 25 |
/**
|
| 26 |
* Register REST Field
|
| 27 |
*
|
| 28 |
+
* @since 3.1
|
| 29 |
*
|
| 30 |
* @internal Called via the `rest_api_init` action.
|
| 31 |
*/
|
| 48 |
/**
|
| 49 |
* Get REST Field
|
| 50 |
*
|
| 51 |
+
* @since 3.1
|
| 52 |
*
|
| 53 |
* @internal Called via register_rest_field() callback.
|
| 54 |
*
|
languages/wp-subtitle.pot
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
|
|
| 1 |
msgid ""
|
| 2 |
msgstr ""
|
| 3 |
"Project-Id-Version: WP Subtitle\n"
|
| 4 |
-
"POT-Creation-Date:
|
| 5 |
"PO-Revision-Date: \n"
|
| 6 |
"Last-Translator: Ben Huson <ben@thewhiteroom.net>\n"
|
| 7 |
"Language-Team: \n"
|
|
@@ -10,25 +11,50 @@ msgstr ""
|
|
| 10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
| 11 |
"Content-Transfer-Encoding: 8bit\n"
|
| 12 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
| 13 |
-
"X-Generator: Poedit
|
| 14 |
"X-Poedit-SourceCharset: UTF-8\n"
|
| 15 |
"X-Poedit-KeywordsList: __;_e;_x;_ex\n"
|
| 16 |
"X-Poedit-Basepath: .\n"
|
| 17 |
"X-Poedit-SearchPath-0: ..\n"
|
| 18 |
|
| 19 |
-
#: ../admin/admin.php:
|
|
|
|
| 20 |
msgid "Subtitle"
|
| 21 |
msgstr ""
|
| 22 |
|
| 23 |
-
#: ../admin/admin.php:
|
| 24 |
msgid "Enter subtitle here"
|
| 25 |
msgstr ""
|
| 26 |
|
| 27 |
-
#: ../admin/pointers.php:
|
| 28 |
#, php-format
|
| 29 |
msgid "%s Field"
|
| 30 |
msgstr ""
|
| 31 |
|
| 32 |
-
#: ../admin/pointers.php:
|
| 33 |
msgid "This field has moved from a meta box to below the post title."
|
| 34 |
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#, fuzzy
|
| 2 |
msgid ""
|
| 3 |
msgstr ""
|
| 4 |
"Project-Id-Version: WP Subtitle\n"
|
| 5 |
+
"POT-Creation-Date: 2017-12-14 08:21+0000\n"
|
| 6 |
"PO-Revision-Date: \n"
|
| 7 |
"Last-Translator: Ben Huson <ben@thewhiteroom.net>\n"
|
| 8 |
"Language-Team: \n"
|
| 11 |
"Content-Type: text/plain; charset=UTF-8\n"
|
| 12 |
"Content-Transfer-Encoding: 8bit\n"
|
| 13 |
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
| 14 |
+
"X-Generator: Poedit 2.0.2\n"
|
| 15 |
"X-Poedit-SourceCharset: UTF-8\n"
|
| 16 |
"X-Poedit-KeywordsList: __;_e;_x;_ex\n"
|
| 17 |
"X-Poedit-Basepath: .\n"
|
| 18 |
"X-Poedit-SearchPath-0: ..\n"
|
| 19 |
|
| 20 |
+
#: ../admin/admin.php:130 ../admin/admin.php:138 ../admin/admin.php:191
|
| 21 |
+
#: ../admin/admin.php:262
|
| 22 |
msgid "Subtitle"
|
| 23 |
msgstr ""
|
| 24 |
|
| 25 |
+
#: ../admin/admin.php:301 ../admin/admin.php:328
|
| 26 |
msgid "Enter subtitle here"
|
| 27 |
msgstr ""
|
| 28 |
|
| 29 |
+
#: ../admin/pointers.php:149
|
| 30 |
#, php-format
|
| 31 |
msgid "%s Field"
|
| 32 |
msgstr ""
|
| 33 |
|
| 34 |
+
#: ../admin/pointers.php:150
|
| 35 |
msgid "This field has moved from a meta box to below the post title."
|
| 36 |
msgstr ""
|
| 37 |
+
|
| 38 |
+
#: ../includes/compat/woocommerce.php:96
|
| 39 |
+
msgid "WP Subtitle"
|
| 40 |
+
msgstr ""
|
| 41 |
+
|
| 42 |
+
#: ../includes/compat/woocommerce.php:103
|
| 43 |
+
msgid "Enable Product Subtitles"
|
| 44 |
+
msgstr ""
|
| 45 |
+
|
| 46 |
+
#: ../includes/compat/woocommerce.php:104
|
| 47 |
+
msgid "Add subtitle field to product edit screen"
|
| 48 |
+
msgstr ""
|
| 49 |
+
|
| 50 |
+
#: ../includes/compat/woocommerce.php:111
|
| 51 |
+
msgid "Subtitle Display"
|
| 52 |
+
msgstr ""
|
| 53 |
+
|
| 54 |
+
#: ../includes/compat/woocommerce.php:112
|
| 55 |
+
msgid "Show on single product pages"
|
| 56 |
+
msgstr ""
|
| 57 |
+
|
| 58 |
+
#: ../includes/compat/woocommerce.php:120
|
| 59 |
+
msgid "Show on product archives"
|
| 60 |
+
msgstr ""
|
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.8
|
| 7 |
-
Stable tag: 3.
|
| 8 |
License: GPLv2
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
| 10 |
|
|
@@ -102,6 +102,12 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 102 |
|
| 103 |
= Unreleased =
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
= 3.0 =
|
| 106 |
* Make `wps_subtitle` available via WordPress REST API.
|
| 107 |
|
|
@@ -110,7 +116,7 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 110 |
|
| 111 |
= 2.9 =
|
| 112 |
* Add support for post revisions. Props [Fabian Marz](https://github.com/fabianmarz).
|
| 113 |
-
* As of WordPress 4.3 no need to esc_attr() AND htmlentities() - can mess up special characters.
|
| 114 |
|
| 115 |
= 2.8.1 =
|
| 116 |
* Fix PHP warning - `get_admin_subtitle_value()` should be declared static.
|
|
@@ -182,6 +188,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 182 |
|
| 183 |
== Upgrade Notice ==
|
| 184 |
|
|
|
|
|
|
|
|
|
|
| 185 |
= 3.0 =
|
| 186 |
* Make `wps_subtitle` available via WordPress REST API.
|
| 187 |
|
| 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.9.8
|
| 7 |
+
Stable tag: 3.1
|
| 8 |
License: GPLv2
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
| 10 |
|
| 102 |
|
| 103 |
= Unreleased =
|
| 104 |
|
| 105 |
+
= 3.1 =
|
| 106 |
+
* Added `%%wps_subtitle%%` placeholders for Yoast SEO compatibility.
|
| 107 |
+
* WooCommerce compatibility. Go to `WooCommerce > Settings > Products > Display` for settings.
|
| 108 |
+
* Added `wps_subtitle_field_position` filter to show subtitle admin field `before_title`, `after_title` or in meta box.
|
| 109 |
+
* Use metabox UI if editing in Gutenberg.
|
| 110 |
+
|
| 111 |
= 3.0 =
|
| 112 |
* Make `wps_subtitle` available via WordPress REST API.
|
| 113 |
|
| 116 |
|
| 117 |
= 2.9 =
|
| 118 |
* Add support for post revisions. Props [Fabian Marz](https://github.com/fabianmarz).
|
| 119 |
+
* As of WordPress 4.3 no need to `esc_attr()` AND `htmlentities()` - can mess up special characters.
|
| 120 |
|
| 121 |
= 2.8.1 =
|
| 122 |
* Fix PHP warning - `get_admin_subtitle_value()` should be declared static.
|
| 188 |
|
| 189 |
== Upgrade Notice ==
|
| 190 |
|
| 191 |
+
= 3.1 =
|
| 192 |
+
WooCommerce compatibility: Go to `WooCommerce > Settings > Products > Display` for settings. Yoast SEO compatibility: Added `%%wps_subtitle%%` placeholders. Gutenberg compatibility: Add metabox UI.
|
| 193 |
+
|
| 194 |
= 3.0 =
|
| 195 |
* Make `wps_subtitle` available via WordPress REST API.
|
| 196 |
|
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: 3.
|
| 8 |
Author: Ben Huson, Husani Oakley
|
| 9 |
Author URI: https://github.com/benhuson/wp-subtitle
|
| 10 |
License: GPLv2
|
|
@@ -42,6 +42,8 @@ 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() ) {
|
|
@@ -65,20 +67,40 @@ class WPSubtitle {
|
|
| 65 |
/**
|
| 66 |
* REST API
|
| 67 |
*
|
| 68 |
-
* @since 3.
|
| 69 |
*
|
| 70 |
* @var WPSubtitle_REST|null
|
| 71 |
*/
|
| 72 |
private static $rest = null;
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
/**
|
| 75 |
* Load
|
| 76 |
*
|
| 77 |
-
* @since 3.
|
| 78 |
*/
|
| 79 |
public static function load() {
|
| 80 |
|
| 81 |
self::$rest = new WPSubtitle_REST();
|
|
|
|
|
|
|
| 82 |
|
| 83 |
}
|
| 84 |
|
| 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.1
|
| 8 |
Author: Ben Huson, Husani Oakley
|
| 9 |
Author URI: https://github.com/benhuson/wp-subtitle
|
| 10 |
License: GPLv2
|
| 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 |
+
include_once( WPSUBTITLE_DIR . 'includes/compat/wordpress-seo.php' );
|
| 46 |
+
include_once( WPSUBTITLE_DIR . 'includes/compat/woocommerce.php' );
|
| 47 |
|
| 48 |
// Include admin-only functionality
|
| 49 |
if ( is_admin() ) {
|
| 67 |
/**
|
| 68 |
* REST API
|
| 69 |
*
|
| 70 |
+
* @since 3.1
|
| 71 |
*
|
| 72 |
* @var WPSubtitle_REST|null
|
| 73 |
*/
|
| 74 |
private static $rest = null;
|
| 75 |
|
| 76 |
+
/**
|
| 77 |
+
* WP SEO (plugin compatibility)
|
| 78 |
+
*
|
| 79 |
+
* @since 3.1
|
| 80 |
+
*
|
| 81 |
+
* @var WPSubtitle_WPSEO|null
|
| 82 |
+
*/
|
| 83 |
+
private static $wpseo = null;
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* WooCommerce
|
| 87 |
+
*
|
| 88 |
+
* @since 3.1
|
| 89 |
+
*
|
| 90 |
+
* @var WPSubtitle_WooCommerce|null
|
| 91 |
+
*/
|
| 92 |
+
private static $woocommerce = null;
|
| 93 |
+
|
| 94 |
/**
|
| 95 |
* Load
|
| 96 |
*
|
| 97 |
+
* @since 3.1
|
| 98 |
*/
|
| 99 |
public static function load() {
|
| 100 |
|
| 101 |
self::$rest = new WPSubtitle_REST();
|
| 102 |
+
self::$wpseo = new WPSubtitle_WPSEO();
|
| 103 |
+
self::$woocommerce = new WPSubtitle_WooCommerce();
|
| 104 |
|
| 105 |
}
|
| 106 |
|
