1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104:
<?php
namespace EventPost;
if(is_multisite()){
global $Multisite;
$Multisite=new Multisite();
}
class Multisite{
function __construct(){
add_filter('eventpost_params',array(&$this,'params'),1,2);
add_filter('eventpost_get',array(&$this,'get'),1,3);
}
public function Multisite(){
$this->__construct();
}
private function no_use(){
__('Extends Event post to multisite networks','event-post');
__('Event Post multisite support','event-post');
}
public function params($param, $context){
$param['blogs']='';
return $param;
}
public function get($empty,$arg,$requete){
$is_result=apply_filters('eventpost_multisite_get',$empty,$arg,$requete);
if($is_result!=$empty)
return $is_result;
if(!is_array($arg) || !isset($arg['blogs']) || ''==$arg['blogs'])
return $empty;
$blog_ids=array();
if($arg['blogs']=='all'){
$blogs=get_sites(array('limit'=>0));
foreach ($blogs as $blog) {
$blog_ids[]=$blog->blog_id;
}
}
elseif(!empty($arg['blogs'])){
$blog_ids=apply_filters('eventpost_multisite_blogids',explode(',',$arg['blogs']));
}
else{
return $empty;
}
global $EventPost,$wpdb;
$all_events=array();
foreach ($blog_ids as $blog_id) {
switch_to_blog($blog_id);
$query = new WP_Query($requete);
$events = $wpdb->get_col($query->request);
foreach($events as $k=>$post){
$event = $EventPost->retreive($post);
$aEvent = (array) $event;
$all_events[($arg['orderby']!='meta_value' && isset($aEvent[$arg['orderby']])?$aEvent[$arg['orderby']]:$event->time_start).'-'.$blog_id.'-'.$event->ID]=$event;
}
restore_current_blog();
}
if($arg['order']!=''){
$sort = $arg['order']=='DESC'?'krsort':'ksort';
$sort($all_events);
}
return $all_events;
}
}