Version Description
- Add [wp_subtitle] shortcode.
- Declare methods as public or private.
- Do not use variable for textdomain - causes issues for parsers.
Download this release
Release Info
| Developer | husobj |
| Plugin | |
| Version | 2.5 |
| Comparing to | |
| See all releases | |
Code changes from version 2.4.1 to 2.5
- admin/admin.php +18 -18
- admin/pointers.php +11 -8
- includes/shortcode.php +121 -0
- languages/wp-subtitle.pot +6 -6
- readme.txt +10 -2
- wp-subtitle.php +10 -11
admin/admin.php
CHANGED
|
@@ -15,7 +15,7 @@ class WPSubtitle_Admin {
|
|
| 15 |
* @since 2.2
|
| 16 |
* @internal
|
| 17 |
*/
|
| 18 |
-
static function _setup() {
|
| 19 |
|
| 20 |
// Language
|
| 21 |
load_plugin_textdomain( 'wp-subtitle', false, dirname( WPSUBTITLE_BASENAME ) . '/languages' );
|
|
@@ -30,7 +30,7 @@ class WPSubtitle_Admin {
|
|
| 30 |
* @since 2.3
|
| 31 |
* @internal
|
| 32 |
*/
|
| 33 |
-
static function _admin_init() {
|
| 34 |
|
| 35 |
global $pagenow;
|
| 36 |
|
|
@@ -47,7 +47,7 @@ class WPSubtitle_Admin {
|
|
| 47 |
|
| 48 |
// Setup Field / Meta Box
|
| 49 |
if ( WPSubtitle::is_supported_post_type( $post_type ) ) {
|
| 50 |
-
if (
|
| 51 |
add_action( 'admin_head', array( 'WPSubtitle_Admin', '_add_admin_styles' ) );
|
| 52 |
add_action( 'edit_form_after_title', array( 'WPSubtitle_Admin', '_add_subtitle_field' ) );
|
| 53 |
} else {
|
|
@@ -76,7 +76,7 @@ class WPSubtitle_Admin {
|
|
| 76 |
foreach ( $columns as $column => $value ) {
|
| 77 |
$new_columns[ $column ] = $value;
|
| 78 |
if ( 'title' == $column ) {
|
| 79 |
-
$new_columns['wps_subtitle'] = __( 'Subtitle',
|
| 80 |
}
|
| 81 |
}
|
| 82 |
|
|
@@ -106,7 +106,7 @@ class WPSubtitle_Admin {
|
|
| 106 |
* @since 2.2
|
| 107 |
* @internal
|
| 108 |
*/
|
| 109 |
-
static function _add_admin_styles() {
|
| 110 |
?>
|
| 111 |
<style>
|
| 112 |
#subtitlediv.top {
|
|
@@ -146,8 +146,8 @@ class WPSubtitle_Admin {
|
|
| 146 |
*
|
| 147 |
* @uses apply_filters( 'wps_meta_box_title' )
|
| 148 |
*/
|
| 149 |
-
static function get_meta_box_title( $post_type ) {
|
| 150 |
-
return apply_filters( 'wps_meta_box_title', __( 'Subtitle',
|
| 151 |
}
|
| 152 |
|
| 153 |
/**
|
|
@@ -160,10 +160,10 @@ class WPSubtitle_Admin {
|
|
| 160 |
* @uses apply_filters( 'wps_meta_box_title' )
|
| 161 |
* @uses WPSubtitle_Admin::_add_subtitle_meta_box()
|
| 162 |
*/
|
| 163 |
-
static function _add_meta_boxes() {
|
| 164 |
$post_types = WPSubtitle::get_supported_post_types();
|
| 165 |
foreach ( $post_types as $post_type ) {
|
| 166 |
-
add_meta_box( 'wps_subtitle_panel',
|
| 167 |
}
|
| 168 |
}
|
| 169 |
|
|
@@ -176,7 +176,7 @@ class WPSubtitle_Admin {
|
|
| 176 |
* @uses WPSubtitle::_get_post_meta()
|
| 177 |
* @uses apply_filters( 'wps_subtitle_field_description' )
|
| 178 |
*/
|
| 179 |
-
static function _add_subtitle_meta_box() {
|
| 180 |
global $post;
|
| 181 |
echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />';
|
| 182 |
echo '<input type="text" id="wpsubtitle" name="wps_subtitle" value="' . esc_attr( WPSubtitle::_get_post_meta( $post->ID ) ) . '" style="width:99%;" />';
|
|
@@ -192,12 +192,12 @@ class WPSubtitle_Admin {
|
|
| 192 |
* @uses WPSubtitle::_get_post_meta()
|
| 193 |
* @uses apply_filters( 'wps_subtitle_field_description' )
|
| 194 |
*/
|
| 195 |
-
static function _add_subtitle_field() {
|
| 196 |
global $post;
|
| 197 |
echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />';
|
| 198 |
echo '<div id="subtitlediv" class="top">';
|
| 199 |
echo '<div id="subtitlewrap">';
|
| 200 |
-
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',
|
| 201 |
echo '</div>';
|
| 202 |
|
| 203 |
// Description
|
|
@@ -218,7 +218,7 @@ class WPSubtitle_Admin {
|
|
| 218 |
*
|
| 219 |
* @param int $post_id Post ID or object.
|
| 220 |
*/
|
| 221 |
-
static function _save_post( $post_id ) {
|
| 222 |
|
| 223 |
// Verify if this is an auto save routine.
|
| 224 |
// If it is our form has not been submitted, so we dont want to do anything
|
|
@@ -227,12 +227,12 @@ class WPSubtitle_Admin {
|
|
| 227 |
}
|
| 228 |
|
| 229 |
// Verify nonce
|
| 230 |
-
if ( !
|
| 231 |
return;
|
| 232 |
}
|
| 233 |
|
| 234 |
// Check edit capability
|
| 235 |
-
if ( !
|
| 236 |
return;
|
| 237 |
}
|
| 238 |
|
|
@@ -251,7 +251,7 @@ class WPSubtitle_Admin {
|
|
| 251 |
* @param int $post_id Post ID.
|
| 252 |
* @return bool
|
| 253 |
*/
|
| 254 |
-
static function _verify_post_edit_capability( $post_id ) {
|
| 255 |
|
| 256 |
$post_types_obj = (array) get_post_types( array(
|
| 257 |
'_builtin' => false
|
|
@@ -281,7 +281,7 @@ class WPSubtitle_Admin {
|
|
| 281 |
* @param string $action Nonce action.
|
| 282 |
* @return bool
|
| 283 |
*/
|
| 284 |
-
static function _verify_posted_nonce( $nonce, $action ) {
|
| 285 |
if ( isset( $_POST[ $nonce ] ) && wp_verify_nonce( $_POST[ $nonce ], $action ) ) {
|
| 286 |
return true;
|
| 287 |
}
|
|
@@ -296,7 +296,7 @@ class WPSubtitle_Admin {
|
|
| 296 |
* @param string $post_type Post type.
|
| 297 |
* @return bool
|
| 298 |
*/
|
| 299 |
-
static function edit_form_after_title_supported( $post_type = '' ) {
|
| 300 |
global $wp_version;
|
| 301 |
|
| 302 |
if ( version_compare( $wp_version, '3.5', '<' ) ) {
|
| 15 |
* @since 2.2
|
| 16 |
* @internal
|
| 17 |
*/
|
| 18 |
+
public static function _setup() {
|
| 19 |
|
| 20 |
// Language
|
| 21 |
load_plugin_textdomain( 'wp-subtitle', false, dirname( WPSUBTITLE_BASENAME ) . '/languages' );
|
| 30 |
* @since 2.3
|
| 31 |
* @internal
|
| 32 |
*/
|
| 33 |
+
public static function _admin_init() {
|
| 34 |
|
| 35 |
global $pagenow;
|
| 36 |
|
| 47 |
|
| 48 |
// Setup Field / Meta Box
|
| 49 |
if ( WPSubtitle::is_supported_post_type( $post_type ) ) {
|
| 50 |
+
if ( self::edit_form_after_title_supported( $post_type ) ) {
|
| 51 |
add_action( 'admin_head', array( 'WPSubtitle_Admin', '_add_admin_styles' ) );
|
| 52 |
add_action( 'edit_form_after_title', array( 'WPSubtitle_Admin', '_add_subtitle_field' ) );
|
| 53 |
} else {
|
| 76 |
foreach ( $columns as $column => $value ) {
|
| 77 |
$new_columns[ $column ] = $value;
|
| 78 |
if ( 'title' == $column ) {
|
| 79 |
+
$new_columns['wps_subtitle'] = __( 'Subtitle', 'wp-subtitle' );
|
| 80 |
}
|
| 81 |
}
|
| 82 |
|
| 106 |
* @since 2.2
|
| 107 |
* @internal
|
| 108 |
*/
|
| 109 |
+
public static function _add_admin_styles() {
|
| 110 |
?>
|
| 111 |
<style>
|
| 112 |
#subtitlediv.top {
|
| 146 |
*
|
| 147 |
* @uses apply_filters( 'wps_meta_box_title' )
|
| 148 |
*/
|
| 149 |
+
public static function get_meta_box_title( $post_type ) {
|
| 150 |
+
return apply_filters( 'wps_meta_box_title', __( 'Subtitle', 'wp-subtitle' ), $post_type );
|
| 151 |
}
|
| 152 |
|
| 153 |
/**
|
| 160 |
* @uses apply_filters( 'wps_meta_box_title' )
|
| 161 |
* @uses WPSubtitle_Admin::_add_subtitle_meta_box()
|
| 162 |
*/
|
| 163 |
+
public static function _add_meta_boxes() {
|
| 164 |
$post_types = WPSubtitle::get_supported_post_types();
|
| 165 |
foreach ( $post_types as $post_type ) {
|
| 166 |
+
add_meta_box( 'wps_subtitle_panel', self::get_meta_box_title( $post_type ), array( 'WPSubtitle_Admin', '_add_subtitle_meta_box' ), $post_type, 'normal', 'high' );
|
| 167 |
}
|
| 168 |
}
|
| 169 |
|
| 176 |
* @uses WPSubtitle::_get_post_meta()
|
| 177 |
* @uses apply_filters( 'wps_subtitle_field_description' )
|
| 178 |
*/
|
| 179 |
+
public static function _add_subtitle_meta_box() {
|
| 180 |
global $post;
|
| 181 |
echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />';
|
| 182 |
echo '<input type="text" id="wpsubtitle" name="wps_subtitle" value="' . esc_attr( WPSubtitle::_get_post_meta( $post->ID ) ) . '" style="width:99%;" />';
|
| 192 |
* @uses WPSubtitle::_get_post_meta()
|
| 193 |
* @uses apply_filters( 'wps_subtitle_field_description' )
|
| 194 |
*/
|
| 195 |
+
public static function _add_subtitle_field() {
|
| 196 |
global $post;
|
| 197 |
echo '<input type="hidden" name="wps_noncename" id="wps_noncename" value="' . wp_create_nonce( 'wp-subtitle' ) . '" />';
|
| 198 |
echo '<div id="subtitlediv" class="top">';
|
| 199 |
echo '<div id="subtitlewrap">';
|
| 200 |
+
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' ) ) ) . '" />';
|
| 201 |
echo '</div>';
|
| 202 |
|
| 203 |
// Description
|
| 218 |
*
|
| 219 |
* @param int $post_id Post ID or object.
|
| 220 |
*/
|
| 221 |
+
public static function _save_post( $post_id ) {
|
| 222 |
|
| 223 |
// Verify if this is an auto save routine.
|
| 224 |
// If it is our form has not been submitted, so we dont want to do anything
|
| 227 |
}
|
| 228 |
|
| 229 |
// Verify nonce
|
| 230 |
+
if ( ! self::_verify_posted_nonce( 'wps_noncename', 'wp-subtitle' ) ) {
|
| 231 |
return;
|
| 232 |
}
|
| 233 |
|
| 234 |
// Check edit capability
|
| 235 |
+
if ( ! self::_verify_post_edit_capability( $post_id ) ) {
|
| 236 |
return;
|
| 237 |
}
|
| 238 |
|
| 251 |
* @param int $post_id Post ID.
|
| 252 |
* @return bool
|
| 253 |
*/
|
| 254 |
+
private static function _verify_post_edit_capability( $post_id ) {
|
| 255 |
|
| 256 |
$post_types_obj = (array) get_post_types( array(
|
| 257 |
'_builtin' => false
|
| 281 |
* @param string $action Nonce action.
|
| 282 |
* @return bool
|
| 283 |
*/
|
| 284 |
+
private static function _verify_posted_nonce( $nonce, $action ) {
|
| 285 |
if ( isset( $_POST[ $nonce ] ) && wp_verify_nonce( $_POST[ $nonce ], $action ) ) {
|
| 286 |
return true;
|
| 287 |
}
|
| 296 |
* @param string $post_type Post type.
|
| 297 |
* @return bool
|
| 298 |
*/
|
| 299 |
+
private static function edit_form_after_title_supported( $post_type = '' ) {
|
| 300 |
global $wp_version;
|
| 301 |
|
| 302 |
if ( version_compare( $wp_version, '3.5', '<' ) ) {
|
admin/pointers.php
CHANGED
|
@@ -15,7 +15,7 @@ class WPSubtitle_Pointers {
|
|
| 15 |
* @since 2.2
|
| 16 |
* @internal
|
| 17 |
*/
|
| 18 |
-
static function _setup() {
|
| 19 |
add_action( 'admin_enqueue_scripts', array( 'WPSubtitle_Pointers', '_pointer_load' ) );
|
| 20 |
|
| 21 |
// Post Pointers
|
|
@@ -33,7 +33,7 @@ class WPSubtitle_Pointers {
|
|
| 33 |
*
|
| 34 |
* @param string $hook_suffix Page hook.
|
| 35 |
*/
|
| 36 |
-
static function _pointer_load( $hook_suffix ) {
|
| 37 |
|
| 38 |
// Don't run on WP < 3.3
|
| 39 |
if ( get_bloginfo( 'version' ) < '3.3' ) {
|
|
@@ -65,10 +65,11 @@ class WPSubtitle_Pointers {
|
|
| 65 |
* Get pointers for the current aadmin screen.
|
| 66 |
*
|
| 67 |
* @since 2.4
|
|
|
|
| 68 |
*
|
| 69 |
* @return array Current screen pointers.
|
| 70 |
*/
|
| 71 |
-
|
| 72 |
|
| 73 |
$screen = get_current_screen();
|
| 74 |
$pointers = apply_filters( 'wps_subtitle_admin_pointers-' . $screen->id, array() );
|
|
@@ -86,11 +87,12 @@ class WPSubtitle_Pointers {
|
|
| 86 |
* Remove Dismissed Pointers
|
| 87 |
*
|
| 88 |
* @since 2.4
|
|
|
|
| 89 |
*
|
| 90 |
* @param array $pointers Pointers.
|
| 91 |
* @return array Active pointers.
|
| 92 |
*/
|
| 93 |
-
|
| 94 |
|
| 95 |
$dismissed = self::get_dismissed_pointers();
|
| 96 |
$valid_pointers = array();
|
|
@@ -117,10 +119,11 @@ class WPSubtitle_Pointers {
|
|
| 117 |
* Get Dismissed Pointers
|
| 118 |
*
|
| 119 |
* @since 2.4
|
|
|
|
| 120 |
*
|
| 121 |
* @return array Dismissed pointers.
|
| 122 |
*/
|
| 123 |
-
|
| 124 |
|
| 125 |
return explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
|
| 126 |
|
|
@@ -136,15 +139,15 @@ class WPSubtitle_Pointers {
|
|
| 136 |
* @param array $pointers Pointers.
|
| 137 |
* @return array Pointers.
|
| 138 |
*/
|
| 139 |
-
static function _post_type_pointers( $pointers ) {
|
| 140 |
|
| 141 |
// Subtitle field moved to below the post title (v.2.2)
|
| 142 |
$pointers['wps_subtitle_field_to_top'] = array(
|
| 143 |
'target' => '#subtitlewrap',
|
| 144 |
'options' => array(
|
| 145 |
'content' => sprintf( '<h3>%s</h3><p>%s</p>',
|
| 146 |
-
sprintf( __( '%s Field',
|
| 147 |
-
__( 'This field has moved from a meta box to below the post title.',
|
| 148 |
),
|
| 149 |
'position' => array(
|
| 150 |
'edge' => 'top',
|
| 15 |
* @since 2.2
|
| 16 |
* @internal
|
| 17 |
*/
|
| 18 |
+
public static function _setup() {
|
| 19 |
add_action( 'admin_enqueue_scripts', array( 'WPSubtitle_Pointers', '_pointer_load' ) );
|
| 20 |
|
| 21 |
// Post Pointers
|
| 33 |
*
|
| 34 |
* @param string $hook_suffix Page hook.
|
| 35 |
*/
|
| 36 |
+
public static function _pointer_load( $hook_suffix ) {
|
| 37 |
|
| 38 |
// Don't run on WP < 3.3
|
| 39 |
if ( get_bloginfo( 'version' ) < '3.3' ) {
|
| 65 |
* Get pointers for the current aadmin screen.
|
| 66 |
*
|
| 67 |
* @since 2.4
|
| 68 |
+
* @internal
|
| 69 |
*
|
| 70 |
* @return array Current screen pointers.
|
| 71 |
*/
|
| 72 |
+
private static function get_current_pointers() {
|
| 73 |
|
| 74 |
$screen = get_current_screen();
|
| 75 |
$pointers = apply_filters( 'wps_subtitle_admin_pointers-' . $screen->id, array() );
|
| 87 |
* Remove Dismissed Pointers
|
| 88 |
*
|
| 89 |
* @since 2.4
|
| 90 |
+
* @internal
|
| 91 |
*
|
| 92 |
* @param array $pointers Pointers.
|
| 93 |
* @return array Active pointers.
|
| 94 |
*/
|
| 95 |
+
private static function remove_dismissed_pointers( $pointers ) {
|
| 96 |
|
| 97 |
$dismissed = self::get_dismissed_pointers();
|
| 98 |
$valid_pointers = array();
|
| 119 |
* Get Dismissed Pointers
|
| 120 |
*
|
| 121 |
* @since 2.4
|
| 122 |
+
* @internal
|
| 123 |
*
|
| 124 |
* @return array Dismissed pointers.
|
| 125 |
*/
|
| 126 |
+
private static function get_dismissed_pointers() {
|
| 127 |
|
| 128 |
return explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
|
| 129 |
|
| 139 |
* @param array $pointers Pointers.
|
| 140 |
* @return array Pointers.
|
| 141 |
*/
|
| 142 |
+
public static function _post_type_pointers( $pointers ) {
|
| 143 |
|
| 144 |
// Subtitle field moved to below the post title (v.2.2)
|
| 145 |
$pointers['wps_subtitle_field_to_top'] = array(
|
| 146 |
'target' => '#subtitlewrap',
|
| 147 |
'options' => array(
|
| 148 |
'content' => sprintf( '<h3>%s</h3><p>%s</p>',
|
| 149 |
+
sprintf( __( '%s Field', 'wp-subtitle' ), WPSubtitle_Admin::get_meta_box_title( get_post_type( get_queried_object_id() ) ) ),
|
| 150 |
+
__( 'This field has moved from a meta box to below the post title.', 'wp-subtitle' )
|
| 151 |
),
|
| 152 |
'position' => array(
|
| 153 |
'edge' => 'top',
|
includes/shortcode.php
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
add_shortcode( 'wp_subtitle', array( 'WPSubtitle_Shortcode', 'shortcode' ) );
|
| 4 |
+
|
| 5 |
+
class WPSubtitle_Shortcode {
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* [wp_subtitle] Shortcode
|
| 9 |
+
*
|
| 10 |
+
* @since 2.5
|
| 11 |
+
*
|
| 12 |
+
* Outputs the post subtitle.
|
| 13 |
+
*
|
| 14 |
+
* If the [wp_subtitle] shortcode tag is wrapped around content, that
|
| 15 |
+
* content will be used as a fallback if no subtitle is specified.
|
| 16 |
+
* e.g. [wp_subtitle]Fallback Subtitle[/wp_subtitle]
|
| 17 |
+
*
|
| 18 |
+
* @param array $atts Shortcode attributes.
|
| 19 |
+
* @param string $content Fallback content (content between the shortcode tags).
|
| 20 |
+
* @return string Subtitle HTML.
|
| 21 |
+
*/
|
| 22 |
+
public static function shortcode( $atts, $content = null ) {
|
| 23 |
+
|
| 24 |
+
global $post;
|
| 25 |
+
|
| 26 |
+
$atts = shortcode_atts( array(
|
| 27 |
+
'tag' => self::get_default_tag(),
|
| 28 |
+
'before' => '',
|
| 29 |
+
'after' => ''
|
| 30 |
+
), $atts, 'wp_subtitle' );
|
| 31 |
+
|
| 32 |
+
// Get HTML tag
|
| 33 |
+
if ( ! empty( $atts['tag'] ) ) {
|
| 34 |
+
$tag = self::validate_tag( $atts['tag'] );
|
| 35 |
+
$before = sprintf( '<%s class="wp-subtitle">', $tag );
|
| 36 |
+
$after = sprintf( '</%s>', $tag );
|
| 37 |
+
} else {
|
| 38 |
+
$before = '';
|
| 39 |
+
$after = '';
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
// Add before/after content
|
| 43 |
+
$before .= self::format_subtitle_content( $atts['before'], 'before' );
|
| 44 |
+
$after = self::format_subtitle_content( $atts['after'], 'after' ) . $after;
|
| 45 |
+
|
| 46 |
+
return get_the_subtitle( $post->ID, $before, $after, false );
|
| 47 |
+
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Get Default Tag
|
| 52 |
+
*
|
| 53 |
+
* @since 2.5
|
| 54 |
+
* @internal
|
| 55 |
+
*
|
| 56 |
+
* @return string Default tag.
|
| 57 |
+
*/
|
| 58 |
+
private static function get_default_tag() {
|
| 59 |
+
|
| 60 |
+
return 'p';
|
| 61 |
+
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Get Allowed Tags
|
| 66 |
+
*
|
| 67 |
+
* @since 2.5
|
| 68 |
+
* @internal
|
| 69 |
+
*
|
| 70 |
+
* @return array Allowed HTML tags.
|
| 71 |
+
*/
|
| 72 |
+
private static function get_allowed_tags() {
|
| 73 |
+
|
| 74 |
+
return array( 'span', 'div', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' );
|
| 75 |
+
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Validate Tag
|
| 80 |
+
*
|
| 81 |
+
* Returns validated tag. Reverts to default if invalid.
|
| 82 |
+
*
|
| 83 |
+
* @since 2.5
|
| 84 |
+
* @internal
|
| 85 |
+
*
|
| 86 |
+
* @param string $tag Tag to validate.
|
| 87 |
+
* @return string Validated tag.
|
| 88 |
+
*/
|
| 89 |
+
private static function validate_tag( $tag ) {
|
| 90 |
+
|
| 91 |
+
if ( ! in_array( $tag, self::get_allowed_tags() ) ) {
|
| 92 |
+
$tag = self::get_default_tag();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
return $tag;
|
| 96 |
+
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* Format Subtitle Content
|
| 101 |
+
*
|
| 102 |
+
* @since 2.5
|
| 103 |
+
* @internal
|
| 104 |
+
*
|
| 105 |
+
* @param string $content Content.
|
| 106 |
+
* @param string $type Content type.
|
| 107 |
+
* @return string HTML formatted content.
|
| 108 |
+
*/
|
| 109 |
+
private static function format_subtitle_content( $content, $type ) {
|
| 110 |
+
|
| 111 |
+
$type = sanitize_html_class( $type );
|
| 112 |
+
|
| 113 |
+
if ( ! empty( $content ) && ! empty( $type ) ) {
|
| 114 |
+
$content = sprintf( '<span class="wp-subtitle-%s">%s</span>', $type, $content );
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
return $content;
|
| 118 |
+
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
}
|
languages/wp-subtitle.pot
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 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 +10,25 @@ 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 1.6
|
| 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 |
msgid ""
|
| 2 |
msgstr ""
|
| 3 |
"Project-Id-Version: WP Subtitle\n"
|
| 4 |
+
"POT-Creation-Date: 2015-07-02 06:57-0000\n"
|
| 5 |
"PO-Revision-Date: \n"
|
| 6 |
"Last-Translator: Ben Huson <ben@thewhiteroom.net>\n"
|
| 7 |
"Language-Team: \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.7.6\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:79 ../admin/admin.php:150
|
| 20 |
msgid "Subtitle"
|
| 21 |
msgstr ""
|
| 22 |
|
| 23 |
+
#: ../admin/admin.php:200
|
| 24 |
msgid "Enter subtitle here"
|
| 25 |
msgstr ""
|
| 26 |
|
| 27 |
+
#: ../admin/pointers.php:146
|
| 28 |
#, php-format
|
| 29 |
msgid "%s Field"
|
| 30 |
msgstr ""
|
| 31 |
|
| 32 |
+
#: ../admin/pointers.php:147
|
| 33 |
msgid "This field has moved from a meta box to below the post title."
|
| 34 |
msgstr ""
|
readme.txt
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
Contributors: husobj, husani
|
| 3 |
Tags: subtitle, content, title, subheading, subhead, alternate title
|
| 4 |
Requires at least: 3.7
|
| 5 |
-
Tested up to: 4.
|
| 6 |
-
Stable tag: 2.
|
| 7 |
License: GPL2
|
| 8 |
|
| 9 |
Add subtitles (subheadings) to your pages, posts or custom post types.
|
|
@@ -98,6 +98,11 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 98 |
|
| 99 |
== Changelog ==
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
= 2.4.1 =
|
| 102 |
* Fix PHP notice warning on 404 error page. Props Jay Williams.
|
| 103 |
* Add a little space above subtitle field when below title field in admin.
|
|
@@ -141,6 +146,9 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 141 |
|
| 142 |
== Upgrade Notice ==
|
| 143 |
|
|
|
|
|
|
|
|
|
|
| 144 |
= 2.4.1 =
|
| 145 |
Fix PHP notice warning on 404 error page.
|
| 146 |
|
| 2 |
Contributors: husobj, husani
|
| 3 |
Tags: subtitle, content, title, subheading, subhead, alternate title
|
| 4 |
Requires at least: 3.7
|
| 5 |
+
Tested up to: 4.3
|
| 6 |
+
Stable tag: 2.5
|
| 7 |
License: GPL2
|
| 8 |
|
| 9 |
Add subtitles (subheadings) to your pages, posts or custom post types.
|
| 98 |
|
| 99 |
== Changelog ==
|
| 100 |
|
| 101 |
+
= 2.5 =
|
| 102 |
+
* Add [wp_subtitle] shortcode.
|
| 103 |
+
* Declare methods as public or private.
|
| 104 |
+
* Do not use variable for textdomain - causes issues for parsers.
|
| 105 |
+
|
| 106 |
= 2.4.1 =
|
| 107 |
* Fix PHP notice warning on 404 error page. Props Jay Williams.
|
| 108 |
* Add a little space above subtitle field when below title field in admin.
|
| 146 |
|
| 147 |
== Upgrade Notice ==
|
| 148 |
|
| 149 |
+
= 2.5 =
|
| 150 |
+
Add [wp_subtitle] shortcode. Do not use variable for textdomain - causes issues for parsers.
|
| 151 |
+
|
| 152 |
= 2.4.1 =
|
| 153 |
Fix PHP notice warning on 404 error page.
|
| 154 |
|
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 |
|
|
@@ -36,6 +36,7 @@ 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() ) {
|
|
@@ -51,15 +52,13 @@ add_action( 'init', array( 'WPSubtitle', '_add_default_post_type_support' ), 5 )
|
|
| 51 |
|
| 52 |
class WPSubtitle {
|
| 53 |
|
| 54 |
-
const TEXTDOMAIN = 'wps_subtitle';
|
| 55 |
-
|
| 56 |
/**
|
| 57 |
* Add Default Post Type Support
|
| 58 |
*
|
| 59 |
* @since 2.0
|
| 60 |
* @internal
|
| 61 |
*/
|
| 62 |
-
static function _add_default_post_type_support() {
|
| 63 |
add_post_type_support( 'page', 'wps_subtitle' );
|
| 64 |
add_post_type_support( 'post', 'wps_subtitle' );
|
| 65 |
}
|
|
@@ -71,7 +70,7 @@ class WPSubtitle {
|
|
| 71 |
*
|
| 72 |
* @return array Array of supported post types.
|
| 73 |
*/
|
| 74 |
-
static function get_supported_post_types() {
|
| 75 |
$post_types = (array) get_post_types( array(
|
| 76 |
'_builtin' => false
|
| 77 |
) );
|
|
@@ -93,8 +92,8 @@ class WPSubtitle {
|
|
| 93 |
* @param string $post_type Post Type.
|
| 94 |
* @return boolean
|
| 95 |
*/
|
| 96 |
-
static function is_supported_post_type( $post_type ) {
|
| 97 |
-
$post_types =
|
| 98 |
if ( in_array( $post_type, $post_types ) ) {
|
| 99 |
return true;
|
| 100 |
}
|
|
@@ -112,10 +111,10 @@ class WPSubtitle {
|
|
| 112 |
* @param int|object $post Post ID or object.
|
| 113 |
* @return string The filtered subtitle meta value.
|
| 114 |
*/
|
| 115 |
-
static function get_the_subtitle( $post = 0 ) {
|
| 116 |
$post = get_post( $post );
|
| 117 |
-
if ( $post &&
|
| 118 |
-
$subtitle =
|
| 119 |
return apply_filters( 'wps_subtitle', $subtitle, $post );
|
| 120 |
}
|
| 121 |
return '';
|
|
@@ -130,7 +129,7 @@ class WPSubtitle {
|
|
| 130 |
* @param int|object $post Post ID or object.
|
| 131 |
* @return string The subtitle meta value.
|
| 132 |
*/
|
| 133 |
-
static function _get_post_meta( $id = 0 ) {
|
| 134 |
$post = get_post( $id );
|
| 135 |
return get_post_meta( $post->ID, 'wps_subtitle', true );
|
| 136 |
}
|
| 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.5
|
| 10 |
License: GPLv2
|
| 11 |
*/
|
| 12 |
|
| 36 |
|
| 37 |
// Includes
|
| 38 |
include_once( WPSUBTITLE_DIR . 'includes/deprecated.php' );
|
| 39 |
+
include_once( WPSUBTITLE_DIR . 'includes/shortcode.php' );
|
| 40 |
|
| 41 |
// Include admin-only functionality
|
| 42 |
if ( is_admin() ) {
|
| 52 |
|
| 53 |
class WPSubtitle {
|
| 54 |
|
|
|
|
|
|
|
| 55 |
/**
|
| 56 |
* Add Default Post Type Support
|
| 57 |
*
|
| 58 |
* @since 2.0
|
| 59 |
* @internal
|
| 60 |
*/
|
| 61 |
+
public static function _add_default_post_type_support() {
|
| 62 |
add_post_type_support( 'page', 'wps_subtitle' );
|
| 63 |
add_post_type_support( 'post', 'wps_subtitle' );
|
| 64 |
}
|
| 70 |
*
|
| 71 |
* @return array Array of supported post types.
|
| 72 |
*/
|
| 73 |
+
public static function get_supported_post_types() {
|
| 74 |
$post_types = (array) get_post_types( array(
|
| 75 |
'_builtin' => false
|
| 76 |
) );
|
| 92 |
* @param string $post_type Post Type.
|
| 93 |
* @return boolean
|
| 94 |
*/
|
| 95 |
+
public static function is_supported_post_type( $post_type ) {
|
| 96 |
+
$post_types = self::get_supported_post_types();
|
| 97 |
if ( in_array( $post_type, $post_types ) ) {
|
| 98 |
return true;
|
| 99 |
}
|
| 111 |
* @param int|object $post Post ID or object.
|
| 112 |
* @return string The filtered subtitle meta value.
|
| 113 |
*/
|
| 114 |
+
public static function get_the_subtitle( $post = 0 ) {
|
| 115 |
$post = get_post( $post );
|
| 116 |
+
if ( $post && self::is_supported_post_type( $post->post_type ) ) {
|
| 117 |
+
$subtitle = self::_get_post_meta( $post );
|
| 118 |
return apply_filters( 'wps_subtitle', $subtitle, $post );
|
| 119 |
}
|
| 120 |
return '';
|
| 129 |
* @param int|object $post Post ID or object.
|
| 130 |
* @return string The subtitle meta value.
|
| 131 |
*/
|
| 132 |
+
public static function _get_post_meta( $id = 0 ) {
|
| 133 |
$post = get_post( $id );
|
| 134 |
return get_post_meta( $post->ID, 'wps_subtitle', true );
|
| 135 |
}
|
