Import legacy nurinda.co.id website
This commit is contained in:
1 parent
3f59bb9038
commit
6e21646ac4
13389 files changed
+3246690
No files matched your search
@@ -0,0 +1,505 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Author: Arlo Carreon <http://arlocarreon.com>
|
||||
* Info: http://mexitek.github.io/phpColors/
|
||||
* License: http://arlo.mit-license.org/
|
||||
*
|
||||
* @modified by js_composer
|
||||
* @since 4.8
|
||||
*/
|
||||
class Vc_Color_Helper {
|
||||
|
||||
/**
|
||||
* A color utility that helps manipulate HEX colors
|
||||
*/
|
||||
|
||||
private $_hex;
|
||||
private $_hsl;
|
||||
private $_rgb;
|
||||
|
||||
/**
|
||||
* Auto darkens/lightens by 10% for sexily-subtle gradients.
|
||||
* Set this to FALSE to adjust automatic shade to be between given color
|
||||
* and black (for darken) or white (for lighten)
|
||||
*/
|
||||
const DEFAULT_ADJUST = 10;
|
||||
|
||||
/**
|
||||
* Instantiates the class with a HEX value
|
||||
*
|
||||
* @param string $hex
|
||||
*
|
||||
* @throws Exception "Bad color format"
|
||||
*/
|
||||
function __construct( $hex ) {
|
||||
// Strip # sign is present
|
||||
$color = str_replace( '#', '', $hex );
|
||||
|
||||
// Make sure it's 6 digits
|
||||
if ( strlen( $color ) === 3 ) {
|
||||
$color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
|
||||
} else if ( strlen( $color ) != 6 ) {
|
||||
throw new Exception( 'HEX color needs to be 6 or 3 digits long' );
|
||||
}
|
||||
|
||||
$this->_hsl = self::hexToHsl( $color );
|
||||
$this->_hex = $color;
|
||||
$this->_rgb = self::hexToRgb( $color );
|
||||
}
|
||||
|
||||
public static function clamp( $val, $max = 1 ) {
|
||||
return min( max( $val, 0 ), $max );
|
||||
}
|
||||
|
||||
// ====================
|
||||
// = Public Interface =
|
||||
// ====================
|
||||
|
||||
/**
|
||||
* Given a HEX string returns a HSL array equivalent.
|
||||
*
|
||||
* @param string $color
|
||||
*
|
||||
* @return array HSL associative array
|
||||
*/
|
||||
public static function hexToHsl( $color ) {
|
||||
|
||||
// Sanity check
|
||||
$color = self::_checkHex( $color );
|
||||
|
||||
// Convert HEX to DEC
|
||||
$R = hexdec( $color[0] . $color[1] );
|
||||
$G = hexdec( $color[2] . $color[3] );
|
||||
$B = hexdec( $color[4] . $color[5] );
|
||||
|
||||
$HSL = array();
|
||||
|
||||
$var_R = ( $R / 255.0 );
|
||||
$var_G = ( $G / 255.0 );
|
||||
$var_B = ( $B / 255.0 );
|
||||
|
||||
$var_Min = min( $var_R, $var_G, $var_B );
|
||||
$var_Max = max( $var_R, $var_G, $var_B );
|
||||
$del_Max = floatval( $var_Max - $var_Min );
|
||||
|
||||
$L = ( $var_Max + $var_Min ) / 2.0;
|
||||
|
||||
$H = 0.0;
|
||||
$S = 0.0;
|
||||
|
||||
if ( 0 != $del_Max ) {
|
||||
if ( $L < 0.5 ) {
|
||||
$S = $del_Max / ( $var_Max + $var_Min );
|
||||
} else {
|
||||
$S = $del_Max / ( 2 - $var_Max - $var_Min );
|
||||
}
|
||||
|
||||
switch ( $var_Max ) {
|
||||
case $var_R:
|
||||
$H = ( $var_G - $var_B ) / $del_Max + ( $var_G < $var_B ? 6 : 0 );
|
||||
break;
|
||||
case $var_G:
|
||||
$H = ( $var_B - $var_R ) / $del_Max + 2;
|
||||
break;
|
||||
case $var_B:
|
||||
$H = ( $var_R - $var_G ) / $del_Max + 4;
|
||||
break;
|
||||
}
|
||||
|
||||
$H /= 6;
|
||||
}
|
||||
|
||||
$HSL['H'] = ( $H * 360.0 );
|
||||
$HSL['S'] = $S;
|
||||
$HSL['L'] = $L;
|
||||
|
||||
return $HSL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a HSL associative array returns the equivalent HEX string
|
||||
*
|
||||
* @param array $hsl
|
||||
*
|
||||
* @return string HEX string
|
||||
* @throws Exception "Bad HSL Array"
|
||||
*/
|
||||
public static function hslToHex( $hsl = array() ) {
|
||||
// Make sure it's HSL
|
||||
if ( empty( $hsl ) || ! isset( $hsl['H'] ) || ! isset( $hsl['S'] ) || ! isset( $hsl['L'] ) ) {
|
||||
throw new Exception( 'Param was not an HSL array' );
|
||||
}
|
||||
|
||||
list( $H, $S, $L ) = array(
|
||||
fmod( $hsl['H'], 360 ) / 360.0,
|
||||
$hsl['S'],
|
||||
$hsl['L'],
|
||||
);
|
||||
|
||||
if ( 0 == $S ) {
|
||||
$r = $L * 255.0;
|
||||
$g = $L * 255.0;
|
||||
$b = $L * 255.0;
|
||||
} else {
|
||||
|
||||
if ( $L < 0.5 ) {
|
||||
$var_2 = $L * ( 1.0 + $S );
|
||||
} else {
|
||||
$var_2 = ( $L + $S ) - ( $S * $L );
|
||||
}
|
||||
|
||||
$var_1 = 2.0 * $L - $var_2;
|
||||
|
||||
$r = self::clamp( round( 255.0 * self::_huetorgb( $var_1, $var_2, $H + ( 1 / 3 ) ) ), 255 );
|
||||
$g = self::clamp( round( 255.0 * self::_huetorgb( $var_1, $var_2, $H ) ), 255 );
|
||||
$b = self::clamp( round( 255.0 * self::_huetorgb( $var_1, $var_2, $H - ( 1 / 3 ) ) ), 255 );
|
||||
|
||||
}
|
||||
|
||||
// Convert to hex
|
||||
$r = dechex( $r );
|
||||
$g = dechex( $g );
|
||||
$b = dechex( $b );
|
||||
|
||||
// Make sure we get 2 digits for decimals
|
||||
$r = ( strlen( '' . $r ) === 1 ) ? '0' . $r : $r;
|
||||
$g = ( strlen( '' . $g ) === 1 ) ? '0' . $g : $g;
|
||||
$b = ( strlen( '' . $b ) === 1 ) ? '0' . $b : $b;
|
||||
|
||||
return $r . $g . $b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a HEX string returns a RGB array equivalent.
|
||||
*
|
||||
* @param string $color
|
||||
*
|
||||
* @return array RGB associative array
|
||||
*/
|
||||
public static function hexToRgb( $color ) {
|
||||
|
||||
// Sanity check
|
||||
$color = self::_checkHex( $color );
|
||||
|
||||
// Convert HEX to DEC
|
||||
$R = hexdec( $color[0] . $color[1] );
|
||||
$G = hexdec( $color[2] . $color[3] );
|
||||
$B = hexdec( $color[4] . $color[5] );
|
||||
|
||||
$RGB['R'] = $R;
|
||||
$RGB['G'] = $G;
|
||||
$RGB['B'] = $B;
|
||||
|
||||
return $RGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an RGB associative array returns the equivalent HEX string
|
||||
*
|
||||
* @param array $rgb
|
||||
*
|
||||
* @return string RGB string
|
||||
* @throws Exception "Bad RGB Array"
|
||||
*/
|
||||
public static function rgbToHex( $rgb = array() ) {
|
||||
// Make sure it's RGB
|
||||
if ( empty( $rgb ) || ! isset( $rgb['R'] ) || ! isset( $rgb['G'] ) || ! isset( $rgb['B'] ) ) {
|
||||
throw new Exception( 'Param was not an RGB array' );
|
||||
}
|
||||
|
||||
// Convert RGB to HEX
|
||||
$hex[0] = dechex( $rgb['R'] );
|
||||
if ( 1 === strlen( $hex[0] ) ) {
|
||||
$hex[0] .= $hex[0];
|
||||
}
|
||||
$hex[1] = dechex( $rgb['G'] );
|
||||
|
||||
if ( 1 === strlen( $hex[1] ) ) {
|
||||
$hex[1] .= $hex[1];
|
||||
}
|
||||
$hex[2] = dechex( $rgb['B'] );
|
||||
|
||||
if ( 1 === strlen( $hex[2] ) ) {
|
||||
$hex[2] .= $hex[2];
|
||||
}
|
||||
|
||||
return implode( '', $hex );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a HEX value, returns a darker color. If no desired amount provided, then the color halfway between
|
||||
* given HEX and black will be returned.
|
||||
*
|
||||
* @param int $amount
|
||||
*
|
||||
* @return string Darker HEX value
|
||||
*/
|
||||
public function darken( $amount = self::DEFAULT_ADJUST ) {
|
||||
// Darken
|
||||
$darkerHSL = $this->_darken( $this->_hsl, $amount );
|
||||
|
||||
// Return as HEX
|
||||
return self::hslToHex( $darkerHSL );
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a HEX value, returns a lighter color. If no desired amount provided, then the color halfway between
|
||||
* given HEX and white will be returned.
|
||||
*
|
||||
* @param int $amount
|
||||
*
|
||||
* @return string Lighter HEX value
|
||||
*/
|
||||
public function lighten( $amount = self::DEFAULT_ADJUST ) {
|
||||
// Lighten
|
||||
$lighterHSL = $this->_lighten( $this->_hsl, $amount );
|
||||
|
||||
// Return as HEX
|
||||
return self::hslToHex( $lighterHSL );
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a HEX value, returns a mixed color. If no desired amount provided, then the color mixed by this ratio
|
||||
*
|
||||
* @param string $hex2 Secondary HEX value to mix with
|
||||
* @param int $amount = -100..0..+100
|
||||
*
|
||||
* @return string mixed HEX value
|
||||
*/
|
||||
public function mix( $hex2, $amount = 0 ) {
|
||||
$rgb2 = self::hexToRgb( $hex2 );
|
||||
$mixed = $this->_mix( $this->_rgb, $rgb2, $amount );
|
||||
|
||||
// Return as HEX
|
||||
return self::rgbToHex( $mixed );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array with two shades that can be used to make a gradient
|
||||
*
|
||||
* @param int $amount Optional percentage amount you want your contrast color
|
||||
*
|
||||
* @return array An array with a 'light' and 'dark' index
|
||||
*/
|
||||
public function makeGradient( $amount = self::DEFAULT_ADJUST ) {
|
||||
// Decide which color needs to be made
|
||||
if ( $this->isLight() ) {
|
||||
$lightColor = $this->_hex;
|
||||
$darkColor = $this->darken( $amount );
|
||||
} else {
|
||||
$lightColor = $this->lighten( $amount );
|
||||
$darkColor = $this->_hex;
|
||||
}
|
||||
|
||||
// Return our gradient array
|
||||
return array( 'light' => $lightColor, 'dark' => $darkColor );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether or not given color is considered "light"
|
||||
*
|
||||
* @param string|Boolean $color
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLight( $color = false ) {
|
||||
// Get our color
|
||||
$color = ( $color ) ? $color : $this->_hex;
|
||||
|
||||
// Calculate straight from rbg
|
||||
$r = hexdec( $color[0] . $color[1] );
|
||||
$g = hexdec( $color[2] . $color[3] );
|
||||
$b = hexdec( $color[4] . $color[5] );
|
||||
|
||||
return ( ( $r * 299 + $g * 587 + $b * 114 ) / 1000 > 130 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not a given color is considered "dark"
|
||||
*
|
||||
* @param string|Boolean $color
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDark( $color = false ) {
|
||||
// Get our color
|
||||
$color = ( $color ) ? $color : $this->_hex;
|
||||
|
||||
// Calculate straight from rbg
|
||||
$r = hexdec( $color[0] . $color[1] );
|
||||
$g = hexdec( $color[2] . $color[3] );
|
||||
$b = hexdec( $color[4] . $color[5] );
|
||||
|
||||
return ( ( $r * 299 + $g * 587 + $b * 114 ) / 1000 <= 130 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the complimentary color
|
||||
* @return string Complementary hex color
|
||||
*
|
||||
*/
|
||||
public function complementary() {
|
||||
// Get our HSL
|
||||
$hsl = $this->_hsl;
|
||||
|
||||
// Adjust Hue 180 degrees
|
||||
$hsl['H'] += ( $hsl['H'] > 180 ) ? - 180 : 180;
|
||||
|
||||
// Return the new value in HEX
|
||||
return self::hslToHex( $hsl );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns your color's HSL array
|
||||
*/
|
||||
public function getHsl() {
|
||||
return $this->_hsl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns your original color
|
||||
*/
|
||||
public function getHex() {
|
||||
return $this->_hex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns your color's RGB array
|
||||
*/
|
||||
public function getRgb() {
|
||||
return $this->_rgb;
|
||||
}
|
||||
|
||||
// ===========================
|
||||
// = Private Functions Below =
|
||||
// ===========================
|
||||
|
||||
|
||||
/**
|
||||
* Darkens a given HSL array
|
||||
*
|
||||
* @param array $hsl
|
||||
* @param int $amount
|
||||
*
|
||||
* @return array $hsl
|
||||
*/
|
||||
private function _darken( $hsl, $amount = self::DEFAULT_ADJUST ) {
|
||||
// Check if we were provided a number
|
||||
if ( $amount ) {
|
||||
$hsl['L'] = ( $hsl['L'] * 100 ) - $amount;
|
||||
$hsl['L'] = ( $hsl['L'] < 0 ) ? 0 : $hsl['L'] / 100;
|
||||
} else {
|
||||
// We need to find out how much to darken
|
||||
$hsl['L'] = $hsl['L'] / 2;
|
||||
}
|
||||
|
||||
return $hsl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lightens a given HSL array
|
||||
*
|
||||
* @param array $hsl
|
||||
* @param int $amount
|
||||
*
|
||||
* @return array $hsl
|
||||
*/
|
||||
private function _lighten( $hsl, $amount = self::DEFAULT_ADJUST ) {
|
||||
// Check if we were provided a number
|
||||
if ( $amount ) {
|
||||
$hsl['L'] = ( $hsl['L'] * 100.0 ) + $amount;
|
||||
$hsl['L'] = ( $hsl['L'] > 100.0 ) ? 1.0 : $hsl['L'] / 100.0;
|
||||
} else {
|
||||
// We need to find out how much to lighten
|
||||
$hsl['L'] += ( 1.0 - $hsl['L'] ) / 2.0;
|
||||
}
|
||||
|
||||
return $hsl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix 2 rgb colors and return an rgb color
|
||||
*
|
||||
* @param array $rgb1
|
||||
* @param array $rgb2
|
||||
* @param int $amount ranged -100..0..+100
|
||||
*
|
||||
* @return array $rgb
|
||||
*
|
||||
* ported from http://phpxref.pagelines.com/nav.html?includes/class.colors.php.source.html
|
||||
*/
|
||||
private function _mix( $rgb1, $rgb2, $amount = 0 ) {
|
||||
|
||||
$r1 = ( $amount + 100 ) / 100;
|
||||
$r2 = 2 - $r1;
|
||||
|
||||
$rmix = ( ( $rgb1['R'] * $r1 ) + ( $rgb2['R'] * $r2 ) ) / 2;
|
||||
$gmix = ( ( $rgb1['G'] * $r1 ) + ( $rgb2['G'] * $r2 ) ) / 2;
|
||||
$bmix = ( ( $rgb1['B'] * $r1 ) + ( $rgb2['B'] * $r2 ) ) / 2;
|
||||
|
||||
return array( 'R' => $rmix, 'G' => $gmix, 'B' => $bmix );
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a Hue, returns corresponding RGB value
|
||||
*
|
||||
* @param int $v1
|
||||
* @param int $v2
|
||||
* @param int $vH
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function _huetorgb( $v1, $v2, $vH ) {
|
||||
if ( $vH < 0 ) {
|
||||
$vH += 1;
|
||||
}
|
||||
|
||||
if ( $vH > 1 ) {
|
||||
$vH -= 1;
|
||||
}
|
||||
|
||||
if ( ( 6 * $vH ) < 1 ) {
|
||||
return ( $v1 + ( $v2 - $v1 ) * 6 * $vH );
|
||||
}
|
||||
|
||||
if ( ( 2 * $vH ) < 1 ) {
|
||||
return $v2;
|
||||
}
|
||||
|
||||
if ( ( 3 * $vH ) < 2 ) {
|
||||
return ( $v1 + ( $v2 - $v1 ) * ( ( 2 / 3 ) - $vH ) * 6 );
|
||||
}
|
||||
|
||||
return $v1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* You need to check if you were given a good hex string
|
||||
*
|
||||
* @param string $hex
|
||||
*
|
||||
* @return string Color
|
||||
* @throws Exception "Bad color format"
|
||||
*/
|
||||
private static function _checkHex( $hex ) {
|
||||
// Strip # sign is present
|
||||
$color = str_replace( '#', '', $hex );
|
||||
|
||||
// Make sure it's 6 digits
|
||||
if ( strlen( $color ) == 3 ) {
|
||||
$color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
|
||||
} else if ( strlen( $color ) != 6 ) {
|
||||
throw new Exception( 'HEX color needs to be 6 or 3 digits long' );
|
||||
}
|
||||
|
||||
return $color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* WPBakery WPBakery Page Builder filter functions
|
||||
*
|
||||
* @package WPBakeryPageBuilder
|
||||
*
|
||||
* http://kb.wpbakery.com/index.php?title=Visual_Composer_Filters
|
||||
*/
|
||||
|
||||
/**
|
||||
* This filter should be applied to all content elements titles
|
||||
*
|
||||
* $params['extraclass'] Extra class name will be added
|
||||
*
|
||||
*
|
||||
* To override content element title default html markup, paste this code in your theme's functions.php file
|
||||
* vc_filter: wpb_widget_title
|
||||
* add_filter('wpb_widget_title', 'override_widget_title', 10, 2);
|
||||
* function override_widget_title($output = '', $params = array('')) {
|
||||
* $extraclass = (isset($params['extraclass'])) ? " ".$params['extraclass'] : "";
|
||||
* return '<h1 class="entry-title'.$extraclass.'">'.$params['title'].'</h1>';
|
||||
* }
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return mixed|string|void
|
||||
*/
|
||||
function wpb_widget_title( $params = array( 'title' => '' ) ) {
|
||||
if ( '' === $params['title'] ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$extraclass = ( isset( $params['extraclass'] ) ) ? ' ' . $params['extraclass'] : '';
|
||||
$output = '<h2 class="wpb_heading' . $extraclass . '">' . $params['title'] . '</h2>';
|
||||
|
||||
return apply_filters( 'wpb_widget_title', $output, $params );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Available filters in default.php
|
||||
wpb_toggle_heading
|
||||
|
||||
Available filters in buttons.php
|
||||
wpb_cta_text
|
||||
|
||||
Available filters in teaser_grid.php
|
||||
vc_teaser_grid_title
|
||||
vc_teaser_grid_thumbnail
|
||||
vc_teaser_grid_content
|
||||
vc_teaser_grid_carousel_arrows
|
||||
|
||||
*/
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,654 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Lean map shortcodes
|
||||
*
|
||||
* @since 4.9
|
||||
*
|
||||
* @param $tag
|
||||
* @param null $settings_function
|
||||
* @param null $settings_file
|
||||
*/
|
||||
function vc_lean_map( $tag, $settings_function = null, $settings_file = null ) {
|
||||
WPBMap::leanMap( $tag, $settings_function, $settings_file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $attributes
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
function vc_map( $attributes ) {
|
||||
if ( ! isset( $attributes['base'] ) ) {
|
||||
trigger_error( __( 'Wrong vc_map object. Base attribute is required', 'js_composer' ), E_USER_ERROR );
|
||||
die();
|
||||
}
|
||||
WPBMap::map( $attributes['base'], $attributes );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $shortcode
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
function vc_remove_element( $shortcode ) {
|
||||
WPBMap::dropShortcode( $shortcode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new shortcode param.
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
* @param $shortcode - tag for shortcode
|
||||
* @param $attributes - attribute settings
|
||||
*/
|
||||
function vc_add_param( $shortcode, $attributes ) {
|
||||
WPBMap::addParam( $shortcode, $attributes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass shortcode params adding function
|
||||
*
|
||||
* @since 4.3
|
||||
*
|
||||
* @param $shortcode - tag for shortcode
|
||||
* @param $attributes - list of attributes arrays
|
||||
*/
|
||||
function vc_add_params( $shortcode, $attributes ) {
|
||||
if ( is_array( $attributes ) ) {
|
||||
foreach ( $attributes as $attr ) {
|
||||
vc_add_param( $shortcode, $attr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand function for WPBMap::modify
|
||||
*
|
||||
* @param $name
|
||||
* @param $setting
|
||||
* @param string $value
|
||||
*
|
||||
* @since 4.2
|
||||
* @return array|bool
|
||||
*/
|
||||
function vc_map_update( $name = '', $setting = '', $value = '' ) {
|
||||
return WPBMap::modify( $name, $setting, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand function for WPBMap::mutateParam
|
||||
*
|
||||
* @param $name
|
||||
* @param array $attribute
|
||||
*
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_update_shortcode_param( $name, $attribute = array() ) {
|
||||
return WPBMap::mutateParam( $name, $attribute );
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand function for WPBMap::dropParam
|
||||
*
|
||||
* @param $name
|
||||
* @param $attribute_name
|
||||
*
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_remove_param( $name = '', $attribute_name = '' ) {
|
||||
return WPBMap::dropParam( $name, $attribute_name );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'vc_set_as_theme' ) ) {
|
||||
/**
|
||||
* Sets plugin as theme plugin.
|
||||
*
|
||||
* @internal param bool $disable_updater - If value is true disables auto updater options.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
function vc_set_as_theme() {
|
||||
vc_manager()->setIsAsTheme( true );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_is_as_theme' ) ) {
|
||||
/**
|
||||
* Is VC as-theme-plugin.
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_is_as_theme() {
|
||||
return vc_manager()->isAsTheme();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_is_updater_disabled' ) ) {
|
||||
/**
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_is_updater_disabled() {
|
||||
return vc_manager()->isUpdaterDisabled();
|
||||
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_default_editor_post_types' ) ) {
|
||||
/**
|
||||
* Returns list of default post type.
|
||||
* @since 4.2
|
||||
* @return array
|
||||
*/
|
||||
function vc_default_editor_post_types() {
|
||||
return vc_manager()->editorDefaultPostTypes();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_set_default_editor_post_types' ) ) {
|
||||
/**
|
||||
* Set post types for VC editor.
|
||||
* @since 4.2
|
||||
*
|
||||
* @param array $list - list of valid post types to set
|
||||
*/
|
||||
function vc_set_default_editor_post_types( array $list ) {
|
||||
vc_manager()->setEditorDefaultPostTypes( $list );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( ( 'vc_editor_post_types' ) ) ) {
|
||||
/**
|
||||
* Returns list of post types where VC editor is enabled.
|
||||
* @since 4.2
|
||||
* @return array
|
||||
*/
|
||||
function vc_editor_post_types() {
|
||||
return vc_manager()->editorPostTypes();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( ( 'vc_editor_set_post_types' ) ) ) {
|
||||
/**
|
||||
* Set list of post types where VC editor is enabled.
|
||||
* @since 4.4
|
||||
*
|
||||
* @param array $post_types
|
||||
*
|
||||
*/
|
||||
function vc_editor_set_post_types( array $post_types ) {
|
||||
vc_manager()->setEditorPostTypes( $post_types );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_mode' ) ) {
|
||||
/**
|
||||
* Return current VC mode.
|
||||
* @since 4.2
|
||||
* @see Vc_Mapper::$mode
|
||||
* @return string
|
||||
*/
|
||||
function vc_mode() {
|
||||
return vc_manager()->mode();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_set_shortcodes_templates_dir' ) ) {
|
||||
/**
|
||||
* Sets directory where WPBakery Page Builder should look for template files for content elements.
|
||||
* @since 4.2
|
||||
*
|
||||
* @param string - full directory path to new template directory with trailing slash
|
||||
*/
|
||||
function vc_set_shortcodes_templates_dir( $dir ) {
|
||||
vc_manager()->setCustomUserShortcodesTemplateDir( $dir );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_shortcodes_theme_templates_dir' ) ) {
|
||||
/**
|
||||
* Get custom theme template path
|
||||
* @since 4.2
|
||||
*
|
||||
* @param $template - filename for template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function vc_shortcodes_theme_templates_dir( $template ) {
|
||||
return vc_manager()->getShortcodesTemplateDir( $template );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*
|
||||
* @todo check usage.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
function set_vc_is_inline( $value = true ) {
|
||||
_deprecated_function( 'set_vc_is_inline', '5.2 (will be removed in 5.3)' );
|
||||
global $vc_is_inline;
|
||||
$vc_is_inline = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable frontend editor for VC
|
||||
* @since 4.3
|
||||
*
|
||||
* @param bool $disable
|
||||
*/
|
||||
function vc_disable_frontend( $disable = true ) {
|
||||
vc_frontend_editor()->disableInline( $disable );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is front end enabled.
|
||||
* @since 4.3
|
||||
* @return bool
|
||||
*/
|
||||
function vc_enabled_frontend() {
|
||||
return vc_frontend_editor()->frontendEditorEnabled();
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'vc_add_default_templates' ) ) {
|
||||
/**
|
||||
* Add custom template in default templates list
|
||||
*
|
||||
* @param array $data | template data (name, content, custom_class, image_path)
|
||||
*
|
||||
* @since 4.3
|
||||
* @return bool
|
||||
*/
|
||||
function vc_add_default_templates( $data ) {
|
||||
return visual_composer()->templatesPanelEditor()->addDefaultTemplates( $data );
|
||||
}
|
||||
}
|
||||
|
||||
function vc_map_integrate_shortcode( $shortcode, $field_prefix = '', $group_prefix = '', $change_fields = null, $dependency = null ) {
|
||||
if ( is_string( $shortcode ) ) {
|
||||
$shortcode_data = WPBMap::getShortCode( $shortcode );
|
||||
} else {
|
||||
$shortcode_data = $shortcode;
|
||||
}
|
||||
if ( is_array( $shortcode_data ) && ! empty( $shortcode_data ) ) {
|
||||
/**
|
||||
* @var $shortcode WPBakeryShortCodeFishBones
|
||||
*/
|
||||
$params = isset( $shortcode_data['params'] ) && ! empty( $shortcode_data['params'] ) ? $shortcode_data['params'] : false;
|
||||
if ( is_array( $params ) && ! empty( $params ) ) {
|
||||
$keys = array_keys( $params );
|
||||
for ( $i = 0; $i < count( $keys ); $i ++ ) {
|
||||
$param = &$params[ $keys[ $i ] ]; // Note! passed by reference to automatically update data
|
||||
if ( isset( $change_fields ) ) {
|
||||
$param = vc_map_integrate_include_exclude_fields( $param, $change_fields );
|
||||
if ( empty( $param ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ( ! empty( $group_prefix ) ) {
|
||||
if ( isset( $param['group'] ) ) {
|
||||
$param['group'] = $group_prefix . ': ' . $param['group'];
|
||||
} else {
|
||||
$param['group'] = $group_prefix;
|
||||
}
|
||||
}
|
||||
if ( ! empty( $field_prefix ) && isset( $param['param_name'] ) ) {
|
||||
$param['param_name'] = $field_prefix . $param['param_name'];
|
||||
if ( isset( $param['dependency'] ) && is_array( $param['dependency'] ) && isset( $param['dependency']['element'] ) ) {
|
||||
$param['dependency']['element'] = $field_prefix . $param['dependency']['element'];
|
||||
}
|
||||
$param = vc_map_integrate_add_dependency( $param, $dependency );
|
||||
|
||||
} elseif ( ! empty( $dependency ) ) {
|
||||
$param = vc_map_integrate_add_dependency( $param, $dependency );
|
||||
}
|
||||
$param['integrated_shortcode'] = is_array( $shortcode ) ? $shortcode['base'] : $shortcode;
|
||||
$param['integrated_shortcode_field'] = $field_prefix;
|
||||
}
|
||||
}
|
||||
|
||||
return is_array( $params ) ? array_filter( $params ) : array();
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to filter params (include/exclude)
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param $param
|
||||
* @param $change_fields
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
function vc_map_integrate_include_exclude_fields( $param, $change_fields ) {
|
||||
if ( is_array( $change_fields ) ) {
|
||||
if ( isset( $change_fields['exclude'] ) && in_array( $param['param_name'], $change_fields['exclude'] ) ) {
|
||||
$param = null;
|
||||
|
||||
return $param; // to prevent group adding to $param
|
||||
} elseif ( isset( $change_fields['exclude_regex'] ) ) {
|
||||
if ( is_array( $change_fields['exclude_regex'] ) && ! empty( $change_fields['exclude_regex'] ) ) {
|
||||
$break_foreach = false;
|
||||
foreach ( $change_fields['exclude_regex'] as $regex ) {
|
||||
if ( false === @preg_match( $regex, null ) ) {
|
||||
// Regular expression is invalid, (don't remove @).
|
||||
} else {
|
||||
if ( preg_match( $regex, $param['param_name'] ) ) {
|
||||
$param = null;
|
||||
$break_foreach = true;
|
||||
}
|
||||
}
|
||||
if ( $break_foreach ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $break_foreach ) {
|
||||
return $param; // to prevent group adding to $param
|
||||
}
|
||||
} elseif ( is_string( $change_fields['exclude_regex'] ) && strlen( $change_fields['exclude_regex'] ) > 0 ) {
|
||||
if ( false === @preg_match( $change_fields['exclude_regex'], null ) ) {
|
||||
// Regular expression is invalid, (don't remove @).
|
||||
} else {
|
||||
if ( preg_match( $change_fields['exclude_regex'], $param['param_name'] ) ) {
|
||||
$param = null;
|
||||
|
||||
return $param; // to prevent group adding to $param
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $change_fields['include_only'] ) && ! in_array( $param['param_name'], $change_fields['include_only'] ) ) {
|
||||
// if we want to enclude only some fields
|
||||
$param = null;
|
||||
|
||||
return $param; // to prevent group adding to $param
|
||||
} elseif ( isset( $change_fields['include_only_regex'] ) ) {
|
||||
if ( is_array( $change_fields['include_only_regex'] ) && ! empty( $change_fields['include_only_regex'] ) ) {
|
||||
$break_foreach = false;
|
||||
foreach ( $change_fields['include_only_regex'] as $regex ) {
|
||||
if ( false === @preg_match( $regex, null ) ) {
|
||||
// Regular expression is invalid, (don't remove @).
|
||||
} else {
|
||||
if ( ! preg_match( $regex, $param['param_name'] ) ) {
|
||||
$param = null;
|
||||
$break_foreach = true;
|
||||
}
|
||||
}
|
||||
if ( $break_foreach ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $break_foreach ) {
|
||||
return $param; // to prevent group adding to $param
|
||||
}
|
||||
} elseif ( is_string( $change_fields['include_only_regex'] ) && strlen( $change_fields['include_only_regex'] ) > 0 ) {
|
||||
if ( false === @preg_match( $change_fields['include_only_regex'], null ) ) {
|
||||
// Regular expression is invalid, (don't remove @).
|
||||
} else {
|
||||
if ( ! preg_match( $change_fields['include_only_regex'], $param['param_name'] ) ) {
|
||||
$param = null;
|
||||
|
||||
return $param; // to prevent group adding to $param
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $param;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal used to add dependency to existed param
|
||||
*
|
||||
* @param $param
|
||||
* @param $dependency
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function vc_map_integrate_add_dependency( $param, $dependency ) {
|
||||
// activator must be used for all elements who doesn't have 'dependency'
|
||||
if ( ! empty( $dependency ) && ( ! isset( $param['dependency'] ) || empty( $param['dependency'] ) ) ) {
|
||||
if ( is_array( $dependency ) ) {
|
||||
$param['dependency'] = $dependency;
|
||||
}
|
||||
}
|
||||
|
||||
return $param;
|
||||
}
|
||||
|
||||
function vc_map_integrate_get_params( $base_shortcode, $integrated_shortcode, $field_prefix = '' ) {
|
||||
$shortcode_data = WPBMap::getShortCode( $base_shortcode );
|
||||
$params = array();
|
||||
if ( is_array( $shortcode_data ) && is_array( $shortcode_data['params'] ) && ! empty( $shortcode_data['params'] ) ) {
|
||||
foreach ( $shortcode_data['params'] as $param ) {
|
||||
if ( is_array( $param ) && isset( $param['integrated_shortcode'] ) && $integrated_shortcode === $param['integrated_shortcode'] ) {
|
||||
if ( ! empty( $field_prefix ) ) {
|
||||
if ( isset( $param['integrated_shortcode_field'] ) && $field_prefix === $param['integrated_shortcode_field'] ) {
|
||||
$params[] = $param;
|
||||
}
|
||||
} else {
|
||||
$params[] = $param;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
function vc_map_integrate_get_atts( $base_shortcode, $integrated_shortcode, $field_prefix = '' ) {
|
||||
$params = vc_map_integrate_get_params( $base_shortcode, $integrated_shortcode, $field_prefix );
|
||||
$atts = array();
|
||||
if ( is_array( $params ) && ! empty( $params ) ) {
|
||||
foreach ( $params as $param ) {
|
||||
$value = '';
|
||||
if ( isset( $param['value'] ) ) {
|
||||
if ( isset( $param['std'] ) ) {
|
||||
$value = $param['std'];
|
||||
} elseif ( is_array( $param['value'] ) ) {
|
||||
reset( $param['value'] );
|
||||
$value = current( $param['value'] );
|
||||
} else {
|
||||
$value = $param['value'];
|
||||
}
|
||||
}
|
||||
$atts[ $param['param_name'] ] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $atts;
|
||||
}
|
||||
|
||||
function vc_map_integrate_parse_atts( $base_shortcode, $integrated_shortcode, $atts, $field_prefix = '' ) {
|
||||
$params = vc_map_integrate_get_params( $base_shortcode, $integrated_shortcode, $field_prefix );
|
||||
$data = array();
|
||||
if ( is_array( $params ) && ! empty( $params ) ) {
|
||||
foreach ( $params as $param ) {
|
||||
if ( isset( $atts[ $param['param_name'] ] ) ) {
|
||||
$value = $atts[ $param['param_name'] ];
|
||||
}
|
||||
if ( isset( $value ) ) {
|
||||
$key = $param['param_name'];
|
||||
if ( strlen( $field_prefix ) > 0 ) {
|
||||
$key = substr( $key, strlen( $field_prefix ) );
|
||||
}
|
||||
$data[ $key ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function vc_map_add_css_animation( $label = true ) {
|
||||
$data = array(
|
||||
'type' => 'animation_style',
|
||||
'heading' => __( 'CSS Animation', 'js_composer' ),
|
||||
'param_name' => 'css_animation',
|
||||
'admin_label' => $label,
|
||||
'value' => '',
|
||||
'settings' => array(
|
||||
'type' => 'in',
|
||||
'custom' => array(
|
||||
array(
|
||||
'label' => __( 'Default', 'js_composer' ),
|
||||
'values' => array(
|
||||
__( 'Top to bottom', 'js_composer' ) => 'top-to-bottom',
|
||||
__( 'Bottom to top', 'js_composer' ) => 'bottom-to-top',
|
||||
__( 'Left to right', 'js_composer' ) => 'left-to-right',
|
||||
__( 'Right to left', 'js_composer' ) => 'right-to-left',
|
||||
__( 'Appear from center', 'js_composer' ) => 'appear',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'description' => __( 'Select type of animation for element to be animated when it "enters" the browsers viewport (Note: works only in modern browsers).', 'js_composer' ),
|
||||
);
|
||||
|
||||
/*
|
||||
|
||||
array(
|
||||
'label' => __( 'Slide Exits', 'js_composer' ),
|
||||
'values' => array(
|
||||
__( 'slideOutDown', 'js_composer' ) => array(
|
||||
'value' => 'slideOutDown',
|
||||
'type' => 'out',
|
||||
),
|
||||
__( 'slideOutLeft', 'js_composer' ) => array(
|
||||
'value' => 'slideOutLeft',
|
||||
'type' => 'out',
|
||||
),
|
||||
__( 'slideOutRight', 'js_composer' ) => array(
|
||||
'value' => 'slideOutRight',
|
||||
'type' => 'out',
|
||||
),
|
||||
__( 'slideOutUp', 'js_composer' ) => array(
|
||||
'value' => 'slideOutUp',
|
||||
'type' => 'out',
|
||||
),
|
||||
),
|
||||
)
|
||||
*/
|
||||
|
||||
return apply_filters( 'vc_map_add_css_animation', $data, $label );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings of the mapped shortcode.
|
||||
*
|
||||
* @param $tag
|
||||
*
|
||||
* @since 4.4.3
|
||||
* @return array|null - settings or null if shortcode not mapped
|
||||
*/
|
||||
function vc_get_shortcode( $tag ) {
|
||||
return WPBMap::getShortCode( $tag );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all mapped shortcodes and the moment when function is called.
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
function vc_remove_all_elements() {
|
||||
WPBMap::dropAllShortcodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get defaults values for shortcode.
|
||||
* @since 4.6
|
||||
*
|
||||
* @param $tag - shortcode tag
|
||||
*
|
||||
* @return array - list of param=>default_value
|
||||
*/
|
||||
function vc_map_get_defaults( $tag ) {
|
||||
$shortcode = vc_get_shortcode( $tag );
|
||||
$params = array();
|
||||
if ( is_array( $shortcode ) && isset( $shortcode['params'] ) && ! empty( $shortcode['params'] ) ) {
|
||||
$params = vc_map_get_params_defaults( $shortcode['params'] );
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
*
|
||||
* @since 4.12
|
||||
* @return array
|
||||
*/
|
||||
function vc_map_get_params_defaults( $params ) {
|
||||
$resultParams = array();
|
||||
foreach ( $params as $param ) {
|
||||
if ( isset( $param['param_name'] ) && 'content' !== $param['param_name'] ) {
|
||||
$value = '';
|
||||
if ( isset( $param['std'] ) ) {
|
||||
$value = $param['std'];
|
||||
} elseif ( isset( $param['value'] ) ) {
|
||||
if ( is_array( $param['value'] ) ) {
|
||||
$value = current( $param['value'] );
|
||||
if ( is_array( $value ) ) {
|
||||
// in case if two-dimensional array provided (vc_basic_grid)
|
||||
$value = current( $value );
|
||||
}
|
||||
// return first value from array (by default)
|
||||
} else {
|
||||
$value = $param['value'];
|
||||
}
|
||||
}
|
||||
$resultParams[ $param['param_name'] ] = apply_filters( 'vc_map_get_param_defaults', $value, $param );
|
||||
}
|
||||
}
|
||||
|
||||
return $resultParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tag - shortcode tag3
|
||||
* @param $atts - shortcode attributes
|
||||
*
|
||||
* @return array - return merged values with provided attributes (
|
||||
* 'a'=>1,'b'=>2 + 'b'=>3,'c'=>4 --> 'a'=>1,'b'=>3 )
|
||||
*
|
||||
* @see vc_shortcode_attribute_parse - return union of provided attributes (
|
||||
* 'a'=>1,'b'=>2 + 'b'=>3,'c'=>4 --> 'a'=>1,
|
||||
* 'b'=>3, 'c'=>4 )
|
||||
*/
|
||||
function vc_map_get_attributes( $tag, $atts = array() ) {
|
||||
$atts = shortcode_atts( vc_map_get_defaults( $tag ), $atts, $tag );
|
||||
|
||||
return apply_filters( 'vc_map_get_attributes', $atts, $tag );
|
||||
}
|
||||
|
||||
function vc_convert_vc_color( $name ) {
|
||||
$colors = array(
|
||||
'blue' => '#5472d2',
|
||||
'turquoise' => '#00c1cf',
|
||||
'pink' => '#fe6c61',
|
||||
'violet' => '#8d6dc4',
|
||||
'peacoc' => '#4cadc9',
|
||||
'chino' => '#cec2ab',
|
||||
'mulled-wine' => '#50485b',
|
||||
'vista-blue' => '#75d69c',
|
||||
'orange' => '#f7be68',
|
||||
'sky' => '#5aa1e3',
|
||||
'green' => '#6dab3c',
|
||||
'juicy-pink' => '#f4524d',
|
||||
'sandy-brown' => '#f79468',
|
||||
'purple' => '#b97ebb',
|
||||
'black' => '#2a2a2a',
|
||||
'grey' => '#ebebeb',
|
||||
'white' => '#ffffff',
|
||||
);
|
||||
$name = str_replace( '_', '-', $name );
|
||||
if ( isset( $colors[ $name ] ) ) {
|
||||
return $colors[ $name ];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to register new shortcode attribute hook.
|
||||
*
|
||||
* @param $name - attribute name
|
||||
* @param $form_field_callback - hook, will be called when settings form is shown and attribute added to shortcode
|
||||
* param list
|
||||
* @param $script_url - javascript file url which will be attached at the end of settings form.
|
||||
*
|
||||
* @since 4.2
|
||||
* @deprecated due to without prefix name 4.4
|
||||
* @return bool
|
||||
*/
|
||||
function add_shortcode_param( $name, $form_field_callback, $script_url = null ) {
|
||||
_deprecated_function( 'add_shortcode_param', '4.4 (will be removed in 6.0)', 'vc_add_shortcode_param' );
|
||||
|
||||
return vc_add_shortcode_param( $name, $form_field_callback, $script_url );
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.2
|
||||
* @since 4.2
|
||||
* @return mixed|string|void
|
||||
*/
|
||||
function get_row_css_class() {
|
||||
_deprecated_function( 'get_row_css_class', '4.2 (will be removed in 6.0)' );
|
||||
$custom = vc_settings()->get( 'row_css_class' );
|
||||
|
||||
return ! empty( $custom ) ? $custom : 'vc_row-fluid';
|
||||
}
|
||||
|
||||
/* Backwards compatibility **/
|
||||
/**
|
||||
* @param $attributes
|
||||
*
|
||||
* @deprecated, use vc_map instead
|
||||
*/
|
||||
function wpb_map( $attributes ) {
|
||||
_deprecated_function( 'wpb_map', '4.2 (will be removed in 6.0)', 'vc_map' );
|
||||
|
||||
vc_map( $attributes );
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 5.2
|
||||
* @return string
|
||||
*/
|
||||
function vc_generate_dependencies_attributes() {
|
||||
_deprecated_function( 'vc_generate_dependencies_attributes', '5.1', '' );
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -0,0 +1,595 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* WPBakery WPBakery Page Builder Main manager.
|
||||
*
|
||||
* @package WPBakeryPageBuilder
|
||||
* @since 4.2
|
||||
*/
|
||||
if ( ! function_exists( 'vc_manager' ) ) {
|
||||
/**
|
||||
* WPBakery Page Builder manager.
|
||||
* @since 4.2
|
||||
* @return Vc_Manager
|
||||
*/
|
||||
function vc_manager() {
|
||||
return Vc_Manager::getInstance();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'visual_composer' ) ) {
|
||||
/**
|
||||
* WPBakery Page Builder instance.
|
||||
* @since 4.2
|
||||
* @return Vc_Base
|
||||
*/
|
||||
function visual_composer() {
|
||||
return vc_manager()->vc();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_mapper' ) ) {
|
||||
/**
|
||||
* Shorthand for Vc Mapper.
|
||||
* @since 4.2
|
||||
* @return Vc_Mapper
|
||||
*/
|
||||
function vc_mapper() {
|
||||
return vc_manager()->mapper();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_settings' ) ) {
|
||||
/**
|
||||
* Shorthand for WPBakery Page Builder settings.
|
||||
* @since 4.2
|
||||
* @return Vc_Settings
|
||||
*/
|
||||
function vc_settings() {
|
||||
return vc_manager()->settings();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_license' ) ) {
|
||||
/**
|
||||
* Get License manager
|
||||
* @since 4.2
|
||||
* @return Vc_License
|
||||
*/
|
||||
function vc_license() {
|
||||
return vc_manager()->license();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_automapper' ) ) {
|
||||
/**
|
||||
* @since 4.2
|
||||
* @return Vc_Automapper
|
||||
*/
|
||||
function vc_automapper() {
|
||||
return vc_manager()->automapper();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_frontend_editor' ) ) {
|
||||
/**
|
||||
* Shorthand for VC frontend editor
|
||||
* @since 4.2
|
||||
* @return Vc_Frontend_Editor
|
||||
*/
|
||||
function vc_frontend_editor() {
|
||||
return vc_manager()->frontendEditor();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_backend_editor' ) ) {
|
||||
/**
|
||||
* Shorthand for VC frontend editor
|
||||
* @since 4.2
|
||||
* @return Vc_Backend_Editor
|
||||
*/
|
||||
function vc_backend_editor() {
|
||||
return vc_manager()->backendEditor();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_updater' ) ) {
|
||||
/**
|
||||
* @since 4.2
|
||||
* @return Vc_Updater
|
||||
*/
|
||||
function vc_updater() {
|
||||
return vc_manager()->updater();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_is_network_plugin' ) ) {
|
||||
/**
|
||||
* Vc is network plugin or not.
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_is_network_plugin() {
|
||||
return vc_manager()->isNetworkPlugin();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_path_dir' ) ) {
|
||||
/**
|
||||
* Get file/directory path in Vc.
|
||||
*
|
||||
* @param string $name - path name
|
||||
* @param string $file
|
||||
*
|
||||
* @since 4.2
|
||||
* @return string
|
||||
*/
|
||||
function vc_path_dir( $name, $file = '' ) {
|
||||
return vc_manager()->path( $name, $file );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_asset_url' ) ) {
|
||||
/**
|
||||
* Get full url for assets.
|
||||
*
|
||||
* @param string $file
|
||||
*
|
||||
* @since 4.2
|
||||
* @return string
|
||||
*/
|
||||
function vc_asset_url( $file ) {
|
||||
return vc_manager()->assetUrl( $file );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_upload_dir' ) ) {
|
||||
/**
|
||||
* Temporary files upload dir;
|
||||
* @since 4.2
|
||||
* @return string
|
||||
*/
|
||||
function vc_upload_dir() {
|
||||
return vc_manager()->uploadDir();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_template' ) ) {
|
||||
/**
|
||||
* @param $file
|
||||
*
|
||||
* @since 4.2
|
||||
* @return string
|
||||
*/
|
||||
function vc_template( $file ) {
|
||||
return vc_path_dir( 'TEMPLATES_DIR', $file );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_post_param' ) ) {
|
||||
/**
|
||||
* Get param value from $_POST if exists.
|
||||
*
|
||||
* @param $param
|
||||
* @param $default
|
||||
*
|
||||
* @since 4.2
|
||||
* @return null|string - null for undefined param.
|
||||
*/
|
||||
function vc_post_param( $param, $default = null ) {
|
||||
return isset( $_POST[ $param ] ) ? $_POST[ $param ] : $default;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_get_param' ) ) {
|
||||
/**
|
||||
* Get param value from $_GET if exists.
|
||||
*
|
||||
* @param string $param
|
||||
* @param $default
|
||||
*
|
||||
* @since 4.2
|
||||
* @return null|string - null for undefined param.
|
||||
*/
|
||||
function vc_get_param( $param, $default = null ) {
|
||||
return isset( $_GET[ $param ] ) ? $_GET[ $param ] : $default;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_request_param' ) ) {
|
||||
/**
|
||||
* Get param value from $_REQUEST if exists.
|
||||
*
|
||||
* @param $param
|
||||
* @param $default
|
||||
*
|
||||
* @since 4.4
|
||||
* @return null|string - null for undefined param.
|
||||
*/
|
||||
function vc_request_param( $param, $default = null ) {
|
||||
return isset( $_REQUEST[ $param ] ) ? $_REQUEST[ $param ] : $default;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_is_frontend_editor' ) ) {
|
||||
/**
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_is_frontend_editor() {
|
||||
return 'admin_frontend_editor' === vc_mode();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_is_page_editable' ) ) {
|
||||
/**
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_is_page_editable() {
|
||||
return 'page_editable' === vc_mode();
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_action' ) ) {
|
||||
/**
|
||||
* Get VC special action param.
|
||||
* @since 4.2
|
||||
* @return string|null
|
||||
*/
|
||||
function vc_action() {
|
||||
$vc_action = null;
|
||||
if ( isset( $_GET['vc_action'] ) ) {
|
||||
$vc_action = $_GET['vc_action'];
|
||||
} elseif ( isset( $_POST['vc_action'] ) ) {
|
||||
$vc_action = $_POST['vc_action'];
|
||||
}
|
||||
|
||||
return $vc_action;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_is_inline' ) ) {
|
||||
/**
|
||||
* Get is inline or not.
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_is_inline() {
|
||||
global $vc_is_inline;
|
||||
if ( is_null( $vc_is_inline ) ) {
|
||||
$vc_is_inline = ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && 'vc_inline' === vc_action() || ! is_null( vc_request_param( 'vc_inline' ) ) || 'true' === vc_request_param( 'vc_editable' );
|
||||
}
|
||||
|
||||
return $vc_is_inline;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'vc_is_frontend_ajax' ) ) {
|
||||
/**
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_is_frontend_ajax() {
|
||||
return 'true' === vc_post_param( 'vc_inline' ) || vc_get_param( 'vc_inline' );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @depreacted since 4.8 ( use vc_is_frontend_editor )
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_is_editor() {
|
||||
return vc_is_frontend_editor();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param bool $encode
|
||||
*
|
||||
* @since 4.2
|
||||
* @return string
|
||||
*/
|
||||
function vc_value_from_safe( $value, $encode = false ) {
|
||||
$value = preg_match( '/^#E\-8_/', $value ) ? rawurldecode( base64_decode( preg_replace( '/^#E\-8_/', '', $value ) ) ) : $value;
|
||||
if ( $encode ) {
|
||||
$value = htmlentities( $value, ENT_COMPAT, 'UTF-8' );
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*
|
||||
* @param bool $disable
|
||||
*/
|
||||
function vc_disable_automapper( $disable = true ) {
|
||||
vc_automapper()->setDisabled( $disable );
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
* @return bool
|
||||
*/
|
||||
function vc_automapper_is_disabled() {
|
||||
return vc_automapper()->disabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $param
|
||||
* @param $value
|
||||
*
|
||||
* @since 4.2
|
||||
* @return mixed|string
|
||||
*/
|
||||
function vc_get_dropdown_option( $param, $value ) {
|
||||
if ( '' === $value && is_array( $param['value'] ) ) {
|
||||
$value = array_shift( $param['value'] );
|
||||
}
|
||||
if ( is_array( $value ) ) {
|
||||
reset( $value );
|
||||
$value = isset( $value['value'] ) ? $value['value'] : current( $value );
|
||||
}
|
||||
$value = preg_replace( '/\s/', '_', $value );
|
||||
|
||||
return ( '' !== $value ? $value : '' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $prefix
|
||||
* @param $color
|
||||
*
|
||||
* @since 4.2
|
||||
* @return string
|
||||
*/
|
||||
function vc_get_css_color( $prefix, $color ) {
|
||||
$rgb_color = preg_match( '/rgba/', $color ) ? preg_replace( array(
|
||||
'/\s+/',
|
||||
'/^rgba\((\d+)\,(\d+)\,(\d+)\,([\d\.]+)\)$/',
|
||||
), array(
|
||||
'',
|
||||
'rgb($1,$2,$3)',
|
||||
), $color ) : $color;
|
||||
$string = $prefix . ':' . $rgb_color . ';';
|
||||
if ( $rgb_color !== $color ) {
|
||||
$string .= $prefix . ':' . $color . ';';
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $param_value
|
||||
* @param string $prefix
|
||||
*
|
||||
* @since 4.2
|
||||
* @return string
|
||||
*/
|
||||
function vc_shortcode_custom_css_class( $param_value, $prefix = '' ) {
|
||||
$css_class = preg_match( '/\s*\.([^\{]+)\s*\{\s*([^\}]+)\s*\}\s*/', $param_value ) ? $prefix . preg_replace( '/\s*\.([^\{]+)\s*\{\s*([^\}]+)\s*\}\s*/', '$1', $param_value ) : '';
|
||||
|
||||
return $css_class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $subject
|
||||
* @param $property
|
||||
* @param bool|false $strict
|
||||
*
|
||||
* @since 4.9
|
||||
* @return bool
|
||||
*/
|
||||
function vc_shortcode_custom_css_has_property( $subject, $property, $strict = false ) {
|
||||
$styles = array();
|
||||
$pattern = '/\{([^\}]*?)\}/i';
|
||||
preg_match( $pattern, $subject, $styles );
|
||||
if ( array_key_exists( 1, $styles ) ) {
|
||||
$styles = explode( ';', $styles[1] );
|
||||
}
|
||||
$new_styles = array();
|
||||
foreach ( $styles as $val ) {
|
||||
$val = explode( ':', $val );
|
||||
if ( is_array( $property ) ) {
|
||||
foreach ( $property as $prop ) {
|
||||
$pos = strpos( $val[0], $prop );
|
||||
$full = ( $strict ) ? ( 0 === $pos && strlen( $val[0] ) === strlen( $prop ) ) : true;
|
||||
if ( false !== $pos && $full ) {
|
||||
$new_styles[] = $val;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$pos = strpos( $val[0], $property );
|
||||
$full = ( $strict ) ? ( 0 === $pos && strlen( $val[0] ) === strlen( $property ) ) : true;
|
||||
if ( false !== $pos && $full ) {
|
||||
$new_styles[] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ! empty( $new_styles );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin name for VC.
|
||||
*
|
||||
* @since 4.2
|
||||
* @return string
|
||||
*/
|
||||
function vc_plugin_name() {
|
||||
return vc_manager()->pluginName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4.3 used in vc_base when getting an custom css output
|
||||
*
|
||||
* @param $filename
|
||||
*
|
||||
* @param bool $partial
|
||||
*
|
||||
* @return bool|mixed|string
|
||||
*/
|
||||
function vc_file_get_contents( $filename, $partial = false ) {
|
||||
global $wp_filesystem;
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
require_once( ABSPATH . '/wp-admin/includes/file.php' );
|
||||
WP_Filesystem( false, false, true );
|
||||
}
|
||||
/** @var $wp_filesystem WP_Filesystem_Base */
|
||||
if ( ! is_object( $wp_filesystem ) || ! $output = $wp_filesystem->get_contents( $filename ) ) {
|
||||
/*if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
||||
|
||||
} elseif ( ! $wp_filesystem->connect() ) {
|
||||
|
||||
} elseif ( ! $wp_filesystem->is_writable( $filename ) ) {
|
||||
|
||||
} else {
|
||||
|
||||
}*/
|
||||
$output = file_get_contents( $filename );
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* HowTo: vc_role_access()->who('administrator')->with('editor')->can('frontend_editor');
|
||||
* @since 4.8
|
||||
* @return Vc_Role_Access;
|
||||
*/
|
||||
function vc_role_access() {
|
||||
return vc_manager()->getRoleAccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get access manager for current user.
|
||||
* HowTo: vc_user_access()->->with('editor')->can('frontend_editor');
|
||||
* @since 4.8
|
||||
* @return Vc_Current_User_Access;
|
||||
*/
|
||||
function vc_user_access() {
|
||||
return vc_manager()->getCurrentUserAccess();
|
||||
}
|
||||
|
||||
function vc_user_roles_get_all() {
|
||||
require_once vc_path_dir( 'SETTINGS_DIR', 'class-vc-roles.php' );
|
||||
$vc_roles = new Vc_Roles();
|
||||
$capabilities = array();
|
||||
foreach ( $vc_roles->getParts() as $part ) {
|
||||
$partObj = vc_user_access()->part( $part );
|
||||
$capabilities[ $part ] = array(
|
||||
'state' => $partObj->getState(),
|
||||
'state_key' => $partObj->getStateKey(),
|
||||
'capabilities' => $partObj->getAllCaps(),
|
||||
);
|
||||
}
|
||||
|
||||
return $capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a $_GET action param for ajax
|
||||
* @since 4.8
|
||||
* @return bool
|
||||
*/
|
||||
function vc_wp_action() {
|
||||
return isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function vc_generate_nonce( $data ) {
|
||||
return wp_create_nonce( is_array( $data ) ? ( 'vc-nonce-' . implode( '|', $data ) ) : ( 'vc-nonce-' . $data ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $nonce
|
||||
* @param $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function vc_verify_nonce( $nonce, $data ) {
|
||||
return (bool) wp_verify_nonce( $nonce, ( is_array( $data ) ? ( 'vc-nonce-' . implode( '|', $data ) ) : ( 'vc-nonce-' . $data ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $nonce
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function vc_verify_admin_nonce( $nonce = '' ) {
|
||||
return (bool) vc_verify_nonce( ! empty( $nonce ) ? $nonce : vc_request_param( '_vcnonce' ), 'vc-admin-nonce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $nonce
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function vc_verify_public_nonce( $nonce = '' ) {
|
||||
return (bool) vc_verify_nonce( ( ! empty( $nonce ) ? $nonce : vc_request_param( '_vcnonce' ) ), 'vc-public-nonce' );
|
||||
}
|
||||
|
||||
function vc_check_post_type( $type ) {
|
||||
if ( empty( $type ) ) {
|
||||
$type = get_post_type();
|
||||
}
|
||||
$valid = apply_filters( 'vc_check_post_type_validation', null, $type );
|
||||
if ( is_null( $valid ) ) {
|
||||
if ( is_multisite() && is_super_admin() ) {
|
||||
return true;
|
||||
}
|
||||
$state = vc_user_access()->part( 'post_types' )->getState();
|
||||
if ( null === $state ) {
|
||||
return in_array( $type, vc_default_editor_post_types() );
|
||||
} else if ( true === $state && ! in_array( $type, vc_default_editor_post_types() ) ) {
|
||||
$valid = false;
|
||||
} else {
|
||||
$valid = vc_user_access()->part( 'post_types' )->can( $type )->get();
|
||||
}
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
function vc_user_access_check_shortcode_edit( $shortcode ) {
|
||||
$do_check = apply_filters( 'vc_user_access_check-shortcode_edit', null, $shortcode );
|
||||
|
||||
if ( is_null( $do_check ) ) {
|
||||
$state_check = vc_user_access()->part( 'shortcodes' )->checkStateAny( true, 'edit', null )->get();
|
||||
if ( $state_check ) {
|
||||
return true;
|
||||
} else {
|
||||
return vc_user_access()->part( 'shortcodes' )->canAny( $shortcode . '_all', $shortcode . '_edit' )->get();
|
||||
}
|
||||
} else {
|
||||
return $do_check;
|
||||
}
|
||||
}
|
||||
|
||||
function vc_user_access_check_shortcode_all( $shortcode ) {
|
||||
$do_check = apply_filters( 'vc_user_access_check-shortcode_all', null, $shortcode );
|
||||
|
||||
if ( is_null( $do_check ) ) {
|
||||
return vc_user_access()->part( 'shortcodes' )->checkStateAny( true, 'custom', null )->can( $shortcode . '_all' )->get();
|
||||
} else {
|
||||
return $do_check;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* htmlspecialchars_decode_deep
|
||||
* Call the htmlspecialchars_decode to a gived multilevel array
|
||||
*
|
||||
* @since 4.8
|
||||
*
|
||||
* @param mixed $value The value to be stripped.
|
||||
*
|
||||
* @return mixed Stripped value.
|
||||
*/
|
||||
function vc_htmlspecialchars_decode_deep( $value ) {
|
||||
if ( is_array( $value ) ) {
|
||||
$value = array_map( 'vc_htmlspecialchars_decode_deep', $value );
|
||||
} elseif ( is_object( $value ) ) {
|
||||
$vars = get_object_vars( $value );
|
||||
foreach ( $vars as $key => $data ) {
|
||||
$value->{$key} = vc_htmlspecialchars_decode_deep( $data );
|
||||
}
|
||||
} elseif ( is_string( $value ) ) {
|
||||
$value = htmlspecialchars_decode( $value );
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
function vc_str_remove_protocol( $str ) {
|
||||
return str_replace( array(
|
||||
'https://',
|
||||
'http://',
|
||||
), '//', $str );
|
||||
}
|
||||
Reference in new issue
Block a user