<?php

if( ! function_exists('zbr_photoswipe')) {
    function zbr_photoswipe(){
        load_template(ZBR_DIR . '/templates/single-zbr_news/photoswipe.php');
    }
}


function zbr_setup_news_data($post){
    unset( $GLOBALS['newsArticle'] );

    if ( is_int( $post ) ) {
        $post = get_post( $post );
    }

    if ( empty( $post->post_type ) || ! in_array( $post->post_type, array( 'zbr_news' ), true ) ) {
        return;
    }

    $GLOBALS['newsArticle'] = zbr_get_news_article( $post );

    return $GLOBALS['newsArticle'];
}

if(!is_admin()){
    add_action( 'the_post', 'zbr_setup_news_data' );
}