• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP strip_shortcodes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中strip_shortcodes函数的典型用法代码示例。如果您正苦于以下问题:PHP strip_shortcodes函数的具体用法?PHP strip_shortcodes怎么用?PHP strip_shortcodes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了strip_shortcodes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: widget

 /**
  * Displays the Widget
  *
  */
 function widget($args, $instance)
 {
     extract($args);
     extract($instance);
     if (is_multisite()) {
         switch_to_blog($blog_id);
     }
     $output = '';
     global $wpdb;
     $request = $wpdb->prepare("SELECT " . $wpdb->prefix . "posts.*\n                   FROM " . $wpdb->prefix . "posts\n                   WHERE post_type='{$post_type}' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 0,%d", (int) $limit);
     $results = $wpdb->get_results($request);
     $results = $wpdb->get_results($request);
     if (!empty($results)) {
         $output = '<ul>';
         foreach ($results as $post) {
             $post_link = get_permalink($post->ID);
             if (!empty($post->post_excerpt)) {
                 $excerpt = $post->post_excerpt;
             } else {
                 $excerpt = $post->post_content;
                 $excerpt = strip_shortcodes($excerpt);
                 $excerpt = strip_tags($excerpt);
             }
             $excerpt = $this->truncate_string($excerpt, $excerpt_length);
             $image = "";
             if (has_post_thumbnail($post->ID)) {
                 $thumb_id = get_post_thumbnail_id($post->ID);
                 $image_data = wp_get_attachment_image_src($thumb_id, 'full');
                 if (is_array($image_data)) {
                     $image_src = plugins_url('timthumb.php', __FILE__) . "?src=" . $image_data[0] . "&w={$imagew}&h={$imageh}&zc=1&a=t";
                     $image = "<img src='{$image_src}' alt='{$post->post_title}' />";
                 }
             }
             $template = trim($template);
             if (empty($template)) {
                 $output .= '<li>';
                 $output .= '<a rel="bookmark" href="' . $post_link . '"><strong class="title">' . $post->post_title . '</strong></a>';
                 $output .= '</li>';
             } else {
                 $tokens = array("{title}", "{link}", "{image}", "{excerpt}");
                 $data = array($post->post_title, $post_link, $image, $excerpt);
                 $matches = null;
                 $returnValue = preg_match_all('/%%(\\w+)%%/', $template, $matches);
                 if (is_array($matches[1])) {
                     foreach ($matches[1] as $customfield) {
                         $tokens[] = "%%{$customfield}%%";
                         $data[] = get_post_meta($post->ID, $customfield, true);
                     }
                 }
                 $output .= '<li>' . str_replace($tokens, $data, $template) . '</li>';
             }
         }
         $output .= '</ul>';
     }
     if (is_multisite()) {
         restore_current_blog();
     }
     echo $before_widget . $before_title . $title . $after_title;
     echo $output . $after_widget;
 }
开发者ID:Wikipraca,项目名称:Wikipraca-WikiSquare,代码行数:64,代码来源:latest_posts_multisite.php


示例2: porto_get_excerpt

function porto_get_excerpt($limit = 45, $more_link = true)
{
    global $porto_settings;
    if (!$limit) {
        $limit = 45;
    }
    if (has_excerpt()) {
        $content = strip_tags(strip_shortcodes(get_the_excerpt()));
    } else {
        $content = strip_tags(strip_shortcodes(get_the_content()));
    }
    $content = explode(' ', $content, $limit);
    if (count($content) >= $limit) {
        array_pop($content);
        if ($more_link) {
            $content = implode(" ", $content) . '... ';
        } else {
            $content = implode(" ", $content) . ' [...]';
        }
    } else {
        $content = implode(" ", $content);
    }
    if ($porto_settings['blog-excerpt-type'] == 'html') {
        $content = apply_filters('the_content', $content);
        $content = do_shortcode($content);
    }
    if ($more_link) {
        $content .= ' <a class="read-more" href="' . esc_url(apply_filters('the_permalink', get_permalink())) . '">' . __('read more', 'porto') . ' <i class="fa fa-angle-right"></i></a>';
    }
    if ($porto_settings['blog-excerpt-type'] != 'html') {
        $content = '<p class="post-excerpt">' . $content . '</p>';
    }
    return $content;
}
开发者ID:prosenjit-itobuz,项目名称:Unitee,代码行数:34,代码来源:post.php


