This commit is contained in:
KhaiNguyen
2020-02-13 10:39:37 +07:00
commit 59401cb805
12867 changed files with 4646216 additions and 0 deletions

View File

@@ -0,0 +1,217 @@
<?php
/**
* @package WPBakery
* @noinspection PhpIncludeInspection
*/
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
*
*/
define( 'VC_SHORTCODE_CUSTOMIZE_PREFIX', 'vc_theme_' );
/**
*
*/
define( 'VC_SHORTCODE_BEFORE_CUSTOMIZE_PREFIX', 'vc_theme_before_' );
/**
*
*/
define( 'VC_SHORTCODE_AFTER_CUSTOMIZE_PREFIX', 'vc_theme_after_' );
/**
*
*/
define( 'VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG', 'vc_shortcodes_css_class' );
require_once $this->path( 'SHORTCODES_DIR', 'core/class-wpbakery-visualcomposer-abstract.php' );
require_once $this->path( 'SHORTCODES_DIR', 'core/class-wpbakeryshortcode.php' );
require_once $this->path( 'SHORTCODES_DIR', 'core/class-wbpakeryshortcodefishbones.php' );
require_once $this->path( 'SHORTCODES_DIR', 'core/class-wpbakeryshortcodescontainer.php' );
/**
* @since 4.9
*
* Class Vc_Shortcodes_Manager
*/
class Vc_Shortcodes_Manager {
private $shortcode_classes = array(
'default' => array(),
);
private $tag;
/**
* Core singleton class
* @var self - pattern realization
*/
private static $instance;
/**
* Get the instance of Vc_Shortcodes_Manager
*
* @return self
*/
public static function getInstance() {
if ( ! ( self::$instance instanceof self ) ) {
self::$instance = new self();
}
return self::$instance;
}
public function getTag() {
return $this->tag;
}
/**
* @param $tag
* @return $this
*/
/**
* @param $tag
* @return $this
*/
public function setTag( $tag ) {
$this->tag = $tag;
return $this;
}
/**
* @param $tag
* @return \WPBakeryShortCodeFishBones
* @throws \Exception
*/
/**
* @param $tag
* @return \WPBakeryShortCodeFishBones
* @throws \Exception
*/
public function getElementClass( $tag ) {
$currentScope = WPBMap::getScope();
if ( isset( $this->shortcode_classes[ $currentScope ], $this->shortcode_classes[ $currentScope ][ $tag ] ) ) {
return $this->shortcode_classes[ $currentScope ][ $tag ];
}
if ( ! isset( $this->shortcode_classes[ $currentScope ] ) ) {
$this->shortcode_classes[ $currentScope ] = array();
}
$settings = WPBMap::getShortCode( $tag );
if ( empty( $settings ) ) {
throw new Exception( 'Element must be mapped in system' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'wordpress-widgets.php' );
$class_name = ! empty( $settings['php_class_name'] ) ? $settings['php_class_name'] : 'WPBakeryShortCode_' . $settings['base'];
$autoloaded_dependencies = VcShortcodeAutoloader::includeClass( $class_name );
if ( ! $autoloaded_dependencies ) {
$file = vc_path_dir( 'SHORTCODES_DIR', str_replace( '_', '-', $settings['base'] ) . '.php' );
if ( is_file( $file ) ) {
require_once $file;
}
}
if ( class_exists( $class_name ) && is_subclass_of( $class_name, 'WPBakeryShortCode' ) ) {
$shortcode_class = new $class_name( $settings );
} else {
$shortcode_class = new WPBakeryShortCodeFishBones( $settings );
}
$this->shortcode_classes[ $currentScope ][ $tag ] = $shortcode_class;
return $shortcode_class;
}
/**
* @return \WPBakeryShortCodeFishBones
* @throws \Exception
*/
/**
* @return \WPBakeryShortCodeFishBones
* @throws \Exception
*/
public function shortcodeClass() {
return $this->getElementClass( $this->tag );
}
/**
* @param string $content
*
* @return string
* @throws \Exception
*/
public function template( $content = '' ) {
return $this->getElementClass( $this->tag )->contentAdmin( array(), $content );
}
/**
* @param $name
*
* @return null
* @throws \Exception
*/
public function settings( $name ) {
$settings = WPBMap::getShortCode( $this->tag );
return isset( $settings[ $name ] ) ? $settings[ $name ] : null;
}
/**
* @param $atts
* @param null $content
* @param null $tag
*
* @return string
* @throws \Exception
*/
public function render( $atts, $content = null, $tag = null ) {
return $this->getElementClass( $this->tag )->output( $atts, $content );
}
public function buildShortcodesAssets() {
$elements = WPBMap::getAllShortCodes();
foreach ( $elements as $tag => $settings ) {
$element_class = $this->getElementClass( $tag );
$element_class->enqueueAssets();
$element_class->printIconStyles();
}
}
public function buildShortcodesAssetsForEditable() {
$elements = WPBMap::getAllShortCodes(); // @todo create pull to use only where it is set inside function. BC problem
foreach ( $elements as $tag => $settings ) {
$element_class = $this->getElementClass( $tag );
$element_class->printIconStyles();
}
}
/**
* @param $tag
* @return bool
*/
/**
* @param $tag
* @return bool
*/
public function isShortcodeClassInitialized( $tag ) {
$currentScope = WPBMap::getScope();
return isset( $this->shortcode_classes[ $currentScope ], $this->shortcode_classes[ $currentScope ][ $tag ] );
}
/**
* @param $tag
* @return bool
*/
/**
* @param $tag
* @return bool
*/
public function unsetElementClass( $tag ) {
$currentScope = WPBMap::getScope();
unset( $this->shortcode_classes[ $currentScope ][ $tag ] );
return true;
}
}

View File

@@ -0,0 +1,154 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCodeFishBones
*/
class WPBakeryShortCodeFishBones extends WPBakeryShortCode {
/**
* @var bool
*/
protected $shortcode_class = false;
/**
* @param $settings
* @throws \Exception
*/
public function __construct( $settings ) {
if ( ! $settings ) {
throw new Exception( 'Element must have settings to register' );
}
$this->settings = $settings;
$this->shortcode = $this->settings['base'];
add_action( 'admin_init', array(
$this,
'hookAdmin',
) );
if ( ! shortcode_exists( $this->shortcode ) ) {
add_shortcode( $this->shortcode, array(
$this,
'render',
) );
}
}
public function hookAdmin() {
$this->enqueueAssets();
add_action( 'admin_init', array(
$this,
'enqueueAssets',
) );
if ( vc_is_page_editable() ) {
// fix for page editable
add_action( 'wp_head', array(
$this,
'printIconStyles',
) );
}
add_action( 'admin_head', array(
$this,
'printIconStyles',
) ); // fe+be
add_action( 'admin_print_scripts-post.php', array(
$this,
'enqueueAssets',
) );
add_action( 'admin_print_scripts-post-new.php', array(
$this,
'enqueueAssets',
) );
}
/**
* @return WPBakeryShortCodeFishBones
* @throws \Exception
*/
public function shortcodeClass() {
if ( false !== $this->shortcode_class ) {
return $this->shortcode_class;
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'wordpress-widgets.php' );
$class_name = $this->settings( 'php_class_name' ) ? $this->settings( 'php_class_name' ) : 'WPBakeryShortCode_' . $this->settings( 'base' );
$autoloaded_dependencies = VcShortcodeAutoloader::includeClass( $class_name );
if ( ! $autoloaded_dependencies ) {
$file = vc_path_dir( 'SHORTCODES_DIR', str_replace( '_', '-', $this->settings( 'base' ) ) . '.php' );
if ( is_file( $file ) ) {
require_once $file;
}
}
if ( class_exists( $class_name ) && is_subclass_of( $class_name, 'WPBakeryShortCode' ) ) {
$this->shortcode_class = new $class_name( $this->settings );
} else {
$this->shortcode_class = new WPBakeryShortCodeFishBones( $this->settings );
}
return $this->shortcode_class;
}
/**
*
*
* @param $tag
*
* @return \WPBakeryShortCodeFishBones
* @throws \Exception
* @since 4.9
*
*/
public static function getElementClass( $tag ) {
$settings = WPBMap::getShortCode( $tag );
if ( empty( $settings ) ) {
throw new Exception( 'Element must be mapped in system' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'wordpress-widgets.php' );
$class_name = ! empty( $settings['php_class_name'] ) ? $settings['php_class_name'] : 'WPBakeryShortCode_' . $settings['base'];
$autoloaded_dependencies = VcShortcodeAutoloader::includeClass( $class_name );
if ( ! $autoloaded_dependencies ) {
$file = vc_path_dir( 'SHORTCODES_DIR', str_replace( '_', '-', $settings['base'] ) . '.php' );
if ( is_file( $file ) ) {
require_once $file;
}
}
if ( class_exists( $class_name ) && is_subclass_of( $class_name, 'WPBakeryShortCode' ) ) {
$shortcode_class = new $class_name( $settings );
} else {
$shortcode_class = new WPBakeryShortCodeFishBones( $settings );
}
return $shortcode_class;
}
/**
* @param $atts
* @param null $content
* @param null $tag
*
* @return string
* @throws \Exception
*/
public function render( $atts, $content = null, $tag = null ) {
return self::getElementClass( $tag )->output( $atts, $content );
}
/**
* @param string $content
*
* @return string
* @throws \Exception
*/
public function template( $content = '' ) {
return $this->shortcodeClass()->contentAdmin( array(), $content );
}
}

View File

@@ -0,0 +1,197 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/* abstract VisualComposer class to create structural object of any type */
/**
* Class WPBakeryVisualComposerAbstract
*/
abstract class WPBakeryVisualComposerAbstract {
/**
* @var
*/
public static $config;
/**
* @var string
*/
protected $controls_css_settings = 'cc';
/**
* @var array
*/
protected $controls_list = array(
'edit',
'clone',
'delete',
);
/**
* @var string
*/
protected $shortcode_content = '';
/**
*
*/
public function __construct() {
}
/**
* @param $settings
* @deprecated not used
*/
public function init( $settings ) {
self::$config = (array) $settings;
}
/**
* @param $action
* @param $method
* @param int $priority
* @return true|void
* @deprecated 6.0 use native WordPress actions
*/
public function addAction( $action, $method, $priority = 10 ) {
return add_action( $action, array(
$this,
$method,
), $priority );
}
/**
* @param $action
* @param $method
* @param int $priority
*
* @return bool
* @deprecated 6.0 use native WordPress actions
*
*/
public function removeAction( $action, $method, $priority = 10 ) {
return remove_action( $action, array(
$this,
$method,
), $priority );
}
/**
* @param $filter
* @param $method
* @param int $priority
*
* @return bool|void
* @deprecated 6.0 use native WordPress actions
*
*/
public function addFilter( $filter, $method, $priority = 10 ) {
return add_filter( $filter, array(
$this,
$method,
), $priority );
}
/**
* @param $filter
* @param $method
* @param int $priority
* @return bool
* @deprecated 6.0 use native WordPress
*
*/
public function removeFilter( $filter, $method, $priority = 10 ) {
return remove_filter( $filter, array(
$this,
$method,
), $priority );
}
/**
* @param $tag
* @param $func
* @deprecated 6.0 not used
*
*/
public function addShortCode( $tag, $func ) {
// this function is deprecated since 6.0
}
/**
* @param $content
* @deprecated 6.0 not used
*
*/
public function doShortCode( $content ) {
// this function is deprecated since 6.0
}
/**
* @param $tag
* @deprecated 6.0 not used
*
*/
public function removeShortCode( $tag ) {
// this function is deprecated since 6.0
}
/**
* @param $param
*
* @return null
* @deprecated 6.0 not used, use vc_post_param
*
*/
public function post( $param ) {
// this function is deprecated since 6.0
return vc_post_param( $param );
}
/**
* @param $param
*
* @return null
* @deprecated 6.0 not used, use vc_get_param
*
*/
public function get( $param ) {
// this function is deprecated since 6.0
return vc_get_param( $param );
}
/**
* @param $asset
*
* @return string
* @deprecated 4.5 use vc_asset_url
*
*/
public function assetURL( $asset ) {
// this function is deprecated since 4.5
return vc_asset_url( $asset );
}
/**
* @param $asset
*
* @return string
* @deprecated 6.0 not used
*/
public function assetPath( $asset ) {
// this function is deprecated since 6.0
return self::$config['APP_ROOT'] . self::$config['ASSETS_DIR'] . $asset;
}
/**
* @param $name
*
* @return null
* @deprecated 6.0 not used
*/
public static function config( $name ) {
return isset( self::$config[ $name ] ) ? self::$config[ $name ] : null;
}
}

View File

@@ -0,0 +1,867 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode
*/
abstract class WPBakeryShortCode extends WPBakeryVisualComposerAbstract {
/**
* @var string - shortcode tag
*/
protected $shortcode;
/**
* @var
*/
protected $html_template;
/**
* @var
*/
protected $atts;
/**
* @var
*/
protected $settings;
/**
* @var array
*/
protected static $js_scripts = array();
/**
* @var array
*/
protected static $css_scripts = array();
/**
* default scripts like scripts
* @var bool
* @since 4.4.3
*/
protected static $default_scripts_enqueued = false;
/**
* @var string
*/
protected $shortcode_string = '';
/**
* @var string
*/
protected $controls_template_file = 'editors/partials/backend_controls.tpl.php';
public $nonDraggableClass = 'vc-non-draggable';
/** @noinspection PhpMissingParentConstructorInspection */
/**
* @param $settings
*/
public function __construct( $settings ) {
$this->settings = $settings;
$this->shortcode = $this->settings['base'];
}
/**
* @param $content
*
* @return string
*/
public function addInlineAnchors( $content ) {
return ( $this->isInline() || $this->isEditor() && true === $this->settings( 'is_container' ) ? '<span class="vc_container-anchor"></span>' : '' ) . $content;
}
/**
*
*/
public function enqueueAssets() {
if ( ! empty( $this->settings['admin_enqueue_js'] ) ) {
$this->registerJs( $this->settings['admin_enqueue_js'] );
}
if ( ! empty( $this->settings['admin_enqueue_css'] ) ) {
$this->registerCss( $this->settings['admin_enqueue_css'] );
}
}
/**
* Prints out the styles needed to render the element icon for the back end interface.
* Only performed if the 'icon' setting is a valid URL.
*
* @return void
* @since 4.2
* @modified 4.4
* @author Benjamin Intal
*/
public function printIconStyles() {
if ( ! filter_var( $this->settings( 'icon' ), FILTER_VALIDATE_URL ) ) {
return;
}
$first_tag = 'style';
echo '
<' . esc_attr( $first_tag ) . '>
.vc_el-container #' . esc_attr( $this->settings['base'] ) . ' .vc_element-icon,
.wpb_' . esc_attr( $this->settings['base'] ) . ' > .wpb_element_wrapper > .wpb_element_title > .vc_element-icon,
.vc_el-container > #' . esc_attr( $this->settings['base'] ) . ' > .vc_element-icon,
.vc_el-container > #' . esc_attr( $this->settings['base'] ) . ' > .vc_element-icon[data-is-container="true"],
.compose_mode .vc_helper.vc_helper-' . esc_attr( $this->settings['base'] ) . ' > .vc_element-icon,
.vc_helper.vc_helper-' . esc_attr( $this->settings['base'] ) . ' > .vc_element-icon,
.compose_mode .vc_helper.vc_helper-' . esc_attr( $this->settings['base'] ) . ' > .vc_element-icon[data-is-container="true"],
.vc_helper.vc_helper-' . esc_attr( $this->settings['base'] ) . ' > .vc_element-icon[data-is-container="true"],
.wpb_' . esc_attr( $this->settings['base'] ) . ' > .wpb_element_wrapper > .wpb_element_title > .vc_element-icon,
.wpb_' . esc_attr( $this->settings['base'] ) . ' > .wpb_element_wrapper > .wpb_element_title > .vc_element-icon[data-is-container="true"] {
background-position: 0 0;
background-image: url(' . esc_url( $this->settings['icon'] ) . ');
-webkit-background-size: contain;
-moz-background-size: contain;
-ms-background-size: contain;
-o-background-size: contain;
background-size: contain;
}
</' . esc_attr( $first_tag ) . '>';
}
/**
* @param $param
*/
protected function registerJs( $param ) {
if ( is_array( $param ) && ! empty( $param ) ) {
foreach ( $param as $value ) {
$this->registerJs( $value );
}
} elseif ( is_string( $param ) && ! empty( $param ) ) {
$name = 'admin_enqueue_js_' . md5( $param );
self::$js_scripts[] = $name;
wp_register_script( $name, $param, array( 'jquery' ), WPB_VC_VERSION, true );
}
}
/**
* @param $param
*/
protected function registerCss( $param ) {
if ( is_array( $param ) && ! empty( $param ) ) {
foreach ( $param as $value ) {
$this->registerCss( $value );
}
} elseif ( is_string( $param ) && ! empty( $param ) ) {
$name = 'admin_enqueue_css_' . md5( $param );
self::$css_scripts[] = $name;
wp_register_style( $name, $param, array( 'js_composer' ), WPB_VC_VERSION );
}
}
/**
*
*/
public static function enqueueCss() {
if ( ! empty( self::$css_scripts ) ) {
foreach ( self::$css_scripts as $stylesheet ) {
wp_enqueue_style( $stylesheet );
}
}
}
/**
*
*/
public static function enqueueJs() {
if ( ! empty( self::$js_scripts ) ) {
foreach ( self::$js_scripts as $script ) {
wp_enqueue_script( $script );
}
}
}
/**
* @param $shortcode
*/
public function shortcode( $shortcode ) {
}
/**
* @param $template
*
* @return string
*/
protected function setTemplate( $template ) {
return $this->html_template = apply_filters( 'vc_shortcode_set_template_' . $this->shortcode, $template );
}
/**
* @return bool
*/
protected function getTemplate() {
if ( isset( $this->html_template ) ) {
return $this->html_template;
}
return false;
}
/**
* @return mixed
*/
protected function getFileName() {
return $this->shortcode;
}
/**
* Find html template for shortcode output.
*/
protected function findShortcodeTemplate() {
// Check template path in shortcode's mapping settings
if ( ! empty( $this->settings['html_template'] ) && is_file( $this->settings( 'html_template' ) ) ) {
return $this->setTemplate( $this->settings['html_template'] );
}
// Check template in theme directory
$user_template = vc_shortcodes_theme_templates_dir( $this->getFileName() . '.php' );
if ( is_file( $user_template ) ) {
return $this->setTemplate( $user_template );
}
// Check default place
$default_dir = vc_manager()->getDefaultShortcodesTemplatesDir() . '/';
if ( is_file( $default_dir . $this->getFileName() . '.php' ) ) {
return $this->setTemplate( $default_dir . $this->getFileName() . '.php' );
}
$template = apply_filters( 'vc_shortcode_set_template_' . $this->shortcode, '' );
if ( ! empty( $template ) ? $template : '' ) {
return $this->setTemplate( $template );
}
return '';
}
/**
* @param $atts
* @param null $content
*
* @return mixed
* @throws \Exception
*/
protected function content( $atts, $content = null ) {
return $this->loadTemplate( $atts, $content );
}
/**
* @param $atts
* @param null $content
*
* vc_filter: vc_shortcode_content_filter - hook to edit template content
* vc_filter: vc_shortcode_content_filter_after - hook after template is loaded to override output
*
* @return mixed
* @throws \Exception
*/
protected function loadTemplate( $atts, $content = null ) {
$output = '';
if ( ! is_null( $content ) ) {
/** @var string $content */
$content = apply_filters( 'vc_shortcode_content_filter', $content, $this->shortcode );
}
$this->findShortcodeTemplate();
if ( $this->html_template && file_exists( $this->html_template ) ) {
if ( strpos( $this->html_template, WPB_PLUGIN_DIR ) === false ) {
// Modified or new
Vc_Modifications::$modified = true;
}
ob_start();
/** @var string $content - used inside template */
$output = require $this->html_template;
// Allow return in template files
if ( 1 === $output ) {
$output = ob_get_contents();
}
ob_end_clean();
}
return apply_filters( 'vc_shortcode_content_filter_after', $output, $this->shortcode, $atts, $content );
}
/**
* @param $atts
* @param $content
*
* @return string
* @throws \Exception
*/
public function contentAdmin( $atts, $content = null ) {
$output = $custom_markup = $width = $el_position = '';
if ( null !== $content ) {
$content = wpautop( stripslashes( $content ) );
}
$shortcode_attributes = array( 'width' => '1/1' );
$atts = vc_map_get_attributes( $this->getShortcode(), $atts ) + $shortcode_attributes;
$this->atts = $atts;
$elem = $this->getElementHolder( $width );
if ( isset( $this->settings['custom_markup'] ) && '' !== $this->settings['custom_markup'] ) {
$markup = $this->settings['custom_markup'];
$elem = str_ireplace( '%wpb_element_content%', $this->customMarkup( $markup, $content ), $elem );
$output .= $elem;
} else {
$inner = $this->outputTitle( $this->settings['name'] );
$inner .= $this->paramsHtmlHolders( $atts );
$elem = str_ireplace( '%wpb_element_content%', $inner, $elem );
$output .= $elem;
}
return $output;
}
/**
* @return bool
*/
public function isAdmin() {
return apply_filters( 'vc_shortcodes_is_admin', is_admin() );
}
/**
* @return bool
*/
public function isInline() {
return vc_is_inline();
}
/**
* @return bool
*/
public function isEditor() {
return vc_is_editor();
}
/**
* @param $atts
* @param null $content
* @param string $base
*
* vc_filter: vc_shortcode_output - hook to override output of shortcode
*
* @return string
* @throws \Exception
*/
public function output( $atts, $content = null, $base = '' ) {
$this->atts = $prepared_atts = $this->prepareAtts( $atts );
$this->shortcode_content = $content;
$output = '';
$content = empty( $content ) && ! empty( $atts['content'] ) ? $atts['content'] : $content;
if ( ( $this->isInline() || vc_is_page_editable() ) && method_exists( $this, 'contentInline' ) ) {
$output .= $this->contentInline( $this->atts, $content );
} else {
$this->enqueueDefaultScripts();
$custom_output = VC_SHORTCODE_CUSTOMIZE_PREFIX . $this->shortcode;
$custom_output_before = VC_SHORTCODE_BEFORE_CUSTOMIZE_PREFIX . $this->shortcode; // before shortcode function hook
$custom_output_after = VC_SHORTCODE_AFTER_CUSTOMIZE_PREFIX . $this->shortcode; // after shortcode function hook
// Before shortcode
if ( function_exists( $custom_output_before ) ) {
$output .= $custom_output_before( $this->atts, $content );
} else {
$output .= $this->beforeShortcode( $this->atts, $content );
}
// Shortcode content
if ( function_exists( $custom_output ) ) {
$output .= $custom_output( $this->atts, $content );
} else {
$output .= $this->content( $this->atts, $content );
}
// After shortcode
if ( function_exists( $custom_output_after ) ) {
$output .= $custom_output_after( $this->atts, $content );
} else {
$output .= $this->afterShortcode( $this->atts, $content );
}
}
// Filter for overriding outputs
$output = apply_filters( 'vc_shortcode_output', $output, $this, $prepared_atts, $this->shortcode );
return $output;
}
public function enqueueDefaultScripts() {
if ( false === self::$default_scripts_enqueued ) {
wp_enqueue_script( 'wpb_composer_front_js' );
wp_enqueue_style( 'js_composer_front' );
self::$default_scripts_enqueued = true;
}
}
/**
* Return shortcode attributes, see \WPBakeryShortCode::output
* @return array
* @since 4.4
*/
public function getAtts() {
return $this->atts;
}
/**
* Creates html before shortcode html.
*
* @param $atts - shortcode attributes list
* @param $content - shortcode content
*
* @return string - html which will be displayed before shortcode html.
*/
public function beforeShortcode( $atts, $content ) {
return '';
}
/**
* Creates html before shortcode html.
*
* @param $atts - shortcode attributes list
* @param $content - shortcode content
*
* @return string - html which will be displayed after shortcode html.
*/
public function afterShortcode( $atts, $content ) {
return '';
}
/**
* @param $el_class
*
* @return string
*/
public function getExtraClass( $el_class ) {
$output = '';
if ( '' !== $el_class ) {
$output = ' ' . str_replace( '.', '', $el_class );
}
return $output;
}
/**
* @param $css_animation
*
* @return string
*/
public function getCSSAnimation( $css_animation ) {
$output = '';
if ( '' !== $css_animation && 'none' !== $css_animation ) {
wp_enqueue_script( 'vc_waypoints' );
wp_enqueue_style( 'vc_animate-css' );
$output = ' wpb_animate_when_almost_visible wpb_' . $css_animation . ' ' . $css_animation;
}
return $output;
}
/**
* Create HTML comment for blocks only if wpb_debug=true
*
* @param $string
*
* @return string
* @deprecated 4.7 For debug type html comments use more generic debugComment function.
*
*/
public function endBlockComment( $string ) {
return '';
}
/**
* if wpb_debug=true return HTML comment
*
* @param string $comment
*
* @return string
* @since 4.7
* @deprecated 5.5 no need for extra info in output, use xdebug
*/
public function debugComment( $comment ) {
return '';
}
/**
* @param $name
*
* @return null
*/
public function settings( $name ) {
return isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : null;
}
/**
* @param $name
* @param $value
*/
public function setSettings( $name, $value ) {
$this->settings[ $name ] = $value;
}
/**
* @return mixed
* @since 5.5
*/
public function getSettings() {
return $this->settings;
}
/**
* @param $width
*
* @return string
* @throws \Exception
*/
public function getElementHolder( $width ) {
$output = '';
$column_controls = $this->getColumnControlsModular();
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? 'wpb_sortable' : $this->nonDraggableClass );
$css_class = 'wpb_' . $this->settings['base'] . ' wpb_content_element ' . $sortable . '' . ( ! empty( $this->settings['class'] ) ? ' ' . $this->settings['class'] : '' );
$output .= '<div data-element_type="' . $this->settings['base'] . '" class="' . $css_class . '">';
$output .= str_replace( '%column_size%', wpb_translateColumnWidthToFractional( $width ), $column_controls );
$output .= $this->getCallbacks( $this->shortcode );
$output .= '<div class="wpb_element_wrapper ' . $this->settings( 'wrapper_class' ) . '">';
$output .= '%wpb_element_content%';
$output .= '</div>';
$output .= '</div>';
return $output;
}
// Return block controls
/**
* @param $controls
* @param string $extended_css
*
* @return string
* @throws \Exception
*/
public function getColumnControls( $controls, $extended_css = '' ) {
$controls_start = '<div class="vc_controls controls_element' . ( ! empty( $extended_css ) ? " {$extended_css}" : '' ) . '">';
$controls_end = '</div>';
$controls_add = '';
$controls_edit = ' <a class="vc_control column_edit" href="javascript:;" title="' . sprintf( esc_attr__( 'Edit %s', 'js_composer' ), strtolower( $this->settings( 'name' ) ) ) . '"><span class="vc_icon"></span></a>';
$controls_delete = ' <a class="vc_control column_clone" href="javascript:;" title="' . sprintf( esc_attr__( 'Clone %s', 'js_composer' ), strtolower( $this->settings( 'name' ) ) ) . '"><span class="vc_icon"></span></a> <a class="column_delete" href="javascript:;" title="' . sprintf( esc_attr__( 'Delete %s', 'js_composer' ), strtolower( $this->settings( 'name' ) ) ) . '"><span class="vc_icon"></span></a>';
$column_controls_full = $controls_start . $controls_add . $controls_edit . $controls_delete . $controls_end;
$column_controls_size_delete = $controls_start . $controls_delete . $controls_end;
$column_controls_popup_delete = $controls_start . $controls_delete . $controls_end;
$column_controls_edit_popup_delete = $controls_start . $controls_edit . $controls_delete . $controls_end;
$column_controls_edit = $controls_start . $controls_edit . $controls_end;
$editAccess = vc_user_access_check_shortcode_edit( $this->shortcode );
$allAccess = vc_user_access_check_shortcode_all( $this->shortcode );
if ( 'popup_delete' === $controls ) {
return $allAccess ? $column_controls_popup_delete : '';
} elseif ( 'edit_popup_delete' === $controls ) {
return $allAccess ? $column_controls_edit_popup_delete : ( $editAccess ? $column_controls_edit : '' );
} elseif ( 'size_delete' === $controls ) {
return $allAccess ? $column_controls_size_delete : '';
} elseif ( 'add' === $controls ) {
return $allAccess ? ( $controls_start . $controls_add . $controls_end ) : '';
} else {
return $allAccess ? $column_controls_full : ( $editAccess ? $column_controls_edit : '' );
}
}
/**
* Return list of controls
* @return array
* @throws \Exception
*/
public function getControlsList() {
$editAccess = vc_user_access_check_shortcode_edit( $this->shortcode );
$allAccess = vc_user_access_check_shortcode_all( $this->shortcode );
if ( $allAccess ) {
return apply_filters( 'vc_wpbakery_shortcode_get_controls_list', $this->controls_list, $this->shortcode );
} else {
$controls = apply_filters( 'vc_wpbakery_shortcode_get_controls_list', $this->controls_list, $this->shortcode );
if ( $editAccess ) {
foreach ( $controls as $key => $value ) {
if ( 'edit' !== $value && 'add' !== $value ) {
unset( $controls[ $key ] );
}
}
return $controls;
} else {
return in_array( 'add', $controls, true ) ? array( 'add' ) : array();
}
}
}
/**
* Build new modern controls for shortcode.
*
* @param string $extended_css
*
* @return string
* @throws \Exception
*/
public function getColumnControlsModular( $extended_css = '' ) {
ob_start();
vc_include_template( apply_filters( 'vc_wpbakery_shortcode_get_column_controls_modular_template', $this->controls_template_file ), array(
'shortcode' => $this->shortcode,
'position' => $this->controls_css_settings,
'extended_css' => $extended_css,
'name' => $this->settings( 'name' ),
'controls' => $this->getControlsList(),
'name_css_class' => $this->getBackendEditorControlsElementCssClass(),
'add_allowed' => $this->getAddAllowed(),
) );
return ob_get_clean();
}
/**
* @return string
* @throws \Exception
*/
public function getBackendEditorControlsElementCssClass() {
$moveAccess = vc_user_access()->part( 'dragndrop' )->checkStateAny( true, null )->get();
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) && $moveAccess ? ' vc_element-move' : ' ' . $this->nonDraggableClass );
return 'vc_control-btn vc_element-name' . $sortable;
}
/**
* This will fire callbacks if they are defined in map.php
*
* @param $id
*
* @return string
*/
public function getCallbacks( $id ) {
$output = '';
if ( isset( $this->settings['js_callback'] ) ) {
foreach ( $this->settings['js_callback'] as $text_val => $val ) {
// TODO: name explain
$output .= '<input type="hidden" class="wpb_vc_callback wpb_vc_' . esc_attr( $text_val ) . '_callback " name="' . esc_attr( $text_val ) . '" value="' . $val . '" />';
}
}
return $output;
}
/**
* @param $param
* @param $value
*
* vc_filter: vc_wpbakeryshortcode_single_param_html_holder_value - hook to override param value (param type and etc is available in args)
*
* @return string
*/
public function singleParamHtmlHolder( $param, $value ) {
$value = apply_filters( 'vc_wpbakeryshortcode_single_param_html_holder_value', $value, $param, $this->settings, $this->atts );
$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 ( ! empty( $param['holder'] ) ) {
if ( 'input' === $param['holder'] ) {
$output .= '<' . $param['holder'] . ' readonly="true" class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" value="' . $value . '">';
} elseif ( in_array( $param['holder'], array(
'img',
'iframe',
), true ) ) {
$output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" src="' . esc_url( $value ) . '">';
} elseif ( 'hidden' !== $param['holder'] ) {
$output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '">' . $value . '</' . $param['holder'] . '>';
}
}
if ( ! empty( $param['admin_label'] ) && true === $param['admin_label'] ) {
$output .= '<span class="vc_admin_label admin_label_' . $param['param_name'] . ( empty( $value ) ? ' hidden-label' : '' ) . '"><label>' . $param['heading'] . '</label>: ' . $value . '</span>';
}
return $output;
}
/**
* @param $params
*
* @return string
*/
protected function getIcon( $params ) {
$data = '';
if ( isset( $params['is_container'] ) && true === $params['is_container'] ) {
$data = ' data-is-container="true"';
}
$title = '';
if ( isset( $params['title'] ) ) {
$title = 'title="' . esc_attr( $params['title'] ) . '" ';
}
return '<i ' . $title . 'class="vc_general vc_element-icon' . ( ! empty( $params['icon'] ) ? ' ' . sanitize_text_field( $params['icon'] ) : '' ) . '"' . $data . '></i> ';
}
/**
* @param $title
*
* @return string
*/
protected function outputTitle( $title ) {
$icon = $this->settings( 'icon' );
if ( filter_var( $icon, FILTER_VALIDATE_URL ) ) {
$icon = '';
}
$params = array(
'icon' => $icon,
'is_container' => $this->settings( 'is_container' ),
);
return '<h4 class="wpb_element_title"> ' . $this->getIcon( $params ) . esc_attr( $title ) . '</h4>';
}
/**
* @param string $content
*
* @return string
* @throws \Exception
*/
public function template( $content = '' ) {
return $this->contentAdmin( $this->atts, $content );
}
/**
* This functions prepares attributes to use in template
* Converts back escaped characters
*
* @param $atts
*
* @return array
*/
protected function prepareAtts( $atts ) {
$returnAttributes = array();
if ( is_array( $atts ) ) {
foreach ( $atts as $key => $val ) {
$returnAttributes[ $key ] = str_replace( array(
'`{`',
'`}`',
'``',
), array(
'[',
']',
'"',
), $val );
}
}
return apply_filters( 'vc_shortcode_prepare_atts', $returnAttributes, $this->shortcode, $this->settings );
}
/**
* @return string
*/
public function getShortcode() {
return $this->shortcode;
}
/**
* Since 4.5
* Possible placeholders:
* {{ content }}
* {{ title }}
* {{ container-class }}
*
* Possible keys:
* {{
* <%
* %
* @param $markup
* @param string $content
*
* @return string
* @throws \Exception
* @since 4.5
*/
protected function customMarkup( $markup, $content = '' ) {
$pattern = '/\{\{([\s\S][^\n]+?)\}\}|<%([\s\S][^\n]+?)%>|%([\s\S][^\n]+?)%/';
preg_match_all( $pattern, $markup, $matches, PREG_SET_ORDER );
if ( is_array( $matches ) && ! empty( $matches ) ) {
foreach ( $matches as $match ) {
switch ( strtolower( trim( $match[1] ) ) ) {
case 'content':
if ( '' !== $content ) {
$markup = str_replace( $match[0], $content, $markup );
} elseif ( isset( $this->settings['default_content_in_template'] ) && '' !== $this->settings['default_content_in_template'] ) {
$markup = str_replace( $match[0], $this->settings['default_content_in_template'], $markup );
} else {
$markup = str_replace( $match[0], '', $markup );
}
break;
case 'title':
$markup = str_replace( $match[0], $this->outputTitle( $this->settings['name'] ), $markup );
break;
case 'container-class':
if ( method_exists( $this, 'containerContentClass' ) ) {
$markup = str_replace( $match[0], $this->containerContentClass(), $markup );
} else {
$markup = str_replace( $match[0], '', $markup );
}
break;
case 'editor_controls':
$markup = str_replace( $match[0], $this->getColumnControls( $this->settings( 'controls' ) ), $markup );
break;
case 'editor_controls_bottom_add':
$markup = str_replace( $match[0], $this->getColumnControls( 'add', 'bottom-controls' ), $markup );
break;
}
}
}
return do_shortcode( $markup );
}
/**
* @param $atts
*
* @return string
*/
protected function paramsHtmlHolders( $atts ) {
$inner = '';
if ( isset( $this->settings['params'] ) && is_array( $this->settings['params'] ) ) {
foreach ( $this->settings['params'] as $param ) {
$param_value = isset( $atts[ $param['param_name'] ] ) ? $atts[ $param['param_name'] ] : '';
$inner .= $this->singleParamHtmlHolder( $param, $param_value );
}
}
return $inner;
}
/**
* Check is allowed to add another element inside current element.
*
* @return bool
* @since 4.8
*
*/
public function getAddAllowed() {
return true;
}
}

