Version Description
- Use
<?phpinstead of just<?. - Break out some of the code into separate functions.
Download this release
Release Info
| Developer | husobj |
| Plugin | |
| Version | 2.0.1 |
| Comparing to | |
| See all releases | |
Code changes from version 2.0 to 2.0.1
- readme.txt +6 -2
- wp-subtitle.php +45 -12
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 |
-
Stable tag: 2.0
|
| 7 |
License: GPL2
|
| 8 |
|
| 9 |
Add subtitles (subheadings) to your pages, posts or custom post types.
|
|
@@ -84,6 +84,10 @@ The plugin is [hosted on GitHub](https://github.com/benhuson/wp-subtitle) and pu
|
|
| 84 |
|
| 85 |
== Changelog ==
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
= 2.0 =
|
| 88 |
* Added custom post type support - use add_post_type_support( '{post_type}', 'wps_subtitle' ).
|
| 89 |
* Fixed bug in more recent versions of WordPress.
|
| 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 |
|
| 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' ).
|
| 93 |
* Fixed bug in more recent versions of WordPress.
|
wp-subtitle.php
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
<?
|
| 2 |
|
| 3 |
/*
|
| 4 |
Plugin Name: WP Subtitle
|
|
@@ -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
|
| 10 |
License: GPLv2
|
| 11 |
*/
|
| 12 |
|
|
@@ -111,28 +111,61 @@ class WPSubtitle {
|
|
| 111 |
return;
|
| 112 |
|
| 113 |
// Verify nonce
|
| 114 |
-
if (
|
| 115 |
-
return
|
| 116 |
|
| 117 |
// Check edit capability
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
$abort = true;
|
| 119 |
$post_types = WPSubtitle::get_supported_post_types();
|
| 120 |
$post_types_obj = (array) get_post_types( array(
|
| 121 |
'_builtin' => false
|
| 122 |
), 'objects' );
|
|
|
|
|
|
|
| 123 |
if ( isset( $_POST['post_type'] ) && in_array( $_POST['post_type'], $post_types ) ) {
|
| 124 |
if ( 'page' == $_POST['post_type'] && current_user_can( 'edit_page', $post_id ) )
|
| 125 |
-
|
| 126 |
elseif ( 'post' == $_POST['post_type'] && current_user_can( 'edit_post', $post_id ) )
|
| 127 |
-
|
| 128 |
elseif ( current_user_can( $post_types_obj[$_POST['post_type']]->cap->edit_post, $post_id ) )
|
| 129 |
-
|
| 130 |
}
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
}
|
| 137 |
|
| 138 |
/**
|
| 1 |
+
<?php
|
| 2 |
|
| 3 |
/*
|
| 4 |
Plugin Name: 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 |
|
| 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 |
/**
|