示例3: smart_excerpt

/**
 * Smart Excerpt
 *
 * Returns an excerpt which is not longer than the given length and always
 * ends with a complete sentence. If first sentence is longer than length,
 * it will add the standard ellipsis… Length is the number of characters.
 *
 * Usage: <?php smart_excerpt(450); >
 *
 * http://www.distractedbysquirrels.com/blog/wordpress-improved-dynamic-excerpt
 */
function smart_excerpt($length, $postId = false)
{
    if ($postId) {
        $post = get_post($postId);
        $text = $post->post_excerpt;
    } else {
        global $post;
        $text = $post->post_excerpt;
    }
    if ('' == $text) {
        if ($postId) {
            $text = $post->post_content;
        } else {
            $text = get_the_content('');
        }
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);
    }
    $text = strip_shortcodes($text);
    $text = wp_strip_all_tags($text, true);
    if (empty($length)) {
        $length = 300;
    }
    $text = substr($text, 0, $length);
    $excerpt = nucleus_reverse_strrchr($text, '.', 1);
    if ($excerpt) {
        echo apply_filters('the_excerpt', $excerpt);
    } else {
        echo apply_filters('the_excerpt', $text . '…');
    }
}
开发者ID:rgfx,项目名称:Nucleus,代码行数:42,代码来源:extras.php


示例4: remove_shortcode_from_index

function remove_shortcode_from_index($content)
{
    if (is_home()) {
        $content = strip_shortcodes($content);
    }
    return $content;
}
开发者ID:bangjojo,项目名称:wp,代码行数:7,代码来源:filters.php


示例5: mantra_trim_excerpt

/**
 * Allows post excerpts to contain HTML tags
 * @since mantra 1.8.7
 * @return string Excerpt with most HTML tags intact
 */
function mantra_trim_excerpt($text)
{
    global $mantra_excerptwords;
    global $mantra_excerptcont;
    global $mantra_excerptdots;
    $raw_excerpt = $text;
    if ('' == $text) {
        //Retrieve the post content.
        $text = get_the_content('');
        //Delete all shortcode tags from the content.
        $text = strip_shortcodes($text);
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]&gt;', $text);
        $allowed_tags = '<a>,<img>,<b>,<strong>,<ul>,<li>,<i>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>,<pre>,<code>,<em>,<u>,<br>,<p>';
        $text = strip_tags($text, $allowed_tags);
        $words = preg_split("/[\n\r\t ]+/", $text, $mantra_excerptwords + 1, PREG_SPLIT_NO_EMPTY);
        if (count($words) > $mantra_excerptwords) {
            array_pop($words);
            $text = implode(' ', $words);
            $text = $text . ' ' . $mantra_excerptdots . ' <a href="' . get_permalink() . '">' . $mantra_excerptcont . ' <span class="meta-nav">&rarr; </span>' . '</a>';
        } else {
            $text = implode(' ', $words);
        }
    }
    return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
开发者ID:rzb,项目名称:boletos2,代码行数:31,代码来源:theme-loop.php


示例6: sb_cl_get_the_excerpt

function sb_cl_get_the_excerpt($id = false)
{
    global $post;
    $old_post = $post;
    if ($id != $post->ID) {
        $post = get_page($id);
    }
    if (!($excerpt = trim($post->post_excerpt))) {
        $excerpt = $post->post_content;
        if (!($more_pos = strpos($excerpt, '<!--more-->'))) {
            if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
                $excerpt = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($excerpt);
            }
            $excerpt = strip_shortcodes($excerpt);
            $excerpt = apply_filters('the_content', $excerpt);
            $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
            $excerpt = strip_tags($excerpt);
            $excerpt_length = apply_filters('excerpt_length', 55);
            $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
            $words = preg_split("/[\n\r\t ]+/", $excerpt, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
            if (count($words) > $excerpt_length) {
                array_pop($words);
                $excerpt = implode(' ', $words);
                $excerpt = $excerpt . $excerpt_more;
            } else {
                $excerpt = implode(' ', $words);
            }
        } else {
            $excerpt = substr($excerpt, 0, $more_pos);
        }
    }
    $post = $old_post;
    return $excerpt;
}
开发者ID:elliottoman,项目名称:shero2016,代码行数:34,代码来源:sb_child_list.php


