themes-wordpress/canard/inc/jetpack.php
2018-10-18 18:45:50 -10:00

133 lines
No EOL
3.9 KiB
PHP

<?php
/**
* Jetpack Compatibility File
* See: http://jetpack.me/
*
* @package Canard
*/
function canard_jetpack_setup() {
// Add theme support for Infinite Scroll.
add_theme_support( 'infinite-scroll', array(
'container' => 'main',
'footer' => 'page',
'footer_widgets' => array( 'sidebar-2' ),
) );
// Add theme support for Featured Content.
add_theme_support( 'featured-content', array(
'filter' => 'canard_get_featured_posts',
'description' => __( 'The featured content section displays on the front page above the header.', 'canard' ),
'max_posts' => 5,
'post_types' => array( 'post', 'page' ),
) );
// Add theme support for Responsive Videos.
add_theme_support( 'jetpack-responsive-videos' );
// Add theme support for Site Logo.
add_image_size( 'canard-logo', 400, 90 );
add_theme_support( 'site-logo', array( 'size' => 'canard-logo' ) );
// Add theme support for Content Options.
add_theme_support( 'jetpack-content-options', array(
'post-details' => array(
'stylesheet' => 'canard-style',
'date' => '.posted-on, body:not(.group-blog) .entry-summary + .entry-meta > .comments-link:before',
'categories' => '.cat-links',
'tags' => '.tags-links',
'author' => '.byline, .group-blog .entry-summary + .entry-meta > .posted-on:before',
'comment' => '.comments-link',
),
'featured-images' => array(
'archive' => true,
'post' => true,
'page' => true,
),
) );
}
add_action( 'after_setup_theme', 'canard_jetpack_setup' );
/**
* Featured Posts
*/
function canard_has_multiple_featured_posts() {
$featured_posts = apply_filters( 'canard_get_featured_posts', array() );
if ( is_array( $featured_posts ) && 1 < count( $featured_posts ) ) {
return true;
}
return false;
}
function canard_get_featured_posts() {
return apply_filters( 'canard_get_featured_posts', false );
}
/**
* Remove sharedaddy from excerpt.
*/
function canard_remove_sharedaddy() {
remove_filter( 'the_excerpt', 'sharing_display', 19 );
}
add_action( 'loop_start', 'canard_remove_sharedaddy' );
/**
* Return early if Site Logo is not available.
*/
function canard_the_site_logo() {
if ( ! function_exists( 'jetpack_the_site_logo' ) ) {
return;
} else {
jetpack_the_site_logo();
}
}
/**
* Show/Hide Featured Image on single posts view outside of the loop.
*/
function canard_jetpack_featured_image_display() {
if ( ! function_exists( 'jetpack_featured_images_remove_post_thumbnail' ) ) {
return true;
} else {
$options = get_theme_support( 'jetpack-content-options' );
$featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null;
$settings = array(
'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1,
'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1,
);
$settings = array_merge( $settings, array(
'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ),
'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ),
) );
if ( ( ! $settings['post-option'] && is_single() )
|| ( ! $settings['page-option'] && is_singular() && is_page() ) ) {
return false;
} else {
return true;
}
}
}
/**
* Remove Post Format classes from Portfolio items.
*/
function canard_jetpack_portfolio_classes( $classes ) {
$post_format = get_post_format();
if ( $post_format && ! is_wp_error( $post_format ) ) {
$class = 'format-' . sanitize_html_class( $post_format );
} else {
$class = 'format-standard';
}
$class_key = array_search( $class, $classes );
if ( false !== $class_key && 'jetpack-portfolio' === get_post_type() ) {
unset( $classes[ $class_key ] );
}
return $classes;
}
add_filter( 'post_class', 'canard_jetpack_portfolio_classes' );