View File

@@ -0,0 +1,182 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCodesContainer
*/
abstract class WPBakeryShortCodesContainer extends WPBakeryShortCode {
/**
* @var array
*/
protected $predefined_atts = array();
protected $backened_editor_prepend_controls = true;
/**
* @return string
*/
public function customAdminBlockParams() {
return '';
}
/**
* @param $width
* @param $i
*
* @return string
* @throws \Exception
*/
public function mainHtmlBlockParams( $width, $i ) {
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? 'wpb_sortable' : $this->nonDraggableClass );
return 'data-element_type="' . esc_attr( $this->settings['base'] ) . '" class="wpb_' . esc_attr( $this->settings['base'] ) . ' ' . esc_attr( $sortable ) . '' . ( ! empty( $this->settings['class'] ) ? ' ' . esc_attr( $this->settings['class'] ) : '' ) . ' wpb_content_holder vc_shortcodes_container"' . $this->customAdminBlockParams();
}
/**
* @param $width
* @param $i
*
* @return string
*/
public function containerHtmlBlockParams( $width, $i ) {
return 'class="' . $this->containerContentClass() . '"';
}
/**
*
* @return string
*/
public function containerContentClass() {
return 'wpb_column_container vc_container_for_children vc_clearfix';
}/** @noinspection PhpMissingParentCallCommonInspection */
/**
* @param string $controls
* @param string $extended_css
*
* @return string
* @throws \Exception
*/
public function getColumnControls( $controls = 'full', $extended_css = '' ) {
$controls_html = array();
$controls_html['start'] = '<div class="vc_controls vc_controls-visible controls_column' . ( ! empty( $extended_css ) ? " {$extended_css}" : '' ) . '">';
$controls_html['end'] = '</div>';
if ( 'bottom-controls' === $extended_css ) {
$controls_html['title'] = sprintf( esc_attr__( 'Append to this %s', 'js_composer' ), strtolower( $this->settings( 'name' ) ) );
} else {
$controls_html['title'] = sprintf( esc_attr__( 'Prepend to this %s', 'js_composer' ), strtolower( $this->settings( 'name' ) ) );
}
$controls_html['move'] = '<a class="vc_control column_move vc_column-move" data-vc-control="move" href="#" title="' . sprintf( esc_attr__( 'Move this %s', 'js_composer' ), strtolower( $this->settings( 'name' ) ) ) . '"><i class="vc-composer-icon vc-c-icon-dragndrop"></i></a>';
$moveAccess = vc_user_access()->part( 'dragndrop' )->checkStateAny( true, null )->get();
if ( ! $moveAccess ) {
$controls_html['move'] = '';
}
$controls_html['add'] = '<a class="vc_control column_add" data-vc-control="add" href="#" title="' . $controls_html['title'] . '"><i class="vc-composer-icon vc-c-icon-add"></i></a>';
$controls_html['edit'] = '<a class="vc_control column_edit" data-vc-control="edit" href="#" title="' . sprintf( esc_html__( 'Edit this %s', 'js_composer' ), strtolower( $this->settings( 'name' ) ) ) . '"><i class="vc-composer-icon vc-c-icon-mode_edit"></i></a>';
$controls_html['clone'] = '<a class="vc_control column_clone" data-vc-control="clone" href="#" title="' . sprintf( esc_html__( 'Clone this %s', 'js_composer' ), strtolower( $this->settings( 'name' ) ) ) . '"><i class="vc-composer-icon vc-c-icon-content_copy"></i></a>';
$controls_html['delete'] = '<a class="vc_control column_delete" data-vc-control="delete" href="#" title="' . sprintf( esc_html__( 'Delete this %s', 'js_composer' ), strtolower( $this->settings( 'name' ) ) ) . '"><i class="vc-composer-icon vc-c-icon-delete_empty"></i></a>';
$controls_html['full'] = $controls_html['move'] . $controls_html['add'] . $controls_html['edit'] . $controls_html['clone'] . $controls_html['delete'];
$editAccess = vc_user_access_check_shortcode_edit( $this->shortcode );
$allAccess = vc_user_access_check_shortcode_all( $this->shortcode );
if ( ! empty( $controls ) ) {
if ( is_string( $controls ) ) {
$controls = array( $controls );
}
$controls_string = $controls_html['start'];
foreach ( $controls as $control ) {
if ( ( $editAccess && 'edit' === $control ) || $allAccess ) {
if ( isset( $controls_html[ $control ] ) ) {
$controls_string .= $controls_html[ $control ];
}
}
}
return $controls_string . $controls_html['end'];
}
if ( $allAccess ) {
return $controls_html['start'] . $controls_html['full'] . $controls_html['end'];
} elseif ( $editAccess ) {
return $controls_html['start'] . $controls_html['edit'] . $controls_html['end'];
}
return $controls_html['start'] . $controls_html['end'];
}
/**
* @param $atts
* @param null $content
*
* @return string
* @throws \Exception
*/
public function contentAdmin( $atts, $content = null ) {
$width = '';
$atts = shortcode_atts( $this->predefined_atts, $atts );
extract( $atts );
$this->atts = $atts;
$output = '';
$output .= '<div ' . $this->mainHtmlBlockParams( $width, 1 ) . '>';
if ( $this->backened_editor_prepend_controls ) {
$output .= $this->getColumnControls( $this->settings( 'controls' ) );
}
$output .= '<div class="wpb_element_wrapper">';
if ( isset( $this->settings['custom_markup'] ) && '' !== $this->settings['custom_markup'] ) {
$markup = $this->settings['custom_markup'];
$output .= $this->customMarkup( $markup );
} else {
$output .= $this->outputTitle( $this->settings['name'] );
$output .= '<div ' . $this->containerHtmlBlockParams( $width, 1 ) . '>';
$output .= do_shortcode( shortcode_unautop( $content ) );
$output .= '</div>';
$output .= $this->paramsHtmlHolders( $atts );
}
$output .= '</div>';
if ( $this->backened_editor_prepend_controls ) {
$output .= $this->getColumnControls( 'add', 'bottom-controls' );
}
$output .= '</div>';
return $output;
}
/**
* @param $title
*
* @return string
*/
protected function outputTitle( $title ) {
$icon = $this->settings( 'icon' );
if ( filter_var( $icon, FILTER_VALIDATE_URL ) ) {
$icon = '';
}
$params = array(
'icon' => $icon,
'is_container' => $this->settings( 'is_container' ),
'title' => $title,
);
return '<h4 class="wpb_element_title"> ' . $this->getIcon( $params ) . '</h4>';
}
/**
* @return string
*/
/**
* @return string
*/
public function getBackendEditorChildControlsElementCssClass() {
return 'vc_element-name';
}
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Layerslider_Vc
*/
class WPBakeryShortCode_Layerslider_Vc extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,133 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class Vc_Pageable
*/
class WPBakeryShortCode_Vc_Pageable extends WPBakeryShortCode {
/**
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->shortcodeScripts();
}
/**
* Register scripts and styles for pager
*/
public function shortcodeScripts() {
wp_register_script( 'vc_pageable_owl-carousel', vc_asset_url( 'lib/owl-carousel2-dist/owl.carousel.min.js' ), array(
'jquery',
), WPB_VC_VERSION, true );
wp_register_script( 'vc_waypoints', vc_asset_url( 'lib/vc_waypoints/vc-waypoints.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_style( 'vc_pageable_owl-carousel-css', vc_asset_url( 'lib/owl-carousel2-dist/assets/owl.min.css' ), array(), WPB_VC_VERSION );
}
/**
* @param $grid_style
* @param $settings
* @param $content
*
* @return string
*/
protected function contentAll( $grid_style, $settings, $content ) {
return '<div class="vc_pageable-slide-wrapper vc_clearfix" data-vc-grid-content="true">' . $content . '</div>';
}
/**
* @param $grid_style
* @param $settings
* @param $content
*
* @return string
*/
protected function contentLoadMore( $grid_style, $settings, $content ) {
if ( ! isset( $settings['btn_data'] ) && isset( $settings['button_style'] ) && isset( $settings['button_size'] ) && isset( $settings['button_color'] ) ) {
// BC: for those who overrided
$output = sprintf( '<div class="vc_pageable-slide-wrapper vc_clearfix" data-vc-grid-content="true">%s</div><div class="vc_pageable-load-more-btn" data-vc-grid-load-more-btn="true">%s</div>', $content, do_shortcode( '[vc_button2 size="' . $settings['button_size'] . '" title="' . esc_attr__( 'Load more', 'js_composer' ) . '" style="' . $settings['button_style'] . '" color="' . $settings['button_color'] . '" el_class="vc_grid-btn-load_more"]' ) );
return $output;
} elseif ( isset( $settings['btn_data'] ) ) {
$data = $settings['btn_data'];
$data['el_class'] = 'vc_grid-btn-load_more';
$data['link'] = 'load-more-grid';
$button3 = new WPBakeryShortCode_Vc_Btn( array( 'base' => 'vc_btn' ) );
$output = sprintf( '<div class="vc_pageable-slide-wrapper vc_clearfix" data-vc-grid-content="true">%s</div><div class="vc_pageable-load-more-btn" data-vc-grid-load-more-btn="true">%s</div>', $content, apply_filters( 'vc_gitem_template_attribute_vc_btn', '', array(
'post' => new stdClass(),
'data' => str_replace( array(
'{{ vc_btn:',
'}}',
), '', $button3->output( $data ) ),
) ) );
return $output;
}
return '';
}
/**
* @param $grid_style
* @param $settings
* @param $content
*
* @return string
*/
protected function contentLazy( $grid_style, $settings, $content ) {
return '<div class="vc_pageable-slide-wrapper vc_clearfix" data-vc-grid-content="true">' . $content . '</div><div data-lazy-loading-btn="true" style="display: none;"><a href="' . esc_url( get_permalink( $settings['page_id'] ) ) . '"></a></div>';
}
/**
* @param $grid_style
* @param $settings
* @param string $content
*
* @param string $css_class
*
* @return string
*/
public function renderPagination( $grid_style, $settings, $content = '', $css_class = '' ) {
$css_class .= empty( $css_class ) ? '' : ' vc_pageable-wrapper vc_hook_hover';
$content_method = vc_camel_case( 'content-' . $grid_style );
$content = method_exists( $this, $content_method ) ? $this->$content_method( $grid_style, $settings, $content ) : $content;
$output = '<div class="' . esc_attr( $css_class ) . '" data-vc-pageable-content="true">' . $content . '</div>';
return $output;
}
public function enqueueScripts() {
wp_enqueue_script( 'vc_pageable_owl-carousel' );
wp_enqueue_style( 'vc_pageable_owl-carousel-css' );
wp_enqueue_style( 'vc_animate-css' );
}
/**
* Check is pageable
* @return bool
* @since 4.7.4
*/
public function isObjectPageable() {
return true;
}
/**
* Check can user manage post.
*
* @param int $page_id
*
* @return bool
*/
public function currentUserCanManage( $page_id ) {
return vc_user_access()->wpAny( array(
'edit_post',
(int) $page_id,
) )->get();
}
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Rev_Slider_Vc
*/
class WPBakeryShortCode_Rev_Slider_Vc extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,151 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-tab.php' );
/**
* Class WPBakeryShortCode_VC_Accordion_tab
*/
class WPBakeryShortCode_VC_Accordion_Tab extends WPBakeryShortCode_VC_Tab {
/**
* @var string
*/
protected $controls_css_settings = 'tc vc_control-container';
/**
* @var array
*/
protected $controls_list = array(
'add',
'edit',
'clone',
'delete',
);
/**
* @var string
*/
public $nonDraggableClass = 'vc-non-draggable-container';
/**
* @param $atts
* @param null $content
* @return string
* @throws \Exception
*/
public function contentAdmin( $atts, $content = null ) {
$width = '';
// @codingStandardsIgnoreLine
extract( vc_map_get_attributes( $this->getShortcode(), $atts ) );
$output = '';
$column_controls = $this->getColumnControls( $this->settings( 'controls' ) );
$column_controls_bottom = $this->getColumnControls( 'add', 'bottom-controls' );
if ( 'column_14' === $width || '1/4' === $width ) {
$width = array( 'vc_col-sm-3' );
} elseif ( 'column_14-14-14-14' === $width ) {
$width = array(
'vc_col-sm-3',
'vc_col-sm-3',
'vc_col-sm-3',
'vc_col-sm-3',
);
} elseif ( 'column_13' === $width || '1/3' === $width ) {
$width = array( 'vc_col-sm-4' );
} elseif ( 'column_13-23' === $width ) {
$width = array(
'vc_col-sm-4',
'vc_col-sm-8',
);
} elseif ( 'column_13-13-13' === $width ) {
$width = array(
'vc_col-sm-4',
'vc_col-sm-4',
'vc_col-sm-4',
);
} elseif ( 'column_12' === $width || '1/2' === $width ) {
$width = array( 'vc_col-sm-6' );
} elseif ( 'column_12-12' === $width ) {
$width = array(
'vc_col-sm-6',
'vc_col-sm-6',
);
} elseif ( 'column_23' === $width || '2/3' === $width ) {
$width = array( 'vc_col-sm-8' );
} elseif ( 'column_34' === $width || '3/4' === $width ) {
$width = array( 'vc_col-sm-9' );
} elseif ( 'column_16' === $width || '1/6' === $width ) {
$width = array( 'vc_col-sm-2' );
} else {
$width = array( '' );
}
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? 'wpb_sortable' : $this->nonDraggableClass );
$count = count( $width );
for ( $i = 0; $i < $count; $i ++ ) {
$output .= '<div class="group ' . $sortable . '">';
$output .= '<h3><span class="tab-label"><%= params.title %></span></h3>';
$output .= '<div ' . $this->mainHtmlBlockParams( $width, $i ) . '>';
$output .= str_replace( '%column_size%', wpb_translateColumnWidthToFractional( $width[ $i ] ), $column_controls );
$output .= '<div class="wpb_element_wrapper">';
$output .= '<div ' . $this->containerHtmlBlockParams( $width, $i ) . '>';
$output .= do_shortcode( shortcode_unautop( $content ) );
$output .= '</div>';
if ( isset( $this->settings['params'] ) ) {
$inner = '';
foreach ( $this->settings['params'] as $param ) {
$param_value = isset( ${$param['param_name']} ) ? ${$param['param_name']} : '';
if ( is_array( $param_value ) ) {
// Get first element from the array
reset( $param_value );
$first_key = key( $param_value );
$param_value = $param_value[ $first_key ];
}
$inner .= $this->singleParamHtmlHolder( $param, $param_value );
}
$output .= $inner;
}
$output .= '</div>';
$output .= str_replace( '%column_size%', wpb_translateColumnWidthToFractional( $width[ $i ] ), $column_controls_bottom );
$output .= '</div>';
$output .= '</div>';
}
return $output;
}
/**
* @param $width
* @param $i
* @return string
*/
public function mainHtmlBlockParams( $width, $i ) {
return 'data-element_type="' . esc_attr( $this->settings['base'] ) . '" class=" wpb_' . esc_attr( $this->settings['base'] ) . '"' . $this->customAdminBlockParams();
}
/**
* @param $width
* @param $i
* @return string
*/
public function containerHtmlBlockParams( $width, $i ) {
return 'class="wpb_column_container vc_container_for_children"';
}
/**
* @param $title
* @return string
*/
protected function outputTitle( $title ) {
return '';
}
/**
* @return string
*/
public function customAdminBlockParams() {
return '';
}
}

View File

@@ -0,0 +1,63 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder shortcodes
*
* @package WPBakeryPageBuilder
*
*/
class WPBakeryShortCode_Vc_Accordion extends WPBakeryShortCode {
protected $controls_css_settings = 'out-tc vc_controls-content-widget';
/**
* @param $atts
* @param null $content
* @return mixed|string
* @throws \Exception
*/
public function contentAdmin( $atts, $content = null ) {
$width = $custom_markup = '';
$shortcode_attributes = array( 'width' => '1/1' );
foreach ( $this->settings['params'] as $param ) {
if ( 'content' !== $param['param_name'] ) {
$shortcode_attributes[ $param['param_name'] ] = isset( $param['value'] ) ? $param['value'] : null;
} elseif ( 'content' === $param['param_name'] && null === $content ) {
$content = $param['value'];
}
}
extract( shortcode_atts( $shortcode_attributes, $atts ) );
$elem = $this->getElementHolder( $width );
$inner = '';
foreach ( $this->settings['params'] as $param ) {
$param_value = isset( ${$param['param_name']} ) ? ${$param['param_name']} : '';
if ( is_array( $param_value ) ) {
// Get first element from the array
reset( $param_value );
$first_key = key( $param_value );
$param_value = $param_value[ $first_key ];
}
$inner .= $this->singleParamHtmlHolder( $param, $param_value );
}
$tmp = '';
if ( isset( $this->settings['custom_markup'] ) && '' !== $this->settings['custom_markup'] ) {
if ( '' !== $content ) {
$custom_markup = str_ireplace( '%content%', $tmp . $content, $this->settings['custom_markup'] );
} elseif ( '' === $content && isset( $this->settings['default_content_in_template'] ) && '' !== $this->settings['default_content_in_template'] ) {
$custom_markup = str_ireplace( '%content%', $this->settings['default_content_in_template'], $this->settings['custom_markup'] );
} else {
$custom_markup = str_ireplace( '%content%', '', $this->settings['custom_markup'] );
}
$inner .= do_shortcode( $custom_markup );
}
$output = str_ireplace( '%wpb_element_content%', $inner, $elem );
return $output;
}
}

View File

@@ -0,0 +1,588 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'paginator/class-vc-pageable.php' );
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-btn.php' );
/**
* Class WPBakeryShortCode_Vc_Basic_Grid
*/
class WPBakeryShortCode_Vc_Basic_Grid extends WPBakeryShortCode_Vc_Pageable {
public $pagable_type = 'grid';
public $items = array();
public static $excluded_ids = array();
protected $element_template = '';
protected static $default_max_items = 1000;
public $post_id = false;
/** @var \Vc_Grid_Item $grid_item */
public $grid_item = false;
protected $filter_terms;
public $attributes_defaults = array(
'initial_loading_animation' => 'zoomIn',
'full_width' => '',
'layout' => '',
'element_width' => '4',
'items_per_page' => '5',
'gap' => '',
'style' => 'all',
'show_filter' => '',
'filter_default_title' => 'all',
'exclude_filter' => '',
'filter_style' => '',
'filter_size' => 'md',
'filter_align' => '',
'filter_color' => '',
'arrows_design' => '',
'arrows_position' => '',
'arrows_color' => '',
'paging_design' => '',
'paging_color' => '',
'paging_animation_in' => '',
'paging_animation_out' => '',
'loop' => '',
'autoplay' => '',
'post_type' => 'post',
'filter_source' => 'category',
'orderby' => '',
'order' => 'DESC',
// @codingStandardsIgnoreLine
'meta_key' => '',
'max_items' => '10',
'offset' => '0',
'taxonomies' => '',
'custom_query' => '',
'data_type' => 'query',
'include' => '',
'exclude' => '',
'item' => 'none',
'grid_id' => '',
// disabled, needed for-BC:
'button_style' => '',
'button_color' => '',
'button_size' => '',
// New button3:
'btn_title' => '',
'btn_style' => 'modern',
'btn_el_id' => '',
'btn_custom_background' => '#ededed',
'btn_custom_text' => '#666',
'btn_outline_custom_color' => '#666',
'btn_outline_custom_hover_background' => '#666',
'btn_outline_custom_hover_text' => '#fff',
'btn_shape' => 'rounded',
'btn_color' => 'blue',
'btn_size' => 'md',
'btn_align' => 'inline',
'btn_button_block' => '',
'btn_add_icon' => '',
'btn_i_align' => 'left',
'btn_i_type' => 'fontawesome',
'btn_i_icon_fontawesome' => 'fa fa-adjust',
'btn_i_icon_openiconic' => 'vc-oi vc-oi-dial',
'btn_i_icon_typicons' => 'typcn typcn-adjust-brightness',
'btn_i_icon_entypo' => 'entypo-icon entypo-icon-note',
'btn_i_icon_linecons' => 'vc_li vc_li-heart',
'btn_i_icon_pixelicons' => 'vc_pixel_icon vc_pixel_icon-alert',
'btn_custom_onclick' => '',
'btn_custom_onclick_code' => '',
// fix template
'page_id' => '',
);
protected $grid_settings = array();
protected $grid_id_unique_name = 'vc_gid'; // if you change this also change in hook-vc-grid.php
/**
* @var \WP_Query
*/
protected $query;
/**
* WPBakeryShortCode_Vc_Basic_Grid constructor.
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->attributes_defaults['btn_title'] = esc_html__( 'Load more', 'js_composer' );
$this->shortcodeScripts();
}
public function shortcodeScripts() {
parent::shortcodeScripts();
wp_register_script( 'vc_grid-js-imagesloaded', vc_asset_url( 'lib/bower/imagesloaded/imagesloaded.pkgd.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'vc_grid', vc_asset_url( 'js/dist/vc_grid.min.js' ), array(
'jquery',
'underscore',
'vc_pageable_owl-carousel',
'vc_waypoints',
// 'isotope',
'vc_grid-js-imagesloaded',
), WPB_VC_VERSION, true );
}
public function enqueueScripts() {
parent::enqueueScripts();
wp_enqueue_script( 'vc_grid-js-imagesloaded' );
wp_enqueue_script( 'vc_grid' );
}
/**
* @param $id
*/
public static function addExcludedId( $id ) {
self::$excluded_ids[] = $id;
}
/**
* @return array
*/
public static function excludedIds() {
return self::$excluded_ids;
}
/**
* @param $atts
* @param $content
* @return false|mixed|string|void
*/
public function getId( $atts, $content ) {
if ( vc_is_page_editable() || is_preview() ) {
/*
* We are in Frontend editor
* We need to send RAW shortcode data, so hash is just json_encode of atts and content
*/
return rawurlencode( wp_json_encode( array(
'tag' => $this->shortcode,
'atts' => $atts,
'content' => $content,
) ) );
}
$id_pattern = '/' . $this->grid_id_unique_name . '\:([\w\-_]+)/';
$id_value = isset( $atts['grid_id'] ) ? $atts['grid_id'] : '';
preg_match( $id_pattern, $id_value, $id_matches );
$id_to_save = wp_json_encode( array( 'failed_to_get_id' => esc_attr( $id_value ) ) );
if ( ! empty( $id_matches ) ) {
$id_to_save = $id_matches[1];
}
return $id_to_save;
}
/**
* @param $page_id
* @param $grid_id
* @return array|mixed|object|void
*/
public function findPostShortcodeById( $page_id, $grid_id ) {
if ( $this->currentUserCanManage( $page_id ) && preg_match( '/\"tag\"\:/', urldecode( $grid_id ) ) ) {
return json_decode( urldecode( $grid_id ), true ); // if frontend, no hash exists - just RAW data
}
$post_meta = get_post_meta( (int) $page_id, '_vc_post_settings' );
$shortcode = false;
if ( is_array( $post_meta ) ) {
foreach ( $post_meta as $meta ) {
if ( isset( $meta['vc_grid_id'] ) && ! empty( $meta['vc_grid_id']['shortcodes'] ) && isset( $meta['vc_grid_id']['shortcodes'][ $grid_id ] ) ) {
$shortcode = $meta['vc_grid_id']['shortcodes'][ $grid_id ];
break;
}
}
}
return apply_filters( 'vc_basic_grid_find_post_shortcode', $shortcode, $page_id, $grid_id );
}
/**
* @return string
* @throws \Exception
*/
public function renderItems() {
$output = '';
$items = '';
$this->buildGridSettings();
$atts = $this->atts;
$settings = $this->grid_settings;
$filter_terms = $this->filter_terms;
$is_end = isset( $this->is_end ) && $this->is_end;
$css_classes = 'vc_grid vc_row' . esc_attr( $atts['gap'] > 0 ? ' vc_grid-gutter-' . (int) $atts['gap'] . 'px' : '' );
$currentScope = WPBMap::getScope();
if ( is_array( $this->items ) && ! empty( $this->items ) ) {
// Adding before vc_map
WPBMap::setScope( Vc_Grid_Item_Editor::postType() );
require_once vc_path_dir( 'PARAMS_DIR', 'vc_grid_item/class-vc-grid-item.php' );
$this->grid_item = new Vc_Grid_Item();
$this->grid_item->setGridAttributes( $atts );
$this->grid_item->setIsEnd( $is_end );
$this->grid_item->setTemplateById( $atts['item'] );
$output .= $this->grid_item->addShortcodesCustomCss();
ob_start();
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
wp_print_styles();
}
$output .= ob_get_clean();
$attributes = array(
'filter_terms' => $filter_terms,
'atts' => $atts,
'grid_item',
$this->grid_item,
);
$output .= apply_filters( 'vc_basic_grid_template_filter', vc_get_template( 'shortcodes/vc_basic_grid_filter.php', $attributes ), $attributes );
global $post;
$backup = $post;
foreach ( $this->items as $postItem ) {
$this->query->setup_postdata( $postItem );
// @codingStandardsIgnoreLine
$post = $postItem;
$items .= $this->grid_item->renderItem( $postItem );
}
wp_reset_postdata();
$post = $backup;
} else {
return '';
}
$items = apply_filters( $this->shortcode . '_items_list', $items );
$output .= $this->renderPagination( $atts['style'], $settings, $items, $css_classes );
WPBMap::setScope( $currentScope );
return $output;
}
public function setContentLimits() {
$atts = $this->atts;
if ( 'ids' === $this->atts['post_type'] ) {
$this->atts['max_items'] = 0;
$this->atts['offset'] = 0;
$this->atts['items_per_page'] = apply_filters( 'vc_basic_grid_max_items', self::$default_max_items );
} else {
$offset = isset( $atts['offset'] ) ? (int) $atts['offset'] : $this->attributes_defaults['offset'];
$this->atts['offset'] = $offset;
$this->atts['max_items'] = isset( $atts['max_items'] ) ? (int) $atts['max_items'] : (int) $this->attributes_defaults['max_items'];
$this->atts['items_per_page'] = ! isset( $atts['items_per_page'] ) ? (int) $this->attributes_defaults['items_per_page'] : (int) $atts['items_per_page'];
if ( $this->atts['max_items'] < 1 ) {
$this->atts['max_items'] = apply_filters( 'vc_basic_grid_max_items', self::$default_max_items );
}
}
$this->setPagingAll( $this->atts['max_items'] );
}
/**
* @param $max_items
*/
protected function setPagingAll( $max_items ) {
$atts = $this->atts;
$this->atts['query_items_per_page'] = $max_items > 0 ? $max_items : apply_filters( 'vc_basic_grid_items_per_page_all_max_items', self::$default_max_items );
$this->atts['items_per_page'] = $this->atts['query_items_per_page'];
$this->atts['query_offset'] = isset( $atts['offset'] ) ? (int) $atts['offset'] : $this->attributes_defaults['offset'];
}
/**
* @param $vc_request_param
* @return false|mixed|string|void
* @throws \Exception
*/
public function renderAjax( $vc_request_param ) {
$this->items = array(); // clear this items array (if used more than once);
$id = isset( $vc_request_param['shortcode_id'] ) ? $vc_request_param['shortcode_id'] : false;
$shortcode = false;
if ( ! isset( $vc_request_param['page_id'] ) ) {
return wp_json_encode( array( 'status' => 'Nothing found' ) );
}
if ( $id ) {
$shortcode = $this->findPostShortcodeById( $vc_request_param['page_id'], $id );
}
if ( ! is_array( $shortcode ) ) {
return wp_json_encode( array( 'status' => 'Nothing found' ) );
}
visual_composer()->registerAdminCss();
visual_composer()->registerAdminJavascript();
// Set post id
$this->post_id = (int) $vc_request_param['page_id'];
$shortcode_atts = $shortcode['atts'];
$this->shortcode_content = $shortcode['content'];
$this->buildAtts( $shortcode_atts, $shortcode['content'] );
$this->buildItems();
return $this->renderItems();
}
/**
* @return bool|false|int
*/
public function postID() {
if ( ! $this->post_id ) {
$this->post_id = get_the_ID();
}
return $this->post_id;
}
/**
* @param $atts
* @param $content
* @throws \Exception
*/
public function buildAtts( $atts, $content ) {
$this->post_id = false;
$this->grid_settings = array();
$this->filter_terms = null;
$this->items = array();
$arr_keys = array_keys( $atts );
$count = count( $atts );
for ( $i = 0; $i < $count; $i ++ ) {
$atts[ $arr_keys[ $i ] ] = html_entity_decode( $atts[ $arr_keys[ $i ] ], ENT_QUOTES, 'utf-8' );
}
if ( isset( $atts['grid_id'] ) && ! empty( $atts['grid_id'] ) ) {
$id_to_save = $this->getId( $atts, $content );
}
$atts = $this->convertButton2ToButton3( $atts );
$atts = shortcode_atts( $this->attributes_defaults, vc_map_get_attributes( $this->getShortcode(), $atts ) );
$this->atts = $atts;
if ( isset( $id_to_save ) ) {
$this->atts['shortcode_id'] = $id_to_save;
}
$this->atts['page_id'] = $this->postID();
$this->element_template = $content;
// @since 4.4.3
if ( 'custom' === $this->attr( 'post_type' ) ) {
$this->atts['style'] = 'all';
}
}
/**
* Getter attribute.
*
* @param $key
*
* @return mixed|null
*/
public function attr( $key ) {
return isset( $this->atts[ $key ] ) ? $this->atts[ $key ] : null;
}
public function buildGridSettings() {
$this->grid_settings = array(
'page_id' => $this->atts['page_id'],
// used in basic grid for initialization
'style' => $this->atts['style'],
'action' => 'vc_get_vc_grid_data',
);
// used in ajax request for items
if ( isset( $this->atts['shortcode_id'] ) && ! empty( $this->atts['shortcode_id'] ) ) {
$this->grid_settings['shortcode_id'] = $this->atts['shortcode_id'];
} elseif ( isset( $this->atts['shortcode_hash'] ) && ! empty( $this->atts['shortcode_hash'] ) ) {
// @deprecated since 4.4.3
$this->grid_settings['shortcode_hash'] = $this->atts['shortcode_hash'];
}
if ( 'load-more' === $this->atts['style'] ) {
$this->grid_settings = array_merge( $this->grid_settings, array(
// used in dispaly style load more button, lazy, pagination
'items_per_page' => $this->atts['items_per_page'],
'btn_data' => vc_map_integrate_parse_atts( $this->shortcode, 'vc_btn', $this->atts, 'btn_' ),
) );
} elseif ( 'lazy' === $this->atts['style'] ) {
$this->grid_settings = array_merge( $this->grid_settings, array(
'items_per_page' => $this->atts['items_per_page'],
) );
} elseif ( 'pagination' === $this->atts['style'] ) {
$this->grid_settings = array_merge( $this->grid_settings, array(
'items_per_page' => $this->atts['items_per_page'],
// used in pagination style
'auto_play' => $this->atts['autoplay'] > 0 ? true : false,
'gap' => (int) $this->atts['gap'],
// not used yet, but can be used in isotope..
'speed' => (int) $this->atts['autoplay'] * 1000,
'loop' => $this->atts['loop'],
'animation_in' => $this->atts['paging_animation_in'],
'animation_out' => $this->atts['paging_animation_out'],
'arrows_design' => $this->atts['arrows_design'],
'arrows_color' => $this->atts['arrows_color'],
'arrows_position' => $this->atts['arrows_position'],
'paging_design' => $this->atts['paging_design'],
'paging_color' => $this->atts['paging_color'],
) );
}
$this->grid_settings['tag'] = $this->shortcode;
}
// TODO: setter & getter to attributes
/**
* @param $atts
* @return array
*/
public function buildQuery( $atts ) {
// Set include & exclude
if ( 'ids' !== $atts['post_type'] && ! empty( $atts['exclude'] ) ) {
$atts['exclude'] .= ',' . implode( ',', $this->excludedIds() );
} else {
$atts['exclude'] = implode( ',', $this->excludedIds() );
}
if ( 'ids' !== $atts['post_type'] ) {
$settings = array(
'posts_per_page' => $atts['query_items_per_page'],
'offset' => $atts['query_offset'],
'orderby' => $atts['orderby'],
'order' => $atts['order'],
'meta_key' => in_array( $atts['orderby'], array(
'meta_value',
'meta_value_num',
), true ) ? $atts['meta_key'] : '',
'post_type' => $atts['post_type'],
'exclude' => $atts['exclude'],
);
if ( ! empty( $atts['taxonomies'] ) ) {
$vc_taxonomies_types = get_taxonomies( array( 'public' => true ) );
$terms = get_terms( array_keys( $vc_taxonomies_types ), array(
'hide_empty' => false,
'include' => $atts['taxonomies'],
) );
$settings['tax_query'] = array();
$tax_queries = array(); // List of taxnonimes
foreach ( $terms as $term ) {
if ( ! isset( $tax_queries[ $term->taxonomy ] ) ) {
$tax_queries[ $term->taxonomy ] = array(
'taxonomy' => $term->taxonomy,
'field' => 'id',
'terms' => array( $term->term_id ),
'relation' => 'IN',
);
} else {
$tax_queries[ $term->taxonomy ]['terms'][] = $term->term_id;
}
}
$settings['tax_query'] = array_values( $tax_queries );
$settings['tax_query']['relation'] = 'OR';
}
} else {
if ( empty( $atts['include'] ) ) {
$atts['include'] = - 1;
} elseif ( ! empty( $atts['exclude'] ) ) {
$include = array_map( 'trim', explode( ',', $atts['include'] ) );
$exclude = array_map( 'trim', explode( ',', $atts['exclude'] ) );
$diff = array_diff( $include, $exclude );
$atts['include'] = implode( ', ', $diff );
}
$settings = array(
'include' => $atts['include'],
'posts_per_page' => $atts['query_items_per_page'],
'offset' => $atts['query_offset'],
'post_type' => 'any',
'orderby' => 'post__in',
);
$this->atts['items_per_page'] = - 1;
}
return $settings;
}
public function buildItems() {
$this->filter_terms = $this->items = array();
$this->query = new WP_Query();
$this->setContentLimits();
$this->addExcludedId( $this->postID() );
if ( 'custom' === $this->atts['post_type'] && ! empty( $this->atts['custom_query'] ) ) {
$query = html_entity_decode( vc_value_from_safe( $this->atts['custom_query'] ), ENT_QUOTES, 'utf-8' );
$query = apply_filters( 'vc_basic_grid_filter_query_filters', $query, $this->atts, $this->shortcode );
$post_data = $this->query->query( $query );
$this->atts['items_per_page'] = - 1;
} elseif ( false !== $this->atts['query_items_per_page'] ) {
$settings = $this->filterQuerySettings( $this->buildQuery( $this->atts ) );
$post_data = $this->query->query( $settings );
} else {
return;
}
if ( $this->atts['items_per_page'] > 0 && count( $post_data ) > $this->atts['items_per_page'] ) {
$post_data = array_slice( $post_data, 0, $this->atts['items_per_page'] );
}
foreach ( $post_data as $post ) {
$post->filter_terms = wp_get_object_terms( $post->ID, $this->atts['filter_source'], array( 'fields' => 'ids' ) );
$this->filter_terms = wp_parse_args( $this->filter_terms, $post->filter_terms );
$this->items[] = $post;
}
}
/**
* @param $args
* @return array
*/
public function filterQuerySettings( $args ) {
$defaults = array(
'numberposts' => 5,
'offset' => 0,
'category' => 0,
'orderby' => 'date',
'order' => 'DESC',
'include' => array(),
'exclude' => array(),
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'suppress_filters' => apply_filters( 'vc_basic_grid_filter_query_suppress_filters', true ),
'public' => true,
);
$r = wp_parse_args( $args, $defaults );
if ( empty( $r['post_status'] ) ) {
$r['post_status'] = ( 'attachment' === $r['post_type'] ) ? 'inherit' : 'publish';
}
if ( ! empty( $r['numberposts'] ) && empty( $r['posts_per_page'] ) ) {
$r['posts_per_page'] = $r['numberposts'];
}
if ( ! empty( $r['category'] ) ) {
$r['cat'] = $r['category'];
}
if ( ! empty( $r['include'] ) ) {
$incposts = wp_parse_id_list( $r['include'] );
$r['posts_per_page'] = count( $incposts ); // only the number of posts included
$r['post__in'] = $incposts;
} elseif ( ! empty( $r['exclude'] ) ) {
$r['post__not_in'] = wp_parse_id_list( $r['exclude'] );
}
$r['ignore_sticky_posts'] = true;
$r['no_found_rows'] = true;
return $r;
}
/**
* @param $atts
* @return mixed
*/
public static function convertButton2ToButton3( $atts ) {
if ( isset( $atts['button_style'] ) || isset( $atts['button_size'] ) || isset( $atts['button_color'] ) ) {
// we use old button 2 attributes:
$style = isset( $atts['button_style'] ) ? $atts['button_style'] : 'rounded';
$size = isset( $atts['button_size'] ) ? $atts['button_size'] : 'md';
$color = isset( $atts['button_color'] ) ? $atts['button_color'] : 'blue';
$oldData = array(
'style' => $style,
'size' => $size,
'color' => str_replace( '_', '-', $color ),
);
// remove attributes on save
$atts['button_style'] = '';
$atts['button_size'] = '';
$atts['button_color'] = '';
$newData = WPBakeryShortCode_Vc_Btn::convertAttributesToButton3( $oldData );
foreach ( $newData as $key => $value ) {
$atts[ 'btn_' . $key ] = $value;
}
}
return $atts;
}
}

