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;
     }
 }
Exemple #2
0
 function rewrite_urls($replace, $object, $result)
 {
     global $wp_query, $wp_rewrite;
     if ($wp_rewrite->using_permalinks() && !defined('EM_DISABLE_PERMALINKS')) {
         switch ($result) {
             case '#_EVENTPAGEURL':
                 //Depreciated
             //Depreciated
             case '#_LINKEDNAME':
                 //Depreciated
             //Depreciated
             case '#_EVENTURL':
                 //Just the URL
             //Just the URL
             case '#_EVENTLINK':
                 //HTML Link
                 if (is_object($object) && get_class($object) == 'EM_Event') {
                     $EM_URI = EM_URI;
                     if (is_multisite() && get_site_option('dbem_ms_global_events') && get_site_option('dbem_ms_global_events_links') && !empty($object->blog_id) && is_main_site() && $object->blog_id != get_current_blog_id()) {
                         $EM_URI = get_blog_permalink($object->blog_id, get_blog_option($object->blog_id, 'dbem_events_page'));
                     }
                     $event_link = trailingslashit(trailingslashit($EM_URI) . 'event/' . $object->slug);
                     if ($result == '#_LINKEDNAME' || $result == '#_EVENTLINK') {
                         $replace = "<a href='{$event_link}' title='{$object->name}'>{$object->name}</a>";
                     } else {
                         $replace = $event_link;
                     }
                 }
                 break;
             case '#_LOCATIONURL':
             case '#_LOCATIONLINK':
             case '#_LOCATIONPAGEURL':
                 //Depreciated
                 if (is_object($object) && get_class($object) == 'EM_Location') {
                     $link = trailingslashit(trailingslashit(EM_URI) . 'location/' . $object->slug);
                     $replace = $result == '#_LOCATIONURL' || $result == '#_LOCATIONPAGEURL' ? $link : '<a href="' . $link . '">' . $object->name . '</a>';
                 }
                 break;
             case '#_CATEGORYLINK':
             case '#_CATEGORYURL':
                 if (is_object($object) && get_class($object) == 'EM_Category') {
                     $link = trailingslashit(trailingslashit(EM_URI) . 'category/' . $object->slug);
                     $replace = $result == '#_CATEGORYURL' ? $link : '<a href="' . $link . '">' . $object->name . '</a>';
                 }
                 break;
         }
     }
     return $replace;
 }
Exemple #3
0
 public function getGroupList()
 {
     global $wpdb;
     $group_l = array();
     $group_id = array(0 => "自由博客", 1 => "运维部", 2 => "PHP部", 3 => "JAVA部", 4 => "Apple", 5 => "前端");
     foreach ($group_id as $id => $v) {
         $r = array();
         $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE\n\t\t\tpublic = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND blog_id != '1' and group_id = {$id}\n\t\t\tORDER BY last_updated DESC limit 5");
         foreach ($blogs as $blog) {
             $blogPostsTable = "wp_" . $blog . "_posts";
             $thispost = $wpdb->get_results("SELECT id, post_title\n\t\t\t\tFROM {$blogPostsTable} WHERE post_status = 'publish' AND post_type = 'post'\n\t\t\t\tORDER BY id DESC limit 0,1");
             $thispermalink = get_blog_permalink($blog, $thispost[0]->id);
             $m = array_merge((array) $thispost[0], array("url" => $thispermalink));
             array_push($r, $m);
         }
         $mm = array($id => array($r, "title" => $v));
         $group_l += $mm;
     }
     return $group_l;
 }
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $limit = (int) $instance['limit'];
     $events = Eab_Network::get_upcoming_events($limit);
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     if ($events) {
         echo '<ul>';
         foreach ($events as $event) {
             echo '<li><a href="' . get_blog_permalink($event->blog_id, $event->ID) . '">' . $event->post_title . '</a>' . '</li>';
         }
         echo '</ul>';
     } else {
         echo '<p class="eab-widget-no_events">' . __('No upcoming events on network', $this->translation_domain) . '</p>';
     }
     echo $after_widget;
 }
 public static function get_archive_content($post, $content = false)
 {
     $event = $post instanceof Eab_EventModel ? $post : new Eab_EventModel($post);
     if ('incsub_event' != $event->get_type()) {
         return $content;
     }
     $start_day = date_i18n('m', $event->get_start_timestamp());
     $network = $event->from_network();
     $link = $network ? get_blog_permalink($network, $event->get_id()) : get_permalink($event->get_id());
     $new_content = '';
     $new_content .= '<div class="event ' . self::get_status_class($event) . '" itemscope itemtype="http://schema.org/Event">';
     $new_content .= '<meta itemprop="name" content="' . esc_attr($event->get_title()) . '" />';
     $new_content .= '<a href="' . $link . '" class="wpmudevevents-viewevent">' . __('View event', Eab_EventsHub::TEXT_DOMAIN) . '</a>';
     $new_content .= apply_filters('eab-template-archive_after_view_link', '', $event);
     $new_content .= '<div style="clear: both;"></div>';
     $new_content .= '<hr />';
     $new_content .= self::get_event_details($event);
     $new_content .= self::get_rsvp_form($event);
     $new_content .= '</div>';
     $new_content .= '<div style="clear:both"></div>';
     return $new_content;
 }
Exemple #6
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;
 }
 /**
  * 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 '';
 }
 function get_edit_url()
 {
     if ($this->can_manage('edit_locations', 'edit_others_locations')) {
         if (EM_MS_GLOBAL) {
             global $current_site, $current_blog;
             if (get_site_option('dbem_ms_mainblog_locations')) {
                 //location stored as post on main blog, but can be edited either in sub-blog admin area or if not on main blog
                 if (get_blog_option($this->blog_id, 'dbem_edit_locations_page') && !is_admin()) {
                     $link = em_add_get_params(get_blog_permalink($this->blog_id, get_blog_option($this->blog_id, 'dbem_edit_locations_page')), array('action' => 'edit', 'location_id' => $this->location_id), false);
                 }
                 if ((is_main_site() || empty($link)) && get_blog_option($current_site->blog_id, 'dbem_edit_locations_page') && !is_admin()) {
                     //if editing on main site and edit page exists, stay on same site
                     $link = em_add_get_params(get_blog_permalink(get_option('dbem_edit_locations_page')), array('action' => 'edit', 'location_id' => $this->location_id), false);
                 }
                 if (empty($link) && !is_main_site()) {
                     $link = get_admin_url($current_blog->blog_id, "edit.php?post_type=event&page=locations&action=edit&location_id={$this->location_id}");
                 } elseif (empty($link) && is_main_site()) {
                     $link = get_admin_url($current_site->blog_id, "post.php?post={$this->post_id}&action=edit");
                 }
             } else {
                 //location stored as post on blog where location was created
                 if (get_blog_option($this->blog_id, 'dbem_edit_locations_page') && !is_admin()) {
                     $link = em_add_get_params(get_blog_permalink($this->blog_id, get_blog_option($this->blog_id, 'dbem_edit_locations_page')), array('action' => 'edit', 'location_id' => $this->location_id), false);
                 }
                 if ((is_main_site() || empty($link)) && get_blog_option($current_site->blog_id, 'dbem_edit_locations_page') && !is_admin()) {
                     //if editing on main site and edit page exists, stay on same site
                     $link = em_add_get_params(get_blog_permalink($current_site->blog_id, get_blog_option($current_site->blog_id, 'dbem_edit_locations_page')), array('action' => 'edit', 'location_id' => $this->location_id), false);
                 }
                 if (empty($link)) {
                     $link = get_admin_url($this->blog_id, "post.php?post={$this->post_id}&action=edit");
                 }
             }
         } else {
             if (get_option('dbem_edit_locations_page') && !is_admin()) {
                 $link = em_add_get_params(get_permalink(get_option('dbem_edit_locations_page')), array('action' => 'edit', 'location_id' => $this->location_id), false);
             }
             if (empty($link)) {
                 $link = admin_url() . "post.php?post={$this->post_id}&action=edit";
             }
         }
         return apply_filters('em_location_get_edit_url', $link, $this);
     }
 }
Exemple #9
0
 /**
  * HideMyWP::custom_404_page()
  * 
  * @param mixed $templates
  * @return
  */
 function custom_404_page($templates)
 {
     global $current_user;
     $visitor = esc_attr(is_user_logged_in() ? $current_user->user_login : $_SERVER["REMOTE_ADDR"]);
     if (is_multisite()) {
         $permalink = get_blog_permalink(BLOG_ID_CURRENT_SITE, $this->opt('custom_404_page'));
     } else {
         $permalink = get_permalink($this->opt('custom_404_page'));
     }
     if ($this->opt('custom_404') && $this->opt('custom_404_page')) {
         wp_redirect(add_query_arg(array('by_user' => $visitor, 'ref_url' => urldecode($_SERVER["REQUEST_URI"])), $permalink));
     } else {
         return $templates;
     }
     die;
 }
Exemple #10
0
 /**
  * Gets the permalink for the given post on the given blog.
  *
  * This gets the permalink for the post on the requested blog when in
  * multisite mode, or on the root blog when running a standard installation.
  *
  * @param  int    $blog_id the ID of a blog
  * @param  int    $post_id the ID of a post on the blog
  * @return string          the URL for the blog
  *
  * @since 0.4
  */
 public static function get_blog_permalink($blog_id, $post_id)
 {
     if (function_exists('get_blog_permalink')) {
         return get_blog_permalink($blog_id, $post_id);
     } else {
         return get_permalink($post_id);
     }
 }
