functions.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <?php
  2. remove_action('wp_head', 'index_rel_link' );
  3. remove_action('wp_head', 'rel_canonical');
  4. remove_action('wp_head', 'start_post_rel_link', 10, 0 );
  5. remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
  6. remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 );
  7. remove_action('wp_head', 'parent_post_rel_link', 10, 0 );
  8. remove_action('wp_head', 'rsd_link');
  9. remove_action('wp_head', 'wlwmanifest_link');
  10. remove_action('wp_head', 'wp_generator');
  11. remove_action('wp_head', 'feed_links_extra', 3 );
  12. remove_action('wp_head', 'feed_links', 2 );
  13. add_editor_style();
  14. add_theme_support( 'post-thumbnails' );
  15. set_post_thumbnail_size( 150, 150, true );
  16. add_image_size( 'post-tiny', 100, 100, true );
  17. add_image_size( 'post-medium', 250, 175, true );
  18. add_image_size( 'post-large', 770, 577, true );
  19. add_theme_support( 'automatic-feed-links' );
  20. add_theme_support( 'menus' );
  21. function dw_remove_wp_ver_css_js( $src ) {
  22. if ( strpos( $src, 'ver=' ) )
  23. $src = remove_query_arg( 'ver', $src );
  24. return $src;
  25. }
  26. add_filter( 'style_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
  27. add_filter( 'script_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
  28. function the_menus() {
  29. register_nav_menus( array( 'main' => __( 'Main' )));
  30. }
  31. add_action( 'init', 'the_menus' );
  32. if ( ! function_exists( 'dw_get_page_number' ) ) :
  33. function dw_get_page_number() {
  34. if ( get_query_var( 'paged' ) )
  35. return ' | ' . __( 'Page ' , 'dw' ) . get_query_var( 'paged' );
  36. }
  37. endif;
  38. if ( ! function_exists( 'dw_the_page_number' ) ) :
  39. function dw_the_page_number() {
  40. echo dw_get_page_number();
  41. }
  42. endif;
  43. if ( ! function_exists( 'dw_excerpt_length' ) ) :
  44. function dw_excerpt_length( $length ) {
  45. return 40;
  46. }
  47. endif;
  48. add_filter( 'excerpt_length', 'dw_excerpt_length' );
  49. if ( ! function_exists( 'daw_excerpt_more' ) ) :
  50. function dw_excerpt_more( $more ) {
  51. return '&nbsp;&hellip; <a href="'. get_permalink() . '">' . __('Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'daw') . '</a>';
  52. }
  53. endif;
  54. add_filter( 'excerpt_more', 'dw_excerpt_more' );
  55. if ( ! function_exists( 'dw_comment' ) ) :
  56. function dw_comment( $comment, $args, $depth ) {
  57. $GLOBALS ['comment'] = $comment; ?>
  58. <?php if ( '' == $comment->comment_type ) : ?>
  59. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  60. <div id="comment-<?php comment_ID(); ?>">
  61. <div class="comment-author vcard">
  62. <?php echo get_avatar( $comment, 40 ); ?>
  63. <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>', 'daw' ), get_comment_author_link() ); ?>
  64. </div>
  65. <?php if ( $comment->comment_approved == '0' ) : ?>
  66. <em><?php _e( 'Your comment is awaiting moderation.', 'daw' ); ?></em>
  67. <br />
  68. <?php endif; ?>
  69. <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( __( '%1$s at %2$s', 'daw' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'daw' ),' ','' ); ?></div>
  70. <div class="comment-body"><?php comment_text(); ?></div>
  71. <div class="reply">
  72. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  73. </div>
  74. </div>
  75. <?php else : ?>
  76. <li class="post pingback">
  77. <p><?php _e( 'Pingback: ', 'daw' ); ?><?php comment_author_link(); ?><?php edit_comment_link ( __('edit', 'daw'), '&nbsp;&nbsp;', '' ); ?></p>
  78. <?php endif;
  79. }
  80. endif;
  81. // Remove inline styles on gallery shortcode
  82. if ( ! function_exists( 'dw_remove_gallery_css' ) ) :
  83. function dw_remove_gallery_css( $css ) {
  84. return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  85. }
  86. endif;
  87. add_filter( 'gallery_style', 'dw_remove_gallery_css' );
  88. if ( ! function_exists( 'dw_cat_list' ) ) :
  89. function dw_cat_list() {
  90. return daw_term_list( 'category', ', ', __( 'Posted in %s', 'dw' ), __( 'Also posted in %s', 'daw' ) );
  91. }
  92. endif;
  93. if ( ! function_exists( 'dw_tag_list' ) ) :
  94. function dw_tag_list() {
  95. return daw_term_list( 'post_tag', ', ', __( 'Tagged %s', 'dw' ), __( 'Also tagged %s', 'daw' ) );
  96. }
  97. endif;
  98. if ( ! function_exists( 'dw_term_list' ) ) :
  99. function daw_term_list( $taxonomy, $glue = ', ', $text = '', $also_text = '' ) {
  100. global $wp_query, $post;
  101. $current_term = $wp_query->get_queried_object();
  102. $terms = wp_get_object_terms( $post->ID, $taxonomy );
  103. // If we're viewing a Taxonomy page..
  104. if ( isset( $current_term->taxonomy ) && $taxonomy == $current_term->taxonomy ) {
  105. // Remove the term from display.
  106. foreach ( (array) $terms as $key => $term ) {
  107. if ( $term->term_id == $current_term->term_id ) {
  108. unset( $terms[$key] );
  109. break;
  110. }
  111. }
  112. // Change to Also text as we've now removed something from the terms list.
  113. $text = $also_text;
  114. }
  115. $tlist = array();
  116. $rel = 'category' == $taxonomy ? 'rel="category"' : 'rel="tag"';
  117. foreach ( (array) $terms as $term ) {
  118. $tlist[] = '<a href="' . get_term_link( $term, $taxonomy ) . '" title="' . esc_attr( sprintf( __( 'View all posts in %s', 'daw' ), $term->name ) ) . '" ' . $rel . '>' . $term->name . '</a>';
  119. }
  120. if ( ! empty( $tlist ) )
  121. return sprintf( $text, join( $glue, $tlist ) );
  122. return '';
  123. }
  124. endif;
  125. if ( ! function_exists( 'dw_widgets_init' ) ) :
  126. function daw_widgets_init() {
  127. // Area Login
  128. register_sidebar( array (
  129. 'name' => 'Login Widget Area',
  130. 'id' => 'login-widget-area',
  131. 'description' => __( 'The login widget area' , 'daw' ),
  132. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  133. 'after_widget' => "</li>",
  134. 'before_title' => '<h3 class="widget-title">',
  135. 'after_title' => '</h3>',
  136. ) );
  137. }
  138. endif;
  139. add_action( 'init', 'daw_widgets_init' );
  140. function dw_remove_recent_comments_style() {
  141. global $wp_widget_factory;
  142. remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
  143. }
  144. add_action( 'widgets_init', 'dw_remove_recent_comments_style' );
  145. function dw_get_next_attachment_url() {
  146. global $post;
  147. $post = get_post( $post );
  148. $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
  149. foreach ( $attachments as $k => $attachment ) {
  150. if ( $attachment->ID == $post->ID )
  151. break;
  152. }
  153. $k++;
  154. if ( isset( $attachments[ $k ] ) )
  155. return get_attachment_link( $attachments[ $k ]->ID );
  156. else
  157. return get_permalink( $post->post_parent );
  158. }
  159. function dw_posted_on() {
  160. return sprintf( __( '<span %1$s></span> %2$s by %3$s', 'daw' ),
  161. 'class="meta-prep meta-prep-author"',
  162. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">',
  163. get_permalink(),
  164. esc_attr( get_the_time() ),
  165. get_the_date()
  166. ),
  167. sprintf( '</span> <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  168. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  169. sprintf( esc_attr__( 'View all posts by %s', 'daw' ), get_the_author() ),
  170. get_the_author()
  171. )
  172. );
  173. }
  174. function dw_posted_in() {
  175. $tag_list = get_the_tag_list( '', ', ', '' );
  176. if ( $tag_list ) {
  177. $utility_text = __( '%1$s and tagged %2$s. <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'daw' );
  178. } else {
  179. $utility_text = __( '%1$s. <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'daw' );
  180. }
  181. return sprintf(
  182. $utility_text,
  183. get_the_category_list( ', ' ),
  184. $tag_list,
  185. get_permalink(),
  186. the_title_attribute( 'echo=0' ),
  187. get_post_comments_feed_link()
  188. );
  189. }
  190. ?>