| Server IP : 141.193.213.11 / Your IP : 216.73.216.58 Web Server : nginx System : Linux pod-400555 6.8.0-1055-gke #61-Ubuntu SMP Tue May 26 22:57:42 UTC 2026 x86_64 User : fpm200079 ( 200079) PHP Version : 8.2.35 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /nas/content/live/bartislaw/wp-content/plugins/js_composer/include/classes/core/ |
Upload File : |
<?php
/**
* WPBakery Page Builder Mapper manager.
*
* @package WPBakeryPageBuilder
* @since 4.2
*/
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* Vc mapper new class. On maintenance
* Allows to bind hooks for shortcodes.
*
* @since 4.2
*/
class Vc_Mapper {
/**
* Stores mapping activities list which where called before initialization.
*
* @since 4.2
* @var array
*/
protected $init_activity = [];
/**
* Stores element-specific activities.
*
* @since 4.9
*
* @var array
*/
protected $element_activities = [];
/**
* Caches access rights for shortcodes.
*
* @var array
*/
protected $hasAccess = [];
/**
* Check access rights for shortcodes.
*
* @var array
*/
protected $checkForAccess = true;
/**
* Vc_Mapper constructor.
*
* @since 4.2
*/
public function __construct() {
}
/**
* Include params list objects and calls all stored activity methods.
*
* @since 4.2
* @access public
*/
public function init() {
do_action( 'vc_mapper_init_before' );
require_once vc_path_dir( 'PARAMS_DIR', 'load.php' );
WPBMap::setInit();
require_once vc_path_dir( 'CONFIG_DIR', 'lean-map.php' );
require_once vc_path_dir( 'HOOKS_DIR', 'class-wpb-lean-map-hooks.php' );
$this->callActivities();
do_action( 'vc_mapper_init_after' );
}
/**
* This method is called by VC objects methods if it is called before VC initialization.
*
* @param string $objectString - name of class object.
* @param string $method - method name.
* @param array $params - list of attributes for object method.
* @since 4.2
* @access public
*
* @see WPBMAP
*/
public function addActivity( $objectString, $method, $params = [] ) {
$this->init_activity[] = [
$objectString,
$method,
$params,
];
}
/**
* This method is called by VC objects methods if it is called before VC initialization.
*
* @param string $tag - shortcode tag of element.
* @param string $method - method name.
* @param array $params - list of attributes for object method.
* @since 4.9
* @access public
*
* @see WPBMAP
*/
public function addElementActivity( $tag, $method, $params = [] ) {
if ( ! isset( $this->element_activities[ $tag ] ) ) {
$this->element_activities[ $tag ] = [];
}
$this->element_activities[ $tag ][] = [
$method,
$params,
];
}
/**
* Call all stored activities.
*
* Called by init method. List of activities stored by $init_activity are created by other objects called after
* initialization.
*
* @since 4.2
* @access public
*/
protected function callActivities() { // phpcs:ignore:Generic.Metrics.CyclomaticComplexity.TooHigh
do_action( 'vc_mapper_call_activities_before' );
foreach ( $this->init_activity as $activity ) {
list( $object, $method, $params ) = $activity;
if ( 'mapper' === $object ) {
switch ( $method ) {
case 'map':
$currentScope = WPBMap::getScope();
if ( isset( $params['scope'] ) ) {
WPBMap::setScope( $params['scope'] );
}
WPBMap::map( $params['tag'], $params['attributes'] );
WPBMap::setScope( $currentScope );
break;
case 'drop_param':
WPBMap::dropParam( $params['name'], $params['attribute_name'] );
break;
case 'add_param':
WPBMap::addParam( $params['name'], $params['attribute'] );
break;
case 'mutate_param':
WPBMap::mutateParam( $params['name'], $params['attribute'] );
break;
case 'drop_all_shortcodes':
WPBMap::dropAllShortcodes();
break;
case 'drop_shortcode':
WPBMap::dropShortcode( $params['name'] );
break;
case 'modify':
WPBMap::modify( $params['name'], $params['setting_name'], $params['value'] );
break;
}
}
}
}
/**
* Does user has access to modify/clone/delete/add shortcode
*
* @param string $shortcode
*
* @return bool
* @since 4.5
* @todo fix_roles and maybe remove/@deprecate this
*/
public function userHasAccess( $shortcode ) {
if ( $this->isCheckForAccess() ) {
if ( isset( $this->hasAccess[ $shortcode ] ) ) {
return $this->hasAccess[ $shortcode ];
} else {
$this->hasAccess[ $shortcode ] = vc_user_access_check_shortcode_edit( $shortcode );
}
return $this->hasAccess[ $shortcode ];
}
return true;
}
/**
* Checks access.
*
* @return bool
* @since 4.5
* @todo fix_roles and maybe remove/@deprecate this
*/
public function isCheckForAccess() {
return $this->checkForAccess;
}
/**
* Set check for access.
*
* @param bool $checkForAccess
* @since 4.5
*
* @todo fix_roles and maybe remove/@deprecate this
*/
public function setCheckForAccess( $checkForAccess ) {
$this->checkForAccess = $checkForAccess;
}
/**
* Calls stored element-specific activities for a given shortcode tag.
*
* @param string $tag
* @throws \Exception
*/
public function callElementActivities( $tag ) {
do_action( 'vc_mapper_call_activities_before' );
if ( isset( $this->element_activities[ $tag ] ) ) {
foreach ( $this->element_activities[ $tag ] as $activity ) {
list( $method, $params ) = $activity;
switch ( $method ) {
case 'drop_param':
WPBMap::dropParam( $params['name'], $params['attribute_name'] );
break;
case 'add_param':
WPBMap::addParam( $params['name'], $params['attribute'] );
break;
case 'mutate_param':
WPBMap::mutateParam( $params['name'], $params['attribute'] );
break;
case 'drop_shortcode':
WPBMap::dropShortcode( $params['name'] );
break;
case 'modify':
WPBMap::modify( $params['name'], $params['setting_name'], $params['value'] );
break;
}
}
}
}
}