本文整理汇总了PHP中get_blog_post函数的典型用法代码示例。如果您正苦于以下问题:PHP get_blog_post函数的具体用法?PHP get_blog_post怎么用?PHP get_blog_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_blog_post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$limit = (int) @$instance['limit'];
$limit = $limit ? $limit : 5;
$data = new Wdpv_Options();
$voted_timeframe = @$instance['voted_timeframe'];
if (!in_array($voted_timeframe, array_keys($data->timeframes))) {
$voted_timeframe = false;
}
if (is_main_site()) {
$model = new Wdpv_Model();
$posts = $model->get_popular_on_network($limit, $voted_timeframe);
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
if (is_array($posts)) {
echo "<ul class='wdpv_popular_posts wdpv_network_popular'>";
foreach ($posts as $post) {
$data = get_blog_post($post['blog_id'], $post['post_id']);
echo "<li>";
echo '<a href="' . get_blog_permalink($post['blog_id'], $post['post_id']) . '">' . $data->post_title . '</a> ';
printf(__('<span class="wdpv_vote_count">(%s votes)</span>', 'wdpv'), $post['total']);
echo "</li>";
}
echo "</ul>";
}
echo $after_widget;
}
}
开发者ID:hscale,项目名称:webento,代码行数:32,代码来源:class_wpdv_widget_network_popular.php
示例2: get_remote_post
/**
* @param WP_Post $source_post
* @param int $blog_id
*
* @return WP_Post
*/
public function get_remote_post(WP_Post $source_post, $blog_id)
{
$linked = \Inpsyde\MultilingualPress\get_translation_ids($source_post->ID);
if (!empty($linked[$blog_id]) && \Inpsyde\MultilingualPress\site_exists($blog_id)) {
$post = get_blog_post($blog_id, $linked[$blog_id]);
if ($post) {
return $post;
}
}
return $this->get_dummy_post($source_post->post_type);
}
开发者ID:inpsyde,项目名称:multilingual-press,代码行数:17,代码来源:Mlp_Translatable_Post_Data.php
示例3: get_remote_post
/**
* @param WP_Post $source_post
* @param int $blog_id
* @return WP_Post
*/
public function get_remote_post(WP_Post $source_post, $blog_id)
{
$post = NULL;
$linked = Mlp_Helpers::load_linked_elements($source_post->ID, '', get_current_blog_id());
if (!empty($linked[$blog_id]) && blog_exists($blog_id)) {
$post = get_blog_post($blog_id, $linked[$blog_id]);
}
if ($post) {
return $post;
}
return $this->get_dummy_post($source_post->post_type);
}
开发者ID:ycms,项目名称:framework,代码行数:17,代码来源:Mlp_Translatable_Post_Data.php
示例4: process_popular_code
function process_popular_code($args)
{
$args = extract(shortcode_atts(array('limit' => 5, 'network' => false), $args));
$model = new Wdpv_Model();
$posts = $network ? $model->get_popular_on_network($limit) : $model->get_popular_on_current_site($limit);
$ret = '';
if (is_array($posts)) {
$ret .= '<ul class="wdpv_popular_posts ' . ($network ? 'wdpv_network_popular' : '') . '">';
foreach ($posts as $post) {
if ($network) {
$data = get_blog_post($post['blog_id'], $post['post_id']);
if (!$data) {
continue;
}
}
$title = $network ? $data->post_title : $post['post_title'];
$permalink = $network ? get_blog_permalink($post['blog_id'], $post['post_id']) : get_permalink($post['ID']);
$ret .= "<li>" . "<a href='{$permalink}'>{$title}</a> " . sprintf(__('<span class="wdpv_vote_count">(%s votes)</span>', 'wdpv'), $post['total']) . "</li>";
}
$ret .= '</ul>';
}
return $ret;
}
开发者ID:hscale,项目名称:webento,代码行数:23,代码来源:class_wdpv_codec.php
示例5: do_redirect
/**
* Check for elements we can redirect to
* and do the redirect.
*
* @since 0.2
* @param int $found | Blog ID
* @param string $lang | Language code of current blog
* @return FALSE | If no related element found
*/
private function do_redirect($found, $lang)
{
// Get currently queried object
$object = get_queried_object();
if (!$object) {
if (is_home()) {
wp_redirect(get_site_url($found));
exit;
}
return FALSE;
}
$url = '';
// Can we redirect to a specific element?
// @TODO: make calling mlp_get_linked_elements easier, i.e. no parameters necessary
$linked_elements = mlp_get_linked_elements($object->ID, '', get_current_blog_id());
// Redirect to specific element within blog. Above
// function returns array() when nothing found,
// so ! is_array won't work here.
if (array() !== $linked_elements) {
$post = get_blog_post($found, $linked_elements[$found]);
// Is the post status 'publish'?
if ('publish' == $post->post_status) {
$url = get_blog_permalink($found, $linked_elements[$found]);
}
}
// No related elements found
if ('' == $url) {
return FALSE;
}
// Otherwise do the redirect
wp_redirect($url);
exit;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:42,代码来源:class-Multilingual_Press_Redirect.php
示例6: db_include
<?php
db_include('get_blog_post');
if (!is_admin()) {
header('HTTP/1.0 403 Forbidden');
echo 'Access is forbidden!';
exit;
}
if (!isset($_GET['id'])) {
$message = 'No post ID specified!';
} else {
if (isset($_POST['blog_fail_return']) && $_POST['blog_fail_return']) {
$title = $_POST['title'];
$body = $_POST['body'];
} else {
$blog_post = get_blog_post($_GET['id']);
if (!$blog_post) {
$message = 'Invalid post ID specified!';
} else {
$title = $blog_post['title'];
$body = $blog_post['body'];
}
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Under the Couch - Edit Blog Post</title>
开发者ID:eon8ight,项目名称:under-the-couch,代码行数:31,代码来源:editblog.php
示例7: get_popular_on_multidb_site
/**
* Multi-DB compatibility layer.
*/
function get_popular_on_multidb_site($site_id, $blog_id, $limit, $posted_timeframe = false, $voted_timeframe = false)
{
$site_id = (int) $site_id;
$blog_id = (int) $blog_id;
$limit = (int) $limit;
if ($posted_timeframe) {
list($start_date, $end_date) = $this->extract_timeframe($posted_timeframe);
}
if ($voted_timeframe) {
list($voted_start_date, $voted_end_date) = $this->extract_timeframe($posted_timeframe);
}
// Woot, mega complex SQL
$sql = "SELECT *, SUM(vote) as total FROM " . $this->db->base_prefix . "wdpv_post_votes " . "WHERE site_id={$site_id} AND blog_id={$blog_id} " . ($posted_timeframe ? "AND post_date > '{$start_date}' AND post_date < '{$end_date}' " : '') . ($voted_timeframe ? "AND date > '{$voted_start_date}' AND date < '{$voted_end_date}' " : '') . "GROUP BY post_id " . "ORDER BY total DESC " . "LIMIT {$limit}";
$results = $this->db->get_results($sql, ARRAY_A);
foreach ($results as $key => $val) {
$post = (array) get_blog_post($val['blog_id'], $val['post_id']);
$results[$key] = array_merge($val, $post);
}
return $results;
}
开发者ID:hscale,项目名称:webento,代码行数:23,代码来源:class_wdpv_model.php
示例8: get_element_permalink
/**
* Get the selected blog's post permalink
*
* @since 0.1
* @access private
* @param int $blog_id
* @param int $post_id
* @uses mlp_get_linked_elements, get_current_blog_id, get_blog_post, get_blog_permalink
* @return string $permalink | the post permalink
*/
private function get_element_permalink($blog_id, $post_id)
{
// Get blog id of desired blog
$remote_blog_id = intval($blog_id);
// Get all elements linked to the current one
$elements = mlp_get_linked_elements(intval($post_id), '', get_current_blog_id());
// No linked elements found
if (array() == $elements || empty($elements[$remote_blog_id])) {
return '';
}
$remote_post_id = intval($elements[$remote_blog_id]);
$post = get_blog_post($remote_blog_id, $remote_post_id);
if (is_object($post) && 'publish' == $post->post_status) {
$permalink = get_blog_permalink($remote_blog_id, $remote_post_id);
} else {
return '';
}
if (1 < strlen($permalink)) {
return $permalink;
}
return '';
}
开发者ID:ycms,项目名称:multilingual-press,代码行数:32,代码来源:Mlp_Quicklink.php
示例9: save
function save()
{
global $wpdb, $current_user, $blog_id, $EM_SAVING_LOCATION;
$EM_SAVING_LOCATION = true;
//TODO shuffle filters into right place
if (get_site_option('dbem_ms_mainblog_locations')) {
self::ms_global_switch();
}
if (!$this->can_manage('edit_locations', 'edit_others_locations') && !(get_option('dbem_events_anonymous_submissions') && empty($this->location_id))) {
return apply_filters('em_location_save', false, $this);
}
remove_action('save_post', array('EM_Location_Post_Admin', 'save_post'), 10, 1);
//disable the default save post action, we'll do it manually this way
do_action('em_location_save_pre', $this);
$post_array = array();
//Deal with updates to a location
if (!empty($this->post_id)) {
//get the full array of post data so we don't overwrite anything.
if (EM_MS_GLOBAL) {
if (!empty($this->blog_id)) {
$post_array = (array) get_blog_post($this->blog_id, $this->post_id);
} else {
$post_array = (array) get_blog_post(get_current_site()->blog_id, $this->post_id);
}
} else {
$post_array = (array) get_post($this->post_id);
}
}
//Overwrite new post info
$post_array['post_type'] = EM_POST_TYPE_LOCATION;
$post_array['post_title'] = $this->location_name;
$post_array['post_content'] = $this->post_content;
//decide on post status
if (count($this->errors) == 0) {
if (EM_MS_GLOBAL && !is_main_site() && get_site_option('dbem_ms_mainblog_locations')) {
//if in global ms mode and user is a valid role to publish on their blog, then we will publish the location on the main blog
restore_current_blog();
$post_array['post_status'] = $this->can_manage('publish_locations') ? 'publish' : 'pending';
EM_Object::ms_global_switch();
//switch 'back' to main blog
} else {
$post_array['post_status'] = $this->can_manage('publish_locations') ? 'publish' : 'pending';
}
} else {
$post_array['post_status'] = 'draft';
}
//Anonymous submission
if (!is_user_logged_in() && get_option('dbem_events_anonymous_submissions') && empty($this->location_id)) {
$post_array['post_author'] = get_option('dbem_events_anonymous_user');
if (!is_numeric($post_array['post_author'])) {
$post_array['post_author'] = 0;
}
}
//Save post and continue with meta
$post_id = wp_insert_post($post_array);
$post_save = false;
$meta_save = false;
if (!is_wp_error($post_id) && !empty($post_id)) {
$post_save = true;
//refresh this event with wp post
$post_data = get_post($post_id);
$this->post_id = $post_id;
$this->location_slug = $post_data->post_name;
$this->location_owner = $post_data->post_author;
$this->post_status = $post_data->post_status;
$this->get_status();
//now save the meta
$meta_save = $this->save_meta();
//save the image
$this->image_upload();
$image_save = count($this->errors) == 0;
} elseif (is_wp_error($post_id)) {
//location not saved, add an error
$this->add_error($post_id->get_error_message());
}
if (get_site_option('dbem_ms_mainblog_locations')) {
self::ms_global_switch_back();
}
$return = apply_filters('em_location_save', $post_save && $meta_save && $image_save, $this);
$EM_SAVING_LOCATION = false;
return $return;
}
开发者ID:javipaur,项目名称:TiendaVirtual,代码行数:82,代码来源:em-location.php
示例10: test_get_blog_post_invalid_returns_null
/**
* A null response should be returned if an invalid post is requested.
*/
function test_get_blog_post_invalid_returns_null()
{
$this->assertNull(get_blog_post(1, 999999));
}
开发者ID:ntwb,项目名称:wordpress-travis,代码行数:7,代码来源:site.php
示例11: render_output
function render_output($wgt_miss, $wgt_count, $wgt_format, $wgt_avsize, $wgt_defav, $wgt_dt, $before_item, $after_item, $before_cont, $after_cont, $wgt_mtext, $wgt_white, $post_limit = 0)
{
global $DiamondCache;
$cachekey = 'diamond_post_' . diamond_arr_to_str($wgt_miss) . '-' . $wgt_count . '-' . $wgt_format . diamond_arr_to_str($wgt_white) . '-' . $wgt_avsize . '-' . $wgt_defav . '-' . $wgt_dt . '-' . $before_item . '-' . $after_item . '-' . $before_cont . '-' . $after_cont . '-' . $wgt_mtext . '-' . $post_limit;
$output = $DiamondCache->get($cachekey, 'recent-posts');
if ($output != false) {
return $output;
}
global $switched;
global $wpdb;
$table_prefix = $wpdb->base_prefix;
if (!isset($wgt_dt) || trim($wgt_dt) == '') {
$wgt_dt = 'M. d. Y.';
}
if (!isset($wgt_avsize) || $wgt_avsize == '') {
$wgt_avsize = 96;
}
if (!isset($before_item) || $before_item == '') {
$before_item = '<li>';
}
if (!isset($after_item) || $after_item == '') {
$after_item = '</li>';
}
if (!isset($before_cont) || $before_cont == '') {
$before_cont = '<ul>';
}
if (!isset($after_cont) || $after_cont == '') {
$after_cont = '</ul>';
}
if (!isset($wgt_miss) || $wgt_miss == '') {
$wgt_miss = array();
}
$white = 0;
if (isset($wgt_white) && $wgt_white != '' && count($wgt_white) > 0 && $wgt_white[0] && $wgt_white[0] != '') {
$white = 1;
}
$limitstr = '';
if ((int) $post_limit > 0) {
$limitstr = ' LIMIT ' . (int) $post_limit;
}
$sqlstr = '';
$blog_list = get_blog_list(0, 'all');
if ($white == 0 && !in_array(1, $wgt_miss) || $white == 1 && in_array(1, $wgt_white)) {
$sqlstr = "(SELECT 1 as blog_id, id, post_date_gmt from " . $table_prefix . "posts where post_status = 'publish' and post_type = 'post' and post_title <> '" . __('Hello world!') . "' " . $limitstr . ")";
}
$uni = '';
foreach ($blog_list as $blog) {
if ($white == 0 && !in_array($blog['blog_id'], $wgt_miss) && $blog['blog_id'] != 1 || $white == 1 && $blog['blog_id'] != 1 && in_array($blog['blog_id'], $wgt_white)) {
if ($sqlstr != '') {
$uni = ' union ';
}
$sqlstr .= $uni . " (SELECT " . $blog['blog_id'] . " as blog_id, id, post_date_gmt from " . $table_prefix . $blog['blog_id'] . "_posts where post_status = 'publish' and post_type = 'post' and post_title <> '" . __('Hello world!') . "' " . $limitstr . ")";
}
}
$limit = '';
if ((int) $wgt_count > 0) {
$limit = ' LIMIT 0, ' . (int) $wgt_count;
}
$sqlstr .= " ORDER BY post_date_gmt desc " . $limit;
//echo $sqlstr;
$post_list = $wpdb->get_results($sqlstr, ARRAY_A);
//echo $wpdb->print_error();
$output = '';
$output .= $before_cont;
foreach ($post_list as $post) {
$output .= $before_item;
$wgt_format = get_format_txt($wgt_format);
$txt = $wgt_format == '' ? '<strong>{title}</strong> - {date}' : $wgt_format;
$p = get_blog_post($post["blog_id"], $post["id"]);
$av = get_avatar(get_userdata($p->post_author)->user_email, $wgt_avsize, $defav);
$ex = $p->post_excerpt;
if (!isset($ex) || trim($ex) == '') {
$ex = mb_substr(strip_tags($p->post_content), 0, 65) . '...';
}
$txt = str_replace('{title}', '<a href="' . get_blog_permalink($post["blog_id"], $post["id"]) . '">' . $p->post_title . '</a>', $txt);
$txt = str_replace('{more}', '<a href="' . get_blog_permalink($post["blog_id"], $post["id"]) . '">' . $wgt_mtext . '</a>', $txt);
$txt = str_replace('{title_txt}', $p->post_title, $txt);
$txt = str_replace('{date}', date_i18n($wgt_dt, strtotime($p->post_date)), $txt);
$txt = str_replace('{excerpt}', $ex, $txt);
$txt = str_replace('{author}', get_userdata($p->post_author)->nickname, $txt);
$txt = str_replace('{avatar}', $av, $txt);
$txt = str_replace('{blog}', get_blog_option($post["blog_id"], 'blogname'), $txt);
$burl = get_blog_option($post["blog_id"], 'home');
$txt = str_replace('{blog_link}', '<a href="' . $burl . '/">' . get_blog_option($post["blog_id"], 'blogname') . '</a>', $txt);
$txt = str_replace('{blog_url}', $burl, $txt);
$output .= $txt;
$output .= $after_item;
}
$output .= $after_cont;
if (false === $post_list) {
$output .= $wpdb->print_error();
}
$DiamondCache->add($cachekey, 'recent-posts', $output);
return $output;
}
开发者ID:Wikipraca,项目名称:Wikipraca-WikiSquare,代码行数:95,代码来源:diamond-recent-posts.php
示例12: connect
?>
bootstrap.min.css" rel="stylesheet">
<link href="<?php
echo BASE_ADDRESS . CSS_F;
?>
custom.css" rel="stylesheet">
</head>
<!-- NAVBAR
================================================== -->
<body>
<?php
include_once INCLUDES_F . SIDE_MENU;
include_once INCLUDES_F . MAIN_TOP;
connect();
$res = get_blog_post();
/* if ($res->num_rows == 0) {
include_once(CONTENT_F . BLOG_F . NO_POST);
} else {
include_once(CONTENT_F . BLOG_F . BLOG_POST);
} */
if ($res->num_rows > 0) {
include_once CONTENT_F . BLOG_F . BLOG_POST;
}
?>
<?php
include_once INCLUDES_F . LOGIN;
include_once INCLUDES_F . FOOTER;
?>
<script src="<?php
开发者ID:SHLee84,项目名称:Coreators,代码行数:31,代码来源:index.php
示例13: strftime
} else {
if ($blog_details->post_count >= "2") {
$postText = "posts";
} else {
$postText = "posts";
}
}
$updatedOn = strftime("%m/%d/%Y at %l:%M %p", strtotime($blog_details->last_updated));
if ($blog_details->post_count == "") {
$blog_details->post_count = "0";
}
$posts = $wpdb->get_col("SELECT ID FROM wp_" . $curauth->primary_blog . "_posts WHERE post_status='publish' AND post_type='post' AND post_author='{$author->ID}' ORDER BY ID DESC LIMIT 5");
$postHTML = "";
$i = 0;
foreach ($posts as $p) {
$postdetail = get_blog_post($curauth->primary_blog, $p);
if ($i == 0) {
$updatedOn = strftime("%m/%d/%Y at %l:%M %p", strtotime($postdetail->post_date));
}
$postHTML .= "• <a href=\"{$postdetail->guid}\">{$postdetail->post_title}</a><br />";
$i++;
}
?>
<div class="author_bio">
<div class="row">
<div class="column grid_2">
<a href="<?php
echo $blog_details->siteurl;
?>
"><?php
echo get_avatar($curauth->user_email, '96', 'http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536');
开发者ID:Blueprint-Marketing,项目名称:interoccupy.net,代码行数:31,代码来源:page-directory-members.php
示例14: render_output
function render_output($wgt_miss, $wgt_count, $wgt_format, $wgt_white)
{
global $switched;
global $wpdb;
$table_prefix = $wpdb->base_prefix;
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
if (!isset($wgt_miss) || $wgt_miss == '') {
$wgt_miss = array();
}
$white = 0;
if (isset($wgt_white) && $wgt_white != '' && count($wgt_white) > 0 && $wgt_white[0] && $wgt_white[0] != '') {
$white = 1;
}
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/" >
<channel>
<title><?php
bloginfo_rss('name');
wp_title_rss();
?>
</title>
<link><?php
self_link();
?>
</link>
<atom:link href="<?php
self_link();
?>
" rel="self" type="application/rss+xml" />
<description><?php
bloginfo_rss("description");
?>
</description>
<language><?php
echo get_option('rss_language');
?>
</language>
<sy:updatePeriod><?php
echo apply_filters('rss_update_period', 'hourly');
?>
</sy:updatePeriod>
<sy:updateFrequency><?php
echo apply_filters('rss_update_frequency', '1');
?>
</sy:updateFrequency><?php
$sqlstr = '';
$blog_list = get_blog_list(0, 'all');
if ($white == 0 && !in_array(1, $wgt_miss) || $white == 1 && in_array(1, $wgt_white)) {
$sqlstr = "SELECT 1 as blog_id, id, post_date_gmt, post_type from " . $table_prefix . "posts where post_status = 'publish' and post_type = 'post' ";
}
$uni = '';
foreach ($blog_list as $blog) {
if ($white == 0 && !in_array($blog['blog_id'], $wgt_miss) && $blog['blog_id'] != 1 || $white == 1 && $blog['blog_id'] != 1 && in_array($blog['blog_id'], $wgt_white)) {
if ($sqlstr != '') {
$uni = ' union ';
}
$sqlstr .= $uni . " SELECT " . $blog['blog_id'] . " as blog_id, id, post_date_gmt, post_type from " . $table_prefix . $blog['blog_id'] . "_posts where post_status = 'publish' and post_type = 'post' ";
}
}
$limit = '';
if ((int) $wgt_count > 0) {
$limit = ' LIMIT 0, ' . (int) $wgt_count;
} else {
$limit = ' LIMIT 0, 100';
}
$sqlstr .= " ORDER BY post_date_gmt desc " . $limit;
$post_list = $wpdb->get_results($sqlstr, ARRAY_A);
foreach ($post_list as $post) {
$txt = $wgt_format == '' ? '{excerpt}' : $wgt_format;
$p = get_blog_post($post["blog_id"], $post["id"]);
$ex = $p->post_excerpt;
//if (!isset($ex) || trim($ex) == '')
//$ex = substr(strip_tags($p->post_content), 0, 65) . '...';
echo "\r";
?>
<item>
<title><![CDATA[<?php
echo $p->post_title;
?>
]]></title>
<link><?php
echo get_blog_permalink($post["blog_id"], $post["id"]);
?>
</link>
<dc:creator><?php
echo get_userdata($p->post_author)->nickname;
?>
</dc:creator>
<guid isPermaLink="false"><?php
echo $p->guid;
?>
</guid>
<pubDate><?php
//.........这里部分代码省略.........
开发者ID:Wikipraca,项目名称:Wikipraca-WikiSquare,代码行数:101,代码来源:diamond-post-feed.php
示例15: bp_record_vote_activity
function bp_record_vote_activity($site_id, $blog_id, $post_id, $vote)
{
if (!bp_loggedin_user_id()) {
return false;
}
$username = bp_get_loggedin_user_fullname();
$username = $username ? $username : bp_get_loggedin_user_username();
if (!$username) {
return false;
}
$user_link = bp_get_loggedin_user_link();
$link = get_blog_permalink($blog_id, $post_id);
$post = get_blog_post($blog_id, $post_id);
$title = $post->post_title;
$args = array('action' => sprintf(__('<a href="%s">%s</a> voted on <a href="%s">%s</a>', 'wdpv'), $user_link, $username, $link, $title), 'component' => 'wdpv_post_vote', 'type' => 'wdpv_post_vote', 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'hide_sitewide' => $this->data->get_option('bp_publish_activity_local'));
$res = bp_activity_add($args);
return $res;
}
开发者ID:hscale,项目名称:webento,代码行数:18,代码来源:class_wdpv_admin_pages.php
示例16: get_blog_post
<?php
$post = get_blog_post(2, 3);
echo $post->post_title;
开发者ID:Cywaithaka,项目名称:bwawwp,代码行数:4,代码来源:example-16.php
示例17: _e
<h4><?php
_e('Recent votes', 'wdpv');
?>
</h4>
<?php
if ($recent_votes) {
?>
<ul>
<?php
foreach ($recent_votes as $vote) {
?>
<li>
<?php
$url = get_blog_permalink($vote['blog_id'], $vote['post_id']);
$post = get_blog_post($vote['blog_id'], $vote['post_id']);
$title = $post->post_title;
?>
<a href="<?php
echo $url;
?>
"><?php
echo $title;
?>
</a>
</li>
<?php
}
?>
</ul>
<?php
开发者ID:hscale,项目名称:webento,代码行数:31,代码来源:bp_profile.php
示例18: remove_unpublished_posts
/**
* @param array $relations
* @return array
*/
private function remove_unpublished_posts(array $relations)
{
foreach ($relations as $site_id => $content_id) {
$post = get_blog_post($site_id, $content_id);
if (!$post || 'publish' !== $post->post_status) {
unset($relations[$site_id]);
}
}
return $relations;
}
开发者ID:ycms,项目名称:framework,代码行数:14,代码来源:Mlp_Language_Api.php
示例19: show_linked_elements
/**
* Get the linked elements and display them as a list
* flag from a blogid
*
* @since 0.1
* @access public
* @param int $blog_id ID of a blog
* @uses mlp_get_available_languages, mlp_get_available_languages_titles, is_single,
* is_page, mlp_get_linked_elements, mlp_get_language_flag, get_current_blog_id,
* get_blog_post, get_site_url
* @return string output of the bloglist
*/
public static function show_linked_elements($args)
{
global $wp_query;
$output = '';
$languages = mlp_get_available_languages();
$language_titles = mlp_get_available_languages_titles();
if (!(0 < count($languages))) {
return $output;
}
// returns NULL if there is no post, get_the_ID() throws a notice,
// if we don' check this before.
$default_post = get_post();
if ($default_post) {
$current_element_id = get_the_ID();
} elseif (!empty($wp_query->queried_object) && !empty($wp_query->queried_object->ID)) {
$current_element_id = $wp_query->queried_object->ID;
} else {
$current_element_id = 0;
}
$linked_elements = array();
// double check to avoid issues with a static front page.
if (!is_front_page() && !is_home() && is_singular()) {
$linked_elements = mlp_get_linked_elements($current_element_id);
}
$defaults = array('link_text' => 'text', 'echo' => TRUE, 'sort' => 'blogid', 'show_current_blog' => FALSE);
$params = wp_parse_args($args, $defaults);
if ('blogid' == $params['sort']) {
ksort($languages);
} else {
asort($languages);
}
$output .= '<div class="mlp_language_box"><ul>';
foreach ($languages as $language_blog => $language_string) {
$current_language = mlp_get_current_blog_language(2);
if ($current_language == $language_string && $params['show_current_blog'] == FALSE) {
continue;
}
// Get params
$flag = mlp_get_language_flag($language_blog);
$title = mlp_get_available_languages_titles(TRUE);
// Display type
if ('flag' == $params['link_text'] && '' != $flag) {
$display = '<img src="' . $flag . '" alt="' . $languages[$language_blog] . '" title="' . $title[$language_blog] . '" />';
} else {
if ('text' == $params['link_text'] && !empty($language_titles[$language_blog])) {
$display = $language_titles[$language_blog];
} else {
if ('text_flag' == $params['link_text']) {
$display = '<img src="' . $flag . '" alt="' . $languages[$language_blog] . '" title="' . $title[$language_blog] . '" />';
if (!empty($language_titles[$language_blog])) {
$display .= ' ' . $language_titles[$language_blog];
}
} else {
$display = $languages[$language_blog];
}
}
}
$class = get_current_blog_id() == $language_blog ? 'id="mlp_current_locale"' : '';
// set element to 0 to avoid empty element
if (!isset($linked_elements[$language_blog])) {
$linked_elements[$language_blog] = 0;
}
// Check post status
$post = $linked_elements[$language_blog] > 0 ? get_blog_post($language_blog, $linked_elements[$language_blog]) : '';
do_action('mlp_before_link');
$link = (is_single() || is_page() || is_home()) && isset($post->post_status) && ('publish' === $post->post_status || 'private' === $post->post_status && is_super_admin()) ? get_blog_permalink($language_blog, $linked_elements[$language_blog]) : get_site_url($language_blog);
// apply filter to help others to change the link
$link = apply_filters('mlp_linked_element_link', $link, $language_blog, $linked_elements[$language_blog]);
do_action('mlp_after_link');
// Output link elements
$output .= '<li ' . ($current_language == $language_string ? 'class="current"' : '') . '><a rel="alternate" hreflang="' . self::get_blog_language($language_blog) . '" ' . $class . ' href="' . $link . '">' . $display . '</a></li>';
}
$output .= '</ul></div>';
return $output;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:87,代码来源:class-Mlp_Helpers.php
示例20: load_all_posts
function load_all_posts($prev, $post_type = 'post')
{
global $wpdb, $current_blog, $current_site;
$documents = array();
$cnt = 0;
$batchsize = 500;
$last = "";
$found = FALSE;
$end = FALSE;
$percent = 0;
//multisite logic is decided s4wp_get_option
$plugin_s4wp_settings = solr_options();
if (isset($blog)) {
$blog_id = $blog->blog_id;
}
if (is_multisite()) {
// there is potential for this to run for an extended period of time, depending on the # of blgos
syslog(LOG_ERR, "starting batch import, setting max execution time to unlimited");
ini_set('memory_limit', '1024M');
set_time_limit(0);
// get a list of blog ids
$bloglist = $wpdb->get_col("SELECT * FROM {$wpdb->base_prefix}blogs WHERE spam = 0 AND deleted = 0", 0);
syslog(LOG_INFO, "pushing posts from " . count($bloglist) . " blogs into Solr");
foreach ($bloglist as $bloginfo) {
// for each blog we need to import we get their id
// and tell wordpress to switch to that blog
$blog_id = trim($bloginfo);
syslog(LOG_INFO, "switching to blogid {$blog_id}");
// attempt to save some memory by flushing wordpress's cache
wp_cache_flush();
// everything just works better if we tell wordpress
// to switch to the blog we're using, this is a multi-site
// specific function
switch_to_blog($blog_id);
// now we actually gather the blog posts
$args = array('post_type' => $post_type, 'post_status' => 'publish', 'fields' => 'ids');
$query = new WP_Query($args);
$postids = $query->posts;
$postcount = count($postids);
syslog(LOG_INFO, "building {$postcount} documents for " . substr(get_bloginfo('wpurl'), 7));
for ($idx = 0; $idx < $postcount; $idx++) {
$postid = $postids[$idx];
$last = $postid;
$percent = floatval($idx) / floatval($postcount) * 100;
if ($prev && !$found) {
if ($postid === $prev) {
$found = TRUE;
}
continue;
}
if ($idx === $postcount - 1) {
$end = TRUE;
}
// using wpurl is better because it will return the proper
// URL for the blog whether it is a subdomain install or otherwise
$solr = get_solr();
$update = $solr->createUpdate();
$documents[] = $this->build_document($update->createDocument(), get_blog_post($blog_id, $postid), substr(get_bloginfo('wpurl'), 7), $current_site->path);
$cnt++;
if ($cnt == $batchsize) {
$this->post($documents, true, false);
$this->post(false, true, false);
wp_cache_flush();
$cnt = 0;
$documents = array();
}
}
// post the documents to Solr
// and reset the batch counters
$this->post($documents, true, false);
$this->post(false, true, false);
$cnt = 0;
$documents = array();
syslog(LOG_INFO, "finished building {$postcount} documents for " . substr(get_bloginfo('wpurl'), 7));
wp_cache_flush();
}
// done importing so lets switch back to the proper blog id
restore_current_blog();
} else {
$args = array('post_type' => $post_type, 'post_status' => 'publish', 'fields' => 'ids');
$query = new WP_Query($args);
$posts = $query->posts;
$postcount = count($posts);
if (0 == $postcount) {
$end = true;
printf("{\"type\": \"" . $post_type . "\", \"last\": \"%s\", \"end\": true, \"percent\": \"%.2f\"}", $last, 100);
die;
}
for ($idx = 0; $idx < $postcount; $idx++) {
$postid = $posts[$idx];
$last = $postid;
$percent = floatval($idx) / floatval($postcount) * 100;
if ($prev && !$found) {
if ($postid === $prev) {
$found = TRUE;
}
continue;
}
if ($idx === $postcount - 1) {
$end = TRUE;
//.........这里部分代码省略.........
开发者ID:csemrm,项目名称:solr-power,代码行数:101,代码来源:class-solrpower-sync.php
注:本文中的get_blog_post函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论