Advertisement
herojig

Broken Events Code from twentythirteen theme

Jun 27th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 18.95 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Twenty Thirteen functions and definitions
  4.  *
  5.  * Sets up the theme and provides some helper functions, which are used in the
  6.  * theme as custom template tags. Others are attached to action and filter
  7.  * hooks in WordPress to change core functionality.
  8.  *
  9.  * When using a child theme (see https://codex.wordpress.org/Theme_Development
  10.  * and https://codex.wordpress.org/Child_Themes), you can override certain
  11.  * functions (those wrapped in a function_exists() call) by defining them first
  12.  * in your child theme's functions.php file. The child theme's functions.php
  13.  * file is included before the parent theme's file, so the child theme
  14.  * functions would be used.
  15.  *
  16.  * Functions that are not pluggable (not wrapped in function_exists()) are
  17.  * instead attached to a filter or action hook.
  18.  *
  19.  * For more information on hooks, actions, and filters, @link https://codex.wordpress.org/Plugin_API
  20.  *
  21.  * @package WordPress
  22.  * @subpackage Twenty_Thirteen
  23.  * @since Twenty Thirteen 1.0
  24.  */
  25.  
  26. /*
  27.  * Set up the content width value based on the theme's design.
  28.  *
  29.  * @see twentythirteen_content_width() for template-specific adjustments.
  30.  */
  31. if ( ! isset( $content_width ) )
  32.     $content_width = 604;
  33.  
  34. /**
  35.  * Add support for a custom header image.
  36.  */
  37. require get_template_directory() . '/inc/custom-header.php';
  38.  
  39. /**
  40.  * Twenty Thirteen only works in WordPress 3.6 or later.
  41.  */
  42. if ( version_compare( $GLOBALS['wp_version'], '3.6-alpha', '<' ) )
  43.     require get_template_directory() . '/inc/back-compat.php';
  44.  
  45. /**
  46.  * Twenty Thirteen setup.
  47.  *
  48.  * Sets up theme defaults and registers the various WordPress features that
  49.  * Twenty Thirteen supports.
  50.  *
  51.  * @uses load_theme_textdomain() For translation/localization support.
  52.  * @uses add_editor_style() To add Visual Editor stylesheets.
  53.  * @uses add_theme_support() To add support for automatic feed links, post
  54.  * formats, and post thumbnails.
  55.  * @uses register_nav_menu() To add support for a navigation menu.
  56.  * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  57.  *
  58.  * @since Twenty Thirteen 1.0
  59.  */
  60. function twentythirteen_setup() {
  61.     /*
  62.      * Makes Twenty Thirteen available for translation.
  63.      *
  64.      * Translations can be added to the /languages/ directory.
  65.      * If you're building a theme based on Twenty Thirteen, use a find and
  66.      * replace to change 'twentythirteen' to the name of your theme in all
  67.      * template files.
  68.      */
  69.     load_theme_textdomain( 'twentythirteen', get_template_directory() . '/languages' );
  70.  
  71.     /*
  72.      * This theme styles the visual editor to resemble the theme style,
  73.      * specifically font, colors, icons, and column width.
  74.      */
  75.     add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', twentythirteen_fonts_url() ) );
  76.  
  77.     // Adds RSS feed links to <head> for posts and comments.
  78.     add_theme_support( 'automatic-feed-links' );
  79.  
  80.     /*
  81.      * Switches default core markup for search form, comment form,
  82.      * and comments to output valid HTML5.
  83.      */
  84.     add_theme_support( 'html5', array(
  85.         'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
  86.     ) );
  87.  
  88.     /*
  89.      * This theme supports all available post formats by default.
  90.      * See https://codex.wordpress.org/Post_Formats
  91.      */
  92.     add_theme_support( 'post-formats', array(
  93.         'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video'
  94.     ) );
  95.  
  96.     // This theme uses wp_nav_menu() in one location.
  97.     register_nav_menu( 'primary', __( 'Navigation Menu', 'twentythirteen' ) );
  98.  
  99.     /*
  100.      * This theme uses a custom image size for featured images, displayed on
  101.      * "standard" posts and pages.
  102.      */
  103.     add_theme_support( 'post-thumbnails' );
  104.     set_post_thumbnail_size( 604, 270, true );
  105.  
  106.     // This theme uses its own gallery styles.
  107.     add_filter( 'use_default_gallery_style', '__return_false' );
  108. }
  109. add_action( 'after_setup_theme', 'twentythirteen_setup' );
  110.  
  111. /**
  112.  * Return the Google font stylesheet URL, if available.
  113.  *
  114.  * The use of Source Sans Pro and Bitter by default is localized. For languages
  115.  * that use characters not supported by the font, the font can be disabled.
  116.  *
  117.  * @since Twenty Thirteen 1.0
  118.  *
  119.  * @return string Font stylesheet or empty string if disabled.
  120.  */
  121. function twentythirteen_fonts_url() {
  122.     $fonts_url = '';
  123.  
  124.     /* Translators: If there are characters in your language that are not
  125.      * supported by Source Sans Pro, translate this to 'off'. Do not translate
  126.      * into your own language.
  127.      */
  128.     $source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentythirteen' );
  129.  
  130.     /* Translators: If there are characters in your language that are not
  131.      * supported by Bitter, translate this to 'off'. Do not translate into your
  132.      * own language.
  133.      */
  134.     $bitter = _x( 'on', 'Bitter font: on or off', 'twentythirteen' );
  135.  
  136.     if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) {
  137.         $font_families = array();
  138.  
  139.         if ( 'off' !== $source_sans_pro )
  140.             $font_families[] = 'Source Sans Pro:300,400,700,300italic,400italic,700italic';
  141.  
  142.         if ( 'off' !== $bitter )
  143.             $font_families[] = 'Bitter:400,700';
  144.  
  145.         $query_args = array(
  146.             'family' => urlencode( implode( '|', $font_families ) ),
  147.             'subset' => urlencode( 'latin,latin-ext' ),
  148.         );
  149.         $fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
  150.     }
  151.  
  152.     return $fonts_url;
  153. }
  154.  
  155. /**
  156.  * Enqueue scripts and styles for the front end.
  157.  *
  158.  * @since Twenty Thirteen 1.0
  159.  */
  160. function twentythirteen_scripts_styles() {
  161.     /*
  162.      * Adds JavaScript to pages with the comment form to support
  163.      * sites with threaded comments (when in use).
  164.      */
  165.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
  166.         wp_enqueue_script( 'comment-reply' );
  167.  
  168.     // Adds Masonry to handle vertical alignment of footer widgets.
  169.     if ( is_active_sidebar( 'sidebar-1' ) )
  170.         wp_enqueue_script( 'jquery-masonry' );
  171.  
  172.     // Loads JavaScript file with functionality specific to Twenty Thirteen.
  173.     wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150330', true );
  174.  
  175.     // Add Source Sans Pro and Bitter fonts, used in the main stylesheet.
  176.     wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
  177.  
  178.     // Add Genericons font, used in the main stylesheet.
  179.     wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.03' );
  180.  
  181.     // Loads our main stylesheet.
  182.     wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri(), array(), '2013-07-18' );
  183.  
  184.     // Loads the Internet Explorer specific stylesheet.
  185.     wp_enqueue_style( 'twentythirteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentythirteen-style' ), '2013-07-18' );
  186.     wp_style_add_data( 'twentythirteen-ie', 'conditional', 'lt IE 9' );
  187. }
  188. add_action( 'wp_enqueue_scripts', 'twentythirteen_scripts_styles' );
  189.  
  190. /**
  191.  * Filter the page title.
  192.  *
  193.  * Creates a nicely formatted and more specific title element text for output
  194.  * in head of document, based on current view.
  195.  *
  196.  * @since Twenty Thirteen 1.0
  197.  *
  198.  * @param string $title Default title text for current view.
  199.  * @param string $sep   Optional separator.
  200.  * @return string The filtered title.
  201.  */
  202. function twentythirteen_wp_title( $title, $sep ) {
  203.     global $paged, $page;
  204.  
  205.     if ( is_feed() )
  206.         return $title;
  207.  
  208.     // Add the site name.
  209.     $title .= get_bloginfo( 'name', 'display' );
  210.  
  211.     // Add the site description for the home/front page.
  212.     $site_description = get_bloginfo( 'description', 'display' );
  213.     if ( $site_description && ( is_home() || is_front_page() ) )
  214.         $title = "$title $sep $site_description";
  215.  
  216.     // Add a page number if necessary.
  217.     if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() )
  218.         $title = "$title $sep " . sprintf( __( 'Page %s', 'twentythirteen' ), max( $paged, $page ) );
  219.  
  220.     return $title;
  221. }
  222. add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 );
  223.  
  224. /**
  225.  * Register two widget areas.
  226.  *
  227.  * @since Twenty Thirteen 1.0
  228.  */
  229. function twentythirteen_widgets_init() {
  230.     register_sidebar( array(
  231.         'name'          => __( 'Main Widget Area', 'twentythirteen' ),
  232.         'id'            => 'sidebar-1',
  233.         'description'   => __( 'Appears in the footer section of the site.', 'twentythirteen' ),
  234.         'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  235.         'after_widget'  => '</aside>',
  236.         'before_title'  => '<h3 class="widget-title">',
  237.         'after_title'   => '</h3>',
  238.     ) );
  239.  
  240.     register_sidebar( array(
  241.         'name'          => __( 'Secondary Widget Area', 'twentythirteen' ),
  242.         'id'            => 'sidebar-2',
  243.         'description'   => __( 'Appears on posts and pages in the sidebar.', 'twentythirteen' ),
  244.         'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  245.         'after_widget'  => '</aside>',
  246.         'before_title'  => '<h3 class="widget-title">',
  247.         'after_title'   => '</h3>',
  248.     ) );
  249. }
  250. add_action( 'widgets_init', 'twentythirteen_widgets_init' );
  251.  
  252. if ( ! function_exists( 'twentythirteen_paging_nav' ) ) :
  253. /**
  254.  * Display navigation to next/previous set of posts when applicable.
  255.  *
  256.  * @since Twenty Thirteen 1.0
  257.  */
  258. function twentythirteen_paging_nav() {
  259.     global $wp_query;
  260.  
  261.     // Don't print empty markup if there's only one page.
  262.     if ( $wp_query->max_num_pages < 2 )
  263.         return;
  264.     ?>
  265.     <nav class="navigation paging-navigation" role="navigation">
  266.         <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentythirteen' ); ?></h1>
  267.         <div class="nav-links">
  268.  
  269.             <?php if ( get_next_posts_link() ) : ?>
  270.             <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentythirteen' ) ); ?></div>
  271.             <?php endif; ?>
  272.  
  273.             <?php if ( get_previous_posts_link() ) : ?>
  274.             <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentythirteen' ) ); ?></div>
  275.             <?php endif; ?>
  276.  
  277.         </div><!-- .nav-links -->
  278.     </nav><!-- .navigation -->
  279.     <?php
  280. }
  281. endif;
  282.  
  283. if ( ! function_exists( 'twentythirteen_post_nav' ) ) :
  284. /**
  285.  * Display navigation to next/previous post when applicable.
  286. *
  287. * @since Twenty Thirteen 1.0
  288. */
  289. function twentythirteen_post_nav() {
  290.     global $post;
  291.  
  292.     // Don't print empty markup if there's nowhere to navigate.
  293.     $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
  294.     $next     = get_adjacent_post( false, '', false );
  295.  
  296.     if ( ! $next && ! $previous )
  297.         return;
  298.     ?>
  299.     <nav class="navigation post-navigation" role="navigation">
  300.         <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentythirteen' ); ?></h1>
  301.         <div class="nav-links">
  302.  
  303.             <?php previous_post_link( '%link', _x( '<span class="meta-nav">&larr;</span> %title', 'Previous post link', 'twentythirteen' ) ); ?>
  304.             <?php next_post_link( '%link', _x( '%title <span class="meta-nav">&rarr;</span>', 'Next post link', 'twentythirteen' ) ); ?>
  305.  
  306.         </div><!-- .nav-links -->
  307.     </nav><!-- .navigation -->
  308.     <?php
  309. }
  310. endif;
  311.  
  312. if ( ! function_exists( 'twentythirteen_entry_meta' ) ) :
  313. /**
  314.  * Print HTML with meta information for current post: categories, tags, permalink, author, and date.
  315.  *
  316.  * Create your own twentythirteen_entry_meta() to override in a child theme.
  317.  *
  318.  * @since Twenty Thirteen 1.0
  319.  */
  320. function twentythirteen_entry_meta() {
  321.     if ( is_sticky() && is_home() && ! is_paged() )
  322.         echo '<span class="featured-post">' . esc_html__( 'Sticky', 'twentythirteen' ) . '</span>';
  323.  
  324.     if ( ! has_post_format( 'link' ) && 'post' == get_post_type() )
  325.         twentythirteen_entry_date();
  326.  
  327.     // Translators: used between list items, there is a space after the comma.
  328.     $categories_list = get_the_category_list( __( ', ', 'twentythirteen' ) );
  329.     if ( $categories_list ) {
  330.         echo '<span class="categories-links">' . $categories_list . '</span>';
  331.     }
  332.  
  333.     // Translators: used between list items, there is a space after the comma.
  334.     $tag_list = get_the_tag_list( '', __( ', ', 'twentythirteen' ) );
  335.     if ( $tag_list ) {
  336.         echo '<span class="tags-links">' . $tag_list . '</span>';
  337.     }
  338.  
  339.     // Post author
  340.     if ( 'post' == get_post_type() ) {
  341.         printf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
  342.             esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  343.             esc_attr( sprintf( __( 'View all posts by %s', 'twentythirteen' ), get_the_author() ) ),
  344.             get_the_author()
  345.         );
  346.     }
  347. }
  348. endif;
  349.  
  350. if ( ! function_exists( 'twentythirteen_entry_date' ) ) :
  351. /**
  352.  * Print HTML with date information for current post.
  353.  *
  354.  * Create your own twentythirteen_entry_date() to override in a child theme.
  355.  *
  356.  * @since Twenty Thirteen 1.0
  357.  *
  358.  * @param boolean $echo (optional) Whether to echo the date. Default true.
  359.  * @return string The HTML-formatted post date.
  360.  */
  361. function twentythirteen_entry_date( $echo = true ) {
  362.     if ( has_post_format( array( 'chat', 'status' ) ) )
  363.         $format_prefix = _x( '%1$s on %2$s', '1: post format name. 2: date', 'twentythirteen' );
  364.     else
  365.         $format_prefix = '%2$s';
  366.  
  367.     $date = sprintf( '<span class="date"><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a></span>',
  368.         esc_url( get_permalink() ),
  369.         esc_attr( sprintf( __( 'Permalink to %s', 'twentythirteen' ), the_title_attribute( 'echo=0' ) ) ),
  370.         esc_attr( get_the_date( 'c' ) ),
  371.         esc_html( sprintf( $format_prefix, get_post_format_string( get_post_format() ), get_the_date() ) )
  372.     );
  373.  
  374.     if ( $echo )
  375.         echo $date;
  376.  
  377.     return $date;
  378. }
  379. endif;
  380.  
  381. if ( ! function_exists( 'twentythirteen_the_attached_image' ) ) :
  382. /**
  383.  * Print the attached image with a link to the next attached image.
  384.  *
  385.  * @since Twenty Thirteen 1.0
  386.  */
  387. function twentythirteen_the_attached_image() {
  388.     /**
  389.      * Filter the image attachment size to use.
  390.      *
  391.      * @since Twenty thirteen 1.0
  392.      *
  393.      * @param array $size {
  394.      *     @type int The attachment height in pixels.
  395.      *     @type int The attachment width in pixels.
  396.      * }
  397.      */
  398.     $attachment_size     = apply_filters( 'twentythirteen_attachment_size', array( 724, 724 ) );
  399.     $next_attachment_url = wp_get_attachment_url();
  400.     $post                = get_post();
  401.  
  402.     /*
  403.      * Grab the IDs of all the image attachments in a gallery so we can get the URL
  404.      * of the next adjacent image in a gallery, or the first image (if we're
  405.      * looking at the last image in a gallery), or, in a gallery of one, just the
  406.      * link to that image file.
  407.      */
  408.     $attachment_ids = get_posts( array(
  409.         'post_parent'    => $post->post_parent,
  410.         'fields'         => 'ids',
  411.         'numberposts'    => -1,
  412.         'post_status'    => 'inherit',
  413.         'post_type'      => 'attachment',
  414.         'post_mime_type' => 'image',
  415.         'order'          => 'ASC',
  416.         'orderby'        => 'menu_order ID',
  417.     ) );
  418.  
  419.     // If there is more than 1 attachment in a gallery...
  420.     if ( count( $attachment_ids ) > 1 ) {
  421.         foreach ( $attachment_ids as $attachment_id ) {
  422.             if ( $attachment_id == $post->ID ) {
  423.                 $next_id = current( $attachment_ids );
  424.                 break;
  425.             }
  426.         }
  427.  
  428.         // get the URL of the next image attachment...
  429.         if ( $next_id )
  430.             $next_attachment_url = get_attachment_link( $next_id );
  431.  
  432.         // or get the URL of the first image attachment.
  433.         else
  434.             $next_attachment_url = get_attachment_link( reset( $attachment_ids ) );
  435.     }
  436.  
  437.     printf( '<a href="%1$s" title="%2$s" rel="attachment">%3$s</a>',
  438.         esc_url( $next_attachment_url ),
  439.         the_title_attribute( array( 'echo' => false ) ),
  440.         wp_get_attachment_image( $post->ID, $attachment_size )
  441.     );
  442. }
  443. endif;
  444.  
  445. /**
  446.  * Return the post URL.
  447.  *
  448.  * @uses get_url_in_content() to get the URL in the post meta (if it exists) or
  449.  * the first link found in the post content.
  450.  *
  451.  * Falls back to the post permalink if no URL is found in the post.
  452.  *
  453.  * @since Twenty Thirteen 1.0
  454.  *
  455.  * @return string The Link format URL.
  456.  */
  457. function twentythirteen_get_link_url() {
  458.     $content = get_the_content();
  459.     $has_url = get_url_in_content( $content );
  460.  
  461.     return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
  462. }
  463.  
  464. if ( ! function_exists( 'twentythirteen_excerpt_more' ) && ! is_admin() ) :
  465. /**
  466.  * Replaces "[...]" (appended to automatically generated excerpts) with ...
  467.  * and a Continue reading link.
  468.  *
  469.  * @since Twenty Thirteen 1.4
  470.  *
  471.  * @param string $more Default Read More excerpt link.
  472.  * @return string Filtered Read More excerpt link.
  473.  */
  474. function twentythirteen_excerpt_more( $more ) {
  475.     $link = sprintf( '<a href="%1$s" class="more-link">%2$s</a>',
  476.         esc_url( get_permalink( get_the_ID() ) ),
  477.             /* translators: %s: Name of current post */
  478.             sprintf( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'twentythirteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
  479.         );
  480.     return ' &hellip; ' . $link;
  481. }
  482. add_filter( 'excerpt_more', 'twentythirteen_excerpt_more' );
  483. endif;
  484.  
  485. /**
  486.  * Extend the default WordPress body classes.
  487.  *
  488.  * Adds body classes to denote:
  489.  * 1. Single or multiple authors.
  490.  * 2. Active widgets in the sidebar to change the layout and spacing.
  491.  * 3. When avatars are disabled in discussion settings.
  492.  *
  493.  * @since Twenty Thirteen 1.0
  494.  *
  495.  * @param array $classes A list of existing body class values.
  496.  * @return array The filtered body class list.
  497.  */
  498. function twentythirteen_body_class( $classes ) {
  499.     if ( ! is_multi_author() )
  500.         $classes[] = 'single-author';
  501.  
  502.     if ( is_active_sidebar( 'sidebar-2' ) && ! is_attachment() && ! is_404() )
  503.         $classes[] = 'sidebar';
  504.  
  505.     if ( ! get_option( 'show_avatars' ) )
  506.         $classes[] = 'no-avatars';
  507.  
  508.     return $classes;
  509. }
  510. add_filter( 'body_class', 'twentythirteen_body_class' );
  511.  
  512. /**
  513.  * Adjust content_width value for video post formats and attachment templates.
  514.  *
  515.  * @since Twenty Thirteen 1.0
  516.  */
  517. function twentythirteen_content_width() {
  518.     global $content_width;
  519.  
  520.     if ( is_attachment() )
  521.         $content_width = 724;
  522.     elseif ( has_post_format( 'audio' ) )
  523.         $content_width = 484;
  524. }
  525. add_action( 'template_redirect', 'twentythirteen_content_width' );
  526.  
  527. /**
  528.  * Add postMessage support for site title and description for the Customizer.
  529.  *
  530.  * @since Twenty Thirteen 1.0
  531.  *
  532.  * @param WP_Customize_Manager $wp_customize Customizer object.
  533.  */
  534. function twentythirteen_customize_register( $wp_customize ) {
  535.     $wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
  536.     $wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
  537.     $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
  538. }
  539. add_action( 'customize_register', 'twentythirteen_customize_register' );
  540.  
  541. /**
  542.  * Enqueue Javascript postMessage handlers for the Customizer.
  543.  *
  544.  * Binds JavaScript handlers to make the Customizer preview
  545.  * reload changes asynchronously.
  546.  *
  547.  * @since Twenty Thirteen 1.0
  548.  */
  549. function twentythirteen_customize_preview_js() {
  550.     wp_enqueue_script( 'twentythirteen-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20141120', true );
  551. }
  552. add_action( 'customize_preview_init', 'twentythirteen_customize_preview_js' );
  553. /**
  554. add_filter('tribe_get_events_title', 'change_upcoming_events_title');
  555.     function change_upcoming_events_title($title) {
  556.         if (tribe_is_upcoming() or tribe_is_map() or tribe_is_photo()) return 'Consultant Availabilty & PCN Events';
  557.     return $title;
  558. }
  559. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement