Cleaned up some issues with rewrites.
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 14 Apr 2017 20:05:07 +0000 (16:05 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 14 Apr 2017 20:05:07 +0000 (16:05 -0400)
Killing off a few undefined variable problems.

models/admin/ajax/eventsCalMonthAJAX.php
models/front/events/list.php
setup/frontHooks.php

index dd6bd17..5eda666 100644 (file)
@@ -132,6 +132,8 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes
         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'] ) ){
@@ -170,10 +172,6 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes
 //                $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'];
 
index 2c89397..c59555f 100644 (file)
@@ -259,7 +259,7 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
         }
 
         $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;
index 4fce8c7..db648e1 100644 (file)
  */
 
 // 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) {
@@ -37,11 +38,14 @@ 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();
+        }
     }
 });