settings['html_template'] ) && is_file( $this->settings( 'html_template' ) ) ) {
return $this->setTemplate( $this->settings['html_template'] );
}
// Check template in theme directory
$user_template = vc_manager()->getShortcodesTemplateDir( $this->getFilename() . '.php' );
if ( is_file( $user_template ) ) {
return $this->setTemplate( $user_template );
}
}
protected function getFileName() {
return $this->shortcode;
}
}
class DTWPBakeryShortcode extends WPBakeryShortCode {
/**
* Find html template for shortcode output.
*/
protected function findShortcodeTemplate() {
// Check template path in shortcode's mapping settings
if ( ! empty( $this->settings['html_template'] ) && is_file( $this->settings( 'html_template' ) ) ) {
return $this->setTemplate( $this->settings['html_template'] );
}
// Check template in theme directory
$user_template = vc_manager()->getShortcodesTemplateDir( $this->getFilename() . '.php' );
if ( is_file( $user_template ) ) {
return $this->setTemplate( $user_template );
}
}
protected function getFileName() {
return $this->shortcode;
}
}
/*
*
*/
class Gamota_VisualComposer {
private $gamota_vc_map;
public $param_holder = 'div';
public function __construct( $gamota_vc_map ) {
if( !isset($gamota_vc_map) ){
return;
}else{
$this->gamota_vc_map = $gamota_vc_map;
}
if ( function_exists( 'vc_set_as_theme' ) ) :
vc_set_as_theme( true );
endif;
if ( function_exists( 'vc_disable_frontend' ) ) :
vc_disable_frontend();
else :
if ( class_exists( 'NewVisualComposer' ) )
NewVisualComposer::disableInline();
endif;
add_action( 'init', array(&$this, 'init') );
add_action( 'init', array( &$this, 'map' ), 20 );
add_action( 'init', array( &$this, 'add_params' ), 50 );
if ( is_admin() ) {
add_action( 'do_meta_boxes', array( &$this, 'remove_vc_teaser_meta_box' ), 1 );
add_action( 'admin_print_scripts-post.php', array( &$this, 'enqueue_scripts' ),100 );
add_action( 'admin_print_scripts-post-new.php', array( &$this, 'enqueue_scripts' ),100 );
// $vc_params_js = DTINC_ASSETS_URL . '/js/vc-params.js';
vc_add_shortcode_param( 'nullfield', array( &$this, 'nullfield_param' ) );
vc_add_shortcode_param(
'product_attribute_filter',
array( &$this, 'product_attribute_filter_param' ) );
vc_add_shortcode_param( 'product_attribute', array( &$this, 'product_attribute_param' ) );
vc_add_shortcode_param( 'products_ajax', array( &$this, 'products_ajax_param' ) );
vc_add_shortcode_param( 'product_brand', array( &$this, 'product_brand_param' ) );
vc_add_shortcode_param( 'product_lookbook', array( &$this, 'product_lookbook_param' ) );
vc_add_shortcode_param( 'product_category', array( &$this, 'product_category_param' ) );
vc_add_shortcode_param( 'ui_datepicker', array( &$this, 'ui_datepicker_param' ) );
vc_add_shortcode_param( 'post_category', array( &$this, 'post_category_param' ) );
vc_add_shortcode_param( 'ui_slider', array( &$this, 'ui_slider_param' ) );
vc_add_shortcode_param( 'dropdown_group', array( &$this, 'dropdown_group_param' ) );
}
}
public function init(){
add_filter(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, array(&$this, 'shortcode_custom_css'), 10,3 );
}
public function shortcode_custom_css( $class_to_filter, $shortcode, $atts ){
if ('vc_widget_sidebar'===$shortcode && isset($atts['use_as_smart_sidebar']) && !empty($atts['use_as_smart_sidebar']))
$class_to_filter .=' vc-as-smartsidebar';
if ('vc_row'===$shortcode && isset($atts['row_top_diagonal']) && !empty($atts['row_top_diagonal']))
$class_to_filter .= ' ' . $atts['row_top_diagonal'];
if ('vc_row'===$shortcode && isset($atts['row_bottom_diagonal']) && !empty($atts['row_bottom_diagonal']))
$class_to_filter .= ' ' . $atts['row_bottom_diagonal'];
return $class_to_filter;
}
public function map() {
$is_wp_version_3_6_more = version_compare(
preg_replace( '/^([\d\.]+)(\-.*$)/', '$1', get_bloginfo( 'version' ) ),
'3.6' ) >= 0;
foreach ( $this->gamota_vc_map as $gamota_vc_map){
vc_map($this->gamota_vc_map);
}
}
public function add_params() {
vc_add_param('vc_widget_sidebar',array(
'weight' => 9998,
'type' => 'checkbox',
'admin_label' => true,
'heading' => __( 'Use as Smart Sidebar', 'gamota' ),
'param_name' => 'use_as_smart_sidebar',
'value' => array( __( 'Yes', 'gamota' ) => 'yes' ),
'description' => __( 'Use as Smart Sidebar.', 'gamota' ),
));
/*vc_add_param(
"vc_row",
array(
"type" => "dropdown",
"group" => __( 'Row Type', 'gamota' ),
"class" => "",
"heading" => "Type",
'std' => 'full_width',
"param_name" => "wrap_type",
"value" => array(
__( "Full Width", 'gamota' ) => "full_width",
__( "In Container", 'gamota' ) => "in_container" ) ) );
vc_add_param(
"vc_row_inner",
array(
"type" => "dropdown",
"group" => __( 'Row Type', 'gamota' ),
"class" => "",
"heading" => "Type",
"param_name" => "wrap_type",
'std' => 'full_width',
"value" => array(
__( "Full Width", 'gamota' ) => "full_width",
__( "In Container", 'gamota' ) => "in_container" ) ) );*/
foreach ( $this->gamota_vc_map as $shortcode ) {
foreach ( (array) $this->_get_optional_param() as $optional_param ) {
vc_add_param( $this->gamota_vc_map['base'], $optional_param );
}
}
return;
}
public function remove_vc_teaser_meta_box() {
$post_types = get_post_types( '', 'names' );
foreach ( $post_types as $post_type ) {
remove_meta_box( 'vc_teaser', $post_type, 'side' );
}
return;
}
protected function _get_optional_param() {
$optional_param = array(
array(
'param_name' => 'visibility',
'heading' => __( 'Visibility', 'gamota' ),
'type' => 'dropdown',
'std' => 'all',
'value' => array(
__( 'All Devices', 'gamota' ) => "all",
__( 'Hidden Phone', 'gamota' ) => "hidden-phone",
__( 'Hidden Tablet', 'gamota' ) => "hidden-tablet",
__( 'Hidden PC', 'gamota' ) => "hidden-pc",
__( 'Visible Phone', 'gamota' ) => "visible-phone",
__( 'Visible Tablet', 'gamota' ) => "visible-tablet",
__( 'Visible PC', 'gamota' ) => "visible-pc" ) ),
array(
'param_name' => 'el_class',
'heading' => __( '(Optional) Extra class name', 'gamota' ),
'type' => 'textfield',
'value' => '',
"description" => __(
"If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.",
'gamota' ) ) );
return $optional_param;
}
public function pricing_table_feature_param( $settings, $value ) {
$value_64 = base64_decode( $value );
$value_arr = json_decode( $value_64 );
if ( empty( $value_arr ) && ! is_array( $value_arr ) ) {
for ( $i = 0; $i < 2; $i++ ) {
$option = new stdClass();
$option->content = ' I am a feature';
$value_arr[] = $option;
}
}
$param_line = '';
$param_line .= '
';
$param_line .= '
';
$param_line .= '';
$param_line .= '';
$param_line .= '| ';
$param_line .= __( 'Content (Add Arbitrary text or HTML.)', 'gamota' );
$param_line .= ' | ';
$param_line .= '';
$param_line .= ' | ';
$param_line .= '
';
$param_line .= '';
$param_line .= '';
if ( is_array( $value_arr ) && ! empty( $value_arr ) ) {
foreach ( $value_arr as $k => $v ) {
$param_line .= '';
$param_line .= '| ';
$param_line .= '';
$param_line .= ' | ';
$param_line .= '';
$param_line .= '-';
$param_line .= ' | ';
$param_line .= '
';
}
}
$param_line .= '';
$param_line .= '';
$param_line .= '';
$param_line .= '| ';
$param_line .= '' . __( 'Add', 'gamota' ) . '';
$param_line .= ' | ';
$param_line .= '
';
$param_line .= '
';
$param_line .= '
';
$param_line .= '
';
return $param_line;
}
public function post_category_param( $settings, $value ) {
$dependency = vc_generate_dependencies_attributes( $settings );
$categories = get_categories( array( 'orderby' => 'NAME', 'order' => 'ASC' ) );
$class = 'gamota-chosen-multiple-select';
$selected_values = explode( ',', $value );
$html = array();
$html[] = '';
$html[] = '';
$html[] = '';
$html[] = '
';
return implode( "\n", $html );
}
public function dropdown_group_param( $param, $param_value ) {
$css_option = vc_get_dropdown_option( $param, $param_value );
$param_line = '';
$param_line .= '';
return $param_line;
}
public function nullfield_param( $settings, $value ) {
return '';
}
public function product_attribute_param( $settings, $value ) {
if ( ! defined( 'WOOCOMMERCE_VERSION' ) )
return '';
$output = '';
$attributes = wc_get_attribute_taxonomies();
$output .= '';
return $output;
}
public function product_attribute_filter_param( $settings, $value ) {
if ( ! defined( 'WOOCOMMERCE_VERSION' ) )
return '';
$output = '';
$args = array( 'orderby' => 'name', 'hide_empty' => false );
$filter_ids = explode( ',', $value );
$attributes = wc_get_attribute_taxonomies();
$output .= '';
$output .= '';
return $output;
}
public function product_brand_param( $settings, $value ) {
if ( ! defined( 'WOOCOMMERCE_VERSION' ) )
return '';
$output = '';
$brands_slugs = explode( ',', $value );
$args = array( 'orderby' => 'name', 'hide_empty' => true );
$brands = get_terms( 'product_brand', $args );
$output .= '';
$output .= '';
return $output;
}
public function product_lookbook_param( $settings, $value ) {
if ( ! defined( 'WOOCOMMERCE_VERSION' ) )
return '';
$output = '';
$lookbook_slugs = explode( ',', $value );
$args = array( 'orderby' => 'name', 'hide_empty' => true );
$lookbooks = get_terms( 'product_lookbook', $args );
$output .= '';
$output .= '';
return $output;
}
public function product_category_param( $settings, $value ) {
if ( ! defined( 'WOOCOMMERCE_VERSION' ) )
return '';
$output = '';
$category_slugs = explode( ',', $value );
$args = array( 'orderby' => 'name', 'hide_empty' => true );
$multiple = isset($settings['multiple']) && $settings['multiple'] == false ? '':' multiple="multiple"';
$categories = get_terms( 'product_cat', $args );
$output .= '';
$output .= '';
return $output;
}
public function products_ajax_param( $settings, $value ) {
if ( ! defined( 'WOOCOMMERCE_VERSION' ) )
return '';
$product_ids = array();
if ( ! empty( $value ) )
$product_ids = array_map( 'absint', explode( ',', $value ) );
$output = '';
$output .= '';
return $output;
}
public function ui_datepicker_param( $param, $param_value ) {
$param_line = '';
$value = $param_value;
$value = htmlspecialchars( $value );
$param_line .= '';
if ( ! defined( 'GAMOTA_UISLDER_PARAM' ) ) {
define( 'GAMOTA_UISLDER_PARAM', 1 );
$param_line .= '';
}
$param_line .= '
';
return $param_line;
}
public function ui_slider_param( $settings, $value ) {
$data_min = ( isset( $settings['data_min'] ) && ! empty( $settings['data_min'] ) ) ? 'data-min="' .
absint( $settings['data_min'] ) . '"' : 'data-min="0"';
$data_max = ( isset( $settings['data_max'] ) && ! empty( $settings['data_max'] ) ) ? 'data-max="' .
absint( $settings['data_max'] ) . '"' : 'data-max="100"';
$data_step = ( isset( $settings['data_step'] ) && ! empty( $settings['data_step'] ) ) ? 'data-step="' .
absint( $settings['data_step'] ) . '"' : 'data-step="1"';
return '';
}
public function enqueue_scripts() {
$pricing_table_feature_tmpl = '';
$pricing_table_feature_tmpl .= ' | - |
';
wp_enqueue_style(
'gamota-vc-admin',
DTINC_ASSETS_URL . '/css/vc-admin.css',
array( 'vendor-font-awesome', 'vendor-elegant-icon', 'vendor-chosen' ),
DTINC_VERSION );
wp_register_script(
'gamota-vc-custom',
DTINC_ASSETS_URL . '/js/vc-custom.js',
array( 'jquery', 'jquery-ui-datepicker' ),
DTINC_VERSION,
true );
$dtvcL10n = array(
'pricing_table_max_item_msg' => __( 'Pricing Table element only support display 5 item', 'gamota' ),
'item_title' => DTVC_ITEM_TITLE,
'add_item_title' => DTVC_ADD_ITEM_TITLE,
'move_title' => DTVC_MOVE_TITLE,
'pricing_table_feature_tmpl' => $pricing_table_feature_tmpl );
wp_localize_script( 'gamota-vc-custom', 'dtvcL10n', $dtvcL10n );
wp_enqueue_script( 'gamota-vc-custom' );
}
}
function gamota_vc_el_increment() {
static $count = 0;
$count++;
return $count;
}
endif;
/*
* This method instantiates the VC Extend ui.
*
* @uses Gamota_VisualComposer()
*
* @params array array add to vc_map
* @return void
*/
if( !function_exists('gamota_register_vc_map') ){
function gamota_register_vc_map( $gamota_vc_map = array() ){
if( ! $gamota_vc_map )
return;
new Gamota_VisualComposer($gamota_vc_map);
}
}