C++
0
Вклад в тег
git clone https://github.com/cristian-ungureanu/customizer-repeater
<?php
function true_customizer_init( $wp_customize ) {
$wp_customize->add_section( 'departments', array(
'title' => 'Отделы',
'priority' => 50,
) );
$wp_customize->add_setting( 'customizer_repeater_department_list', array(
'sanitize_callback' => 'customizer_repeater_sanitize',
));
$wp_customize->add_control( new Customizer_Repeater( $wp_customize, 'customizer_repeater_department_list', array(
'label' => esc_html__('Отдел','customizer-repeater'),
'section' => 'departments',
'priority' => 1,
'customizer_repeater_title_control' => true,
) ) );
}
add_action( 'customize_register', 'true_customizer_init' );
<?php
require get_template_directory() . '/customizer-repeater/functions.php';
require get_template_directory() . '/inc/customizer/init.php';
...
$customizer_repeater_department_list = get_theme_mod('customizer_repeater_department_list', json_encode( array(/*The content from your default parameter or delete this argument if you don't want a default*/)) );
/*This returns a json so we have to decode it*/
$customizer_repeater_department_list_decoded = json_decode($customizer_repeater_department_list);
foreach($customizer_repeater_department_list_decoded as $repeater_item){
echo $repeater_item->title;
}