public static function from_html($html, $title) { // give us soem breathing room ini_set('max_execution_time', 180); //$ohtml = $html; // pre-parse remote or url based assets try { $html = self::_pre_parse_remote_assets($html); } catch (Exception $e) { die('error'); echo '<h1>Problem parsing html.</h1>'; echo '<h2>' . force_balance_tags($e->getMessage()) . '</h2>'; return; } // if we are debugging the pdf, then depending on the mode, dump the html contents onw if (QSOT_DEBUG_PDF & 2) { // || ( current_user_can( 'edit_posts' ) && isset( $_GET['as'] ) && 'html' == $_GET['as'] ) ) { echo '<pre>'; echo htmlspecialchars($html); echo '</pre>'; die; } // include the library require_once QSOT::plugin_dir() . 'libs/dompdf/dompdf_config.inc.php'; // make and output the pdf $pdf = new DOMPDF(); $pdf->load_html($html); $pdf->render(); $pdf->stream(sanitize_title_with_dashes('ticket-' . $title) . '.pdf', array('Attachment' => 1)); exit; }
/** * Social Shorcodes */ function dnp_social($params, $content = null) { extract(shortcode_atts(array('type' => 'facebook', 'link' => '#'), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<a class="social ' . $type . '" href="' . $link . '"><i class="icon-' . ($type !== 'gplus' ? $type : 'google-plus') . '"></i></a>'; return force_balance_tags($result); }
function bs_buttons($params, $content = null) { extract(shortcode_atts(array('size' => 'default', 'type' => 'default', 'value' => 'button', 'href' => "#"), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<a class="btn btn-' . $size . ' btn-' . $type . '" href="' . $href . '">' . $value . '</a>'; return force_balance_tags($result); }
/** * xprofile_sanitize_data_value_before_save ( $field_value, $field_id ) * * Safely runs profile field data through kses and force_balance_tags. * * @param string $field_value * @param int $field_id * @return string */ function xprofile_sanitize_data_value_before_save ( $field_value, $field_id ) { // Return if empty if ( empty( $field_value ) ) return; // Value might be serialized $field_value = maybe_unserialize( $field_value ); // Filter single value if ( !is_array( $field_value ) ) { $kses_field_value = wp_filter_kses( $field_value ); $filtered_field_value = force_balance_tags( $kses_field_value ); // Filter each array item independently } else { foreach ( (array)$field_value as $value ) { $kses_field_value = wp_filter_kses( $value ); $filtered_values[] = force_balance_tags( $kses_field_value ); } $filtered_field_value = serialize( $filtered_values ); } return $filtered_field_value; }
function dnp_contact($params, $content = null) { extract(shortcode_atts(array(), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = ''; $result .= '<form class="comment_form" id="commentform" method="post" action="' . admin_url('admin-ajax.php?action=contact') . '"> <div class="row-fluid"> <div class="span6"> <input type="email" placeholder="' . __('Email', '') . '" required name="email" id="email"> </div> <div class="span6"> <input type="text" placeholder="' . __('Name', '') . '" required name="name" id="name"> </div> </div> <div class="row-fluid"> <div class="span8"> <textarea rows="10" cols="30" placeholder="' . __('Message', '') . '" name="message"></textarea> </div> <div class="span4"> <button type="submit" class="btn "><i class="li_paperplane"></i>' . __('Send message', 'argo') . '</button> </div> </div> </form>'; return force_balance_tags($result); }
/** * Button */ function dws_icons($params, $content = null) { extract(shortcode_atts(array('name' => 'default'), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<i class="' . $name . '"></i>'; return force_balance_tags($result); }
function erh_trim_excerpt($text) { $raw_excerpt = $text; if ('' == $text) { $text = get_the_content(''); $text = strip_shortcodes($text); $text = apply_filters('the_content', $text); // $text = str_replace(']]>', ']]>', $text); // $text = strip_tags($text, '<em><strong><p>'); // Set the excerpt length $excerpt_length = apply_filters('excerpt_length', 150); // Set what appears at the end of the excerpt $excerpt_more = apply_filters('excerpt_more', ' ' . '...'); $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); if (count($words) > $excerpt_length) { array_pop($words); $text = implode(' ', $words); $text = $text . $excerpt_more; $text = force_balance_tags($text); } else { $text = implode(' ', $words); } } return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); }
/** * Removes empty p-tags * @param string $content Text * @return string Markup */ public function removeEmptyPTag($content) { $content = force_balance_tags($content); $content = preg_replace('#<p>\\s*+(<br\\s*/*>)?\\s*</p>#i', '', $content); $content = preg_replace('~\\s?<p>(\\s| )+</p>\\s?~', '', $content); return $content; }
function els_heading($params, $content = null) { extract(shortcode_atts(array('size' => 'h2', 'text' => 'Heading 2 Custom'), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = sprintf('<%1$s class="els-heading"><span class="sr">%2$s</span></%1$s>', $size, $text); return force_balance_tags($result); }
function els_labels($params, $content = null) { extract(shortcode_atts(array('type' => 'default'), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<span class="label label-' . $type . '">' . $content . '</span>'; return force_balance_tags($result); }
function dnp_code_inline($params, $content = null) { extract(shortcode_atts(array('type' => '', 'value' => ''), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<code>' . do_shortcode($content) . '</code>'; return force_balance_tags($result); }
function dnp_buttons_toolbar($params, $content = null) { extract(shortcode_atts(array(), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<div class="btn-toolbar">' . do_shortcode($content) . '</div>'; return force_balance_tags($result); }
function my_shortcode_panel($atts, $content = null) { // extract and set defaults extract(shortcode_atts(array('type' => 'keyline'), $atts)); $output_string = '<article class="island panel ' . $type . '">' . $content . '</article>'; return force_balance_tags($output_string); }
/** * xprofile_sanitize_data_value_before_save ( $field_value, $field_id ) * * Safely runs profile field data through kses and force_balance_tags. * * @param string $field_value * @param int $field_id * @param bool $reserialize Whether to reserialize arrays before returning. Defaults to true * @return string */ function xprofile_sanitize_data_value_before_save($field_value, $field_id, $reserialize = true) { // Return if empty if (empty($field_value)) { return; } // Value might be serialized $field_value = maybe_unserialize($field_value); // Filter single value if (!is_array($field_value)) { $kses_field_value = xprofile_filter_kses($field_value); $filtered_field_value = nxt_rel_nofollow(force_balance_tags($kses_field_value)); $filtered_field_value = apply_filters('xprofile_filtered_data_value_before_save', $filtered_field_value, $field_value); // Filter each array item independently } else { $filtered_values = array(); foreach ((array) $field_value as $value) { $kses_field_value = xprofile_filter_kses($value); $filtered_value = nxt_rel_nofollow(force_balance_tags($kses_field_value)); $filtered_values[] = apply_filters('xprofile_filtered_data_value_before_save', $filtered_value, $value); } if ($reserialize) { $filtered_field_value = serialize($filtered_values); } else { $filtered_field_value = $filtered_values; } } return $filtered_field_value; }
function the_excerpt_rereloaded($words = 40, $link_text = 'Leia Mais', $allowed_tags = '', $container = 'p', $smileys = 'no' ) { global $post; if ( $allowed_tags == 'all' ) $allowed_tags = '<h3>,<br>,<p>,<i>,<em>,<b>,<strong>,<ul>,<ol>,<li>,<span>,<blockquote>,<img>'; $text = preg_replace('/\[.*\]/', '', strip_tags($post->post_content, $allowed_tags)); $text = explode(' ', $text); $tot = count($text); for ( $i=0; $i<$words; $i++ ) : $output .= $text[$i] . ' '; endfor; if ( $smileys == "yes" ) $output = convert_smilies($output); ?><p><?php echo force_balance_tags($output) ?><?php if ( $i < $tot ) : ?> ...<?php else : ?></p><?php endif; ?> <?php if ( $i < $tot ) : if ( $container == 'p' || $container == 'div' ) : ?></p><?php endif; if ( $container != 'plain' ) : ?><<?php echo $container; ?> class="more"><?php if ( $container == 'div' ) : ?><p><?php endif; endif; ?> <a href="<?php the_permalink(); ?>" title="<?php echo $link_text; ?>"><?php echo $link_text; ?></a><?php if ( $container == 'div' ) : ?></p><?php endif; if ( $container != 'plain' ) : ?></<?php echo $container; ?>><?php endif; if ( $container == 'plain' || $container == 'span' ) : ?></p><?php endif; endif; }
function dnp_thumbnails_container($params, $content = null) { extract(shortcode_atts(array('alt' => '', 'src' => ""), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<div class="thumbnail"> <img src="' . $src . '" alt="' . $alt . '"> <div class="caption">' . do_shortcode($content) . ' </div></div>'; return force_balance_tags($result); }
/** Images Shorcodes */ function dnp_images($params, $content = null) { extract(shortcode_atts(array('alt' => '', 'class' => '', 'src' => ""), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<img class="image ' . $class . '" src="' . $src . '" alt="' . $alt . '" />'; return force_balance_tags($result); }
function custom_wp_trim_excerpt($text) { $raw_excerpt = $text; if ('' == $text) { //Retrieve the post content. $text = get_the_content(''); $text = strip_shortcodes($text); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); // the code below sets the excerpt length to 55 words. You can adjust this number for your own blog. $excerpt_length = apply_filters('excerpt_length', 55); // the code below sets what appears at the end of the excerpt, in this case ... $excerpt_more = apply_filters('excerpt_more', ' ' . '...'); $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); if (count($words) > $excerpt_length) { array_pop($words); $text = implode(' ', $words); $text = force_balance_tags($text); $text = $text . $excerpt_more; } else { $text = implode(' ', $words); } } return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); }
function dnp_blockquote_author($params, $content = null) { extract(shortcode_atts(array('type' => ''), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<small class="author">' . do_shortcode($content) . '</small>'; return force_balance_tags($result); }
function frame($params, $content = null) { extract(shortcode_atts(array('bgcolor' => 'none', 'version' => '', 'closed' => '', 'closetext' => 'Close', 'opentext' => 'Open', 'ver' => $GLOBALS['aitThemeShortcodes']['boxesFrames']), $params)); $result = ""; if ($bgcolor == "none") { $bg = ''; } else { if ($ver == '1') { $bg = 'background: ' . $bgcolor . ';'; } elseif ($ver == '2') { $bg = 'background: ' . $bgcolor . '; border-color: ' . $bgcolor . ';'; } } if ($closed != "") { $cl = '<div class="frame-close closed"><span class="open text">' . $opentext . '</span><span class="close text" style="display: none;">' . $closetext . '</span></div>'; $closedStyle = ' display: none;'; $frameStyle = 'openable'; $result .= "<script type='text/javascript'>\n\t\tjQuery(function() {\n\t\t\tjQuery('.frame .frame-close.closed .close.text').hide();\n\t\t\tjQuery('.frame .frame-close.closed .open.text').show();\n\t\t\t\n\t\t\tjQuery('.frame .frame-close').click(function(){\n\t\t\t\tif(jQuery(this).hasClass('closed')){\n\t\t\t\t\tvar butt = jQuery(this);\n\t\t\t\t\tjQuery(this).parent().find('.frame-wrap').slideDown('slow',function(){\n\t\t\t\t\t\tbutt.removeClass('closed');\n\t\t\t\t\t\tbutt.find('.close.text').show();\n\t\t\t\t\t\tbutt.find('.open.text').hide();\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tvar butt = jQuery(this);\n\t\t\t\t\tjQuery(this).parent().find('.frame-wrap').slideUp('slow',function(){\n\t\t\t\t\t\tbutt.addClass('closed');\n\t\t\t\t\t\tbutt.find('.close.text').hide();\n\t\t\t\t\t\tbutt.find('.open.text').show();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\t</script>"; } else { $cl = ''; $closedStyle = ''; $frameStyle = ''; } if ($ver == '1') { $result .= '<div class="frame ' . $version . ' ' . $frameStyle . '"' . $bg . '>' . $cl . '<div class="frame-wrap" style="' . $closedStyle . '"><div class="frame-inner">'; } elseif ($ver == '2') { $result .= '<div class="frame ' . $version . ' ' . $frameStyle . '">' . $cl . '<div class="frame-wrap" style="' . $bg . $closedStyle . '"><div class="frame-inner">'; } $result .= do_shortcode($content); $result .= '</div></div></div>'; return force_balance_tags($result); }
/** * Service */ function dnp_service($params, $content = null) { extract(shortcode_atts(array(), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<div class="brick2 sev_list">' . do_shortcode($content) . '</div>'; return force_balance_tags($result); }
/** * * @return string */ public function get() { if (!$this->bIncludeExtra) { $this->_removeExtraElements(); } $_oTD = $this->oSimpleDOM->find('table > tbody > tr > td', 0); if (!$_oTD) { return ''; } $_iCount = 0; foreach ($_oTD->children() as $_oElement) { if ('br' === $_oElement->tag) { $_oElement->outertext = ''; continue; } if ('div' !== $_oElement->tag) { continue; } $_iCount++; if ($_iCount > $this->iMaxCount) { $_oElement->outertext = ''; continue; } } if ($this->bIsSSL) { $_oIMGs = $this->oSimpleDOM->find('img'); foreach ($_oIMGs as $_oIMG) { $_oIMG->src = $this->getAmazonSSLImageURL($_oIMG->src); } } $_sHTML = str_replace(' 0 ', '', $this->oSimpleDOM->outertext); return force_balance_tags($_sHTML); }
/** * Allowing HTML (images!) in excerpts * | code from: http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/ * | plus bits and pieces from template-tags.php in 2015 theme * | updated bugs by applying: https://web.archive.org/web/20100123185020/http://palehorseinformation.com/2009/12/23/fixing-the-wordpress-excerpt */ function vanillamilkshake_improved_trim_excerpt($text) { // Fakes an excerpt if needed global $post; if ('' == $text) { $readmorestring = __('Continue reading', 'vanillamilkshake'); $text = get_the_content($readmorestring); // $text = strip_shortcodes( $text ); have to disable, messes up on <figure> $text = apply_filters('the_content', $text); /* $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text); */ $text = str_replace('\\]\\]\\>', ']]>', $text); // $text = strip_tags($text, '<p><img><img/><i><em><strong><figure><figcaption><blockquote><a><iframe><sub><sup><pre><code>'); $excerpt_length = 72; $words = explode(' ', $text, $excerpt_length + 1); $link = sprintf('<p class="clear-both"><a href="%1$s#s" class="more-link">%2$s</a><p>', esc_url(get_permalink(get_the_ID())), $readmorestring . '<span class="screen-reader-text">' . get_the_title(get_the_ID()) . '</span>'); if (count($words) > $excerpt_length) { array_pop($words); $text = implode(' ', $words); $text = $text . '…'; $text = force_balance_tags($text); $text = $text . $link; } } return $text; }
/** * This method is used to display the output of the element. * @return void */ function element() { $options = $this->data['uid']; echo '<div class="zn_custom_html ' . $this->data['uid'] . '">'; echo force_balance_tags($this->opt('custom_html')); echo '</div>'; }
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $advert_image = isset($instance['advert_image']) ? $instance['advert_image'] : ''; $advert_link = isset($instance['advert_link']) ? $instance['advert_link'] : ''; $advert_code = isset($instance['advert_code']) ? $instance['advert_code'] : ''; /* Before widget (defined by themes). */ echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="widget_advert_inner"> <?php if ($advert_image != '') { echo ($advert_link != '' ? '<a href="' . esc_url($advert_link) . '"' : '<span') . ' class="image_wrap"><img src="' . esc_url($advert_image) . '" alt="' . esc_attr($title) . '" />' . ($advert_link != '' ? '</a>' : '</span>'); } if ($advert_code != '') { echo force_balance_tags(axiom_substitute_all($advert_code)); } ?> </div> <?php /* After widget (defined by themes). */ echo $after_widget; }
function dnp_typo_h5($params, $content = null) { extract(shortcode_atts(array('class' => ''), $params)); $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<h5 class="' . $class . ' ">' . do_shortcode($content) . '</h5>'; return force_balance_tags($result); }
function bs_span($params, $content = null) { extract(shortcode_atts(array('class' => 'col-sm-1'), $params)); $result = '<div class="' . $class . '">'; $result .= do_shortcode($content); $result .= '</div>'; return force_balance_tags($result); }
function bs_lead($params, $content = null) { $content = preg_replace('/<br class="nc".\\/>/', '', $content); $result = '<div class="lead">'; $result .= do_shortcode($content); $result .= '</div>'; return force_balance_tags($result); }
function theme_one_fourth_last($params, $content = null) { $result .= '<div class="one-fourth-last">'; $result .= do_shortcode($content); $result .= '</div>'; $result .= '<div class="clearing"></div>'; return force_balance_tags($result); }
/** * @return Facebook Send HTML */ public function mb_render_facebook_send_html($args = array()) { global $mb_plugin_options; $flag = $this->mb_get_uniqueue_flag(5); $fb_send_button_url = $args['fb_send_to_url']; $mb_output = sprintf('<div class="fb-send" data-href="%s" data-layout="button_count"></div>', $fb_send_button_url); echo force_balance_tags($mb_output); }