global $wpdb;
$event_data = [];
+ $image_url = false;
+ $datesArray = array();
// this section is for a sidebar events widget, typically on a front page
if( isset( $_REQUEST['date_string'] ) || isset($_REQUEST['all_events'] ) ){
// $this->dateRangeTimes = "AND end_time >= CURDATE() ORDER BY start_time LIMIT 3";
// $events = $this->getModelTimesData();
-
-
-
- $datesArray = array();
foreach($events as $event){
$sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events WHERE id = " . $event['event'];
}
$categories = $this->getCategories();
- if ( isset( $categories ) ) {
+ if ( isset($categories) && is_array($categories)) {
foreach( $categories as &$category ) {
if ( $categoryId && is_array( $categoryId ) && in_array( $category['id'], $categoryId ) ) {
$category['default'] = 1;
*/
// Setup rewrite for package detail page
+define ('GLM_EVENTS_REWRITE_RULE', '('.$this->config['settings']['canonical_event_page'].')/([^/]*)$');
add_filter( 'rewrite_rules_array', function($rules) {
$newrules = array();
- $newrules['('.$this->config['settings']['canonical_event_page'].')/([^/]*)$']='index.php?pagename=$matches[1]&eventslug=$matches[2]';
+ $newrules[GLM_EVENTS_REWRITE_RULE]='index.php?pagename=$matches[1]&eventslug=$matches[2]';
return $newrules + $rules;
});
add_filter( 'query_vars', function($vars) {
return $vars;
});
add_action('wp_loaded', function() {
- $rules = get_option('rewrite_rules');
- if ( ! isset( $rules['('.$this->config['settings']['canonical_event_page'].')/([^/]*)$'] ) ) {
- trigger_error('Doing rewrite flush - Event detail page', E_USER_NOTICE); // Logging that this is happening so we can track when that happens.
- global $wp_rewrite;
- $wp_rewrite->flush_rules();
+ // Only do this if this is a front-end request
+ if (!is_admin()) {
+ $rules = get_option('rewrite_rules');
+ if ( ! isset( $rules[GLM_EVENTS_REWRITE_RULE] ) ) {
+ trigger_error('Doing rewrite flush - Event detail page', E_USER_NOTICE); // Logging that this is happening so we can track when that happens.
+ global $wp_rewrite;
+ $wp_rewrite->flush_rules();
+ }
}
});