本文整理汇总了PHP中wp_siteurl函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_siteurl函数的具体用法?PHP wp_siteurl怎么用?PHP wp_siteurl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_siteurl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _b_wp_archives_monthly_show
function _b_wp_archives_monthly_show($options, $wp_num = '')
{
$block_style = $options[0] ? $options[0] : 0;
$with_count = $options[1] == 0 ? false : true;
$tpl_file = empty($options[2]) ? 'wp_archives_monthly.html' : $options[2];
$sel_value = '';
if (current_wp()) {
if (!empty($_SERVER['PATH_INFO'])) {
permlink_to_param();
}
init_param('GET', 'm', 'string', '');
init_param('GET', 'year', 'integer', '');
init_param('GET', 'monthnum', 'integer', '');
init_param('GET', 'day', 'integer', '');
if (strlen(get_param('m')) == 6) {
$sel_value = get_param('m');
} else {
if (test_param('year') && test_param('monthnum') && !test_param('day')) {
$sel_value = get_param('year') . zeroise(get_param('monthnum'), 2);
}
}
}
$block['wp_num'] = $wp_num;
$block['divid'] = 'wpArchive' . $wp_num;
$block['siteurl'] = wp_siteurl();
$block['style'] = block_style_get(false);
$block['block_style'] = $block_style;
$block['with_count'] = $with_count;
$now = current_time('mysql');
$postHandler =& wp_handler('Post');
$criteria =& new CriteriaCompo(new Criteria('post_date', $now, '<'));
$criteria->add(new Criteria('post_status', 'publish'));
$criteria->setSort('post_date');
$criteria->setOrder('DESC');
$criteria->setGroupby('YEAR(post_date), MONTH(post_date)');
$postObjects =& $postHandler->getObjects($criteria, false, 'DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts');
$block['records'] = array();
if ($postObjects) {
foreach ($postObjects as $postObject) {
$this_year = $postObject->getExtraVar('year');
$this_month = $postObject->getExtraVar('month');
$_record['url'] = get_month_link($this_year, $this_month);
$_record['text'] = format_month($this_year, $GLOBALS['month'][zeroise($this_month, 2)]);
if ($with_count) {
$_record['count'] = ' (' . $postObject->getExtraVar('posts') . ')';
} else {
$_record['count'] = '';
}
$_record['select'] = $sel_value == $this_year . zeroise($this_month, 2) ? 'selected="selected"' : '';
$block['records'][] = $_record;
}
}
$_wpTpl =& new WordPresTpl('theme');
$_wpTpl->assign('block', $block);
if (!$_wpTpl->tpl_exists($tpl_file)) {
$tpl_file = 'wp_archives_monthly.html';
}
$block['content'] = $_wpTpl->fetch($tpl_file);
return $block;
}
示例2: b_wp_authors_show
function b_wp_authors_show($options, $wp_num = "")
{
$with_count = empty($options[0]) ? 0 : $options[0];
$idmode = empty($options[1]) ? '' : $options[1];
$show_rss2_icon = empty($options[2]) ? 0 : $options[2];
$id = 1;
$GLOBALS['use_cache'] = 1;
if ($wp_num == "") {
$GLOBALS['wp_id'] = $wp_num;
$GLOBALS['wp_inblock'] = 1;
require dirname(__FILE__) . '/../wp-config.php';
$GLOBALS['wp_inblock'] = 0;
}
$optioncount = $with_count == 1;
$exclude_admin = false;
$show_fullname = false;
$hide_empty = true;
$feed = $show_rss2_icon == 1 ? 'rss2' : '';
$feed_image = $show_rss2_icon == 1 ? wp_siteurl() . '/wp-images/rss-mini.gif' : '';
ob_start();
block_style_get($wp_num);
echo "<ul class='wpBlockList'>\n";
list_authors2($optioncount, $exclude_admin, $idmode, $hide_empty, $feed, $feed_image);
echo "</ul>\n";
$block['content'] = ob_get_contents();
ob_end_clean();
return $block;
}
示例3: _b_wp_search_show
function _b_wp_search_show($option, $wp_num = "")
{
$block['wp_num'] = $wp_num;
$block['divid'] = 'wpSearch' . $wp_num;
$block['style'] = block_style_get(false);
$block['act_url'] = wp_siteurl() . '/';
$_wpTpl =& new WordPresTpl('theme');
$_wpTpl->assign('block', $block);
$block['content'] = $_wpTpl->fetch('wp_search.html');
return $block;
}
示例4: _b_wp_search_show
function _b_wp_search_show($option, $wp_num = "")
{
$act_url = wp_siteurl() . '/';
$block['content'] = <<<EOD
\t\t<form name="searchform{$wp_num}" id="searchform{$wp_num}" method="get" action="{$act_url}">
\t\t<div>
\t\t\t<input type="text" name="s" size="12" /> <input type="submit" name="submit" value="search" />
\t\t</div>
\t\t</form>
EOD;
return $block;
}
示例5: _b_wp_categories_show
function _b_wp_categories_show($options, $wp_num = "")
{
$block_style = $options[0] ? $options[0] : 0;
$with_count = $options[1] ? $options[1] : 0;
$sorting_key = $options[2] ? $options[2] : 'name';
$sorting_order = $options[3] ? $options[3] : 'asc';
if (current_wp()) {
if (!empty($_SERVER['PATH_INFO'])) {
permlink_to_param();
}
init_param('GET', 'cat', 'string', '');
init_param('GET', 'category_name', 'string', '');
if (!empty($GLOBALS['category_name']) && empty($GLOBALS['cat'])) {
if (stristr($GLOBALS['category_name'], '/')) {
$GLOBALS['category_name'] = explode('/', $GLOBALS['category_name']);
if ($GLOBALS['category_name'][count($GLOBALS['category_name']) - 1]) {
$GLOBALS['category_name'] = $GLOBALS['category_name'][count($GLOBALS['category_name']) - 1];
// no trailing slash
} else {
$GLOBALS['category_name'] = $GLOBALS['category_name'][count($GLOBALS['category_name']) - 2];
// there was a trailling slash
}
}
$categoryHandler =& wp_handler('Category');
$categoryObject =& $categoryHandler->getByNiceName($GLOBALS['category_name']);
if ($categoryObject) {
$GLOBALS['cat'] = $categoryObject->getVar('cat_ID');
}
}
} else {
$GLOBALS['cat'] = '';
}
$block['wp_num'] = $wp_num;
$block['divid'] = 'wpCategory' . $wp_num;
$block['siteurl'] = wp_siteurl();
$block['style'] = block_style_get(false);
$block['block_style'] = $block_style;
$block['with_count'] = $with_count;
if ($block_style == 0) {
$cat_block = _b_wp_categories_list($sorting_key, $sorting_order, $with_count, 0, null, true);
} else {
$cat_block = _b_wp_categories_list($sorting_key, $sorting_order, $with_count, 0, null, false, '–', 0, $GLOBALS['cat']);
}
$block['records'] = $cat_block['records'];
$_wpTpl =& new WordPresTpl('theme');
$_wpTpl->assign('block', $block);
$block['content'] = $_wpTpl->fetch('wp_categories.html');
return $block;
}
示例6: wp_xoops_search
function wp_xoops_search($queryarray, $andor, $limit, $offset, $userid, $wp_num = "")
{
$GLOBALS['use_cache'] = 1;
if ($wp_num == "") {
$GLOBALS['wp_id'] = $wp_num;
$GLOBALS['wp_inblock'] = 1;
require XOOPS_ROOT_PATH . "/modules/wordpress/wp-config.php";
$GLOBALS['wp_inblock'] = 0;
}
$now = date('Y-m-d H:i:s', time() + get_settings('time_difference') * 3600);
$where = "(post_status = 'publish') AND (post_date <= '" . $now . "')";
if (is_array($queryarray) && ($count = count($queryarray))) {
$where .= " AND ((post_title LIKE '%{$queryarray['0']}%' OR post_content LIKE '%{$queryarray['0']}%')";
for ($i = 1; $i < $count; $i++) {
$where .= " {$andor} ";
$where .= "(post_title LIKE '%{$queryarray[$i]}%' OR post_content LIKE '%{$queryarray[$i]}%')";
}
$where .= ") ";
}
if ($userid) {
$userid = intval($userid);
$where .= " AND (post_author=" . $userid . ")";
}
$request = "SELECT * FROM " . wp_table('posts') . " WHERE " . $where;
$request .= " ORDER BY post_date DESC";
$result = $GLOBALS['xoopsDB']->query($request, $limit, $offset);
$ret = array();
$i = 0;
while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) {
$ret[$i]['link'] = str_replace(wp_siteurl() . "/", "", get_permalink($myrow['ID']));
$ret[$i]['title'] = htmlspecialchars($myrow['post_title'], ENT_QUOTES);
$ret[$i]['image'] = "wp-images/search.png";
$date_str = $myrow['post_date'];
$yyyy = substr($date_str, 0, 4);
$mm = substr($date_str, 5, 2);
$dd = substr($date_str, 8, 2);
$hh = substr($date_str, 11, 2);
$nn = substr($date_str, 15, 2);
$ss = substr($date_str, 17, 2);
$ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy);
$ret[$i]['uid'] = $myrow['post_author'];
$ret[$i]['page'] = $myrow['post_title'];
if (!empty($myrow['post_content']) && function_exists('xoops_make_context')) {
$ret[$i]['context'] = xoops_make_context(strip_tags($myrow['post_content']), $queryarray);
}
$i++;
}
return $ret;
}
示例7: _wp_xoops_search
function _wp_xoops_search($queryarray, $andor, $limit, $offset, $userid)
{
$now = current_time('mysql');
$where = '(post_status = \'publish\') AND (post_date <= \'' . $now . '\')';
if (is_array($queryarray) && ($count = count($queryarray))) {
$where .= " AND ((post_title LIKE '%{$queryarray['0']}%' OR post_content LIKE '%{$queryarray['0']}%')";
for ($i = 1; $i < $count; $i++) {
$where .= " {$andor} ";
$where .= "(post_title LIKE '%{$queryarray[$i]}%' OR post_content LIKE '%{$queryarray[$i]}%')";
}
$where .= ') ';
}
if ($userid) {
$userid = intval($userid);
$where .= ' AND (post_author=' . $userid . ')';
}
$request = 'SELECT * FROM ' . wp_table('posts') . ' WHERE ' . $where;
$request .= ' ORDER BY post_date DESC';
$result = $GLOBALS['xoopsDB']->query($request, $limit, $offset);
$ret = array();
$i = 0;
while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) {
$ret[$i]['link'] = str_replace(wp_siteurl() . '/', '', get_permalink($myrow['ID']));
$ret[$i]['title'] = htmlspecialchars($myrow['post_title'], ENT_QUOTES);
$ret[$i]['image'] = 'wp-images/search.png';
$date_str = $myrow['post_date'];
$yyyy = substr($date_str, 0, 4);
$mm = substr($date_str, 5, 2);
$dd = substr($date_str, 8, 2);
$hh = substr($date_str, 11, 2);
$nn = substr($date_str, 15, 2);
$ss = substr($date_str, 17, 2);
$ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy);
$ret[$i]['uid'] = $myrow['post_author'];
$ret[$i]['page'] = $myrow['post_title'];
if (!empty($myrow['post_content']) && function_exists('xoops_make_context')) {
$ret[$i]['context'] = xoops_make_context(strip_tags($myrow['post_content']), $queryarray);
}
if (!empty($myrow['post_content']) && function_exists('search_make_context')) {
if (!empty($_GET['showcontext']) && $_GET['showcontext'] == 1) {
$ret[$i]['context'] = search_make_context(strip_tags($myrow['post_content']), $queryarray);
}
}
$i++;
}
return $ret;
}
示例8: _b_wp_authors_show
function _b_wp_authors_show($options, $wp_num = "")
{
$with_count = empty($options[0]) ? 0 : $options[0];
$idmode = empty($options[1]) ? '' : $options[1];
$show_rss2_icon = empty($options[2]) ? 0 : $options[2];
$optioncount = $with_count == 1;
$exclude_admin = false;
$show_fullname = false;
$hide_empty = true;
$feed = $show_rss2_icon == 1 ? 'rss2' : '';
$feed_image = $show_rss2_icon == 1 ? wp_siteurl() . '/wp-images/rss-mini.gif' : '';
ob_start();
block_style_get();
echo "<ul class='wpBlockList'>\n";
list_authors2($optioncount, $exclude_admin, $idmode, $hide_empty, $feed, $feed_image);
echo "</ul>\n";
$block['content'] = ob_get_contents();
ob_end_clean();
return $block;
}
示例9: _b_wp_authors_show
function _b_wp_authors_show($options, $wp_num = "")
{
$with_count = empty($options[0]) ? 0 : $options[0];
$idmode = empty($options[1]) ? '' : $options[1];
$show_rss2_icon = empty($options[2]) ? 0 : $options[2];
$optioncount = $with_count == 1;
$exclude_admin = false;
$show_fullname = false;
$hide_empty = true;
$feed = $show_rss2_icon == 1 ? 'rss2' : '';
$feed_image = $show_rss2_icon == 1 ? wp_siteurl() . '/wp-images/rss-mini.gif' : '';
$block['wp_num'] = $wp_num;
$block['divid'] = 'wpAuthor' . $wp_num;
$block['style'] = block_style_get(false);
$block['authors'] = list_authors2($optioncount, $exclude_admin, $idmode, $hide_empty, $feed, $feed_image, false);
$_wpTpl =& new WordPresTpl('theme');
$_wpTpl->assign('block', $block);
$block['content'] = $_wpTpl->fetch('wp_authors.html');
return $block;
}
示例10: _b_wp_archives_monthly_show
function _b_wp_archives_monthly_show($options, $wp_num = '')
{
$block_style = $options[0] ? $options[0] : 0;
$with_count = $options[1] == 0 ? false : true;
$sel_value = '';
if (current_wp()) {
if (!empty($_SERVER['PATH_INFO'])) {
permlink_to_param();
}
init_param('GET', 'm', 'string', '');
init_param('GET', 'year', 'integer', '');
init_param('GET', 'monthnum', 'integer', '');
if (strlen(get_param('m')) == 6) {
$sel_value = get_param('m');
} else {
if (test_param('year') && test_param('monthnum')) {
$sel_value = get_param('year') . zeroise(get_param('monthnum'), 2);
}
}
}
ob_start();
block_style_get($wp_num);
if ($block_style == 0) {
// Simple Listing
echo '<ul class="wpBlockList">' . "\n";
get_archives('monthly', '', 'html', '', '', $with_count);
echo '</ul>' . "\n";
} else {
// Dropdown Listing
echo '<form name="archiveform' . $wp_num . '" id="archiveform' . $wp_num . '" action="#">';
echo '<select name="archive_chrono" onchange="window.location = (document.forms.archiveform' . $wp_num . '.archive_chrono[document.forms.archiveform' . $wp_num . '.archive_chrono.selectedIndex].value);"> ';
echo '<option value="' . wp_siteurl() . '">' . _WP_BY_MONTHLY . '</option>';
get_archives('monthly', '', 'option', '', '', $with_count, $sel_value);
echo '</select>';
echo '</form>';
}
$block['content'] = ob_get_contents();
ob_end_clean();
return $block;
}
示例11: add_referer
function add_referer()
{
if (!empty($GLOBALS['single'])) {
if (isset($_SERVER['HTTP_REFERER'])) {
$url = $_SERVER['HTTP_REFERER'];
if (not_excluded($url)) {
require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
$snoopy = new Snoopy();
if ($snoopy->fetch($url)) {
$page = $snoopy->results;
$matched = false;
$page = mb_conv($page, $GLOBALS['blog_charset'], 'auto');
if (preg_match_all('/<a\\s[^>]*?href=[\\"\']([^\\"\']*?)[\\"\'][^>]*>/', $page, $matches, PREG_PATTERN_ORDER)) {
foreach ($matches[1] as $match) {
if (strstr($match, wp_siteurl())) {
$matched = true;
}
}
}
if (!$matched) {
return;
}
preg_match('/<title>(.+)<\\/title>/is', $page, $title);
$title = $title[1];
if (!$title) {
preg_match('/^(http:\\/\\/)?([^\\/]+)/i', $url, $matches);
$host = $matches[2];
preg_match('/[^\\.\\/]+\\.[^\\.\\/]+$/', $host, $matches);
$title = $matches[0];
}
$new_entry = addslashes($title . ":!-!:" . $url);
add_post_meta($GLOBALS['wp_post_id'], 'wp-refer', $new_entry);
$GLOBALS['post_meta_cache'][wp_id()][$GLOBALS['wp_post_id']]['wp-refer'][] = $new_entry;
}
}
}
}
}
示例12: edit_comment_link
function edit_comment_link($link = _WP_TPL_EDIT_THIS, $before = '', $after = '', $echo = true)
{
get_currentuserinfo();
if (!user_can_edit($GLOBALS['post']->post_author)) {
return "";
}
$location = wp_siteurl() . "/wp-admin/post.php?action=editcomment&comment={$GLOBALS['comment']->comment_ID}";
return _echo("{$before} <a href='{$location}'>{$link}</a> {$after}", $echo);
}
示例13: pingback_ping
function pingback_ping($m)
{
// original code by Mort
// (http://mort.mine.nu:8080)
global $wpdb;
global $wp_version;
if (!get_settings('use_pingback')) {
return new xmlrpcresp(new xmlrpcval('Sorry, this weblog does not allow you to pingback its posts.'));
}
$title = '';
$pagelinkedfrom = $m->getParam(0);
$pagelinkedfrom = $pagelinkedfrom->scalarval();
$pagelinkedto = $m->getParam(1);
$pagelinkedto = $pagelinkedto->scalarval();
$pagelinkedfrom = addslashes(str_replace('&', '&', $pagelinkedfrom));
$pagelinkedto = preg_replace('#&([^amp\\;])#is', '&$1', $pagelinkedto);
$messages = array(htmlentities('Pingback from ' . $pagelinkedfrom . ' to ' . $pagelinkedto . ' registered. Keep the web talking! :-)'), htmlentities("We can't find the URL to the post you are trying to " . "link to in your entry. Please check how you wrote the post's permalink in your entry."), htmlentities("We can't find the post you are trying to link to." . " Please check the post's permalink."));
$message = $messages[0];
// Check if the page linked to is in our site
$pos1 = strpos($pagelinkedto, str_replace('http://', '', str_replace('www.', '', wp_siteurl())));
if ($pos1) {
// let's find which post is linked to
$urltest = parse_url($pagelinkedto);
if ($post_ID = url_to_postid($pagelinkedto)) {
$way = 'url_to_postid()';
} elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
// the path defines the post_ID (archives/p/XXXX)
$blah = explode('/', $match[0]);
$post_ID = $blah[1];
$way = 'from the path';
} elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
// the querystring defines the post_ID (?p=XXXX)
$blah = explode('=', $match[0]);
$post_ID = $blah[1];
$way = 'from the querystring';
} elseif (isset($urltest['fragment'])) {
// an #anchor is there, it's either...
if (intval($urltest['fragment'])) {
// ...an integer #XXXX (simpliest case)
$post_ID = $urltest['fragment'];
$way = 'from the fragment (numeric)';
} elseif (preg_match('/post-[0-9]+/', $urltest['fragment'])) {
// ...a post id in the form 'post-###'
$post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
$way = 'from the fragment (post-###)';
} elseif (is_string($urltest['fragment'])) {
// ...or a string #title, a little more complicated
$title = preg_replace('/[^a-zA-Z0-9]/', '.', $urltest['fragment']);
$sql = "SELECT ID FROM " . wp_table('posts') . " WHERE post_title RLIKE '" . addslashes($title) . "'";
$post_ID = $wpdb->get_var($sql) or die("Query: {$sql}\n\nError: ");
$way = 'from the fragment (title)';
}
} else {
// TODO: Attempt to extract a post ID from the given URL
$post_ID = -1;
$way = 'no match';
}
logIO('O', "(PB) URI='{$pagelinkedto}' ID='{$post_ID}' Found='{$way}'");
$sql = "SELECT post_author FROM " . wp_table('posts') . " WHERE ID = {$post_ID}";
$result = $wpdb->get_results($sql);
if ($wpdb->num_rows) {
// Let's check that the remote site didn't already pingback this entry
$sql = 'SELECT * FROM ' . wp_table('comments') . '
WHERE comment_post_ID = ' . $post_ID . '
AND comment_author_url = \'' . $pagelinkedfrom . '\'
AND comment_content LIKE \'%<pingback />%\'';
$result = $wpdb->get_results($sql);
if ($wpdb->num_rows || 1 == 1) {
// very stupid, but gives time to the 'from' server to publish !
sleep(1);
// Let's check the remote site
require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
$snoopy = new Snoopy();
if ($snoopy->fetch($pagelinkedfrom)) {
$linea = $snoopy->results;
} else {
$linea = '';
}
logIO('O', "(PB) CHARSET='" . $GLOBALS['blog_charset']);
$linea = mb_conv($linea, $GLOBALS['blog_charset'], 'auto');
// Work around bug in strip_tags():
$linea = str_replace('<!DOCTYPE', '<DOCTYPE', $linea);
$linea = strip_tags($linea, '<title><a>');
$linea = strip_all_but_one_link($linea, $pagelinkedto);
// I don't think we need this? -- emc3
if (empty($matchtitle)) {
preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
}
$pos2 = strpos($linea, $pagelinkedto);
$pos3 = strpos($linea, str_replace('http://www.', 'http://', $pagelinkedto));
logIO('O', "(PB) POS='{$pos2}, {$pos3}'");
if (is_integer($pos2) || is_integer($pos3)) {
//debug_fwrite($log, 'The page really links to us :)'."\n");
$pos4 = is_integer($pos2) ? $pos2 : $pos3;
$start = $pos4 - 50;
if (function_exists('mb_convert_encoding')) {
$tmp1 = mb_strcut($linea, 0, $start, $GLOBALS['blog_charset']);
} else {
$tmp1 = substr($linea, 0, $start);
}
//.........这里部分代码省略.........
示例14: tkzy_get_recent_comments
function tkzy_get_recent_comments($limit = 10, $cat_date = 1, $show_type = 1)
{
$comment_lenth = 30;
$request = 'SELECT ID, post_title, post_date,
comment_ID, comment_author, comment_author_url, comment_author_email, comment_date, comment_content
FROM ' . wp_table('posts') . ', ' . wp_table('comments') . ' WHERE ' . wp_table('posts') . '.ID=' . wp_table('comments') . '.comment_post_ID AND ' . wp_table('comments') . '.comment_approved=\'1\'';
if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) {
$request .= ' AND (comment_content like \'<trackback />%\' OR comment_content like \'<pingkback />%\') ';
}
$request .= ' ORDER BY ' . wp_table('comments') . '.comment_date DESC LIMIT ' . $limit;
$lcomments = $GLOBALS['wpdb']->get_results($request);
$output = '';
if ($lcomments) {
usort($lcomments, 'sort_comment_by_date');
}
$new_post_ID = -1;
if ($lcomments) {
$output .= '<ul class="wpBlockList">';
foreach ($lcomments as $lcomment) {
if ($lcomment->ID != $new_post_ID) {
// next post
if ($new_post_ID != -1) {
$output .= '</ul></li>';
}
$post_title = stripslashes($lcomment->post_title);
if (trim($post_title) == "") {
$post_title = _WP_POST_NOTITLE;
}
$comment_content = strip_tags($lcomment->comment_content);
$comment_content = stripslashes($comment_content);
if (function_exists('mb_substr')) {
$comment_excerpt = mb_substr($comment_content, 0, $comment_lenth);
} else {
$comment_excerpt = substr($comment_content, 0, $comment_lenth);
}
$permalink = wp_siteurl() . '/index.php?p=' . $lcomment->ID . '&c=1';
$output .= '<li>';
$output .= '<span class="comment-title"><a href="' . $permalink . '">' . $post_title . '</a></span>';
$output .= '<ul class="children" style="list-style-type: none;">';
$new_post_ID = $lcomment->ID;
}
$output .= "\t\t<li>";
if ($cat_date) {
$comment_date = $lcomment->comment_date;
if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) {
# within 24 hours
$comment_date = mysql2date('H:i', $comment_date);
} else {
$comment_date = mysql2date('m/d', $comment_date);
}
$output .= '<span class="post-date">' . $comment_date . '</span> : ';
}
$output .= '<span class="comment_author">' . tkzy_get_comment_author_link($lcomment, 25) . '</span></li>';
if (preg_match('|<trackback />|', $lcomment->comment_content)) {
$type = '[TrackBack]';
} elseif (preg_match('|<pingback />|', $lcomment->comment_content)) {
$type = '[Ping]';
} else {
$type = '[Comment]';
}
if ($show_type) {
$output .= '<span style="font-size:90%"> - ' . $type . '</span>';
}
}
}
$output .= '</ul></li></ul>';
return $output;
}
示例15: _b_wp_recent_comments_show
//.........这里部分代码省略.........
$_record['comment_author_link'] = _get_comment_author_link($lcomment, 25);
$_record['comment_content'] = strip_tags($lcomment->comment_content);
if (function_exists('mb_substr')) {
$_record['comment_excerpt'] = mb_substr($_record['comment_content'], 0, $comment_lenth);
} else {
$_record['comment_excerpt'] = substr($_record['comment_content'], 0, $comment_lenth);
}
$_record['comment_excerpt'] = preg_replace('/([a-zA-Z0-9\\.\\/\\:\\%\\?\\-\\+\\&\\;]{15})/ms', '\\1​', $_record['comment_excerpt']);
$_record['permalink'] = get_permalink($lcomment->ID) . '#comment-' . $lcomment->comment_ID;
if ($show_type) {
$_record['type'] = $type;
}
$block['records'][] = $_record;
}
}
} else {
$request = 'SELECT ID, post_title, post_date, comment_ID, comment_author, comment_author_url,
comment_date, comment_content, comment_type
FROM ' . wp_table('posts') . ', ' . wp_table('comments') . '
WHERE ' . wp_table('posts') . '.ID=' . wp_table('comments') . '.comment_post_ID
AND ' . wp_table('comments') . '.comment_approved=\'1\'';
if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) {
$request .= "AND (comment_content like '<trackback />%' \n\t\t\t\t OR comment_content like '<pingkback />%'\n\t\t\t\t OR comment_type = 'trackback'\n\t\t\t\t OR comment_type = 'pingback'\n\t\t\t\t ) ";
}
$request .= ' ORDER BY ' . wp_table('comments') . '.comment_date DESC LIMIT ' . $num_of_list;
$lcomments = $GLOBALS['wpdb']->get_results($request);
$output = '';
if ($lcomments) {
usort($lcomments, 'sort_comment_by_date');
}
$new_post_ID = -1;
$block['records'] = array();
if ($lcomments) {
foreach ($lcomments as $lcomment) {
$_record['new_post_ID'] = $new_post_ID;
$_record['ID'] = $lcomment->ID;
if ($lcomment->ID != $new_post_ID) {
// next post
$_record['post_title'] = $lcomment->post_title;
if (trim($_record['post_title']) == "") {
$_record['post_title'] = _WP_POST_NOTITLE;
}
$_record['comment_content'] = strip_tags($lcomment->comment_content);
if (function_exists('mb_substr')) {
$_record['comment_excerpt'] = mb_substr($_record['comment_content'], 0, $comment_lenth);
} else {
$_record['comment_excerpt'] = substr($_record['comment_content'], 0, $comment_lenth);
}
$_record['comment_excerpt'] = preg_replace('/([a-zA-Z0-9\\.\\/\\:\\?\\-\\+%&;]{15})/ms', '\\1​', $_record['comment_excerpt']);
$_record['permalink'] = wp_siteurl() . '/index.php?p=' . $lcomment->ID . '&c=1';
$new_post_ID = $lcomment->ID;
}
if ($cat_date) {
$comment_date = $lcomment->comment_date;
if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) {
# within 24 hours
$_record['comment_date'] = mysql2date('H:i', $comment_date);
} else {
$_record['comment_date'] = mysql2date('m/d', $comment_date);
}
}
$_record['comment_author'] = apply_filters('comment_author', $lcomment->comment_author);
$_record['comment_author_link'] = _get_comment_author_link($lcomment, 25);
if (empty($lcomment->comment_type)) {
if (preg_match('|<trackback />|', $lcomment->comment_content)) {
$type = '[TrackBack]';
} elseif (preg_match('|<pingback />|', $lcomment->comment_content)) {
$type = '[PingBack]';
} else {
$type = '[Comment]';
}
} else {
if ($lcomment->comment_type == 'trackback') {
$type = '[TrackBack]';
} elseif ($lcomment->comment_type == 'pingback') {
$type = '[PingBack]';
} else {
$type = '[Comment]';
}
}
if ($show_type) {
$_record['type'] = $type;
}
$block['records'][] = $_record;
}
}
}
if ($show_rss_icon) {
$block['feed_icon'] = array('url' => get_bloginfo('comments_rss2_url'), 'icon' => wp_siteurl() . '/wp-images/rss_comment.gif', 'alt' => 'Comment RSS');
} else {
$block['feed_icon'] = array();
}
$_wpTpl =& new WordPresTpl('theme');
$_wpTpl->assign('block', $block);
if (!$_wpTpl->tpl_exists($tpl_file)) {
$tpl_file = 'wp_recent_comments.html';
}
$block['content'] = $_wpTpl->fetch($tpl_file);
return $block;
}