'1/1' );
foreach ( $this->settings['params'] as $param ) {
if ( 'content' !== $param['param_name'] ) {
$shortcode_attributes[ $param['param_name'] ] = isset( $param['value'] ) ? $param['value'] : null;
} elseif ( 'content' === $param['param_name'] && null === $content ) {
$content = $param['value'];
}
}
extract( shortcode_atts( $shortcode_attributes, $atts ) );
// Extract tab titles
preg_match_all( '/vc_tab title="([^\"]+)"(\stab_id\=\"([^\"]+)\"){0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE );
$tab_titles = array();
if ( isset( $matches[0] ) ) {
$tab_titles = $matches[0];
}
$tmp = '';
if ( count( $tab_titles ) ) {
$tmp .= '
';
foreach ( $tab_titles as $tab ) {
preg_match( '/title="([^\"]+)"(\stab_id\=\"([^\"]+)\"){0,1}/i', $tab[0], $tab_matches, PREG_OFFSET_CAPTURE );
if ( isset( $tab_matches[1][0] ) ) {
$tmp .= '- ' . $tab_matches[1][0] . '
';
}
}
$tmp .= '
' . "\n";
}
$elem = $this->getElementHolder( $width );
$iner = '';
foreach ( $this->settings['params'] as $param ) {
$param_value = isset( ${$param['param_name']} ) ? ${$param['param_name']} : '';
if ( is_array( $param_value ) ) {
// Get first element from the array
reset( $param_value );
$first_key = key( $param_value );
$param_value = $param_value[ $first_key ];
}
$iner .= $this->singleParamHtmlHolder( $param, $param_value );
}
if ( isset( $this->settings['custom_markup'] ) && '' !== $this->settings['custom_markup'] ) {
if ( '' !== $content ) {
$custom_markup = str_ireplace( '%content%', $tmp . $content, $this->settings['custom_markup'] );
} elseif ( '' === $content && isset( $this->settings['default_content_in_template'] ) && '' !== $this->settings['default_content_in_template'] ) {
$custom_markup = str_ireplace( '%content%', $this->settings['default_content_in_template'], $this->settings['custom_markup'] );
} else {
$custom_markup = str_ireplace( '%content%', '', $this->settings['custom_markup'] );
}
$iner .= do_shortcode( $custom_markup );
}
$elem = str_ireplace( '%wpb_element_content%', $iner, $elem );
$output = $elem;
return $output;
}
/**
* @return string
*/
public function getTabTemplate() {
return '' . do_shortcode( '[vc_tab title="Tab" tab_id=""][/vc_tab]' ) . '
';
}
/**
* @param $content
* @return string|string[]|null
*/
public function setCustomTabId( $content ) {
return preg_replace( '/tab\_id\=\"([^\"]+)\"/', 'tab_id="$1-' . time() . '"', $content );
}
}