$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); /** * 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 '