From baea5c69fc8d28406ed1e8cc8c6ea7a530033d7d Mon Sep 17 00:00:00 2001 From: Marco Antonio Vivas Date: Sun, 14 Sep 2025 16:13:19 -0300 Subject: [PATCH] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20do=20banner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- customizer.js | 23 +++++++++++++++++ front-page.php | 24 ++++++++++++----- functions.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ style.css | 11 ++++++++ 4 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 customizer.js diff --git a/customizer.js b/customizer.js new file mode 100644 index 0000000..9ea8b23 --- /dev/null +++ b/customizer.js @@ -0,0 +1,23 @@ +/** + * Live-previews para o Customizer do WordPress. + */ +(function ($) { + "use strict"; + + // Título do Hero + wp.customize('hero_title', function (value) { + value.bind(function (to) { + $('.hero-content h1').text(to); + }); + }); + + // Descrição do Hero + wp.customize('hero_description', function (value) { + value.bind(function (to) { + $('.hero-content p').text(to); + }); + }); + + // Você pode adicionar os botões aqui também, se desejar. + +})(jQuery); \ No newline at end of file diff --git a/front-page.php b/front-page.php index 4566290..544ebb5 100644 --- a/front-page.php +++ b/front-page.php @@ -9,17 +9,27 @@ get_header(); ?>
-
+ +
> +
diff --git a/functions.php b/functions.php index 0797624..a426db2 100644 --- a/functions.php +++ b/functions.php @@ -96,6 +96,76 @@ function newstc_scripts() { } add_action('wp_enqueue_scripts', 'newstc_scripts'); +/** + * Adiciona opções ao Personalizador do WordPress. + */ +function newstc_customize_register( $wp_customize ) { + // Seção Hero + $wp_customize->add_section('newstc_hero_section', array( + 'title' => __('Seção Hero', 'newstc'), + 'description' => __('Opções para a seção Hero na página inicial.', 'newstc'), + 'priority' => 30, + )); + + // Título + $wp_customize->add_setting('hero_title', ['default' => __('Notícias Corporativas', 'newstc'), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage']); + $wp_customize->add_control('hero_title', ['label' => __('Título', 'newstc'), 'section' => 'newstc_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', 'newstc'), 'sanitize_callback' => 'wp_kses_post', 'transport' => 'postMessage']); + $wp_customize->add_control('hero_description', ['label' => __('Descrição', 'newstc'), 'section' => 'newstc_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', 'newstc'), 'section' => 'newstc_hero_section'])); + + // Texto do Botão Primário + $wp_customize->add_setting('hero_button_primary_text', ['default' => __('Ver Notícias', 'newstc'), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage']); + $wp_customize->add_control('hero_button_primary_text', ['label' => __('Texto do Botão Primário', 'newstc'), 'section' => 'newstc_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', 'newstc'), 'section' => 'newstc_hero_section', 'type' => 'url']); + + // Texto do Botão Secundário + $wp_customize->add_setting('hero_button_secondary_text', ['default' => __('Saiba Mais', 'newstc'), 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage']); + $wp_customize->add_control('hero_button_secondary_text', ['label' => __('Texto do Botão Secundário', 'newstc'), 'section' => 'newstc_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', 'newstc'), 'section' => 'newstc_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', 'newstc_customize_register'); + +/** + * Enfileira script para o live preview do Customizer. + */ +function newstc_customizer_live_preview() { + wp_enqueue_script( + 'newstc-customizer', + get_template_directory_uri() . '/assets/js/customizer.js', + array('jquery', 'customize-preview'), + NEWSTC_VERSION, + true + ); +} +add_action('customize_preview_init', 'newstc_customizer_live_preview'); + // Registrar áreas de widgets function newstc_widgets_init() { register_sidebar(array( diff --git a/style.css b/style.css index 0fd43c5..ad9ecc9 100644 --- a/style.css +++ b/style.css @@ -407,6 +407,17 @@ p { opacity: 0.9; } +.hero-overlay { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 53, 84, 0.7); /* Overlay escuro sobre a imagem */ + z-index: 1; +} + + .hero-cta { display: flex; gap: var(--spacing-md);