public static function map($name, $attributes) { if (empty($attributes['name'])) { trigger_error(sprintf(__("Wrong name for shortcode:%s. Name required", "js_composer"), $name)); } elseif (empty($attributes['base'])) { trigger_error(sprintf(__("Wrong base for shortcode:%s. Base required", "js_composer"), $name)); } else { self::$sc[$name] = $attributes; self::$sc[$name]['params'] = array(); if (!empty($attributes['params'])) { $attributes_keys = array(); foreach ($attributes['params'] as $attribute) { if ($attribute['type'] === 'loop') { $attribute['value'] = VcLoopSettings::buildDefault($attribute); } $key = array_search($attribute['param_name'], $attributes_keys); if ($key === false) { $attributes_keys[] = $attribute['param_name']; self::$sc[$name]['params'][] = $attribute; } else { self::$sc[$name]['params'][$key] = $attribute; } } } WPBakeryVisualComposer::getInstance()->addShortCodePlugin(self::$sc[$name]); self::$sc_row[] = self::$sc[$name]; } }
function vc_set_loop_default_value($param) { if (empty($param['value']) && isset($param['settings'])) { $param['value'] = VcLoopSettings::buildDefault($param); } return $param; }
public static function map($name, $attributes) { if (!self::$is_init) { vc_mapper()->addActivity('mapper', 'map', array('name' => $name, 'attributes' => $attributes)); return false; } if (empty($attributes['name'])) { trigger_error(sprintf(__("Wrong name for shortcode:%s. Name required", LANGUAGE_ZONE), $name)); } elseif (empty($attributes['base'])) { trigger_error(sprintf(__("Wrong base for shortcode:%s. Base required", LANGUAGE_ZONE), $name)); } else { self::$sc[$name] = $attributes; self::$sc[$name]['params'] = array(); if (!empty($attributes['params'])) { $attributes_keys = array(); foreach ($attributes['params'] as $attribute) { if ($attribute['type'] === 'loop') { $attribute['value'] = VcLoopSettings::buildDefault($attribute); } $key = array_search($attribute['param_name'], $attributes_keys); if ($key === false) { $attributes_keys[] = $attribute['param_name']; self::$sc[$name]['params'][] = $attribute; } else { self::$sc[$name]['params'][$key] = $attribute; } } } WPBakeryVisualComposer::getInstance()->addShortCodePlugin(self::$sc[$name]); } }