示例7: fb_strip_and_format_desc

function fb_strip_and_format_desc($post)
{
    $desc_no_html = "";
    $desc_no_html = strip_shortcodes($desc_no_html);
    // Strip shortcodes first in case there is HTML inside the shortcode
    $desc_no_html = wp_strip_all_tags($desc_no_html);
    // Strip all html
    $desc_no_html = trim($desc_no_html);
    // Trim the final string, we may have stripped everything out of the post so this will make the value empty if that's the case
    // Check if empty, may be that the strip functions above made excerpt empty, doubhtful but we want to be 100% sure.
    if (empty($desc_no_html)) {
        $desc_no_html = $post->post_content;
        // Start over, this time with the post_content
        $desc_no_html = strip_shortcodes($desc_no_html);
        // Strip shortcodes first in case there is HTML inside the shortcode
        $desc_no_html = str_replace(']]>', ']]&gt;', $desc_no_html);
        // Angelo Recommendation, if for some reason ]]> happens to be in the_content, rare but We've seen it happen
        $desc_no_html = wp_strip_all_tags($desc_no_html);
        $excerpt_length = apply_filters('excerpt_length', 55);
        $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
        $desc_no_html = wp_trim_words($desc_no_html, $excerpt_length, $excerpt_more);
        $desc_no_html = trim($desc_no_html);
        // Trim the final string, we may have stripped everything out of the post so this will make the value empty if that's the case
    }
    $desc_no_html = str_replace(array("\r\n", "\r", "\n"), ' ', $desc_no_html);
    // I take it Facebook doesn't like new lines?
    return $desc_no_html;
}
开发者ID:hscale,项目名称:webento,代码行数:28,代码来源:fb-open-graph.php


示例8: easy_event_the_excerpt

/**
 * Custom excerpt
 *
 * @param $post_excerpt
 *
 * @return mixed|string
 */
function easy_event_the_excerpt($post_excerpt)
{
    $post_id = get_the_ID();
    $post = get_post($post_id);
    $excerpt_temp = $post->post_excerpt;
    if ($excerpt_temp == '') {
        $excerpt_temp = get_post_meta($post_id, 'easy_event_description', true);
    }
    if ($excerpt_temp == '') {
        $excerpt_temp = strip_tags($post->post_content);
    }
    $excerpt_temp = strip_shortcodes($excerpt_temp);
    /**
     * Excerpt length
     */
    $excerpt_length = get_option('easy_event_excerpt_length');
    if ($excerpt_length == false) {
        $excerpt_length = 250;
    }
    $excerpt_length += 5;
    if (mb_strlen($excerpt_temp) > $excerpt_length) {
        $subex = mb_substr($excerpt_temp, 0, $excerpt_length - 5);
        $exwords = explode(' ', $subex);
        $excut = -mb_strlen($exwords[count($exwords) - 1]);
        if ($excut < 0) {
            return mb_substr($subex, 0, $excut) . '[...]';
        } else {
            return $subex . '[...]';
        }
    } else {
        return $excerpt_temp;
    }
}
开发者ID:tutv95,项目名称:easy-events,代码行数:40,代码来源:functions.php


示例9: clean_description

 /**
  * Clean post description text in preparation for Open Graph protocol description or Facebook post caption|description
  *
  * @since 1.1
  * @uses strip_shortcodes()
  * @uses wp_trim_words()
  * @param string $description description text
  * @return string description text passed through WordPress Core description cleaners, possibly trimmed
  */
 public static function clean_description($description, $trimmed = true)
 {
     $description = trim($description);
     if (!$description) {
         return '';
     }
     // basic filters from wp_trim_excerpt() that should apply to both excerpt and content
     // note: the_content filter is so polluted with extra third-party stuff we purposely avoid to better represent page content
     $description = strip_shortcodes($description);
     // remove any shortcodes that may exist, such as an image macro
     $description = str_replace(']]>', ']]&gt;', $description);
     $description = trim($description);
     if (!$description) {
         return '';
     }
     if ($trimmed) {
         // use the built-in WordPress function for localized support of words vs. characters
         // pass in customizations based on WordPress with publisher overrides
         $description = wp_trim_words($description, apply_filters('facebook_excerpt_length', apply_filters('excerpt_length', 55)), apply_filters('facebook_excerpt_more', __('&hellip;')));
     } else {
         $description = wp_strip_all_tags($description);
     }
     if ($description) {
         return $description;
     }
     return '';
 }
