';
}
}
add_action( 'wp_head', 'catch_fullscreen_pingback_header' );
/**
* Adds custom background image overlay for each section
*/
function catch_fullscreen_sections_bg_image_overlay_css() {
$css = '';
// For Header Media.
$overlay = get_theme_mod( 'catch_fullscreen_header_media_bg_image_opacity', '10' );
$overlay_bg = $overlay / 100;
if ( '10' !== $overlay ) {
$css = '.custom-header.has-section-background-image:before { background-color: rgba(0, 0, 0, ' . esc_attr( $overlay_bg ) . '); } '; // Dividing by 100 as the option is shown as % for user
}
// For Featured Content.
$overlay = get_theme_mod( 'catch_fullscreen_featured_content_bg_image_opacity', '10' );
$overlay_bg = $overlay / 100;
if ( '10' !== $overlay ) {
$css .= '#featured-content-section.has-section-background-image:before { background-color: rgba(0, 0, 0, ' . esc_attr( $overlay_bg ) . '); } '; // Dividing by 100 as the option is shown as % for user
}
// For Service.
$overlay = get_theme_mod( 'catch_fullscreen_service_bg_image_opacity', '10' );
$overlay_bg = $overlay / 100;
if ( '10' !== $overlay ) {
$css .= '#service-content-section.has-section-background-image:before { background-color: rgba(0, 0, 0, ' . esc_attr( $overlay_bg ) . '); } '; // Dividing by 100 as the option is shown as % for user
}
// For Team.
$overlay = get_theme_mod( 'catch_fullscreen_team_bg_image_opacity', '10' );
$overlay_bg = $overlay / 100;
if ( '10' !== $overlay ) {
$css .= '#team-content-section.has-section-background-image:before { background-color: rgba(0, 0, 0, ' . esc_attr( $overlay_bg ) . '); } '; // Dividing by 100 as the option is shown as % for user
}
// For Testimonial.
$overlay = get_theme_mod( 'catch_fullscreen_testimonials_bg_image_opacity', '10' );
$overlay_bg = $overlay / 100;
if ( '10' !== $overlay ) {
$css .= '#testimonial-content-section.has-section-background-image:before { background-color: rgba(0, 0, 0, ' . esc_attr( $overlay_bg ) . '); } '; // Dividing by 100 as the option is shown as % for user
}
// For gallery.
$overlay = get_theme_mod( 'catch_fullscreen_gallery_bg_image_opacity', '10' );
$overlay_bg = $overlay / 100;
if ( '10' !== $overlay ) {
$css .= '.gallery-section.has-section-background-image:before { background-color: rgba(0, 0, 0, ' . esc_attr( $overlay_bg ) . '); } '; // Dividing by 100 as the option is shown as % for user
}
// For portfolio.
$overlay = get_theme_mod( 'catch_fullscreen_portfolio_bg_image_opacity', '10' );
$overlay_bg = $overlay / 100;
if ( '10' !== $overlay ) {
$css .= '#portfolio-content-section.has-section-background-image:before { background-color: rgba(0, 0, 0, ' . esc_attr( $overlay_bg ) . '); } '; // Dividing by 100 as the option is shown as % for user
}
// For Hero.
$overlay = get_theme_mod( 'catch_fullscreen_hero_bg_image_opacity', '10' );
$overlay_bg = $overlay / 100;
if ( '10' !== $overlay ) {
$css .= '#hero-section.has-section-background-image:before { background-color: rgba(0, 0, 0, ' . esc_attr( $overlay_bg ) . '); } '; // Dividing by 100 as the option is shown as % for user
}
// For Promotion.
$overlay = get_theme_mod( 'catch_fullscreen_promotion_bg_image_opacity', '10' );
$overlay_bg = $overlay / 100;
if ( '10' !== $overlay ) {
$css .= '#promotion-section.has-section-background-image:before { 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( 'catch-fullscreen-style', $css );
}
add_action( 'wp_enqueue_scripts', 'catch_fullscreen_sections_bg_image_overlay_css', 11 );
/**
* Remove first post from blog as it is already show via recent post template
*/
function catch_fullscreen_alter_home( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$cats = get_theme_mod( 'catch_fullscreen_front_page_category' );
if ( is_array( $cats ) && ! in_array( '0', $cats ) ) {
$query->query_vars['category__in'] = $cats;
}
}
}
add_action( 'pre_get_posts', 'catch_fullscreen_alter_home' );
/**
* Function to add Scroll Up icon
*/
function catch_fullscreen_scrollup() {
$disable_scrollup = get_theme_mod( 'catch_fullscreen_disable_scrollup' );
if ( $disable_scrollup ) {
return;
}
echo '' . catch_fullscreen_get_svg( array( 'icon' => 'angle-down' ) ) . '' . esc_html__( 'Scroll Up', 'catch-fullscreen' ) . '' ;
}
add_action( 'wp_footer', 'catch_fullscreen_scrollup', 1 );
if ( ! function_exists( 'catch_fullscreen_content_nav' ) ) :
/**
* Display navigation/pagination when applicable
*
* @since Catch Fullscreen 1.0
*/
function catch_fullscreen_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( 'catch_fullscreen_pagination_type', 'default' );
/**
* Check if navigation type is Jetpack Infinite Scroll and if it is enabled, else goto default pagination
* if it's active then disable pagination
*/
if ( ( 'infinite-scroll' === $pagination_type ) && class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'infinite-scroll' ) ) {
return false;
}
if ( 'numeric' === $pagination_type && function_exists( 'the_posts_pagination' ) ) {
the_posts_pagination( array(
'prev_text' => esc_html__( 'Previous page', 'catch-fullscreen' ),
'next_text' => esc_html__( 'Next page', 'catch-fullscreen' ),
'before_page_number' => '' . esc_html__( 'Page', 'catch-fullscreen' ) . ' ',
) );
} else {
the_posts_navigation();
}
}
endif; // catch_fullscreen_content_nav
/**
* 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 catch_fullscreen_check_section( $value ) {
global $wp_query;
// Get Page ID outside Loop
$page_id = $wp_query->get_queried_object_id();
// Front page displays in Reading Settings
$page_for_posts = get_option('page_for_posts');
return ( 'entire-site' == $value || ( ( is_front_page() || ( is_home() && intval( $page_for_posts ) !== intval( $page_id ) ) ) && '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 Catch Fullscreen 1.0
*/
function catch_fullscreen_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 catch_fullscreen_get_theme_layout() {
$layout = '';
if ( is_page_template( 'templates/no-sidebar.php' ) ) {
$layout = 'no-sidebar';
} elseif ( is_page_template( 'templates/right-sidebar.php' ) ) {
$layout = 'right-sidebar';
} else {
$layout = get_theme_mod( 'catch_fullscreen_default_layout', 'right-sidebar' );
if ( is_home() || is_archive() ) {
$layout = get_theme_mod( 'catch_fullscreen_homepage_archive_layout', 'right-sidebar' );
}
}
return $layout;
}
function catch_fullscreen_get_sidebar_id() {
$sidebar = '';
$layout = catch_fullscreen_get_theme_layout();
$sidebaroptions = '';
if ( 'no-sidebar' === $layout ) {
return $sidebar;
}
if ( is_active_sidebar( 'sidebar-1' ) ) {
$sidebar = 'sidebar-1'; // Primary Sidebar.
}
return $sidebar;
}
/**
* Display social Menu
*/
function catch_fullscreen_social_menu() {
if ( has_nav_menu( 'social-menu' ) ) :
?>
$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; //catch-catch_fullscreen_truncate_phrase
if ( ! function_exists( 'catch_fullscreen_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 Catch Fullscreen 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 catch_fullscreen_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', '