Permalink
Browse files

Forgot to add the 'meta.php' file.

git-svn-id: http://svn.locallylost.com/themes/hybrid-core/trunk@944 dba0f204-706d-4bc1-bc29-8b92e0485636
  • Loading branch information...
1 parent 9a737cc commit 77235eaa68ff2b08e6e61ca272b7300910068646 greenshady committed Dec 9, 2011
Showing with 63 additions and 0 deletions.
  1. +63 −0 functions/meta.php
View
@@ -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 );
+}
+
+?>

0 comments on commit 77235ea

Please sign in to comment.