WordPress Infinite Scroll – Ajax Load More - Version 2.10.1

Version Description

  • May 8, 2016 =
  • NEW - Users can now load a custom version of ajax-load-more.css from {/alm} folder in current theme directory.
  • NEW - Class definitions for alm shortcode and css enqueue script. More to come.
  • FIX - Removed unnecessary ob_end_clean() function from alm_query_posts() that was causing php notices for some users.
  • FIX - Fixed meta_query issue with EXISTS and NOT EXISTS meta_compare values.
  • FIX - Issue with meta_key parameter and orderby.
  • UPDATE - Updated $.fn.almUpdateCurrentPage() function to allow for multiple instances of Paging.
  • UPDATE - Various Admin UI bug fixes/enhancements.
Download this release

Release Info

Developer dcooney
Plugin Icon 128x128 WordPress Infinite Scroll – Ajax Load More
Version 2.10.1
Comparing to
See all releases

Code changes from version 2.10.0.1 to 2.10.1

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dcooney
3
  Donate link: https://connekthq.com/donate/
4
  Tags: infinite scroll, scroll, infinite, lazy load, lazy loading, pagination, ajax pagination, ajax, ajax posts, ajax load posts, loop, query, dynamic, shortcode builder, wp_query, search, tags, category, post types, taxonomy, meta_query, archives, date, infinite scrolling, woocommerce
5
  Requires at least: 3.6
6
- Tested up to: 4.5
7
- Stable tag: 2.10.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -326,11 +326,22 @@ How to install Ajax Load More.
326
 
327
  == Changelog ==
328
 
329
- = 2.10.0.1 =
 
 
 
 
 
 
 
 
 
 
330
  * FIX - JavaScript fix for 'Unexpected token' error is Safari and IE with alm.AjaxLoadMore.success() function.
331
  * FIX - Fixed canonical URL issue on home/front pages.
332
 
333
- = 2.10.0 =
 
334
  * NEW - Converted the Ajax return content type from HTML to JSON.
335
  * NEW - Adding transition_speed shortcode parameter.
336
  * NEW - Added alm_button_label filter to modify default button text.
3
  Donate link: https://connekthq.com/donate/
4
  Tags: infinite scroll, scroll, infinite, lazy load, lazy loading, pagination, ajax pagination, ajax, ajax posts, ajax load posts, loop, query, dynamic, shortcode builder, wp_query, search, tags, category, post types, taxonomy, meta_query, archives, date, infinite scrolling, woocommerce
5
  Requires at least: 3.6
6
+ Tested up to: 4.5.2
7
+ Stable tag: 2.10.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
326
 
327
  == Changelog ==
328
 
329
+ = 2.10.1 - May 8, 2016 =
330
+ * NEW - Users can now load a custom version of ajax-load-more.css from {/alm} folder in current theme directory.
331
+ * NEW - Class definitions for alm shortcode and css enqueue script. More to come.
332
+ * FIX - Removed unnecessary ob_end_clean() function from alm_query_posts() that was causing php notices for some users.
333
+ * FIX - Fixed meta_query issue with EXISTS and NOT EXISTS meta_compare values.
334
+ * FIX - Issue with meta_key parameter and orderby.
335
+ * UPDATE - Updated $.fn.almUpdateCurrentPage() function to allow for multiple instances of Paging.
336
+ * UPDATE - Various Admin UI bug fixes/enhancements.
337
+
338
+
339
+ = 2.10.0.1 - April 11, 2016 =
340
  * FIX - JavaScript fix for 'Unexpected token' error is Safari and IE with alm.AjaxLoadMore.success() function.
341
  * FIX - Fixed canonical URL issue on home/front pages.
342
 
343
+
344
+ = 2.10.0 - April 10, 2016 =
345
  * NEW - Converted the Ajax return content type from HTML to JSON.
346
  * NEW - Adding transition_speed shortcode parameter.
347
  * NEW - Added alm_button_label filter to modify default button text.
admin/admin.php CHANGED
@@ -21,70 +21,76 @@ add_action( 'wp_ajax_alm_layouts_get', 'alm_layouts_get' ); // Get layout
21
 
22
  function alm_license_activation(){
23
 
24
- $nonce = $_GET["nonce"];
25
- $type = $_GET["type"]; // activate / deactivate
26
- $item = $_GET["item"];
27
- $license = $_GET["license"];
28
- $url = $_GET["url"];
29
- $upgrade = $_GET["upgrade"];
30
- $option_status = $_GET["status"];
31
- $option_key = $_GET["key"];
32
-
33
- // Check our nonce, if they don't match then bounce!
34
- if (! wp_verify_nonce( $nonce, 'alm_repeater_nonce' ))
35
- die('Error - unable to verify nonce, please try again.');
36
-
37
- // data to send in our API request
38
- if($type === 'activate'){
39
- $action = 'activate_license';
40
- }else{
41
- $action = 'deactivate_license';
42
- }
43
-
44
- $api_params = array(
45
- 'edd_action'=> $action,
46
- 'license' => $license,
47
- 'item_id' => $item, // the ID of our product in EDD
48
- 'url' => home_url()
49
- );
50
-
51
- // Call the custom API.
52
- //$response = wp_remote_get( add_query_arg( $api_params, $url ), array( 'timeout' => 15, 'sslverify' => false ) );
53
-
54
- // Updated 2.8.7
55
- $response = wp_remote_post( ALM_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
56
-
57
- // make sure the response came back okay
58
- if ( is_wp_error( $response ) )
59
- return false;
60
-
61
-
62
- $license_data = $response['body'];
63
- $license_data = json_decode($license_data); // decode the license data
64
 
65
-
66
- $return["success"] = $license_data->success;
 
 
 
 
67
 
68
- $msg = '';
69
- if($type === 'activate'){
70
- $return["license_limit"] = $license_data->license_limit;
71
- $return["expires"] = $license_data->expires;
72
- $return["site_count"] = $license_data->site_count;
73
- $return["activations_left"] = $license_data->activations_left;
74
- $return["license"] = $license_data->license;
75
- $return["item_name"] = $license_data->item_name;
76
- if($license_data->activations_left === 0 && $license_data->success === false){
77
- $msg = '<strong>Sorry, but you are out of available licenses <em>('. $license_data->license_limit .' / '. $license_data->site_count .')</em>.</strong> Please visit the <a href="'.$upgrade.'" target="_blank">'.$license_data->item_name.'</a> page to add additional licenses.';
78
- }
79
- }
80
- $return["msg"] = $msg;
81
 
82
- update_option( $option_status, $license_data->license);
83
- update_option( $option_key, $license );
 
 
 
 
 
 
84
 
85
- echo json_encode($return);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
- die();
 
 
88
  }
89
 
90
 
@@ -155,6 +161,7 @@ function alm_admin_vars() { ?>
155
  <?php }
156
 
157
 
 
158
  /*
159
  * alm_set_admin_nonce
160
  * Create admin nonce on Repeater Template page only
21
 
22
  function alm_license_activation(){
23
 
24
+ if (current_user_can( 'edit_theme_options' )){
25
+
26
+ $nonce = $_GET["nonce"];
27
+ $type = $_GET["type"]; // activate / deactivate
28
+ $item = $_GET["item"];
29
+ $license = $_GET["license"];
30
+ $url = $_GET["url"];
31
+ $upgrade = $_GET["upgrade"];
32
+ $option_status = $_GET["status"];
33
+ $option_key = $_GET["key"];
34
+
35
+ // Check our nonce, if they don't match then bounce!
36
+ if (! wp_verify_nonce( $nonce, 'alm_repeater_nonce' ))
37
+ die('Error - unable to verify nonce, please try again.');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ // data to send in our API request
40
+ if($type === 'activate'){
41
+ $action = 'activate_license';
42
+ }else{
43
+ $action = 'deactivate_license';
44
+ }
45
 
46
+ $api_params = array(
47
+ 'edd_action'=> $action,
48
+ 'license' => $license,
49
+ 'item_id' => $item, // the ID of our product in EDD
50
+ 'url' => home_url()
51
+ );
52
+
53
+ // Call the custom API.
54
+ //$response = wp_remote_get( add_query_arg( $api_params, $url ), array( 'timeout' => 15, 'sslverify' => false ) );
55
+
56
+ // Updated 2.8.7
57
+ $response = wp_remote_post( ALM_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
 
58
 
59
+ // make sure the response came back okay
60
+ if ( is_wp_error( $response ) )
61
+ return false;
62
+
63
+
64
+ $license_data = $response['body'];
65
+ $license_data = json_decode($license_data); // decode the license data
66
+
67
 
68
+ $return["success"] = $license_data->success;
69
+
70
+ $msg = '';
71
+ if($type === 'activate'){
72
+ $return["license_limit"] = $license_data->license_limit;
73
+ $return["expires"] = $license_data->expires;
74
+ $return["site_count"] = $license_data->site_count;
75
+ $return["activations_left"] = $license_data->activations_left;
76
+ $return["license"] = $license_data->license;
77
+ $return["item_name"] = $license_data->item_name;
78
+ if($license_data->activations_left === 0 && $license_data->success === false){
79
+ $msg = '<strong>Sorry, but you are out of available licenses <em>('. $license_data->license_limit .' / '. $license_data->site_count .')</em>.</strong> Please visit the <a href="'.$upgrade.'" target="_blank">'.$license_data->item_name.'</a> page to add additional licenses.';
80
+ }
81
+ }
82
+ $return["msg"] = $msg;
83
+
84
+ update_option( $option_status, $license_data->license);
85
+ update_option( $option_key, $license );
86
+
87
+ echo json_encode($return);
88
+
89
+ die();
90
 
91
+ } else {
92
+ echo __('You don\'t belong here.', ALM_NAME);
93
+ }
94
  }
95
 
96
 
161
  <?php }
162
 
163
 
164
+
165
  /*
166
  * alm_set_admin_nonce
167
  * Create admin nonce on Repeater Template page only
admin/css/admin.css CHANGED
@@ -668,6 +668,9 @@ a.layout-hover{
668
  .ajax-load-more .repeaters input[type=text]{
669
  padding: 9px 10px;
670
  }
 
 
 
671
 
672
  .ajax-load-more input.disabled-input{
673
  opacity: 0.5;
@@ -2106,18 +2109,18 @@ table.highlight{
2106
  text-align: center;
2107
  margin: 15px 0 0 !important;
2108
  display: block;
2109
- font-size: 14px !important;
2110
  font-weight: 700;
2111
  text-transform: none !important;
2112
  text-align: center;
2113
- /* text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.1); */
2114
  }
