';
}
}
add_action( 'wp_head', 'shutter_up_pingback_header' );
/**
* Adds custom overlay for Header Media
*/
function shutter_up_header_media_image_overlay_css() {
$overlay = get_theme_mod( 'shutter_up_header_media_image_opacity', 25 );
$css = '';
$overlay_bg = $overlay / 100;
if ( $overlay ) {
$css = '.custom-header-overlay {
background-color: rgba(0, 0, 0, ' . esc_attr( $overlay_bg ) . ' );
} '; // Dividing by 100 as the option is shown as % for user
}
wp_add_inline_style( 'shutter-up-style', $css );
}
add_action( 'wp_enqueue_scripts', 'shutter_up_header_media_image_overlay_css', 11 );
/**
* Remove first post from blog as it is already show via recent post template
*/
function shutter_up_alter_home( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$cats = get_theme_mod( 'shutter_up_front_page_category' );
if ( is_array( $cats ) && ! in_array( '0', $cats ) ) {
$query->query_vars['category__in'] = $cats;
}
}
}
add_action( 'pre_get_posts', 'shutter_up_alter_home' );
if ( ! function_exists( 'shutter_up_content_nav' ) ) :
/**
* Display navigation/pagination when applicable
*
* @since Shutter Up 1.0
*/
function shutter_up_content_nav() {
global $wp_query;
// Don't print empty markup in archives if there's only one page.
if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) {
return;
}
$pagination_type = get_theme_mod( 'shutter_up_pagination_type', 'default' );
if ( ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'infinite-scroll' ) ) || class_exists( 'Catch_Infinite_Scroll' ) ) {
// Support infinite scroll plugins.
the_posts_navigation();
} elseif ( 'numeric' === $pagination_type && function_exists( 'the_posts_pagination' ) ) {
the_posts_pagination( array(
'prev_text' => '' . esc_html__( 'Prev', 'shutter-up' ) . '',
'next_text' => '' . esc_html__( 'Next', 'shutter-up' ) . '',
'screen_reader_text' => '' . esc_html__( 'Page', 'shutter-up' ) . ' ',
) );
} else {
the_posts_navigation();
}
}
endif; // shutter_up_content_nav
/**
* Footer Text
*
* @get footer text from theme options and display them accordingly
* @display footer_text
* @action shutter_up_footer
*
* @since Shutter Up 1.0
*/
function shutter_up_footer_content() {
$theme_data = wp_get_theme();
$footer_content = get_theme_mod( 'shutter_up_footer_content', sprintf( _x( 'Copyright © %1$s %2$s %3$s', '1: Year, 2: Site Title with home URL, 3: Privacy Policy Link', 'shutter-up' ), '[the-year]', '[site-link]', '[privacy-policy-link]' ) . ' | ' . $theme_data->get( 'Name' ) . ' ' . esc_html__( 'by', 'shutter-up' ) . ' ' . esc_html( $theme_data->get( 'Author' ) ) . '' );
if ( ! $footer_content ) {
// Bail early if footer content is empty
return;
}
$search = array( '[the-year]', '[site-link]', '[privacy-policy-link]' );
$replace = array( esc_attr( date_i18n( __( 'Y', 'shutter-up' ) ) ), ''. esc_attr( get_bloginfo( 'name', 'display' ) ) . '', function_exists( 'get_the_privacy_policy_link' ) ? get_the_privacy_policy_link() : '' );
$footer_content = str_replace( $search, $replace, $footer_content );
echo '
' . $footer_content . '
';
}
add_action( 'shutter_up_credits', 'shutter_up_footer_content', 10 );
/**
* Check if a section is enabled or not based on the $value parameter
* @param string $value Value of the section that is to be checked
* @return boolean return true if section is enabled otherwise false
*/
function shutter_up_check_section( $value ) {
return ( 'entire-site' == $value || ( is_front_page() && 'homepage' === $value ) );
}
/**
* Return the first image in a post. Works inside a loop.
* @param [integer] $post_id [Post or page id]
* @param [string/array] $size Image size. Either a string keyword (thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, e.g. array(32,32).
* @param [string/array] $attr Query string or array of attributes.
* @return [string] image html
*
* @since Shutter Up 1.0
*/
function shutter_up_get_first_image( $postID, $size, $attr, $src = false ) {
ob_start();
ob_end_clean();
$image = '';
$output = preg_match_all('//i', get_post_field('post_content', $postID ) , $matches);
if ( isset( $matches[1][0] ) ) {
// Get first image.
$first_img = $matches[1][0];
if ( $src ) {
//Return url of src is true
return $first_img;
}
return '';
}
return false;
}
function shutter_up_get_theme_layout() {
$layout = '';
if ( is_page_template( 'templates/no-sidebar.php' ) ) {
$layout = 'no-sidebar';
} elseif ( is_page_template( 'templates/full-width-page.php' ) ) {
$layout = 'no-sidebar-full-width';
} elseif ( is_page_template( 'templates/left-sidebar.php' ) ) {
$layout = 'left-sidebar';
} elseif ( is_page_template( 'templates/right-sidebar.php' ) ) {
$layout = 'right-sidebar';
} else {
$layout = get_theme_mod( 'shutter_up_default_layout', 'no-sidebar' );
if ( is_home() || is_archive() ) {
$layout = get_theme_mod( 'shutter_up_homepage_archive_layout', 'no-sidebar-full-width' );
}
}
return $layout;
}
function shutter_up_get_sidebar_id() {
$sidebar = $id = '';
$layout = shutter_up_get_theme_layout();
if ( 'no-sidebar-full-width' === $layout || 'no-sidebar' === $layout ) {
return $sidebar;
}
if ( is_active_sidebar( 'sidebar-1' ) ) {
$sidebar = 'sidebar-1'; // Primary Sidebar.
}
return $sidebar;
}
if ( ! function_exists( 'shutter_up_truncate_phrase' ) ) :
/**
* Return a phrase shortened in length to a maximum number of characters.
*
* Result will be truncated at the last white space in the original string. In this function the word separator is a
* single space. Other white space characters (like newlines and tabs) are ignored.
*
* If the first `$max_characters` of the string does not contain a space character, an empty string will be returned.
*
* @since Shutter Up 1.0
*
* @param string $text A string to be shortened.
* @param integer $max_characters The maximum number of characters to return.
*
* @return string Truncated string
*/
function shutter_up_truncate_phrase( $text, $max_characters ) {
$text = trim( $text );
if ( mb_strlen( $text ) > $max_characters ) {
//* Truncate $text to $max_characters + 1
$text = mb_substr( $text, 0, $max_characters + 1 );
//* Truncate to the last space in the truncated string
$text = trim( mb_substr( $text, 0, mb_strrpos( $text, ' ' ) ) );
}
return $text;
}
endif; //shutter_up_truncate_phrase
if ( ! function_exists( 'shutter_up_get_the_content_limit' ) ) :
/**
* Return content stripped down and limited content.
*
* Strips out tags and shortcodes, limits the output to `$max_char` characters, and appends an ellipsis and more link to the end.
*
* @since Shutter Up 1.0
*
* @param integer $max_characters The maximum number of characters to return.
* @param string $more_link_text Optional. Text of the more link. Default is "(more...)".
* @param bool $stripteaser Optional. Strip teaser content before the more text. Default is false.
*
* @return string Limited content.
*/
function shutter_up_get_the_content_limit( $max_characters, $more_link_text = '(more...)', $stripteaser = false ) {
$content = get_the_content( '', $stripteaser );
// Strip tags and shortcodes so the content truncation count is done correctly.
$content = strip_tags( strip_shortcodes( $content ), apply_filters( 'get_the_content_limit_allowedtags', '