'; } } add_action( 'wp_head', 'alpert_pingback_header' ); if ( ! function_exists( 'alpert_excerpt_length' ) ) : /** * Sets the post excerpt length to n words. * * function tied to the excerpt_length filter hook. * @uses filter excerpt_length */ function alpert_excerpt_length( $length ) { if ( is_admin() ) { return $length; } // Getting data from Theme Options $length = alpert_gtm( 'alpert_excerpt_length' ); return absint( $length ); } // alpert_excerpt_length. endif; add_filter( 'excerpt_length', 'alpert_excerpt_length', 999 ); if ( ! function_exists( 'alpert_excerpt_more' ) ) : /** * Replaces "[...]" (appended to automatically generated excerpts) with ... and a option from customizer * * @return string option from customizer prepended with an ellipsis. */ function alpert_excerpt_more( $more ) { if ( is_admin() ) { return $more; } $more_tag_text = alpert_gtm( 'alpert_excerpt_more_text' ); $link = sprintf( '%2$s', esc_url( get_permalink() ), /* translators: %s: Name of current post */ wp_kses_data( $more_tag_text ). '' . esc_html( get_the_title( get_the_ID() ) ) . '' ); return '…' . $link; } endif; add_filter( 'excerpt_more', 'alpert_excerpt_more' ); if ( ! function_exists( 'alpert_custom_excerpt' ) ) : /** * Adds Continue reading link to more tag excerpts. * * function tied to the get_the_excerpt filter hook. */ function alpert_custom_excerpt( $output ) { if ( is_admin() ) { return $output; } if ( has_excerpt() && ! is_attachment() ) { $more_tag_text = alpert_gtm( 'alpert_excerpt_more_text' ); $link = sprintf( '%2$s', esc_url( get_permalink() ), /* translators: %s: Name of current post */ wp_kses_data( $more_tag_text ). '' . esc_html( get_the_title( get_the_ID() ) ) . '' ); $output .= '…' . $link; } return $output; } // alpert_custom_excerpt. endif; add_filter( 'get_the_excerpt', 'alpert_custom_excerpt' ); if ( ! function_exists( 'alpert_more_link' ) ) : /** * Replacing Continue reading link to the_content more. * * function tied to the the_content_more_link filter hook. */ function alpert_more_link( $more_link, $more_link_text ) { $more_tag_text = alpert_gtm( 'alpert_excerpt_more_text' ); return str_replace( $more_link_text, wp_kses_data( $more_tag_text ), $more_link ); } // alpert_more_link. endif; add_filter( 'the_content_more_link', 'alpert_more_link', 10, 2 ); /** * Filter Homepage Options as selected in theme options. */ function alpert_alter_home( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $cats = alpert_gtm( 'alpert_front_page_category' ); if ( $cats ) { $query->query_vars['category__in'] = explode( ',', $cats ); } } } add_action( 'pre_get_posts', 'alpert_alter_home' ); /** * Display section as selected in theme options. */ function alpert_display_section( $option ) { if ( 'entire-site' === $option || 'custom-pages' === $option || ( is_front_page() && 'homepage' === $option ) || ( ! is_front_page() && 'excluding-home' === $option ) ) { return true; } // Section is disabled. return false; } /** * Return theme layout * @return layout */ function alpert_get_theme_layout() { $layout = ''; if ( is_page_template( 'templates/full-width-page.php' ) ) { $layout = 'no-sidebar-full-width'; }elseif ( is_page_template( 'templates/right-sidebar.php' ) ) { $layout = 'right-sidebar'; } else { $layout = alpert_gtm( 'alpert_default_layout' ); if ( is_home() || is_archive() ) { $layout = alpert_gtm( 'alpert_homepage_archive_layout' ); } } return $layout; } /** * Return theme layout * @return layout */ function alpert_get_sidebar_id() { $sidebar = ''; $layout = alpert_get_theme_layout(); if ( 'no-sidebar-full-width' === $layout || 'no-sidebar' === $layout ) { return $sidebar; } $sidebaroptions = ''; global $post, $wp_query; // Front page displays in Reading Settings. $page_on_front = get_option( 'page_on_front' ); $page_for_posts = get_option( 'page_for_posts' ); // Get Page ID outside Loop. $page_id = $wp_query->get_queried_object_id(); // Blog Page or Front Page setting in Reading Settings. if ( $page_id == $page_for_posts || $page_id == $page_on_front ) { $sidebaroptions = get_post_meta( $page_id, 'alpert-sidebar-option', true ); } elseif ( is_singular() ) { if ( is_attachment() ) { $parent = $post->post_parent; $sidebaroptions = get_post_meta( $parent, 'alpert-sidebar-option', true ); } else { $sidebaroptions = get_post_meta( $post->ID, 'alpert-sidebar-option', true ); } } return is_active_sidebar( $sidebar ) ? $sidebar : 'sidebar-1'; // sidebar-1 is main sidebar. } /** * Function to add Scroll Up icon */ function alpert_scrollup() { $disable_scrollup = alpert_gtm( 'alpert_band_disable_scrollup' ); if ( $disable_scrollup ) { return; } echo '' ; } add_action( 'wp_footer', 'alpert_scrollup', 1 ); /** * Return args for specific section type */ function alpert_get_section_args( $section_name ) { $numbers = alpert_gtm( 'alpert_' . $section_name . '_number' ); $args = array( 'ignore_sticky_posts' => 1, 'posts_per_page' => absint( $numbers ), ); // If post or page or product, then set post__in argument. $post__in = array(); for( $i = 0; $i < $numbers; $i++ ) { $post__in[] = alpert_gtm( 'alpert_' . $section_name . '_page_' . $i ); } $args['post__in'] = $post__in; $args['orderby'] = 'post__in'; $args['post_type'] = 'page'; return $args; } /** * Button Border Radius CSS. */ function alpert_button_border_radius() { $border_radius = alpert_gtm( 'alpert_button_border_radius' ); if ( ! $border_radius ) { return; } $css = '.ff-button, .ff-button:visited, button, a.button, input[type="button"], input[type="reset"], input[type="submit"], .woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt { border-radius: ' . esc_attr( $border_radius ) . 'px }'; wp_add_inline_style( 'alpert-style', $css ); } add_action( 'wp_enqueue_scripts', 'alpert_button_border_radius', 11 ); /** * Display content. */ function alpert_display_content( $section ) { ?>