MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /disk001/machen/www/support/wp-content/themes/wp-moose/inc/template-functions.php
<?php

if ( !function_exists( 'wp_moose_primary_navigation_fallback' ) ) {
    /**
     * Fallback for primary navigation.
     */
    function wp_moose_primary_navigation_fallback( $args )
    {
        echo  '<ul class="' . $args['menu_class'] . '">' ;
        echo  '<li class="menu-item"><a href="' . esc_url( home_url( '/' ) ) . '">' . esc_html__( 'Home', 'wp-moose' ) . '</a></li>' ;
        wp_list_pages( array(
            'title_li' => '',
            'depth'    => 1,
            'number'   => 5,
        ) );
        echo  '</ul>' ;
    }

}
if ( !function_exists( 'wp_moose_list_archive_image_style' ) ) {
    /**
     * Dynamic css for feature image in archive page
     *
     * @return string
     */
    function wp_moose_list_archive_image_style()
    {
        if ( get_wp_moose_option( 'wp_moose_posts_layout' ) === 'archive-grid' ) {
            return '';
        }
        $width = get_wp_moose_option( 'wp_moose_archive_list_layout_image_width' );
        if ( $width <= 0 ) {
            return '';
        }
        return sprintf( 'min-width: %1$s%%; max-width: %1$s%%;', $width );
    }

}
if ( !function_exists( 'wp_moose_post_views' ) ) {
    /**
     * Gets total post views for a post
     *
     * @param int $post_id
     *
     * @return int
     */
    function wp_moose_post_views( $post_id = 0 )
    {
        if ( function_exists( 'pvc_get_post_views' ) ) {
            return pvc_get_post_views( $post_id );
        }
        return -1;
    }

}
if ( !function_exists( 'wp_moose_render_attributes' ) ) {
    /**
     * Render html attributes
     *
     * @param $attributes
     */
    function wp_moose_render_attributes( $attributes )
    {
        $attrArr = array();
        foreach ( $attributes as $key => $value ) {
            $attrArr[] = $key . '="' . esc_attr( $value ) . '"';
        }
        // PHPCS - the output hold safe data.
        echo  implode( ' ', $attrArr ) ;
        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    }

}
if ( !function_exists( 'wp_moose_clsx' ) ) {
    /**
     * A utility for constructing className strings conditionally.
     *
     * @return string
     */
    function wp_moose_clsx( ... $args )
    {
        $classNames = array();
        foreach ( $args as $arg ) {
            
            if ( is_string( $arg ) ) {
                $classNames[] = $arg;
            } else {
                if ( is_array( $arg ) ) {
                    foreach ( $arg as $k => $v ) {
                        
                        if ( is_string( $v ) ) {
                            $classNames[] = $v;
                        } else {
                            if ( is_bool( $v ) && $v === true ) {
                                $classNames[] = $k;
                            }
                        }
                    
                    }
                }
            }
        
        }
        return esc_attr( implode( ' ', $classNames ) );
    }

}
if ( !function_exists( 'wp_moose_clsx_echo' ) ) {
    /**
     * Echo version for wp_moose_clsx
     *
     * @param ...$args
     */
    function wp_moose_clsx_echo( ... $args )
    {
        echo  wp_moose_clsx( ...$args ) ;
    }

}
if ( !function_exists( 'wp_moose_is_hero_visible' ) ) {
    /**
     * Return is hero section visible
     *
     * @return bool
     */
    function wp_moose_is_hero_visible()
    {
        return is_front_page() && !is_home() && get_wp_moose_option( 'wp_moose_show_frontpage_hero' );
    }

}
if ( !function_exists( 'wp_moose_is_frontpage_header' ) ) {
    /**
     *
     */
    function wp_moose_is_frontpage_header()
    {
        return is_front_page() && !is_home();
    }

}
if ( !function_exists( 'wp_moose_custom_logo' ) ) {
    /**
     * Get custom logo.
     */
    function wp_moose_custom_logo()
    {
        $is_frontpage_transparent_navbar = wp_moose_is_frontpage_header() && get_wp_moose_frontpage_header_style() === 'navbar-transparent';
        $main_logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
        if ( !empty($main_logo) && is_array( $main_logo ) ) {
            $main_logo = $main_logo[0];
        }
        $transparent_logo = wp_get_attachment_image_src( get_wp_moose_option( 'wp_moose_transparent_header_logo' ), 'full' );
        if ( !empty($transparent_logo) && is_array( $transparent_logo ) ) {
            $transparent_logo = $transparent_logo[0];
        }
        $transparent_reverse_logo = wp_get_attachment_image_src( get_wp_moose_option( 'wp_moose_transparent_reverse_header_logo' ), 'full' );
        if ( !empty($transparent_reverse_logo) && is_array( $transparent_reverse_logo ) ) {
            $transparent_reverse_logo = $transparent_reverse_logo[0];
        }
        // show transparent logo
        
        if ( $is_frontpage_transparent_navbar && empty($transparent_logo) === false ) {
            $attachment_id = attachment_url_to_postid( $transparent_logo );
            $alt_attribute = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
            $alt_attribute = ( !empty($alt_attribute) ? $alt_attribute : get_bloginfo( 'name' ) );
            echo  '<img class="wp-moose-transparent-logo" src="' . esc_url( $transparent_logo ) . '" alt="' . esc_attr( $alt_attribute ) . '" />' ;
            
            if ( empty($transparent_reverse_logo) === false ) {
                echo  '<img class="wp-moose-transparent-reverse-logo" src="' . esc_url( $transparent_reverse_logo ) . '" alt="' . esc_attr( $alt_attribute ) . '" />' ;
                return;
            }
        
        }
        
        $custom_logo_css = wp_moose_clsx( array( 'font-bold', 'wp-moose-custom-logo' => empty($transparent_logo) === false ) );
        // show default logo
        
        if ( empty($main_logo) === false ) {
            $alt_attribute = get_post_meta( get_theme_mod( 'custom_logo' ), '_wp_attachment_image_alt', true );
            $alt_attribute = ( !empty($alt_attribute) ? $alt_attribute : get_bloginfo( 'name' ) );
            echo  '<img class="' . $custom_logo_css . '" src="' . esc_url( $main_logo ) . '" alt="' . esc_attr( $alt_attribute ) . '" />' ;
            return;
        }
        
        // show text logo
        echo  '<span class="' . $custom_logo_css . '">' . get_wp_moose_option( 'wp_moose_text_logo' ) . '</span>' ;
    }

}
if ( !function_exists( 'wp_moose_hero_section_content' ) ) {
    /**
     * Show hero content
     */
    function wp_moose_hero_section_content()
    {
        $btn_style = array( 'btn mx-half-gutter mb-half-gutter', get_wp_moose_hero_button_style() );
        $btn_primary_text = get_wp_moose_option( 'wp_moose_hero_button_primary_text' );
        $btn_secondary_text = get_wp_moose_option( 'wp_moose_hero_button_secondary_text' );
        $content_align = wp_moose_get_text_align_css( get_wp_moose_option( 'wp_moose_hero_content_alignment' ) );
        ?>
        <div class="wp-moose-hero-content container mx-auto px-half-gutter pt-36 pb-48 <?php 
        echo  esc_attr( $content_align ) ;
        ?>">
            <h1 class="text-5xl mb-6 font-bold">
				<?php 
        echo  esc_html( get_wp_moose_option( 'wp_moose_hero_title' ) ) ;
        ?>
                <span class="wp-moose-hero-title-highlight text-primary">
                    <?php 
        echo  esc_html__( get_wp_moose_option( 'wp_moose_hero_title_highlight' ) ) ;
        ?>
                </span>
            </h1>

            <p class="text-xl font-light opacity-75">
				<?php 
        echo  esc_html( get_wp_moose_option( 'wp_moose_hero_subtitle' ) ) ;
        ?>
            </p>

            <div class="mt-20 -mx-half-gutter">
				<?php 
        
        if ( $btn_primary_text !== '' ) {
            ?>
                    <a class="<?php 
            wp_moose_clsx_echo( $btn_style );
            ?>"
                       href="<?php 
            echo  esc_url( get_wp_moose_option( 'wp_moose_hero_button_primary_url' ) ) ;
            ?>">
						<?php 
            echo  esc_html( $btn_primary_text ) ;
            ?>
                    </a>
				<?php 
        }
        
        ?>
				<?php 
        
        if ( $btn_secondary_text !== '' ) {
            ?>
                    <a class="btn-outline <?php 
            wp_moose_clsx_echo( $btn_style );
            ?>"
                       href="<?php 
            echo  esc_url( get_wp_moose_option( 'wp_moose_hero_button_secondary_url' ) ) ;
            ?>">
						<?php 
            echo  esc_html( $btn_secondary_text ) ;
            ?>
                    </a>
				<?php 
        }
        
        ?>
            </div>
        </div>
		<?php 
    }

}
if ( !function_exists( 'wp_moose_render_image_radio' ) ) {
    /**
     * Render image radio.
     *
     * @param array $args
     * @param \Closure $callback
     * @param array $callback_args
     *
     * @return string
     */
    function wp_moose_render_image_radio( $args, $callback, $callback_args = array() )
    {
        $defaults = [
            'id'       => '',
            'name'     => '',
            'selected' => 0,
            'echo'     => true,
        ];
        $r = wp_parse_args( $args, $defaults );
        $output = '';
        $choices = array();
        if ( is_callable( $callback ) ) {
            $choices = call_user_func_array( $callback, $callback_args );
        }
        
        if ( !empty($choices) ) {
            $output = '<div id="' . $r['id'] . '" class="wp-moose-image-radio-button-control">';
            foreach ( $choices as $key => $choice ) {
                $output .= '<label class="radio-button-label">';
                $output .= '<input type="radio" id="' . $r['id'] . $key . '" name="' . $r['name'] . '" value="' . $key . '" ';
                $output .= checked( $r['selected'], $key, false );
                $output .= '/>';
                $output .= '<img src="' . $choice['image'] . '" alt="' . $choice['name'] . '" title="' . $choice['name'] . '"/>';
                $output .= '</label>';
            }
            $output .= "</div>\n";
        }
        
        if ( $r['echo'] ) {
            echo  $output ;
        }
        return $output;
    }

}
if ( !function_exists( 'wp_moose_render_select_dropdown' ) ) {
    /**
     * Render select dropdown.
     *
     * @param array $args
     * @param \Closure $callback
     * @param array $callback_args
     *
     * @return string
     */
    function wp_moose_render_select_dropdown( $args, $callback, $callback_args = array() )
    {
        $defaults = [
            'id'          => '',
            'name'        => '',
            'selected'    => 0,
            'echo'        => true,
            'add_default' => false,
        ];
        $r = wp_parse_args( $args, $defaults );
        $output = '';
        $choices = array();
        if ( is_callable( $callback ) ) {
            $choices = call_user_func_array( $callback, $callback_args );
        }
        
        if ( !empty($choices) || true === $r['add_default'] ) {
            $output = "<select name='" . esc_attr( $r['name'] ) . "' id='" . esc_attr( $r['id'] ) . "'>\n";
            if ( true === $r['add_default'] ) {
                $output .= '<option value="">' . esc_html__( 'Default', 'wp-moose' ) . '</option>\\n';
            }
            if ( !empty($choices) ) {
                foreach ( $choices as $key => $choice ) {
                    $output .= '<option value="' . esc_attr( $key ) . '" ';
                    $output .= selected( $r['selected'], $key, false );
                    $output .= '>' . esc_html( $choice ) . '</option>\\n';
                }
            }
            $output .= "</select>\n";
        }
        
        if ( $r['echo'] ) {
            echo  $output ;
        }
        return $output;
    }

}