本文整理汇总了PHP中pp_substr函数的典型用法代码示例。如果您正苦于以下问题:PHP pp_substr函数的具体用法?PHP pp_substr怎么用?PHP pp_substr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pp_substr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pp_cat_posts
function pp_cat_posts($cat_id = '', $items = 5, $echo = TRUE, $show_thumb = TRUE)
{
$return_html = '';
$posts = get_posts('numberposts=' . $items . '&order=DESC&orderby=date&category=' . $cat_id);
$title = get_cat_name($cat_id);
$category_link = get_category_link($cat_id);
$count_post = count($posts);
if (!empty($posts)) {
$return_html .= '<h2 class="widgettitle"><span>' . $title . '</span></h2>';
$return_html .= '<ul class="posts blog ';
if ($show_thumb) {
$return_html .= 'withthumb ';
}
$return_html .= '">';
foreach ($posts as $key => $post) {
$return_html .= '<li>';
if (!empty($show_thumb) && has_post_thumbnail($post->ID, 'related_post')) {
$image_id = get_post_thumbnail_id($post->ID);
$image_url = wp_get_attachment_image_src($image_id, 'related_post', true);
$return_html .= '<div class="post_circle_thumb"><a href="' . get_permalink($post->ID) . '"><img class="alignleft frame post_thumb" src="' . $image_url[0] . '" alt="" /></a></div>';
}
$return_html .= '<a href="' . get_permalink($post->ID) . '">' . pp_substr($post->post_title, 50) . '</a><div class="post_attribute">' . date_i18n(THEMEDATEFORMAT, get_the_time('U', $post->ID)) . '</div>';
$return_html .= '</li>';
}
$return_html .= '</ul><br class="clear"/>';
}
if ($echo) {
echo $return_html;
} else {
return $return_html;
}
}
示例2: pp_substr
?>
/images/icon_zoom.png" alt=""/>
</a>
</span>
</div>
<br class="clear"/>
<div class="portfolio_desc">
<br/>
<h4 class="cufon"><?php
echo $portfolio_item->post_title;
?>
</h4><br/>
<?php
echo pp_substr(strip_tags(strip_shortcodes($portfolio_item->post_content)), 140);
?>
<?php
$pp_portfolio_hide_view = get_option('pp_portfolio_hide_view');
if (!empty($pp_portfolio_hide_view)) {
$pp_portfolio_view_title = get_option('pp_portfolio_view_title');
if (empty($pp_portfolio_view_title)) {
$pp_portfolio_view_title = 'View';
}
?>
<br/><br/><br/>
<input type="button" value="<?php
echo $pp_portfolio_view_title;
?>
" onclick="location.href='<?php
示例3: pp_substr
/>
<?php
if ($caption_align != 'No Caption') {
?>
<span rel="<?php
echo $caption_style;
?>
;z-index:99">
<h4><?php
echo $gallery_item->post_title;
?>
</h4>
<?php
echo pp_substr(strip_tags(strip_shortcodes($gallery_item->post_content)), 200);
?>
</span>
<?php
}
?>
</a>
<?php
}
?>
</div>
<?php
示例4: get_option
//end switch
?>
<div class="portfolio_desc" style="width:490px;margin-top:5px">
<h6 class="cufon"><?php
echo $portfolio_item->post_title;
?>
</h6>
<?php
$pp_portfolio_display_desc = get_option('pp_portfolio_display_desc');
if (!empty($pp_portfolio_display_desc)) {
?>
<span>
<?php
echo pp_substr(strip_tags(strip_shortcodes($portfolio_item->post_excerpt)), 220);
?>
</span>
<?php
}
?>
</div>
</div>
<?php
}
//End foreach loop
?>
示例5: the_permalink
}
?>
<div class="two_third last">
<h6><a href="<?php
the_permalink();
?>
" rel="bookmark" title="Permanent Link to <?php
the_title_attribute();
?>
"><?php
the_title();
?>
</a></h6><br/><?php
echo pp_substr(strip_tags(strip_shortcodes($post->post_content)), 220);
?>
</div>
<br class="clear"/><br/><br/>
<?php
}
wp_reset_query();
?>
</div>
<br class="clear"/>
<?php
}
}
?>
示例6: ppb_blog_grid_func
//.........这里部分代码省略.........
case 'Image':
default:
if (!empty($image_thumb)) {
$small_image_url = wp_get_attachment_image_src($image_id, 'blog', true);
$return_html .= '<div class="post_img small">
<a href="' . esc_url(get_permalink($ppb_post->ID)) . '">
<img src="' . esc_url($small_image_url[0]) . '" alt="' . esc_attr($ppb_post->post_title) . '" class=""/>
</a>
</div>';
}
break;
case 'Vimeo Video':
$post_ft_vimeo = get_post_meta($ppb_post->ID, 'post_ft_vimeo', true);
$return_html .= do_shortcode('[tg_vimeo video_id="' . $post_ft_vimeo . '" width="670" height="377"]') . '<br/>';
break;
case 'Youtube Video':
$post_ft_youtube = get_post_meta($ppb_post->ID, 'post_ft_youtube', true);
$return_html .= do_shortcode('[tg_youtube video_id="' . $post_ft_youtube . '" width="670" height="377"]') . '<br/>';
break;
case 'Gallery':
$post_ft_gallery = get_post_meta($ppb_post->ID, 'post_ft_gallery', true);
$return_html .= do_shortcode('[tg_gallery_slider gallery_id="' . $post_ft_gallery . '" size="gallery_2" width="670" height="270"]');
break;
}
//End switch
$return_html .= '<div class="blog_grid_content">';
//Check post format
$post_format = get_post_format($ppb_post->ID);
switch ($post_format) {
case 'quote':
$return_html .= '
<div class="post_header quote">
<div class="post_quote_title grid">
<a href="' . esc_url(get_permalink($ppb_post->ID)) . '"><p>' . $ppb_post->post_content . '</p></a>
<div class="post_detail">
' . get_the_time(THEMEDATEFORMAT, $ppb_post->ID) . ' ';
$post_categories = wp_get_post_categories($ppb_post->ID);
if (!empty($post_categories)) {
$return_html .= __('In', PLUGINDOMAIN) . ' ';
foreach ($post_categories as $c) {
$cat = get_category($c);
$return_html .= '<a href="' . esc_url(get_category_link($cat->term_id)) . '">' . $cat->name . '</a>';
}
}
$return_html .= '</div>
</div>
</div>';
break;
case 'link':
$return_html .= '
<div class="post_header quote">
<div class="post_quote_title grid">
' . $ppb_post->post_content . '
<div class="post_detail">
' . get_the_time(THEMEDATEFORMAT, $ppb_post->ID) . ' ';
$post_categories = wp_get_post_categories($ppb_post->ID);
if (!empty($post_categories)) {
$return_html .= __('In', PLUGINDOMAIN) . ' ';
foreach ($post_categories as $c) {
$cat = get_category($c);
$return_html .= '<a href="' . esc_url(get_category_link($cat->term_id)) . '">' . $cat->name . '</a>';
}
}
$return_html .= '</div>';
$return_html .= '
</div>
</div>';
break;
default:
$return_html .= '<div class="post_header grid">
<h6><a href="' . esc_url(get_permalink($ppb_post->ID)) . '" title="' . get_the_title($ppb_post->ID) . '">' . get_the_title($ppb_post->ID) . '</a></h6>
<div class="post_detail">
' . get_the_time(THEMEDATEFORMAT, $ppb_post->ID) . ' ';
$post_categories = wp_get_post_categories($ppb_post->ID);
if (!empty($post_categories)) {
$return_html .= __('In', PLUGINDOMAIN) . ' ';
foreach ($post_categories as $c) {
$cat = get_category($c);
$return_html .= '<a href="' . esc_url(get_category_link($cat->term_id)) . '">' . $cat->name . '</a>';
}
}
$return_html .= '</div>
</div>';
$return_html .= pp_substr($ppb_post->post_excerpt, 110);
break;
}
$return_html .= '
</div>
</div>
</div>';
}
$return_html .= '</div>';
}
$return_html .= '</div></div></div></div></div>';
if (!empty($link_title) && !empty($link_url)) {
$return_html .= '<a href="' . esc_url($link_url) . '" class="button continue_ppb_blog">' . urldecode($link_title) . '</a>';
}
return $return_html;
}
示例7: caption
fit_landscape : 1, //Landscape images will not exceed browser width
fit_always : 1,
//Components
navigation : 0, //Slideshow controls on/off
thumbnail_navigation : 0, //Thumbnail navigation
slide_counter : 0, //Display slide numbers
slide_captions : 0, //Slide caption (Pull from "title" in slides array)
progress_bar : 0,
slides : [ //Slideshow Images
<?php
foreach ($all_photo_arr as $photo_id) {
$image_url = wp_get_attachment_image_src($photo_id, 'original', true);
$small_image_url = wp_get_attachment_image_src($photo_id, 'thumbnail', true);
//Get image meta data
$image_title = get_the_title($photo_id);
$image_desc = get_post_field('post_content', $photo_id);
$homeslides .= '{image : \'' . $image_url[0] . '\', thumb: \'' . $small_image_url[0] . '\', title: \'<div id="gallery_caption"><h2>' . pp_substr(addslashes(strip_tags($image_title)), 30) . '</h2><div class="gallery_desc">' . pp_substr(addslashes(trim(preg_replace('/\\s+/', ' ', $image_desc))), 80) . '</div></div>\'},';
}
?>
<?php
$homeslides = substr($homeslides, 0, -1);
echo $homeslides;
?>
]
});
});
<?php
}
示例8: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
echo $before_widget;
$items = empty($instance['items']) ? ' ' : apply_filters('widget_title', $instance['items']);
if (!is_numeric($items)) {
$items = 3;
}
if (!empty($items)) {
$pp_portfolio_sort = get_option('pp_portfolio_sort');
if (empty($pp_portfolio_sort)) {
$pp_portfolio_sort = 'ASC';
}
$portfolio_items = get_posts('numberposts=' . $items . '&order=' . $pp_portfolio_sort . '&orderby=date&post_type=portfolios');
if (isset($portfolio_items) && !empty($portfolio_items)) {
echo '<h2 class="widgettitle">Portfolio</h2>';
foreach ($portfolio_items as $key => $portfolio_item) {
$image_url = '';
if (has_post_thumbnail($portfolio_item->ID, 'large')) {
$image_id = get_post_thumbnail_id($portfolio_item->ID);
$image_url = wp_get_attachment_image_src($image_id, 'large', true);
}
$permalink_url = get_permalink($portfolio_item->ID);
$word_count = 400;
if (!empty($image_url[0])) {
$word_count = 100;
}
?>
<div class="portfolio_grid">
<?php
if (!empty($image_url)) {
?>
<div class="portfolio_image">
<a href="<?php
echo $permalink_url;
?>
">
<img src="<?php
bloginfo('stylesheet_directory');
?>
/timthumb.php?src=<?php
echo $image_url[0];
?>
&h=120&w=200&zc=1" alt="" class="frame"/>
</a>
</div>
<?php
}
?>
<div class="portfolio_desc">
<h6 class="cufon"><a href="<?php
echo $permalink_url;
?>
"><?php
echo $portfolio_item->post_title;
?>
</a></h6>
<p><?php
echo pp_substr(strip_tags(strip_shortcodes($portfolio_item->post_content)), $word_count);
?>
</p>
</div>
</div>
<br class="clear"/>
<?php
}
}
}
echo $after_widget;
}
示例9: pp_posts
/**
* Setup recent posts widget
**/
function pp_posts($sort = 'recent', $items = 3, $echo = TRUE, $bg_color = 'black', $echo_title = TRUE)
{
$return_html = '';
if ($sort == 'recent') {
$posts = get_posts('numberposts=' . $items . '&order=DESC&orderby=date&post_type=post&post_status=publish');
$title = 'Recent Posts';
} else {
global $wpdb;
$query = "SELECT ID, post_title, post_content FROM {$wpdb->prefix}posts WHERE post_type = 'post' AND post_status= 'publish' ORDER BY comment_count DESC LIMIT 0," . $items;
$posts = $wpdb->get_results($query);
$title = 'Popular Posts';
}
if (!empty($posts)) {
if ($echo_title) {
$return_html .= '<h2 class="widgettitle">' . $title . '</h2>';
}
$return_html .= '<ul class="posts blog ' . $bg_color . '_wrapper">';
foreach ($posts as $post) {
$image_thumb = '';
if (has_post_thumbnail($post->ID, 'large')) {
$image_id = get_post_thumbnail_id($post->ID);
$image_thumb = wp_get_attachment_image_src($image_id, 'large', true);
}
$return_html .= '<li>';
if (!empty($image_thumb)) {
$return_html .= '<a href="' . get_permalink($post->ID) . '"><img src="' . get_bloginfo('stylesheet_directory') . '/timthumb.php?src=' . $image_thumb[0] . '&h=75&w=75&zc=1" alt="" class="frame" /></a>';
}
$return_html .= '<strong class="header"><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></strong><br/>';
$return_html .= pp_substr(strip_tags(strip_shortcodes($post->post_content)), 80) . '</li>';
}
$return_html .= '</ul>';
}
if ($echo) {
echo $return_html;
} else {
return $return_html;
}
}
示例10: ppb_blog_func
function ppb_blog_func($atts, $content)
{
//extract short code attr
extract(shortcode_atts(array('size' => 'one', 'title' => '', 'cat' => '', 'items' => '', 'custom_css' => ''), $atts));
$return_html = '<div class="' . esc_attr($size) . '" ';
if (!empty($custom_css)) {
$return_html .= 'style="' . urldecode(esc_attr($custom_css)) . '" ';
}
$return_html .= '>';
$return_html .= '<div class="page_content_wrapper"><div class="inner">';
//Display Title
if (!empty($title)) {
$return_html .= '<h2 class="ppb_title">' . $title . '</h2>';
}
if (!empty($content)) {
$return_html .= do_shortcode(tg_apply_content($content)) . '<br class="clear"/><br/>';
}
if (!is_numeric($items)) {
$items = 3;
}
//Get blog posts
$args = array('numberposts' => $items, 'order' => 'DESC', 'orderby' => 'post_date', 'post_type' => array('post'), 'suppress_filters' => 0);
if (!empty($cat)) {
$args['category'] = $cat;
}
$posts_arr = get_posts($args);
if (!empty($posts_arr) && is_array($posts_arr)) {
$return_html .= '<div class="blog_grid_wrapper">';
foreach ($posts_arr as $key => $ppb_post) {
$image_thumb = '';
if (has_post_thumbnail($ppb_post->ID, 'large')) {
$image_id = get_post_thumbnail_id($ppb_post->ID);
$image_thumb = wp_get_attachment_image_src($image_id, 'large', true);
}
$return_html .= '
<div id="post-' . $ppb_post->ID . '" class="post type-post">
<div class="post_wrapper grid_layout">';
if (!empty($image_thumb)) {
$small_image_url = wp_get_attachment_image_src($image_id, 'gallery_c', true);
$return_html .= '
<div class="post_img">
<a href="' . esc_url(get_permalink($ppb_post->ID)) . '">
<img src="' . esc_url($small_image_url[0]) . '" alt="" class=""/>
</a>
</div>';
}
$return_html .= '<div class="post_header grid_layout">';
//Get Post's Categories
$post_categories = wp_get_post_categories($ppb_post->ID);
if (!empty($post_categories)) {
$return_html .= '<div class="post_subtitle">';
foreach ($post_categories as $c) {
$cat = get_category($c);
$return_html .= '<a href="' . esc_url(get_category_link($cat->term_id)) . '">' . $cat->name . '</a> ';
}
$return_html .= '</div>';
}
$return_html .= '<h5><a href="' . esc_url(get_permalink($ppb_post->ID)) . '" title="' . esc_attr(get_the_title($ppb_post->ID)) . '">' . get_the_title($ppb_post->ID) . '</a></h5>';
$return_html .= '<div class="post_detail">';
$return_html .= get_the_time(THEMEDATEFORMAT, $ppb_post->ID) . ' ';
//Get post author meta
$author_name = get_the_author_meta('user_nicename', $ppb_post->post_author);
$author_url = get_the_author_meta('user_url', $ppb_post->post_author);
if (!empty($author_name)) {
$return_html .= __('by', THEMEDOMAIN) . ' <a href="' . esc_url($author_url) . '">' . $author_name . '</a> ';
}
$return_html .= '</div>';
$return_html .= '</div><br class="clear"/><br/>';
$post_excerpt = pp_get_the_excerpt($ppb_post->ID);
$return_html .= pp_substr(strip_shortcodes($post_excerpt), 100) . '<br/><br/><br/>
<a class="readmore button transparent" href="' . esc_url(get_permalink($ppb_post->ID)) . '">' . __('Read More', THEMEDOMAIN) . '</a>';
$return_html .= '
</div>
</div>';
}
$return_html .= '</div>';
}
$return_html .= '<br class="clear"/></div></div></div>';
return $return_html;
}
示例11: get_permalink
echo get_permalink($prev_post->ID);
?>
">
<h6><?php
echo $prev_post->post_title;
?>
</h6>
</a>
<div class="post_detail">
<?php
echo date(THEMEDATEFORMAT, strtotime($prev_post->post_date));
?>
- <?php
echo date(THEMETIMEFORMAT, strtotime($prev_post->post_date));
?>
</div>
<?php
echo pp_substr(strip_tags(strip_shortcodes($prev_post->post_content)), 110);
?>
</div>
</div>
<?php
}
?>
<br class="clear"/>
</div>
<?php
get_footer();
示例12: esc_url
<a href="<?php
echo esc_url(get_category_link($cat->term_id));
?>
"><?php
echo esc_html($cat->name);
?>
</a>
<?php
}
}
?>
</div>
</div>
<?php
echo pp_substr(get_excerpt_by_id($post->ID), 110);
?>
<?php
break;
}
?>
</div>
</div>
</div>
<!-- End each blog post -->
<?php
$key++;
?>
示例13: esc_url
?>
<a href="<?php
echo esc_url(get_category_link($cat->term_id));
?>
"><?php
echo esc_html($cat->name);
?>
</a>
<?php
}
}
?>
</div>
<?php
echo pp_substr(strip_tags(strip_shortcodes(get_the_content())), 200);
?>
</div>
</div>
</div>
</div>
</div>
<br class="clear"/>
<!-- End each blog post -->
<?php
}
}
?>
示例14: while
?>
</div>
</div>
<?php
}
if (have_posts()) {
?>
<div id="portfolio_filter_wrapper" class="three_columns portfolio-content section content clearfix">
<?php
while ($wp_query->have_posts()) {
$wp_query->the_post();
$image_url = '';
$portfolio_ID = get_the_ID();
$portfolio_title = get_the_title();
$portfolio_excerpt = pp_substr(strip_tags(strip_shortcodes(get_the_excerpt())), 50);
if (has_post_thumbnail($portfolio_ID, 'portfolio3')) {
$image_id = get_post_thumbnail_id($portfolio_ID);
$image_url = wp_get_attachment_image_src($image_id, 'portfolio3', true);
$full_image_url = wp_get_attachment_image_src($image_id, 'full', true);
}
$portfolio_link_url = get_post_meta($portfolio_ID, 'portfolio_link_url', true);
if (empty($portfolio_link_url)) {
$permalink_url = get_permalink($portfolio_ID);
} else {
$permalink_url = $portfolio_link_url;
}
$portfolio_item_set = '';
$portfolio_item_sets = wp_get_object_terms($portfolio_ID, 'portfoliosets');
if (is_array($portfolio_item_sets)) {
foreach ($portfolio_item_sets as $set) {
示例15: esc_url
<a href="<?php
echo esc_url(get_category_link($cat->term_id));
?>
"><?php
echo esc_html($cat->name);
?>
</a>
<?php
}
}
?>
</div>
</div>
<?php
echo pp_substr(get_the_excerpt(), 170);
?>
<?php
break;
}
?>
</div>
</div>
</div>
<!-- End each blog post -->
<?php
$key++;
}