?
vendors/plugins/class-vc-vendor-qtranslate-x.php 0000666 00000005004 15126312411 0016044 0 ustar 00 <?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 );
}
}
vendors/plugins/class-vc-vendor-ninja-forms.php 0000666 00000004625 15126312411 0015654 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Ninja Forms vendor
* @since 4.4
*/
class Vc_Vendor_NinjaForms implements Vc_Vendor_Interface {
/**
* Implement interface, map ninja forms shortcode
* @since 4.4
*/
public function load() {
vc_lean_map( 'ninja_forms_display_form', array(
$this,
'addShortcodeSettings',
) );
}
/**
* Add Shortcode To Visual Composer
*
* @param array $ninja_forms - list of ninja forms (ID->NAME)
*
* @since 4.4
*
* @deprecated 4.9
*/
public function mapNinjaForms( $ninja_forms = array() ) {
// We map only ninja_forms_display_form shortcode same as contact-form-7
vc_map( array(
'base' => 'ninja_forms_display_form',
'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' ),
),
),
) );
}
/**
* Mapping settings for lean method.
*
* @since 4.9
*
* @param $tag
*
* @return array
*/
public function addShortcodeSettings( $tag ) {
if ( ! function_exists( 'ninja_forms_get_all_forms' ) ) {
// experimental, maybe not needed
require_once( NINJA_FORMS_DIR . '/includes/database.php' );
}
$ninja_forms_data = ninja_forms_get_all_forms();
$ninja_forms = array();
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'];
}
}
}
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' ),
),
),
);
}
}
vendors/plugins/class-vc-vendor-contact-form7.php 0000666 00000003511 15126312411 0016105 0 ustar 00 <?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 Visual Composer
*/
$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' ),
),
),
);
}
}
vendors/plugins/class-vc-vendor-yoast_seo.php 0000666 00000004776 15126312411 0015445 0 ustar 00 <?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 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() {
wp_enqueue_script( 'vc_vendor_yoast_js', vc_asset_url( 'js/vendors/yoast.js' ), array( 'yoast-seo-admin-global-script' ), 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' ) );
}
}
vendors/plugins/acf/class-vc-gitem-acf-shortcode.php 0000666 00000003051 15126312411 0016503 0 ustar 00 <?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>';
}
}
vendors/plugins/acf/grid-item-attributes.php 0000666 00000002622 15126312411 0015216 0 ustar 00 <?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 );
vendors/plugins/acf/grid-item-shortcodes.php 0000666 00000005323 15126312411 0015206 0 ustar 00 <?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 ( $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(),
),
);
vendors/plugins/class-vc-vendor-jwplayer.php 0000666 00000003757 15126312411 0015273 0 ustar 00 <?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 );
}
}
core/class-vc-base.php 0000666 00000067066 15126312411 0010647 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery Visual Composer main class.
*
* @package WPBakeryVisualComposer
* @since 4.2
*/
/**
* Visual Composer basic class.
* @since 4.2
*/
class Vc_Base {
/**
* Shortcode's edit form.
*
* @since 4.2
* @access protected
* @var bool|Vc_Shortcode_Edit_Form
*/
protected $shortcode_edit_form = false;
/**
* Templates management panel.
* @deprecated 4.4 updated to $templates_panel_editor, use Vc_Base::setTemplatesPanelEditor
* @since 4.2
* @access protected
* @var bool|Vc_Templates_Editor
*/
protected $templates_editor = false;
/**
* Templates management panel editor.
* @since 4.4
* @access protected
* @var bool|Vc_Templates_Panel_Editor
*/
protected $templates_panel_editor = false;
/**
* Post object for VC in Admin.
*
* @since 4.4
* @access protected
* @var bool|Vc_Post_Admin
*/
protected $post_admin = false;
/**
* Post object for VC.
*
* @since 4.4.3
* @access protected
* @var bool|Vc_Post_Admin
*/
protected $post = false;
/**
* List of shortcodes map to VC.
*
* @since 4.2
* @access public
* @var array WPBakeryShortCodeFishBones
*/
protected $shortcodes = array();
/**
* @deprecated 4.4 due to autoload logic
* @var Vc_Vendors_Manager $vendor_manager
*/
protected $vendor_manager;
/**
* Load default object like shortcode parsing.
*
* @since 4.2
* @access public
*/
public function init() {
do_action( 'vc_before_init_base' );
if ( is_admin() ) {
$this->postAdmin()->init();
}
add_filter( 'body_class', array(
&$this,
'bodyClass',
) );
add_filter( 'the_excerpt', array(
&$this,
'excerptFilter',
) );
add_action( 'wp_head', array(
&$this,
'addMetaData',
) );
add_action( 'wp_head', array(
&$this,
'addIEMinimalSupport',
) );
if ( is_admin() ) {
$this->initAdmin();
} else {
$this->initPage();
}
do_action( 'vc_after_init_base' );
}
/**
* Post object for interacting with Current post data.
* @since 4.4
* @return Vc_Post_Admin
*/
public function postAdmin() {
if ( false === $this->post_admin ) {
require_once vc_path_dir( 'CORE_DIR', 'class-vc-post-admin.php' );
$this->post_admin = new Vc_Post_Admin();
}
return $this->post_admin;
}
/**
* Build VC for frontend pages.
*
* @since 4.2
* @access public
*/
public function initPage() {
do_action( 'vc_build_page' );
add_action( 'template_redirect', array(
&$this,
'frontCss',
) );
add_action( 'template_redirect', array(
'WPBMap',
'addAllMappedShortcodes',
) );
add_action( 'wp_head', array(
&$this,
'addFrontCss',
), 1000 );
add_action( 'wp_head', array(
&$this,
'addNoScript',
), 1000 );
add_action( 'template_redirect', array(
&$this,
'frontJsRegister',
) );
add_filter( 'the_content', array(
&$this,
'fixPContent',
), 11 );
}
/**
* Load admin required modules and elements
*
* @since 4.2
* @access public
*/
public function initAdmin() {
do_action( 'vc_build_admin_page' );
// Build settings for admin page;
//$this->registerAdminJavascript();
//$this->registerAdminCss();
// editors actions:
$this->editForm()->init();
$this->templatesPanelEditor()->init();
// ajax params/shortcode action
add_action( 'wp_ajax_wpb_single_image_src', array(
&$this,
'singleImageSrc',
) ); // @todo move it
add_action( 'wp_ajax_wpb_gallery_html', array(
&$this,
'galleryHTML',
) ); // @todo move it
// plugins list page actions links
add_filter( 'plugin_action_links', array(
&$this,
'pluginActionLinks',
), 10, 2 );
}
/**
* Setter for edit form.
* @since 4.2
*
* @param Vc_Shortcode_Edit_Form $form
*/
public function setEditForm( Vc_Shortcode_Edit_Form $form ) {
$this->shortcode_edit_form = $form;
}
/**
* Get Shortcodes Edit form object.
*
* @see Vc_Shortcode_Edit_Form::__construct
* @since 4.2
* @access public
* @return Vc_Shortcode_Edit_Form
*/
public function editForm() {
return $this->shortcode_edit_form;
}
/**
* Setter for Templates editor.
* @deprecated 4.4 updated to panel editor see Vc_Templates_Panel_Editor::__construct
* @use setTemplatesPanelEditor
* @since 4.2
*
* @param Vc_Templates_Editor $editor
*/
public function setTemplatesEditor( Vc_Templates_Editor $editor ) {
// _deprecated_function( 'Vc_Base::setTemplatesEditor', '4.4 (will be removed in 4.10)', 'Vc_Base::setTemplatesPanelEditor' );
$this->templates_editor = $editor;
}
/**
* Setter for Templates editor.
* @since 4.4
*
* @param Vc_Templates_Panel_Editor $editor
*/
public function setTemplatesPanelEditor( Vc_Templates_Panel_Editor $editor ) {
$this->templates_panel_editor = $editor;
}
/**
* Get templates manager.
* @deprecated updated to panel editor see Vc_Templates_Panel_Editor::__construct
* @see Vc_Templates_Editor::__construct
* @since 4.2
* @access public
* @return bool|Vc_Templates_Editor
*/
public function templatesEditor() {
// _deprecated_function( 'Vc_Base::templatesEditor', '4.4 (will be removed in 4.10)', 'Vc_Base::templatesPanelEditor' );
return $this->templates_editor;
}
/**
* Get templates manager.
* @see Vc_Templates_Panel_Editor::__construct
* @since 4.4
* @access public
* @return bool|Vc_Templates_Panel_Editor
*/
public function templatesPanelEditor() {
return $this->templates_panel_editor;
}
/**
* Save method for edit_post action.
* @deprecated 4.9
* @since 4.2
* @access public
*
* @param null $post_id
*/
public function save( $post_id = null ) {
// _deprecated_function( '\Vc_Base::save', '4.9 (will be removed in 4.11)', '\Vc_Post_Admin::save' );
}
/**
* Add new shortcode to Visual composer.
*
* @see WPBMap::map
* @since 4.2
* @access public
* @deprecated 4.9
*
* @param array $shortcode - array of options.
*/
public function addShortCode( array $shortcode ) {
// _deprecated_function( '\Vc_Base::addShortcode', '4.9 (will be removed in 4.11)', '\Vc_Post_Admin::save' );
if ( ! isset( $this->shortcodes[ $shortcode['base'] ] ) ) {
require_once vc_path_dir( 'SHORTCODES_DIR', 'shortcodes.php' );
$this->shortcodes[ $shortcode['base'] ] = new WPBakeryShortCodeFishBones( $shortcode );
}
}
/**
* Get shortcode class instance.
*
* @see WPBakeryShortCodeFishBones
* @since 4.2
* @access public
*
* @param string $tag
*
* @return Vc_Shortcodes_Manager|null
*/
public function getShortCode( $tag ) {
return Vc_Shortcodes_Manager::getInstance()->setTag( $tag );
}
/**
* Remove shortcode from shortcodes list of VC.
*
* @since 4.2
* @access public
*
* @param $tag - shortcode tag
*/
public function removeShortCode( $tag ) {
remove_shortcode( $tag );
}
/**
* @todo move it
* @since 4.2
*/
public function singleImageSrc() {
// @todo again, this method should be moved (comment added on 4.8)
vc_user_access()
->checkAdminNonce()
->validateDie()
->wpAny( 'edit_posts', 'edit_pages' )
->validateDie();
$image_id = (int) vc_post_param( 'content' );
$params = vc_post_param( 'params' );
$post_id = vc_post_param( 'post_id' );
$img_size = vc_post_param( 'size' );
$img = '';
if ( ! empty( $params['source'] ) ) {
$source = $params['source'];
} else {
$source = 'media_library';
}
switch ( $source ) {
case 'media_library':
case 'featured_image':
if ( 'featured_image' === $source ) {
if ( $post_id && has_post_thumbnail( $post_id ) ) {
$img_id = get_post_thumbnail_id( $post_id );
} else {
$img_id = 0;
}
} else {
$img_id = preg_replace( '/[^\d]/', '', $image_id );
}
if ( ! $img_size ) {
$img_size = 'thumbnail';
}
if ( $img_id ) {
$img = wp_get_attachment_image_src( $img_id, $img_size );
if ( $img ) {
$img = $img[0];
}
}
break;
case 'external_link':
if ( ! empty( $params['custom_src'] ) ) {
$img = $params['custom_src'];
}
break;
}
die( $img );
}
/**
* @todo move it
* @since 4.2
*/
public function galleryHTML() {
// @todo again, this method should be moved (comment added on 4.8)
vc_user_access()
->checkAdminNonce()
->validateDie()
->wpAny( 'edit_posts', 'edit_pages' )
->validateDie();
$images = vc_post_param( 'content' );
if ( ! empty( $images ) ) {
echo fieldAttachedImages( explode( ',', $images ) );
}
die();
}
/**
* Rewrite code or name
* @since 4.2
*/
public function createShortCodes() {
_deprecated_function( 'Vc_Base::createShortCodes', '4.2' );
}
/**
* Set or modify new settings for shortcode.
*
* This function widely used by WPBMap class methods to modify shortcodes mapping
*
* @since 4.3
*
* @param $tag
* @param $name
* @param $value
*/
public function updateShortcodeSetting( $tag, $name, $value ) {
Vc_Shortcodes_Manager::getInstance()
->getElementClass( $tag )
->setSettings( $name, $value );
}
/**
* Build custom css styles for page from shortcodes attributes created by VC editors.
*
* Called by save method, which is hooked by edit_post action.
* Function creates meta data for post with the key '_wpb_shortcodes_custom_css'
* and value as css string, which will be added to the footer of the page.
*
* @since 4.2
* @access public
*
* @param $post_id
*/
public function buildShortcodesCustomCss( $post_id ) {
$post = get_post( $post_id );
/**
* vc_filter: vc_base_build_shortcodes_custom_css
* @since 4.4
*/
$css = apply_filters( 'vc_base_build_shortcodes_custom_css', $this->parseShortcodesCustomCss( $post->post_content ) );
if ( empty( $css ) ) {
delete_post_meta( $post_id, '_wpb_shortcodes_custom_css' );
} else {
update_post_meta( $post_id, '_wpb_shortcodes_custom_css', $css );
}
}
/**
* Parse shortcodes custom css string.
*
* This function is used by self::buildShortcodesCustomCss and creates css string from shortcodes attributes
* like 'css_editor'.
*
* @see WPBakeryVisualComposerCssEditor
* @since 4.2
* @access public
*
* @param $content
*
* @return string
*/
public function parseShortcodesCustomCss( $content ) {
$css = '';
if ( ! preg_match( '/\s*(\.[^\{]+)\s*\{\s*([^\}]+)\s*\}\s*/', $content ) ) {
return $css;
}
WPBMap::addAllMappedShortcodes();
preg_match_all( '/' . get_shortcode_regex() . '/', $content, $shortcodes );
foreach ( $shortcodes[2] as $index => $tag ) {
$shortcode = WPBMap::getShortCode( $tag );
$attr_array = shortcode_parse_atts( trim( $shortcodes[3][ $index ] ) );
if ( isset( $shortcode['params'] ) && ! empty( $shortcode['params'] ) ) {
foreach ( $shortcode['params'] as $param ) {
if ( 'css_editor' === $param['type'] && isset( $attr_array[ $param['param_name'] ] ) ) {
$css .= $attr_array[ $param['param_name'] ];
}
}
}
}
foreach ( $shortcodes[5] as $shortcode_content ) {
$css .= $this->parseShortcodesCustomCss( $shortcode_content );
}
return $css;
}
/**
* Hooked class method by wp_head WP action to output post custom css.
*
* Method gets post meta value for page by key '_wpb_post_custom_css' and if it is not empty
* outputs css string wrapped into style tag.
*
* @since 4.2
* @access public
*
* @param int $id
*/
public function addPageCustomCss( $id = null ) {
if ( ! is_singular() ) {
return;
}
if ( ! $id ) {
$id = get_the_ID();
}
if ( $id ) {
$post_custom_css = get_post_meta( $id, '_wpb_post_custom_css', true );
if ( ! empty( $post_custom_css ) ) {
$post_custom_css = strip_tags( $post_custom_css );
echo '<style type="text/css" data-type="vc_custom-css">';
echo $post_custom_css;
echo '</style>';
}
}
}
/**
* Hooked class method by wp_footer WP action to output shortcodes css editor settings from page meta data.
*
* Method gets post meta value for page by key '_wpb_shortcodes_custom_css' and if it is not empty
* outputs css string wrapped into style tag.
*
* @since 4.2
* @access public
*
* @param int $id
*
*/
public function addShortcodesCustomCss( $id = null ) {
if ( ! is_singular() ) {
return;
}
if ( ! $id ) {
$id = get_the_ID();
}
if ( $id ) {
$shortcodes_custom_css = get_post_meta( $id, '_wpb_shortcodes_custom_css', true );
if ( ! empty( $shortcodes_custom_css ) ) {
$shortcodes_custom_css = strip_tags( $shortcodes_custom_css );
echo '<style type="text/css" data-type="vc_shortcodes-custom-css">';
echo $shortcodes_custom_css;
echo '</style>';
}
}
}
/**
* Add css styles for current page and elements design options added w\ editor.
*/
public function addFrontCss() {
$this->addPageCustomCss();
$this->addShortcodesCustomCss();
}
public function addNoScript() {
echo '<noscript>';
echo '<style type="text/css">';
echo ' .wpb_animate_when_almost_visible { opacity: 1; }';
echo '</style>';
echo '</noscript>';
}
/**
* Register front css styles.
*
* Calls wp_register_style for required css libraries files.
*
* @since 3.1
* @access public
*/
public function frontCss() {
wp_register_style( 'flexslider', vc_asset_url( 'lib/bower/flexslider/flexslider.min.css' ), array(), WPB_VC_VERSION );
wp_register_style( 'nivo-slider-css', vc_asset_url( 'lib/bower/nivoslider/nivo-slider.min.css' ), array(), WPB_VC_VERSION );
wp_register_style( 'nivo-slider-theme', vc_asset_url( 'lib/bower/nivoslider/themes/default/default.min.css' ), array( 'nivo-slider-css' ), WPB_VC_VERSION );
wp_register_style( 'prettyphoto', vc_asset_url( 'lib/prettyphoto/css/prettyPhoto.min.css' ), array(), WPB_VC_VERSION );
wp_register_style( 'isotope-css', vc_asset_url( 'css/lib/isotope.min.css' ), array(), WPB_VC_VERSION );
wp_register_style( 'font-awesome', vc_asset_url( 'lib/bower/font-awesome/css/font-awesome.min.css' ), array(), WPB_VC_VERSION );
$front_css_file = vc_asset_url( 'css/js_composer.min.css' );
$upload_dir = wp_upload_dir();
$vc_upload_dir = vc_upload_dir();
if ( '1' === vc_settings()->get( 'use_custom' ) && is_file( $upload_dir['basedir'] . '/' . $vc_upload_dir . '/js_composer_front_custom.css' ) ) {
$front_css_file = $upload_dir['baseurl'] . '/' . $vc_upload_dir . '/js_composer_front_custom.css';
$front_css_file = vc_str_remove_protocol( $front_css_file );
}
wp_register_style( 'js_composer_front', $front_css_file, array(), WPB_VC_VERSION );
$custom_css_path = $upload_dir['basedir'] . '/' . $vc_upload_dir . '/custom.css';
if ( is_file( $upload_dir['basedir'] . '/' . $vc_upload_dir . '/custom.css' ) && filesize( $custom_css_path ) > 0 ) {
$custom_css_url = $upload_dir['baseurl'] . '/' . $vc_upload_dir . '/custom.css';
$custom_css_url = vc_str_remove_protocol( $custom_css_url );
wp_register_style( 'js_composer_custom_css', $custom_css_url, array(), WPB_VC_VERSION );
}
add_action( 'wp_enqueue_scripts', array(
&$this,
'enqueueStyle',
) );
/**
* @since 4.4
*/
do_action( 'vc_base_register_front_css' );
}
/**
* Enqueue base css class for VC elements and enqueue custom css if exists.
*/
public function enqueueStyle() {
$post = get_post();
if ( $post && preg_match( '/vc_row/', $post->post_content ) ) {
wp_enqueue_style( 'js_composer_front' );
}
wp_enqueue_style( 'js_composer_custom_css' );
}
/**
* Register front javascript libs.
*
* Calls wp_register_script for required css libraries files.
*
* @since 3.1
* @access public
*/
public function frontJsRegister() {
wp_register_script( 'prettyphoto', vc_asset_url( 'lib/prettyphoto/js/jquery.prettyPhoto.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'waypoints', vc_asset_url( 'lib/waypoints/waypoints.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
// @deprecated used in old tabs
wp_register_script( 'jquery_ui_tabs_rotate', vc_asset_url( 'lib/bower/jquery-ui-tabs-rotate/jquery-ui-tabs-rotate.min.js' ), array(
'jquery',
'jquery-ui-tabs',
), WPB_VC_VERSION, true );
// used in vc_gallery, old grid
wp_register_script( 'isotope', vc_asset_url( 'lib/bower/isotope/dist/isotope.pkgd.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'twbs-pagination', vc_asset_url( 'lib/bower/twbs-pagination/jquery.twbsPagination.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'nivo-slider', vc_asset_url( 'lib/bower/nivoslider/jquery.nivo.slider.pack.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'flexslider', vc_asset_url( 'lib/bower/flexslider/jquery.flexslider-min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'wpb_composer_front_js', vc_asset_url( 'js/dist/js_composer_front.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
/**
* @since 4.4
*/
do_action( 'vc_base_register_front_js' );
}
/**
* Register admin javascript libs.
*
* Calls wp_register_script for required css libraries files for Admin dashboard.
*
* @since 3.1
* vc_filter: vc_i18n_locale_composer_js_view, since 4.4 - override localization for js
* @access public
*/
public function registerAdminJavascript() {
/**
* @since 4.4
*/
do_action( 'vc_base_register_admin_js' );
}
/**
* Register admin css styles.
*
* Calls wp_register_style for required css libraries files for admin dashboard.
*
* @since 3.1
* @access public
*/
public function registerAdminCss() {
/**
* @since 4.4
*/
do_action( 'vc_base_register_admin_css' );
}
/**
* Add Settings link in plugin's page
* @since 4.2
*
* @param $links
* @param $file
*
* @return array
*/
public function pluginActionLinks( $links, $file ) {
if ( plugin_basename( vc_path_dir( 'APP_DIR', '/js_composer.php' ) ) == $file ) {
$title = __( 'Visual Composer Settings', 'js_composer' );
$html = esc_html__( 'Settings', 'js_composer' );
if ( ! vc_user_access()
->part( 'settings' )
->can( 'vc-general-tab' )
->get()
) {
$title = __( 'About Visual Composer', 'js_composer' );
$html = esc_html__( 'About', 'js_composer' );
}
$link = '<a title="' . esc_attr( $title ) . '" href="' . esc_url( $this->getSettingsPageLink() ) . '">' . $html . '</a>';
array_unshift( $links, $link ); // Add to top
}
return $links;
}
/**
* Get settings page link
* @since 4.2
* @return string url to settings page
*/
public function getSettingsPageLink() {
$page = 'vc-general';
if ( ! vc_user_access()
->part( 'settings' )
->can( 'vc-general-tab' )
->get()
) {
$page = 'vc-welcome';
}
return add_query_arg( array( 'page' => $page ), admin_url( 'admin.php' ) );
}
/**
* Hooked class method by wp_head WP action.
* @since 4.2
* @access public
*/
public function addMetaData() {
echo '<meta name="generator" content="Powered by Visual Composer - drag and drop page builder for WordPress."/>' . "\n";
}
/**
* Also add fix for IE8 bootstrap styles from WPExplorer
* @since 4.9
* @access public
*/
public function addIEMinimalSupport() {
echo '<!--[if lte IE 9]><link rel="stylesheet" type="text/css" href="' . vc_asset_url( 'css/vc_lte_ie9.min.css' ) . '" media="screen"><![endif]-->';
echo '<!--[if IE 8]><link rel="stylesheet" type="text/css" href="' . vc_asset_url( 'css/vc-ie8.min.css' ) . '" media="screen"><![endif]-->';
}
/**
* Method adds css class to body tag.
*
* Hooked class method by body_class WP filter. Method adds custom css class to body tag of the page to help
* identify and build design specially for VC shortcodes.
*
* @since 4.2
* @access public
*
* @param $classes
*
* @return array
*/
public function bodyClass( $classes ) {
return js_composer_body_class( $classes );
}
/**
* Builds excerpt for post from content.
*
* Hooked class method by the_excerpt WP filter. When user creates content with VC all content is always wrapped by
* shortcodes. This methods calls do_shortcode for post's content and then creates a new excerpt.
*
* @since 4.2
* @access public
*
* @param $output
*
* @return string
*/
public function excerptFilter( $output ) {
global $post;
if ( empty( $output ) && ! empty( $post->post_content ) ) {
$text = strip_tags( do_shortcode( $post->post_content ) );
$excerpt_length = apply_filters( 'excerpt_length', 55 );
$excerpt_more = apply_filters( 'excerpt_more', ' ' . '[...]' );
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
return $text;
}
return $output;
}
/**
* Remove unwanted wraping with p for content.
*
* Hooked by 'the_content' filter.
* @since 4.2
*
* @param null $content
*
* @return string|null
*/
public function fixPContent( $content = null ) {
if ( $content ) {
$s = array(
'/' . preg_quote( '</div>', '/' ) . '[\s\n\f]*' . preg_quote( '</p>', '/' ) . '/i',
'/' . preg_quote( '<p>', '/' ) . '[\s\n\f]*' . preg_quote( '<div ', '/' ) . '/i',
'/' . preg_quote( '<p>', '/' ) . '[\s\n\f]*' . preg_quote( '<section ', '/' ) . '/i',
'/' . preg_quote( '</section>', '/' ) . '[\s\n\f]*' . preg_quote( '</p>', '/' ) . '/i',
);
$r = array(
'</div>',
'<div ',
'<section ',
'</section>',
);
$content = preg_replace( $s, $r, $content );
return $content;
}
return null;
}
/**
* @todo remove this (comment added on 4.8) also remove helpers
* Set manger for custom third-party plugins.
* @deprecated due to autoload logic 4.4
* @since 4.3
*
* @param Vc_Vendors_Manager $vendor_manager
*/
public function setVendorsManager( Vc_Vendors_Manager $vendor_manager ) {
// _deprecated_function( 'Vc_Base::setVendorsManager', '4.4 (will be removed in 4.10)', 'autoload logic' );
$this->vendor_manager = $vendor_manager;
}
/**
* @todo remove this (comment added on 4.8) also remove helpers
* Get vendors manager.
* @deprecated due to autoload logic from 4.4
* @since 4.3
* @return bool|Vc_Vendors_Manager
*/
public function vendorsManager() {
// _deprecated_function( 'Vc_Base::vendorsManager', '4.4 (will be removed in 4.10)', 'autoload logic' );
return $this->vendor_manager;
}
/**
* Get array of string for locale.
*
* @since 4.7
*
* @return array
*/
public function getEditorsLocale() {
return array(
'add_remove_picture' => __( 'Add/remove picture', 'js_composer' ),
'finish_adding_text' => __( 'Finish Adding Images', 'js_composer' ),
'add_image' => __( 'Add Image', 'js_composer' ),
'add_images' => __( 'Add Images', 'js_composer' ),
'settings' => __( 'Settings', 'js_composer' ),
'main_button_title' => __( 'Visual Composer', 'js_composer' ),
'main_button_title_backend_editor' => __( 'BACKEND EDITOR', 'js_composer' ),
'main_button_title_frontend_editor' => __( 'FRONTEND EDITOR', 'js_composer' ),
'main_button_title_revert' => __( 'CLASSIC MODE', 'js_composer' ),
'please_enter_templates_name' => __( 'Enter template name you want to save.', 'js_composer' ),
'confirm_deleting_template' => __( 'Confirm deleting "{template_name}" template, press Cancel to leave. This action cannot be undone.', 'js_composer' ),
'press_ok_to_delete_section' => __( 'Press OK to delete section, Cancel to leave', 'js_composer' ),
'drag_drop_me_in_column' => __( 'Drag and drop me in the column', 'js_composer' ),
'press_ok_to_delete_tab' => __( 'Press OK to delete "{tab_name}" tab, Cancel to leave', 'js_composer' ),
'slide' => __( 'Slide', 'js_composer' ),
'tab' => __( 'Tab', 'js_composer' ),
'section' => __( 'Section', 'js_composer' ),
'please_enter_new_tab_title' => __( 'Please enter new tab title', 'js_composer' ),
'press_ok_delete_section' => __( 'Press OK to delete "{tab_name}" section, Cancel to leave', 'js_composer' ),
'section_default_title' => __( 'Section', 'js_composer' ),
'please_enter_section_title' => __( 'Please enter new section title', 'js_composer' ),
'error_please_try_again' => __( 'Error. Please try again.', 'js_composer' ),
'if_close_data_lost' => __( 'If you close this window all shortcode settings will be lost. Close this window?', 'js_composer' ),
'header_select_element_type' => __( 'Select element type', 'js_composer' ),
'header_media_gallery' => __( 'Media gallery', 'js_composer' ),
'header_element_settings' => __( 'Element settings', 'js_composer' ),
'add_tab' => __( 'Add tab', 'js_composer' ),
'are_you_sure_convert_to_new_version' => __( 'Are you sure you want to convert to new version?', 'js_composer' ),
'loading' => __( 'Loading...', 'js_composer' ),
// Media editor
'set_image' => __( 'Set Image', 'js_composer' ),
'are_you_sure_reset_css_classes' => __( 'Are you sure that you want to remove all your data?', 'js_composer' ),
'loop_frame_title' => __( 'Loop settings', 'js_composer' ),
'enter_custom_layout' => __( 'Custom row layout', 'js_composer' ),
'wrong_cells_layout' => __( 'Wrong row layout format! Example: 1/2 + 1/2 or span6 + span6.', 'js_composer' ),
'row_background_color' => __( 'Row background color', 'js_composer' ),
'row_background_image' => __( 'Row background image', 'js_composer' ),
'column_background_color' => __( 'Column background color', 'js_composer' ),
'column_background_image' => __( 'Column background image', 'js_composer' ),
'guides_on' => __( 'Guides ON', 'js_composer' ),
'guides_off' => __( 'Guides OFF', 'js_composer' ),
'template_save' => __( 'New template successfully saved.', 'js_composer' ),
'template_added' => __( 'Template added to the page.', 'js_composer' ),
'template_added_with_id' => __( 'Template added to the page. Template has ID attributes, make sure that they are not used more than once on the same page.', 'js_composer' ),
'template_removed' => __( 'Template successfully removed.', 'js_composer' ),
'template_is_empty' => __( 'Template is empty: There is no content to be saved as a template.', 'js_composer' ),
'template_save_error' => __( 'Error while saving template.', 'js_composer' ),
'css_updated' => __( 'Page settings updated!', 'js_composer' ),
'update_all' => __( 'Update all', 'js_composer' ),
'confirm_to_leave' => __( 'The changes you made will be lost if you navigate away from this page.', 'js_composer' ),
'inline_element_saved' => __( '%s saved!', 'js_composer' ),
'inline_element_deleted' => __( '%s deleted!', 'js_composer' ),
'inline_element_cloned' => __( '%s cloned. <a href="#" class="vc_edit-cloned" data-model-id="%s">Edit now?</a>', 'js_composer' ),
'gfonts_loading_google_font_failed' => __( 'Loading Google Font failed', 'js_composer' ),
'gfonts_loading_google_font' => __( 'Loading Font...', 'js_composer' ),
'gfonts_unable_to_load_google_fonts' => __( 'Unable to load Google Fonts', 'js_composer' ),
'no_title_parenthesis' => sprintf( '(%s)', __( 'no title', 'js_composer' ) ),
'error_while_saving_image_filtered' => __( 'Error while applying filter to the image. Check your server and memory settings.', 'js_composer' ),
'ui_saved' => sprintf( '<i class="vc_ui-icon-pixel vc_ui-icon-pixel-check"></i> %s', __( 'Saved!', 'js_composer' ) ),
'delete_preset_confirmation' => __( 'You are about to delete this preset. This action can not be undone.', 'js_composer' ),
);
}
}
/**
* @todo remove this (comment added on 4.8) also remove helpers
* VC backward capability.
* @deprecated @since 4.3
*/
class WPBakeryVisualComposer extends Vc_Base {
/**
* @deprecated since 4.3
*/
function __construct() {
// _deprecated_function( 'WPBakeryVisualComposer class', '4.3 (will be removed in 4.10)', 'Vc_Base class' );
}
/**
* @param $template
*
* @deprecated 4.3
* @return string
*/
public static function getUserTemplate( $template ) {
// _deprecated_function( 'WPBakeryVisualComposer getUserTemplate', '4.3 (will be removed in 4.10)', 'Vc_Base getShortcodesTemplateDir' );
return vc_manager()->getShortcodesTemplateDir( $template );
}
}
core/class-vc-mapper.php 0000666 00000011674 15126312411 0011213 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery Visual Composer Main manager.
*
* @package WPBakeryVisualComposer
* @since 4.2
*/
/**
* Vc mapper new class. On maintenance
* Allows to bind hooks for shortcodes.
* @since 4.2
*/
class Vc_Mapper {
/**
* @since 4.2
* Stores mapping activities list which where called before initialization
* @var array
*/
protected $init_activity = array();
/**
*
*
* @since 4.9
*
* @var array
*/
protected $element_activities = array();
protected $hasAccess = array();
// @todo fix_roles and maybe remove/@deprecate this
protected $checkForAccess = true;
/**
* @since 4.2
*/
function __construct() {
}
/**
* Include params list objects and calls all stored activity methods.
*
* @since 4.2
* @access public
*/
public function init() {
do_action( 'vc_mapper_init_before' );
require_once vc_path_dir( 'PARAMS_DIR', 'load.php' );
WPBMap::setInit();
require_once vc_path_dir( 'CONFIG_DIR', 'lean-map.php' );
$this->callActivities();
do_action( 'vc_mapper_init_after' );
}
/**
* This method is called by VC objects methods if it is called before VC initialization.
*
* @see WPBMAP
* @since 4.2
* @access public
*
* @param $object - mame of class object
* @param $method - method name
* @param array $params - list of attributes for object method
*/
public function addActivity( $object, $method, $params = array() ) {
$this->init_activity[] = array(
$object,
$method,
$params,
);
}
/**
* This method is called by VC objects methods if it is called before VC initialization.
*
* @see WPBMAP
* @since 4.9
* @access public
*
* @param $tag - shortcode tag of element
* @param $method - method name
* @param array $params - list of attributes for object method
*/
public function addElementActivity( $tag, $method, $params = array() ) {
if ( ! isset( $this->element_activities[ $tag ] ) ) {
$this->element_activities[ $tag ] = array();
}
$this->element_activities[ $tag ][] = array(
$method,
$params,
);
}
/**
* Call all stored activities.
*
* Called by init method. List of activities stored by $init_activity are created by other objects called after
* initialization.
*
* @since 4.2
* @access public
*/
protected function callActivities() {
do_action( 'vc_mapper_call_activities_before' );
while ( $activity = each( $this->init_activity ) ) {
list( $object, $method, $params ) = $activity[1];
if ( 'mapper' === $object ) {
switch ( $method ) {
case 'map':
WPBMap::map( $params['tag'], $params['attributes'] );
break;
case 'drop_param':
WPBMap::dropParam( $params['name'], $params['attribute_name'] );
break;
case 'add_param':
WPBMap::addParam( $params['name'], $params['attribute'] );
break;
case 'mutate_param':
WPBMap::mutateParam( $params['name'], $params['attribute'] );
break;
case 'drop_all_shortcodes':
WPBMap::dropAllShortcodes();
break;
case 'drop_shortcode':
WPBMap::dropShortcode( $params['name'] );
break;
case 'modify':
WPBMap::modify( $params['name'], $params['setting_name'], $params['value'] );
break;
}
}
}
}
/**
* Does user has access to modify/clone/delete/add shortcode
*
* @param $shortcode
*
* @todo fix_roles and maybe remove/@deprecate this
* @since 4.5
* @return bool
*/
public function userHasAccess( $shortcode ) {
if ( $this->isCheckForAccess() ) {
if ( isset( $this->hasAccess[ $shortcode ] ) ) {
return $this->hasAccess[ $shortcode ];
} else {
$this->hasAccess[ $shortcode ] = vc_user_access_check_shortcode_edit( $shortcode );
}
return $this->hasAccess[ $shortcode ];
}
return true;
}
/**
* @todo fix_roles and maybe remove/@deprecate this
* @since 4.5
* @return bool
*/
public function isCheckForAccess() {
return $this->checkForAccess;
}
/**
* @todo fix_roles and maybe remove/@deprecate this
* @since 4.5
*
* @param bool $checkForAccess
*/
public function setCheckForAccess( $checkForAccess ) {
$this->checkForAccess = $checkForAccess;
}
public function callElementActivities( $tag ) {
do_action( 'vc_mapper_call_activities_before' );
if ( isset( $this->element_activities[ $tag ] ) ) {
while ( $activity = each( $this->element_activities[ $tag ] ) ) {
list( $method, $params ) = $activity[1];
switch ( $method ) {
case 'drop_param':
WPBMap::dropParam( $params['name'], $params['attribute_name'] );
break;
case 'add_param':
WPBMap::addParam( $params['name'], $params['attribute'] );
break;
case 'mutate_param':
WPBMap::mutateParam( $params['name'], $params['attribute'] );
break;
case 'drop_shortcode':
WPBMap::dropShortcode( $params['name'] );
break;
case 'modify':
WPBMap::modify( $params['name'], $params['setting_name'], $params['value'] );
break;
}
}
}
}
}
core/class-vc-pages-group.php 0000666 00000002400 15126312411 0012143 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class Vs_Pages_Group Show the groups of the pages likes pages with tabs.
*
* @since 4.5
*/
class Vc_Pages_Group extends Vc_Page {
protected $activePage;
protected $pages;
protected $templatePath;
/**
* @return mixed
*/
public function getActivePage() {
return $this->activePage;
}
/**
* @param Vc_Page $activePage
*
* @return $this
*/
public function setActivePage( Vc_Page $activePage ) {
$this->activePage = $activePage;
return $this;
}
/**
* @return mixed
*/
public function getPages() {
return $this->pages;
}
/**
* @param mixed $pages
*
* @return $this
*/
public function setPages( $pages ) {
$this->pages = $pages;
return $this;
}
/**
* @return mixed
*/
public function getTemplatePath() {
return $this->templatePath;
}
/**
* @param mixed $templatePath
*
* @return $this
*/
public function setTemplatePath( $templatePath ) {
$this->templatePath = $templatePath;
return $this;
}
/**
* Render html output for current page.
*/
public function render() {
vc_include_template( $this->getTemplatePath(),
array(
'pages' => $this->getPages(),
'active_page' => $this->activePage,
'page' => $this,
) );
}
}
core/class-vc-shared-library.php 0000666 00000020107 15126312411 0012626 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/*** Visual Composer Content elements refresh ***/
class VcSharedLibrary {
// Here we will store plugin wise (shared) settings. Colors, Locations, Sizes, etc...
/**
* @var array
*/
private static $colors = array(
'Blue' => 'blue',
'Turquoise' => 'turquoise',
'Pink' => 'pink',
'Violet' => 'violet',
'Peacoc' => 'peacoc',
'Chino' => 'chino',
'Mulled Wine' => 'mulled_wine',
'Vista Blue' => 'vista_blue',
'Black' => 'black',
'Grey' => 'grey',
'Orange' => 'orange',
'Sky' => 'sky',
'Green' => 'green',
'Juicy pink' => 'juicy_pink',
'Sandy brown' => 'sandy_brown',
'Purple' => 'purple',
'White' => 'white',
);
/**
* @var array
*/
public static $icons = array(
'Glass' => 'glass',
'Music' => 'music',
'Search' => 'search',
);
/**
* @var array
*/
public static $sizes = array(
'Mini' => 'xs',
'Small' => 'sm',
'Normal' => 'md',
'Large' => 'lg',
);
/**
* @var array
*/
public static $button_styles = array(
'Rounded' => 'rounded',
'Square' => 'square',
'Round' => 'round',
'Outlined' => 'outlined',
'3D' => '3d',
'Square Outlined' => 'square_outlined',
);
/**
* @var array
*/
public static $message_box_styles = array(
'Standard' => 'standard',
'Solid' => 'solid',
'Solid icon' => 'solid-icon',
'Outline' => 'outline',
'3D' => '3d',
);
/**
* Toggle styles
* @var array
*/
public static $toggle_styles = array(
'Default' => 'default',
'Simple' => 'simple',
'Round' => 'round',
'Round Outline' => 'round_outline',
'Rounded' => 'rounded',
'Rounded Outline' => 'rounded_outline',
'Square' => 'square',
'Square Outline' => 'square_outline',
'Arrow' => 'arrow',
'Text Only' => 'text_only',
);
/**
* Animation styles
* @var array
*/
public static $animation_styles = array(
'Bounce' => 'easeOutBounce',
'Elastic' => 'easeOutElastic',
'Back' => 'easeOutBack',
'Cubic' => 'easeinOutCubic',
'Quint' => 'easeinOutQuint',
'Quart' => 'easeOutQuart',
'Quad' => 'easeinQuad',
'Sine' => 'easeOutSine',
);
/**
* @var array
*/
public static $cta_styles = array(
'Rounded' => 'rounded',
'Square' => 'square',
'Round' => 'round',
'Outlined' => 'outlined',
'Square Outlined' => 'square_outlined',
);
/**
* @var array
*/
public static $txt_align = array(
'Left' => 'left',
'Right' => 'right',
'Center' => 'center',
'Justify' => 'justify',
);
/**
* @var array
*/
public static $el_widths = array(
'100%' => '',
'90%' => '90',
'80%' => '80',
'70%' => '70',
'60%' => '60',
'50%' => '50',
'40%' => '40',
'30%' => '30',
'20%' => '20',
'10%' => '10',
);
/**
* @var array
*/
public static $sep_widths = array(
'1px' => '',
'2px' => '2',
'3px' => '3',
'4px' => '4',
'5px' => '5',
'6px' => '6',
'7px' => '7',
'8px' => '8',
'9px' => '9',
'10px' => '10',
);
/**
* @var array
*/
public static $sep_styles = array(
'Border' => '',
'Dashed' => 'dashed',
'Dotted' => 'dotted',
'Double' => 'double',
'Shadow' => 'shadow',
);
/**
* @var array
*/
public static $box_styles = array(
'Default' => '',
'Rounded' => 'vc_box_rounded',
'Border' => 'vc_box_border',
'Outline' => 'vc_box_outline',
'Shadow' => 'vc_box_shadow',
'Bordered shadow' => 'vc_box_shadow_border',
'3D Shadow' => 'vc_box_shadow_3d',
);
/**
* Round box styles
*
* @var array
*/
public static $round_box_styles = array(
'Round' => 'vc_box_circle',
'Round Border' => 'vc_box_border_circle',
'Round Outline' => 'vc_box_outline_circle',
'Round Shadow' => 'vc_box_shadow_circle',
'Round Border Shadow' => 'vc_box_shadow_border_circle',
);
/**
* Circle box styles
*
* @var array
*/
public static $circle_box_styles = array(
'Circle' => 'vc_box_circle_2',
'Circle Border' => 'vc_box_border_circle_2',
'Circle Outline' => 'vc_box_outline_circle_2',
'Circle Shadow' => 'vc_box_shadow_circle_2',
'Circle Border Shadow' => 'vc_box_shadow_border_circle_2',
);
/**
* @return array
*/
public static function getColors() {
return self::$colors;
}
/**
* @return array
*/
public static function getIcons() {
return self::$icons;
}
/**
* @return array
*/
public static function getSizes() {
return self::$sizes;
}
/**
* @return array
*/
public static function getButtonStyles() {
return self::$button_styles;
}
/**
* @return array
*/
public static function getMessageBoxStyles() {
return self::$message_box_styles;
}
/**
* @return array
*/
public static function getToggleStyles() {
return self::$toggle_styles;
}
/**
* @return array
*/
public static function getAnimationStyles() {
return self::$animation_styles;
}
/**
* @return array
*/
public static function getCtaStyles() {
return self::$cta_styles;
}
/**
* @return array
*/
public static function getTextAlign() {
return self::$txt_align;
}
/**
* @return array
*/
public static function getBorderWidths() {
return self::$sep_widths;
}
/**
* @return array
*/
public static function getElementWidths() {
return self::$el_widths;
}
/**
* @return array
*/
public static function getSeparatorStyles() {
return self::$sep_styles;
}
/**
* Get list of box styles
*
* Possible $groups values:
* - default
* - round
* - circle
*
* @param array $groups Array of groups to include. If not specified, return all
*
* @return array
*/
public static function getBoxStyles( $groups = array() ) {
$list = array();
$groups = (array) $groups;
if ( ! $groups || in_array( 'default', $groups ) ) {
$list += self::$box_styles;
}
if ( ! $groups || in_array( 'round', $groups ) ) {
$list += self::$round_box_styles;
}
if ( ! $groups || in_array( 'cirlce', $groups ) ) {
$list += self::$circle_box_styles;
}
return $list;
}
public static function getColorsDashed() {
$colors = array(
__( 'Blue', 'js_composer' ) => 'blue',
__( 'Turquoise', 'js_composer' ) => 'turquoise',
__( 'Pink', 'js_composer' ) => 'pink',
__( 'Violet', 'js_composer' ) => 'violet',
__( 'Peacoc', 'js_composer' ) => 'peacoc',
__( 'Chino', 'js_composer' ) => 'chino',
__( 'Mulled Wine', 'js_composer' ) => 'mulled-wine',
__( 'Vista Blue', 'js_composer' ) => 'vista-blue',
__( 'Black', 'js_composer' ) => 'black',
__( 'Grey', 'js_composer' ) => 'grey',
__( 'Orange', 'js_composer' ) => 'orange',
__( 'Sky', 'js_composer' ) => 'sky',
__( 'Green', 'js_composer' ) => 'green',
__( 'Juicy pink', 'js_composer' ) => 'juicy-pink',
__( 'Sandy brown', 'js_composer' ) => 'sandy-brown',
__( 'Purple', 'js_composer' ) => 'purple',
__( 'White', 'js_composer' ) => 'white',
);
return $colors;
}
}
/**
* @param string $asset
*
* @return array
*/
function getVcShared( $asset = '' ) {
switch ( $asset ) {
case 'colors':
return VcSharedLibrary::getColors();
break;
case 'colors-dashed':
return VcSharedLibrary::getColorsDashed();
break;
case 'icons':
return VcSharedLibrary::getIcons();
break;
case 'sizes':
return VcSharedLibrary::getSizes();
break;
case 'button styles':
case 'alert styles':
return VcSharedLibrary::getButtonStyles();
break;
case 'message_box_styles':
return VcSharedLibrary::getMessageBoxStyles();
break;
case 'cta styles':
return VcSharedLibrary::getCtaStyles();
break;
case 'text align':
return VcSharedLibrary::getTextAlign();
break;
case 'cta widths':
case 'separator widths':
return VcSharedLibrary::getElementWidths();
break;
case 'separator styles':
return VcSharedLibrary::getSeparatorStyles();
break;
case 'separator border widths':
return VcSharedLibrary::getBorderWidths();
break;
case 'single image styles':
return VcSharedLibrary::getBoxStyles();
break;
case 'single image external styles':
return VcSharedLibrary::getBoxStyles( array( 'default', 'round' ) );
break;
case 'toggle styles':
return VcSharedLibrary::getToggleStyles();
break;
case 'animation styles':
return VcSharedLibrary::getAnimationStyles();
break;
default:
# code...
break;
}
return '';
}
core/class-wpb-map.php 0000666 00000046737 15126312411 0010674 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery Visual Composer Main manager.
*
* @package WPBakeryVisualComposer
* @since 4.2
*/
class WPBMap {
/**
* @var array
*/
protected static $sc = array();
/**
* @var bool
*/
protected static $sorted_sc = false;
/**
* @var array|false
*/
protected static $categories = false;
/**
* @var bool
*/
protected static $user_sc = false;
/**
* @var bool
*/
protected static $user_sorted_sc = false;
/**
* @var bool
*/
protected static $user_categories = false;
/**
* @var Vc_Settings $settings
*/
protected static $settings;
/**
* @var
*/
protected static $user_role;
/**
* @var
*/
protected static $tags_regexp;
/**
* @var bool
*/
protected static $is_init = false;
/**
* @var bool
*/
protected static $init_elements = array();
/**
* Set init status fro WPMap.
*
* if $is_init is FALSE, then all activity like add, update and delete for shortcodes attributes will be hold in
* the list of activity and will be executed after initialization.
*
* @see Vc_Mapper::iniy.
* @static
*
* @param bool $value
*/
public static function setInit( $value = true ) {
self::$is_init = $value;
}
/**
* Gets user role and access rules for current user.
*
* @static
* @return mixed
*/
protected static function getSettings() {
global $current_user;
// @todo fix_roles? what is this and why it is inside class-wpb-map?
if ( null !== self::$settings ) {
if ( function_exists( 'wp_get_current_user' ) ) {
wp_get_current_user();
/** @var Vc_Settings $settings - get use group access rules */
if ( ! empty( $current_user->roles ) ) {
self::$user_role = $current_user->roles[0];
} else {
self::$user_role = 'author';
}
} else {
self::$user_role = 'author';
}
self::$settings = vc_settings()->get( 'groups_access_rules' );
}
return self::$settings;
}
/**
* Check is shortcode with a tag mapped to VC.
*
* @static
*
* @param $tag - shortcode tag.
*
* @return bool
*/
public static function exists( $tag ) {
return (boolean) isset( self::$sc[ $tag ] );
}
/**
* Map shortcode to VC.
*
* This method maps shortcode to VC.
* You need to shortcode's tag and settings to map correctly.
* Default shortcodes are mapped in config/map.php file.
* The best way is to call this method with "init" action callback function of WP.
*
* vc_filter: vc_mapper_tag - to change shortcode tag, arguments 2 ( $tag, $attributes )
* vc_filter: vc_mapper_attributes - to change shortcode attributes (like params array), arguments 2 ( $attributes,
* $tag ) vc_filter: vc_mapper_attribute - to change singe shortcode param data, arguments 2 ( $attribute, $tag )
* vc_filter: vc_mapper_attribute_{PARAM_TYPE} - to change singe shortcode param data by param type, arguments 2 (
* $attribute, $tag )
*
* @static
*
* @param $tag
* @param $attributes
*
* @return bool
*/
public static function map( $tag, $attributes ) {
if ( ! self::$is_init ) {
if ( empty( $attributes['name'] ) ) {
trigger_error( sprintf( __( 'Wrong name for shortcode:%s. Name required', 'js_composer' ), $tag ) );
} elseif ( empty( $attributes['base'] ) ) {
trigger_error( sprintf( __( 'Wrong base for shortcode:%s. Base required', 'js_composer' ), $tag ) );
} else {
vc_mapper()->addActivity( 'mapper', 'map', array(
'tag' => $tag,
'attributes' => $attributes,
) );
return true;
}
return false;
}
if ( empty( $attributes['name'] ) ) {
trigger_error( sprintf( __( 'Wrong name for shortcode:%s. Name required', 'js_composer' ), $tag ) );
} elseif ( empty( $attributes['base'] ) ) {
trigger_error( sprintf( __( 'Wrong base for shortcode:%s. Base required', 'js_composer' ), $tag ) );
} else {
self::$sc[ $tag ] = $attributes;
return true;
}
return false;
}
/**
* Lazy method to map shortcode to VC.
*
* This method maps shortcode to VC.
* You can shortcode settings as you do in self::map method. Bu also you
* can pass function name or file, which will be used to add settings for
* element. But this will be done only when element data is really required.
*
* @static
* @since 4.9
*
* @param $tag
* @param $settings_file
* @param $settings_function
* @param $attributes
*
* @return bool
*/
public static function leanMap( $tag, $settings_function = null, $settings_file = null, $attributes = array() ) {
self::$sc[ $tag ] = $attributes;
self::$sc[ $tag ]['base'] = $tag;
if ( is_string( $settings_file ) ) {
self::$sc[ $tag ]['__vc_settings_file'] = $settings_file;
}
if ( ! is_null( $settings_function ) ) {
self::$sc[ $tag ]['__vc_settings_function'] = $settings_function;
}
return true;
}
/**
* Generates list of shortcodes taking into account the access rules for shortcodes from VC Settings page.
*
* This method parses the list of mapped shortcodes and creates categories list for users.
*
* @static
*
* @param bool $force - force data generation even data already generated.
*/
protected static function generateUserData( $force = false ) {
if ( ! $force && false !== self::$user_sc && false !== self::$user_categories ) {
return;
}
//$settings = self::getSettings();
self::$user_sc = self::$user_categories = self::$user_sorted_sc = array();
$deprecated = 'deprecated';
$add_deprecated = false;
if ( is_array( self::$sc ) && ! empty( self::$sc ) ) {
foreach ( array_keys( self::$sc ) as $name ) {
self::setElementSettings( $name );
if ( ! isset( self::$sc[ $name ] ) ) {
continue;
}
$values = self::$sc[ $name ];
if ( vc_user_access_check_shortcode_all( $name ) ) {
if ( ! isset( $values['content_element'] ) || true === $values['content_element'] ) {
$categories = isset( $values['category'] ) ? $values['category'] : '_other_category_';
$values['_category_ids'] = array();
if ( isset( $values['deprecated'] ) && false !== $values['deprecated'] ) {
$add_deprecated = true;
$values['_category_ids'][] = 'deprecated';
} else {
if ( is_array( $categories ) && ! empty( $categories ) ) {
foreach ( $categories as $c ) {
if ( false === array_search( $c, self::$user_categories ) ) {
self::$user_categories[] = $c;
}
$values['_category_ids'][] = md5( $c );
}
} else {
if ( false === array_search( $categories, self::$user_categories ) ) {
self::$user_categories[] = $categories;
}
$values['_category_ids'][] = md5( $categories );
}
}
}
self::$user_sc[ $name ] = $values;
self::$user_sorted_sc[] = $values;
}
}
}
if ( $add_deprecated ) {
self::$user_categories[] = $deprecated;
}
$sort = new Vc_Sort( self::$user_sorted_sc );
self::$user_sorted_sc = $sort->sortByKey();
}
/**
* Generates list of shortcodes.
*
* This method parses the list of mapped shortcodes and creates categories list.
*
* @static_other_category_
*
* @param bool $force - force data generation even data already generated.
*/
protected static function generateData( $force = false ) {
if ( ! $force && false !== self::$categories ) {
return;
}
foreach ( self::$sc as $tag => $settings ) {
self::setElementSettings( $tag );
}
self::$categories = self::collectCategories( self::$sc );
$sort = new Vc_Sort( array_values( self::$sc ) );
self::$sorted_sc = $sort->sortByKey();
}
/**
* Get mapped shortcode settings.
*
* @static
* @return array
*/
public static function getShortCodes() {
return self::$sc;
}
/**
* Get mapped shortcode settings.
*
* @static
* @return array
*/
public static function getAllShortCodes() {
self::generateData();
return self::$sc;
}
/**
* Get mapped shortcode settings.
*
* @static
* @return array
*/
public static function getSortedAllShortCodes() {
self::generateData();
return self::$sorted_sc;
}
/**
* Get sorted list of mapped shortcode settings for current user.
*
* Sorting depends on the weight attribute and mapping order.
*
* @static
* @return array
*/
public static function getSortedUserShortCodes() {
self::generateUserData();
return self::$user_sorted_sc;
}
/**
* Get list of mapped shortcode settings for current user.
* @static
* @return array - associated array of shortcodes settings with tag as the key.
*/
public static function getUserShortCodes() {
self::generateUserData();
return self::$user_sc;
}
/**
* Get mapped shortcode settings by tag.
*
* @static
*
* @param $tag - shortcode tag.
*
* @return array|null null @since 4.4.3
*/
public static function getShortCode( $tag ) {
if ( isset( self::$sc[ $tag ] ) && is_array( self::$sc[ $tag ] ) ) {
self::setElementSettings( $tag );
$shortcode = self::$sc[ $tag ];
} else {
$shortcode = null;
}
return $shortcode;
}
/**
* Get mapped shortcode settings by tag.
*
* @since 4.5.2
* @static
*
* @param $tag - shortcode tag.
*
* @return array|null
*/
public static function getUserShortCode( $tag ) {
self::generateUserData();
if ( isset( self::$user_sc[ $tag ] ) && is_array( self::$user_sc[ $tag ] ) ) {
$shortcode = self::$user_sc[ $tag ];
if ( ! empty( $shortcode['params'] ) ) {
$params = $shortcode['params'];
$shortcode['params'] = array();
foreach ( $params as $attribute ) {
$attribute = apply_filters( 'vc_mapper_attribute', $attribute, $tag );
$attribute = apply_filters( 'vc_mapper_attribute_' . $attribute['type'], $attribute, $tag );
$shortcode['params'][] = $attribute;
}
$sort = new Vc_Sort( $shortcode['params'] );
$shortcode['params'] = $sort->sortByKey();
}
return $shortcode;
}
return null;
}
/**
* Get all categories for mapped shortcodes.
*
* @static
* @return array
*/
public static function getCategories() {
self::generateData();
return self::$categories;
}
/**
* Get all categories for current user.
*
* Category is added to the list when at least one shortcode of this category is allowed for current user
* by Vc access rules.
*
* @static
* @return array
*/
public static function getUserCategories() {
self::generateUserData();
return self::$user_categories;
}
/**
* Drop shortcode param.
*
* @static
*
* @param $name
* @param $attribute_name
*
* @return bool
*/
public static function dropParam( $name, $attribute_name ) {
if ( ! isset( self::$init_elements[ $name ] ) ) {
vc_mapper()->addElementActivity( $name, 'drop_param', array(
'name' => $name,
'attribute_name' => $attribute_name,
) );
return true;
}
if ( isset( self::$sc[ $name ], self::$sc[ $name ]['params'] ) && is_array( self::$sc[ $name ]['params'] ) ) {
foreach ( self::$sc[ $name ]['params'] as $index => $param ) {
if ( $param['param_name'] == $attribute_name ) {
unset( self::$sc[ $name ][ 'params' ][ $index ] );
self::$sc[ $name ]['params'] = array_merge( self::$sc[ $name ]['params'] ); // fix indexes
return true;
}
}
}
return true;
}
/**
* Returns param settings for mapped shortcodes.
*
* @static
*
* @param $tag
* @param $param_name
*
* @return bool| array
*/
public static function getParam( $tag, $param_name ) {
if ( ! isset( self::$sc[ $tag ] ) ) {
return trigger_error( sprintf( __( 'Wrong name for shortcode:%s. Name required', 'js_composer' ), $tag ) );
}
if ( isset( self::$sc[ $tag ]['__vc_settings_function'] ) || isset( self::$sc[ $tag ]['__vc_settings_file'] ) ) {
self::setElementSettings( $tag );
}
if ( ! isset( self::$sc[ $tag ]['params'] ) ) {
return false;
}
foreach ( self::$sc[ $tag ]['params'] as $index => $param ) {
if ( $param['param_name'] == $param_name ) {
return self::$sc[ $tag ]['params'][ $index ];
}
}
return false;
}
/**
* Add new param to shortcode params list.
*
* @static
*
* @param $name
* @param array $attribute
*
* @return bool - true if added, false if scheduled/rejected
*/
public static function addParam( $name, $attribute = array() ) {
if ( ! isset( self::$init_elements[ $name ] ) ) {
vc_mapper()->addElementActivity( $name, 'add_param', array(
'name' => $name,
'attribute' => $attribute,
) );
return false;
}
if ( ! isset( self::$sc[ $name ] ) ) {
trigger_error( sprintf( __( 'Wrong name for shortcode:%s. Name required', 'js_composer' ), $name ) );
} elseif ( ! isset( $attribute['param_name'] ) ) {
trigger_error( sprintf( __( "Wrong attribute for '%s' shortcode. Attribute 'param_name' required", 'js_composer' ), $name ) );
} else {
$replaced = false;
foreach ( self::$sc[ $name ]['params'] as $index => $param ) {
if ( $param['param_name'] == $attribute['param_name'] ) {
$replaced = true;
self::$sc[ $name ]['params'][ $index ] = $attribute;
break;
}
}
if ( false === $replaced ) {
self::$sc[ $name ]['params'][] = $attribute;
}
$sort = new Vc_Sort( self::$sc[ $name ]['params'] );
self::$sc[ $name ]['params'] = $sort->sortByKey();
return true;
}
return false;
}
/**
* Change param attributes of mapped shortcode.
*
* @static
*
* @param $name
* @param array $attribute
*
* @return bool
*/
public static function mutateParam( $name, $attribute = array() ) {
if ( ! isset( self::$init_elements[ $name ] ) ) {
vc_mapper()->addElementActivity( $name, 'mutate_param', array(
'name' => $name,
'attribute' => $attribute,
) );
return false;
}
if ( ! isset( self::$sc[ $name ] ) ) {
return trigger_error( sprintf( __( 'Wrong name for shortcode:%s. Name required', 'js_composer' ), $name ) );
} elseif ( ! isset( $attribute['param_name'] ) ) {
trigger_error( sprintf( __( "Wrong attribute for '%s' shortcode. Attribute 'param_name' required", 'js_composer' ), $name ) );
} else {
$replaced = false;
foreach ( self::$sc[ $name ]['params'] as $index => $param ) {
if ( $param['param_name'] == $attribute['param_name'] ) {
$replaced = true;
self::$sc[ $name ]['params'][ $index ] = array_merge( $param, $attribute );
break;
}
}
if ( false === $replaced ) {
self::$sc[ $name ]['params'][] = $attribute;
}
$sort = new Vc_Sort( self::$sc[ $name ]['params'] );
self::$sc[ $name ]['params'] = $sort->sortByKey();
}
return true;
}
/**
* Removes shortcode from mapping list.
*
* @static
*
* @param $name
*
* @return bool
*/
public static function dropShortcode( $name ) {
if ( ! isset( self::$init_elements[ $name ] ) ) {
vc_mapper()->addElementActivity( $name, 'drop_shortcode', array(
'name' => $name,
) );
return false;
}
unset( self::$sc[ $name ] );
visual_composer()->removeShortCode( $name );
return true;
}
public static function dropAllShortcodes() {
if ( ! self::$is_init ) {
vc_mapper()->addActivity( '*', 'drop_all_shortcodes', array() );
return false;
}
foreach ( self::$sc as $name => $data ) {
visual_composer()->removeShortCode( $name );
}
self::$sc = array();
self::$user_sc = self::$user_categories = self::$user_sorted_sc = false;
return true;
}
/**
* Modify shortcode's mapped settings.
* You can modify only one option of the group options.
* Call this method with $settings_name param as associated array to mass modifications.
*
* @static
*
* @param $name - shortcode' name.
* @param $setting_name - option key name or the array of options.
* @param $value - value of settings if $setting_name is option key.
*
* @return array|bool
*/
public static function modify( $name, $setting_name, $value = '' ) {
if ( ! isset( self::$init_elements[ $name ] ) ) {
vc_mapper()->addElementActivity( $name, 'modify', array(
'name' => $name,
'setting_name' => $setting_name,
'value' => $value,
) );
return false;
}
if ( ! isset( self::$sc[ $name ] ) ) {
return trigger_error( sprintf( __( 'Wrong name for shortcode:%s. Name required', 'js_composer' ), $name ) );
} elseif ( 'base' === $setting_name ) {
return trigger_error( sprintf( __( "Wrong setting_name for shortcode:%s. Base can't be modified.", 'js_composer' ), $name ) );
}
if ( is_array( $setting_name ) ) {
foreach ( $setting_name as $key => $value ) {
self::modify( $name, $key, $value );
}
} else {
if ( is_array( $value ) ) {
$value = array_merge( $value ); // fix indexes
}
self::$sc[ $name ][ $setting_name ] = $value;
visual_composer()->updateShortcodeSetting( $name, $setting_name, $value );
}
return self::$sc;
}
/**
* Returns "|" separated list of mapped shortcode tags.
*
* @static
* @return string
*/
public static function getTagsRegexp() {
if ( empty( self::$tags_regexp ) ) {
self::$tags_regexp = implode( '|', array_keys( self::$sc ) );
}
return self::$tags_regexp;
}
/**
* Sorting method for WPBMap::generateUserData method. Called by uasort php function.
* @deprecated - use Vc_Sort::sortByKey since 4.4
* @static
*
* @param $a
* @param $b
*
* @return int
*/
public static function sort( $a, $b ) {
// _deprecated_function( 'WPBMap::sort', '4.4 (will be removed in 4.10)', 'Vc_Sort class, :sortByKey' );
$a_weight = isset( $a['weight'] ) ? (int) $a['weight'] : 0;
$b_weight = isset( $b['weight'] ) ? (int) $b['weight'] : 0;
if ( $a_weight == $b_weight ) {
$cmpa = array_search( $a, (array) self::$user_sorted_sc );
$cmpb = array_search( $b, (array) self::$user_sorted_sc );
return ( $cmpa > $cmpb ) ? 1 : - 1;
}
return ( $a_weight < $b_weight ) ? 1 : - 1;
}
public static function collectCategories( &$shortcodes ) {
$categories_list = array();
$deprecated = 'deprecated';
$add_deprecated = false;
if ( is_array( $shortcodes ) && ! empty( $shortcodes ) ) {
foreach ( $shortcodes as $name => $values ) {
$values['_category_ids'] = array();
if ( isset( $values['deprecated'] ) && false !== $values['deprecated'] ) {
$add_deprecated = true;
$values['_category_ids'][] = 'deprecated';
} elseif ( isset( $values['category'] ) ) {
$categories = $values['category'];
if ( is_array( $categories ) && ! empty( $categories ) ) {
foreach ( $categories as $c ) {
if ( false === array_search( $c, $categories_list ) ) {
$categories[] = $c;
}
$values['_category_ids'][] = md5( $c );
}
} else {
if ( false === array_search( $categories, $categories_list ) ) {
$categories_list[] = $categories;
}
$values['_category_ids'][] = md5( $categories );
}
}
$shortcodes[ $name ] = $values;
}
}
if ( $add_deprecated ) {
$categories_list[] = $deprecated;
}
return $categories_list;
}
/**
* Process files/functions for lean mapping settings
*
* @since 4.9
*
* @param $tag
*
* @return bool
*/
public static function setElementSettings( $tag ) {
if ( ! isset( self::$sc[ $tag ] ) ) {
return false;
}
$settings = self::$sc[ $tag ];
if ( isset( $settings['__vc_settings_function'] ) ) {
self::$sc[ $tag ] = call_user_func( $settings['__vc_settings_function'], $tag );
} elseif ( isset( $settings['__vc_settings_file'] ) ) {
self::$sc[ $tag ] = include $settings['__vc_settings_file'];
}
self::$sc[ $tag ]['base'] = $tag;
self::$init_elements[ $tag ] = true;
vc_mapper()->callElementActivities( $tag );
}
/**
* Add elements as shortcodes
*
* @since 4.9
*/
public static function addAllMappedShortcodes() {
foreach ( self::$sc as $tag => $settings ) {
if ( ! shortcode_exists( $tag ) ) {
add_shortcode( $tag, 'vc_do_shortcode' );
}
}
}
}
core/class-vc-sort.php 0000666 00000003423 15126312411 0010707 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Sort array values by key, default key is 'weight'
* Used in uasort() function.
* For fix equal weight problem used $this->data array_search
*
* @since 4.4
*/
/**
* Class Vc_Sort
* @since 4.4
*/
class Vc_Sort {
/**
* @since 4.4
* @var array $data - sorting data
*/
protected $data = array();
/**
* @since 4.4
* @var string $key - key for search
*/
protected $key = 'weight';
/**
* @since 4.4
*
* @param $data - array to sort
*/
public function __construct( $data ) {
$this->data = $data;
}
/**
* Used to change/set data to sort
*
* @since 4.5
*
* @param $data
*/
public function setData( $data ) {
$this->data = $data;
}
/**
* Sort $this->data by user key, used in class-vc-mapper.
* If keys are equals it SAVES a position in array (index).
*
* @since 4.4
*
* @param string $key
*
* @return array - sorted array
*/
public function sortByKey( $key = 'weight' ) {
$this->key = $key;
uasort( $this->data, array( &$this, '_key' ) );
return array_merge( $this->data ); // reset array keys to 0..N
}
/**
* Sorting by key callable for usort function
* @since 4.4
*
* @param $a - compare value
* @param $b - compare value
*
* @return int
*/
private function _key( $a, $b ) {
$a_weight = isset( $a[ $this->key ] ) ? (int) $a[ $this->key ] : 0;
$b_weight = isset( $b[ $this->key ] ) ? (int) $b[ $this->key ] : 0;
// To save real-ordering
if ( $a_weight == $b_weight ) {
$cmp_a = array_search( $a, $this->data );
$cmp_b = array_search( $b, $this->data );
return $cmp_a - $cmp_b;
}
return $b_weight - $a_weight;
}
/**
* @since 4.4
*
* @return array - sorting data
*/
public function getData() {
return $this->data;
}
}
core/access/class-vc-role-access-controller.php 0000666 00000013523 15126312411 0015544 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'CORE_DIR', 'access/abstract-class-vc-access.php' );
/**
* Class Vc_Role_Access_Controller
*
* @since 4.8
*/
class Vc_Role_Access_Controller extends Vc_Access {
protected static $part_name_prefix = 'vc_access_rules_';
protected $part = false;
protected $roleName = false;
protected $role = false;
protected $validAccess = true;
protected $mergedCaps = array(
'vc_row_inner_all' => 'vc_row_all',
'vc_column_all' => 'vc_row_all',
'vc_column_inner_all' => 'vc_row_all',
'vc_row_inner_edit' => 'vc_row_edit',
'vc_column_edit' => 'vc_row_edit',
'vc_column_inner_edit' => 'vc_row_edit',
);
function __construct( $part ) {
$this->part = $part;
}
/**
* Set role name.
*
* @param $role_name
*/
public function setRoleName( $role_name ) {
$this->roleName = $role_name;
}
/**
* Get part for role.
* @return bool
*/
public function getPart() {
return $this->part;
}
/**
* Get state of the Vc access rules part.
*
* @return mixed;
*/
public function getState() {
$role = $this->getRole();
$state = null;
if ( $role && isset( $role->capabilities, $role->capabilities[ $this->getStateKey() ] ) ) {
$state = $role->capabilities[ $this->getStateKey() ];
}
return apply_filters( 'vc_role_access_with_' . $this->getPart() . '_get_state', $state, $this->getRole() );
}
/**
* Set state for full part.
*
* State can have 3 values:
* true - all allowed under this part;
* false - all disabled under this part;
* string|'custom' - custom settings. It means that need to check exact capability.
*
* @param bool $value
*
* @return bool
*/
public function setState( $value = true ) {
$this->getRole() && $this->getRole()
->add_cap( $this->getStateKey(), $value );
}
/**
* Can user do what he doo.
* Any rule has three types of state: true, false, string.
*
* @param string $rule
* @param bool|true $check_state
*
* @return $this
*/
public function can( $rule = '', $check_state = true ) {
if ( null === $this->getRole() ) {
$this->setValidAccess( is_super_admin() );
} elseif ( $this->getValidAccess() ) {
// YES it is hard coded :)
if ( 'administrator' === $this->getRole()->name && 'settings' === $this->getPart() && ( 'vc-roles-tab' === $rule || 'vc-updater-tab' === $rule ) ) {
$this->setValidAccess( true );
return $this;
}
$rule = $this->updateMergedCaps( $rule );
if ( true === $check_state ) {
$state = $this->getState();
$return = false !== $state;
if ( null === $state ) {
$return = true;
} elseif ( is_bool( $state ) ) {
$return = $state;
} elseif ( '' !== $rule ) {
$return = $this->getCapRule( $rule );
}
} else {
$return = $this->getCapRule( $rule );
}
$return = apply_filters( 'vc_role_access_with_' . $this->getPart() . '_can', $return, $this->getRole(), $rule );
$return = apply_filters( 'vc_role_access_with_' . $this->getPart() . '_can_' . $rule, $return, $this->getRole() );
$this->setValidAccess( $return );
}
return $this;
}
/**
* Can user do what he doo.
* Any rule has three types of state: true,false, string.
*/
public function canAny() {
if ( $this->getValidAccess() ) {
$args = func_get_args();
$this->checkMulti( 'can', true, $args );
}
return $this;
}
/**
* Can user do what he doo.
* Any rule has three types of state: true,false, string.
*/
public function canAll() {
if ( $this->getValidAccess() ) {
$args = func_get_args();
$this->checkMulti( 'can', false, $args );
}
return $this;
}
/**
* Get capability for role
*
* @param $rule
*
* @return bool
*/
public function getCapRule( $rule ) {
$rule = $this->getStateKey() . '/' . $rule;
return $this->getRole() ? $this->getRole()->has_cap( $rule ) : false;
}
/**
* Add capability to role.
*
* @param $rule
* @param bool $value
*/
public function setCapRule( $rule, $value = true ) {
$role_rule = $this->getStateKey() . '/' . $rule;
$this->getRole() && $this->getRole()->add_cap( $role_rule, $value );
}
/**
* Get all capability for this part.
*/
public function getAllCaps() {
$role = $this->getRole();
$caps = array();
if ( $role ) {
$role = apply_filters( 'vc_role_access_all_caps_role', $role );
if ( isset( $role->capabilities ) && is_array( $role->capabilities ) ) {
foreach ( $role->capabilities as $key => $value ) {
if ( preg_match( '/^' . $this->getStateKey() . '\//', $key ) ) {
$rule = preg_replace( '/^' . $this->getStateKey() . '\//', '', $key );
$caps[ $rule ] = $value;
}
}
}
}
return $caps;
}
/**
* @return null|\WP_Role
* @throws Exception
*/
public function getRole() {
if ( ! $this->role ) {
if ( ! $this->getRoleName() ) {
throw new Exception( 'roleName for role_manager is not set, please use ->who(roleName) method to set!' );
}
$this->role = get_role( $this->getRoleName() );
}
return $this->role;
}
/**
* @return null|string
*/
public function getRoleName() {
return $this->roleName;
}
public function getStateKey() {
return self::$part_name_prefix . $this->getPart();
}
public function checkState( $data ) {
if ( $this->getValidAccess() ) {
$this->setValidAccess( $this->getState() === $data );
}
return $this;
}
public function checkStateAny() {
if ( $this->getValidAccess() ) {
$args = func_get_args();
$this->checkMulti( 'checkState', true, $args );
}
return $this;
}
/**
* Return access value.
* @return string
*/
public function __toString() {
return (string) $this->get();
}
public function updateMergedCaps( $rule ) {
if ( isset( $this->mergedCaps[ $rule ] ) ) {
return $this->mergedCaps[ $rule ];
}
return $rule;
}
/**
* @return array
*/
public function getMergedCaps() {
return $this->mergedCaps;
}
}
core/access/class-vc-role-access.php 0000666 00000003212 15126312411 0013355 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'CORE_DIR', 'access/abstract-class-vc-access.php' );
/**
* Class Vc_Role_Access
*/
class Vc_Role_Access extends Vc_Access {
/**
* @var bool
*/
protected $roleName = false;
/**
* @var array
*/
protected $parts = array();
/**
*
*/
public function __construct() {
require_once( ABSPATH . 'wp-admin/includes/user.php' );
}
/**
* @param $part
*
* @return Vc_Role_Access_Controller
*/
public function part( $part ) {
$role_name = $this->getRoleName();
if ( ! $role_name ) {
throw new Exception( 'roleName for vc_role_access is not set, please use ->who(roleName) method to set!' );
}
$key = $part . '_' . $role_name;
if ( ! isset( $this->parts[ $key ] ) ) {
require_once vc_path_dir( 'CORE_DIR', 'access/class-vc-role-access-controller.php' );
/** @var $role_access_controller Vc_Role_Access_Controller */
$role_access_controller = $this->parts[ $key ] = new Vc_Role_Access_Controller( $part );
$role_access_controller->setRoleName( $this->getRoleName() );
}
/** @var $role_access_controller Vc_Role_Access_Controller */
$role_access_controller = $this->parts[ $key ];
$role_access_controller->setValidAccess( $this->getValidAccess() ); // send current status to upper level
$this->setValidAccess( true ); // reset
return $role_access_controller;
}
/**
* Set role to get access to data.
*
* @param $role
*
* @return $this
*/
public function who( $roleName ) {
$this->roleName = $roleName;
return $this;
}
/**
* @return null|string
*/
public function getRoleName() {
return $this->roleName;
}
}
core/access/class-vc-current-user-access.php 0000666 00000004214 15126312411 0015055 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'CORE_DIR', 'access/class-vc-role-access.php' );
/**
* Class Vc_User_Access
*/
class Vc_Current_User_Access extends Vc_Role_Access {
/**
* @param $part
*
* @return Vc_Current_User_Access_Controller;
*/
public function part( $part ) {
if ( ! isset( $this->parts[ $part ] ) ) {
require_once vc_path_dir( 'CORE_DIR', 'access/class-vc-current-user-access-controller.php' );
/** @var $user_access_controller Vc_Current_User_Access_Controller */
$user_access_controller = $this->parts[ $part ] = new Vc_Current_User_Access_Controller( $part );
}
/** @var $user_access_controller Vc_Current_User_Access_Controller */
$user_access_controller = $this->parts[ $part ];
// we also check for user "logged_in" status
$is_user_logged_in = function_exists( 'is_user_logged_in' ) && is_user_logged_in();
$user_access_controller->setValidAccess( $is_user_logged_in && $this->getValidAccess() ); // send current status to upper level
$this->setValidAccess( true ); // reset
return $user_access_controller;
}
public function wpMulti( $method, $valid, $argsList ) {
if ( $this->getValidAccess() ) {
$access = ! $valid;
foreach ( $argsList as &$args ) {
if ( ! is_array( $args ) ) {
$args = array( $args );
}
array_unshift( $args, 'current_user_can' );
$this->setValidAccess( true );
call_user_func_array( array(
&$this,
$method,
), $args );
if ( $valid === $this->getValidAccess() ) {
$access = $valid;
break;
}
}
$this->setValidAccess( $access );
}
return $this;
}
/**
* Check Wordpress capability. Should be valid one cap at least.
*
* @return Vc_Current_User_Access
*/
public function wpAny() {
if ( $this->getValidAccess() ) {
$args = func_get_args();
$this->wpMulti( 'check', true, $args );
}
return $this;
}
/**
* Check Wordpress capability. Should be valid all caps.
*
* @return Vc_Current_User_Access
*/
public function wpAll() {
if ( $this->getValidAccess() ) {
$args = func_get_args();
$this->wpMulti( 'check', false, $args );
}
return $this;
}
}
core/class-vc-page.php 0000666 00000001773 15126312411 0010642 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
class Vc_Page implements Vc_Render {
protected $slug;
protected $title;
protected $templatePath;
/**
* @return string
*
*/
public function getSlug() {
return $this->slug;
}
/**
* @param mixed $slug
*
* @return $this;
*/
public function setSlug( $slug ) {
$this->slug = (string) $slug;
return $this;
}
/**
* @return mixed
*/
public function getTitle() {
return $this->title;
}
/**
* @param string $title
*
* @return $this
*/
public function setTitle( $title ) {
$this->title = (string) $title;
return $this;
}
/**
* @return mixed
*/
public function getTemplatePath() {
return $this->templatePath;
}
/**
* @param mixed $templatePath
*
* @return $this
*/
public function setTemplatePath( $templatePath ) {
$this->templatePath = $templatePath;
return $this;
}
public function render() {
vc_include_template( $this->getTemplatePath(),
array(
'page' => $this,
) );
}
}
editors/navbar/class-vc-navbar-frontend.php 0000666 00000013174 15126312411 0015004 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'EDITORS_DIR', 'navbar/class-vc-navbar.php' );
/**
*
*/
class Vc_Navbar_Frontend extends Vc_Navbar {
/**
* @var array
*/
protected $controls = array(
'add_element',
'templates',
'view_post',
'save_update',
'screen_size',
//'guides_switch', // disabled in 4.9
'custom_css',
);
/**
* @var string
*/
protected $controls_filter_name = 'vc_nav_front_controls';
/**
* @var string
*/
protected $brand_url = 'http://vc.wpbakery.com/?utm_campaign=VCplugin&utm_source=vc_user&utm_medium=frontend_editor';
/**
* @var string
*/
protected $css_class = 'vc_navbar vc_navgar-frontend';
/**
* @return string
*/
public function getControlGuidesSwitch() {
return '<li class="vc_pull-right">'
. '<button id="vc_guides-toggle-button" class="vc_btn vc_btn-primary vc_btn-sm vc_navbar-btn"'
. ' title="' . __( "Toggle editor's guides", 'js_composer' ) . '">'
. __( 'Guides ON', 'js_composer' )
. '</button>'
. '</li>';
}
/**
* @return string
*/
public function getControlScreenSize() {
$disable_responsive = vc_settings()->get( 'not_responsive_css' );
if ( '1' !== $disable_responsive ) {
$screen_sizes = array(
array(
'title' => __( 'Desktop', 'js_composer' ),
'size' => '100%',
'key' => 'default',
'active' => true,
),
array(
'title' => __( 'Tablet landscape mode', 'js_composer' ),
'size' => '1024px',
'key' => 'landscape-tablets',
),
array(
'title' => __( 'Tablet portrait mode', 'js_composer' ),
'size' => '768px',
'key' => 'portrait-tablets',
),
array(
'title' => __( 'Smartphone landscape mode', 'js_composer' ),
'size' => '480px',
'key' => 'landscape-smartphones',
),
array(
'title' => __( 'Smartphone portrait mode', 'js_composer' ),
'size' => '320px',
'key' => 'portrait-smartphones',
),
);
$output = '<li class="vc_pull-right">'
. '<div class="vc_dropdown" id="vc_screen-size-control">'
. '<a href="#" class="vc_dropdown-toggle"'
. ' title="' . __( 'Responsive preview', 'js_composer' ) . '"><i class="vc_icon default"'
. ' id="vc_screen-size-current"></i><b class="vc_caret"></b></a>'
. '<ul class="vc_dropdown-list">';
while ( $screen = current( $screen_sizes ) ) {
$output .= '<li><a href="#" title="' . esc_attr( $screen['title'] ) . '"'
. ' class="vc_screen-width ' . $screen['key']
. ( isset( $screen['active'] ) && $screen['active'] ? ' active' : '' )
. '" data-size="' . $screen['size'] . '"></a></li>';
next( $screen_sizes );
}
$output .= '</ul></div></li>';
return $output;
}
return '';
}
/**
* @return string
*/
public function getControlSaveUpdate() {
$post = $this->post();
$post_type = get_post_type_object( $this->post->post_type );
$can_publish = current_user_can( $post_type->cap->publish_posts );
ob_start();
?>
<li class="vc_show-mobile vc_pull-right">
<button data-url="<?php esc_attr_e( get_edit_post_link( $post->ID ) . '&wpb_vc_js_status=true' ) ?>"
class="vc_btn vc_btn-default vc_btn-sm vc_navbar-btn vc_btn-backend-editor" id="vc_button-cancel"
title="<?php _e( 'Cancel all changes and return to WP dashboard', 'js_composer' ) ?>"><?php echo vc_user_access()
->part( 'backend_editor' )
->can()
->get() ? __( 'Backend Editor', 'js_composer' ) : __( 'Edit', 'js_composer' ); ?></button>
<?php if ( ! in_array( $post->post_status, array(
'publish',
'future',
'private',
) )
) : ?>
<?php if ( 'draft' === $post->post_status ) : ?>
<button type="button" class="vc_btn vc_btn-default vc_btn-sm vc_navbar-btn vc_btn-save-draft"
id="vc_button-save-draft"
title="<?php esc_attr_e( 'Save Draft', 'js_composer' ) ?>"><?php _e( 'Save Draft', 'js_composer' ) ?></button>
<?php elseif ( 'pending' === $post->post_status && $can_publish ) : ?>
<button type="button" class="vc_btn vc_btn-primary vc_btn-sm vc_navbar-btn vc_btn-save"
id="vc_button-save-as-pending"
title="<?php esc_attr_e( 'Save as Pending', 'js_composer' ) ?>"><?php _e( 'Save as Pending', 'js_composer' ) ?></button>
<?php endif ?>
<?php if ( $can_publish ) : ?>
<button type="button" class="vc_btn vc_btn-primary vc_btn-sm vc_navbar-btn vc_btn-save"
id="vc_button-update" title="<?php esc_attr_e( 'Publish', 'js_composer' ) ?>"
data-change-status="publish"><?php _e( 'Publish', 'js_composer' ) ?></button>
<?php else : ?>
<button type="button" class="vc_btn vc_btn-primary vc_btn-sm vc_navbar-btn vc_btn-save"
id="vc_button-update" title="<?php esc_attr_e( 'Submit for Review', 'js_composer' ) ?>"
data-change-status="pending"><?php _e( 'Submit for Review', 'js_composer' ) ?></button>
<?php endif ?>
<?php else : ?>
<button type="button" class="vc_btn vc_btn-primary vc_btn-sm vc_navbar-btn vc_btn-save"
id="vc_button-update"
title="<?php esc_attr_e( 'Update', 'js_composer' ) ?>"><?php _e( 'Update', 'js_composer' ) ?></button>
<?php endif ?>
</li>
<?php
$output = ob_get_contents();
ob_end_clean();
return $output;
}
/**
* @return string
*/
public function getControlViewPost() {
return '<li class="vc_pull-right">'
. '<a href="' . esc_attr( get_permalink( $this->post() ) ) . '" class="vc_icon-btn vc_back-button"'
. ' title="' . esc_attr__( 'Exit Visual Composer edit mode', 'js_composer' ) . '"></a>'
. '</li>';
}
}
editors/navbar/class-vc-navbar.php 0000666 00000012054 15126312411 0013163 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Renders navigation bar for Editors.
*/
class Vc_Navbar implements Vc_Render {
/**
* @var array
*/
protected $controls = array(
'add_element',
'templates',
'save_backend',
'preview',
'frontend',
'custom_css',
'fullscreen',
'windowed',
);
/**
* @var string
*/
protected $brand_url = 'http://vc.wpbakery.com/?utm_campaign=VCplugin&utm_source=vc_user&utm_medium=backend_editor';
/**
* @var string
*/
protected $css_class = 'vc_navbar';
/**
* @var string
*/
protected $controls_filter_name = 'vc_nav_controls';
/**
* @var bool|WP_Post
*/
protected $post = false;
/**
* @param WP_Post $post
*/
public function __construct( WP_Post $post ) {
$this->post = $post;
}
/**
* Generate array of controls by iterating property $controls list.
* vc_filter: vc_nav_controls - hook to override list of controls
* @return array - list of arrays witch contains key name and html output for button.
*/
public function getControls() {
$list = array();
foreach ( $this->controls as $control ) {
$method = vc_camel_case( 'get_control_' . $control );
if ( method_exists( $this, $method ) ) {
$list[] = array( $control, $this->$method() . "\n" );
}
}
return apply_filters( $this->controls_filter_name, $list );
}
/**
* Get current post.
* @return null|WP_Post
*/
public function post() {
if ( $this->post ) {
return $this->post;
}
return get_post();
}
/**
* Render template.
*/
public function render() {
vc_include_template( 'editors/navbar/navbar.tpl.php', array(
'css_class' => $this->css_class,
'controls' => $this->getControls(),
'nav_bar' => $this,
'post' => $this->post(),
) );
}
/**
* vc_filter: vc_nav_front_logo - hook to override visual composer logo
* @return mixed|void
*/
public function getLogo() {
$output = '<a id="vc_logo" class="vc_navbar-brand" title="' . __( 'Visual Composer', 'js_composer' )
. '" href="' . esc_attr( $this->brand_url ) . '" target="_blank">'
. __( 'Visual Composer', 'js_composer' ) . '</a>';
return apply_filters( 'vc_nav_front_logo', $output );
}
/**
* @return string
*/
public function getControlCustomCss() {
if ( ! vc_user_access()->part( 'post_settings' )->can()->get() ) {
return '';
}
return '<li class="vc_pull-right"><a id="vc_post-settings-button" href="javascript:;" class="vc_icon-btn vc_post-settings" title="'
. __( 'Page settings', 'js_composer' ) . '">'
. '<span id="vc_post-css-badge" class="vc_badge vc_badge-custom-css" style="display: none;">' . __( 'CSS', 'js_composer' ) . '</span></a>'
. '</li>';
}
/**
* @return string
*/
public function getControlFullscreen() {
return '<li class="vc_show-mobile vc_pull-right">'
. '<a id="vc_fullscreen-button" class="vc_icon-btn vc_fullscreen-button" title="'. __( 'Full screen', 'js_composer' ) . '"></a>'
. '</li>';
}
/**
* @return string
*/
public function getControlWindowed() {
return '<li class="vc_show-mobile vc_pull-right">'
. '<a id="vc_windowed-button" class="vc_icon-btn vc_windowed-button" title="'. __( 'Exit full screen', 'js_composer' ) . '"></a>'
. '</li>';
}
/**
* @return string
*/
public function getControlAddElement() {
if ( vc_user_access()
->part( 'shortcodes' )
->checkStateAny( true, 'custom', null )
->get() &&
vc_user_access_check_shortcode_all( 'vc_row' ) && vc_user_access_check_shortcode_all( 'vc_column' )
) {
return '<li class="vc_show-mobile">'
. ' <a href="javascript:;" class="vc_icon-btn vc_element-button" data-model-id="vc_element" id="vc_add-new-element" title="'
. '' . __( 'Add new element', 'js_composer' ) . '">'
. ' </a>'
. '</li>';
}
return '';
}
/**
* @return string
*/
public function getControlTemplates() {
if ( ! vc_user_access()->part( 'templates' )->can()->get() ) {
return '';
}
return '<li><a href="javascript:;" class="vc_icon-btn vc_templates-button vc_navbar-border-right" id="vc_templates-editor-button" title="'
. __( 'Templates', 'js_composer' ) . '"></a></li>';
}
/**
* @return string
*/
public function getControlFrontend() {
if ( ! vc_enabled_frontend() ) {
return '';
}
return '<li class="vc_pull-right">'
. '<a href="' . vc_frontend_editor()->getInlineUrl() . '" class="vc_btn vc_btn-primary vc_btn-sm vc_navbar-btn" id="wpb-edit-inline">' . __( 'Frontend', 'js_composer' ) . '</a>'
. '</li>';
}
/**
* @return string
*/
public function getControlPreview() {
return '';
}
/**
* @return string
*/
public function getControlSaveBackend() {
return '<li class="vc_pull-right vc_save-backend">'
. '<a href="javascript:;" class="vc_btn vc_btn-grey vc_btn-sm vc_navbar-btn vc_control-preview">' . __( 'Preview', 'js_composer' ) . '</a>'
. '<a class="vc_btn vc_btn-sm vc_navbar-btn vc_btn-primary vc_control-save" id="wpb-save-post">' . __( 'Update', 'js_composer' ) . '</a>'
. '</li>';
}
}
editors/popups/class-vc-add-element-box.php 0000666 00000010176 15126312411 0014737 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery Visual Composer front end editor
*
* @package WPBakeryVisualComposer
*
*/
/**
* Add element for VC editors with a list of mapped shortcodes.
*
* @since 4.3
*/
class Vc_Add_Element_Box implements Vc_Render {
/**
* Enable show empty message
*
* @since 4.8
* @var bool
*/
protected $show_empty_message = false;
/**
* @param $params
*
* @return string
*/
protected function getIcon( $params ) {
$data = '';
if ( isset( $params['is_container'] ) && true === $params['is_container'] ) {
$data = ' data-is-container="true"';
}
return '<i class="vc_general vc_element-icon' . ( ! empty( $params['icon'] ) ? ' ' . sanitize_text_field( $params['icon'] ) : '' ) . '"' . $data . '></i> ';
}
/**
* Single button html template
*
* @param $params
*
* @return string
*/
public function renderButton( $params ) {
if ( ! is_array( $params ) || empty( $params ) ) {
return '';
}
$output = $class = $class_out = $data = $category_css_classes = '';
if ( ! empty( $params['class'] ) ) {
$class_ar = $class_at_out = explode( ' ', $params['class'] );
for ( $n = 0; $n < count( $class_ar ); $n ++ ) {
$class_ar[ $n ] .= '_nav';
$class_at_out[ $n ] .= '_o';
}
$class = ' ' . implode( ' ', $class_ar );
$class_out = ' ' . implode( ' ', $class_at_out );
}
if ( isset( $params['_category_ids'] ) ) {
foreach ( $params['_category_ids'] as $id ) {
$category_css_classes .= ' js-category-' . $id;
}
}
if ( isset( $params['is_container'] ) && true === $params['is_container'] ) {
$data .= ' data-is-container="true"';
}
$data .= ' data-vc-ui-element="add-element-button"';
$description = ! empty( $params['description'] ) ? '<i class="vc_element-description">' . htmlspecialchars( $params['description'] ) . '</i>' : '';
$output .= '<li data-element="' . $params['base'] . '" class="wpb-layout-element-button vc_col-xs-12 vc_col-sm-4 vc_col-md-3 vc_col-lg-2' . ( isset( $params['deprecated'] ) ? ' vc_element-deprecated' : '' ) . $category_css_classes . $class_out . '"' . $data . '><div class="vc_el-container"><a id="' . $params['base'] . '" data-tag="' . $params['base'] . '" class="dropable_el vc_shortcode-link' . $class . '" href="#" data-vc-clickable>' . $this->getIcon( $params ) . htmlspecialchars( stripslashes( $params['name'] ) ) . $description . '</a></div></li>';
return $output;
}
/**
* Get mapped shortcodes list.
*
* @since 4.4
* @return array
*/
public function shortcodes() {
return WPBMap::getSortedUserShortCodes();
}
/**
* Render list of buttons for each mapped and allowed VC shortcodes.
* vc_filter: vc_add_element_box_buttons - hook to override output of getControls method
* @see WPBMap::getSortedUserShortCodes
* @return mixed|void
*/
public function getControls() {
$output = '<ul class="wpb-content-layouts">';
/** @var array $element */
$buttons_count = 0;
foreach ( $this->shortcodes() as $element ) {
if ( isset( $element['content_element'] ) && false === $element['content_element'] ) {
continue;
}
$button = $this->renderButton( $element );
if ( ! empty( $button ) ) {
$buttons_count ++;
}
$output .= $button;
}
$output .= '</ul>';
if ( 0 === $buttons_count ) {
$this->show_empty_message = true;
}
return apply_filters( 'vc_add_element_box_buttons', $output );
}
/**
* Get categories list from mapping data.
* @since 4.5
*
* @return array
*/
public function getCategories() {
return WPBMap::getUserCategories();
}
public function render() {
vc_include_template( 'editors/popups/vc_ui-panel-add-element.tpl.php', array(
'box' => $this,
'template_variables' => array(
'categories' => $this->getCategories(),
),
) );
}
/**
* Render icon for shortcode
*
* @param $params
*
* @since 4.8
* @return string
*/
public function renderIcon( $params ) {
return $this->getIcon( $params );
}
/**
* @return boolean
*/
public function isShowEmptyMessage() {
return $this->show_empty_message;
}
public function getPartState() {
return vc_user_access()->part( 'shortcodes' )->getState();
}
}
editors/popups/class-vc-edit-layout.php 0000666 00000001406 15126312411 0014226 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery Visual Composer main class.
*
* @package WPBakeryVisualComposer
* @since 4.3
*/
/**
* Edit row layout
*
* @since 4.3
*/
class Vc_Edit_Layout implements Vc_Render {
/**
* @deprecated 4.7
*/
public function render() {
_deprecated_function( '\Vc_Edit_Layout::render', '4.7 (will be removed in 4.11)', '\Vc_Edit_Layout::renderUITemplate' );
global $vc_row_layouts;
vc_include_template( 'editors/popups/panel_edit_layout.tpl.php', array(
'vc_row_layouts' => $vc_row_layouts,
) );
}
public function renderUITemplate() {
global $vc_row_layouts;
vc_include_template( 'editors/popups/vc_ui-panel-row-layout.tpl.php', array(
'vc_row_layouts' => $vc_row_layouts,
) );
}
}
editors/class-vc-edit-form-fields.php 0000666 00000024763 15126312411 0013605 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery Visual Composer shortcode attributes fields
*
* @package WPBakeryVisualComposer
*
*/
/**
* Edit form fields builder for shortcode attributes.
*
* @since 4.4
*/
class Vc_Edit_Form_Fields implements Vc_Render {
/**
* @since 4.4
* @var bool
*/
protected $tag = false;
/**
* @since 4.4
* @var array
*/
protected $atts = array();
/**
* @since 4.4
* @var array
*/
protected $settings = array();
/**
* @since 4.4
* @var bool
*/
protected $post_id = false;
/**
* Construct Form fields.
*
* @since 4.4
*
* @param $tag - shortcode tag
* @param $atts - list of attribute assign to the shortcode.
*/
public function __construct( $tag, $atts ) {
$this->tag = $tag;
$this->atts = apply_filters( 'vc_edit_form_fields_attributes_' . $this->tag, $atts );
$this->setSettings( WPBMap::getShortCode( $this->tag ) );
}
/**
* Get settings
* @since 4.4
*
* @param $key
*
* @return null
*/
public function setting( $key ) {
return isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : null;
}
/**
* Set settings data
* @since 4.4
*
* @param array $settings
*/
public function setSettings( array $settings ) {
$this->settings = $settings;
}
/**
* Shortcode Post ID getter.
* If post id isn't set try to get from get_the_ID function.
* @since 4.4
* @return int|bool;
*/
public function postId() {
if ( false === $this->post_id ) {
$this->post_id = get_the_ID();
}
return $this->post_id;
}
/**
* Shortcode Post ID setter.
* @since 4.4
*
* @param $post_id - integer value in post_id
*/
public function setPostId( $post_id ) {
$this->post_id = (int) $post_id;
}
/**
* Get shortcode attribute value.
*
* This function checks if value isn't set then it uses std or value fields in param settings.
* @since 4.4
*
* @param $param_settings
* @param $value
*
* @return null
*/
protected function parseShortcodeAttributeValue( $param_settings, $value ) {
if ( is_null( $value ) ) { // If value doesn't exists
if ( isset( $param_settings['std'] ) ) {
$value = $param_settings['std'];
} elseif ( isset( $param_settings['value'] ) && is_array( $param_settings['value'] ) && ! empty( $param_settings['type'] ) && 'checkbox' !== $param_settings['type']
) {
$first_key = key( $param_settings['value'] );
$value = $first_key ? $param_settings['value'][ $first_key ] : '';
} elseif ( isset( $param_settings['value'] ) && ! is_array( $param_settings['value'] ) ) {
$value = $param_settings['value'];
}
}
return $value;
}
/**
* Enqueue js scripts for attributes types.
* @since 4.4
* @return string
*/
public function enqueueScripts() {
$output = '';
if ( ! WpbakeryShortcodeParams::isEnqueue() ) {
$scripts = apply_filters( 'vc_edit_form_enqueue_script', WpbakeryShortcodeParams::getScripts() );
foreach ( $scripts as $script ) {
$output .= "\n\n" . '<script type="text/javascript" src="' . $script . '"></script>';
}
}
return $output;
}
/**
* Render grouped fields.
* @since 4.4
*
* @param $groups
* @param $groups_content
*
* @return string
*/
protected function renderGroupedFields( $groups, $groups_content ) {
$output = '';
if ( sizeof( $groups ) > 1 || ( sizeof( $groups ) >= 1 && empty( $groups_content['_general'] ) ) ) {
$output .= '<div class="vc_panel-tabs" id="vc_edit-form-tabs">';
$output .= '<ul class="vc_general vc_ui-tabs-line" data-vc-ui-element="panel-tabs-controls">';
$key = 0;
foreach ( $groups as $g ) {
$output .= '<li class="vc_edit-form-tab-control" data-tab-index="'
. $key . '"><button data-vc-ui-element-target="#vc_edit-form-tab-'
. $key ++ . '" class="vc_ui-tabs-line-trigger" data-vc-ui-element="panel-tab-control">'
. ( '_general' === $g ? __( 'General', 'js_composer' ) : $g ) . '</button></li>';
}
$output .= '<li class="vc_ui-tabs-line-dropdown-toggle" data-vc-action="dropdown"
data-vc-content=".vc_ui-tabs-line-dropdown" data-vc-ui-element="panel-tabs-line-toggle">
<span class="vc_ui-tabs-line-trigger" data-vc-accordion
data-vc-container=".vc_ui-tabs-line-dropdown-toggle"
data-vc-target=".vc_ui-tabs-line-dropdown"> </span>
<ul class="vc_ui-tabs-line-dropdown" data-vc-ui-element="panel-tabs-line-dropdown">
</ul>
</ul>';
$key = 0;
foreach ( $groups as $g ) {
$output .= '<div id="vc_edit-form-tab-' . $key ++ . '" class="vc_edit-form-tab vc_row vc_ui-flex-row" data-vc-ui-element="panel-edit-element-tab">';
$output .= $groups_content[ $g ];
$output .= '</div>';
}
$output .= '</div>';
} elseif ( ! empty( $groups_content['_general'] ) ) {
$output .= '<div class="vc_edit-form-tab vc_row vc_ui-flex-row vc_active" data-vc-ui-element="panel-edit-element-tab">' . $groups_content['_general'] . '</div>';
}
return $output;
}
/**
* Render fields html and output it.
* @since 4.4
* vc_filter: vc_edit_form_class - filter to override editor_css_classes array
*/
public function render() {
$this->loadDefaultParams();
$output = $el_position = '';
$groups_content = $groups = array();
$params = $this->setting( 'params' );
$editor_css_classes = apply_filters( 'vc_edit_form_class',
array(
'wpb_edit_form_elements',
'vc_edit_form_elements',
),
$this->atts,
$params
);
$deprecated = $this->setting( 'deprecated' );
require_once vc_path_dir( 'AUTOLOAD_DIR', 'class-vc-settings-presets.php' );
$list_vendor_presets = Vc_Settings_Preset::listVendorSettingsPresets( $this->tag );
$list_presets = Vc_Settings_Preset::listSettingsPresets( $this->tag );
if ( vc_user_access()
->part( 'presets' )
->checkStateAny( true, null )
->get() || ! empty( $list_presets ) || ! empty( $list_vendor_presets )
) {
$output .= '<script type="text/javascript">window.vc_presets_show=true;</script>';
} else {
$output .= '<script type="text/javascript">window.vc_presets_show=false;</script>';
}
if ( ! empty( $deprecated ) ) {
$output .= '<div class="vc_row vc_ui-flex-row vc_shortcode-edit-form-deprecated-message"><div class="vc_col-sm-12 wpb_element_wrapper">' .
vc_message_warning( sprintf( __( 'You are using outdated element, it is deprecated since version %s.', 'js_composer' ), $this->setting( 'deprecated' ) ) ) .
'</div></div>';
}
$output .= '<div class="' . implode( ' ', $editor_css_classes ) . '" data-title="' . htmlspecialchars( __( 'Edit', 'js_composer' ) . ' ' . __( $this->setting( 'name' ), 'js_composer' ) ) . '">';
if ( is_array( $params ) ) {
foreach ( $params as $param ) {
$name = isset( $param['param_name'] ) ? $param['param_name'] : null;
if ( ! is_null( $name ) ) {
$value = isset( $this->atts[ $name ] ) ? $this->atts[ $name ] : null;
$value = $this->parseShortcodeAttributeValue( $param, $value );
$group = isset( $param['group'] ) && '' !== $param['group'] ? $param['group'] : '_general';
if ( ! isset( $groups_content[ $group ] ) ) {
$groups[] = $group;
$groups_content[ $group ] = '';
}
$groups_content[ $group ] .= $this->renderField( $param, $value );
}
}
}
$output .= $this->renderGroupedFields( $groups, $groups_content );
$output .= '</div>';
$output .= $this->enqueueScripts();
echo $output;
do_action( 'vc_edit_form_fields_after_render' );
}
/**
* Generate html for shortcode attribute.
*
* Method
* @since 4.4
*
* @param $param
* @param $value
*
* vc_filter: vc_single_param_edit - hook to edit any shortode param
* vc_filter: vc_form_fields_render_field_{shortcode_name}_{param_name}_param_value - hook to edit shortcode param
* value vc_filter: vc_form_fields_render_field_{shortcode_name}_{param_name}_param - hook to edit shortcode
* param attributes vc_filter: vc_single_param_edit_holder_output - hook to edit output of this method
*
* @return mixed|void
*/
protected function renderField( $param, $value ) {
$param['vc_single_param_edit_holder_class'] = array(
'wpb_el_type_' . $param['type'],
'vc_wrapper-param-type-' . $param['type'],
'vc_shortcode-param',
'vc_column',
);
if ( ! empty( $param['param_holder_class'] ) ) {
$param['vc_single_param_edit_holder_class'][] = $param['param_holder_class'];
}
$param = apply_filters( 'vc_single_param_edit', $param, $value );
$output = '<div class="' . implode( ' ', $param['vc_single_param_edit_holder_class'] ) . '" data-vc-ui-element="panel-shortcode-param" data-vc-shortcode-param-name="' . esc_attr( $param['param_name'] ) . '" data-param_type="' . esc_attr( $param['type'] ) . '" data-param_settings="' . esc_attr( json_encode( $param ) ) . '">';
$output .= ( isset( $param['heading'] ) ) ? '<div class="wpb_element_label">' . $param['heading'] . '</div>' : '';
$output .= '<div class="edit_form_line">';
$value = apply_filters( 'vc_form_fields_render_field_' . $this->setting( 'base' ) . '_' . $param['param_name'] . '_param_value',
$value,
$param,
$this->settings,
$this->atts
);
$param = apply_filters( 'vc_form_fields_render_field_' . $this->setting( 'base' ) . '_' . $param['param_name'] . '_param',
$param,
$value,
$this->settings,
$this->atts
);
$output = apply_filters( 'vc_edit_form_fields_render_field_' . $param['type'] . '_before', $output );
$output .= vc_do_shortcode_param_settings_field( $param['type'], $param, $value, $this->setting( 'base' ) );
$output_after = '';
if ( isset( $param['description'] ) ) {
$output_after .= '<span class="vc_description vc_clearfix">' . $param['description'] . '</span>';
}
$output_after .= '</div></div>';
$output .= apply_filters( 'vc_edit_form_fields_render_field_' . $param['type'] . '_after', $output_after );
return apply_filters( 'vc_single_param_edit_holder_output',
$output,
$param,
$value,
$this->settings,
$this->atts
);
}
/**
* Create default shortcode params
*
* List of params stored in global variable $vc_params_list.
* Please check include/params/load.php for default params list.
* @since 4.4
* @return bool
*/
public function loadDefaultParams() {
global $vc_params_list;
if ( empty( $vc_params_list ) ) {
return false;
}
$script_url = vc_asset_url( 'js/dist/edit-form.min.js' );
foreach ( $vc_params_list as $param ) {
vc_add_shortcode_param( $param, 'vc_' . $param . '_form_field', $script_url );
}
do_action( 'vc_load_default_params' );
return true;
}
}
shortcodes/vc-gitem-zone-b.php 0000666 00000000452 15126312411 0012336 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-zone.php' );
class WPBakeryShortCode_VC_Gitem_Zone_B extends WPBakeryShortCode_VC_Gitem_Zone {
public $zone_name = 'b';
protected function getFileName() {
return 'vc_gitem_zone';
}
}
shortcodes/vc-gitem-post-author.php 0000666 00000000445 15126312411 0013433 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-post-data.php' );
class WPBakeryShortCode_VC_Gitem_Post_Author extends WPBakeryShortCode_VC_Gitem_Post_Data {
protected function getFileName() {
return 'vc_gitem_post_author';
}
}
shortcodes/vc-gitem-zone-c.php 0000666 00000000350 15126312411 0012334 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-zone.php' );
class WPBakeryShortCode_VC_Gitem_Zone_C extends WPBakeryShortCode_VC_Gitem_Zone {
public $zone_name = 'c';
}
shortcodes/vc-masonry-media-grid.php 0000666 00000002106 15126312411 0013527 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-media-grid.php' );
class WPBakeryShortCode_VC_Masonry_Media_Grid extends WPBakeryShortCode_VC_Media_Grid {
public function shortcodeScripts() {
parent::shortcodeScripts();
wp_register_script( 'vc_masonry', vc_asset_url( 'lib/bower/masonry/dist/masonry.pkgd.min.js' ),
array(), WPB_VC_VERSION, true
);
}
public function enqueueScripts() {
wp_enqueue_script( 'vc_masonry' );
parent::enqueueScripts();
}
public function buildGridSettings() {
parent::buildGridSettings();
$this->grid_settings['style'] .= '-masonry';
}
protected function contentAllMasonry( $grid_style, $settings, $content ) {
return parent::contentAll( $grid_style, $settings, $content );
}
protected function contentLazyMasonry( $grid_style, $settings, $content ) {
return parent::contentLazy( $grid_style, $settings, $content );
}
protected function contentLoadMoreMasonry( $grid_style, $settings, $content ) {
return parent::contentLoadMore( $grid_style, $settings, $content );
}
}
shortcodes/vc-gallery.php 0000666 00000004244 15126312411 0011503 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
class WPBakeryShortCode_VC_gallery extends WPBakeryShortCode {
function __construct( $settings ) {
parent::__construct( $settings );
$this->shortcodeScripts();
}
public function shortcodeScripts() {
wp_register_script( 'vc_grid-js-imagesloaded',
vc_asset_url( 'lib/bower/imagesloaded/imagesloaded.pkgd.min.js' )
);
}
public function singleParamHtmlHolder( $param, $value ) {
$output = '';
// Compatibility fixes
$old_names = array(
'yellow_message',
'blue_message',
'green_message',
'button_green',
'button_grey',
'button_yellow',
'button_blue',
'button_red',
'button_orange',
);
$new_names = array(
'alert-block',
'alert-info',
'alert-success',
'btn-success',
'btn',
'btn-info',
'btn-primary',
'btn-danger',
'btn-warning',
);
$value = str_ireplace( $old_names, $new_names, $value );
$param_name = isset( $param['param_name'] ) ? $param['param_name'] : '';
$type = isset( $param['type'] ) ? $param['type'] : '';
$class = isset( $param['class'] ) ? $param['class'] : '';
if ( isset( $param['holder'] ) && 'hidden' !== $param['holder'] ) {
$output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '">' . $value . '</' . $param['holder'] . '>';
}
if ( 'images' === $param_name ) {
$images_ids = empty( $value ) ? array() : explode( ',', trim( $value ) );
$output .= '<ul class="attachment-thumbnails' . ( empty( $images_ids ) ? ' image-exists' : '' ) . '" data-name="' . $param_name . '">';
foreach ( $images_ids as $image ) {
$img = wpb_getImageBySize( array( 'attach_id' => (int) $image, 'thumb_size' => 'thumbnail' ) );
$output .= ( $img ? '<li>' . $img['thumbnail'] . '</li>' : '<li><img width="150" height="150" test="' . $image . '" src="' . vc_asset_url( 'vc/blank.gif' ) . '" class="attachment-thumbnail" alt="" title="" /></li>' );
}
$output .= '</ul>';
$output .= '<a href="#" class="column_edit_trigger' . ( ! empty( $images_ids ) ? ' image-exists' : '' ) . '">' . __( 'Add images', 'js_composer' ) . '</a>';
}
return $output;
}
}
shortcodes/vc-gitem-zone-a.php 0000666 00000000452 15126312411 0012335 0 ustar 00 <?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-zone.php' );
class WPBakeryShortCode_VC_Gitem_Zone_A extends WPBakeryShortCode_VC_Gitem_Zone {
public $zone_name = 'a';
protected function getFileName() {
return 'vc_gitem_zone';
}
}