PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

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

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 108 lines | 54 code | 14 blank | 40 comment | 5 complexity | 8dae65a71d7e949b657de88d5b6ff1cb 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 Beach
  5. */
  6. /**
  7. * Make theme available for translation
  8. * Translations can be filed in the /languages/ directory
  9. * If you're building a theme based on beach, use a find and replace
  10. * to change 'beach' to the name of your theme in all the template files
  11. */
  12. load_theme_textdomain( 'beach', TEMPLATEPATH . '/languages' );
  13. $locale = get_locale();
  14. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  15. if ( is_readable( $locale_file ) )
  16. require_once( $locale_file );
  17. /**
  18. * Set the content width based on the theme's design and stylesheet.
  19. */
  20. if ( ! isset( $content_width ) )
  21. $content_width = 530;
  22. /**
  23. * This theme uses wp_nav_menu() in one location.
  24. */
  25. register_nav_menus( array(
  26. 'primary' => __( 'Primary Menu', 'beach' ),
  27. 'secondary' => __( 'Secondary Menu', 'beach' ),
  28. ) );
  29. /**
  30. * Add default posts and comments RSS feed links to head
  31. */
  32. add_theme_support( 'automatic-feed-links' );
  33. /**
  34. * Add Post Format support
  35. */
  36. add_theme_support( 'post-formats', array( 'aside', 'gallery', 'quote', 'status' ) );
  37. /**
  38. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  39. */
  40. function beach_page_menu_args($args) {
  41. $args['show_home'] = true;
  42. return $args;
  43. }
  44. add_filter( 'wp_page_menu_args', 'beach_page_menu_args' );
  45. /**
  46. * Register widgetized area and update sidebar with default widgets
  47. */
  48. function beach_widgets_init() {
  49. register_sidebar( array (
  50. 'name' => __( 'Sidebar', 'beach' ),
  51. 'id' => 'sidebar-1',
  52. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  53. 'after_widget' => "</aside>",
  54. 'before_title' => '<h1 class="widget-title">',
  55. 'after_title' => '</h1>',
  56. ) );
  57. }
  58. add_action( 'init', 'beach_widgets_init' );
  59. /**
  60. * Display navigation to next/previous pages when applicable
  61. */
  62. function beach_content_nav($nav_id) {
  63. global $wp_query;
  64. if ( $wp_query->max_num_pages > 1 ) : ?>
  65. <nav id="<?php echo $nav_id; ?>">
  66. <h1 class="section-heading"><?php _e( 'Post navigation', 'beach' ); ?></h1>
  67. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'beach' ) ); ?></div>
  68. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'beach' ) ); ?></div>
  69. </nav><!-- #nav-above -->
  70. <?php endif;
  71. }
  72. /**
  73. * Returns a "Continue Reading" link for excerpts
  74. */
  75. function beach_continue_reading_link() {
  76. return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'beach' ) . '</a>';
  77. }
  78. /**
  79. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and beach_continue_reading_link().
  80. */
  81. function beach_auto_excerpt_more( $more ) {
  82. return ' &hellip;' . beach_continue_reading_link();
  83. }
  84. add_filter( 'excerpt_more', 'beach_auto_excerpt_more' );
  85. /**
  86. * Adds a pretty "Continue Reading" link to custom post excerpts.
  87. */
  88. function beach_custom_excerpt_more( $output ) {
  89. if ( has_excerpt() && ! is_attachment() ) {
  90. $output .= beach_continue_reading_link();
  91. }
  92. return $output;
  93. }
  94. add_filter( 'get_the_excerpt', 'beach_custom_excerpt_more' );