Import legacy nurinda.co.id website

This commit is contained in:
dirga committed 2026-10-01 14:27:19 +07:00
1 parent 3f59bb9038
commit 6e21646ac4
13389 files changed
+3246690

No files matched your search

@@ -0,0 +1,59 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
class WPBakeryShortCode_Vc_Acf extends WPBakeryShortCode {
/**
* @param $atts
* @param null $content
*
* @return mixed|void
*/
protected function content( $atts, $content = null ) {
$atts = $atts + vc_map_get_attributes( $this->getShortcode(), $atts );
$field_group = $atts['field_group'];
$field_key = '';
if ( 0 === strlen( $atts['field_group'] ) ) {
$groups = function_exists( 'acf_get_field_groups' ) ? acf_get_field_groups() : apply_filters( 'acf/get_field_groups', array() );
if ( is_array( $groups ) && isset( $groups[0] ) ) {
$key = isset( $groups[0]['id'] ) ? 'id' : ( isset( $groups[0]['ID'] ) ? 'ID' : 'id' );
$field_group = $groups[0][ $key ];
}
}
if ( $field_group ) {
$field_key = ! empty( $atts[ 'field_from_' . $field_group ] ) ? $atts[ 'field_from_' . $field_group ] : 'field_from_group_' . $field_group;
}
$css_class = array();
$css_class[] = 'vc_acf';
if ( $atts['el_class'] ) {
$css_class[] = $atts['el_class'];
}
if ( $atts['align'] ) {
$css_class[] = 'vc_txt_align_' . $atts['align'];
}
$value = '';
if ( $field_key ) {
$css_class[] = $field_key;
$value = do_shortcode( '[acf field="' . $field_key . '" post_id="' . get_the_ID() . '"]' );
if ( $atts['show_label'] ) {
$field = get_field_object( $field_key );
$label = is_array( $field ) && isset( $field['label'] ) ? '<span class="vc_acf-label">' . $field['label'] . ':</span> ' : '';
$value = $label . $value;
}
}
$css_string = implode( ' ', $css_class );
$output = '<div class="' . esc_attr( $css_string ) . '">' . $value . '</div>';
return $output;
}
}
@@ -0,0 +1,49 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
class Vc_Gitem_Acf_Shortcode extends WPBakeryShortCode {
/**
* @param $atts
* @param null $content
*
* @return mixed|void
*/
protected function content( $atts, $content = null ) {
$field_key = $label = '';
/**
* @var string $el_class
* @var string $show_label
* @var string $align
* @var string $field_group
*/
extract( shortcode_atts( array(
'el_class' => '',
'field_group' => '',
'show_label' => '',
'align' => '',
), $atts ) );
if ( 0 === strlen( $field_group ) ) {
$groups = function_exists( 'acf_get_field_groups' ) ? acf_get_field_groups() : apply_filters( 'acf/get_field_groups', array() );
if ( is_array( $groups ) && isset( $groups[0] ) ) {
$key = isset( $groups[0]['id'] ) ? 'id' : ( isset( $groups[0]['ID'] ) ? 'ID' : 'id' );
$field_group = $groups[0][ $key ];
}
}
if ( ! empty( $field_group ) ) {
$field_key = ! empty( $atts[ 'field_from_' . $field_group ] ) ? $atts[ 'field_from_' . $field_group ] : 'field_from_group_' . $field_group;
}
if ( 'yes' === $show_label && $field_key ) {
$field_key .= '_labeled';
}
$css_class = 'vc_gitem-acf'
. ( strlen( $el_class ) ? ' ' . $el_class : '' )
. ( strlen( $align ) ? ' vc_gitem-align-' . $align : '' )
. ( strlen( $field_key ) ? ' ' . $field_key : '' );
return '<div ' . $field_key . ' class="' . esc_attr( $css_class ) . '">'
. '{{ acf' . ( ! empty( $field_key ) ? ':' . $field_key : '' ) . ' }}'
. '</div>';
}
}
@@ -0,0 +1,48 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Get ACF data
*
* @param $value
* @param $data
*
* @return string
*/
function vc_gitem_template_attribute_acf( $value, $data ) {
$label = '';
/**
* @var null|Wp_Post $post ;
* @var string $data ;
*/
extract( array_merge( array(
'post' => null,
'data' => '',
), $data ) );
if ( strstr( $data, 'field_from_group_' ) ) {
$group_id = preg_replace( '/(^field_from_group_|_labeled$)/', '', $data );
$fields = function_exists( 'acf_get_fields' ) ? acf_get_fields( $group_id ) : apply_filters( 'acf/field_group/get_fields', array(), $group_id );
$field = is_array( $fields ) && isset( $fields[0] ) ? $fields[0] : false;
if ( is_array( $field ) && isset( $field['key'] ) ) {
$data = $field['key'] . ( strstr( $data, '_labeled' ) ? '_labeled' : '' );
}
}
$label = '';
if ( preg_match( '/_labeled$/', $data ) ) {
$data = preg_replace( '/_labeled$/', '', $data );
$field = get_field_object( $data );
$label = is_array( $field ) && isset( $field['label'] ) ? '<span class="vc_gitem-acf-label">' . $field['label'] . ':</span> ' : '';
}
$value = '';
if ( $data ) {
$value = do_shortcode( '[acf field="' . $data . '" post_id="' . $post->ID . '"]' );
}
return $label . apply_filters( 'vc_gitem_template_attribute_acf_value', $value );
}
add_filter( 'vc_gitem_template_attribute_acf', 'vc_gitem_template_attribute_acf', 10, 2 );
@@ -0,0 +1,79 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
$groups = function_exists( 'acf_get_field_groups' ) ? acf_get_field_groups() : apply_filters( 'acf/get_field_groups', array() );
$groups_param_values = $fields_params = array();
foreach ( $groups as $group ) {
$id = isset( $group['id'] ) ? 'id' : ( isset( $group['ID'] ) ? 'ID' : 'id' );
$groups_param_values[ $group['title'] ] = $group[ $id ];
$fields = function_exists( 'acf_get_fields' ) ? acf_get_fields( $group[ $id ] ) : apply_filters( 'acf/field_group/get_fields', array(), $group[ $id ] );
$fields_param_value = array();
foreach ( (array) $fields as $field ) {
$fields_param_value[ $field['label'] ] = (string) $field['key'];
}
$fields_params[] = array(
'type' => 'dropdown',
'heading' => __( 'Field name', 'js_composer' ),
'param_name' => 'field_from_' . $group[ $id ],
'value' => $fields_param_value,
'save_always' => true,
'description' => __( 'Select field from group.', 'js_composer' ),
'dependency' => array(
'element' => 'field_group',
'value' => array( (string) $group[ $id ] ),
),
);
}
return array(
'vc_gitem_acf' => array(
'name' => __( 'Advanced Custom Field', 'js_composer' ),
'base' => 'vc_gitem_acf',
'icon' => 'vc_icon-acf',
'category' => __( 'Content', 'js_composer' ),
'description' => __( 'Advanced Custom Field', 'js_composer' ),
'php_class_name' => 'Vc_Gitem_Acf_Shortcode',
'params' => array_merge(
array(
array(
'type' => 'dropdown',
'heading' => __( 'Field group', 'js_composer' ),
'param_name' => 'field_group',
'value' => $groups_param_values,
'save_always' => true,
'description' => __( 'Select field group.', 'js_composer' ),
),
), $fields_params,
array(
array(
'type' => 'checkbox',
'heading' => __( 'Show label', 'js_composer' ),
'param_name' => 'show_label',
'value' => array( __( 'Yes', 'js_composer' ) => 'yes' ),
'description' => __( 'Enter label to display before key value.', 'js_composer' ),
),
array(
'type' => 'dropdown',
'heading' => __( 'Align', 'js_composer' ),
'param_name' => 'align',
'value' => array(
__( 'left', 'js_composer' ) => 'left',
__( 'right', 'js_composer' ) => 'right',
__( 'center', 'js_composer' ) => 'center',
__( 'justify', 'js_composer' ) => 'justify',
),
'description' => __( 'Select alignment.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => __( 'Extra class name', 'js_composer' ),
'param_name' => 'el_class',
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
),
)
),
'post_type' => Vc_Grid_Item_Editor::postType(),
),
);
@@ -0,0 +1,72 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
$groups = function_exists( 'acf_get_field_groups' ) ? acf_get_field_groups() : apply_filters( 'acf/get_field_groups', array() );
$groups_param_values = $fields_params = array();
foreach ( (array) $groups as $group ) {
$id = isset( $group['id'] ) ? 'id' : ( isset( $group['ID'] ) ? 'ID' : 'id' );
$groups_param_values[ $group['title'] ] = $group[ $id ];
$fields = function_exists( 'acf_get_fields' ) ? acf_get_fields( $group[ $id ] ) : apply_filters( 'acf/field_group/get_fields', array(), $group[ $id ] );
$fields_param_value = array();
foreach ( (array) $fields as $field ) {
$fields_param_value[ $field['label'] ] = (string) $field['key'];
}
$fields_params[] = array(
'type' => 'dropdown',
'heading' => __( 'Field name', 'js_composer' ),
'param_name' => 'field_from_' . $group[ $id ],
'value' => $fields_param_value,
'save_always' => true,
'description' => __( 'Select field from group.', 'js_composer' ),
'dependency' => array(
'element' => 'field_group',
'value' => array( (string) $group[ $id ] ),
),
);
}
return array(
'name' => __( 'Advanced Custom Field', 'js_composer' ),
'base' => 'vc_acf',
'icon' => 'vc_icon-acf',
'category' => __( 'Content', 'js_composer' ),
'description' => __( 'Advanced Custom Field', 'js_composer' ),
'params' => array_merge( array(
array(
'type' => 'dropdown',
'heading' => __( 'Field group', 'js_composer' ),
'param_name' => 'field_group',
'value' => $groups_param_values,
'save_always' => true,
'description' => __( 'Select field group.', 'js_composer' ),
),
), $fields_params, array(
array(
'type' => 'checkbox',
'heading' => __( 'Show label', 'js_composer' ),
'param_name' => 'show_label',
'value' => array( __( 'Yes', 'js_composer' ) => 'yes' ),
'description' => __( 'Enter label to display before key value.', 'js_composer' ),
),
array(
'type' => 'dropdown',
'heading' => __( 'Align', 'js_composer' ),
'param_name' => 'align',
'value' => array(
__( 'left', 'js_composer' ) => 'left',
__( 'right', 'js_composer' ) => 'right',
__( 'center', 'js_composer' ) => 'center',
__( 'justify', 'js_composer' ) => 'justify',
),
'description' => __( 'Select alignment.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => __( 'Extra class name', 'js_composer' ),
'param_name' => 'el_class',
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
),
) ),
);
@@ -0,0 +1,71 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Vendor class for plugin advanced custom fields,
* Needed to apply extra js when backend/frontend editor rendered.
* Class Vc_Vendor_AdvancedCustomFields
* @since 4.3.3
*/
class Vc_Vendor_AdvancedCustomFields implements Vc_Vendor_Interface {
/**
* Initializing actions when backend/frontend editor renders to enqueue fix-js file
* @since 4.3.3
*/
public function load() {
if ( did_action( 'vc-vendor-acf-load' ) ) {
return;
}
/**
* Action when backend editor is rendering
* @see Vc_Backend_Editor::renderEditor wp-content/plugins/js_composer/include/classes/editors/class-vc-backend-editor.php
*/
add_action( 'vc_backend_editor_render', array(
$this,
'enqueueJs',
) );
/**
* Action when frontend editor is rendering
* @see Vc_Frontend_Editor::renderEditor wp-content/plugins/js_composer/include/classes/editors/class-vc-frontend-editor.php
*/
add_action( 'vc_frontend_editor_render', array(
$this,
'enqueueJs',
) );
add_filter( 'vc_grid_item_shortcodes', array(
$this,
'mapGridItemShortcodes',
) );
add_action( 'vc_after_mapping', array(
$this,
'mapEditorsShortcodes',
) );
do_action( 'vc-vendor-acf-load', $this );
}
/**
* Small fix for editor when try to change field
* @since 4.3.3
*/
public function enqueueJs() {
wp_enqueue_script( 'vc_vendor_acf', vc_asset_url( 'js/vendors/advanced_custom_fields.js' ), array( 'jquery' ), '1.0', true );
}
public function mapGridItemShortcodes( array $shortcodes ) {
require_once vc_path_dir( 'VENDORS_DIR', 'plugins/acf/class-vc-gitem-acf-shortcode.php' );
require_once vc_path_dir( 'VENDORS_DIR', 'plugins/acf/grid-item-attributes.php' );
$wc_shortcodes = include vc_path_dir( 'VENDORS_DIR', 'plugins/acf/grid-item-shortcodes.php' );
return $shortcodes + $wc_shortcodes;
}
public function mapEditorsShortcodes() {
require_once vc_path_dir( 'VENDORS_DIR', 'plugins/acf/class-vc-acf-shortcode.php' );
vc_lean_map( 'vc_acf', null, vc_path_dir( 'VENDORS_DIR', 'plugins/acf/shortcode.php' ) );
}
}
@@ -0,0 +1,77 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Contact form7 vendor
* =======
* Plugin Contact form 7 vendor
* To fix issues when shortcode doesn't exists in frontend editor. #1053, #1054 etc.
* @since 4.3
*/
class Vc_Vendor_ContactForm7 implements Vc_Vendor_Interface {
/**
* Add action when contact form 7 is initialized to add shortcode.
* @since 4.3
*/
public function load() {
vc_lean_map( 'contact-form-7',
array(
$this,
'addShortcodeSettings',
) );
}
/**
* Mapping settings for lean method.
*
* @since 4.9
*
* @param $tag
*
* @return array
*/
public function addShortcodeSettings( $tag ) {
/**
* Add Shortcode To WPBakery Page Builder
*/
$cf7 = get_posts( 'post_type="wpcf7_contact_form"&numberposts=-1' );
$contact_forms = array();
if ( $cf7 ) {
foreach ( $cf7 as $cform ) {
$contact_forms[ $cform->post_title ] = $cform->ID;
}
} else {
$contact_forms[ __( 'No contact forms found', 'js_composer' ) ] = 0;
}
return array(
'base' => $tag,
'name' => __( 'Contact Form 7', 'js_composer' ),
'icon' => 'icon-wpb-contactform7',
'category' => __( 'Content', 'js_composer' ),
'description' => __( 'Place Contact Form7', 'js_composer' ),
'params' => array(
array(
'type' => 'dropdown',
'heading' => __( 'Select contact form', 'js_composer' ),
'param_name' => 'id',
'value' => $contact_forms,
'save_always' => true,
'description' => __( 'Choose previously created contact form from the drop down list.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => __( 'Search title', 'js_composer' ),
'param_name' => 'title',
'admin_label' => true,
'description' => __( 'Enter optional title to search if no ID selected or cannot find by ID.', 'js_composer' ),
),
),
);
}
}
@@ -0,0 +1,90 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* JWPLayer loader.
* @since 4.3
*/
class Vc_Vendor_Jwplayer implements Vc_Vendor_Interface {
/**
* Dublicate jwplayer logic for editor, when used in frontend editor mode.
*
* @since 4.3
*/
public function load() {
add_action( 'wp_enqueue_scripts', array(
$this,
'vc_load_iframe_jscss',
) );
add_filter( 'vc_front_render_shortcodes', array(
$this,
'renderShortcodes',
) );
add_filter( 'vc_frontend_template_the_content', array(
$this,
'wrapPlaceholder',
) );
// fix for #1065
add_filter( 'vc_shortcode_content_filter_after', array(
$this,
'renderShortcodesPreview',
) );
}
/**
* @param $output
*
* @since 4.3
*
* @return mixed|string
*/
public function renderShortcodes( $output ) {
$output = str_replace( '][jwplayer', '] [jwplayer', $output ); // fixes jwplayer shortcode regex..
$data = JWP6_Shortcode::the_content_filter( $output );
preg_match_all( '/(jwplayer-\d+)/', $data, $matches );
$pairs = array_unique( $matches[0] );
if ( count( $pairs ) > 0 ) {
$id_zero = time();
foreach ( $pairs as $pair ) {
$data = str_replace( $pair, 'jwplayer-' . $id_zero ++, $data );
}
}
return $data;
}
public function wrapPlaceholder( $content ) {
add_shortcode( 'jwplayer', array( $this, 'renderPlaceholder' ) );
return $content;
}
public function renderPlaceholder() {
return '<div class="vc_placeholder-jwplayer"></div>';
}
/**
* @param $output
*
* @since 4.3, due to #1065
*
* @return string
*/
public function renderShortcodesPreview( $output ) {
$output = str_replace( '][jwplayer', '] [jwplayer', $output ); // fixes jwplayer shortcode regex..
return $output;
}
/**
* @since 4.3
* @todo check it for preview mode (check is it needed)
*/
public function vc_load_iframe_jscss() {
wp_enqueue_script( 'vc_vendor_jwplayer', vc_asset_url( 'js/frontend_editor/vendors/plugins/jwplayer.js' ), array( 'jquery' ), '1.0', true );
}
}
@@ -0,0 +1,163 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* LayerSlider loader.
* Adds layerSlider shortcode to WPBakery Page Builder and fixes issue in frontend editor
*
* @since 4.3
*/
class Vc_Vendor_Layerslider implements Vc_Vendor_Interface {
/**
* @var int - used to detect id for layerslider in frontend
* @deprecated
*/
protected static $instanceIndex = 1;
/**
* Add layerslayer shortcode to WPBakery Page Builder, and add fix for ID in frontend editor
* @since 4.3
*/
public function load() {
add_action( 'vc_after_mapping', array(
$this,
'buildShortcode',
) );
}
/**
* Add shortcode and filters for layerslider id
* @since 4.3
*/
public function buildShortcode() {
vc_lean_map( 'layerslider_vc', array(
$this,
'addShortcodeSettings',
) );
if ( vc_is_page_editable() ) {
add_filter( 'layerslider_slider_init', array(
$this,
'setMarkupId',
), 10, 3 );
add_filter( 'layerslider_slider_markup', array(
$this,
'setMarkupId',
), 10, 3 );
}
}
/**
* @since 4.3
*
* @param $output
*
* @return string
*/
public function setId( $output ) {
return preg_replace( '/(layerslider_\d+)/', '$1_' . $_SERVER['REQUEST_TIME'], $output );
}
/**
* @since 4.3
*
* @param $output
*
* @deprecated 5.2
* @return string
*/
public function setMarkupId( $markup, $slider, $id ) {
return str_replace( $id, $id . '_' . $_SERVER['REQUEST_TIME'], $markup );
}
/**
* Mapping settings for lean method.
*
* @since 4.9
*
* @param $tag
*
* @return array
*/
public function addShortcodeSettings( $tag ) {
$use_old = class_exists( 'LS_Sliders' );
if ( ! class_exists( 'LS_Sliders' ) && defined( 'LS_ROOT_PATH' ) && false === strpos( LS_ROOT_PATH, '.php' ) ) {
include_once LS_ROOT_PATH . '/classes/class.ls.sliders.php';
$use_old = false;
}
if ( ! class_exists( 'LS_Sliders' ) ) {
//again check is needed if some problem inside file "class.ls.sliders.php
$use_old = true;
}
/**
* Filter to use old type of layerslider vendor.
* @since 4.4.2
*/
$use_old = apply_filters( 'vc_vendor_layerslider_old', $use_old ); // @since 4.4.2 hook to use old style return true.
if ( $use_old ) {
global $wpdb;
$ls = $wpdb->get_results( '
SELECT id, name, date_c
FROM ' . $wpdb->prefix . "layerslider
WHERE flag_hidden = '0' AND flag_deleted = '0'
ORDER BY date_c ASC LIMIT 999
" );
$layer_sliders = array();
if ( ! empty( $ls ) ) {
foreach ( $ls as $slider ) {
$layer_sliders[ $slider->name ] = $slider->id;
}
} else {
$layer_sliders[ __( 'No sliders found', 'js_composer' ) ] = 0;
}
} else {
$ls = LS_Sliders::find( array(
'limit' => 999,
'order' => 'ASC',
) );
$layer_sliders = array();
if ( ! empty( $ls ) ) {
foreach ( $ls as $slider ) {
$layer_sliders[ $slider['name'] ] = $slider['id'];
}
} else {
$layer_sliders[ __( 'No sliders found', 'js_composer' ) ] = 0;
}
}
return array(
'base' => $tag,
'name' => __( 'Layer Slider', 'js_composer' ),
'icon' => 'icon-wpb-layerslider',
'category' => __( 'Content', 'js_composer' ),
'description' => __( 'Place LayerSlider', 'js_composer' ),
'params' => array(
array(
'type' => 'textfield',
'heading' => __( 'Widget title', 'js_composer' ),
'param_name' => 'title',
'description' => __( 'Enter text used as widget title (Note: located above content element).', 'js_composer' ),
),
array(
'type' => 'dropdown',
'heading' => __( 'LayerSlider ID', 'js_composer' ),
'param_name' => 'id',
'admin_label' => true,
'value' => $layer_sliders,
'save_always' => true,
'description' => __( 'Select your LayerSlider.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => __( 'Extra class name', 'js_composer' ),
'param_name' => 'el_class',
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
),
),
);
}
}
@@ -0,0 +1,35 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'VENDORS_DIR', 'plugins/class-vc-vendor-qtranslate.php' );
/**
* Class Vc_Vendor_Mqtranslate extends class Vc_Vendor_Qtranslate::__construct
* @since 4.3
*/
class Vc_Vendor_Mqtranslate extends Vc_Vendor_Qtranslate implements Vc_Vendor_Interface {
/**
* @since 4.3
*/
public function setLanguages() {
global $q_config;
$languages = get_option( 'mqtranslate_enabled_languages' );
if ( ! is_array( $languages ) ) {
$languages = $q_config['enabled_languages'];
}
$this->languages = $languages;
}
/**
* @since 4.3
*/
public function qtransSwitch() {
global $q_config;
$q_config['js']['qtrans_save'] .= '
var mqtranslate = true;
';
}
}
@@ -0,0 +1,123 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Ninja Forms vendor
* @since 4.4
*/
class Vc_Vendor_NinjaForms implements Vc_Vendor_Interface {
private static $ninjaCount;
/**
* Implement interface, map ninja forms shortcode
* @since 4.4
*/
public function load() {
vc_lean_map( 'ninja_form', array(
$this,
'addShortcodeSettings',
) );
add_filter( 'vc_frontend_editor_load_shortcode_ajax_output', array(
$this,
'replaceIds',
) );
}
/**
* Mapping settings for lean method.
*
* @since 4.9
*
* @param $tag
*
* @return array
*/
public function addShortcodeSettings( $tag ) {
$ninja_forms = $this->get_forms();
return array(
'base' => $tag,
'name' => __( 'Ninja Forms', 'js_composer' ),
'icon' => 'icon-wpb-ninjaforms',
'category' => __( 'Content', 'js_composer' ),
'description' => __( 'Place Ninja Form', 'js_composer' ),
'params' => array(
array(
'type' => 'dropdown',
'heading' => __( 'Select ninja form', 'js_composer' ),
'param_name' => 'id',
'value' => $ninja_forms,
'save_always' => true,
'description' => __( 'Choose previously created ninja form from the drop down list.', 'js_composer' ),
),
),
);
}
private function get_forms() {
$ninja_forms = array();
if ( $this->is_ninja_forms_three() ) {
$ninja_forms_data = ninja_forms_get_all_forms();
if ( ! empty( $ninja_forms_data ) ) {
// Fill array with Name=>Value(ID)
foreach ( $ninja_forms_data as $key => $value ) {
if ( is_array( $value ) ) {
$ninja_forms[ $value['name'] ] = $value['id'];
}
}
}
} else {
$ninja_forms_data = Ninja_Forms()->form()->get_forms();
if ( ! empty( $ninja_forms_data ) ) {
// Fill array with Name=>Value(ID)
foreach ( $ninja_forms_data as $form ) {
$ninja_forms[ $form->get_setting( 'title' ) ] = $form->get_id();
}
}
}
return $ninja_forms;
}
private function is_ninja_forms_three() {
return ( version_compare( get_option( 'ninja_forms_version', '0.0.0' ), '3.0', '<' ) || get_option( 'ninja_forms_load_deprecated', false ) );
}
public function replaceIds( $output ) {
if ( is_null( self::$ninjaCount ) ) {
self::$ninjaCount = 1;
} else {
self::$ninjaCount ++;
}
$patterns = array(
'(nf-form-)(\d+)(-cont)',
'(nf-form-title-)(\d+)()',
'(nf-form-errors-)(\d+)()',
'(form.id\s*=\s*\')(\d+)(\')',
);
$time = time() . self::$ninjaCount . rand( 100, 999 );
foreach ( $patterns as $pattern ) {
$output = preg_replace( '/' . $pattern . '/', '${1}' . $time . '${3}', $output );
}
$replaceTo = <<<JS
if (typeof nfForms !== 'undefined') {
nfForms = nfForms.filter( function(item, index) {
if (item && item.id) {
return document.querySelector('#nf-form-' + item.id + '-cont')
}
})
}
JS;
$response = str_replace( 'var nfForms', $replaceTo . ';var nfForms', $output );
return $response;
}
}
@@ -0,0 +1,107 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class Vc_Vendor_QtranslateX
* @since 4.12
*/
class Vc_Vendor_QtranslateX implements Vc_Vendor_Interface {
public function load() {
add_action( 'vc_backend_editor_render', array(
$this,
'enqueueJsBackend',
) );
add_action( 'vc_frontend_editor_render', array(
$this,
'enqueueJsFrontend',
) );
add_filter( 'vc_frontend_editor_iframe_url', array(
$this,
'appendLangToUrl',
) );
add_filter( 'vc_nav_front_controls', array(
$this,
'vcNavControlsFrontend',
) );
if ( ! vc_is_frontend_editor() ) {
add_filter( 'vc_get_inline_url', array(
$this,
'vcRenderEditButtonLink',
) );
}
}
public function enqueueJsBackend() {
wp_enqueue_script( 'vc_vendor_qtranslatex_backend', vc_asset_url( 'js/vendors/qtranslatex_backend.js' ), array(
'vc-backend-min-js',
'jquery',
), '1.0', true );
}
public function appendLangToUrl( $link ) {
global $q_config;
if ( $q_config && isset( $q_config['language'] ) ) {
return add_query_arg( array( 'lang' => ( $q_config['language'] ) ), $link );
}
return $link;
}
public function enqueueJsFrontend() {
wp_enqueue_script( 'vc_vendor_qtranslatex_frontend', vc_asset_url( 'js/vendors/qtranslatex_frontend.js' ), array(
'vc-frontend-editor-min-js',
'jquery',
), '1.0', true );
}
/**
* @return string
*/
public function generateSelectFrontend() {
global $q_config;
$output = '';
$output .= '<select id="vc_vendor_qtranslatex_langs_front" class="vc_select vc_select-navbar">';
$inline_url = vc_frontend_editor()->getInlineUrl();
$activeLanguage = $q_config['language'];
$availableLanguages = $q_config['enabled_languages'];
foreach ( $availableLanguages as $lang ) {
$output .= '<option value="' . add_query_arg( array( 'lang' => $lang ), $inline_url ) . '"' . ( $activeLanguage == $lang ? ' selected' : '' ) . ' > ' . qtranxf_getLanguageNameNative( $lang ) . '</option > ';
}
$output .= '</select > ';
return $output;
}
/**
* @param $list
*
* @return array
*/
public function vcNavControlsFrontend( $list ) {
if ( is_array( $list ) ) {
$list[] = array(
'qtranslatex',
'<li class="vc_pull-right" > ' . $this->generateSelectFrontend() . '</li > ',
);
}
return $list;
}
/**
* @param $link
*
* @return string
*/
public function vcRenderEditButtonLink( $link ) {
global $q_config;
$activeLanguage = $q_config['language'];
return add_query_arg( array( 'lang' => $activeLanguage ), $link );
}
}
@@ -0,0 +1,355 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class Vc_Vendor_Qtranslate
* @since 4.3
*/
class Vc_Vendor_Qtranslate implements Vc_Vendor_Interface {
/**
* @since 4.3
* @var array
*/
protected $languages = array();
/**
* @since 4.3
*/
public function setLanguages() {
global $q_config;
$languages = get_option( 'qtranslate_enabled_languages' );
if ( ! is_array( $languages ) ) {
$languages = $q_config['enabled_languages'];
}
$this->languages = $languages;
}
public function isValidPostType() {
return in_array( get_post_type(), vc_editor_post_types() );
}
/**
* @since 4.3
*/
public function load() {
$this->setLanguages();
global $q_config;
add_filter( 'vc_frontend_get_page_shortcodes_post_content', array(
$this,
'filterPostContent',
) );
add_action( 'vc_backend_editor_render', array(
$this,
'enqueueJsBackend',
) );
add_action( 'vc_frontend_editor_render', array(
$this,
'enqueueJsFrontend',
) );
add_action( 'vc_frontend_editor_render_template', array(
$this,
'vcFrontEndEditorRender',
) );
add_filter( 'vc_nav_controls', array(
$this,
'vcNavControls',
) );
add_filter( 'vc_nav_front_controls', array(
$this,
'vcNavControlsFrontend',
) );
add_filter( 'vc_frontend_editor_iframe_url', array(
$this,
'vcRenderEditButtonLink',
) );
if ( ! vc_is_frontend_editor() ) {
add_filter( 'vc_get_inline_url', array(
$this,
'vcRenderEditButtonLink',
) );
}
$q_lang = vc_get_param( 'qlang' );
if ( is_string( $q_lang ) ) {
$q_config['language'] = $q_lang;
}
add_action( 'init', array(
$this,
'qtransPostInit',
), 1000 );
}
/**
* @since 4.3
*/
public function qtransPostInit() {
global $q_config;
$q_config['js']['qtrans_switch'] = "
var swtg= jQuery.extend(true, {}, switchEditors);
switchEditors.go = function(id, lang) {
if ('content' !== id && 'qtrans_textarea_content' !== id && -1 === id.indexOf('qtrans')) {
return swtg.go(id,lang);
}
id = id || 'qtrans_textarea_content';
lang = lang || 'toggle';
if ( 'toggle' === lang ) {
if ( ed && !ed.isHidden() )
lang = 'html';
else
lang = 'tmce';
} else if ( 'tinymce' === lang )
lang = 'tmce';
var inst = tinyMCE.get('qtrans_textarea_' + id);
var vta = document.getElementById('qtrans_textarea_' + id);
var ta = document.getElementById(id);
var dom = tinymce.DOM;
var wrap_id = 'wp-'+id+'-wrap';
var wrap_id2 = 'wp-qtrans_textarea_content-wrap';
// update merged content
if (inst && ! inst.isHidden()) {
tinyMCE.triggerSave();
} else {
qtrans_save(vta.value);
}
// check if language is already active
if (lang !== 'tmce' && lang !== 'html' && document.getElementById('qtrans_select_'+lang).className === 'wp-switch-editor switch-tmce switch-html') {
return;
}
if (lang !== 'tmce' && lang !== 'html') {
document.getElementById('qtrans_select_'+qtrans_get_active_language()).className='wp-switch-editor';
document.getElementById('qtrans_select_'+lang).className='wp-switch-editor switch-tmce switch-html';
}
if (lang === 'html') {
if ( inst && inst.isHidden() )
return false;
if ( inst ) {
vta.style.height = inst.getContentAreaContainer().offsetHeight + 20 + 'px';
inst.hide();
}
dom.removeClass(wrap_id, 'tmce-active');
dom.addClass(wrap_id, 'html-active');
dom.removeClass(wrap_id2, 'tmce-active');
dom.addClass(wrap_id2, 'html-active');
setUserSetting( 'editor', 'html' );
} else if (lang === 'tmce') {
if (inst && ! inst.isHidden())
return false;
if ( 'undefined' !== typeof(QTags) )
QTags.closeAllTags('qtrans_textarea_' + id);
if ( tinyMCEPreInit.mceInit['qtrans_textarea_'+id] && tinyMCEPreInit.mceInit['qtrans_textarea_'+id].wpautop )
vta.value = this.wpautop(qtrans_use(qtrans_get_active_language(),ta.value));
if (inst) {
inst.show();
} else {
qtrans_hook_on_tinyMCE('qtrans_textarea_'+id, true);
}
dom.removeClass(wrap_id, 'html-active');
dom.addClass(wrap_id, 'tmce-active');
dom.removeClass(wrap_id2, 'html-active');
dom.addClass(wrap_id2, 'tmce-active');
setUserSetting('editor', 'tinymce');
} else {
// switch content
qtrans_assign('qtrans_textarea_'+id,qtrans_use(lang,ta.value));
}
}
";
$this->qtransSwitch();
}
/**
* @since 4.3
*/
public function qtransSwitch() {
global $q_config;
$q_config['js']['qtrans_switch'] .= '
jQuery(document).ready(function(){ switchEditors.switchto(document.getElementById("content-html")); });
';
}
/**
* @since 4.3
*/
public function enqueueJsBackend() {
if ( $this->isValidPostType() || apply_filters( 'vc_vendor_qtranslate_enqueue_js_backend', false ) ) {
wp_enqueue_script( 'vc_vendor_qtranslate_backend', vc_asset_url( 'js/vendors/qtranslate_backend.js' ), array( 'vc-backend-min-js' ), '1.0', true );
}
}
/**
* @since 4.3
*/
public function enqueueJsFrontend() {
if ( $this->isValidPostType() ) {
wp_enqueue_script( 'vc_vendor_qtranslate_frontend', vc_asset_url( 'js/vendors/qtranslate_frontend.js' ), array( 'vc-frontend-editor-min-js' ), '1.0', true );
global $q_config;
$q_config['js']['qtrans_save'] = '';
$q_config['js']['qtrans_integrate_category'] = '';
$q_config['js']['qtrans_integrate_title'] = '';
$q_config['js']['qtrans_assign'] = '';
$q_config['js']['qtrans_tinyMCEOverload'] = '';
$q_config['js']['qtrans_wpActiveEditorOverload'] = '';
$q_config['js']['qtrans_updateTinyMCE'] = '';
$q_config['js']['qtrans_wpOnload'] = '';
$q_config['js']['qtrans_editorInit'] = '';
$q_config['js']['qtrans_hook_on_tinyMCE'] = '';
$q_config['js']['qtrans_switch_postbox'] = '';
$q_config['js']['qtrans_switch'] = '';
}
}
/**
* @since 4.3
* @return string
*/
public function generateSelect() {
$output = '';
if ( is_array( $this->languages ) && ! empty( $this->languages ) ) {
$output .= '<select id="vc_vendor_qtranslate_langs" class="vc_select vc_select-navbar" style="display:none;">';
$inline_url = vc_frontend_editor()->getInlineUrl();
foreach ( $this->languages as $lang ) {
$output .= '<option value="' . $lang . '" link="' . add_query_arg( array( 'qlang' => $lang ), $inline_url ) . '">' . qtrans_getLanguageName( $lang ) . '</option>';
}
$output .= '</select>';
}
return $output;
}
/**
* @since 4.3
* @return string
*/
public function generateSelectFrontend() {
$output = '';
if ( is_array( $this->languages ) && ! empty( $this->languages ) ) {
$output .= '<select id="vc_vendor_qtranslate_langs_front" class="vc_select vc_select-navbar">';
$q_lang = vc_get_param( 'qlang' );
$inline_url = vc_frontend_editor()->getInlineUrl();
foreach ( $this->languages as $lang ) {
$output .= '<option value="' . add_query_arg( array( 'qlang' => $lang ), $inline_url ) . '"' . ( $q_lang == $lang ? ' selected' : '' ) . ' > ' . qtrans_getLanguageName( $lang ) . '</option > ';
}
$output .= '</select > ';
}
return $output;
}
/**
* @since 4.3
*
* @param $list
*
* @return array
*/
public function vcNavControls( $list ) {
if ( $this->isValidPostType() ) {
if ( is_array( $list ) ) {
$list[] = array(
'qtranslate',
$this->getControlSelectDropdown(),
);
}
}
return $list;
}
/**
* @since 4.3
*
* @param $list
*
* @return array
*/
public function vcNavControlsFrontend( $list ) {
if ( $this->isValidPostType() ) {
if ( is_array( $list ) ) {
$list[] = array(
'qtranslate',
$this->getControlSelectDropdownFrontend(),
);
}
}
return $list;
}
/**
* @since 4.3
* @return string
*/
public function getControlSelectDropdown() {
return '<li class="vc_pull-right" > ' . $this->generateSelect() . '</li > ';
}
/**
* @return string
*/
public function getControlSelectDropdownFrontend() {
return '<li class="vc_pull-right" > ' . $this->generateSelectFrontend() . '</li > ';
}
/**
* @since 4.3
*
* @param $link
*
* @return string
*/
public function vcRenderEditButtonLink( $link ) {
return add_query_arg( array( 'qlang' => qtrans_getLanguage() ), $link );
}
/**
* @since 4.3
*/
public function vcFrontendEditorRender() {
global $q_config;
$output = '';
$q_lang = vc_get_param( 'qlang' );
if ( ! is_string( $q_lang ) ) {
$q_lang = $q_config['language'];
}
$output .= '<input type="hidden" id="vc_vendor_qtranslate_postcontent" value="' . esc_attr( vc_frontend_editor()->post()->post_content ) . '" data-lang="' . $q_lang . '"/>';
$output .= '<input type="hidden" id="vc_vendor_qtranslate_posttitle" value="' . esc_attr( vc_frontend_editor()->post()->post_title ) . '" data-lang="' . $q_lang . '"/>';
echo $output;
}
/**
* @since 4.3
*
* @param $content
*
* @return string
*/
public function filterPostContent( $content ) {
return qtrans_useCurrentLanguageIfNotFoundShowAvailable( $content );
}
}
@@ -0,0 +1,154 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* RevSlider loader.
* @since 4.3
*/
class Vc_Vendor_Revslider implements Vc_Vendor_Interface {
/**
* @since 4.3
* @var int - index of revslider
*/
protected static $instanceIndex = 1;
/**
* Add shortcode to WPBakery Page Builder also add fix for frontend to regenerate id of revslider.
* @since 4.3
*/
public function load() {
add_action( 'vc_after_mapping', array(
$this,
'buildShortcode',
) );
}
/**
* @since 4.3
*/
public function buildShortcode() {
if ( class_exists( 'RevSlider' ) ) {
vc_lean_map( 'rev_slider_vc', array(
$this,
'addShortcodeSettings',
) );
if ( vc_is_frontend_ajax() || vc_is_frontend_editor() ) {
add_filter( 'vc_revslider_shortcode', array(
$this,
'setId',
) );
}
}
}
/**
* @since 4.4
*
* @param array $revsliders
*
* @deprecated 4.9
*/
public function mapShortcode( $revsliders = array() ) {
vc_map( array(
'base' => 'rev_slider_vc',
'name' => __( 'Revolution Slider', 'js_composer' ),
'icon' => 'icon-wpb-revslider',
'category' => __( 'Content', 'js_composer' ),
'description' => __( 'Place Revolution slider', 'js_composer' ),
'params' => array(
array(
'type' => 'textfield',
'heading' => __( 'Widget title', 'js_composer' ),
'param_name' => 'title',
'description' => __( 'Enter text used as widget title (Note: located above content element).', 'js_composer' ),
),
array(
'type' => 'dropdown',
'heading' => __( 'Revolution Slider', 'js_composer' ),
'param_name' => 'alias',
'admin_label' => true,
'value' => $revsliders,
'save_always' => true,
'description' => __( 'Select your Revolution Slider.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => __( 'Extra class name', 'js_composer' ),
'param_name' => 'el_class',
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
),
),
) );
}
/**
* Replaces id of revslider for frontend editor.
* @since 4.3
*
* @param $output
*
* @return string
*/
public function setId( $output ) {
return preg_replace( '/rev_slider_(\d+)_(\d+)/', 'rev_slider_$1_$2' . time() . '_' . self::$instanceIndex ++, $output );
}
/**
* Mapping settings for lean method.
*
* @since 4.9
*
* @param $tag
*
* @return array
*/
public function addShortcodeSettings( $tag ) {
$slider = new RevSlider();
$arrSliders = $slider->getArrSliders();
$revsliders = array();
if ( $arrSliders ) {
foreach ( $arrSliders as $slider ) {
/** @var $slider RevSlider */
$revsliders[ $slider->getTitle() ] = $slider->getAlias();
}
} else {
$revsliders[ __( 'No sliders found', 'js_composer' ) ] = 0;
}
// Add fixes for frontend editor to regenerate id
return array(
'base' => $tag,
'name' => __( 'Revolution Slider', 'js_composer' ),
'icon' => 'icon-wpb-revslider',
'category' => __( 'Content', 'js_composer' ),
'description' => __( 'Place Revolution slider', 'js_composer' ),
'params' => array(
array(
'type' => 'textfield',
'heading' => __( 'Widget title', 'js_composer' ),
'param_name' => 'title',
'description' => __( 'Enter text used as widget title (Note: located above content element).', 'js_composer' ),
),
array(
'type' => 'dropdown',
'heading' => __( 'Revolution Slider', 'js_composer' ),
'param_name' => 'alias',
'admin_label' => true,
'value' => $revsliders,
'save_always' => true,
'description' => __( 'Select your Revolution Slider.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => __( 'Extra class name', 'js_composer' ),
'param_name' => 'el_class',
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
),
),
);
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,53 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class Vc_Vendor_WPML
* @since 4.9
*/
class Vc_Vendor_WPML implements Vc_Vendor_Interface {
public function load() {
add_filter( 'vc_object_id', array(
$this,
'filterMediaId',
) );
add_filter( 'vc_basic_grid_filter_query_suppress_filters', '__return_false' );
add_filter( 'vc_grid_request_url', array(
$this,
'appendLangToUrlGrid',
) );
global $sitepress;
$action = vc_post_param( 'action' );
if ( vc_is_page_editable() && 'vc_frontend_load_template' === $action ) {
// Fix Issue with loading template #135512264670405
remove_action( 'wp_loaded', array(
$sitepress,
'maybe_set_this_lang',
) );
}
}
public function appendLangToUrlGrid( $link ) {
global $sitepress;
if ( is_object( $sitepress ) ) {
if ( is_string( $link ) && strpos( $link, 'lang' ) === false ) {
// add langs for vc_inline/vc_editable requests
if ( strpos( $link, 'admin-ajax' ) !== false ) {
return add_query_arg( array( 'lang' => $sitepress->get_current_language() ), $link );
}
}
}
return $link;
}
public function filterMediaId( $id ) {
return apply_filters( 'wpml_object_id', $id, 'post', true );
}
}
@@ -0,0 +1,144 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class Vc_Vendor_YoastSeo
* @since 4.4
*/
class Vc_Vendor_YoastSeo implements Vc_Vendor_Interface {
/**
* Created to improve yoast multiply calling wpseo_pre_analysis_post_content filter.
* @since 4.5.3
* @var string - parsed post content
*/
protected $parsedContent;
function __construct() {
add_action( 'vc_backend_editor_render', array(
$this,
'enqueueJs',
) );
add_filter( 'wpseo_sitemap_urlimages', array(
$this,
'filterSitemapUrlImages',
), 10, 2 );
}
/**
* Add filter for yoast.
* @since 4.4
*/
public function load() {
if ( class_exists( 'WPSEO_Metabox' ) && ( 'admin_page' === vc_mode() || 'admin_frontend_editor' === vc_mode() ) ) {
add_filter( 'wpseo_pre_analysis_post_content', array(
$this,
'filterResults',
) );
}
}
/**
* Properly parse content to detect images/text keywords.
* @since 4.4
*
* @param $content
*
* @return string
*/
public function filterResults( $content ) {
if ( empty( $this->parsedContent ) ) {
global $post, $wp_the_query;
$wp_the_query->post = $post; // since 4.5.3 to avoid the_post replaces
/**
* @since 4.4.3
* vc_filter: vc_vendor_yoastseo_filter_results
*/
do_action( 'vc_vendor_yoastseo_filter_results' );
$this->parsedContent = do_shortcode( shortcode_unautop( $content ) );
wp_reset_query();
}
return $this->parsedContent;
}
/**
* @since 4.4
*/
public function enqueueJs() {
require_once vc_path_dir( 'PARAMS_DIR', 'vc_grid_item/editor/class-vc-grid-item-editor.php' );
if ( get_post_type() === Vc_Grid_Item_Editor::postType() ) {
return;
}
wp_enqueue_script( 'vc_vendor_yoast_js', vc_asset_url( 'js/vendors/yoast.js' ), array( 'yoast-seo-post-scraper' ), WPB_VC_VERSION, true );
}
public function frontendEditorBuild() {
$vc_yoast_meta_box = $GLOBALS['wpseo_metabox'];
remove_action( 'admin_init', array(
$GLOBALS['wpseo_meta_columns'],
'setup_hooks',
) );
apply_filters( 'wpseo_use_page_analysis', false );
remove_action( 'add_meta_boxes', array(
$vc_yoast_meta_box,
'add_meta_box',
) );
remove_action( 'admin_enqueue_scripts', array(
$vc_yoast_meta_box,
'enqueue',
) );
remove_action( 'wp_insert_post', array(
$vc_yoast_meta_box,
'save_postdata',
) );
remove_action( 'edit_attachment', array(
$vc_yoast_meta_box,
'save_postdata',
) );
remove_action( 'add_attachment', array(
$vc_yoast_meta_box,
'save_postdata',
) );
remove_action( 'post_submitbox_start', array(
$vc_yoast_meta_box,
'publish_box',
) );
remove_action( 'admin_init', array(
$vc_yoast_meta_box,
'setup_page_analysis',
) );
remove_action( 'admin_init', array(
$vc_yoast_meta_box,
'translate_meta_boxes',
) );
remove_action( 'admin_footer', array(
$vc_yoast_meta_box,
'template_keyword_tab',
) );
}
public function filterSitemapUrlImages( $images, $id ) {
if ( empty( $images ) ) {
$post = get_post( $id );
if ( $post && strpos( $post->post_content, '[vc_row' ) !== false ) {
preg_match_all( '/(?:image|images|ids|include)\=\"([^\"]+)\"/', $post->post_content, $matches );
foreach ( $matches[1] as $m ) {
$ids = explode( ',', $m );
foreach ( $ids as $id ) {
if ( (int) $id ) {
$images[] = array(
'src' => wp_get_attachment_url( $id ),
'title' => get_the_title( $id ),
);
}
}
}
}
}
return $images;
}
}
@@ -0,0 +1,52 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
class Vc_Gitem_Woocommerce_Shortcode extends WPBakeryShortCode {
/**
* @param $atts
* @param null $content
*
* @return mixed|void
*/
protected function content( $atts, $content = null ) {
$key = '';
/**
* @var string $el_class
* @var string $post_type
* @var string $product_field_key
* @var string $order_field_key
* @var string $product_custom_key
* @var string $order_custom_key
* @var string $show_label
* @var string $align
*/
$atts = shortcode_atts( array(
'el_class' => '',
'post_type' => 'product',
'product_field_key' => 'sku',
'product_custom_key' => '',
'order_field_key' => 'order_number',
'order_custom_key' => '',
'show_label' => '',
'align' => '',
), $atts );
extract( $atts );
if ( 'product' === $post_type ) {
$key = '_custom_' === $product_field_key ? $product_custom_key : $product_field_key;
} elseif ( 'order' === $post_type ) {
$key = '_custom_' === $order_field_key ? $order_custom_key : $order_field_key;
}
if ( 'yes' === $show_label ) {
$key .= '_labeled';
}
$css_class = 'vc_gitem-woocommerce vc_gitem-woocommerce-' . $post_type . '-' . $key
. ( strlen( $el_class ) ? ' ' . $el_class : '' )
. ( strlen( $align ) ? ' vc_gitem-align-' . $align : '' );
return '<div class="' . esc_attr( $css_class ) . '">'
. '{{ woocommerce_' . $post_type . ':' . $key . ' }}'
. '</div>';
}
}
@@ -0,0 +1,162 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Get woocommerce data for product
*
* @param $value
* @param $data
*
* @return string
*/
function vc_gitem_template_attribute_woocommerce_product( $value, $data ) {
$label = '';
/**
* @var null|Wp_Post $post ;
* @var string $data ;
*/
extract( array_merge( array(
'post' => null,
'data' => '',
), $data ) );
require_once WC()->plugin_path() . '/includes/abstracts/abstract-wc-product.php';
$product = new WC_Product( $post );
if ( preg_match( '/_labeled$/', $data ) ) {
$data = preg_replace( '/_labeled$/', '', $data );
$label = apply_filters( 'vc_gitem_template_attribute_woocommerce_product_' . $data . '_label',
Vc_Vendor_Woocommerce::getProductFieldLabel( $data ) . ': ' );
}
switch ( $data ) {
case 'id':
$value = (int) $product->is_type( 'variation' ) ? $product->get_id() : $product->id;
break;
case 'sku':
$value = $product->get_sku();
break;
case 'price':
$value = wc_price( $product->get_price() );
break;
case 'regular_price':
$value = wc_price( $product->get_regular_price() );
break;
case 'sale_price':
$value = wc_price( $product->get_sale_price() );
break;
case 'price_html':
$value = $product->get_price_html();
break;
case 'reviews_count':
$value = count( get_comments( array( 'post_id' => $post->ID, 'approve' => 'approve' ) ) );
break;
case 'short_description':
$value = apply_filters( 'woocommerce_short_description', get_post( $product->get_id() )->post_excerpt );
break;
case 'dimensions':
$units = get_option( 'woocommerce_dimension_unit' );
$value = $product->length . $units . 'x' . $product->width . $units . 'x' . $product->height . $units;
break;
case 'rating_count':
$value = $product->get_rating_count();
break;
case 'weight':
$value = $product->get_weight() ? wc_format_decimal( $product->get_weight(), 2 ) : '';
break;
case 'on_sale':
$value = $product->is_on_sale() ? 'yes' : 'no'; // TODO: change
break;
default:
$value = $product->$data;
}
return strlen( $value ) > 0 ? $label . apply_filters( 'vc_gitem_template_attribute_woocommerce_product_'
. $data . '_value',
$value ) : '';
}
/**
* Gte woocommerce data for order
*
* @param $value
* @param $data
*
* @return string
*/
function vc_gitem_template_attribute_woocommerce_order( $value, $data ) {
$label = '';
/**
* @var null|Wp_Post $post ;
* @var string $data ;
*/
extract( array_merge( array(
'post' => null,
'data' => '',
), $data ) );
require_once WC()->plugin_path() . '/includes/class-wc-order.php';
$order = new WC_Order( $post->ID );
if ( preg_match( '/_labeled$/', $data ) ) {
$data = preg_replace( '/_labeled$/', '', $data );
$label = apply_filters( 'vc_gitem_template_attribute_woocommerce_order_' . $data . '_label',
Vc_Vendor_Woocommerce::getOrderFieldLabel( $data ) . ': ' );
}
switch ( $data ) {
case 'id':
$value = $order->id;
break;
case 'order_number':
$value = $order->get_order_number();
break;
case 'total':
$value = sprintf( get_woocommerce_price_format(), wc_format_decimal( $order->get_total(), 2 ),
$order->order_currency );
break;
case 'payment_method':
$value = $order->payment_method_title;
break;
case 'billing_address_city':
$value = $order->billing_city;
break;
case 'billing_address_country':
$value = $order->billing_country;
break;
case 'shipping_address_city':
$value = $order->shipping_city;
break;
case 'shipping_address_country':
$value = $order->shipping_country;
break;
default:
$value = $order->$data;
}
return strlen( $value ) > 0 ? $label . apply_filters( 'vc_gitem_template_attribute_woocommerce_order_' . $data . '_value', $value ) : '';
}
/**
* Get woocommerce product add to cart url.
*
* @param $value
* @param $data
*
* @since 4.5
*
* @return string
*/
function vc_gitem_template_attribute_woocommerce_product_link( $value, $data ) {
/**
* @var null|Wp_Post $post ;
* @var string $data ;
*/
extract( array_merge( array(
'post' => null,
'data' => '',
), $data ) );
$link = do_shortcode( '[add_to_cart_url id="' . $post->ID . '"]' );
return apply_filters( 'vc_gitem_template_attribute_woocommerce_product_link_value', $link );
}
add_filter( 'vc_gitem_template_attribute_woocommerce_product', 'vc_gitem_template_attribute_woocommerce_product', 10, 2 );
add_filter( 'vc_gitem_template_attribute_woocommerce_order', 'vc_gitem_template_attribute_woocommerce_order', 10, 2 );
add_filter( 'vc_gitem_template_attribute_woocommerce_product_link', 'vc_gitem_template_attribute_woocommerce_product_link', 10, 2 );
@@ -0,0 +1,121 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Append 'add to card' link to the list of Add link for grid element shortcodes.
*
* @param $param
*
* @since 4.5
*
* @return array
*/
function vc_gitem_add_link_param_woocommerce( $param ) {
$param['value'][ __( 'WooCommerce add to card link', 'js_composer' ) ] = 'woo_add_to_card';
return $param;
}
/**
* Add WooCommerce link attributes to enable add to cart functionality
*
* @param $link
* @param $atts
* @param string $css_class
*
* @since 4.5
*
* @return string
*/
function vc_gitem_post_data_get_link_link_woocommerce( $link, $atts, $css_class = '' ) {
if ( isset( $atts['link'] ) && 'woo_add_to_card' === $atts['link'] ) {
$css_class .= ' add_to_cart_button vc-gitem-link-ajax product_type_simple';
return 'a href="{{ woocommerce_product_link }}" class="' . esc_attr( $css_class ) . '" data-product_id="{{ woocommerce_product:id }}"' . ' data-product_sku="{{ woocommerce_product:sku }}" data-product-quantity="1"';
}
return $link;
}
/**¬
* Remove target as useless for add to cart link.
*
* @param $link
* @param $atts
*
* @since 4.5
*
* @return string
*/
function vc_gitem_post_data_get_link_target_woocommerce( $link, $atts ) {
if ( isset( $atts['link'] ) && 'woo_add_to_card' === $atts['link'] ) {
return '';
}
return $link;
}
/**
* Add WooCommerce link attributes to enable add to cart functionality. Not using item element templates vars.
*
* @param $link
* @param $atts
* @param $post
* @param string $css_class
* @return string
* @since 4.5
*
*/
function vc_gitem_post_data_get_link_real_link_woocommerce( $link, $atts, $post, $css_class = '' ) {
if ( isset( $atts['link'] ) && 'woo_add_to_card' === $atts['link'] ) {
$css_class .= ' add_to_cart_button vc-gitem-link-ajax product_type_simple';
$link = 'a href="'
. do_shortcode( '[add_to_cart_url id="' . $post->ID . '"]' )
. '" class="' . esc_attr( $css_class ) . '" data-product_id="'
. esc_attr(
vc_gitem_template_attribute_woocommerce_product( '',
array(
'post' => $post,
'data' => 'id',
)
)
) . '"' . ' data-product_sku="' . esc_attr(
vc_gitem_template_attribute_woocommerce_product( '',
array(
'post' => $post,
'data' => 'sku',
)
)
) . '" data-product-quantity="1"';
}
return $link;
}
/**¬
* Remove target as useless for add to cart link.
*
* @param $link
* @param $atts
* @param $post
*
* @since 4.5
*
* @return string
*/
function vc_gitem_post_data_get_link_real_target_woocommerce( $link, $atts, $post ) {
return 'woo_add_to_card' === $link ? '' : $link;
}
function vc_gitem_zone_image_block_link_woocommerce( $image_block, $link, $css_class ) {
if ( 'woo_add_to_card' === $link ) {
$css_class .= ' add_to_cart_button vc-gitem-link-ajax product_type_simple';
return '<a href="{{ woocommerce_product_link }}" class="' . esc_attr( $css_class ) . '" data-product_id="{{ woocommerce_product:id }}"' . ' data-product_sku="{{ woocommerce_product:sku }}" data-product-quantity="1"></a>';
}
return $image_block;
}
@@ -0,0 +1,101 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
return array(
'vc_gitem_wocommerce' => array(
'name' => __( 'WooCommerce field', 'js_composer' ),
'base' => 'vc_gitem_wocommerce',
'icon' => 'icon-wpb-woocommerce',
'category' => __( 'Content', 'js_composer' ),
'description' => __( 'Woocommerce', 'js_composer' ),
'php_class_name' => 'Vc_Gitem_Woocommerce_Shortcode',
'params' => array(
array(
'type' => 'dropdown',
'heading' => __( 'Content type', 'js_composer' ),
'param_name' => 'post_type',
'value' => array(
__( 'Product', 'js_composer' ) => 'product',
__( 'Order', 'js_composer' ) => 'order',
),
'save_always' => true,
'description' => __( 'Select Woo Commerce post type.', 'js_composer' ),
),
array(
'type' => 'dropdown',
'heading' => __( 'Product field name', 'js_composer' ),
'param_name' => 'product_field_key',
'value' => Vc_Vendor_Woocommerce::getProductsFieldsList(),
'dependency' => array(
'element' => 'post_type',
'value' => array( 'product' ),
),
'save_always' => true,
'description' => __( 'Select field from product.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => __( 'Product custom key', 'js_composer' ),
'param_name' => 'product_custom_key',
'description' => __( 'Enter custom key.', 'js_composer' ),
'dependency' => array(
'element' => 'product_field_key',
'value' => array( '_custom_' ),
),
),
array(
'type' => 'dropdown',
'heading' => __( 'Order fields', 'js_composer' ),
'param_name' => 'order_field_key',
'value' => Vc_Vendor_Woocommerce::getOrderFieldsList(),
'dependency' => array(
'element' => 'post_type',
'value' => array( 'order' ),
),
'save_always' => true,
'description' => __( 'Select field from order.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => __( 'Order custom key', 'js_composer' ),
'param_name' => 'order_custom_key',
'dependency' => array(
'element' => 'order_field_key',
'value' => array( '_custom_' ),
),
'description' => __( 'Enter custom key.', 'js_composer' ),
),
array(
'type' => 'checkbox',
'heading' => __( 'Show label', 'js_composer' ),
'param_name' => 'show_label',
'value' => array( __( 'Yes', 'js_composer' ) => 'yes' ),
'save_always' => true,
'description' => __( 'Enter label to display before key value.', 'js_composer' ),
),
array(
'type' => 'dropdown',
'heading' => __( 'Align', 'js_composer' ),
'param_name' => 'align',
'value' => array(
__( 'left', 'js_composer' ) => 'left',
__( 'right', 'js_composer' ) => 'right',
__( 'center', 'js_composer' ) => 'center',
__( 'justify', 'js_composer' ) => 'justify',
),
'save_always' => true,
'description' => __( 'Select alignment.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => __( 'Extra class name', 'js_composer' ),
'param_name' => 'el_class',
'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
),
),
'post_type' => Vc_Grid_Item_Editor::postType(),
),
);