Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.locallylost.com/themes/hybrid-core/trunk@944 dba0f204-706d-4bc1-bc29-8b92e0485636
- Loading branch information
greenshady
committed
Dec 9, 2011
1 parent
9a737cc
commit 77235ea
Showing
1 changed file
with
63 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,63 @@ | ||
<?php | ||
/** | ||
* Metadata functions used in the core framework. This file registers meta keys for use in WordPress | ||
* in a safe manner by setting up a custom sanitize callback. | ||
* | ||
* @package HybridCore | ||
* @subpackage Functions | ||
* @author Justin Tadlock <justin@justintadlock.com> | ||
* @copyright Copyright (c) 2008 - 2011, Justin Tadlock | ||
* @link http://themehybrid.com/hybrid-core | ||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | ||
*/ | ||
|
||
/* Register meta on the 'init' hook. */ | ||
add_action( 'init', 'hybrid_register_meta' ); | ||
|
||
/** | ||
* Registers the framework's custom metadata keys and sets up the sanitize callback function. | ||
* | ||
* @since 1.3.0 | ||
* @return void | ||
*/ | ||
function hybrid_register_meta() { | ||
|
||
/* Register meta if the theme supports the 'hybrid-core-seo' feature. */ | ||
if ( current_theme_supports( 'hybrid-core-seo' ) ) { | ||
|
||
/* Register 'Title', 'Description', and 'Keywords' meta for posts. */ | ||
register_meta( 'post', 'Title', 'hybrid_sanitize_meta' ); | ||
register_meta( 'post', 'Description', 'hybrid_sanitize_meta' ); | ||
register_meta( 'post', 'Keywords', 'hybrid_sanitize_meta' ); | ||
|
||
/* Register 'Title', 'Description', and 'Keywords' meta for users. */ | ||
register_meta( 'user', 'Title', 'hybrid_sanitize_meta' ); | ||
register_meta( 'user', 'Description', 'hybrid_sanitize_meta' ); | ||
register_meta( 'user', 'Keywords', 'hybrid_sanitize_meta' ); | ||
} | ||
|
||
if ( current_theme_supports( 'hybrid-core-template-hierarchy' ) ) { | ||
|
||
$post_types = get_post_types( array( 'public' => true ) ); | ||
|
||
foreach ( $post_types as $post_type ) | ||
register_meta( 'post', "_wp_{$post_type}_template", 'hybrid_sanitize_meta' ); | ||
} | ||
} | ||
|
||
/** | ||
* Callback function for sanitizing meta when add_metadata() or update_metadata() is called by WordPress. | ||
* If a developer wants to set up a custom method for sanitizing the data, they should use the | ||
* "sanitize_{$meta_type}_meta_{$meta_key}" filter hook to do so. | ||
* | ||
* @since 1.3.0 | ||
* @param mixed $meta_value The value of the data to sanitize. | ||
* @param string $meta_key The meta key name. | ||
* @param string $meta_type The type of metadata (post, comment, user, etc.) | ||
* @return mixed $meta_value | ||
*/ | ||
function hybrid_sanitize_meta( $meta_value, $meta_key, $meta_type ) { | ||
return strip_tags( $meta_value ); | ||
} | ||
|
||
?> |