vc-tab.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. define( 'TAB_TITLE', esc_attr__( 'Tab', 'js_composer' ) );
  6. require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-column.php' );
  7. /**
  8. * Class WPBakeryShortCode_Vc_Tab
  9. */
  10. class WPBakeryShortCode_Vc_Tab extends WPBakeryShortCode_Vc_Column {
  11. protected $controls_css_settings = 'tc vc_control-container';
  12. protected $controls_list = array(
  13. 'add',
  14. 'edit',
  15. 'clone',
  16. 'delete',
  17. );
  18. protected $controls_template_file = 'editors/partials/backend_controls_tab.tpl.php';
  19. /**
  20. * @return string
  21. */
  22. public function customAdminBlockParams() {
  23. return ' id="tab-' . $this->atts['tab_id'] . '"';
  24. }
  25. /**
  26. * @param $width
  27. * @param $i
  28. * @return string
  29. * @throws \Exception
  30. */
  31. public function mainHtmlBlockParams( $width, $i ) {
  32. $sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? 'wpb_sortable' : $this->nonDraggableClass );
  33. return 'data-element_type="' . $this->settings['base'] . '" class="wpb_' . $this->settings['base'] . ' ' . $sortable . ' wpb_content_holder"' . $this->customAdminBlockParams();
  34. }
  35. /**
  36. * @param $width
  37. * @param $i
  38. * @return string
  39. */
  40. public function containerHtmlBlockParams( $width, $i ) {
  41. return 'class="wpb_column_container vc_container_for_children"';
  42. }
  43. /**
  44. * @param $controls
  45. * @param string $extended_css
  46. * @return string
  47. * @throws \Exception
  48. */
  49. public function getColumnControls( $controls, $extended_css = '' ) {
  50. return $this->getColumnControlsModular( $extended_css );
  51. }
  52. }
  53. /**
  54. * @param $settings
  55. * @param $value
  56. *
  57. * @return string
  58. * @since 4.4
  59. */
  60. function vc_tab_id_settings_field( $settings, $value ) {
  61. return sprintf( '<div class="vc_tab_id_block"><input name="%s" class="wpb_vc_param_value wpb-textinput %s %s_field" type="hidden" value="%s" /><label>%s</label></div>', $settings['param_name'], $settings['param_name'], $settings['type'], $value, $value );
  62. }
  63. vc_add_shortcode_param( 'tab_id', 'vc_tab_id_settings_field' );