Exemple #11
0
function xpress_grobal_recent_posts($num = 10,$exclusion_blog = 0, $shown_for_each_blog = false)
{
	global $wpdb, $wp_rewrite , $switched , $blog_id;
	if (empty($date_format)) $date_format = get_settings('date_format');
	if (empty($time_format)) $time_format = get_settings('time_format');
	$exclusion = explode(',' , $exclusion_blog);


	$first_blogid = $blog_id;
	$num = (int)$num;
//	$wp_query->in_the_loop = true;		//for use the_tags() in multi lopp 
	$data_array = array();
	if (xpress_is_multiblog()){
		$blogs = get_blog_list(0,'all');
		foreach ($blogs AS $blog) {
			if (!in_array(0, $exclusion) && in_array($blog['blog_id'], $exclusion)) continue;
			switch_to_blog($blog['blog_id']);
			$wp_rewrite->init();  // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.

				if (empty($num)){
					query_posts("post_status=publish");
				} else {
					query_posts("showposts=$num&post_status=publish");
				}
				if (have_posts()){
					while(have_posts()){
						$data = new stdClass();
						
						the_post();
						ob_start();
							the_ID();
							$data->post_id = ob_get_contents();
						ob_end_clean();
						
						$data->blog_id = $blog['blog_id'];
						$data->blog_name = get_bloginfo('name');
						$data->blog_url = get_bloginfo('url');
						$data->blog_link = '<a href="' . $data->blog_url . '">' . $data->blog_name . '</a>' ;


						ob_start();
							the_title();
							$data->title = ob_get_contents();
						ob_end_clean();
						$data->post_permalink = get_blog_permalink($data->brog_id, $data->post_id);
						$data->title_link = '<a href="' . $data->post_permalink . '">' . $data->title . '</a>' ;

						ob_start();
							the_author_posts_link();
							$data->post_author = ob_get_contents();
						ob_end_clean();

						ob_start();
							the_category(' &bull; ');
							$data->post_category = ob_get_contents();
						ob_end_clean();	
						
						if (function_exists('the_tags')){
							ob_start();
								the_tags(__('Tags:', 'xpress') . ' ',' &bull; ','');
								$data->post_tags = ob_get_contents();
							ob_end_clean();	
						} else {
							$data->tags = '';
						}

						$data->the_content = xpress_the_content('echo=0');
						
						ob_start();
							the_content();
							$data->the_full_content = ob_get_contents();
						ob_end_clean();
						
						ob_start();
							the_modified_date($date_format);
							$data->post_modified_date = ob_get_contents();
						ob_end_clean();
							
						ob_start();
							the_modified_date($time_format);
							$data->post_modified_time = ob_get_contents();
						ob_end_clean();
						$data->post_modified_date_time = $data->post_modified_date . ' ' . $data->post_modified_time;
						
						ob_start();
							the_time('U');
							$data->post_unix_time = ob_get_contents();
						ob_end_clean();
						
						ob_start();
							the_time($date_format);
							$data->post_date = ob_get_contents();
						ob_end_clean();
						
						ob_start();
							the_time($time_format);
							$data->post_time = ob_get_contents();
						ob_end_clean();
						
						$data->post_date_time = $data->post_date . ' ' . $data->post_time;

						ob_start();
							comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
							$data->comments_link = ob_get_contents();
						ob_end_clean();
						
						$data->post_views = xpress_post_views_count('post_id=' . $data->post_id . '&blogid=' . $data->brog_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
						if (function_exists('the_qf_get_thumb_one')){
							$data->post_thumbnail = the_qf_get_thumb_one("num=0&width=120&tag=1","",$data->the_full_content);
						} else {
							$data->post_thumbnail = get_the_post_thumbnail(null,'thumbnail');
						}
						$data->author_avatar =get_avatar(get_the_author_meta('ID'),$size = '32');

						$data_array[] = $data;
	        		}  // end whilwe
				} // end if
			restore_current_blog();
//			$wp_rewrite->init();
		} // end foreach
//		switch_to_blog($first_blogid);
		$wp_rewrite->init(); // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.

		restore_current_blog();
	}
	if (!$shown_for_each_blog){
		usort($data_array, "the_time_cmp");
		if (!empty($num)){
			$data_array = array_slice($data_array,0,$num);
		}
	}
	return $data_array;
}
function network_latest_posts($parameters)
{
    // Global variables
    global $wpdb;
    //global $nlp_time_frame;
    // Default values
    $defaults = array('title' => NULL, 'number_posts' => 10, 'time_frame' => 0, 'title_only' => TRUE, 'display_type' => 'ulist', 'blog_id' => NULL, 'ignore_blog' => NULL, 'thumbnail' => FALSE, 'thumbnail_wh' => '80x80', 'thumbnail_class' => NULL, 'thumbnail_filler' => 'placeholder', 'thumbnail_custom' => FALSE, 'thumbnail_field' => NULL, 'thumbnail_url' => NULL, 'custom_post_type' => 'post', 'category' => NULL, 'tag' => NULL, 'paginate' => FALSE, 'posts_per_page' => NULL, 'display_content' => FALSE, 'excerpt_length' => NULL, 'auto_excerpt' => FALSE, 'excerpt_trail' => 'text', 'full_meta' => FALSE, 'sort_by_date' => FALSE, 'sort_by_blog' => FALSE, 'sorting_order' => NULL, 'sorting_limit' => NULL, 'post_status' => 'publish', 'css_style' => NULL, 'wrapper_list_css' => 'nav nav-tabs nav-stacked', 'wrapper_block_css' => 'content', 'instance' => NULL, 'random' => FALSE, 'post_ignore' => NULL);
    // Parse & merge parameters with the defaults
    $settings = wp_parse_args($parameters, $defaults);
    // Paranoid mode activated (yes I'm a security freak)
    foreach ($settings as $parameter => $value) {
        // Strip everything
        $settings[$parameter] = strip_tags($value);
    }
    // Extract each parameter as its own variable
    extract($settings, EXTR_SKIP);
    // If no instance was set, make one
    if (empty($instance)) {
        $instance = 'default';
    }
    // HTML Tags
    $html_tags = nlp_display_type($display_type, $instance, $wrapper_list_css, $wrapper_block_css);
    // If Custom CSS
    if (!empty($css_style)) {
        // If RTL
        if (is_rtl()) {
            // Tell WordPress this plugin is switching to RTL mode
            /* Set the text direction to RTL
             * This two variables will tell load-styles.php
             * load the Dashboard in RTL instead of LTR mode
             */
            global $wp_locale, $wp_styles;
            $wp_locale->text_direction = 'rtl';
            $wp_styles->text_direction = 'rtl';
        }
        // File path
        $cssfile = get_stylesheet_directory_uri() . '/' . $css_style . '.css';
        // Load styles
        nlp_load_styles($cssfile);
    }
    // Display blog or blogs
    // if the user passes one value
    if (!preg_match("/,/", $blog_id)) {
        // Always clean this stuff ;) (oh.. told you I'm a paranoid)
        $blog_id = (int) htmlspecialchars($blog_id);
        // Check if it's numeric
        if (is_numeric($blog_id)) {
            // and put the sql
            $display = " AND blog_id = {$blog_id} ";
        }
        // if the user passes more than one value separated by commas
    } else {
        // create an array
        $display_arr = explode(",", $blog_id);
        // and repeat the sql for each ID found
        for ($counter = 0; $counter < count($display_arr); $counter++) {
            // Add AND the first time
            if ($counter == 0) {
                $display .= " AND blog_id = " . (int) $display_arr[$counter];
                // Add OR the rest of the time
            } else {
                $display .= " OR blog_id = " . (int) $display_arr[$counter];
            }
        }
    }
    // Ignore blog or blogs
    // if the user passes one value
    if (!preg_match("/,/", $ignore_blog)) {
        // Always clean this stuff ;)
        $ignore_blog = (int) htmlspecialchars($ignore_blog);
        // Check if it's numeric
        if (is_numeric($ignore_blog)) {
            // and put the sql
            $ignore = " AND blog_id != {$ignore_blog} ";
        }
        // if the user passes more than one value separated by commas
    } else {
        // create an array
        $ignore_arr = explode(",", $ignore_blog);
        // and repeat the sql for each ID found
        for ($counter = 0; $counter < count($ignore_arr); $counter++) {
            $ignore .= " AND blog_id != " . (int) $ignore_arr[$counter];
        }
    }
    // If multiple tags found, set an array
    if (preg_match("/,/", $tag)) {
        $tag = explode(",", $tag);
    } else {
        if (!empty($tag)) {
            $tag = str_split($tag, strlen($tag));
        }
    }
    // If multiple categories found, set an array
    if (preg_match("/,/", $category)) {
        $category = explode(",", $category);
    } else {
        if (!empty($category)) {
            $category = str_split($category, strlen($category));
        }
    }
    // If multiple post type found, set an array
    if (preg_match("/,/", $custom_post_type)) {
        $custom_post_type = explode(",", $custom_post_type);
    } else {
        if (!empty($category)) {
            $custom_post_type = str_split($custom_post_type, strlen($custom_post_type));
        }
    }
    // Paranoid ;)
    $time_frame = (int) $time_frame;
    // Get the list of blogs in order of most recent update, get only public and nonarchived/spam/mature/deleted
    if ($time_frame > 0) {
        // By blog ID except those ignored
        if (!empty($blog_id) && $blog_id != NULL) {
            $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE\n                public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' {$display}\n                    {$ignore} AND last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL {$time_frame} DAY)\n                        ORDER BY last_updated DESC");
            // Everything but ignored blogs
        } else {
            $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE\n                public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'\n                    {$ignore} AND last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL {$time_frame} DAY)\n                        ORDER BY last_updated DESC");
        }
        // Everything written so far
    } else {
        // By blog ID except those ignored
        if (!empty($blog_id) && $blog_id != NULL) {
            $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE\n                public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' {$display}\n                    {$ignore} ORDER BY last_updated DESC");
            // Everything but ignored blogs
        } else {
            $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE\n                public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'\n                    {$ignore} ORDER BY last_updated DESC");
        }
    }
    // Ignore one or many posts
    // if the user passes one value
    if (!preg_match("/,/", $post_ignore)) {
        // Always clean this stuff ;) (oh.. told you I'm a paranoid)
        $post_ignore = array(0 => (int) htmlspecialchars($post_ignore));
        // if the user passes more than one value separated by commas
    } else {
        // create an array
        $post_ignore = explode(",", $post_ignore);
    }
    // If it found something
    if ($blogs) {
        // Count blogs found
        $count_blogs = count($blogs);
        // Dig into each blog
        foreach ($blogs as $blog_key) {
            // Options: Site URL, Blog Name, Date Format
            ${'blog_url_' . $blog_key} = get_blog_option($blog_key, 'siteurl');
            ${'blog_name_' . $blog_key} = get_blog_option($blog_key, 'blogname');
            ${'date_format_' . $blog_key} = get_blog_option($blog_key, 'date_format');
            // Orderby
            if ($random == 'true') {
                $orderby = 'rand';
            } else {
                $orderby = 'post_date';
            }
            // Categories or Tags
            if (!empty($category) && !empty($tag)) {
                $args = array('tax_query' => array('relation' => 'OR', array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $category), array('taxonomy' => 'post_tag', 'field' => 'slug', 'terms' => $tag)), 'numberposts' => $number_posts, 'post_status' => $post_status, 'post_type' => $custom_post_type, 'orderby' => $orderby);
            }
            // Categories only
            if (!empty($category) && empty($tag)) {
                $args = array('tax_query' => array(array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $category)), 'numberposts' => $number_posts, 'post_status' => $post_status, 'post_type' => $custom_post_type, 'orderby' => $orderby);
            }
            // Tags only
            if (!empty($tag) && empty($category)) {
                $args = array('tax_query' => array(array('taxonomy' => 'post_tag', 'field' => 'slug', 'terms' => $tag)), 'numberposts' => $number_posts, 'post_status' => $post_status, 'post_type' => $custom_post_type, 'orderby' => $orderby);
            }
            // Everything by Default
            if (empty($category) && empty($tag)) {
                // By default
                $args = array('numberposts' => $number_posts, 'post_status' => $post_status, 'post_type' => $custom_post_type, 'orderby' => $orderby);
            }
            // Switch to the blog
            switch_to_blog($blog_key);
            // Get posts
            ${'posts_' . $blog_key} = get_posts($args);
            // Check if posts with the defined criteria were found
            if (empty(${'posts_' . $blog_key})) {
                /* If no posts matching the criteria were found then
                 * move to the next blog
                 */
                next($blogs);
            }
            // Put everything inside an array for sorting purposes
            foreach (${'posts_' . $blog_key} as $post) {
                // Access all post data
                setup_postdata($post);
                // Sort by blog ID
                if ($sort_by_blog == 'true') {
                    // Ignore Posts
                    if (!in_array($post->ID, $post_ignore)) {
                        // Put inside another array and use blog ID as keys
                        $all_posts[$blog_key . $post->post_modified] = $post;
                    }
                } else {
                    // Ignore Posts
                    if (!in_array($post->ID, $post_ignore)) {
                        // Put everything inside another array using the modified date as
                        // the array keys
                        $all_posts[$post->post_modified] = $post;
                    }
                }
                // The guid is the only value which can differenciate a post from
                // others in the whole network
                $all_permalinks[$post->guid] = get_blog_permalink($blog_key, $post->ID);
                $all_blogkeys[$post->guid] = $blog_key;
            }
            // Back the current blog
            restore_current_blog();
        }
        // If no content was found
        if (empty($all_posts)) {
            // Nothing to do here, let people know and get out of here
            echo "<div class='alert'><p>" . __("Sorry, I couldn't find any recent posts matching your parameters.", "trans-nlp") . "</p></div>";
            return;
        }
        // Sort by date (regardless blog IDs)
        if ($sort_by_date == 'true') {
            // Sorting order (newer / older)
            if (!empty($sorting_order)) {
                switch ($sorting_order) {
                    // From newest to oldest
                    case "newer":
                        // Sort the array
                        @krsort($all_posts);
                        // Limit the number of posts
                        if (!empty($sorting_limit)) {
                            $all_posts = @array_slice($all_posts, 0, $sorting_limit, true);
                        }
                        break;
                        // From oldest to newest
                    // From oldest to newest
                    case "older":
                        // Sort the array
                        @ksort($all_posts);
                        // Limit the number of posts
                        if (!empty($sorting_limit)) {
                            $all_posts = @array_slice($all_posts, 0, $sorting_limit, true);
                        }
                        break;
                        // Newest to oldest by default
                    // Newest to oldest by default
                    default:
                        // Sort the array
                        @krsort($all_posts);
                        // Limit the number of posts
                        if (!empty($sorting_limit)) {
                            $all_posts = @array_slice($all_posts, 0, $sorting_limit, true);
                        }
                        break;
                }
            } else {
                // Sort the array
                @krsort($all_posts);
                // Limit the number of posts
                if (!empty($sorting_limit)) {
                    $all_posts = @array_slice($all_posts, 0, $sorting_limit, true);
                }
            }
        }
        // Sort by blog ID
        if ($sort_by_blog == 'true') {
            // Sorting order (newer / older)
            if (!empty($sorting_order)) {
                switch ($sorting_order) {
                    // Ascendant
                    case "asc":
                        // Sort the array
                        @ksort($all_posts);
                        // Limit the number of posts
                        if (!empty($sorting_limit)) {
                            $all_posts = @array_slice($all_posts, 0, $sorting_limit, true);
                        }
                        break;
                        // Descendant
                    // Descendant
                    case "desc":
                        // Sort the array
                        @krsort($all_posts);
                        // Limit the number of posts
                        if (!empty($sorting_limit)) {
                            $all_posts = @array_slice($all_posts, 0, $sorting_limit, true);
                        }
                        break;
                        // Newest to oldest by default
                    // Newest to oldest by default
                    default:
                        // Sort the array
                        @krsort($all_posts);
                        // Limit the number of posts
                        if (!empty($sorting_limit)) {
                            $all_posts = @array_slice($all_posts, 0, $sorting_limit, true);
                        }
                        break;
                }
            } else {
                // Sort the array
                @ksort($all_posts);
                // Limit the number of posts
                if (!empty($sorting_limit)) {
                    $all_posts = @array_slice($all_posts, 0, $sorting_limit, true);
                }
            }
        }
        // Open content box
        echo $html_tags['content_o'];
        // NLPosts title
        if (!empty($title)) {
            // Open widget title box
            echo $html_tags['wtitle_o'];
            // Print the title
            echo $title;
            // Close widget title box
            echo $html_tags['wtitle_c'];
        }
        // Open wrapper
        echo $html_tags['wrapper_o'];
        // Paginate results
        if ($paginate && $posts_per_page) {
            // Page number
            $pag = isset($_GET['pag']) ? abs((int) $_GET['pag']) : 1;
            // Break all posts into pages
            $pages = array_chunk($all_posts, $posts_per_page);
            // Set the page number variable
            add_query_arg('pag', '%#%');
            // Print out the posts
            foreach ($pages[$pag - 1] as $field) {
                // Open item box
                $item_o = $html_tags['item_o'];
                $item_o = str_replace("'>", " nlposts-siteid-" . $all_blogkeys[$field->guid] . "'>", $item_o);
                echo $item_o;
                // Thumbnails
                if ($thumbnail === 'true') {
                    // Open thumbnail container
                    echo $html_tags['thumbnail_o'];
                    // Open thumbnail item placeholder
                    echo $html_tags['thumbnail_io'];
                    // Switch to the blog
                    switch_to_blog($all_blogkeys[$field->guid]);
                    // Put the dimensions into an array
                    $thumbnail_size = str_replace('x', ',', $thumbnail_wh);
                    $thumbnail_size = explode(',', $thumbnail_size);
                    if ($thumbnail_custom != 'true' && $thumbnail_field == NULL) {
                        // Get the thumbnail
                        $thumb_html = get_the_post_thumbnail($field->ID, $thumbnail_size, array('class' => $thumbnail_class, 'alt' => $field->post_title, 'title' => $field->post_title));
                    } else {
                        $thumbnail_custom_field = get_post_meta($field->ID, $thumbnail_field, true);
                        if (!empty($thumbnail_custom_field)) {
                            // Get custom thumbnail
                            $thumb_html = "<img src='" . $thumbnail_custom_field . "' width='" . $thumbnail_size[0] . "' height='" . $thumbnail_size[1] . " alt='" . $field->post_title . "' title='" . $field->post_title . "' />";
                        } else {
                            // Get the regular thumbnail
                            $thumb_html = get_the_post_thumbnail($field->ID, $thumbnail_size, array('class' => $thumbnail_class, 'alt' => $field->post_title, 'title' => $field->post_title));
                        }
                    }
                    // If there is a thumbnail
                    if (!empty($thumb_html)) {
                        // Display the thumbnail
                        echo "<a href='" . $all_permalinks[$field->guid] . "'>{$thumb_html}</a>";
                        // Thumbnail not found
                    } else {
                        // Put a placeholder with the post title
                        switch ($thumbnail_filler) {
                            // Placeholder provided by Placehold.it
                            case 'placeholder':
                                echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placehold.it/" . $thumbnail_wh . "&text=" . $field->post_title . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                break;
                                // Just for fun Kittens thanks to PlaceKitten
                            // Just for fun Kittens thanks to PlaceKitten
                            case 'kittens':
                                echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placekitten.com/" . $thumbnail_size[0] . "/" . $thumbnail_size[1] . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                break;
                                // More fun Puppies thanks to PlaceDog
                            // More fun Puppies thanks to PlaceDog
                            case 'puppies':
                                echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placedog.com/" . $thumbnail_size[0] . "/" . $thumbnail_size[1] . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                break;
                            case 'custom':
                                if (!empty($thumbnail_url)) {
                                    echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='" . $thumbnail_url . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' width='" . $thumbnail_size[0] . "' height='" . $thumbnail_size[1] . "' /></a>";
                                } else {
                                    echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placehold.it/" . $thumbnail_wh . "&text=" . $field->post_title . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                }
                                break;
                                // Boring by default ;)
                            // Boring by default ;)
                            default:
                                echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placehold.it/" . $thumbnail_wh . "&text=" . $field->post_title . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                break;
                        }
                    }
                    // Back the current blog
                    restore_current_blog();
                    // Open title box
                    echo $html_tags['title_o'];
                    // Print the title
                    echo "<a href='" . $all_permalinks[$field->guid] . "'>" . $field->post_title . "</a>";
                    // Close the title box
                    echo $html_tags['title_c'];
                    if ($full_meta === 'true') {
                        // Open meta box
                        echo $html_tags['meta_o'];
                        // Set metainfo
                        $author = get_user_by('id', $field->post_author);
                        $format = (string) ${'date_format_' . $all_blogkeys[$field->guid]};
                        $datepost = date_i18n($format, strtotime(trim($field->post_date)));
                        $blog_name = '<a href="' . ${'blog_url_' . $all_blogkeys[$field->guid]} . '">' . ${'blog_name_' . $all_blogkeys[$field->guid]} . "</a>";
                        // The network's root (main blog) is called 'blog',
                        // so we have to set this up because the url ignores the root's subdirectory
                        if ($all_blogkeys[$field->guid] == 1) {
                            // Author's page for the main blog
                            $author_url = ${'blog_url_' . $all_blogkeys[$field->guid]} . '/blog/author/' . $author->user_login;
                        } else {
                            // Author's page for other blogs
                            $author_url = ${'blog_url_' . $all_blogkeys[$field->guid]} . '/author/' . $author->user_login;
                        }
                        // Print metainfo
                        echo $blog_name . ' - ' . __('Published on', 'trans-nlp') . ' ' . $datepost . ' ' . __('by', 'trans-nlp') . ' ' . '<a href="' . $author_url . '">' . $author->display_name . '</a>';
                        // Close meta box
                        echo $html_tags['meta_c'];
                    }
                    // Print the content
                    if ($title_only === 'false') {
                        // Open excerpt wrapper
                        echo $html_tags['excerpt_o'];
                        // Display excerpts or content
                        if ($display_content != 'true') {
                            // Custom Excerpt
                            if ($auto_excerpt != 'true') {
                                // Print out the excerpt
                                echo nlp_custom_excerpt($excerpt_length, $field->post_excerpt, $all_permalinks[$field->guid], $excerpt_trail);
                                // Extract excerpt from content
                            } else {
                                // Get the excerpt
                                echo nlp_custom_excerpt($excerpt_length, $field->post_content, $all_permalinks[$field->guid], $excerpt_trail);
                            }
                        } else {
                            // Display post content
                            echo nl2br(do_shortcode($field->post_content));
                        }
                        // Close excerpt wrapper
                        echo $html_tags['excerpt_c'];
                    }
                    // Close thumbnail item placeholder
                    echo $html_tags['thumbnail_ic'];
                    // Close thumbnail container
                    echo $html_tags['thumbnail_c'];
                } else {
                    // Open title box
                    echo $html_tags['title_o'];
                    // Print the title
                    echo "<a href='" . $all_permalinks[$field->guid] . "'>" . $field->post_title . "</a>";
                    // Close the title box
                    echo $html_tags['title_c'];
                    if ($full_meta === 'true') {
                        // Open meta box
                        echo $html_tags['meta_o'];
                        // Set metainfo
                        $author = get_user_by('id', $field->post_author);
                        $format = (string) ${'date_format_' . $all_blogkeys[$field->guid]};
                        $datepost = date_i18n($format, strtotime(trim($field->post_date)));
                        $blog_name = '<a href="' . ${'blog_url_' . $all_blogkeys[$field->guid]} . '">' . ${'blog_name_' . $all_blogkeys[$field->guid]} . "</a>";
                        // The network's root (main blog) is called 'blog',
                        // so we have to set this up because the url ignores the root's subdirectory
                        if ($all_blogkeys[$field->guid] == 1) {
                            // Author's page for the main blog
                            $author_url = ${'blog_url_' . $all_blogkeys[$field->guid]} . '/blog/author/' . $author->user_login;
                        } else {
                            // Author's page for other blogs
                            $author_url = ${'blog_url_' . $all_blogkeys[$field->guid]} . '/author/' . $author->user_login;
                        }
                        // Print metainfo
                        echo $blog_name . ' - ' . __('Published on', 'trans-nlp') . ' ' . $datepost . ' ' . __('by', 'trans-nlp') . ' ' . '<a href="' . $author_url . '">' . $author->display_name . '</a>';
                        // Close meta box
                        echo $html_tags['meta_c'];
                    }
                    // Print the content
                    if ($title_only === 'false') {
                        // Open excerpt wrapper
                        echo $html_tags['excerpt_o'];
                        // Display excerpts or content
                        if ($display_content != 'true') {
                            // Custom Excerpt
                            if ($auto_excerpt != 'true') {
                                // Print out the excerpt
                                echo nlp_custom_excerpt($excerpt_length, $field->post_excerpt, $all_permalinks[$field->guid], $excerpt_trail);
                                // Extract excerpt from content
                            } else {
                                // Get the excerpt
                                echo nlp_custom_excerpt($excerpt_length, $field->post_content, $all_permalinks[$field->guid], $excerpt_trail);
                            }
                        } else {
                            // Display post content
                            echo nl2br(do_shortcode($field->post_content));
                        }
                        // Close excerpt wrapper
                        echo $html_tags['excerpt_c'];
                    }
                }
                // Close item box
                echo $html_tags['item_c'];
            }
            // Print out the pagination menu
            for ($i = 1; $i < count($pages) + 1; $i++) {
                // Count the number of pages
                $total += 1;
            }
            // Open pagination wrapper
            echo $html_tags['pagination_o'];
            echo paginate_links(array('base' => add_query_arg('pag', '%#%'), 'format' => '', 'prev_text' => __('&laquo;', 'trans-nlp'), 'next_text' => __('&raquo;', 'trans-nlp'), 'total' => $total, 'current' => $pag, 'type' => 'list'));
            // Close pagination wrapper
            echo $html_tags['pagination_c'];
            // Close wrapper
            echo $html_tags['wrapper_c'];
            /*
             * jQuery function
             * Asynchronous pagination links
             */
            echo '
            <script type="text/javascript" charset="utf-8">
                //<![CDATA[
                jQuery(document).ready(function(){
                    jQuery(".nlp-instance-' . $instance . ' .pagination a").live("click", function(e){
                        e.preventDefault();
                        var link = jQuery(this).attr("href");
                        jQuery(".nlp-instance-' . $instance . ' .nlposts-wrapper").html("<style type=\\"text/css\\">p.loading { text-align:center;margin:0 auto; padding:20px; }</style><p class=\\"loading\\"><img src=\\"' . plugins_url('/img/loader.gif', __FILE__) . '\\" /></p>");
                        jQuery(".nlp-instance-' . $instance . ' .nlposts-wrapper").fadeOut("slow",function(){
                            jQuery(".nlp-instance-' . $instance . ' .nlposts-wrapper").load(link+" .nlp-instance-' . $instance . ' .nlposts-wrapper > *").fadeIn(3000);
                        });

                    });
                });
                //]]>
            </script>';
            // Close content box
            echo $html_tags['content_c'];
            // Without pagination
        } else {
            // Print out the posts
            foreach ($all_posts as $field) {
                // Open item box
                $item_o = $html_tags['item_o'];
                $item_o = str_replace("'>", " nlposts-siteid-" . $all_blogkeys[$field->guid] . "'>", $item_o);
                echo $item_o;
                // Thumbnails
                if ($thumbnail === 'true') {
                    // Open thumbnail container
                    echo $html_tags['thumbnail_o'];
                    // Open thumbnail item placeholder
                    echo $html_tags['thumbnail_io'];
                    // Switch to the blog
                    switch_to_blog($all_blogkeys[$field->guid]);
                    // Put the dimensions into an array
                    $thumbnail_size = str_replace('x', ',', $thumbnail_wh);
                    $thumbnail_size = explode(',', $thumbnail_size);
                    if ($thumbnail_custom != 'true' && $thumbnail_field == NULL) {
                        // Get the thumbnail
                        $thumb_html = get_the_post_thumbnail($field->ID, $thumbnail_size, array('class' => $thumbnail_class, 'alt' => $field->post_title, 'title' => $field->post_title));
                    } else {
                        $thumbnail_custom_field = get_post_meta($field->ID, $thumbnail_field, true);
                        if (!empty($thumbnail_custom_field)) {
                            // Get custom thumbnail
                            $thumb_html = "<img src='" . $thumbnail_custom_field . "' width='" . $thumbnail_size[0] . "' height='" . $thumbnail_size[1] . " alt='" . $field->post_title . "' title='" . $field->post_title . "' />";
                        } else {
                            // Get the regular thumbnail
                            $thumb_html = get_the_post_thumbnail($field->ID, $thumbnail_size, array('class' => $thumbnail_class, 'alt' => $field->post_title, 'title' => $field->post_title));
                        }
                    }
                    // If there is a thumbnail
                    if (!empty($thumb_html)) {
                        // Display the thumbnail
                        echo "<a href='" . $all_permalinks[$field->guid] . "'>{$thumb_html}</a>";
                        // Thumbnail not found
                    } else {
                        // Put a placeholder with the post title
                        switch ($thumbnail_filler) {
                            // Placeholder provided by Placehold.it
                            case 'placeholder':
                                echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placehold.it/" . $thumbnail_wh . "&text=" . $field->post_title . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                break;
                                // Just for fun Kittens thanks to PlaceKitten
                            // Just for fun Kittens thanks to PlaceKitten
                            case 'kittens':
                                echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placekitten.com/" . $thumbnail_size[0] . "/" . $thumbnail_size[1] . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                break;
                                // More fun Puppies thanks to PlaceDog
                            // More fun Puppies thanks to PlaceDog
                            case 'puppies':
                                echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placedog.com/" . $thumbnail_size[0] . "/" . $thumbnail_size[1] . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                break;
                            case 'custom':
                                if (!empty($thumbnail_url)) {
                                    echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='" . $thumbnail_url . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                } else {
                                    echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placehold.it/" . $thumbnail_wh . "&text=" . $field->post_title . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                }
                                break;
                                // Boring by default ;)
                            // Boring by default ;)
                            default:
                                echo "<a href='" . $all_permalinks[$field->guid] . "'><img src='http://placehold.it/" . $thumbnail_wh . "&text=" . $field->post_title . "' alt='" . $field->post_title . "' title='" . $field->post_title . "' /></a>";
                                break;
                        }
                    }
                    // Back the current blog
                    restore_current_blog();
                    // Open title box
                    echo $html_tags['title_o'];
                    // Print the title
                    echo "<a href='" . $all_permalinks[$field->guid] . "'>" . $field->post_title . "</a>";
                    // Close the title box
                    echo $html_tags['title_c'];
                    if ($full_meta === 'true') {
                        // Open meta box
                        echo $html_tags['meta_o'];
                        // Set metainfo
                        $author = get_user_by('id', $field->post_author);
                        $format = (string) ${'date_format_' . $all_blogkeys[$field->guid]};
                        $datepost = date_i18n($format, strtotime(trim($field->post_date)));
                        $blog_name = '<a href="' . ${'blog_url_' . $all_blogkeys[$field->guid]} . '">' . ${'blog_name_' . $all_blogkeys[$field->guid]} . "</a>";
                        // The network's root (main blog) is called 'blog',
                        // so we have to set this up because the url ignores the root's subdirectory
                        if ($all_blogkeys[$field->guid] == 1) {
                            // Author's page for the main blog
                            $author_url = ${'blog_url_' . $all_blogkeys[$field->guid]} . '/blog/author/' . $author->user_login;
                        } else {
                            // Author's page for other blogs
                            $author_url = ${'blog_url_' . $all_blogkeys[$field->guid]} . '/author/' . $author->user_login;
                        }
                        // Print metainfo
                        echo $blog_name . ' - ' . __('Published on', 'trans-nlp') . ' ' . $datepost . ' ' . __('by', 'trans-nlp') . ' ' . '<a href="' . $author_url . '">' . $author->display_name . '</a>';
                        // Close meta box
                        echo $html_tags['meta_c'];
                    }
                    // Print the content
                    if ($title_only === 'false') {
                        // Open excerpt wrapper
                        echo $html_tags['excerpt_o'];
                        // Display excerpts or content
                        if ($display_content != 'true') {
                            // Custom Excerpt
                            if ($auto_excerpt != 'true') {
                                // Print out the excerpt
                                echo nlp_custom_excerpt($excerpt_length, $field->post_excerpt, $all_permalinks[$field->guid], $excerpt_trail);
                                // Extract excerpt from content
                            } else {
                                // Get the excerpt
                                echo nlp_custom_excerpt($excerpt_length, $field->post_content, $all_permalinks[$field->guid], $excerpt_trail);
                            }
                        } else {
                            // Display post content
                            echo nl2br(do_shortcode($field->post_content));
                        }
                        // Close excerpt wrapper
                        echo $html_tags['excerpt_c'];
                    }
                    // Close thumbnail item placeholder
                    echo $html_tags['thumbnail_ic'];
                    // Close thumbnail container
                    echo $html_tags['thumbnail_c'];
                } else {
                    // Open title box
                    echo $html_tags['title_o'];
                    // Print the title
                    echo "<a href='" . $all_permalinks[$field->guid] . "'>" . $field->post_title . "</a>";
                    // Close the title box
                    echo $html_tags['title_c'];
                    if ($full_meta === 'true') {
                        // Open meta box
                        echo $html_tags['meta_o'];
                        // Set metainfo
                        $author = get_user_by('id', $field->post_author);
                        $format = (string) ${'date_format_' . $all_blogkeys[$field->guid]};
                        $datepost = date_i18n($format, strtotime(trim($field->post_date)));
                        $blog_name = '<a href="' . ${'blog_url_' . $all_blogkeys[$field->guid]} . '">' . ${'blog_name_' . $all_blogkeys[$field->guid]} . "</a>";
                        // The network's root (main blog) is called 'blog',
                        // so we have to set this up because the url ignores the root's subdirectory
                        if ($all_blogkeys[$field->guid] == 1) {
                            // Author's page for the main blog
                            $author_url = ${'blog_url_' . $all_blogkeys[$field->guid]} . '/blog/author/' . $author->user_login;
                        } else {
                            // Author's page for other blogs
                            $author_url = ${'blog_url_' . $all_blogkeys[$field->guid]} . '/author/' . $author->user_login;
                        }
                        // Print metainfo
                        echo $blog_name . ' - ' . __('Published on', 'trans-nlp') . ' ' . $datepost . ' ' . __('by', 'trans-nlp') . ' ' . '<a href="' . $author_url . '">' . $author->display_name . '</a>';
                        // Close meta box
                        echo $html_tags['meta_c'];
                    }
                    // Print the content
                    if ($title_only === 'false') {
                        // Open excerpt wrapper
                        echo $html_tags['excerpt_o'];
                        // Display excerpts or content
                        if ($display_content != 'true') {
                            // Custom Excerpt
                            if ($auto_excerpt != 'true') {
                                // Print out the excerpt
                                echo nlp_custom_excerpt($excerpt_length, $field->post_excerpt, $all_permalinks[$field->guid], $excerpt_trail);
                                // Extract excerpt from content
                            } else {
                                // Get the excerpt
                                echo nlp_custom_excerpt($excerpt_length, $field->post_content, $all_permalinks[$field->guid], $excerpt_trail);
                            }
                        } else {
                            // Display post content
                            echo nl2br(do_shortcode($field->post_content));
                        }
                        // Close excerpt wrapper
                        echo $html_tags['excerpt_c'];
                    }
                }
                // Close item box
                echo $html_tags['item_c'];
            }
            // Close wrapper
            echo $html_tags['wrapper_c'];
            // Close content box
            echo $html_tags['content_c'];
        }
    }
    // Reset post data
    wp_reset_postdata();
}
Exemple #13
0
function _likebtn_get_entity_url($entity_name, $entity_id, $url = '', $blog_id = 0)
{
    if ($url) {
        return $url;
    }
    switch ($entity_name) {
        case LIKEBTN_ENTITY_COMMENT:
            if (!$blog_id) {
                $url = get_comment_link($entity_id);
            } else {
                $url = _likebtn_get_blog_comment_link($blog_id, $entity_id);
            }
            break;
        case LIKEBTN_ENTITY_BP_ACTIVITY_POST:
        case LIKEBTN_ENTITY_BP_ACTIVITY_UPDATE:
        case LIKEBTN_ENTITY_BP_ACTIVITY_COMMENT:
        case LIKEBTN_ENTITY_BP_ACTIVITY_TOPIC:
            if (function_exists('bp_activity_get_permalink')) {
                $url = bp_activity_get_permalink($entity_id);
            }
            break;
        case LIKEBTN_ENTITY_BP_MEMBER:
        case LIKEBTN_ENTITY_BBP_USER:
            if (function_exists('bp_core_get_user_domain')) {
                $url = bp_core_get_user_domain($entity_id);
            }
            break;
        case LIKEBTN_ENTITY_USER:
            $url = get_author_posts_url($entity_id);
            break;
        default:
            if (!$blog_id) {
                $url = get_permalink($entity_id);
            } else {
                $url = get_blog_permalink($blog_id, $entity_id);
            }
            break;
    }
    return $url;
}
    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 
    }