开发者ID:batruji,项目名称:metareading,代码行数:36,代码来源:open-graph-protocol.php


示例10: fb_description

function fb_description()
{
    global $post;
    if (!empty($post->post_excerpt)) {
        $description = $post->post_excerpt;
    } else {
        $description = trim(strip_shortcodes(strip_tags($post->post_content)));
        $pos0 = strpos($description, '.') + 1;
        $pos0 = $pos0 === false ? strlen($description) : $pos0;
        $pos = strpos(substr($description, $pos0), '.');
        if ($pos < 0 || $pos === false) {
            $pos = strlen($description);
        } else {
            $pos = $pos + $pos0;
        }
        $description = str_replace("\n", "", substr($description, 0, $pos));
        $description = str_replace("\r", "", $description);
        $description = str_replace("\"", "'", $description);
        $description = nl2br($description);
    }
    if (is_front_page()) {
        $description = get_bloginfo('description');
    }
    return $description;
}
开发者ID:nixter,项目名称:d.school,代码行数:25,代码来源:facebook-opengraph.php


示例11: register_meta_tags

 public function register_meta_tags()
 {
     add_action('wp_head', function () {
         if (is_singular() && false == post_password_required()) {
             if ('' == ($description = get_the_excerpt())) {
                 $description = wp_trim_words(esc_html(strip_shortcodes(get_the_content())), 20, '...');
             }
         } elseif (is_category() && '' != category_description()) {
             $description = category_description();
         } elseif (is_tag() && '' != term_description()) {
             $description = term_description();
         } else {
             $description = get_bloginfo('description');
         }
         $description = esc_attr($description);
         echo "<meta name=\"description\" content=\"{$description}\" />\n";
         echo "<meta name=\"og:description\" content=\"{$description}\" />\n";
         if (is_singular() && false == post_password_required() && has_post_thumbnail()) {
             list($image, $width, $height) = wp_get_attachment_image_src(get_post_thumbnail_id(), 'facebook');
         } else {
             $image = apply_filters('', $this->get_theme_assets_url() . '/images/logo-fb.png');
         }
         $image = esc_url($image);
         echo "<meta name=\"og:image\" content=\"{$image}\" />\n";
         echo "<meta name=\"twitter:image\" content=\"{$image}\" />\n";
     });
 }
开发者ID:shtrihstr,项目名称:wpk15-theme-wpkit,代码行数:27,代码来源:Initialization.php


示例12: jl_brd_dashboard_recent_drafts

function jl_brd_dashboard_recent_drafts($drafts = false)
{
    if (!$drafts) {
        $drafts_query = new WP_Query(array('post_type' => 'any', 'post_status' => array('draft', 'pending'), 'posts_per_page' => 150, 'orderby' => 'modified', 'order' => 'DESC'));
        $drafts =& $drafts_query->posts;
    }
    if ($drafts && is_array($drafts)) {
        $list = array();
        foreach ($drafts as $draft) {
            $url = get_edit_post_link($draft->ID);
            $title = _draft_or_post_title($draft->ID);
            $last_id = get_post_meta($draft->ID, '_edit_last', true);
            $last_user = get_userdata($last_id);
            $last_modified = '<i>' . esc_html($last_user->display_name) . '</i>';
            $item = '<h4><a href="' . $url . '" title="' . sprintf(__('Edit ?%s?'), esc_attr($title)) . '">' . esc_html($title) . '</a>' . '<abbr> ' . $draft->post_status . ' ' . $draft->post_type . '</abbr>' . '<abbr style="display:block;margin-left:0;">' . sprintf(__('Last edited by %1$s on %2$s at %3$s'), $last_modified, mysql2date(get_option('date_format'), $draft->post_modified), mysql2date(get_option('time_format'), $draft->post_modified)) . '</abbr></h4>';
            if ($the_content = preg_split('#\\s#', strip_shortcodes(strip_tags($draft->post_content), 11, PREG_SPLIT_NO_EMPTY))) {
                $item .= '<p>' . join(' ', array_slice($the_content, 0, 10)) . (10 < count($the_content) ? '&hellip;' : '') . '</p>';
            }
            $list[] = $item;
        }
        ?>
	<ul>
		<li><?php 
        echo join("</li>\n<li>", $list);
        ?>
</li>
	</ul>
<?php 
    } else {
        _e('There are no drafts at the moment');
    }
}
开发者ID:aarontgrogg,项目名称:aarontgrogg,代码行数:32,代码来源:better-recent-drafts.php


