Skip to content

Commit

Permalink
Install dependent entitlements first
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshenoy99 committed Oct 22, 2024
1 parent 079a320 commit 8cad4a3
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build/1.2.0-beta.6/dataAttrListener.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-dom-ready'), 'version' => 'd688a7c45dc137ed4ceb');
<?php return array('dependencies' => array('wp-dom-ready'), 'version' => 'b208b9a3938b304abbde');
2 changes: 1 addition & 1 deletion build/1.2.0-beta.6/dataAttrListener.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/1.2.0-beta.6/installer.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '0d7170526bf9b8a49427');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '0374e667fa1f111980fb');
4 changes: 2 additions & 2 deletions build/1.2.0-beta.6/installer.js

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions src/Installer/components/Modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,49 @@ const Modal = ( {
};
}, [ pluginStatus ] );

// Function to handle premium plugin installation
const installDependantPlugins = async () => {
try {
// TODO: Change this logic to ensure we get dependent plugins as a prop
if ( pluginProvider === 'yith' ) {
await apiFetch( {
url: installerAPI,
method: 'POST',
headers: {
'X-NFD-INSTALLER': pluginInstallHash,
},
data: {
activate: true,
queue: false,
priority: 0,
plugin: 'woocommerce',
},
} );
} else if ( pluginProvider === 'yoast' ) {
// TODO: This will cause 2 calls to install the Yoast SEO Plugin. Remove this once we have dependent plugins as a prop.
await apiFetch( {
url: installerAPI,
method: 'POST',
headers: {
'X-NFD-INSTALLER': pluginInstallHash,
},
data: {
activate: true,
queue: false,
priority: 0,
plugin: 'wordpress-seo',
},
} );
}
} catch ( error ) {
throw error;
}
};

const installPremiumPlugin = async () => {
try {
setPluginStatus( 'installing' );
await installDependantPlugins();
await apiFetch( {
url: installerAPI,
method: 'POST',
Expand All @@ -107,6 +147,7 @@ const Modal = ( {
const installFreePlugin = async () => {
try {
setPluginStatus( 'installing' );
await installDependantPlugins();
await apiFetch( {
url: installerAPI,
method: 'POST',
Expand Down
3 changes: 3 additions & 0 deletions src/Scripts/dataAttrListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ domReady( () => {
pluginDownloadUrl: el.getAttribute(
'data-nfd-installer-download-url'
),
pluginProvider: el.getAttribute(
'data-nfd-installer-pls-provider'
),
redirectUrl,
} );
return false;
Expand Down

0 comments on commit 8cad4a3

Please sign in to comment.