WP Subtitle - Version 1.0

Version Description

Download this release

Release Info

Developer husani
Plugin Icon 128x128 WP Subtitle
Version 1.0
Comparing to
See all releases

Version 1.0

admin/compat_panel.inc.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <div class="dbx-b-ox-wrapper">
2
+ <fieldset id="myplugin_fieldsetid" class="dbx-box">
3
+ <div class="dbx-h-andle-wrapper"><h3 class="dbx-handle"><?__( 'My Post Section Title', 'myplugin_textdomain' )?></h3></div>
4
+ <div class="dbx-c-ontent-wrapper"><div class="dbx-content">
5
+ <?wps_showSubtitlePanel();?>
6
+ </div></div></fieldset></div>
admin/css/panel.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ input#wpsubtitle{
2
+ position: relative;
3
+ border: 1px solid #DFDFDF;
4
+ font-size:1.5em;
5
+ outline-color:-moz-use-text-color;
6
+ outline-style:none;
7
+ outline-width:medium;
8
+ padding:3px 4px;
9
+ width:100%;
10
+ }
admin/panel.inc.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <input type="hidden" name="wps_noncename" id="wps_noncename" value="<?=wp_create_nonce('wp-subtitle')?>" />
2
+ <input type="text" id="wpsubtitle" name="wps_subtitle" value="<?wps_get_the_subtitle()?>" />
readme.txt ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP Subtitle ===
2
+ Contributors: husani
3
+ Tags: subtitle, content, title, subheading, subhead, alternate title
4
+ Donate link: http://www.husani.com/ventures/wordpress-plugins/wp-subtitle/#donate
5
+ Requires at least: 2.7
6
+ Tested up to: 2.8
7
+ Stable tag: 1.0
8
+
9
+ Add subtitles (subheadings) to your pages and posts.
10
+
11
+ == Description ==
12
+
13
+ The WP Subtitle plugin allows your pages and posts to contain a subtitle. Also called a sub-heading, this this short line of text is meant to appear beneath a post's (or page's) title, but can be inserted in your template wherever you choose.
14
+
15
+ &lt;?the_subtitle()?&gt; is used for inside The Loop -- if you wish to get a page/post's subtitle outside The Loop, use &lt;?get_the_subtitle($id)?&gt;, where $id is the page or post's ID ($post->ID).
16
+
17
+ Just like WP's built-in &lt;?the_title()?&gt; method, &lt;?the_subtitle()?&gt; tag accepts three parameters:
18
+
19
+ $before
20
+ (string) Text to place before the subtitle, defaults to "".
21
+
22
+ $after
23
+ (string) Text to place after the subtitle, defaults to "".
24
+
25
+ $display
26
+ (boolean) If true, display the subtitle in XHTML; if false, return the subtitle for use in PHP. Defaults to true.
27
+
28
+ Things are slightly different in &lt;?get_the_subtitle()?&gt;:
29
+
30
+ $id
31
+ (integer) Post (or page) ID.
32
+
33
+ $before
34
+ (string) Text to place before the subtitle, defaults to "".
35
+
36
+ $after
37
+ (string) Text to place after the subtitle, defaults to "".
38
+
39
+ $display
40
+ (boolean) If true, display the subtitle in XHTML; if false, return the subtitle for use in PHP. Defaults to true.
41
+
42
+ Changelog:
43
+
44
+ * 1.0:
45
+ - First version
46
+
47
+
48
+ == Installation ==
49
+
50
+ 1. Upload the WP Subtitle plugin to your blog (YOURBLOG/wp-content/plugins) and activate it using the Wordpress plugin admin screen.
51
+ 2. Edit your page and/or post template and add &lt;?the_subtitle()?&gt; or &lt;?get_the_subtitle()?&gt; where you'd like the subtitle to appear. Pass arguments per above instructions.
52
+
53
+ == Frequently Asked Questions ==
54
+
55
+ = How does WP Subtitle work? =
56
+
57
+ The plugin uses a WP's actions/hooks to add a custom field to posts and pages. Simple.
58
+
59
+ = Does WP Subtitle use the Wordpress database? =
60
+
61
+ Yes, all subtitles are stored as custom fields. Deactivating this plugin will not remove those firleds.
62
+
63
+ == Screenshots ==
64
+
65
+ 1. Post edit
66
+ 2. Page edit
67
+ 3. List of posts showing subtitles
68
+ 4. A single page showing a subtitle
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
wp-subtitle.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?
2
+ /*
3
+ Plugin Name: WP Subtitle
4
+ Plugin URI: http://www.husani.com/ventures/wordpress-plugins/wp-subtitle/
5
+ Description: Add a subtitle to pages and posts. Place &lt;?=the_subtitle()?&gt; where you'd like the subtitle to appear. Similar to the_title, you can pass before, after, and display arguments. Documentation included in this plugin's readme file. Get help at <a href="http://forums.husani.com/forum/wp-subtitle/" target="_blank">support forums</a> and sign up for the <a href="http://www.husani.com/ventures/wordpress-plugins/wp-subtitle/mailing-list/" target="_blank">mailing list</a> to receive updates and news about WP Subtitle. By <a href="http://www.husani.com" target="_blank">Husani Oakley</a>.
6
+ Author
7
+ Version: 1.0
8
+ */
9
+
10
+ /* Copyright 2009 Husani Oakley (email : wordpressplugins@husani.com)
11
+
12
+ This program is free software; you can redistribute it and/or modify
13
+ it under the terms of the GNU General Public License as published by
14
+ the Free Software Foundation; either version 2 of the License, or
15
+ (at your option) any later version.
16
+
17
+ This program is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU General Public License for more details.
21
+
22
+ You should have received a copy of the GNU General Public License
23
+ along with this program; if not, write to the Free Software
24
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
+ */
26
+
27
+ /**
28
+ * query db and echo page/post subtitle, if any
29
+ */
30
+ function wps_get_the_subtitle(){
31
+ global $post;
32
+ echo get_post_meta($post->ID, "wps_subtitle", true);
33
+ }
34
+
35
+ /** HOOKS */
36
+ add_action('admin_menu', 'wps_addPanelXHTML');
37
+ add_action('save_post', 'wps_saveSubtitle');
38
+
39
+ /** FUNCTIONS FOR HOOKS */
40
+
41
+ /**
42
+ * display xhtml for subtitle panel
43
+ */
44
+ function wps_addPanelXHTML(){
45
+ if( function_exists( 'add_meta_box' )) {
46
+ add_meta_box('wps_panel', 'Page Subtitle', 'wps_showSubtitlePanel', 'page', 'normal', 'high');
47
+ add_meta_box('wps_panel', 'Post Subtitle', 'wps_showSubtitlePanel', 'post', 'normal', 'high');
48
+ } else {
49
+ add_action('dbx_page_advanced', 'wps_showSubtitlePanelOld');
50
+ add_action('dbx_post_advanced', 'wps_showSubtitlePanelOld');
51
+ }
52
+ //include css if admin
53
+ if(is_admin()){
54
+ add_action('admin_print_styles', 'wps_addPanelCSS');
55
+ }
56
+ }
57
+
58
+ /**
59
+ * include CSS for subtitle panel
60
+ */
61
+ function wps_addPanelCSS(){
62
+ $css = WP_PLUGIN_URL . '/wp-subtitle/admin/css/panel.css';
63
+ wp_register_style('wps_css', $css);
64
+ wp_enqueue_style( 'wps_css');
65
+ }
66
+
67
+ /**
68
+ * include XHTML for form inside panel
69
+ */
70
+ function wps_showSubtitlePanel(){
71
+ include ABSPATH . PLUGINDIR . "/wp-subtitle/admin/panel.inc.php";
72
+ }
73
+
74
+ /**
75
+ * for pre-2.5, include shell for panel
76
+ */
77
+ function wps_showSubtitlePanelOld(){
78
+ include ABSPATH . PLUGINDIR . "/wp-subtitle/admin/compat_panel.inc.php";
79
+ }
80
+
81
+ /**
82
+ * store subtitle content in db as custom field
83
+ */
84
+ function wps_saveSubtitle($post_id){
85
+ //verify
86
+ if (!wp_verify_nonce( $_POST['wps_noncename'], 'wp-subtitle')) {
87
+ return $post_id;
88
+ }
89
+ if ('page' == $_POST['post_type']){
90
+ if (!current_user_can('edit_page', $post_id)){
91
+ return $post_id;
92
+ }
93
+ } else {
94
+ if (!current_user_can('edit_post', $post_id)){
95
+ return $post_id;
96
+ }
97
+ }
98
+ //save data
99
+ if(!update_post_meta($post_id, "wps_subtitle", $_POST["wps_subtitle"])){
100
+ add_post_meta($post_id, "wps_subtitle", $_POST["wps_subtitle"]);
101
+ }
102
+ }
103
+
104
+ /**
105
+ * return subtitle from post inside The Loop
106
+ */
107
+ function the_subtitle($before="", $after="", $display=true){
108
+ global $post;
109
+ $subtitle = $before . get_post_meta($post->ID, "wps_subtitle", true) . $after;
110
+ if($display){
111
+ echo $subtitle;
112
+ } else {
113
+ return $subtitle;
114
+ }
115
+ }
116
+
117
+ /**
118
+ * return (or display) subtitle from post with ID passed as argument
119
+ */
120
+ function get_the_subtitle($id, $before="", $after="", $display=true){
121
+ $subtitle = $before . get_post_meta($id, "wps_subtitle", true) . $after;
122
+ if($display){
123
+ echo $subtitle;
124
+ } else {
125
+ return $subtitle;
126
+ }
127
+ }
128
+
129
+
130
+ ?>