📄 wp_recent_posts.php
字号:
<?phpif( ! defined( 'WP_RECENT_POSTS_INCLUDED' ) ) { define( 'WP_RECENT_POSTS_INCLUDED' , 1 ) ; function b_wp_recent_posts_edit($options) { global $wpdb, $siteurl, $use_cache; $form = "<table width='100%'>"; $form .= "<tr><td width='40%'>显示数目:</td>"; $form .= "<td><input type='text' name='options[]' value='".$options[0]."' /></td></tr>"; $form .= "<tr><td>显示发表日期:</td>"; $chk = ( $options[1] == 1 ) ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[1]' value='1'".$chk." /> "._YES." "; $chk = ( $options[1] == 0 ) ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[1]' value='0'".$chk." /> "._NO."</td></tr>"; $form .= "<tr><td>显示RSS图标:</td>"; $chk = ( $options[2] == 1 ) ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[2]' value='1'".$chk." /> "._YES." "; $chk = ( $options[2] == 0 ) ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[2]' value='0'".$chk." /> "._NO."</td></tr>"; $form .= "<tr><td>显示RDF图标:</td>"; $chk = ( $options[3] == 1 ) ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[3]' value='1'".$chk." /> "._YES." "; $chk = ( $options[3] == 0 ) ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[3]' value='0'".$chk." /> "._NO."</td></tr>"; $form .= "<tr><td>显示RSS2图标:</td>"; $chk = ( $options[4] == 1 ) ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[4]' value='1'".$chk." /> "._YES." "; $chk = ( $options[4] == 0 ) ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[4]' value='0'".$chk." /> "._NO."</td></tr>"; $form .= "<tr><td>显示ATOM图标:</td>"; $chk = ( $options[5] == 1 ) ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[5]' value='1'".$chk." /> "._YES." "; $chk = ( $options[5] == 0 ) ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[5]' value='0'".$chk." /> "._NO."</td></tr>"; $form .= "<tr><td>Meta Feed(RSS,RDF,ATOM)中日志数目:</td>"; $form .= "<td><input type='text' name='options[6]' value='".$options[6]."' /></td></tr>"; $form .= "<tr><td>只显示下列类别中的日志:</td><td>"; require(dirname(__FILE__).'/../wp-config.php'); $cat = $options[7]; ob_start(); dropdown_cats(1,_WP_LIST_CAT_ALL,'ID','asc',0,0,0,FALSE,$options[7]); $list_str = ob_get_contents(); ob_end_clean(); $select_str = '<select name="options[7]">'; $form .= ereg_replace('\<select name\=[^\>]*\>',$select_str,$list_str); $form .= "</td></tr>"; $form .= "<tr><td>显示'新'标志:</td>"; $chk = ( $options[8] == 1 ) ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[8]' value='1'".$chk." /> "._YES." "; $chk = ( $options[8] == 0 ) ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[8]' value='0'".$chk." /> "._NO."</td></tr>"; $form .= "</table>"; return $form; } function b_wp_recent_posts_show($options) { $no_posts = (empty($options[0]))? 10 : $options[0]; $cat_date = (empty($options[1]))? 0 : $options[1]; $show_rss_icon = (empty($options[2]))? 0 : $options[2]; $show_rdf_icon = (empty($options[3]))? 0 : $options[3]; $show_rss2_icon = (empty($options[4]))? 0 : $options[4]; $show_atom_icon = (empty($options[5]))? 0 : $options[5]; $rss_num = (empty($options[6]))? "" : $options[6]; $category = (empty($options[7]))? "all" : $options[7]; $new_flg = (empty($options[8]))? 0 : $options[8]; global $xoopsDB; global $wpdb, $siteurl, $use_cache; $id=1; $use_cache = 1; require(dirname(__FILE__).'/../wp-config.php'); if ((empty($category)) || ($category == 'all') || ($category == '0')) { $whichcat=''; $join = ''; $cat_param =''; } else { $join = " LEFT JOIN {$wpdb->post2cat} ON ({$wpdb->posts}.ID = {$wpdb->post2cat}.post_id) "; $whichcat = ' AND (category_id = '.$category.')'; $cat_param = 'cat='.$category; } $now = date('Y-m-d H:i:s',(time() + (get_settings('time_difference') * 3600))); $request = "SELECT * FROM ".$xoopsDB->prefix("wp_posts").$join." WHERE post_status = 'publish' "; $request .= " AND post_date <= '".$now."'". $whichcat; $request .= " ORDER BY post_date DESC LIMIT 0, $no_posts"; $lposts = $wpdb->get_results($request); $date = ""; $pdate = ""; ob_start(); block_style_get(); $output = ob_get_contents(); ob_end_clean(); $output .= "<div id='wpRecentPost'>"; if ($lposts) { if (!$cat_date) { $output .= "<ul class='wpBlockList'>\n"; } else { $output .= "<ul class='wpBlockDateList'>\n"; } foreach ($lposts as $lpost) { if ($cat_date) { $date=mysql2date("Y-n-j", $lpost->post_date); if ($date <> $pdate) { if ($pdate <> "") { $output .= "</ul>\n"; } $output .= "<li><span id=\"postDate\">".$date."</span></li>\n<ul class=\"children\">\n"; $pdate = $date; } } $newstr = ""; if ($new_flg) { $m = $lpost->post_date; $elapse = time() + get_settings('time_difference') * 3600 - mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4)); if ($elapse < 1*60*60*24 ) { $newstr = ' <span class="new1">新!</span>'; } else if ($elapse < 7*60*60*24) { $newstr = ' <span class="new2">新</span>'; } else { $newstr = ''; } } $post_title = stripslashes($lpost->post_title); if (trim($post_title)=="") $post_title = _WP_POST_NOTITLE; $permalink = get_permalink($lpost->ID); $output .= '<li><span class="post-title"><a href="' . $permalink . '" rel="bookmark" title="Permanent Link: ' . $post_title . '">' . $post_title . '</a></span>'.$newstr.'<br />'; $output .= "</li>\n"; } $output .= "</ul>\n"; } if ($show_rss_icon || $show_rdf_icon || $show_rss2_icon || $show_atom_icon) { $output .= '<hr width="100%" />'; } $feed_param = $rss_num ? "?num=".$rss_num : ""; if ($feed_param != "") { $feed_param .= $cat_param ? "&".$cat_param : ""; } else { $feed_param = $cat_param ? "?".$cat_param : ""; } if ($show_rss_icon) { $output .= '<div style="text-align:right"> <a href="'.get_bloginfo('rss_url').$feed_param.'"><img src="'.XOOPS_URL.'/modules/wordpress/wp-images/rss-092.png" /></a></div>'; } if ($show_rdf_icon) { $output .= '<div style="text-align:right"> <a href="'.get_bloginfo('rdf_url').$feed_param.'"><img src="'.XOOPS_URL.'/modules/wordpress/wp-images/rdf-1.png" /></a></div>'; } if ($show_rss2_icon) { $output .= '<div style="text-align:right"> <a href="'.get_bloginfo('rss2_url').$feed_param.'"><img src="'.XOOPS_URL.'/modules/wordpress/wp-images/rss-2.png" /></a></div>'; } if ($show_atom_icon) { $output .= '<div style="text-align:right"> <a href="'.get_bloginfo('atom_url').$feed_param.'"><img src="'.XOOPS_URL.'/modules/wordpress/wp-images/atom-03.png" /></a></div>'; } $output .= "</div>"; $block['content'] = $output; return $block; }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -