Skip to content

Commit f8f0967

Browse files
authored
Merge pull request #3930 from reduxframework/update-extendify-3dia7hm
Update Extendify Library
2 parents 06dbb68 + 54326d0 commit f8f0967

File tree

91 files changed

+2036
-710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2036
-710
lines changed

extendify-sdk/app/AdminPageRouter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function addAdminMenu()
133133
$badgeCount = $remainingTasks > 9 ? '9' : strval($remainingTasks);
134134
$menuLabel = Config::$launchCompleted ? __('Site Assistant', 'extendify') : __('Site Launcher', 'extendify');
135135
$menuLabel = Config::$showOnboarding ? $menuLabel : 'Extendify';
136-
$menuLabel = sprintf('%1$s <span class="extendify-assist-badge-count"></span>', $menuLabel);
136+
$menuLabel = sprintf('%1$s <span class="extendify-assist-badge-count" data-test="assist-badge-count"></span>', $menuLabel);
137137

138138
\add_menu_page(
139139
'Extendify',

extendify-sdk/app/Assist/Admin.php

Lines changed: 75 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,14 @@ function () {
6565
return;
6666
}
6767

68+
$partnerData = $this->checkPartnerDataSources();
69+
70+
$logo = isset($partnerData['logo']) ? $partnerData['logo'] : null;
71+
$name = isset($partnerData['name']) ? $partnerData['name'] : \__('Partner logo', 'extendify');
72+
6873
$version = Config::$environment === 'PRODUCTION' ? Config::$version : uniqid();
69-
$scriptAssetPath = EXTENDIFY_PATH . 'public/build/extendify-assist.asset.php';
70-
$fallback = [
71-
'dependencies' => [],
72-
'version' => $version,
73-
];
74-
$scriptAsset = file_exists($scriptAssetPath) ? require $scriptAssetPath : $fallback;
75-
wp_enqueue_media();
76-
foreach ($scriptAsset['dependencies'] as $style) {
77-
wp_enqueue_style($style);
78-
}
7974

80-
\wp_enqueue_script(
81-
Config::$slug . '-assist-scripts',
82-
EXTENDIFY_BASE_URL . 'public/build/extendify-assist.js',
83-
$scriptAsset['dependencies'],
84-
$scriptAsset['version'],
85-
true
86-
);
75+
$this->enqueueGutenbergAssets();
8776

8877
$assistState = get_option('extendify_assist_globals');
8978
$dismissed = isset($assistState['state']['dismissedNotices']) ? $assistState['state']['dismissedNotices'] : [];
@@ -101,6 +90,8 @@ function () {
10190
'asset_path' => \esc_url(EXTENDIFY_URL . 'public/assets'),
10291
'launchCompleted' => Config::$launchCompleted,
10392
'dismissedNotices' => $dismissed,
93+
'partnerLogo' => $logo,
94+
'partnerName' => $name,
10495
]),
10596
'before'
10697
);
@@ -114,7 +105,74 @@ function () {
114105
$version,
115106
'all'
116107
);
108+
109+
if (isset($partnerData['bgColor']) && isset($partnerData['fgColor'])) {
110+
\wp_add_inline_style(Config::$slug . '-assist-styles', ":root {
111+
--ext-partner-theme-primary-bg: {$partnerData['bgColor']};
112+
--ext-partner-theme-primary-text: {$partnerData['fgColor']};
113+
}");
114+
}
117115
}
118116
);
119117
}
118+
119+
/**
120+
* Enqueues Gutenberg stuff on a non-Gutenberg page.
121+
*
122+
* @return void
123+
*/
124+
public function enqueueGutenbergAssets()
125+
{
126+
$version = Config::$environment === 'PRODUCTION' ? Config::$version : uniqid();
127+
$scriptAssetPath = EXTENDIFY_PATH . 'public/build/extendify-assist.asset.php';
128+
$fallback = [
129+
'dependencies' => [],
130+
'version' => $version,
131+
];
132+
$scriptAsset = file_exists($scriptAssetPath) ? require $scriptAssetPath : $fallback;
133+
wp_enqueue_media();
134+
foreach ($scriptAsset['dependencies'] as $style) {
135+
wp_enqueue_style($style);
136+
}
137+
138+
\wp_enqueue_script(
139+
Config::$slug . '-assist-scripts',
140+
EXTENDIFY_BASE_URL . 'public/build/extendify-assist.js',
141+
$scriptAsset['dependencies'],
142+
$scriptAsset['version'],
143+
true
144+
);
145+
}
146+
147+
/**
148+
* Check if partner data is available.
149+
*
150+
* @return array
151+
*/
152+
public function checkPartnerDataSources()
153+
{
154+
$return = [];
155+
156+
try {
157+
if (defined('EXTENDIFY_ONBOARDING_BG')) {
158+
$return['bgColor'] = constant('EXTENDIFY_ONBOARDING_BG');
159+
$return['fgColor'] = constant('EXTENDIFY_ONBOARDING_TXT');
160+
$return['logo'] = constant('EXTENDIFY_PARTNER_LOGO');
161+
}
162+
163+
$data = get_option('extendify_partner_data');
164+
if ($data) {
165+
$return['bgColor'] = $data['backgroundColor'];
166+
$return['fgColor'] = $data['foregroundColor'];
167+
// Need this check to avoid errors if no partner logo is set in Airtable.
168+
$return['logo'] = $data['logo'] ? $data['logo'][0]['thumbnails']['large']['url'] : null;
169+
$return['name'] = isset($data['name']) ? $data['name'] : '';
170+
}
171+
} catch (\Exception $e) {
172+
// Do nothing here, set variables below. Coding Standards require something to be in the catch.
173+
$e;
174+
}//end try
175+
176+
return $return;
177+
}
120178
}

