Version Description
- Prevent subtitle fields from displaying on post types for which support has not been added using add_post_type_support(). Previously the fields were displayed but the subtitle would not be saved.
- Escape subtitle admin field value - fixes issues with subtitles with quotes.
Download this release
Release Info
Developer | husobj |
Plugin | WP Subtitle |
Version | 2.3 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.3
- admin/admin.php +25 -12
- readme.txt +23 -3
- wp-subtitle.php +22 -3
admin/admin.php
CHANGED
@@ -20,16 +20,30 @@ class WPSubtitle_Admin {
|
|
20 |
// Language
|
21 |
load_plugin_textdomain( 'wp-subtitle', false, dirname( WPSUBTITLE_BASENAME ) . '/languages' );
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
$post_type = isset( $_GET['post'] ) ? get_post_type( $_GET['post'] ) : '';
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
-
add_action( 'save_post', array( 'WPSubtitle_Admin', '_save_post' ) );
|
33 |
}
|
34 |
|
35 |
/**
|
@@ -110,7 +124,7 @@ class WPSubtitle_Admin {
|
|
110 |
static function _add_subtitle_meta_box() {
|
111 |
global $post;
|
112 |
echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />';
|
113 |
-
echo '<input type="text" id="wpsubtitle" name="wps_subtitle" value="' . WPSubtitle::_get_post_meta( $post->ID ) . '" style="width:99%;" />';
|
114 |
echo apply_filters( 'wps_subtitle_field_description', '', $post );
|
115 |
}
|
116 |
|
@@ -128,7 +142,7 @@ class WPSubtitle_Admin {
|
|
128 |
echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />';
|
129 |
echo '<div id="subtitlediv" class="top">';
|
130 |
echo '<div id="subtitlewrap">';
|
131 |
-
echo '<input type="text" id="wpsubtitle" name="wps_subtitle" value="' . WPSubtitle::_get_post_meta( $post->ID ) . '" autocomplete="off" placeholder="' . esc_attr( apply_filters( 'wps_subtitle_field_placeholder', __( 'Enter subtitle here', 'wp-subtitle' ) ) ) . '" />';
|
132 |
echo '</div>';
|
133 |
|
134 |
// Description
|
@@ -183,14 +197,13 @@ class WPSubtitle_Admin {
|
|
183 |
* @return bool
|
184 |
*/
|
185 |
static function _verify_post_edit_capability( $post_id ) {
|
186 |
-
|
187 |
-
$post_types = WPSubtitle::get_supported_post_types();
|
188 |
$post_types_obj = (array) get_post_types( array(
|
189 |
'_builtin' => false
|
190 |
), 'objects' );
|
191 |
|
192 |
// Check supported post type
|
193 |
-
if ( isset( $_POST['post_type'] ) &&
|
194 |
if ( 'page' == $_POST['post_type'] && current_user_can( 'edit_page', $post_id ) ) {
|
195 |
return true;
|
196 |
} elseif ( 'post' == $_POST['post_type'] && current_user_can( 'edit_post', $post_id ) ) {
|
20 |
// Language
|
21 |
load_plugin_textdomain( 'wp-subtitle', false, dirname( WPSUBTITLE_BASENAME ) . '/languages' );
|
22 |
|
23 |
+
add_action( 'admin_init', array( 'WPSubtitle_Admin', '_admin_init' ) );
|
24 |
+
add_action( 'save_post', array( 'WPSubtitle_Admin', '_save_post' ) );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Admin Init
|
29 |
+
*
|
30 |
+
* @since 2.3
|
31 |
+
* @internal
|
32 |
+
*/
|
33 |
+
static function _admin_init() {
|
34 |
+
|
35 |
$post_type = isset( $_GET['post'] ) ? get_post_type( $_GET['post'] ) : '';
|
36 |
+
|
37 |
+
// Setup Field / Meta Box
|
38 |
+
if ( WPSubtitle::is_supported_post_type( $post_type ) ) {
|
39 |
+
if ( WPSubtitle_Admin::edit_form_after_title_supported( $post_type ) ) {
|
40 |
+
add_action( 'admin_head', array( 'WPSubtitle_Admin', '_add_admin_styles' ) );
|
41 |
+
add_action( 'edit_form_after_title', array( 'WPSubtitle_Admin', '_add_subtitle_field' ) );
|
42 |
+
} else {
|
43 |
+
add_action( 'add_meta_boxes', array( 'WPSubtitle_Admin', '_add_meta_boxes' ) );
|
44 |
+
}
|
45 |
}
|
46 |
|
|
|
47 |
}
|
48 |
|
49 |
/**
|
124 |
static function _add_subtitle_meta_box() {
|
125 |
global $post;
|
126 |
echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />';
|
127 |
+
echo '<input type="text" id="wpsubtitle" name="wps_subtitle" value="' . esc_attr( WPSubtitle::_get_post_meta( $post->ID ) ) . '" style="width:99%;" />';
|
128 |
echo apply_filters( 'wps_subtitle_field_description', '', $post );
|
129 |
}
|
130 |
|
142 |
echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />';
|
143 |
echo '<div id="subtitlediv" class="top">';
|
144 |
echo '<div id="subtitlewrap">';
|
145 |
+
echo '<input type="text" id="wpsubtitle" name="wps_subtitle" value="' . esc_attr( WPSubtitle::_get_post_meta( $post->ID ) ) . '" autocomplete="off" placeholder="' . esc_attr( apply_filters( 'wps_subtitle_field_placeholder', __( 'Enter subtitle here', 'wp-subtitle' ) ) ) . '" />';
|
146 |
echo '</div>';
|
147 |
|
148 |
// Description
|
197 |
* @return bool
|
198 |
*/
|
199 |
static function _verify_post_edit_capability( $post_id ) {
|
200 |
+
|
|
|
201 |
$post_types_obj = (array) get_post_types( array(
|
202 |
'_builtin' => false
|
203 |
), 'objects' );
|
204 |
|
205 |
// Check supported post type
|
206 |
+
if ( isset( $_POST['post_type'] ) && WPSubtitle::is_supported_post_type( $_POST['post_type'] ) ) {
|
207 |
if ( 'page' == $_POST['post_type'] && current_user_can( 'edit_page', $post_id ) ) {
|
208 |
return true;
|
209 |
} elseif ( 'post' == $_POST['post_type'] && current_user_can( 'edit_post', $post_id ) ) {
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: husani, husobj
|
3 |
Tags: subtitle, content, title, subheading, subhead, alternate title
|
4 |
Requires at least: 3.0
|
5 |
-
Tested up to:
|
6 |
-
Stable tag: 2.
|
7 |
License: GPL2
|
8 |
|
9 |
Add subtitles (subheadings) to your pages, posts or custom post types.
|
@@ -43,6 +43,8 @@ Things are slightly different in `<?php get_the_subtitle(); ?>`:
|
|
43 |
|
44 |
For full details on the template tags and their arguments, [view the documentation here](https://github.com/benhuson/wp-subtitle/wiki).
|
45 |
|
|
|
|
|
46 |
== Installation ==
|
47 |
|
48 |
1. Upload the WP Subtitle plugin to your WordPress site in the `/wp-content/plugins` folder or install via the WordPress admin.
|
@@ -65,6 +67,17 @@ All subtitles are stored as post meta data. Deactivating this plugin will not re
|
|
65 |
|
66 |
Refer to [the documentation](https://github.com/benhuson/wp-subtitle/wiki).
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
= Where can I get help? =
|
69 |
|
70 |
Please post support requests and questions in the [WordPress.org Support](http://wordpress.org/support/plugin/wp-subtitle) forum.
|
@@ -83,7 +96,11 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
83 |
1. Edit post screen (for earlier versions of WordPress or using the 'wps_subtitle_use_meta_box' filter)
|
84 |
2. A single page showing a subtitle
|
85 |
|
86 |
-
== Changelog
|
|
|
|
|
|
|
|
|
87 |
|
88 |
= 2.2 =
|
89 |
* Moved subtitle field from meta box to below title field in WordPress 3.5+ (props Tor Morten)
|
@@ -111,6 +128,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
111 |
|
112 |
== Upgrade Notice ==
|
113 |
|
|
|
|
|
|
|
114 |
= 2.2 =
|
115 |
Subtitle field moved to below title field (only in WordPress 3.5+)
|
116 |
|
2 |
Contributors: husani, husobj
|
3 |
Tags: subtitle, content, title, subheading, subhead, alternate title
|
4 |
Requires at least: 3.0
|
5 |
+
Tested up to: 4.0
|
6 |
+
Stable tag: 2.3
|
7 |
License: GPL2
|
8 |
|
9 |
Add subtitles (subheadings) to your pages, posts or custom post types.
|
43 |
|
44 |
For full details on the template tags and their arguments, [view the documentation here](https://github.com/benhuson/wp-subtitle/wiki).
|
45 |
|
46 |
+
By default, subtitle are supported by both posts and pages. To add support for custom post types use add_post_type_support( 'my_post_type', 'wps_subtitle' ).
|
47 |
+
|
48 |
== Installation ==
|
49 |
|
50 |
1. Upload the WP Subtitle plugin to your WordPress site in the `/wp-content/plugins` folder or install via the WordPress admin.
|
67 |
|
68 |
Refer to [the documentation](https://github.com/benhuson/wp-subtitle/wiki).
|
69 |
|
70 |
+
= How do I add support for custom post types? =
|
71 |
+
|
72 |
+
To add support for custom post types use add_post_type_support( 'my_post_type', 'wps_subtitle' ):
|
73 |
+
|
74 |
+
`
|
75 |
+
function my_wp_subtitle_page_part_support() {
|
76 |
+
add_post_type_support( 'my_post_type', 'wps_subtitle' );
|
77 |
+
}
|
78 |
+
add_action( 'init', 'my_wp_subtitle_page_part_support' );
|
79 |
+
`
|
80 |
+
|
81 |
= Where can I get help? =
|
82 |
|
83 |
Please post support requests and questions in the [WordPress.org Support](http://wordpress.org/support/plugin/wp-subtitle) forum.
|
96 |
1. Edit post screen (for earlier versions of WordPress or using the 'wps_subtitle_use_meta_box' filter)
|
97 |
2. A single page showing a subtitle
|
98 |
|
99 |
+
== Changelog =
|
100 |
+
|
101 |
+
= 2.3 =
|
102 |
+
* Prevent subtitle fields from displaying on post types for which support has not been added using add_post_type_support(). Previously the fields were displayed but the subtitle would not be saved.
|
103 |
+
* Escape subtitle admin field value - fixes issues with subtitles with quotes.
|
104 |
|
105 |
= 2.2 =
|
106 |
* Moved subtitle field from meta box to below title field in WordPress 3.5+ (props Tor Morten)
|
128 |
|
129 |
== Upgrade Notice ==
|
130 |
|
131 |
+
= 2.3 =
|
132 |
+
Prevent subtitle fields from displaying on unsupported post types and fix issue with quotes in subtitles.
|
133 |
+
|
134 |
= 2.2 =
|
135 |
Subtitle field moved to below title field (only in WordPress 3.5+)
|
136 |
|
wp-subtitle.php
CHANGED
@@ -6,7 +6,7 @@ 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 |
Author: Husani Oakley, Ben Huson
|
8 |
Author URI: https://github.com/benhuson/wp-subtitle
|
9 |
-
Version: 2.
|
10 |
License: GPLv2
|
11 |
*/
|
12 |
|
@@ -83,6 +83,22 @@ class WPSubtitle {
|
|
83 |
return $supported;
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
/**
|
87 |
* Get the Subtitle
|
88 |
*
|
@@ -96,8 +112,11 @@ class WPSubtitle {
|
|
96 |
*/
|
97 |
static function get_the_subtitle( $post = 0 ) {
|
98 |
$post = get_post( $post );
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
/**
|
6 |
Description: Adds a subtitle field to pages and posts. Possible to add support for custom post types.
|
7 |
Author: Husani Oakley, Ben Huson
|
8 |
Author URI: https://github.com/benhuson/wp-subtitle
|
9 |
+
Version: 2.3
|
10 |
License: GPLv2
|
11 |
*/
|
12 |
|
83 |
return $supported;
|
84 |
}
|
85 |
|
86 |
+
/**
|
87 |
+
* Is Supported Post Type
|
88 |
+
*
|
89 |
+
* @since 2.3
|
90 |
+
*
|
91 |
+
* @param string $post_type Post Type.
|
92 |
+
* @return boolean
|
93 |
+
*/
|
94 |
+
static function is_supported_post_type( $post_type ) {
|
95 |
+
$post_types = WPSubtitle::get_supported_post_types();
|
96 |
+
if ( in_array( $post_type, $post_types ) ) {
|
97 |
+
return true;
|
98 |
+
}
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
|
102 |
/**
|
103 |
* Get the Subtitle
|
104 |
*
|
112 |
*/
|
113 |
static function get_the_subtitle( $post = 0 ) {
|
114 |
$post = get_post( $post );
|
115 |
+
if ( WPSubtitle::is_supported_post_type( $post->post_type ) ) {
|
116 |
+
$subtitle = WPSubtitle::_get_post_meta( $post );
|
117 |
+
return apply_filters( 'wps_subtitle', $subtitle, $post );
|
118 |
+
}
|
119 |
+
return '';
|
120 |
}
|
121 |
|
122 |
/**
|