WordPress Infinite Scroll – Ajax Load More - Version 5.1.0.1

Version Description

  • May 7, 2019 =

  • UPDATE - After the 5.1.0 launch I discovered an issue with the REST API and WooCommerce. I have reverted the default REST API Usage until I can sort this out.

Download this release

Release Info

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

Code changes from version 5.0.2 to 5.1.0.1

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dcooney, connekthq
3
  Donate link: https://connekthq.com/donate/
4
  Tags: infinite scroll, infinite scrolling, scroll, infinite, lazy load, lazy loading, endless scroll, pagination, ajax pagination, ajax, ajax posts, woocommerce, ajax load more, masonry
5
  Requires at least: 4.0
6
- Tested up to: 5.1.1
7
- Stable tag: 5.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -328,7 +328,7 @@ global $post;
328
  * Safari (Mac, iOS)
329
  * Opera
330
  * Android
331
- * IE10+
332
 
333
 
334
  = How Can You Contribute? =
@@ -377,6 +377,34 @@ How to install Ajax Load More.
377
 
378
  == Changelog ==
379
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  = 5.0.2 - April 4, 2019 =
381
  * NEW - `alm_shortcode_defaults` filter (docs coming soon).
382
  * NEW - `Added alm_settings` filter (docs coming soon).
3
  Donate link: https://connekthq.com/donate/
4
  Tags: infinite scroll, infinite scrolling, scroll, infinite, lazy load, lazy loading, endless scroll, pagination, ajax pagination, ajax, ajax posts, woocommerce, ajax load more, masonry
5
  Requires at least: 4.0
6
+ Tested up to: 5.2.0
7
+ Stable tag: 5.1.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
328
  * Safari (Mac, iOS)
329
  * Opera
330
  * Android
331
+ * IE11+
332
 
333
 
334
  = How Can You Contribute? =
377
 
378
  == Changelog ==
379
 
