/** * Breaks block quotes out of the content they're in. We want blockquotes to be full width * * @param string $content Current content of the page. * * @return string */ public function blockquote_full_width($content) { $shortcode = new Shortcodes(); $content = str_replace('<blockquote>', $shortcode->get_break_out_body() . '<blockquote>', $content); $content = str_replace('</blockquote>', '</blockquote>' . $shortcode->get_restart_body(), $content); return $content; }
public static function init() { //Add shortcodes include 'shortcodes.php'; Shortcodes::init(); add_action('plugins_loaded', array(__CLASS__, 'check_visual_composer_plugin')); }
/** * Get the Shortcode instance. * * @return \Grav\Plugin\Shortcodes */ public static function getShortcodesClass() { if (!self::$shortcodes) { self::$shortcodes = Shortcodes::instance(); } return self::$shortcodes; }
function lock_highlight_end($message) { global $mybb, $replacement; if (!empty($mybb->input['highlight'])) { $message = str_replace($replacement, 'hide', $message); } return Shortcodes::parse($message); }
function addQRCode($atts, $content = null) { extract(Shortcodes::shortcodeAtts(array("size" => 150, "eclevel" => 'L', "margin" => '0', "url" => null), $atts)); if (is_null($url)) { //$url = Core::curPageURL(); } return '<img src="https://chart.googleapis.com/chart?chs=' . $size . 'x' . $size . '&cht=qr&chld=' . $eclevel . '|' . $margin . '&chl=' . $url . '" alt="QR code" width="' . $size . '" height="' . $size . '"/>'; }
public function load() { add_action('wp_head', [__CLASS__, 'insert_script']); add_action('podlove_podcast_settings_tabs', [__CLASS__, 'podcast_settings_tabs']); add_filter('podlove_templates_global_context', [__CLASS__, 'add_flattr_to_template_context']); FeedExtension::init(); ContributorExtension::init(); Shortcodes::init(); }
public function init() { Craft::import('plugins.shortcodes.lib.Shortcodes'); $results = craft()->plugins->call('registerShortcodes'); foreach ($results as $class => $result) { $callables = is_object($result[0]) ? array($result) : $result; foreach ($callables as $callable) { Shortcodes::add_shortcode($callable[1], $callable); } } }
function yoast_rss_shortcode($atts) { extract(Shortcodes::shortcodeAtts(array("feed" => '', "num" => '5', "excerpt" => true, "target" => '_self'), $atts)); $content = file_get_contents($feed); $x = new SimpleXmlElement($content); $content = "<ul>"; foreach ($x->channel->item as $entry) { $content .= "<li><a href='{$entry->link}' title='{$entry->title}'>" . $entry->title . "</a></li>"; } $content .= "</ul>"; return $content; }
function chart_shortcode($atts) { extract(Shortcodes::shortcodeAtts(array('data' => '', 'colors' => '', 'size' => '400x200', 'bg' => 'ffffff', 'title' => '', 'labels' => '', 'advanced' => '', 'type' => 'pie'), $atts)); $string = ''; switch ($type) { case 'line': $charttype = 'lc'; break; case 'xyline': $charttype = 'lxy'; break; case 'sparkline': $charttype = 'ls'; break; case 'meter': $charttype = 'gom'; break; case 'scatter': $charttype = 's'; break; case 'venn': $charttype = 'v'; break; case 'pie': $charttype = 'p3'; break; case 'pie2d': $charttype = 'p'; break; default: $charttype = $type; break; } if ($title) { $string .= '&chtt=' . $title . ''; } if ($labels) { $string .= '&chl=' . $labels . ''; } if ($colors) { $string .= '&chco=' . $colors . ''; } $string .= '&chs=' . $size . ''; $string .= '&chd=t:' . $data . ''; $string .= '&chf=' . $bg . ''; return '<img title="' . $title . '" src="http://chart.apis.google.com/chart?cht=' . $charttype . '' . $string . $advanced . '" alt="' . $title . '" />'; }
function showFlickrGallery($atts) { extract(Shortcodes::shortcodeAtts(array("name" => ''), $atts)); $ch = @curl_init(); @curl_setopt($ch, CURLOPT_URL, "http://api.flickr.com/services/feeds/photoset.gne?set=72157634215973638&nsid=97716697@N07&lang=en-us&format=json&nojsoncallback=1"); @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); @curl_setopt($ch, CURLOPT_TIMEOUT, 10); $response = @curl_exec($ch); $errno = @curl_errno($ch); $error = @curl_error($ch); if ($errno == CURLE_OK) { $pics = json_decode($response); } $ret = ''; foreach ($pics->items as $item) { $ret .= "<img src='" . $item->media->m . "' alt='" . $item->title . "' />"; } return $ret; }
public static function addCode($atts, $content = null) { extract(Shortcodes::shortcodeAtts(array("mode" => null), $atts)); $mode = isset($mode) ? $mode : 'html'; return '<pre data-language="' . $mode . '"><code>' . htmlspecialchars($content) . '</code></pre>'; }
echo esc_html($atts['color']); ?> &loop=<?php echo esc_html($atts['loop']); ?> &player_id=<?php echo esc_html($atts['player_id']); ?> &portrait=<?php echo esc_html($atts['portrait']); ?> &title=<?php echo esc_html($atts['title']); ?> &autoplay=<?php echo esc_html($atts['autoplay']); ?> &autopause=<?php echo esc_html($atts['autopause']); ?> " frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> </div> <?php $vimeo = ob_get_clean(); } return $vimeo; } } Shortcodes::init();
$args = array('posts_per_page' => $number, 'post_type' => 'property', 'orderby' => 'meta_value', 'meta_key' => 'wptrebs_last_updated_text'); $query = new WP_Query($args); if ($query->have_posts()) { echo '<ul class="wptrebs_feed">'; while ($query->have_posts()) { $query->the_post(); ?> <li class="wptrebs_feed_item"> <div class="price"><span>$</span><?php echo number_format(get_post_meta(get_the_ID(), 'wptrebs_price', true)); ?> </div> <a href="<?php the_permalink(); ?> "><?php the_post_thumbnail('wptrebs_feed_img'); ?> </a> </li> <?php } // end while echo '</ul>'; echo '<div class="wptrebs_clear"></div>'; } // end if } } add_shortcode('wptrebs_feed', array(Shortcodes::get_instance(), 'FeedShortcode'));
function showSection($atts, $content = null) { extract(Shortcodes::shortcodeAtts(array("name" => '', "class" => ''), $atts)); return "<div id='" . $name . "' class='" . $class . "'>" . Shortcodes::doShortcode($content) . "</div>"; }
function addSoundcloud($atts, $content = null) { extract(Shortcodes::shortcodeAtts(array("url" => null, "width" => '400', "height" => '225', "scrolling" => 'no', "frameborder" => 'no', "iframe" => 'true'), $atts)); return '<iframe width="' . $width . '" height="' . $height . '" scrolling="' . $scrolling . '" frameborder="' . $frameborder . '" src="https://w.soundcloud.com/player/?url=' . $url . '"></iframe>'; }
/** * @covers Xoops\Core\Text\ShortCodes::addShortcode * @covers Xoops\Core\Text\ShortCodes::process * @covers Xoops\Core\Text\ShortCodes::processTag * @covers Xoops\Core\Text\ShortCodes::parseAttributes * @covers Xoops\Core\Text\ShortCodes::shortcodeRegex */ public function testEscaping() { $shortcodes = new Shortcodes(); $shortcodes->addShortcode('test', array($this, 'dummyFunction_test')); $content = 'Hello my name is [[test name="Sam"]]!'; $expectation = 'Hello my name is [test name="Sam"]!'; $this->assertEquals($expectation, $shortcodes->process($content)); }
<?php namespace WordPress\Plugin\Glossary; abstract class Shortcodes { static function Init() { Add_Shortcode('glossary_related_terms', array(__CLASS__, 'Related_Terms')); } static function Related_Terms($attributes = Null) { $attributes = Is_Array($attributes) ? $attributes : array(); $attributes = Array_Merge(array('number' => 5), $attributes); $related_terms = Core::getTagRelatedTerms($attributes); return Template::load('glossary-related-terms.php', array('attributes' => $attributes, 'related_terms' => $related_terms)); } } Shortcodes::Init();
function addYoutube($atts, $content = null) { extract(Shortcodes::shortcodeAtts(array("id" => null, "width" => '400', "height" => '225'), $atts)); return '<iframe width="' . $width . '" height="' . $height . '" src="http://www.youtube.com/embed/' . $id . '?autoplay=0" frameborder="0" allowfullscreen></iframe>'; }
require_once __DIR__ . '/../pcrypt.php'; $key = $mybb->settings['lock_key']; $pcrypt = new pcrypt(MODE_ECB, "BLOWFISH", $key); // place the info we need, into an array $info = array('pid' => $post['pid'], 'cost' => $cost); // encode the information as json, for safe transit $info = json_encode($info); // encrypt the json, and encode it as base64; so it can be submitted in a form. $info = base64_encode($pcrypt->encrypt($info)); // build the return button. $return = "<form method=\"post\">\n <button type=\"submit\">Unlock for {$cost} points.</button>\n <input type=\"hidden\" name=\"info\" value=\"{$info}\" />\n <input type=\"hidden\" name=\"action\" value=\"purchase\" />\n </form>"; // if the user doesn't need to pay, but hasn't posted } elseif (!$paid && !$posted) { // tell them to reply to the thread. $return = "You must reply to this thread to view this content."; // all is good. } else { // give them the content. $return = $content; } // bypass the hide tags. } else { // give them the content $return = $content; } eval("\$return = \"" . $templates->get("lock_wrapper") . "\";"); return $return; } // add the hide tag if the shortcodes plugin has been installed. Shortcodes::add("hide", "lock_hide");
/** * Remove all shortcode tags from the given content. * * @uses $shortcode_tags * * @param string $content Content to remove shortcode tags. * @return string Content without shortcode tags. */ public function strip_shortcodes($content) { $shortcode_tags = Shortcodes::$shortcode_tags; if (empty($shortcode_tags) || !is_array($shortcode_tags)) { return $content; } $pattern = Shortcodes::getShortcodeRegex(); return preg_replace('/' . $pattern . '/s', '$1$6', $content); }
function mapme($attr) { global $numMaps; // default atts $attr = Shortcodes::shortcodeAtts(array('lat' => '0', 'lon' => '0', 'id' => 'map', 'z' => '1', 'w' => '400', 'h' => '300', 'maptype' => 'ROADMAP', 'address' => '', 'marker' => '', 'markerimage' => '', 'infowindow' => '', 'infowindowdefault' => 'yes', 'directions' => '', 'hidecontrols' => 'false', 'scale' => 'false', 'scrollwheel' => 'true'), $attr); $returnme = ' <div id="' . $attr['id'] . '" style="width:' . $attr['w'] . 'px;height:' . $attr['h'] . 'px;"></div> '; if ($numMaps == 0) { $returnme .= '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>'; $numMaps++; } $returnme .= ' <script type="text/javascript"> var latlng = new google.maps.LatLng(' . $attr['lat'] . ', ' . $attr['lon'] . '); var myOptions = { zoom: ' . $attr['z'] . ', center: latlng, scrollwheel: ' . $attr['scrollwheel'] . ', scaleControl: ' . $attr['scale'] . ', disableDefaultUI: ' . $attr['hidecontrols'] . ', mapTypeId: google.maps.MapTypeId.' . $attr['maptype'] . ' }; var ' . $attr['id'] . ' = new google.maps.Map(document.getElementById("' . $attr['id'] . '"), myOptions); '; //address if ($attr['address'] != '') { $returnme .= ' var geocoder_' . $attr['id'] . ' = new google.maps.Geocoder(); var address = \'' . $attr['address'] . '\'; geocoder_' . $attr['id'] . '.geocode( { \'address\': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { ' . $attr['id'] . '.setCenter(results[0].geometry.location); '; if ($attr['marker'] != '') { //add custom image if ($attr['markerimage'] != '') { $returnme .= 'var image = "' . $attr['markerimage'] . '";'; } $returnme .= ' var marker = new google.maps.Marker({ map: ' . $attr['id'] . ', '; if ($attr['markerimage'] != '') { $returnme .= 'icon: image,'; } $returnme .= ' position: ' . $attr['id'] . '.getCenter() }); '; //infowindow if ($attr['infowindow'] != '') { //first convert and decode html chars $thiscontent = htmlspecialchars_decode($attr['infowindow']); $returnme .= ' var contentString = \'' . $thiscontent . '\'; var infowindow = new google.maps.InfoWindow({ content: contentString }); google.maps.event.addListener(marker, \'click\', function() { infowindow.open(' . $attr['id'] . ',marker); }); '; //infowindow default if ($attr['infowindowdefault'] == 'yes') { $returnme .= ' infowindow.open(' . $attr['id'] . ',marker); '; } } } $returnme .= ' } else { alert("Geocode was not successful for the following reason: " + status); } }); '; } //marker: show if address is not specified if ($attr['marker'] != '' && $attr['address'] == '') { //add custom image if ($attr['markerimage'] != '') { $returnme .= 'var image = "' . $attr['markerimage'] . '";'; } $returnme .= ' var marker = new google.maps.Marker({ map: ' . $attr['id'] . ', '; if ($attr['markerimage'] != '') { $returnme .= 'icon: image,'; } $returnme .= ' position: ' . $attr['id'] . '.getCenter() }); '; //infowindow if ($attr['infowindow'] != '') { $returnme .= ' var contentString = \'' . $attr['infowindow'] . '\'; var infowindow = new google.maps.InfoWindow({ content: contentString }); google.maps.event.addListener(marker, \'click\', function() { infowindow.open(' . $attr['id'] . ',marker); }); '; //infowindow default if ($attr['infowindowdefault'] == 'yes') { $returnme .= ' infowindow.open(' . $attr['id'] . ',marker); '; } } } $returnme .= '</script>'; return $returnme; ?> <?php }
public function stripShortcodes($content) { return Shortcodes::strip_shortcodes($content); }