Guest User

Untitled

a guest
May 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. wp.customize.bind('ready', function () {
  2. var product_count = wp.customize.control('mitutoyo_home_product_count').setting.get();
  3. console.log(product_count);
  4.  
  5. var infoi = 1;
  6.  
  7. wp.customize.control('home_products_artical_pdf_link' + infoi).container.slideUp('fast');
  8.  
  9. wp.customize('demo_radio_control' + infoi, function (setting) {
  10. // console.log(value);
  11. var visibility = function () {
  12. if (setting.get() === 'a') {
  13.  
  14. wp.customize.control('mitutoyo_home_products_artical_slug' + infoi).container.slideDown('fast');
  15. wp.customize.control('home_products_artical_pdf_link' + infoi).container.slideUp('fast');
  16. } else {
  17. wp.customize.control('mitutoyo_home_products_artical_slug' + infoi).container.slideUp('fast');
  18. wp.customize.control('home_products_artical_pdf_link' + infoi).container.slideDown('fast');
  19. }
  20. };
  21. visibility();
  22. setting.bind(visibility);
  23. });
  24.  
  25.  
  26. });
  27.  
  28. $home_product_count = get_theme_mod('demo_home_product_count','4');
  29.  
  30. for($p = 1; $p <= $home_product_count; $p++){
  31.  
  32. $wp_customize->add_setting('home_product_images'.$p, array(
  33. 'transport' => 'refresh',
  34. 'sanitize_callback' => 'absint',
  35. 'default' => get_template_directory_uri().'/images/banner'.$p.'.jpg',
  36. //'height' => 50,
  37. ));
  38.  
  39. $wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'home_product_images'.$p, array(
  40. 'label' => 'Card Image #'.$p,
  41. 'section' => 'demo_home_product',
  42. 'settings' => 'home_product_images'.$p,
  43. 'width' => 400,
  44. 'height' => 300,
  45. 'flex_width' => false,
  46. 'flex_height' => false,
  47. )));
  48.  
  49. $wp_customize->add_setting( 'demo_home_products_artical_tittle'.$p, array(
  50. 'default' => 'Product name'.$p,
  51. 'sanitize_callback' => 'esc_textarea',
  52. 'transport' => 'refresh',
  53. 'capability' => 'manage_options'
  54. )
  55. );
  56.  
  57. // $wp_customize->add_setting( 'demo_home_products_artical_link_target'.$p, array(
  58. // 'default' => '0',
  59. // 'sanitize_callback' => 'demo_sanitize_checkbox',
  60. // 'transport' => 'refresh',
  61. // //'capability' => 'manage_options'
  62. // )
  63. // );
  64. // $wp_customize->add_control( 'demo_home_products_artical_link_target'.$p, array(
  65. // 'label' => 'Open link in a new tab',
  66. // 'section' => 'demo_home_product',
  67. // 'settings' => 'demo_home_products_artical_link_target'.$p,
  68. // 'type' => 'checkbox',
  69. // )
  70. // );
  71.  
  72. $wp_customize->add_setting( 'demo_radio_control'.$p, array(
  73. 'default' => 'a',
  74. ) );
  75.  
  76. $wp_customize->add_control( 'demo_radio_control'.$p, array(
  77. 'label' => 'radio_control',
  78. 'section' => 'demo_home_product',
  79. 'settings' => 'demo_radio_control'.$p,
  80. 'type' => 'radio',
  81. 'choices' => array(
  82. 'a' => 'Choice A',
  83. 'b' => 'Choice B',
  84. ),
  85. )
  86. );
  87.  
  88. $wp_customize->add_setting( 'demo_home_products_artical_slug'.$p, array(
  89. 'default' => 'link path'.$p,
  90. 'transport' => 'refresh',
  91. )
  92. );
  93. $wp_customize->add_control( 'demo_home_products_artical_slug'.$p, array(
  94. 'label' => 'Product Link path'.$p,
  95. 'section' => 'demo_home_product',
  96. 'settings' => 'demo_home_products_artical_slug'.$p,
  97. 'type' => 'text',
  98. //'active_callback' => 'choice_a_callback',
  99. )
  100. );
  101.  
  102. // = File Upload =
  103. // =============================
  104. $wp_customize->add_setting('home_products_artical_pdf_link'.$p, array(
  105. 'default' => '#!'.$p,
  106. 'capability' => 'edit_theme_options',
  107. // 'sanitize_callback' => 'absint',
  108. ));
  109. $wp_customize->add_control( new WP_Customize_Upload_Control($wp_customize, 'home_products_artical_pdf_link'.$p, array(
  110. 'label' => __('Atach Pdf - '.$p, 'themename'),
  111. 'section' => 'demo_home_product',
  112. 'settings' => 'home_products_artical_pdf_link'.$p,
  113. //'active_callback' => 'choice_b_callback',
  114. // 'active_callback' => function( $control ) {
  115. // $control->get_setting('demo_radio_control'.$p )->value() == 'b';
  116. // },
  117. )));
  118.  
  119.  
  120.  
  121.  
  122. $wp_customize->add_setting( 'demo_home_products_artical_link_text'.$p, array(
  123. 'default' => 'Read More',
  124. 'sanitize_callback' => 'esc_textarea',
  125. 'transport' => 'refresh',
  126. 'capability' => 'manage_options'
  127. )
  128. );
  129. $wp_customize->add_control( 'demo_home_products_artical_link_text'.$p, array(
  130. 'label' => 'Products card Link'.$p.' Text',
  131. 'section' => 'demo_home_product',
  132. 'settings' => 'demo_home_products_artical_link_text'.$p,
  133. 'type' => 'text',
  134. )
  135. );
  136. }
Add Comment
Please, Sign In to add comment