/home/bdqbpbxa/rc-subdomains/brnr-rc.goodface.com.ua/wp-content/themes/burner/inc/acf-fields.php
<?php
/**
* ACF Blocks Configuration
*
* @package burner
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
/**
* Set ACF JSON save and load paths
*/
function burner_acf_json_save_point($path) {
return get_stylesheet_directory() . '/acf-json';
}
add_filter('acf/settings/save_json', 'burner_acf_json_save_point');
function burner_acf_json_load_point($paths) {
unset($paths[0]);
$paths[] = get_stylesheet_directory() . '/acf-json';
return $paths;
}
add_filter('acf/settings/load_json', 'burner_acf_json_load_point');
/**
* Register custom block category
*/
function burner_register_block_category($categories, $post) {
return array_merge(
$categories,
array(
array(
'slug' => 'burner-blocks',
'title' => __('Burner Blocks', 'burner'),
'icon' => 'admin-home',
),
)
);
}
add_filter('block_categories_all', 'burner_register_block_category', 10, 2);
/**
* Initialize ACF blocks
*/
function burner_acf_init_block_types() {
// Check if function exists and ACF is active
if (function_exists('acf_register_block_type')) {
// Register Home Section Block
acf_register_block_type(array(
'name' => 'home-section',
'title' => __('Home Section'),
'description' => __('A custom home section block with title and description.'),
'render_template' => 'blocks/home-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-home',
'keywords' => array('home', 'section', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register About Section 1 Block
acf_register_block_type(array(
'name' => 'about-section-1',
'title' => __('About Section 1'),
'description' => __('Who we are section with title and description.'),
'render_template' => 'blocks/about-section-1.php',
'category' => 'burner-blocks',
'icon' => 'admin-users',
'keywords' => array('about', 'who', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register About Section 2 Block
acf_register_block_type(array(
'name' => 'about-section-2',
'title' => __('About Section 2'),
'description' => __('What we do section with services list.'),
'render_template' => 'blocks/about-section-2.php',
'category' => 'burner-blocks',
'icon' => 'admin-tools',
'keywords' => array('about', 'services', 'what', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register About Section 3 Block
acf_register_block_type(array(
'name' => 'about-section-3',
'title' => __('About Section 3'),
'description' => __('Our priorities section with services grid.'),
'render_template' => 'blocks/about-section-3.php',
'category' => 'burner-blocks',
'icon' => 'admin-settings',
'keywords' => array('priorities', 'services', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Portfolio Block
acf_register_block_type(array(
'name' => 'portfolio-section',
'title' => __('Portfolio Section'),
'description' => __('Portfolio section with project grid.'),
'render_template' => 'blocks/portfolio-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-media',
'keywords' => array('portfolio', 'projects', 'burner'),
'mode' => 'auto',
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Contact Section Block
acf_register_block_type(array(
'name' => 'contact-section',
'title' => __('Contact Section'),
'description' => __('Pitch us contact section.'),
'render_template' => 'blocks/contact-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-comments',
'keywords' => array('contact', 'pitch', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Referral Section Block
acf_register_block_type(array(
'name' => 'referral-section',
'title' => __('Referral Section'),
'description' => __('Referral program section.'),
'render_template' => 'blocks/referral-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-links',
'keywords' => array('referral', 'recommend', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Set Fire Section Block
acf_register_block_type(array(
'name' => 'setfire-section',
'title' => __('Set Fire Section'),
'description' => __('Final call-to-action section with footer.'),
'render_template' => 'blocks/setfire-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-generic',
'keywords' => array('setfire', 'cta', 'footer', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Referral Home Section Block
acf_register_block_type(array(
'name' => 'referral-home-section',
'title' => __('Referral Home Section'),
'description' => __('Referral program main section with title and description.'),
'render_template' => 'blocks/referral-home-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-home',
'keywords' => array('referral', 'home', 'program', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Referral Amount Section Block
acf_register_block_type(array(
'name' => 'referral-amount-section',
'title' => __('Referral Amount Section'),
'description' => __('Referral fees and process explanation section.'),
'render_template' => 'blocks/referral-amount-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-generic',
'keywords' => array('referral', 'amount', 'fees', 'process', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Referral Interested Section Block
acf_register_block_type(array(
'name' => 'referral-interested-section',
'title' => __('Referral Interested Section'),
'description' => __('Company investment interests and criteria section.'),
'render_template' => 'blocks/referral-interested-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-tools',
'keywords' => array('referral', 'interested', 'investment', 'criteria', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Referral Contact Section Block
acf_register_block_type(array(
'name' => 'referral-contact-section',
'title' => __('Referral Contact Section'),
'description' => __('Contact form section for project recommendations.'),
'render_template' => 'blocks/referral-contact-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-comments',
'keywords' => array('referral', 'contact', 'form', 'recommend', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Referral Terms Section Block
acf_register_block_type(array(
'name' => 'referral-terms-section',
'title' => __('Referral Terms Section'),
'description' => __('General terms and criteria for valid recommendations.'),
'render_template' => 'blocks/referral-terms-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-page',
'keywords' => array('referral', 'terms', 'criteria', 'conditions', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
// Register Media Section Block
acf_register_block_type(array(
'name' => 'media-section',
'title' => __('Media Section'),
'description' => __('Media about us section with logos and press kit button.'),
'render_template' => 'blocks/media-section.php',
'category' => 'burner-blocks',
'icon' => 'admin-media',
'keywords' => array('media', 'press', 'logos', 'burner'),
'mode' => 'auto',
'example' => array(
'attributes' => array(
'mode' => 'preview',
'data' => array(
'is_preview' => true
)
)
)
));
}
}
add_action('acf/init', 'burner_acf_init_block_types');
function burner_load_admin_style() {
$version = '2.6';
wp_enqueue_style('front_css', get_template_directory_uri() . '/assets/css/admin.css', [], $version);
}
// add_action("enqueue_block_editor_assets", "burner_load_admin_style", 10, 0);
function ut_get_webp($image_url) {
if ( ! wp_http_validate_url($image_url) ) {
return false;
}
if ( strpos($image_url, '.webp') == true ) {
return esc_url($image_url);
}
if ( strpos($image_url, '.svg') == true ) {
return esc_url($image_url);
}
$webp_url = str_replace("/wp-content/", "/wp-content/webp-express/webp-images/", $image_url) . '.webp';
return esc_url($webp_url);
}
class Custom_Walker_Nav_Menu extends Walker_Nav_Menu {
private $item_count = 0;
private $total_items = 0;
// Count total items before starting
function walk($elements, $max_depth, ...$args) {
$this->total_items = count($elements);
$this->item_count = 0;
return parent::walk($elements, $max_depth, ...$args);
}
function start_el(&$output, $item, $depth = 0, $args = null, $id = 0) {
$this->item_count++;
$classes = empty($item->classes) ? array() : (array) $item->classes;
$class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
$class_names = $class_names ? ' class="menu-item ' . esc_attr($class_names) . '"' : ' class="menu-item"';
$output .= '<li' . $class_names .'>';
// Create data-menuanchor from URL fragment (anchor)
$menu_anchor = '';
if (!empty($item->url) && strpos($item->url, '#') !== false) {
$menu_anchor = strtolower(str_replace('#', '', $item->url));
} else {
// Fallback to title if no anchor in URL
$menu_anchor = strtolower(trim($item->title));
}
// Remove spaces and special characters
$menu_anchor = preg_replace('/[^a-z0-9]+/', '', $menu_anchor);
// Create class for link: {title}-menu-item
$link_class = strtolower(trim($item->title));
$link_class = preg_replace('/[^a-z0-9]+/', '-', $link_class);
$link_class = trim($link_class, '-') . '-menu-item';
$attributes = ! empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
$attributes .= ' data-menuanchor="' . esc_attr($menu_anchor) . '"';
$attributes .= ' class="' . esc_attr($link_class) . '"';
$item_output = '<a' . $attributes . '>';
$item_output .= apply_filters('the_title', $item->title, $item->ID);
$item_output .= '</a>';
$output .= $item_output;
}
function end_el(&$output, $item, $depth = 0, $args = null) {
$output .= "</li>\n";
// If this is the last menu item, add LinkedIn and language switcher
if ($this->item_count == $this->total_items) {
$languages = apply_filters('wpml_active_languages', NULL, 'orderby=id&order=desc');
$output .= '<div class="linkedin-item">
<a href="https://www.linkedin.com/company/burnerfund/" target="_blank" class="linkedin-item-link"></a>
</div>';
if ($languages && count($languages) > 1) {
$output .= '<div class="language-switcher">';
foreach ($languages as $lang) {
if (!$lang['active']) {
$output .= '<a href="' . esc_url($lang['url']) . '" class="language-switcher-item">';
$output .= strtoupper($lang['translated_name']);
$output .= '</a>';
}
}
$output .= '</div>';
}
}
}
}