| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/infrafs/INFRABIKEDE/wp-content/plugins/eltd-core/shortcodes/tabs/ |
Upload File : |
<?php
namespace ElatedCore\CPT\Shortcodes\Tabs;
use ElatedCore\Lib;
class Tabs implements Lib\ShortcodeInterface {
private $base;
function __construct() {
$this->base = 'eltd_tabs';
add_action( 'vc_before_init', array( $this, 'vcMap' ) );
}
public function getBase() {
return $this->base;
}
public function vcMap() {
if ( function_exists( 'vc_map' ) ) {
vc_map(
array(
'name' => esc_html__( 'Elated Tabs', 'eltd-core' ),
'base' => $this->getBase(),
'as_parent' => array( 'only' => 'eltd_tabs_item' ),
'content_element' => true,
'category' => esc_html__( 'by ELATED', 'eltd-core' ),
'icon' => 'icon-wpb-tabs extended-custom-icon',
'js_view' => 'VcColumnView',
'params' => array(
array(
'type' => 'textfield',
'param_name' => 'custom_class',
'heading' => esc_html__( 'Custom CSS Class', 'eltd-core' ),
'description' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS', 'eltd-core' )
),
array(
'type' => 'dropdown',
'param_name' => 'type',
'heading' => esc_html__( 'Type', 'eltd-core' ),
'value' => array(
esc_html__( 'Standard', 'eltd-core' ) => 'standard',
esc_html__( 'Boxed', 'eltd-core' ) => 'boxed',
esc_html__( 'Simple', 'eltd-core' ) => 'simple',
esc_html__( 'Vertical', 'eltd-core' ) => 'vertical'
),
'save_always' => true
)
)
)
);
}
}
public function render( $atts, $content = null ) {
$args = array(
'custom_class' => '',
'type' => 'standard'
);
$params = shortcode_atts( $args, $atts );
// Extract tab titles
preg_match_all( '/tab_title="([^\"]+)"/i', $content, $matches, PREG_OFFSET_CAPTURE );
$tab_titles = array();
/**
* get tab titles array
*/
if ( isset( $matches[0] ) ) {
$tab_titles = $matches[0];
}
$tab_title_array = array();
foreach ( $tab_titles as $tab ) {
preg_match( '/tab_title="([^\"]+)"/i', $tab[0], $tab_matches, PREG_OFFSET_CAPTURE );
$tab_title_array[] = $tab_matches[1][0];
}
$params['holder_classes'] = $this->getHolderClasses( $params );
$params['tabs_titles'] = $tab_title_array;
$params['content'] = $content;
$output = eltd_core_get_shortcode_module_template_part( 'templates/tab-template', 'tabs', '', $params );
return $output;
}
private function getHolderClasses( $params ) {
$holderClasses = array();
$holderClasses[] = ! empty( $params['custom_class'] ) ? esc_attr( $params['custom_class'] ) : '';
$holderClasses[] = ! empty( $params['type'] ) ? 'eltd-tabs-' . esc_attr( $params['type'] ) : 'eltd-tabs-standard';
return implode( ' ', $holderClasses );
}
}