示例13: postExcerptCallback

 function postExcerptCallback($matches)
 {
     $pageContent = strip_tags($this->page->post_content);
     //return "blah" .$exLength;
     if ($this->page->post_excerpt == "") {
         //if there's no excerpt applied to the post, extract one
         //$postCallback->pageContent = strip_tags($page->post_content);
         //$str = preg_replace_callback('#\[ *post_excerpt *(length=[\'|\"]([^\'\"]*)[\'|\"])? *\]#', array(&$postCallback, 'postExcerptCallback'), $str);
         if (isset($matches[2])) {
             $exLength = intval($matches[2]);
         } else {
             $exLength = 250;
         }
         //return "blah";
         if (strlen($pageContent) > $exLength) {
             return strip_shortcodes(substr($pageContent, 0, $exLength)) . "...";
             //clean up and return excerpt
         } else {
             return strip_shortcodes($pageContent);
         }
     } else {
         //if there is a post excerpt just use it and don't generate our own
         /* if(isset($matches[2])){//uncomment this if/else statement if you want the manual excerpt to be trimmed to the passed in length
            $exLength = intval($matches[2]);
            return substr($this->page->post_excerpt, 0, $exLength);
            }else{
            return $this->page->post_excerpt;
            } */
         return $this->page->post_excerpt;
     }
 }
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:31,代码来源:APLCallback.php


示例14: swp_get_excerpt_by_id

