/df_home/static/test/portalbkd/wp-content/plugins/js_composer/include/classes/shortcodes/vc-accordion-tab.php

https://gitlab.com/darmawan.fatria/df-skp-2014 · PHP · 130 lines · 117 code · 11 blank · 2 comment · 48 complexity · 025426f4733e9040adbb0f5d16c535e9 MD5 · raw file

  1. <?php
  2. require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-tab.php' );
  3. class WPBakeryShortCode_VC_Accordion_tab extends WPBakeryShortCode_VC_Tab {
  4. protected $controls_css_settings = 'tc vc_control-container';
  5. protected $controls_list = array( 'add', 'edit', 'clone', 'delete' );
  6. protected $predefined_atts = array(
  7. 'el_class' => '',
  8. 'width' => '',
  9. 'title' => ''
  10. );
  11. public function contentAdmin( $atts, $content = null ) {
  12. $width = $el_class = $title = '';
  13. extract( shortcode_atts( $this->predefined_atts, $atts ) );
  14. $output = '';
  15. $column_controls = $this->getColumnControls( $this->settings( 'controls' ) );
  16. $column_controls_bottom = $this->getColumnControls( 'add', 'bottom-controls' );
  17. if ( $width == 'column_14' || $width == '1/4' ) {
  18. $width = array( 'vc_col-sm-3' );
  19. } else if ( $width == 'column_14-14-14-14' ) {
  20. $width = array( 'vc_col-sm-3', 'vc_col-sm-3', 'vc_col-sm-3', 'vc_col-sm-3' );
  21. } else if ( $width == 'column_13' || $width == '1/3' ) {
  22. $width = array( 'vc_col-sm-4' );
  23. } else if ( $width == 'column_13-23' ) {
  24. $width = array( 'vc_col-sm-4', 'vc_col-sm-8' );
  25. } else if ( $width == 'column_13-13-13' ) {
  26. $width = array( 'vc_col-sm-4', 'vc_col-sm-4', 'vc_col-sm-4' );
  27. } else if ( $width == 'column_12' || $width == '1/2' ) {
  28. $width = array( 'vc_col-sm-6' );
  29. } else if ( $width == 'column_12-12' ) {
  30. $width = array( 'vc_col-sm-6', 'vc_col-sm-6' );
  31. } else if ( $width == 'column_23' || $width == '2/3' ) {
  32. $width = array( 'vc_col-sm-8' );
  33. } else if ( $width == 'column_34' || $width == '3/4' ) {
  34. $width = array( 'vc_col-sm-9' );
  35. } else if ( $width == 'column_16' || $width == '1/6' ) {
  36. $width = array( 'vc_col-sm-2' );
  37. } else {
  38. $width = array( '' );
  39. }
  40. for ( $i = 0; $i < count( $width ); $i ++ ) {
  41. $output .= '<div class="group wpb_sortable">';
  42. $output .= '<h3><span class="tab-label"><%= params.title %></span></h3>';
  43. $output .= '<div ' . $this->mainHtmlBlockParams( $width, $i ) . '>';
  44. $output .= str_replace( "%column_size%", wpb_translateColumnWidthToFractional( $width[ $i ] ), $column_controls );
  45. $output .= '<div class="wpb_element_wrapper">';
  46. $output .= '<div ' . $this->containerHtmlBlockParams( $width, $i ) . '>';
  47. $output .= do_shortcode( shortcode_unautop( $content ) );
  48. $output .= '</div>';
  49. if ( isset( $this->settings['params'] ) ) {
  50. $inner = '';
  51. foreach ( $this->settings['params'] as $param ) {
  52. $param_value = isset( $$param['param_name'] ) ? $$param['param_name'] : '';
  53. if ( is_array( $param_value ) ) {
  54. // Get first element from the array
  55. reset( $param_value );
  56. $first_key = key( $param_value );
  57. $param_value = $param_value[ $first_key ];
  58. }
  59. $inner .= $this->singleParamHtmlHolder( $param, $param_value );
  60. }
  61. $output .= $inner;
  62. }
  63. $output .= '</div>';
  64. $output .= str_replace( "%column_size%", wpb_translateColumnWidthToFractional( $width[ $i ] ), $column_controls_bottom );
  65. $output .= '</div>';
  66. $output .= '</div>';
  67. }
  68. return $output;
  69. }
  70. public function mainHtmlBlockParams( $width, $i ) {
  71. return 'data-element_type="' . $this->settings["base"] . '" class=" wpb_' . $this->settings['base'] . '"' . $this->customAdminBlockParams();
  72. }
  73. public function containerHtmlBlockParams( $width, $i ) {
  74. return 'class="wpb_column_container vc_container_for_children"';
  75. }
  76. public function contentAdmin_old( $atts, $content = null ) {
  77. $width = $el_class = $title = '';
  78. extract( shortcode_atts( $this->predefined_atts, $atts ) );
  79. $output = '';
  80. $column_controls = $this->getColumnControls( $this->settings( 'controls' ) );
  81. for ( $i = 0; $i < count( $width ); $i ++ ) {
  82. $output .= '<div class="group wpb_sortable">';
  83. $output .= '<div class="wpb_element_wrapper">';
  84. $output .= '<div class="vc_row-fluid wpb_row_container">';
  85. $output .= '<h3><a href="#">' . $title . '</a></h3>';
  86. $output .= '<div data-element_type="' . $this->settings["base"] . '" class=" wpb_' . $this->settings['base'] . ' wpb_sortable">';
  87. $output .= '<div class="wpb_element_wrapper">';
  88. $output .= '<div class="vc_row-fluid wpb_row_container">';
  89. $output .= do_shortcode( shortcode_unautop( $content ) );
  90. $output .= '</div>';
  91. if ( isset( $this->settings['params'] ) ) {
  92. $inner = '';
  93. foreach ( $this->settings['params'] as $param ) {
  94. $param_value = isset( $$param['param_name'] ) ? $$param['param_name'] : '';
  95. if ( is_array( $param_value ) ) {
  96. // Get first element from the array
  97. reset( $param_value );
  98. $first_key = key( $param_value );
  99. $param_value = $param_value[ $first_key ];
  100. }
  101. $inner .= $this->singleParamHtmlHolder( $param, $param_value );
  102. }
  103. $output .= $inner;
  104. }
  105. $output .= '</div>';
  106. $output .= '</div>';
  107. $output .= '</div>';
  108. $output .= '</div>';
  109. $output .= '</div>';
  110. }
  111. return $output;
  112. }
  113. protected function outputTitle( $title ) {
  114. return '';
  115. }
  116. public function customAdminBlockParams() {
  117. return '';
  118. }
  119. }