File: /disk001/machen/www/support/wp-content/themes/wp-moose/inc/theme-hooks.php
<?php
/**
* Document structure hooks
*/
if ( !function_exists( 'wp_moose_doctype' ) ) {
/**
* Doctype declaration.
*/
function wp_moose_doctype()
{
$clsx = apply_filters( 'wp_moose_filter_html_class', [] );
echo '<!DOCTYPE html><html ' . get_language_attributes() . ' ' . wp_moose_get_theme_attributes() . ' class="' . implode( ' ', $clsx ) . '">' ;
}
}
add_action( 'wp_moose_action_doctype', 'wp_moose_doctype', 10 );
if ( !function_exists( 'wp_moose_head' ) ) {
/**
* Head tags.
*/
function wp_moose_head()
{
?>
<meta charset="<?php
bloginfo( 'charset' );
?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="profile" href="http://gmpg.org/xfn/11">
<?php
if ( is_singular() && pings_open() ) {
?>
<link rel="pingback" href="<?php
bloginfo( 'pingback_url' );
?>">
<?php
}
}
}
add_action( 'wp_moose_action_head', 'wp_moose_head' );
if ( !function_exists( 'wp_moose_add_preloader' ) ) {
/**
* Add preloader
*/
function wp_moose_add_preloader()
{
if ( get_theme_mod( 'wp_moose_disable_preloader' ) === true ) {
return;
}
get_template_part( 'template-parts/preloader' );
}
}
add_action( 'wp_moose_action_before', 'wp_moose_add_preloader' );
/**
* Header area hook
*/
if ( !function_exists( 'wp_moose_add_header_open' ) ) {
function wp_moose_add_header_open()
{
?>
<header class="<?php
echo esc_attr( wp_moose_get_header_class() ) ;
?>">
<?php
}
}
add_action( 'wp_moose_action_before_header', 'wp_moose_add_header_open' );
if ( !function_exists( 'wp_moose_add_primary_navbar' ) ) {
/**
* Add primary navbar.
*/
function wp_moose_add_primary_navbar()
{
get_template_part( 'template-parts/header', 'navbar' );
}
}
add_action( 'wp_moose_action_header', 'wp_moose_add_primary_navbar', 30 );
if ( !function_exists( 'wp_moose_add_header_close' ) ) {
function wp_moose_add_header_close()
{
?>
</header>
<?php
}
}
add_action( 'wp_moose_action_after_header', 'wp_moose_add_header_close' );
if ( !function_exists( 'wp_moose_add_search_modal' ) ) {
function wp_moose_add_search_modal()
{
if ( get_wp_moose_option( 'wp_moose_show_header_search' ) ) {
get_template_part( 'template-parts/header', 'search-modal' );
}
}
}
add_action( 'wp_moose_action_after_header', 'wp_moose_add_search_modal' );
if ( !function_exists( 'wp_moose_add_frontpage_hero' ) ) {
/**
* Add hero section to frontpage
*/
function wp_moose_add_frontpage_hero()
{
if ( wp_moose_is_hero_visible() ) {
get_template_part( 'template-parts/frontpage', 'hero' );
}
}
}
add_action( 'wp_moose_action_after_header', 'wp_moose_add_frontpage_hero', 40 );
/**
* Content & sidebar hooks
*/
if ( !function_exists( 'wp_moose_add_primary_sidebar' ) ) {
/**
* Add primary sidebar.
*/
function wp_moose_add_primary_sidebar( $layout )
{
// Include primary sidebar.
if ( 'no-sidebar' !== $layout ) {
get_sidebar();
}
}
}
add_action( 'wp_moose_action_sidebar', 'wp_moose_add_primary_sidebar' );
if ( !function_exists( 'wp_moose_show_post_content' ) ) {
/**
* Show post content.
*/
function wp_moose_show_post_content()
{
get_template_part( 'template-parts/content', 'single' );
}
}
add_action( 'wp_moose_action_single_post', 'wp_moose_show_post_content' );
if ( !function_exists( 'wp_moose_show_page_content' ) ) {
/**
* Show page content.
*/
function wp_moose_show_page_content()
{
get_template_part( 'template-parts/content', 'page' );
}
}
add_action( 'wp_moose_action_page', 'wp_moose_show_page_content' );
if ( !function_exists( 'wp_moose_add_post_navigation' ) ) {
/**
* Add post navigation.
*/
function wp_moose_add_post_navigation()
{
the_post_navigation( [
'prev_text' => '<i class="text-sm fa fa-angle-double-left"></i><span class="px-half-gutter">%title</span>',
'next_text' => '<span class="px-half-gutter">%title</span><i class="text-sm fa fa-angle-double-right"></i>',
'screen_reader_text' => '<span class="nav-subtitle screen-reader-text">' . esc_html__( 'Page', 'wp-moose' ) . '</span>',
'class' => 'post-navigation',
] );
}
}
add_action( 'wp_moose_action_after_single_post', 'wp_moose_add_post_navigation', 10 );
if ( !function_exists( 'wp_moose_add_after_posts_widget_area' ) ) {
/**
* Add after posts widget area
*/
function wp_moose_add_after_posts_widget_area()
{
if ( is_active_sidebar( 'sidebar-after-posts-widget-area' ) ) {
echo '<div id="sidebar-after-posts-widget-area" class="widgets mt-4 py-half-gutter">' ;
dynamic_sidebar( 'sidebar-after-posts-widget-area' );
echo '</div>' ;
}
}
}
add_action( 'wp_moose_action_after_single_post', 'wp_moose_add_after_posts_widget_area', 20 );
if ( !function_exists( 'wp_moose_add_comments' ) ) {
/**
* Add post comments.
*/
function wp_moose_add_comments()
{
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
}
add_action( 'wp_moose_action_after_single_post', 'wp_moose_add_comments', 30 );
add_action( 'wp_moose_action_after_page', 'wp_moose_add_comments' );
if ( !function_exists( 'wp_moose_custom_posts_pagination' ) ) {
/**
* Posts navigation.
*/
function wp_moose_custom_posts_pagination()
{
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;
}
$navigation_args = [
'class' => 'my-gutter',
'prev_text' => '<span><i class="fa fa-angle-double-left"></i></span>',
'next_text' => '<span><i class="fa fa-angle-double-right"></i></span>',
'screen_reader_text' => '<span class="nav-subtitle screen-reader-text">' . esc_html__( 'Page', 'wp-moose' ) . ' </span>',
];
$pagination_type = get_wp_moose_option( 'wp_moose_pagination_type' );
echo '<div class="px-half-gutter mb-20">' ;
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'infinite-scroll' ) || class_exists( 'Catch_Infinite_Scroll' ) ) {
// Support infinite scroll plugins.
$navigation = get_the_posts_navigation( $navigation_args );
} elseif ( 'numeric' === $pagination_type && function_exists( 'the_posts_pagination' ) ) {
$navigation = get_the_posts_pagination( $navigation_args );
} else {
$navigation = get_the_posts_navigation( $navigation_args );
}
$navigation = str_replace( array(
'nav-links',
'page-numbers',
'nav-previous',
'nav-next',
'current',
'dots'
), array(
'btn-group justify-center',
'btn btn-md ' . get_wp_moose_pagination_style(),
'btn btn-md ' . get_wp_moose_pagination_style(),
'btn btn-md ' . get_wp_moose_pagination_style(),
'btn-active',
'btn-disabled'
), $navigation );
echo $navigation ;
echo '</div>' ;
}
}
add_action( 'wp_moose_action_posts_pagination', 'wp_moose_custom_posts_pagination' );
/**
* Footer area hooks
*/
if ( !function_exists( 'wp_moose_add_footer_widgets' ) ) {
/**
* Add footer widgets.
*/
function wp_moose_add_footer_widgets()
{
get_template_part( 'template-parts/footer', 'widgets' );
}
}
add_action( 'wp_moose_action_before_footer', 'wp_moose_add_footer_widgets', 10 );
if ( !function_exists( 'wp_moose_footer_start' ) ) {
/**
* Footer start.
*/
function wp_moose_footer_start()
{
// Check if footer is disabled.
if ( true !== apply_filters( 'wp_moose_filter_footer_status', true ) ) {
return;
}
echo '<footer class="text-sm border-t ' . get_wp_moose_footer_style() . '">' ;
echo '<div class="container mx-auto py-gutter text-center">' ;
}
}
add_action( 'wp_moose_action_before_footer', 'wp_moose_footer_start', 20 );
if ( !function_exists( 'wp_moose_footer_end' ) ) {
/**
* Footer end.
*/
function wp_moose_footer_end()
{
// Check if footer is disabled.
if ( true !== apply_filters( 'wp_moose_filter_footer_status', true ) ) {
return;
}
echo '</div></footer>' ;
}
}
add_action( 'wp_moose_action_after_footer', 'wp_moose_footer_end' );
if ( !function_exists( 'wp_moose_footer_menu' ) ) {
function wp_moose_footer_menu()
{
// Check if footer is disabled.
if ( true !== apply_filters( 'wp_moose_filter_footer_status', true ) ) {
return;
}
if ( has_nav_menu( 'footer' ) ) {
$footer_style = get_wp_moose_option( 'wp_moose_footer_style' );
$clsx = array( 'pb-4 menu menu-horizontal menu-segment clearfix', 'menu-links menu-primary' => $footer_style !== 'primary' && $footer_style !== 'secondary', 'menu-underline' => $footer_style === 'primary' || $footer_style === 'secondary' );
wp_nav_menu( array(
'theme_location' => 'footer',
'container' => 'div',
'container_class' => 'flex justify-center',
'depth' => 1,
'menu_class' => wp_moose_clsx( $clsx ),
'fallback_cb' => false,
) );
}
}
}
add_action( 'wp_moose_action_footer', 'wp_moose_footer_menu', 10 );
if ( !function_exists( 'wp_moose_footer_copyright' ) ) {
/**
* Footer copyright.
*/
function wp_moose_footer_copyright()
{
// Check if footer is disabled.
if ( true !== apply_filters( 'wp_moose_filter_footer_status', true ) ) {
return;
}
// Copyright content.
$copyright_text = get_wp_moose_option( 'wp_moose_copyright_text' );
?>
<?php
if ( !empty($copyright_text) ) {
?>
<div class="px-half-gutter inline-block">
<?php
echo wp_kses_post( $copyright_text ) ;
?>
</div>
<?php
}
}
}
add_action( 'wp_moose_action_footer', 'wp_moose_footer_copyright', 20 );
if ( !function_exists( 'wp_moose_footer_credits' ) ) {
/**
* Footer credits
*/
function wp_moose_footer_credits()
{
// Check if footer is disabled.
if ( true !== apply_filters( 'wp_moose_filter_footer_status', true ) ) {
return;
}
?>
<div class="px-half-gutter inline-block">
<?php
$theme_data = wp_get_theme();
$site_info = sprintf(
/* translators: 1: Site Title with home URL, 2: Privacy Policy Link */
_x( '%1$s %2$s', '1: Site Title with home URL, 2: Privacy Policy Link', 'wp-moose' ),
'<a class="link" href="' . esc_url( home_url( '/' ) ) . '">' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '</a>',
( function_exists( 'get_the_privacy_policy_link' ) ? get_the_privacy_policy_link() : '' )
);
$theme_info = '<span class="sep"> | </span>' . '<a class="link" target="_blank" href="' . esc_url( $theme_data->get( 'ThemeURI' ) ) . '">' . esc_html( $theme_data->get( 'Name' ) ) . '</a>' . ' ' . esc_html__( 'by', 'wp-moose' ) . ' <a class="link" target="_blank" href="' . esc_url( $theme_data->get( 'AuthorURI' ) ) . '">' . esc_html( $theme_data->get( 'Author' ) ) . '</a>';
echo $site_info . $theme_info ;
?>
</div>
<?php
}
}
add_action( 'wp_moose_action_footer', 'wp_moose_footer_credits', 30 );
if ( !function_exists( 'wp_moose_add_to_top' ) ) {
/**
* To top button.
*/
function wp_moose_add_to_top()
{
if ( get_wp_moose_option( 'wp_moose_show_to_top' ) ) {
$clsx = array(
'z-50',
'fixed',
'bottom-double-gutter',
'rounded-full',
'h-[60px]',
'w-[60px]',
'flex',
'items-center',
'justify-center',
'bg-base',
'text-base-content',
'shadow-md'
);
$clsx[] = ( is_rtl() ? 'left-double-gutter' : 'right-double-gutter' );
echo '<a href="#" id="scroll-top" class="' . wp_moose_clsx( $clsx ) . '"><i class="fa fa-angle-up"></i></a>' ;
}
}
}
add_action( 'wp_moose_action_footer', 'wp_moose_add_to_top' );