2115
  .alm-add-template a{
2116
  background: #efefef;
2117
  border: 1px solid #e1e1e1;
2118
  color: #333;
2119
  display: inline-block;
2120
- padding: 9px 14px 8px;
 
2121
  -webkit-border-radius: 3px;
2122
  -moz-border-radius: 3px;
2123
  border-radius: 3px;
668
  .ajax-load-more .repeaters input[type=text]{
669
  padding: 9px 10px;
670
  }
671
+ .ajax-load-more input[type=number]{
672
+ height: auto;
673
+ }
674
 
675
  .ajax-load-more input.disabled-input{
676
  opacity: 0.5;
2109
  text-align: center;
2110
  margin: 15px 0 0 !important;
2111
  display: block;
2112
+ font-size: 15px !important;
2113
  font-weight: 700;
2114
  text-transform: none !important;
2115
  text-align: center;
 
2116
  }
2117
  .alm-add-template a{
2118
  background: #efefef;
2119
  border: 1px solid #e1e1e1;
2120
  color: #333;
2121
  display: inline-block;
2122
+ padding: 11px 16px 13px;
2123
+ line-height: 1;
2124
  -webkit-border-radius: 3px;
2125
  -moz-border-radius: 3px;
2126
  border-radius: 3px;
admin/includes/cta/dyk.php CHANGED
@@ -1,7 +1,7 @@
1
  <div class="cta dyk">
2
  <h3><?php _e('Did you know?', 'ajax-load-more'); ?></h3>
3
  <?php
4
- $random = rand(1, 3);
5
  ?>
6
  <?php if($random == 1){ ?>
7
  <img src="<?php echo ALM_ADMIN_URL; ?>img/add-ons/shortcode-editor.jpg"><br/>
@@ -23,4 +23,11 @@
23
  <p><a target="blank" style="font-weight: 700;" href="https://connekthq.com/plugins/ajax-load-more/add-ons/previous-post/?utm_source=WP%20Admin&utm_medium=ALM%20DYK&utm_campaign=PreviousPost">Learn More &raquo;</a></p>
24
  <?php } ?>
25
 
 
 
 
 
 
 
 
26
  </div>
1
  <div class="cta dyk">
2
  <h3><?php _e('Did you know?', 'ajax-load-more'); ?></h3>
3
  <?php
4
+ $random = rand(1, 4);
5
  ?>
6
  <?php if($random == 1){ ?>
7
  <img src="<?php echo ALM_ADMIN_URL; ?>img/add-ons/shortcode-editor.jpg"><br/>
23
  <p><a target="blank" style="font-weight: 700;" href="https://connekthq.com/plugins/ajax-load-more/add-ons/previous-post/?utm_source=WP%20Admin&utm_medium=ALM%20DYK&utm_campaign=PreviousPost">Learn More &raquo;</a></p>
24
  <?php } ?>
25
 
26
+ <?php if($random == 4){ ?>
27
+ <img src="<?php echo ALM_ADMIN_URL; ?>img/add-ons/comments-add-on.jpg"><br/>
28
+ <p class="addon-intro">You can lazy load your comments with Ajax Load More!</p>
29
+ <p>The <a target="blank" style="font-weight: 700;" href="https://connekthq.com/plugins/ajax-load-more/add-ons/comments/?utm_source=WP%20Admin&utm_medium=ALM%20DYK&utm_campaign=COmments">Comments</a> add-on will load and display blog comments using the core Ajax Load More infinite scroll functionality.</p>
30
+ <p><a target="blank" style="font-weight: 700;" href="https://connekthq.com/plugins/ajax-load-more/add-ons/comments/?utm_source=WP%20Admin&utm_medium=ALM%20DYK&utm_campaign=COmments">Learn More &raquo;</a></p>
31
+ <?php } ?>
32
+
33
  </div>
admin/views/repeater-templates.php CHANGED
@@ -247,8 +247,7 @@
247
  </div>
248
 
249
  <div class="cnkt-sidebar">
250
- <?php include_once( ALM_PATH . 'admin/includes/cta/writeable.php'); ?>
251
- <div class="cta">
252
  <h3><?php _e('Templating Help', 'ajax-load-more'); ?></h3>
253
  <div class="item">
254
  <p><strong><?php _e('What is a repeater template?', 'ajax-load-more'); ?></strong></p>
@@ -265,6 +264,7 @@
265
  </ul>
266
  </div>
267
  </div>
 
268
  </div>
269
 
270
  </div>
247
  </div>
248
 
249
  <div class="cnkt-sidebar">
250
+ <div class="cta">
 
251
  <h3><?php _e('Templating Help', 'ajax-load-more'); ?></h3>
252
  <div class="item">
253
  <p><strong><?php _e('What is a repeater template?', 'ajax-load-more'); ?></strong></p>
264
  </ul>
265
  </div>
266
  </div>
267
+ <?php include_once( ALM_PATH . 'admin/includes/cta/writeable.php'); ?>
268
  </div>
269
 
270
  </div>
ajax-load-more.php CHANGED
@@ -2,51 +2,21 @@
2
  /*
3
  Plugin Name: Ajax Load More
4
  Plugin URI: http://connekthq.com/plugins/ajax-load-more
5
- Description: A powerful solution to add infinite scroll functionality to your website.
6
  Text Domain: ajax-load-more
7
  Author: Darren Cooney
8
  Twitter: @KaptonKaos
9
  Author URI: http://connekthq.com
10
- Version: 2.10.0.1
11
  License: GPL
12
  Copyright: Darren Cooney & Connekt Media
13
-
14
  */
15
 
16
-
17
- define('ALM_VERSION', '2.10.0.1');
18
- define('ALM_RELEASE', 'April 11, 2016');
19
- define('ALM_STORE_URL', 'https://connekthq.com');
20
-
21
- if (!defined('ALM_ALTERNATING_ITEM_NAME'))
22
- define('ALM_ALTERNATING_ITEM_NAME', '14456' );
23
-
24
- if (!defined('ALM_CACHE_ITEM_NAME'))
25
- define('ALM_CACHE_ITEM_NAME', '4878' );
26
-
27
- if (!defined('ALM_COMMENTS_ITEM_NAME'))
28
- define('ALM_COMMENTS_ITEM_NAME', '12172' );
29
-
30
- if (!defined('ALM_UNLIMITED_ITEM_NAME'))
31
- define('ALM_UNLIMITED_ITEM_NAME', '3118' );
32
-
33
- if (!defined('ALM_LAYOUTS_ITEM_NAME'))
34
- define('ALM_LAYOUTS_ITEM_NAME', '11398' );
35
-
36
- if (!defined('ALM_PAGING_ITEM_NAME'))
37
- define('ALM_PAGING_ITEM_NAME', '6898' );
38
-
39
- if (!defined('ALM_PRELOADED_ITEM_NAME'))
40
- define('ALM_PRELOADED_ITEM_NAME', '4293' );
41
-
42
- if (!defined('ALM_PREV_POST_ITEM_NAME'))
43
- define('ALM_PREV_POST_ITEM_NAME', '9686');
44
-
45
- if (!defined('ALM_SEO_ITEM_NAME'))
46
- define('ALM_SEO_ITEM_NAME', '3482');
47
 
48
- if (!defined('ALM_THEME_REPEATERS_ITEM_NAME'))
49
- define('ALM_THEME_REPEATERS_ITEM_NAME', '8860');
50
 
51
 
52
  /*
@@ -80,7 +50,15 @@ function alm_install($network_wide) {
80
  register_activation_hook( __FILE__, 'alm_install' );
81
  add_action( 'wpmu_new_blog', 'alm_install' );
82
 
83
- /* Create table function */
 
 
 
 
 
 
 
 
84
  function alm_create_table(){
85
 
86
  global $wpdb;
@@ -129,19 +107,14 @@ function alm_create_table(){
129
  }
130
 
131
 
132
-
133
  if( !class_exists('AjaxLoadMore') ):
 
134
  class AjaxLoadMore {
135
-
136
- public $counter = 0;
137
 
138
  function __construct(){
139
 
140
- define('ALM_PATH', plugin_dir_path(__FILE__));
141
- define('ALM_URL', plugins_url('', __FILE__));
142
- define('ALM_ADMIN_URL', plugins_url('admin/', __FILE__));
143
- define('ALM_NAME', '_ajax_load_more');
144
- define('ALM_TITLE', 'Ajax Load More');
145
 
146
  add_action( 'wp_ajax_alm_query_posts', array(&$this, 'alm_query_posts') );
147
  add_action( 'wp_ajax_nopriv_alm_query_posts', array(&$this, 'alm_query_posts') );
@@ -151,33 +124,62 @@ if( !class_exists('AjaxLoadMore') ):
151
  add_action( 'after_setup_theme', array(&$this, 'alm_image_sizes') );
152
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'alm_action_links') );
153
  add_filter( 'plugin_row_meta', array(&$this, 'alm_plugin_meta_links'), 10, 2 );
154
- add_shortcode( 'ajax_load_more', array(&$this, 'alm_shortcode') );
155
-
156
- add_filter( 'widget_text', 'do_shortcode' ); // Allow shortcodes in widget areas
157
 
158
- load_plugin_textdomain( 'ajax-load-more', false, dirname(plugin_basename( __FILE__ )).'/lang/');//load text domain
159
-
160
- include_once( ALM_PATH . 'core/functions.php'); // Include ALM query functions
161
-
162
- $this->alm_before_theme(); // includes WP admin core
163
-
164
- }
165
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
 
168
  /*
169
- * alm_before_theme
170
  * Load these files before the theme loads
171
  *
172
  * @since 2.0.0
173
  */
174
 
175
- function alm_before_theme(){
176
- if( is_admin()){
 
 
 
 
 
177
  include_once('admin/editor/editor.php');
178
  include_once('admin/admin.php');
179
- }
180
- }
 
181
 
182
 
183
 
@@ -188,7 +190,7 @@ if( !class_exists('AjaxLoadMore') ):
188
  * @since 2.2.3
189
  */
190
 
191
- function alm_action_links( $links ) {
192
  $links[] = '<a href="'. get_admin_url(null, 'admin.php?page=ajax-load-more') .'">'.__('Settings', 'ajax-load-more').'</a>';
193
  return $links;
194
  }
@@ -202,7 +204,7 @@ if( !class_exists('AjaxLoadMore') ):
202
  * @since 2.7.2.1
203
  */
204
 
205
- function alm_plugin_meta_links( $links, $file ) {
206
  if ( strpos( $file, 'ajax-load-more.php' ) !== false ) {
207
  $new_links = array(
208
  '<a href="admin.php?page=ajax-load-more-shortcode-builder">Shortcode Builder</a>',
@@ -218,13 +220,13 @@ if( !class_exists('AjaxLoadMore') ):
218
 
219
 
220
  /*
221
- * alm_layouts_image_sizes
222
- * Add the required image sizes
223
  *
224
  * @since 2.8.3
225
  */
226
 
227
- function alm_image_sizes(){
228
  add_image_size( 'alm-thumbnail', 150, 150, true); // Custom ALM thumbnail size
229
  }
230
 
@@ -237,19 +239,23 @@ if( !class_exists('AjaxLoadMore') ):
237
  * @since 2.0.0
238
  */
239
 
240
- function alm_enqueue_scripts(){
241
  $options = get_option( 'alm_settings' );
242
 
243
- // Load JS
244
-
245
  //wp_register_script( 'ajax-load-more', plugins_url( '/core/js/ajax-load-more.js', __FILE__ ), array('jquery'), ALM_VERSION, true );
246
- wp_register_script( 'ajax-load-more', plugins_url( '/core/js/ajax-load-more.min.js', __FILE__ ), array('jquery'), ALM_VERSION, true );
247
-
248
 
249
- // Load CSS
250
- if(!isset($options['_alm_disable_css']) || $options['_alm_disable_css'] != '1'){
251
- //wp_enqueue_style( 'ajax-load-more', plugins_url('/core/css/ajax-load-more.css', __FILE__ ));
252
- wp_enqueue_style( 'ajax-load-more', plugins_url('/core/css/ajax-load-more.min.css', __FILE__ ));
 
 
 
 
 
253
  }
254
 
255
  // Prevent loading of unnessasry posts - move user to top of page
@@ -261,8 +267,7 @@ if( !class_exists('AjaxLoadMore') ):
261
  }
262
 
263
  wp_localize_script(
264
- 'ajax-load-more',
265
- 'alm_localize',
266
  array(
267
  'ajaxurl' => admin_url('admin-ajax.php'),
268
  'alm_nonce' => wp_create_nonce( "ajax_load_more_nonce" ),
@@ -282,595 +287,10 @@ if( !class_exists('AjaxLoadMore') ):
282
  * @since 2.0.0
283
  */
284
 
285
- function alm_shortcode($atts) {
286
 
287
- global $post;
288
- $options = get_option( 'alm_settings' ); // Get ALM Settings
289
-
290
- $slug = '';
291
- if(!is_archive()){
292
- // If not an archive page, set the post slug
293
- $slug = $post->post_name;
294
- }
295
-
296
- $this->counter++; // Shotcode counter
297
-
298
- // Custom CSS for Layouts
299
- if(has_action('alm_layouts_custom_css')){
300
- do_action('alm_layouts_custom_css', $this->counter);
301
- }
302
-
303
- extract(shortcode_atts(array(
304
- 'comments' => false,
305
- 'comments_per_page' => '5',
306
- 'comments_type' => 'comment',
307
- 'comments_style' => 'ol',
308
- 'comments_template' => 'none',
309
- 'comments_callback' => '',
310
- 'comments_post_id' => 'null',
311
- 'previous_post' => false,
312
- 'previous_post_id' => 'null',
313
- 'previous_post_taxonomy' => '',
314
- 'cache' => 'false',
315
- 'cache_id' => '',
316
- 'paging' => 'false',
317
- 'paging_controls' => 'false',
318
- 'paging_show_at_most' => '7',
319
- 'paging_classes' => '',
320
- 'preloaded' => 'false',
321
- 'preloaded_amount' => '5',
322
- 'seo' => 'false',
323
- 'repeater' => 'default',
324
- 'theme_repeater' => 'null',
325
- 'alternate' => false,
326
- 'alternate_sequence' => '',
327
- 'alternate_sequence_max' => '0',
328
- 'alternate_repeater' => 'null',
329
- 'alternate_theme_repeater' => 'null',
330
- 'post_type' => 'post',
331
- 'post_format' => '',
332
- 'category' => '',
333
- 'category__not_in' => '',
334
- 'tag' => '',
335
- 'tag__not_in' => '',
336
- 'taxonomy' => '',
337
- 'taxonomy_terms' => '',
338
- 'taxonomy_operator' => '',
339
- 'taxonomy_relation' => '',
340
- 'meta_key' => '',
341
- 'meta_value' => '',
342
- 'meta_compare' => '',
343
- 'meta_relation' => '',
344
- 'meta_type' => '',
345
- 'year' => '',
346
- 'month' => '',
347
- 'day' => '',
348
- 'author' => '',
349
- 'search' => '',
350
- 'custom_args' => '',
351
- 'post_status' => '',
352
- 'order' => 'DESC',
353
- 'orderby' => 'date',
354
- 'post__in' => '',
355
- 'post__not_in' => '',
356
- 'exclude' => '',
357
- 'offset' => '0',
358
- 'posts_per_page' => '5',
359
- 'scroll' => 'true',
360
- 'scroll_distance' => '150',
361
- 'max_pages' => '5',
362
- 'pause_override' => 'false',
363
- 'pause' => 'false',
364
- 'destroy_after' => '',
365
- 'transition' => 'slide',
366
- 'transition_speed' => '250',
367
- 'transition_container' => 'true',
368
- 'images_loaded' => 'false',
369
- 'button_label' => apply_filters('alm_button_label', __('Older Posts', 'ajax-load-more')),
370
- 'button_loading_label' => '',
371
- 'container_type' => '',
372
- 'css_classes' => '',
373
- ), $atts));
374
-
375
-
376
- // Enqueue core Ajax Load More JS
377
- wp_enqueue_script( 'ajax-load-more' );
378
-
379
-
380
- // Enqueue add-on JS
381
- if(has_action('alm_seo_installed') && $seo === 'true'){
382
- wp_enqueue_script( 'ajax-load-more-seo' );
383
- }
384
- if(has_action('alm_paging_installed') && $paging === 'true'){
385
- wp_enqueue_script( 'ajax-load-more-paging' );
386
- }
387
- if(has_action('alm_prev_post_installed') && $previous_post === 'true'){
388
- wp_enqueue_script( 'ajax-load-more-previous-post' );
389
- }
390
- if(has_action('alm_layouts_installed')){
391
- wp_enqueue_script( 'ajax-load-more-layouts' );
392
- }
393
-
394
- if($previous_post === 'true')
395
- $previous_post === true;
396
-
397
- if($seo === "true" || $previous_post)
398
- $transition_container = "true";
399
-
400
-
401
- // Get container elements (ul | div)
402
-
403
- $container_element = 'ul';
404
- if($options['_alm_container_type'] == '2' || $previous_post)
405
- $container_element = 'div';
406
-
407
- // override shortcode param
408
- if($container_type){
409
- $container_element = $container_type;
410
- }
411
-
412
- // Previous post override
413
- if($previous_post){
414
- $posts_per_page = 1;
415
- $container_element = 'div';
416
- }
417
-
418
- // Comments
419
- if($comments === 'true'){
420
- $container_element = $comments_style;
421
- }
422
-
423
- // Get extra classnames
424
- $classname = '';
425
- if(isset($options['_alm_classname']))
426
- $classname = ' '.$options['_alm_classname'];
427
-
428
- // Get button color
429
- $btn_color = '';
430
- if(isset($options['_alm_btn_color']))
431
- $btn_color = ' '.$options['_alm_btn_color'];
432
-
433
- // Get paging color
434
- $paging_color = '';
435
- if(isset($options['_alm_paging_color']) && has_action('alm_paging_installed'))
436
- $paging_color = ' paging-'.$options['_alm_paging_color'];
437
-
438
- // Get Layouts activated
439
- $alm_layouts = '';
440
- if(has_action('alm_layouts_installed'))
441
- $alm_layouts = ' alm-layouts';
442
-
443
- // Get btn classnames
444
- $button_classname = '';
445
- if(isset($options['_alm_btn_classname']))
446
- $button_classname = $options['_alm_btn_classname'];
447
-
448
-
449
- // Language support
450
- $lang = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : ''; // WPML - http://wpml.org
451
- if (function_exists('pll_current_language')) // Polylang - https://wordpress.org/plugins/polylang/
452
- $lang = pll_current_language();
453
- if (function_exists('qtrans_getLanguage')) // qTranslate - https://wordpress.org/plugins/qtranslate/
454
- $lang = qtrans_getLanguage();
455
-
456
- $wp_posts_per_page = get_option( 'posts_per_page' ); // Posts per page - settings -> reading
457
-
458
- /* If $wp_posts_per_page > than shortcode value then $posts_per_page to $wp_posts_per_page */
459
- if(has_action('alm_seo_installed') && $wp_posts_per_page > $posts_per_page && $seo === 'true')
460
- $posts_per_page = $wp_posts_per_page;
461
-
462
- $paging_container_class = '';
463
- if($paging === 'true'){
464
- $paging_container_class = ' alm-paging-wrap';
465
- $preloaded = "false";
466
- }
467
-
468
- // Start ALM object
469
- $ajaxloadmore = '';
470
-
471
- $ajaxloadmore .= apply_filters('alm_before_container', ''); // ALM Core Filter Hook
472
-
473
- // Build canonical URL
474
- // - Check the page/post type and then get the correct base url for the page.
475
-
476
- // Date
477
- if(is_date()){
478
- // Is archive page
479
- $archive_year = get_the_date('Y');
480
- $archive_month = get_the_date('m');
481
- $archive_day = get_the_date('d');
482
- if(is_year()){
483
- $canonicalURL = get_year_link( $archive_year );
484
- }
485
- if(is_month()){
486
- $canonicalURL = get_month_link( $archive_year, $archive_month );
487
- }
488
- if(is_day()){
489
- $canonicalURL = get_month_link( $archive_year, $archive_month, $archive_day );
490
- }
491
- }
492
- // Frontpage
493
- elseif(is_front_page() || is_home()){
494
- $canonicalURL = get_home_url().'/';
495
- }
496
- // Category
497
- elseif(is_category()){
498
- $cur_cat_id = get_cat_id( single_cat_title('',false) );
499
- $canonicalURL = get_category_link($cur_cat_id);
500
- }
501
- // Tag
502
- elseif(is_tag()){
503
- $cur_tag_id = get_query_var('tag_id');
504
- $canonicalURL = get_tag_link($cur_tag_id);
505
- }
506
- // Author
507
- elseif(is_author()){
508
- $author_id = get_the_author_meta('ID');
509
- $canonicalURL = get_author_posts_url($author_id);
510
- }
511
- // Taxonomy
512
- elseif(is_tax()){
513
- $tax_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy' ));
514
- $tax_id = $tax_term->term_id;
515
- $canonicalURL = get_term_link($tax_id);
516
- }
517
- // post_type
518
- elseif(is_post_type_archive()){
519
- $post_type_archive = get_post_type();
520
- $canonicalURL = get_post_type_archive_link($post_type_archive);
521
- }
522
- else{
523
- $canonicalURL = get_permalink();
524
- }
525
- // End build canonical URL
526
-
527
-
528
- // ALM Wrapper
529
- $ajaxloadmore .= '<div id="ajax-load-more" class="ajax-load-more-wrap'. $btn_color .''. $paging_color .''. $alm_layouts .'" data-id="" data-canonical-url="'. $canonicalURL .'" data-slug="'. $slug .'">';
530
-
531
-
532
- // Previous Post
533
- // - Set other add-on params to false
534
- if($previous_post){
535
- $preloaded = false;
536
- $seo = false;
537
- $paging = false;
538
- $cache = false;
539
- $comments = false;
540
- }
541
-
542
- // Comments
543
- // - Set other add-on params to false
544
- if($comments){
545
- $previous_post = false;
546
- $preloaded = false;
547
- $seo = false;
548
- $paging = false;
549
- $cache = false;
550
- }
551
-
552
-
553
- // ********************************
554
- // Preloaded Add-on
555
- // Retreive preloaded posts and append to ajax load more object
556
- if(has_action('alm_preload_installed') && $preloaded === 'true'){
557
-
558
- $preload_offset = $offset;
559
-
560
- // If SEO, set $preloaded_amount to $posts_per_page
561
- if(has_action('alm_seo_installed') && $seo === 'true'){
562
- $preloaded_amount = $posts_per_page;
563
- }
564
-
565
- // If Paging, set $preloaded_amount to $posts_per_page
566
- if($paging === 'true'){
567
- $preloaded_amount = $posts_per_page;
568
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
569
- if($paged > 1){
570
- $preload_offset = $preloaded_amount * ($paged-2);
571
- }
572
- }
573
-
574
- $preloaded_arr = array( // Create preload data array
575
- 'post_type' => $post_type,
576
- 'post_format' => $post_format,
577
- 'category' => $category,
578
- 'category__not_in' => $category__not_in,
579
- 'tag' => $tag,
580
- 'tag__not_in' => $tag__not_in,
581
- 'taxonomy' => $taxonomy,
582
- 'taxonomy_terms' => $taxonomy_terms,
583
- 'taxonomy_operator' => $taxonomy_operator,
584
- 'taxonomy_relation' => $taxonomy_relation,
585
- 'meta_key' => $meta_key,
586
- 'meta_value' => $meta_value,
587
- 'meta_compare' => $meta_compare,
588
- 'meta_relation' => $meta_relation,
589
- 'meta_type' => $meta_type,
590
- 'year' => $year,
591
- 'month' => $month,
592
- 'day' => $day,
593
- 'author' => $author,
594
- 'post__in' => $post__in,
595
- 'post__not_in' => $post__not_in,
596
- 'search' => $search,
597
- 'custom_args' => $custom_args,
598
- 'post_status' => $post_status,
599
- 'order' => $order,
600
- 'orderby' => $orderby,
601
- 'exclude' => $exclude,
602
- 'offset' => $preload_offset,
603
- 'posts_per_page' => $preloaded_amount,
604
- 'lang' => $lang,
605
- 'css_classes' => $css_classes,
606
- );
607
-
608
- $type = alm_get_repeater_type($repeater);
609
-
610
- $args = apply_filters('alm_preload_args', $preloaded_arr); // Create preloaded $args
611
- $args = apply_filters('alm_modify_query_args', $args, $slug); // ALM Core Filter Hook
612
-
613
- $alm_preload_query = new WP_Query($args);
614
- $alm_total_posts = $alm_preload_query->found_posts - $offset;
615
- $output = '';
616
- $noscript = '';
617
-
618
-
619
- // Alternating Templates
620
- if($alternate === 'true' && has_action('alm_alternating_installed')){
621
- $alternate_sequence_array = '';
622
- if($alternate_sequence === 'even'){
623
- $alternate_sequence_array = 'even';
624
- }else{
625
- $alternate_sequence_array = explode(',', $alternate_sequence);
626
- }
627
- $global_repeater = $repeater;
628
- $global_type = $type;
629
- $global_theme_repeater = $theme_repeater;
630
- }
631
-
632
-
633
- if ($alm_preload_query->have_posts()) :
634
- $alm_loop_count = 0; // Count var
635
- $alm_page = 0; // Set page to 0
636
- $alm_found_posts = $alm_total_posts;
637
- $alm_current = 0;
638
- while ($alm_preload_query->have_posts()) : $alm_preload_query->the_post();
639
- $alm_loop_count++;
640
- $alm_current++;
641
- $alm_item = $alm_loop_count; // Get current item in loop
642
-
643
- // Alternating Templates
644
- if($alternate === 'true' && has_action('alm_alternating_installed')){
645
- if (function_exists('alm_alternate_is_in_array')) {
646
- if(alm_alternate_is_in_array($alm_current, $alternate_sequence_array)){ // If $alm_current is found in array
647
- if($alternate_theme_repeater != 'null' && has_filter('alm_get_theme_repeater')){
648
- $theme_repeater = $alternate_theme_repeater;
649
- }else{
650
- $repeater = $alternate_repeater;
651
- $type = alm_get_repeater_type($repeater);
652
- }
653
- }else{ // Reset $repeater values
654
- $repeater = $global_repeater;
655
- $type = $global_type;
656
- $theme_repeater = $global_theme_repeater;
657
- }
658
- }
659
- }
660
-
661
- $output .= apply_filters('alm_preload_inc', $repeater, $type, $theme_repeater, $alm_found_posts, $alm_page, $alm_item, $alm_current);
662
-
663
- endwhile; wp_reset_query();
664
-
665
- if(has_action('alm_seo_installed') && $seo === 'true'){ // If SEO, add noscript paging
666
- // Create noscript paging for SEO if preload and seo are enabled
667
- $noscript = alm_paging_no_script($alm_preload_query);
668
- }
669
-
670
- endif;
671
- $preloaded_output = '<'.$container_element.' class="alm-listing alm-preloaded'. $classname .' '. $css_classes .'" data-total-posts="'. $alm_total_posts .'">';
672
- if($seo === "true"){
673
- $preloaded_output .= '<div class="alm-reveal alm-seo" data-page="1" data-url="'.$canonicalURL.'">';
674
- }
675
- $preloaded_output .= $output;
676
- if($seo === "true"){
677
- $preloaded_output .= '</div>';
678
- }
679
- $preloaded_output .= '</'.$container_element.'>';
680
-
681
- if(has_action('alm_seo_installed')){ // If SEO, add noscript paging
682
- $preloaded_output .= $noscript;
683
- }
684
-
685
- // Reset templates (custom and theme) if $alternate is true
686
- if($alternate === 'true' && has_action('alm_alternating_installed')){
687
- $repeater = $global_repeater;
688
- $type = $global_type;
689
- $theme_repeater = $theme_repeater;
690
- }
691
-
692
- $ajaxloadmore .= $preloaded_output; // Add $preloaded_output data to $ajaxloadmore
693
- }
694
- // End Preload Posts
695
- // ********************************
696
-
697
- $listing_class = 'alm-listing';
698
-
699
- // If comments
700
- if($comments === 'true'){
701
- $listing_class = 'commentlist alm-comments';
702
- }
703
-
704
- $ajaxloadmore .= '<'.$container_element.' class="'.$listing_class.' alm-ajax'. $paging_container_class .' '. $classname . ' '. $css_classes .'"'; // Build ALM container
705
-
706
-
707
- // Alternating Templates Add-on
708
- if(has_action('alm_alternating_installed') && $alternate === 'true'){
709
- $alternate_return = apply_filters(
710
- 'alm_alternating_templates_shortcode',
711
- $alternate,
712
- $alternate_sequence,
713
- $alternate_sequence_max,
714
- $alternate_repeater,
715
- $alternate_theme_repeater
716
- );
717
- $ajaxloadmore .= $alternate_return;
718
- }
719
-
720
- // Cache Add-on
721
- if(has_action('alm_cache_installed') && $cache === 'true'){
722
- $cache_return = apply_filters(
723
- 'alm_cache_shortcode',
724
- $cache,
725
- $cache_id,
726
- $options
727
- );
728
- $ajaxloadmore .= $cache_return;
729
- }
730
-
731
- // Comments Add-on
732
- if(has_action('alm_comments_installed') && $comments === 'true'){
733
- $comments_return = apply_filters(
734
- 'alm_comments_shortcode',
735
- $comments,
736
- $comments_per_page,
737
- $comments_type,
738
- $comments_style,
739
- $comments_template,
740
- $comments_callback,
741
- $comments_post_id
742
- );
743
- $ajaxloadmore .= $comments_return;
744
- }
745
-
746
-
747
- // Paging Add-on
748
- if(has_action('alm_paging_installed') && $paging === 'true'){
749
- $paging_return = apply_filters(
750
- 'alm_paging_shortcode',
751
- $paging,
752
- $paging_controls,
753
- $paging_show_at_most,
754
- $paging_classes,
755
- $options
756
- );
757
- $ajaxloadmore .= $paging_return;
758
- }
759
-
760
-
761
- // Preloaded Add-on
762
- if(has_action('alm_preload_installed') && $preloaded === 'true'){
763
- $ajaxloadmore .= ' data-preloaded="'.$preloaded.'"';
764
- $ajaxloadmore .= ' data-preloaded-amount="'.$preloaded_amount.'"';
765
- }
766
-
767
-
768
- // SEO Add-on
769
- if(has_action('alm_seo_installed') && $seo === 'true'){
770
- $seo_return = apply_filters(
771
- 'alm_seo_shortcode',
772
- $seo,
773
- $preloaded,
774
- $options
775
- );
776
- $ajaxloadmore .= $seo_return;
777
- }
778
-
779
-
780
- // Previous Post Post Add-on
781
- if(has_action('alm_prev_post_installed') && $previous_post){
782
- $prev_post_return = apply_filters(
783
- 'alm_prev_post_shortcode',
784
- $previous_post_id,
785
- $previous_post_taxonomy,
786
- $options
787
- );
788
- $ajaxloadmore .= $prev_post_return;
789
- }
790
-
791
-
792
- $ajaxloadmore .= ' data-repeater="'.$repeater.'"';
793
- if($theme_repeater != 'null'){
794
- $ajaxloadmore .= ' data-theme-repeater="'.$theme_repeater.'"';
795
- }
796
- $ajaxloadmore .= ' data-post-type="'.$post_type.'"';
797
- $ajaxloadmore .= ' data-post-format="'.$post_format.'"';
798
- $ajaxloadmore .= ' data-category="'.$category.'"';
799
- $ajaxloadmore .= ' data-category-not-in="'.$category__not_in.'"';
800
- $ajaxloadmore .= ' data-tag="'.$tag.'"';
801
- $ajaxloadmore .= ' data-tag-not-in="'.$tag__not_in.'"';
802
- $ajaxloadmore .= ' data-taxonomy="'.$taxonomy.'"';
803
- $ajaxloadmore .= ' data-taxonomy-terms="'.$taxonomy_terms.'"';
804
- $ajaxloadmore .= ' data-taxonomy-operator="'.$taxonomy_operator.'"';
805
- $ajaxloadmore .= ' data-taxonomy-relation="'.$taxonomy_relation.'"';
806
- $ajaxloadmore .= ' data-meta-key="'.$meta_key.'"';
807
- $ajaxloadmore .= ' data-meta-value="'.$meta_value.'"';
808
- $ajaxloadmore .= ' data-meta-compare="'.$meta_compare.'"';
809
- $ajaxloadmore .= ' data-meta-relation="'.$meta_relation.'"';
810
- $ajaxloadmore .= ' data-meta-type="'.$meta_type.'"';
811
- $ajaxloadmore .= ' data-year="'.$year.'"';
812
- $ajaxloadmore .= ' data-month="'.$month.'"';
813
- $ajaxloadmore .= ' data-day="'.$day.'"';
814
- $ajaxloadmore .= ' data-author="'.$author.'"';
815
- $ajaxloadmore .= ' data-post-in="'.$post__in.'"';
816
- $ajaxloadmore .= ' data-post-not-in="'.$post__not_in.'"';
817
- $ajaxloadmore .= ' data-exclude="'.$exclude.'"';
818
- $ajaxloadmore .= ' data-search="'.$search.'"';
819
- $ajaxloadmore .= ' data-custom-args="'.$custom_args.'"';
820
- $ajaxloadmore .= ' data-post-status="'.$post_status.'"';
821
- $ajaxloadmore .= ' data-order="'.$order.'"';
822
- $ajaxloadmore .= ' data-orderby="'.$orderby.'"';
823
- $ajaxloadmore .= ' data-offset="'.$offset.'"';
824
- $ajaxloadmore .= ' data-posts-per-page="'.$posts_per_page.'"';
825
- $ajaxloadmore .= ' data-lang="'.$lang.'"';
826
- $ajaxloadmore .= ' data-scroll="'.$scroll.'"';
827
- $ajaxloadmore .= ' data-scroll-distance="'.$scroll_distance.'"';
828
- $ajaxloadmore .= ' data-max-pages="'.$max_pages.'"';
829
- $ajaxloadmore .= ' data-pause-override="'.$pause_override.'"';
830
- $ajaxloadmore .= ' data-pause="'.$pause.'"';
831
- $ajaxloadmore .= ' data-button-label="'.$button_label.'"';
832
- if(!empty($button_loading_label)){
833
- $ajaxloadmore .= ' data-button-loading-label="'.$button_loading_label.'"';
834
- }
835
- $ajaxloadmore .= ' data-button-class="'.$button_classname.'"';
836
- $ajaxloadmore .= ' data-destroy-after="'.$destroy_after.'"';
837
- $ajaxloadmore .= ' data-transition="'.$transition.'"';
838
- if($transition_speed !== '250')
839
- $ajaxloadmore .= ' data-transition-speed="'.$transition_speed.'"';
840
- if($transition_container === 'false')
841
- $ajaxloadmore .= ' data-transition-container="'.$transition_container.'"';
842
- $ajaxloadmore .= ' data-images-loaded="'.$images_loaded.'"';
843
-
844
- $ajaxloadmore .= '>';
845
-
846
-
847
- // Previous Post Add-on
848
- // - Get first post and append to ajax load more object
849
- if(has_action('alm_prev_post_installed') && $previous_post){
850
- $repeater_type = preg_split('/(?=\d)/', $repeater, 2); // split $repeater at number to retrieve type
851
- $repeater_type = $repeater_type[0]; // (default | repeater | template_)
852
- if($theme_repeater != 'null' && has_filter('alm_get_theme_repeater')){
853
- $repeater_type = null;
854
- }
855
- // Get next post include and build the output from the next post filter
856
- $previous_post_output = '<div class="alm-reveal alm-previous-post post-'. $previous_post_id .'" data-url="'. get_permalink($previous_post_id) .'" data-title="'. get_the_title($previous_post_id) .'" data-id="'. $previous_post_id .'">'; // Set the post id .alm-reveal div
857
- $previous_post_output .= apply_filters('alm_prev_post_inc', $repeater, $repeater_type, $theme_repeater, $previous_post_id, $post_type);
858
- $previous_post_output .= '</div>';
859
- $ajaxloadmore .= $previous_post_output; // Add $next_post_output data to $ajaxloadmore
860
-
861
- }
862
- // End Previous Post
863
-
864
-
865
- $ajaxloadmore .= '</'.$container_element.'>';
866
-
867
- $ajaxloadmore .= apply_filters('alm_before_button', ''); // ALM Core Filter Hook
868
-
869
- $ajaxloadmore .= '</div>';
870
-
871
- $ajaxloadmore .= apply_filters('alm_after_container', ''); // ALM Core Filter Hook
872
-
873
- return $ajaxloadmore; // End ALM object
874
  }
875
 
876
 
@@ -882,7 +302,7 @@ if( !class_exists('AjaxLoadMore') ):
882
  * @since 2.0.0
883
  */
884
 
885
- function alm_query_posts() {
886
 
887
  $nonce = $_GET['nonce'];
888
  $options = get_option( 'alm_settings' );
@@ -1088,7 +508,7 @@ if( !class_exists('AjaxLoadMore') ):
1088
  }
1089
 
1090
  // Meta Query
1091
- if(!empty($meta_key) && !empty($meta_value)){
1092
 
1093
  // Parse multiple meta query
1094
  $meta_query_total = count(explode(":", $meta_key)); // Total meta_query objects
@@ -1131,8 +551,10 @@ if( !class_exists('AjaxLoadMore') ):
1131
 
1132
  // Meta_key, used for ordering by meta value
1133
  if(!empty($meta_key)){
1134
- $meta_key_single = explode(":", $meta_key);
1135
- $args['meta_key'] = $meta_key_single[0];
 
 
1136
  }
1137
 
1138
  // Author
@@ -1277,7 +699,6 @@ if( !class_exists('AjaxLoadMore') ):
1277
  endwhile; wp_reset_query();
1278
 
1279
  $data = ob_get_clean();
1280
- ob_end_clean();
1281
 
1282
  // If Cache is enabled and seo_start_page is 1 (meaning, a user has not requested /page/12/)
1283
  // - Only create cached files if the user visits pages in order 1, 2, 3 etc.
@@ -1318,10 +739,11 @@ if( !class_exists('AjaxLoadMore') ):
1318
  */
1319
 
1320
  function AjaxLoadMore(){
1321
- global $ajax_load_more;
1322
- if( !isset($ajax_load_more)){
 
1323
  $ajax_load_more = new AjaxLoadMore();
1324
- }
1325
  return $ajax_load_more;
1326
  }
1327
  // initialize
2
  /*
3
  Plugin Name: Ajax Load More
4
  Plugin URI: http://connekthq.com/plugins/ajax-load-more
5
+ Description: The ultimate solution to add infinite scroll functionality to your website.
6
  Text Domain: ajax-load-more
7
  Author: Darren Cooney
8
  Twitter: @KaptonKaos
9
  Author URI: http://connekthq.com
10
+ Version: 2.10.1
11
  License: GPL
12
  Copyright: Darren Cooney & Connekt Media
 
13
  */
14
 
15
+
16
+ define('ALM_VERSION', '2.10.1');
17
+ define('ALM_RELEASE', 'May 8, 2016');
18
+ define('ALM_STORE_URL', 'https://connekthq.com');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
 
 
20
 
21
 
22
  /*
50
  register_activation_hook( __FILE__, 'alm_install' );
51
  add_action( 'wpmu_new_blog', 'alm_install' );
52
 
53
+
54
+
55
+ /*
56
+ * alm_create_table
57
+ *
58
+ * Create new table and repeater template
59
+ *
60
+ * @since 2.0.0
61
+ */
62
  function alm_create_table(){
63
 
64
  global $wpdb;
107
  }
108
 
109
 
 
110
  if( !class_exists('AjaxLoadMore') ):
111
+
112
  class AjaxLoadMore {
 
 
113
 
114
  function __construct(){
115
 
116
+ $this->alm_define_constants();
117
+ $this->alm_includes();
 
 
 
118
 
119
  add_action( 'wp_ajax_alm_query_posts', array(&$this, 'alm_query_posts') );
120
  add_action( 'wp_ajax_nopriv_alm_query_posts', array(&$this, 'alm_query_posts') );
124
  add_action( 'after_setup_theme', array(&$this, 'alm_image_sizes') );
125
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'alm_action_links') );
126
  add_filter( 'plugin_row_meta', array(&$this, 'alm_plugin_meta_links'), 10, 2 );
127
+ add_shortcode( 'ajax_load_more', array(&$this, 'alm_shortcode') );
128
+ add_filter( 'widget_text', 'do_shortcode' ); // Allow shortcodes in widget areas
129
+ load_plugin_textdomain( 'ajax-load-more', false, dirname(plugin_basename( __FILE__ )).'/lang/'); //load text domain
130
 
131
+ }
132
+
133
+
134
+
135
+ /*
136
+ * alm_define_constants
137
+ * Define plugin constants
138
+ *
139
+ * @since 2.10.1
140
+ */
141
+
142
+ public function alm_define_constants(){
143
+
144
+ define('ALM_PATH', plugin_dir_path(__FILE__));
145
+ define('ALM_URL', plugins_url('', __FILE__));
146
+ define('ALM_ADMIN_URL', plugins_url('admin/', __FILE__));
147
+ define('ALM_NAME', '_ajax_load_more');
148
+ define('ALM_TITLE', 'Ajax Load More');
149
+
150
+ if (!defined('ALM_ALTERNATING_ITEM_NAME')) define('ALM_ALTERNATING_ITEM_NAME', '14456');
151
+ if (!defined('ALM_CACHE_ITEM_NAME')) define('ALM_CACHE_ITEM_NAME', '4878');
152
+ if (!defined('ALM_COMMENTS_ITEM_NAME')) define('ALM_COMMENTS_ITEM_NAME', '12172');
153
+ if (!defined('ALM_UNLIMITED_ITEM_NAME')) define('ALM_UNLIMITED_ITEM_NAME', '3118');
154
+ if (!defined('ALM_LAYOUTS_ITEM_NAME')) define('ALM_LAYOUTS_ITEM_NAME', '11398');
155
+ if (!defined('ALM_PAGING_ITEM_NAME')) define('ALM_PAGING_ITEM_NAME', '6898');
156
+ if (!defined('ALM_PRELOADED_ITEM_NAME')) define('ALM_PRELOADED_ITEM_NAME', '4293');
157
+ if (!defined('ALM_PREV_POST_ITEM_NAME')) define('ALM_PREV_POST_ITEM_NAME', '9686');
158
+ if (!defined('ALM_SEO_ITEM_NAME')) define('ALM_SEO_ITEM_NAME', '3482');
159
+ if (!defined('ALM_THEME_REPEATERS_ITEM_NAME')) define('ALM_THEME_REPEATERS_ITEM_NAME', '8860');
160
+
161
+ }
162
 
163
 
164
  /*
165
+ * alm_includes
166
  * Load these files before the theme loads
167
  *
168
  * @since 2.0.0
169
  */
170
 
171
+ public function alm_includes(){
172
+
173
+ include_once( ALM_PATH . 'core/functions.php'); // Functions
174
+ include_once( ALM_PATH . 'core/classes/class.alm-shortcode.php'); // Shortcode
175
+ include_once( ALM_PATH . 'core/classes/class.alm-enqueue.php'); // Enqueue
176
+
177
+ if( is_admin() ){
178
  include_once('admin/editor/editor.php');
179
  include_once('admin/admin.php');
180
+ }
181
+
182
+ }
183
 
184
 
185
 
190
  * @since 2.2.3
191
  */
192
 
193
+ public function alm_action_links( $links ) {
194
  $links[] = '<a href="'. get_admin_url(null, 'admin.php?page=ajax-load-more') .'">'.__('Settings', 'ajax-load-more').'</a>';
195
  return $links;
196
  }
204
  * @since 2.7.2.1
205
  */
206
 
207
+ public function alm_plugin_meta_links( $links, $file ) {
208
  if ( strpos( $file, 'ajax-load-more.php' ) !== false ) {
209
  $new_links = array(
210
  '<a href="admin.php?page=ajax-load-more-shortcode-builder">Shortcode Builder</a>',
220
 
221
 
222
  /*
223
+ * alm_image_sizes
224
+ * Add default image size
225
  *
226
  * @since 2.8.3
227
  */
228
 
229
+ public function alm_image_sizes(){
230
  add_image_size( 'alm-thumbnail', 150, 150, true); // Custom ALM thumbnail size
231
  }
232
 
239
  * @since 2.0.0
240
  */
241
 
242
+ public function alm_enqueue_scripts(){
243
  $options = get_option( 'alm_settings' );
244
 
245
+ // Load JS
 
246
  //wp_register_script( 'ajax-load-more', plugins_url( '/core/js/ajax-load-more.js', __FILE__ ), array('jquery'), ALM_VERSION, true );
247
+ wp_register_script( 'ajax-load-more', plugins_url( '/core/js/ajax-load-more.min.js', __FILE__ ), array('jquery'), ALM_VERSION, true );
248
+
249
 
250
+ // Load CSS
251
+ if(!isset($options['_alm_disable_css']) || $options['_alm_disable_css'] != '1'){
252
+
253
+ //$file = plugins_url('/core/css/ajax-load-more.css', __FILE__ );
254
+ $file = plugins_url('/core/css/ajax-load-more.min.css', __FILE__ );
255
+
256
+ $filename = 'ajax-load-more';
257
+ ALM_ENQUEUE::alm_enqueue_css($filename, $file);
258
+
259
  }
260
 
261
  // Prevent loading of unnessasry posts - move user to top of page
267
  }
268
 
269
  wp_localize_script(
270
+ 'ajax-load-more', 'alm_localize',
 
271
  array(
272
  'ajaxurl' => admin_url('admin-ajax.php'),
273
  'alm_nonce' => wp_create_nonce( "ajax_load_more_nonce" ),
287
  * @since 2.0.0
288
  */
289
 
290
+ public function alm_shortcode($atts) {
291
 
292
+ return ALM_SHORTCODE::alm_render_shortcode($atts);
293
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  }
295
 
296
 
302
  * @since 2.0.0
303
  */
304
 
305
+ public function alm_query_posts() {
306
 
307
  $nonce = $_GET['nonce'];
308
  $options = get_option( 'alm_settings' );
508
  }
509
 
510
  // Meta Query
511
+ if(!empty($meta_key) && !empty($meta_value) || !empty($meta_key) && $meta_compare !== "IN"){
512
 
513
  // Parse multiple meta query
514
  $meta_query_total = count(explode(":", $meta_key)); // Total meta_query objects
551
 
552
  // Meta_key, used for ordering by meta value
553
  if(!empty($meta_key)){
554
+ if (strpos($orderby, 'meta_value') !== false) { // Only order by meta_key, if $orderby is set to meta_value{_num}
555
+ $meta_key_single = explode(":", $meta_key);
556
+ $args['meta_key'] = $meta_key_single[0];
557
+ }
558
  }
559
 
560
  // Author
699
  endwhile; wp_reset_query();
700
 
701
  $data = ob_get_clean();
 
702
 
703
  // If Cache is enabled and seo_start_page is 1 (meaning, a user has not requested /page/12/)
704
  // - Only create cached files if the user visits pages in order 1, 2, 3 etc.
739
  */
740
 
741
  function AjaxLoadMore(){
742
+ global $ajax_load_more;
743
+
744
+ if( !isset($ajax_load_more))
745
  $ajax_load_more = new AjaxLoadMore();
746
+
747
  return $ajax_load_more;
748
  }
749
  // initialize
core/classes/class.alm-enqueue.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ajax Load More Enqueue
4
+ *
5
+ * Enqueue scripts.
6
+ *
7
+ * @author Darren Cooney
8
+ * @since 2.10.1
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ if( !class_exists('ALM_ENQUEUE') ):
16
+
17
+ class ALM_ENQUEUE {
18
+
19
+
20
+
21
+ /**
22
+ * alm_enqueue_css
23
+ *
24
+ * Load ALM CSS
25
+ *
26
+ * @since 2.10.1
27
+ * @return wp_enqueue_style
28
+ */
29
+ public static function alm_enqueue_css($name, $file){
30
+ $css = '';
31
+ $css_path = '';
32
+ $dir = 'alm';
33
+ $file_css = $name.'.css';
34
+
35
+ // - Check theme for local ajax-load-more.css, if found, load that file
36
+ if(is_child_theme()){
37
+ $css = get_stylesheet_directory_uri().'/'. $dir .'/' .$file_css;
38
+ $css_path = get_stylesheet_directory().'/'. $dir .'/' .$file_css;
39
+ // if child theme does not have CSS, check the parent theme
40
+ if(!file_exists($css_path)){
41
+ $css = get_template_directory_uri().'/'. $dir .'/' .$file_css;
42
+ $css_path = get_template_directory().'/'. $dir .'/' .$file_css;
43
+ }
44
+ }
45
+ else{
46
+ $css = get_template_directory_uri().'/'. $dir .'/' .$file_css;
47
+ $css_path = get_template_directory().'/'. $dir .'/' .$file_css;
48
+ }
49
+
50
+ if($css_path !== ''){ // If $css_path has been
51
+ if(file_exists($css_path)){
52
+ $file = $css;
53
+ }
54
+ }
55
+
56
+ // Enqueue $file
57
+ wp_enqueue_style( $name, $file );
58
+ }
59
+
60
+ }
61
+
62
+ endif;
core/classes/class.alm-shortcode.php ADDED
@@ -0,0 +1,650 @@