Guest User

Untitled

a guest
May 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. function wdo_tabs_child() {
  2. if (function_exists("vc_map")) {
  3.  
  4.  
  5. vc_map(array(
  6. "name" => __("Пункт левого меню", "wdo-tabs"),
  7. "base" => "wdo_advance_tab_free",
  8. "as_child" => array('only' => 'wdo_advance_tabs_free'),
  9. 'as_parent' => array(''),
  10. 'allowed_container_element' => 'vc_row',
  11. 'js_view' => 'VcColumnView',
  12. "icon" => 'extended-custom-icon-wdo icon-wpb-advanced-tab',
  13. 'params' => array_merge(
  14. array(
  15. array(
  16. 'type' => 'textfield',
  17. "holder" => "div",
  18. 'admin_label' => true,
  19. 'heading' => esc_html__('Название пункта', "wdo-tabs"),
  20. 'param_name' => 'wdo_tab_title',
  21. "description" => "Например: Характеристики.",
  22. ),
  23. array(
  24. "type" => "textfield",
  25. "param_name" => "wdo_tab_style",
  26. "heading" => __("Состояния пункта", "wdo-tabs"),
  27. "description" => __("Выберите состояния пункта: Активный или неактивный", "wdo-tabs"),
  28. ),
  29. )
  30. )
  31. ));
  32.  
  33.  
  34. }
  35. }
  36.  
  37. function wdo_advance_tabs_rendering($atts, $content = null, $tag) {
  38.  
  39. preg_match_all('/wdo_tab_title="([^"]+)"/i', $content, $matches, PREG_OFFSET_CAPTURE);
  40. $tab_titles = array();
  41.  
  42. if (isset($matches[0])) {
  43. $tab_titles = $matches[0];
  44. }
  45.  
  46. $tab_title_array = array();
  47.  
  48. foreach($tab_titles as $tab) {
  49. preg_match('/wdo_tab_title="([^"]+)"/i', $tab[0], $tab_matches, PREG_OFFSET_CAPTURE);
  50. $tab_title_array[] = $tab_matches[1][0];
  51. }
  52.  
  53. $params['wdo_tabs_titles'] = $tab_title_array;
  54.  
  55. $uniqid = rand(0, 1000);
  56.  
  57. ob_start();
  58.  
  59. ?>
  60.  
  61. <ul id="sadiya_ul-<?php echo $uniqid ?>" class="nav nav-tabs">
  62. <?php foreach ($tab_title_array as $tab_title) {
  63. $words = preg_replace('/[0-9]+/', '', $tab_title);
  64. echo '<li class="li__'.sanitize_title($words).'">';
  65. echo '<a data-toggle="tab" class="'.sanitize_title($words).'" href="#tab-'.sanitize_title($tab_title).'">'.$tab_title.'</a>';
  66. echo '</li>';
  67. }
  68. ?>
  69. </ul>
Add Comment
Please, Sign In to add comment