function woo_add_order_notes_to_email() { global $woocommerce, $post; $args = array('post_id' => $post->ID, 'approve' => 'approve', 'type' => 'order_note'); $notes = get_comments($args); echo '<h2>' . __('Order Notes', 'woocommerce') . '</h2>'; echo '<ul class="order_notes">'; if ($notes) { foreach ($notes as $note) { $note_classes = get_comment_meta($note->comment_ID, 'is_customer_note', true) ? array('customer-note', 'note') : array('note'); ?> <li rel="<?php echo absint($note->comment_ID); ?> " class="<?php echo implode(' ', $note_classes); ?> "> <div class="note_content"> (<?php printf(__('added %s ago', 'woocommerce'), human_time_diff(strtotime($note->comment_date_gmt), current_time('timestamp', 1))); ?> ) <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> </div> </li> <?php } } else { echo '<li>' . __('There are no notes for this order yet.', 'woocommerce') . '</li>'; } echo '</ul>'; }
public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); // before and after widget arguments are defined by themes echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } // This is where you run the code and display the output // Get other recent posts global $post; $cat_ID = array(); $categories = get_the_category(); //get all categories for this post foreach ($categories as $category) { array_push($cat_ID, $category->cat_ID); } $args = array('orderby' => 'date', 'order' => 'DESC', 'post__not_in' => array($post->ID), 'category__in' => $cat_ID); // post__not_in will exclude the post we are displaying $otherposts = get_posts($args); if (sizeof($otherposts) > 0) { $out = ''; foreach ($otherposts as $otherpost) { $out .= '<li>'; $out .= '<a href="' . get_permalink($otherpost->ID) . '" title="' . wptexturize($otherpost->post_title) . '">' . wptexturize($otherpost->post_title) . '</a></li>'; } $out = '<ul class="otherpost">' . $out . '</ul>'; echo $out; } else { echo "<li>Não existem outras publicações.</li>"; } echo $args['after_widget']; }
function ubik_seo_meta_description($desc = '') { // Generate a meta description if (empty($desc)) { // Single posts, pages, and attachments if (is_singular()) { $post = get_post(); if (empty($post)) { $desc = ''; } $desc = wptexturize($post->post_content); // Get the entire contents, not the excerpt, so as to not duplicate Ubik Excerpt } // Check to see if we have a description for this category, tag, or taxonomy if (is_category() || is_tag() || is_tax()) { $desc = term_description(); } // Now match other possibilities... if (is_author()) { $desc = get_the_author_meta('description'); } // Front or home page if (is_front_page() || is_home()) { $desc = get_bloginfo('description'); } // No excerpt to return if (is_404() || is_search()) { $desc = ''; } $desc = ubik_seo_meta_description_sanitize($desc); } return apply_filters('ubik_seo_meta_description', $desc); }
/** * @internal * @param string $url * @param string $text * @return mixed */ protected function get_archives_link($url, $text) { $ret = array(); $ret['text'] = $ret['title'] = $ret['name'] = wptexturize($text); $ret['url'] = $ret['link'] = esc_url(TimberURLHelper::prepend_to_url($url, $this->base)); return $ret; }
/** * Sanitize the input string. HTML tags can be permitted. * The permitted tags can be supplied in an array. * * @TODO: Finish the code needed to support the $permittedTags array. * * @param string $string * @param bool $allowHTML [optional] * @param array $permittedTags [optional] * @return string */ public function sanitizeString($string, $allowHTML = FALSE, $permittedTags = array()) { // Strip all tags except the permitted. if (!$allowHTML) { // Ensure all tags are closed. Uses WordPress method balanceTags(). $balancedText = balanceTags($string, TRUE); $strippedText = strip_tags($balancedText); // Strip all script and style tags. $strippedText = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $strippedText); // Escape text using the WordPress method and then strip slashes. $escapedText = stripslashes(esc_attr($strippedText)); // Remove line breaks and trim white space. $escapedText = preg_replace('/[\\r\\n\\t ]+/', ' ', $escapedText); return trim($escapedText); } else { // Strip all script and style tags. $strippedText = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $string); $strippedText = preg_replace('/<(script|style).*?>.*?<\\/\\1>/si', '', stripslashes($strippedText)); /* * Use WordPress method make_clickable() to make links clickable and * use kses for filtering. * * http://ottopress.com/2010/wp-quickie-kses/ */ return wptexturize(wpautop(make_clickable(wp_kses_post($strippedText)))); } }
function custom_gallery($attr) { $post = get_post(); static $instance = 0; $instance++; # hard-coding these values so that they can't be broken $attr['columns'] = 1; $attr['size'] = 'full'; $attr['link'] = 'none'; $attr['orderby'] = 'post__in'; $attr['include'] = $attr['ids']; #Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ($output != '') { return $output; } # We're trusting author input, so let's at least make sure it looks like a valid orderby statement if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'div', 'icontag' => 'div', 'captiontag' => 'p', 'columns' => 4, 'size' => 'gallery-thumbnail', 'include' => '', 'exclude' => ''), $attr)); $id = intval($id); if ('RAND' == $order) { $orderby = 'none'; } if (!empty($include)) { $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } else { $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } if (empty($attachments)) { return ''; } $gallery_style = $gallery_div = ''; if (apply_filters('use_default_gallery_style', true)) { $gallery_style = "<!-- see gallery_shortcode() in functions.php -->"; } $gallery_div = "<ul class='clearing-thumbs small-block-grid-2 large-block-grid-4' data-clearing>"; $output = apply_filters('gallery_style', $gallery_style . "\n\t\t" . $gallery_div); foreach ($attachments as $id => $attachment) { $link = wp_get_attachment_link($id, 'full', false, false); $output .= "<li>"; $output .= "{$link}"; if ($captiontag && trim($attachment->post_excerpt)) { $output .= "\n\t\t\t\t<p class='wp-caption-text homepage-gallery-caption hide'>\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\n\t\t\t\t</p>"; } $output .= "</li>"; } $output .= "</ul>\n"; return $output; }
private function get_post_title($single, $tag = null, $css_class = null) { $info = '<a href="' . get_permalink($single->ID); $lcp_post_title = apply_filters('the_title', $single->post_title, $single->ID); if (!empty($this->params['title_limit']) && $this->params['title_limit'] != "0") { $lcp_post_title = substr($lcp_post_title, 0, intval($this->params['title_limit'])); if (strlen($lcp_post_title) >= intval($this->params['title_limit'])) { $lcp_post_title .= "…"; } } $info .= '" title="' . wptexturize($single->post_title) . '"'; if (!empty($this->params['link_target'])) { $info .= ' target="' . $this->params['link_target'] . '" '; } if (!empty($this->params['title_class']) && empty($this->params['title_tag'])) { $info .= ' class="' . $this->params['title_class'] . '"'; } $info .= '>' . $lcp_post_title . '</a>'; if (!empty($this->params['post_suffix'])) { $info .= " " . $this->params['post_suffix']; } if (!empty($this->params['title_tag'])) { $pre = "<" . $this->params['title_tag']; if (!empty($this->params['title_class'])) { $pre .= ' class="' . $this->params['title_class'] . '"'; } $pre .= '>'; $post = "</" . $this->params['title_tag'] . ">"; $info = $pre . $info . $post; } if ($tag !== null || $css_class !== null) { $info = $this->assign_style($info, $tag, $css_class); } return $info; }
/** * add meta_description * * hook after post has loaded to add a unique meta-description * */ public static function meta_description() { $post = new \TimberPost(); // check for custom field $description = wptexturize($post->get_field('meta_description')); if (is_tax()) { if ($temp = term_description(get_queried_object(), get_query_var('taxonomy'))) { $description = $temp; } } elseif (is_post_type_archive()) { if ($temp = get_the_archive_description()) { $description = $temp; } } // else use preview if (empty($description)) { $description = str_replace('', "'", $post->get_preview(40, true, false, true)); } // finally use the blog description if (empty($description)) { $description = get_bloginfo('description', 'raw'); } $description = esc_attr(wp_strip_all_tags($description)); // limit to SEO recommended length if (strlen($description) > 155) { $description = substr($description, 0, 155); $description = \TimberHelper::trim_words($description, str_word_count($description) - 1); } return $description; }
function admin_page_warning() { $jetpack = Jetpack::init(); $blog_name = get_bloginfo('blogname'); if (empty($blog_name)) { $blog_name = home_url('/'); } ?> <div id="message" class="updated jetpack-message jp-connect"> <div class="jetpack-wrap-container"> <div class="jetpack-text-container"> <h4> <p><?php printf(esc_html(wptexturize(__("To use Publicize, you'll need to link your %s account to your WordPress.com account using the button to the right.", 'jetpack'))), '<strong>' . esc_html($blog_name) . '</strong>'); ?> </p> <p><?php echo esc_html(wptexturize(__("If you don't have a WordPress.com account yet, you can sign up for free in just a few seconds.", 'jetpack'))); ?> </p> </h4> </div> <div class="jetpack-install-container"> <p class="submit"><a href="<?php echo $jetpack->build_connect_url(false, menu_page_url('sharing', false)); ?> " class="button-connector" id="wpcom-connect"><?php esc_html_e('Link account with WordPress.com', 'jetpack'); ?> </a></p> </div> </div> </div> <?php }
/** * Update the credits text. * * @since 1.0.0 * * @param string $text Credits text. * @return string */ public function credits_text($text) { $settings = wp_parse_args((array) get_option('footer_credits'), array('placement' => '', 'text' => '')); switch ($settings['placement']) { case 'after': $text .= ' ' . $settings['text']; break; case 'before': $text = $settings['text'] . ' ' . $text; break; case 'remove': $text = ''; break; case 'replace': $text = $settings['text']; break; } $search = array('{{year}}'); $replace = array(date('Y')); $text = str_replace($search, $replace, $text); $text = wptexturize(trim($text)); $text = convert_chars($text); $text = $this->allowed_tags($text); return $text; }
/** * Clean up gallery_shortcode() * * Re-create the [gallery] shortcode and use thumbnails styling from Bootstrap * * @link http://twitter.github.com/bootstrap/components.html#thumbnails */ function roots_gallery($attr) { $post = get_post(); static $instance = 0; $instance++; if (!empty($attr['ids'])) { if (empty($attr['orderby'])) { $attr['orderby'] = 'post__in'; } $attr['include'] = $attr['ids']; } $output = apply_filters('post_gallery', '', $attr); if ($output != '') { return $output; } if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => '', 'icontag' => '', 'captiontag' => '', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'link' => 'file'), $attr)); $id = intval($id); if ($order === 'RAND') { $orderby = 'none'; } if (!empty($include)) { $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } else { $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } if (empty($attachments)) { return ''; } if (is_feed()) { $output = "\n"; foreach ($attachments as $att_id => $attachment) { $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; } return $output; } $output = '<ul class="thumbnails gallery">'; $i = 0; foreach ($attachments as $id => $attachment) { $image = 'file' == $link ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); $output .= '<li>' . $image; if (trim($attachment->post_excerpt)) { $output .= '<div class="caption hidden">' . wptexturize($attachment->post_excerpt) . '</div>'; } $output .= '</li>'; } $output .= '</ul>'; return $output; }
/** * Display the testimonial content. * * @param null $length * * @since 1.24.0 * @since 2.4.0 Run content through selected filters only, instead * of all filters added to the_excerpt() or the_content(). * * @todo Use native auto-excerpt and trim_words instead. */ function wpmtst_the_content($length = null) { if ($length) { $excerpt = false; } else { $excerpt = WPMST()->atts('excerpt'); $length = WPMST()->atts('length'); } // In View settings, {excerpt} overrides {length} overrides {full content}. if ($excerpt) { $content = get_the_excerpt(); $content = apply_filters('the_excerpt', $content); } else { if ($length) { $content = wpmtst_get_field('truncated', array('char_limit' => $length)); } else { $content = get_the_content(); } // Applying all content filters breaks POS NextGEN Gallery. // So need to find a way to select which additional filters, if any, to apply. // For instance, All In One Rich Snippets. //$content = apply_filters( 'the_content', $content ); $content = wptexturize($content); $content = convert_smilies($content); $content = wpautop($content); $content = shortcode_unautop($content); $content = do_shortcode($content); } echo $content; }
public function get() { $license = $this->get_license(); $downloads = $this->get_downloads(); $config = ["alwaysShowHours" => true, "alwaysShowControls" => true, "chaptersVisible" => true, "permalink" => get_permalink($this->post->ID), "publicationDate" => mysql2date("c", $this->post->post_date), "title" => get_the_title($this->post->ID), "subtitle" => wptexturize(convert_chars(trim($this->episode->subtitle))), "summary" => nl2br(wptexturize(convert_chars(trim($this->episode->summary)))), "poster" => $this->episode->cover_art_with_fallback()->setWidth(500)->url(), "show" => ['title' => $this->podcast->title, 'subtitle' => $this->podcast->subtitle, 'summary' => $this->podcast->summary, 'poster' => $this->podcast->cover_art()->setWidth(500)->url(), 'url' => \Podlove\get_landing_page_url()], "license" => ["name" => $license['name'], "url" => $license['url']], "downloads" => $downloads, "duration" => $this->episode->get_duration(), "features" => ["current", "progress", "duration", "tracks", "fullscreen", "volume"], "chapters" => json_decode($this->episode->get_chapters('json')), "languageCode" => $this->podcast->language]; return $config; }
function newautop($text) { $newtext = ""; $pos = 0; $tags = array('<!-- noformat on -->', '<!-- noformat off -->'); $status = 0; while (!(($newpos = strpos($text, $tags[$status], $pos)) === FALSE)) { $sub = substr($text, $pos, $newpos - $pos); if ($status) { $newtext .= $sub; } else { $newtext .= convert_chars(wptexturize(wpautop($sub))); } //Apply both functions (faster) $pos = $newpos + strlen($tags[$status]); $status = $status ? 0 : 1; } $sub = substr($text, $pos, strlen($text) - $pos); if ($status) { $newtext .= $sub; } else { $newtext .= convert_chars(wptexturize(wpautop($sub))); } //Apply both functions (faster) //To remove the tags $newtext = str_replace($tags[0], "", $newtext); $newtext = str_replace($tags[1], "", $newtext); return $newtext; }
function widget_untappd() { require_once ABSPATH . 'wp-includes/rss-functions.php'; $wp_untappd_rss = get_option('untappd_rss'); $wp_untappd_title = get_option('untappd_title') == '' ? "Beers I'm Drinking" : get_option('untappd_title'); $wp_untappd_userid = get_option('untappd_userid'); echo wptexturize('<div id="widget_untappd">'); echo wptexturize('<div id="widget_untappd_header">' . $wp_untappd_title . '</div>'); echo wptexturize('<div id="widget_untappd_beer_list">'); if ($wp_untappd_rss != '') { $rss = fetch_rss($wp_untappd_rss); if (count($rss->items) != 0) { $limit = 5; foreach ($rss->items as $item) { if ($limit == 0) { break; } echo wptexturize('<div class="widget_untappd_beer"><a target="_blank" href="' . $item['link'] . '">' . $item['title'] . '</a></div>'); $limit++; } } else { echo wptexturize('<div class="widget_untappd_beer">What?!? No beers yet?!?<br /><br /></div>'); } } else { echo wptexturize('<div class="widget_untappd_beer">Widget not setup yet<br /><br /></div>'); } echo wptexturize('</div>'); if ($wp_untappd_userid != '') { echo wptexturize('<div id="widget_untappd_follow"><a target="_blank" href="http://untappd.com/user/' . $wp_untappd_userid . '">Follow me on Untappd!</a></div>'); } else { echo wptexturize('<div id="widget_untappd_follow"><a target="_blank" href="http://untappd.com/">Drink Socially at Untappd!</a></div>'); } echo wptexturize('</div>'); echo wptexturize('<div id="widget_untappd_logo"><a target="_blank" href="http://untappd.com"><span></span></a></div>'); }
public function print_img_columns($name, $post_id) { $attachment = get_post($post_id); if(!is_object($attachment) || is_wp_error($attachment)) return; if(substr($attachment->post_mime_type, 0, 5) == 'image') { $none = '<span style="color:#dd0000;">'. __('Empty Alt Text. Please Fix!') .'</span>'; $alt = stripslashes(get_post_meta($post_id, '_wp_attachment_image_alt', true )); switch($name) { case 'image_alt' : echo !empty($alt) || $alt== $attachment->post_title ? $alt : $none; if ( empty($alt) ) { //print_r($attachment); } break; case 'post_author' : echo !empty($alt) || $alt== $attachment->post_title ? $alt : $none; break; case 'post_excerpt' : echo !empty($alt) || $alt== $attachment->post_title ? $alt : $none; echo (!empty($attachment->post_excerpt)) ? trim(wptexturize(wp_kses(stripslashes($attachment->post_excerpt), $this->allowed))) : '' ; break; } } }
function widget($args, $instance) { extract($args); extract($instance); /* Display widget ---------------------------------------------------------------*/ echo $before_widget; ?> <div class="bearded-cta-container row"> <div class="column large-8"> <h1 class="cta-widget-title"><?php echo $title; ?> </h1> <?php echo wptexturize(wpautop($content)); ?> </div> <div class="column large-4"> <a class="button radius hover-light alignright" href="<?php echo $link; ?> " title="<?php echo $label; ?> "><?php echo $label; ?> </a> </div> </div> <?php echo $after_widget; }
function related_posts_shortcode($atts) { extract(shortcode_atts(array('limit' => '5'), $atts)); global $wpdb, $post, $table_prefix; if ($post->ID) { $retval = '<ul>'; // Get tags $tags = wp_get_post_tags($post->ID); $tagsarray = array(); foreach ($tags as $tag) { $tagsarray[] = $tag->term_id; } $tagslist = implode(',', $tagsarray); // Do the query $q = "\r\n SELECT p.*, count(tr.object_id) as count\r\n FROM {$wpdb->term_taxonomy} AS tt, {$wpdb->term_relationships} AS tr, {$wpdb->posts} AS p\r\n WHERE tt.taxonomy ='post_tag'\r\n AND tt.term_taxonomy_id = tr.term_taxonomy_id\r\n AND tr.object_id = p.ID\r\n AND tt.term_id IN ({$tagslist})\r\n AND p.ID != {$post->ID}\r\n AND p.post_status = 'publish'\r\n AND p.post_date_gmt < NOW() GROUP BY tr.object_id ORDER BY count DESC, p.post_date_gmt DESC LIMIT {$limit};"; $related = $wpdb->get_results($q); if ($related) { foreach ($related as $r) { $retval .= '<li><a title="' . wptexturize($r->post_title) . '" href="' . get_permalink($r->ID) . '">' . wptexturize($r->post_title) . '</a></li>'; } } else { $retval .= '<li>No related posts found</li>'; } $retval .= '</ul>'; return $retval; } return; }
function photoline_modified_post_gallery($output, $attr) { global $post; static $instance = 0; $instance++; //disable all filter if (empty($attr['type']) || $attr['type'] != 'slider') { return; } if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'size' => 'photoline-featured', 'include' => '', 'exclude' => ''), $attr)); $id = intval($id); if ('RAND' == $order) { $orderby = 'none'; } if (!empty($include)) { $include = preg_replace('/[^0-9,]+/', '', $include); $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { $exclude = preg_replace('/[^0-9,]+/', '', $exclude); $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } else { $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } if (empty($attachments)) { return ''; } if (is_feed()) { $output = "\n"; foreach ($attachments as $att_id => $attachment) { $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; } return $output; } $selector = "gallery-{$instance}"; $size_class = sanitize_html_class($size); $gallery_div = "<div id='{$selector}' class='gallery galleryid-{$id} gallery-size-{$size_class} flexslider'>"; $output = apply_filters('gallery_style', $gallery_div); $output .= '<ul class="slides">'; $i = 0; foreach ($attachments as $id => $attachment) { $caption = !empty($attachment->post_excerpt) ? '<p class="flex-caption wp-caption-text gallery-caption">' . wptexturize($attachment->post_excerpt) . '</p>' : ''; $image = wp_get_attachment_image($id, $size); $output .= '<li>'; $output .= $image; $output .= $caption; $output .= '</li>'; } $output .= "\r\n </ul><!-- .slides -->\r\n </div>\n"; return $output; }
function woocommerce_product_taxonomy_content() { global $wp_query; $term = get_term_by('slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']); ?> <h1 class="page-title"><?php echo wptexturize($term->name); ?> </h1> <?php if ($term->description) { ?> <div class="term_description"><?php echo wpautop(wptexturize($term->description)); ?> </div> <?php } ?> <?php woocommerce_get_template_part('loop', 'shop'); ?> <?php do_action('woocommerce_pagination'); }
/** * Choose a lucky number * * @param int $max_number The maximum random value. * @return Returns a number from 1 - $max_number. */ private function get_lucky_number($max_number = 10) { // wptexturize() is not really needed here, since we're only dealing // with a number, but it is something that should be noted as useful for // more complex plugins. return wptexturize(mt_rand(1, $max_number)); }
/** * Frontend Shortcode Handle. * @param array $atts Array of attributes. * @param string $content Text within enclosing form of shortcode element. * @param string $shortcode The shortcode found, when == callback name. * @param string $meta Meta data. * @return string Returns the modified html string. */ public function shortcode_handle($atts, $content = '', $shortcode = '', $meta = '') { extract(shortcode_atts(array('heading' => '', 'tag' => '', 'size' => '', 'position' => '', 'subheading' => '', 'subheading_text' => '', 'subheading_size' => '', 'padding' => '', 'font_color' => '', 'color' => ''), $atts, $this->shortcode['name'])); // Don't display if the heading text is empty if (empty($heading)) { return; } $sub_heading = "<div class='ac-subheading' style='font-size:{$subheading_size}px;'><p>"; $sub_heading .= $subheading_text; $sub_heading .= "</p></div>"; $above_heading = $below_heading = ''; if ($subheading === 'subheading-above') { $above_heading = $sub_heading; } elseif ($subheading === 'subheading-below') { $below_heading = $sub_heading; } $custom_style = "padding-bottom:{$padding}px;"; if ($font_color === "specific") { $custom_style .= "color:{$color};"; } if (!empty($custom_style)) { $custom_style = "style='{$custom_style}'"; } $custom_class = empty($meta['custom_class']) ? '' : $meta['custom_class']; $custom_class .= $position; $heading = apply_filters('axiscomposer_format_heading', wptexturize($heading)); ob_start(); ?> <div class="axiscomposer ac-special-heading <?php echo $custom_class; ?> " <?php echo $custom_style; ?> > <?php echo $above_heading; ?> <div class="ac-special-heading-tag" style="font-size:<?php echo $size; ?> px;"> <<?php echo $tag; ?> ><?php echo $heading; ?> </<?php echo $tag; ?> > </div> <?php echo $below_heading; ?> </div> <?php return ob_get_clean(); }
function get_plugin_data($plugin_file) { $plugin_data = implode('', file($plugin_file)); preg_match('|Plugin Name:(.*)$|mi', $plugin_data, $plugin_name); preg_match('|Plugin URI:(.*)$|mi', $plugin_data, $plugin_uri); preg_match('|Description:(.*)$|mi', $plugin_data, $description); preg_match('|Author:(.*)$|mi', $plugin_data, $author_name); preg_match('|Author URI:(.*)$|mi', $plugin_data, $author_uri); if (preg_match("|Version:(.*)|i", $plugin_data, $version)) { $version = trim($version[1]); } else { $version = ''; } $description = wptexturize(trim($description[1])); $name = $plugin_name[1]; $name = trim($name); $plugin = $name; if ('' != trim($plugin_uri[1]) && '' != $name) { $plugin = '<a href="' . trim($plugin_uri[1]) . '" title="' . __('Visit plugin homepage') . '">' . $plugin . '</a>'; } if ('' == $author_uri[1]) { $author = trim($author_name[1]); } else { $author = '<a href="' . trim($author_uri[1]) . '" title="' . __('Visit author homepage') . '">' . trim($author_name[1]) . '</a>'; } return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version); }
function wp_lorem_ipsum() { $generator = new Badcow\LoremIpsum\Generator(); $sentences = $generator->getSentences(30); $chosen = wptexturize($sentences[mt_rand(0, count($sentences) - 1)]); echo "<p id='wp-lorem-ipsum-text'>{$chosen}</p>"; }
/** * Custom List Users * * Custom function to generate a list of blog authors, * built based on WordPress' native wp_list_users function. * * @since Grammatizator 0.6 */ function gramm_list_authors($args = '') { // SET up variables global $wpdb; $defaults = array('orderby' => 'name', 'order' => 'ASC', 'role' => '', 'include' => array(), 'biolength' => 55, 'heading_tag' => 'h5', 'echo' => true); $args = wp_parse_args($args, $defaults); $return = ''; // GET data from database with database query // Use this to get the paramenters we need for get_users() out of the default $args $query_args = wp_array_slice_assoc($args, array('orderby', 'order', 'role', 'include')); // Used to request only an array of user IDs from get_users() $query_args['fields'] = 'ids'; $authors = get_users($query_args); // STEP through the data foreach ($authors as $authorid) { // GET individual user data and save in temporary variables $author = get_userdata($authorid); // First Last name if ($author->first_name && $author->last_name) { $name = "{$author->first_name} {$author->last_name}"; } else { $name = $author->display_name; } // Bio if (get_the_author_meta('description', $author->ID)) { $bio = get_the_author_meta('description', $author->ID); } else { $bio = ''; } // Twitter handle if (get_the_author_meta('twitter', $author->ID)) { $twit = '<p class="social-links"><a class="twitter" href="https://twitter.com/' . get_the_author_meta('twitter', $author->ID) . '" title="' . esc_attr(sprintf(__("%s on Twitter"), $author->display_name)) . '">@' . get_the_author_meta('twitter', $author->ID) . '</a></p>'; } else { $twit = ''; } // Link to users's posts $authorlink = '<a class="fn" href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr(sprintf(__("Posts by %s"), $author->display_name)) . '">' . $name . '</a>'; // BUILD output $return .= '<section class="author byline vcard">'; // Image $return .= '<div class="avatar-wrap avatar-size-90">'; $return .= get_avatar($author->ID, 90); $return .= '</div>'; $return .= '<div class="bio-wrap">'; $return .= '<' . $args['heading_tag'] . '>' . $authorlink . '</' . $args['heading_tag'] . '>'; $return .= $twit; if ($args['biolength'] > 0 && $bio) { $return .= '<p class="author-bio">'; $return .= wptexturize($bio); $return .= '</p>'; } $return .= '</div><!-- close .bio-wrap -->'; $return .= '</section>'; // End output } // End foreach loop // OUTPUT results // guesses? }
function wpsight_format_content($content) { if (!$content) { return; } $content = do_shortcode(shortcode_unautop(wpautop(convert_chars(convert_smilies(wptexturize($content)))))); return apply_filters('wpsight_format_content', $content); }
/** * Add content to the WC emails. * * @access public * @param WC_Order $order * @param bool $sent_to_admin * @param bool $plain_text * * @return void */ public function email_instructions($order, $sent_to_admin, $plain_text = false) { if (!$sent_to_admin && 'bKash' === $order->payment_method && $order->has_status('on-hold')) { if ($this->instructions) { echo wpautop(wptexturize($this->instructions)) . PHP_EOL; } } }
/** * * @return String */ public function say() { $lyrics = "Hello, Dolly\nWell, hello, Dolly\nIt's so nice to have you back where you belong\nYou're lookin' swell, Dolly\nI can tell, Dolly\nYou're still glowin', you're still crowin'\nYou're still goin' strong\nWe feel the room swayin'\nWhile the band's playin'\nOne of your old favourite songs from way back when\nSo, take her wrap, fellas\nFind her an empty lap, fellas\nDolly'll never go away again\nHello, Dolly\nWell, hello, Dolly\nIt's so nice to have you back where you belong\nYou're lookin' swell, Dolly\nI can tell, Dolly\nYou're still glowin', you're still crowin'\nYou're still goin' strong\nWe feel the room swayin'\nWhile the band's playin'\nOne of your old favourite songs from way back when\nGolly, gee, fellas\nFind her a vacant knee, fellas\nDolly'll never go away\nDolly'll never go away\nDolly'll never go away again"; // Here we split it into lines $lyrics = explode("\n", $lyrics); // And then randomly choose a line return wptexturize($lyrics[mt_rand(0, count($lyrics) - 1)]); }
function cb_Cond_WPTexturize ($inData) { global $tOffAutoFmt; if ($tOffAutoFmt != 1) { $inData = wptexturize($inData); } return $inData; }
function theme_formatter($content) { $new_content = ''; $pattern_full = "/<pre class='code'>(.*?)<\\/pre>/ims"; $content = preg_replace($pattern_full, '<pre class="code">' . str_replace(array('<p>', '</p>', '<br />', '<p>', '</p>'), '', wptexturize(wpautop('$1'))) . '</pre>', $content); $content = str_replace(array('<br />'), '', $content); return $content; }