Advertisement
RoseCitySister

functions.php

Sep 17th, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'after_setup_theme', 'silverblue_add_editor_styles' );
  4. add_action( 'after_setup_theme', 'silverblue_setup' );
  5. function silverblue_setup()
  6. {
  7. load_theme_textdomain( 'silverblue', get_template_directory() . '/languages' );
  8. $args = array(
  9. 'flex-width' => true,
  10. 'width' => 950,
  11. 'flex-height' => true,
  12. 'height' => 348,
  13. 'default-image' => get_template_directory_uri() . '/images/silver-blue-and-gold-sky.jpg',
  14. 'uploads' => true,
  15. );
  16. add_theme_support( 'custom-header', $args );
  17. add_theme_support( 'automatic-feed-links' );
  18. add_theme_support( 'post-thumbnails' );
  19. add_theme_support( 'custom-background' );
  20. global $content_width;
  21. if ( ! isset( $content_width ) ) $content_width = 640;
  22. register_nav_menus(
  23. array( 'main' => __( 'Main Menu', 'silverblue' ) )
  24. );
  25. }
  26.  
  27.  
  28. function silverblue_add_editor_styles() {
  29. add_editor_style( 'custom-editor-style.css' );
  30. }
  31. add_action( 'wp_enqueue_scripts', 'silverblue_load_scripts' );
  32. function silverblue_load_scripts()
  33. {
  34. wp_enqueue_script( 'jquery' );
  35. }
  36. add_action( 'comment_form_before', 'silverblue_enqueue_comment_reply_script' );
  37. function silverblue_enqueue_comment_reply_script()
  38. {
  39. if ( get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); }
  40. }
  41. add_filter( 'the_title', 'silverblue_title' );
  42. function silverblue_title( $title ) {
  43. if ( $title == '' ) {
  44. return '&rarr;';
  45. } else {
  46. return $title;
  47. }
  48. }
  49. function silverblue_customize_register( $wp_customize ) {
  50. $wp_customize->add_setting( 'dark_color' , array(
  51. 'default' => '#225a93',
  52. 'transport' => 'refresh',
  53. ) );
  54.  
  55. $wp_customize->add_section( 'silverblue_dark_color' , array(
  56. 'title' => __( 'Darker Accent Color', 'silverblue' ),
  57. 'priority' => 40,
  58. ) );
  59.  
  60. $wp_customize->add_control(
  61. new WP_Customize_Color_Control(
  62. $wp_customize,
  63. 'color',
  64. array(
  65. 'label' => __( 'Choose a color', 'silverblue' ),
  66. 'section' => 'silverblue_dark_color',
  67. 'settings' => 'dark_color',
  68. 'context' => 'normal'
  69. )
  70. ) );
  71. $wp_customize->add_setting( 'header_bgcolor' , array(
  72. 'default' => '#225a93',
  73. 'transport' => 'refresh',
  74. ) );
  75.  
  76. $wp_customize->add_section( 'silverblue_header_bgcolor' , array(
  77. 'title' => __( 'Header and Footer Background Color', 'silverblue' ),
  78. 'priority' => 30,
  79. ) );
  80.  
  81. $wp_customize->add_control(
  82. new WP_Customize_Color_Control(
  83. $wp_customize,
  84. 'color',
  85. array(
  86. 'label' => __( 'Choose a background color', 'silverblue' ),
  87. 'section' => 'silverblue_header_bgcolor',
  88. 'settings' => 'header_bgcolor',
  89. 'context' => 'normal'
  90. )
  91. )
  92. );
  93.  
  94. }
  95. add_action( 'customize_register', 'silverblue_customize_register' );
  96.  
  97. function silverblue_customize_css()
  98. {
  99. ?>
  100. <style type="text/css">
  101. #header, #footer { background-color: url(<?php echo get_theme_mod('header_bgcolor') ?>); }
  102. .entry-title, h3, .widget-title { color: <?php echo get_theme_mod('dark_color') ?>; } </style>
  103. <?php
  104. }
  105. add_action( 'wp_head', 'silverblue_customize_css');
  106. add_filter( 'wp_title', 'silverblue_filter_wp_title' );
  107. function silverblue_filter_wp_title( $title )
  108. {
  109. return $title . esc_attr( get_bloginfo( 'name' ) );
  110. }
  111. add_action( 'widgets_init', 'silverblue_widgets_init' );
  112. function silverblue_widgets_init()
  113. {
  114. register_sidebar( array (
  115. 'name' => __( 'sidebar', 'silverblue' ),
  116. 'id' => 'primary-widget-area',
  117. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  118. 'after_widget' => "</li>",
  119. 'before_title' => '<h3 class="widget-title">',
  120. 'after_title' => '</h3>',
  121. ) );
  122.  
  123. register_sidebar( array (
  124. 'name' => __('Right Widget Area', 'silverblue'),
  125. 'id' => 'secondary-widget-area',
  126. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  127. 'after_widget' => "</li>",
  128. 'before_title' => '<h3 class="widget-title">',
  129. 'after_title' => '</h3>',
  130. ) );
  131.  
  132. }
  133. function silverblue_custom_pings( $comment )
  134. {
  135. $GLOBALS['comment'] = $comment;
  136. ?>
  137. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"><?php echo comment_author_link(); ?></li>
  138. <?php
  139. }
  140. add_filter( 'get_comments_number', 'silverblue_comments_number' );
  141. function silverblue_comments_number( $count )
  142. {
  143. if ( !is_admin() ) {
  144. global $id;
  145. $comments_by_type = &separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
  146. return count( $comments_by_type['comment'] );
  147. } else {
  148. return $count;
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement