<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
/**
 * Enqueue child styles.
 */
function child_enqueue_styles() {
	wp_enqueue_style( 'child-theme', get_stylesheet_directory_uri() . '/style.css', array(), 105 );
}
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles' );

function bw_block_editor_assets() {
	wp_enqueue_style( 'bw_block_editor_style', get_stylesheet_directory_uri() . '/assets/css/block-editor.css', array(), 100 );
}
add_action( 'enqueue_block_editor_assets', 'bw_block_editor_assets' );

function bw_block_assets() {
	wp_register_script( 'slick', get_stylesheet_directory_uri() . '/assets/js/slick.min.js', array('jquery'), '1.4' );
	wp_register_style( 'slick', get_stylesheet_directory_uri() . '/assets/css/slick.css', array(), '1.4' );
}
add_action('enqueue_block_assets', 'bw_block_assets');

require_once 'acf-blocks/index.php';
require_once 'includes/extend_theme_customizer.php';
require_once 'includes/filters.php';
require_once 'includes/header_search_bar.php';
require_once 'includes/halo_products.php';


add_filter( 'post_thumbnail_html', 'wrap_partner_logo_with_acf_link', 10, 5 );
function wrap_partner_logo_with_acf_link( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
    // Only for Partners post type
    if ( get_post_type( $post_id ) === 'partners' ) {
        $partner_link = get_field( 'partner_link', $post_id );

        if ( $partner_link ) {
            $html = '<a href="' . esc_url( $partner_link ) . '" target="_blank" rel="noopener noreferrer">' . $html . '</a>';
        }
    }

    return $html;
}