View File

@@ -0,0 +1,99 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder shortcodes
*
* @package WPBakeryPageBuilder
*
*/
/**
* Class WPBakeryShortCode_Vc_Btn
* @since 4.5
*/
class WPBakeryShortCode_Vc_Btn extends WPBakeryShortCode {
/**
* @param $atts
* @return mixed
*/
public static function convertAttributesToButton3( $atts ) {
// size btn1 to size btn2
$btn1_sizes = array(
'wpb_regularsize',
'btn-large',
'btn-small',
'btn-mini',
);
if ( isset( $atts['size'] ) && in_array( $atts['size'], $btn1_sizes, true ) ) {
$atts['size'] = str_replace( $btn1_sizes, array(
'md',
'lg',
'sm',
'xs',
), $atts['size'] );
}
// Convert Btn1 href+target attributes to Btn2 `link` attribute
if ( ! isset( $atts['link'] ) && isset( $atts['href'] ) && strlen( $atts['href'] ) > 0 ) {
$link = $atts['href'];
$target = isset( $atts['target'] ) ? $atts['target'] : '';
$title = isset( $atts['title'] ) ? $atts['title'] : $link;
$atts['link'] = 'url:' . rawurlencode( $link ) . '|title:' . $title . ( strlen( $target ) > 0 ? '|target:' . rawurlencode( $target ) : '' );
}
if ( ( ! isset( $atts['add_icon'] ) || 'true' !== $atts['add_icon'] ) && isset( $atts['icon'] ) && strlen( $atts['icon'] ) > 0 && 'none' !== $atts['icon'] ) {
// old icon from btn1 is set, let's convert it to new btn
$atts['add_icon'] = 'true';
$atts['icon_type'] = 'pixelicons';
$atts['icon_align'] = 'right';
$atts['icon_pixelicons'] = 'vc_pixel_icon vc_pixel_icon-' . str_replace( 'wpb_', '', $atts['icon'] );
}
$haystack = array(
'rounded',
'square',
'round',
'outlined',
'square_outlined',
);
if ( isset( $atts['style'] ) && in_array( $atts['style'], $haystack, true ) ) {
switch ( $atts['style'] ) {
case 'rounded':
$atts['style'] = 'flat';
$atts['shape'] = 'rounded';
break;
case 'square':
$atts['style'] = 'flat';
$atts['shape'] = 'square';
break;
case 'round':
$atts['style'] = 'flat';
$atts['shape'] = 'round';
break;
case 'outlined':
$atts['style'] = 'outline';
break;
case 'square_outlined':
$atts['style'] = 'outline';
$atts['shape'] = 'square';
break;
}
}
return $atts;
}
/**
* @param $title
*
* @return string
* @since 4.5
*/
protected function outputTitle( $title ) {
$icon = $this->settings( 'icon' );
return '<h4 class="wpb_element_title"><span class="vc_general vc_element-icon vc_btn3-icon' . ( ! empty( $icon ) ? ' ' . $icon : '' ) . '"></span></h4>';
}
}

