diff --git a/includes/assets/js/NFDPluginsMarketplace.js b/includes/assets/js/NFDPluginsMarketplace.js index 8a4df72..f4981dc 100644 --- a/includes/assets/js/NFDPluginsMarketplace.js +++ b/includes/assets/js/NFDPluginsMarketplace.js @@ -1,99 +1,119 @@ /** * Class to show Marketplace products (plugins) in a tab under plugin-install.php */ -class NFDPluginsMarketplace { - constructor() { - // Add event listener for when the DOM is loaded - window.addEventListener('DOMContentLoaded', () => { - this.setupContainer(); - - // Fetch data from the Marketplace API - fetch(nfdPremiumPluginsMarketplace.restApiRoot + '/newfold-marketplace/v1/marketplace', { - credentials: 'same-origin', - headers: { - 'Content-Type': 'application/json', - 'X-WP-Nonce': nfdPremiumPluginsMarketplace.restApiNonce - } - }) - .then((response) => response.json()) - .then((data) => { - if (! data.hasOwnProperty('products')) { - this.isError(); - } else { - this.isLoaded(); - this.showProducts(this.filterProducts(data.products.data)); - } - }) - }) - } - // Function that sets up the container for the plugin marketplace - setupContainer() { - const pluginsListTable = document.createElement('div'); - pluginsListTable.classList.add('wp-list-table', 'widefat', 'plugin-install', 'nfd-premium-plugins-marketplace'); - pluginsListTable.innerHTML = `
${nfdPremiumPluginsMarketplace.marketplaceDescription}