$padding_value, 'right' => $padding_value, 'bottom' => $padding_value, 'left' => $padding_value ]; } } return $parsed_block; }, 10, 1); // Exit if accessed directly if (! defined('ABSPATH')) { exit; } /** * Display the review count with proper formatting */ function blynex_product_review_count() { if (!post_type_supports('product', 'comments')) { return; } $count = (int) get_comments_number(); $text = sprintf( _n('%d customer review', '%d customer reviews', $count, 'blynex'), $count ); $review_link = get_permalink() . '#reviews'; return '' . esc_html($text) . ''; } /** * Suppress multiple text domains warning for theme check * * This is needed because WooCommerce uses its own text domain * and theme check flags this as a warning. */ function blynex_suppress_text_domain_warnings() { add_filter('override_load_textdomain', function ($retval, $domain) { if ('woocommerce' === $domain) { return true; // Skip loading WooCommerce text domain } return $retval; }, 10, 2); // Also add filter for theme check plugin add_filter('theme_check_locale_code_skip_text_domains', function ($domains) { $domains[] = 'woocommerce'; return $domains; }); } add_action('after_setup_theme', 'blynex_suppress_text_domain_warnings', 1); /** * Load theme core functionality * * The class-loader.php file contains the main theme class and autoloader. * This file initializes the theme's core functionality and sets up hooks. */ require_once get_template_directory() . '/includes/class-loader.php'; /** * Initialize the theme * * Creates a singleton instance of the main theme class. * This ensures the theme is properly initialized with all required functionality. */ if (class_exists('Blynex_Theme')) { Blynex_Theme::get_instance(); } /** * Enable custom styling options for image blocks * * This function adds theme support for spacing, colors and enables * padding, background color, and text color controls for image blocks. */ function blynex_enable_image_block_supports() { // Enable image block supports using the register_block_type_args filter add_filter('register_block_type_args', function ($args, $name) { if ($name === 'core/image' || $name === 'core/cover') { // Ensure supports array exists if (!isset($args['supports'])) { $args['supports'] = array(); } // Add spacing support $args['supports']['spacing'] = array( 'padding' => true, 'margin' => true, '__experimentalDefaultControls' => array( 'padding' => true, 'margin' => true ) ); // Add color support $args['supports']['color'] = array( 'text' => true, 'background' => true, '__experimentalDefaultControls' => array( 'text' => true, 'background' => true ) ); // Add border support $args['supports']['border'] = array( 'radius' => true, '__experimentalDefaultControls' => array( 'radius' => true ) ); } return $args; }, 10, 2); } add_action('init', 'blynex_enable_image_block_supports', 5); function blynex_enqueue_theme_scripts() { // Enqueue theme styles wp_enqueue_style('blynex-style-index', get_theme_file_uri('build/style-index.css'), array()); // Add inline CSS for skip link as backup $skip_link_css = " .skip-link { position: absolute !important; top: -40px !important; left: 6px !important; background: #000 !important; color: #fff !important; padding: 8px 16px !important; text-decoration: none !important; border-radius: 4px !important; z-index: 10000 !important; transition: top 0.3s ease !important; font-weight: bold !important; display: block !important; width: auto !important; height: auto !important; overflow: visible !important; } .skip-link:focus { top: 42px !important; outline: 2px solid #fff !important; outline-offset: 2px !important; } "; wp_add_inline_style('blynex-style-index', $skip_link_css); } add_action('wp_enqueue_scripts', 'blynex_enqueue_theme_scripts'); // Add skip link for accessibility at the very top of the body add_action('wp_body_open', function () { echo '' . esc_html__('Skip to content', 'blynex') . ''; }); /** * Debug function to verify block supports are enabled * Add ?debug_blocks=1 to any admin URL to see block configurations */ function blynex_debug_block_supports() { if (isset($_GET['debug_blocks']) && $_GET['debug_blocks'] == '1' && current_user_can('manage_options')) { echo '
' . print_r($image_block->supports ?? 'No supports found', true) . ''; echo '
' . print_r($cover_block->supports ?? 'No supports found', true) . ''; echo '
' . print_r($settings['color'] ?? 'No color settings', true) . ''; echo '
' . print_r($settings['spacing'] ?? 'No spacing settings', true) . ''; echo '