View File

@@ -0,0 +1,22 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder shortcodes
*
* @package WPBakeryPageBuilder
*
*/
class WPBakeryShortCode_Vc_Button extends WPBakeryShortCode {
/**
* @param $title
* @return string
*/
protected function outputTitle( $title ) {
$icon = $this->settings( 'icon' );
return '<h4 class="wpb_element_title"><span class="vc_general vc_element-icon' . ( ! empty( $icon ) ? ' ' . esc_attr( $icon ) : '' ) . '"></span></h4>';
}
}

View File

@@ -0,0 +1,22 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder shortcodes
*
* @package WPBakeryPageBuilder
*
*/
class WPBakeryShortCode_Vc_Button2 extends WPBakeryShortCode {
/**
* @param $title
* @return string
*/
protected function outputTitle( $title ) {
$icon = $this->settings( 'icon' );
return '<h4 class="wpb_element_title"><span class="vc_general vc_element-icon' . ( ! empty( $icon ) ? ' ' . esc_attr( $icon ) : '' ) . '"></span></h4>';
}
}

View File

@@ -0,0 +1,12 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-column.php' );
/**
* Class WPBakeryShortCode_Vc_Column_Inner
*/
class WPBakeryShortCode_Vc_Column_Inner extends WPBakeryShortCode_Vc_Column {
}

View File

@@ -0,0 +1,17 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Column_Text
*/
class WPBakeryShortCode_Vc_Column_Text extends WPBakeryShortCode {
/**
* @param $title
* @return string
*/
protected function outputTitle( $title ) {
return '';
}
}

View File

@@ -0,0 +1,290 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder shortcodes
*
* @package WPBakeryPageBuilder
*
*/
class WPBakeryShortCode_VC_Column extends WPBakeryShortCode {
/**
* @var string
*/
public $nonDraggableClass = 'vc-non-draggable-column';
/**
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->shortcodeScripts();
}
/**
*
*/
protected function shortcodeScripts() {
wp_register_script( 'vc_jquery_skrollr_js', vc_asset_url( 'lib/bower/skrollr/dist/skrollr.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'vc_youtube_iframe_api_js', 'https://www.youtube.com/iframe_api', array(), WPB_VC_VERSION, true );
}
/**
* @param $controls
* @param string $extended_css
*
* @return string
* @throws \Exception
*/
public function getColumnControls( $controls, $extended_css = '' ) {
$output = '<div class="vc_controls vc_control-column vc_controls-visible' . ( ! empty( $extended_css ) ? " {$extended_css}" : '' ) . '">';
$controls_end = '</div>';
if ( ' bottom-controls' === $extended_css ) {
$control_title = __( 'Append to this column', 'js_composer' );
} else {
$control_title = __( 'Prepend to this column', 'js_composer' );
}
if ( vc_user_access()->part( 'shortcodes' )->checkStateAny( true, 'custom', null )->get() ) {
$controls_add = '<a class="vc_control column_add vc_column-add" data-vc-control="add" href="#" title="' . $control_title . '"><i class="vc-composer-icon vc-c-icon-add"></i></a>';
} else {
$controls_add = '';
}
$controls_edit = '<a class="vc_control column_edit vc_column-edit" data-vc-control="edit" href="#" title="' . __( 'Edit this column', 'js_composer' ) . '"><i class="vc-composer-icon vc-c-icon-mode_edit"></i></a>';
$controls_delete = '<a class="vc_control column_delete vc_column-delete" data-vc-control="delete" href="#" title="' . __( 'Delete this column', 'js_composer' ) . '"><i class="vc-composer-icon vc-c-icon-delete_empty"></i></a>';
$editAccess = vc_user_access_check_shortcode_edit( $this->shortcode );
$allAccess = vc_user_access_check_shortcode_all( $this->shortcode );
if ( is_array( $controls ) && ! empty( $controls ) ) {
foreach ( $controls as $control ) {
if ( 'add' === $control || ( $editAccess && 'edit' === $control ) || $allAccess ) {
$method_name = vc_camel_case( 'output-editor-control-' . $control );
if ( method_exists( $this, $method_name ) ) {
$output .= $this->$method_name();
} else {
$control_var = 'controls_' . $control;
if ( isset( ${$control_var} ) ) {
$output .= ${$control_var};
}
}
}
}
return $output . $controls_end;
} elseif ( is_string( $controls ) && 'full' === $controls ) {
if ( $allAccess ) {
return $output . $controls_add . $controls_edit . $controls_delete . $controls_end;
} elseif ( $editAccess ) {
return $output . $controls_add . $controls_edit . $controls_end;
}
return $output . $controls_add . $controls_end;
} elseif ( is_string( $controls ) ) {
$control_var = 'controls_' . $controls;
if ( 'add' === $controls || ( $editAccess && 'edit' === $controls || $allAccess ) && isset( ${$control_var} ) ) {
return $output . ${$control_var} . $controls_end;
}
return $output . $controls_end;
}
if ( $allAccess ) {
return $output . $controls_add . $controls_edit . $controls_delete . $controls_end;
} elseif ( $editAccess ) {
return $output . $controls_add . $controls_edit . $controls_end;
}
return $output . $controls_add . $controls_end;
}
/**
* @param $param
* @param $value
*
* @return string
*/
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'] . '>';
}
return $output;
}
/**
* @param $atts
* @param null $content
*
* @return string
*/
public function contentAdmin( $atts, $content = null ) {
$width = '';
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
// @codingStandardsIgnoreLine
extract( $atts );
$this->atts = $atts;
$output = '';
$column_controls = $this->getColumnControls( $this->settings( 'controls' ) );
$column_controls_bottom = $this->getColumnControls( 'add', 'bottom-controls' );
if ( 'column_14' === $width || '1/4' === $width ) {
$width = array( 'vc_col-sm-3' );
} elseif ( 'column_14-14-14-14' === $width ) {
$width = array(
'vc_col-sm-3',
'vc_col-sm-3',
'vc_col-sm-3',
'vc_col-sm-3',
);
} elseif ( 'column_13' === $width || '1/3' === $width ) {
$width = array( 'vc_col-sm-4' );
} elseif ( 'column_13-23' === $width ) {
$width = array(
'vc_col-sm-4',
'vc_col-sm-8',
);
} elseif ( 'column_13-13-13' === $width ) {
$width = array(
'vc_col-sm-4',
'vc_col-sm-4',
'vc_col-sm-4',
);
} elseif ( 'column_12' === $width || '1/2' === $width ) {
$width = array( 'vc_col-sm-6' );
} elseif ( 'column_12-12' === $width ) {
$width = array(
'vc_col-sm-6',
'vc_col-sm-6',
);
} elseif ( 'column_23' === $width || '2/3' === $width ) {
$width = array( 'vc_col-sm-8' );
} elseif ( 'column_34' === $width || '3/4' === $width ) {
$width = array( 'vc_col-sm-9' );
} elseif ( 'column_16' === $width || '1/6' === $width ) {
$width = array( 'vc_col-sm-2' );
} elseif ( ' column_56' === $width || ' 5/6' === $width ) {
$width = array( 'vc_col-sm-10' );
} else {
$width = array( '' );
}
$count = count( $width );
for ( $i = 0; $i < $count; $i ++ ) {
$output .= '<div ' . $this->mainHtmlBlockParams( $width, $i ) . '>';
$output .= str_replace( '%column_size%', wpb_translateColumnWidthToFractional( $width[ $i ] ), $column_controls );
$output .= '<div class="wpb_element_wrapper">';
$output .= '<div ' . $this->containerHtmlBlockParams( $width, $i ) . '>';
$output .= do_shortcode( shortcode_unautop( $content ) );
$output .= '</div>';
if ( isset( $this->settings['params'] ) ) {
$inner = '';
foreach ( $this->settings['params'] as $param ) {
$param_value = isset( ${$param['param_name']} ) ? ${$param['param_name']} : '';
if ( is_array( $param_value ) ) {
// Get first element from the array
reset( $param_value );
$first_key = key( $param_value );
$param_value = $param_value[ $first_key ];
}
$inner .= $this->singleParamHtmlHolder( $param, $param_value );
}
$output .= $inner;
}
$output .= '</div>';
$output .= str_replace( '%column_size%', wpb_translateColumnWidthToFractional( $width[ $i ] ), $column_controls_bottom );
$output .= '</div>';
}
return $output;
}
/**
* @return string
*/
public function customAdminBlockParams() {
return '';
}
/**
* @param $width
* @param $i
*
* @return string
* @throws \Exception
*/
public function mainHtmlBlockParams( $width, $i ) {
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? 'wpb_sortable' : $this->nonDraggableClass );
return 'data-element_type="' . $this->settings['base'] . '" data-vc-column-width="' . wpb_vc_get_column_width_indent( $width[ $i ] ) . '" class="wpb_' . $this->settings['base'] . ' ' . $sortable . '' . ( ! empty( $this->settings['class'] ) ? ' ' . $this->settings['class'] : '' ) . ' ' . $this->templateWidth() . ' wpb_content_holder"' . $this->customAdminBlockParams();
}
/**
* @param $width
* @param $i
*
* @return string
*/
public function containerHtmlBlockParams( $width, $i ) {
return 'class="wpb_column_container vc_container_for_children"';
}
/**
* @param string $content
*
* @return string
*/
public function template( $content = '' ) {
return $this->contentAdmin( $this->atts );
}
/**
* @return string
*/
protected function templateWidth() {
return '<%= window.vc_convert_column_size(params.width) %>';
}
/**
* @param string $font_color
*
* @return string
*/
public function buildStyle( $font_color = '' ) {
$style = '';
if ( ! empty( $font_color ) ) {
$style .= vc_get_css_color( 'color', $font_color );
}
return empty( $style ) ? $style : ' style="' . esc_attr( $style ) . '"';
}
}

View File

@@ -0,0 +1,13 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder shortcodes
*
* @package WPBakeryPageBuilder
*
*/
class WPBakeryShortCode_Vc_Cta_Button extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,13 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder shortcodes
*
* @package WPBakeryPageBuilder
*
*/
class WPBakeryShortCode_Vc_Cta_Button2 extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,179 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder shortcodes
*
* @package WPBakeryPageBuilder
* @since 4.5
*/
/**
* @since 4.5
* Class WPBakeryShortCode_Vc_Cta
*/
class WPBakeryShortCode_Vc_Cta extends WPBakeryShortCode {
protected $template_vars = array();
/**
* @param $atts
* @param $content
* @throws \Exception
*/
public function buildTemplate( $atts, $content ) {
$output = array();
$inline_css = array();
$main_wrapper_classes = array( 'vc_cta3' );
$container_classes = array();
if ( ! empty( $atts['el_class'] ) ) {
$main_wrapper_classes[] = $atts['el_class'];
}
if ( ! empty( $atts['style'] ) ) {
$main_wrapper_classes[] = 'vc_cta3-style-' . $atts['style'];
}
if ( ! empty( $atts['shape'] ) ) {
$main_wrapper_classes[] = 'vc_cta3-shape-' . $atts['shape'];
}
if ( ! empty( $atts['txt_align'] ) ) {
$main_wrapper_classes[] = 'vc_cta3-align-' . $atts['txt_align'];
}
if ( ! empty( $atts['color'] ) && ! ( isset( $atts['style'] ) && 'custom' === $atts['style'] ) ) {
$main_wrapper_classes[] = 'vc_cta3-color-' . $atts['color'];
}
if ( isset( $atts['style'] ) && 'custom' === $atts['style'] ) {
if ( ! empty( $atts['custom_background'] ) ) {
$inline_css[] = vc_get_css_color( 'background-color', $atts['custom_background'] );
}
}
if ( ! empty( $atts['i_on_border'] ) ) {
$main_wrapper_classes[] = 'vc_cta3-icons-on-border';
}
if ( ! empty( $atts['i_size'] ) ) {
$main_wrapper_classes[] = 'vc_cta3-icon-size-' . $atts['i_size'];
}
if ( ! empty( $atts['i_background_style'] ) ) {
$main_wrapper_classes[] = 'vc_cta3-icons-in-box';
}
if ( ! empty( $atts['el_width'] ) ) {
$container_classes[] = 'vc_cta3-size-' . $atts['el_width'];
}
if ( ! empty( $atts['add_icon'] ) ) {
$output[ 'icons-' . $atts['add_icon'] ] = $this->getVcIcon( $atts );
$main_wrapper_classes[] = 'vc_cta3-icons-' . $atts['add_icon'];
}
if ( ! empty( $atts['add_button'] ) ) {
$output[ 'actions-' . $atts['add_button'] ] = $this->getButton( $atts );
$main_wrapper_classes[] = 'vc_cta3-actions-' . $atts['add_button'];
}
if ( ! empty( $atts['css_animation'] ) ) {
$main_wrapper_classes[] = $this->getCSSAnimation( $atts['css_animation'] );
}
if ( ! empty( $atts['css'] ) ) {
$main_wrapper_classes[] = vc_shortcode_custom_css_class( $atts['css'] );
}
$output['content'] = wpb_js_remove_wpautop( $content, true );
$output['heading1'] = $this->getHeading( 'h2', $atts );
$output['heading2'] = $this->getHeading( 'h4', $atts );
$output['css-class'] = $main_wrapper_classes;
$output['container-class'] = $container_classes;
$output['inline-css'] = $inline_css;
$this->template_vars = $output;
}
/**
* @param $tag
* @param $atts
* @return string
* @throws \Exception
*/
public function getHeading( $tag, $atts ) {
if ( isset( $atts[ $tag ] ) && '' !== trim( $atts[ $tag ] ) ) {
if ( isset( $atts[ 'use_custom_fonts_' . $tag ] ) && 'true' === $atts[ 'use_custom_fonts_' . $tag ] ) {
$custom_heading = visual_composer()->getShortCode( 'vc_custom_heading' );
$data = vc_map_integrate_parse_atts( $this->shortcode, 'vc_custom_heading', $atts, $tag . '_' );
$data['font_container'] = implode( '|', array_filter( array(
'tag:' . $tag,
$data['font_container'],
) ) );
$data['text'] = $atts[ $tag ]; // provide text to shortcode
return $custom_heading->render( array_filter( $data ) );
} else {
$inline_css = array();
$inline_css_string = '';
if ( isset( $atts['style'] ) && 'custom' === $atts['style'] ) {
if ( ! empty( $atts['custom_text'] ) ) {
$inline_css[] = vc_get_css_color( 'color', $atts['custom_text'] );
}
}
if ( ! empty( $inline_css ) ) {
$inline_css_string = ' style="' . implode( '', $inline_css ) . '"';
}
return '<' . $tag . $inline_css_string . '>' . $atts[ $tag ] . '</' . $tag . '>';
}
}
return '';
}
/**
* @param $atts
* @return string
* @throws \Exception
*/
public function getButton( $atts ) {
$data = vc_map_integrate_parse_atts( $this->shortcode, 'vc_btn', $atts, 'btn_' );
if ( $data ) {
$btn = visual_composer()->getShortCode( 'vc_btn' );
if ( is_object( $btn ) ) {
return '<div class="vc_cta3-actions">' . $btn->render( array_filter( $data ) ) . '</div>';
}
}
return '';
}
/**
* @param $atts
* @return string
* @throws \Exception
*/
public function getVcIcon( $atts ) {
if ( empty( $atts['i_type'] ) ) {
$atts['i_type'] = 'fontawesome';
}
$data = vc_map_integrate_parse_atts( $this->shortcode, 'vc_icon', $atts, 'i_' );
if ( $data ) {
$icon = visual_composer()->getShortCode( 'vc_icon' );
if ( is_object( $icon ) ) {
return '<div class="vc_cta3-icons">' . $icon->render( array_filter( $data ) ) . '</div>';
}
}
return '';
}
/**
* @param $string
* @return mixed|string
*/
public function getTemplateVariable( $string ) {
if ( is_array( $this->template_vars ) && isset( $this->template_vars[ $string ] ) ) {
return $this->template_vars[ $string ];
}
return '';
}
}

View File

