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

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

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 145 lines | 113 code | 23 blank | 9 comment | 12 complexity | 7bebe898f2b918482fecec809d1f528e 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 Spectrum
  5. */
  6. // Enqueue the Spectrum scripts
  7. function spectrum_script_init() {
  8. wp_enqueue_script( 'jquery' );
  9. wp_enqueue_script( 'spectrum-min', get_bloginfo( 'template_directory' ) . '/js/spectrum-min.js', array( 'jquery' ) );
  10. }
  11. add_action( 'init', 'spectrum_script_init' );
  12. // Get the Spectrum theme options
  13. require_once( get_template_directory() . '/theme-options.php' );
  14. $themecolors = array(
  15. 'bg' => 'ffffff',
  16. 'border' => 'dddddd',
  17. 'text' => '444444',
  18. 'link' => 'AC6C13',
  19. 'url' => 'AC6C13'
  20. );
  21. $content_width = 540;
  22. function spectrum_widgets_init() {
  23. register_sidebar( array(
  24. 'name' => __( 'Primary Widget Area', 'spectrum' ),
  25. 'id' => 'primary-widget-area',
  26. 'description' => __( 'The primary widget area', 'spectrum' ),
  27. 'before_widget' => '<div id="%1$s" class="widget %2$s sidebar-box">',
  28. 'after_widget' => '</div>',
  29. 'before_title' => '<div class="sidebar-title"><h4>',
  30. 'after_title' => '</h4></div>'
  31. ));
  32. }
  33. add_action( 'widgets_init', 'spectrum_widgets_init' );
  34. add_theme_support( 'automatic-feed-links' );
  35. register_nav_menus( array(
  36. 'primary' => __( 'Primary Navigation' ),
  37. ) );
  38. function spectrum_page_menu() { // fallback for primary navigation ?>
  39. <ul>
  40. <?php wp_list_pages( 'title_li=&depth=1' ); ?>
  41. </ul>
  42. <?php }
  43. add_custom_background();
  44. // Allow custom colors to clear the background image
  45. function spectrum_custom_background_color() {
  46. if ( get_background_image() == '' && get_background_color() != '' ) { ?>
  47. <style type="text/css">
  48. body {
  49. background-image: none;
  50. }
  51. </style>
  52. <?php }
  53. }
  54. add_action( 'wp_head', 'spectrum_custom_background_color' );
  55. define( 'HEADER_IMAGE', '' );
  56. define( 'HEADER_IMAGE_WIDTH', 938 );
  57. define( 'HEADER_IMAGE_HEIGHT', 150 );
  58. define( 'HEADER_TEXTCOLOR', '' );
  59. define( 'NO_HEADER_TEXT', true );
  60. function admin_header_style() {
  61. ?><style type="text/css">
  62. #headimg {
  63. width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
  64. height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
  65. }
  66. </style><?php
  67. }
  68. add_custom_image_header( '', 'admin_header_style' );
  69. // Tag Cloud
  70. function spectrum_tag_cloud( $tags ) {
  71. $tags = preg_replace_callback( "|(class='tag-link-[0-9]+)('.*?)(style='font-size: )([0-9]+)(px;')|",
  72. create_function(
  73. '$match',
  74. '$low=1; $high=10; $sz=($match[4])/(2); return "{$match[1]} tagSize-{$sz}{$match[2]}";'
  75. ),
  76. $tags );
  77. return $tags;
  78. }
  79. add_action( 'wp_tag_cloud', 'spectrum_tag_cloud' );
  80. function spectrum_date() {
  81. $date_format = get_option( 'date_format' );
  82. if ( 'd/m/Y' == $date_format ) : ?>
  83. <span class="month"><?php the_time( 'd' ); ?></span>
  84. <span class="day"><?php the_time( 'm' ); ?></span>
  85. <span class="year"><?php the_time( 'y' ); ?></span>
  86. <?php elseif ( 'm/d/Y' == $date_format ) : ?>
  87. <span class="month"><?php the_time( 'm' ); ?></span>
  88. <span class="day"><?php the_time( 'd' ); ?></span>
  89. <span class="year"><?php the_time( 'y' ); ?></span>
  90. <?php elseif ( 'Y/m/d' == $date_format ) : ?>
  91. <span class="year"><?php the_time( 'y' ); ?></span>
  92. <span class="month"><?php the_time( 'm' ); ?></span>
  93. <span class="day"><?php the_time( 'd' ); ?></span>
  94. <?php else: // all other date formats get one big span ?>
  95. <span><?php the_date(); ?></span>
  96. <?php endif;
  97. }
  98. function spectrum_comments( $comment, $args, $depth ) {
  99. $GLOBALS[ 'comment' ] = $comment; ?>
  100. <li <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?> id="comment-<?php comment_ID(); ?>">
  101. <div class="avatar-holder">
  102. <?php if ( $args[ 'avatar_size' ] != 0 ) echo get_avatar( $comment, $args[ 'avatar_size' ] ); ?>
  103. </div>
  104. <div <?php comment_class(); ?> id="div-comment-<?php comment_ID(); ?>">
  105. <div class="comment-author-and-date">
  106. <div class="comment-author">
  107. <?php printf( __( '<strong>%s</strong> <em>said:</em>' ), get_comment_author_link() ); ?>
  108. </div>
  109. <div class="commentDate">
  110. <a href="<?php comments_link(); ?> "><?php printf( __( '%1$s at %2$s' ), get_comment_date(), get_comment_time() ); ?></a>
  111. </div>
  112. </div>
  113. <div class="commentText">
  114. <?php comment_text(); ?>
  115. <?php if ( $comment->comment_approved == '0' ) : ?>
  116. <p class="waiting4Mod"><?php _e( 'Your comment is awaiting moderation.' ); ?></p>
  117. <?php endif; ?>
  118. <p class="edit-comment"><?php edit_comment_link( __( '(Edit)' ),'','' ); ?></p>
  119. <p class="reply-link"><?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'reply_text' => '', 'max_depth' => $args[ 'max_depth' ] ) ) ); ?></p>
  120. </div>
  121. </div>
  122. <?php } ?>