PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/news/library/functions/meta.php

https://bitbucket.org/lgorence/quickpress
PHP | 66 lines | 23 code | 10 blank | 33 comment | 3 complexity | b50da1c3492847c929785a7d0bdd8ef5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. /**
  3. * Metadata functions used in the core framework. This file registers meta keys for use in WordPress
  4. * in a safe manner by setting up a custom sanitize callback.
  5. *
  6. * @package HybridCore
  7. * @subpackage Functions
  8. * @author Justin Tadlock <justin@justintadlock.com>
  9. * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
  10. * @link http://themehybrid.com/hybrid-core
  11. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  12. */
  13. /* Register meta on the 'init' hook. */
  14. add_action( 'init', 'hybrid_register_meta' );
  15. /**
  16. * Registers the framework's custom metadata keys and sets up the sanitize callback function.
  17. *
  18. * @since 1.3.0
  19. * @return void
  20. */
  21. function hybrid_register_meta() {
  22. /* Register meta if the theme supports the 'hybrid-core-seo' feature. */
  23. if ( current_theme_supports( 'hybrid-core-seo' ) ) {
  24. /* Register 'Title', 'Description', and 'Keywords' meta for posts. */
  25. register_meta( 'post', 'Title', 'hybrid_sanitize_meta' );
  26. register_meta( 'post', 'Description', 'hybrid_sanitize_meta' );
  27. register_meta( 'post', 'Keywords', 'hybrid_sanitize_meta' );
  28. /* Register 'Title', 'Description', and 'Keywords' meta for users. */
  29. register_meta( 'user', 'Title', 'hybrid_sanitize_meta' );
  30. register_meta( 'user', 'Description', 'hybrid_sanitize_meta' );
  31. register_meta( 'user', 'Keywords', 'hybrid_sanitize_meta' );
  32. }
  33. /* Register meta if the theme supports the 'hybrid-core-template-hierarchy' feature. */
  34. if ( current_theme_supports( 'hybrid-core-template-hierarchy' ) ) {
  35. $post_types = get_post_types( array( 'public' => true ) );
  36. foreach ( $post_types as $post_type ) {
  37. if ( 'page' !== $post_type )
  38. register_meta( 'post', "_wp_{$post_type}_template", 'hybrid_sanitize_meta' );
  39. }
  40. }
  41. }
  42. /**
  43. * Callback function for sanitizing meta when add_metadata() or update_metadata() is called by WordPress.
  44. * If a developer wants to set up a custom method for sanitizing the data, they should use the
  45. * "sanitize_{$meta_type}_meta_{$meta_key}" filter hook to do so.
  46. *
  47. * @since 1.3.0
  48. * @param mixed $meta_value The value of the data to sanitize.
  49. * @param string $meta_key The meta key name.
  50. * @param string $meta_type The type of metadata (post, comment, user, etc.)
  51. * @return mixed $meta_value
  52. */
  53. function hybrid_sanitize_meta( $meta_value, $meta_key, $meta_type ) {
  54. return strip_tags( $meta_value );
  55. }
  56. ?>