File size: 10,319 Bytes
bf98100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<?php
/**
 * Isabella Moreno - Tema de WordPress
 * 
 * @package IsabellaMoreno
 * @version 1.0.0
 */

// Prevenir acceso directo
if (!defined('ABSPATH')) {
    exit;
}

/**
 * Configuración del tema
 */
function isabella_setup() {
    // Soporte para título dinámico
    add_theme_support('title-tag');
    
    // Soporte para imágenes destacadas
    add_theme_support('post-thumbnails');
    set_post_thumbnail_size(1200, 630, true);
    add_image_size('portfolio', 640, 360, true);
    add_image_size('testimonial', 200, 200, true);
    add_image_size('instagram', 320, 240, true);
    
    // Menús de navegación
    register_nav_menus(array(
        'primary' => __('Menú Principal', 'isabella'),
        'footer' => __('Menú Footer', 'isabella'),
    ));
    
    // Soporte para HTML5
    add_theme_support('html5', array(
        'search-form',
        'comment-form',
        'comment-list',
        'gallery',
        'caption',
        'style',
        'script',
    ));
    
    // Soporte para WooCommerce (opcional)
    add_theme_support('woocommerce');
    
    // Soporte para Gutenberg
    add_theme_support('editor-styles');
    add_editor_style('assets/css/editor-style.css');
}
add_action('after_setup_theme', 'isabella_setup');

/**
 * Enqueue scripts y estilos
 */
function isabella_scripts() {
    // Google Fonts
    wp_enqueue_style(
        'isabella-fonts',
        'https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Lato:wght@300;400;700&display=swap',
        array(),
        null
    );
    
    // Tailwind CSS
    wp_enqueue_script(
        'tailwindcss',
        'https://cdn.tailwindcss.com',
        array(),
        null,
        false
    );
    
    // Lucide Icons
    wp_enqueue_script(
        'lucide-icons',
        'https://unpkg.com/lucide@latest',
        array(),
        null,
        true
    );
    
    // Estilos personalizados
    wp_enqueue_style(
        'isabella-style',
        get_stylesheet_uri(),
        array(),
        '1.0.0'
    );
    
    wp_enqueue_style(
        'isabella-custom',
        get_template_directory_uri() . '/assets/css/custom.css',
        array(),
        '1.0.0'
    );
    
    // Scripts personalizados
    wp_enqueue_script(
        'isabella-main',
        get_template_directory_uri() . '/assets/js/main.js',
        array('lucide-icons'),
        '1.0.0',
        true
    );
    
    // Configuración AJAX
    wp_localize_script('isabella-main', 'isabella_ajax', array(
        'ajax_url' => admin_url('admin-ajax.php'),
        'nonce' => wp_create_nonce('isabella_nonce')
    ));
}
add_action('wp_enqueue_scripts', 'isabella_scripts');

/**
 * Configuración de Tailwind
 */
function isabella_tailwind_config() {
    ?>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    fontFamily: {
                        'serif': ['Playfair Display', 'serif'],
                        'sans': ['Lato', 'sans-serif'],
                    },
                    colors: {
                        'brand': {
                            50: '#fdf2f8',
                            100: '#fce7f3',
                            200: '#fbcfe8',
                            300: '#f9a8d4',
                            400: '#f472b6',
                            500: '#ec4899',
                            600: '#db2777',
                            700: '#be185d',
                            800: '#9d174d',
                            900: '#831843',
                        },
                        'gold': {
                            400: '#fbbf24',
                            500: '#f59e0b',
                            600: '#d97706',
                        }
                    }
                }
            }
        }
    </script>
    <?php
}
add_action('wp_head', 'isabella_tailwind_config', 1);

/**
 * Custom Post Type: Portafolio
 */
function isabella_portfolio_post_type() {
    $labels = array(
        'name' => __('Portafolio', 'isabella'),
        'singular_name' => __('Proyecto', 'isabella'),
        'add_new' => __('Añadir Nuevo', 'isabella'),
        'add_new_item' => __('Añadir Nuevo Proyecto', 'isabella'),
        'edit_item' => __('Editar Proyecto', 'isabella'),
        'new_item' => __('Nuevo Proyecto', 'isabella'),
        'view_item' => __('Ver Proyecto', 'isabella'),
        'search_items' => __('Buscar Proyectos', 'isabella'),
        'not_found' => __('No se encontraron proyectos', 'isabella'),
    );
    
    $args = array(
        'labels' => $labels,
        'public' => true,
        'has_archive' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,
        'menu_icon' => 'dashicons-format-gallery',
        'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'),
        'taxonomies' => array('portfolio_category'),
        'rewrite' => array('slug' => 'portafolio'),
    );
    
    register_post_type('portfolio', $args);
}
add_action('init', 'isabella_portfolio_post_type');

/**
 * Taxonomía: Categorías de Portafolio
 */