function swp_get_excerpt_by_id($post_id)
{
    // Check if the post has an excerpt
    if (has_excerpt()) {
        $the_post = get_post($post_id);
        //Gets post ID
        $the_excerpt = $the_post->post_excerpt;
        // If not, let's create an excerpt
    } else {
        $the_post = get_post($post_id);
        //Gets post ID
        $the_excerpt = $the_post->post_content;
        //Gets post_content to be used as a basis for the excerpt
    }
    $excerpt_length = 100;
    //Sets excerpt length by word count
    $the_excerpt = strip_tags(strip_shortcodes($the_excerpt));
    //Strips tags and images
    $the_excerpt = str_replace(']]>', ']]&gt;', $the_excerpt);
    $the_excerpt = strip_tags($the_excerpt);
    $excerpt_length = apply_filters('excerpt_length', 100);
    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    $words = preg_split("/[\n\r\t ]+/", $the_excerpt, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
    if (count($words) > $excerpt_length) {
        array_pop($words);
        // array_push($words, '…');
        $the_excerpt = implode(' ', $words);
    }
    $the_excerpt = preg_replace("/\r|\n/", "", $the_excerpt);
    return $the_excerpt;
}
开发者ID:warfare-plugins,项目名称:social-warfare,代码行数:31,代码来源:excerpt.php


示例15: de_excerpt

function de_excerpt($excerpt, $content, $length = 0)
{
    if (strlen($excerpt)) {
        $length = $length == 0 ? strlen($excerpt) : $length;
        if (strlen($excerpt) > $length) {
            $result = mb_substr($excerpt, 0, $length, 'UTF-8');
            $result .= '...';
        } else {
            $result = $excerpt;
        }
    } else {
        $content = trim(strip_shortcodes($content));
        if (strlen($content) > strlen(strip_shortcodes($content))) {
            $length = $length == 0 ? strlen($content) : $length;
            $content = de_excerpt('', $content, $length);
        }
        $content = strip_tags($content);
        $length = $length == 0 ? strlen($content) : $length;
        if (strlen($content) > $length) {
            $result = mb_substr($content, 0, $length, 'UTF-8');
            $result .= '...';
        } else {
            $result = $content;
        }
    }
    return $result;
}
开发者ID:JerryXie96,项目名称:PBSMUNC2013WebSite,代码行数:27,代码来源:main.php


示例16: truncate_content

function truncate_content($limit, $echo = true, $paragraphs = true, $customfield = 0)
{
    global $post;
    $output = '';
    if ($customfield !== 0) {
        $output = get_post_meta($post->ID, $customfield, true);
    }
    if ($output == '') {
        $content = get_the_content();
        $content = strip_shortcodes(strip_tags($content));
        $len = strlen($content);
        if ($len > $limit) {
            $output = substr($content, 0, $limit);
            $output .= '...';
        } else {
            $output = $content;
        }
    }
    if ($paragraphs == true) {
        $output = '<p>' . $output . '</p>';
    }
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:xiguawanous-friends,项目名称:dazhe-temporary,代码行数:27,代码来源:custom-functions.php


示例17: get_post

 private function get_post()
 {
     if (isset($this->options['text_limit']) && !empty($this->options['text_limit'])) {
         $limit = $this->options['text_limit'];
     } else {
         $limit = 100;
     }
     $start_date = date('F jS, Y', strtotime($this->options['start_date']));
     $getPost = new WP_Query(array('cat' => implode(',', $this->options['categories']), 'date_query' => array(array('after' => $start_date)), 'orderby' => 'date', 'order' => 'ASC', 'meta_query' => array('relation' => 'OR', array('key' => 'aus_telegram_sent', 'compare' => 'NOT EXISTS', 'value' => '')), 'posts_per_page' => 1));
     if (isset($getPost->posts[0])) {
         $getPost = $getPost->posts[0];
         $text = $getPost->post_content;
         $text = strip_shortcodes($text);
         $text = preg_replace('/[\\r\\n]+/', "", $text);
         $text = preg_replace('/\\s+/', ' ', $text);
         $text = trim($text);
         $text = strip_tags($text);
         $text = $this->limit($text, $limit);
         $cat_ids = wp_get_post_categories($getPost->ID);
         if (!empty($cat_ids)) {
             $category = get_category($cat_ids[0])->name;
         } else {
             $category = '';
         }
         $post = array('id' => $getPost->ID, 'title' => $getPost->post_title, 'url' => $getPost->guid, 'date' => date('d.m.Y', strtotime($getPost->post_date)), 'category' => $category, 'text' => $text);
         wp_reset_query();
         return $post;
     } else {
         return false;
     }
 }
开发者ID:anvarulugov,项目名称:AUS-telegram-channel,代码行数:31,代码来源:aus-telegram-channel.php


示例18: crp_excerpt

/**
 * Function to create an excerpt for the post.
 *
 * @since 1.6
 *
 * @param int        $id Post ID
 * @param int|string $excerpt_length Length of the excerpt in words
 * @return string Excerpt
 */
function crp_excerpt($id, $excerpt_length = 0, $use_excerpt = true)
{
    $content = $excerpt = '';
    if ($use_excerpt) {
        $content = get_post($id)->post_excerpt;
    }
    if ('' == $content) {
        $content = get_post($id)->post_content;
    }
    $output = strip_tags(strip_shortcodes($content));
    if ($excerpt_length > 0) {
        $output = wp_trim_words($output, $excerpt_length);
    }
    /**
     * Filters excerpt generated by CRP.
     *
     * @since	1.9
     *
     * @param	array	$output			Formatted excerpt
     * @param	int		$id				Post ID
     * @param	int		$excerpt_length	Length of the excerpt
     * @param	boolean	$use_excerpt	Use the excerpt?
     */
    return apply_filters('crp_excerpt', $output, $id, $excerpt_length, $use_excerpt);
}
开发者ID:olechka1505,项目名称:hungrylemur,代码行数:34,代码来源:tools.php


示例19: ubermenu_recent_posts

function ubermenu_recent_posts($atts)
{
    global $uberMenu;
    extract(shortcode_atts(array('num' => 3, 'img' => 'on', 'img_size' => 'inherit', 'img_width' => 45, 'img_height' => 45, 'excerpt' => 'off', 'category' => '', 'default_img' => false, 'offset' => 0), $atts));
    $args = array('numberposts' => $num, 'offset' => $offset, 'suppress_filters' => false);
    if (!empty($category)) {
        if (is_numeric($category)) {
            $args['category'] = $category;
        } else {
            $args['category_name'] = $category;
        }
    }
    $posts = get_posts($args);
    $class = 'ubermenu-postlist';
    if ($img == 'on') {
        $class .= ' ubermenu-postlist-w-img';
    }
    $html = '<ul class="' . $class . '">';
    foreach ($posts as $post) {
        $ex = $post->post_excerpt;
        if ($ex == '' && function_exists('wp_trim_words')) {
            //wp_trim_words is a WP3.3 function
            $ex = $post->post_content;
            $ex = strip_shortcodes($ex);
            $ex = str_replace(']]>', ']]&gt;', $ex);
            $excerpt_length = apply_filters('excerpt_length', 55);
            $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
            $ex = wp_trim_words($ex, $excerpt_length, $excerpt_more);
        }
        //$ex = apply_filters('get_the_excerpt', $post->post_excerpt);
        $post_url = get_permalink($post->ID);
        $image = '';
        $w = $img_width;
        $h = $img_height;
        $content_styles = array();
        //if($img == 'on') $image = $uberMenu->getPostImage($post->ID, $w, $h, $default_img);
        if ($img == 'on') {
            $img_data = ubermenu_get_image(false, $post->ID, true, array('img_w' => $w, 'img_h' => $h, 'img_size' => $img_size, 'default_img' => $default_img));
            if (isset($img_data['img'])) {
                $image = $img_data['img'];
                $content_styles['padding-left'] = $img_data['w'] + 10 . 'px';
            }
        }
        $_content_styles = '';
        if (!empty($content_styles)) {
            $_content_styles = 'style="';
            foreach ($content_styles as $prop => $val) {
                $_content_styles .= $prop . ':' . $val . ';';
            }
            $_content_styles .= '"';
        }
        $html .= '<li class="ubermenu-postlist-item">' . $image . '<div class="ubermenu-postlist-title" ' . $_content_styles . '><a href="' . $post_url . '">' . $post->post_title . '</a></div>';
        if ($excerpt == 'on') {
            $html .= '<div class="ubermenu-postlist-content" ' . $_content_styles . '>' . $ex . '</div>';
        }
        $html .= '</li>';
    }
    $html .= '</ul>';
    return $html;
}
开发者ID:WackoMako,项目名称:stonedape,代码行数:60,代码来源:shortcodes.php


示例20: get_sanitized_word_array

 /**
  * Get an array of words from a string. Parses out HTML tags and shortcodes, removes punctuation, 
  * removes line breaks, removes whitespace, lowercase all words, removes stop words, and removes
  * words that are less than 3 characters.
  *
  * @access private
  *
  * @param string $text String of text to parse
  *
  * @uses strip_shortcodes()
  * @uses apply_filters()
  * 
  * @return array Sanitized words
  */
 private function get_sanitized_word_array($text)
 {
     // Strip html tags and shortcodes
     $text = strip_tags($text);
     $text = strip_shortcodes($text);
     // Remove anything that's not a letter or number
     $text = preg_replace('/[^a-zA-Z 0-9]+/', ' ', $text);
     // Remove line breaks
     $text = str_replace("\n", '', $text);
     $text = str_replace("\r", '', $text);
     // Replace multiple spaces with a single space
     $text = preg_replace('!\\s+!', ' ', $text);
     // Create an array of words
     $words = explode(' ', $text);
     // Lowercase and trim the words
     $words = array_map('strtolower', $words);
     $words = array_map('trim', $words);
     // Define our stop words
     $stopwords = apply_filters('mlt_stop_words', array('a', 'just', 'nbsp', 'about', 'above', 'above', 'across', 'after', 'afterwards', 'again', 'against', 'all', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'am', 'among', 'amongst', 'amoungst', 'amount', 'an', 'and', 'another', 'any', 'anyhow', 'anyone', 'anything', 'anyway', 'anywhere', 'are', 'around', 'as', 'at', 'back', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'below', 'beside', 'besides', 'between', 'beyond', 'bill', 'both', 'bottom', 'but', 'by', 'call', 'can', 'cannot', 'cant', 'co', 'con', 'could', 'couldnt', 'cry', 'de', 'describe', 'detail', 'do', 'done', 'down', 'due', 'during', 'each', 'eg', 'eight', 'either', 'eleven', 'else', 'elsewhere', 'empty', 'enough', 'etc', 'even', 'ever', 'every', 'everyone', 'everything', 'everywhere', 'except', 'few', 'fifteen', 'fify', 'fill', 'find', 'fire', 'first', 'five', 'for', 'former', 'formerly', 'forty', 'found', 'four', 'from', 'front', 'full', 'further', 'get', 'give', 'go', 'had', 'has', 'hasnt', 'have', 'he', 'hence', 'her', 'here', 'hereafter', 'hereby', 'herein', 'hereupon', 'hers', 'herself', 'him', 'himself', 'his', 'how', 'however', 'hundred', 'ie', 'if', 'in', 'inc', 'indeed', 'interest', 'into', 'is', 'it', 'its', 'itself', 'keep', 'last', 'latter', 'latterly', 'least', 'less', 'ltd', 'made', 'many', 'may', 'me', 'meanwhile', 'might', 'mill', 'mine', 'more', 'moreover', 'most', 'mostly', 'move', 'much', 'must', 'my', 'myself', 'name', 'namely', 'neither', 'never', 'nevertheless', 'next', 'nine', 'no', 'nobody', 'none', 'noone', 'nor', 'not', 'nothing', 'now', 'nowhere', 'of', 'off', 'often', 'on', 'once', 'one', 'only', 'onto', 'or', 'other', 'others', 'otherwise', 'our', 'ours', 'ourselves', 'out', 'over', 'own', 'part', 'per', 'perhaps', 'please', 'put', 'rather', 're', 'same', 'see', 'seem', 'seemed', 'seeming', 'seems', 'serious', 'several', 'she', 'should', 'show', 'side', 'since', 'sincere', 'six', 'sixty', 'so', 'some', 'somehow', 'someone', 'something', 'sometime', 'sometimes', 'somewhere', 'still', 'such', 'system', 'take', 'ten', 'than', 'that', 'the', 'their', 'them', 'themselves', 'then', 'thence', 'there', 'thereafter', 'thereby', 'therefore', 'therein', 'thereupon', 'these', 'they', 'thickv', 'thin', 'third', 'this', 'those', 'though', 'three', 'through', 'throughout', 'thru', 'thus', 'to', 'together', 'too', 'top', 'toward', 'towards', 'twelve', 'twenty', 'two', 'un', 'under', 'until', 'up', 'upon', 'us', 'very', 'via', 'was', 'we', 'well', 'were', 'what', 'whatever', 'when', 'whence', 'whenever', 'where', 'whereafter', 'whereas', 'whereby', 'wherein', 'whereupon', 'wherever', 'whether', 'which', 'while', 'whither', 'who', 'whoever', 'whole', 'whom', 'whose', 'why', 'will', 'with', 'within', 'without', 'would', 'yet', 'you', 'your', 'yours', 'yourself', 'yourselves', 'the'));
     // Remove stop words from our words array
     $words = preg_replace('/\\b(' . implode('|', $stopwords) . ')\\b/', '', $words);
     // Remove words that are less than 3 characters
     $words = array_filter($words, function ($word) {
         return strlen($word) > 2;
     });
     // Return the results
     return $words;
 }
开发者ID:rcoll,项目名称:WP_MLT_Query,代码行数:42,代码来源:wp_mlt_query.php



注:本文中的strip_shortcodes函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP strip_slashes函数代码示例发布时间:2022-05-23
下一篇:
PHP strip_search_index函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap