-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5cfb21f
Showing
9 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="dbx-b-ox-wrapper"> | ||
<fieldset id="myplugin_fieldsetid" class="dbx-box"> | ||
<div class="dbx-h-andle-wrapper"><h3 class="dbx-handle"><?__( 'My Post Section Title', 'myplugin_textdomain' )?></h3></div> | ||
<div class="dbx-c-ontent-wrapper"><div class="dbx-content"> | ||
<?wps_showSubtitlePanel();?> | ||
</div></div></fieldset></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
input#wpsubtitle{ | ||
position: relative; | ||
border: 1px solid #DFDFDF; | ||
font-size:1.5em; | ||
outline-color:-moz-use-text-color; | ||
outline-style:none; | ||
outline-width:medium; | ||
padding:3px 4px; | ||
width:100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<input type="hidden" name="wps_noncename" id="wps_noncename" value="<?=wp_create_nonce('wp-subtitle')?>" /> | ||
<input type="text" id="wpsubtitle" name="wps_subtitle" value="<?wps_get_the_subtitle()?>" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
=== WP Subtitle === | ||
Contributors: husani | ||
Tags: subtitle, content, title, subheading, subhead, alternate title | ||
Donate link: http://www.husani.com/ventures/wordpress-plugins/wp-subtitle/#donate | ||
Requires at least: 2.7 | ||
Tested up to: 2.8 | ||
Stable tag: 1.0 | ||
|
||
Add subtitles (subheadings) to your pages and posts. | ||
|
||
== Description == | ||
|
||
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. | ||
|
||
<?the_subtitle()?> is used for inside The Loop -- if you wish to get a page/post's subtitle outside The Loop, use <?get_the_subtitle($id)?>, where $id is the page or post's ID ($post->ID). | ||
|
||
Just like WP's built-in <?the_title()?> method, <?the_subtitle()?> tag accepts three parameters: | ||
|
||
$before | ||
(string) Text to place before the subtitle, defaults to "". | ||
|
||
$after | ||
(string) Text to place after the subtitle, defaults to "". | ||
|
||
$display | ||
(boolean) If true, display the subtitle in XHTML; if false, return the subtitle for use in PHP. Defaults to true. | ||
|
||
Things are slightly different in <?get_the_subtitle()?>: | ||
|
||
$id | ||
(integer) Post (or page) ID. | ||
|
||
$before | ||
(string) Text to place before the subtitle, defaults to "". | ||
|
||
$after | ||
(string) Text to place after the subtitle, defaults to "". | ||
|
||
$display | ||
(boolean) If true, display the subtitle in XHTML; if false, return the subtitle for use in PHP. Defaults to true. | ||
|
||
Changelog: | ||
|
||
* 1.0: | ||
- First version | ||
|
||
|
||
== Installation == | ||
|
||
1. Upload the WP Subtitle plugin to your blog (YOURBLOG/wp-content/plugins) and activate it using the Wordpress plugin admin screen. | ||
2. Edit your page and/or post template and add <?the_subtitle()?> or <?get_the_subtitle()?> where you'd like the subtitle to appear. Pass arguments per above instructions. | ||
|
||
== Frequently Asked Questions == | ||
|
||
= How does WP Subtitle work? = | ||
|
||
The plugin uses a WP's actions/hooks to add a custom field to posts and pages. Simple. | ||
|
||
= Does WP Subtitle use the Wordpress database? = | ||
|
||
Yes, all subtitles are stored as custom fields. Deactivating this plugin will not remove those firleds. | ||
|
||
== Screenshots == | ||
|
||
1. Post edit | ||
2. Page edit | ||
3. List of posts showing subtitles | ||
4. A single page showing a subtitle |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<? | ||
/* | ||
Plugin Name: WP Subtitle | ||
Plugin URI: http://www.husani.com/ventures/wordpress-plugins/wp-subtitle/ | ||
Description: Add a subtitle to pages and posts. Place <?=the_subtitle()?> 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>. | ||
Author | ||
Version: 1.0 | ||
*/ | ||
|
||
/* Copyright 2009 Husani Oakley (email : [email protected]) | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
/** | ||
* query db and echo page/post subtitle, if any | ||
*/ | ||
function wps_get_the_subtitle(){ | ||
global $post; | ||
echo get_post_meta($post->ID, "wps_subtitle", true); | ||
} | ||
|
||
/** HOOKS */ | ||
add_action('admin_menu', 'wps_addPanelXHTML'); | ||
add_action('save_post', 'wps_saveSubtitle'); | ||
|
||
/** FUNCTIONS FOR HOOKS */ | ||
|
||
/** | ||
* display xhtml for subtitle panel | ||
*/ | ||
function wps_addPanelXHTML(){ | ||
if( function_exists( 'add_meta_box' )) { | ||
add_meta_box('wps_panel', 'Page Subtitle', 'wps_showSubtitlePanel', 'page', 'normal', 'high'); | ||
add_meta_box('wps_panel', 'Post Subtitle', 'wps_showSubtitlePanel', 'post', 'normal', 'high'); | ||
} else { | ||
add_action('dbx_page_advanced', 'wps_showSubtitlePanelOld'); | ||
add_action('dbx_post_advanced', 'wps_showSubtitlePanelOld'); | ||
} | ||
//include css if admin | ||
if(is_admin()){ | ||
add_action('admin_print_styles', 'wps_addPanelCSS'); | ||
} | ||
} | ||
|
||
/** | ||
* include CSS for subtitle panel | ||
*/ | ||
function wps_addPanelCSS(){ | ||
$css = WP_PLUGIN_URL . '/wp-subtitle/admin/css/panel.css'; | ||
wp_register_style('wps_css', $css); | ||
wp_enqueue_style( 'wps_css'); | ||
} | ||
|
||
/** | ||
* include XHTML for form inside panel | ||
*/ | ||
function wps_showSubtitlePanel(){ | ||
include ABSPATH . PLUGINDIR . "/wp-subtitle/admin/panel.inc.php"; | ||
} | ||
|
||
/** | ||
* for pre-2.5, include shell for panel | ||
*/ | ||
function wps_showSubtitlePanelOld(){ | ||
include ABSPATH . PLUGINDIR . "/wp-subtitle/admin/compat_panel.inc.php"; | ||
} | ||
|
||
/** | ||
* store subtitle content in db as custom field | ||
*/ | ||
function wps_saveSubtitle($post_id){ | ||
//verify | ||
if (!wp_verify_nonce( $_POST['wps_noncename'], 'wp-subtitle')) { | ||
return $post_id; | ||
} | ||
if ('page' == $_POST['post_type']){ | ||
if (!current_user_can('edit_page', $post_id)){ | ||
return $post_id; | ||
} | ||
} else { | ||
if (!current_user_can('edit_post', $post_id)){ | ||
return $post_id; | ||
} | ||
} | ||
//save data | ||
if(!update_post_meta($post_id, "wps_subtitle", $_POST["wps_subtitle"])){ | ||
add_post_meta($post_id, "wps_subtitle", $_POST["wps_subtitle"]); | ||
} | ||
} | ||
|
||
/** | ||
* return subtitle from post inside The Loop | ||
*/ | ||
function the_subtitle($before="", $after="", $display=true){ | ||
global $post; | ||
$subtitle = $before . get_post_meta($post->ID, "wps_subtitle", true) . $after; | ||
if($display){ | ||
echo $subtitle; | ||
} else { | ||
return $subtitle; | ||
} | ||
} | ||
|
||
/** | ||
* return (or display) subtitle from post with ID passed as argument | ||
*/ | ||
function get_the_subtitle($id, $before="", $after="", $display=true){ | ||
$subtitle = $before . get_post_meta($id, "wps_subtitle", true) . $after; | ||
if($display){ | ||
echo $subtitle; | ||
} else { | ||
return $subtitle; | ||
} | ||
} | ||
|
||
|
||
?> |