Apply the limit to events after the sorting.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 1 Jun 2018 16:15:08 +0000 (12:15 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 1 Jun 2018 16:15:08 +0000 (12:15 -0400)
After the resorting of the events need to check for and apply any limit.

index.php
models/front/events/list.php

index 8a10a78..a5acf84 100644 (file)
--- a/index.php
+++ b/index.php
@@ -4,7 +4,7 @@
  * Plugin URI: http://www.gaslightmedia.com/
  * Description: Gaslight Media Members Database.
 
- * Version: 1.6.84
+ * Version: 1.6.85
 
  * Author: Chuck Scott
  * Author URI: http://www.gaslightmedia.com/
@@ -22,7 +22,7 @@
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
 
- * @version 1.6.84
+ * @version 1.6.85
 
  */
 
@@ -47,7 +47,7 @@ if (!defined('ABSPATH')) {
  *  so that we're sure the other add-ons see an up to date
  *  version from this plugin.
  */
-define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.84');
+define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.85');
 define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.5');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
index fd7cea2..704079d 100644 (file)
@@ -791,6 +791,9 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
                 }
                 return ( $event1['starting_timestamp'] < $event2['starting_timestamp'] ) ? -1: 1;
             } );
+            if ( $limit && $limit = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
+                $events = array_slice( $events, 0, $limit );
+            }
         }
 
          // Check for alternate template requests