PageRenderTime 34ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-content/themes/notepad/functions.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 112 lines | 79 code | 19 blank | 14 comment | 11 complexity | b21b3afc2b4a914cb248a7e711c9474a MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @package WordPress
  4. * @subpackage Notepad
  5. */
  6. // Theme colors and content width
  7. $themecolors = array(
  8. 'bg' => 'fafad3',
  9. 'border' => '644527',
  10. 'text' => '6F5E4E',
  11. 'link' => '6F5E4E',
  12. 'url' => '6F5E4E'
  13. );
  14. $content_width = 500;
  15. // Automatic feed links
  16. add_theme_support( 'automatic-feed-links' );
  17. // Register support for nav menus
  18. register_nav_menus( array(
  19. 'primary' => __( 'Primary Menu', 'notepad-theme' ),
  20. ) );
  21. // Filter the default page menu
  22. function notepad_page_menu_args( $args ) {
  23. $args['show_home'] = true;
  24. return $args;
  25. }
  26. add_filter( 'wp_page_menu_args', 'notepad_page_menu_args' );
  27. // Add ID and CLASS attributes to the first <ul> occurence in wp_page_menu
  28. function add_menuclass($ulclass) {
  29. return preg_replace('/<ul>/', '<ul class="menu">', $ulclass, 1);
  30. }
  31. add_filter('wp_page_menu','add_menuclass');
  32. //sidebar widgets
  33. if ( function_exists('register_sidebar') ) {
  34. register_sidebar(array(
  35. 'name' => __( 'Sidebar', 'notepad-theme' ),
  36. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  37. 'after_widget' => '</div>',
  38. 'before_title' => '<h4 class="widgettitle">',
  39. 'after_title' => '</h4>',
  40. ));
  41. }
  42. // Make [...] link to posts (from search results page)
  43. function new_excerpt_more($more) {
  44. global $post;
  45. return ' <a href="' . get_permalink() . '" class="excerpt-more-link">' . '[&hellip;]' . '</a>';
  46. }
  47. add_filter('excerpt_more', 'new_excerpt_more');
  48. function resize_youtube( $content ) {
  49. if ( strpos( $content, "width='425' height='350'></embed>" ) != -1 )
  50. return str_replace( "width='425' height='350'></embed>", "width='240' height='197'></embed>", $content );
  51. }
  52. add_filter( 'the_content', 'resize_youtube', 999 );
  53. // Grab our theme options
  54. require_once ( get_template_directory() . '/theme-options.php' );
  55. //custom comment template
  56. function mytheme_comment( $comment, $args, $depth ) {
  57. $GLOBALS['comment'] = $comment; ?>
  58. <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
  59. <p class="comment-author">
  60. <?php echo get_avatar( $comment, $size='48' ); ?>
  61. <?php printf(__( '<cite>%s</cite>' ), get_comment_author_link() ) ?><br />
  62. <small>
  63. <strong><?php comment_date( 'M d, Y' ); ?></strong> @ <?php comment_time( 'H:i:s' ); ?>
  64. <?php edit_comment_link( 'Edit',' [',']' ) ?>
  65. </small>
  66. </p>
  67. <?php if ( '' == $comment->comment_type ) : ?>
  68. <div class="commententry" id="comment-<?php comment_ID() ?>">
  69. <?php if ( $comment->comment_approved == '0' ) : ?>
  70. <p>
  71. <em>
  72. <?php _e( 'Your comment is awaiting moderation.' ) ?>
  73. </em>
  74. </p>
  75. <?php endif; ?>
  76. <?php comment_text() ?>
  77. </div>
  78. <p class="reply">
  79. <?php comment_reply_link( array_merge( $args, array( 'add_below' => 'commententry', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ) ?>
  80. </p>
  81. <?php endif; ?>
  82. <?php
  83. }
  84. // Custom background
  85. add_custom_background();
  86. function notepad_custom_background() {
  87. if ( '' != get_background_color() || '' != get_background_image() ) { ?>
  88. <style type="text/css">
  89. html { background-image: none; }
  90. </style>
  91. <?php }
  92. }
  93. add_action( 'wp_head', 'notepad_custom_background' );