/** * Group items * * @param type $element * * @return string */ static function render($element) { $_element = $element; $label_item = isset($element['label_item']) ? $element['label_item'] : ''; $sub_items = $_element['sub_items']; $overwrite_shortcode_data = isset($element['overwrite_shortcode_data']) ? $element['overwrite_shortcode_data'] : true; $sub_item_type = $element['sub_item_type']; $items_html = array(); $shortcode_name = str_replace('WR_', '', $element['shortcode']); // get id of parameter to extract $extract_title = isset($element['extract_title']) ? $element['extract_title'] : ''; $extra_params = array('drag_handle' => false); if ($sub_items) { foreach ($sub_items as $idx => $item) { $el = new $sub_item_type(); $el->init_element(); // check if $item['std'] is empty or not $shortcode_data = ''; if (!$label_item) { $content = __($shortcode_name, WR_PBL) . ' ' . __('Item', WR_PBL) . ' ' . ($idx + 1); } else { $content = $label_item . ($idx + 1); } if (isset($_element['no_title'])) { $content = $_element['no_title']; } if (!empty($item['std'])) { // keep shortcode data as it is $shortcode_data = $item['std']; // reassign params for shortcode base on std string $extract_params = WR_Pb_Helper_Shortcode::extract_params($item['std']); $params = WR_Pb_Helper_Shortcode::generate_shortcode_params($el->items, NULL, $extract_params, TRUE, FALSE, $content); $el->shortcode_data(); $params['extract_title'] = empty($params['extract_title']) ? __('(Untitled)', WR_PBL) : $params['extract_title']; $content = $params['extract_title']; if ($overwrite_shortcode_data) { $shortcode_data = $el->config['shortcode_structure']; } } $element_type = (array) $el->element_in_pgbldr($content, $shortcode_data, '', '', true, $extra_params); foreach ($element_type as $element_structure) { $items_html[$shortcode_data] = $element_structure; } } } $style = isset($_element['style']) ? 'style="' . $_element['style'] . '"' : ''; // Wrap item html to table $html = ''; foreach ($items_html as $shortcode_data => $item_html) { if (!empty($extract_title)) { $attrs = shortcode_parse_atts($shortcode_data); $title = isset($attrs[$extract_title]) ? $attrs[$extract_title] : ''; $html .= sprintf('<tr><td><b>%s</b></td><td>%s</td></tr>', $title, $item_html); } } $html = sprintf('<table class="%s" %s>%s</table>', 'table table-bordered', $style, balanceTags($html)); $element_name = isset($_element['name']) ? $_element['name'] : __(ucwords(!$label_item ? $shortcode_name : $label_item), WR_PBL) . ' ' . __('Items', WR_PBL); $html_element = "<div id='{$_element['id']}' class='form-group control-group clearfix'><label class='control-label'>{$element_name}</label>\n\t\t\t\t<div class='item-container submodal_frame_2 controls group-table {$_element['class']}'>\n <div class='item-container-content jsn-items-list'>\n {$html}\n </div>\n </div>\n </div>"; return $html_element; }
/** * Parse the CF7 shortcode ID in single or nested shortcodes * @return (array) of CF7 id(s) * @since 1.0.2 */ function parse_shortcode_id($content) { $tag = 'contact-form-7'; // Return if there is no CF7 shortcode in post content if (!has_shortcode($content, $tag)) { return false; } // Get all the CF7 form shortcodes in the post content // Use similar approach as wp-includes\shortcodes.php has_shortcode() function preg_match_all('/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER); if (empty($matches)) { return false; } // Loop through shortcodes, parse shortcode attributes and get the CF7 form ID foreach ($matches as $shortcode) { if ($tag === $shortcode[2]) { $atts = shortcode_parse_atts($shortcode[3]); $ids[] = $atts['id']; // Add the CF7 form ID // Nested shortcode } elseif (!empty($shortcode[5]) && has_shortcode($shortcode[5], $tag)) { // nested shortcodes $shortcode = $this->parse_shortcode_id($shortcode[5]); } } // Return all the CF7 form ID if (isset($ids)) { return $ids; } }
function iva_accordion($atts, $content) { extract(shortcode_atts(array('animation' => ''), $atts)); if (!preg_match_all("/(.?)\\[(accordion)\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/accordion\\])?(.?)/s", $content, $matches)) { return do_shortcode($content); } else { for ($i = 0; $i < count($matches[0]); $i++) { $matches[3][$i] = shortcode_parse_atts($matches[3][$i]); } // Animation Effects //-------------------------------------------------------- $animation = $animation ? ' data-id="' . $animation . '"' : ''; $out = '<div ' . $animation . ' id="accordion' . rand(1, 9) . '" class="ac_wrap iva_anim">'; for ($i = 0; $i < count($matches[0]); $i++) { $active = isset($matches[3][$i]['active']) == 'true' ? 'active' : ''; $out .= '<div class="ac_title ' . $active . '"><span class="arrow"></span>'; if (isset($matches[3][$i]['icon'])) { $out .= '<i class="' . $matches[3][$i]['icon'] . '"></i>'; } $out .= $matches[3][$i]['title'] . '</div>'; $out .= '<div class="ac_content ' . $active . '">' . do_shortcode(trim($matches[5][$i])) . '</div>'; } $out .= '</div>'; return $out; } }
function sc_pricing($atts, $content = null, $code) { if(is_null($content)) return; preg_match_all('/\[price\b([^\]]*)\]((?:(?!\[\/price\]).)+)\[\/price\]/s', $content, $matches); $sub_atts = $matches[1]; $sub_contents = $matches[2]; $price_count = sizeof($sub_atts); ob_start(); ?> <div class="pricing col-<?php echo $price_count?> clearfix"> <?php for($i=0; $i<$price_count; $i++): ?> <?php $sub_atts[$i] = shortcode_parse_atts($sub_atts[$i]); ?> <div class="price <?php if($sub_atts[$i]['featured'] == 'true') echo 'featured'?>"> <h2><?php echo $sub_atts[$i]['title'] ?></h2> <h3><?php echo $sub_atts[$i]['amount'] ?></h3> <div class="description"><?php echo $sub_contents[$i]?></div> <a href="<?php echo $sub_atts[$i]['button_link']?>" title="<?php echo $sub_atts[$i]['button_text']?>" class="button"><?php echo $sub_atts[$i]['button_text']?></a> </div> <?php endfor ?> </div> <?php return ob_get_clean(); }
function translator_template_helper($matches) { $attr = shortcode_parse_atts($matches[3]); // anything which is not a slug is not an exercise and passes through unchanged. if (!array_key_exists('slug', $attr)) { return $matches[0]; } if (!array_key_exists('title', $attr)) { pyboxlog('[in translator_template_helper] Warning: ' . $attr['slug'] . ' has no title!'); $attr['title'] = ""; } $r = '[pyRecall slug="' . $attr['slug'] . '"'; $to_translate = array('title', 'epilogue', 'right', 'wrong', 'defaultcode'); foreach ($to_translate as $key) { if (array_key_exists($key, $attr)) { $r .= ' ' . $key . '="'; $value = $attr[$key]; $value = str_replace('"', '""', $value); $value = str_replace("\n", '\\n', $value); $r .= $value . '"'; } } $r .= ']' . $matches[5] . '[/pyRecall]'; return $r; }
/** * @param $matches * * @return string */ protected function replace_tag($matches) { $tags = $this->all(); $tag = $matches[1]; if (isset($tags[$tag])) { $config = $tags[$tag]; $replacement = ''; if (isset($config['replacement'])) { $replacement = $config['replacement']; } elseif (isset($config['callback'])) { // parse attributes $attributes = array(); if (isset($matches[2])) { $attribute_string = $matches[2]; $attributes = shortcode_parse_atts($attribute_string); } // call function $replacement = call_user_func($config['callback'], $attributes); } return $this->escape_value($replacement); } // default to not replacing it // @todo always replace with empty string? return $matches[0]; }
function shortcodesOnPost() { // get the post data global $post; // get the shortcode regex $pattern = get_shortcode_regex(); // run regex on the content to find all the shortcodes being used preg_match_all('/' . $pattern . '/s', $post->post_content, $matches); // only if there are matches if (!empty($matches)) { //loop through the results //$matches[3] contains the atts //$matches[2] contains the shortcode name //$matches[5] contains the shortcode Data foreach ($matches[3] as $key => $arg) { $shortcode = $matches[2][$key]; //check to see if the found code is mine :) if ($shortcode == 'myShortCode') { // Parse the attributes to an array $data = shortcode_parse_atts($arg); // get the shortcode content $content = $matches[5][$key]; // wp_enqueue_script // wp_enqueue_style // for the specific shortcodes used } } } }
function mom_graph($atts, $content) { extract(shortcode_atts(array('height' => '', 'strips' => ''), $atts)); if ($strips == 'true') { $strips = '<div class="mom_graph_strips"></div>'; } $line_height = ''; if ($height != '') { $line_height = 'line-height:' . ($height + 2) . 'px;'; $height = 'height:' . $height . 'px;'; } if (!preg_match_all("/(.?)\\[(graph)\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/graph\\])?(.?)/s", $content, $matches)) { return do_shortcode($content); } else { for ($i = 0; $i < count($matches[0]); $i++) { $matches[3][$i] = shortcode_parse_atts($matches[3][$i]); } $output = ''; for ($i = 0; $i < count($matches[0]); $i++) { $color = ''; $text_color = ''; if (isset($matches[3][$i]['color'])) { $color = $matches[3][$i]['color']; } if (isset($matches[3][$i]['text_color'])) { $text_color = 'color:' . $matches[3][$i]['text_color'] . ';'; } $output .= '<div class="progress_bar"><span style="' . $text_color . $height . $line_height . '">' . $matches[3][$i]['title'] . ' ' . $matches[3][$i]['score'] . '%</span><div class="progress_wrap"><div class="parograss_text" style="' . $height . '"></div><div class="parograss_inner" style="width:' . $matches[3][$i]['score'] . '%; background-color:' . $color . ';' . $height . '">' . $strips . '</div> </div> </div>'; } return '<div class="progress_outer">' . $output . '</div>'; } }
function pl_get_attachment_ids_from_gallery() { global $post; if ($post != null) { $attachment_ids = array(); $pattern = get_shortcode_regex(); $ids = array(); //finds the "gallery" shortcode, puts the image ids in an associative array: $matches[3] if (preg_match_all('/' . $pattern . '/s', $post->post_content, $matches)) { $count = count($matches[3]); //in case there is more than one gallery in the post. for ($i = 0; $i < $count; $i++) { $atts = shortcode_parse_atts($matches[3][$i]); if (isset($atts['ids'])) { $attachment_ids = explode(',', $atts['ids']); $ids = array_merge($ids, $attachment_ids); } } } return $ids; } else { $ids = array(); return $ids; } }
/** * Loop over all the content in the main loop and do a request for all the items present so that we're only getting * a few API hits instead of all of them. Then, when anything else calls `easyazon_get_item` it will get the cached * data and not have to hit the API. */ public static function prefetch_items() { global $wp_query; $identifiers = array_fill_keys(array_keys(easyazon_get_locales()), array()); $preparsed = array(); $shortcodes = easyazon_get_shortcodes(); foreach ($wp_query->posts as $post) { preg_match_all('/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $shortcode = trim($match[2]); if (in_array($shortcode, $shortcodes)) { $attributes = shortcode_parse_atts($match[3]); $locale = isset($attributes['locale']) ? $attributes['locale'] : false; $identifier = isset($attributes['identifier']) ? $attributes['identifier'] : false; if (!is_array($preparsed[$shortcode])) { $preparsed[$shortcode] = array(); } $preparsed[$shortcode][] = $attributes; if ($locale && $identifier) { $identifiers[$locale][] = $identifier; } } } } foreach ($identifiers as $locale => $queryable) { $cached_items = easyazon_get_items($queryable, $locale); } self::$preparsed_shortcodes = $preparsed; }
function inbound_shortcode_tabs($atts, $content = null) { extract(shortcode_atts(array('heading' => ''), $atts)); $out = ''; if (!preg_match_all("/(.?)\\[(tab)\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/tab\\])?(.?)/s", $content, $matches)) { return do_shortcode($content); } else { for ($i = 0; $i < count($matches[0]); $i++) { $matches[3][$i] = shortcode_parse_atts($matches[3][$i]); } if ($heading != '') { $out .= '<div class="heading"><h3>' . $heading . '</h3><div class="sep"></div></div>'; } $out .= '<div class="tabs-content">'; $out .= '<ul class="tabs-nav clearfix">'; for ($i = 0; $i < count($matches[0]); $i++) { $icon = $matches[3][$i]['icon'] != '' ? '<i class="tab-icon icon-' . $matches[3][$i]['icon'] . '"></i>' : ''; $out .= '<li><a id="tab_' . $i . '_nav" title="' . $matches[3][$i]['title'] . '" href="#tab_' . $i . '">' . $icon . '<span>' . $matches[3][$i]['title'] . '<span></a></li>'; } $out .= '</ul>'; $out .= '<div class="tabs">'; for ($i = 0; $i < count($matches[0]); $i++) { $out .= '<div id="tab_' . $i . '">' . do_shortcode(trim($matches[5][$i])) . '</div>'; } $out .= '</div>'; $out .= '</div>'; return $out; } }
static function input($args, $formdata = false) { if (false !== $formdata) { $form = new scbForm($formdata); return $form->input($args); } if (empty($args['name'])) { return trigger_error('Empty name', E_USER_WARNING); } $args = wp_parse_args($args, array('desc' => '', 'desc_pos' => 'after', 'wrap' => self::TOKEN, 'wrap_each' => self::TOKEN)); if (isset($args['value']) && is_array($args['value'])) { $args['values'] = $args['value']; unset($args['value']); } if (isset($args['extra']) && !is_array($args['extra'])) { $args['extra'] = shortcode_parse_atts($args['extra']); } self::$cur_name = self::get_name($args['name']); switch ($args['type']) { case 'select': case 'radio': $input = self::_single_choice($args); break; case 'checkbox': if (isset($args['values'])) { $input = self::_multiple_choice($args); } else { $input = self::_checkbox($args); } break; default: $input = self::_input($args); } return str_replace(self::TOKEN, $input, $args['wrap']); }
/** * Get Image from Post core file * * This file contains all the logic required for the plugin * * @package Get Post Gallery Images * @copyright Copyright (c) 2013, Sierj Khaletski * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer) * * @since Get Post Gallery Images 0.1 */ function get_post_gallery_images_gpgi() { $attachment_ids = array(); $pattern = get_shortcode_regex(); $images = array(); if (preg_match_all('/' . $pattern . '/s', get_the_content(), $matches)) { //finds the "gallery" shortcode and puts the image ids in an associative array at $matches[3] $count = count($matches[3]); //in case there is more than one gallery in the post. for ($i = 0; $i < $count; $i++) { $atts = shortcode_parse_atts($matches[3][$i]); if (isset($atts['ids'])) { $attachment_ids = explode(',', $atts['ids']); $attachementsCount = count($attachment_ids); if ($attachementsCount > 0) { for ($j = 0; $j < $attachementsCount; $j++) { $image = array(); $attachmentId = intval($attachment_ids[$j]); $image['id'] = $attachmentId; $image['full'] = wp_get_attachment_image_src($attachmentId, 'full'); $image['medium'] = wp_get_attachment_image_src($attachmentId, 'medium'); $image['thumbnail'] = wp_get_attachment_image_src($attachmentId, 'thumbnail'); array_push($images, $image); } } } } } return $images; }
function curly_tabs_vc($atts, $content = null) { $GLOBALS['tabsID'] = isset($GLOBALS['tabsID']) ? $GLOBALS['tabsID'] + 1 : 0; $GLOBALS['tabsSlideID'] = $GLOBALS['tabsID'] * 100; $pattern = get_shortcode_regex(); preg_match_all("/{$pattern}/", $content, $shortcodes); $shortcodes_array = $shortcodes[2]; $shortcodes_values_array = $shortcodes[3]; $shortcodes_content_array = $shortcodes[5]; extract(shortcode_atts(array(), $atts)); if (has_shortcode($content, 'curly_tab')) { $html = '<div class="tabs-container">'; $html .= '<ul class="nav nav-tabs">'; $tabs_keys = array_keys($shortcodes_array, 'curly_tab'); $index = 0; foreach ($tabs_keys as $key => $tab) { extract(shortcode_atts(array('title' => null), shortcode_parse_atts($shortcodes_values_array[$tab]), 'curly_tab')); $html .= '<li class="' . ($index === 0 ? 'active' : '') . '"><a href="#tab' . (100 * $GLOBALS['tabsID'] + 1) . '" data-toggle="tab">' . $title . '</a></li>'; $index++; } $html .= '</ul>'; $html .= '<div class="tab-content">'; $html .= do_shortcode($content); $html .= '</div>'; $html .= '</div>'; return $html; } }
/** * Build edit form fields * * @deprecated 4.4 * @use Vc_Shortcode_Edit_Form::renderFields */ public function build() { $tag = vc_post_param('element'); $shortCode = stripslashes(vc_post_param('shortcode')); $fields = new Vc_Edit_Form_Fields($tag, shortcode_parse_atts($shortCode)); $fields->render(); die; }
/** * Build edit form fields * * @deprecated 4.4 * @use Vc_Shortcode_Edit_Form::renderFields */ public function build() { $tag = vc_post_param('element'); $shortCode = stripslashes(vc_post_param('shortcode')); require_once vc_path_dir('EDITORS_DIR', 'class-vc-edit-form-fields.php'); $fields = new Vc_Edit_Form_Fields($tag, shortcode_parse_atts($shortCode)); $fields->render(); die; }
function iva_tabs($atts, $content = null, $code) { extract(shortcode_atts(array('type' => '', 'position' => '', 'animation' => ''), $atts)); $icons = $out = $customtabcolor = $customtabtextcolor = ''; if ($type == "vertical") { $type = 'vertical'; } else { $type = ""; } switch ($position) { case 'centertabs': $positiontype = "centertabs"; break; case 'righttabs': $positiontype = "righttabs"; break; default: $positiontype = ""; } if (!preg_match_all("/(.?)\\[(tab)\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/tab\\])?(.?)/s", $content, $matches)) { return do_shortcode($content); } else { for ($i = 0; $i < count($matches[0]); $i++) { $matches[3][$i] = shortcode_parse_atts($matches[3][$i]); } // Animation Effects //-------------------------------------------------------- $animation = $animation ? ' data-id="' . $animation . '"' : ''; $tabid = 'tab' . rand(1, 99); $out .= '<div ' . $animation . ' id="' . $tabid . '" class="iva_anim systabspane ' . $type . '">'; $out .= '<ul class="tabs">'; for ($i = 0; $i < count($matches[0]); $i++) { if (isset($matches[3][$i]['tabcolor'])) { if (strpos($matches[3][$i]['tabcolor'], '#') !== false) { $customtabcolor = ' style="background-color:' . $matches[3][$i]['tabcolor'] . '"'; } } if (isset($matches[3][$i]['textcolor'])) { if (strpos($matches[3][$i]['textcolor'], '#') !== false) { $customtabtextcolor = ' style="color:' . $matches[3][$i]['textcolor'] . '"'; } } if (isset($matches[3][$i]['icon'])) { $icons = $matches[3][$i]['icon']; } $out .= '<li class="' . $icons . '" id="#' . $tabid . $i . '" ' . $customtabcolor . ' ><a ' . $customtabtextcolor . '>' . $matches[3][$i]['title'] . '</a></li>'; } $out .= '</ul>'; $out .= '<div class="panes">'; for ($i = 0; $i < count($matches[0]); $i++) { $out .= '<div class="tab_content" id="' . $tabid . $i . '" >' . pre_process_shortcode(do_shortcode(trim($matches[5][$i]))) . '</div>'; } $out .= '</div></div>'; return $out; } }
/** * */ public static function ratings($atts = null, $content = null, $code = null) { if ($atts == 'generator') { $numbers = range(1, 10); $scores = array('0.5' => '0.5', '1' => '1', '1.5' => '1.5', '2' => '2', '2.5' => '2.5', '3' => '3', '3.5' => '3.5', '4' => '4', '4.5' => '4.5', '5' => '5'); $option = array('name' => __('Stars', MISS_ADMIN_TEXTDOMAIN), 'value' => 'ratings', 'options' => array(array('name' => __('Number of Bars', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Select the number of slides you wish to display. Slides are the selectable areas which change the content.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'multiply', 'default' => '', 'options' => $numbers, 'type' => 'select', 'shortcode_multiplier' => true), array('name' => __('Show Total', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Check this option to display total score.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'show_overall', 'default' => '', 'type' => 'checkbox', 'options' => array('true' => __('Enable Total Score', MISS_ADMIN_TEXTDOMAIN)), 'shortcode_dont_multiply' => true, 'shortcode_optional_wrap' => false), array('name' => __('Icon', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Please select score icon type.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'icon', 'default' => 'im-icon-accessibility', 'type' => 'icons', 'target' => 'all_icons', 'shortcode_dont_multiply' => true, 'shortcode_optional_wrap' => false), array('name' => __('Active Colour', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Please select active icon colour.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'style_color', 'default' => '', 'type' => 'color', 'shortcode_dont_multiply' => true, 'shortcode_optional_wrap' => false), array('name' => __('Inactive Colour', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Please select inactive icon colour.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'style_color2', 'default' => '', 'type' => 'color', 'shortcode_dont_multiply' => true, 'shortcode_optional_wrap' => false), array('name' => __('Icon size', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Change icon size.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'size', 'default' => '18', 'type' => 'numeral', 'shortcode_dont_multiply' => true, 'shortcode_optional_wrap' => false), array('name' => __('Animation', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Turn on CSS3 transitions. You may specify animation effect.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'animation', 'default' => 'im-icon-android', 'type' => 'select', 'target' => 'css_animation', 'shortcode_dont_multiply' => true, 'shortcode_optional_wrap' => false), array('name' => __('Criteria 1 Title', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Enter criteria title.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'content', 'default' => '', 'type' => 'text', 'shortcode_multiply' => true), array('name' => __('Criteria 1 Value', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Define score value from 0.5 to 5.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'score', 'default' => '', 'type' => 'select', 'options' => $scores, 'shortcode_multiply' => true), array('value' => 'score', 'nested' => true), 'shortcode_has_atts' => true)); return $option; } if (!preg_match_all("/(.?)\\[(score)\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/score\\])?(.?)/s", $content, $matches)) { return miss_content_group($content); } else { for ($i = 0; $i < count($matches[0]); $i++) { $matches[3][$i] = shortcode_parse_atts($matches[3][$i]); } extract(shortcode_atts(array('size' => '18', 'animation' => '', 'icon' => 'im-icon-star'), $atts)); $out = ''; $out .= !empty($atts['caption']) ? '<h4><span>' . $atts['caption'] . '</span></h4>' : ''; $atts['animation'] = !empty($atts['animation']) ? ' im-transform im-animate-element ' . $atts['animation'] : ''; $atts['size'] = !empty($atts['size']) ? $atts['size'] : '18'; $atts['style_color'] = !empty($atts['style_color']) ? $atts['style_color'] : ''; $atts['style_color2'] = !empty($atts['style_color2']) ? $atts['style_color2'] : ''; $out .= '<ul class="rates">'; $overall = 0; $counter = 0; for ($i = 0; $i < count($matches[0]); $i++) { $counter++; $rating = $matches[3][$i]['score']; if (!isset($atts['icon'])) { $atts['icon'] = 'im-icon-star-6'; } $out .= '<li class="rating_row' . $atts['animation'] . '">'; $out .= $matches[5][$i]; $out .= '<div class="rating_right">'; $out .= score_output($rating, $atts['size'], $atts['style_color'], $atts['style_color2'], $atts['icon']); $out .= '</div>'; $out .= '</li>'; $overall += $rating; } $out .= '</ul>'; if (isset($atts['show_overall']) && $atts['show_overall'] == "true") { if ($counter > 1) { $out .= '<div class="overall_rating' . $atts['animation'] . '">'; $overall = $overall / $counter; $overget = $overall - floor($overall); if ($overget >= 0.5) { $overall = floor($overall) + 0.5; } else { $overall = floor($overall); } $out .= "<h4><span class='uppercase transform-uppercase'>" . __("Total", MISS_TEXTDOMAIN) . "</span></h4><div class='total-inner'><span class='score total'>" . $overall . "</span><span class='right'>" . score_output($overall, '40', $atts['style_color'], $atts['style_color2'], $atts['icon']) . "</span></div>"; $out .= '</div>'; } } return '<div class="rating_box shortcode">' . $out . '</div>'; } }
/** * Build edit form fields * * @deprecated 4.4 * @use Vc_Shortcode_Edit_Form::renderFields */ public function build() { // _deprecated_function( 'Vc_Shortcode_Edit_Form::build', '4.4 (will be removed in 4.10)', 'Vc_Shortcode_Edit_Form::renderFields' ); $tag = vc_post_param('element'); vc_user_access()->checkAdminNonce()->validateDie(__('Access denied', 'js_composer'))->wpAny('edit_posts', 'edit_pages')->validateDie(__('Access denied', 'js_composer'))->check('vc_user_access_check_shortcode_edit', $tag)->validateDie(__('Access denied', 'js_composer')); $shortcode = stripslashes(vc_post_param('shortcode')); require_once vc_path_dir('EDITORS_DIR', 'class-vc-edit-form-fields.php'); $fields = new Vc_Edit_Form_Fields($tag, shortcode_parse_atts($shortcode)); $fields->render(); die; }
function inbound_shortcode_teaser($atts, $content = null) { extract(shortcode_atts(array('heading' => '', 'style' => '', 'column' => '4'), $atts)); $out = ''; $grid = ' grid full'; if ($column == '2') { $grid = ' grid one-half'; } if ($column == '3') { $grid = ' grid one-third'; } if ($column == '4') { $grid = ' grid one-fourth'; } if ($column == '5') { $grid = ' grid one-fifth'; } $style = $style != '' ? ' ' . $style : ''; if (!preg_match_all("/(.?)\\[(block)\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/block\\])?(.?)/s", $content, $matches)) { return do_shortcode($content); } else { for ($i = 0; $i < count($matches[0]); $i++) { $matches[3][$i] = shortcode_parse_atts($matches[3][$i]); } $out .= '<div class="row">'; if ($heading != '') { $out .= '<div class="grid full"><div class="heading"><h3>' . $heading . '</h3><div class="sep"></div></div></div>'; } for ($i = 0; $i < count($matches[0]); $i++) { $title = $matches[3][$i]['link'] ? '<a class="reserve" href="' . $matches[3][$i]['link'] . '">' . $matches[3][$i]['title'] . '</a>' : $matches[3][$i]['title']; $out .= '<aside class="teaser' . $grid . $style . '">'; if ($matches[3][$i]['image']) { $out .= '<div class="teaser-image"><img src="' . $matches[3][$i]['image'] . '" alt="" /></div>'; } elseif ($matches[3][$i]['icon']) { $out .= '<div class="teaser-icon"><i class="icon-' . $matches[3][$i]['icon'] . '"></i></div>'; } $out .= '<header class="teaser-header">'; $out .= '<h3 class="teaser-title">' . $title . '</h3>'; if ($matches[3][$i]['subtitle']) { $out .= '<div class="teaser-subtitle">' . $matches[3][$i]['subtitle'] . '</div>'; } $out .= '</header>'; if ($matches[5][$i]) { $out .= '<div class="teaser-content">' . do_shortcode(trim($matches[5][$i])) . '</div>'; } $out .= '</aside>'; } if ($i == $column - 1) { $out .= '<div class="clear"></div>'; } $out .= '</div>'; } return $out; }
/** * Function to process [codesyntax] tag in comments * * @param array $m * @return string */ function wp_synhighlight_do_shortcode_tag($m) { $attr = shortcode_parse_atts($m[2]); if (isset($m[4])) { // enclosing tag - extra parameter return fr_codesyntax_handler($attr, html_entity_decode($m[4]), false, true); } else { // self-closing tag return fr_codesyntax_handler($attr, NULL, false, true); } }
/** * Build edit form fields * * @deprecated 4.4 * @use Vc_Shortcode_Edit_Form::renderFields */ public function build() { if (!vc_verify_admin_nonce(vc_post_param('nonce')) || !current_user_can('edit_posts') && !current_user_can('edit_pages')) { wp_send_json(array('success' => false)); } $tag = vc_post_param('element'); $shortCode = stripslashes(vc_post_param('shortcode')); require_once vc_path_dir('EDITORS_DIR', 'class-vc-edit-form-fields.php'); $fields = new Vc_Edit_Form_Fields($tag, shortcode_parse_atts($shortCode)); $fields->render(); die; }
/** * Modifies post data to use new imported ids * * @return void * @author **/ function oxy_one_click_before_insert_post($post, $one_click) { if (!class_exists('simple_html_dom')) { require_once OXY_THEME_DIR . 'vendor/oxygenna/oxygenna-one-click/inc/simple_html_dom.php'; } // create post object $post_object = new stdClass(); // strip slashes added by json $post_object->post_content = stripslashes($post['post_content']); $gallery_shortcode = oxy_get_content_shortcode($post_object, 'gallery'); if ($gallery_shortcode !== null) { if (isset($gallery_shortcode[0])) { // show gallery $gallery_ids = null; if (array_key_exists(3, $gallery_shortcode)) { if (array_key_exists(0, $gallery_shortcode[3])) { $gallery_attrs = shortcode_parse_atts($gallery_shortcode[3][0]); if (array_key_exists('ids', $gallery_attrs)) { // we have a gallery with ids so lets replace the ids $gallery_ids = explode(',', $gallery_attrs['ids']); $new_gallery_ids = array(); foreach ($gallery_ids as $gallery_id) { $new_gallery_ids[] = $one_click->install_package->lookup_map('attachments', $gallery_id); } // replace old ids with new ones $old_string = 'ids="' . implode(',', $gallery_ids) . '"'; $new_string = 'ids="' . implode(',', $new_gallery_ids) . '"'; $post_object->post_content = str_replace($old_string, $new_string, $post_object->post_content); } } } } } if (!empty($post_object->post_content)) { $html = str_get_html($post_object->post_content); $imgs = $html->find('img'); foreach ($imgs as $img) { $replace_image_src = $one_click->install_package->lookup_map('images', $img->src); if (false !== $replace_image_src) { $img->src = $replace_image_src; } } $post_object->post_content = $html->save(); $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'vc_single_image', 'image', 'attachments'); $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'vc_row', 'background_image', 'attachments'); $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'shapedimage', 'image', 'attachments'); $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'staff_featured', 'member', 'oxy_staff'); $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'post_featured', 'featured', 'post'); } // replace post content with one from object $post['post_content'] = $post_object->post_content; return $post; }
function inbound_shortcode_testimonial($atts, $content = null) { extract(shortcode_atts(array('heading' => __('Testimonial', 'leads'), 'column' => 1), $atts)); $grid = ' grid full'; if ($column == '2') { $grid = ' grid one-half'; } if ($column == '3') { $grid = ' grid one-third'; } if ($column == '4') { $grid = ' grid one-fourth'; } if ($column == '5') { $grid = ' grid one-fifth'; } $out = ''; $out .= '<div class="testimonial row">'; if ($heading != '') { $out .= '<div class="grid full"><div class="heading"><h3>' . $heading . '</h3><div class="sep"></div></div></div>'; } if (!preg_match_all("/(.?)\\[(testimony)\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/testimony\\])?(.?)/s", $content, $matches)) { return do_shortcode($content); } else { for ($i = 0; $i < count($matches[0]); $i++) { $matches[3][$i] = shortcode_parse_atts($matches[3][$i]); } for ($i = 0; $i < count($matches[0]); $i++) { $out .= '<div class="' . $grid . '">'; $out .= '<div class="fancy-quote">'; $out .= '<div class="quote-text">'; $out .= '<div class="triangle"></div>'; $out .= '<p>' . do_shortcode(trim($matches[5][$i])) . '</p>'; $out .= '</div>'; $out .= '<div class="quote-author">'; if ($matches[3][$i]['author']) { $out .= '<span class="quote-author-name">' . $matches[3][$i]['author'] . '</span>'; } if ($matches[3][$i]['meta']) { $out .= ' - <span class="quote-author-meta">' . $matches[3][$i]['meta'] . '</span>'; } $out .= '</div>'; $out .= '</div>'; $out .= '</div>'; if ($i == $column - 1) { $out .= '<div class="clear"></div>'; } } } $out .= '</div>'; return $out; }
function fancy_images($atts = null, $content = null) { if ($atts == 'generator') { $option = array('name' => __('Fancy Images', MYSITE_ADMIN_TEXTDOMAIN), 'value' => 'fancy_images', 'options' => array(array('name' => __('Width', MYSITE_ADMIN_TEXTDOMAIN), "desc" => __('Set the width for your image. Leave this blank if you do not want your image to be resized.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'width', 'type' => 'text', 'shortcode_dont_multiply' => true), array('name' => __('Height', MYSITE_ADMIN_TEXTDOMAIN), "desc" => __('Set the width for your image. Leave this blank if you do not want your image to be resized.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'height', 'type' => 'text', 'shortcode_dont_multiply' => true), array('name' => __('Number of images', MYSITE_ADMIN_TEXTDOMAIN), "desc" => __('Select how many images you wish to display.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'multiply', 'options' => range(1, 20), 'type' => 'select', 'shortcode_multiplier' => true), array('name' => __('Image 1 URL', MYSITE_ADMIN_TEXTDOMAIN), "desc" => __('You can upload the image you wish to use here.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'content', 'type' => 'upload', 'shortcode_multiply' => true), array('name' => __('Image 1 Title Attribute <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN), "desc" => __('Type out the title text you wish to use with your image.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'title', 'type' => 'text', 'shortcode_multiply' => true), array('name' => __('Image 1 Alt Attribute <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN), "desc" => __('Type out the alt text you wish to use with your image.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'alt', 'type' => 'text', 'shortcode_multiply' => true), array('name' => __('Image 1 Caption <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN), "desc" => __('Type out the caption text you wish to use with your image.<br /><br />This text will be displayed below your image.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'caption', 'type' => 'text', 'shortcode_multiply' => true), array('name' => __('Image 1 Custom Link <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN), "desc" => __('By default when a reader clicks on your image it will open in a lightbox.<br /><br />You can paste a URL here to use instead.', MYSITE_ADMIN_TEXTDOMAIN), 'id' => 'link_to', 'type' => 'text', 'shortcode_multiply' => true), array('value' => 'image', 'nested' => true), 'shortcode_has_atts' => true)); return $option; } global $mysite; extract(shortcode_atts(array('width' => '', 'height' => '', 'group' => '', 'class' => 'true'), $atts)); $out = ''; $width = !empty($width) ? trim(str_replace(' ', '', str_replace('px', '', $width))) : $mysite->layout['images']['three_column_portfolio'][0]; $height = !empty($height) ? trim(str_replace(' ', '', str_replace('px', '', $height))) : $mysite->layout['images']['three_column_portfolio'][1]; if (!preg_match_all('/(.?)\\[(image)\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/image\\])?(.?)/s', $content, $matches)) { if (preg_match_all('!https?://.+\\.(?:jpe?g|png|gif)!Ui', $content, $matches)) { if (empty($group)) { $group = 'fancy_img_group_' . rand(1, 1000); } $out .= '<div class="fancy_images">'; foreach ($matches[0] as $img) { $out .= '<div class="fancy_image">'; $out .= mysite_display_image(array('src' => $img, 'alt' => '', 'title' => '', 'height' => $height, 'width' => $width, 'class' => $class == 'true' ? 'hover_fade_js' : '', 'link_to' => $img, 'link_class' => 'fancy_image_load', 'prettyphoto' => true, 'group' => $group, 'preload' => isset($mysite->mobile) ? false : true)); $out .= '</div>'; } $out .= '</div>'; } } else { for ($i = 0; $i < count($matches[0]); $i++) { $matches[3][$i] = shortcode_parse_atts($matches[3][$i]); if (isset($matches[3][$i]['caption'])) { $has_caption = true; } } if (empty($group)) { $group = 'fancy_img_group_' . rand(1, 1000); } $out .= '<div class="fancy_images' . (isset($has_caption) ? ' has_captions' : '') . '">'; for ($i = 0; $i < count($matches[0]); $i++) { $img = $matches[5][$i]; $alt = isset($matches[3][$i]['alt']) ? $matches[3][$i]['alt'] : ''; $title = isset($matches[3][$i]['title']) ? $matches[3][$i]['title'] : ''; $link_to = !empty($matches[3][$i]['link_to']) ? $matches[3][$i]['link_to'] : $img; $prettyphoto = !empty($matches[3][$i]['link_to']) && strpos($matches[3][$i]['link_to'], 'iframe') === false ? false : true; $out .= '<div class="fancy_image">'; $out .= mysite_display_image(array('src' => $img, 'alt' => $alt, 'title' => $title, 'height' => $height, 'width' => $width, 'class' => $class == 'true' ? 'hover_fade_js' : '', 'link_to' => $link_to, 'link_class' => 'fancy_image_load', 'prettyphoto' => $prettyphoto, 'group' => $group, 'preload' => isset($mysite->mobile) ? false : true)); if (isset($has_caption)) { $out .= '<span class="fancy_image_caption" style="display:none;">' . $matches[3][$i]['caption'] . '</span>'; } $out .= '</div>'; } $out .= '</div>'; } return $out; }
function kt_get_all_attributes($tag, $text) { preg_match_all('/' . get_shortcode_regex() . '/s', $text, $matches); $out = array(); if (isset($matches[2])) { foreach ((array) $matches[2] as $key => $value) { if ($tag === $value) { $out[] = shortcode_parse_atts($matches[3][$key]); } } } return $out; }
function do_shortcode_tag($m) { global $shortcode_tags; $tag = $m[1]; $attr = shortcode_parse_atts($m[2]); if (isset($m[4])) { // enclosing tag - extra parameter return call_user_func($shortcode_tags[$tag], $attr, $m[4]); } else { // self-closing tag return call_user_func($shortcode_tags[$tag], $attr); } }
function dialogue_api_parse_content($content) { $newct = array(); $pattern = get_shortcode_regex(); $len = preg_match_all('/' . $pattern . '/s', $content, $paragraphs); for ($i = 0; $i < $len; $i++) { if ($paragraphs[2][$i] != 'commentable') { continue; } $attrs = shortcode_parse_atts($paragraphs[3][$i]); $newct[$attrs['id']] = $paragraphs[5][$i]; } return $newct; }
function minti_accordion($atts, $content = null, $code) { extract(shortcode_atts(array('open' => '1'), $atts)); if (!preg_match_all("/(.?)\\[(accordion-item)\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/accordion-item\\])?(.?)/s", $content, $matches)) { return do_shortcode($content); } else { $output = ''; for ($i = 0; $i < count($matches[0]); $i++) { $matches[3][$i] = shortcode_parse_atts($matches[3][$i]); $output .= '<div class="accordion-title"><a href="#">' . $matches[3][$i]['title'] . '</a></div><div class="accordion-inner">' . do_shortcode(trim($matches[5][$i])) . '</div>'; } return '<div class="accordion" rel="' . $open . '">' . $output . '</div>'; } }
function bs_attribute_map($str, $att = null) { $res = array(); $return = array(); $reg = get_shortcode_regex(); preg_match_all('~' . $reg . '~', $str, $matches); foreach ($matches[2] as $key => $name) { $parsed = shortcode_parse_atts($matches[3][$key]); $parsed = is_array($parsed) ? $parsed : array(); $res[$name] = $parsed; $return[] = $res; } return $return; }