本文整理汇总了PHP中WPBMap::addAllMappedShortcodes方法的典型用法代码示例。如果您正苦于以下问题:PHP WPBMap::addAllMappedShortcodes方法的具体用法?PHP WPBMap::addAllMappedShortcodes怎么用?PHP WPBMap::addAllMappedShortcodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPBMap
的用法示例。
在下文中一共展示了WPBMap::addAllMappedShortcodes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// make sure all vc shortcodes are loaded (needed for ajax pagination)
if (method_exists('WPBMap', 'addAllMappedShortcodes')) {
WPBMap::addAllMappedShortcodes();
}
add_action('the_content', array($this, 'render_custom_css'));
// this adds the [Fields and Views] to editor of visual composers text element
if (array_key_exists('action', $_POST) && $_POST['action'] == 'vc_edit_form') {
add_filter('wpv_filter_dialog_for_editors_requires_post', '__return_false');
}
}
示例2: outputShortcode
/**
* Frozen row shortcode hook.
*
* @param $atts
* @param string $content
*
* @return string
*/
public function outputShortcode($atts, $content = '')
{
$id = $el_class = $output = '';
extract(shortcode_atts(array('el_class' => '', 'id' => ''), $atts));
if (empty($id)) {
return $output;
}
$my_query = new WP_Query(array('post_type' => self::postType(), 'p' => (int) $id));
WPBMap::addAllMappedShortcodes();
while ($my_query->have_posts()) {
$my_query->the_post();
if (get_the_ID() === (int) $id) {
$output .= '<div class="templatera_shortcode' . ($el_class ? ' ' . $el_class : '') . '">';
ob_start();
visual_composer()->addFrontCss();
$content = get_the_content();
echo $content;
$output .= ob_get_clean();
$output .= '</div>';
}
}
wp_reset_query();
wp_enqueue_style('templatera_inline', $this->assetUrl('css/front_style.css'), false, '2.1');
return do_shortcode($output);
}
示例3: parseShortcodesString
/**
* @param $content
* @param bool $is_container
* @param bool $parent_id
*
* @since 4.2
* @return string
*/
function parseShortcodesString($content, $is_container = false, $parent_id = false)
{
$string = '';
preg_match_all('/' . self::shortcodesRegexp() . '/', trim($content), $found);
WPBMap::addAllMappedShortcodes();
add_shortcode('vc_container_anchor', 'vc_container_anchor');
if (count($found[2]) === 0) {
return $is_container && strlen($content) > 0 ? $this->parseShortcodesString('[vc_column_text]' . $content . '[/vc_column_text]', false, $parent_id) : $content;
}
foreach ($found[2] as $index => $s) {
$id = md5(time() . '-' . $this->tag_index++);
$content = $found[5][$index];
$shortcode = array('tag' => $s, 'attrs_query' => $found[3][$index], 'attrs' => shortcode_parse_atts($found[3][$index]), 'id' => $id, 'parent_id' => $parent_id);
if (false !== WPBMap::getParam($s, 'content')) {
$shortcode['attrs']['content'] = $content;
}
$this->post_shortcodes[] = rawurlencode(json_encode($shortcode));
$string .= $this->toString($shortcode, $content);
}
return $string;
}
示例4: parseTemplate
/**
* Generates html with template's variables for rendering new project.
*
* @param $template
*/
public function parseTemplate($template)
{
$this->mapShortcodes();
WPBMap::addAllMappedShortcodes();
$attr = ' width="' . $this->gridAttribute('element_width', 12) . '"' . ' is_end="' . ('true' === $this->isEnd() ? 'true' : '') . '"';
$template = preg_replace('/(\\[(\\[?)vc_gitem\\b)/', '$1' . $attr, $template);
$this->html_template .= do_shortcode($template);
}
示例5: renderTemplatePreview
/**
* Render new template view as backened editor content.
*
* @since 4.8
*/
public function renderTemplatePreview()
{
vc_user_access()->checkAdminNonce()->validateDie()->wpAny(array('edit_post', (int) vc_request_param('post_id')))->validateDie()->part('templates')->can()->validateDie();
$template_id = vc_request_param('template_unique_id');
$template_type = vc_request_param('template_type');
global $current_user;
wp_get_current_user();
if (!isset($template_id, $template_type) || '' === $template_id || '' === $template_type) {
die(__('Error: wrong template id.', 'js_composer'));
}
WPBMap::addAllMappedShortcodes();
if ('my_templates' === $template_type) {
$saved_templates = get_option($this->option_name);
$content = trim($saved_templates[$template_id]['template']);
$content = str_replace('\\"', '"', $content);
$pattern = get_shortcode_regex();
$content = preg_replace_callback("/{$pattern}/s", 'vc_convert_shortcode', $content);
} else {
if ('default_templates' === $template_type) {
$content = $this->getBackendDefaultTemplate(true);
} else {
$content = apply_filters('vc_templates_render_backend_template_preview', $template_id, $template_type);
}
}
vc_include_template(apply_filters('vc_render_template_preview_include_template', 'editors/vc_ui-template-preview.tpl.php'), array('content' => $content, 'editorPost' => get_post(vc_request_param('post_id')), 'current_user' => $current_user));
die;
}
示例6: parseShortcodesCustomCss
/**
* Parse shortcodes custom css string.
*
* This function is used by self::buildShortcodesCustomCss and creates css string from shortcodes attributes
* like 'css_editor'.
*
* @see WPBakeryVisualComposerCssEditor
* @since 4.2
* @access public
*
* @param $content
*
* @return string
*/
public function parseShortcodesCustomCss($content)
{
$css = '';
if (!preg_match('/\\s*(\\.[^\\{]+)\\s*\\{\\s*([^\\}]+)\\s*\\}\\s*/', $content)) {
return $css;
}
WPBMap::addAllMappedShortcodes();
preg_match_all('/' . get_shortcode_regex() . '/', $content, $shortcodes);
foreach ($shortcodes[2] as $index => $tag) {
$shortcode = WPBMap::getShortCode($tag);
$attr_array = shortcode_parse_atts(trim($shortcodes[3][$index]));
if (isset($shortcode['params']) && !empty($shortcode['params'])) {
foreach ($shortcode['params'] as $param) {
if ('css_editor' === $param['type'] && isset($attr_array[$param['param_name']])) {
$css .= $attr_array[$param['param_name']];
}
}
}
}
foreach ($shortcodes[5] as $shortcode_content) {
$css .= $this->parseShortcodesCustomCss($shortcode_content);
}
return $css;
}
示例7: getTemplate
/**
* Get template's shortcodes string
*
* @param $template_data
* @return string|null
*/
protected function getTemplate($template_data)
{
$template = null;
$template_settings = preg_split('/\\:\\:/', $template_data);
$template_id = $template_settings[1];
$template_type = $template_settings[0];
if (!isset($template_id, $template_type) || '' === $template_id || '' === $template_type) {
return $template;
}
WPBMap::addAllMappedShortcodes();
if ('my_templates' === $template_type) {
$saved_templates = get_option($this->getTemplatesEditor()->getOptionName());
$content = trim($saved_templates[$template_id]['template']);
$content = str_replace('\\"', '"', $content);
$pattern = get_shortcode_regex();
$template = preg_replace_callback("/{$pattern}/s", 'vc_convert_shortcode', $content);
} else {
if ('default_templates' === $template_type) {
$template_data = $this->getTemplatesEditor()->getDefaultTemplate($template_id);
if (isset($template_data['content'])) {
$template = $template_data['content'];
}
} else {
$template_preview = apply_filters('vc_templates_render_backend_template_preview', $template_id, $template_type);
if ((string) $template_preview !== (string) $template_id) {
$template = $template_preview;
}
}
}
return $template;
}