PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/news/library/admin/meta-box-theme-footer.php

https://bitbucket.org/lgorence/quickpress
PHP | 74 lines | 25 code | 12 blank | 37 comment | 2 complexity | 67d08a7a03ba64ca3b089e9a0285e1d0 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. /**
  3. * Creates a meta box for the theme settings page, which holds a textarea for custom footer text within
  4. * the theme. To use this feature, the theme must support the 'footer' argument for the
  5. * 'hybrid-core-theme-settings' feature.
  6. *
  7. * @package HybridCore
  8. * @subpackage Admin
  9. * @author Justin Tadlock <justin@justintadlock.com>
  10. * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
  11. * @link http://themehybrid.com/hybrid-core
  12. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  13. */
  14. /* Create the footer meta box on the 'add_meta_boxes' hook. */
  15. add_action( 'add_meta_boxes', 'hybrid_meta_box_theme_add_footer' );
  16. /* Sanitize the footer settings before adding them to the database. */
  17. add_filter( 'sanitize_option_' . hybrid_get_prefix() . '_theme_settings', 'hybrid_meta_box_theme_save_footer' );
  18. /**
  19. * Adds the core theme footer meta box to the theme settings page in the admin.
  20. *
  21. * @since 1.2.0
  22. * @return void
  23. */
  24. function hybrid_meta_box_theme_add_footer() {
  25. add_meta_box( 'hybrid-core-footer', __( 'Footer settings', 'hybrid-core' ), 'hybrid_meta_box_theme_display_footer', hybrid_get_settings_page_name(), 'normal', 'high' );
  26. }
  27. /**
  28. * Creates a meta box that allows users to customize their footer.
  29. *
  30. * @since 1.2.0
  31. * @uses wp_editor() Creates an instance of the WordPress text/content editor.
  32. * @return void
  33. */
  34. function hybrid_meta_box_theme_display_footer() {
  35. /* Add a textarea using the wp_editor() function to make it easier on users to add custom content. */
  36. wp_editor(
  37. esc_textarea( hybrid_get_setting( 'footer_insert' ) ), // Editor content.
  38. hybrid_settings_field_id( 'footer_insert' ), // Editor ID.
  39. array(
  40. 'tinymce' => false, // Don't use TinyMCE in a meta box.
  41. 'textarea_name' => hybrid_settings_field_name( 'footer_insert' )
  42. )
  43. ); ?>
  44. <p>
  45. <span class="description"><?php _e( 'You can add custom <acronym title="Hypertext Markup Language">HTML</acronym> and/or shortcodes, which will be automatically inserted into your theme.', 'hybrid-core' ); ?></span>
  46. </p>
  47. <?php }
  48. /**
  49. * Saves the footer meta box settings by filtering the "sanitize_option_{$prefix}_theme_settings" hook.
  50. *
  51. * @since 1.2.0
  52. * @param array $settings Array of theme settings passed by the Settings API for validation.
  53. * @return array $settings
  54. */
  55. function hybrid_meta_box_theme_save_footer( $settings ) {
  56. /* Make sure we kill evil scripts from users without the 'unfiltered_html' cap. */
  57. if ( isset( $settings['footer_insert'] ) && !current_user_can( 'unfiltered_html' ) )
  58. $settings['footer_insert'] = stripslashes( wp_filter_post_kses( addslashes( $settings['footer_insert'] ) ) );
  59. /* Return the theme settings. */
  60. return $settings;
  61. }
  62. ?>