function isabella_portfolio_taxonomy() {
    $labels = array(
        'name' => __('Categorías', 'isabella'),
        'singular_name' => __('Categoría', 'isabella'),
    );
    
    $args = array(
        'labels' => $labels,
        'hierarchical' => true,
        'public' => true,
        'show_ui' => true,
        'show_admin_column' => true,
        'query_var' => true,
        'rewrite' => array('slug' => 'categoria-portafolio'),
    );
    
    register_taxonomy('portfolio_category', array('portfolio'), $args);
}
add_action('init', 'isabella_portfolio_taxonomy');

/**
 * Custom Post Type: Testimonios
 */
function isabella_testimonials_post_type() {
    $labels = array(
        'name' => __('Testimonios', 'isabella'),
        'singular_name' => __('Testimonio', 'isabella'),
    );
    
    $args = array(
        'labels' => $labels,
        'public' => false,
        'publicly_queryable' => false,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 6,
        'menu_icon' => 'dashicons-format-quote',
        'supports' => array('title', 'editor', 'thumbnail'),
    );
    
    register_post_type('testimonial', $args);
}
add_action('init', 'isabella_testimonials_post_type');

/**
 * Custom Post Type: Servicios
 */
function isabella_services_post_type() {
    $labels = array(
        'name' => __('Servicios', 'isabella'),
        'singular_name' => __('Servicio', 'isabella'),
    );
    
    $args = array(
        'labels' => $labels,
        'public' => false,
        'publicly_queryable' => false,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 7,
        'menu_icon' => 'dashicons-star-filled',
        'supports' => array('title', 'editor', 'thumbnail'),
    );
    
    register_post_type('service', $args);
}
add_action('init', 'isabella_services_post_type');

/**
 * Opciones del Tema (ACF o Customizer)
 */
function isabella_customize_register($wp_customize) {
    // Sección de Información General
    $wp_customize->add_section('isabella_general', array(
        'title' => __('Información General', 'isabella'),
        'priority' => 30,
    ));
    
    // Email de contacto
    $wp_customize->add_setting('isabella_email', array(
        'default' => 'booking@isabellamoreno.com',
        'sanitize_callback' => 'sanitize_email',
    ));
    
    $wp_customize->add_control('isabella_email', array(
        'label' => __('Email de Contacto', 'isabella'),
        'section' => 'isabella_general',
        'type' => 'email',
    ));
    
    // Teléfono
    $wp_customize->add_setting('isabella_phone', array(
        'default' => '+1 (305) 555-0123',
        'sanitize_callback' => 'sanitize_text_field',
    ));
    
    $wp_customize->add_control('isabella_phone', array(
        'label' => __('Teléfono', 'isabella'),
        'section' => 'isabella_general',
        'type' => 'text',
    ));
    
    // Ubicación
    $wp_customize->add_setting('isabella_location', array(
        'default' => 'Miami, FL',
        'sanitize_callback' => 'sanitize_text_field',
    ));
    
    $wp_customize->add_control('isabella_location', array(
        'label' => __('Ubicación', 'isabella'),
        'section' => 'isabella_general',
        'type' => 'text',
    ));
    
    // Redes Sociales
    $wp_customize->add_section('isabella_social', array(
        'title' => __('Redes Sociales', 'isabella'),
        'priority' => 35,
    ));
    
    $socials = array('instagram', 'twitter', 'facebook', 'linkedin');
    foreach ($socials as $social) {
        $wp_customize->add_setting("isabella_{$social}", array(
            'sanitize_callback' => 'esc_url_raw',
        ));
        
        $wp_customize->add_control("isabella_{$social}", array(
            'label' => ucfirst($social),
            'section' => 'isabella_social',
            'type' => 'url',
        ));
    }
}
add_action('customize_register', 'isabella_customize_register');

/**
 * Widgets
 */
function isabella_widgets_init() {
    register_sidebar(array(
        'name' => __('Sidebar Footer', 'isabella'),
        'id' => 'footer-1',
        'description' => __('Widgets para el footer', 'isabella'),
        'before_widget' => '<div class="widget">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ));
}
add_action('widgets_init', 'isabella_widgets_init');

/**
* Manejo de formulario de contacto AJAX
 */
function isabella_handle_contact_form() {
    check_ajax_referer('isabella_nonce', 'nonce');
    
    $name = sanitize_text_field($_POST['name']);
    $email = sanitize_email($_POST['email']);
    $project = sanitize_text_field($_POST['project']);
    $message = sanitize_textarea_field($_POST['message']);
    
    $to = get_option('admin_email');
    $subject = "Nuevo mensaje de contacto de {$name}";
    $body = "Nombre: {$name}\nEmail: {$email}\nTipo de proyecto: {$project}\n\nMensaje:\n{$message}";
    $headers = array('Content-Type: text/plain; charset=UTF-8', "Reply-To: {$email}");
    
    $sent = wp_mail($to, $subject, $body, $headers