@@ -0,0 +1,13 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder shortcodes
*
* @package WPBakeryPageBuilder
*
*/
class WPBakeryShortCode_Vc_Custom_Field extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,159 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Custom_heading
* @since 4.3
*/
class WPBakeryShortCode_Vc_Custom_Heading extends WPBakeryShortCode {
/**
* Defines fields names for google_fonts, font_container and etc
* @since 4.4
* @var array
*/
protected $fields = array(
'google_fonts' => 'google_fonts',
'font_container' => 'font_container',
'el_class' => 'el_class',
'css' => 'css',
'text' => 'text',
);
/**
* Used to get field name in vc_map function for google_fonts, font_container and etc..
*
* @param $key
*
* @return bool
* @since 4.4
*/
protected function getField( $key ) {
return isset( $this->fields[ $key ] ) ? $this->fields[ $key ] : false;
}
/**
* Get param value by providing key
*
* @param $key
*
* @return array|bool
* @throws \Exception
* @since 4.4
*/
protected function getParamData( $key ) {
return WPBMap::getParam( $this->shortcode, $this->getField( $key ) );
}
/**
* Parses shortcode attributes and set defaults based on vc_map function relative to shortcode and fields names
*
* @param $atts
*
* @return array
* @throws \Exception
* @since 4.3
*/
public function getAttributes( $atts ) {
/**
* Shortcode attributes
* @var $text
* @var $google_fonts
* @var $font_container
* @var $el_class
* @var $link
* @var $css
*/
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );
/**
* Get default values from VC_MAP.
*/
$google_fonts_field = $this->getParamData( 'google_fonts' );
$font_container_field = $this->getParamData( 'font_container' );
$el_class = $this->getExtraClass( $el_class );
$font_container_obj = new Vc_Font_Container();
$google_fonts_obj = new Vc_Google_Fonts();
$font_container_field_settings = isset( $font_container_field['settings'], $font_container_field['settings']['fields'] ) ? $font_container_field['settings']['fields'] : array();
$google_fonts_field_settings = isset( $google_fonts_field['settings'], $google_fonts_field['settings']['fields'] ) ? $google_fonts_field['settings']['fields'] : array();
$font_container_data = $font_container_obj->_vc_font_container_parse_attributes( $font_container_field_settings, $font_container );
$google_fonts_data = strlen( $google_fonts ) > 0 ? $google_fonts_obj->_vc_google_fonts_parse_attributes( $google_fonts_field_settings, $google_fonts ) : '';
return array(
'text' => isset( $text ) ? $text : '',
'google_fonts' => $google_fonts,
'font_container' => $font_container,
'el_class' => $el_class,
'css' => isset( $css ) ? $css : '',
'link' => ( 0 === strpos( $link, '|' ) ) ? false : $link,
'font_container_data' => $font_container_data,
'google_fonts_data' => $google_fonts_data,
);
}
/**
* Parses google_fonts_data and font_container_data to get needed css styles to markup
*
* @param $el_class
* @param $css
* @param $google_fonts_data
* @param $font_container_data
* @param $atts
*
* @return array
* @since 4.3
*/
public function getStyles( $el_class, $css, $google_fonts_data, $font_container_data, $atts ) {
$styles = array();
if ( ! empty( $font_container_data ) && isset( $font_container_data['values'] ) ) {
foreach ( $font_container_data['values'] as $key => $value ) {
if ( 'tag' !== $key && strlen( $value ) ) {
if ( preg_match( '/description/', $key ) ) {
continue;
}
if ( 'font_size' === $key || 'line_height' === $key ) {
$value = preg_replace( '/\s+/', '', $value );
}
if ( 'font_size' === $key ) {
$pattern = '/^(\d*(?:\.\d+)?)\s*(px|\%|in|cm|mm|em|rem|ex|pt|pc|vw|vh|vmin|vmax)?$/';
// allowed metrics: http://www.w3schools.com/cssref/css_units.asp
preg_match( $pattern, $value, $matches );
$value = isset( $matches[1] ) ? (float) $matches[1] : (float) $value;
$unit = isset( $matches[2] ) ? $matches[2] : 'px';
$value = $value . $unit;
}
if ( strlen( $value ) > 0 ) {
$styles[] = str_replace( '_', '-', $key ) . ': ' . $value;
}
}
}
}
if ( ( ! isset( $atts['use_theme_fonts'] ) || 'yes' !== $atts['use_theme_fonts'] ) && ! empty( $google_fonts_data ) && isset( $google_fonts_data['values'], $google_fonts_data['values']['font_family'], $google_fonts_data['values']['font_style'] ) ) {
$google_fonts_family = explode( ':', $google_fonts_data['values']['font_family'] );
$styles[] = 'font-family:' . $google_fonts_family[0];
$google_fonts_styles = explode( ':', $google_fonts_data['values']['font_style'] );
$styles[] = 'font-weight:' . $google_fonts_styles[1];
$styles[] = 'font-style:' . $google_fonts_styles[2];
}
/**
* Filter 'VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG' to change vc_custom_heading class
*
* @param string - filter_name
* @param string - element_class
* @param string - shortcode_name
* @param array - shortcode_attributes
*
* @since 4.3
*/
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'vc_custom_heading ' . $el_class . vc_shortcode_custom_css_class( $css, ' ' ), $this->settings['base'], $atts );
return array(
'css_class' => trim( preg_replace( '/\s+/', ' ', $css_class ) ),
'styles' => $styles,
);
}
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Empty_space
*/
class WPBakeryShortCode_Vc_Empty_Space extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,42 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Facebook
*/
class WPBakeryShortCode_Vc_Facebook extends WPBakeryShortCode {
/**
* @param $atts
* @param null $content
* @return string
* @throws \Exception
*/
protected function contentInline( $atts, $content = null ) {
/**
* Shortcode attributes
* @var $atts
* @var $type
* @var $el_class
* @var $css
* @var $css_animation
* Shortcode class
* @var WPBakeryShortCode_Vc_Facebook $this
*/
$type = $css = $el_class = '';
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );
$url = get_permalink();
$css = isset( $atts['css'] ) ? $atts['css'] : '';
$el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : '';
$class_to_filter = 'wpb_googleplus vc_social-placeholder wpb_content_element vc_socialtype-' . $type;
$class_to_filter .= vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation );
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
return '<a href="' . esc_url( $url ) . '" class="' . esc_attr( $css_class ) . '"></a>';
}
}

View File

@@ -0,0 +1,62 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_flickr
*/
class WPBakeryShortCode_Vc_Flickr extends WPBakeryShortCode {
/**
* @param $atts
* @param null $content
* @return string
* @throws \Exception
*/
protected function contentInline( $atts, $content = null ) {
/**
* Shortcode attributes
* @var $atts
* @var $el_class
* @var $title
* @var $flickr_id
* @var $count
* @var $type
* @var $display
* @var $css
* @var $css_animation
* Shortcode class
* @var WPBakeryShortCode_Vc_flickr $this
*/
$title = '';
$flickr_id = '';
$css_animation = '';
$count = '';
$type = '';
$display = '';
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );
$css = isset( $atts['css'] ) ? $atts['css'] : '';
$el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : '';
$class_to_filter = 'wpb_flickr_widget wpb_content_element';
$class_to_filter .= vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation );
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
$params = array(
'title' => $title,
'extraclass' => 'wpb_flickr_heading',
);
$output = sprintf( '
<div class="%s">
<div class="wpb_wrapper">
%s
<div class="vc_flickr-inline-placeholder" data-link="https://www.flickr.com/badge_code_v2.gne?count=%s&amp;display=%s&amp;size=s&amp;layout=x&amp;source=%s&amp;%s=%s"></div>
<p class="flickr_stream_wrap"><a class="wpb_follow_btn wpb_flickr_stream" href="https://www.flickr.com/photos/%s">%s</a></p>
</div>
</div>', $css_class, wpb_widget_title( $params ), $count, $display, $type, $type, $flickr_id, $flickr_id, esc_html__( 'View stream on flickr', 'js_composer' ) );
return $output;
}
}

View File

@@ -0,0 +1,79 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_gallery
*/
class WPBakeryShortCode_Vc_Gallery extends WPBakeryShortCode {
/**
* WPBakeryShortCode_Vc_gallery constructor.
* @param $settings
*/
public 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' ), array( 'jquery' ), WPB_VC_VERSION, true );
}
/**
* @param $param
* @param $value
* @return string
*/
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="' . esc_url( 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' : '' ) . '">' . esc_html__( 'Add images', 'js_composer' ) . '</a>';
}
return $output;
}
}

View File

@@ -0,0 +1,56 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Animated_Block
*/
class WPBakeryShortCode_Vc_Gitem_Animated_Block extends WPBakeryShortCode_Vc_Gitem {
protected static $animations = array();
/**
* @return string
*/
public function itemGrid() {
$output = '';
$output .= '<div class="vc_gitem-animated-block-content-controls">' . '<ul class="vc_gitem-tabs vc_clearfix" data-vc-gitem-animated-block="tabs">' . '</ul>' . '</div>';
$output .= '' . '<div class="vc_gitem-zone-tab vc_clearfix" data-vc-gitem-animated-block="add-a"></div>' . '<div class="vc_gitem-zone-tab vc_clearfix" data-vc-gitem-animated-block="add-b"></div>';
return $output;
}
/**
* @param $width
* @param $i
* @return string
*/
public function containerHtmlBlockParams( $width, $i ) {
return 'class="vc_gitem-animated-block-content"';
}
/**
* @return array
*/
public static function animations() {
return array(
esc_html__( 'Single block (no animation)', 'js_composer' ) => '',
esc_html__( 'Double block (no animation)', 'js_composer' ) => 'none',
esc_html__( 'Fade in', 'js_composer' ) => 'fadeIn',
esc_html__( 'Scale in', 'js_composer' ) => 'scaleIn',
esc_html__( 'Scale in with rotation', 'js_composer' ) => 'scaleRotateIn',
esc_html__( 'Blur out', 'js_composer' ) => 'blurOut',
esc_html__( 'Blur scale out', 'js_composer' ) => 'blurScaleOut',
esc_html__( 'Slide in from left', 'js_composer' ) => 'slideInRight',
esc_html__( 'Slide in from right', 'js_composer' ) => 'slideInLeft',
esc_html__( 'Slide bottom', 'js_composer' ) => 'slideBottom',
esc_html__( 'Slide top', 'js_composer' ) => 'slideTop',
esc_html__( 'Vertical flip in with fade', 'js_composer' ) => 'flipFadeIn',
esc_html__( 'Horizontal flip in with fade', 'js_composer' ) => 'flipHorizontalFadeIn',
esc_html__( 'Go top', 'js_composer' ) => 'goTop20',
esc_html__( 'Go bottom', 'js_composer' ) => 'goBottom20',
);
}
}

View File

@@ -0,0 +1,52 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-column.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Col
*/
class WPBakeryShortCode_Vc_Gitem_Col extends WPBakeryShortCode_Vc_Column {
public $nonDraggableClass = 'vc-non-draggable-column';
/**
* @param $width
* @param $i
* @return string
* @throws \Exception
*/
public function mainHtmlBlockParams( $width, $i ) {
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? ' wpb_sortable ' : ' ' . $this->nonDraggableClass . ' ' );
return 'data-element_type="' . $this->settings['base'] . '" data-vc-column-width="' . wpb_vc_get_column_width_indent( $width[ $i ] ) . '" class="wpb_vc_column wpb_' . $this->settings['base'] . $sortable . $this->templateWidth() . ' wpb_content_holder"' . $this->customAdminBlockParams();
}
/**
* @return string
*/
public function outputEditorControlAlign() {
$alignment = array(
array(
'name' => 'left',
'label' => esc_html__( 'Left', 'js_composer' ),
),
array(
'name' => 'center',
'label' => esc_html__( 'Center', 'js_composer' ),
),
array(
'name' => 'right',
'label' => esc_html__( 'Right', 'js_composer' ),
),
);
$output = '<span class="vc_control vc_control-align"><span class="vc_control-wrap">';
foreach ( $alignment as $data ) {
$attr = esc_attr( $data['name'] );
$output .= sprintf( '<a href="#" data-vc-control-btn="align" data-vc-align="%s" class="vc_control vc_control-align-%s" title="%s"><i class="vc_icon vc_icon-align-%s"></i></a>', esc_attr( $attr ), $attr, esc_html( $data['label'] ), $attr );
}
return $output . '</span></span>';
}
}

View File

@@ -0,0 +1,22 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-custom-heading.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Image
*/
class WPBakeryShortCode_Vc_Gitem_Image extends WPBakeryShortCode_Vc_Gitem_Post_Data {
/**
* Get data_source attribute value
*
* @param array $atts - list of shortcode attributes
*
* @return string
*/
public function getDataSource( array $atts ) {
return 'post_image';
}
}

View File

@@ -0,0 +1,18 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-post-data.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Post_Author
*/
class WPBakeryShortCode_Vc_Gitem_Post_Author extends WPBakeryShortCode_Vc_Gitem_Post_Data {
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_gitem_post_author';
}
}

View File

@@ -0,0 +1,18 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-post-data.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Post_Categories
*/
class WPBakeryShortCode_Vc_Gitem_Post_Categories extends WPBakeryShortCode_Vc_Gitem_Post_Data {
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_gitem_post_categories';
}
}

View File

@@ -0,0 +1,45 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-custom-heading.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Post_Data
*/
class WPBakeryShortCode_Vc_Gitem_Post_Data extends WPBakeryShortCode_Vc_Custom_heading {
/**
* Get data_source attribute value
*
* @param array $atts - list of shortcode attributes
*
* @return string
*/
public function getDataSource( array $atts ) {
return isset( $atts['data_source'] ) ? $atts['data_source'] : 'post_title';
}
/**
* @param $atts
* @return array
* @throws \Exception
*/
public function getAttributes( $atts ) {
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
if ( isset( $atts['block_container'] ) && strlen( $atts['block_container'] ) > 0 ) {
if ( ! isset( $atts['font_container'] ) ) {
$atts['font_container'] = $atts['block_container'];
} else {
// merging two params into font_container
$atts['font_container'] .= '|' . $atts['block_container'];
}
}
$atts = parent::getAttributes( $atts );
if ( ! isset( $this->atts['use_custom_fonts'] ) || 'yes' !== $this->atts['use_custom_fonts'] ) {
$atts['google_fonts_data'] = array();
}
return $atts;
}
}

View File

@@ -0,0 +1,29 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-post-data.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Post_Date
*/
class WPBakeryShortCode_Vc_Gitem_Post_Date extends WPBakeryShortCode_Vc_Gitem_Post_Data {
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_gitem_post_data';
}
/**
* Get data_source attribute value
*
* @param array $atts - list of shortcode attributes
*
* @return string
*/
public function getDataSource( array $atts ) {
return isset( $atts['time'] ) && 'yes' === $atts['time'] ? 'post_datetime' : 'post_date';
}
}

View File

@@ -0,0 +1,29 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-post-data.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Post_Excerpt
*/
class WPBakeryShortCode_Vc_Gitem_Post_Excerpt extends WPBakeryShortCode_Vc_Gitem_Post_Data {
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_gitem_post_data';
}
/**
* Get data_source attribute value
*
* @param array $atts - list of shortcode attributes
*
* @return string
*/
public function getDataSource( array $atts ) {
return 'post_excerpt';
}
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Gitem_Post_Meta
*/
class WPBakeryShortCode_Vc_Gitem_Post_Meta extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,29 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-post-data.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Post_title
*/
class WPBakeryShortCode_Vc_Gitem_Post_Title extends WPBakeryShortCode_Vc_Gitem_Post_Data {
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_gitem_post_data';
}
/**
* Get data_source attribute value
*
* @param array $atts - list of shortcode attributes
*
* @return string
*/
public function getDataSource( array $atts ) {
return 'post_title';
}
}

View File

@@ -0,0 +1,25 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-row.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Row
*/
class WPBakeryShortCode_Vc_Gitem_Row extends WPBakeryShortCode_Vc_Row {
/**
* @return string
*/
public function getLayoutsControl() {
global $vc_row_layouts;
$controls_layout = '<span class="vc_row_layouts vc_control">';
foreach ( array_slice( $vc_row_layouts, 0, 4 ) as $layout ) {
$controls_layout .= '<a class="vc_control-set-column set_columns" data-cells="' . $layout['cells'] . '" data-cells-mask="' . $layout['mask'] . '" title="' . $layout['title'] . '"><i class="vc-composer-icon vc-c-icon-' . $layout['icon_class'] . '"></i></a> ';
}
$controls_layout .= '</span>';
return $controls_layout;
}
}

View File

@@ -0,0 +1,20 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-zone.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Zone_A
*/
class WPBakeryShortCode_Vc_Gitem_Zone_A extends WPBakeryShortCode_Vc_Gitem_Zone {
public $zone_name = 'a';
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_gitem_zone';
}
}

View File

@@ -0,0 +1,20 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-zone.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Zone_B
*/
class WPBakeryShortCode_Vc_Gitem_Zone_B extends WPBakeryShortCode_Vc_Gitem_Zone {
public $zone_name = 'b';
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_gitem_zone';
}
}

View File

@@ -0,0 +1,13 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gitem-zone.php' );
/**
* Class WPBakeryShortCode_Vc_Gitem_Zone_C
*/
class WPBakeryShortCode_Vc_Gitem_Zone_C extends WPBakeryShortCode_Vc_Gitem_Zone {
public $zone_name = 'c';
}

View File

@@ -0,0 +1,11 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Gitem_Zone
*/
class WPBakeryShortCode_Vc_Gitem_Zone extends WPBakeryShortCodesContainer {
public $zone_name = '';
}

View File

@@ -0,0 +1,122 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Gitem
*/
class WPBakeryShortCode_Vc_Gitem extends WPBakeryShortCodesContainer {
/**
* @param $atts
* @param null $content
* @return string
* @throws \Exception
*/
public function contentAdmin( $atts, $content = null ) {
/**
* @var string @el_class - comes
*/
extract( shortcode_atts( $this->predefined_atts, $atts ) );
$output = '';
$column_controls = $this->getControls( $this->settings( 'controls' ) );
$output .= '<div ' . $this->mainHtmlBlockParams( '12', '' ) . '>';
$output .= $column_controls;
$output .= '<div ' . $this->containerHtmlBlockParams( '12', '' ) . '>';
$output .= $this->itemGrid();
$output .= do_shortcode( shortcode_unautop( $content ) );
$output .= '</div>';
if ( isset( $this->settings['params'] ) ) {
$inner = '';
foreach ( $this->settings['params'] as $param ) {
$param_value = isset( ${$param['param_name']} ) ? ${$param['param_name']} : '';
if ( is_array( $param_value ) ) {
// Get first element from the array
reset( $param_value );
$first_key = key( $param_value );
$param_value = $param_value[ $first_key ];
}
$inner .= $this->singleParamHtmlHolder( $param, $param_value );
}
$output .= $inner;
}
$output .= '</div>';
$output .= '</div>';
return $output;
}
/**
* @param $width
* @param $i
* @return string
* @throws \Exception
*/
public function mainHtmlBlockParams( $width, $i ) {
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? 'wpb_sortable' : $this->nonDraggableClass );
return 'data-element_type="' . $this->settings['base'] . '" class="' . $this->settings['base'] . '-shortcode ' . $sortable . ' wpb_content_holder vc_shortcodes_container"' . $this->customAdminBlockParams();
}
/**
* @return string
*/
public function itemGrid() {
$output = '<div class="vc_row"><div class="vc_col-xs-4 vc_col-xs-offset-4"><div class="vc_gitem-add-c-col" data-vc-gitem="add-c" data-vc-position="top"></div></div></div><div class="vc_row"><div class="vc_col-xs-4 vc_gitem-add-c-left"><div class="vc_gitem-add-c-col" data-vc-gitem="add-c" data-vc-position="left"></div></div><div class="vc_col-xs-4 vc_gitem-ab-zone" data-vc-gitem="add-ab"></div><div class="vc_col-xs-4 vc_gitem-add-c-right"><div class="vc_gitem-add-c-col" data-vc-gitem="add-c" data-vc-position="right"></div></div></div><div class="vc_row"><div class="vc_col-xs-4 vc_col-xs-offset-4 vc_gitem-add-c-bottom"><div class="vc_gitem-add-c-col" data-vc-gitem="add-c" data-vc-position="bottom"></div></div></div>';
return $output;
}
/**
* @param $width
* @param $i
* @return string
*/
public function containerHtmlBlockParams( $width, $i ) {
return 'class="vc_gitem-content"';
}
/**
* Get rendered controls
*
* @param array $controls
*
* @return string
* @throws \Exception
*/
public function getControls( $controls ) {
if ( ! is_array( $controls ) || empty( $controls ) ) {
return '';
}
$buttons = array();
$editAccess = vc_user_access_check_shortcode_edit( $this->shortcode );
$allAccess = vc_user_access_check_shortcode_all( $this->shortcode );
foreach ( $controls as $control ) {
switch ( $control ) {
case 'add':
if ( $allAccess ) {
$buttons[] = '<a class="vc_control-btn vc_control-btn-add" href="#" title="' . esc_attr__( 'Add to this grid item', 'js_composer' ) . '" data-vc-control="add"><i class="vc_icon"></i></a>';
}
break;
case 'edit':
if ( $editAccess ) {
$buttons[] = '<a class="vc_control-btn vc_control-btn-edit" href="#" title="' . esc_attr__( 'Edit this grid item', 'js_composer' ) . '" data-vc-control="edit"><i class="vc_icon"></i></a>';
}
break;
case 'delete':
if ( $allAccess ) {
$buttons[] = '<a class="vc_control-btn vc_control-btn-delete" href="#" title="' . esc_attr__( 'Delete this grid item ', 'js_composer' ) . '" data-vc-control="delete"><i class="vc_icon"></i></a>';
}
break;
}
}
$html = '<div class="vc_controls vc_controls-dark vc_controls-visible">' . implode( ' ', $buttons ) . '</div>';
return $html;
}
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Gmaps
*/
class WPBakeryShortCode_Vc_Gmaps extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,47 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_GooglePlus
*/
class WPBakeryShortCode_Vc_GooglePlus extends WPBakeryShortCode {
/**
* @param $atts
* @param null $content
* @return string
* @throws \Exception
*/
protected function contentInline( $atts, $content = null ) {
/**
* Shortcode attributes
* @var $atts
* @var $type
* @var $annotation
* @var $widget_width
* @var $css
* @var $css_animation
* Shortcode class
* @var WPBakeryShortCode_Vc_GooglePlus $this
*/
$type = $annotation = $widget_width = $css = $css_animation = '';
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );
if ( strlen( $type ) === 0 ) {
$type = 'standard';
}
if ( strlen( $annotation ) === 0 ) {
$annotation = 'bubble';
}
$css = isset( $atts['css'] ) ? $atts['css'] : '';
$el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : '';
$class_to_filter = 'wpb_googleplus vc_social-placeholder wpb_content_element vc_socialtype-' . $type;
$class_to_filter .= vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation );
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
return '<div class="' . esc_attr( $css_class ) . '"></div>';
}
}

View File

@@ -0,0 +1,17 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Gutenberg
*/
class WPBakeryShortCode_Vc_Gutenberg extends WPBakeryShortCode {
/**
* @param $title
* @return string
*/
protected function outputTitle( $title ) {
return '';
}
}

View File

@@ -0,0 +1,65 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Hoverbox
*/
class WPBakeryShortCode_Vc_Hoverbox extends WPBakeryShortCode {
/**
* @param $tag
* @param $atts
* @param $align
* @return string
* @throws \Exception
*/
public function getHeading( $tag, $atts, $align ) {
if ( isset( $atts[ $tag ] ) && '' !== trim( $atts[ $tag ] ) ) {
if ( isset( $atts[ 'use_custom_fonts_' . $tag ] ) && 'true' === $atts[ 'use_custom_fonts_' . $tag ] ) {
$custom_heading = visual_composer()->getShortCode( 'vc_custom_heading' );
$data = vc_map_integrate_parse_atts( $this->shortcode, 'vc_custom_heading', $atts, $tag . '_' );
$data['font_container'] = implode( '|', array_filter( array(
'tag:h2',
'text_align:' . esc_attr( $align ),
$data['font_container'],
) ) );
$data['text'] = $atts[ $tag ]; // provide text to shortcode
return $custom_heading->render( array_filter( $data ) );
} else {
$inline_css = array();
$inline_css_string = '';
if ( isset( $atts['style'] ) && 'custom' === $atts['style'] ) {
if ( ! empty( $atts['custom_text'] ) ) {
$inline_css[] = vc_get_css_color( 'color', $atts['custom_text'] );
}
}
if ( $align ) {
$inline_css[] = 'text-align:' . esc_attr( $align );
}
if ( ! empty( $inline_css ) ) {
$inline_css_string = ' style="' . implode( '', $inline_css ) . '"';
}
return '<h2' . $inline_css_string . '>' . $atts[ $tag ] . '</h2>';
}
}
return '';
}
/**
* @param $atts
* @return string
* @throws \Exception
*/
public function renderButton( $atts ) {
$button_atts = vc_map_integrate_parse_atts( $this->shortcode, 'vc_btn', $atts, 'hover_btn_' );
$button = visual_composer()->getShortCode( 'vc_btn' );
return $button->render( array_filter( $button_atts ) );
}
}