extendify-sdk/app/Assist/AdminPage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function pageContent()
5353
id="extendify-assist-landing-page"
5454
class="extendify-assist"
5555
data-test="assist-landing">
56-
></div>
56+
</div>
5757
<?php
5858
}
5959
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Controls Quick Links
4+
*/
5+
6+
namespace Extendify\Assist\Controllers;
7+
8+
use Extendify\Http;
9+
10+
if (!defined('ABSPATH')) {
11+
die('No direct access.');
12+
}
13+
14+
/**
15+
* The controller for fetching quick links
16+
*/
17+
class QuickLinksController
18+
{
19+
/**
20+
* Return quick links from source.
21+
*
22+
* @return \WP_REST_Response
23+
*/
24+
public static function fetchQuickLinks()
25+
{
26+
$response = Http::get('/quicklinks');
27+
return new \WP_REST_Response(
28+
$response,
29+
wp_remote_retrieve_response_code($response)
30+
);
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Controls Recommendations
4+
*/
5+
6+
namespace Extendify\Assist\Controllers;
7+
8+
use Extendify\Http;
9+
10+
if (!defined('ABSPATH')) {
11+
die('No direct access.');
12+
}
13+
14+
/**
15+
* The controller for fetching recommendations
16+
*/
17+
class RecommendationsController
18+
{
19+
/**
20+
* Return recommendations from source.
21+
*
22+
* @return \WP_REST_Response
23+
*/
24+
public static function fetchRecommendations()
25+
{
26+
$response = Http::get('/recommendations');
27+
return new \WP_REST_Response(
28+
$response,
29+
wp_remote_retrieve_response_code($response)
30+
);
31+
}
32+
}

extendify-sdk/app/Onboarding/Admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function addScopedScriptsAndStyles()
223223
$version
224224
);
225225

226-
\wp_add_inline_style(Config::$slug . '-onboarding-styles', "body {
226+
\wp_add_inline_style(Config::$slug . '-onboarding-styles', ":root {
227227
--ext-partner-theme-primary-bg: {$bgColor};
228228
--ext-partner-theme-primary-text: {$fgColor};
229229
}");

extendify-sdk/app/Onboarding/Controllers/DataController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ public static function getSiteTypes()
3030
);
3131
}
3232

33+
/**
34+
* Get Site type information.
35+
*
36+
* @return \WP_REST_Response
37+
*/
38+
public static function getStylesList()
39+
{
40+
$response = Http::get('/styles-list');
41+
return new \WP_REST_Response(
42+
$response,
43+
wp_remote_retrieve_response_code($response)
44+
);
45+
}
46+
3347
/**
3448
* Get styles with code template.
3549
*
-1.15 MB
Binary file not shown.
-1.16 MB
Binary file not shown.
-1000 KB
Binary file not shown.

0 commit comments

Comments
 (0)