function likebtn_admin_statistics()
{
    global $likebtn_page_sizes;
    global $likebtn_post_statuses;
    global $wpdb;
    $query_parameters = array();
    $likebtn_entities = _likebtn_get_entities(true);
    // Custom item
    $likebtn_entities[LIKEBTN_ENTITY_CUSTOM_ITEM] = __('Custom item');
    // get parameters
    $entity_name = _likebtn_statistics_entity();
    // Process bulk actions
    //_likebtn_bulk_actions($entity_name);
    // Multisite - available for super admin only
    $blogs = array();
    $blog_list = array();
    $statistics_blog_id = '';
    $prefix_prepared = $wpdb->prefix;
    if (is_multisite() && is_super_admin()) {
        global $blog_id;
        $blog_list = $wpdb->get_results("\n            SELECT blog_id, domain\n            FROM {$wpdb->blogs}\n            WHERE site_id = '{$wpdb->siteid}'\n            AND spam = '0'\n            AND deleted = '0'\n            AND archived = '0'\n            ORDER BY blog_id\n        ");
        // Place current blog on the first place
        foreach ($blog_list as $blog) {
            if ($blog->blog_id == $blog_id) {
                $blogs["{$blog->blog_id}"] = get_blog_option($blog->blog_id, 'blogname') . ' - ' . $blog->domain;
                break;
            }
        }
        foreach ($blog_list as $blog) {
            if ($blog->blog_id != $blog_id) {
                $blogs["{$blog->blog_id}"] = get_blog_option($blog->blog_id, 'blogname') . ' - ' . $blog->domain;
            }
        }
        // Add all
        $blogs['all'] = __('All Sites');
        // Determine selected blog id
        if (isset($_GET['likebtn_blog_id'])) {
            if ($_GET['likebtn_blog_id'] == 'all') {
                $statistics_blog_id = $_GET['likebtn_blog_id'];
            } else {
                // Check if blog with ID exists
                foreach ($blog_list as $blog) {
                    if ($blog->blog_id == (int) $_GET['likebtn_blog_id']) {
                        $statistics_blog_id = (int) $_GET['likebtn_blog_id'];
                        break;
                    }
                }
            }
        }
        // Prepare prefix if this is not main blog
        if ($blog_id != 1) {
            $prefix_prepared = substr($wpdb->prefix, 0, strlen($wpdb->prefix) - strlen($blog_id) - 1);
        }
    }
    // add comment statuses
    $likebtn_post_statuses['0'] = __('Comment not approved', LIKEBTN_I18N_DOMAIN);
    $likebtn_post_statuses['1'] = __('Comment approved', LIKEBTN_I18N_DOMAIN);
    $sort_by = '';
    if (isset($_GET['likebtn_sort_by'])) {
        $sort_by = $_GET['likebtn_sort_by'];
    }
    if (!$sort_by) {
        $sort_by = 'likes';
    } elseif ($entity_name == LIKEBTN_ENTITY_CUSTOM_ITEM && $sort_by == 'post_id') {
        $sort_by = 'likes';
    }
    $page_size = LIKEBTN_STATISTIC_PAGE_SIZE;
    if (isset($_GET['likebtn_page_size'])) {
        $page_size = LIKEBTN_STATISTIC_PAGE_SIZE;
    }
    $post_id = '';
    if (isset($_GET['likebtn_post_id'])) {
        $post_id = trim(stripcslashes($_GET['likebtn_post_id']));
    }
    $post_title = '';
    if (isset($_GET['likebtn_post_title'])) {
        $post_title = trim(stripcslashes($_GET['likebtn_post_title']));
    }
    $post_status = '';
    if (isset($_GET['likebtn_post_status'])) {
        $post_status = trim($_GET['likebtn_post_status']);
    }
    // pagination
    require_once dirname(__FILE__) . '/likebtn_like_button_pagination.class.php';
    $pagination_target = "admin.php?page=likebtn_statistics";
    foreach ($_GET as $get_parameter => $get_value) {
        $pagination_target .= '&' . $get_parameter . '=' . stripcslashes($get_value);
    }
    $p = new LikeBtnLikeButtonPagination();
    $p->limit($page_size);
    // Limit entries per page
    $p->target($pagination_target);
    //$p->currentPage(); // Gets and validates the current page
    $p->prevLabel(__('Previous', LIKEBTN_I18N_DOMAIN));
    $p->nextLabel(__('Next', LIKEBTN_I18N_DOMAIN));
    if (!isset($_GET['paging'])) {
        $p->page = 1;
    } else {
        $p->page = $_GET['paging'];
    }
    // query for limit paging
    $query_limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
    // query parameters
    $query_where = '';
    // Post type
    switch ($entity_name) {
        case LIKEBTN_ENTITY_COMMENT:
        case LIKEBTN_ENTITY_CUSTOM_ITEM:
        case LIKEBTN_ENTITY_BP_ACTIVITY_POST:
        case LIKEBTN_ENTITY_BP_ACTIVITY_UPDATE:
        case LIKEBTN_ENTITY_BP_ACTIVITY_COMMENT:
        case LIKEBTN_ENTITY_BP_ACTIVITY_TOPIC:
        case LIKEBTN_ENTITY_BP_MEMBER:
        case LIKEBTN_ENTITY_BBP_POST:
        case LIKEBTN_ENTITY_BBP_USER:
            break;
        default:
            $query_where .= ' AND p.post_type = %s ';
            $query_parameters[] = $entity_name;
            break;
    }
    // Post ID
    if ($post_id) {
        switch ($entity_name) {
            case LIKEBTN_ENTITY_BP_ACTIVITY_POST:
            case LIKEBTN_ENTITY_BP_ACTIVITY_UPDATE:
            case LIKEBTN_ENTITY_BP_ACTIVITY_COMMENT:
            case LIKEBTN_ENTITY_BP_ACTIVITY_TOPIC:
            case LIKEBTN_ENTITY_BP_MEMBER:
                $query_where .= ' AND p.id = %d ';
                break;
            case LIKEBTN_ENTITY_COMMENT:
                $query_where .= ' AND p.comment_ID = %d ';
                break;
            default:
                $query_where .= ' AND p.ID = %d ';
                break;
        }
        $query_parameters[] = $post_id;
    }
    if ($post_title) {
        switch ($entity_name) {
            case LIKEBTN_ENTITY_BP_ACTIVITY_POST:
            case LIKEBTN_ENTITY_BP_ACTIVITY_UPDATE:
            case LIKEBTN_ENTITY_BP_ACTIVITY_COMMENT:
            case LIKEBTN_ENTITY_BP_ACTIVITY_TOPIC:
                $query_where .= ' AND LOWER(CONCAT(p.action, p.content)) LIKE "%%%s%%" ';
                break;
            case LIKEBTN_ENTITY_BP_MEMBER:
                $query_where .= ' AND LOWER(p.value) LIKE "%%%s%%" ';
                break;
            case LIKEBTN_ENTITY_BBP_USER:
                $query_where .= ' AND LOWER(CONCAT(p.user_login, p.display_name)) LIKE "%%%s%%" ';
                break;
            case LIKEBTN_ENTITY_COMMENT:
                $query_where .= ' AND LOWER(p.comment_content) LIKE "%%%s%%" ';
                break;
            case LIKEBTN_ENTITY_CUSTOM_ITEM:
                $query_where .= ' AND LOWER(p.identifier) LIKE "%%%s%%" ';
                break;
            default:
                $query_where .= ' AND LOWER(p.post_title) LIKE "%%%s%%" ';
                break;
        }
        $query_parameters[] = strtolower($post_title);
    }
    if ($post_status !== '') {
        if ($entity_name == LIKEBTN_ENTITY_COMMENT) {
            $query_where .= ' AND p.comment_approved = %s ';
        } elseif ($entity_name != LIKEBTN_ENTITY_CUSTOM_ITEM) {
            $query_where .= ' AND p.post_status = %s ';
        }
        $query_parameters[] = $post_status;
    }
    // order by
    switch ($sort_by) {
        case 'dislikes':
            $query_orderby = 'ORDER BY dislikes DESC';
            break;
        case 'likes_minus_dislikes':
            $query_orderby = 'ORDER BY likes_minus_dislikes DESC';
            break;
        case 'post_id':
            $query_orderby = 'ORDER BY post_id ASC';
            break;
        case 'post_title':
            $query_orderby = 'ORDER BY post_title ASC';
            break;
        case 'likes':
        default:
            $query_orderby = 'ORDER BY likes DESC';
            $sort_by = 'likes';
            break;
            /*case 'last_updated':
              $query_orderby = 'ORDER BY pm_likes.meta_id DESC';
              break;*/
    }
    // For Multisite
    $query = '';
    if ($statistics_blog_id && $statistics_blog_id != 1 && $statistics_blog_id != 'all') {
        $prefix = "{$prefix_prepared}{$statistics_blog_id}_";
        $query = _likebtn_get_statistics_sql($entity_name, $prefix, $query_where, $query_orderby, $query_limit);
        $query_prepared = $wpdb->prepare($query, $query_parameters);
    } else {
        if ($statistics_blog_id == 'all') {
            foreach ($blog_list as $blog) {
                if ($blog->blog_id == 1) {
                    $prefix = $prefix_prepared;
                } else {
                    $prefix = "{$prefix_prepared}{$blog->blog_id}_";
                }
                $query_list[] = $wpdb->prepare(_likebtn_get_statistics_sql($entity_name, $prefix, $query_where, '', '', $blog->blog_id . ' as blog_id, '), $query_parameters);
            }
            $query_prepared = ' SELECT SQL_CALC_FOUND_ROWS * from (' . implode(' UNION ', $query_list) . ") query {$query_orderby} {$query_limit} ";
        } else {
            $query = _likebtn_get_statistics_sql($entity_name, $prefix_prepared, $query_where, $query_orderby, $query_limit);
            $query_prepared = $wpdb->prepare($query, $query_parameters);
        }
    }
    // echo "<pre>";
    // echo $query_prepared;
    // echo $wpdb->prepare($query, $query_parameters);
    // $wpdb->show_errors();
    //exit();
    $statistics = $wpdb->get_results($query_prepared);
    $total_found = 0;
    if (isset($statistics[0])) {
        $query_found_rows = "SELECT FOUND_ROWS() as found_rows";
        $found_rows = $wpdb->get_results($query_found_rows);
        $total_found = (int) $found_rows[0]->found_rows;
        $p->items($total_found);
        $p->calculate();
        // Calculates what to show
        $p->parameterName('paging');
        $p->adjacents(1);
        // No. of page away from the current page
    }
    likebtn_admin_header();
    ?>

    <script type="text/javascript">
        var likebtn_msg_select_items = '<?php 
    _e("Please select item(s)", LIKEBTN_I18N_DOMAIN);
    ?>
';
        var likebtn_msg_upgrade = '<?php 
    _e("Upgrade your website to VIP to be able to use the feature", LIKEBTN_I18N_DOMAIN);
    ?>
';
    </script>
    <div>

        <?php 
    if (!_likebtn_is_stat_enabled() || get_option('likebtn_last_sync_message')) {
        ?>
            <span class="likebtn_error">
                <?php 
        echo strtr(__('Statistics not available, enable synchronization in order to view statistics:', LIKEBTN_I18N_DOMAIN), array('%url_sync%' => admin_url() . 'admin.php?page=likebtn_settings'));
        ?>
            </span>
            <?php 
        /*_e('To enable statistics:', LIKEBTN_I18N_DOMAIN)*/
        ?>
            <ol>
                <?php 
        if (get_option('likebtn_plan') < LIKEBTN_PLAN_PRO) {
            ?>
                    <li>
                        <?php 
            echo strtr(__('<a href="%url_upgrade%">Upgrade</a> your website to PRO or higher plan on LikeBtn.com.', LIKEBTN_I18N_DOMAIN), array('%url_upgrade%' => "javascript:likebtnPopup('" . __('http://likebtn.com/en/', LIKEBTN_I18N_DOMAIN) . "#plans_pricing')"));
            ?>
                    </li>
                <?php 
        }
        ?>
                <li>
                    <?php 
        echo strtr(__('Enable synchronization on <a href="%url_sync%">Synchronization</a> tab.', LIKEBTN_I18N_DOMAIN), array('%url_sync%' => admin_url() . 'admin.php?page=likebtn_settings'));
        ?>
                </li>
                <?php 
        /*<li><?php _e('Set your website tariff plan in Settings.', LIKEBTN_I18N_DOMAIN); ?></li>
          <li><?php _e('Enter E-mail and API key in Settings.', LIKEBTN_I18N_DOMAIN); ?></li>
          <li><?php _e('Set Synchronization interval in Settings.', LIKEBTN_I18N_DOMAIN); ?></li>*/
        ?>
                <?php 
        /* <li><?php _e('Run Synchronization test in Settings.', LIKEBTN_I18N_DOMAIN); ?></li> */
        ?>
            </ol>
        <?php 
    } else {
        ?>
            <p class="description">
                ● <?php 
        _e('Keep in mind that items appear in Statistics after receiving at least one vote.', LIKEBTN_I18N_DOMAIN);
        ?>
<br/>
                ● <?php 
        _e('Select <u>Custom item</u> content type to view votes of like buttons added using shortcode or HTML code.', LIKEBTN_I18N_DOMAIN);
        ?>
<br/>
                ● <?php 
        _e('To edit item votes click on a number of likes/dislikes in the statistics table.', LIKEBTN_I18N_DOMAIN);
        ?>
            </p>
        <?php 
    }
    ?>
        <br/>
        <form action="" method="get" id="statistics_form">
            <input type="hidden" name="page" value="likebtn_statistics" />

            <?php 
    if ($blogs) {
        ?>
                <label><?php 
        _e('Site', LIKEBTN_I18N_DOMAIN);
        ?>
:</label>
                <select name="likebtn_blog_id" >
                    <?php 
        foreach ($blogs as $blog_id_value => $blog_title) {
            ?>
                        <option value="<?php 
            echo $blog_id_value;
            ?>
" <?php 
            selected($statistics_blog_id, $blog_id_value);
            ?>
 ><?php 
            echo $blog_title;
            ?>
</option>
                    <?php 
        }
        ?>
                </select>
                &nbsp;&nbsp;
            <?php 
    }
    ?>

            <label><?php 
    _e('Content type', LIKEBTN_I18N_DOMAIN);
    ?>
:</label>
            <select name="likebtn_entity_name" >
                <?php 
    foreach ($likebtn_entities as $entity_name_value => $entity_title) {
        ?>
                    <option value="<?php 
        echo $entity_name_value;
        ?>
" <?php 
        selected($entity_name, $entity_name_value);
        ?>
 ><?php 
        _e($entity_title, LIKEBTN_I18N_DOMAIN);
        ?>
</option>
                <?php 
    }
    ?>
            </select>
            &nbsp;&nbsp;
            <label><?php 
    _e('Order by', LIKEBTN_I18N_DOMAIN);
    ?>
:</label>
            <select name="likebtn_sort_by" >
                <option value="likes" <?php 
    selected('likes', $sort_by);
    ?>
 ><?php 
    _e('Likes', LIKEBTN_I18N_DOMAIN);
    ?>
</option>
                <option value="dislikes" <?php 
    selected('dislikes', $sort_by);
    ?>
 ><?php 
    _e('Dislikes', LIKEBTN_I18N_DOMAIN);
    ?>
</option>
                <option value="likes_minus_dislikes" <?php 
    selected('likes_minus_dislikes', $sort_by);
    ?>
 ><?php 
    _e('Likes minus dislikes', LIKEBTN_I18N_DOMAIN);
    ?>
</option>
                <option value="post_id" <?php 
    selected('post_id', $sort_by);
    ?>
 ><?php 
    _e('ID', LIKEBTN_I18N_DOMAIN);
    ?>
</option>
                <option value="post_title" <?php 
    selected('post_title', $sort_by);
    ?>
 ><?php 
    _e('Title', LIKEBTN_I18N_DOMAIN);
    ?>
</option>
                <?php 
    /* <option value="last_updated" <?php selected('last_updated', $sort_by); ?> ><?php _e('Last updated', LIKEBTN_I18N_DOMAIN); ?></option> */
    ?>
            </select>

            &nbsp;&nbsp;
            <label><?php 
    _e('Per page', LIKEBTN_I18N_DOMAIN);
    ?>
:</label>
            <select name="likebtn_page_size" >
                <?php 
    foreach ($likebtn_page_sizes as $page_size_value) {
        ?>
                    <option value="<?php 
        echo $page_size_value;
        ?>
" <?php 
        selected($page_size, $page_size_value);
        ?>
 ><?php 
        echo $page_size_value;
        ?>
</option>
                <?php 
    }
    ?>

            </select>
            <br/><br/>
            <div class="postbox statistics_filter_container">
                <?php 
    /*<h3><?php _e('Filter', LIKEBTN_I18N_DOMAIN); ?></h3>*/
    ?>
                <div class="inside">
                    <label><?php 
    _e('ID', LIKEBTN_I18N_DOMAIN);
    ?>
:</label>
                    <input type="text" name="likebtn_post_id" value="<?php 
    echo htmlspecialchars($post_id);
    ?>
" size="5" />
                    &nbsp;&nbsp;
                    <label><?php 
    _e('Title');
    ?>
:</label>
                    <input type="text" name="likebtn_post_title" value="<?php 
    echo htmlspecialchars($post_title);
    ?>
" size="25"/>
                    &nbsp;&nbsp;
                    <label><?php 
    _e('Status', LIKEBTN_I18N_DOMAIN);
    ?>
:</label>
                    <select name="likebtn_post_status" >
                        <option value=""></option>
                        <?php 
    foreach ($likebtn_post_statuses as $post_status_value => $post_status_title) {
        ?>
                            <option value="<?php 
        echo $post_status_value;
        ?>
" <?php 
        selected($post_status, $post_status_value);
        ?>
 ><?php 
        echo _e($post_status_title);
        ?>
</option>
                        <?php 
    }
    ?>
                    </select>

                    &nbsp;&nbsp;
                    <input class="button-secondary" type="button" name="reset" value="<?php 
    _e('Reset filter', LIKEBTN_I18N_DOMAIN);
    ?>
" onClick="jQuery('.statistics_filter_container :input[type!=button]').val('');
                jQuery('#statistics_form').submit();"/>
                </div>
            </div>

            <input class="button-primary" type="submit" name="show" value="<?php 
    _e('View', LIKEBTN_I18N_DOMAIN);
    ?>
" /> 
        </form>
        <br/>
        <?php 
    _e('Total found', LIKEBTN_I18N_DOMAIN);
    ?>
: <strong><?php 
    echo $total_found;
    ?>
</strong>
        <br/>
        <form method="post" action="" id="stats_actions_form">
            <input type="hidden" name="bulk_action" value="" id="stats_bulk_action" />
        <?php 
    if (count($statistics) && $p->total_pages > 0) {
        ?>
            <div class="tablenav">
                <input type="button" class="button-secondary likebtn_ttip" onclick="likebtnStatsBulkAction('reset', '<?php 
        echo get_option('likebtn_plan');
        ?>
', '<?php 
        _e("The votes count can not be recovered after resetting. Are you sure you want to reset likes and dislikes for the selected item(s)?", LIKEBTN_I18N_DOMAIN);
        ?>
')" value="<?php 
        _e('Reset', LIKEBTN_I18N_DOMAIN);
        ?>
" title="<?php 
        _e('Set to zero number of likes and dislikes for selected items', LIKEBTN_I18N_DOMAIN);
        ?>
">
                
                <input type="button" class="button-secondary likebtn_ttip" onclick="likebtnStatsBulkAction('delete', '<?php 
        echo get_option('likebtn_plan');
        ?>
', '<?php 
        _e("The votes count can not be recovered after deleting. Are you sure you want to delete selected item(s) from statistics?", LIKEBTN_I18N_DOMAIN);
        ?>
')" value="<?php 
        _e('Delete', LIKEBTN_I18N_DOMAIN);
        ?>
" title="<?php 
        _e('Delete selected items from statistics: no posts, pages, comments, etc will be deleted, just their votes will be deleted from statistics', LIKEBTN_I18N_DOMAIN);
        ?>
">

                <div class="tablenav-pages">
                    <?php 
        echo $p->show();
        ?>
                </div>
            </div>
        <?php 
    }
    ?>
        <table class="widefat" id="statistics_container">
            <thead>
                <tr>
                    <th><input type="checkbox" onclick="statisticsItemsCheckbox(this)" value="all" style="margin:0"></th>
                    <?php 
    if ($entity_name != LIKEBTN_ENTITY_CUSTOM_ITEM) {
        ?>
                        <th>ID<?php 
        if ($sort_by == 'post_id') {
            ?>
&nbsp;↓<?php 
        }
        ?>
</th>
                    <?php 
    }
    ?>
                    <?php 
    if ($entity_name == LIKEBTN_ENTITY_POST) {
        ?>
                        <th><?php 
        _e('Featured image', LIKEBTN_I18N_DOMAIN);
        ?>
</th>
                    <?php 
    }
    ?>
                    <th width="100%"><?php 
    _e('Title', LIKEBTN_I18N_DOMAIN);
    if ($sort_by == 'post_title') {
        ?>
&nbsp;↓<?php 
    }
    ?>
</th>
                    <?php 
    if ($blogs && $statistics_blog_id == 'all') {
        ?>
                        <th><?php 
        _e('Site');
        ?>
</th>
                    <?php 
    }
    ?>
                    <th><?php 
    _e('Likes', LIKEBTN_I18N_DOMAIN);
    if ($sort_by == 'likes') {
        ?>
&nbsp;↓<?php 
    }
    ?>
</th>
                    <th><?php 
    _e('Dislikes', LIKEBTN_I18N_DOMAIN);
    if ($sort_by == 'dislikes') {
        ?>
&nbsp;↓<?php 
    }
    ?>
</th>
                    <th><?php 
    _e('Likes minus dislikes', LIKEBTN_I18N_DOMAIN);
    if ($sort_by == 'likes_minus_dislikes') {
        ?>
&nbsp;↓<?php 
    }
    ?>
</th>
                </tr>
            </thead>
            <tbody>
                <?php 
    foreach ($statistics as $statistics_item) {
        ?>
                    <?php 
        // URL
        if (!$blogs) {
            $post_url = _likebtn_get_entity_url($entity_name, $statistics_item->post_id, $statistics_item->url);
        } else {
            // Multisite
            switch ($entity_name) {
                case LIKEBTN_ENTITY_COMMENT:
                    $post_url = _likebtn_get_blog_comment_link($statistics_item->blog_id, $statistics_item->post_id);
                    break;
                case LIKEBTN_ENTITY_CUSTOM_ITEM:
                    $post_url = $statistics_item->url;
                    break;
                case LIKEBTN_ENTITY_BP_ACTIVITY_POST:
                case LIKEBTN_ENTITY_BP_ACTIVITY_UPDATE:
                case LIKEBTN_ENTITY_BP_ACTIVITY_COMMENT:
                case LIKEBTN_ENTITY_BP_ACTIVITY_TOPIC:
                    $post_url = bp_activity_get_permalink($statistics_item->post_id);
                    break;
                default:
                    $post_url = get_blog_permalink($statistics_item->blog_id, $statistics_item->post_id);
                    break;
            }
        }
        ?>

                    <?php 
        $statistics_item->post_title = _likebtn_prepare_title($entity_name, $statistics_item->post_title);
        ?>

                    <tr id="item_<?php 
        echo $statistics_item->post_id;
        ?>
">
                        <td><input type="checkbox" class="item_checkbox" value="<?php 
        echo $statistics_item->post_id;
        ?>
" name="item[]" <?php 
        if ($blogs && $statistics_item->blog_id != $blog_id) {
            ?>
disabled="disabled"<?php 
        }
        ?>
></td>
                        <?php 
        if ($entity_name != LIKEBTN_ENTITY_CUSTOM_ITEM) {
            ?>
                            <td><?php 
            echo $statistics_item->post_id;
            ?>
</td>
                        <?php 
        }
        ?>
                        <?php 
        if ($entity_name == LIKEBTN_ENTITY_POST) {
            ?>
                            <td><?php 
            echo get_the_post_thumbnail($statistics_item->post_id, array(32, 32));
            ?>
&nbsp;</td>
                        <?php 
        }
        ?>
                        <td><a href="<?php 
        echo $post_url;
        ?>
" target="_blank"><?php 
        echo htmlspecialchars($statistics_item->post_title);
        ?>
</a></td>
                        <?php 
        if ($blogs && $statistics_blog_id == 'all') {
            ?>
                            <td><?php 
            echo get_blog_option($statistics_item->blog_id, 'blogname');
            ?>
</td>
                        <?php 
        }
        ?>
                        <td>
                            <?php 
        if ($blogs && $statistics_item->blog_id != $blog_id) {
            ?>
                                <?php 
            echo $statistics_item->likes;
            ?>
                            <?php 
        } else {
            ?>
                                <a href="javascript:statisticsEdit('<?php 
            echo $entity_name;
            ?>
', '<?php 
            echo $statistics_item->post_id;
            ?>
', 'like', '<?php 
            echo get_option('likebtn_plan');
            ?>
', '<?php 
            _e('Enter new value:', LIKEBTN_I18N_DOMAIN);
            ?>
', '<?php 
            _e('Upgrade your website plan to the ULTRA plan to use the feature', LIKEBTN_I18N_DOMAIN);
            ?>
', '<?php 
            _e('Error occured. Please, try again later.', LIKEBTN_I18N_DOMAIN);
            ?>
');void(0);" title="<?php 
            _e('Click to change', LIKEBTN_I18N_DOMAIN);
            ?>
" class="item_like likebtn_ttip"><?php 
            echo $statistics_item->likes;
            ?>
</a>
                            <?php 
        }
        ?>
                        </td>
                        <td>
                            <?php 
        if ($blogs && $statistics_item->blog_id != $blog_id) {
            ?>
                                <?php 
            echo $statistics_item->dislikes;
            ?>
                            <?php 
        } else {
            ?>
                                <a href="javascript:statisticsEdit('<?php 
            echo $entity_name;
            ?>
', '<?php 
            echo $statistics_item->post_id;
            ?>
', 'dislike', '<?php 
            echo get_option('likebtn_plan');
            ?>
', '<?php 
            _e('Enter new value:', LIKEBTN_I18N_DOMAIN);
            ?>
', '<?php 
            _e('Upgrade your website plan to the ULTRA plan to use the feature', LIKEBTN_I18N_DOMAIN);
            ?>
', '<?php 
            _e('Error occured. Please, try again later.', LIKEBTN_I18N_DOMAIN);
            ?>
');void(0);" title="<?php 
            _e('Click to change', LIKEBTN_I18N_DOMAIN);
            ?>
" class="item_dislike likebtn_ttip"><?php 
            echo $statistics_item->dislikes;
            ?>
</a>
                            <?php 
        }
        ?>
                        </td>
                        <td><?php 
        echo $statistics_item->likes_minus_dislikes;
        ?>
</td>
                    </tr>
                <?php 
    }
    ?>
            </tbody>
        </table>
        </form>
        <?php 
    if (count($statistics) && $p->total_pages > 0) {
        ?>
            <div class="tablenav">
                <div class="tablenav-pages">
                    <?php 
        echo $p->show();
        ?>
                </div>
            </div>
        <?php 
    }
    ?>

    </div>

    <?php 
    _likebtn_admin_footer();
}
function s4wp_build_document(Solarium\QueryType\Update\Query\Document\Document $doc, $post_info, $domain = NULL, $path = NULL)
{
    $plugin_s4wp_settings = s4wp_get_option();
    $exclude_ids = $plugin_s4wp_settings['s4wp_exclude_pages'];
    if (!is_array($plugin_s4wp_settings['s4wp_exclude_pages'])) {
        $exclude_ids = explode(',', $plugin_s4wp_settings['s4wp_exclude_pages']);
    }
    $categoy_as_taxonomy = $plugin_s4wp_settings['s4wp_cat_as_taxo'];
    $index_comments = $plugin_s4wp_settings['s4wp_index_comments'];
    $index_custom_fields = $plugin_s4wp_settings['s4wp_index_custom_fields'];
    if (!is_array($plugin_s4wp_settings['s4wp_index_custom_fields'])) {
        $index_custom_fields = explode(',', $plugin_s4wp_settings['s4wp_index_custom_fields']);
    }
    if ($post_info) {
        # check if we need to exclude this document
        if (is_multisite() && in_array(substr(site_url(), 7) . $post_info->ID, (array) $exclude_ids)) {
            return NULL;
        } else {
            if (!is_multisite() && in_array($post_info->ID, (array) $exclude_ids)) {
                return NULL;
            }
        }
        $auth_info = get_userdata($post_info->post_author);
        # wpmu specific info
        if (is_multisite()) {
            // if we get here we expect that we've "switched" what blog we're running
            // as
            if ($domain == NULL) {
                $domain = $current_blog->domain;
            }
            if ($path == NULL) {
                $path = $current_blog->path;
            }
            $blogid = get_blog_id_from_url($domain, $path);
            $doc->setField('id', $domain . $path . $post_info->ID);
            $doc->setField('permalink', get_blog_permalink($blogid, $post_info->ID));
            $doc->setField('blogid', $blogid);
            $doc->setField('blogdomain', $domain);
            $doc->setField('blogpath', $path);
            $doc->setField('wp', 'multisite');
        } else {
            $doc->setField('id', $post_info->ID);
            $doc->setField('permalink', get_permalink($post_info->ID));
            $doc->setField('wp', 'wp');
        }
        $numcomments = 0;
        if ($index_comments) {
            $comments = get_comments("status=approve&post_id={$post_info->ID}");
            foreach ($comments as $comment) {
                $doc->addField('comments', $comment->comment_content);
                $numcomments += 1;
            }
        }
        $doc->setField('title', $post_info->post_title);
        $doc->setField('content', strip_tags($post_info->post_content));
        $doc->setField('numcomments', $numcomments);
        if (isset($auth_info->display_name)) {
            $doc->setField('author', $auth_info->display_name);
        }
        if (isset($auth_info->user_nicename)) {
            $doc->setField('author_s', get_author_posts_url($auth_info->ID, $auth_info->user_nicename));
        }
        $doc->setField('type', $post_info->post_type);
        $doc->setField('date', s4wp_format_date($post_info->post_date_gmt));
        $doc->setField('modified', s4wp_format_date($post_info->post_modified_gmt));
        $doc->setField('displaydate', $post_info->post_date);
        $doc->setField('displaymodified', $post_info->post_modified);
        $categories = get_the_category($post_info->ID);
        if (!$categories == NULL) {
            foreach ($categories as $category) {
                if ($categoy_as_taxonomy) {
                    $doc->addField('categories', get_category_parents($category->cat_ID, FALSE, '^^'));
                } else {
                    $doc->addField('categories', $category->cat_name);
                }
            }
        }
        //get all the taxonomy names used by wp
        $taxonomies = (array) get_taxonomies(array('_builtin' => FALSE), 'names');
        foreach ($taxonomies as $parent) {
            $terms = get_the_terms($post_info->ID, $parent);
            if ((array) $terms === $terms) {
                //we are creating *_taxonomy as dynamic fields using our schema
                //so lets set up all our taxonomies in that format
                $parent = $parent . "_taxonomy";
                foreach ($terms as $term) {
                    $doc->addField($parent, $term->name);
                }
            }
        }
        $tags = get_the_tags($post_info->ID);
        if (!$tags == NULL) {
            foreach ($tags as $tag) {
                $doc->addField('tags', $tag->name);
            }
        }
        if (count($index_custom_fields) > 0 && count($custom_fields = get_post_custom($post_info->ID))) {
            foreach ((array) $index_custom_fields as $field_name) {
                // test a php error notice.
                if (isset($custom_fields[$field_name])) {
                    $field = (array) $custom_fields[$field_name];
                    foreach ($field as $key => $value) {
                        $doc->addField($field_name . '_str', $value);
                        $doc->addField($field_name . '_srch', $value);
                    }
                }
            }
        }
    } else {
        // this will fire during blog sign up on multisite, not sure why
        _e('Post Information is NULL', 'solr4wp');
    }
    return $doc;
}
 /**
  * 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;
 }
 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;
 }
 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;
 }
Exemple #20
0
 function get_permalink()
 {
     if (EM_MS_GLOBAL) {
         if (get_site_option('dbem_ms_global_locations_links') && !empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id()) {
             //linking directly to the blog, we should be on the main blog here
             $link = get_blog_permalink($this->blog_id, $this->post_id);
         } elseif (!empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id()) {
             if (get_option('dbem_locations_page')) {
                 $link = trailingslashit(get_permalink(get_option('dbem_locations_page')) . get_site_option('dbem_ms_locations_slug', EM_LOCATION_SLUG) . '/' . $this->location_slug . '-' . $this->location_id);
             } else {
                 $link = trailingslashit(home_url()) . EM_POST_TYPE_LOCATION_SLUG . '/' . get_site_option('dbem_ms_events_slug', EM_LOCATION_SLUG) . '/' . $this->location_slug . '-' . $this->location_id;
             }
         }
     }
     if (empty($link)) {
         $link = get_post_permalink($this->post_id);
     }
     return apply_filters('em_location_get_permalink', $link, $this);
 }
function network_latest_posts($how_many = 10, $how_long = 0, $titleOnly = true, $begin_wrap = "\n<li>", $end_wrap = "</li>", $blog_id = 'null', $thumbnail = false, $cpt = "post", $ignore_blog = 'null', $cat = 'null', $tag = 'null', $paginate = false, $excerpt_length = 'null', $display_root = false)
{
    global $wpdb;
    global $table_prefix;
    $counter = 0;
    $hack_cont = 0;
    // Custom post type
    $cpt = htmlspecialchars($cpt);
    // Ignore blog or blogs
    // if the user passes one value
    if (!preg_match("/,/", $ignore_blog)) {
        // Always clean this stuff ;)
        $ignore_blog = htmlspecialchars($ignore_blog);
        // Check if it's numeric
        if (is_numeric($ignore_blog)) {
            // and put the sql
            $ignore = " AND blog_id != {$ignore_blog} ";
        }
        // if the user passes more than one value separated by commas
    } else {
        // create an array
        $ignore_arr = explode(",", $ignore_blog);
        // and repeat the sql for each ID found
        for ($z = 0; $z < count($ignore_arr); $z++) {
            $ignore .= " AND blog_id != {$ignore_arr[$z]}";
        }
    }
    // get a list of blogs in order of most recent update. show only public and nonarchived/spam/mature/deleted
    if ($how_long > 0) {
        // Select by blog id
        if (!empty($blog_id) && $blog_id != 'null') {
            $blog_id = htmlspecialchars($blog_id);
            $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE\n                       public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'\n                       AND blog_id = {$blog_id} {$ignore} AND last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL {$how_long} DAY)\n                       ORDER BY last_updated DESC");
        } else {
            $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE\n                       public = '1' {$ignore} AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'\n                       AND last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL {$how_long} DAY)\n                       ORDER BY last_updated DESC");
        }
    } else {
        if (!empty($blog_id) && $blog_id != 'null') {
            $blog_id = htmlspecialchars($blog_id);
            $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE\n                        public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND blog_id = {$blog_id}\n                        {$ignore} ORDER BY last_updated DESC");
        } else {
            $blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs} WHERE\n                        public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'\n                        {$ignore} ORDER BY last_updated DESC");
        }
    }
    if ($blogs) {
        // Count how many blogs we've found
        $nblogs = count($blogs);
        // Lets dig into each blog
        foreach ($blogs as $blognlp) {
            // we need _posts and _options tables for this to work
            // Get the options table for each blog
            if ($display_root == true) {
                if ($blognlp == 1) {
                    $blogOptionsTable = $wpdb->base_prefix . "options";
                    // Get the posts table for each blog
                    $blogPostsTable = $wpdb->base_prefix . "posts";
                    // Get the terms relationships table for each blog
                    $blogTermRelationship = $wpdb->base_prefix . "term_relationships";
                    // Get the term taxonomy table for each blog
                    $blogTermTaxonomy = $wpdb->base_prefix . "term_taxonomy";
                    // Get the terms table for each blog
                    $blogTerms = $wpdb->base_prefix . "terms";
                } else {
                    $blogOptionsTable = $wpdb->base_prefix . $blognlp . "_options";
                    // Get the posts table for each blog
                    $blogPostsTable = $wpdb->base_prefix . $blognlp . "_posts";
                    // Get the terms relationships table for each blog
                    $blogTermRelationship = $wpdb->base_prefix . $blognlp . "_term_relationships";
                    // Get the term taxonomy table for each blog
                    $blogTermTaxonomy = $wpdb->base_prefix . $blognlp . "_term_taxonomy";
                    // Get the terms table for each blog
                    $blogTerms = $wpdb->base_prefix . $blognlp . "_terms";
                }
            } else {
                $blogOptionsTable = $wpdb->base_prefix . $blognlp . "_options";
                // Get the posts table for each blog
                $blogPostsTable = $wpdb->base_prefix . $blognlp . "_posts";
                // Get the terms relationships table for each blog
                $blogTermRelationship = $wpdb->base_prefix . $blognlp . "_term_relationships";
                // Get the term taxonomy table for each blog
                $blogTermTaxonomy = $wpdb->base_prefix . $blognlp . "_term_taxonomy";
                // Get the terms table for each blog
                $blogTerms = $wpdb->base_prefix . $blognlp . "_terms";
            }
            // --- Because the categories and tags are handled the same way by WP
            // --- I'm hacking the $cat variable so I can use it for both without
            // --- repeating the code
            if (!empty($cat) && $cat != 'null' && (empty($tag) || $tag == 'null')) {
                // Categories
                $cat_hack = $cat;
                $taxonomy = "taxonomy = 'category'";
            } elseif (!empty($tag) && $tag != 'null' && (empty($cat) || $cat == 'null')) {
                // Tags
                $cat_hack = $tag;
                $taxonomy = "taxonomy = 'post_tag'";
            } elseif (!empty($cat) && $cat != 'null' && !empty($tag) && $tag != 'null') {
                // Categories & Tags
                $cat_hack = $cat . "," . $tag;
                $taxonomy = "(taxonomy = 'category' OR taxonomy = 'post_tag')";
            }
            // --- Categories
            if (!empty($cat_hack) && $cat_hack != 'null') {
                if (!preg_match('/,/', $cat_hack)) {
                    $cat_hack = htmlspecialchars($cat_hack);
                    // Get the category's ID
                    $catid = $wpdb->get_results("SELECT term_id FROM {$blogTerms} WHERE slug = '{$cat_hack}'");
                    $cats[$blognlp] = $catid[0]->term_id;
                } else {
                    $cat_arr = explode(',', $cat_hack);
                    for ($x = 0; $x < count($cat_arr); $x++) {
                        $cat_ids = $wpdb->get_results("SELECT term_id FROM {$blogTerms} WHERE slug = '{$cat_arr[$x]}' ");
                        if (!empty($cat_ids[0]->term_id)) {
                            // Get the categories' IDs
                            $catsa[$blognlp][] = $cat_ids[0]->term_id;
                        }
                    }
                }
            }
            // Let's find the ID for the category(ies) or tag(s)
            if (count($cats[$blognlp]) == 1) {
                $taxo = $wpdb->get_results("SELECT term_taxonomy_id FROM {$blogTermTaxonomy} WHERE {$taxonomy} AND term_id = " . $cats[$blognlp]);
                $taxs[$blognlp] = $taxo[0]->term_taxonomy_id;
            } elseif (count($catsa[$blognlp]) >= 1) {
                for ($y = 0; $y < count($catsa[$blognlp]); $y++) {
                    $tax_id = $wpdb->get_results("SELECT term_taxonomy_id FROM {$blogTermTaxonomy} WHERE {$taxonomy} AND term_id = " . $catsa[$blognlp][$y]);
                    if (!empty($tax_id[0]->term_taxonomy_id)) {
                        $taxsa[$blognlp][] = $tax_id[0]->term_taxonomy_id;
                    }
                }
            }
            // Next, let's find how they are related to the posts
            if (count($taxs[$blognlp]) == 1) {
                $pids = $wpdb->get_results("SELECT object_id FROM {$blogTermRelationship} WHERE term_taxonomy_id = " . $taxs[$blognlp]);
                for ($w = 0; $w < count($pids); $w++) {
                    $postids[$blognlp][] = $pids[$w]->object_id;
                }
            } elseif (count($taxsa[$blognlp]) >= 1) {
                for ($w = 0; $w < count($taxsa[$blognlp]); $w++) {
                    $p_id = $wpdb->get_results("SELECT object_id FROM {$blogTermRelationship} WHERE term_taxonomy_id = " . $taxsa[$blognlp][$w]);
                    for ($q = 0; $q < count($p_id); $q++) {
                        $postidsa[$blognlp][] = $p_id[$q]->object_id;
                    }
                }
            }
            // Finally let's find the posts' IDs
            if (count($postids[$blognlp]) == 1) {
                $filter_cat = " AND ID = " . $postids[$blognlp];
                if (!empty($filter_cat)) {
                    if (!preg_match('/\\(/', $filter_cat)) {
                        $needle = ' AND ';
                        $replacement = ' AND (';
                        $filter_cat = str_replace($needle, $replacement, $filter_cat);
                    }
                }
            } elseif (count($postids[$blognlp]) > 1) {
                for ($v = 0; $v < count($postids[$blognlp]); $v++) {
                    if ($v == 0 && $hack_cont == 0) {
                        $filter_cat .= " AND ID = " . $postids[$blognlp][$v];
                        $hack_cont++;
                    } elseif ($hack_cont > 0) {
                        $filter_cat .= " OR ID = " . $postids[$blognlp][$v];
                    }
                }
                if (!empty($filter_cat)) {
                    if (!preg_match('/\\(/', $filter_cat)) {
                        $needle = ' AND ';
                        $replacement = ' AND (';
                        $filter_cat = str_replace($needle, $replacement, $filter_cat);
                    }
                }
            } elseif (count($postidsa[$blognlp]) >= 1) {
                for ($v = 0; $v < count($postidsa[$blognlp]); $v++) {
                    if ($v == 0 && $hack_cont == 0) {
                        $filter_cat .= " AND ID = " . $postidsa[$blognlp][$v];
                        $hack_cont++;
                    } elseif ($hack_cont > 0) {
                        $filter_cat .= " OR ID = " . $postidsa[$blognlp][$v];
                    }
                }
                if (!empty($filter_cat)) {
                    if (!preg_match('/\\(/', $filter_cat)) {
                        $needle = ' AND ';
                        $replacement = ' AND (';
                        $filter_cat = str_replace($needle, $replacement, $filter_cat);
                    }
                }
            }
            // --- Categories\\
            // Get the saved options
            $options = $wpdb->get_results("SELECT option_value FROM\n                                {$blogOptionsTable} WHERE option_name IN ('siteurl','blogname')\n                                ORDER BY option_name DESC");
            // we fetch the title, excerpt and ID for the latest post
            if ($how_long > 0) {
                if (!empty($filter_cat) && !empty($cat_hack)) {
                    // Without pagination
                    if (!$paginate) {
                        $thispost = $wpdb->get_results("SELECT ID, post_title, post_excerpt\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   {$filter_cat} )\n                                                   AND post_type = '{$cpt}'\n                                                   AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {$how_long} DAY)\n                                                   ORDER BY id DESC LIMIT 0,{$how_many}");
                        // Paginated results
                    } else {
                        $posts_per_page = $how_many;
                        $page = isset($_GET['pnum']) ? abs((int) $_GET['pnum']) : 1;
                        $total_records = $wpdb->get_var("SELECT COUNT(ID)\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   {$filter_cat} )\n                                                   AND post_type = '{$cpt}'\n                                                   AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {$how_long} DAY)\n                                                   ORDER BY id DESC");
                        $total = $total_records;
                        $thispost = $wpdb->get_results("SELECT ID, post_title, post_excerpt\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   {$filter_cat} )\n                                                   AND post_type = '{$cpt}'\n                                                   AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {$how_long} DAY)\n                                                   ORDER BY id DESC LIMIT " . ($page * $posts_per_page - $posts_per_page) . ",{$posts_per_page}");
                    }
                } elseif (empty($filter_cat) && empty($cat_hack)) {
                    // Without pagination
                    if (!$paginate) {
                        $thispost = $wpdb->get_results("SELECT ID, post_title, post_excerpt\n                                               FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                               AND ID > 1\n                                               AND post_type = '{$cpt}'\n                                               AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {$how_long} DAY)\n                                               ORDER BY id DESC LIMIT 0,{$how_many}");
                        // Paginated results
                    } else {
                        $posts_per_page = $how_many;
                        $page = isset($_GET['pnum']) ? abs((int) $_GET['pnum']) : 1;
                        $total_records = $wpdb->get_var("SELECT COUNT(ID)\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   AND ID > 1\n                                                   AND post_type = '{$cpt}'\n                                                   AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {$how_long} DAY)\n                                                   ORDER BY id DESC");
                        $total = $total_records;
                        $thispost = $wpdb->get_results("SELECT ID, post_title, post_excerpt\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   AND ID > 1\n                                                   AND post_type = '{$cpt}'\n                                                   AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {$how_long} DAY)\n                                                   ORDER BY id DESC LIMIT " . ($page * $posts_per_page - $posts_per_page) . ",{$posts_per_page}");
                    }
                }
            } else {
                if (!empty($filter_cat) && !empty($cat_hack)) {
                    // Without pagination
                    if (!$paginate) {
                        $thispost = $wpdb->get_results("SELECT ID, post_title, post_excerpt\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   {$filter_cat} )\n                                                   AND post_type = '{$cpt}'\n                                                   ORDER BY id DESC LIMIT 0,{$how_many}");
                        // Paginated results
                    } else {
                        $posts_per_page = $how_many;
                        $page = isset($_GET['pnum']) ? abs((int) $_GET['pnum']) : 1;
                        $total_records = $wpdb->get_var("SELECT COUNT(ID)\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   {$filter_cat} )\n                                                   AND post_type = '{$cpt}'\n                                                   ORDER BY id DESC");
                        $total = $total_records;
                        $thispost = $wpdb->get_results("SELECT ID, post_title, post_excerpt\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   {$filter_cat} )\n                                                   AND post_type = '{$cpt}'\n                                                   ORDER BY id DESC LIMIT " . ($page * $posts_per_page - $posts_per_page) . ",{$posts_per_page}");
                    }
                } elseif (empty($filter_cat) && empty($cat_hack)) {
                    // Without pagination
                    if (!$paginate) {
                        $thispost = $wpdb->get_results("SELECT ID, post_title, post_excerpt\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   AND ID > 1\n                                                   AND post_type = '{$cpt}'\n                                                   ORDER BY id DESC LIMIT 0,{$how_many}");
                    } else {
                        $posts_per_page = $how_many;
                        $page = isset($_GET['pnum']) ? abs((int) $_GET['pnum']) : 1;
                        $total_records = $wpdb->get_var("SELECT COUNT(ID)\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   AND ID > 1\n                                                   AND post_type = '{$cpt}'\n                                                   ORDER BY id DESC");
                        $total = $total_records;
                        $thispost = $wpdb->get_results("SELECT ID, post_title, post_excerpt\n                                                   FROM {$blogPostsTable} WHERE post_status = 'publish'\n                                                   AND ID > 1\n                                                   AND post_type = '{$cpt}'\n                                                   ORDER BY id DESC LIMIT " . ($page * $posts_per_page - $posts_per_page) . ",{$posts_per_page}");
                    }
                }
            }
            // if it is found put it to the output
            if ($thispost) {
                // Remember we are doing this for multiple blogs?, well we need to display
                // the number of posts chosen for each of them
                for ($i = 0; $i < count($thispost); $i++) {
                    // get permalink by ID.  check wp-includes/wpmu-functions.php
                    $thispermalink = get_blog_permalink($blognlp, $thispost[$i]->ID);
                    // If we want to show the excerpt, we do this
                    if ($titleOnly == false || $titleOnly == 'false') {
                        // Widget list
                        if ((!empty($begin_wrap) || $begin_wrap != '') && preg_match("/\\bli\\b/", $begin_wrap) && $thumbnail == false) {
                            echo $begin_wrap . '<div class="network-posts blog-' . $blognlp . '"><a href="' . $thispermalink . '">' . $thispost[$i]->post_title . '</a><span class="network-posts-source"> ' . esc_html__('published in', 'eGallery') . ' <a href="' . $options[0]->option_value . '">' . $options[1]->option_value . '</a></span><p class="network-posts-excerpt">' . the_excerpt() . '</p></div>' . $end_wrap;
                            // Shortcode
                        } else {
                            // Display thumbnail
                            if ($thumbnail) {
                                if ($i == 0) {
                                    echo '<div id="wrapper-' . $blognlp . '">';
                                }
                                echo $begin_wrap . '<div class="network-posts blog-' . $blognlp . '"><h1 class="network-posts-title"><a href="' . $thispermalink . '">' . $thispost[$i]->post_title . '</a></h1><span class="network-posts-source"> ' . __('published in', 'trans-nlp') . ' <a href="' . $options[0]->option_value . '">' . $options[1]->option_value . '</a></span><a href="' . $thispermalink . '">' . the_post_thumbnail_by_blog($blognlp, $thispost[$i]->ID) . '</a> <p class="network-posts-excerpt">' . custom_excerpt($excerpt_length, $thispost[$i]->post_excerpt, $thispermalink) . '</p>';
                                if ($i == count($thispost) - 1 && $paginate == true) {
                                    echo '<div class="network-posts-pagination">';
                                    echo paginate_links(array('base' => add_query_arg('pnum', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($total / $posts_per_page), 'current' => $page, 'type' => 'list'));
                                    echo '</div>';
                                    echo '<script type="text/javascript" charset="utf-8">
                                                           jQuery(document).ready(function(){
   
                                                                   jQuery(".blog-' . $blognlp . ' .network-posts-pagination a").live("click", function(e){
                                                                           e.preventDefault();
                                                                           var link = jQuery(this).attr("href");
                                                                           jQuery("#wrapper-' . $blognlp . '").html("<img src=\\"' . plugins_url('/img/loader.gif', __FILE__) . '\\" />");
                                                                           jQuery("#wrapper-' . $blognlp . '").load(link+" .blog-' . $blognlp . '");
   
                                                                   });
   
                                                           });
                                                       </script>';
                                }
                                echo "</div>" . $end_wrap;
                                if ($i == count($thispost) - 1) {
                                    echo "</div>";
                                }
                                // Without thumbnail
                            } else {
                                if ($i == 0) {
                                    echo '<div id="wrapper-' . $blognlp . '">';
                                }
                                echo $begin_wrap . '<div class="network-posts blog-' . $blognlp . '"><h1 class="network-posts-title"><a href="' . $thispermalink . '">' . $thispost[$i]->post_title . '</a></h1><span class="network-posts-source"> ' . __('published in', 'trans-nlp') . ' <a href="' . $options[0]->option_value . '">' . $options[1]->option_value . '</a></span><p class="network-posts-excerpt">' . custom_excerpt($excerpt_length, $thispost[$i]->post_excerpt, $thispermalink) . '</p>';
                                if ($i == count($thispost) - 1 && $paginate == true) {
                                    echo '<div class="network-posts-pagination">';
                                    echo paginate_links(array('base' => add_query_arg('pnum', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($total / $posts_per_page), 'current' => $page, 'type' => 'list'));
                                    echo '</div>';
                                    echo '<script type="text/javascript" charset="utf-8">
                                                           jQuery(document).ready(function(){
   
                                                                   jQuery(".blog-' . $blognlp . ' .network-posts-pagination a").live("click", function(e){
                                                                           e.preventDefault();
                                                                           var link = jQuery(this).attr("href");
                                                                           jQuery("#wrapper-' . $blognlp . '").html("<img src=\\"' . plugins_url('/img/loader.gif', __FILE__) . '\\" />");
                                                                           jQuery("#wrapper-' . $blognlp . '").load(link+" .blog-' . $blognlp . '");
   
                                                                   });
   
                                                           });
                                                       </script>';
                                }
                                echo "</div>" . $end_wrap;
                                if ($i == count($thispost) - 1) {
                                    echo "</div>";
                                }
                            }
                        }
                        // Otherwise we just show the titles (useful when used as a widget)
                    } else {
                        // Widget list
                        if ($i == 0) {
                            echo '<div id="wrapperw-' . $blognlp . '">';
                        }
                        if (preg_match("/\\bli\\b/", $begin_wrap)) {
                            echo $begin_wrap . '<div class="network-posts blogw-' . $blognlp . '"><a href="' . $thispermalink . '">' . $thispost[$i]->post_title . '</a>';
                            if ($i == count($thispost) - 1 && $paginate == true) {
                                echo '<div class="network-posts-pagination">';
                                echo paginate_links(array('base' => add_query_arg('pnum', '%#%'), 'format' => '', 'show_all' => false, 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($total / $posts_per_page), 'current' => $page, 'type' => 'list'));
                                echo '</div>';
                                echo '<script type="text/javascript" charset="utf-8">
                                                       jQuery(document).ready(function(){
   
                                                               jQuery(".blogw-' . $blognlp . ' .network-posts-pagination a").live("click", function(e){
                                                                       e.preventDefault();
                                                                       var link = jQuery(this).attr("href");
                                                                       jQuery("#wrapperw-' . $blognlp . '").html("<img src=\\"' . plugins_url('/img/loader.gif', __FILE__) . '\\" />");
                                                                       jQuery("#wrapperw-' . $blognlp . '").load(link+" .blogw-' . $blognlp . '");
   
                                                               });
   
                                                       });
                                                   </script>';
                            }
                            echo '</div>' . $end_wrap;
                            if ($i == count($thispost) - 1) {
                                echo "</div>";
                            }
                            // Shortcode
                        } else {
                            if ($i == 0) {
                                echo '<div id="wrapper-' . $blognlp . '">';
                            }
                            echo $begin_wrap . '<div class="network-posts blog-' . $blognlp . '"><h1 class="network-posts-title"><a href="' . $thispermalink . '">' . $thispost[$i]->post_title . '</a></h1>';
                            if ($i == count($thispost) - 1 && $paginate == true) {
                                echo '<div class="network-posts-pagination">';
                                echo paginate_links(array('base' => add_query_arg('pnum', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($total / $posts_per_page), 'current' => $page, 'type' => 'list'));
                                echo '</div>';
                                echo '<script type="text/javascript" charset="utf-8">
                                                       jQuery(document).ready(function(){
   
                                                               jQuery(".blog-' . $blognlp . ' .network-posts-pagination a").live("click", function(e){
                                                                       e.preventDefault();
                                                                       var link = jQuery(this).attr("href");
                                                                       jQuery("#wrapper-' . $blognlp . '").html("<img src=\\"' . plugins_url('/img/loader.gif', __FILE__) . '\\" />");
                                                                       jQuery("#wrapper-' . $blognlp . '").load(link+" .blog-' . $blognlp . '");
   
                                                               });
   
                                                       });
                                                   </script>';
                            }
                            echo '</div>' . $end_wrap;
                            if ($i == count($thispost) - 1) {
                                echo "</div>";
                            }
                        }
                    }
                }
                // Count only when all posts has been displayed
                $counter++;
            }
            // don't go over the limit of blogs
            if ($counter >= $nblogs) {
                break;
            }
        }
    }
}
Exemple #22
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 
Exemple #23
0
 /**
  * Will output a event in the format passed in $format by replacing placeholders within the format.
  * @param string $format
  * @param string $target
  * @return string
  */
 function output($format, $target = "html")
 {
     //First let's do some conditional placeholder removals
     preg_match_all('/\\{([a-zA-Z0-9_]+)\\}([^{]+)\\{\\/[a-zA-Z0-9_]+\\}/', $format, $conditionals);
     if (count($conditionals[0]) > 0) {
         //Check if the language we want exists, if not we take the first language there
         foreach ($conditionals[1] as $key => $condition) {
             $replacement = $conditionals[0][$key];
             if ($condition == 'has_bookings') {
                 //check if there's a booking, if not, remove this section of code.
                 if ($this->rsvp) {
                     $replacement = substr($conditionals[0][$key], 14, strlen($conditionals[0][$key]) - 29);
                     //29 = (15+14)
                 } else {
                     $replacement = '';
                 }
             }
             if ($condition == 'no_bookings') {
                 //check if there's a booking, if not, remove this section of code.
                 if (!$this->rsvp) {
                     $replacement = substr($conditionals[0][$key], 13, strlen($conditionals[0][$key]) - 28);
                     //28 = (13+14)
                 } else {
                     $replacement = '';
                 }
                 str_replace($conditionals[0][$key], $replacement, $format);
             }
             $format = str_replace($conditionals[0][$key], apply_filters('em_event_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $format);
         }
     }
     $event_string = $format;
     //Now let's check out the placeholders.
     preg_match_all("/#@?_?[A-Za-z0-9]+/", $format, $placeholders);
     foreach ($placeholders[0] as $result) {
         $match = true;
         $replace = '';
         switch ($result) {
             //Event Details
             case '#_EVENTID':
                 $replace = $this->id;
                 break;
             case '#_NAME':
                 $replace = $this->name;
                 break;
             case '#_NOTES':
             case '#_EXCERPT':
                 //SEE AT BOTTOM OF FILE FOR OLD TARGET FILTERS FROM 2.x
                 $replace = $this->notes;
                 if ($result == "#_EXCERPT") {
                     $matches = explode('<!--more', $this->notes);
                     $replace = $matches[0];
                 }
                 break;
             case '#_EVENTIMAGEURL':
             case '#_EVENTIMAGE':
                 if ($this->image_url != '') {
                     $replace = $result == '#_EVENTIMAGEURL' ? $this->image_url : "<img src='" . $this->image_url . "' alt='" . $this->name . "'/>";
                 }
                 break;
                 //Times
             //Times
             case '#_24HSTARTTIME':
             case '#_24HENDTIME':
                 $time = $result == '#_24HSTARTTIME' ? $this->start_time : $this->end_time;
                 $replace = substr($time, 0, 5);
                 break;
             case '#_12HSTARTTIME':
             case '#_12HENDTIME':
                 $time = $result == '#_12HSTARTTIME' ? $this->start_time : $this->end_time;
                 $replace = date('g:i A', strtotime($time));
                 break;
                 //Links
             //Links
             case '#_EVENTPAGEURL':
                 //Depreciated
             //Depreciated
             case '#_LINKEDNAME':
                 //Depreciated
             //Depreciated
             case '#_EVENTURL':
                 //Just the URL
             //Just the URL
             case '#_EVENTLINK':
                 //HTML Link
                 //If this event is not of this blog, we need a new URL
                 $EM_URI = EM_URI;
                 if (is_multisite() && get_site_option('dbem_ms_global_events') && get_site_option('dbem_ms_global_events_links') && !empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id()) {
                     $EM_URI = get_blog_permalink($this->blog_id, get_blog_option($this->blog_id, 'dbem_events_page'));
                 }
                 $joiner = stristr($EM_URI, "?") ? "&amp;" : "?";
                 $event_link = $EM_URI . $joiner . "event_id=" . $this->id;
                 if ($result == '#_LINKEDNAME' || $result == '#_EVENTLINK') {
                     $replace = "<a href='{$event_link}' title='{$this->name}'>{$this->name}</a>";
                 } else {
                     $replace = $event_link;
                 }
                 break;
             case '#_EDITEVENTURL':
             case '#_EDITEVENTLINK':
                 if ($this->can_manage('edit_events', 'edit_others_events')) {
                     if (is_multisite() && get_site_option('dbem_ms_global_events') && get_site_option('dbem_ms_global_events_links') && !empty($this->blog_id) && is_main_site() && $this->blog_id != get_current_blog_id()) {
                         $replace = get_site_url($this->blog_id, "/wp-admin/admin.php?page=events-manager-event&amp;event_id={$this->id}");
                     } else {
                         $replace = get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-event&amp;event_id={$this->id}";
                     }
                     if ($result == '#_EDITEVENTLINK') {
                         $replace = "<a href='{$replace}'>" . __('Edit') . ' ' . __('Event', 'dbem') . "</a>";
                     }
                 }
                 break;
                 //Bookings
             //Bookings
             case '#_ADDBOOKINGFORM':
                 //Depreciated
             //Depreciated
             case '#_REMOVEBOOKINGFORM':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGFORM':
                 ob_start();
                 $template = em_locate_template('placeholders/bookingform.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_BOOKINGBUTTON':
                 ob_start();
                 $template = em_locate_template('placeholders/bookingbutton.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_AVAILABLESEATS':
                 //Depreciated
             //Depreciated
             case '#_AVAILABLESPACES':
                 if ($this->rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_available_spaces();
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_BOOKEDSEATS':
                 //Depreciated
             //Depreciated
             case '#_BOOKEDSPACES':
                 if ($this->rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_booked_spaces();
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_PENDINGSPACES':
                 if ($this->rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_pending_spaces();
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_SEATS':
                 //Depreciated
             //Depreciated
             case '#_SPACES':
                 $replace = $this->get_spaces();
                 break;
             case '#_BOOKINGSURL':
             case '#_BOOKINGSLINK':
                 $bookings_link = get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager-bookings&amp;event_id=" . $this->id;
                 if ($result == '#_BOOKINGSLINK') {
                     $replace = "<a href='{$bookings_link}' title='{$this->name}'>{$this->name}</a>";
                 } else {
                     $replace = $bookings_link;
                 }
                 break;
                 //Contact Person
             //Contact Person
             case '#_CONTACTNAME':
             case '#_CONTACTPERSON':
                 //Depreciated (your call, I think name is better)
                 $replace = $this->contact->display_name;
                 break;
             case '#_CONTACTUSERNAME':
                 $replace = $this->contact->user_login;
                 break;
             case '#_CONTACTEMAIL':
             case '#_CONTACTMAIL':
                 //Depreciated
                 $replace = $this->contact->user_email;
                 break;
             case '#_CONTACTID':
                 $replace = $this->contact->ID;
                 break;
             case '#_CONTACTPHONE':
                 $replace = $this->contact->phone != '' ? $this->contact->phone : __('N/A', 'dbem');
                 break;
             case '#_CONTACTAVATAR':
                 $replace = get_avatar($this->contact->ID, $size = '50');
                 break;
             case '#_CONTACTPROFILELINK':
             case '#_CONTACTPROFILEURL':
                 if (function_exists('bp_core_get_user_domain')) {
                     $replace = bp_core_get_user_domain($this->contact->ID);
                     if ($result == '#_CONTACTPROFILELINK') {
                         $replace = '<a href="' . $replace . '">' . __('Profile') . '</a>';
                     }
                 }
                 break;
             case '#_CONTACTPROFILELINK':
             case '#_CONTACTPROFILEURL':
                 if (function_exists('bp_core_get_user_domain')) {
                     $replace = bp_core_get_user_domain($this->contact->ID);
                     if ($result == '#_CONTACTPROFILELINK') {
                         $replace = '<a href="' . $replace . '">' . __('Profile') . '</a>';
                     }
                 }
                 break;
             case '#_ATTENDEES':
                 ob_start();
                 $template = em_locate_template('placeholders/attendees.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_CATEGORIES':
                 ob_start();
                 $template = em_locate_template('placeholders/categories.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             default:
                 $replace = $result;
                 break;
         }
         $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
         $event_string = str_replace($result, $replace, $event_string);
     }
     //Time placeholders
     foreach ($placeholders[0] as $result) {
         // matches all PHP START date and time placeholders
         if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
             $replace = date_i18n(ltrim($result, "#"), $this->start);
             $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
             $event_string = str_replace($result, $replace, $event_string);
         }
         // matches all PHP END time placeholders for endtime
         if (preg_match('/^#@[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
             $replace = date_i18n(ltrim($result, "#@"), $this->end);
             $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
             $event_string = str_replace($result, $replace, $event_string);
         }
     }
     //Time place holder that doesn't show if empty.
     //TODO add filter here too
     preg_match_all('/#@?_\\{[A-Za-z0-9 -\\/,\\.\\\\]+\\}/', $format, $results);
     foreach ($results[0] as $result) {
         if (substr($result, 0, 3) == "#@_") {
             $date = 'end_date';
             $offset = 4;
         } else {
             $date = 'start_date';
             $offset = 3;
         }
         if ($date == 'end_date' && $this->end_date == $this->start_date) {
             $replace = __(apply_filters('em_event_output_placeholder', '', $this, $result, $target));
         } else {
             $replace = __(apply_filters('em_event_output_placeholder', mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $this->{$date}), $this, $result, $target));
         }
         $event_string = str_replace($result, $replace, $event_string);
     }
     //This is for the custom attributes
     preg_match_all('/#_ATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $format, $results);
     foreach ($results[0] as $resultKey => $result) {
         //Strip string of placeholder and just leave the reference
         $attRef = substr(substr($result, 0, strpos($result, '}')), 6);
         $attString = '';
         if (is_array($this->attributes) && array_key_exists($attRef, $this->attributes)) {
             $attString = $this->attributes[$attRef];
         } elseif (!empty($results[3][$resultKey])) {
             //Check to see if we have a second set of braces;
             $attString = $results[3][$resultKey];
         }
         $attString = apply_filters('em_event_output_placeholder', $attString, $this, $result, $target);
         $event_string = str_replace($result, $attString, $event_string);
     }
     //Now do dependent objects
     $event_string = $this->location->output($event_string, $target);
     //for backwards compat and easy use, take over the individual category placeholders with the frirst cat in th elist.
     $EM_Categories = $this->get_categories();
     if (count($EM_Categories->categories) > 0) {
         $EM_Category = $EM_Categories->categories[0];
     }
     if (empty($EM_Category)) {
         $EM_Category = new EM_Category();
     }
     $event_string = $EM_Category->output($event_string, $target);
     return apply_filters('em_event_output', $event_string, $this, $target);
 }
 /**
  * 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;
 }
 private function _get_default_content($event)
 {
     $network = $event->from_network();
     $link = $network ? get_blog_permalink($network, $event->get_id()) : get_permalink($event->get_id());
     $content = eab_call_template('get_event_dates', $event) . '<div class="eab-event-excerpt">' . $event->get_excerpt_or_fallback(256) . '</div>' . "<a href='{$link}'>" . $event->get_title() . '</a>' . '';
     return apply_filters('eab-email-newsletter-default_content', $content, $event);
 }
function s4w_build_document($post_info, $domain = NULL, $path = NULL)
{
    global $blog_id;
    global $current_blog;
    $doc = NULL;
    $plugin_s4w_settings = s4w_get_option();
    $exclude_ids = $plugin_s4w_settings['s4w_exclude_pages'];
    $categoy_as_taxonomy = $plugin_s4w_settings['s4w_cat_as_taxo'];
    $index_comments = $plugin_s4w_settings['s4w_index_comments'];
    $index_custom_fields = $plugin_s4w_settings['s4w_index_custom_fields'];
    if ($post_info) {
        # check if we need to exclude this document
        if (is_multisite() && in_array($current_blog->domain . $post_info->ID, (array) $exclude_ids)) {
            return NULL;
        } else {
            if (!is_multisite() && in_array($post_info->ID, (array) $exclude_ids)) {
                return NULL;
            }
        }
        $doc = new Apache_Solr_Document();
        $auth_info = get_userdata($post_info->post_author);
        # wpmu specific info
        if (is_multisite()) {
            // if we get here we expect that we've "switched" what blog we're running
            // as
            if ($domain == NULL) {
                $domain = $current_blog->domain;
            }
            if ($path == NULL) {
                $path = $current_blog->path;
            }
            $blogid = get_blog_id_from_url($domain, $path);
            $doc->setField('id', $domain . $path . $post_info->ID);
            $doc->setField('permalink', get_blog_permalink($blogid, $post_info->ID));
            $doc->setField('blogid', $blogid);
            $doc->setField('blogdomain', $domain);
            $doc->setField('blogpath', $path);
            $doc->setField('wp', 'multisite');
        } else {
            $doc->setField('id', $post_info->ID);
            $doc->setField('permalink', get_permalink($post_info->ID));
            $doc->setField('wp', 'wp');
        }
        $numcomments = 0;
        if ($index_comments) {
            $comments = get_comments("status=approve&post_id={$post_info->ID}");
            foreach ($comments as $comment) {
                $doc->addField('comments', $comment->comment_content);
                $numcomments += 1;
            }
        }
        $doc->setField('title', $post_info->post_title);
        $doc->setField('content', strip_tags($post_info->post_content));
        // rawcontent strips out characters lower than 0x20
        $doc->setField('rawcontent', strip_tags(preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', $post_info->post_content)));
        // contentnoshortcodes also strips characters below 0x20 but also strips shortcodes
        // used in WP to add images or other content, useful if you're pulling this data
        // into another system
        //
        // For example
        //   [caption id="attachment_92495" align="alignright" width="160" caption="Duane Sand"][/caption] FARGO - Republican U.S. Senate...
        //
        // Will become
        //   FARGO - Republican U.S. Senate...
        $doc->setField('contentnoshortcodes', strip_tags(preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', strip_tags(strip_shortcodes($post_info->post_content)))));
        $doc->setField('numcomments', $numcomments);
        $doc->setField('author', $auth_info->display_name);
        $doc->setField('author_s', get_author_posts_url($auth_info->ID, $auth_info->user_nicename));
        $doc->setField('type', $post_info->post_type);
        $doc->setField('date', s4w_format_date($post_info->post_date_gmt));
        $doc->setField('tdate', s4w_format_date($post_info->post_date_gmt));
        $doc->setField('modified', s4w_format_date($post_info->post_modified_gmt));
        $doc->setField('displaydate', $post_info->post_date);
        $doc->setField('displaymodified', $post_info->post_modified);
        $categories = get_the_category($post_info->ID);
        if (!$categories == NULL) {
            foreach ($categories as $category) {
                if ($categoy_as_taxonomy) {
                    $doc->addField('categories', get_category_parents($category->cat_ID, FALSE, '^^'));
                } else {
                    $doc->addField('categories', $category->cat_name);
                }
            }
        }
        //get all the taxonomy names used by wp
        $taxonomies = (array) get_taxonomies(array('_builtin' => FALSE), 'names');
        foreach ($taxonomies as $parent) {
            $terms = get_the_terms($post_info->ID, $parent);
            if ((array) $terms === $terms) {
                //we are creating *_taxonomy as dynamic fields using our schema
                //so lets set up all our taxonomies in that format
                $parent = $parent . "_taxonomy";
                foreach ($terms as $term) {
                    $doc->addField($parent, $term->name);
                }
            }
        }
        $tags = get_the_tags($post_info->ID);
        if (!$tags == NULL) {
            foreach ($tags as $tag) {
                $doc->addField('tags', $tag->name);
            }
        }
        if (count($index_custom_fields) > 0 && count($custom_fields = get_post_custom($post_info->ID))) {
            foreach ((array) $index_custom_fields as $field_name) {
                $field = (array) $custom_fields[$field_name];
                foreach ($field as $key => $value) {
                    $doc->addField($field_name . '_str', $value);
                    $doc->addField($field_name . '_srch', $value);
                }
            }
        }
        // add full json respone
        $json_response = new JSON_API_Response();
        $json_post = new JSON_API_Post_full(get_post($post_info->ID));
        $response = (object) array('post' => $json_post);
        $doc->setField('json', $json_response->get_json($response));
        // add tone: /nieuws/beste van het web/weblog/column/
        $tone = 'Nieuws';
        if ($blog_id > 1) {
            $nmt_blog_type = stripslashes(get_blog_option($blog_id, 'nmt_blog_type'));
            $nmt_blog_types = array(1 => 'Weblog', 2 => 'Column', 3 => 'Nieuws', 4 => 'Fotoserie');
            $tone = $nmt_blog_types[$nmt_blog_type];
        } else {
            $category_slugs = array();
            if (!$categories == NULL) {
                foreach ($categories as $category) {
                    $category_slugs[] = $category->slug;
                }
            }
            if (in_array('beste-van-het-web', $category_slugs)) {
                $tone = 'Beste van het web';
            }
        }
        $doc->setField('tone', $tone);
    } else {
        // this will fire during blog sign up on multisite, not sure why
        _e('Post Information is NULL', 'solr4wp');
    }
    syslog(LOG_ERR, "built document for {$blog_id} - {$domain}{$path} with title " . $post_info->post_title . " and status of " . $post_info->post_status);
    return $doc;
}
 /**
  * Get MS Page URL.
  *
  * @since  1.0.0
  *
  * @param string|WP_Post $page_type The page type name or a WP_Post object.
  * @param boolean $ssl If wanted a SSL url. Set to null to use auto detection.
  * @return string The MS Page URL.
  */
 public static function get_page_url($page_type, $ssl = null)
 {
     static $Urls = array();
     $site_id = self::get_site_info('id');
     $page_id = self::get_page_id($page_type);
     if (!isset($Urls[$page_id])) {
         if (is_multisite()) {
             $url = get_blog_permalink($site_id, $page_id);
         } else {
             $url = get_permalink($page_id);
         }
         if (null === $ssl) {
             $ssl = is_ssl();
         }
         if ($ssl) {
             $url = MS_Helper_Utility::get_ssl_url($url);
         }
         $Urls[$page_id] = apply_filters('ms_model_pages_get_ms_page_url', $url, $page_type, $ssl, $site_id);
     }
     return $Urls[$page_id];
 }
Exemple #28
0
 function get_permalink()
 {
     if (EM_MS_GLOBAL) {
         $blog_id = empty($this->blog_id) ? get_current_blog_id() : $this->blog_id;
         //linking directly to the blog by default
         $event_link = get_blog_permalink($this->blog_id, $this->post_id);
         //if on main site and direct links disabled then show link to main site
         if (!get_site_option('dbem_ms_global_events_links') && is_main_site() && $blog_id != get_current_blog_id()) {
             if (get_option('dbem_events_page')) {
                 $event_link = trailingslashit(get_permalink(get_option('dbem_events_page')) . get_site_option('dbem_ms_events_slug', EM_EVENT_SLUG) . '/' . $this->event_slug . '-' . $this->event_id);
             }
         }
     }
     if (empty($event_link)) {
         $event_link = get_post_permalink($this->post_id);
     }
     return apply_filters('em_event_get_permalink', $event_link, $this);
 }
Exemple #29
0
 function get_permalink()
 {
     if (EM_MS_GLOBAL) {
         //if no blog id defined, assume it's the main blog
         $blog_id = empty($this->blog_id) ? get_current_site()->blog_id : $this->blog_id;
         //if we're not on the same blog as this event then decide whether to link to main blog or to source blog
         if ($blog_id != get_current_blog_id()) {
             if (!get_site_option('dbem_ms_global_events_links') && is_main_site() && get_option('dbem_events_page')) {
                 //if on main site, and events page exists and direct links are disabled then show link to main site
                 $event_link = trailingslashit(get_permalink(get_option('dbem_events_page')) . get_site_option('dbem_ms_events_slug', EM_EVENT_SLUG) . '/' . $this->event_slug . '-' . $this->event_id);
             } else {
                 //linking directly to the source blog by default
                 $event_link = get_blog_permalink($blog_id, $this->post_id);
             }
         }
     }
     if (empty($event_link)) {
         $event_link = get_post_permalink($this->post_id);
     }
     return apply_filters('em_event_get_permalink', $event_link, $this);
 }
Exemple #30
0
			<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 
            echo $blog_url;
            ?>
"><?php 
            echo $blog_name;
            ?>
</a></b></td><?php 
        }
        ?>