View File

@@ -0,0 +1,11 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Icon
* @since 4.4
*/
class WPBakeryShortCode_Vc_Icon extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,64 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-gallery.php' );
/**
* Class WPBakeryShortCode_Vc_images_carousel
*/
class WPBakeryShortCode_Vc_Images_Carousel extends WPBakeryShortCode_Vc_Gallery {
protected static $carousel_index = 1;
/**
* WPBakeryShortCode_Vc_images_carousel constructor.
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->jsCssScripts();
}
public function jsCssScripts() {
wp_register_script( 'vc_transition_bootstrap_js', vc_asset_url( 'lib/vc_carousel/js/transition.min.js' ), array(), WPB_VC_VERSION, true );
wp_register_script( 'vc_carousel_js', vc_asset_url( 'lib/vc_carousel/js/vc_carousel.min.js' ), array( 'vc_transition_bootstrap_js' ), WPB_VC_VERSION, true );
wp_register_style( 'vc_carousel_css', vc_asset_url( 'lib/vc_carousel/css/vc_carousel.min.css' ), array(), WPB_VC_VERSION );
}
/**
* @return string
*/
public static function getCarouselIndex() {
return ( self::$carousel_index ++ ) . '-' . time();
}
/**
* @param $size
* @return string
*/
protected function getSliderWidth( $size ) {
global $_wp_additional_image_sizes;
$width = '100%';
if ( in_array( $size, get_intermediate_image_sizes(), true ) ) {
if ( in_array( $size, array(
'thumbnail',
'medium',
'large',
), true ) ) {
$width = get_option( $size . '_size_w' ) . 'px';
} else {
if ( isset( $_wp_additional_image_sizes ) && isset( $_wp_additional_image_sizes[ $size ] ) ) {
$width = $_wp_additional_image_sizes[ $size ]['width'] . 'px';
}
}
} else {
preg_match_all( '/\d+/', $size, $matches );
if ( count( $matches[0] ) > 1 ) {
$width = $matches[0][0] . 'px';
}
}
return $width;
}
}

View File

@@ -0,0 +1,28 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Line_Chart
*/
class WPBakeryShortCode_Vc_Line_Chart extends WPBakeryShortCode {
/**
* WPBakeryShortCode_Vc_Line_Chart constructor.
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->jsScripts();
}
public function jsScripts() {
wp_register_script( 'vc_waypoints', vc_asset_url( 'lib/vc_waypoints/vc-waypoints.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'ChartJS', vc_asset_url( 'lib/bower/chartjs/Chart.min.js' ), array(), WPB_VC_VERSION, true );
wp_register_script( 'vc_line_chart', vc_asset_url( 'lib/vc_line_chart/vc_line_chart.min.js' ), array(
'jquery',
'vc_waypoints',
'ChartJS',
), WPB_VC_VERSION, true );
}
}

View File

@@ -0,0 +1,63 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-basic-grid.php' );
/**
* Class WPBakeryShortCode_Vc_Masonry_Grid
*/
class WPBakeryShortCode_Vc_Masonry_Grid extends WPBakeryShortCode_Vc_Basic_Grid {
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_basic_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';
}
/**
* @param $grid_style
* @param $settings
* @param $content
* @return string
*/
protected function contentAllMasonry( $grid_style, $settings, $content ) {
return parent::contentAll( $grid_style, $settings, $content );
}
/**
* @param $grid_style
* @param $settings
* @param $content
* @return string
*/
protected function contentLazyMasonry( $grid_style, $settings, $content ) {
return parent::contentLazy( $grid_style, $settings, $content );
}
/**
* @param $grid_style
* @param $settings
* @param $content
* @return string
*/
protected function contentLoadMoreMasonry( $grid_style, $settings, $content ) {
return parent::contentLoadMore( $grid_style, $settings, $content );
}
}

View File

@@ -0,0 +1,58 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-media-grid.php' );
/**
* Class WPBakeryShortCode_Vc_Masonry_Media_Grid
*/
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';
}
/**
* @param $grid_style
* @param $settings
* @param $content
* @return string
*/
protected function contentAllMasonry( $grid_style, $settings, $content ) {
return parent::contentAll( $grid_style, $settings, $content );
}
/**
* @param $grid_style
* @param $settings
* @param $content
* @return string
*/
protected function contentLazyMasonry( $grid_style, $settings, $content ) {
return parent::contentLazy( $grid_style, $settings, $content );
}
/**
* @param $grid_style
* @param $settings
* @param $content
* @return string
*/
protected function contentLoadMoreMasonry( $grid_style, $settings, $content ) {
return parent::contentLoadMore( $grid_style, $settings, $content );
}
}

View File

@@ -0,0 +1,133 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-basic-grid.php' );
/**
* Class WPBakeryShortCode_Vc_Media_Grid
*/
class WPBakeryShortCode_Vc_Media_Grid extends WPBakeryShortCode_Vc_Basic_Grid {
/**
* WPBakeryShortCode_Vc_Media_Grid constructor.
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
add_filter( $this->shortcode . '_items_list', array(
$this,
'setItemsIfEmpty',
) );
}
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_basic_grid';
}
/**
* @param $max_items
*/
protected function setPagingAll( $max_items ) {
$this->atts['items_per_page'] = $this->atts['query_items_per_page'] = apply_filters( 'vc_basic_grid_items_per_page_all_max_items', self::$default_max_items );
}
/**
* @param $atts
* @return array
*/
public function buildQuery( $atts ) {
if ( empty( $atts['include'] ) ) {
$atts['include'] = - 1;
}
$settings = array(
'include' => $atts['include'],
'posts_per_page' => apply_filters( 'vc_basic_grid_max_items', self::$default_max_items ),
'offset' => 0,
'post_type' => 'attachment',
'orderby' => 'post__in',
);
return $settings;
}
/**
* @param $items
* @return string
*/
public function setItemsIfEmpty( $items ) {
if ( empty( $items ) ) {
require_once vc_path_dir( 'PARAMS_DIR', 'vc_grid_item/class-vc-grid-item.php' );
$grid_item = new Vc_Grid_Item();
$grid_item->setGridAttributes( $this->atts );
$grid_item->shortcodes();
$item = '[vc_gitem]<img src="' . esc_url( vc_asset_url( 'vc/vc_gitem_image.png' ) ) . '">[/vc_gitem]';
$grid_item->parseTemplate( $item );
$items = str_repeat( $grid_item->renderItem( get_post( (int) vc_request_param( 'vc_post_id' ) ) ), 3 );
}
return $items;
}
/**
* @param $param
* @param $value
* @return string
*/
public function singleParamHtmlHolder( $param, $value ) {
$output = '';
// Compatibility fixes
// TODO: check $old_names & &new_names. Leftover from copypasting?
$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 ( 'include' === $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" src="' . esc_url( 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' : '' ) . '">' . esc_html__( 'Add images', 'js_composer' ) . '</a>';
}
return $output;
}
}

View File

@@ -0,0 +1,39 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Message
*/
class WPBakeryShortCode_Vc_Message extends WPBakeryShortCode {
/**
* @param $atts
* @return mixed
*/
public static function convertAttributesToMessageBox2( $atts ) {
if ( isset( $atts['style'] ) ) {
if ( '3d' === $atts['style'] ) {
$atts['message_box_style'] = '3d';
$atts['style'] = 'rounded';
} elseif ( 'outlined' === $atts['style'] ) {
$atts['message_box_style'] = 'outline';
$atts['style'] = 'rounded';
} elseif ( 'square_outlined' === $atts['style'] ) {
$atts['message_box_style'] = 'outline';
$atts['style'] = 'square';
}
}
return $atts;
}
/**
* @param $title
* @return string
*/
public function outputTitle( $title ) {
return '';
}
}

View File

@@ -0,0 +1,60 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Pie
*/
class WPBakeryShortCode_Vc_Pie extends WPBakeryShortCode {
/**
* WPBakeryShortCode_Vc_Pie constructor.
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->jsScripts();
}
public function jsScripts() {
wp_register_script( 'vc_waypoints', vc_asset_url( 'lib/vc_waypoints/vc-waypoints.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'progressCircle', vc_asset_url( 'lib/bower/progress-circle/ProgressCircle.min.js' ), array(), WPB_VC_VERSION, true );
wp_register_script( 'vc_pie', vc_asset_url( 'lib/vc_chart/jquery.vc_chart.min.js' ), array(
'jquery',
'vc_waypoints',
'progressCircle',
), WPB_VC_VERSION, true );
}
/**
* Convert old color names to new ones for BC
*
* @param array $atts
*
* @return array
*/
public static function convertOldColorsToNew( $atts ) {
$map = array(
'btn-primary' => '#0088cc',
'btn-success' => '#6ab165',
'btn-warning' => '#ff9900',
'btn-inverse' => '#555555',
'btn-danger' => '#ff675b',
'btn-info' => '#58b9da',
'primary' => '#0088cc',
'success' => '#6ab165',
'warning' => '#ff9900',
'inverse' => '#555555',
'danger' => '#ff675b',
'info' => '#58b9da',
'default' => '#f7f7f7',
);
if ( isset( $atts['color'] ) && isset( $map[ $atts['color'] ] ) ) {
$atts['custom_color'] = $map[ $atts['color'] ];
$atts['color'] = 'custom';
}
return $atts;
}
}

View File

@@ -0,0 +1,40 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Pinterest
*/
class WPBakeryShortCode_Vc_Pinterest extends WPBakeryShortCode {
/**
* @param $atts
* @param null $content
* @return string
* @throws \Exception
*/
protected function contentInline( $atts, $content = null ) {
/**
* Shortcode attributes
* @var $atts
* @var $type
* @var $annotation // TODO: check why annotation doesn't set before
* @var $css
* @var $css_animation
* Shortcode class
* @var WPBakeryShortCode_Vc_Pinterest $this
*/
$type = $annotation = $css = $css_animation = '';
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );
$css = isset( $atts['css'] ) ? $atts['css'] : '';
$el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : '';
$class_to_filter = 'wpb_googleplus vc_social-placeholder wpb_content_element vc_socialtype-' . $type;
$class_to_filter .= vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation );
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
return '<div class="' . esc_attr( $css_class ) . '"></div>';
}
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Posts_slider
*/
class WPBakeryShortCode_Vc_Posts_Slider extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,42 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Progress_Bar
*/
class WPBakeryShortCode_Vc_Progress_Bar extends WPBakeryShortCode {
/**
* @param $atts
* @return mixed
*/
public static function convertAttributesToNewProgressBar( $atts ) {
if ( isset( $atts['values'] ) && strlen( $atts['values'] ) > 0 ) {
$values = vc_param_group_parse_atts( $atts['values'] );
if ( ! is_array( $values ) ) {
$temp = explode( ',', $atts['values'] );
$paramValues = array();
foreach ( $temp as $value ) {
$data = explode( '|', $value );
$colorIndex = 2;
$newLine = array();
$newLine['value'] = isset( $data[0] ) ? $data[0] : 0;
$newLine['label'] = isset( $data[1] ) ? $data[1] : '';
if ( isset( $data[1] ) && preg_match( '/^\d{1,3}\%$/', $data[1] ) ) {
$colorIndex ++;
$newLine['value'] = (float) str_replace( '%', '', $data[1] );
$newLine['label'] = isset( $data[2] ) ? $data[2] : '';
}
if ( isset( $data[ $colorIndex ] ) ) {
$newLine['customcolor'] = $data[ $colorIndex ];
}
$paramValues[] = $newLine;
}
$atts['values'] = rawurlencode( wp_json_encode( $paramValues ) );
}
}
return $atts;
}
}

View File

@@ -0,0 +1,59 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
*/
class WPBakeryShortCode_Vc_Raw_Html extends WPBakeryShortCode {
/**
* @param $param
* @param $value
* @return string
*/
public function singleParamHtmlHolder( $param, $value ) {
$output = '';
// Compatibility fixes
// TODO: check $old_names & &new_names. Leftover from copypasting?
$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'] ) {
if ( 'textarea_raw_html' === $param['type'] ) {
// @codingStandardsIgnoreLine
$output .= sprintf( '<%s class="wpb_vc_param_value %s %s %s" name="%s">%s</%s><input type="hidden" name="%s_code" class="%s_code" value="%s" />', $param['holder'], $param_name, $type, $class, $param_name, htmlentities( rawurldecode( base64_decode( wp_strip_all_tags( $value ) ) ), ENT_COMPAT, 'UTF-8' ), $param['holder'], $param_name, $param_name, wp_strip_all_tags( $value ) );
} else {
$output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '">' . $value . '</' . $param['holder'] . '>';
}
}
return $output;
}
}

View File

@@ -0,0 +1,48 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-raw-html.php' );
/**
* Class WPBakeryShortCode_Vc_Raw_Js
*/
class WPBakeryShortCode_Vc_Raw_Js extends WPBakeryShortCode_Vc_Raw_html {
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_raw_html';
}
/**
* @param $atts
* @param null $content
* @return string
*/
protected function contentInline( $atts, $content = null ) {
$el_class = $width = $el_position = '';
extract( shortcode_atts( array(
'el_class' => '',
'el_position' => '',
'width' => '1/2',
), $atts ) );
$el_class = $this->getExtraClass( $el_class );
$el_class .= ' wpb_raw_js';
// @codingStandardsIgnoreLine
$content = rawurldecode( base64_decode( wp_strip_all_tags( $content ) ) );
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'wpb_raw_code' . $el_class, $this->settings['base'], $atts );
$output = '
<div class="' . $css_class . '">
<div class="wpb_wrapper">
<textarea style="display: none;" class="vc_js_inline_holder">' . esc_attr( $content ) . '</textarea>
</div>
</div>
';
return $output;
}
}

View File

@@ -0,0 +1,28 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Round_Chart
*/
class WPBakeryShortCode_Vc_Round_Chart extends WPBakeryShortCode {
/**
* WPBakeryShortCode_Vc_Round_Chart constructor.
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->jsScripts();
}
public function jsScripts() {
wp_register_script( 'vc_waypoints', vc_asset_url( 'lib/vc_waypoints/vc-waypoints.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'ChartJS', vc_asset_url( 'lib/bower/chartjs/Chart.min.js' ), array(), WPB_VC_VERSION, true );
wp_register_script( 'vc_round_chart', vc_asset_url( 'lib/vc_round_chart/vc_round_chart.min.js' ), array(
'jquery',
'vc_waypoints',
'ChartJS',
), WPB_VC_VERSION, true );
}
}

View File

@@ -0,0 +1,21 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-row.php' );
/**
* Class WPBakeryShortCode_Vc_Row_Inner
*/
class WPBakeryShortCode_Vc_Row_Inner extends WPBakeryShortCode_Vc_Row {
/**
* @param string $content
* @return string
* @throws \Exception
*/
public function template( $content = '' ) {
return $this->contentAdmin( $this->atts );
}
}

View File

@@ -0,0 +1,236 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder row
*
* @package WPBakeryPageBuilder
*
*/
class WPBakeryShortCode_Vc_Row extends WPBakeryShortCode {
protected $predefined_atts = array(
'el_class' => '',
);
public $nonDraggableClass = 'vc-non-draggable-row';
/**
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->shortcodeScripts();
}
protected function shortcodeScripts() {
wp_register_script( 'vc_jquery_skrollr_js', vc_asset_url( 'lib/bower/skrollr/dist/skrollr.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'vc_youtube_iframe_api_js', 'https://www.youtube.com/iframe_api', array(), WPB_VC_VERSION, true );
}
/**
* @param $atts
* @param null $content
* @return mixed|string
*/
protected function content( $atts, $content = null ) {
$prefix = '';
return $prefix . $this->loadTemplate( $atts, $content );
}
/**
* This returs block controls
*/
public function getLayoutsControl() {
global $vc_row_layouts;
$controls_layout = '<span class="vc_row_layouts vc_control">';
foreach ( $vc_row_layouts as $layout ) {
$controls_layout .= '<a class="vc_control-set-column set_columns" data-cells="' . $layout['cells'] . '" data-cells-mask="' . $layout['mask'] . '" title="' . $layout['title'] . '"><i class="vc-composer-icon vc-c-icon-' . $layout['icon_class'] . '"></i></a> ';
}
$controls_layout .= '<br/><a class="vc_control-set-column set_columns custom_columns" data-cells="custom" data-cells-mask="custom" title="' . esc_attr__( 'Custom layout', 'js_composer' ) . '">' . esc_html__( 'Custom', 'js_composer' ) . '</a> ';
$controls_layout .= '</span>';
return $controls_layout;
}
/**
* @param $controls
* @param string $extended_css
* @return string
* @throws \Exception
*/
public function getColumnControls( $controls, $extended_css = '' ) {
$output = '<div class="vc_controls vc_controls-row controls_row vc_clearfix">';
$controls_end = '</div>';
// Create columns
$controls_layout = $this->getLayoutsControl();
$controls_move = ' <a class="vc_control column_move vc_column-move" href="#" title="' . esc_attr__( 'Drag row to reorder', 'js_composer' ) . '" data-vc-control="move"><i class="vc-composer-icon vc-c-icon-dragndrop"></i></a>';
$moveAccess = vc_user_access()->part( 'dragndrop' )->checkStateAny( true, null )->get();
if ( ! $moveAccess ) {
$controls_move = '';
}
$controls_add = ' <a class="vc_control column_add vc_column-add" href="#" title="' . esc_attr__( 'Add column', 'js_composer' ) . '" data-vc-control="add"><i class="vc-composer-icon vc-c-icon-add"></i></a>';
$controls_delete = '<a class="vc_control column_delete vc_column-delete" href="#" title="' . esc_attr__( 'Delete this row', 'js_composer' ) . '" data-vc-control="delete"><i class="vc-composer-icon vc-c-icon-delete_empty"></i></a>';
$controls_edit = ' <a class="vc_control column_edit vc_column-edit" href="#" title="' . esc_attr__( 'Edit this row', 'js_composer' ) . '" data-vc-control="edit"><i class="vc-composer-icon vc-c-icon-mode_edit"></i></a>';
$controls_clone = ' <a class="vc_control column_clone vc_column-clone" href="#" title="' . esc_attr__( 'Clone this row', 'js_composer' ) . '" data-vc-control="clone"><i class="vc-composer-icon vc-c-icon-content_copy"></i></a>';
$controls_toggle = ' <a class="vc_control column_toggle vc_column-toggle" href="#" title="' . esc_attr__( 'Toggle row', 'js_composer' ) . '" data-vc-control="toggle"><i class="vc-composer-icon vc-c-icon-arrow_drop_down"></i></a>';
$editAccess = vc_user_access_check_shortcode_edit( $this->shortcode );
$allAccess = vc_user_access_check_shortcode_all( $this->shortcode );
if ( is_array( $controls ) && ! empty( $controls ) ) {
foreach ( $controls as $control ) {
$control_var = 'controls_' . $control;
if ( ( $editAccess && 'edit' === $control ) || $allAccess ) {
if ( isset( ${$control_var} ) ) {
$output .= ${$control_var};
}
}
}
$output .= $controls_end;
} elseif ( is_string( $controls ) ) {
$control_var = 'controls_' . $controls;
if ( ( $editAccess && 'edit' === $controls ) || $allAccess ) {
if ( isset( ${$control_var} ) ) {
$output .= ${$control_var} . $controls_end;
}
}
} else {
$row_edit_clone_delete = '<span class="vc_row_edit_clone_delete">';
if ( $allAccess ) {
$row_edit_clone_delete .= $controls_delete . $controls_clone . $controls_edit;
} elseif ( $editAccess ) {
$row_edit_clone_delete .= $controls_edit;
}
$row_edit_clone_delete .= $controls_toggle;
$row_edit_clone_delete .= '</span>';
if ( $allAccess ) {
$output .= '<div>' . $controls_move . $controls_layout . $controls_add . '</div>' . $row_edit_clone_delete . $controls_end;
} elseif ( $editAccess ) {
$output .= $row_edit_clone_delete . $controls_end;
} else {
$output .= $row_edit_clone_delete . $controls_end;
}
}
return $output;
}
/**
* @param $atts
* @param null $content
* @return string
* @throws \Exception
*/
public function contentAdmin( $atts, $content = null ) {
$atts = shortcode_atts( $this->predefined_atts, $atts );
$output = '';
$column_controls = $this->getColumnControls( $this->settings( 'controls' ) );
$output .= '<div data-element_type="' . $this->settings['base'] . '" class="' . $this->cssAdminClass() . '">';
$output .= str_replace( '%column_size%', 1, $column_controls );
$output .= '<div class="wpb_element_wrapper">';
$output .= '<div class="vc_row vc_row-fluid wpb_row_container vc_container_for_children">';
if ( '' === $content && ! empty( $this->settings['default_content_in_template'] ) ) {
$output .= do_shortcode( shortcode_unautop( $this->settings['default_content_in_template'] ) );
} else {
$output .= do_shortcode( shortcode_unautop( $content ) );
}
$output .= '</div>';
if ( isset( $this->settings['params'] ) ) {
$inner = '';
foreach ( $this->settings['params'] as $param ) {
if ( ! isset( $param['param_name'] ) ) {
continue;
}
$param_value = isset( $atts[ $param['param_name'] ] ) ? $atts[ $param['param_name'] ] : '';
if ( is_array( $param_value ) ) {
// Get first element from the array
reset( $param_value );
$first_key = key( $param_value );
$param_value = $param_value[ $first_key ];
}
$inner .= $this->singleParamHtmlHolder( $param, $param_value );
}
$output .= $inner;
}
$output .= '</div>';
$output .= '</div>';
return $output;
}
/**
* @return string
* @throws \Exception
*/
public function cssAdminClass() {
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? ' wpb_sortable' : ' ' . $this->nonDraggableClass );
return 'wpb_' . $this->settings['base'] . $sortable . '' . ( ! empty( $this->settings['class'] ) ? ' ' . $this->settings['class'] : '' );
}
/**
* @return string
* @deprecated 4.5 - due to it is not used anywhere? 4.5
* @typo Bock - Block
*/
public function customAdminBockParams() {
// this function is depreacted
return '';
}
/**
* @param string $bg_image
* @param string $bg_color
* @param string $bg_image_repeat
* @param string $font_color
* @param string $padding
* @param string $margin_bottom
*
* @return string
* @deprecated 4.5
*
*/
public function buildStyle( $bg_image = '', $bg_color = '', $bg_image_repeat = '', $font_color = '', $padding = '', $margin_bottom = '' ) {
// this function is deprecated
$has_image = false;
$style = '';
$image_url = wp_get_attachment_url( $bg_image );
if ( $image_url ) {
$has_image = true;
$style .= 'background-image: url(' . $image_url . ');';
}
if ( ! empty( $bg_color ) ) {
$style .= vc_get_css_color( 'background-color', $bg_color );
}
if ( ! empty( $bg_image_repeat ) && $has_image ) {
if ( 'cover' === $bg_image_repeat ) {
$style .= 'background-repeat:no-repeat;background-size: cover;';
} elseif ( 'contain' === $bg_image_repeat ) {
$style .= 'background-repeat:no-repeat;background-size: contain;';
} elseif ( 'no-repeat' === $bg_image_repeat ) {
$style .= 'background-repeat: no-repeat;';
}
}
if ( ! empty( $font_color ) ) {
$style .= vc_get_css_color( 'color', $font_color );
}
if ( '' !== $padding ) {
$style .= 'padding: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $padding ) ? $padding : $padding . 'px' ) . ';';
}
if ( '' !== $margin_bottom ) {
$style .= 'margin-bottom: ' . ( preg_match( '/(px|em|\%|pt|cm)$/', $margin_bottom ) ? $margin_bottom : $margin_bottom . 'px' ) . ';';
}
return empty( $style ) ? '' : ' style="' . esc_attr( $style ) . '"';
}
}

