本文整理汇总了PHP中get_blog_post函数的典型用法代码示例。如果您正苦于以下问题:PHP get_blog_post函数的具体用法?PHP get_blog_post怎么用?PHP get_blog_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_blog_post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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>
示例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;
}
示例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 '';
}
示例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;
}
示例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));
}
示例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;
}
示例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
示例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');
示例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
//.........这里部分代码省略.........
示例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;
}