options-functions.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. function foto_custom_css() {
  3. if (of_get_option('foto_custom_css')) {
  4. echo "<!-- Custom Styling -->\n<style type=\"text/css\">\n" . esc_html( of_get_option( 'foto_custom_css' ) ) . "\n</style>\n";
  5. }
  6. }
  7. add_action('wp_head', 'foto_custom_css', 10);
  8. /**
  9. * Output favicon from theme options
  10. *
  11. * @since 0.0.1
  12. */
  13. function foto_custom_favicon() {
  14. if ( of_get_option( 'foto_custom_favicon' ) )
  15. echo '<link rel="shortcut icon" href="'. esc_url( of_get_option( 'foto_custom_favicon' ) ) .'">'."\n";
  16. }
  17. add_action( 'wp_head', 'foto_custom_favicon', 5 );
  18. /**
  19. * Output analytics code in footer from theme options
  20. *
  21. * @since 0.0.1
  22. */
  23. function foto_analytics(){
  24. $output = of_get_option( 'foto_analytic_code' );
  25. if ( $output )
  26. echo "\n" . stripslashes($output) . "\n";
  27. }
  28. add_action( 'wp_footer','foto_analytics' );
  29. /*
  30. * for 'textarea' sanitization and $allowedposttags + embed and script.
  31. *
  32. * @since 0.0.1
  33. */
  34. function foto_change_santiziation() {
  35. remove_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
  36. add_filter( 'of_sanitize_textarea', 'foto_sanitize_textarea' );
  37. }
  38. add_action( 'admin_init', 'foto_change_santiziation', 100 );
  39. function foto_sanitize_textarea($input) {
  40. global $allowedposttags;
  41. $custom_allowedtags["embed"] = array(
  42. "src" => array(),
  43. "type" => array(),
  44. "allowfullscreen" => array(),
  45. "allowscriptaccess" => array(),
  46. "height" => array(),
  47. "width" => array()
  48. );
  49. $custom_allowedtags["script"] = array(
  50. "src" => array(),
  51. "type" => array()
  52. );
  53. $custom_allowedtags["meta"] = array(
  54. "name" => array(),
  55. "content" => array()
  56. );
  57. $custom_allowedtags["link"] = array(
  58. "href" => array(),
  59. "rel" => array(),
  60. "type" => array()
  61. );
  62. $custom_allowedtags = array_merge($custom_allowedtags, $allowedposttags);
  63. $output = wp_kses( $input, $custom_allowedtags);
  64. return $output;
  65. }
  66. ?>