Skip to content

Commit 4479d3a

Browse files
feat: add PHP compatibility check for featured plugins suggestion
1 parent daf4239 commit 4479d3a

File tree

2 files changed

+49
-42
lines changed

2 files changed

+49
-42
lines changed

includes/Admin.php

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -816,57 +816,57 @@ private function get_localization() {
816816
}
817817

818818
return array(
819-
'version' => TIOB_VERSION,
820-
'nonce' => wp_create_nonce( 'wp_rest' ),
821-
'assets' => TIOB_URL . 'assets/',
822-
'upgradeURL' => $upgrade_url,
823-
'upgradeURLTpc' => $upgrade_url_tpc,
824-
'siteUrl' => trailingslashit( get_site_url() ),
825-
'strings' => array(
819+
'version' => TIOB_VERSION,
820+
'nonce' => wp_create_nonce( 'wp_rest' ),
821+
'assets' => TIOB_URL . 'assets/',
822+
'upgradeURL' => $upgrade_url,
823+
'upgradeURLTpc' => $upgrade_url_tpc,
824+
'siteUrl' => trailingslashit( get_site_url() ),
825+
'strings' => array(
826826
/* translators: %s - Theme name */
827827
'starterSitesTabDescription' => __( 'Choose from multiple unique demos, specially designed for you, that can be installed with a single click. You just need to choose your favorite, and we will take care of everything else.', 'templates-patterns-collection' ),
828828
),
829-
'cleanupAllowed' => ( ! empty( get_transient( Active_State::STATE_NAME ) ) ) ? 'yes' : 'no',
830-
'onboarding' => array(),
831-
'hasFileSystem' => WP_Filesystem(),
832-
'themesURL' => admin_url( 'themes.php' ),
833-
'themeAction' => $this->get_theme_action(),
834-
'brandedTheme' => $this->get_whitelabel_name(),
835-
'hideStarterSites' => $this->is_starter_sites_disabled(),
836-
'hideMyLibrary' => $this->is_library_disabled(),
837-
'fontParings' => $this->font_pairs_neve,
838-
'endpoint' => ( defined( 'TPC_TEMPLATES_CLOUD_ENDPOINT' ) ) ? TPC_TEMPLATES_CLOUD_ENDPOINT : self::get_templates_cloud_endpoint(),
839-
'params' => array(
829+
'cleanupAllowed' => ( ! empty( get_transient( Active_State::STATE_NAME ) ) ) ? 'yes' : 'no',
830+
'onboarding' => array(),
831+
'hasFileSystem' => WP_Filesystem(),
832+
'themesURL' => admin_url( 'themes.php' ),
833+
'themeAction' => $this->get_theme_action(),
834+
'brandedTheme' => $this->get_whitelabel_name(),
835+
'hideStarterSites' => $this->is_starter_sites_disabled(),
836+
'hideMyLibrary' => $this->is_library_disabled(),
837+
'fontParings' => $this->font_pairs_neve,
838+
'endpoint' => ( defined( 'TPC_TEMPLATES_CLOUD_ENDPOINT' ) ) ? TPC_TEMPLATES_CLOUD_ENDPOINT : self::get_templates_cloud_endpoint(),
839+
'params' => array(
840840
'site_url' => get_site_url(),
841841
'license_id' => License::get_license_data()->key,
842842
),
843-
'upsellNotifications' => $this->get_upsell_notifications(),
844-
'isValidLicense' => $this->has_valid_addons(),
845-
'licenseTIOB' => License::get_license_data(),
846-
'emailSubscribe' => array(
843+
'upsellNotifications' => $this->get_upsell_notifications(),
844+
'isValidLicense' => $this->has_valid_addons(),
845+
'licenseTIOB' => License::get_license_data(),
846+
'emailSubscribe' => array(
847847
'ajaxURL' => esc_url( admin_url( 'admin-ajax.php' ) ),
848848
'nonce' => wp_create_nonce( 'skip_subscribe_nonce' ),
849849
'skipStatus' => $this->get_skip_subscribe_status() ? 'yes' : 'no',
850850
'email' => ( ! empty( $user->user_email ) ) ? $user->user_email : '',
851851
),
852-
'onboardingDone' => array(
852+
'onboardingDone' => array(
853853
'ajaxURL' => esc_url( admin_url( 'admin-ajax.php' ) ),
854854
'nonce' => wp_create_nonce( 'onboarding_done_nonce' ),
855855
),
856-
'feedback' => array(
856+
'feedback' => array(
857857
'count' => get_option( self::IMPORTED_TEMPLATES_COUNT_OPT, 0 ),
858858
'dismissed' => get_option( self::FEEDBACK_DISMISSED_OPT, false ),
859859
),
860-
'onboardingUpsell' => array(
860+
'onboardingUpsell' => array(
861861
'dashboard' => tsdk_translate_link( tsdk_utmify( 'https://store.themeisle.com/', 'onboarding_upsell' ), 'query' ),
862862
'contact' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/contact/', 'onboarding_upsell' ), 'query' ),
863863
'upgrade' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'onboarding_upsell' ), 'query' ),
864864
'upgradeToast' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/', 'onboarding_toast' ), 'query' ),
865865
),
866-
'onboardingAllowed' => $this->should_load_onboarding(),
867-
'onboardingRedirect' => admin_url( 'admin.php?page=neve-onboarding' ),
868-
'tiobSettings' => admin_url( 'admin.php?page=tiob-plugin#settings' ),
869-
'links' => array(
866+
'onboardingAllowed' => $this->should_load_onboarding(),
867+
'onboardingRedirect' => admin_url( 'admin.php?page=neve-onboarding' ),
868+
'tiobSettings' => admin_url( 'admin.php?page=tiob-plugin#settings' ),
869+
'links' => array(
870870
array(
871871
'label' => __( 'Support', 'templates-patterns-collection' ),
872872
'is_external' => true,
@@ -888,12 +888,15 @@ private function get_localization() {
888888
'is_button' => true,
889889
),
890890
),
891-
'isFSETheme' => self::is_fse_theme(),
892-
'newTCNotice' => array(
891+
'isFSETheme' => self::is_fse_theme(),
892+
'newTCNotice' => array(
893893
'show' => get_option( self::TC_NEW_NOTICE_DISMISSED, 'no' ) !== 'yes' && self::has_legacy_template_cloud(),
894894
'ajaxURL' => esc_url( admin_url( 'admin-ajax.php' ) ),
895895
'nonce' => wp_create_nonce( 'dismiss_new_tc_notice' ),
896896
),
897+
'onboardingPluginCompatibility' => array(
898+
'hyve-lite' => is_php_version_compatible( '8.1' ),
899+
),
897900
);
898901
}
899902

onboarding/src/Components/FeaturesList.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const decodeHtmlEntities = (str) => {
1010
};
1111

1212
/**
13-
* Product display.
13+
* Plugins to promote.
1414
*/
1515
const featuredPluginCollection = [
1616
{
@@ -47,20 +47,20 @@ const featuredPluginCollection = [
4747
id: 'chatbot',
4848
pluginSlug: 'hyve-lite',
4949
label: __('AI ChatBot', 'templates-patterns-collection'),
50-
description: __('Add intelligent chat functionality to your site.', 'templates-patterns-collection')
51-
},
50+
description: __('Add intelligent chat functionality to your site.', 'templates-patterns-collection'),
51+
}
52+
];
53+
54+
/**
55+
* Appears only if they are a part of the required plugins for template site.
56+
*/
57+
const pluginCollection = [
5258
{
5359
id: 'visualizer',
5460
pluginSlug: 'visualizer',
5561
label: __('Tables and Chart', 'templates-patterns-collection'),
5662
description: __('A powerful and easy to use plugin for responsive charts & tables.', 'templates-patterns-collection')
5763
},
58-
];
59-
60-
/**
61-
* Third-party product display. Appears only if they are a part of the required plugins for template site.
62-
*/
63-
const thirdPartyFeaturedPluginCollection = [
6464
{
6565
id: 'woocommerce',
6666
pluginSlug: 'woocommerce',
@@ -157,7 +157,11 @@ const FeaturesList = ({ requiredPlugins, onToggle }) => {
157157
useEffect(() => {
158158
const requiredPluginSlugs = Object.keys(requiredPlugins ?? {});
159159

160-
const allProductDisplay = [...featuredPluginCollection, ...thirdPartyFeaturedPluginCollection];
160+
const compatibleFeaturedPlugins = featuredPluginCollection.filter(feature =>
161+
window.tiobDash?.onboardingPluginCompatibility?.[feature.pluginSlug] !== false
162+
);
163+
164+
const allProductDisplay = [...compatibleFeaturedPlugins, ...pluginCollection];
161165

162166
const missingRequiredPlugins = Object.entries(requiredPlugins ?? {})
163167
.filter(([slug]) => allProductDisplay.every(({ pluginSlug }) => slug !== pluginSlug))
@@ -181,7 +185,7 @@ const FeaturesList = ({ requiredPlugins, onToggle }) => {
181185
];
182186

183187
if (orderedFeatures.length < MAX_FEATURE_LIST_LENGTH) {
184-
const additionalFeatures = featuredPluginCollection.filter(
188+
const additionalFeatures = compatibleFeaturedPlugins.filter(
185189
({ pluginSlug }) => !orderedFeatures.some(f => f.pluginSlug === pluginSlug)
186190
);
187191

0 commit comments

Comments
 (0)