post_content, '' ) ); $format = ( false !== get_post_format() ) ? get_post_format() : 'standard'; $show_excerpt = ( 'excerpt' === generate_get_option( 'post_content' ) ) ? true : false; $show_excerpt = ( 'standard' !== $format ) ? false : $show_excerpt; $show_excerpt = ( $more_tag ) ? false : $show_excerpt; $show_excerpt = ( is_search() ) ? true : $show_excerpt; return apply_filters( 'generate_show_excerpt', $show_excerpt ); } } if ( ! function_exists( 'generate_show_title' ) ) { /** * Check to see if we should show our page/post title or not. * * @since 1.3.18 * * @return bool Whether to show the content title. */ function generate_show_title() { return apply_filters( 'generate_show_title', true ); } } /** * Check whether we should display the entry header or not. * * @since 3.0.0 */ function generate_show_entry_header() { $show_entry_header = true; $show_title = generate_show_title(); $has_before_entry_title = has_action( 'generate_before_entry_title' ); $has_after_entry_title = has_action( 'generate_after_entry_title' ); if ( is_page() ) { $has_before_entry_title = has_action( 'generate_before_page_title' ); $has_after_entry_title = has_action( 'generate_after_page_title' ); } if ( ! $show_title && ! $has_before_entry_title && ! $has_after_entry_title ) { $show_entry_header = false; } return apply_filters( 'generate_show_entry_header', $show_entry_header ); } if ( ! function_exists( 'generate_get_premium_url' ) ) { /** * Generate a URL to our premium add-ons. * Allows the use of a referral ID and campaign. * * @since 1.3.42 * * @param string $url URL to premium page. * @param bool $trailing_slash Whether we want to include a trailing slash. * @return string The URL to generatepress.com. */ function generate_get_premium_url( $url = 'https://generatepress.com/premium', $trailing_slash = true ) { if ( $trailing_slash ) { $url = trailingslashit( $url ); } $args = apply_filters( 'generate_premium_url_args', array( 'ref' => null, 'campaign' => null, ) ); if ( isset( $args['ref'] ) ) { $url = add_query_arg( 'ref', absint( $args['ref'] ), $url ); } if ( isset( $args['campaign'] ) ) { $url = add_query_arg( 'campaign', sanitize_text_field( $args['campaign'] ), $url ); } return esc_url( $url ); } } if ( ! function_exists( 'generate_padding_css' ) ) { /** * Shorten our padding/margin values into shorthand form. * * @since 0.1 * * @param int $top Top spacing. * @param int $right Right spacing. * @param int $bottom Bottom spacing. * @param int $left Left spacing. * @return string Element spacing values. */ function generate_padding_css( $top, $right, $bottom, $left ) { $padding_top = ( isset( $top ) && '' !== $top ) ? absint( $top ) . 'px ' : '0px '; $padding_right = ( isset( $right ) && '' !== $right ) ? absint( $right ) . 'px ' : '0px '; $padding_bottom = ( isset( $bottom ) && '' !== $bottom ) ? absint( $bottom ) . 'px ' : '0px '; $padding_left = ( isset( $left ) && '' !== $left ) ? absint( $left ) . 'px' : '0px'; if ( ( absint( $padding_top ) === absint( $padding_right ) ) && ( absint( $padding_right ) === absint( $padding_bottom ) ) && ( absint( $padding_bottom ) === absint( $padding_left ) ) ) { return $padding_left; } return $padding_top . $padding_right . $padding_bottom . $padding_left; } } if ( ! function_exists( 'generate_get_link_url' ) ) { /** * Return the post URL. * * Falls back to the post permalink if no URL is found in the post. * * @since 1.2.5 * * @see get_url_in_content() * @return string The Link format URL. */ function generate_get_link_url() { $has_url = get_url_in_content( get_the_content() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Core filter name. return $has_url ? $has_url : apply_filters( 'the_permalink', get_permalink() ); } } if ( ! function_exists( 'generate_get_navigation_location' ) ) { /** * Get the location of the navigation and filter it. * * @since 1.3.41 * * @return string The primary menu location. */ function generate_get_navigation_location() { return apply_filters( 'generate_navigation_location', generate_get_option( 'nav_position_setting' ) ); } } /** * Check if the logo and site branding are active. * * @since 2.3 */ function generate_has_logo_site_branding() { $has_site_title = ! generate_get_option( 'hide_title' ) && get_bloginfo( 'title' ); $has_site_tagline = ! generate_get_option( 'hide_tagline' ) && get_bloginfo( 'description' ); if ( get_theme_mod( 'custom_logo' ) && ( $has_site_title || $has_site_tagline ) ) { return true; } return false; } /** * Create SVG icons. * * @since 2.3 * * @param string $icon The icon to get. * @param bool $replace Whether we're replacing an icon on action (click). */ function generate_get_svg_icon( $icon, $replace = false ) { if ( 'svg' !== generate_get_option( 'icons' ) ) { return; } $output = ''; if ( 'menu-bars' === $icon ) { $output = ''; } if ( 'close' === $icon ) { $output = ''; } if ( 'search' === $icon ) { $output = ''; } if ( 'categories' === $icon ) { $output = ''; } if ( 'tags' === $icon ) { $output = ''; } if ( 'comments' === $icon ) { $output = ''; } if ( 'arrow' === $icon ) { $output = ''; } if ( 'arrow-right' === $icon ) { $output = ' '; } if ( 'arrow-left' === $icon ) { $output = ' '; } if ( 'arrow-up' === $icon ) { $output = ' '; } if ( $replace ) { $output .= ''; } $output = apply_filters( 'generate_svg_icon_element', $output, $icon ); $classes = array( 'gp-icon', 'icon-' . $icon, ); $output = sprintf( '%2$s', implode( ' ', $classes ), $output ); return apply_filters( 'generate_svg_icon', $output, $icon ); } /** * Out our icon HTML. * * @since 2.3 * * @param string $icon The icon to print. * @param bool $replace Whether to include the close icon to be shown using JS. */ function generate_do_svg_icon( $icon, $replace = false ) { echo generate_get_svg_icon( $icon, $replace ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function. } /** * Get our media queries. * * @since 2.4 * * @param string $name Name of the media query. * @return string The full media query. */ function generate_get_media_query( $name ) { $desktop = apply_filters( 'generate_desktop_media_query', '(min-width:1025px)' ); $tablet = apply_filters( 'generate_tablet_media_query', '(min-width: 769px) and (max-width: 1024px)' ); $mobile = apply_filters( 'generate_mobile_media_query', '(max-width:768px)' ); $mobile_menu = apply_filters( 'generate_mobile_menu_media_query', $mobile ); $queries = apply_filters( 'generate_media_queries', array( 'desktop' => $desktop, 'tablet' => $tablet, 'mobile' => $mobile, 'mobile-menu' => $mobile_menu, ) ); return $queries[ $name ]; } /** * Display HTML classes for an element. * * @since 2.2 * * @param string $context The element we're targeting. * @param string|array $class One or more classes to add to the class list. */ function generate_do_element_classes( $context, $class = '' ) { $after = apply_filters( 'generate_after_element_class_attribute', '', $context ); if ( $after ) { $after = ' ' . $after; } echo 'class="' . join( ' ', generate_get_element_classes( $context, $class ) ) . '"' . $after; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function. } /** * Retrieve HTML classes for an element. * * @since 2.2 * * @param string $context The element we're targeting. * @param string|array $class One or more classes to add to the class list. * @return array Array of classes. */ function generate_get_element_classes( $context, $class = '' ) { $classes = array(); if ( ! empty( $class ) ) { if ( ! is_array( $class ) ) { $class = preg_split( '#\s+#', $class ); } $classes = array_merge( $classes, $class ); } $classes = array_map( 'esc_attr', $classes ); return apply_filters( "generate_{$context}_class", $classes, $class ); } /** * Get the kind of schema we're using. * * @since 3.0.0 */ function generate_get_schema_type() { return apply_filters( 'generate_schema_type', 'microdata' ); } /** * Get any necessary microdata. * * @since 2.2 * * @param string $context The element to target. * @return string Our final attribute to add to the element. */ function generate_get_microdata( $context ) { $data = false; if ( 'microdata' !== generate_get_schema_type() ) { return false; } if ( 'body' === $context ) { $type = 'WebPage'; if ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) { $type = 'Blog'; } if ( is_search() ) { $type = 'SearchResultsPage'; } $type = apply_filters( 'generate_body_itemtype', $type ); $data = sprintf( 'itemtype="https://schema.org/%s" itemscope', esc_html( $type ) ); } if ( 'header' === $context ) { $data = 'itemtype="https://schema.org/WPHeader" itemscope'; } if ( 'navigation' === $context ) { $data = 'itemtype="https://schema.org/SiteNavigationElement" itemscope'; } if ( 'article' === $context ) { $type = apply_filters( 'generate_article_itemtype', 'CreativeWork' ); $data = sprintf( 'itemtype="https://schema.org/%s" itemscope', esc_html( $type ) ); } if ( 'post-author' === $context ) { $data = 'itemprop="author" itemtype="https://schema.org/Person" itemscope'; } if ( 'comment-body' === $context ) { $data = 'itemtype="https://schema.org/Comment" itemscope'; } if ( 'comment-author' === $context ) { $data = 'itemprop="author" itemtype="https://schema.org/Person" itemscope'; } if ( 'sidebar' === $context ) { $data = 'itemtype="https://schema.org/WPSideBar" itemscope'; } if ( 'footer' === $context ) { $data = 'itemtype="https://schema.org/WPFooter" itemscope'; } if ( $data ) { return apply_filters( "generate_{$context}_microdata", $data ); } } /** * Output our microdata for an element. * * @since 2.2 * * @param string $context The element to target. */ function generate_do_microdata( $context ) { echo generate_get_microdata( $context ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function. } /** * Whether to print hAtom output or not. * * @since 3.0.0 */ function generate_is_using_hatom() { return apply_filters( 'generate_is_using_hatom', true ); } /** * Check whether we're using the Flexbox structure. * * @since 3.0.0 */ function generate_is_using_flexbox() { // No flexbox for old versions of GPP. if ( defined( 'GP_PREMIUM_VERSION' ) && version_compare( GP_PREMIUM_VERSION, '1.11.0-alpha.1', '<' ) ) { return false; } return 'flexbox' === generate_get_option( 'structure' ); } /** * Check if we have any menu bar items. * * @since 3.0.0 */ function generate_has_menu_bar_items() { return has_action( 'generate_menu_bar_items' ); } /** * Check if we should include the default template part. * * @since 3.0.0 * @param string $template The template to get. */ function generate_do_template_part( $template ) { /** * generate_before_do_template_part hook. * * @since 3.0.0 * @param string $template The template. */ do_action( 'generate_before_do_template_part', $template ); if ( apply_filters( 'generate_do_template_part', true, $template ) ) { if ( 'archive' === $template || 'index' === $template ) { get_template_part( 'content', get_post_format() ); } if ( 'page' === $template ) { get_template_part( 'content', 'page' ); } if ( 'single' === $template ) { get_template_part( 'content', 'single' ); } if ( 'search' === $template ) { get_template_part( 'content', 'search' ); } if ( '404' === $template ) { get_template_part( 'content', '404' ); } if ( 'none' === $template ) { get_template_part( 'no-results' ); } } /** * generate_after_do_template_parts hook. * * @since 3.0.0 * @param string $template The template. */ do_action( 'generate_after_do_template_part', $template ); } /** * Check if we should use inline mobile navigation. * * @since 3.0.0 */ function generate_has_inline_mobile_toggle() { $has_inline_mobile_toggle = generate_is_using_flexbox() && ( 'nav-float-right' === generate_get_navigation_location() || 'nav-float-left' === generate_get_navigation_location() ); return apply_filters( 'generate_has_inline_mobile_toggle', $has_inline_mobile_toggle ); } /** * Build our the_title() parameters. * * @since 3.0.0 */ function generate_get_the_title_parameters() { $params = array( 'before' => sprintf( '

', 'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : '' ), 'after' => '

', ); if ( ! is_singular() ) { $params = array( 'before' => sprintf( '

', esc_url( get_permalink() ), 'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : '' ), 'after' => '

', ); } if ( 'link' === get_post_format() ) { $params = array( 'before' => sprintf( '

', esc_url( generate_get_link_url() ), 'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : '' ), 'after' => '

', ); } return apply_filters( 'generate_get_the_title_parameters', $params ); } /** * Check whether we should display the default loop or not. * * @since 3.0.0 */ function generate_has_default_loop() { return apply_filters( 'generate_has_default_loop', true ); } /** * Detemine whether to output site branding container. * * @since 3.0.0 */ function generate_needs_site_branding_container() { $container = false; if ( generate_has_logo_site_branding() ) { if ( generate_is_using_flexbox() || generate_get_option( 'inline_logo_site_branding' ) ) { $container = true; } } return $container; }