get_setting in for loops wordpress

by Arun99178   Last Updated May 15, 2018 20:08 PM

function choice_a_callback( $control ) {
if ( $control->manager->get_setting('demo_radio_control1')->value() == 'a' ) { return true; } else { return false; } var_dump( 'choice_a_callback' ); }

function choice_b_callback( $control ) { if ( $control->manager->get_setting('demo_radio_control1')->value() == 'b' ) { return true; } else { return false; } } function choice_callback( $control ) { $radio_setting = $control->manager->get_setting('demo_radio_control1')->value(); $control_id = $control->id; if ( $control_id == 'demo_home_products_artical_slug1' && $radio_setting == 'a' ) return true; if ( $control_id == 'home_products_artical_pdf_link1' && $radio_setting == 'b' ) return true; return false; }

$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',
    )
);    

}

Tags : custom-field


Related Questions


Can't get taxonomy terms by custom field value

Updated November 13, 2017 08:08 AM


Custom post type name and assigning custom taxonomy

Updated April 10, 2016 09:03 AM



Cache file /home/queryxchang/public_html/apps/frontend/config/../cache/-q-9-303646-get-setting-in-for-loops-wordpress- could not be written