<?php
/**
 * Created by PhpStorm.
 * User: adiardana
 * Date: 20/03/19
 * Time: 13.07
 */

function myprefix_cpt_entry_blocks( $blocks ) {
    $blocks = [];
    $blocks['header'] = function(){
        $id = get_the_ID();
        $title = get_the_title($id);
        $link = get_permalink($id);
        $img = wp_get_attachment_image_url(get_post_thumbnail_id($id), 'large');
        ?>
        <div class="cpt-entry-media entry-media clr ">
            <a href="<?php echo $link;?>" title="<?php echo $title;?>" rel="bookmark" class="cpt-entry-media-link" style="background-image: url(<?php echo $img;?>);"></a>
        </div>
        <?php
    };
    $blocks['content'] = function(){
        $id = get_the_ID();
        $title = get_the_title($id);
        $link = get_permalink($id);
        $excerpt = get_the_excerpt($id);
        if(!$excerpt){
            $excerpt = get_post_field('post_content', $id);
        }
        $excerpt = cft_trim($excerpt, 150);
        ?>
        <div class="archive-content equal-height">
            <header class="cpt-entry-header wpex-clr">
                <h2 class="cpt-entry-title entry-title">
                    <a href="<?php echo $link;?>" rel="bookmark"><?php echo $title;?></a>
                </h2>
            </header>
            <div class="cpt-entry-excerpt entry-excerpt wpex-clr">
                <p><?php echo $excerpt;?></p>
            </div>
        </div>
        <?php
    };

    // Return blocks
    return $blocks;

}
//add_filter( 'wpex_client_entry_blocks', 'myprefix_cpt_entry_blocks' );

/*
add_action('wpex_hook_content_bottom', function(){
    if(is_archive()){
        $cpt = get_post_type();
        echo '<div class="cft-pagination-button"><a href="#" class="button btn-light">Read more '.$cpt.'</a></div>';
    }
});
*/