60, 'width' => 200, 'flex-width' => true, 'flex-height' => true, ] ); add_theme_support( 'custom-header', [ 'default-image' => '', 'width' => 1920, 'height' => 600, 'flex-width' => true, 'flex-height' => true, ] ); add_theme_support( 'custom-background', [ 'default-color' => '080810', ] ); add_theme_support( 'wp-block-styles' ); add_theme_support( 'responsive-embeds' ); add_theme_support( 'align-wide' ); add_editor_style( 'assets/css/editor-style.css' ); register_nav_menus( [ 'primary' => __( 'Menu Principal', 'rawcode' ), ] ); } add_action( 'after_setup_theme', 'rawcode_setup' ); /* ------------------------------------------------------- BLOCK STYLES & PATTERNS ------------------------------------------------------- */ function rawcode_block_styles() { register_block_style( 'core/button', [ 'name' => 'rawcode-primary', 'label' => __( 'RAWCODE Primary', 'rawcode' ), ] ); } add_action( 'init', 'rawcode_block_styles' ); function rawcode_block_patterns() { register_block_pattern( 'rawcode/cta-whatsapp', [ 'title' => __( 'CTA WhatsApp', 'rawcode' ), 'description' => __( 'Botão de chamada para ação com WhatsApp', 'rawcode' ), 'content' => '

Entre em contato pelo WhatsApp!

', ] ); } add_action( 'init', 'rawcode_block_patterns' ); /* ------------------------------------------------------- ENQUEUE STYLES & SCRIPTS ------------------------------------------------------- */ function rawcode_enqueue() { wp_enqueue_style( 'rawcode-fonts', 'https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;700&display=swap', [], null ); wp_enqueue_style( 'rawcode-style', get_stylesheet_uri(), [], RAWCODE_VERSION ); wp_enqueue_style( 'rawcode-main', RAWCODE_URI . '/assets/css/main.css', [ 'rawcode-style' ], RAWCODE_VERSION ); wp_enqueue_script( 'rawcode-main', RAWCODE_URI . '/assets/js/main.js', [], RAWCODE_VERSION, true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } wp_localize_script( 'rawcode-main', 'rawcodeData', [ 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'rawcode_nonce' ), ] ); } add_action( 'wp_enqueue_scripts', 'rawcode_enqueue' ); /* ------------------------------------------------------- WIDGETS / SIDEBARS ------------------------------------------------------- */ function rawcode_widgets_init() { register_sidebar( [ 'name' => __( 'Sidebar Principal', 'rawcode' ), 'id' => 'sidebar-1', 'description' => __( 'Adicione widgets aqui.', 'rawcode' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ] ); } add_action( 'widgets_init', 'rawcode_widgets_init' ); /* ------------------------------------------------------- CUSTOMIZER OPTIONS ------------------------------------------------------- */ function rawcode_customizer( $wp_customize ) { $wp_customize->add_panel( 'rawcode_panel', [ 'title' => __( 'RAWCODE — Configurações', 'rawcode' ), 'priority' => 10, ] ); // Hero $wp_customize->add_section( 'rawcode_hero', [ 'title' => __( 'Hero', 'rawcode' ), 'panel' => 'rawcode_panel' ] ); rawcode_add_text( $wp_customize, 'hero_tag', 'rawcode_hero', __('Tag', 'rawcode'), 'Desenvolvimento Web Profissional' ); rawcode_add_text( $wp_customize, 'hero_title1', 'rawcode_hero', __('Título Linha 1', 'rawcode'), 'SITES QUE' ); rawcode_add_text( $wp_customize, 'hero_title2', 'rawcode_hero', __('Título Destaque', 'rawcode'), 'VENDEM' ); rawcode_add_text( $wp_customize, 'hero_title3', 'rawcode_hero', __('Título Linha 3', 'rawcode'), 'DE VERDADE' ); rawcode_add_textarea( $wp_customize, 'hero_desc', 'rawcode_hero', __('Descrição', 'rawcode'), 'Criamos sites e lojas virtuais de alta performance para empresas que levam o digital a sério.' ); rawcode_add_text( $wp_customize, 'hero_cta', 'rawcode_hero', __('Texto CTA', 'rawcode'), 'Quero meu site' ); rawcode_add_text( $wp_customize, 'hero_stat1_num', 'rawcode_hero', __('Stat 1 Número', 'rawcode'), '50+' ); rawcode_add_text( $wp_customize, 'hero_stat1_lbl', 'rawcode_hero', __('Stat 1 Label', 'rawcode'), 'Projetos entregues' ); rawcode_add_text( $wp_customize, 'hero_stat2_num', 'rawcode_hero', __('Stat 2 Número', 'rawcode'), '100%' ); rawcode_add_text( $wp_customize, 'hero_stat2_lbl', 'rawcode_hero', __('Stat 2 Label', 'rawcode'), 'Responsivo & rápido' ); rawcode_add_text( $wp_customize, 'hero_stat3_num', 'rawcode_hero', __('Stat 3 Número', 'rawcode'), '7d' ); rawcode_add_text( $wp_customize, 'hero_stat3_lbl', 'rawcode_hero', __('Stat 3 Label', 'rawcode'), 'Prazo de entrega' ); // Contato $wp_customize->add_section( 'rawcode_contact', [ 'title' => __( 'Contato', 'rawcode' ), 'panel' => 'rawcode_panel' ] ); rawcode_add_text( $wp_customize, 'whatsapp_number', 'rawcode_contact', __('WhatsApp (ex: 5511999999999)', 'rawcode'), '5511999999999' ); rawcode_add_text( $wp_customize, 'whatsapp_msg', 'rawcode_contact', __('Mensagem padrão WhatsApp', 'rawcode'), 'Olá! Quero um orçamento para meu site.' ); rawcode_add_text( $wp_customize, 'contact_email', 'rawcode_contact', __('E-mail de contato', 'rawcode'), 'contato@rawcode.com.br' ); // Cores $wp_customize->add_section( 'rawcode_colors', [ 'title' => __( 'Cores', 'rawcode' ), 'panel' => 'rawcode_panel' ] ); rawcode_add_color( $wp_customize, 'color_accent', 'rawcode_colors', __('Cor de Destaque', 'rawcode'), '#00f5c4' ); rawcode_add_color( $wp_customize, 'color_accent2', 'rawcode_colors', __('Cor Secundária', 'rawcode'), '#7b6cff' ); rawcode_add_color( $wp_customize, 'color_bg', 'rawcode_colors', __('Fundo Principal', 'rawcode'), '#080810' ); } add_action( 'customize_register', 'rawcode_customizer' ); function rawcode_add_text( $c, $id, $section, $label, $default ) { $c->add_setting( $id, [ 'default' => $default, 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'refresh' ] ); $c->add_control( $id, [ 'label' => $label, 'section' => $section, 'type' => 'text' ] ); } function rawcode_add_textarea( $c, $id, $section, $label, $default ) { $c->add_setting( $id, [ 'default' => $default, 'sanitize_callback' => 'sanitize_textarea_field', 'transport' => 'refresh' ] ); $c->add_control( $id, [ 'label' => $label, 'section' => $section, 'type' => 'textarea' ] ); } function rawcode_add_color( $c, $id, $section, $label, $default ) { $c->add_setting( $id, [ 'default' => $default, 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage' ] ); $c->add_control( new WP_Customize_Color_Control( $c, $id, [ 'label' => $label, 'section' => $section ] ) ); } /* ------------------------------------------------------- DYNAMIC CSS ------------------------------------------------------- */ function rawcode_dynamic_css() { $accent = get_theme_mod( 'color_accent', '#00f5c4' ); $accent2 = get_theme_mod( 'color_accent2', '#7b6cff' ); $bg = get_theme_mod( 'color_bg', '#080810' ); echo "" . "\n"; } add_action( 'wp_head', 'rawcode_dynamic_css' ); /* ------------------------------------------------------- CONTACT FORM AJAX ------------------------------------------------------- */ function rawcode_handle_contact() { check_ajax_referer( 'rawcode_nonce', 'nonce' ); $name = sanitize_text_field( $_POST['name'] ?? '' ); $email = sanitize_email( $_POST['email'] ?? '' ); $service = sanitize_text_field( $_POST['service'] ?? '' ); $message = sanitize_textarea_field( $_POST['message'] ?? '' ); if ( ! $name || ! is_email( $email ) ) { wp_send_json_error( [ 'message' => 'Dados inválidos.' ] ); } $to = get_theme_mod( 'contact_email', get_option( 'admin_email' ) ); $subject = "Novo contato via site — {$name}"; $body = "Nome: {$name}\nE-mail: {$email}\nServiço: {$service}\n\nMensagem:\n{$message}"; $headers = [ 'Content-Type: text/plain; charset=UTF-8', "Reply-To: {$email}" ]; $sent = wp_mail( $to, $subject, $body, $headers ); $sent ? wp_send_json_success( [ 'message' => 'Mensagem enviada com sucesso!' ] ) : wp_send_json_error( [ 'message' => 'Erro ao enviar. Tente pelo WhatsApp.' ] ); } add_action( 'wp_ajax_rawcode_contact', 'rawcode_handle_contact' ); add_action( 'wp_ajax_nopriv_rawcode_contact', 'rawcode_handle_contact' ); /* ------------------------------------------------------- HELPERS ------------------------------------------------------- */ function rc( $key, $fallback = '' ) { return esc_html( get_theme_mod( $key, $fallback ) ); }