Esempio n. 1
0
 public function init($settings)
 {
     parent::init($settings);
     $this->composer = WPBakeryVisualComposer::getInstance();
     /**
      * initialize vc manager.
      */
     vc_mapper();
     $this->addAction('init', 'setUp');
 }
Esempio n. 2
0
 /**
  * Add new param to shortcode params list after specified parameter.
  *
  * @static
  *
  * @param $name
  * @param array $attribute
  *
  * @return bool - true if added, false if scheduled/rejected
  */
 public static function addParamAfter($name, $attribute = array(), $after = false)
 {
     if (!$after) {
         return self::addParam($name, $attribute);
     }
     if (!self::$is_init) {
         vc_mapper()->addActivity('mapper', 'add_param', array('name' => $name, 'attribute' => $attribute));
         return false;
     }
     if (!isset(self::$sc[$name])) {
         trigger_error(sprintf(__("Wrong name for shortcode:%s. Name required", "js_composer"), $name));
     } elseif (!isset($attribute['param_name'])) {
         trigger_error(sprintf(__("Wrong attribute for '%s' shortcode. Attribute 'param_name' required", "js_composer"), $name));
     } else {
         $replaced = false;
         foreach (self::$sc[$name]['params'] as $index => $param) {
             if ($param['param_name'] == $attribute['param_name']) {
                 $replaced = true;
                 self::$sc[$name]['params'][$index] = $attribute;
             }
         }
         if ($replaced === false) {
             $after_index = false;
             foreach (self::$sc[$name]['params'] as $index => $param) {
                 if ($param['param_name'] == $after) {
                     $after_index = $index;
                     break;
                 }
             }
             if ($after_index) {
                 array_splice(self::$sc[$name]['params'], $after_index + 1, 0, array($attribute));
             } else {
                 self::$sc[$name]['params'][] = $attribute;
             }
         }
         $sort = new Vc_Sort(self::$sc[$name]['params']);
         self::$sc[$name]['params'] = $sort->sortByKey();
         visual_composer()->addShortCode(self::$sc[$name]);
         return true;
     }
     return false;
 }
function vc_gitem_set_mapper_check_access()
{
    if ('true' === vc_post_param('vc_grid_item_editor')) {
        vc_mapper()->setCheckForAccess(false);
    }
}
 /**
  * Modify shortcode's mapped settings.
  * You can modify only one option of the group options.
  * Call this method with $settings_name param as associated array to mass modifications.
  *
  * @static
  *
  * @param $name - shortcode' name.
  * @param $setting_name - option key name or the array of options.
  * @param $value - value of settings if $setting_name is option key.
  *
  * @return array|bool
  */
 public static function modify($name, $setting_name, $value = '')
 {
     if (!self::$is_init) {
         vc_mapper()->addActivity('mapper', 'modify', array('name' => $name, 'setting_name' => $setting_name, 'value' => $value));
         return false;
     }
     if (!isset(self::$sc[$name])) {
         return trigger_error(sprintf(__("Wrong name for shortcode:%s. Name required", "js_composer"), $name));
     } elseif ($setting_name === 'base') {
         return trigger_error(sprintf(__("Wrong setting_name for shortcode:%s. Base can't be modified.", "js_composer"), $name));
     }
     if (is_array($setting_name)) {
         foreach ($setting_name as $key => $value) {
             self::modify($name, $key, $value);
         }
     } else {
         self::$sc[$name][$setting_name] = $value;
         visual_composer()->updateShortcodeSetting($name, $setting_name, $value);
     }
     return self::$sc;
 }
Esempio n. 5
0
function vc_gitem_set_mapper_check_access()
{
    if (vc_user_access()->checkAdminNonce()->wpAny('edit_posts', 'edit_pages')->part('grid_builder')->can()->get() && 'true' === vc_post_param('vc_grid_item_editor')) {
        vc_mapper()->setCheckForAccess(false);
    }
}
">
		<a class="<?php 
echo esc_attr($name_css_class);
?>
">
				<span class="vc_btn-content"
				      title="<?php 
printf(__('Drag to move %s', 'js_composer'), $name);
?>
"><?php 
echo $name;
?>
</span>
		</a>
		<?php 
if (vc_mapper()->userHasAccess($shortcode)) {
    ?>
			<?php 
    foreach ($controls as $control) {
        ?>
				<?php 
        if ($control === 'add') {
            ?>
					<a class="vc_control-btn vc_control-btn-prepend vc_edit" href="#"
					   title="<?php 
            printf(__('Prepend to %s', 'js_composer'), $name);
            ?>
"><span
							class="vc_btn-content"><span class="icon"></span></span></a>
				<?php 
        } elseif ($control === 'edit') {
	<div class="vc_buttons">
		<a id="vc_not-empty-add-element" class="vc_add-element-not-empty-button vc_add-element-action"
		   title="<?php 
_e('Add Element', 'js_composer');
?>
"></a><a id="vc_no-content-add-element"
		                                                              class="vc_add-element-button vc_add-element-action vc_btn vc_btn-grace vc_btn-md vc_btn_3d"
		                                                              href="#"
		                                                              title="<?php 
_e('Add Element', 'js_composer');
?>
"><?php 
_e('Add Element', 'js_composer');
?>
</a><?php 
if (vc_mapper()->userHasAccess('vc_column_text')) {
    ?>
<a
			id="vc_no-content-add-text-block" class="vc_add-text-block-button vc_btn vc_btn-sky vc_btn-md vc_btn_3d"
			href="#"
			title="<?php 
    _e('Add Text Block', 'js_composer');
    ?>
"><?php 
    _e('Add Text Block', 'js_composer');
    ?>
</a><?php 
}
?>
	</div>
	<?php 
function vc_gitem_set_mapper_check_access()
{
    if (vc_verify_admin_nonce() && (current_user_can('edit_posts') || current_user_can('edit_pages')) && 'true' === vc_post_param('vc_grid_item_editor')) {
        vc_mapper()->setCheckForAccess(false);
    }
}
Esempio n. 9
0
 /**
  * Process files/functions for lean mapping settings
  *
  * @since 4.9
  *
  * @param $tag
  *
  * @return bool
  */
 public static function setElementSettings($tag)
 {
     if (!isset(self::$sc[$tag])) {
         return false;
     }
     $settings = self::$sc[$tag];
     if (isset($settings['__vc_settings_function'])) {
         self::$sc[$tag] = call_user_func($settings['__vc_settings_function'], $tag);
     } elseif (isset($settings['__vc_settings_file'])) {
         self::$sc[$tag] = (include $settings['__vc_settings_file']);
     }
     self::$sc[$tag]['base'] = $tag;
     self::$init_elements[$tag] = true;
     vc_mapper()->callElementActivities($tag);
 }