View File

@@ -0,0 +1,141 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* WPBakery WPBakery Page Builder section
*
* @package WPBakeryPageBuilder
*
*/
class WPBakeryShortCode_Vc_Section extends WPBakeryShortCodesContainer {
/**
* @param $width
* @param $i
* @return string
*/
public function containerHtmlBlockParams( $width, $i ) {
return 'class="vc_section_container vc_container_for_children"';
}
/**
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->shortcodeScripts();
}
protected function shortcodeScripts() {
wp_register_script( 'vc_jquery_skrollr_js', vc_asset_url( 'lib/bower/skrollr/dist/skrollr.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'vc_youtube_iframe_api_js', 'https://www.youtube.com/iframe_api', array(), WPB_VC_VERSION, true );
}
/**
* @return string
* @throws \Exception
*/
public function cssAdminClass() {
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? ' wpb_sortable' : ' ' . $this->nonDraggableClass );
return 'wpb_' . $this->settings['base'] . $sortable . '' . ( ! empty( $this->settings['class'] ) ? ' ' . $this->settings['class'] : '' );
}
/**
* @param string $controls
* @param string $extended_css
* @return string
* @throws \Exception
*/
public function getColumnControls( $controls = 'full', $extended_css = '' ) {
$controls_start = '<div class="vc_controls vc_controls-visible controls_column' . ( ! empty( $extended_css ) ? " {$extended_css}" : '' ) . '">';
$output = '<div class="vc_controls vc_controls-row controls_row vc_clearfix">';
$controls_end = '</div>';
// Create columns
$controls_move = ' <a class="vc_control column_move vc_column-move" href="#" title="' . esc_attr__( 'Drag row to reorder', 'js_composer' ) . '" data-vc-control="move"><i class="vc-composer-icon vc-c-icon-dragndrop"></i></a>';
$moveAccess = vc_user_access()->part( 'dragndrop' )->checkStateAny( true, null )->get();
if ( ! $moveAccess ) {
$controls_move = '';
}
$controls_add = ' <a class="vc_control column_add vc_column-add" href="#" title="' . esc_attr__( 'Add column', 'js_composer' ) . '" data-vc-control="add"><i class="vc-composer-icon vc-c-icon-add"></i></a>';
$controls_delete = '<a class="vc_control column_delete vc_column-delete" href="#" title="' . esc_attr__( 'Delete this row', 'js_composer' ) . '" data-vc-control="delete"><i class="vc-composer-icon vc-c-icon-delete_empty"></i></a>';
$controls_edit = ' <a class="vc_control column_edit vc_column-edit" href="#" title="' . esc_attr__( 'Edit this row', 'js_composer' ) . '" data-vc-control="edit"><i class="vc-composer-icon vc-c-icon-mode_edit"></i></a>';
$controls_clone = ' <a class="vc_control column_clone vc_column-clone" href="#" title="' . esc_attr__( 'Clone this row', 'js_composer' ) . '" data-vc-control="clone"><i class="vc-composer-icon vc-c-icon-content_copy"></i></a>';
$editAccess = vc_user_access_check_shortcode_edit( $this->shortcode );
$allAccess = vc_user_access_check_shortcode_all( $this->shortcode );
$row_edit_clone_delete = '<span class="vc_row_edit_clone_delete">';
if ( 'add' === $controls ) {
return $controls_start . $controls_add . $controls_end;
}
if ( $allAccess ) {
$row_edit_clone_delete .= $controls_delete . $controls_clone . $controls_edit;
} elseif ( $editAccess ) {
$row_edit_clone_delete .= $controls_edit;
}
$row_edit_clone_delete .= '</span>';
if ( $allAccess ) {
$output .= '<div>' . $controls_move . $controls_add . '</div>' . $row_edit_clone_delete . $controls_end;
} elseif ( $editAccess ) {
$output .= $row_edit_clone_delete . $controls_end;
} else {
$output .= $row_edit_clone_delete . $controls_end;
}
return $output;
}
/**
* @param $atts
* @param null $content
* @return string
* @throws \Exception
*/
public function contentAdmin( $atts, $content = null ) {
$width = '';
$atts = shortcode_atts( $this->predefined_atts, $atts );
$output = '';
$column_controls = $this->getColumnControls();
$output .= '<div data-element_type="' . $this->settings['base'] . '" class="' . $this->cssAdminClass() . '">';
$output .= str_replace( '%column_size%', 1, $column_controls );
$output .= '<div class="wpb_element_wrapper">';
if ( isset( $this->settings['custom_markup'] ) && '' !== $this->settings['custom_markup'] ) {
$markup = $this->settings['custom_markup'];
$output .= $this->customMarkup( $markup );
} else {
$output .= '<div ' . $this->containerHtmlBlockParams( $width, 1 ) . '>';
$output .= do_shortcode( shortcode_unautop( $content ) );
$output .= '</div>';
}
if ( isset( $this->settings['params'] ) ) {
$inner = '';
foreach ( $this->settings['params'] as $param ) {
if ( ! isset( $param['param_name'] ) ) {
continue;
}
$param_value = isset( $atts[ $param['param_name'] ] ) ? $atts[ $param['param_name'] ] : '';
if ( is_array( $param_value ) ) {
// Get first element from the array
reset( $param_value );
$first_key = key( $param_value );
$param_value = $param_value[ $first_key ];
}
$inner .= $this->singleParamHtmlHolder( $param, $param_value );
}
$output .= $inner;
}
$output .= '</div>';
if ( $this->backened_editor_prepend_controls ) {
$output .= $this->getColumnControls( 'add', 'vc_section-bottom-controls bottom-controls' );
}
$output .= '</div>';
return $output;
}
}

View File

@@ -0,0 +1,18 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Separator
*/
class WPBakeryShortCode_Vc_Separator extends WPBakeryShortCode {
/**
* @param $title
* @return string
*/
public function outputTitle( $title ) {
return '';
}
}

View File

@@ -0,0 +1,137 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Single_image
*/
class WPBakeryShortCode_Vc_Single_Image extends WPBakeryShortCode {
/**
* WPBakeryShortCode_Vc_Single_image constructor.
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->jsScripts();
}
public function jsScripts() {
wp_register_script( 'zoom', vc_asset_url( 'lib/bower/zoom/jquery.zoom.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'vc_image_zoom', vc_asset_url( 'lib/vc_image_zoom/vc_image_zoom.min.js' ), array(
'jquery',
'zoom',
), WPB_VC_VERSION, true );
}
/**
* @param $param
* @param $value
* @return string
*/
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 ( 'attach_image' === $param['type'] && 'image' === $param_name ) {
$output .= '<input type="hidden" class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" value="' . $value . '" />';
$element_icon = $this->settings( 'icon' );
$img = wpb_getImageBySize( array(
'attach_id' => (int) preg_replace( '/[^\d]/', '', $value ),
'thumb_size' => 'thumbnail',
) );
$this->setSettings( 'logo', ( $img ? $img['thumbnail'] : '<img width="150" height="150" src="' . esc_url( vc_asset_url( 'vc/blank.gif' ) ) . '" class="attachment-thumbnail vc_general vc_element-icon" data-name="' . $param_name . '" alt="" title="" style="display: none;" />' ) . '<span class="no_image_image vc_element-icon' . ( ! empty( $element_icon ) ? ' ' . $element_icon : '' ) . ( $img && ! empty( $img['p_img_large'][0] ) ? ' image-exists' : '' ) . '"></span><a href="#" class="column_edit_trigger' . ( $img && ! empty( $img['p_img_large'][0] ) ? ' image-exists' : '' ) . '">' . esc_html__( 'Add image', 'js_composer' ) . '</a>' );
$output .= $this->outputTitleTrue( $this->settings['name'] );
} elseif ( ! empty( $param['holder'] ) ) {
if ( 'input' === $param['holder'] ) {
$output .= '<' . $param['holder'] . ' readonly="true" class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" value="' . $value . '">';
} elseif ( in_array( $param['holder'], array(
'img',
'iframe',
), true ) ) {
$output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '" src="' . esc_url( $value ) . '">';
} elseif ( 'hidden' !== $param['holder'] ) {
$output .= '<' . $param['holder'] . ' class="wpb_vc_param_value ' . $param_name . ' ' . $type . ' ' . $class . '" name="' . $param_name . '">' . $value . '</' . $param['holder'] . '>';
}
}
if ( ! empty( $param['admin_label'] ) && true === $param['admin_label'] ) {
$output .= '<span class="vc_admin_label admin_label_' . $param['param_name'] . ( empty( $value ) ? ' hidden-label' : '' ) . '"><label>' . $param['heading'] . '</label>: ' . $value . '</span>';
}
return $output;
}
/**
* @param $img_id
* @param $img_size
* @return string
*/
public function getImageSquareSize( $img_id, $img_size ) {
if ( preg_match_all( '/(\d+)x(\d+)/', $img_size, $sizes ) ) {
$exact_size = array(
'width' => isset( $sizes[1][0] ) ? $sizes[1][0] : '0',
'height' => isset( $sizes[2][0] ) ? $sizes[2][0] : '0',
);
} else {
$image_downsize = image_downsize( $img_id, $img_size );
$exact_size = array(
'width' => $image_downsize[1],
'height' => $image_downsize[2],
);
}
$exact_size_int_w = (int) $exact_size['width'];
$exact_size_int_h = (int) $exact_size['height'];
if ( isset( $exact_size['width'] ) && $exact_size_int_w !== $exact_size_int_h ) {
$img_size = $exact_size_int_w > $exact_size_int_h ? $exact_size['height'] . 'x' . $exact_size['height'] : $exact_size['width'] . 'x' . $exact_size['width'];
}
return $img_size;
}
/**
* @param $title
* @return string
*/
protected function outputTitle( $title ) {
return '';
}
/**
* @param $title
* @return string
*/
protected function outputTitleTrue( $title ) {
return '<h4 class="wpb_element_title">' . $title . ' ' . $this->settings( 'logo' ) . '</h4>';
}
}

View File

@@ -0,0 +1,72 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
define( 'TAB_TITLE', esc_attr__( 'Tab', 'js_composer' ) );
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-column.php' );
/**
* Class WPBakeryShortCode_Vc_Tab
*/
class WPBakeryShortCode_Vc_Tab extends WPBakeryShortCode_Vc_Column {
protected $controls_css_settings = 'tc vc_control-container';
protected $controls_list = array(
'add',
'edit',
'clone',
'delete',
);
protected $controls_template_file = 'editors/partials/backend_controls_tab.tpl.php';
/**
* @return string
*/
public function customAdminBlockParams() {
return ' id="tab-' . $this->atts['tab_id'] . '"';
}
/**
* @param $width
* @param $i
* @return string
* @throws \Exception
*/
public function mainHtmlBlockParams( $width, $i ) {
$sortable = ( vc_user_access_check_shortcode_all( $this->shortcode ) ? 'wpb_sortable' : $this->nonDraggableClass );
return 'data-element_type="' . $this->settings['base'] . '" class="wpb_' . $this->settings['base'] . ' ' . $sortable . ' wpb_content_holder"' . $this->customAdminBlockParams();
}
/**
* @param $width
* @param $i
* @return string
*/
public function containerHtmlBlockParams( $width, $i ) {
return 'class="wpb_column_container vc_container_for_children"';
}
/**
* @param $controls
* @param string $extended_css
* @return string
* @throws \Exception
*/
public function getColumnControls( $controls, $extended_css = '' ) {
return $this->getColumnControlsModular( $extended_css );
}
}
/**
* @param $settings
* @param $value
*
* @return string
* @since 4.4
*/
function vc_tab_id_settings_field( $settings, $value ) {
return sprintf( '<div class="vc_tab_id_block"><input name="%s" class="wpb_vc_param_value wpb-textinput %s %s_field" type="hidden" value="%s" /><label>%s</label></div>', $settings['param_name'], $settings['param_name'], $settings['type'], $value, $value );
}
vc_add_shortcode_param( 'tab_id', 'vc_tab_id_settings_field' );

View File

