load_includes(); add_action('after_setup_theme', [$this, 'setup_theme']); add_action('wp_enqueue_scripts', [$this, 'enqueue_theme_styles']); add_action('init', [$this, 'register_block_bindings']); add_action('init', [$this, 'register_pattern_categories']); } /** * Load necessary files for the theme. * * Includes all required PHP files from the includes directory. */ private function load_includes() { $files = [ 'class-attributes.php', // Handles custom block attributes 'block-styles.php', // Registers custom block styles 'class-enqueue.php', // Handles asset loading ]; foreach ($files as $file) { $path = get_template_directory() . '/includes/' . $file; if (file_exists($path)) { require_once $path; } } } /** * Set up theme features and support. * * Registers theme support for various WordPress features. */ public function setup_theme() { // Load theme text domain for translations load_theme_textdomain('blynex', get_template_directory() . '/languages'); // Add support for post formats add_theme_support( 'post-formats', ['aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video'] ); } /** * Enqueue theme styles. * * Loads the main stylesheet for the theme. */ public function enqueue_theme_styles() { wp_enqueue_style( 'blynex-style', get_parent_theme_file_uri('style.css'), [], wp_get_theme()->get('Version') ); } /** * Register block bindings for dynamic content. * * Sets up custom block bindings for the theme. */ public function register_block_bindings() { register_block_bindings_source( 'blynex/format', [ 'label' => _x('Post format name', 'Label for the block binding placeholder in the editor', 'blynex'), 'get_value_callback' => [$this, 'format_binding_callback'], ] ); } /** * Callback for the post format binding. * * Returns the formatted post format name. * * @return string|null The post format name or null if standard format. */ public function format_binding_callback() { $post_format_slug = get_post_format(); if ($post_format_slug && 'standard' !== $post_format_slug) { return get_post_format_string($post_format_slug); } } /** * Register block pattern categories. * * Creates custom pattern categories for the theme. */ public function register_pattern_categories() { register_block_pattern_category( 'blynex_page', [ 'label' => __('Pages', 'blynex'), 'description' => __('A collection of full page layouts.', 'blynex'), ] ); register_block_pattern_category( 'blynex_post-format', [ 'label' => __('Post formats', 'blynex'), 'description' => __('A collection of post format patterns.', 'blynex'), ] ); } }