diff --git a/.gitignore b/.gitignore index 619782f..3df10d1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ npm-shrinkwrap.json *.map _out /vendor +.nvmrc.old + diff --git a/.nvmrc b/.nvmrc index 063dbc8..8351c19 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -10.20.1 +14 diff --git a/README.txt b/README.txt index 2ced776..2f846d3 100755 --- a/README.txt +++ b/README.txt @@ -5,7 +5,7 @@ Tags: infinite scroll, load more, ajax, lazy load, endless scroll, infinite scro Requires at least: 4.4 Requires PHP: 5.6 Tested up to: 6.1 -Stable tag: 5.5.5 +Stable tag: 5.6.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -128,7 +128,6 @@ The following [add-ons](https://connekthq.com/plugins/ajax-load-more/add-ons/) a - **[SEO](https://connekthq.com/plugins/ajax-load-more/add-ons/search-engine-optimization/)**: Generate unique paging URLs with each Ajax Load More query. - **[Single Post](https://connekthq.com/plugins/ajax-load-more/add-ons/single-post/)**: Enable infinite scrolling of single posts on your WordPress post templates. - **[Theme Repeaters](https://connekthq.com/plugins/ajax-load-more/add-ons/theme-repeaters/)**: Manage Ajax Load More repeater templates from within your current theme directory. -- **[Users](https://connekthq.com/plugins/ajax-load-more/add-ons/users/)**: Lazy loading WordPress Users with Ajax Load More. - **[WooCommerce](https://connekthq.com/plugins/ajax-load-more/add-ons/woocommerce/)**: Infinite scroll WooCommerce products with Ajax Load More. ### Extensions @@ -139,7 +138,8 @@ The following free [extensions](https://connekthq.com/plugins/ajax-load-more/ext - **[Relevanssi](https://connekthq.com/plugins/ajax-load-more/extensions/relevanssi/)**: Display Relevanssi search results with Ajax Load More. - **[REST API](https://connekthq.com/plugins/ajax-load-more/extensions/rest-api/)**: Enable compatibility with the WordPress REST API. - **[SearchWP](https://connekthq.com/plugins/ajax-load-more/extensions/searchwp/)**: Display SearchWP query results with Ajax Load More. -- **[Term Query](https://wordpress.org/plugins/ajax-load-more-for-terms/)**: Infinite scroll WordPress Terms. +- **[Term Query](https://connekthq.com/plugins/ajax-load-more/extensions/terms/)**: Infinite scroll WordPress Terms. +- **[Users](https://connekthq.com/plugins/ajax-load-more/extensions/users/)**: Lazy loading WordPress Users with Ajax Load More. ### Callback Functions @@ -263,6 +263,17 @@ How to install Ajax Load More. == Changelog == += 5.6.0 - February 14, 2023 = +* NEW: Added new ajaxloadmore.click() public JS function to manually trigger an Ajax Load More load action from any element on the screen. +* NEW: Added support for new Filter facets in Filters add-on version 2.0. +* NEW: Added alm JavaScript object to the global `window` object so accessing config params can be done in browser. e.g. `window.ajax_load_more` +* NEW: Added support for `include_children` when running a taxonomy query. +* FIX: Fixed issue with localized data variables not working in Full Site Editing (FSE) themes. +* FIX: Fixed deprecation notice in Elementor widgetregistration +* UPDATE: Security fix for escaping data attributes in shortcode. +* UPDATE: Code cleanup. + + = 5.5.5 - January 5, 2013 = * UPDATE: Removed requirement of `transition_container` to be present when using Preloaded. * UPDATE: Various updates required for the new 2.0 Layouts add-on release. diff --git a/admin/admin.php b/admin/admin.php index aeacfc4..166a31d 100755 --- a/admin/admin.php +++ b/admin/admin.php @@ -444,7 +444,9 @@ function alm_cache_page() { * @since 3.4.0 */ function alm_filters_page() { - include_once ALM_FILTERS_PATH . 'admin/functions.php'; + if ( ! function_exists( 'alm_list_all_filters' ) ) { + include_once ALM_FILTERS_PATH . 'admin/functions.php'; // Deprecated: This is loaded in Filters add-on. + } include_once ALM_FILTERS_PATH . 'admin/views/filters.php'; } diff --git a/admin/dist/js/admin.js b/admin/dist/js/admin.js index 55c3ad8..e418325 100644 --- a/admin/dist/js/admin.js +++ b/admin/dist/js/admin.js @@ -1406,9 +1406,8 @@ jQuery(document).ready(function ($) { * @since 5.1 */ document.addEventListener('keydown', function (e) { - if ((window.navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey) && e.keyCode == 83) { + if ((window.navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey) && e.keyCode === 83) { if (e.target.nodeName === 'TEXTAREA' && $(e.target).closest('.repeater-wrap')) { - console.log('Saving template...'); var btn = $(e.target).closest('.repeater-wrap').find('input.save-repeater'); if (btn) { btn.click(); diff --git a/admin/shortcode-builder/components/filters.php b/admin/shortcode-builder/components/filters.php index 5308753..816221c 100755 --- a/admin/shortcode-builder/components/filters.php +++ b/admin/shortcode-builder/components/filters.php @@ -1,195 +1,200 @@ - +
-

-
- -
-
-

-
-
-
-
    -
  • - - -
  • -
  • - - -
  • -
-
-
-
- -
-
-
-
-

-

filter instance by selecting the filter ID.', 'ajax-load-more'); ?>

-
-
-
- '. $value .''; - } - } - if($count > 0){ - echo ''; - } else { ?> -

!

- -
-
-
-
-
-

-


e.g. ?category=design&tag=mobile

-
-
-
-
    -
  • - - -
  • -
  • - - -
  • -
-
-
-
- -
-
-

-

?pg={x} to the browser querystring as users load additional pages.', 'ajax-load-more'); ?>

-
-
-
-
    -
  • - - -
  • -
  • - - -
  • -
-
-
-
- -
-
-

-

-
-
-
-
    -
  • - - -
  • -
  • - - -
  • -
-
-
-
- +

+
+ +
+
+

+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
+
+
+
+ +
+
+
+
+

+

filter instance by selecting the filter ID.', 'ajax-load-more' ); ?>

+
+
+
+ ' . $value . ''; + } + } + if ( $count > 0 ) { + echo ''; + } else { + ?> +

!

+ +
+
+
+ +
+
+

+


e.g. ?category=design&tag=mobile

+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
+
+
+
+ +
+
+

+

?pg={x} to the browser querystring as users load additional pages.', 'ajax-load-more' ) ); ?>

+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
+
+
+
+ +
+
+

+

+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
+
+
+
+ - -
-
-

-

-
-
-
-
    -
  • - - -
  • -
  • - - -
  • -
-
-
+ +
+
+

+

+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
+
+
- -
-
-

-

-
-
-
-
    -
  • - - -
  • -
  • - - -
  • -
-
-
-
-
- -
-
+
+
+

+

+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
+
+
+
+
+
+
- \ No newline at end of file + diff --git a/admin/shortcode-builder/includes/tax-query-options.php b/admin/shortcode-builder/includes/tax-query-options.php index 159cb33..02d440f 100755 --- a/admin/shortcode-builder/includes/tax-query-options.php +++ b/admin/shortcode-builder/includes/tax-query-options.php @@ -1,82 +1,78 @@ - -
- + + + +
+ - + + + + + +
- +
- +
- -
    -
  • - + +
      +
    • + -
    • +
    • -
    • - - -
    • -
    • - - -
    • -
    • - - -
    • -
    +
- +
-
-
- - -
-
+
+
+ + +
+
- -
- + +
+ × - + + + + + +
- +
- +
- -
    -
  • - + +
      +
    • + -
    • +
    • @@ -93,33 +89,33 @@
    • -
    -
+ +
- -
- + +
+ × - + + + + + +
- +
- +
- -
    -
  • - + +
      +
    • + -
    • +
    • @@ -136,8 +132,8 @@
    • -
    -
+ +
-
\ No newline at end of file +
diff --git a/admin/shortcode-builder/js/shortcode-builder.js b/admin/shortcode-builder/js/shortcode-builder.js index e392a16..3f40e9d 100755 --- a/admin/shortcode-builder/js/shortcode-builder.js +++ b/admin/shortcode-builder/js/shortcode-builder.js @@ -1,4 +1,4 @@ -jQuery(document).ready(function($) { +jQuery(document).ready(function ($) { ('use strict'); var _alm = {}, @@ -13,25 +13,21 @@ jQuery(document).ready(function($) { * * @since 2.5.0 */ - _alm.select2 = function() { + _alm.select2 = function () { // Default Select2 - $('.row select, .cnkt-main select, select.jump-menu') - .not('.multiple, .meta-compare, .meta-type, .alm-filter-select') - .select2({}); + $('.row select, .cnkt-main select, select.jump-menu').not('.multiple, .meta-compare, .meta-type, .alm-filter-select').select2({}); // Set placeholder $('.ajax-load-more select.multiple').select2({ - placeholder: '-- ' + alm_admin_localize.select + ' --' + placeholder: '-- ' + alm_admin_localize.select + ' --', }); }; _alm.select2(); // Reset all selects - _alm.reset_select2 = function() { + _alm.reset_select2 = function () { // Default Select2 - $('.row select, .cnkt-main select, select.jump-menu') - .not('.multiple') - .select2(); + $('.row select, .cnkt-main select, select.jump-menu').not('.multiple').select2(); // multiple $('.ajax-load-more .categories select.multiple').select2(); @@ -44,7 +40,7 @@ jQuery(document).ready(function($) { // Taxonomy Query var total_tax_query = 0, max_tax_query = 2; - $('#add-tax-query').on('click', function(e) { + $('#add-tax-query').on('click', function (e) { e.preventDefault(); if (total_tax_query < 2) { @@ -65,16 +61,14 @@ jQuery(document).ready(function($) { }); /* Delete Tax Query */ - $(document).on('click', '.remove-tax-query', function(e) { + $(document).on('click', '.remove-tax-query', function (e) { var el = $(this), parent = el.parent('.taxonomy-wrap'); - $('select', parent) - .select2('val', '') - .trigger('change'); + $('select', parent).select2('val', '').trigger('change'); total_tax_query--; parent.addClass('removing'); - parent.fadeOut(250, function() { + parent.fadeOut(250, function () { _alm.buildShortcode(); parent.removeClass('removing'); }); @@ -90,12 +84,10 @@ jQuery(document).ready(function($) { }); // Add additional meta_query - var meta_query_obj = $('.meta-query-wrap') - .eq(0) - .clone(); + var meta_query_obj = $('.meta-query-wrap').eq(0).clone(); $('.meta-query-wrap .remove').remove(); $('select.meta-compare, select.meta-type').select2(); - $('#add-meta-query').on('click', function(e) { + $('#add-meta-query').on('click', function (e) { e.preventDefault(); if ($('.meta-query-wrap').length > 3) { @@ -125,10 +117,10 @@ jQuery(document).ready(function($) { }); /* Delete Meta Query */ - $(document).on('click', '.remove-meta-query', function(e) { + $(document).on('click', '.remove-meta-query', function (e) { var el = $(this); el.parent('.meta-query-wrap').addClass('removing'); - el.parent('.meta-query-wrap').fadeOut(250, function() { + el.parent('.meta-query-wrap').fadeOut(250, function () { el.parent('.meta-query-wrap').remove(); _alm.buildShortcode(); }); @@ -145,7 +137,7 @@ jQuery(document).ready(function($) { * @since 1.0 */ - _alm.buildShortcode = function() { + _alm.buildShortcode = function () { output = '[ajax_load_more'; // --------------------------- @@ -161,9 +153,7 @@ jQuery(document).ready(function($) { var loading_style = $('select#loading-style').val(); var loading_style_default = $('select#loading-style').data('default'); - var loading_style_target = $('select#loading-style') - .parent() - .find('.ajax-load-more-wrap'); + var loading_style_target = $('select#loading-style').parent().find('.ajax-load-more-wrap'); if (loading_style_target) { var loading_style_base = loading_style_target.data('base'); loading_style_target.removeAttr('class'); @@ -288,9 +278,7 @@ jQuery(document).ready(function($) { comments_per_page = $('#comments-per-page').val(), comments_type = $('#comments_type').val(), comments_template = $('#comments_template').val(), - comments_callback = $('#comments_callback') - .val() - .trim(), + comments_callback = $('#comments_callback').val().trim(), comments_style = $('#alm-comments input[name=alm_comment_style]:checked').val(); if (comments_callback !== '') { @@ -332,38 +320,33 @@ jQuery(document).ready(function($) { output += ' filters="' + filters + '"'; - var filters_url = $('#alm-filters input[name=filters-url]:checked') - .val() - .trim(); - if (filters_url !== '' && filters_url !== 'true') output += ' filters_url="' + filters_url + '"'; + var filters_url = $('#alm-filters input[name=filters-url]:checked').val().trim(); + if (filters_url !== '' && filters_url !== 'true') { + output += ' filters_url="' + filters_url + '"'; + } - var filters_paging = $('#alm-filters input[name=filters-paging]:checked') - .val() - .trim(); - if (filters_paging !== '' && filters_paging !== 'true') output += ' filters_paging="' + filters_paging + '"'; + var filters_paging = $('#alm-filters input[name=filters-paging]:checked').val().trim(); + if (filters_paging !== '' && filters_paging !== 'true') { + output += ' filters_paging="' + filters_paging + '"'; + } - var filters_scroll = $('#alm-filters input[name=filters-scroll]:checked') - .val() - .trim(); - if (filters_scroll !== '' && filters_scroll !== 'false') output += ' filters_scroll="' + filters_paging + '"'; + var filters_scroll = $('#alm-filters input[name=filters-scroll]:checked').val().trim(); + if (filters_scroll !== '' && filters_scroll !== 'false') { + output += ' filters_scroll="' + filters_paging + '"'; + } if (filters_paging === 'true' || filters_scroll === 'true') { $('#filter-scrollTopOptions').slideDown(250, 'alm_easeInOutQuad'); - var filters_scrolltop = $('#alm-filters input[name=filters-scrolltop]').val(); if (filters_scrolltop !== '30') output += ' filters_scrolltop="' + filters_scrolltop + '"'; } else { $('#filter-scrollTopOptions').slideUp(250, 'alm_easeInOutQuad'); } - var filters_analytics = $('#alm-filters input[name=filters-analytics]:checked') - .val() - .trim(); + var filters_analytics = $('#alm-filters input[name=filters-analytics]:checked').val().trim(); if (filters_analytics !== '' && filters_analytics !== 'true') output += ' filters_analytics="' + filters_analytics + '"'; - var filters_debug = $('#alm-filters input[name=filters-debug]:checked') - .val() - .trim(); + var filters_debug = $('#alm-filters input[name=filters-debug]:checked').val().trim(); if (filters_debug !== '' && filters_debug !== 'false') output += ' filters_debug="' + filters_debug + '"'; } else { $('.filters_options').slideUp(250, 'alm_easeInOutQuad'); @@ -493,21 +476,11 @@ jQuery(document).ready(function($) { $('.restapi_options').slideDown(250, 'alm_easeInOutQuad'); output += ' restapi="' + rest + '"'; - var restapi_base = $('#alm-rest input#rest-base') - .val() - .trim(), - restapi_namespace = $('#alm-rest input#rest-namespace') - .val() - .trim(), - restapi_endpoint = $('#alm-rest input#rest-endpoint') - .val() - .trim(), - restapi_template_id = $('#alm-rest input#rest-template-id') - .val() - .trim(), - restapi_debug = $('#alm-rest input[name=rest-debug]:checked') - .val() - .trim(); + var restapi_base = $('#alm-rest input#rest-base').val().trim(), + restapi_namespace = $('#alm-rest input#rest-namespace').val().trim(), + restapi_endpoint = $('#alm-rest input#rest-endpoint').val().trim(), + restapi_template_id = $('#alm-rest input#rest-template-id').val().trim(), + restapi_debug = $('#alm-rest input[name=rest-debug]:checked').val().trim(); if (restapi_base !== '') output += ' restapi_base="' + restapi_base + '"'; @@ -750,7 +723,7 @@ jQuery(document).ready(function($) { var post_type_count = 0, selected_post_type = ''; - $('ul.alm-post-type-list input[type=checkbox]').each(function(e) { + $('ul.alm-post-type-list input[type=checkbox]').each(function (e) { if ($(this).is(':checked')) { post_type_count++; if (post_type_count > 1) { @@ -905,7 +878,7 @@ jQuery(document).ready(function($) { } var tax_term_count1 = 0; - $('#tax-terms-container1 input[type=checkbox]').each(function(e) { + $('#tax-terms-container1 input[type=checkbox]').each(function (e) { if ($(this).is(':checked')) { tax_term_count1++; if (tax_term_count1 > 1) { @@ -931,7 +904,7 @@ jQuery(document).ready(function($) { } var tax_term_count2 = 0; - $('#tax-terms-container2 input[type=checkbox]').each(function(e) { + $('#tax-terms-container2 input[type=checkbox]').each(function (e) { if ($(this).is(':checked')) { tax_term_count2++; if (tax_term_count2 > 1) { @@ -957,7 +930,7 @@ jQuery(document).ready(function($) { } var tax_term_count3 = 0; - $('#tax-terms-container3 input[type=checkbox]').each(function(e) { + $('#tax-terms-container3 input[type=checkbox]').each(function (e) { if ($(this).is(':checked')) { tax_term_count3++; if (tax_term_count3 > 1) { @@ -1007,26 +980,10 @@ jQuery(document).ready(function($) { // --------------------------- // - Custom Fields Meta Query // --------------------------- - var meta_key = $.trim( - $('.meta-query-wrap') - .eq(0) - .find('input.meta-key') - .val() - ), - meta_value = $.trim( - $('.meta-query-wrap') - .eq(0) - .find('input.meta-value') - .val() - ), - meta_compare = $('.meta-query-wrap') - .eq(0) - .find('select.meta-compare') - .val(), - meta_type = $('.meta-query-wrap') - .eq(0) - .find('select.meta-type') - .val(), + var meta_key = $.trim($('.meta-query-wrap').eq(0).find('input.meta-key').val()), + meta_value = $.trim($('.meta-query-wrap').eq(0).find('input.meta-value').val()), + meta_compare = $('.meta-query-wrap').eq(0).find('select.meta-compare').val(), + meta_type = $('.meta-query-wrap').eq(0).find('select.meta-type').val(), meta_relation = $('select.meta-relation').val(), meta_query_length = $('.meta-query-wrap').length; @@ -1057,7 +1014,7 @@ jQuery(document).ready(function($) { meta_value = ''; meta_compare = ''; meta_type = ''; - $('.meta-query-wrap').each(function(e) { + $('.meta-query-wrap').each(function (e) { var el = $(this), mk = $.trim(el.find('input.meta-key').val()), mv = $.trim(el.find('input.meta-value').val()), @@ -1332,15 +1289,9 @@ jQuery(document).ready(function($) { // - Button Label // --------------------------- - var button_label = $('.btn-label input#button-label') - .val() - .trim(), - button_loading_label = $('.btn-label input#button-loading-label') - .val() - .trim(), - button_done_label = $('.btn-label input#button-done-label') - .val() - .trim(); + var button_label = $('.btn-label input#button-label').val().trim(), + button_loading_label = $('.btn-label input#button-loading-label').val().trim(), + button_done_label = $('.btn-label input#button-done-label').val().trim(); if (button_label !== '' && button_label !== 'Load More') { output += ' button_label="' + button_label + '"'; @@ -1401,15 +1352,11 @@ jQuery(document).ready(function($) { */ //Select 'post' by default - $('.post_types input[type=checkbox]#chk-post') - .prop('checked', true) - .addClass('changed'); + $('.post_types input[type=checkbox]#chk-post').prop('checked', true).addClass('changed'); //Select SEO 'false' by default - $('.seo input[type=radio]#seo-false') - .prop('checked', true) - .addClass('changed'); + $('.seo input[type=radio]#seo-false').prop('checked', true).addClass('changed'); - $(document).on('change keyup', '.alm_element', function() { + $(document).on('change keyup', '.alm_element', function () { var el = $(this); el.addClass('changed'); @@ -1417,12 +1364,10 @@ jQuery(document).ready(function($) { if (el.attr('name') === 'woocommerce') { var postTypeCheckboxes = $('ul.alm-post-type-list input[type=checkbox]'); // Check 'product' - $('ul.alm-post-type-list input[type=checkbox]#chk-product') - .prop('checked', true) - .addClass('changed'); + $('ul.alm-post-type-list input[type=checkbox]#chk-product').prop('checked', true).addClass('changed'); if (postTypeCheckboxes) { - postTypeCheckboxes.each(function(index, item) { + postTypeCheckboxes.each(function (index, item) { if (item.dataset.type !== 'product') { item.checked = false; } @@ -1468,7 +1413,7 @@ jQuery(document).ready(function($) { _alm.buildShortcode(); }); - $('input.numbers-only').keydown(function(e) { + $('input.numbers-only').keydown(function (e) { if ( $.inArray(e.keyCode, [188, 46, 8, 9, 27, 13, 110, 190]) !== -1 || // Allow: Ctrl+A @@ -1497,30 +1442,26 @@ jQuery(document).ready(function($) { var jumpMenuOptions = ''; function almBuildJumpMenu(type) { if (type === 'repeaters') { - $('.row').each(function() { + $('.row').each(function () { if (!$(this).hasClass('no-brd')) { // Special case for back 2 top on shortcode builder landing var id = $(this).attr('id'), - title = $(this) - .find('h3.heading') - .text(); + title = $(this).find('h3.heading').text(); jumpMenuOptions += ''; } }); } if (type === 'shortcode') { - $('.shortcode-parameter-wrap').each(function() { + $('.shortcode-parameter-wrap').each(function () { var el = $(this), opttitle = el.find('h2').text(); jumpMenuOptions += ''; - $('.row', el).each(function() { + $('.row', el).each(function () { if (!$(this).hasClass('no-brd')) { // Special case for back 2 top on shortcode builder landing var id = $(this).attr('id'), - title = $(this) - .find('h3.heading') - .text(); + title = $(this).find('h3.heading').text(); jumpMenuOptions += ''; } }); @@ -1533,7 +1474,7 @@ jQuery(document).ready(function($) { } if ($('#alm-repeaters .repeaters').length) { if ($('#unlmited-container').length) { - $('#unlmited-container .row').each(function() { + $('#unlmited-container .row').each(function () { var el = $(this), id = el.find('.wrap').data('name'); el.attr('id', 'alm_' + id); @@ -1544,12 +1485,12 @@ jQuery(document).ready(function($) { // Jump Menu. $('select.jump-menu').append(jumpMenuOptions); - $('select.jump-menu').change(function() { + $('select.jump-menu').change(function () { var pos = $(this).val(); if (pos !== 'null') { $('html,body').animate( { - scrollTop: $('#' + pos).offset().top - ($('.intro').height() - 20) + scrollTop: $('#' + pos).offset().top - ($('.intro').height() - 20), }, 200, 'alm_easeInOutQuad' @@ -1565,16 +1506,14 @@ jQuery(document).ready(function($) { $('.table-of-contents .toc').append(''); } - $('.table-of-contents .toc') - .append(jumpMenuOptions) - .select2(); + $('.table-of-contents .toc').append(jumpMenuOptions).select2(); - $('.table-of-contents .toc').change(function() { + $('.table-of-contents .toc').change(function () { var pos = $(this).val(); if (pos !== 'null' && pos !== '#') { $('html,body').animate( { - scrollTop: $('#' + pos).offset().top - 46 + scrollTop: $('#' + pos).offset().top - 46, }, 500, 'alm_easeInOutQuad' @@ -1598,55 +1537,53 @@ jQuery(document).ready(function($) { action: 'alm_get_tax_terms', taxonomy: tax, index: index, - nonce: alm_admin_localize.alm_admin_nonce + nonce: alm_admin_localize.alm_admin_nonce, }, dataType: 'html', - success: function(data) { + success: function (data) { placement.html(data); }, - error: function(xhr, status, error) { + error: function (xhr, status, error) { responseText.html('

Error - Something went wrong and the terms could not be retrieved.'); - } + }, }); } // Ajax Load More easing. - $.easing.alm_easeInOutQuad = function(x, t, b, c, d) { + $.easing.alm_easeInOutQuad = function (x, t, b, c, d) { if ((t /= d / 2) < 1) return (c / 2) * t * t + b; return (-c / 2) * (--t * (t - 2) - 1) + b; }; // Reset shortcode builder. - $(document).on('click', '.reset-shortcode-builder a', function() { + $(document).on('click', '.reset-shortcode-builder a', function () { $('#alm-shortcode-builder-form').trigger('reset'); _alm.reset_select2(); _alm.buildShortcode(); }); // Generate Unique Cache ID. - _alm.generateUniqueID = function(length, el) { + _alm.generateUniqueID = function (length, el) { var id = Math.floor(Math.pow(10, length - 1) + Math.random() * 9 * Math.pow(10, length - 1)); $(el).val(id); }; // Option toggle click events. - $('.builder-option-toggle--buttons button').on('click', function() { - var siblings = $(this) - .siblings('button') - .removeClass('active'); + $('.builder-option-toggle--buttons button').on('click', function () { + var siblings = $(this).siblings('button').removeClass('active'); $(this).addClass('active'); _alm.buildShortcode(); }); // Generate Unique/Cache ID. - $(document).on('click', '.generate-id a', function() { + $(document).on('click', '.generate-id a', function () { var id = $(this).data('id'), el = $('#' + id); _alm.generateUniqueID(10, el); }); // Button loader preview. - $('.ajax-load-more-wrap button').on('click', function(e) { + $('.ajax-load-more-wrap button').on('click', function (e) { var button = $(this).get(0); var parent = button.parentNode; if (parent.classList.contains('infinite')) { @@ -1657,13 +1594,13 @@ jQuery(document).ready(function($) { }); // Create anchor links for shortcode builder items. - $('.shortcode-parameter-wrap.alm-tabbed-wrapper--section').each(function() { + $('.shortcode-parameter-wrap.alm-tabbed-wrapper--section').each(function () { var section = this; var ul = section.querySelector('ul.section-anchor-nav'); var headings = section.querySelectorAll('h3.heading'); if (headings && headings.length > 2) { var list = ''; - $(headings).each(function() { + $(headings).each(function () { var title = $(this).text(); list += '

  • ' + title + '
  • '; }); @@ -1671,18 +1608,18 @@ jQuery(document).ready(function($) { var anchors = ul.querySelectorAll('a'); if (anchors) { - $(anchors).each(function() { - $(this).on('click', function() { + $(anchors).each(function () { + $(this).on('click', function () { var element = this; var text = element.innerHTML; var target = $('h3.heading:contains(' + text + ')', section); if (target) { $('html, body').animate( { - scrollTop: target.offset().top - 45 + scrollTop: target.offset().top - 45, }, 350, - function() { + function () { // Set focus on the element scrolled to. target.get(0).focus({ preventScroll: true }); } diff --git a/admin/src/js/admin.js b/admin/src/js/admin.js index 398dea0..73ca6e6 100644 --- a/admin/src/js/admin.js +++ b/admin/src/js/admin.js @@ -1,10 +1,10 @@ var _alm = _alm || {}; -jQuery(document).ready(function($) { +jQuery(document).ready(function ($) { 'use strict'; _alm.options = { - speed: 200 + speed: 200, }; /* @@ -17,15 +17,15 @@ jQuery(document).ready(function($) { type: 'GET', url: alm_admin_localize.restapi.url + alm_admin_localize.restapi.namespace + '/test/', dataType: 'json', - success: function(data) { + success: function (data) { if (data.success) { console.log('Ajax Load More successfully connected to the WordPress REST API.'); } }, - error: function(status) { + error: function (status) { console.log(status); $('.restapi-access').fadeIn(); - } + }, }); } @@ -79,10 +79,10 @@ jQuery(document).ready(function($) { sections[index].focus({ preventScroll: true }); $('html, body').animate( { - scrollTop: $('.alm-tabbed-wrapper--sections').offset().top - 45 + scrollTop: $('.alm-tabbed-wrapper--sections').offset().top - 45, }, 350, - function() { + function () { var section = parseInt(index) + 1; window.location.hash = 'alm-section-' + section; } @@ -100,8 +100,8 @@ jQuery(document).ready(function($) { } let tabbedNav = almTabbedWrapper.querySelectorAll('.alm-tabbed-wrapper--nav button'); if (tabbedNav) { - tabbedNav.forEach(function(item, index) { - item.addEventListener('click', function() { + tabbedNav.forEach(function (item, index) { + item.addEventListener('click', function () { openTabbedItem(this, index, almTabbedWrapper); }); }); @@ -133,13 +133,10 @@ jQuery(document).ready(function($) { */ document.addEventListener( 'keydown', - function(e) { - if ((window.navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey) && e.keyCode == 83) { + function (e) { + if ((window.navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey) && e.keyCode === 83) { if (e.target.nodeName === 'TEXTAREA' && $(e.target).closest('.repeater-wrap')) { - console.log('Saving template...'); - var btn = $(e.target) - .closest('.repeater-wrap') - .find('input.save-repeater'); + var btn = $(e.target).closest('.repeater-wrap').find('input.save-repeater'); if (btn) { btn.click(); } @@ -155,7 +152,7 @@ jQuery(document).ready(function($) { * Set focus in code mirror editor * @since 5.1 */ - $('label.trigger-codemirror').on('click', function() { + $('label.trigger-codemirror').on('click', function () { var el = $(this); var id = el.data('id'); var cm = window['editor_' + id]; @@ -179,7 +176,7 @@ jQuery(document).ready(function($) { document.body.appendChild(settingsTarget); } - _alm.saveSettings = function() { + _alm.saveSettings = function () { if (savingSettings) return false; savingSettings = true; @@ -189,9 +186,9 @@ jQuery(document).ready(function($) { almSettings.ajaxSubmit({ // Success - success: function() { + success: function () { // Delay for effect - setTimeout(function() { + setTimeout(function () { settingsTarget.classList.remove('--saving'); settingsTarget.classList.add('--saved'); settingsTarget.innerHTML = alm_admin_localize.settings_saved; @@ -199,16 +196,16 @@ jQuery(document).ready(function($) { //console.log(alm_admin_localize.ajax_load_more +' - '+ alm_admin_localize.settings_saved); savingSettings = false; - setTimeout(function() { + setTimeout(function () { settingsTarget.classList.remove('--saved'); }, 2500); }, 500); }, // Error - error: function() { + error: function () { // Delay for effect - setTimeout(function() { + setTimeout(function () { settingsTarget.classList.remove('--saving'); settingsTarget.classList.add('--error'); settingsTarget.innerHTML = alm_admin_localize.settings_error; @@ -216,21 +213,21 @@ jQuery(document).ready(function($) { console.log(alm_admin_localize.ajax_load_more + ' - ' + alm_admin_localize.settings_error); savingSettings = false; - setTimeout(function() { + setTimeout(function () { settingsTarget.classList.remove('--error'); }, 2500); }, 500); - } + }, }); return false; }; // On Change, save the settings let settingsTimer; - $(document).on('change', '#alm_OptionsForm input, #alm_OptionsForm textarea, #alm_OptionsForm select', function() { + $(document).on('change', '#alm_OptionsForm input, #alm_OptionsForm textarea, #alm_OptionsForm select', function () { // Set a timer to avoid updating settings to frequently if (settingsTimer) clearTimeout(settingsTimer); - settingsTimer = setTimeout(function() { + settingsTimer = setTimeout(function () { _alm.saveSettings(); }, 500); }); @@ -241,7 +238,7 @@ jQuery(document).ready(function($) { * * @since 3.6 */ - $('.download-repeater').on('click', function() { + $('.download-repeater').on('click', function () { let el = this; el.closest('form').submit(); }); @@ -252,12 +249,12 @@ jQuery(document).ready(function($) { * @see http://iamceege.github.io/tooltipster/ * @since 2.8.4 */ - $('.ajax-load-more-inner-wrapper').on('mouseenter', '.tooltip:not(.tooltipstered)', function() { + $('.ajax-load-more-inner-wrapper').on('mouseenter', '.tooltip:not(.tooltipstered)', function () { $(this) .tooltipster({ delay: 100, speed: 150, - maxWidth: 325 + maxWidth: 325, }) .tooltipster('show'); }); @@ -268,7 +265,7 @@ jQuery(document).ready(function($) { * * @since 2.8.4 */ - $('select#alm_settings_btn_color').on('change', function() { + $('select#alm_settings_btn_color').on('change', function () { var color = jQuery(this).val(); // Remove other colors var wrap = $('.ajax-load-more-wrap'); @@ -283,43 +280,32 @@ jQuery(document).ready(function($) { } }); - $('select#alm_settings_btn_color').click(function(e) { + $('select#alm_settings_btn_color').click(function (e) { e.preventDefault(); }); - $('.alm-template-listing li a').click(function(e) { + $('.alm-template-listing li a').click(function (e) { e.preventDefault(); var el = $(this), val = el.data('path'); - el.parent() - .parent() - .next('.template-selection') - .val(val); + el.parent().parent().next('.template-selection').val(val); }); - $('.alm-template-section-nav li a').click(function(e) { + $('.alm-template-section-nav li a').click(function (e) { e.preventDefault(); var el = $(this), index = el.parent().index(), - parent = el - .parent() - .parent() - .parent('.repeater-wrap'); + parent = el.parent().parent().parent('.repeater-wrap'); if (!el.hasClass('active')) { - el.parent() - .addClass('active') - .siblings() - .removeClass('active'); + el.parent().addClass('active').siblings().removeClass('active'); $('.alm-template-toggle', parent).hide(); - $('.alm-template-toggle', parent) - .eq(index) - .show(); + $('.alm-template-toggle', parent).eq(index).show(); } }); // Copy to Clipboard - $('.copy-to-clipboard').on('click', function() { + $('.copy-to-clipboard').on('click', function () { var btn = $(this).get(0); var input = document.querySelector('#shortcode_output'); @@ -336,7 +322,7 @@ jQuery(document).ready(function($) { // Set Text of Button btn.innerHTML = copied_txt; - setTimeout(function() { + setTimeout(function () { btn.innerHTML = old_txt; input.disabled = false; btn.disabled = false; @@ -344,12 +330,12 @@ jQuery(document).ready(function($) { } }); - _alm.copyToClipboard = function(text) { + _alm.copyToClipboard = function (text) { window.prompt('Copy link to your clipboard: Press Ctrl + C then hit Enter to copy.', text); }; // Copy link on repeater templates - $('.alm-dropdown .copy a').click(function() { + $('.alm-dropdown .copy a').click(function () { var container = $(this).closest('.repeater-wrap'), // find closet wrap el = container.data('name'); // get template name @@ -364,25 +350,25 @@ jQuery(document).ready(function($) { * @since 2.0.0 */ - $(document).on('click', 'h3.heading', function() { + $(document).on('click', 'h3.heading', function () { var el = $(this); if ($(el).hasClass('open')) { $(el) .next('.expand-wrap') - .slideDown(_alm.options.speed, 'alm_easeInOutQuad', function() { + .slideDown(_alm.options.speed, 'alm_easeInOutQuad', function () { $(el).removeClass('open'); }); } else { $(el) .next('.expand-wrap') - .slideUp(_alm.options.speed, 'alm_easeInOutQuad', function() { + .slideUp(_alm.options.speed, 'alm_easeInOutQuad', function () { $(el).addClass('open'); }); } }); // Toggle Links. - $(document).on('click', '.toggle-all', function() { + $(document).on('click', '.toggle-all', function () { var el = $(this); if (el.hasClass('closed')) { el.removeClass('closed'); @@ -400,7 +386,7 @@ jQuery(document).ready(function($) { }); // Trigger click events on enter/return - $('h3.heading, h2.shortcode-title').on('keypress', function(e) { + $('h3.heading, h2.shortcode-title').on('keypress', function (e) { var key = e.which; if (key == 13) { // the enter key code @@ -415,7 +401,7 @@ jQuery(document).ready(function($) { * @since 2.8.3 */ var almActivating = false; - $(document).on('click', '.license-btn', function(e) { + $(document).on('click', '.license-btn', function (e) { e.preventDefault(); if (!almActivating) { $('.license-btn-wrap .msg').remove(); @@ -449,54 +435,40 @@ jQuery(document).ready(function($) { url: url, upgrade: upgrade, key: key, - license: license + license: license, }, - success: function(data) { + success: function (data) { if (data.msg) { $('.license-btn-wrap', parent).append('
    ' + data.msg + '
    '); } if (data.license === 'valid') { - $('.license-key-field .status', parent) - .addClass('active') - .removeClass('inactive') - .text(alm_admin_localize.active); - $('.license-title .status', parent) - .addClass('valid') - .removeClass('invalid'); + $('.license-key-field .status', parent).addClass('active').removeClass('inactive').text(alm_admin_localize.active); + $('.license-title .status', parent).addClass('valid').removeClass('invalid'); $('.activate.license-btn', parent).addClass('hide'); $('.check-licence.license-btn', parent).addClass('hide'); $('.deactivate.license-btn', parent).removeClass('hide'); $('.renew-btn', parent).addClass('hide'); $('.no-license', parent).slideUp(200); } else { - $('.license-key-field .status', parent) - .removeClass('active') - .addClass('inactive') - .text(alm_admin_localize.inactive); - $('.license-title .status', parent) - .removeClass('valid') - .addClass('invalid'); + $('.license-key-field .status', parent).removeClass('active').addClass('inactive').text(alm_admin_localize.inactive); + $('.license-title .status', parent).removeClass('valid').addClass('invalid'); $('.activate.license-btn', parent).removeClass('hide'); $('.check-licence.license-btn', parent).addClass('hide'); $('.deactivate.license-btn', parent).addClass('hide'); $('.no-license', parent).slideDown(200); } - $('.loading', parent) - .delay(250) - .fadeOut(300); + $('.loading', parent).delay(250).fadeOut(300); almActivating = false; }, - error: function(status, error) { + error: function (status, error) { console.log(status, error); - $('.loading', parent) - .delay(250) - .fadeOut(300); + $('.loading', parent).delay(250).fadeOut(300); almActivating = false; - } + }, }); } }); @@ -506,7 +478,7 @@ jQuery(document).ready(function($) { * * @since 2.8.7 */ - $(document).on('click', '.alm-layout-selection li a.layout', function(e) { + $(document).on('click', '.alm-layout-selection li a.layout', function (e) { e.preventDefault(); var el = $(this), type = el.data('type'), @@ -537,28 +509,26 @@ jQuery(document).ready(function($) { action: 'alm_get_layout', type: type, custom: custom, - nonce: alm_admin_localize.alm_admin_nonce + nonce: alm_admin_localize.alm_admin_nonce, }, dataType: 'JSON', - success: function(data) { + success: function (data) { eid.setValue(data.value); // Clear button styles - setTimeout(function() { + setTimeout(function () { el.text(alm_admin_localize.template_updated).blur(); - setTimeout(function() { - el.removeClass('updating') - .html(layout_btn_text) - .blur(); // CLose drop menu + setTimeout(function () { + el.removeClass('updating').html(layout_btn_text).blur(); // CLose drop menu el.closest('.alm-drop-btn').trigger('click'); textarea.removeClass('loading'); }, 400); }, 400); }, - error: function(xhr, status, error) { + error: function (xhr, status, error) { console.log(status); textarea.removeClass('loading'); - } + }, }); } }); @@ -568,7 +538,7 @@ jQuery(document).ready(function($) { * * @since 4.0 */ - $(document).on('click', '.alm-transient button.notice-dismiss', function(e) { + $(document).on('click', '.alm-transient button.notice-dismiss', function (e) { e.preventDefault(); var el = $(this), container = el.parent('.alm-transient'), @@ -583,14 +553,14 @@ jQuery(document).ready(function($) { action: 'alm_set_transient', nonce: alm_admin_localize.alm_admin_nonce, transient_name: transient_name, - duration: duration + duration: duration, }, - success: function(data) { + success: function (data) { container.fadeOut(); }, - error: function(xhr, status, error) { + error: function (xhr, status, error) { console.log(status); - } + }, }); }); @@ -599,7 +569,7 @@ jQuery(document).ready(function($) { * * @since 2.7.3 */ - $(document).on('change', '#alm-settings-nav', function(e) { + $(document).on('change', '#alm-settings-nav', function (e) { e.preventDefault(); var el = $(this), index = $('option:selected', el).index(); @@ -607,10 +577,7 @@ jQuery(document).ready(function($) { index = index - 1; $('html, body').animate( { - scrollTop: - $('#alm_OptionsForm h2') - .eq(index) - .offset().top - 40 + scrollTop: $('#alm_OptionsForm h2').eq(index).offset().top - 40, }, 500 ); diff --git a/admin/vendor/connekt-plugin-installer/.editorconfig b/admin/vendor/connekt-plugin-installer/.editorconfig deleted file mode 100755 index e488634..0000000 --- a/admin/vendor/connekt-plugin-installer/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -# EditorConfig helps developers define and maintain consistent -# coding styles between different editors and IDEs -# editorconfig.org - -# PHP PSR-2 Coding Standards -# http://www.php-fig.org/psr/psr-2/ - -root = true - -[*.php] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = tab -indent_size = 3 diff --git a/admin/vendor/connekt-plugin-installer/.phpcs.xml b/admin/vendor/connekt-plugin-installer/.phpcs.xml new file mode 100644 index 0000000..c05ba6c --- /dev/null +++ b/admin/vendor/connekt-plugin-installer/.phpcs.xml @@ -0,0 +1,65 @@ + + + Apply WordPress Coding Standards + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ./ + + + /build/* + /node_modules/* + /vendor/* + diff --git a/admin/vendor/connekt-plugin-installer/LICENSE b/admin/vendor/connekt-plugin-installer/LICENSE new file mode 100644 index 0000000..23cb790 --- /dev/null +++ b/admin/vendor/connekt-plugin-installer/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/admin/vendor/connekt-plugin-installer/README.md b/admin/vendor/connekt-plugin-installer/README.md new file mode 100644 index 0000000..38c85f2 --- /dev/null +++ b/admin/vendor/connekt-plugin-installer/README.md @@ -0,0 +1,70 @@ +# wordpress-plugin-installer + +The **Connekt Plugin Installer** is a class for displaying a list of recommended or related plugins inside of the WordPress admin. + +The installer displays a list of plugins that users can easily install and activate from the screen they are currently viewing. + +![Connekt Plugin Installer Example](http://examples.connekthq.com/_gif/plugin-installer_2.gif) + +This is a perfect tool for plugin and theme developers who want to make it as easy as possible for users to install recommended or related plugins. + +To see a live example, install a copy of [Ajax Load More](https://wordpress.org/plugins/ajax-load-more/) and go to the Extensions section. + +*** + +## Getting Started + +To get started, you'll simply need to load and initialize the class. The installer provides the required CSS and JS for display and functionality. + +### Class Loader + +First step is to load the class into your plugin or theme. This would typically appear in `functions.php` or in the `_construct` of your plugin Class. + +```php +include_once('vendor/connekt-plugin-installer/class-connekt-plugin-installer.php'); +``` + +### Display + +Next, build an array of plugin slugs and pass the array to the `init` method for display. + +```php +$plugins = [ + [ + 'slug' => 'ajax-load-more', + ], + [ + 'slug' => 'block-manager', + ], + [ + 'slug' => 'instant-images' + ], + [ + 'slug' => 'easy-query' + ] +]; + +if( class_exists( 'Connekt_Plugin_Installer' ) ) { + Connekt_Plugin_Installer::init( $plugins ); +} +``` + +And that's it. Happy coding :) + +*** + +## Notes + +- Plugins _must_ be available on the wordpress.org plugin repository to be installed and activated using this class. +- Using this class outside of the plugins directory will require modification to the `CNKT_INSTALLER_PATH` constant for loading assets. You can define this constant in `functions.php` prior to loading the class. `define('CNKT_INSTALLER_PATH', get_template_directory_uri() .'/vendor/connekt-plugin-installer/')`; + +## Changelong + +1.0.1 - Janaury 16, 2025 + +- UPDATE: Code cleanup and PHPCS fixes. +- FIX: Fixed issue with broken layout if wordpress.org thumbnail not available. + +## License + +The code is available under the [GPLv2 license](https://github.com/dcooney/wordpress-plugin-installer/blob/master/LICENSE) diff --git a/admin/vendor/connekt-plugin-installer/assets/installer.css b/admin/vendor/connekt-plugin-installer/assets/installer.css old mode 100755 new mode 100644 index 34d3d9c..a56e7dd --- a/admin/vendor/connekt-plugin-installer/assets/installer.css +++ b/admin/vendor/connekt-plugin-installer/assets/installer.css @@ -4,7 +4,7 @@ display: -moz-box; display: -ms-flexbox; display: -webkit-flex; - display: flex; + display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; flex-flow: row wrap; @@ -19,7 +19,7 @@ flex: auto; } .cnkt-plugin-installer * { - box-sizing: border-box; + box-sizing: border-box; } .cnkt-plugin-installer .plugin{ width: 31.333%; @@ -35,7 +35,7 @@ .cnkt-plugin-installer .plugin:hover{ border-color: #cecece; } - + .cnkt-plugin-installer .plugin-wrap{ padding: 20px 20px 95px 145px; min-height: 214px; @@ -44,7 +44,7 @@ } .cnkt-plugin-installer li a, .cnkt-plugin-installer .plugin-wrap a{ - text-decoration: none; + text-decoration: none; } .cnkt-plugin-installer .plugin-wrap img{ display: block; @@ -60,7 +60,7 @@ padding: 0; margin: 0; font-size: 17px; - font-weight: 600; + font-weight: 600; color: #333; line-height: 1.4; } @@ -68,15 +68,15 @@ padding: 10px 0 0; margin: 0; font-size: 14px; - font-weight: 400; + font-weight: 400; color: #777; } .cnkt-plugin-installer .plugin-wrap p.plugin-author{ font-size: 13px; padding-top: 20px; font-style: italic; - } - + } + .cnkt-plugin-installer .activation-row{ display: block; margin: 0; @@ -101,10 +101,10 @@ @media screen and (max-width: 1170px){ .cnkt-plugin-installer .plugin{ - width: 48%; + width: 48%; margin: 0 1% 15px; } -} +} @media screen and (max-width: 960px){ .cnkt-plugin-installer .plugin-wrap{ padding: 20px 20px 95px 115px; @@ -112,9 +112,9 @@ } .cnkt-plugin-installer .plugin-wrap img{ max-width: 78px; - max-height: 78px; + max-height: 78px; } -} +} @media screen and (max-width: 640px){ .cnkt-plugin-installer{ width: 100%; @@ -122,8 +122,8 @@ } .cnkt-plugin-installer .plugin{ width: 100%; - margin: 0 0 20px; + margin: 0 0 20px; } } - - + + diff --git a/admin/vendor/connekt-plugin-installer/assets/installer.js b/admin/vendor/connekt-plugin-installer/assets/installer.js old mode 100755 new mode 100644 index 5502e1b..bbfbbc8 --- a/admin/vendor/connekt-plugin-installer/assets/installer.js +++ b/admin/vendor/connekt-plugin-installer/assets/installer.js @@ -1,134 +1,109 @@ var cnkt_installer = cnkt_installer || {}; -jQuery(document).ready(function($) { - - "use strict"; - - var is_loading = false; - - - - /* - * install_plugin - * Install the plugin - * - * - * @param el object Button element - * @param plugin string Plugin slug - * @since 1.0 - */ - - cnkt_installer.install_plugin = function(el, plugin){ - - // Confirm activation - var r = confirm(cnkt_installer_localize.install_now); - - if (r) { - - is_loading = true; - el.addClass('installing'); - - $.ajax({ - type: 'POST', - url: cnkt_installer_localize.ajax_url, - data: { - action: 'cnkt_plugin_installer', - plugin: plugin, - nonce: cnkt_installer_localize.admin_nonce, - dataType: 'json' - }, - success: function(data) { - if(data){ - if(data.status === 'success'){ - el.attr('class', 'activate button button-primary'); - el.html(cnkt_installer_localize.activate_btn); - } else { - el.removeClass('installing'); - } - } else { - el.removeClass('installing'); - } - is_loading = false; - }, - error: function(xhr, status, error) { - console.log(status); - el.removeClass('installing'); - is_loading = false; - } - }); - - } - } - - - - /* - * activate_plugin - * Activate the plugin - * - * - * @param el object Button element - * @param plugin string Plugin slug - * @since 1.0 - */ - - cnkt_installer.activate_plugin = function(el, plugin){ - - $.ajax({ - type: 'POST', - url: cnkt_installer_localize.ajax_url, - data: { - action: 'cnkt_plugin_activation', - plugin: plugin, - nonce: cnkt_installer_localize.admin_nonce, - dataType: 'json' - }, - success: function(data) { - if(data){ - if(data.status === 'success'){ - el.attr('class', 'installed button disabled'); - el.html(cnkt_installer_localize.installed_btn); - } - } - is_loading = false; - }, - error: function(xhr, status, error) { - console.log(status); - is_loading = false; - } - }); - +jQuery(document).ready(function ($) { + ("use strict"); + + var is_loading = false; + + /** + * Install the plugin. + * + * @param {Element} el Button element. + * @param {string} plugin The plugin slug. + */ + cnkt_installer.install_plugin = function (el, plugin) { + // Confirm activation. + var r = confirm(cnkt_installer_localize.install_now); + if (r) { + is_loading = true; + el.addClass("installing"); + + $.ajax({ + type: "POST", + url: cnkt_installer_localize.ajax_url, + data: { + action: "cnkt_plugin_installer", + plugin: plugin, + nonce: cnkt_installer_localize.admin_nonce, + dataType: "json", + }, + success: function (data) { + if (data) { + if (data.status === "success") { + el.attr("class", "activate button button-primary"); + el.html(cnkt_installer_localize.activate_btn); + } else { + el.removeClass("installing"); + } + } else { + el.removeClass("installing"); + } + is_loading = false; + }, + error: function (status) { + console.log(status); + el.removeClass("installing"); + is_loading = false; + }, + }); + } + }; + + /** + * Activate the plugin + * + * @param {Element} el Button element. + * @param {string} plugin The plugin slug. + */ + cnkt_installer.activate_plugin = function (el, plugin) { + $.ajax({ + type: "POST", + url: cnkt_installer_localize.ajax_url, + data: { + action: "cnkt_plugin_activation", + plugin: plugin, + nonce: cnkt_installer_localize.admin_nonce, + dataType: "json", + }, + success: function (data) { + if (data) { + if (data.status === "success") { + el.attr("class", "installed button disabled"); + el.html(cnkt_installer_localize.installed_btn); + } + } + is_loading = false; + }, + error: function (xhr, status, error) { + console.log(status); + is_loading = false; + }, + }); }; - - - - /* - * Install/Activate Button Click - * - * @since 1.0 - */ - - $(document).on('click', '.cnkt-plugin-installer a.button', function(e){ - var el = $(this), - plugin = el.data('slug'); - - e.preventDefault(); - - if(!el.hasClass('disabled')){ - - if(is_loading) return false; - - // Installation - if(el.hasClass('install')){ - cnkt_installer.install_plugin(el, plugin); - } - - // Activation - if(el.hasClass('activate')){ - cnkt_installer.activate_plugin(el, plugin); - } - } + + /** + * Install/Activate Button Click. + * + * @since 1.0 + */ + $(document).on("click", ".cnkt-plugin-installer a.button", function (e) { + var el = $(this), + plugin = el.data("slug"); + + e.preventDefault(); + + if (!el.hasClass("disabled")) { + if (is_loading) return false; + + // Installation + if (el.hasClass("install")) { + cnkt_installer.install_plugin(el, plugin); + } + + // Activation + if (el.hasClass("activate")) { + cnkt_installer.activate_plugin(el, plugin); + } + } }); - - -}); \ No newline at end of file +}); diff --git a/admin/vendor/connekt-plugin-installer/class-connekt-plugin-installer.php b/admin/vendor/connekt-plugin-installer/class-connekt-plugin-installer.php old mode 100755 new mode 100644 index ac6459b..415638f --- a/admin/vendor/connekt-plugin-installer/class-connekt-plugin-installer.php +++ b/admin/vendor/connekt-plugin-installer/class-connekt-plugin-installer.php @@ -1,393 +1,358 @@ +
    + sanitize_file_name( $plugin['slug'] ), + 'fields' => [ + 'short_description' => true, + 'sections' => false, + 'requires' => false, + 'downloaded' => true, + 'last_updated' => false, + 'added' => false, + 'tags' => false, + 'compatibility' => false, + 'homepage' => false, + 'donate_link' => false, + 'icons' => true, + 'banners' => true, + ], + ] + ); + + if ( ! is_wp_error( $api ) ) { + // Confirm no errors. + + $main_plugin_file = self::get_plugin_file( $plugin['slug'] ); // Get main plugin file. + + if ( self::check_file_extension( $main_plugin_file ) ) { + // check file extension. + if ( is_plugin_active( $main_plugin_file ) ) { + // plugin activated. + $button_classes = 'button disabled'; + $button_text = __( 'Activated', 'cnkt-installer' ); + } else { + // Installed, let's activate it. + $button_classes = 'activate button button-primary'; + $button_text = __( 'Activate', 'cnkt-installer' ); + } + } + + // Send plugin data to template. + self::render_template( $plugin, $api, $button_text, $button_classes ); + } + endforeach; + ?> +
    + - -
    - sanitize_file_name($plugin['slug']), - 'fields' => array( - 'short_description' => true, - 'sections' => false, - 'requires' => false, - 'downloaded' => true, - 'last_updated' => false, - 'added' => false, - 'tags' => false, - 'compatibility' => false, - 'homepage' => false, - 'donate_link' => false, - 'icons' => true, - 'banners' => true, - ), - ) - ); - - //echo '
    ';
    -               //print_r($api);
    -               //echo '
    '; - - - if ( !is_wp_error( $api ) ) { // confirm error free - - $main_plugin_file = Connekt_Plugin_Installer::get_plugin_file($plugin['slug']); // Get main plugin file - //echo $main_plugin_file; - if(self::check_file_extension($main_plugin_file)){ // check file extension - if(is_plugin_active($main_plugin_file)){ - // plugin activation confirmed - $button_classes = 'button disabled'; - $button_text = __('Activated', 'framework'); - } else { - // It's installed, let's activate it - $button_classes = 'activate button button-primary'; - $button_text = __('Activate', 'framework'); - } - } - - // Send plugin data to template - self::render_template($plugin, $api, $button_text, $button_classes); - - } - - endforeach; - ?> -
    - -
    -
    - -

    name; ?>

    -

    short_description; ?>

    - -

    author; ?>

    -
    - -
    - +
    +
    + icons ) && isset( $api->icons['1x'] ) ) { ?> + + + + +

    name ); ?>

    +

    short_description ); ?>

    +

    author ); ?>

    +
    + +
    + $plugin, - 'fields' => array( + // Required core libs for installation. + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php'; + require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php'; + + // Get plugin data. + $api = plugins_api( + 'plugin_information', + [ + 'slug' => $plugin, + 'fields' => [ 'short_description' => false, - 'sections' => false, - 'requires' => false, - 'rating' => false, - 'ratings' => false, - 'downloaded' => false, - 'last_updated' => false, - 'added' => false, - 'tags' => false, - 'compatibility' => false, - 'homepage' => false, - 'donate_link' => false, - ), - ) + 'sections' => false, + 'requires' => false, + 'rating' => false, + 'ratings' => false, + 'downloaded' => false, + 'last_updated' => false, + 'added' => false, + 'tags' => false, + 'compatibility' => false, + 'homepage' => false, + 'donate_link' => false, + ], + ] ); $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); - $upgrader->install($api->download_link); + $upgrader->install( $api->download_link ); - if($api->name){ + if ( $api->name ) { $status = 'success'; - $msg = $api->name .' successfully installed.'; + $msg = $api->name . ' successfully installed.'; } else { $status = 'failed'; - $msg = 'There was an error installing '. $api->name .'.'; + $msg = 'There was an error installing ' . $api->name . '.'; } - $json = array( + $json = [ 'status' => $status, - 'msg' => $msg, - ); - - wp_send_json($json); + 'msg' => $msg, + ]; + wp_send_json( $json ); } + /** + * Activate plugin via Ajax. + * + * @since 1.0 + * @return void|string The plugin data as JSON. + */ + public function cnkt_plugin_activation() { + if ( ! current_user_can( 'install_plugins' ) ) { + // Bail early if requirements not met. + wp_die( esc_attr__( 'Sorry, you are not allowed to activate plugins on this site.', 'cnkt-installer' ) ); + } - - /* - * cnkt_plugin_activation - * Activate plugin via Ajax. - * - * @return $json - * - * @since 1.0 - */ - public function cnkt_plugin_activation(){ - if ( ! current_user_can('install_plugins') ) - wp_die( __( 'Sorry, you are not allowed to activate plugins on this site.', 'framework' ) ); - - $nonce = $_POST["nonce"]; - $plugin = $_POST["plugin"]; + // Get POST data. + $params = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); + $nonce = $params['nonce']; + $plugin = $params['plugin']; // Check our nonce, if they don't match then bounce! - if (! wp_verify_nonce( $nonce, 'cnkt_installer_nonce' )) - die( __( 'Error - unable to verify nonce, please try again.', 'framework' ) ); - - - // Include required libs for activation - require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); - require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); - require_once( ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php' ); - + if ( ! wp_verify_nonce( $nonce, 'cnkt_installer_nonce' ) ) { + wp_die( esc_attr__( 'Error - unable to verify nonce, please try again.', 'cnkt-installer' ) ); + } - // Get Plugin Info - $api = plugins_api( 'plugin_information', - array( - 'slug' => $plugin, - 'fields' => array( + // Required core WP libs for activation. + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php'; + + // Get plugin data. + $api = plugins_api( + 'plugin_information', + [ + 'slug' => $plugin, + 'fields' => [ 'short_description' => false, - 'sections' => false, - 'requires' => false, - 'rating' => false, - 'ratings' => false, - 'downloaded' => false, - 'last_updated' => false, - 'added' => false, - 'tags' => false, - 'compatibility' => false, - 'homepage' => false, - 'donate_link' => false, - ), - ) + 'sections' => false, + 'requires' => false, + 'rating' => false, + 'ratings' => false, + 'downloaded' => false, + 'last_updated' => false, + 'added' => false, + 'tags' => false, + 'compatibility' => false, + 'homepage' => false, + 'donate_link' => false, + ], + ] ); - - if($api->name){ - $main_plugin_file = Connekt_Plugin_Installer::get_plugin_file($plugin); - $status = 'success'; - if($main_plugin_file){ - activate_plugin($main_plugin_file); - $msg = $api->name .' successfully activated.'; + if ( $api->name ) { + $main_plugin_file = self::get_plugin_file( $plugin ); + $status = 'success'; + if ( $main_plugin_file ) { + activate_plugin( $main_plugin_file ); + $msg = $api->name . ' successfully activated.'; } } else { $status = 'failed'; - $msg = 'There was an error activating '. $api->name .'.'; + $msg = 'There was an error activating ' . $api->name . '.'; } - $json = array( + $json = [ 'status' => $status, - 'msg' => $msg, - ); - - wp_send_json($json); - + 'msg' => $msg, + ]; + wp_send_json( $json ); } + /** + * A method to get the main plugin file. + * + * @since 1.0 + * @param string $plugin_slug The slug of the plugin. + * @return void|string The plugin file. + */ + public static function get_plugin_file( $plugin_slug ) { + // Load core WP plugin lib. + require_once ABSPATH . '/wp-admin/includes/plugin.php'; + + $plugins = get_plugins(); + if ( ! $plugins ) { + return; + } + foreach ( $plugins as $plugin_file => $plugin_info ) { + // Get the basename of the plugin e.g. [askismet]/askismet.php. + $slug = dirname( plugin_basename( $plugin_file ) ); + if ( $slug ) { + if ( $slug === $plugin_slug ) { + return $plugin_file; + } + } + } + } - - /* - * get_plugin_file - * A method to get the main plugin file. - * - * - * @param $plugin_slug String - The slug of the plugin - * @return $plugin_file - * - * @since 1.0 - */ - - public static function get_plugin_file( $plugin_slug ) { - require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); // Load plugin lib - $plugins = get_plugins(); - - foreach( $plugins as $plugin_file => $plugin_info ) { - - // Get the basename of the plugin e.g. [askismet]/askismet.php - $slug = dirname( plugin_basename( $plugin_file ) ); - - if($slug){ - if ( $slug == $plugin_slug ) { - return $plugin_file; // If $slug = $plugin_name - } - } - } - return null; - } - - - - - /* - * check_file_extension - * A helper to check file extension - * - * - * @param $filename String - The filename of the plugin - * @return boolean - * - * @since 1.0 - */ + /** + * Helper function to check file extension. + * + * @since 1.0 + * @param string $filename The filename of the plugin. + * @return boolean + */ public static function check_file_extension( $filename ) { - if( substr( strrchr($filename, '.' ), 1 ) === 'php' ){ - // has .php exension + if ( substr( strrchr( $filename, '.' ), 1 ) === 'php' ) { + // has .php exension. return true; } else { - // ./wp-content/plugins + // ./wp-content/plugins. return false; } } + /** + * Enqueue admin scripts and scripts localization. + * + * @since 1.0 + */ + public function cnkt_installer_enqueue_scripts() { + wp_enqueue_script( 'plugin-installer', CNKT_INSTALLER_PATH . 'assets/installer.js', [ 'jquery' ], CNKT_INSTALLER_VERSION, false ); + wp_localize_script( + 'plugin-installer', + 'cnkt_installer_localize', + [ + 'ajax_url' => admin_url( 'admin-ajax.php' ), + 'admin_nonce' => wp_create_nonce( 'cnkt_installer_nonce' ), + 'install_now' => __( 'Are you sure you want to install this plugin?', 'cnkt-installer' ), + 'install_btn' => __( 'Install Now', 'cnkt-installer' ), + 'activate_btn' => __( 'Activate', 'cnkt-installer' ), + 'installed_btn' => __( 'Activated', 'cnkt-installer' ), + ] + ); + wp_enqueue_style( 'plugin-installer', CNKT_INSTALLER_PATH . 'assets/installer.css', '', CNKT_INSTALLER_VERSION ); + } + } - - - /* - * enqueue_scripts - * Enqueue admin scripts - * - * - * @since 1.0 - */ - public function enqueue_scripts(){ - wp_enqueue_script( 'plugin-installer', CNKT_INSTALLER_PATH. 'assets/installer.js', array( 'jquery' )); - wp_enqueue_style( 'plugin-installer', CNKT_INSTALLER_PATH. 'assets/installer.css'); - } - - - - - /* - * localize_admin - * Create admin variables and ajax nonce - * - * @since 1.0 - */ - public function localize_admin() { ?> - - start(); + // Initialize the installer class. + $cnkt_plugin_installer = new Connekt_Plugin_Installer(); + $cnkt_plugin_installer->start(); } diff --git a/admin/views/add-ons.php b/admin/views/add-ons.php index eeba862..41f6340 100755 --- a/admin/views/add-ons.php +++ b/admin/views/add-ons.php @@ -1,3 +1,13 @@ + +
    diff --git a/admin/views/extensions.php b/admin/views/extensions.php index 754ac80..4c94cf6 100755 --- a/admin/views/extensions.php +++ b/admin/views/extensions.php @@ -1,46 +1,53 @@ +
    -
    -

    - : - . -

    - -
    - -
    - -
    - 'ajax-load-more-for-acf', - ), - array( - 'slug' => 'ajax-load-more-for-relevanssi', - ), - array( - 'slug' => 'ajax-load-more-rest-api', - ), - array( - 'slug' => 'ajax-load-more-for-searchwp', - ), - array( - 'slug' => 'ajax-load-more-for-terms', - ), - ); - if ( class_exists( 'Connekt_Plugin_Installer' ) ) { - Connekt_Plugin_Installer::init( $plugin_array ); - } - ?> - -
    -

    plugin dashboard.', 'ajax-load-more' ); ?>

    -
    -
    - -
    -
    - +
    +

    + : + . +

    + +
    +
    +
    + 'ajax-load-more-for-acf', + ), + array( + 'slug' => 'ajax-load-more-for-relevanssi', + ), + array( + 'slug' => 'ajax-load-more-rest-api', + ), + array( + 'slug' => 'ajax-load-more-for-searchwp', + ), + array( + 'slug' => 'ajax-load-more-for-terms', + ), + array( + 'slug' => 'ajax-load-more-for-users', + ), + ); + if ( class_exists( 'Connekt_Plugin_Installer' ) ) { + Connekt_Plugin_Installer::init( $plugin_array ); + } + ?> +
    +

    plugin dashboard.', 'ajax-load-more' ); ?>

    +
    +
    +
    +
    diff --git a/admin/views/go-pro.php b/admin/views/go-pro.php index 70b4d00..292aed9 100755 --- a/admin/views/go-pro.php +++ b/admin/views/go-pro.php @@ -1,71 +1,80 @@ +
    -
    -

    - : - -

    -
    +
    +

    + : + +

    +
    -
    +
    -
    +
    -
    - +
    +

    - +

    - - - + + +
    -
    +
    - + -
    -
    +
    +
    diff --git a/admin/views/help.php b/admin/views/help.php index f73b3e4..33624e2 100755 --- a/admin/views/help.php +++ b/admin/views/help.php @@ -1,88 +1,109 @@ +
    -
    -

    - : - -

    - -
    +
    +

    + : + +

    + +
    -
    +
    -
    +
    - + - + -
    - -
    +
    + +
    - + } + ?> -
    +
    - + } else { + // Examples + ?> +
    +

    +
    +

    examples available on the plugin website', 'ajax-load-more' ); ?>.

    +
    +
    + +
    +
    + +
    -
    +
    diff --git a/admin/views/licenses.php b/admin/views/licenses.php index 7c1ffb7..1a666a9 100755 --- a/admin/views/licenses.php +++ b/admin/views/licenses.php @@ -1,3 +1,12 @@ + add-on updates from the plugins dashboard', 'ajax-load-more' ); @@ -80,7 +89,11 @@
    - + id="" name="" type="" @@ -143,7 +156,7 @@ class="regular-text" + ?>

    | |

    diff --git a/admin/views/repeater-templates.php b/admin/views/repeater-templates.php index 94b3438..ff81b3d 100755 --- a/admin/views/repeater-templates.php +++ b/admin/views/repeater-templates.php @@ -1,3 +1,12 @@ +
    diff --git a/admin/views/shortcode-builder.php b/admin/views/shortcode-builder.php index 0aa4de5..95b4990 100755 --- a/admin/views/shortcode-builder.php +++ b/admin/views/shortcode-builder.php @@ -1,4 +1,11 @@
    @@ -6,43 +13,43 @@

    - : - shortcode by adjusting the values below', 'ajax-load-more'); ?> + : + shortcode by adjusting the values below', 'ajax-load-more' ); ?>

    -
    -
    - -
    -

    -
    +
    +
    + +
    +

    +
    - + -
    -
    +
    +
    diff --git a/ajax-load-more.php b/ajax-load-more.php index 443e227..45d69af 100755 --- a/ajax-load-more.php +++ b/ajax-load-more.php @@ -1,4 +1,4 @@ - $post_type, 'posts_per_page' => $posts_per_page, @@ -162,43 +161,6 @@ public static function alm_build_queryargs( $a, $is_ajax = true ) { 'ignore_sticky_posts' => true, ]; - // Post Format & Taxonomy. - // Both use tax_query, so we need to combine these queries. - if ( ! empty( $post_format ) || ! empty( $taxonomy ) ) { - - $tax_query_total = count( explode( ':', $taxonomy ) ); // Total $taxonomy objects. - $taxonomy = explode( ':', $taxonomy ); // convert to array. - $taxonomy_terms = explode( ':', $taxonomy_terms ); // convert to array. - $taxonomy_operator = explode( ':', $taxonomy_operator ); // convert to array. - - if ( empty( $taxonomy ) ) { - - // Post Format only. - $args['tax_query'] = [ - alm_get_post_format( $post_format ), - ]; - - } else { - - // Post Format. - if ( ! empty( $post_format ) ) { - $args['tax_query'] = [ - 'relation' => $taxonomy_relation, - alm_get_post_format( $post_format ), - ]; - } else { - $args['tax_query'] = [ - 'relation' => $taxonomy_relation, - ]; - } - - // Loop Taxonomies. - for ( $tax_i = 0; $tax_i < $tax_query_total; $tax_i++ ) { - $args['tax_query'][] = alm_get_taxonomy_query( $taxonomy[ $tax_i ], $taxonomy_terms[ $tax_i ], $taxonomy_operator[ $tax_i ] ); - } - } - } - // Category. if ( ! empty( $category ) ) { $args['category_name'] = $category; @@ -238,6 +200,46 @@ public static function alm_build_queryargs( $a, $is_ajax = true ) { $args['day'] = $day; } + // Taxonomy & Post Format. + // Both use tax_query, so we need to combine the queries. + if ( ! empty( $post_format ) || ! empty( $taxonomy ) ) { + $tax_query_total = count( explode( ':', $taxonomy ) ); // Total $taxonomy objects. + $taxonomy = explode( ':', $taxonomy ); // Convert to array. + $taxonomy_terms = explode( ':', $taxonomy_terms ); // Convert to array. + $taxonomy_operator = explode( ':', $taxonomy_operator ); // Convert to array. + $taxonomy_children = explode( ':', $taxonomy_children ); // Convert to array. + + if ( empty( $taxonomy ) ) { + // Post Format only. + $args['tax_query'] = [ + alm_get_post_format( $post_format ), + ]; + + } else { + // Post Format. + if ( ! empty( $post_format ) ) { + $args['tax_query'] = [ + 'relation' => $taxonomy_relation, + alm_get_post_format( $post_format ), + ]; + } else { + $args['tax_query'] = [ + 'relation' => $taxonomy_relation, + ]; + } + + // Loop Taxonomies. + for ( $i = 0; $i < $tax_query_total; $i++ ) { + $args['tax_query'][] = alm_get_taxonomy_query( + $taxonomy[ $i ], + $taxonomy_terms[ $i ], + $taxonomy_operator[ $i ], + isset( $taxonomy_children[ $i ] ) ? $taxonomy_children[ $i ] : true + ); + } + } + } + // Meta Query. if ( ! empty( $meta_key ) && isset( $meta_value ) || ! empty( $meta_key ) && $meta_compare !== 'IN' ) { @@ -255,13 +257,13 @@ public static function alm_build_queryargs( $a, $is_ajax = true ) { // Loop and build the Meta Query. for ( $i = 0; $i < $meta_query_total; $i++ ) { - $meta_array = [ + $meta_array = [ 'key' => isset( $meta_keys[ $i ] ) ? $meta_keys[ $i ] : '', 'value' => isset( $meta_value[ $i ] ) ? $meta_value[ $i ] : '', 'compare' => isset( $meta_compare[ $i ] ) ? $meta_compare[ $i ] : 'IN', 'type' => isset( $meta_type[ $i ] ) ? $meta_type[ $i ] : 'CHAR', ]; - $args['meta_query'][] = alm_get_meta_query( $meta_array ); + $args['meta_query'][ alm_create_meta_clause( $meta_keys[ $i ] ) ] = alm_get_meta_query( $meta_array ); } } @@ -320,14 +322,11 @@ public static function alm_build_queryargs( $a, $is_ajax = true ) { $sticky_post__not_in = isset( $args['post__not_in'] ) ? $args['post__not_in'] : ''; if ( $is_ajax ) { // Ajax Query. - - $sticky_query_args = $args; - + $sticky_query_args = $args; $sticky_query_args['post__not_in'] = $sticky_posts; $sticky_query_args['posts_per_page'] = apply_filters( 'alm_max_sticky_per_page', 50 ); // Set a maximum to prevent fatal query errors. $sticky_query_args['fields'] = 'ids'; - - $sticky_query = new WP_Query( $sticky_query_args ); // Query all non-sticky posts. + $sticky_query = new WP_Query( $sticky_query_args ); // Query all non-sticky posts. // If has sticky and regular posts. if ( $sticky_posts && $sticky_query->posts ) { diff --git a/core/classes/class-alm-shortcode.php b/core/classes/class-alm-shortcode.php index 2c28fc5..9f62f90 100755 --- a/core/classes/class-alm-shortcode.php +++ b/core/classes/class-alm-shortcode.php @@ -38,11 +38,11 @@ public static function alm_render_shortcode( $atts ) { /** * Override default ALM Settings. - * ALM Core Filter Hook + * ALM Core Filter Hook. * - * @return $options; + * @return array $options Options array. */ - $options = ( has_filter( 'alm_settings' ) ) ? apply_filters( 'alm_settings', $options ) : $options; + $options = has_filter( 'alm_settings' ) ? apply_filters( 'alm_settings', $options ) : $options; self::$counter++; // Counter. $slug = apply_filters( 'alm_page_slug', alm_get_page_slug( $post ) ); // Define page slug. @@ -172,6 +172,7 @@ public static function alm_render_shortcode( $atts ) { 'taxonomy_terms' => '', 'taxonomy_operator' => '', 'taxonomy_relation' => '', + 'taxonomy_include_children' => '', 'meta_key' => '', 'meta_value' => '', 'meta_compare' => '', @@ -236,9 +237,10 @@ public static function alm_render_shortcode( $atts ) { $atts ) ); + // phpcs:enable // Elementor. - $elementor = ( 'true' === $elementor ) ? 'single' : $elementor; + $elementor = $elementor === 'true' ? 'single' : $elementor; if ( 'single' === $elementor ) { // Single Template. if ( ! is_singular( $post_type ) ) { // Exit if not singular template. @@ -248,7 +250,7 @@ public static function alm_render_shortcode( $atts ) { $offset = '1'; } - if ( 'posts' === $elementor && ! empty( $elementor_target ) ) { // Posts Grid. + if ( $elementor === 'posts' && ! empty( $elementor_target ) ) { // Posts Grid. $container_element = 'div'; $pause = 'true'; } @@ -258,11 +260,11 @@ public static function alm_render_shortcode( $atts ) { $woocommerce = 'true' === $woocommerce ? true : false; // Standard ALM. // Archives. - $archive = 'true' === $archive ? true : false; + $archive = $archive === 'true' ? true : false; // Backwards compat. // If $previous_post_ is true, set the $single_post_{value} params. - if ( 'true' === $previous_post ) { + if ( $previous_post === 'true' ) { $single_post = 'true'; $single_post_id = $previous_post_id; $single_post_order = $previous_post_order; @@ -302,7 +304,7 @@ public static function alm_render_shortcode( $atts ) { } // Next Page. - if ( has_action( 'alm_nextpage_installed' ) && $nextpage === 'true' ) { + if ( has_action( 'alm_nextpage_installed' ) && $nextpage === 'true' ) { wp_enqueue_script( 'ajax-load-more-nextpage' ); } @@ -400,7 +402,7 @@ public static function alm_render_shortcode( $atts ) { $transition_container_classes = ! empty( $transition_container_classes ) ? ' ' . esc_attr( $transition_container_classes ) : ''; // REST API. - if ( $restapi=== 'true' ) { + if ( $restapi === 'true' ) { $restapi = true; $preloaded = false; } @@ -507,8 +509,7 @@ public static function alm_render_shortcode( $atts ) { // Start ALM object. - $ajaxloadmore = ''; - + $ajaxloadmore = ''; $ajaxloadmore .= ALM_WOOCOMMERCE::hide_pagination( $woocommerce ); $ajaxloadmore .= ALM_WOOCOMMERCE::hide_orderby( $woocommerce ); @@ -516,8 +517,8 @@ public static function alm_render_shortcode( $atts ) { $ajaxloadmore .= has_action( 'alm_elementor_installed' ) && $elementor === 'posts' ? apply_filters( 'alm_elementor_hide_pagination', '' ) : ''; /* - * ALM Before Container - * ALM Core Filter Hook + * ALM Before Container. + * ALM Core Filter Hook. * * @return html */ @@ -526,14 +527,15 @@ public static function alm_render_shortcode( $atts ) { // Generate ALM ID. $div_id = self::$counter > 1 ? 'ajax-load-more-' . self::$counter : 'ajax-load-more'; - // Localized ID - ID used for storin glocalized variables. + // Localized ID - ID used for storing localized variables. $localize_id = empty( $id ) ? $div_id : 'ajax-load-more-' . $id; // Master ID - Manual or generated ALM ID. $master_id = empty( $id ) ? $div_id : $id; - // Custom unique ALM ID (shortcode). - $unique_id = ! empty( $id ) ? 'data-id="' . $id . '"' : ''; + // Unique ALM ID and object variable. + $unique_id = ! empty( $id ) ? 'data-id="' . $id . '"' : ''; + $alm_object_var = ! empty( $id ) ? 'data-alm-object="ajax_load_more_' . $id . '"' : ''; // Search atts - Used with SEO. $is_search = is_search() ? 'data-search="true"' : ''; @@ -560,7 +562,7 @@ public static function alm_render_shortcode( $atts ) { } // Start $ajaxloadmore element. - $ajaxloadmore .= '
    '; + $ajaxloadmore .= '
    '; // Masonry Hook (Before). $ajaxloadmore .= apply_filters( 'alm_masonry_before', $transition ); @@ -746,75 +748,76 @@ public static function alm_render_shortcode( $atts ) { // $query_args array to store global ALM variables. $query_args = [ - 'post_id' => $post_id, - 'preloaded' => $preloaded, - 'preloaded_amount' => $preloaded_amount, - 'filters' => $filters, - 'facets' => $facets, - 'acf' => $acf, - 'acf_post_id' => $acf_post_id, - 'acf_field_type' => $acf_field_type, - 'acf_field_name' => $acf_field_name, - 'acf_parent_field_name' => $acf_parent_field_name, - 'term_query' => [ + 'post_id' => $post_id, + 'preloaded' => $preloaded, + 'preloaded_amount' => $preloaded_amount, + 'filters' => $filters, + 'facets' => $facets, + 'acf' => $acf, + 'acf_post_id' => $acf_post_id, + 'acf_field_type' => $acf_field_type, + 'acf_field_name' => $acf_field_name, + 'acf_parent_field_name' => $acf_parent_field_name, + 'term_query' => [ 'taxonomy' => $term_query_taxonomy, 'hide_empty' => $term_query_hide_empty, 'number' => $term_query_number, ], - 'nextpage' => $nextpage, - 'users' => $users, - 'users_role' => $users_role, - 'users_include' => $users_include, - 'users_exclude' => $users_exclude, - 'users_per_page' => $users_per_page, - 'users_order' => $users_order, - 'users_orderby' => $users_orderby, - 'comments' => $comments, - 'comments_per_page' => $comments_per_page, - 'comments_type' => $comments_type, - 'comments_style' => $comments_style, - 'comments_template' => $comments_template, - 'comments_callback' => $comments_callback, - 'comments_post_id' => $comments_post_id, - 'post_type' => $post_type, - 'sticky_posts' => $sticky_posts, - 'post_format' => $post_format, - 'category' => $category, - 'category__and' => $category__and, - 'category__not_in' => $category__not_in, - 'tag' => $tag, - 'tag__and' => $tag__and, - 'tag__not_in' => $tag__not_in, - 'taxonomy' => $taxonomy, - 'taxonomy_terms' => $taxonomy_terms, - 'taxonomy_operator' => $taxonomy_operator, - 'taxonomy_relation' => $taxonomy_relation, - 'meta_key' => $meta_key, - 'meta_value' => $meta_value, - 'meta_compare' => $meta_compare, - 'meta_relation' => $meta_relation, - 'meta_type' => $meta_type, - 'year' => $year, - 'month' => $month, - 'day' => $day, - 'author' => $author, - 'post__in' => $post__in, - 'post__not_in' => $post__not_in, - 'search' => $search, - 'custom_args' => $custom_args, - 'post_status' => $post_status, - 'order' => $order, - 'orderby' => $orderby, - 'exclude' => $exclude, - 'offset' => $offset, - 'posts_per_page' => $posts_per_page, - 'lang' => $lang, - 'css_classes' => $css_classes, - 'id' => $id, - 'vars' => $vars, - 'repeater' => $repeater, - 'theme_repeater' => $theme_repeater, - 'paged' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1, + 'nextpage' => $nextpage, + 'users' => $users, + 'users_role' => $users_role, + 'users_include' => $users_include, + 'users_exclude' => $users_exclude, + 'users_per_page' => $users_per_page, + 'users_order' => $users_order, + 'users_orderby' => $users_orderby, + 'comments' => $comments, + 'comments_per_page' => $comments_per_page, + 'comments_type' => $comments_type, + 'comments_style' => $comments_style, + 'comments_template' => $comments_template, + 'comments_callback' => $comments_callback, + 'comments_post_id' => $comments_post_id, + 'post_type' => $post_type, + 'sticky_posts' => $sticky_posts, + 'post_format' => $post_format, + 'category' => $category, + 'category__and' => $category__and, + 'category__not_in' => $category__not_in, + 'tag' => $tag, + 'tag__and' => $tag__and, + 'tag__not_in' => $tag__not_in, + 'taxonomy' => $taxonomy, + 'taxonomy_terms' => $taxonomy_terms, + 'taxonomy_operator' => $taxonomy_operator, + 'taxonomy_include_children' => $taxonomy_include_children, + 'taxonomy_relation' => $taxonomy_relation, + 'meta_key' => $meta_key, + 'meta_value' => $meta_value, + 'meta_compare' => $meta_compare, + 'meta_relation' => $meta_relation, + 'meta_type' => $meta_type, + 'year' => $year, + 'month' => $month, + 'day' => $day, + 'author' => $author, + 'post__in' => $post__in, + 'post__not_in' => $post__not_in, + 'search' => $search, + 'custom_args' => $custom_args, + 'post_status' => $post_status, + 'order' => $order, + 'orderby' => $orderby, + 'exclude' => $exclude, + 'offset' => $offset, + 'posts_per_page' => $posts_per_page, + 'lang' => $lang, + 'css_classes' => $css_classes, + 'id' => $id, + 'vars' => $vars, + 'repeater' => $repeater, + 'theme_repeater' => $theme_repeater, + 'paged' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1, ]; // Set `alm-listing` classname. @@ -903,7 +906,7 @@ public static function alm_render_shortcode( $atts ) { $options ); $ajaxloadmore .= wp_kses_post( $filters_return ); - $ajaxloadmore .= $facets === 'true' ? ' data-facets="true"' : ''; + $facets = function_exists( 'alm_filters_has_facets' ) && alm_filters_has_facets( $target ) ? true : false; } // Nextpage Post Add-on. @@ -1112,124 +1115,125 @@ public static function alm_render_shortcode( $atts ) { // Repeaters. if ( ! $woo && $elementor !== 'posts' ) { - $ajaxloadmore .= $theme_repeater === 'null' ? ' data-repeater="' . $repeater . '"' : ''; - $ajaxloadmore .= $theme_repeater !== 'null' ? ' data-theme-repeater="' . $theme_repeater . '"' : ''; + $ajaxloadmore .= $theme_repeater === 'null' ? ' data-repeater="' . esc_attr( $repeater ) . '"' : ''; + $ajaxloadmore .= $theme_repeater !== 'null' ? ' data-theme-repeater="' . esc_attr( $theme_repeater ) . '"' : ''; } // Post Type. - $ajaxloadmore .= ' data-post-type="' . $post_type . '"'; + $ajaxloadmore .= ' data-post-type="' . esc_attr( $post_type ) . '"'; // Sticky posts. - $ajaxloadmore .= $sticky_posts === 'true' ? ' data-sticky-posts="' . $sticky_posts . '"' : ''; + $ajaxloadmore .= $sticky_posts === 'true' ? ' data-sticky-posts="' . esc_attr( $sticky_posts ) . '"' : ''; // Post Format. - $ajaxloadmore .= ! empty( $post_format ) ? ' data-post-format="' . $post_format . '"' : ''; + $ajaxloadmore .= ! empty( $post_format ) ? ' data-post-format="' . esc_attr( $post_format ) . '"' : ''; // Category. - $ajaxloadmore .= ! empty( $category ) ? ' data-category="' . $category . '"' : ''; - $ajaxloadmore .= ! empty( $category__and ) ? ' data-category-and="' . $category__and . '"' : ''; - $ajaxloadmore .= ! empty( $category__not_in ) ? ' data-category-not-in="' . $category__not_in . '"' : ''; + $ajaxloadmore .= ! empty( $category ) ? ' data-category="' . esc_attr( $category ) . '"' : ''; + $ajaxloadmore .= ! empty( $category__and ) ? ' data-category-and="' . esc_attr( $category__and ) . '"' : ''; + $ajaxloadmore .= ! empty( $category__not_in ) ? ' data-category-not-in="' . esc_attr( $category__not_in ) . '"' : ''; // Tag. - $ajaxloadmore .= ! empty( $tag ) ? ' data-tag="' . $tag . '"' : ''; - $ajaxloadmore .= ! empty( $tag__and ) ? ' data-tag-and="' . $tag__and . '"' : ''; - $ajaxloadmore .= ! empty( $tag__not_in ) ? ' data-tag-not-in="' . $tag__not_in . '"' : ''; + $ajaxloadmore .= ! empty( $tag ) ? ' data-tag="' . esc_attr( $tag ) . '"' : ''; + $ajaxloadmore .= ! empty( $tag__and ) ? ' data-tag-and="' . esc_attr( $tag__and ) . '"' : ''; + $ajaxloadmore .= ! empty( $tag__not_in ) ? ' data-tag-not-in="' . esc_attr( $tag__not_in ) . '"' : ''; // Taxonomy. - $ajaxloadmore .= ! empty( $taxonomy ) ? ' data-taxonomy="' . $taxonomy . '"' : ''; - $ajaxloadmore .= ! empty( $taxonomy_terms ) ? ' data-taxonomy-terms="' . $taxonomy_terms . '"' : ''; - $ajaxloadmore .= ! empty( $taxonomy_operator ) ? ' data-taxonomy-operator="' . $taxonomy_operator . '"' : ''; - $ajaxloadmore .= ! empty( $taxonomy_relation ) ? ' data-taxonomy-relation="' . $taxonomy_relation . '"' : ''; + $ajaxloadmore .= ! empty( $taxonomy ) ? ' data-taxonomy="' . esc_attr( $taxonomy ) . '"' : ''; + $ajaxloadmore .= ! empty( $taxonomy_terms ) ? ' data-taxonomy-terms="' . esc_attr( $taxonomy_terms ) . '"' : ''; + $ajaxloadmore .= ! empty( $taxonomy_operator ) ? ' data-taxonomy-operator="' . esc_attr( $taxonomy_operator ) . '"' : ''; + $ajaxloadmore .= ! empty( $taxonomy_include_children ) ? ' data-taxonomy-include-children="' . esc_attr( $taxonomy_include_children ) . '"' : ''; + $ajaxloadmore .= ! empty( $taxonomy_relation ) ? ' data-taxonomy-relation="' . esc_attr( $taxonomy_relation ) . '"' : ''; // Meta Query. - $ajaxloadmore .= ! empty( $meta_key ) ? ' data-meta-key="' . $meta_key . '"' : ''; - $ajaxloadmore .= ! empty( $meta_value || $meta_value === '0' ) ? ' data-meta-value="' . $meta_value . '"' : ''; - $ajaxloadmore .= ! empty( $meta_compare ) ? ' data-meta-compare="' . $meta_compare . '"' : ''; - $ajaxloadmore .= ! empty( $meta_relation ) ? ' data-meta-relation="' . $meta_relation . '"' : ''; - $ajaxloadmore .= ! empty( $meta_type ) ? ' data-meta-type="' . $meta_type . '"' : ''; + $ajaxloadmore .= ! empty( $meta_key ) ? ' data-meta-key="' . esc_attr( $meta_key ) . '"' : ''; + $ajaxloadmore .= ! empty( $meta_value || $meta_value === '0' ) ? ' data-meta-value="' . esc_attr( $meta_value ) . '"' : ''; + $ajaxloadmore .= ! empty( $meta_compare ) ? ' data-meta-compare="' . esc_attr( $meta_compare ) . '"' : ''; + $ajaxloadmore .= ! empty( $meta_relation ) ? ' data-meta-relation="' . esc_attr( $meta_relation ) . '"' : ''; + $ajaxloadmore .= ! empty( $meta_type ) ? ' data-meta-type="' . esc_attr( $meta_type ) . '"' : ''; // Dates. - $ajaxloadmore .= ! empty( $year ) ? ' data-year="' . $year . '"' : ''; - $ajaxloadmore .= ! empty( $month ) ? ' data-month="' . $month . '"' : ''; - $ajaxloadmore .= ! empty( $day ) ? ' data-day="' . $day . '"' : ''; + $ajaxloadmore .= ! empty( $year ) ? ' data-year="' . esc_attr( $year ) . '"' : ''; + $ajaxloadmore .= ! empty( $month ) ? ' data-month="' . esc_attr( $month ) . '"' : ''; + $ajaxloadmore .= ! empty( $day ) ? ' data-day="' . esc_attr( $day ) . '"' : ''; // Author. - $ajaxloadmore .= ! empty( $author ) ? ' data-author="' . $author . '"' : ''; + $ajaxloadmore .= ! empty( $author ) ? ' data-author="' . esc_attr( $author ) . '"' : ''; // Post Parameters. - $ajaxloadmore .= ! empty( $post__in ) ? ' data-post-in="' . $post__in . '"' : ''; - $ajaxloadmore .= ! empty( $post__not_in ) ? ' data-post-not-in="' . $post__not_in . '"' : ''; - $ajaxloadmore .= ! empty( $exclude ) ? ' data-exclude="' . $exclude . '"' : ''; + $ajaxloadmore .= ! empty( $post__in ) ? ' data-post-in="' . esc_attr( $post__in ) . '"' : ''; + $ajaxloadmore .= ! empty( $post__not_in ) ? ' data-post-not-in="' . esc_attr( $post__not_in ) . '"' : ''; + $ajaxloadmore .= ! empty( $exclude ) ? ' data-exclude="' . esc_attr( $exclude ) . '"' : ''; // Search. - $ajaxloadmore .= ! empty( $search ) ? ' data-search="' . $search . '"' : ''; + $ajaxloadmore .= ! empty( $search ) ? ' data-search="' . esc_attr( $search ) . '"' : ''; // Custom Args. - $ajaxloadmore .= ! empty( $custom_args ) ? ' data-custom-args="' . $custom_args . '"' : ''; + $ajaxloadmore .= ! empty( $custom_args ) ? ' data-custom-args="' . esc_attr( $custom_args ) . '"' : ''; // Vars. - $ajaxloadmore .= ! empty( $vars ) ? ' data-vars="' . $vars . '"' : ''; + $ajaxloadmore .= ! empty( $vars ) ? ' data-vars="' . esc_attr( $vars ) . '"' : ''; // Status. - $ajaxloadmore .= ! empty( $post_status ) ? ' data-post-status="' . $post_status . '"' : ''; + $ajaxloadmore .= ! empty( $post_status ) ? ' data-post-status="' . esc_attr( $post_status ) . '"' : ''; // Order. - $ajaxloadmore .= ' data-order="' . $order . '"'; - $ajaxloadmore .= ' data-orderby="' . $orderby . '"'; + $ajaxloadmore .= ' data-order="' . esc_attr( $order ) . '"'; + $ajaxloadmore .= ' data-orderby="' . esc_attr( $orderby ) . '"'; // Offset. - $ajaxloadmore .= ' data-offset="' . $offset . '"'; + $ajaxloadmore .= ' data-offset="' . esc_attr( $offset ) . '"'; // Posts Per Page. - $ajaxloadmore .= ' data-posts-per-page="' . $posts_per_page . '"'; + $ajaxloadmore .= ' data-posts-per-page="' . esc_attr( $posts_per_page ) . '"'; // Lang. - $ajaxloadmore .= ! empty( $lang ) ? ' data-lang="' . $lang . '"' : ''; + $ajaxloadmore .= ! empty( $lang ) ? ' data-lang="' . esc_attr( $lang ) . '"' : ''; // Scroll. if ( $paging !== 'true' ) { - $ajaxloadmore .= ' data-scroll="' . $scroll . '"'; + $ajaxloadmore .= ' data-scroll="' . esc_attr( $scroll ) . '"'; if ( $scroll === 'true' ) { - $ajaxloadmore .= ' data-scroll-distance="' . $scroll_distance . '"'; - $ajaxloadmore .= ! empty( $scroll_container ) ? ' data-scroll-container="' . $scroll_container . '"' : ''; - $ajaxloadmore .= ! empty( $scroll_direction ) ? ' data-scroll-direction="' . $scroll_direction . '"' : ''; + $ajaxloadmore .= ' data-scroll-distance="' . esc_attr( $scroll_distance ) . '"'; + $ajaxloadmore .= ! empty( $scroll_container ) ? ' data-scroll-container="' . esc_attr( $scroll_container ) . '"' : ''; + $ajaxloadmore .= ! empty( $scroll_direction ) ? ' data-scroll-direction="' . esc_attr( $scroll_direction ) . '"' : ''; $ajaxloadmore .= ' data-max-pages="' . $max_pages . '"'; - $ajaxloadmore .= ! empty( $pause_override ) ? ' data-pause-override="' . $pause_override . '"' : ''; + $ajaxloadmore .= ! empty( $pause_override ) ? ' data-pause-override="' . esc_attr( $pause_override ) . '"' : ''; } } // Pause. - $ajaxloadmore .= ' data-pause="' . $pause . '"'; + $ajaxloadmore .= ' data-pause="' . esc_attr( $pause ) . '"'; // Button. - $ajaxloadmore .= ' data-button-label="' . $button_label . '"'; - $ajaxloadmore .= ! empty( $button_loading_label ) ? ' data-button-loading-label="' . $button_loading_label . '"' : ''; - $ajaxloadmore .= ! empty( $button_done_label ) ? ' data-button-done-label="' . $button_done_label . '"' : ''; + $ajaxloadmore .= ' data-button-label="' . wp_kses_post( $button_label ) . '"'; + $ajaxloadmore .= ! empty( $button_loading_label ) ? ' data-button-loading-label="' . wp_kses_post( $button_loading_label ) . '"' : ''; + $ajaxloadmore .= ! empty( $button_done_label ) ? ' data-button-done-label="' . wp_kses_post( $button_done_label ) . '"' : ''; // Destroy After. - $ajaxloadmore .= ! empty( $destroy_after ) ? ' data-destroy-after="' . $destroy_after . '"' : ''; + $ajaxloadmore .= ! empty( $destroy_after ) ? ' data-destroy-after="' . esc_attr( $destroy_after ) . '"' : ''; // Transition. - $ajaxloadmore .= $transition !== 'fade' ? ' data-transition="' . $transition . '"' : ''; - $ajaxloadmore .= $transition_container === 'false' ? ' data-transition-container="' . $transition_container . '"' : ''; - $ajaxloadmore .= ! empty( $transition_container_classes ) ? ' data-transition-container-classes="' . $transition_container_classes . '"' : ''; + $ajaxloadmore .= $transition !== 'fade' ? ' data-transition="' . esc_attr( $transition ) . '"' : ''; + $ajaxloadmore .= $transition_container === 'false' ? ' data-transition-container="' . esc_attr( $transition_container ) . '"' : ''; + $ajaxloadmore .= ! empty( $transition_container_classes ) ? ' data-transition-container-classes="' . esc_attr( $transition_container_classes ) . '"' : ''; // Masonry. if ( 'masonry' === $transition ) { $masonry_config = [ - 'selector' => $masonry_selector, - 'columnwidth' => $masonry_columnwidth, - 'animation' => $masonry_animation, - 'horizontalorder' => $masonry_horizontalorder, + 'selector' => esc_attr( $masonry_selector ), + 'columnwidth' => esc_attr( $masonry_columnwidth ), + 'animation' => esc_attr( $masonry_animation ), + 'horizontalorder' => esc_attr( $masonry_horizontalorder ), ]; $ajaxloadmore .= ' data-masonry-config="' . htmlspecialchars( wp_json_encode( $masonry_config ), ENT_QUOTES, 'UTF-8' ) . '"'; } // Images Loaded. - $ajaxloadmore .= $images_loaded !== 'false' ? ' data-images-loaded="' . $images_loaded . '"' : ''; + $ajaxloadmore .= $images_loaded !== 'false' ? ' data-images-loaded="' . esc_attr( $images_loaded ) . '"' : ''; // Lazy Load Images. - $ajaxloadmore .= $lazy_images !== false ? ' data-lazy-images="' . $lazy_images . '"' : ''; + $ajaxloadmore .= $lazy_images !== false ? ' data-lazy-images="' . esc_attr( $lazy_images ) . '"' : ''; // Primary. $ajaxloadmore .= $primary !== false ? ' data-primary="true"' : ''; @@ -1239,7 +1243,7 @@ public static function alm_render_shortcode( $atts ) { // SEO Offset. if ( $seo_offset === 'true' ) { - $ajaxloadmore .= '
    '; + $ajaxloadmore .= '
    '; } // Preloaded. @@ -1281,7 +1285,7 @@ public static function alm_render_shortcode( $atts ) { // Next Page Add-on. if ( has_action( 'alm_nextpage_installed' ) && $nextpage ) { - $nextpage_start = alm_get_startpage(); // Located in `core/functions.php`. + $nextpage_start = alm_get_startpage(); // Located in `core/functions.php`. $nextpage_is_paged = $nextpage_start > 1 ? true : false; /** @@ -1289,7 +1293,7 @@ public static function alm_render_shortcode( $atts ) { * * @return boolean; */ - $nextpage_is_paged = apply_filters( 'alm_nextpage_paged', $nextpage_is_paged ); + $nextpage_is_paged = apply_filters( 'alm_nextpage_paged', $nextpage_is_paged ); $ajaxloadmore .= apply_filters( 'alm_init_nextpage', $nextpage_post_id, $nextpage_start, $nextpage_is_paged, $paging, $div_id, $id, $nested ); @@ -1395,15 +1399,18 @@ public static function alm_render_shortcode( $atts ) { // Get the localized data. $localized_data = ALM_LOCALIZE::return_localized_data( $localize_id ); - /** * Append the localized data `', json_encode( $localized_data[$localize_id] ) ); - }); + add_action( + 'wp_footer', + function() use ( $localized_data, $localize_id ) { + // phpcs:ignore + printf( '', json_encode( $localized_data[ $localize_id ] ) ); + } + ); // End $ajaxloadmore element. return $ajaxloadmore; diff --git a/core/classes/includes/preloaded.php b/core/classes/includes/preloaded.php index 414b7fd..b061ad7 100755 --- a/core/classes/includes/preloaded.php +++ b/core/classes/includes/preloaded.php @@ -167,8 +167,8 @@ } } -// Advanced Custom Fields (Repeater, Gallery, Flex Content) -elseif ( $acf && ( $acf_field_type !== 'relationship' ) ) { +// Advanced Custom Fields (Repeater, Gallery, Flex Content). +elseif ( $acf && $acf_field_type !== 'relationship' ) { if ( has_action( 'alm_acf_installed' ) && $acf ) { @@ -179,7 +179,6 @@ */ $preloaded_acf = apply_filters( 'alm_acf_preloaded', $query_args, $repeater, $theme_repeater ); // located in ACF add-on - // Add total_posts to localized ALM JS variables $acf_total_rows = apply_filters( 'alm_acf_total_rows', $query_args ); ALM_LOCALIZE::add_localized_var( 'total_posts', $acf_total_rows, $localize_id ); @@ -300,7 +299,7 @@ ALM_LOCALIZE::add_localized_var( 'post_count', $alm_post_count, $localize_id ); // Get Filter Facets. - if ( $filters && $facets === 'true' && function_exists( 'alm_filters_get_facets' ) && ! empty( $target ) ) { + if ( $filters && $facets && function_exists( 'alm_filters_get_facets' ) && ! empty( $target ) ) { ALM_LOCALIZE::add_localized_var( 'facets', alm_filters_get_facets( $args, $target ), $localize_id ); } diff --git a/core/dist/js/ajax-load-more.js b/core/dist/js/ajax-load-more.js index 44eb91a..6eab58b 100644 --- a/core/dist/js/ajax-load-more.js +++ b/core/dist/js/ajax-load-more.js @@ -164,7 +164,6 @@ function wooCache(alm, content) { _axios2.default.post(alm_localize.ajaxurl, formData).then(function () { console.log('Cache created for post: ' + alm.canonical_url); - //console.log(response); }); } @@ -637,11 +636,10 @@ function _interopRequireDefault(obj) { var FILTERS_CLASSNAME = 'alm-filters'; /** - * parseQuerystring - * Parse a filter querystring for returning caches directories + * Parse a filter querystring for returning caches directories. * - * @param {Object} alm - * @param {Array} elements + * @param {object} alm The ALM object. + * @param {array} elements An array of filter elements. * @since 5.3.1 */ function parseQuerystring(path) { @@ -682,11 +680,11 @@ function parseQuerystring(path) { } /** - * Build new paging URL for filters + * Build new paging URL for filters. * - * @param {Object} alm - * @param {String} querystring - * @param {Int} page + * @param {object} alm The ALM object. + * @param {string} querystring The current querystring. + * @param {number} page The page number. * @since 5.3.5 */ function buildFilterURL(alm) { @@ -720,10 +718,10 @@ function buildFilterURL(alm) { } /** - * Create data attributes for Filters paged results + * Create data attributes for Filters paged results. * - * @param {Object} alm - * @param {Array} elements + * @param {object} alm The ALM object. + * @param {array} elements An array of filter elements. * @since 5.3.1 */ function createMasonryFiltersPage(alm, element) { @@ -742,8 +740,8 @@ function createMasonryFiltersPage(alm, element) { /** * Create data attributes for Filters - used when ?pg=2, ?pg=3 etc are hit on page load * - * @param {Object} alm - * @param {Array} elements + * @param {object} alm The ALM object. + * @param {array} elements An array of filter elements. * @since 5.3.1 */ function createMasonryFiltersPages(alm, elements) { @@ -784,7 +782,15 @@ function createMasonryFiltersPages(alm, elements) { return elements; } -// Create the attributes (page, url, classes) for the masonry items +/** + * Create the attributes (page, url, classes) for the masonry items. + * + * @param {object} alm The ALM object. + * @param {Element} element The container element. + * @param {string} querystring The current querystring. + * @param {number} page The page number. + * @returns + */ function masonryFiltersAtts(alm, element, querystring, pagenum) { element.classList.add(FILTERS_CLASSNAME); element.dataset.page = pagenum; @@ -1441,7 +1447,7 @@ function getContainerCount(container) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.render = exports.getOffset = exports.almScroll = exports.start = exports.tab = exports.tracking = exports.getTotalPosts = exports.getPostCount = exports.reset = exports.filter = undefined; +exports.click = exports.render = exports.getOffset = exports.almScroll = exports.start = exports.tab = exports.tracking = exports.getTotalPosts = exports.getPostCount = exports.reset = exports.filter = undefined; var _axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js"); @@ -1595,7 +1601,7 @@ function _asyncToGenerator(fn) { }; } -/* +/** * Ajax Load More * https://connekthq.com/plugins/ajax-load-more/ * Author: Darren Cooney @@ -1631,7 +1637,7 @@ var alm_is_filtering = false; /** * Initiate Ajax Load More. * - * @param {HTMLElement} el The Ajax Load More DOM element/container. + * @param {Element} el The Ajax Load More DOM element/container. * @param {Number} index The current index number of the Ajax Load More instance. */ @@ -1671,6 +1677,9 @@ var alm_is_filtering = false; alm.master_id = alm.master_id.replace(/-/g, '_'); // Convert dashes to underscores for the var name alm.localize = window[alm.master_id + '_vars']; // Get localize vars + // Add ALM object to the global window scope. + window[alm.master_id] = alm; // e.g. window.ajax_load_more or window.ajax_load_more_{id} + // ALM Element Containers alm.main = el; // Top level DOM element alm.listing = el.querySelector('.alm-listing') || el.querySelector('.alm-comments'); @@ -1834,8 +1843,8 @@ var alm_is_filtering = false; // Extension Shortcode Params // REST API. - alm.extensions.restapi = alm.listing.dataset.restapi; - if (alm.extensions.restapi === 'true') { + alm.extensions.restapi = alm.listing.dataset.restapi === 'true' ? true : false; + if (alm.extensions.restapi) { alm.extensions.restapi_base_url = alm.listing.dataset.restapiBaseUrl; alm.extensions.restapi_namespace = alm.listing.dataset.restapiNamespace; alm.extensions.restapi_endpoint = alm.listing.dataset.restapiEndpoint; @@ -1844,26 +1853,24 @@ var alm_is_filtering = false; } // ACF. - alm.extensions.acf = alm.listing.dataset.acf; - if (alm.extensions.acf === 'true') { + alm.extensions.acf = alm.listing.dataset.acf === 'true' ? true : false; + if (alm.extensions.acf) { alm.extensions.acf_field_type = alm.listing.dataset.acfFieldType; alm.extensions.acf_field_name = alm.listing.dataset.acfFieldName; alm.extensions.acf_parent_field_name = alm.listing.dataset.acfParentFieldName; alm.extensions.acf_post_id = alm.listing.dataset.acfPostId; - alm.extensions.acf = alm.extensions.acf === 'true' ? true : false; - // if field type, name or post ID is empty + // if field type, name or post ID is empty. if (alm.extensions.acf_field_type === undefined || alm.extensions.acf_field_name === undefined || alm.extensions.acf_post_id === undefined) { alm.extensions.acf = false; } } // Term Query. - alm.extensions.term_query = alm.listing.dataset.termQuery; - if (alm.extensions.term_query === 'true') { + alm.extensions.term_query = alm.listing.dataset.termQuery === 'true' ? true : false; + if (alm.extensions.term_query) { alm.extensions.term_query_taxonomy = alm.listing.dataset.termQueryTaxonomy; alm.extensions.term_query_hide_empty = alm.listing.dataset.termQueryHideEmpty; alm.extensions.term_query_number = alm.listing.dataset.termQueryNumber; - alm.extensions.term_query = alm.extensions.term_query === 'true' ? true : false; } // Paging. @@ -1944,17 +1951,12 @@ var alm_is_filtering = false; } else { alm.addons.tabs = false; } - /* End Tabs */ /* REST API */ - if (alm.extensions.restapi === 'true') { - alm.extensions.restapi = true; + if (alm.extensions.restapi) { alm.extensions.restapi_debug = alm.extensions.restapi_debug === undefined ? false : alm.extensions.restapi_debug; alm.extensions.restapi = alm.extensions.restapi_template_id === '' ? false : alm.extensions.restapi; - } else { - alm.extensions.restapi = false; } - /* End REST API */ /* Preloaded */ if (alm.addons.preloaded === 'true') { @@ -2675,21 +2677,21 @@ var alm_is_filtering = false; } } - // Set Filter Facets + /** + * Set Filter Facets. + */ if (alm.addons.filters && alm.facets && data.facets && typeof almFiltersFacets === 'function') { window.almFiltersFacets(data.facets); } /** - * Display alm_debug results + * Display alm_debug results. */ - (0, _almDebug2.default)(alm); /** - * Set localized variables and Results Text + * Set localized variables and Results Text. */ - _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { @@ -2709,7 +2711,6 @@ var alm_is_filtering = false; /** * Render results */ - if (total > 0) { // We have results! @@ -2980,7 +2981,7 @@ var alm_is_filtering = false; } } }, _callee4, this); - }))().catch(function (e) { + }))().catch(function () { console.log('There was an error with ALM Masonry'); }); } @@ -3577,7 +3578,7 @@ var alm_is_filtering = false; /** * Set the Load Previous button to alm object. * - * @param {HTMLElement} button The button element. + * @param {Element} button The button element. * @since 5.5.0 */ alm.AjaxLoadMore.setPreviousButton = function (button) { @@ -4170,38 +4171,48 @@ var reset = function reset() { exports.reset = reset; /** - * Get the total post count in the current query by ALM instance ID. + * Get the total post count in the current query by ALM instance ID from the ALM Localized variables. + * + * @see https://github.com/dcooney/wordpress-ajax-load-more/blob/main/core/classes/class-alm-localize.php * - * @param {string} id The ALM ID. + * @param {string} id An optional Ajax Load More ID. * @return {Number} The results from the localized variable. */ var getPostCount = function getPostCount() { - var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; + var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + // Get the ALM localized variable name. + var localize_var = id ? 'ajax_load_more_' + id + '_vars' : 'ajax_load_more_vars'; - var theID = window['ajax_load_more_' + id + '_vars']; - if (!theID && !theID.post_count) { + // Get the value from the window object. + var localized = window[localize_var]; + if (!localized && !localized.post_count) { return null; } - return parseInt(theID.post_count); + return parseInt(localized.post_count); }; exports.getPostCount = getPostCount; /** - * Get the total number of posts by ALM instance ID. + * Get the total number of posts by ALM instance ID from the ALM Localized variables. * - * @param {string} id The ALM ID. + * @param {string} id An optional Ajax Load More ID. * @return {Number} The results from the localized variable. */ var getTotalPosts = function getTotalPosts() { - var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; + var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - var theID = window['ajax_load_more_' + id + '_vars']; - if (!theID && !theID.total_posts) { + // Get the ALM localized variable name. + var localize_var = id ? 'ajax_load_more_' + id + '_vars' : 'ajax_load_more_vars'; + + // Get the value from the window object. + var localized = window[localize_var]; + if (!localized && !localized.total_posts) { return null; } - return parseInt(theID.total_posts); + return parseInt(localized.total_posts); }; exports.getTotalPosts = getTotalPosts; @@ -4283,7 +4294,7 @@ exports.tab = tab; * Trigger Ajax Load More from other events. * * @since 5.0 - * @param {*} el + * @param {Element} el */ var start = function start(el) { @@ -4298,7 +4309,7 @@ exports.start = start; * Scroll window to position (global function). * * @since 5.0 - * @param {*} position + * @param {string} position The position of the scrollto. */ var almScroll = function almScroll(position) { @@ -4348,6 +4359,32 @@ var render = function render(el) { }; exports.render = render; +/** + * Trigger a click event to load Ajax Load More content. + * + * @param {string} id The Ajax Load More ID. + */ + +var click = function click() { + var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + var alm = document.querySelector('.ajax-load-more-wrap'); + var button = ''; + if (!id && alm) { + // Default ALM element. + button = alm.querySelector('button.alm-load-more-btn'); + button && button.click(); + } else { + // Ajax Load More by ID. + alm = document.querySelector('.ajax-load-more-wrap[data-id="' + id + '"]'); + if (alm) { + button = alm.querySelector('button.alm-load-more-btn'); + button && button.click(); + } + } +}; +exports.click = click; + /***/ }), /***/ "./core/src/js/helpers/almAppendChild.js": @@ -4363,17 +4400,16 @@ exports.render = render; Object.defineProperty(exports, "__esModule", { value: true }); +var nodeNameArray = ['#text', '#comment']; + /** * Append a child element to a container * - * @param {*} target | Target element to append items - * @param {*} element | The element to append - * @param {*} transition | The transiton + * @param {Element} target | Target element to append items + * @param {Element} element | The element to append + * @param {string} transition | The transiton * @since 5.0 */ - -var nodeNameArray = ['#text', '#comment']; - var almAppendChild = function almAppendChild() { var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var element = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; @@ -4422,9 +4458,9 @@ function _interopRequireDefault(obj) { /** * Loop array of elements and append to target * - * @param {*} target | Target element to append items - * @param {*} array | An array of elements - * @param {*} transition | The transiton + * @param {Element} target | Target element to append items + * @param {Element} array | An array of elements + * @param {string} transition | The transiton * @since 5.0 */ @@ -4621,16 +4657,16 @@ exports.default = getCacheUrl; Object.defineProperty(exports, "__esModule", { - value: true + value: true }); var getParameterByName = function getParameterByName(name, url) { - if (!url) url = window.location.href; - name = name.replace(/[\[\]]/g, "\\$&"); - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), - results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, " ")); + if (!url) url = window.location.href; + name = name.replace(/[\[\]]/g, '\\$&'); + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, ' ')); }; exports.default = getParameterByName; @@ -5181,6 +5217,9 @@ function almGetAjaxParams(alm, action, queryType) { if (alm.listing.dataset.taxonomyOperator) { data.taxonomy_operator = alm.listing.dataset.taxonomyOperator; } + if (alm.listing.dataset.taxonomyIncludeChildren) { + data.taxonomy_include_children = alm.listing.dataset.taxonomyIncludeChildren; + } if (alm.listing.dataset.taxonomyRelation) { data.taxonomy_relation = alm.listing.dataset.taxonomyRelation; } @@ -5363,7 +5402,7 @@ exports.default = srcsetPolyfill; Object.defineProperty(exports, "__esModule", { - value: true + value: true }); /** * Remove empty HTML nodes from array of nodes @@ -5374,22 +5413,22 @@ Object.defineProperty(exports, "__esModule", { * @since 5.1.3 */ var stripEmptyNodes = function stripEmptyNodes() { - var nodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + var nodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - if (!nodes) { - return false; - } + if (!nodes) { + return false; + } - // Exclude these nodeNames from being rendered - var nodeNameArray = ['#text', '#comment']; + // Exclude these nodeNames from being rendered + var nodeNameArray = ['#text', '#comment']; - // Filter data by nodeName - var results = nodes.filter(function (node) { - return nodeNameArray.indexOf(node.nodeName.toLowerCase()) === -1; - }); + // Filter data by nodeName + var results = nodes.filter(function (node) { + return nodeNameArray.indexOf(node.nodeName.toLowerCase()) === -1; + }); - // Send the results - return results; + // Send the results + return results; }; exports.default = stripEmptyNodes; @@ -5406,25 +5445,25 @@ exports.default = stripEmptyNodes; Object.defineProperty(exports, "__esModule", { - value: true + value: true }); /** * Wrap `table` containers in tbody elements * innerHTML and DOMParser do not work with elements etc. * - * @param {*} html | Plain text + * @param {string} html Plain text HTML. * @since 5.0 */ var tableWrap = function tableWrap() { - var html = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + var html = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - if (!html) { - return false; - } - var table_reveal = document.createElement('tbody'); - table_reveal.innerHTML = html; - var table_reveal_array = [table_reveal]; - return table_reveal_array; // Return new array + if (!html) { + return false; + } + var table_reveal = document.createElement('tbody'); + table_reveal.innerHTML = html; + var table_reveal_array = [table_reveal]; + return table_reveal_array; // Return new array }; exports.default = tableWrap; @@ -5859,9 +5898,9 @@ var getButtonURL = exports.getButtonURL = function getButtonURL(alm) { /** * Set button dataset attributes. * - * @param {*} button The HTML element. - * @param {*} page The current page number. - * @param {*} url The URL for updating. + * @param {Element} button The HTML element. + * @param {number} page The current page number. + * @param {string} url The URL for updating. */ var setButtonAtts = exports.setButtonAtts = function setButtonAtts(button, page, url) { if (!button) { @@ -5892,11 +5931,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); /** - * getScrollPercentage - * Get the scroll distance in pixels from a percentage - * - * @param {Object} alm - * @return {NUMBER} newdistance + * Get the scroll distance in pixels from a percentage. + * + * @param {object} alm The Ajax Load More object. + * @return {number} The new distance. * @since 5.2 */ @@ -5905,14 +5943,11 @@ var getScrollPercentage = function getScrollPercentage(alm) { return false; } - var is_negative = alm.scroll_distance_orig.toString().indexOf("-") === -1 ? false : true; // Is this a negative number - var raw_distance = alm.scroll_distance_orig.toString().replace("-", "").replace("%", ""); // Remove - and perc + var is_negative = alm.scroll_distance_orig.toString().indexOf('-') === -1 ? false : true; // Is this a negative number + var raw_distance = alm.scroll_distance_orig.toString().replace('-', '').replace('%', ''); // Remove - and perc var wh = alm.window.innerHeight; // window height - var height = Math.floor(wh / 100 * parseInt(raw_distance)); // Do math to get distance - - var newdistance = is_negative ? "-" + height : height; // Set the distance - //console.log(parseInt(newdistance)); + var newdistance = is_negative ? '-' + height : height; // Set the distance return parseInt(newdistance); }; @@ -5946,11 +5981,10 @@ function _interopRequireDefault(obj) { * insertScript * Search nodes for