WP Subtitle - Version 2.1

Version Description

  • Ready for translation - .pot file added.
  • Only include admin functionality when needed.
  • Added deprecated function warnings if WP_DEBUG enabled.
  • Fix static method warnings.
Download this release

Release Info

Developer husobj
Plugin Icon 128x128 WP Subtitle
Version 2.1
Comparing to
See all releases

Code changes from version 2.0.1 to 2.1

Files changed (5) hide show
  1. admin/admin.php +132 -0
  2. includes/deprecated.php +69 -0
  3. languages/wp-subtitle.pot +21 -0
  4. readme.txt +12 -3
  5. wp-subtitle.php +28 -190
admin/admin.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package WP Subtitle
5
+ * @subpackage Admin
6
+ */
7
+
8
+ // Language
9
+ load_plugin_textdomain( 'wp-subtitle', false, dirname( WPSUBTITLE_BASENAME ) . '/languages' );
10
+
11
+ // Includes
12
+ add_action( 'add_meta_boxes', array( 'WPSubtitle_Admin', '_add_meta_boxes' ) );
13
+ add_action( 'save_post', array( 'WPSubtitle_Admin', '_save_post' ) );
14
+
15
+ class WPSubtitle_Admin {
16
+
17
+ /**
18
+ * Add Meta Boxes
19
+ *
20
+ * @since 2.0
21
+ * @internal
22
+ *
23
+ * @uses WPSubtitle::get_supported_post_types()
24
+ * @uses apply_filters( 'wps_meta_box_title' )
25
+ * @uses WPSubtitle_Admin::_add_subtitle_meta_box()
26
+ */
27
+ static function _add_meta_boxes() {
28
+ $post_types = WPSubtitle::get_supported_post_types();
29
+ foreach ( $post_types as $post_type ) {
30
+ $meta_box_title = apply_filters( 'wps_meta_box_title', __( 'Subtitle', 'wp-subtitle' ), $post_type );
31
+ add_meta_box( 'wps_subtitle_panel', __( $meta_box_title ), array( 'WPSubtitle_Admin', '_add_subtitle_meta_box' ), $post_type, 'normal', 'high' );
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Add Subtitle Meta Box
37
+ *
38
+ * @since 2.0
39
+ * @internal
40
+ *
41
+ * @uses WPSubtitle::_get_post_meta()
42
+ * @uses apply_filters( 'wps_subtitle_field_description' )
43
+ */
44
+ static function _add_subtitle_meta_box() {
45
+ global $post;
46
+ echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />';
47
+ echo '<input type="text" id="wpsubtitle" name="wps_subtitle" value="' . WPSubtitle::_get_post_meta( $post->ID ) . '" style="width:99%;" />';
48
+ echo apply_filters( 'wps_subtitle_field_description', '', $post );
49
+ }
50
+
51
+ /**
52
+ * Save Subtitle
53
+ *
54
+ * @since 2.0
55
+ * @internal
56
+ *
57
+ * @uses WPSubtitle::get_supported_post_types()
58
+ *
59
+ * @param int $post_id Post ID or object.
60
+ */
61
+ static function _save_post( $post_id ) {
62
+
63
+ // Verify if this is an auto save routine.
64
+ // If it is our form has not been submitted, so we dont want to do anything
65
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
66
+ return;
67
+ }
68
+
69
+ // Verify nonce
70
+ if ( ! WPSubtitle_Admin::_verify_posted_nonce( 'wps_noncename', 'wp-subtitle' ) ) {
71
+ return;
72
+ }
73
+
74
+ // Check edit capability
75
+ if ( ! WPSubtitle_Admin::_verify_post_edit_capability( $post_id ) ) {
76
+ return;
77
+ }
78
+
79
+ // Save data
80
+ if ( isset( $_POST['wps_subtitle'] ) ) {
81
+ update_post_meta( $post_id, 'wps_subtitle', $_POST['wps_subtitle'] );
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Verify Post Edit Capability
87
+ *
88
+ * @since 2.0.1
89
+ * @internal
90
+ *
91
+ * @param int $post_id Post ID.
92
+ * @return bool
93
+ */
94
+ static function _verify_post_edit_capability( $post_id ) {
95
+ $abort = true;
96
+ $post_types = WPSubtitle::get_supported_post_types();
97
+ $post_types_obj = (array) get_post_types( array(
98
+ '_builtin' => false
99
+ ), 'objects' );
100
+
101
+ // Check supported post type
102
+ if ( isset( $_POST['post_type'] ) && in_array( $_POST['post_type'], $post_types ) ) {
103
+ if ( 'page' == $_POST['post_type'] && current_user_can( 'edit_page', $post_id ) ) {
104
+ return true;
105
+ } elseif ( 'post' == $_POST['post_type'] && current_user_can( 'edit_post', $post_id ) ) {
106
+ return true;
107
+ } elseif ( current_user_can( $post_types_obj[ $_POST['post_type'] ]->cap->edit_post, $post_id ) ) {
108
+ return true;
109
+ }
110
+ }
111
+
112
+ return false;
113
+ }
114
+
115
+ /**
116
+ * Verify Posted Nonce
117
+ *
118
+ * @since 2.0.1
119
+ * @internal
120
+ *
121
+ * @param string $nonce Posted nonce name.
122
+ * @param string $action Nonce action.
123
+ * @return bool
124
+ */
125
+ static function _verify_posted_nonce( $nonce, $action ) {
126
+ if ( isset( $_POST[ $nonce ] ) && wp_verify_nonce( $_POST[ $nonce ], $action ) ) {
127
+ return true;
128
+ }
129
+ return false;
130
+ }
131
+
132
+ }
includes/deprecated.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package WP Subtitle
5
+ * @subpackage Deprecated Functions
6
+ */
7
+
8
+ /**
9
+ * Query DB and echo page/post subtitle, if any
10
+ *
11
+ * @uses WPSubtitle::_get_post_meta()
12
+ *
13
+ * @since 1.0
14
+ * @deprecated 2.0 Use get_the_subtitle() instead.
15
+ */
16
+ function wps_get_the_subtitle() {
17
+ _deprecated_function( 'wps_get_the_subtitle()', '2.0', 'the_subtitle()' );
18
+ the_subtitle();
19
+ }
20
+
21
+ /**
22
+ * Display XHTML for subtitle panel
23
+ *
24
+ * @since 1.0
25
+ * @deprecated 2.0 Legacy function.
26
+ */
27
+ function wps_addPanelXHTML() {
28
+ _deprecated_function( 'wps_addPanelXHTML()', '2.0' );
29
+ }
30
+
31
+ /**
32
+ * Include CSS for subtitle panel
33
+ *
34
+ * @since 1.0
35
+ * @deprecated 2.0 Legacy function.
36
+ */
37
+ function wps_addPanelCSS() {
38
+ _deprecated_function( 'wps_addPanelCSS()', '2.0' );
39
+ }
40
+
41
+ /**
42
+ * Include XHTML for form inside panel
43
+ *
44
+ * @since 1.0
45
+ * @deprecated 2.0 Legacy function.
46
+ */
47
+ function wps_showSubtitlePanel() {
48
+ _deprecated_function( 'wps_addPanelCSS()', '2.0' );
49
+ }
50
+
51
+ /**
52
+ * For pre-2.5, include shell for panel
53
+ *
54
+ * @since 1.0
55
+ * @deprecated 2.0 Legacy function.
56
+ */
57
+ function wps_showSubtitlePanelOld() {
58
+ _deprecated_function( 'wps_showSubtitlePanelOld()', '2.0' );
59
+ }
60
+
61
+ /**
62
+ * Store subtitle content in db as custom field
63
+ *
64
+ * @since 1.0
65
+ * @deprecated 2.0 Legacy function.
66
+ */
67
+ function wps_saveSubtitle( $post_id ) {
68
+ _deprecated_function( 'wps_saveSubtitle()', '2.0' );
69
+ }
languages/wp-subtitle.pot ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Subtitle\n"
4
+ "POT-Creation-Date: 2014-03-12 07:07-0000\n"
5
+ "PO-Revision-Date: \n"
6
+ "Last-Translator: Ben Huson <ben@thewhiteroom.net>\n"
7
+ "Language-Team: \n"
8
+ "Language: en_US\n"
9
+ "MIME-Version: 1.0\n"
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 1.6.2\n"
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:30
20
+ msgid "Subtitle"
21
+ msgstr ""
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: 3.6.1
6
- Stable tag: 2.0.1
7
  License: GPL2
8
 
9
  Add subtitles (subheadings) to your pages, posts or custom post types.
@@ -84,9 +84,15 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
84
 
85
  == Changelog ==
86
 
 
 
 
 
 
 
87
  = 2.0.1 =
88
  * Use `<?php` instead of just `<?`.
89
- * Break out some of the code into separate functions.
90
 
91
  = 2.0 =
92
  * Added custom post type support - use add_post_type_support( '{post_type}', 'wps_subtitle' ).
@@ -100,6 +106,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
100
 
101
  == Upgrade Notice ==
102
 
 
 
 
103
  = 2.0 =
104
  * Added custom post type support and support for more recent versions of WordPress.
105
 
2
  Contributors: husani, husobj
3
  Tags: subtitle, content, title, subheading, subhead, alternate title
4
  Requires at least: 3.0
5
+ Tested up to: 3.8.1
6
+ Stable tag: 2.1
7
  License: GPL2
8
 
9
  Add subtitles (subheadings) to your pages, posts or custom post types.
84
 
85
  == Changelog ==
86
 
87
+ = 2.1 =
88
+ * Ready for translation - .pot file added.
89
+ * Only include admin functionality when needed.
90
+ * Added deprecated function warnings if WP_DEBUG enabled.
91
+ * Fix static method warnings.
92
+
93
  = 2.0.1 =
94
  * Use `<?php` instead of just `<?`.
95
+ * Break out some of the code into separate functions.
96
 
97
  = 2.0 =
98
  * Added custom post type support - use add_post_type_support( '{post_type}', 'wps_subtitle' ).
106
 
107
  == Upgrade Notice ==
108
 
109
+ = 2.1 =
110
+ * Fixed static method warnings and only load admin functionality when needed.
111
+
112
  = 2.0 =
113
  * Added custom post type support and support for more recent versions of WordPress.
114
 
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.0.1
10
  License: GPLv2
11
  */
12
 
@@ -28,25 +28,27 @@ along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29
  */
30
 
31
- add_action( 'plugins_loaded', array( 'WPSubtitle', '_init' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- class WPSubtitle {
34
 
35
- /**
36
- * Init
37
- *
38
- * @since 2.0
39
- * @internal
40
- *
41
- * @uses WPSubtitle::_add_default_post_type_support()
42
- * @uses WPSubtitle::_add_meta_boxes()
43
- * @uses WPSubtitle::_save_post()
44
- */
45
- function _init() {
46
- add_action( 'init', array( 'WPSubtitle', '_add_default_post_type_support' ), 5 );
47
- add_action( 'add_meta_boxes', array( 'WPSubtitle', '_add_meta_boxes' ) );
48
- add_action( 'save_post', array( 'WPSubtitle', '_save_post' ) );
49
- }
50
 
51
  /**
52
  * Add Default Post Type Support
@@ -54,120 +56,11 @@ class WPSubtitle {
54
  * @since 2.0
55
  * @internal
56
  */
57
- function _add_default_post_type_support() {
58
  add_post_type_support( 'page', 'wps_subtitle' );
59
  add_post_type_support( 'post', 'wps_subtitle' );
60
  }
61
 
62
- /**
63
- * Add Meta Boxes
64
- *
65
- * @since 2.0
66
- * @internal
67
- *
68
- * @uses WPSubtitle::get_supported_post_types()
69
- * @uses apply_filters( 'wps_meta_box_title' )
70
- * @uses WPSubtitle::_add_subtitle_meta_box()
71
- */
72
- function _add_meta_boxes() {
73
- $post_types = WPSubtitle::get_supported_post_types();
74
- foreach ( $post_types as $post_type ) {
75
- $meta_box_title = apply_filters( 'wps_meta_box_title', 'Subtitle', $post_type );
76
- add_meta_box( 'wps_subtitle_panel', __( $meta_box_title ), array( 'WPSubtitle', '_add_subtitle_meta_box' ), $post_type, 'normal', 'high' );
77
- }
78
- }
79
-
80
- /**
81
- * Add Subtitle Meta Box
82
- *
83
- * @since 2.0
84
- * @internal
85
- *
86
- * @uses WPSubtitle::_get_post_meta()
87
- * @uses apply_filters( 'wps_subtitle_field_description' )
88
- */
89
- function _add_subtitle_meta_box() {
90
- global $post;
91
- echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />
92
- <input type="text" id="wpsubtitle" name="wps_subtitle" value="' . WPSubtitle::_get_post_meta( $post->ID ) . '" style="width:99%;" />';
93
- echo apply_filters( 'wps_subtitle_field_description', '', $post );
94
- }
95
-
96
- /**
97
- * Save Subtitle
98
- *
99
- * @since 2.0
100
- * @internal
101
- *
102
- * @uses WPSubtitle::get_supported_post_types()
103
- *
104
- * @param int $post_id Post ID or object.
105
- */
106
- function _save_post( $post_id ) {
107
-
108
- // Verify if this is an auto save routine.
109
- // If it is our form has not been submitted, so we dont want to do anything
110
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
111
- return;
112
-
113
- // Verify nonce
114
- if ( ! WPSubtitle::_verify_posted_nonce( 'wps_noncename', 'wp-subtitle' ) )
115
- return;
116
-
117
- // Check edit capability
118
- if ( ! WPSubtitle::_verify_post_edit_capability( $post_id ) )
119
- return;
120
-
121
- // Save data
122
- if ( isset( $_POST['wps_subtitle'] ) )
123
- update_post_meta( $post_id, 'wps_subtitle', $_POST['wps_subtitle'] );
124
- }
125
-
126
- /**
127
- * Verify Post Edit Capability
128
- *
129
- * @since 2.0.1
130
- * @internal
131
- *
132
- * @param int $post_id Post ID.
133
- * @return bool
134
- */
135
- function _verify_post_edit_capability( $post_id ) {
136
- $abort = true;
137
- $post_types = WPSubtitle::get_supported_post_types();
138
- $post_types_obj = (array) get_post_types( array(
139
- '_builtin' => false
140
- ), 'objects' );
141
-
142
- // Check supported post type
143
- if ( isset( $_POST['post_type'] ) && in_array( $_POST['post_type'], $post_types ) ) {
144
- if ( 'page' == $_POST['post_type'] && current_user_can( 'edit_page', $post_id ) )
145
- return true;
146
- elseif ( 'post' == $_POST['post_type'] && current_user_can( 'edit_post', $post_id ) )
147
- return true;
148
- elseif ( current_user_can( $post_types_obj[$_POST['post_type']]->cap->edit_post, $post_id ) )
149
- return true;
150
- }
151
-
152
- return false;
153
- }
154
-
155
- /**
156
- * Verify Posted Nonce
157
- *
158
- * @since 2.0.1
159
- * @internal
160
- *
161
- * @param string $nonce Posted nonce name.
162
- * @param string $action Nonce action.
163
- * @return bool
164
- */
165
- function _verify_posted_nonce( $nonce, $action ) {
166
- if ( isset( $_POST[$nonce] ) && wp_verify_nonce( $_POST[$nonce], $action ) )
167
- return true;
168
- return false;
169
- }
170
-
171
  /**
172
  * Get Supported Post Types
173
  *
@@ -175,15 +68,16 @@ class WPSubtitle {
175
  *
176
  * @return array Array of supported post types.
177
  */
178
- function get_supported_post_types() {
179
  $post_types = (array) get_post_types( array(
180
  '_builtin' => false
181
  ) );
182
  $post_types = array_merge( $post_types, array( 'post', 'page' ) );
183
  $supported = array();
184
  foreach ( $post_types as $post_type ) {
185
- if ( post_type_supports( $post_type, 'wps_subtitle' ) )
186
  $supported[] = $post_type;
 
187
  }
188
  return $supported;
189
  }
@@ -199,7 +93,7 @@ class WPSubtitle {
199
  * @param int|object $post Post ID or object.
200
  * @return string The filtered subtitle meta value.
201
  */
202
- function get_the_subtitle( $post = 0 ) {
203
  $post = get_post( $post );
204
  $subtitle = WPSubtitle::_get_post_meta( $post );
205
  return apply_filters( 'wps_subtitle', $subtitle, $post );
@@ -214,70 +108,13 @@ class WPSubtitle {
214
  * @param int|object $post Post ID or object.
215
  * @return string The subtitle meta value.
216
  */
217
- function _get_post_meta( $id = 0 ) {
218
  $post = get_post( $id );
219
  return get_post_meta( $post->ID, 'wps_subtitle', true );
220
  }
221
 
222
  }
223
 
224
- /**
225
- * Query DB and echo page/post subtitle, if any
226
- *
227
- * @uses WPSubtitle::_get_post_meta()
228
- *
229
- * @since 1.0
230
- * @deprecated 2.0 Use get_the_subtitle() instead.
231
- */
232
- function wps_get_the_subtitle() {
233
- echo WPSubtitle::_get_post_meta();
234
- }
235
-
236
- /**
237
- * Display XHTML for subtitle panel
238
- *
239
- * @since 1.0
240
- * @deprecated 2.0 Legacy function.
241
- */
242
- function wps_addPanelXHTML() {
243
- }
244
-
245
- /**
246
- * Include CSS for subtitle panel
247
- *
248
- * @since 1.0
249
- * @deprecated 2.0 Legacy function.
250
- */
251
- function wps_addPanelCSS() {
252
- }
253
-
254
- /**
255
- * Include XHTML for form inside panel
256
- *
257
- * @since 1.0
258
- * @deprecated 2.0 Legacy function.
259
- */
260
- function wps_showSubtitlePanel() {
261
- }
262
-
263
- /**
264
- * For pre-2.5, include shell for panel
265
- *
266
- * @since 1.0
267
- * @deprecated 2.0 Legacy function.
268
- */
269
- function wps_showSubtitlePanelOld() {
270
- }
271
-
272
- /**
273
- * Store subtitle content in db as custom field
274
- *
275
- * @since 1.0
276
- * @deprecated 2.0 Legacy function.
277
- */
278
- function wps_saveSubtitle( $post_id ) {
279
- }
280
-
281
  /**
282
  * The Subtitle
283
  *
@@ -314,7 +151,8 @@ function get_the_subtitle( $post = 0, $before = '', $after = '', $echo = true )
314
  $subtitle = $before . $subtitle . $after;
315
  }
316
 
317
- if ( ! $echo )
318
  return $subtitle;
 
319
  echo $subtitle;
320
  }
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.1
10
  License: GPLv2
11
  */
12
 
28
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29
  */
30
 
31
+ // Plugin directory and url paths.
32
+ define( 'WPSUBTITLE_BASENAME', plugin_basename( __FILE__ ) );
33
+ define( 'WPSUBTITLE_SUBDIR', '/' . str_replace( basename( __FILE__ ), '', WPSUBTITLE_BASENAME ) );
34
+ define( 'WPSUBTITLE_URL', plugins_url( WPSUBTITLE_SUBDIR ) );
35
+ define( 'WPSUBTITLE_DIR', plugin_dir_path( __FILE__ ) );
36
+
37
+ // Includes
38
+ include_once( WPSUBTITLE_DIR . 'includes/deprecated.php' );
39
+
40
+ // Include admin-only functionality
41
+ if ( is_admin() ) {
42
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
43
+ // Load AJAX functions here if required...
44
+ } else {
45
+ require_once( WPSUBTITLE_DIR . 'admin/admin.php' );
46
+ }
47
+ }
48
 
49
+ add_action( 'init', array( 'WPSubtitle', '_add_default_post_type_support' ), 5 );
50
 
51
+ class WPSubtitle {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  /**
54
  * Add Default Post Type Support
56
  * @since 2.0
57
  * @internal
58
  */
59
+ static function _add_default_post_type_support() {
60
  add_post_type_support( 'page', 'wps_subtitle' );
61
  add_post_type_support( 'post', 'wps_subtitle' );
62
  }
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  /**
65
  * Get Supported Post Types
66
  *
68
  *
69
  * @return array Array of supported post types.
70
  */
71
+ static function get_supported_post_types() {
72
  $post_types = (array) get_post_types( array(
73
  '_builtin' => false
74
  ) );
75
  $post_types = array_merge( $post_types, array( 'post', 'page' ) );
76
  $supported = array();
77
  foreach ( $post_types as $post_type ) {
78
+ if ( post_type_supports( $post_type, 'wps_subtitle' ) ) {
79
  $supported[] = $post_type;
80
+ }
81
  }
82
  return $supported;
83
  }
93
  * @param int|object $post Post ID or object.
94
  * @return string The filtered subtitle meta value.
95
  */
96
+ static function get_the_subtitle( $post = 0 ) {
97
  $post = get_post( $post );
98
  $subtitle = WPSubtitle::_get_post_meta( $post );
99
  return apply_filters( 'wps_subtitle', $subtitle, $post );
108
  * @param int|object $post Post ID or object.
109
  * @return string The subtitle meta value.
110
  */
111
+ static function _get_post_meta( $id = 0 ) {
112
  $post = get_post( $id );
113
  return get_post_meta( $post->ID, 'wps_subtitle', true );
114
  }
115
 
116
  }
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  /**
119
  * The Subtitle
120
  *
151
  $subtitle = $before . $subtitle . $after;
152
  }
153
 
154
+ if ( ! $echo ) {
155
  return $subtitle;
156
+ }
157
  echo $subtitle;
158
  }