本文整理汇总了PHP中shortcode_parse_atts函数的典型用法代码示例。如果您正苦于以下问题:PHP shortcode_parse_atts函数的具体用法?PHP shortcode_parse_atts怎么用?PHP shortcode_parse_atts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shortcode_parse_atts函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* 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;
}
示例2: parse_shortcode_id
/**
* 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;
}
}
示例3: iva_accordion
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;
}
}
示例4: sc_pricing
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();
}
示例5: translator_template_helper
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;
}
示例6: replace_tag
/**
* @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];
}
示例7: shortcodesOnPost
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
}
}
}
}
示例8: mom_graph
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>';
}
}
示例9: pl_get_attachment_ids_from_gallery
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;
}
}
示例10: prefetch_items
/**
* 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;
}
示例11: inbound_shortcode_tabs
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;
}
}
示例12: input
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']);
}
示例13: get_post_gallery_images_gpgi
/**
* 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;
}
示例14: curly_tabs_vc
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;
}
}
示例15: build
/**
* 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;
}