Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function vhm_customize_register($wp_customize)
- {
- /**
- * PANEL: Home page
- *
- * Primero creamos el panel donde alojaremos nuestras opciones.
- */
- $wp_customize->add_panel( 'home_page_template', array(
- 'priority' => 100,
- 'capability' => 'edit_theme_options',
- 'theme_supports' => '',
- 'title' => __('Home page settings', TEXTDOMAIN),
- 'description' => __('Several settings pertaining my theme', TEXTDOMAIN),
- ) );
- /**
- * FIRST SECTION: SERVICES
- *
- * Luego creamos la sección de ejemplo "Servicios"
- */
- $wp_customize->add_section('services', array(
- 'priority' => 100,
- 'title' => __('Services section', TEXTDOMAIN),
- 'description' => 'The first section',
- 'panel' => 'home_page_template'
- ));
- // Con esta función creamos la primera opción. En este caso se llamará "Main section title"
- $wp_customize->add_setting('main_section_title', array(
- 'default' => ''
- ));
- // Y por último el controlador que por defecto será un campo del tipo "text"
- $wp_customize->add_control('main_section_title_control', array(
- 'label' => __('Main section title', TEXTDOMAIN),
- 'section' => 'services',
- 'settings' => 'main_section_title',
- ));
- // Agregamos otra opción
- $wp_customize->add_setting('first_column_template', array(
- 'default' => ''
- ));
- // Y en este caso usamos la variable "type" para definir que se tratará de un campo "textarea"
- $wp_customize->add_control('first_column_template_control', array(
- 'label' => __('First column template', TEXTDOMAIN),
- 'section' => 'services',
- 'settings' => 'first_column_template',
- 'type' => 'textarea'
- ));
- /**
- * SECOND SECTION: ABOUT
- *
- * Luego creamos otra sección dentro de nuestro panel principal
- */
- $wp_customize->add_section('about_us', array(
- 'priority' => 100,
- 'title' => __('About us section', TEXTDOMAIN),
- 'description' => 'The second section',
- 'panel' => 'home_page_template'
- ));
- // Y nuevamente agregamos la opción y esta vez con el valor por defecto "Set title"
- $wp_customize->add_setting('second_section_title', array(
- 'default' => 'Set title'
- ));
- // Una vez más, agregamos el controlador que será tipo "text" por defecto ya que no lo definimos con la variable "type"
- $wp_customize->add_control('second_section_title_control', array(
- 'label' => __('Main section title', TEXTDOMAIN),
- 'section' => 'about_us',
- 'settings' => 'second_section_title',
- ));
- // Creamos otra sección con un valor "vacío" por defecto
- $wp_customize->add_setting('second_section_text', array(
- 'default' => ''
- ));
- // Y nuevamente el controlador tipo "textarea"
- $wp_customize->add_control('second_section_text_control', array(
- 'label' => __('Short description', TEXTDOMAIN),
- 'section' => 'about_us',
- 'settings' => 'second_section_text',
- 'type' => 'textarea',
- ));
- }
- add_action("customize_register","vhm_customize_register");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement