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;
     }
 }
 /**
  * @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
0
 /**
  * @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
0
 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;
 }
 /**
  * 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
0
<?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
0
 /**
  * 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
0
 /**
  * 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
0
 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
0
 /**
  * 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));
 }
 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
0
?>
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 
    } 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 .= "&#149; <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');
    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 
            echo date(DATE_RFC822, strtotime($p->post_date));
            ?>
</pubDate><?php 
            //	echo '<content:encoded><![CDATA[' . $p->post_content . ']]></content:encoded>';
            $txt = str_replace('{content}', $p->post_content, $txt);
            $txt = str_replace('{excerpt}', $ex, $txt);
            $txt = str_replace('{blog}', get_blog_option($post["blog_id"], 'blogname'), $txt);
            echo "\r";
            ?>
		<description><![CDATA[<?php 
            echo $txt;
            ?>
]]></description>			
	</item><?php 
        }
        echo "\r";
        ?>
</channel>
</rss><?php 
    }
Пример #15
0
 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;
 }
Пример #16
0
<?php

$post = get_blog_post(2, 3);
echo $post->post_title;
Пример #17
0
<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 
Пример #18
0
 /**
  * @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;
 }
 /**
  * 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;
 }
Пример #20
0
 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;
             }
             $solr = get_solr();
             $update = $solr->createUpdate();
             $documents[] = $this->build_document($update->createDocument(), get_post($postid));
             $cnt++;
             if ($cnt == $batchsize) {
                 $this->post($documents, true, FALSE);
                 $cnt = 0;
                 $documents = array();
                 wp_cache_flush();
                 break;
             }
         }
     }
     if ($documents) {
         $this->post($documents, true, FALSE);
     }
     if ($end) {
         printf("{\"type\": \"" . $post_type . "\", \"last\": \"%s\", \"end\": true, \"percent\": \"%.2f\"}", $last, 100);
     } else {
         printf("{\"type\": \"" . $post_type . "\", \"last\": \"%s\", \"end\": false, \"percent\": \"%.2f\"}", $last, $percent);
     }
 }
/**
 * This function indexes all the different content types.
 * This does not include attachments and revisions
 *
 * @param $prev 
 * @param $type what content to index: post type machine name or all content.
 * @return string (json reply)
 */
function s4w_load_all_posts($prev, $type = 'all')
{
    global $wpdb, $current_blog, $current_site;
    $documents = array();
    $cnt = 0;
    $batchsize = 250;
    $last = "";
    $found = FALSE;
    $end = FALSE;
    $percent = 0;
    //multisite logic is decided s4w_get_option
    $plugin_s4w_settings = s4w_get_option();
    $blog_id = $blog->blog_id;
    //retrieve the post types that can be indexed
    $indexable_content = $plugin_s4w_settings['s4w_content']['index'];
    $indexable_type = array_keys($indexable_content);
    //if the provided $type is not allowed to be index, lets stop
    if (!in_array($type, $indexable_type) && $type != 'all') {
        return false;
    }
    //lets setup our where clause to find the appropriate posts
    $where_and = $type == 'all' ? "AND post_type IN ('" . implode("', '", $indexable_type) . "')" : " AND post_type = '{$type}'";
    if ($plugin_s4w_settings['s4w_index_all_sites']) {
        // 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->blogs} WHERE spam = 0 AND deleted = 0", 0);
        syslog(LOG_ERR, "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_ERR, "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
            $postids = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' {$where_and} ORDER BY ID;");
            $postcount = count($postids);
            syslog(LOG_ERR, "building {$postcount} documents for " . substr(get_bloginfo('wpurl'), 7));
            for ($idx = 0; $idx < $postcount; $idx++) {
                $postid = $postids[$idx]->ID;
                $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
                $documents[] = s4w_build_document(get_blog_post($blog_id, $postid), substr(get_bloginfo('wpurl'), 7), $current_site->path);
                $cnt++;
                if ($cnt == $batchsize) {
                    s4w_post($documents, false, false);
                    s4w_post(false, true, false);
                    wp_cache_flush();
                    $cnt = 0;
                    $documents = array();
                }
            }
            // post the documents to Solr
            // and reset the batch counters
            s4w_post($documents, false, false);
            s4w_post(false, true, false);
            $cnt = 0;
            $documents = array();
            syslog(LOG_ERR, "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 {
        $posts = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' {$where_and} ORDER BY ID;");
        $postcount = count($posts);
        for ($idx = 0; $idx < $postcount; $idx++) {
            $postid = $posts[$idx]->ID;
            $last = $postid;
            $percent = floatval($idx) / floatval($postcount) * 100;
            if ($prev && !$found) {
                if ($postid === $prev) {
                    $found = TRUE;
                }
                continue;
            }
            if ($idx === $postcount - 1) {
                $end = TRUE;
            }
            $documents[] = s4w_build_document(get_post($postid));
            $cnt++;
            if ($cnt == $batchsize) {
                s4w_post($documents, FALSE, FALSE);
                $cnt = 0;
                $documents = array();
                wp_cache_flush();
                break;
            }
        }
    }
    if ($documents) {
        s4w_post($documents, FALSE, FALSE);
    }
    if ($end) {
        s4w_post(FALSE, TRUE, FALSE);
        printf("{\"type\": \"%s\", \"last\": \"%s\", \"end\": true, \"percent\": \"%.2f\"}", $type, $last, $percent);
    } else {
        printf("{\"type\": \"%s\", \"last\": \"%s\", \"end\": false, \"percent\": \"%.2f\"}", $type, $last, $percent);
    }
}
Пример #22
0
	function test_get_blog_post() {
		$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
		$blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) );
		$current_blog_id = get_current_blog_id();

		$post_id = $this->factory->post->create();
		$this->assertInstanceOf( 'WP_Post', get_post( $post_id ) );
		switch_to_blog( $blog_id );
		$this->assertNull( get_post( $post_id ) );
		$post = get_blog_post( $current_blog_id, $post_id );
		$this->assertInstanceOf( 'WP_Post', $post );
		$this->assertEquals( $post_id, $post->ID );
		restore_current_blog();

		wp_update_post( array( 'ID' => $post_id, 'post_title' => 'A Different Title' ) );
		switch_to_blog( $blog_id );
		$post = get_blog_post( $current_blog_id, $post_id );
		// Make sure cache is good
		$this->assertEquals( 'A Different Title', $post->post_title );

		$post_id2 = $this->factory->post->create();
		// Test get_blog_post() with currently active blog ID.
		$post = get_blog_post( $blog_id, $post_id2 );
		$this->assertInstanceOf( 'WP_Post', $post );
		$this->assertEquals( $post_id2, $post->ID );
		restore_current_blog();
	}
Пример #23
0
			<?php 
    if (WP_NETWORK_ADMIN) {
        ?>
<th>Blog</th><?php 
    }
    ?>
			<th>Title</th>
			<th>Total</th>
			<th>Votes up</th>
			<th>Votes down</th>
		</tr>
	</thead>
<?php 
    foreach ($overall as $post) {
        if (WP_NETWORK_ADMIN) {
            $data = get_blog_post($post['blog_id'], $post['post_id']);
            if (!$data) {
                continue;
            }
            $blog_name = get_blog_option($post['blog_id'], 'blogname');
            $blog_url = get_blog_option($post['blog_id'], 'siteurl');
        }
        $title = WP_NETWORK_ADMIN ? $data->post_title : $post['post_title'];
        $permalink = WP_NETWORK_ADMIN ? get_blog_permalink($post['blog_id'], $post['post_id']) : get_permalink($post['ID']);
        $results = $this->model->get_stats($post['post_id'], $post['blog_id'], $post['site_id']);
        ?>
		<tr>
			<?php 
        if (WP_NETWORK_ADMIN) {
            ?>
<td><b><a href="<?php 
Пример #24
0
 /**
  * Will save the current instance into the database, along with location information if a new one was created and return true if successful, false if not.
  * Will automatically detect whether it's a new or existing event. 
  * @return boolean
  */
 function save()
 {
     global $wpdb, $current_user, $blog_id, $EM_SAVING_EVENT;
     $EM_SAVING_EVENT = true;
     if (!$this->can_manage('edit_events', 'edit_others_events') && !(get_option('dbem_events_anonymous_submissions') && empty($this->event_id))) {
         //unless events can be submitted by an anonymous user (and this is a new event), user must have permissions.
         return apply_filters('em_event_save', false, $this);
     }
     remove_action('save_post', array('EM_Event_Post_Admin', 'save_post'), 10, 1);
     //disable the default save post action, we'll do it manually this way
     do_action('em_event_save_pre', $this);
     $post_array = array();
     //Deal with updates to an event
     if (!empty($this->post_id)) {
         //get the full array of post data so we don't overwrite anything.
         if (!empty($this->blog_id) && is_multisite()) {
             $post_array = (array) get_blog_post($this->blog_id, $this->post_id);
         } else {
             $post_array = (array) get_post($this->post_id);
         }
     }
     //Overwrite new post info
     $post_array['post_type'] = $this->recurrence && get_option('dbem_recurrence_enabled') ? 'event-recurring' : EM_POST_TYPE_EVENT;
     $post_array['post_title'] = $this->event_name;
     $post_array['post_content'] = $this->post_content;
     $post_array['post_excerpt'] = $this->post_excerpt;
     //decide on post status
     if (empty($this->force_status)) {
         if (count($this->errors) == 0) {
             $post_array['post_status'] = $this->can_manage('publish_events', 'publish_events') ? 'publish' : 'pending';
         } else {
             $post_array['post_status'] = 'draft';
         }
     } else {
         $post_array['post_status'] = $this->force_status;
     }
     //anonymous submission only
     if (!is_user_logged_in() && get_option('dbem_events_anonymous_submissions') && empty($this->event_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 info we'll put into the db
         $post_data = get_post($post_id);
         $this->post_id = $post_id;
         $this->event_slug = $post_data->post_name;
         $this->event_owner = $post_data->post_author;
         $this->post_status = $post_data->post_status;
         $this->get_status();
         //Categories? note that categories will soft-fail, so no errors
         $this->get_categories()->event_id = $this->event_id;
         $this->categories->post_id = $this->post_id;
         $this->categories->save();
         //anonymous submissions should save this information
         if (!empty($this->event_owner_anonymous)) {
             update_post_meta($this->post_id, '_event_owner_anonymous', 1);
             update_post_meta($this->post_id, '_event_owner_name', $this->event_owner_name);
             update_post_meta($this->post_id, '_event_owner_email', $this->event_owner_email);
         }
         //save the image
         $this->image_upload();
         //now save the meta
         $meta_save = $this->save_meta();
         $image_save = count($this->errors) == 0;
         //whilst it might not be an image save that fails, we can know something went wrong
     }
     $result = $meta_save && $post_save && $image_save;
     if ($result) {
         $this->load_postdata($post_data, $blog_id);
     }
     //reload post info
     //do a dirty update for location too if it's not published
     if ($this->is_published() && !empty($this->location_id)) {
         $EM_Location = $this->get_location();
         if ($EM_Location->location_status !== 1) {
             //let's also publish the location
             $EM_Location->set_status(1, true);
         }
     }
     $return = apply_filters('em_event_save', $result, $this);
     $EM_SAVING_EVENT = false;
     return $return;
 }
 function render_output($wgt_miss, $wgt_count, $wgt_format, $wgt_avsize, $wgt_defav, $wgt_dt, $before_item, $after_item, $before_cont, $after_cont, $wgt_white, $comment_type)
 {
     global $DiamondCache;
     $cachekey = 'diamond_comments_' . 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 . '-' . $comment_type;
     $output = $DiamondCache->get($cachekey, 'recent-comments');
     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;
     }
     $first_comment = __('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.');
     $first_comment = get_site_option('first_comment', $first_comment);
     $sqlstr = '';
     $where_comment_type = " and (comment_type = '' or comment_type is null) ";
     if ($comment_type != '') {
         $where_comment_type = " AND comment_type = '" . $comment_type . "' ";
     }
     $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, comment_date, comment_id, comment_post_id, comment_content, comment_date_gmt, comment_author, comment_author_email from " . $table_prefix . "comments where comment_approved = 1 " . $where_comment_type . " and comment_content <> '" . $first_comment . "'";
     }
     $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, comment_date, comment_id, comment_post_id, comment_content, comment_date_gmt, comment_author, comment_author_email   from " . $table_prefix . $blog['blog_id'] . "_comments where comment_approved = 1  " . $where_comment_type . " and comment_content <> '" . $first_comment . "'";
         }
     }
     $limit = '';
     if ((int) $wgt_count > 0) {
         $limit = ' LIMIT 0, ' . (int) $wgt_count;
     }
     $sqlstr .= " ORDER BY comment_date_gmt desc " . $limit;
     // echo $sqlstr;
     $output = '';
     $comm_list = $wpdb->get_results($sqlstr, ARRAY_A);
     $output .= $before_cont;
     foreach ($comm_list as $comm) {
         $output .= $before_item;
         $wgt_format = get_format_txt($wgt_format);
         $txt = $wgt_format == '' ? '<strong>{title}</strong> - {date}' : $wgt_format;
         $p = get_blog_post($comm["blog_id"], $comm["comment_post_id"]);
         $c = $comm['comment_content'];
         $av = get_avatar($comm['comment_author_email'], $wgt_avsize, $defav);
         if (strlen($c) > 50) {
             $c = mb_substr(strip_tags($c), 0, 51) . '...';
         }
         $txt = str_replace('{title}', '<a href="' . get_blog_permalink($comm["blog_id"], $comm["comment_post_id"]) . '#comment-' . $comm["comment_id"] . '">' . $c . '</a>', $txt);
         $txt = str_replace('{title_txt}', $c, $txt);
         $txt = str_replace('{author}', $comm['comment_author'], $txt);
         $txt = str_replace('{avatar}', $av, $txt);
         $txt = str_replace('{post-title}', '<a href="' . get_blog_permalink($comm["blog_id"], $comm["comment_post_id"]) . '">' . $p->post_title . '</a>', $txt);
         $txt = str_replace('{post-title_txt}', $p->post_title, $txt);
         $txt = str_replace('{date}', date_i18n($wgt_dt, strtotime($comm['comment_date'])), $txt);
         $output .= $txt;
         $output .= $after_item;
     }
     $output .= $after_cont;
     if (false === $comm_list) {
         $output .= $wpdb->print_error();
     }
     $DiamondCache->add($cachekey, 'recent-comments', $output);
     return $output;
 }