/*
Theme Name: Twenty Twenty-Five
Theme URI: https://wordpress.org/themes/twentytwentyfive/
Author: the WordPress team
Author URI: https://wordpress.org
Description: Twenty Twenty-Five emphasizes simplicity and adaptability. It offers flexible design options, supported by a variety of patterns for different page types, such as services and landing pages, making it ideal for building personal blogs, professional portfolios, online magazines, or business websites. Its templates cater to various blog styles, from text-focused to image-heavy layouts. Additionally, it supports international typography and diverse color palettes, ensuring accessibility and customization for users worldwide.
Requires at least: 6.7
Tested up to: 6.8
Requires PHP: 7.2
Version: 1.2
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: twentytwentyfive
Tags: one-column, custom-colors, custom-menu, custom-logo, editor-style, featured-images, full-site-editing, block-patterns, rtl-language-support, sticky-post, threaded-comments, translation-ready, wide-blocks, block-styles, style-variations, accessibility-ready, blog, portfolio, news
*/

/*
 * Link styles
 * https://github.com/WordPress/gutenberg/issues/42319
 */
a {
	text-decoration-thickness: 1px !important;
	text-underline-offset: .1em;
}

/* Focus styles */
:where(.wp-site-blocks *:focus) {
	outline-width: 2px;
	outline-style: solid;
}

/* Increase the bottom margin on submenus, so that the outline is visible. */
.wp-block-navigation .wp-block-navigation-submenu .wp-block-navigation-item:not(:last-child) {
	margin-bottom: 3px;
}

/* Increase the outline offset on the parent menu items, so that the outline does not touch the text. */
.wp-block-navigation .wp-block-navigation-item .wp-block-navigation-item__content {
	outline-offset: 4px;
}

/* Remove outline offset from the submenus, otherwise the outline is visible outside the submenu container. */
.wp-block-navigation .wp-block-navigation-item ul.wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	outline-offset: 0;
}

/*
 * Progressive enhancement to reduce widows and orphans
 * https://github.com/WordPress/gutenberg/issues/55190
 */
h1, h2, h3, h4, h5, h6, blockquote, caption, figcaption, p {
	text-wrap: pretty;
}

/*
 * Change the position of the more block on the front, by making it a block level element.
 * https://github.com/WordPress/gutenberg/issues/65934
*/
.more-link {
	display: block;
}
// Força o processamento de shortcodes em todas as áreas de texto do site
add_filter('the_content', 'do_shortcode');
add_filter('widget_custom_html_content', 'do_shortcode');
<?php
/* 
   SISTEMA PBJ POWER - INJEÇÃO DE DADOS B2B
   Lógica: Substituição de Strings em Tempo de Renderização
   👨‍💻 Releitura: Verificado para evitar loops infinitos e garantir compatibilidade com WooCommerce.
*/

add_filter( 'render_block', function( $block_content, $block ) {
    
    // FILTRO 1: Só age se o bloco for do tipo "HTML Personalizado"
    if ( 'core/html' === $block['blockName'] ) {
        
        $post_id = get_the_ID();

        // LOGICA A: Injeta a Descrição Curta (Aba Compatibilidade)
        // Se encontrar o texto "PBJ_DESCRICAO_DINAMICA", ele substitui pelo Excerpt do banco.
        if ( strpos( $block_content, 'PBJ_DESCRICAO_DINAMICA' ) !== false ) {
            $excerpt = get_the_excerpt($post_id);
            $block_content = str_replace( 'PBJ_DESCRICAO_DINAMICA', $excerpt, $block_content );
        }

        // LOGICA B: Injeta a Tabela Técnica (Aba Especificações)
        // Se encontrar o texto "PBJ_SPECS_DINAMICA", ele busca os Atributos do WooCommerce.
        if ( strpos( $block_content, 'PBJ_SPECS_DINAMICA' ) !== false ) {
            global $product;
            
            // Garante que temos o objeto do produto correto em mãos
            if ( ! is_a( $product, 'WC_Product' ) ) {
                $product = wc_get_product( $post_id );
            }
            
            if ( $product ) {
                // Captura a saída da função do Woo pq ela dá 'echo' por padrão
                ob_start();
                wc_display_product_attributes( $product );
                $specs = ob_get_clean();
                
                $block_content = str_replace( 'PBJ_SPECS_DINAMICA', $specs, $block_content );
            }
        }
    }
    
    return $block_content;
}, 10, 2 );

/* 
   Nota de Ensino: Estamos usando o filtro 'render_block'. 
   Ele é como um fiscal que olha cada 'caixa' do site antes de ela aparecer na tela.
   Se ele vê a nossa 'etiqueta' personalizada, ele troca pelo dado real do banco.

/* 
   SISTEMA PBJ POWER - MOTOR DE SINCRONIZAÇÃO FINAL
   Lógica: Localizar os "atalhos" entre colchetes e injetar os dados do WooCommerce.
*/

add_filter( 'render_block', function( $block_content, $block ) {
    
    // Só executa se for o bloco de HTML Personalizado
    if ( 'core/html' === $block['blockName'] ) {
        
        $post_id = get_the_ID();

        // 1. Troca [pbj_desc] pela Descrição Curta
        if ( strpos( $block_content, '[pbj_desc]' ) !== false ) {
            $excerpt = get_the_excerpt($post_id);
            $block_content = str_replace( '[pbj_desc]', $excerpt, $block_content );
        }

        // 2. Troca [pbj_specs] pelos Atributos Técnicos
        if ( strpos( $block_content, '[pbj_specs]' ) !== false ) {
            global $product;
            if ( ! is_a( $product, 'WC_Product' ) ) {
                $product = wc_get_product( $post_id );
            }
            
            if ( $product ) {
                ob_start();
                wc_display_product_attributes( $product );
                $specs = ob_get_clean();
                $block_content = str_replace( '[pbj_specs]', $specs, $block_content );
            }
        }
    }
    
    return $block_content;
}, 10, 2 );
*/