@@ -0,0 +1,117 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Tabs
*/
class WPBakeryShortCode_Vc_Tabs extends WPBakeryShortCode {
public static $filter_added = false;
protected $controls_css_settings = 'out-tc vc_controls-content-widget';
protected $controls_list = array(
'edit',
'clone',
'delete',
);
/**
* WPBakeryShortCode_Vc_Tabs constructor.
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
if ( ! self::$filter_added ) {
add_filter( 'vc_inline_template_content', array(
$this,
'setCustomTabId',
) );
self::$filter_added = true;
}
}
/**
* @param $atts
* @param null $content
* @return mixed|string
* @throws \Exception
*/
public function contentAdmin( $atts, $content = null ) {
$width = $custom_markup = '';
$shortcode_attributes = array( 'width' => '1/1' );
foreach ( $this->settings['params'] as $param ) {
if ( 'content' !== $param['param_name'] ) {
$shortcode_attributes[ $param['param_name'] ] = isset( $param['value'] ) ? $param['value'] : null;
} elseif ( 'content' === $param['param_name'] && null === $content ) {
$content = $param['value'];
}
}
extract( shortcode_atts( $shortcode_attributes, $atts ) );
// Extract tab titles
preg_match_all( '/vc_tab title="([^\"]+)"(\stab_id\=\"([^\"]+)\"){0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE );
$tab_titles = array();
if ( isset( $matches[0] ) ) {
$tab_titles = $matches[0];
}
$tmp = '';
if ( count( $tab_titles ) ) {
$tmp .= '<ul class="clearfix tabs_controls">';
foreach ( $tab_titles as $tab ) {
preg_match( '/title="([^\"]+)"(\stab_id\=\"([^\"]+)\"){0,1}/i', $tab[0], $tab_matches, PREG_OFFSET_CAPTURE );
if ( isset( $tab_matches[1][0] ) ) {
$tmp .= '<li><a href="#tab-' . ( isset( $tab_matches[3][0] ) ? $tab_matches[3][0] : sanitize_title( $tab_matches[1][0] ) ) . '">' . $tab_matches[1][0] . '</a></li>';
}
}
$tmp .= '</ul>' . "\n";
}
$elem = $this->getElementHolder( $width );
$iner = '';
foreach ( $this->settings['params'] as $param ) {
$param_value = isset( ${$param['param_name']} ) ? ${$param['param_name']} : '';
if ( is_array( $param_value ) ) {
// Get first element from the array
reset( $param_value );
$first_key = key( $param_value );
$param_value = $param_value[ $first_key ];
}
$iner .= $this->singleParamHtmlHolder( $param, $param_value );
}
if ( isset( $this->settings['custom_markup'] ) && '' !== $this->settings['custom_markup'] ) {
if ( '' !== $content ) {
$custom_markup = str_ireplace( '%content%', $tmp . $content, $this->settings['custom_markup'] );
} elseif ( '' === $content && isset( $this->settings['default_content_in_template'] ) && '' !== $this->settings['default_content_in_template'] ) {
$custom_markup = str_ireplace( '%content%', $this->settings['default_content_in_template'], $this->settings['custom_markup'] );
} else {
$custom_markup = str_ireplace( '%content%', '', $this->settings['custom_markup'] );
}
$iner .= do_shortcode( $custom_markup );
}
$elem = str_ireplace( '%wpb_element_content%', $iner, $elem );
$output = $elem;
return $output;
}
/**
* @return string
*/
public function getTabTemplate() {
return '<div class="wpb_template">' . do_shortcode( '[vc_tab title="Tab" tab_id=""][/vc_tab]' ) . '</div>';
}
/**
* @param $content
* @return string|string[]|null
*/
public function setCustomTabId( $content ) {
return preg_replace( '/tab\_id\=\"([^\"]+)\"/', 'tab_id="$1-' . time() . '"', $content );
}
}

View File

@@ -0,0 +1,39 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Text_separator
*/
class WPBakeryShortCode_Vc_Text_Separator extends WPBakeryShortCode {
/**
* @param $title
* @return string
*/
public function outputTitle( $title ) {
return '';
}
/**
* @param $atts
* @return string
* @throws \Exception
*/
public function getVcIcon( $atts ) {
if ( empty( $atts['i_type'] ) ) {
$atts['i_type'] = 'fontawesome';
}
$data = vc_map_integrate_parse_atts( $this->shortcode, 'vc_icon', $atts, 'i_' );
if ( $data ) {
$icon = visual_composer()->getShortCode( 'vc_icon' );
if ( is_object( $icon ) ) {
return $icon->render( array_filter( $data ) );
}
}
return '';
}
}

View File

@@ -0,0 +1,35 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Toggle
*/
class WPBakeryShortCode_Vc_Toggle extends WPBakeryShortCode {
/**
* @param $title
* @return string
*/
public function outputTitle( $title ) {
return '';
}
/**
* @param $atts
* @return string
* @throws \Exception
*/
public function getHeading( $atts ) {
if ( isset( $atts['use_custom_heading'] ) && 'true' === $atts['use_custom_heading'] ) {
$custom_heading = visual_composer()->getShortCode( 'vc_custom_heading' );
$data = vc_map_integrate_parse_atts( $this->shortcode, 'vc_custom_heading', $atts, 'custom_' );
$data['text'] = $atts['title'];
return $custom_heading->render( array_filter( $data ) );
} else {
return '<h4>' . esc_html( $atts['title'] ) . '</h4>';
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
require_once vc_path_dir( 'SHORTCODES_DIR', 'vc-tabs.php' );
/**
* Class WPBakeryShortCode_Vc_Tour
*/
class WPBakeryShortCode_Vc_Tour extends WPBakeryShortCode_Vc_Tabs {
/**
* @return mixed|string
*/
protected function getFileName() {
return 'vc_tabs';
}
/**
* @return string
*/
public function getTabTemplate() {
return '<div class="wpb_template">' . do_shortcode( '[vc_tab title="' . esc_attr__( 'Slide', 'js_composer' ) . '" tab_id=""][/vc_tab]' ) . '</div>';
}
}

View File

@@ -0,0 +1,451 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Tta_Accordion
*/
class WPBakeryShortCode_Vc_Tta_Accordion extends WPBakeryShortCodesContainer {
protected $controls_css_settings = 'out-tc vc_controls-content-widget';
protected $controls_list = array(
'add',
'edit',
'clone',
'delete',
);
protected $template_vars = array();
public $layout = 'accordion';
protected $content;
public $activeClass = 'vc_active';
/**
* @var WPBakeryShortCode_Vc_Tta_Section
*/
protected $sectionClass;
public $nonDraggableClass = 'vc-non-draggable-container';
/**
* @return mixed|string
*/
public function getFileName() {
return 'vc_tta_global';
}
/**
* @return string
*/
public function containerContentClass() {
return 'vc_container_for_children vc_clearfix';
}
/**
* @param $atts
* @param $content
*
*/
public function resetVariables( $atts, $content ) {
$this->atts = $atts;
$this->content = $content;
$this->template_vars = array();
}
/**
* @return bool
* @throws \Exception
*/
public function setGlobalTtaInfo() {
$sectionClass = visual_composer()->getShortCode( 'vc_tta_section' )->shortcodeClass();
$this->sectionClass = $sectionClass;
/** @var WPBakeryShortCode_Vc_Tta_Section $sectionClass */
if ( is_object( $sectionClass ) ) {
VcShortcodeAutoloader::getInstance()->includeClass( 'WPBakeryShortCode_Vc_Tta_Section' );
WPBakeryShortCode_Vc_Tta_Section::$tta_base_shortcode = $this;
WPBakeryShortCode_Vc_Tta_Section::$self_count = 0;
WPBakeryShortCode_Vc_Tta_Section::$section_info = array();
return true;
}
return false;
}
/**
* Override default getColumnControls to make it "simple"(blue), as single element has
*
* @param string $controls
* @param string $extended_css
*
* @return string
* @throws \Exception
*/
public function getColumnControls( $controls = 'full', $extended_css = '' ) {
// we don't need containers bottom-controls for tabs
if ( 'bottom-controls' === $extended_css ) {
return '';
}
$column_controls = $this->getColumnControlsModular();
return $output = $column_controls;
}
/**
* @return string
*/
public function getTtaContainerClasses() {
$classes = array();
$classes[] = 'vc_tta-container';
return implode( ' ', apply_filters( 'vc_tta_container_classes', array_filter( $classes ), $this->getAtts() ) );
}
/**
* @return string
*/
public function getTtaGeneralClasses() {
$classes = array();
$classes[] = 'vc_general';
$classes[] = 'vc_tta';
$classes[] = 'vc_tta-' . $this->layout;
$classes[] = $this->getTemplateVariable( 'color' );
$classes[] = $this->getTemplateVariable( 'style' );
$classes[] = $this->getTemplateVariable( 'shape' );
$classes[] = $this->getTemplateVariable( 'spacing' );
$classes[] = $this->getTemplateVariable( 'gap' );
$classes[] = $this->getTemplateVariable( 'c_align' );
$classes[] = $this->getTemplateVariable( 'no_fill' );
if ( isset( $this->atts['collapsible_all'] ) && 'true' === $this->atts['collapsible_all'] ) {
$classes[] = 'vc_tta-o-all-clickable';
}
$pagination = isset( $this->atts['pagination_style'] ) ? trim( $this->atts['pagination_style'] ) : false;
if ( $pagination && 'none' !== $pagination && strlen( $pagination ) > 0 ) {
$classes[] = 'vc_tta-has-pagination';
}
/**
* @since 4.6.2
*/
if ( isset( $this->atts['el_class'] ) ) {
$classes[] = $this->getExtraClass( $this->atts['el_class'] );
}
return implode( ' ', apply_filters( 'vc_tta_accordion_general_classes', array_filter( $classes ), $this->getAtts() ) );
}
/**
* @return string
*/
public function getTtaPaginationClasses() {
$classes = array();
$classes[] = 'vc_general';
$classes[] = 'vc_pagination';
if ( isset( $this->atts['pagination_style'] ) && strlen( $this->atts['pagination_style'] ) > 0 ) {
$chunks = explode( '-', $this->atts['pagination_style'] );
$classes[] = 'vc_pagination-style-' . $chunks[0];
$classes[] = 'vc_pagination-shape-' . $chunks[1];
}
if ( isset( $this->atts['pagination_color'] ) && strlen( $this->atts['pagination_color'] ) > 0 ) {
$classes[] = 'vc_pagination-color-' . $this->atts['pagination_color'];
}
return implode( ' ', $classes );
}
/**
* @return string
*/
public function getWrapperAttributes() {
$attributes = array();
$attributes[] = 'class="' . esc_attr( $this->getTtaContainerClasses() ) . '"';
$attributes[] = 'data-vc-action="' . ( 'true' === $this->atts['collapsible_all'] ? 'collapseAll' : 'collapse' ) . '"';
$autoplay = isset( $this->atts['autoplay'] ) ? trim( $this->atts['autoplay'] ) : false;
if ( $autoplay && 'none' !== $autoplay && intval( $autoplay ) > 0 ) {
$autoplayAttr = wp_json_encode( array(
'delay' => intval( $autoplay ) * 1000,
) );
$attributes[] = 'data-vc-tta-autoplay="' . esc_attr( $autoplayAttr ) . '"';
}
if ( ! empty( $this->atts['el_id'] ) ) {
$attributes[] = 'id="' . esc_attr( $this->atts['el_id'] ) . '"';
}
return implode( ' ', $attributes );
}
/**
* @param $string
* @return mixed|string
*/
public function getTemplateVariable( $string ) {
if ( isset( $this->template_vars[ $string ] ) ) {
return $this->template_vars[ $string ];
} elseif ( method_exists( $this, 'getParam' . vc_studly( $string ) ) ) {
$this->template_vars[ $string ] = $this->{'getParam' . vc_studly( $string )}( $this->atts, $this->content );
return $this->template_vars[ $string ];
}
return '';
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamColor( $atts, $content ) {
if ( isset( $atts['color'] ) && strlen( $atts['color'] ) > 0 ) {
return 'vc_tta-color-' . esc_attr( $atts['color'] );
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamStyle( $atts, $content ) {
if ( isset( $atts['style'] ) && strlen( $atts['style'] ) > 0 ) {
return 'vc_tta-style-' . esc_attr( $atts['style'] );
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamTitle( $atts, $content ) {
if ( isset( $atts['title'] ) && strlen( $atts['title'] ) > 0 ) {
return '<h2>' . $atts['title'] . '</h2>';
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamContent( $atts, $content ) {
$panelsContent = wpb_js_remove_wpautop( $content );
if ( isset( $atts['c_icon'] ) && strlen( $atts['c_icon'] ) > 0 ) {
$isPageEditable = vc_is_page_editable();
if ( ! $isPageEditable ) {
$panelsContent = str_replace( '{{{ control-icon }}}', '<i class="vc_tta-controls-icon vc_tta-controls-icon-' . $atts['c_icon'] . '"></i>', $panelsContent );
} else {
$panelsContent = str_replace( '{{{ control-icon }}}', '<i class="vc_tta-controls-icon" data-vc-tta-controls-icon="' . $atts['c_icon'] . '"></i>', $panelsContent );
}
} else {
$panelsContent = str_replace( '{{{ control-icon }}}', '', $panelsContent );
}
return $panelsContent;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamShape( $atts, $content ) {
if ( isset( $atts['shape'] ) && strlen( $atts['shape'] ) > 0 ) {
return 'vc_tta-shape-' . $atts['shape'];
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string
*/
public function getParamSpacing( $atts, $content ) {
if ( isset( $atts['spacing'] ) && strlen( $atts['spacing'] ) > 0 ) {
return 'vc_tta-spacing-' . $atts['spacing'];
}
// In case if no spacing set we need to append extra class
return 'vc_tta-o-shape-group';
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamGap( $atts, $content ) {
if ( isset( $atts['gap'] ) && strlen( $atts['gap'] ) > 0 ) {
return 'vc_tta-gap-' . $atts['gap'];
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamNoFill( $atts, $content ) {
if ( isset( $atts['no_fill'] ) && 'true' === $atts['no_fill'] ) {
return 'vc_tta-o-no-fill';
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamCAlign( $atts, $content ) {
if ( isset( $atts['c_align'] ) && strlen( $atts['c_align'] ) > 0 ) {
return 'vc_tta-controls-align-' . $atts['c_align'];
}
return null;
}
/**
* Accordion doesn't have pagination
*
* @param $atts
* @param $content
*
* @return null
*/
public function getParamPaginationTop( $atts, $content ) {
return null;
}
/**
* Accordion doesn't have pagination
*
* @param $atts
* @param $content
*
* @return null
*/
public function getParamPaginationBottom( $atts, $content ) {
return null;
}
/**
* Get currently active section (from $atts)
*
* @param $atts
* @param bool $strict_bounds If true, check for min/max bounds
*
* @return int nth position (one-based) of active section
*/
public function getActiveSection( $atts, $strict_bounds = false ) {
$active_section = intval( $atts['active_section'] );
if ( $strict_bounds ) {
VcShortcodeAutoloader::getInstance()->includeClass( 'WPBakeryShortCode_Vc_Tta_Section' );
if ( $active_section < 1 ) {
$active_section = 1;
} elseif ( $active_section > WPBakeryShortCode_Vc_Tta_Section::$self_count ) {
$active_section = WPBakeryShortCode_Vc_Tta_Section::$self_count;
}
}
return $active_section;
}
/**
* @param $atts
* @param $content
*
* @return string
*/
public function getParamPaginationList( $atts, $content ) {
if ( empty( $atts['pagination_style'] ) ) {
return null;
}
$isPageEditabe = vc_is_page_editable();
$html = array();
$html[] = '<ul class="' . $this->getTtaPaginationClasses() . '">';
if ( ! $isPageEditabe ) {
VcShortcodeAutoloader::getInstance()->includeClass( 'WPBakeryShortCode_Vc_Tta_Section' );
foreach ( WPBakeryShortCode_Vc_Tta_Section::$section_info as $nth => $section ) {
$active_section = $this->getActiveSection( $atts, false );
$classes = array( 'vc_pagination-item' );
if ( ( $nth + 1 ) === $active_section ) {
$classes[] = $this->activeClass;
}
$a_html = '<a href="#' . $section['tab_id'] . '" class="vc_pagination-trigger" data-vc-tabs data-vc-container=".vc_tta"></a>';
$html[] = '<li class="' . implode( ' ', $classes ) . '" data-vc-tab>' . $a_html . '</li>';
}
}
$html[] = '</ul>';
return implode( '', $html );
}
public function enqueueTtaStyles() {
wp_register_style( 'vc_tta_style', vc_asset_url( 'css/js_composer_tta.min.css' ), false, WPB_VC_VERSION );
wp_enqueue_style( 'vc_tta_style' );
}
public function enqueueTtaScript() {
wp_register_script( 'vc_accordion_script', vc_asset_url( 'lib/vc_accordion/vc-accordion.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'vc_tta_autoplay_script', vc_asset_url( 'lib/vc-tta-autoplay/vc-tta-autoplay.min.js' ), array( 'vc_accordion_script' ), WPB_VC_VERSION, true );
wp_enqueue_script( 'vc_accordion_script' );
if ( ! vc_is_page_editable() ) {
wp_enqueue_script( 'vc_tta_autoplay_script' );
}
}
/**
* Override default outputTitle (also Icon). To remove anything, also Icon.
*
* @param $title - just for strict standards
*
* @return string
*/
protected function outputTitle( $title ) {
return '';
}
/**
* Check is allowed to add another element inside current element.
*
* @return bool
* @throws \Exception
* @since 4.8
*/
public function getAddAllowed() {
return vc_user_access_check_shortcode_all( 'vc_tta_section' );
}
}

View File

@@ -0,0 +1,56 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
VcShortcodeAutoloader::getInstance()->includeClass( 'WPBakeryShortCode_Vc_Tta_Tabs' );
/**
* Class WPBakeryShortCode_Vc_Tta_Pageable
*/
class WPBakeryShortCode_Vc_Tta_Pageable extends WPBakeryShortCode_Vc_Tta_Tabs {
public $layout = 'tabs';
/**
* @return string
*/
public function getTtaContainerClasses() {
$classes = parent::getTtaContainerClasses();
$classes .= ' vc_tta-o-non-responsive';
return $classes;
}
/**
* @return mixed|string
*/
public function getTtaGeneralClasses() {
$classes = parent::getTtaGeneralClasses();
$classes .= ' vc_tta-pageable';
// tabs have pagination on opposite side of tabs. pageable should behave normally
if ( false !== strpos( $classes, 'vc_tta-tabs-position-top' ) ) {
$classes = str_replace( 'vc_tta-tabs-position-top', 'vc_tta-tabs-position-bottom', $classes );
} else {
$classes = str_replace( 'vc_tta-tabs-position-bottom', 'vc_tta-tabs-position-top', $classes );
}
return $classes;
}
/**
* Disable all tabs
*
* @param $atts
* @param $content
*
* @return string
*/
public function getParamTabsList( $atts, $content ) {
return '';
}
}

View File

@@ -0,0 +1,303 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
VcShortcodeAutoloader::getInstance()->includeClass( 'WPBakeryShortCode_Vc_Tta_Accordion' );
/**
* Class WPBakeryShortCode_Vc_Tta_Section
*/
class WPBakeryShortCode_Vc_Tta_Section extends WPBakeryShortCode_Vc_Tta_Accordion {
protected $controls_css_settings = 'tc vc_control-container';
protected $controls_list = array(
'add',
'edit',
'clone',
'delete',
);
protected $backened_editor_prepend_controls = false;
/**
* @var WPBakeryShortCode_Vc_Tta_Accordion
*/
public static $tta_base_shortcode;
public static $self_count = 0;
public static $section_info = array();
/**
* @return mixed|string
*/
public function getFileName() {
if ( isset( self::$tta_base_shortcode ) && 'vc_tta_pageable' === self::$tta_base_shortcode->getShortcode() ) {
return 'vc_tta_pageable_section';
} else {
return 'vc_tta_section';
}
}
/**
* @return string
*/
public function containerContentClass() {
return 'wpb_column_container vc_container_for_children vc_clearfix';
}
/**
* @return string
*/
public function getElementClasses() {
$classes = array();
$classes[] = 'vc_tta-panel';
$isActive = ! vc_is_page_editable() && $this->getTemplateVariable( 'section-is-active' );
if ( $isActive ) {
$classes[] = $this->activeClass;
}
/**
* @since 4.6.2
*/
if ( isset( $this->atts['el_class'] ) ) {
$classes[] = $this->atts['el_class'];
}
return implode( ' ', array_filter( $classes ) );
}
/**
* @param $atts
* @param $content
*
* @return string
*/
public function getParamContent( $atts, $content ) {
return wpb_js_remove_wpautop( $content );
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamTabId( $atts, $content ) {
if ( isset( $atts['tab_id'] ) && strlen( $atts['tab_id'] ) > 0 ) {
return $atts['tab_id'];
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamTitle( $atts, $content ) {
if ( isset( $atts['title'] ) && strlen( $atts['title'] ) > 0 ) {
return $atts['title'];
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamIcon( $atts, $content ) {
if ( ! empty( $atts['add_icon'] ) && 'true' === $atts['add_icon'] ) {
$iconClass = '';
if ( isset( $atts[ 'i_icon_' . $atts['i_type'] ] ) ) {
$iconClass = $atts[ 'i_icon_' . $atts['i_type'] ];
}
vc_icon_element_fonts_enqueue( $atts['i_type'] );
return '<i class="vc_tta-icon ' . esc_attr( $iconClass ) . '"></i>';
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamIconLeft( $atts, $content ) {
if ( 'left' === $atts['i_position'] ) {
return $this->getParamIcon( $atts, $content );
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamIconRight( $atts, $content ) {
if ( 'right' === $atts['i_position'] ) {
return $this->getParamIcon( $atts, $content );
}
return null;
}
/**
* Section param active
* @param $atts
* @param $content
* @return bool|null
*/
public function getParamSectionIsActive( $atts, $content ) {
if ( is_object( self::$tta_base_shortcode ) ) {
if ( isset( self::$tta_base_shortcode->atts['active_section'] ) && strlen( self::$tta_base_shortcode->atts['active_section'] ) > 0 ) {
$active = (int) self::$tta_base_shortcode->atts['active_section'];
if ( $active === self::$self_count ) {
return true;
}
}
}
return null;
}
/**
* @param $atts
* @param $content
* @return string|null
*/
public function getParamControlIconPosition( $atts, $content ) {
if ( is_object( self::$tta_base_shortcode ) ) {
if ( isset( self::$tta_base_shortcode->atts['c_icon'] ) && strlen( self::$tta_base_shortcode->atts['c_icon'] ) > 0 && isset( self::$tta_base_shortcode->atts['c_position'] ) && strlen( self::$tta_base_shortcode->atts['c_position'] ) > 0 ) {
$c_position = self::$tta_base_shortcode->atts['c_position'];
return 'vc_tta-controls-icon-position-' . $c_position;
}
}
return null;
}
/**
* @param $atts
* @param $content
* @return string|null
*/
public function getParamControlIcon( $atts, $content ) {
if ( is_object( self::$tta_base_shortcode ) ) {
if ( isset( self::$tta_base_shortcode->atts['c_icon'] ) && strlen( self::$tta_base_shortcode->atts['c_icon'] ) > 0 ) {
$c_icon = self::$tta_base_shortcode->atts['c_icon'];
return '<i class="vc_tta-controls-icon vc_tta-controls-icon-' . $c_icon . '"></i>';
}
}
return null;
}
/**
* @param $atts
* @param $content
* @return string
*/
public function getParamHeading( $atts, $content ) {
$isPageEditable = vc_is_page_editable();
$h4attributes = array();
$h4classes = array(
'vc_tta-panel-title',
);
if ( $isPageEditable ) {
$h4attributes[] = 'data-vc-tta-controls-icon-position=""';
} else {
$controlIconPosition = $this->getTemplateVariable( 'control-icon-position' );
if ( $controlIconPosition ) {
$h4classes[] = $controlIconPosition;
}
}
$h4attributes[] = 'class="' . implode( ' ', $h4classes ) . '"';
$output = '<h4 ' . implode( ' ', $h4attributes ) . '>'; // close h4
if ( $isPageEditable ) {
$output .= '<a href="javascript:;" data-vc-target=""';
$output .= ' data-vc-tta-controls-icon-wrapper';
$output .= ' data-vc-use-cache="false"';
} else {
$output .= '<a href="#' . esc_attr( $this->getTemplateVariable( 'tab_id' ) ) . '"';
}
$output .= ' data-vc-accordion';
$output .= ' data-vc-container=".vc_tta-container">';
$output .= $this->getTemplateVariable( 'icon-left' );
$output .= '<span class="vc_tta-title-text">' . $this->getTemplateVariable( 'title' ) . '</span>';
$output .= $this->getTemplateVariable( 'icon-right' );
if ( ! $isPageEditable ) {
$output .= $this->getTemplateVariable( 'control-icon' );
}
$output .= '</a>';
$output .= '</h4>'; // close h4 fix #2229
return $output;
}
/**
* Get basic heading
*
* These are used in Pageable element inside content and are hidden from view
*
* @param $atts
* @param $content
*
* @return string
*/
public function getParamBasicHeading( $atts, $content ) {
$isPageEditable = vc_is_page_editable();
if ( $isPageEditable ) {
$attributes = array(
'href' => 'javascript:;',
'data-vc-container' => '.vc_tta-container',
'data-vc-accordion' => '',
'data-vc-target' => '',
'data-vc-tta-controls-icon-wrapper' => '',
'data-vc-use-cache' => 'false',
);
} else {
$attributes = array(
'data-vc-container' => '.vc_tta-container',
'data-vc-accordion' => '',
'data-vc-target' => esc_attr( '#' . $this->getTemplateVariable( 'tab_id' ) ),
);
}
$output = '
<span class="vc_tta-panel-title">
<a ' . vc_convert_atts_to_string( $attributes ) . '></a>
</span>
';
return $output;
}
/**
* Check is allowed to add another element inside current element.
*
* @return bool
* @since 4.8
*
*/
public function getAddAllowed() {
return vc_user_access()->part( 'shortcodes' )->checkStateAny( true, 'custom', null )->get();
}
}

View File

@@ -0,0 +1,207 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
VcShortcodeAutoloader::getInstance()->includeClass( 'WPBakeryShortCode_Vc_Tta_Accordion' );
/**
* Class WPBakeryShortCode_Vc_Tta_Tabs
*/
class WPBakeryShortCode_Vc_Tta_Tabs extends WPBakeryShortCode_Vc_Tta_Accordion {
public $layout = 'tabs';
public function enqueueTtaScript() {
wp_register_script( 'vc_tabs_script', vc_asset_url( 'lib/vc_tabs/vc-tabs.min.js' ), array( 'vc_accordion_script' ), WPB_VC_VERSION, true );
parent::enqueueTtaScript();
wp_enqueue_script( 'vc_tabs_script' );
}
/**
* @return string
*/
public function getWrapperAttributes() {
$attributes = array();
$attributes[] = 'class="' . esc_attr( $this->getTtaContainerClasses() ) . '"';
$attributes[] = 'data-vc-action="collapse"';
$autoplay = $this->atts['autoplay'];
if ( $autoplay && 'none' !== $autoplay && intval( $autoplay ) > 0 ) {
$attributes[] = 'data-vc-tta-autoplay="' . esc_attr( wp_json_encode( array(
'delay' => intval( $autoplay ) * 1000,
) ) ) . '"';
}
if ( ! empty( $this->atts['el_id'] ) ) {
$attributes[] = 'id="' . esc_attr( $this->atts['el_id'] ) . '"';
}
return implode( ' ', $attributes );
}
/**
* @return string
*/
public function getTtaGeneralClasses() {
$classes = parent::getTtaGeneralClasses();
if ( ! empty( $this->atts['no_fill_content_area'] ) ) {
$classes .= ' vc_tta-o-no-fill';
}
if ( isset( $this->atts['tab_position'] ) ) {
$classes .= ' ' . $this->getTemplateVariable( 'tab_position' );
}
$classes .= ' ' . $this->getParamAlignment( $this->atts, $this->content );
return $classes;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamTabPosition( $atts, $content ) {
if ( isset( $atts['tab_position'] ) && strlen( $atts['tab_position'] ) > 0 ) {
return 'vc_tta-tabs-position-' . $atts['tab_position'];
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamTabsListTop( $atts, $content ) {
if ( empty( $atts['tab_position'] ) || 'top' !== $atts['tab_position'] ) {
return null;
}
return $this->getParamTabsList( $atts, $content );
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamTabsListBottom( $atts, $content ) {
if ( empty( $atts['tab_position'] ) || 'bottom' !== $atts['tab_position'] ) {
return null;
}
return $this->getParamTabsList( $atts, $content );
}
/**
* Pagination is on top only if tabs are at bottom
*
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamPaginationTop( $atts, $content ) {
if ( empty( $atts['tab_position'] ) || 'bottom' !== $atts['tab_position'] ) {
return null;
}
return $this->getParamPaginationList( $atts, $content );
}
/**
* Pagination is at bottom only if tabs are on top
*
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamPaginationBottom( $atts, $content ) {
if ( empty( $atts['tab_position'] ) || 'top' !== $atts['tab_position'] ) {
return null;
}
return $this->getParamPaginationList( $atts, $content );
}
/**
* @param $atts
*
* @return string
*/
public function constructIcon( $atts ) {
vc_icon_element_fonts_enqueue( $atts['i_type'] );
$class = 'vc_tta-icon';
if ( isset( $atts[ 'i_icon_' . $atts['i_type'] ] ) ) {
$class .= ' ' . $atts[ 'i_icon_' . $atts['i_type'] ];
} else {
$class .= ' fa fa-adjust';
}
return '<i class="' . $class . '"></i>';
}
/**
* @param $atts
* @param $content
*
* @return string
*/
public function getParamTabsList( $atts, $content ) {
$isPageEditabe = vc_is_page_editable();
$html = array();
$html[] = '<div class="vc_tta-tabs-container">';
$html[] = '<ul class="vc_tta-tabs-list">';
if ( ! $isPageEditabe ) {
$active_section = $this->getActiveSection( $atts, false );
foreach ( WPBakeryShortCode_Vc_Tta_Section::$section_info as $nth => $section ) {
$classes = array( 'vc_tta-tab' );
if ( ( $nth + 1 ) === $active_section ) {
$classes[] = $this->activeClass;
}
$title = '<span class="vc_tta-title-text">' . $section['title'] . '</span>';
if ( 'true' === $section['add_icon'] ) {
$icon_html = $this->constructIcon( $section );
if ( 'left' === $section['i_position'] ) {
$title = $icon_html . $title;
} else {
$title = $title . $icon_html;
}
}
$a_html = '<a href="#' . $section['tab_id'] . '" data-vc-tabs data-vc-container=".vc_tta">' . $title . '</a>';
$html[] = '<li class="' . implode( ' ', $classes ) . '" data-vc-tab>' . $a_html . '</li>';
}
}
$html[] = '</ul>';
$html[] = '</div>';
return implode( '', apply_filters( 'vc-tta-get-params-tabs-list', $html, $atts, $content, $this ) );
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamAlignment( $atts, $content ) {
if ( isset( $atts['alignment'] ) && strlen( $atts['alignment'] ) > 0 ) {
return 'vc_tta-controls-align-' . $atts['alignment'];
}
return null;
}
}

View File

@@ -0,0 +1,93 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
VcShortcodeAutoloader::getInstance()->includeClass( 'WPBakeryShortCode_Vc_Tta_Tabs' );
/**
* Class WPBakeryShortCode_Vc_Tta_Tour
*/
class WPBakeryShortCode_Vc_Tta_Tour extends WPBakeryShortCode_Vc_Tta_Tabs {
public $layout = 'tabs';
/**
* @return string
*/
public function getTtaGeneralClasses() {
$classes = parent::getTtaGeneralClasses();
if ( isset( $this->atts['controls_size'] ) ) {
$classes .= ' ' . $this->getTemplateVariable( 'controls_size' );
}
return $classes;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamControlsSize( $atts, $content ) {
if ( isset( $atts['controls_size'] ) && strlen( $atts['controls_size'] ) > 0 ) {
return 'vc_tta-controls-size-' . $atts['controls_size'];
}
return null;
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamTabsListLeft( $atts, $content ) {
if ( empty( $atts['tab_position'] ) || 'left' !== $atts['tab_position'] ) {
return null;
}
return $this->getParamTabsList( $atts, $content );
}
/**
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamTabsListRight( $atts, $content ) {
if ( empty( $atts['tab_position'] ) || 'right' !== $atts['tab_position'] ) {
return null;
}
return $this->getParamTabsList( $atts, $content );
}
/**
* Never on top
*
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamPaginationTop( $atts, $content ) {
return null;
}
/**
* Always on bottom
*
* @param $atts
* @param $content
*
* @return string|null
*/
public function getParamPaginationBottom( $atts, $content ) {
return $this->getParamPaginationList( $atts, $content );
}
}

View File

@@ -0,0 +1,33 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_TweetMeMe
*/
class WPBakeryShortCode_Vc_TweetMeMe extends WPBakeryShortCode {
/**
* @param $atts
* @param null $content
* @return string
* @throws \Exception
*/
protected function contentInline( $atts, $content = null ) {
/**
* Shortcode attributes
* @var $atts
* Shortcode class
* @var WPBakeryShortCode_Vc_TweetMeMe $this
*/
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
$css = isset( $atts['css'] ) ? $atts['css'] : '';
$el_class = isset( $atts['el_class'] ) ? $atts['el_class'] : '';
$class_to_filter = 'wpb_googleplus vc_social-placeholder wpb_content_element';
$class_to_filter .= vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $atts['css_animation'] );
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );
return '<div class="' . esc_attr( $css_class ) . '"></div>';
}
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Twitter
*/
class WPBakeryShortCode_Vc_Twitter extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Video
*/
class WPBakeryShortCode_Vc_Video extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Widget_sidebar
*/
class WPBakeryShortCode_Vc_Widget_Sidebar extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Zigzag
*/
class WPBakeryShortCode_Vc_Zigzag extends WPBakeryShortCode {
}

View File

@@ -0,0 +1,27 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Class WPBakeryShortCode_Vc_Wp_Text
*/
class WPBakeryShortCode_Vc_Wp_Text extends WPBakeryShortCode {
/**
* This actually fixes #1537 by converting 'text' to 'content'
* @param $atts
*
* @return mixed
* @since 4.4
*
*/
public static function convertTextAttributeToContent( $atts ) {
if ( isset( $atts['text'] ) ) {
if ( ! isset( $atts['content'] ) || empty( $atts['content'] ) ) {
$atts['content'] = $atts['text'];
}
}
return $atts;
}
}