Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wp.customize.bind('ready', function () {
- var product_count = wp.customize.control('mitutoyo_home_product_count').setting.get();
- console.log(product_count);
- var infoi = 1;
- wp.customize.control('home_products_artical_pdf_link' + infoi).container.slideUp('fast');
- wp.customize('demo_radio_control' + infoi, function (setting) {
- // console.log(value);
- var visibility = function () {
- if (setting.get() === 'a') {
- wp.customize.control('mitutoyo_home_products_artical_slug' + infoi).container.slideDown('fast');
- wp.customize.control('home_products_artical_pdf_link' + infoi).container.slideUp('fast');
- } else {
- wp.customize.control('mitutoyo_home_products_artical_slug' + infoi).container.slideUp('fast');
- wp.customize.control('home_products_artical_pdf_link' + infoi).container.slideDown('fast');
- }
- };
- visibility();
- setting.bind(visibility);
- });
- });
- $home_product_count = get_theme_mod('demo_home_product_count','4');
- for($p = 1; $p <= $home_product_count; $p++){
- $wp_customize->add_setting('home_product_images'.$p, array(
- 'transport' => 'refresh',
- 'sanitize_callback' => 'absint',
- 'default' => get_template_directory_uri().'/images/banner'.$p.'.jpg',
- //'height' => 50,
- ));
- $wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'home_product_images'.$p, array(
- 'label' => 'Card Image #'.$p,
- 'section' => 'demo_home_product',
- 'settings' => 'home_product_images'.$p,
- 'width' => 400,
- 'height' => 300,
- 'flex_width' => false,
- 'flex_height' => false,
- )));
- $wp_customize->add_setting( 'demo_home_products_artical_tittle'.$p, array(
- 'default' => 'Product name'.$p,
- 'sanitize_callback' => 'esc_textarea',
- 'transport' => 'refresh',
- 'capability' => 'manage_options'
- )
- );
- // $wp_customize->add_setting( 'demo_home_products_artical_link_target'.$p, array(
- // 'default' => '0',
- // 'sanitize_callback' => 'demo_sanitize_checkbox',
- // 'transport' => 'refresh',
- // //'capability' => 'manage_options'
- // )
- // );
- // $wp_customize->add_control( 'demo_home_products_artical_link_target'.$p, array(
- // 'label' => 'Open link in a new tab',
- // 'section' => 'demo_home_product',
- // 'settings' => 'demo_home_products_artical_link_target'.$p,
- // 'type' => 'checkbox',
- // )
- // );
- $wp_customize->add_setting( 'demo_radio_control'.$p, array(
- 'default' => 'a',
- ) );
- $wp_customize->add_control( 'demo_radio_control'.$p, array(
- 'label' => 'radio_control',
- 'section' => 'demo_home_product',
- 'settings' => 'demo_radio_control'.$p,
- 'type' => 'radio',
- 'choices' => array(
- 'a' => 'Choice A',
- 'b' => 'Choice B',
- ),
- )
- );
- $wp_customize->add_setting( 'demo_home_products_artical_slug'.$p, array(
- 'default' => 'link path'.$p,
- 'transport' => 'refresh',
- )
- );
- $wp_customize->add_control( 'demo_home_products_artical_slug'.$p, array(
- 'label' => 'Product Link path'.$p,
- 'section' => 'demo_home_product',
- 'settings' => 'demo_home_products_artical_slug'.$p,
- 'type' => 'text',
- //'active_callback' => 'choice_a_callback',
- )
- );
- // = File Upload =
- // =============================
- $wp_customize->add_setting('home_products_artical_pdf_link'.$p, array(
- 'default' => '#!'.$p,
- 'capability' => 'edit_theme_options',
- // 'sanitize_callback' => 'absint',
- ));
- $wp_customize->add_control( new WP_Customize_Upload_Control($wp_customize, 'home_products_artical_pdf_link'.$p, array(
- 'label' => __('Atach Pdf - '.$p, 'themename'),
- 'section' => 'demo_home_product',
- 'settings' => 'home_products_artical_pdf_link'.$p,
- //'active_callback' => 'choice_b_callback',
- // 'active_callback' => function( $control ) {
- // $control->get_setting('demo_radio_control'.$p )->value() == 'b';
- // },
- )));
- $wp_customize->add_setting( 'demo_home_products_artical_link_text'.$p, array(
- 'default' => 'Read More',
- 'sanitize_callback' => 'esc_textarea',
- 'transport' => 'refresh',
- 'capability' => 'manage_options'
- )
- );
- $wp_customize->add_control( 'demo_home_products_artical_link_text'.$p, array(
- 'label' => 'Products card Link'.$p.' Text',
- 'section' => 'demo_home_product',
- 'settings' => 'demo_home_products_artical_link_text'.$p,
- 'type' => 'text',
- )
- );
- }
Add Comment
Please, Sign In to add comment