本文整理汇总了PHP中wp_html_excerpt函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_html_excerpt函数的具体用法?PHP wp_html_excerpt怎么用?PHP wp_html_excerpt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_html_excerpt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sys_recent_posts
function sys_recent_posts($atts, $content = null)
{
extract(shortcode_atts(array('limit' => '2', 'description' => '40', 'cat_id' => '23', 'thumb' => 'true', 'postdate' => ''), $atts));
$out = '<div class="widget_postslist sc">';
$out .= '<ul>';
global $wpdb;
$myposts = get_posts("numberposts={$limit}&offset=0&cat={$cat_id}");
foreach ($myposts as $post) {
$post_date = $post->post_date;
$post_date = mysql2date('F j, Y', $post_date, false);
$out .= "<li>";
if ($thumb == "true") {
$thumbid = get_post_thumbnail_id($post->ID);
$imgsrc = wp_get_attachment_image_src($thumbid, array(9999, 9999));
$out .= '<div class="thumb"><a href="' . get_permalink($post->ID) . '" title="' . $post->post_title . '">';
if ($thumbid) {
$out .= atp_resize('', $imgsrc['0'], '50', '50', 'imgborder', '');
} else {
//$out .= '<img class="imgborder" src="'.THEME_URI.'/images/no-image.jpg'.'" alt="' .$post->post_title. '" />';
}
$out .= '</a></div>';
}
$out .= '<div class="pdesc"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . $post->post_title . '</a>';
if ($postdate == "true") {
$out .= '<div class="w-postmeta"><span>' . $post_date . '</span></div>';
} else {
$out .= '<p>' . wp_html_excerpt($post->post_content, $description, '...') . '</p>';
}
$out .= '</div></li>';
}
$out .= '</ul></div>';
return $out;
wp_reset_query();
}
开发者ID:pryspry,项目名称:MusicPlay,代码行数:34,代码来源:recentposts.php
示例2: test_entities
function test_entities()
{
$this->assertEquals("Baba ", wp_html_excerpt("Baba & Dyado", 8));
$this->assertEquals("Baba ", wp_html_excerpt("Baba & Dyado", 8));
$this->assertEquals("Baba & D", wp_html_excerpt("Baba & Dyado", 12));
$this->assertEquals("Baba & Dyado", wp_html_excerpt("Baba & Dyado", 100));
}
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:7,代码来源:HtmlExcerpt.php
示例3: s8_dashboard_widget_function
function s8_dashboard_widget_function()
{
$rss = fetch_feed("http://station8branding.com/feed/");
if (is_wp_error($rss)) {
if (is_admin() || current_user_can('manage_options')) {
echo '<p>';
printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
echo '</p>';
}
return;
}
if (!$rss->get_item_quantity()) {
echo '<p>Apparently, there are no updates to show!</p>';
$rss->__destruct();
unset($rss);
return;
}
echo "<header style='background: black; padding: 10px; text-align: center; margin: -11px -12px;'><a href='http://station8branding.com' target='_blank'><img src='http://station8branding.com/wp-content/uploads/2014/12/branding2.png'></a></header>";
echo "<ul>\n";
if (!isset($items)) {
$items = 5;
}
foreach ($rss->get_items(0, $items) as $item) {
$link = esc_url(strip_tags($item->get_link()));
$title = esc_html($item->get_title());
$content = $item->get_content();
$content = wp_html_excerpt($content, 150) . ' ...';
//$image = $item->get_the_post_thumbnail();
echo "<li><a class='rsswidget' href='{$link}'>{$title}</a>\n<div class='rssSummary'>{$content}</div>\n";
}
echo "</ul>\n";
echo "<a href='http://station8branding.com'>Visit Station8 for more information</a>";
$rss->__destruct();
unset($rss);
}
开发者ID:Station8branding,项目名称:WP_roots,代码行数:35,代码来源:station.php
示例4: dashboard_widget_function
function dashboard_widget_function()
{
$rss = fetch_feed("http://oldtownmediainc.com/feed/");
if (is_wp_error($rss)) {
if (is_admin() || current_user_can('manage_options')) {
echo '<p>';
printf(__('<strong>RSS Error</strong>: %s', 'evans-mu'), $rss->get_error_message());
echo '</p>';
}
return;
}
if (!$rss->get_item_quantity()) {
echo '<p>' . __('Apparently, there are no updates to show!', 'evans-mu') . '</p>';
$rss->__destruct();
unset($rss);
return;
}
echo "<ul>\n";
if (!isset($items)) {
$items = 5;
}
foreach ($rss->get_items(0, $items) as $item) {
$publisher = $site_link = $link = $content = '';
$date = $item->get_date();
$link = esc_url(strip_tags($item->get_link()));
$title = esc_html($item->get_title());
$content = $item->get_content();
$content = wp_html_excerpt($content, 350) . '...';
echo "<li class='rss-widget'><a class='rsswidget' href='{$link}'>{$title}</a><span class='rss-date'> - {$date}</span>\n<div class='rssSummary'>{$content}</div>\n\r\n";
}
echo "</ul>\n";
$rss->__destruct();
unset($rss);
}
开发者ID:TheTypoMaster,项目名称:evans,代码行数:34,代码来源:otm-blog-dashboard-widget.php
示例5: new_service
public function new_service($label, $url, $icon)
{
// Validate
$label = trim(wp_html_excerpt(wp_kses($label, array()), 30));
$url = trim(esc_url_raw($url));
$icon = trim(esc_url_raw($icon));
if ($label && $url && $icon) {
$options = get_option('sharing-options');
if (!is_array($options)) {
$options = array();
}
$service_id = 'custom-' . time();
// Add a new custom service
$options['global']['custom'][] = $service_id;
if (false !== $this->global) {
$this->global['custom'][] = $service_id;
}
update_option('sharing-options', $options);
// Create a custom service and set the options for it
$service = new Share_Custom($service_id, array('name' => $label, 'url' => $url, 'icon' => $icon));
$this->set_service($service_id, $service);
// Return the service
return $service;
}
return false;
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:26,代码来源:sharing-service.php
示例6: widget
function widget($args, $instance)
{
global $familia_option;
extract($args);
$warrior_recent_comments_title = apply_filters('widget_title', empty($instance['warrior_recent_comments_title']) ? __('Recent Comments', 'familia') : $instance['warrior_recent_comments_title'], $instance, $this->id_base);
$warrior_recent_comments_count = !empty($instance['warrior_recent_comments_count']) ? absint($instance['warrior_recent_comments_count']) : 4;
$warrior_recent_excerpt_count = !empty($instance['warrior_recent_excerpt_count']) ? absint($instance['warrior_recent_excerpt_count']) : 90;
if (!$warrior_recent_comments_count) {
$warrior_recent_comments_count = 4;
}
?>
<?php
echo $before_widget;
?>
<?php
echo $before_title . $warrior_recent_comments_title . $after_title;
?>
<?php
$args = array('status' => 'approve', 'number' => $warrior_recent_comments_count);
$comments = get_comments($args);
?>
<ul class="recent-comments-widget">
<?php
foreach ($comments as $comment) {
?>
<li class="recent-comments-wrapper">
<div class="comments-avatar">
<?php
echo get_avatar($comment, '50');
?>
</div>
<div class="detail">
<a href="<?php
echo get_permalink($comment->comment_post_ID);
?>
#comment-<?php
echo $comment->comment_ID;
?>
" rel="external nofollow">
<?php
echo '<span class="recommauth">' . $comment->comment_author . '</span>';
?>
</a>
<p><?php
echo wp_html_excerpt($comment->comment_content, $warrior_recent_excerpt_count, '...');
?>
</p>
</div>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
}
开发者ID:TakenCdosG,项目名称:chefs_blog,代码行数:59,代码来源:warrior-recent-comments.php
示例7: rss_box
/**
* Creates the RSS metabox
*
* @access public
* @since 1.0
* @return void
*/
function rss_box($rss)
{
// Get RSS Feed(s)
include_once ABSPATH . WPINC . '/feed.php';
// My feeds list (add your own RSS feeds urls)
$my_feeds = array('http://agora.xtec.cat/nodes/categoria/portada/feed');
// Loop through Feeds
foreach ($my_feeds as $feed) {
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed($feed);
if (!is_wp_error($rss)) {
// Checks that the object is created correctly
// Figure out how many total items there are, and choose a limit
$maxitems = $rss->get_item_quantity(20);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
// Get RSS title
$rss_title = '<a href="' . $rss->get_permalink() . '" target="_blank">' . strtoupper($rss->get_title()) . '</a>';
}
// Display the container
echo '<div class="rss-widget">';
echo '<strong>' . $rss_title . '</strong>';
echo '<hr style="border: 0; background-color: #DFDFDF; height: 1px;">';
// Starts items listing within <ul> tag
echo '<ul>';
// Check items
if ($maxitems == 0) {
echo '<li>' . __('No item', 'rc_mdm') . '.</li>';
} else {
// Loop through each feed item and display each item as a hyperlink.
foreach ($rss_items as $item) {
// Uncomment line below to display non human date
//$item_date = $item->get_date( get_option('date_format').' @ '.get_option('time_format') );
// Get human date (comment if you want to use non human date)
$item_date = human_time_diff($item->get_date('U'), current_time('timestamp')) . ' ' . __('ago', 'rc_mdm');
// Start displaying item content within a <li> tag
echo '<li>';
// create item link
echo '<a href="' . esc_url($item->get_permalink()) . '" title="' . $item_date . '">';
// Get item title
echo esc_html($item->get_title());
echo '</a>';
// Display date
echo ' <span class="rss-date">' . $item_date . '</span><br />';
// Get item content
$content = $item->get_content();
// Shorten content
$content = wp_html_excerpt($content, 120) . ' [...]';
// Display content
echo $content;
// End <li> tag
echo '</li>';
}
}
// End <ul> tag
echo '</ul></div>';
}
// End foreach feed
}
开发者ID:pausaura,项目名称:agora_nodes,代码行数:66,代码来源:rss-metabox.php
示例8: widget
function widget($args, $instance)
{
//defaults
$instance = wp_parse_args($instance, array("title" => "", "categories" => "", "count" => "", "limit" => "", "show_thumbnails" => "", "show_excerpt" => "", "thumb_width" => "", "thumb_height" => ""));
extract($args);
$title = !empty($instance['title']) ? apply_filters('widget_title', $instance['title']) : "";
$categories = !empty($instance['categories']) ? implode($instance['categories'], ',') : "";
$count = !empty($instance['count']) ? $instance['count'] : 5;
$limit = !empty($instance['limit']) ? $instance['limit'] : 100;
$show_thumbnails = !empty($instance['show_thumbnails']) ? $instance['show_thumbnails'] : "";
$show_excerpt = !empty($instance['show_excerpt']) ? $instance['show_excerpt'] : "";
$thumb_width = !empty($instance['thumb_width']) ? $instance['thumb_width'] : 260;
$thumb_height = !empty($instance['thumb_height']) ? $instance['thumb_height'] : 260;
$comment = "";
//remove aside and quote post formats from the list
$postargs = array('orderby' => 'comment_count', 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1);
$post_query = new WP_Query($postargs);
$rt_posts = '';
if ($post_query->have_posts()) {
while ($post_query->have_posts()) {
$post_query->the_post();
$post_title = get_the_title();
$link = get_permalink();
$date = get_the_time('d M Y');
$comment_count = get_comment_count($post_query->post->ID);
$featured_image_id = get_post_thumbnail_id();
$get_the_excerpt = $show_excerpt ? '<p>' . wp_html_excerpt(get_the_excerpt(), $limit) . '...</p>' : "";
// Create thumbnail image
$thumbnail_image_output = !empty($featured_image_id) ? get_resized_image_output(array("image_url" => "", "image_id" => $featured_image_id, "w" => $thumb_width, "h" => $thumb_height, "crop" => 1, "class" => "post-thumb")) : "";
if (empty($thumbnail_image_output) || !empty($show_thumbnails)) {
$thumbnail_image_output = "";
}
if ($comment_count['approved'] > 0) {
if ($comment_count['approved'] > 1) {
$comments = $comment_count['approved'] . ' ' . __('Comments', 'rt_theme');
} else {
$comments = __('1 Comment', 'rt_theme');
}
$comment = ' | <span class="comment_number"><span class="icon-comment-empty"></span><a href="' . get_comments_link() . '" title="' . $comments . '" class="comment_link">' . $comment_count['approved'] . '</a></span>';
}
$rt_posts .= sprintf('
<div>
%1$s
<a class="title" href="%2$s" title="%3$s" rel="bookmark">%3$s</a>
<span class="meta">%4$s %6$s</span>
%5$s
</div>
', $thumbnail_image_output, $link, $post_title, get_the_date(), $get_the_excerpt, $comment);
}
wp_reset_postdata();
}
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
echo $rt_posts;
echo $after_widget;
}
开发者ID:ryan-konkolewski,项目名称:rt-theme-19-extentions-multisite,代码行数:58,代码来源:popular_posts.php
示例9: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$categories = empty($instance['categories']) ? $instance['categories'] : implode($instance['categories'], ',');
$count = empty($instance['count']) ? 5 : $instance['count'];
$limit = empty($instance['limit']) ? 100 : $instance['limit'];
$show_thumbnails = $instance['show_thumbnails'];
$show_excerpt = $instance['show_excerpt'];
$all_post_formats = $instance['all_post_formats'];
$thumb_width = empty($instance['thumb_width']) ? 50 : $instance['thumb_width'];
$thumb_height = empty($instance['thumb_height']) ? 50 : $instance['thumb_height'];
//remove aside and quote post formats from the list
$postargs = $all_post_formats ? array('orderby' => 'comment_count', 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1) : array('orderby' => 'comment_count', 'tax_query' => array(array('operator' => 'NOT IN', 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-quote', 'post-format-aside'))), 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1);
$post_query = new WP_Query($postargs);
$rt_posts = '<div class="recent_posts clearfix"><ul>';
if ($post_query->have_posts()) {
while ($post_query->have_posts()) {
$post_query->the_post();
$post_title = get_the_title();
$link = get_permalink();
$date = get_the_time('d M Y');
$comment_count = get_comment_count($post_query->post->ID);
$rt_gallery_images = get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_images", true) ? get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_images", true) : "";
$rt_gallery_image_titles = get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_titles", true) ? get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_titles", true) : "";
$rt_gallery_image_descs = get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_descs", true) ? get_post_meta($post_query->post->ID, THEMESLUG . "rt_gallery_image_descs", true) : "";
$fist_featured_image = is_array($rt_gallery_images) ? find_image_org_path($rt_gallery_images[0]) : "";
$rt_posts .= '<li class="clearfix">';
if ($fist_featured_image && !$show_thumbnails) {
$f_image = @vt_resize('', $fist_featured_image, $thumb_width, $thumb_height, true);
if ($f_image["url"]) {
$rt_posts .= '<img src="' . $f_image["url"] . '" alt="' . $title . '" class="recent-posts-thumb" />';
}
}
$rt_posts .= '<span class="date">' . $date . '</span>';
$rt_posts .= '<span class="title"><a href="' . $link . '">' . $post_title . '</a></span>';
$rt_posts .= $show_excerpt ? '' . wp_html_excerpt(get_the_excerpt(), $limit) . '...' : "";
if ($comment_count['approved'] > 0) {
if ($comment_count['approved'] > 1) {
$comments = $comment_count['approved'] . ' ' . __('Comments', 'rt_theme');
} else {
$comments = __('1 Comment', 'rt_theme');
}
$rt_posts .= ' <span class="comment_number date"><a href="' . get_comments_link() . '" title="' . $comments . '" class="comment_link">' . $comments . '</a></span>';
$rt_posts .= $show_excerpt ? '<div class="space margin-b10"></div>' : "";
}
$rt_posts .= '</li>';
}
}
wp_reset_query();
$rt_posts .= '</ul></div>';
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
echo $rt_posts;
echo $after_widget;
}
开发者ID:patrickouc,项目名称:wordpress2,代码行数:58,代码来源:popular_posts.php
示例10: tc_alter_wp_customizer_settings
function tc_alter_wp_customizer_settings($wp_customize)
{
//CHANGE BLOGNAME AND BLOGDESCRIPTION TRANSPORT
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
//IF WP VERSION >= 4.3 AND SITE_ICON SETTING EXISTS
//=> REMOVE CUSTOMIZR FAV ICON CONTROL
//=> CHANGE SITE ICON DEFAULT WP SECTION TO CUSTOMIZR LOGO SECTION
global $wp_version;
if (version_compare($wp_version, '4.3', '>=') && is_object($wp_customize->get_control('site_icon'))) {
$tc_option_group = TC___::$tc_option_group;
$wp_customize->remove_control("{$tc_option_group}[tc_fav_upload]");
//note : the setting is kept because used in the customizer js api to handle the transition between Customizr favicon to WP site icon.
$wp_customize->get_control('site_icon')->section = 'logo_sec';
//add a favicon title after the logo upload
add_action('__after_setting_control', array($this, 'tc_add_favicon_title'));
}
//end ALTER SITE ICON
//CHANGE MENUS PROPERTIES
$locations = get_registered_nav_menus();
$menus = wp_get_nav_menus();
$choices = array('' => __('— Select —', 'customizr'));
foreach ($menus as $menu) {
$choices[$menu->term_id] = wp_html_excerpt($menu->name, 40, '…');
}
$_priorities = array('main' => 10, 'secondary' => 20);
//WP only adds the menu(s) settings and controls if the user has created at least one menu.
//1) if no menus yet, we still want to display the menu picker + add a notice with a link to the admin menu creation panel
//=> add_setting and add_control for each menu location. Check if they are set first by security
//2) if user has already created a menu, the settings are already created, we just need to update the controls.
$_priority = 0;
//assign new priorities to the menus controls
foreach ($locations as $location => $description) {
$menu_setting_id = "nav_menu_locations[{$location}]";
//create the settings if they don't exist
//=> in the condition, make sure that the setting has really not been created yet (maybe over secured)
if (!$menus && !is_object($wp_customize->get_setting($menu_setting_id))) {
$wp_customize->add_setting($menu_setting_id, array('sanitize_callback' => 'absint', 'theme_supports' => 'menus'));
}
//remove the controls if they exists
if (is_object($wp_customize->get_control($menu_setting_id))) {
$wp_customize->remove_control($menu_setting_id);
}
//replace the controls by our custom controls
$_control_properties = array('label' => $description, 'section' => 'nav', 'title' => "main" == $location ? __('Assign menus to locations', 'customizr') : false, 'type' => 'select', 'choices' => $choices, 'priority' => isset($_priorities[$location]) ? $_priorities[$location] : $_priority);
//add a notice property if no menu created yet.
if (!$menus) {
//adapt the nav section description for v4.3 (menu in the customizer from now on)
$_create_menu_link = version_compare($GLOBALS['wp_version'], '4.3', '<') ? admin_url('nav-menus.php') : "javascript:wp.customize.section('nav').container.find('.customize-section-back').trigger('click'); wp.customize.panel('nav_menus').focus();";
$_control_properties['notice'] = sprintf(__("You haven't created any menu yet. %s or check the %s to learn more about menus.", "customizr"), sprintf('<strong><a href="%1$s" title="%2$s">%2$s</a></strong>', $_create_menu_link, __("Create a new menu now", "customizr")), sprintf('<a href="%1$s" title="%2$s" target="_blank">%2$s</a>', esc_url('codex.wordpress.org/WordPress_Menu_User_Guide'), __("WordPress documentation", "customizr")));
}
$wp_customize->add_control(new TC_controls($wp_customize, $menu_setting_id, $_control_properties));
$_priority = $_priority + 10;
}
//foreach
}
开发者ID:mightyx,项目名称:customizr,代码行数:56,代码来源:class-admin-customize.php
示例11: _ga_adjust_admin_bar_site_menu
function _ga_adjust_admin_bar_site_menu($admin_bar)
{
if (!is_user_logged_in() || !current_user_can('manage_global')) {
return;
}
$blogname = sprintf(__('Global Admin: %s'), esc_html(get_global_option('global_name')));
$title = wp_html_excerpt($blogname, 40, '…');
$admin_bar->add_menu(array('id' => 'site-name', 'title' => $title, 'href' => home_url('/')));
$admin_bar->add_menu(array('parent' => 'site-name', 'id' => 'view-site', 'title' => __('Visit Site'), 'href' => home_url('/')));
}
开发者ID:felixarntz,项目名称:global-admin,代码行数:10,代码来源:admin-bar.php
示例12: planar_dashboard_rss_box
function planar_dashboard_rss_box()
{
// Get RSS Feed(s)
include_once ABSPATH . WPINC . '/feed.php';
// Feeds list (add your own RSS feeds urls)
$my_feeds = array(esc_url('http://www.dinevthemes.com/feed/'));
// Loop through Feeds
foreach ($my_feeds as $feed) {
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed($feed);
if (!is_wp_error($rss)) {
// Checks that the object is created correctly
// Figure out how many total items there are, and choose a limit
$maxitems = $rss->get_item_quantity(4);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
// Get RSS title
$rss_title = '<a class="rsswidget" href="' . $rss->get_permalink() . '" target="_blank">' . strtoupper($rss->get_title()) . '</a>';
}
// Display the container
echo '<div class="rss-widget">';
// Starts items listing within <ul> tag
echo '<ul>';
// Check items
if ($maxitems == 0) {
echo '<li>' . __('No items', 'planar') . '.</li>';
} else {
// Loop through each feed item and display each item as a hyperlink.
foreach ($rss_items as $item) {
$item_date = human_time_diff($item->get_date('U'), current_time('timestamp')) . ' ' . __('ago', 'rc_mdm');
// Start displaying item content within a <li> tag
echo '<li style="margin-bottom:15px;">';
// create item link
echo '<a class="rsswidget" style="font-weight:400;" href="' . esc_url($item->get_permalink()) . '" title="' . esc_html($item->get_title()) . '">';
// Get item title
echo esc_html($item->get_title());
echo '</a>';
// Display date
echo ' <span class="rss-date">' . $item_date . '</span><br />';
// Get item content
$content = $item->get_content();
// Shorten content
$content = '<div class="rssSummary">' . wp_html_excerpt($content, 140) . ' [...]</div>';
// Display content
echo $content;
// End <li> tag
echo '</li>';
}
}
// End <ul> tag
echo '</ul><div style="margin-top:20px;padding-top:10px;border-top:1px solid #eee;">Feed from <a href="' . esc_url('http://www.dinevthemes.com') . '">dinevthemes.com</a></div></div>';
}
// End foreach feed
}
开发者ID:raineorshine,项目名称:iccs-planar-theme,代码行数:54,代码来源:dashboard-feed.php
示例13: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$categories = empty($instance['categories']) ? $instance['categories'] : implode($instance['categories'], ',');
$count = empty($instance['count']) ? 5 : $instance['count'];
$limit = empty($instance['limit']) ? 100 : $instance['limit'];
$show_thumbnails = $instance['show_thumbnails'];
$show_excerpt = $instance['show_excerpt'];
$thumb_width = empty($instance['thumb_width']) ? 50 : $instance['thumb_width'];
$thumb_height = empty($instance['thumb_height']) ? 50 : $instance['thumb_height'];
$comment = "";
//remove aside and quote post formats from the list
$postargs = array('orderby' => 'comment_count', 'post_type' => 'post', 'showposts' => $count, 'cat' => $categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1);
$post_query = new WP_Query($postargs);
$rt_posts = '<div class="recent_posts clearfix"><ul>';
if ($post_query->have_posts()) {
while ($post_query->have_posts()) {
$post_query->the_post();
$post_title = get_the_title();
$link = get_permalink();
$date = get_the_time('d M Y');
$comment_count = get_comment_count($post_query->post->ID);
$featured_image_id = get_post_thumbnail_id();
// Create thumbnail image
$thumbnail_image_output = !empty($featured_image_id) ? get_resized_image_output(array("image_url" => "", "image_id" => $featured_image_id, "w" => $thumb_width, "h" => $thumb_height, "crop" => 1, "class" => "recent-posts-thumb")) : "";
$rt_posts .= '<li class="clearfix">';
if ($thumbnail_image_output && !$show_thumbnails) {
$rt_posts .= $thumbnail_image_output;
}
if ($comment_count['approved'] > 0) {
if ($comment_count['approved'] > 1) {
$comments = $comment_count['approved'] . ' ' . __('Comments', 'rt_theme');
} else {
$comments = __('1 Comment', 'rt_theme');
}
$comment = ' <span class="comment_number"><span class="icon-comment-empty"></span><a href="' . get_comments_link() . '" title="' . $comments . '" class="comment_link">' . $comment_count['approved'] . '</a></span>';
}
$rt_posts .= '<span class="title"><a href="' . $link . '">' . $post_title . '</a></span>';
$rt_posts .= '<div class="widget-meta"><span class="date">' . $date . '</span> ' . $comment . '</div>';
$rt_posts .= $show_excerpt ? '' . wp_html_excerpt(get_the_excerpt(), $limit) . '...' . '<div class="space margin-b10"></div>' : "";
$rt_posts .= '</li>';
}
}
wp_reset_query();
$rt_posts .= '</ul></div>';
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
echo $rt_posts;
echo $after_widget;
}
开发者ID:nikolaev-k,项目名称:alwadi,代码行数:53,代码来源:popular_posts.php
示例14: lbmn_get_menuid_by_menutitle
function lbmn_get_menuid_by_menutitle($menu_name)
{
$menus = wp_get_nav_menus();
// get all menus
$menu_id = 0;
foreach ($menus as $menu) {
$current_menu_name = wp_html_excerpt($menu->name, 40, '…');
if ($menu_name == $current_menu_name) {
$menu_id = $menu->term_id;
}
}
return $menu_id;
}
开发者ID:shimion,项目名称:localinsurance-theme,代码行数:13,代码来源:functions-extras.php
示例15: sys_popular_posts
function sys_popular_posts($atts, $content = null)
{
extract(shortcode_atts(array('limit' => '2', 'description' => '40', 'thumb' => 'true', 'popular_select' => 'time'), $atts));
$out = '<div class="widget_postslist sc">';
$out .= '<ul>';
global $wpdb;
$popular_limits = $limit;
$show_pass_post = false;
$duration = '';
$request = "SELECT ID, post_title,post_date,post_content, COUNT({$wpdb->comments}.comment_post_ID) AS 'comment_count' FROM {$wpdb->posts}, {$wpdb->comments}";
$request .= " WHERE comment_approved = '1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID AND post_status = 'publish'";
if (!$show_pass_post) {
$request .= " AND post_password =''";
}
if ($duration != "") {
$request .= " AND DATE_SUB(CURDATE(),INTERVAL " . $duration . " DAY) < post_date ";
}
$request .= " GROUP BY {$wpdb->comments}.comment_post_ID ORDER BY comment_count DESC LIMIT {$popular_limits}";
$popular_posts = $wpdb->get_results($request);
foreach ($popular_posts as $post) {
if ($post) {
$post_date = $post->post_date;
$post_date = mysql2date('F j, Y', $post_date, false);
$out .= "<li>";
if ($thumb == "true") {
$thumbid = get_post_thumbnail_id($post->ID);
$imgesc = wp_get_attachment_image_src($thumbid, array(9999, 9999));
$out .= '<div class="thumb"><a href="' . get_permalink($post->ID) . '" title="' . $post->post_title . '">';
if ($thumbid) {
$out .= atp_resize('', $imgesc['0'], '50', '50', 'imgborder', '');
} else {
//$out .= '<img class="imgborder" src="'. THEME_URI.'/images/no-image.jpg" title="'.$post->post_title.'" alt="" />';
}
$out .= '</a></div>';
}
$out .= '<div class="pdesc"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . $post->post_title . '</a>';
if ($popular_select == 'time') {
$out .= '<div class="w-postmeta"><span>' . $post_date . '</span></div>';
} else {
$out .= '<p>' . wp_html_excerpt($post->post_content, $description, '...') . '</p>';
}
$out .= '</div></li>';
}
}
$out .= '</ul></div>';
return $out;
wp_reset_query();
}
开发者ID:pryspry,项目名称:MusicPlay,代码行数:48,代码来源:popularposts.php
示例16: xtreme_dashboard_rss_widget
function xtreme_dashboard_rss_widget()
{
$url = 'https://github.com/xtreme-themes/xtreme-one/releases.atom';
$news = fetch_feed($url);
if (is_wp_error($news)) {
if (is_admin() || current_user_can('manage_options')) {
echo '<p>';
printf(__('<strong>RSS Error</strong>: %s', XF_TEXTDOMAIN), $news->get_error_message());
echo '</p>';
}
return;
}
if (!$news->get_item_quantity()) {
echo '<p>' . __('An error has occurred; the feed is probably down. Try again later.', XF_TEXTDOMAIN) . '</p>';
return;
}
echo '<ul>';
foreach ($news->get_items(0, 5) as $item) {
$link = $item->get_link();
while (stristr($link, 'http') != $link) {
$link = substr($link, 1);
}
$link = esc_url(strip_tags($link));
$title = esc_attr(strip_tags($item->get_title()));
if (empty($title)) {
$title = __('Untitled', XF_TEXTDOMAIN);
}
$desc = str_replace(array("\n", "\r"), ' ', esc_attr(strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset')))));
$desc = wp_html_excerpt($desc, 360) . ' […]';
$desc = esc_html($desc);
$summary = "<div class='rssSummary'>{$desc}</div>";
$date = $item->get_date();
if ($date) {
if ($date_stamp = strtotime($date)) {
$date = ' <span class="rss-date">' . date_i18n(get_option('date_format'), $date_stamp) . '</span>';
} else {
$date = '';
}
}
if ($link == '') {
echo "<li>{$title}{$date}{$summary}{$author}</li>";
} else {
echo "<li><a class='rsswidget' href='{$link}' title='{$desc}'>{$title}</a>{$date}{$summary}</li>";
}
}
echo '</ul>';
}
开发者ID:katikos,项目名称:xtreme-one,代码行数:47,代码来源:xtreme-admin-functions.php
示例17: widget
function widget($args, $instance)
{
extract($args);
$title = esc_attr($instance['title']);
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
?>
<?php
$comments = get_comments('status=approve&number=1');
?>
<?php
foreach ($comments as $comment) {
?>
<?php
$title = get_the_title($comment->comment_post_ID);
echo '<div class="whosaid"><p>Recently ' . $comment->comment_author . '';
_e(' said: ', 'cebolang');
?>
</p><span class="icon-right-quote" aria-hidden="true"></span></div><p class="quoter"> "<?php
echo wp_html_excerpt($comment->comment_content, 112);
?>
…"</p>
<div class="saidmore"><p><a href="<?php
echo get_permalink($comment->comment_post_ID);
?>
"
rel="external nofollow" title="<?php
echo $title;
?>
"><?php
_e('Read The Post ', 'cebolang');
?>
</a></p></div>
<?php
}
?>
<?php
echo $after_widget;
}
开发者ID:Vinnica,项目名称:theboxerboston.com,代码行数:47,代码来源:widgets.php
示例18: tc_alter_wp_customizer_settings
function tc_alter_wp_customizer_settings($wp_customize)
{
//CHANGE BLOGNAME AND BLOGDESCRIPTION TRANSPORT
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
//CHANGE NAV SECTION DESCRIPTION
$_complement_descr = sprintf(' <a class="button-primary" href="%2$s" target="_blank">%3$s</a><p>%1$s</p>', __('If a location nas no menu assigned, a default page menu will be used.', 'customizr'), admin_url('nav-menus.php'), __('Manage menus', 'customizr'));
$wp_customize->get_section('nav')->description .= $_complement_descr;
//CHANGE MENUS PROPERTIES
$locations = get_registered_nav_menus();
|
请发表评论