380
+ = 5.1.0.1 - May 7, 2019 =
381
+
382
+ * UPDATE - After the 5.1.0 launch I discovered an issue with the REST API and WooCommerce. I have reverted the default REST API Usage until I can sort this out. 😢
383
+
384
+
385
+ = 5.1.0 - May 7, 2019 =
386
+
387
+ MAJOR UPDATE NOTICE
388
+ Ajax Load More can now use the WordPress REST API as the default for Ajax requests - this includes all add-ons and extensions.
389
+ Users that wish to continue using `admin-ajax.php` for Ajax requests can disable the REST API from `Ajax Load More > Settings > Global Settings` in your WordPress admin.
390
+
391
+ For backwards compatibility, all users running WordPress version 4.7 or lower will default to using `admin-ajax.php`.
392
+
393
+ Please update all your add-ons and extensions when you update Ajax Load More as this release contains breaking changes.
394
+
395
+ What's New in 5.1.0
396
+ * NEW - ALM now uses the REST API for all Ajax queries 👏. This includes all add-ons and extensions.
397
+ * NEW - Added new Results Text display for displaying the current page number to users. [view example](https://connekthq.com/plugins/ajax-load-more/examples/results-text/)
398
+ * NEW - Added custom JavaScript fix for reply links in Comment query causing page refresh.
399
+ * NEW - Added custom WP_Query parameter, `alm_query` that can be used in hooks/filters to modify the current query.
400
+ * UPDATE - Added `aria` attributes and focus position after Ajax load to improve plugin accessibility.
401
+ * FIX - Fixed issue with images not displaying in Safari when `transition_container="false"` is set.
402
+ * FIX - Fixed issue where Load More button was not hiding after `destory_after` value was reached.
403
+ * FIX - Fixed issue with `meta_value` shortcode parameter. Passing zero as a value was returning false and not the number.
404
+ * FIX - Fixed IE11 issue where filtering was not working with camelCase data attributes.
405
+
406
+
407
+
408
  = 5.0.2 - April 4, 2019 =
409
  * NEW - `alm_shortcode_defaults` filter (docs coming soon).
410
  * NEW - `Added alm_settings` filter (docs coming soon).
admin/admin.php CHANGED
@@ -319,6 +319,10 @@ function alm_admin_vars() { ?>
319
  /* <![CDATA[ */
320
  var alm_admin_localize = <?php echo json_encode( array(
321
  'ajax_admin_url' => admin_url( 'admin-ajax.php' ),
 
 
 
 
322
  'ajax_load_more' => __('Ajax Load More', 'ajax-load-more'),
323
  'active' => __('Active', 'ajax-load-more'),
324
  'inactive' => __('Inactive', 'ajax-load-more'),
@@ -1234,15 +1238,17 @@ function alm_admin_init(){
1234
  'alm_general_settings'
1235
  );
1236
 
1237
- add_settings_field( // Scroll to top on load
1238
- '_alm_scroll_top',
1239
- __('Top of Page', 'ajax-load-more' ),
1240
- '_alm_scroll_top_callback',
 
1241
  'ajax-load-more',
1242
  'alm_general_settings'
1243
  );
 
1244
 
1245
- add_settings_field( // Scroll to top on load
1246
  '_alm_legacy_callbacks',
1247
  __('Legacy Callbacks', 'ajax-load-more' ),
1248
  '_alm_legacy_callbacks_callback',
@@ -1250,6 +1256,14 @@ function alm_admin_init(){
1250
  'alm_general_settings'
1251
  );
1252
 
 
 
 
 
 
 
 
 
1253
  add_settings_field( // Uninstall
1254
  '_alm_uninstall',
1255
  __('Delete on Uninstall', 'ajax-load-more' ),
@@ -1480,10 +1494,10 @@ function alm_container_type_callback() {
1480
  $options['_alm_container_type'] = '1';
1481
 
1482
  $html = '<input type="radio" id="_alm_container_type_one" name="alm_settings[_alm_container_type]" value="1"' . checked( 1, $options['_alm_container_type'], false ) . '/>';
1483
- $html .= '<label for="_alm_container_type_one">&lt;ul&gt; <span>&lt;!-- '.__('Ajax Posts Here', 'ajax-load-more').' --&gt;</span> &lt;/ul&gt;</label><br/>';
1484
 
1485
  $html .= '<input type="radio" id="_alm_container_type_two" name="alm_settings[_alm_container_type]" value="2"' . checked( 2, $options['_alm_container_type'], false ) . '/>';
1486
- $html .= '<label for="_alm_container_type_two">&lt;div&gt; <span>&lt;!-- '.__('Ajax Posts Here', 'ajax-load-more').' --&gt;</span> &lt;/div&gt;</label>';
1487
 
1488
  $html .= '<label style="cursor: default !important"><span style="display:block">'.__('You can modify the container type when building a shortcode.', 'ajax-load-more').'</span></label>';
1489
 
@@ -1611,7 +1625,7 @@ function alm_inline_css_callback(){
1611
 
1612
  $html = '<input type="hidden" name="alm_settings[_alm_inline_css]" value="0" />';
1613
  $html .= '<input type="checkbox" name="alm_settings[_alm_inline_css]" id="alm_inline_css" value="1"'. (($options['_alm_inline_css']) ? ' checked="checked"' : '') .' />';
1614
- $html .= '<label for="alm_inline_css">'.__('Improve site performance by loading Ajax Load More CSS inline', 'ajax-load-more').'.</label>';
1615
 
1616
  echo $html;
1617
  }
@@ -1686,6 +1700,30 @@ function _alm_scroll_top_callback(){
1686
 
1687
 
1688
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1689
  /*
1690
  * _alm_legacy_callbacks_callback
1691
  * Load legacy callback actions
@@ -1732,24 +1770,3 @@ function _alm_uninstall_callback(){
1732
  echo $html;
1733
  }
1734
 
1735
-
1736
-
1737
- /*
1738
- * _alm_nonce_security_callback
1739
- * Move window to top of screen on page load
1740
- *
1741
- * @since 2.6.3
1742
- */
1743
-
1744
- function _alm_nonce_security_callback(){
1745
- $options = get_option( 'alm_settings' );
1746
- if(!isset($options['_alm_nonce_security']))
1747
- $options['_alm_nonce_security'] = '0';
1748
-
1749
- $html = '<input type="hidden" name="alm_settings[_alm_nonce_security]" value="0" />';
1750
- $html .= '<input type="checkbox" name="alm_settings[_alm_nonce_security]" id="_alm_nonce_security" value="1"'. (($options['_alm_nonce_security']) ? ' checked="checked"' : '') .' />';
1751
- $html .= '<label for="_alm_nonce_security">'.__('Enable <a href="https://codex.wordpress.org/WordPress_Nonces" target="_blank">WP nonce</a> verification to help protect URLs against certain types of misuse, malicious or otherwise on each Ajax Load More query.', 'ajax-load-more').'</label>';
1752
-
1753
- echo $html;
1754
- }
1755
-
319
  /* <![CDATA[ */
320
  var alm_admin_localize = <?php echo json_encode( array(
321
  'ajax_admin_url' => admin_url( 'admin-ajax.php' ),
322
+ 'restapi' => array(
323
+ 'url' => function_exists('get_rest_url') ? get_rest_url() : '',
324
+ 'namespace' => ALM_REST_NAMESPACE
325
+ ),
326
  'ajax_load_more' => __('Ajax Load More', 'ajax-load-more'),
327
  'active' => __('Active', 'ajax-load-more'),
328
  'inactive' => __('Inactive', 'ajax-load-more'),
1238
  'alm_general_settings'
1239
  );
1240
 
1241
+ /*
1242
+ add_settings_field( // Disable REST API
1243
+ '_alm_use_rest_api',
1244
+ __('REST API', 'ajax-load-more' ),
1245
+ '_alm_use_rest_api_callback',
1246
  'ajax-load-more',
1247
  'alm_general_settings'
1248
  );
1249
+ */
1250
 
1251
+ add_settings_field( // Legacy Callbacks
1252
  '_alm_legacy_callbacks',
1253
  __('Legacy Callbacks', 'ajax-load-more' ),
1254
  '_alm_legacy_callbacks_callback',
1256
  'alm_general_settings'
1257
  );
1258
 
1259
+ add_settings_field( // Scroll to top on load
1260
+ '_alm_scroll_top',
1261
+ __('Top of Page', 'ajax-load-more' ),
1262
+ '_alm_scroll_top_callback',
1263
+ 'ajax-load-more',
1264
+ 'alm_general_settings'
1265
+ );
1266
+
1267
  add_settings_field( // Uninstall
1268
  '_alm_uninstall',
1269
  __('Delete on Uninstall', 'ajax-load-more' ),
1494
  $options['_alm_container_type'] = '1';
1495
 
1496
  $html = '<input type="radio" id="_alm_container_type_one" name="alm_settings[_alm_container_type]" value="1"' . checked( 1, $options['_alm_container_type'], false ) . '/>';
1497
+ $html .= '<label for="_alm_container_type_one">&lt;ul&gt; <span style="padding-top: 2px;">&lt;!-- '.__('Ajax Posts Here', 'ajax-load-more').' --&gt;</span> &lt;/ul&gt;</label><br/>';
1498
 
1499
  $html .= '<input type="radio" id="_alm_container_type_two" name="alm_settings[_alm_container_type]" value="2"' . checked( 2, $options['_alm_container_type'], false ) . '/>';
1500
+ $html .= '<label for="_alm_container_type_two">&lt;div&gt; <span style="padding-top: 2px;">&lt;!-- '.__('Ajax Posts Here', 'ajax-load-more').' --&gt;</span> &lt;/div&gt;</label>';
1501
 
1502
  $html .= '<label style="cursor: default !important"><span style="display:block">'.__('You can modify the container type when building a shortcode.', 'ajax-load-more').'</span></label>';
1503
 
1625
 
1626
  $html = '<input type="hidden" name="alm_settings[_alm_inline_css]" value="0" />';
1627
  $html .= '<input type="checkbox" name="alm_settings[_alm_inline_css]" id="alm_inline_css" value="1"'. (($options['_alm_inline_css']) ? ' checked="checked"' : '') .' />';
1628
+ $html .= '<label for="alm_inline_css">'.__('Improve site performance by loading Ajax Load More CSS inline.', 'ajax-load-more').'</label>';
1629
 
1630
  echo $html;
1631
  }
1700
 
1701
 
1702
 
1703
+ /*
1704
+ * _alm_use_rest_api
1705
+ * Disable REST API in favor of admin-ajax.php
1706
+ *
1707
+ * @since 5.1
1708
+ */
1709
+
1710
+ function _alm_use_rest_api_callback(){
1711
+ $options = get_option( 'alm_settings' );
1712
+ if(!isset($options['_alm_use_rest_api']))
1713
+ $options['_alm_use_rest_api'] = '0';
1714
+
1715
+ $html = '<input type="hidden" name="alm_settings[_alm_use_rest_api]" value="0" />';
1716
+ $html .= '<input type="checkbox" name="alm_settings[_alm_use_rest_api]" id="_alm_use_rest_api" value="1"'. (($options['_alm_use_rest_api']) ? ' checked="checked"' : '') .' />';
1717
+ $html .= '<label for="_alm_use_rest_api">';
1718
+ $html .= __('Disable REST API.', 'ajax-load-more');
1719
+ $html .= '<span style="display:block">'. __('Use `admin-ajax.php` in favour of the WordPress REST API for all Ajax requests.', 'ajax-load-more') .'</span>';
1720
+ $html .= '</label>';
1721
+
1722
+ echo $html;
1723
+ }
1724
+
1725
+
1726
+
1727
  /*
1728
  * _alm_legacy_callbacks_callback
1729
  * Load legacy callback actions
1770
  echo $html;
1771
  }
1772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/dist/css/admin.css CHANGED
@@ -1078,8 +1078,7 @@ body.ajax-load-more_page_ajax-load-more-pro {
1078
  border-bottom: none;
1079
  padding: 20px 20px 6px;
1080
  margin: 20px 0 0;
1081
- font-weight: 600;
1082
- font-size: 18px;
1083
  border-radius: 2px 2px 0 0; }
1084
  #alm-settings form h2:first-of-type {
1085
  margin: 0; }
@@ -1214,7 +1213,7 @@ a.layout-hover:hover img {
1214
 
1215
  /* Expand Collapse Headings */
1216
  .ajax-load-more h3.heading {
1217
- font-weight: 600;
1218
  padding: 15px 10px 15px 38px !important;
1219
  line-height: normal !important;
1220
  margin: 0 !important;
@@ -2217,7 +2216,7 @@ hr.indented {
2217
  .ajax-load-more h2.addon-title {
2218
  font-size: 19px !important;
2219
  line-height: 24px;
2220
- font-weight: 600 !important;
2221
  color: #444 !important;
2222
  padding: 0;
2223
  margin: 0 0 10px; }
@@ -2899,6 +2898,7 @@ span.cnkt-button.installed i,
2899
  margin: 0;
2900
  display: block;
2901
  font-size: 15px;
 
2902
  text-transform: none;
2903
  border-radius: 2px 2px 0 0; }
2904
 
@@ -3482,7 +3482,7 @@ p.theme-title {
3482
  .alm-dir-listing.theme-repeaters ul li {
3483
  display: block;
3484
  width: 100%;
3485
- padding-top: 12px; }
3486
 
3487
  .alm-dir-listing.theme-repeaters ul li label {
3488
  display: block;
@@ -3610,7 +3610,7 @@ p.theme-title {
3610
  background-color: #f7f7f7;
3611
  border-radius: 2px 2px 0 0;
3612
  color: #555;
3613
- font-weight: 600;
3614
  position: relative;
3615
  cursor: pointer; }
3616
  #alm-shortcode-builder-form .shortcode-parameter-wrap h2:focus, #alm-shortcode-builder-form .shortcode-parameter-wrap h2:hover {
1078
  border-bottom: none;
1079
  padding: 20px 20px 6px;
1080
  margin: 20px 0 0;
1081
+ font-weight: 700;
 
1082
  border-radius: 2px 2px 0 0; }
1083
  #alm-settings form h2:first-of-type {
1084
  margin: 0; }
1213
 
1214
  /* Expand Collapse Headings */
1215
  .ajax-load-more h3.heading {
1216
+ font-weight: 700;
1217
  padding: 15px 10px 15px 38px !important;
1218
  line-height: normal !important;
1219
  margin: 0 !important;
2216
  .ajax-load-more h2.addon-title {
2217
  font-size: 19px !important;
2218
  line-height: 24px;
2219
+ font-weight: 700 !important;
2220
  color: #444 !important;
2221
  padding: 0;
2222
  margin: 0 0 10px; }
2898
  margin: 0;
2899
  display: block;
2900
  font-size: 15px;
2901
+ font-weight: 700;
2902
  text-transform: none;
2903
  border-radius: 2px 2px 0 0; }
2904
 
3482
  .alm-dir-listing.theme-repeaters ul li {
3483
  display: block;
3484
  width: 100%;
3485
+ padding-top: 10px; }
3486
 
3487
  .alm-dir-listing.theme-repeaters ul li label {
3488
  display: block;
3610
  background-color: #f7f7f7;
3611
  border-radius: 2px 2px 0 0;
3612
  color: #555;
3613
+ font-weight: 700;
3614
  position: relative;
3615
  cursor: pointer; }
3616
  #alm-shortcode-builder-form .shortcode-parameter-wrap h2:focus, #alm-shortcode-builder-form .shortcode-parameter-wrap h2:hover {
admin/dist/js/admin.js CHANGED
@@ -1279,6 +1279,28 @@ jQuery(document).ready(function ($) {
1279
  speed: 200
1280
  };
1281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1282
  /*
1283
  * _alm.saveSettings
1284
  * Setting panel save actions
@@ -1591,7 +1613,7 @@ jQuery(document).ready(function ($) {
1591
  $('.loading', parent).delay(250).fadeOut(300);
1592
  almActivating = false;
1593
  },
1594
- error: function error(xhr, status, _error) {
1595
  console.log(status);
1596
  $('.loading', parent).delay(250).fadeOut(300);
1597
  almActivating = false;
@@ -1653,7 +1675,7 @@ jQuery(document).ready(function ($) {
1653
  }, 400);
1654
  }, 400);
1655
  },
1656
- error: function error(xhr, status, _error2) {
1657
  console.log(status);
1658
  textarea.removeClass('loading');
1659
  }
@@ -1680,7 +1702,7 @@ jQuery(document).ready(function ($) {
1680
  success: function success(data) {
1681
  container.fadeOut();
1682
  },
1683
- error: function error(xhr, status, _error3) {
1684
  console.log(status);
1685
  }
1686
  });
@@ -1710,7 +1732,7 @@ jQuery(document).ready(function ($) {
1710
  success: function success(data) {
1711
  container.fadeOut();
1712
  },
1713
- error: function error(xhr, status, _error4) {
1714
  console.log(status);
1715
  }
1716
  });
1279
  speed: 200
1280
  };
1281
 
1282
+ /*
1283
+ * Test REST API access
1284
+ *
1285
+ * @since 5.1.1
1286
+ */
1287
+ if ($('.restapi-access').length) {
1288
+ $.ajax({
1289
+ type: 'GET',
1290
+ url: alm_admin_localize.restapi.url + alm_admin_localize.restapi.namespace + '/test/',
1291
+ dataType: 'json',
1292
+ success: function success(data) {
1293
+ if (data.success) {
1294
+ console.log('Ajax Load More successfully connected to the WordPress REST API.');
1295
+ }
1296
+ },
1297
+ error: function error(xhr, status, _error) {
1298
+ console.log(status);
1299
+ $('.restapi-access').fadeIn();
1300
+ }
1301
+ });
1302
+ }
1303
+
1304
  /*
1305
  * _alm.saveSettings
1306
  * Setting panel save actions
1613
  $('.loading', parent).delay(250).fadeOut(300);
1614
  almActivating = false;
1615
  },
1616
+ error: function error(xhr, status, _error2) {
1617
  console.log(status);
1618
  $('.loading', parent).delay(250).fadeOut(300);
1619
  almActivating = false;
1675
  }, 400);
1676
  }, 400);
1677
  },
1678
+ error: function error(xhr, status, _error3) {
1679
  console.log(status);
1680
  textarea.removeClass('loading');
1681
  }
1702
  success: function success(data) {
1703
  container.fadeOut();
1704
  },
1705
+ error: function error(xhr, status, _error4) {
1706
  console.log(status);
1707
  }
1708
  });
1732
  success: function success(data) {
1733
  container.fadeOut();
1734
  },
1735
+ error: function error(xhr, status, _error5) {
1736
  console.log(status);
1737
  }
1738
  });
admin/includes/cta/pro-hero.php CHANGED
@@ -13,7 +13,7 @@ if(!has_action('alm_pro_installed')){
13
  $img = $pro['img'];
14
  ?>
15
  <div class="group no-shadow highlighted">
16
- <a href="<?php echo $url; ?>?utm_source=WP%20Admin&utm_medium=ALM%20Add-ons&utm_campaign=<?php echo $name; ?>" <?php echo $target; ?>>
17
  <div class="pro-img">
18
  <img src="<?php echo ALM_ADMIN_URL; ?><?php echo $img; ?>" alt="">
19
  </div>
13
  $img = $pro['img'];
14
  ?>
15
  <div class="group no-shadow highlighted">
16
+ <a href="<?php echo $url; ?>?utm_source=WP%20Admin&utm_medium=ALM%20Add-ons&utm_campaign=<?php echo $name; ?>" target="_blank">
17
  <div class="pro-img">
18
  <img src="<?php echo ALM_ADMIN_URL; ?><?php echo $img; ?>" alt="">
19
  </div>
admin/includes/cta/test.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Only render REST API test if REST API is active
3
+
4
+ $options = get_option( 'alm_settings' ); // Get ALM Options
5
+
6
+ if(isset($options['_alm_use_rest_api']) && $options['_alm_use_rest_api'] !== '1'){ // REST API manually disabled from ALM settings.
7
+ if(!function_exists('get_rest_url')) { ?>
8
+ <div class="cta restapi-access">
9
+ <h3><?php _e('REST API Access', 'ajax-load-more'); ?></h3>
10
+ <div class="cta-inner">
11
+ <div class="item">
12
+ <p class="writeable-title">
13
+ <i class="fa fa-exclamation"></i>
14
+ <strong><?php _e('REST API Blocked', 'ajax-load-more'); ?></strong><br/>
15
+ <?php echo __('Unable to access the WordPress REST API. Are you running a security plugin or have your server configured in a way that may be preventing access to the REST API?', 'ajax-load-more'); ?>
16
+ </p>
17
+ <p class="writeable-title">
18
+ <a href="https://connekthq.com/plugins/ajax-load-more/support" target="_blank" class="button button-primary"><?php _e('Get Plugin Support', 'ajax-load-more'); ?></a>
19
+ </p>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ <?php } ?>
24
+ <?php } ?>
admin/shortcode-builder/js/shortcode-builder.js CHANGED
@@ -1084,6 +1084,15 @@ jQuery(document).ready(function($) {
1084
  }
1085
 
1086
 
 
 
 
 
 
 
 
 
 
1087
  // ---------------------------
1088
  // - Scrolling
1089
  // ---------------------------
@@ -1202,15 +1211,6 @@ jQuery(document).ready(function($) {
1202
  output += ' images_loaded="true"';
1203
 
1204
 
1205
- // ---------------------------
1206
- // - Destroy After
1207
- // ---------------------------
1208
-
1209
- var destroy_after = $('.alm-destroy-after input[name=destroy-after]').val();
1210
- if(destroy_after !== '' && destroy_after !== undefined && destroy_after !== '0')
1211
- output += ' destroy_after="'+destroy_after+'"';
1212
-
1213
-
1214
  // ---------------------------
1215
  // - Button Label
1216
  // ---------------------------
1084
  }
1085
 
1086
 
1087
+ // ---------------------------
1088
+ // - Destroy After
1089
+ // ---------------------------
1090
+
1091
+ var destroy_after = $('.alm-destroy-after input[name=destroy-after]').val();
1092
+ if(destroy_after !== '' && destroy_after !== undefined && destroy_after !== '0')
1093
+ output += ' destroy_after="'+destroy_after+'"';
1094
+
1095
+
1096
  // ---------------------------
1097
  // - Scrolling
1098
  // ---------------------------
1211
  output += ' images_loaded="true"';
1212
 
1213
 
 
 
 
 
 
 
 
 
 
1214
  // ---------------------------
1215
  // - Button Label
1216
  // ---------------------------
admin/shortcode-builder/shortcode-builder.php CHANGED
@@ -113,6 +113,20 @@
113
  </div>
114
  </div>
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  <div class="clear"></div>
117
  <hr/>
118
 
@@ -329,13 +343,13 @@
329
  <hr>
330
  <div class="section-title full" style="padding-bottom: 10px;">
331
  <h4><?php _e('Masonry Options', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('Ajax Load More does not support all available Masonry options','ajax-load-more'); ?>."></a></h4>
332
- <p><?php _e('The following Masonry <a href="https://masonry.desandro.com/options.html" target="_blank">options</a> are supported by Ajax Load More', 'ajax-load-more'); ?>.</p>
333
  </div>
334
  <div class="clear"></div>
335
 
336
  <div class="section-title">
337
- <h4><?php _e('Item Selector', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('Item Selector is required for Masonry to target each element loaded with Ajax','ajax-load-more'); ?>."></a></h4>
338
- <p><?php _e('Enter the target classname of each masonry item', 'ajax-load-more'); ?>.<br/>
339
  e.g <span>.grid-item</span>
340
  </p>
341
  </div>
@@ -349,8 +363,8 @@
349
  <hr class="indented" />
350
 
351
  <div class="section-title">
352
- <h4><?php _e('Column Width', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('If columnWidth is not set, Masonry will use the outer width of the first Item Selector','ajax-load-more'); ?>."></a></h4>
353
- <p><?php _e('Enter the <a href="https://masonry.desandro.com/options.html#columnwidth" target="_blank">columnWidth</a> of the masonry items', 'ajax-load-more'); ?>.<br/>
354
  e.g <span>80</span>
355
  </p>
356
  </div>
@@ -364,8 +378,8 @@
364
  <hr class="indented" />
365
 
366
  <div class="section-title">
367
- <h4><?php _e('Animation Type', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('All Masonry animations include a fade-in effect as items are loaded','ajax-load-more'); ?>."></a></h4>
368
- <p><?php _e('Select a loading transition for Masonry items', 'ajax-load-more'); ?>.</p>
369
  </div>
370
  <div class="wrap">
371
  <div class="inner">
@@ -374,14 +388,14 @@
374
  <input class="alm_element" type="radio" name="masonry-animation" value="default" id="masonry-animation-default" checked="checked">
375
  <label for="masonry-animation-default">
376
  <?php _e('Default (Zoom)', 'ajax-load-more'); ?>
377
- <span class="description"><?php _e('Items scale up from 50% to 100% size on load','ajax-load-more'); ?>.</span>
378
  </label>
379
  </li>
380
  <li style="width:100%;">
381
  <input class="alm_element" type="radio" name="masonry-animation" value="zoom-out" id="masonry-animation-zoom-out">
382
  <label for="masonry-animation-zoom-out">
383
  <?php _e('Zoom Out', 'ajax-load-more'); ?>
384
- <span class="description"><?php _e('Items scale down from 125% to 100% size on load','ajax-load-more'); ?>.</span>
385
  </label>
386
  </li>
387
  <li style="width:100%;">
@@ -413,7 +427,7 @@
413
 
414
  <div class="section-title">
415
  <h4><?php _e('Horizontal Order', 'ajax-load-more'); ?></h4>
416
- <p><?php _e('Lays out items to maintain left-to-right order', 'ajax-load-more'); ?>.
417
  </p>
418
  </div>
419
  <div class="wrap">
@@ -430,6 +444,11 @@
430
  </ul>
431
  </div>
432
  </div>
 
 
 
 
 
433
 
434
  </div>
435
 
@@ -574,23 +593,6 @@
574
  </div>
575
  </div>
576
  <!-- End Images Loaded -->
577
-
578
- <!-- Destroy After -->
579
- <div class="row input alm-destroy-after" id="alm-destroy-after">
580
- <h3 class="heading" tabindex="0"><?php _e('Destroy After', 'ajax-load-more'); ?></h3>
581
- <!-- Destroy After -->
582
- <div class="expand-wrap">
583
- <div class="section-title">
584
- <p><?php _e('Remove Ajax Load More functionality after {<em>n</em>} number of pages have been loaded.', 'ajax-load-more'); ?></p>
585
- </div>
586
- <div class="wrap">
587
- <div class="inner">
588
- <input type="number" class="alm_element numbers-only" placeholder="0" name="destroy-after" id="disable-after" step="1" min="0" value="">
589
- </div>
590
- </div>
591
- </div>
592
- </div>
593
- <!-- End Destroy After -->
594
 
595
  </div>
596
  </div>
113
  </div>
114
  </div>
115
 
116
+ <div class="clear"></div>
117
+ <hr/>
118
+
119
+ <!-- Destroy After -->
120
+ <div class="section-title">
121
+ <h4><?php _e('Destroy After', 'ajax-load-more'); ?></h4>
122
+ <p><?php _e('Remove Ajax Load More functionality after {<em>n</em>} number of pages have been loaded.', 'ajax-load-more'); ?></p>
123
+ </div>
124
+ <div class="wrap alm-destroy-after">
125
+ <div class="inner">
126
+ <input type="number" class="alm_element numbers-only" placeholder="0" name="destroy-after" id="disable-after" step="1" min="0" value="">
127
+ </div>
128
+ </div>
129
+
130
  <div class="clear"></div>
131
  <hr/>
132
 
343
  <hr>
344
  <div class="section-title full" style="padding-bottom: 10px;">
345
  <h4><?php _e('Masonry Options', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('Ajax Load More does not support all available Masonry options','ajax-load-more'); ?>."></a></h4>
346
+ <p><?php _e('The following Masonry <a href="https://masonry.desandro.com/options.html" target="_blank">options</a> are supported by Ajax Load More.', 'ajax-load-more'); ?></p>
347
  </div>
348
  <div class="clear"></div>
349
 
350
  <div class="section-title">
351
+ <h4><?php _e('Item Selector', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('Item Selector is required for Masonry to target each element loaded with Ajax.','ajax-load-more'); ?>"></a></h4>
352
+ <p><?php _e('Enter the target classname of each masonry item.', 'ajax-load-more'); ?><br/>
353
  e.g <span>.grid-item</span>
354
  </p>
355
  </div>
363
  <hr class="indented" />
364
 
365
  <div class="section-title">
366
+ <h4><?php _e('Column Width', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('If columnWidth is not set, Masonry will use the outer width of the first Item Selector.','ajax-load-more'); ?>"></a></h4>
367
+ <p><?php _e('Enter the <a href="https://masonry.desandro.com/options.html#columnwidth" target="_blank">columnWidth</a> of the masonry items.', 'ajax-load-more'); ?><br/>
368
  e.g <span>80</span>
369
  </p>
370
  </div>
378
  <hr class="indented" />
379
 
380
  <div class="section-title">
381
+ <h4><?php _e('Animation Type', 'ajax-load-more'); ?> <a href="javascript:void(0)" class="fa fa-question-circle tooltip" title="<?php _e('All Masonry animations include a fade-in effect as items are loaded.','ajax-load-more'); ?>"></a></h4>
382
+ <p><?php _e('Select a loading transition for Masonry items.', 'ajax-load-more'); ?></p>
383
  </div>
384
  <div class="wrap">
385
  <div class="inner">
388
  <input class="alm_element" type="radio" name="masonry-animation" value="default" id="masonry-animation-default" checked="checked">
389
  <label for="masonry-animation-default">
390
  <?php _e('Default (Zoom)', 'ajax-load-more'); ?>
391
+ <span class="description"><?php _e('Items scale up from 50% to 100% size on load.','ajax-load-more'); ?></span>
392
  </label>
393
  </li>
394
  <li style="width:100%;">
395
  <input class="alm_element" type="radio" name="masonry-animation" value="zoom-out" id="masonry-animation-zoom-out">
396
  <label for="masonry-animation-zoom-out">
397
  <?php _e('Zoom Out', 'ajax-load-more'); ?>
398
+ <span class="description"><?php _e('Items scale down from 125% to 100% size on load.','ajax-load-more'); ?></span>
399
  </label>
400
  </li>
401
  <li style="width:100%;">
427
 
428
  <div class="section-title">
429
  <h4><?php _e('Horizontal Order', 'ajax-load-more'); ?></h4>
430
+ <p><?php _e('Lays out items to maintain left-to-right order.', 'ajax-load-more'); ?>
431
  </p>
432
  </div>
433
  <div class="wrap">
444
  </ul>
445
  </div>
446
  </div>
447
+
448
+ <p class="warning-callout">
449
+ <?php _e('Don\'t see your favorite Masonry option listed? You can always add your own!', 'ajax-load-more'); ?>
450
+ <a class="button-small" href="https://connekthq.com/plugins/ajax-load-more/docs/masonry/" target="_blank"><?php _e('View Docs', 'ajax-load-more'); ?></a>
451
+ </p>
452
 
453
  </div>
454
 
593
  </div>
594
  </div>
595
  <!-- End Images Loaded -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
 
597
  </div>
598
  </div>
admin/src/js/admin.js CHANGED
@@ -6,6 +6,31 @@ jQuery(document).ready(function($) {
6
  _alm.options = {
7
  speed: 200
8
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
 
11
  /*
6
  _alm.options = {
7
  speed: 200
8
  };
9
+
10
+
11
+
12
+ /*
13
+ * Test REST API access
14
+ *
15
+ * @since 5.1.1
16
+ */
17
+ if($('.restapi-access').length){
18
+ $.ajax({
19
+ type: 'GET',
20
+ url: alm_admin_localize.restapi.url + alm_admin_localize.restapi.namespace + '/test/',
21
+ dataType: 'json',
22
+ success: function(data) {
23
+ if(data.success){
24
+ console.log('Ajax Load More successfully connected to the WordPress REST API.');
25
+ }
26
+ },
27
+ error: function(xhr, status, error) {
28
+ console.log(status);
29
+ $('.restapi-access').fadeIn();
30
+ }
31
+ });
32
+ }
33
+
34
 
35
 
36
  /*
admin/src/scss/admin.scss CHANGED
@@ -171,8 +171,7 @@ body.ajax-load-more_page_ajax-load-more-pro{
171
  border-bottom: none;
172
  padding: 20px 20px 6px;
173
  margin: 20px 0 0;
174
- font-weight: 600;
175
- font-size: 18px;
176
  border-radius: 2px 2px 0 0;
177
  &:first-of-type{
178
  margin: 0;
@@ -317,7 +316,7 @@ a.layout-hover{
317
 
318
  /* Expand Collapse Headings */
319
  .ajax-load-more h3.heading{
320
- font-weight: 600;
321
  padding: 15px 10px 15px 38px !important;
322
  line-height: normal !important;
323
  margin: 0 !important;
@@ -1436,7 +1435,7 @@ hr.indented{ // Indented as fake padding in shortcode builder
1436
  .ajax-load-more h2.addon-title{
1437
  font-size: 19px !important;
1438
  line-height: 24px;
1439
- font-weight: 600 !important;
1440
  color: #444 !important;
1441
  padding: 0;
1442
  margin: 0 0 10px;
@@ -2154,6 +2153,7 @@ table.highlight{
2154
  margin: 0;
2155
  display: block;
2156
  font-size: 15px;
 
2157
  text-transform: none;
2158
  border-radius: 2px 2px 0 0;
2159
  }
@@ -2800,7 +2800,7 @@ p.theme-title{
2800
  .alm-dir-listing.theme-repeaters ul li{
2801
  display: block;
2802
  width: 100%;
2803
- padding-top: 12px;
2804
  }
2805
  .alm-dir-listing.theme-repeaters ul li label{
2806
  display: block;
@@ -2938,7 +2938,7 @@ p.theme-title{
2938
  background-color: #f7f7f7;
2939
  border-radius: 2px 2px 0 0;
2940
  color: $grey;
2941
- font-weight: 600;
2942
  position: relative;
2943
  cursor: pointer;
2944
  &:focus,
171
  border-bottom: none;
172
  padding: 20px 20px 6px;
173
  margin: 20px 0 0;
174
+ font-weight: 700;
 
175
  border-radius: 2px 2px 0 0;
176
  &:first-of-type{
177
  margin: 0;
316
 
317
  /* Expand Collapse Headings */
318
  .ajax-load-more h3.heading{
319
+ font-weight: 700;
320
  padding: 15px 10px 15px 38px !important;
321
  line-height: normal !important;
322
  margin: 0 !important;
1435
  .ajax-load-more h2.addon-title{
1436
  font-size: 19px !important;
1437
  line-height: 24px;
1438
+ font-weight: 700 !important;
1439
  color: #444 !important;
1440
  padding: 0;
1441
  margin: 0 0 10px;
2153
  margin: 0;
2154
  display: block;
2155
  font-size: 15px;
2156
+ font-weight: 700;
2157
  text-transform: none;
2158
  border-radius: 2px 2px 0 0;
2159
  }
2800
  .alm-dir-listing.theme-repeaters ul li{
2801
  display: block;
2802
  width: 100%;
2803
+ padding-top: 10px;
2804
  }
2805
  .alm-dir-listing.theme-repeaters ul li label{
2806
  display: block;
2938
  background-color: #f7f7f7;
2939
  border-radius: 2px 2px 0 0;
2940
  color: $grey;
2941
+ font-weight: 700;
2942
  position: relative;
2943
  cursor: pointer;
2944
  &:focus,
admin/views/settings.php CHANGED
@@ -67,6 +67,7 @@
67
  <aside class="cnkt-sidebar">
68
  <?php //include_once( ALM_PATH . 'admin/includes/cta/pro.php'); ?>
69
  <?php //include_once( ALM_PATH . 'admin/includes/cta/sharing.php'); ?>
 
70
  <?php include_once( ALM_PATH . 'admin/includes/cta/resources.php'); ?>
71
  <?php include_once( ALM_PATH . 'admin/includes/cta/dyk.php'); ?>
72
  <?php include_once( ALM_PATH . 'admin/includes/cta/about.php'); ?>
67
  <aside class="cnkt-sidebar">
68
  <?php //include_once( ALM_PATH . 'admin/includes/cta/pro.php'); ?>
69
  <?php //include_once( ALM_PATH . 'admin/includes/cta/sharing.php'); ?>
70
+ <?php include_once( ALM_PATH . 'admin/includes/cta/test.php'); ?>
71
  <?php include_once( ALM_PATH . 'admin/includes/cta/resources.php'); ?>
72
  <?php include_once( ALM_PATH . 'admin/includes/cta/dyk.php'); ?>
73
  <?php include_once( ALM_PATH . 'admin/includes/cta/about.php'); ?>
ajax-load-more.php CHANGED
@@ -7,14 +7,14 @@ Text Domain: ajax-load-more
7
  Author: Darren Cooney
8
  Twitter: @KaptonKaos
9
  Author URI: https://connekthq.com
10
- Version: 5.0.2
11
  License: GPL
12
  Copyright: Darren Cooney & Connekt Media
13
  */
14
 
15
 
16
- define('ALM_VERSION', '5.0.2');
17
- define('ALM_RELEASE', 'April 4, 2019');
18
  define('ALM_STORE_URL', 'https://connekthq.com');
19
 
20
 
@@ -103,6 +103,8 @@ function alm_render($args){
103
  }
104
 
105
 
 
 
106
  if( !class_exists('AjaxLoadMore') ):
107
 
108
  class AjaxLoadMore {
@@ -113,11 +115,9 @@ if( !class_exists('AjaxLoadMore') ):
113
 
114
  $this->alm_define_constants();
115
  $this->alm_includes();
116
-
117
- add_action( 'wp_ajax_alm_query_posts', array(&$this, 'alm_query_posts') );
118
- add_action( 'wp_ajax_nopriv_alm_query_posts', array(&$this, 'alm_query_posts') );
119
- add_action( 'wp_ajax_alm_query_total', array(&$this, 'alm_query_total') );
120
- add_action( 'wp_ajax_nopriv_alm_query_total', array(&$this, 'alm_query_total') );
121
  add_action( 'wp_enqueue_scripts', array(&$this, 'alm_enqueue_scripts') );
122
  add_action( 'after_setup_theme', array(&$this, 'alm_image_sizes') );
123
  add_filter( 'alm_noscript', array(&$this, 'alm_noscript'), 10, 5 );
@@ -132,12 +132,12 @@ if( !class_exists('AjaxLoadMore') ):
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
 
@@ -147,6 +147,7 @@ if( !class_exists('AjaxLoadMore') ):
147
  define('ALM_NAME', '_ajax_load_more');
148
  define('ALM_TITLE', 'Ajax Load More');
149
  define('ALM_SLUG', 'ajax-load-more');
 
150
 
151
  if (!defined('ALM_CACHE_ITEM_NAME')) define('ALM_CACHE_ITEM_NAME', '4878');
152
  if (!defined('ALM_CTA_ITEM_NAME')) define('ALM_CTA_ITEM_NAME', '14456');
@@ -168,13 +169,13 @@ if( !class_exists('AjaxLoadMore') ):
168
 
169
 
170
 
171
- /*
172
- * alm_noscript
173
- * This function will build an query for users without JS enabled
174
- *
175
- * @return $return string
176
- * @since 3.7
177
- */
178
  function alm_noscript($args, $container_element, $css_classes = '', $transition_container_classes = ''){
179
  if(is_admin()){
180
  return false;
@@ -188,13 +189,13 @@ if( !class_exists('AjaxLoadMore') ):
188
 
189
 
190
 
191
- /*
192
- * alm_noscript_pagination
193
- * This function will build an pagination for users without JS enabled
194
- *
195
- * @return $return string
196
- * @since 3.7
197
- */
198
  function alm_noscript_pagination($query){
199
  if(is_admin()){
200
  return false;
@@ -208,15 +209,15 @@ if( !class_exists('AjaxLoadMore') ):
208
 
209
 
210
 
211
- /*
212
- * alm_get_repeater_base_path
213
- * Get absolute path to repeater directory base
214
- *
215
- * Multisite installs directories will be `uploads/sites/{id}/alm_templates`
216
- *
217
- * @return $path;
218
- * @since 3.5
219
- */
220
  public static function alm_get_repeater_path(){
221
  $upload_dir = wp_upload_dir();
222
  $path = apply_filters( 'alm_repeater_path', $upload_dir['basedir']. '/alm_templates' );
@@ -225,12 +226,12 @@ if( !class_exists('AjaxLoadMore') ):
225
 
226
 
227
 
228
- /*
229
- * alm_mkdir
230
- * Create repeater template directory
231
- *
232
- * @since 3.5
233
- */
234
  public static function alm_mkdir($dir){
235
 
236
  // Does $dir exist?
@@ -246,15 +247,18 @@ if( !class_exists('AjaxLoadMore') ):
246
 
247
 
248
 
249
- /*
250
- * alm_includes
251
- * Load these files before the theme loads
252
- *
253
- * @since 2.0.0
254
- */
255
 
256
  public function alm_includes(){
 
257
  include_once( ALM_PATH . 'core/functions.php'); // Load Core Functions
 
 
258
  include_once( ALM_PATH . 'core/classes/class.alm-shortcode.php'); // Load Shortcode Class
259
  include_once( ALM_PATH . 'core/classes/class.alm-enqueue.php'); // Load Enqueue Class
260
  include_once( ALM_PATH . 'core/classes/class.alm-queryargs.php'); // Load Query Args Class
@@ -269,16 +273,17 @@ if( !class_exists('AjaxLoadMore') ):
269
  include( dirname( __FILE__ ) . '/vendor/EDD_SL_Plugin_Updater.php' );
270
  }
271
  }
 
272
  }
273
 
274
 
275
 
276
- /*
277
- * alm_return_addons
278
- * Returns add-on data (admin/admin-functions.php)
279
- *
280
- * @since 2.0.0
281
- */
282
 
283
  public function alm_return_addons(){
284
  return alm_get_addons();
@@ -286,12 +291,12 @@ if( !class_exists('AjaxLoadMore') ):
286
 
287
 
288
 
289
- /*
290
- * alm_action_links
291
- * Add plugin action links to WP plugin screen
292
- *
293
- * @since 2.2.3
294
- */
295
 
296
  public function alm_action_links( $links ) {
297
  $links[] = '<a href="'. get_admin_url(null, 'admin.php?page=ajax-load-more') .'">'.__('Settings', 'ajax-load-more').'</a>';
@@ -300,12 +305,12 @@ if( !class_exists('AjaxLoadMore') ):
300
 
301
 
302
 
303
- /*
304
- * alm_plugin_meta_links
305
- * Add plugin meta links to WP plugin screen
306
- *
307
- * @since 2.7.2.1
308
- */
309
 
310
  public function alm_plugin_meta_links( $links, $file ) {
311
  if ( strpos( $file, 'ajax-load-more.php' ) !== false ) {
@@ -320,12 +325,12 @@ if( !class_exists('AjaxLoadMore') ):
320
 
321
 
322
 
323
- /*
324
- * alm_image_sizes
325
- * Add default image size
326
- *
327
- * @since 2.8.3
328
- */
329
 
330
  public function alm_image_sizes(){
331
  add_image_size( 'alm-thumbnail', 150, 150, true); // Custom ALM thumbnail size
@@ -333,12 +338,12 @@ if( !class_exists('AjaxLoadMore') ):
333
 
334
 
335
 
336
- /*
337
- * alm_enqueue_scripts
338
- * Enqueue scripts and create localized variables
339
- *
340
- * @since 2.0.0
341
- */
342
 
343
  public function alm_enqueue_scripts(){
344
 
@@ -377,32 +382,49 @@ if( !class_exists('AjaxLoadMore') ):
377
  }
378
 
379
  // Prevent loading of unnessasry posts - move user to top of page
380
- // if unset or false
381
  $scrolltop = (!isset($options['_alm_scroll_top']) || $options['_alm_scroll_top'] != '1') ? 'false' : 'true';
382
 
 
 
 
 
 
 
 
 
 
 
 
383
  wp_localize_script(
384
  'ajax-load-more',
385
  'alm_localize',
386
  array(
387
- 'ajaxurl' => admin_url('admin-ajax.php'),
 
 
 
 
 
388
  'alm_nonce' => wp_create_nonce( "ajax_load_more_nonce" ),
389
  'pluginurl' => ALM_URL,
390
  'scrolltop' => $scrolltop,
391
- 'display_results' => apply_filters('alm_display_results', __('Showing {num} of {total} results', 'ajax-load-more')),
392
- 'ajax_object' => array('is_single' => true, 'is_singular' => true )
 
393
  )
394
  );
 
395
  }
396
 
397
 
398
 
399
- /*
400
- * alm_shortcode
401
- * The AjaxLoadMore shortcode
402
- *
403
- * @since 2.0.0
404
- * @updated 3.2.0
405
- */
406
  public function alm_shortcode($atts) {
407
  self::$shortcode_atts = $atts;
408
  return ALM_SHORTCODE::alm_render_shortcode($atts);
@@ -410,337 +432,343 @@ if( !class_exists('AjaxLoadMore') ):
410
 
411
 
412
 
413
- /*
414
- * alm_return_shortcode_atts
415
- * Return the ALM shortcode atts
416
- *
417
- * @since 3.2.0
418
- */
419
  public static function alm_return_shortcode_atts(){
420
  return self::$shortcode_atts;
421
  }
422
-
423
-
424
-
425
- /*
426
- * alm_query_posts
427
- * Ajax Load More Query
428
- *
429
- * @since 2.0.0
430
- */
431
-
432
- public function alm_query_posts() {
433
-
434
  // WPML fix for category/tag/taxonomy archives
435
  if ( (isset( $_GET['category'] ) && $_GET['category']) || (isset($_GET['taxonomy']) && $_GET['taxonomy']) ) {
436
  unset($_REQUEST['post_id']);
437
  }
438
-
439
- $id = (isset($_GET['id'])) ? $_GET['id'] : '';
440
- $post_id = (isset($_GET['post_id'])) ? $_GET['post_id'] : '';
441
- $slug = (isset($_GET['slug'])) ? $_GET['slug'] : '';
442
- $canonical_url = (isset($_GET['canonical_url'])) ? $_GET['canonical_url'] : $_SERVER['HTTP_REFERER'];
443
-
 
444
  // Ajax Query Type
445
- $queryType = (isset($_GET['query_type'])) ? $_GET['query_type'] : 'standard'; // 'standard' or 'totalposts'; totalposts returns $alm_found_posts
446
-
447
-
448
  // Cache
449
- $cache_id = (isset($_GET['cache_id'])) ? $_GET['cache_id'] : '';
450
- $cache_logged_in = (isset($_GET['cache_logged_in'])) ? $_GET['cache_logged_in'] : false;
451
- $do_create_cache = ($cache_logged_in === 'true' && is_user_logged_in()) ? false : true;
452
-
453
-
454
- // Offset
455
- $offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0;
456
-
457
-
458
  // Repeater Templates
459
- $repeater = (isset($_GET['repeater'])) ? $_GET['repeater'] : 'default';
460
- $type = alm_get_repeater_type($repeater);
461
- $theme_repeater = (isset($_GET['theme_repeater'])) ? $_GET['theme_repeater'] : 'null';
462
-
463
-
464
  // Post Type
465
- $postType = (isset($_GET['post_type'])) ? $_GET['post_type'] : 'post';
466
-
467
-
468
- // Page Parameters
469
- $posts_per_page = (isset($_GET['posts_per_page'])) ? $_GET['posts_per_page'] : 5;
470
- $page = (isset($_GET['page'])) ? $_GET['page'] : 0;
471
-
472
-
473
- // Advanced Custom Fields
474
- $acfData = (isset($_GET['acf'])) ? $_GET['acf'] : false;
475
- if($acfData){
476
- $acf = (isset($acfData['acf'])) ? $acfData['acf'] : false; // true / false
477
- $acf_post_id = (isset($acfData['post_id'])) ? $acfData['post_id'] : ''; // Post ID
478
- $acf_field_type = (isset($acfData['field_type'])) ? $acfData['field_type'] : ''; // ACF Field Type
479
- $acf_field_name = (isset($acfData['field_name'])) ? $acfData['field_name'] : ''; // ACF Field Type
480
- }
481
-
482
-
483
- // Paging Add-on
484
- $paging = (isset($_GET['paging'])) ? $_GET['paging'] : 'false';
485
-
486
-
487
- // Preload Add-on
488
- $preloaded = (isset($_GET['preloaded'])) ? $_GET['preloaded'] : 'false';
489
- $preloaded_amount = (isset($_GET['preloaded_amount'])) ? $_GET['preloaded_amount'] : '5';
490
- if(has_action('alm_preload_installed') && $preloaded === 'true'){
491
- // If preload - offset the ajax posts by posts_per_page + preload_amount val
492
- $old_offset = $preloaded_amount;
493
- $offset = $offset + $preloaded_amount;
494
- }
495
-
496
-
497
- // CTA Add-on
498
- $cta = false;
499
- $ctaData = (isset($_GET['cta'])) ? $_GET['cta'] : false;
500
- if($ctaData){
501
- $cta = true;
502
- $cta_position = (isset($ctaData['cta_position'])) ? $ctaData['cta_position'] : 'before:1';
503
- $cta_position_array = explode(":", $cta_position);
504
  $cta_pos = (string)$cta_position_array[0];
505
  $cta_val = (string)$cta_position_array[1];
506
- if($cta_pos != 'after'){
507
- $cta_pos = 'before';
508
- }
509
- $cta_repeater = (isset($ctaData['cta_repeater'])) ? $ctaData['cta_repeater'] : 'null';
510
- $cta_theme_repeater = (isset($ctaData['cta_theme_repeater'])) ? $ctaData['cta_theme_repeater'] : 'null';
511
- }
512
-
513
-
514
- // Single Post Add-on
515
- $single_post = false;
516
- $single_post_data = (isset($_GET['single_post'])) ? $_GET['single_post'] : false;
517
- if($single_post_data){
518
- $single_post = true;
519
- $single_post_id = (isset($single_post_data['id'])) ? $single_post_data['id'] : '';
520
- $single_post_slug = (isset($single_post_data['slug'])) ? $single_post_data['slug'] : '';
521
- }
522
-
523
-
524
- // SEO Add-on
525
- $seo_start_page = (isset($_GET['seo_start_page'])) ? $_GET['seo_start_page'] : 1;
526
-
527
-
528
- // Set up initial WP_Query $args
529
- $args = ALM_QUERY_ARGS::alm_build_queryargs($_GET, true);
530
- $args['paged'] = (get_query_var('paged')) ? get_query_var('paged') : 1;
531
- $args['offset'] = $offset + ($posts_per_page*$page);
532
-
533
-
534
- // Get current page number for determining item number
535
- $alm_page_count = ($page == 0) ? 1 : $page + 1;
536
-
537
-
538
- /*
539
- * alm_single_post_args
540
- *
541
- * Single Post Add-on hook
542
- * Hijack $args and and return single post only $args
543
- *
544
- * @return $args;
545
- */
546
- $args = ($single_post && has_action('alm_single_post_installed')) ? apply_filters('alm_single_post_args', $single_post_id, $postType) : $args;
547
-
548
-
549
-
550
- /*
551
- * alm_modify_query_args
552
- *
553
- * ALM Core Filter Hook
554
- *
555
- * @return $args;
556
- * Deprecated 2.10
557
- */
558
- $args = apply_filters('alm_modify_query_args', $args, $slug); // ALM Core Filter Hook
559
-
560
-
561
-
562
- /*
563
- * alm_query_args_{id}
564
- *
565
- * ALM Core Filter Hook
566
- *
567
- * @return $args;
568
- */
569
- $args = apply_filters('alm_query_args_'.$id, $args, $post_id); // ALM Core Filter Hook
570
-
571
-
572
-
573
- /*
574
- * WP_Query
575
- *
576
- * ALM Query
577
- *
578
- * @return $alm_query;
579
- */
580
-
581
- $alm_query = new WP_Query( $args );
582
-
583
-
584
- // If preloaded, update our loop count and total posts
585
- if(has_action('alm_preload_installed') && $preloaded === 'true'){
586
- $alm_total_posts = $alm_query->found_posts - $offset + $preloaded_amount;
587
- if($old_offset > 0)
588
- $alm_loop_count = $old_offset;
589
- else
590
- $alm_loop_count = $offset;
591
- }else {
592
- $alm_total_posts = $alm_query->found_posts - $offset;
593
- $alm_loop_count = 0;
594
- }
595
-
596
-
597
-
598
- /*
599
- * alm_cache_create_dir
600
- *
601
- * Cache Add-on hook
602
- * Create cache directory + meta .txt file
603
- *
604
- * @return null
605
- */
606
- if(!empty($cache_id) && has_action('alm_cache_create_dir') && $do_create_cache){
607
- apply_filters('alm_cache_create_dir', $cache_id, $canonical_url);
608
- }
609
-
610
-
611
- if($queryType === 'standard'){
612
-
613
- // Run the loop
614
-
615
- if ($alm_query->have_posts()) {
616
-
 
 
 
617
  $alm_found_posts = $alm_total_posts;
618
- $alm_post_count = $alm_query->post_count;
619
- $alm_current = 0;
620
- $alm_has_cta = false;
621
-
622
- $cta_array = Array();
623
- if($cta && has_action('alm_cta_pos_array')){ // Build CTA Position Array
624
  $cta_array = apply_filters('alm_cta_pos_array', $seo_start_page, $page, $posts_per_page, $alm_post_count, $cta_val, $paging);
625
- }
626
-
627
- ob_start();
628
-
629
- // ALM Loop
630
- while ($alm_query->have_posts()): $alm_query->the_post();
631
-
632
- $alm_loop_count++;
633
- $alm_current++; // Current item in loop
634
- $alm_page = $alm_page_count; // Get page number
635
- $alm_item = ($alm_page_count * $posts_per_page) - $posts_per_page + $alm_loop_count; // Get current item
636
-
637
-
638
- // Call to Action [Before]
639
- if($cta && has_action('alm_cta_inc') && $cta_pos === 'before' && in_array($alm_current, $cta_array)){
640
- do_action('alm_cta_inc', $cta_repeater, $cta_theme_repeater, $alm_found_posts, $alm_page, $alm_item, $alm_current, false);
641
- $alm_has_cta = true;
642
- }
643
-
644
-
645
- // Repeater Template
646
- if($theme_repeater != 'null' && has_action('alm_get_theme_repeater')){ // Theme Repeater
647
  do_action('alm_get_theme_repeater', $theme_repeater, $alm_found_posts, $alm_page, $alm_item, $alm_current);
648
  }else{
649
  include(alm_get_current_repeater( $repeater, $type )); // Repeater
650
  }
651
  // End Repeater Template
652
-
653
-
654
- // Call to Action [After]
655
- if($cta && has_action('alm_cta_inc') && $cta_pos === 'after' && in_array($alm_current, $cta_array)){
656
- do_action('alm_cta_inc', $cta_repeater, $cta_theme_repeater, $alm_found_posts, $alm_page, $alm_item, $alm_current, false);
657
- $alm_has_cta = true;
658
- }
659
-
660
-
661
- endwhile; wp_reset_query();
662
- // End ALM Loop
663
-
664
- $data = ob_get_clean();
665
-
666
-
667
- /*
668
- * alm_cache_file
669
- *
670
- * Cache Add-on hook
671
- * If Cache is enabled, check the cache file
672
- *
673
- * @param $cache_id String ID of the ALM cache
674
- * @param $do_create_cache Boolean Should cache be created for this user
675
- *
676
- * @updated 3.2.1
677
- * @return null
678
- */
679
- if(!empty($cache_id) && has_action('alm_cache_installed') && $do_create_cache){
680
- if($single_post){
681
- // Single Post Cache
682
- apply_filters('alm_previous_post_cache_file', $cache_id, $single_post_id, $data);
683
- }else{
684
- // Standard Cache
685
- apply_filters('alm_cache_file', $cache_id, $page, $seo_start_page, $data, $preloaded);
686
- }
687
- }
688
-
689
-
690
-
691
- /*
692
  * alm_debug
693
  *
694
  * ALM Core Filter Hook
695
  *
696
  * @return $alm_query/false;
697
  */
698
- $debug = (apply_filters('alm_debug', false)) ? $alm_query : false;
699
-
700
-
701
- $return = array(
702
- 'html' => $data,
703
- 'meta' => array(
704
- 'postcount' => $alm_post_count,
705
- 'totalposts' => $alm_found_posts,
706
- 'debug' => $debug
707
- )
708
- );
709
- wp_send_json($return);
710
-
711
- } else {
712
-
713
- $return = array(
714
- 'html' => null,
715
- 'meta' => array(
716
- 'postcount' => 0,
717
- 'totalposts' => 0,
718
- 'debug' => null
719
- )
720
- );
721
- wp_send_json($return);
722
-
723
- }
724
-
725
- }
726
- elseif($queryType === 'totalposts'){ // Paging add-on
727
-
728
- echo $alm_total_posts;
729
-
730
- }
731
-
732
- wp_die();
733
- }
 
 
 
 
 
 
734
 
735
  }
 
736
 
737
 
738
- /*
739
- * AjaxLoadMore
740
- * The main function responsible for returning the one true AjaxLoadMore Instance to functions everywhere.
741
- *
742
- * @since 2.0.0
743
- */
744
 
745
  function AjaxLoadMore(){
746
  global $ajax_load_more;
@@ -749,7 +777,9 @@ if( !class_exists('AjaxLoadMore') ):
749
  }
750
  return $ajax_load_more;
751
  }
752
- // initialize
753
- AjaxLoadMore();
 
 
754
 
755
  endif; // class_exists check
7
  Author: Darren Cooney
8
  Twitter: @KaptonKaos
9
  Author URI: https://connekthq.com
10
+ Version: 5.1.0.1
11
  License: GPL
12
  Copyright: Darren Cooney & Connekt Media
13
  */
14
 
15
 
16
+ define('ALM_VERSION', '5.1.0.1');
17
+ define('ALM_RELEASE', 'May 7, 2019');
18
  define('ALM_STORE_URL', 'https://connekthq.com');
19
 
20
 
103
  }
104
 
105
 
106
+
107
+
108
  if( !class_exists('AjaxLoadMore') ):
109
 
110
  class AjaxLoadMore {
115
 
116
  $this->alm_define_constants();
117
  $this->alm_includes();
118
+
119
+ add_action( 'wp_ajax_alm_get_posts', array(&$this, 'alm_query_posts') );
120
+ add_action( 'wp_ajax_nopriv_alm_get_posts', array(&$this, 'alm_query_posts') );
 
 
121
  add_action( 'wp_enqueue_scripts', array(&$this, 'alm_enqueue_scripts') );
122
  add_action( 'after_setup_theme', array(&$this, 'alm_image_sizes') );
123
  add_filter( 'alm_noscript', array(&$this, 'alm_noscript'), 10, 5 );
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
 
147
  define('ALM_NAME', '_ajax_load_more');
148
  define('ALM_TITLE', 'Ajax Load More');
149
  define('ALM_SLUG', 'ajax-load-more');
150
+ define('ALM_REST_NAMESPACE', 'ajaxloadmore');
151
 
152
  if (!defined('ALM_CACHE_ITEM_NAME')) define('ALM_CACHE_ITEM_NAME', '4878');
153
  if (!defined('ALM_CTA_ITEM_NAME')) define('ALM_CTA_ITEM_NAME', '14456');
169
 
170
 
171
 
172
+ /**
173
+ * alm_noscript
174
+ * This function will build an query for users without JS enabled
175
+ *
176
+ * @return $return string
177
+ * @since 3.7
178
+ */
179
  function alm_noscript($args, $container_element, $css_classes = '', $transition_container_classes = ''){
180
  if(is_admin()){
181
  return false;
189
 
190
 
191
 
192
+ /**
193
+ * alm_noscript_pagination
194
+ * This function will build an pagination for users without JS enabled
195
+ *
196
+ * @return $return string
197
+ * @since 3.7
198
+ */
199
  function alm_noscript_pagination($query){
200
  if(is_admin()){
201
  return false;
209
 
210
 
211
 
212
+ /**
213
+ * alm_get_repeater_base_path
214
+ * Get absolute path to repeater directory base
215
+ *
216
+ * Multisite installs directories will be `uploads/sites/{id}/alm_templates`
217
+ *
218
+ * @return $path;
219
+ * @since 3.5
220
+ */
221
  public static function alm_get_repeater_path(){
222
  $upload_dir = wp_upload_dir();
223
  $path = apply_filters( 'alm_repeater_path', $upload_dir['basedir']. '/alm_templates' );
226
 
227
 
228
 
229
+ /**
230
+ * alm_mkdir
231
+ * Create repeater template directory
232
+ *
233
+ * @since 3.5
234
+ */
235
  public static function alm_mkdir($dir){
236
 
237
  // Does $dir exist?
247
 
248
 
249
 
250
+ /**
251
+ * alm_includes
252
+ * Load these files before the theme loads
253
+ *
254
+ * @since 2.0.0
255
+ */
256
 
257
  public function alm_includes(){
258
+
259
  include_once( ALM_PATH . 'core/functions.php'); // Load Core Functions
260
+ include_once( ALM_PATH . 'core/api/get_posts.php'); // API Endpoint
261
+ include_once( ALM_PATH . 'core/api/test.php'); // API Endpoint
262
  include_once( ALM_PATH . 'core/classes/class.alm-shortcode.php'); // Load Shortcode Class
263
  include_once( ALM_PATH . 'core/classes/class.alm-enqueue.php'); // Load Enqueue Class
264
  include_once( ALM_PATH . 'core/classes/class.alm-queryargs.php'); // Load Query Args Class
273
  include( dirname( __FILE__ ) . '/vendor/EDD_SL_Plugin_Updater.php' );
274
  }
275
  }
276
+
277
  }
278
 
279
 
280
 
281
+ /**
282
+ * alm_return_addons
283
+ * Returns add-on data (admin/admin-functions.php)
284
+ *
285
+ * @since 2.0.0
286
+ */
287
 
288
  public function alm_return_addons(){
289
  return alm_get_addons();
291
 
292
 
293
 
294
+ /**
295
+ * alm_action_links
296
+ * Add plugin action links to WP plugin screen
297
+ *
298
+ * @since 2.2.3
299
+ */
300
 
301
  public function alm_action_links( $links ) {
302
  $links[] = '<a href="'. get_admin_url(null, 'admin.php?page=ajax-load-more') .'">'.__('Settings', 'ajax-load-more').'</a>';
305
 
306
 
307
 
308
+ /**
309
+ * alm_plugin_meta_links
310
+ * Add plugin meta links to WP plugin screen
311
+ *
312
+ * @since 2.7.2.1
313
+ */
314
 
315
  public function alm_plugin_meta_links( $links, $file ) {
316
  if ( strpos( $file, 'ajax-load-more.php' ) !== false ) {
325
 
326
 
327
 
328
+ /**
329
+ * alm_image_sizes
330
+ * Add default image size
331
+ *
332
+ * @since 2.8.3
333
+ */
334
 
335
  public function alm_image_sizes(){
336
  add_image_size( 'alm-thumbnail', 150, 150, true); // Custom ALM thumbnail size
338
 
339
 
340
 
341
+ /**
342
+ * alm_enqueue_scripts
343
+ * Enqueue scripts and create localized variables
344
+ *
345
+ * @since 2.0.0
346
+ */
347
 
348
  public function alm_enqueue_scripts(){
349
 
382
  }
383
 
384
  // Prevent loading of unnessasry posts - move user to top of page
 
385
  $scrolltop = (!isset($options['_alm_scroll_top']) || $options['_alm_scroll_top'] != '1') ? 'false' : 'true';
386
 
387
+
388
+ // Use REST API
389
+ $use_restapi = function_exists('get_rest_url') ? true : false; // Is REST API enabled
390
+ if($use_restapi){
391
+ if(isset($options['_alm_use_rest_api']) && $options['_alm_use_rest_api'] == '1'){ // Disable REST API setting checked
392
+ $use_restapi = false;
393
+ }
394
+ }
395
+
396
+
397
+ // Localized JS variables
398
  wp_localize_script(
399
  'ajax-load-more',
400
  'alm_localize',
401
  array(
402
+ 'ajaxurl' => admin_url('admin-ajax.php'),
403
+ 'restapi' => array(
404
+ 'active' => false,
405
+ 'url' => function_exists('get_rest_url') ? get_rest_url() : '',
406
+ 'namespace' => ALM_REST_NAMESPACE
407
+ ),
408
  'alm_nonce' => wp_create_nonce( "ajax_load_more_nonce" ),
409
  'pluginurl' => ALM_URL,
410
  'scrolltop' => $scrolltop,
411
+ 'speed' => apply_filters('alm_speed', 250),
412
+ 'results_text' => apply_filters('alm_display_results', __('Displaying page {num} of {total}.', 'ajax-load-more')),
413
+ 'no_results_text' => apply_filters('alm_no_results_text', __('No results found.', 'ajax-load-more'))
414
  )
415
  );
416
+
417
  }
418
 
419
 
420
 
421
+ /**
422
+ * alm_shortcode
423
+ * The AjaxLoadMore shortcode
424
+ *
425
+ * @since 2.0.0
426
+ * @updated 3.2.0
427
+ */
428
  public function alm_shortcode($atts) {
429
  self::$shortcode_atts = $atts;
430
  return ALM_SHORTCODE::alm_render_shortcode($atts);
432
 
433
 
434
 
435
+ /**
436
+ * alm_return_shortcode_atts
437
+ * Return the ALM shortcode atts
438
+ *
439
+ * @since 3.2.0
440
+ */
441
  public static function alm_return_shortcode_atts(){
442
  return self::$shortcode_atts;
443
  }
444
+
445
+
446
+
447
+ /**
448
+ * alm_query_posts
449
+ * Ajax Load More Query - Legacy admin-ajax usage
450
+ *
451
+ * @since 2.0.0
452
+ */
453
+ public function alm_query_posts() {
454
+
 
455
  // WPML fix for category/tag/taxonomy archives
456
  if ( (isset( $_GET['category'] ) && $_GET['category']) || (isset($_GET['taxonomy']) && $_GET['taxonomy']) ) {
457
  unset($_REQUEST['post_id']);
458
  }
459
+
460
+ $id = (isset($_GET['id'])) ? $_GET['id'] : '';
461
+ $post_id = (isset($_GET['post_id'])) ? $_GET['post_id'] : '';
462
+ $slug = (isset($_GET['slug'])) ? $_GET['slug'] : '';
463
+ $canonical_url = (isset($_GET['canonical_url'])) ? $_GET['canonical_url'] : $_SERVER['HTTP_REFERER'];
464
+
465
+
466
  // Ajax Query Type
467
+ $queryType = (isset($_GET['query_type'])) ? $_GET['query_type'] : 'standard'; // 'standard' or 'totalposts'; totalposts returns $alm_found_posts
468
+
469
+
470
  // Cache
471
+ $cache_id = (isset($_GET['cache_id'])) ? $_GET['cache_id'] : '';
472
+ $cache_logged_in = (isset($_GET['cache_logged_in'])) ? $_GET['cache_logged_in'] : false;
473
+ $do_create_cache = ($cache_logged_in === 'true' && is_user_logged_in()) ? false : true;
474
+
475
+
476
+ // Offset
477
+ $offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0;
478
+
479
+
480
  // Repeater Templates
481
+ $repeater = (isset($_GET['repeater'])) ? $_GET['repeater'] : 'default';
482
+ $type = alm_get_repeater_type($repeater);
483
+ $theme_repeater = (isset($_GET['theme_repeater'])) ? $_GET['theme_repeater'] : 'null';
484
+
485
+
486
  // Post Type
487
+ $postType = (isset($_GET['post_type'])) ? $_GET['post_type'] : 'post';
488
+
489
+
490
+ // Page Parameters
491
+ $posts_per_page = (isset($_GET['posts_per_page'])) ? $_GET['posts_per_page'] : 5;
492
+ $page = (isset($_GET['page'])) ? $_GET['page'] : 0;
493
+
494
+
495
+ // Advanced Custom Fields
496
+ $acfData = (isset($_GET['acf'])) ? $_GET['acf'] : false;
497
+ if($acfData){
498
+ $acf = (isset($acfData['acf'])) ? $acfData['acf'] : false; // true / false
499
+ $acf_post_id = (isset($acfData['post_id'])) ? $acfData['post_id'] : ''; // Post ID
500
+ $acf_field_type = (isset($acfData['field_type'])) ? $acfData['field_type'] : ''; // ACF Field Type
501
+ $acf_field_name = (isset($acfData['field_name'])) ? $acfData['field_name'] : ''; // ACF Field Type
502
+ }
503
+
504
+
505
+ // Paging Add-on
506
+ $paging = (isset($_GET['paging'])) ? $_GET['paging'] : 'false';
507
+
508
+
509
+ // Preload Add-on
510
+ $preloaded = (isset($_GET['preloaded'])) ? $_GET['preloaded'] : 'false';
511
+ $preloaded_amount = (isset($_GET['preloaded_amount'])) ? $_GET['preloaded_amount'] : '5';
512
+ if(has_action('alm_preload_installed') && $preloaded === 'true'){
513
+ // If preload - offset the ajax posts by posts_per_page + preload_amount val
514
+ $old_offset = $preloaded_amount;
515
+ $offset = $offset + $preloaded_amount;
516
+ }
517
+
518
+
519
+ // CTA Add-on
520
+ $cta = false;
521
+ $ctaData = (isset($_GET['cta'])) ? $_GET['cta'] : false;
522
+ if($ctaData){
523
+ $cta = true;
524
+ $cta_position = (isset($ctaData['cta_position'])) ? $ctaData['cta_position'] : 'before:1';
525
+ $cta_position_array = explode(":", $cta_position);
526
  $cta_pos = (string)$cta_position_array[0];
527
  $cta_val = (string)$cta_position_array[1];
528
+ $cta_pos = ($cta_pos != 'after') ? 'before' : $cta_pos;
529
+ $cta_repeater = (isset($ctaData['cta_repeater'])) ? $ctaData['cta_repeater'] : 'null';
530
+ $cta_theme_repeater = (isset($ctaData['cta_theme_repeater'])) ? $ctaData['cta_theme_repeater'] : 'null';
531
+ }
532
+
533
+
534
+ // Single Post Add-on
535
+ $single_post = false;
536
+ $single_post_data = (isset($_GET['single_post'])) ? $_GET['single_post'] : false;
537
+ if($single_post_data){
538
+ $single_post = true;
539
+ $single_post_id = (isset($single_post_data['id'])) ? $single_post_data['id'] : '';
540
+ $single_post_slug = (isset($single_post_data['slug'])) ? $single_post_data['slug'] : '';
541
+ }
542
+
543
+
544
+ // SEO Add-on
545
+ $seo_start_page = (isset($_GET['seo_start_page'])) ? $_GET['seo_start_page'] : 1;
546
+
547
+
548
+ // Set up initial WP_Query $args
549
+ $args = ALM_QUERY_ARGS::alm_build_queryargs($_GET, true);
550
+ $args['paged'] = (get_query_var('paged')) ? get_query_var('paged') : 1;
551
+ $args['offset'] = $offset + ($posts_per_page*$page);
552
+
553
+
554
+ // Get current page number for determining item number
555
+ $alm_page_count = ($page == 0) ? 1 : $page + 1;
556
+
557
+
558
+ /*
559
+ * alm_single_post_args
560
+ *
561
+ * Single Post Add-on hook
562
+ * Hijack $args and and return single post only $args
563
+ *
564
+ * @return $args;
565
+ */
566
+ $args = ($single_post && has_action('alm_single_post_installed')) ? apply_filters('alm_single_post_args', $single_post_id, $postType) : $args;
567
+
568
+
569
+
570
+ /*
571
+ * alm_modify_query_args
572
+ *
573
+ * ALM Core Filter Hook
574
+ *
575
+ * @return $args;
576
+ * Deprecated 2.10
577
+ */
578
+ $args = apply_filters('alm_modify_query_args', $args, $slug); // ALM Core Filter Hook
579
+
580
+
581
+
582
+ /*
583
+ * alm_query_args_{id}
584
+ *
585
+ * ALM Core Filter Hook
586
+ *
587
+ * @return $args;
588
+ */
589
+ $args = apply_filters('alm_query_args_'.$id, $args, $post_id); // ALM Core Filter Hook
590
+
591
+
592
+
593
+ /*
594
+ * Set custom `alm_action` parameter in the WP_Query
595
+ * Value is accessed elsewhere for filters & hooks etc.
596
+ */
597
+ $args['alm_query'] = ($single_post) ? 'single_posts' : 'alm';
598
+
599
+
600
+
601
+ /*
602
+ * WP_Query || ALM Query
603
+ *
604
+ * @return $alm_query;
605
+ */
606
+ $alm_query = new WP_Query( $args );
607
+
608
+
609
+ // If preloaded, update our loop count and total posts
610
+ if(has_action('alm_preload_installed') && $preloaded === 'true'){
611
+ $alm_total_posts = $alm_query->found_posts - $offset + $preloaded_amount;
612
+ if($old_offset > 0)
613
+ $alm_loop_count = $old_offset;
614
+ else
615
+ $alm_loop_count = $offset;
616
+ }else {
617
+ $alm_total_posts = $alm_query->found_posts - $offset;
618
+ $alm_loop_count = 0;
619
+ }
620
+
621
+
622
+
623
+ /*
624
+ * alm_cache_create_dir
625
+ *
626
+ * Cache Add-on hook
627
+ * Create cache directory + meta .txt file
628
+ *
629
+ * @return null
630
+ */
631
+ if(!empty($cache_id) && has_action('alm_cache_create_dir') && $do_create_cache){
632
+ apply_filters('alm_cache_create_dir', $cache_id, $canonical_url);
633
+ }
634
+
635
+
636
+ if($queryType === 'standard'){
637
+
638
+ // Run the loop
639
+
640
+ if ($alm_query->have_posts()) {
641
+
642
  $alm_found_posts = $alm_total_posts;
643
+ $alm_post_count = $alm_query->post_count;
644
+ $alm_current = 0;
645
+ $alm_has_cta = false;
646
+
647
+ $cta_array = Array();
648
+ if($cta && has_action('alm_cta_pos_array')){ // Build CTA Position Array
649
  $cta_array = apply_filters('alm_cta_pos_array', $seo_start_page, $page, $posts_per_page, $alm_post_count, $cta_val, $paging);
650
+ }
651
+
652
+ ob_start();
653
+
654
+ // ALM Loop
655
+ while ($alm_query->have_posts()): $alm_query->the_post();
656
+
657
+ $alm_loop_count++;
658
+ $alm_current++; // Current item in loop
659
+ $alm_page = $alm_page_count; // Get page number
660
+ $alm_item = ($alm_page_count * $posts_per_page) - $posts_per_page + $alm_loop_count; // Get current item
661
+
662
+ // Call to Action [Before]
663
+ if($cta && has_action('alm_cta_inc') && $cta_pos === 'before' && in_array($alm_current, $cta_array)){
664
+ do_action('alm_cta_inc', $cta_repeater, $cta_theme_repeater, $alm_found_posts, $alm_page, $alm_item, $alm_current, false);
665
+ $alm_has_cta = true;
666
+ }
667
+
668
+ // Repeater Template
669
+ if($theme_repeater != 'null' && has_action('alm_get_theme_repeater')){ // Theme Repeater
 
 
670
  do_action('alm_get_theme_repeater', $theme_repeater, $alm_found_posts, $alm_page, $alm_item, $alm_current);
671
  }else{
672
  include(alm_get_current_repeater( $repeater, $type )); // Repeater
673
  }
674
  // End Repeater Template
675
+
676
+ // Call to Action [After]
677
+ if($cta && has_action('alm_cta_inc') && $cta_pos === 'after' && in_array($alm_current, $cta_array)){
678
+ do_action('alm_cta_inc', $cta_repeater, $cta_theme_repeater, $alm_found_posts, $alm_page, $alm_item, $alm_current, false);
679
+ $alm_has_cta = true;
680
+ }
681
+
682
+ endwhile; wp_reset_query();
683
+ // End ALM Loop
684
+
685
+ $data = ob_get_clean();
686
+
687
+
688
+ /*
689
+ * alm_cache_file
690
+ *
691
+ * Cache Add-on hook
692
+ * If Cache is enabled, check the cache file
693
+ *
694
+ * @param $cache_id String ID of the ALM cache
695
+ * @param $do_create_cache Boolean Should cache be created for this user
696
+ *
697
+ * @updated 3.2.1
698
+ * @return null
699
+ */
700
+ if(!empty($cache_id) && has_action('alm_cache_installed') && $do_create_cache){
701
+ if($single_post){
702
+ // Single Post Cache
703
+ apply_filters('alm_previous_post_cache_file', $cache_id, $single_post_id, $data);
704
+ }else{
705
+ // Standard Cache
706
+ apply_filters('alm_cache_file', $cache_id, $page, $seo_start_page, $data, $preloaded);
707
+ }
708
+ }
709
+
710
+
711
+
712
+ /*
 
 
713
  * alm_debug
714
  *
715
  * ALM Core Filter Hook
716
  *
717
  * @return $alm_query/false;
718
  */
719
+ $debug = (apply_filters('alm_debug', false)) ? $alm_query : false;
720
+
721
+
722
+ $return = array(
723
+ 'html' => $data,
724
+ 'meta' => array(
725
+ 'postcount' => $alm_post_count,
726
+ 'totalposts' => $alm_found_posts,
727
+ 'debug' => $debug
728
+ )
729
+ );
730
+ wp_send_json($return);
731
+
732
+ } else {
733
+
734
+ $return = array(
735
+ 'html' => null,
736
+ 'meta' => array(
737
+ 'postcount' => 0,
738
+ 'totalposts' => 0,
739
+ 'debug' => null
740
+ )
741
+ );
742
+
743
+ wp_send_json($return);
744
+
745
+ }
746
+
747
+ }
748
+
749
+ elseif($queryType === 'totalposts'){ // Paging add-on
750
+
751
+ // Paging add-on
752
+ wp_send_json(array(
753
+ 'totalposts' => $alm_total_posts
754
+ ));
755
+
756
+ }
757
+
758
+ wp_die();
759
+
760
+ }
761
 
762
  }
763
+
764
 
765
 
766
+ /**
767
+ * AjaxLoadMore
768
+ * The main function responsible for returning the one true AjaxLoadMore instance.
769
+ *
770
+ * @since 2.0.0
771
+ */
772
 
773
  function AjaxLoadMore(){
774
  global $ajax_load_more;
777
  }
778
  return $ajax_load_more;
779
  }
780
+
781
+ AjaxLoadMore(); // initialize
782
+
783
+
784
 
785
  endif; // class_exists check
core/api/get_posts.php ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Register REST API Route
4
+ add_action( 'rest_api_init', function () {
5
+ $namespace = ALM_REST_NAMESPACE;
6
+ $endpoint = '/get_posts';
7
+ register_rest_route( $namespace, $endpoint,
8
+ array(
9
+ 'methods' => 'GET',
10
+ 'callback' => 'alm_get_posts_query',
11
+ )
12
+ );
13
+ });
14
+
15
+
16
+
17
+ /**
18
+ * alm_get_posts_query
19
+ * Main Ajax Load More Query
20
+ *
21
+ * @param $req $_GET
22
+ * @since 5.1
23
+ * @return JSON
24
+ */
25
+ function alm_get_posts_query( WP_REST_Request $req ) {
26
+
27
+ if(!isset($req)){ return false; }
28
+
29
+ error_reporting(E_ALL|E_STRICT);
30
+
31
+ // WPML fix for category/tag/taxonomy archives
32
+ if ( (isset( $req['category'] ) && $req['category']) || (isset($req['taxonomy']) && $req['taxonomy']) ) {
33
+ unset($_REQUEST['post_id']);
34
+ }
35
+
36
+ $id = (isset($req['id'])) ? $req['id'] : '';
37
+ $post_id = (isset($req['post_id'])) ? $req['post_id'] : '';
38
+ $slug = (isset($req['slug'])) ? $req['slug'] : '';
39
+ $canonical_url = (isset($req['canonical_url'])) ? $req['canonical_url'] : $_SERVER['HTTP_REFERER'];
40
+
41
+
42
+ // Ajax Query Type
43
+ $queryType = (isset($req['query_type'])) ? $req['query_type'] : 'standard'; // 'standard' or 'totalposts'; totalposts returns $alm_found_posts
44
+
45
+
46
+ // Cache
47
+ $cache_id = (isset($req['cache_id'])) ? $req['cache_id'] : '';
48
+ $cache_logged_in = (isset($req['cache_logged_in'])) ? $req['cache_logged_in'] : false;
49
+ $do_create_cache = ($cache_logged_in === 'true' && is_user_logged_in()) ? false : true;
50
+
51
+
52
+ // Offset
53
+ $offset = (isset($req['offset'])) ? $req['offset'] : 0;
54
+
55
+
56
+ // Repeater Templates
57
+ $repeater = (isset($req['repeater'])) ? $req['repeater'] : 'default';
58
+ $type = alm_get_repeater_type($repeater);
59
+ $theme_repeater = (isset($req['theme_repeater'])) ? $req['theme_repeater'] : 'null';
60
+
61
+
62
+ // Post Type
63
+ $postType = (isset($req['post_type'])) ? $req['post_type'] : 'post';
64
+
65
+
66
+ // Page Parameters
67
+ $posts_per_page = (isset($req['posts_per_page'])) ? $req['posts_per_page'] : 5;
68
+ $page = (isset($req['page'])) ? $req['page'] : 0;
69
+
70
+
71
+ // Advanced Custom Fields
72
+ $acfData = (isset($req['acf'])) ? $req['acf'] : false;
73
+ if($acfData){
74
+ $acf = (isset($acfData['acf'])) ? $acfData['acf'] : false; // true / false
75
+ $acf_post_id = (isset($acfData['post_id'])) ? $acfData['post_id'] : ''; // Post ID
76
+ $acf_field_type = (isset($acfData['field_type'])) ? $acfData['field_type'] : ''; // ACF Field Type
77
+ $acf_field_name = (isset($acfData['field_name'])) ? $acfData['field_name'] : ''; // ACF Field Type
78
+ }
79
+
80
+
81
+ // Paging Add-on
82
+ $paging = (isset($req['paging'])) ? $req['paging'] : 'false';
83
+
84
+
85
+ // Preload Add-on
86
+ $preloaded = (isset($req['preloaded'])) ? $req['preloaded'] : 'false';
87
+ $preloaded_amount = (isset($req['preloaded_amount'])) ? $req['preloaded_amount'] : '5';
88
+ if(has_action('alm_preload_installed') && $preloaded === 'true'){
89
+ // If preload - offset the ajax posts by posts_per_page + preload_amount val
90
+ $old_offset = $preloaded_amount;
91
+ $offset = $offset + $preloaded_amount;
92
+ }
93
+
94
+
95
+ // CTA Add-on
96
+ $cta = false;
97
+ $ctaData = (isset($req['cta'])) ? $req['cta'] : false;
98
+ if($ctaData){
99
+ $cta = true;
100
+ $cta_position = (isset($ctaData['cta_position'])) ? $ctaData['cta_position'] : 'before:1';
101
+ $cta_position_array = explode(":", $cta_position);
102
+ $cta_pos = (string)$cta_position_array[0];
103
+ $cta_val = (string)$cta_position_array[1];
104
+ $cta_pos = ($cta_pos != 'after') ? 'before' : $cta_pos;
105
+ $cta_repeater = (isset($ctaData['cta_repeater'])) ? $ctaData['cta_repeater'] : 'null';
106
+ $cta_theme_repeater = (isset($ctaData['cta_theme_repeater'])) ? $ctaData['cta_theme_repeater'] : 'null';
107
+ }
108
+
109
+
110
+ // Single Post Add-on
111
+ $single_post = false;
112
+ $single_post_data = (isset($req['single_post'])) ? $req['single_post'] : false;
113
+ if($single_post_data){
114
+ $single_post = true;
115
+ $single_post_id = (isset($single_post_data['id'])) ? $single_post_data['id'] : '';
116
+ $single_post_slug = (isset($single_post_data['slug'])) ? $single_post_data['slug'] : '';
117
+ }
118
+
119
+
120
+ // SEO Add-on
121
+ $seo_start_page = (isset($req['seo_start_page'])) ? $req['seo_start_page'] : 1;
122
+
123
+
124
+ // Set up initial WP_Query $args
125
+ $args = ALM_QUERY_ARGS::alm_build_queryargs($req, true);
126
+ $args['paged'] = (get_query_var('paged')) ? get_query_var('paged') : 1;
127
+ $args['offset'] = $offset + ($posts_per_page*$page);
128
+
129
+
130
+ // Get current page number for determining item number
131
+ $alm_page_count = ($page == 0) ? 1 : $page + 1;
132
+
133
+
134
+ /*
135
+ * alm_single_post_args
136
+ *
137
+ * Single Post Add-on hook
138
+ * Hijack $args and and return single post only $args
139
+ *
140
+ * @return $args;
141
+ */
142
+ $args = ($single_post && has_action('alm_single_post_installed')) ? apply_filters('alm_single_post_args', $single_post_id, $postType) : $args;
143
+
144
+
145
+
146
+ /*
147
+ * alm_modify_query_args
148
+ *
149
+ * ALM Core Filter Hook
150
+ *
151
+ * @return $args;
152
+ * Deprecated 2.10
153
+ */
154
+ $args = apply_filters('alm_modify_query_args', $args, $slug); // ALM Core Filter Hook
155
+
156
+
157
+
158
+ /*
159
+ * alm_query_args_{id}
160
+ *
161
+ * ALM Core Filter Hook
162
+ *
163
+ * @return $args;
164
+ */
165
+ $args = apply_filters('alm_query_args_'.$id, $args, $post_id); // ALM Core Filter Hook
166
+
167
+
168
+
<