Edit File by line
/home/zeestwma/ajeebong.../wp-conte.../plugins/revslide.../includes
File: em-integration.class.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* @author ThemePunch <info@themepunch.com>
[2] Fix | Delete
* @link https://www.themepunch.com/
[3] Fix | Delete
* @copyright 2024 ThemePunch
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
if(!defined('ABSPATH')) exit();
[7] Fix | Delete
[8] Fix | Delete
class RevSliderEventsManager extends RevSliderFunctions {
[9] Fix | Delete
public function __construct(){
[10] Fix | Delete
$this->init_em();
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
public function init_em(){
[14] Fix | Delete
add_filter('revslider_get_posts_by_category', array($this, 'add_post_query'), 10, 2);
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* check if events class exists
[19] Fix | Delete
*/
[20] Fix | Delete
public static function isEventsExists(){
[21] Fix | Delete
return defined('EM_VERSION') && defined('EM_PRO_MIN_VERSION');
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* get sort by list
[26] Fix | Delete
* @before: RevSliderEventsManager::getArrFilterTypes()
[27] Fix | Delete
*/
[28] Fix | Delete
public static function get_filter_types(){
[29] Fix | Delete
return array(
[30] Fix | Delete
'none' => __('All Events', 'revslider'),
[31] Fix | Delete
'today' => __('Today', 'revslider'),
[32] Fix | Delete
'tomorrow' => __('Tomorrow', 'revslider'),
[33] Fix | Delete
'future' => __('Future', 'revslider'),
[34] Fix | Delete
'past' => __('Past', 'revslider'),
[35] Fix | Delete
'month' => __('This Month', 'revslider'),
[36] Fix | Delete
'nextmonth' => __('Next Month', 'revslider')
[37] Fix | Delete
);
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* get meta query
[43] Fix | Delete
* @before: RevSliderEventsManager::getWPQuery()
[44] Fix | Delete
*/
[45] Fix | Delete
public static function get_query($filter_type, $sort_by){
[46] Fix | Delete
$response = array();
[47] Fix | Delete
$dayMs = 60 * 60 * 24;
[48] Fix | Delete
$time = current_time('timestamp');
[49] Fix | Delete
$todayStart = strtotime(date('Y-m-d', $time));
[50] Fix | Delete
$todayEnd = $todayStart + $dayMs-1;
[51] Fix | Delete
$tomorrowStart = $todayEnd+1;
[52] Fix | Delete
$tomorrowEnd = $tomorrowStart + $dayMs-1;
[53] Fix | Delete
$start_month = strtotime(date('Y-m-1',$time));
[54] Fix | Delete
$end_month = strtotime(date('Y-m-t',$time)) + 86399;
[55] Fix | Delete
$next_month_middle = strtotime('+1 month', $time); //get the end of this month + 1 day
[56] Fix | Delete
$start_next_month = strtotime(date('Y-m-1',$next_month_middle));
[57] Fix | Delete
$end_next_month = strtotime(date('Y-m-t',$next_month_middle)) + 86399;
[58] Fix | Delete
$query = array();
[59] Fix | Delete
[60] Fix | Delete
switch($filter_type){
[61] Fix | Delete
case 'none': //none
[62] Fix | Delete
break;
[63] Fix | Delete
case 'today':
[64] Fix | Delete
$query[] = array('key' => '_start_ts', 'value' => $todayEnd, 'compare' => '<=');
[65] Fix | Delete
$query[] = array('key' => '_end_ts', 'value' => $todayStart, 'compare' => '>=');
[66] Fix | Delete
break;
[67] Fix | Delete
case 'future':
[68] Fix | Delete
$query[] = array('key' => '_start_ts', 'value' => $time, 'compare' => '>');
[69] Fix | Delete
break;
[70] Fix | Delete
case 'tomorrow':
[71] Fix | Delete
$query[] = array('key' => '_start_ts', 'value' => $tomorrowEnd, 'compare' => '<=');
[72] Fix | Delete
$query[] = array('key' => '_end_ts', 'value' => $todayStart, 'compare' => '>=');
[73] Fix | Delete
break;
[74] Fix | Delete
case 'past':
[75] Fix | Delete
$query[] = array('key' => '_end_ts', 'value' => $todayStart, 'compare' => '<');
[76] Fix | Delete
break;
[77] Fix | Delete
case 'month':
[78] Fix | Delete
$query[] = array('key' => '_start_ts', 'value' => $end_month, 'compare' => '<=');
[79] Fix | Delete
$query[] = array('key' => '_end_ts', 'value' => $start_month, 'compare' => '>=');
[80] Fix | Delete
break;
[81] Fix | Delete
case 'nextmonth':
[82] Fix | Delete
$query[] = array('key' => '_start_ts', 'value' => $end_next_month, 'compare' => '<=');
[83] Fix | Delete
$query[] = array('key' => '_end_ts', 'value' => $start_next_month, 'compare' => '>=');
[84] Fix | Delete
break;
[85] Fix | Delete
default:
[86] Fix | Delete
$f = RevSliderGlobals::instance()->get('RevSliderFunctions');
[87] Fix | Delete
$f->throw_error('Wrong event filter');
[88] Fix | Delete
break;
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
if(!empty($query))
[92] Fix | Delete
$response['meta_query'] = $query;
[93] Fix | Delete
[94] Fix | Delete
//convert sortby
[95] Fix | Delete
switch($sort_by){
[96] Fix | Delete
case 'event_start_date':
[97] Fix | Delete
$response['orderby'] = 'meta_value_num';
[98] Fix | Delete
$response['meta_key'] = '_start_ts';
[99] Fix | Delete
break;
[100] Fix | Delete
case 'event_end_date':
[101] Fix | Delete
$response['orderby'] = 'meta_value_num';
[102] Fix | Delete
$response['meta_key'] = '_end_ts';
[103] Fix | Delete
break;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
return $response;
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* get event post data in array.
[112] Fix | Delete
* if the post is not event, return empty array
[113] Fix | Delete
* @before: RevSliderEventsManager::getEventPostData()
[114] Fix | Delete
*/
[115] Fix | Delete
public static function get_event_post_data($postID, $prefix = ''){
[116] Fix | Delete
if(self::isEventsExists() == false) return array();
[117] Fix | Delete
[118] Fix | Delete
$postType = get_post_type($postID);
[119] Fix | Delete
[120] Fix | Delete
if($postType != EM_POST_TYPE_EVENT) return array();
[121] Fix | Delete
[122] Fix | Delete
$f = RevSliderGlobals::instance()->get('RevSliderFunctions');
[123] Fix | Delete
$event = new EM_Event($postID, 'post_id');
[124] Fix | Delete
$location = $event->get_location();
[125] Fix | Delete
$ev = $event->to_array();
[126] Fix | Delete
$loc = $location->to_array();
[127] Fix | Delete
$date_format = get_option('date_format');
[128] Fix | Delete
$time_format = get_option('time_format');
[129] Fix | Delete
[130] Fix | Delete
$response = array(
[131] Fix | Delete
$prefix.'id' => $f->get_val($ev, 'event_id'),
[132] Fix | Delete
$prefix.'start_date' => date_format(date_create_from_format('Y-m-d', $f->get_val($ev, 'event_start_date')), $date_format),
[133] Fix | Delete
$prefix.'end_date' => date_format(date_create_from_format('Y-m-d', $f->get_val($ev, 'event_end_date')), $date_format),
[134] Fix | Delete
$prefix.'start_time' => date_format(date_create_from_format('H:i:s', $f->get_val($ev, 'event_start_time')), $time_format),
[135] Fix | Delete
$prefix.'end_time' => date_format(date_create_from_format('H:i:s', $f->get_val($ev, 'event_end_time')), $time_format),
[136] Fix | Delete
$prefix.'location_name' => $f->get_val($loc, 'location_name'),
[137] Fix | Delete
$prefix.'location_address' => $f->get_val($loc, 'location_address'),
[138] Fix | Delete
$prefix.'location_slug' => $f->get_val($loc, 'location_slug'),
[139] Fix | Delete
$prefix.'location_town' => $f->get_val($loc, 'location_town'),
[140] Fix | Delete
$prefix.'location_state' => $f->get_val($loc, 'location_state'),
[141] Fix | Delete
$prefix.'location_postcode' => $f->get_val($loc, 'location_postcode'),
[142] Fix | Delete
$prefix.'location_region' => $f->get_val($loc, 'location_region'),
[143] Fix | Delete
$prefix.'location_country' => $f->get_val($loc, 'location_country'),
[144] Fix | Delete
$prefix.'location_latitude' => $f->get_val($loc, 'location_latitude'),
[145] Fix | Delete
$prefix.'location_longitude' => $f->get_val($loc, 'location_longitude')
[146] Fix | Delete
);
[147] Fix | Delete
[148] Fix | Delete
return $response;
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
[152] Fix | Delete
/**
[153] Fix | Delete
* get events sort by array
[154] Fix | Delete
*/
[155] Fix | Delete
public static function getArrSortBy(){
[156] Fix | Delete
return array(
[157] Fix | Delete
'event_start_date' => __('Event Start Date', 'revslider'),
[158] Fix | Delete
'event_end_date' => __('Event End Date', 'revslider')
[159] Fix | Delete
);
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
/**
[163] Fix | Delete
* triggered if we receive posts by categories (RevSliderSlider::get_posts_by_categories())
[164] Fix | Delete
**/
[165] Fix | Delete
public function add_post_query($data, $slider){
[166] Fix | Delete
$filter_type = $slider->get_param('events_filter', 'none');
[167] Fix | Delete
if(self::isEventsExists()){
[168] Fix | Delete
$data['addition'] = RevSliderEventsManager::get_query($filter_type, $this->get_val($data, 'sort_by'));
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
return $data;
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
public static function add_em_layer_v7($post_data, $data, $metas, $slider){
[175] Fix | Delete
if(self::isEventsExists() == false) return $post_data;
[176] Fix | Delete
[177] Fix | Delete
$f = RevSliderGlobals::instance()->get('RevSliderFunctions');
[178] Fix | Delete
[179] Fix | Delete
foreach($post_data ?? [] as $key => $post){
[180] Fix | Delete
$data = RevSliderEventsManager::get_event_post_data($f->get_val($post, 'id'), 'event_');
[181] Fix | Delete
if($data === false) continue;
[182] Fix | Delete
//modify excerpt if empty to be filled with content
[183] Fix | Delete
if(!isset($post['excerpt']) || trim($post['excerpt']) === ''){
[184] Fix | Delete
$post['excerpt'] = str_replace(array('<br/>', '<br />'), '', strip_tags($f->get_val($post, array('content', 'content')), '<b><br><i><strong><small>'));
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
$post_data[$key] = array_merge($post, $data);
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
return $post_data;
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
add_filter('sr_streamline_post_data_post', array('RevSliderEventsManager', 'add_em_layer_v7'), 10, 4);
[196] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function