__('Menu Principal', 'terradorei'), 'footer' => __('Menu do Rodapé', 'terradorei'), )); // Suporte a widgets add_theme_support('widgets'); add_theme_support('widgets-block-editor'); // Suporte a logo personalizada add_theme_support('custom-logo', array( 'height' => 60, 'width' => 200, 'flex-height' => true, 'flex-width' => true, )); // Suporte a wide alignment no editor add_theme_support('align-wide'); // Suporte a estilos do editor add_theme_support('editor-styles'); add_editor_style('assets/css/editor-style.css'); // Suporte a core block patterns add_theme_support('core-block-patterns'); // Remover estilos padrão da galeria add_filter('use_default_gallery_style', '__return_false'); } endif; add_action('after_setup_theme', 'terradorei_setup'); // Enfileirar scripts e estilos function terradorei_scripts() { // Estilo principal wp_enqueue_style('terradorei-style', get_stylesheet_uri(), array(), TERRADOREI_VERSION); // Google Fonts wp_enqueue_style('terradorei-google-fonts', 'https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap', array(), null); // Font Awesome wp_enqueue_style('terradorei-font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css', array(), '6.4.0'); // Script principal wp_enqueue_script('terradorei-script', TERRADOREI_TEMPLATE_URI . '/assets/js/main.js', array(), TERRADOREI_VERSION, true); // Adiciona dados para scripts wp_localize_script('terradorei-script', 'terradorei_ajax', array( 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('terradorei_nonce') )); } add_action('wp_enqueue_scripts', 'terradorei_scripts'); /** * Adiciona opções ao Personalizador do WordPress. */ function terradorei_customize_register( $wp_customize ) { // Seção Hero $wp_customize->add_section('terradorei_hero_section', array( 'title' => __('Seção Hero', 'terradorei'), 'description' => __('Opções para a seção Hero na página inicial.', 'terradorei'), 'priority' => 30, )); // Título $wp_customize->add_setting('hero_title', ['default' => __('Notícias Corporativas', 'terradorei'), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage']); $wp_customize->add_control('hero_title', ['label' => __('Título', 'terradorei'), 'section' => 'terradorei_hero_section', 'type' => 'text']); // Descrição $wp_customize->add_setting('hero_description', ['default' => __('Mantenha-se atualizado com as últimas notícias e informações da empresa', 'terradorei'), 'sanitize_callback' => 'wp_kses_post', 'transport' => 'postMessage']); $wp_customize->add_control('hero_description', ['label' => __('Descrição', 'terradorei'), 'section' => 'terradorei_hero_section', 'type' => 'textarea']); // Imagem de Fundo $wp_customize->add_setting('hero_background_image', ['default' => '', 'sanitize_callback' => 'esc_url_raw']); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'hero_background_image', ['label' => __('Imagem de Fundo', 'terradorei'), 'section' => 'terradorei_hero_section'])); // Texto do Botão Primário $wp_customize->add_setting('hero_button_primary_text', ['default' => __('Ver Notícias', 'terradorei'), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage']); $wp_customize->add_control('hero_button_primary_text', ['label' => __('Texto do Botão Primário', 'terradorei'), 'section' => 'terradorei_hero_section', 'type' => 'text']); // Link do Botão Primário $wp_customize->add_setting('hero_button_primary_link', ['default' => '#', 'sanitize_callback' => 'esc_url_raw']); $wp_customize->add_control('hero_button_primary_link', ['label' => __('Link do Botão Primário', 'terradorei'), 'section' => 'terradorei_hero_section', 'type' => 'url']); // Texto do Botão Secundário $wp_customize->add_setting('hero_button_secondary_text', ['default' => __('Saiba Mais', 'terradorei'), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage']); $wp_customize->add_control('hero_button_secondary_text', ['label' => __('Texto do Botão Secundário', 'terradorei'), 'section' => 'terradorei_hero_section', 'type' => 'text']); // Link do Botão Secundário $wp_customize->add_setting('hero_button_secondary_link', ['default' => '#', 'sanitize_callback' => 'esc_url_raw']); $wp_customize->add_control('hero_button_secondary_link', ['label' => __('Link do Botão Secundário', 'terradorei'), 'section' => 'terradorei_hero_section', 'type' => 'url']); // Habilitar Live Preview $wp_customize->get_setting('hero_title')->transport = 'postMessage'; $wp_customize->get_setting('hero_description')->transport = 'postMessage'; $wp_customize->get_setting('hero_button_primary_text')->transport = 'postMessage'; $wp_customize->get_setting('hero_button_secondary_text')->transport = 'postMessage'; $wp_customize->selective_refresh->add_partial('hero_title', [ 'selector' => '.hero-content h1', 'render_callback' => function() { return get_theme_mod('hero_title'); }, ]); $wp_customize->selective_refresh->add_partial('hero_description', [ 'selector' => '.hero-content p', 'render_callback' => function() { return get_theme_mod('hero_description'); }, ]); } add_action('customize_register', 'terradorei_customize_register'); /** * Enfileira script para o live preview do Customizer. */ function terradorei_customizer_live_preview() { wp_enqueue_script( 'terradorei-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array('jquery', 'customize-preview'), TERRADOREI_VERSION, true ); } add_action('customize_preview_init', 'terradorei_customizer_live_preview'); // Registrar áreas de widgets function terradorei_widgets_init() { register_sidebar(array( 'name' => __('Sidebar Principal', 'terradorei'), 'id' => 'sidebar-1', 'description' => __('Widgets que aparecem na sidebar principal.', 'terradorei'), 'before_widget' => '
', 'before_title' => 'Font Awesome' ); ?>
'Início', 'post_content' => 'Esta é a sua página inicial. Edite-a para adicionar seu próprio conteúdo.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed', 'ping_status' => 'closed', ) ); } else { $home_page_id = $home_page->ID; } // Verifica se a página 'Blog' já existe $blog_page = get_page_by_title( 'Blog' ); if ( ! $blog_page ) { $blog_page_id = wp_insert_post( array( 'post_title' => 'Blog', 'post_content' => 'Esta página exibirá suas últimas notícias.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed', 'ping_status' => 'closed', ) ); } else { $blog_page_id = $blog_page->ID; } // Define as páginas nas configurações de Leitura do WordPress if ( isset( $home_page_id ) && isset( $blog_page_id ) ) { update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $home_page_id ); update_option( 'page_for_posts', $blog_page_id ); } } add_action( 'after_switch_theme', 'terradorei_setup_default_pages' );