* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Adds the meta tag to the site header.
*
* @since 1.0.0
*/
function sinatra_meta_viewport() {
echo '';
}
add_action( 'wp_head', 'sinatra_meta_viewport', 1 );
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*
* @since 1.0.0
*/
function sinatra_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( '' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) );
}
}
add_action( 'wp_head', 'sinatra_pingback_header' );
/**
* Adds the meta tag for website accent color.
*
* @since 1.0.0
*/
function sinatra_meta_theme_color() {
$color = sinatra_option( 'accent_color' );
if ( $color ) {
printf( '', esc_attr( $color ) );
}
}
add_action( 'wp_head', 'sinatra_meta_theme_color' );
/**
* Outputs the theme top bar area.
*
* @since 1.0.0
*/
function sinatra_topbar_output() {
if ( ! sinatra_is_top_bar_displayed() ) {
return;
}
get_template_part( 'template-parts/topbar/topbar' );
}
add_action( 'sinatra_header', 'sinatra_topbar_output', 10 );
/**
* Outputs the top bar widgets.
*
* @since 1.0.0
* @param string $location Widget location in top bar.
*/
function sinatra_topbar_widgets_output( $location ) {
do_action( 'sinatra_top_bar_widgets_before_' . $location );
$sinatra_top_bar_widgets = sinatra_option( 'top_bar_widgets' );
if ( is_array( $sinatra_top_bar_widgets ) && ! empty( $sinatra_top_bar_widgets ) ) {
foreach ( $sinatra_top_bar_widgets as $widget ) {
if ( ! isset( $widget['values'] ) ) {
continue;
}
if ( $location !== $widget['values']['location'] ) {
continue;
}
if ( function_exists( 'sinatra_top_bar_widget_' . $widget['type'] ) ) {
$classes = array();
$classes[] = 'si-topbar-widget__' . esc_attr( $widget['type'] );
$classes[] = 'si-topbar-widget';
if ( isset( $widget['values']['visibility'] ) && $widget['values']['visibility'] ) {
$classes[] = 'sinatra-' . esc_attr( $widget['values']['visibility'] );
}
$classes = apply_filters( 'sinatra_topbar_widget_classes', $classes, $widget );
$classes = trim( implode( ' ', $classes ) );
printf( '
', esc_attr( $classes ) );
call_user_func( 'sinatra_top_bar_widget_' . $widget['type'], $widget['values'] );
printf( '
' );
}
}
}
do_action( 'sinatra_top_bar_widgets_after_' . $location );
}
add_action( 'sinatra_topbar_widgets', 'sinatra_topbar_widgets_output' );
/**
* Outputs the theme header area.
*
* @since 1.0.0
*/
function sinatra_header_output() {
if ( ! sinatra_is_header_displayed() ) {
return;
}
get_template_part( 'template-parts/header/base' );
}
add_action( 'sinatra_header', 'sinatra_header_output', 20 );
/**
* Outputs the header widgets in Header Widget Locations.
*
* @since 1.0.0
* @param string $locations Widget location.
*/
function sinatra_header_widgets( $locations ) {
$locations = (array) $locations;
$all_widgets = (array) sinatra_option( 'header_widgets' );
$header_widgets = $all_widgets;
$header_class = '';
if ( ! empty( $locations ) ) {
$header_widgets = array();
foreach ( $locations as $location ) {
$header_class = ' sinatra-widget-location-' . $location;
$header_widgets[ $location ] = array();
if ( ! empty( $all_widgets ) ) {
foreach ( $all_widgets as $i => $widget ) {
if ( $location === $widget['values']['location'] ) {
$header_widgets[ $location ][] = $widget;
}
}
}
}
}
echo '';
}
add_action( 'sinatra_header_widget_location', 'sinatra_header_widgets', 1 );
/**
* Outputs the content of theme header.
*
* @since 1.0.0
*/
function sinatra_header_content_output() {
// Get the selected header layout from Customizer.
$header_layout = sinatra_option( 'header_layout' );
?>
', esc_attr( $classes ) );
call_user_func( 'sinatra_copyright_widget_' . $widget['type'], $widget['values'] );
printf( '' );
}
}
}
do_action( 'sinatra_copyright_widgets_after_' . $location );
}
add_action( 'sinatra_copyright_widgets', 'sinatra_copyright_widgets_output' );
/**
* Outputs the theme sidebar area.
*
* @since 1.0.0
*/
function sinatra_sidebar_output() {
if ( sinatra_is_sidebar_displayed() ) {
get_sidebar();
}
}
add_action( 'sinatra_sidebar', 'sinatra_sidebar_output' );
/**
* Outputs the back to top button.
*
* @since 1.0.0
*/
function sinatra_back_to_top_output() {
if ( ! sinatra_option( 'enable_scroll_top' ) ) {
return;
}
get_template_part( 'template-parts/misc/back-to-top' );
}
add_action( 'sinatra_after_page_wrapper', 'sinatra_back_to_top_output' );
/**
* Outputs the theme page content.
*
* @since 1.0.0
*/
function sinatra_page_header_template() {
do_action( 'sinatra_before_page_header' );
if ( sinatra_is_page_header_displayed() ) {
if ( is_singular( 'post' ) ) {
get_template_part( 'template-parts/header-page-title-single' );
} else {
get_template_part( 'template-parts/header-page-title' );
}
}
do_action( 'sinatra_after_page_header' );
}
add_action( 'sinatra_page_header', 'sinatra_page_header_template' );
/**
* Outputs the theme hero content.
*
* @since 1.0.0
*/
function sinatra_hero() {
if ( ! sinatra_is_hero_displayed() ) {
return;
}
// Hero type.
$hero_type = sinatra_option( 'hero_type' );
do_action( 'sinatra_before_hero' );
// Enqueue Sinatra Slider script.
wp_enqueue_script( 'sinatra-slider' );
?>
>
'',
'container_after' => '
',
);
sinatra_breadcrumb( $args );
}
}
add_action( 'sinatra_main_start', 'sinatra_breadcrumb_after_header_output' );
/**
* Outputs breadcumbs in page header.
*
* @since 1.1.0
* @return void
*/
function sinatra_breadcrumb_page_header_output() {
if ( sinatra_page_header_has_breadcrumbs() ) {
if ( is_singular( 'post' ) ) {
$args = array(
'container_before' => '',
'container_after' => '
',
);
} else {
$args = array(
'container_before' => '',
'container_after' => '
',
);
}
sinatra_breadcrumb( $args );
}
}
add_action( 'sinatra_page_header_end', 'sinatra_breadcrumb_page_header_output' );
/**
* Replace tranparent header logo.
*
* @since 1.1.1
* @param string $output Current logo markup.
* @return string Update logo markup.
*/
function sinatra_transparent_header_logo( $output ) {
// Check if transparent header is displayed.
if ( sinatra_is_header_transparent() ) {
// Check if transparent logo is set.
$logo = sinatra_option( 'tsp_logo' );
$logo = isset( $logo['background-image-id'] ) ? $logo['background-image-id'] : false;
$retina = sinatra_option( 'tsp_logo_retina' );
$retina = isset( $retina['background-image-id'] ) ? $retina['background-image-id'] : false;
if ( $logo ) {
$output = sinatra_get_logo_img_output( $logo, $retina, 'si-tsp-logo' );
}
}
return $output;
}
add_filter( 'sinatra_logo_img_output', 'sinatra_transparent_header_logo' );
add_filter( 'sinatra_site_title_markup', 'sinatra_transparent_header_logo' );
/**
* Output the main navigation template.
*/
function sinatra_main_navigation_template() {
get_template_part( 'template-parts/header/navigation' );
}
/**
* Output the Header logo template.
*/
function sinatra_header_logo_template() {
get_template_part( 'template-parts/header/logo' );
}