Skip to content

Commit 6fc0528

Browse files
authored
Merge pull request #3933 from reduxframework/update-extendify-ljodbj0
Update Extendify Library
2 parents b17edc2 + c7474b0 commit 6fc0528

File tree

80 files changed

+2579
-793
lines changed

Some content is hidden

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

80 files changed

+2579
-793
lines changed

extendify-sdk/app/Assist/Controllers/RecommendationsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RecommendationsController
2121
*
2222
* @return \WP_REST_Response
2323
*/
24-
public static function fetchRecommendations()
24+
public static function get()
2525
{
2626
$response = Http::get('/recommendations');
2727
return new \WP_REST_Response(
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/**
3+
* Controls Support Articles
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 support articles
16+
*/
17+
class SupportArticlesController
18+
{
19+
/**
20+
* Return support articles from source.
21+
*
22+
* @return \WP_REST_Response
23+
*/
24+
public static function articles()
25+
{
26+
$response = Http::get('/support-articles');
27+
return new \WP_REST_Response(
28+
$response,
29+
wp_remote_retrieve_response_code($response)
30+
);
31+
}
32+
33+
/**
34+
* Return support article categories from source.
35+
*
36+
* @return \WP_REST_Response
37+
*/
38+
public static function categories()
39+
{
40+
$response = Http::get('/support-article-categories');
41+
return new \WP_REST_Response(
42+
$response,
43+
wp_remote_retrieve_response_code($response)
44+
);
45+
}
46+
47+
/**
48+
* Return the selected support article from source.
49+
*
50+
* @param \WP_REST_Request $request - The request.
51+
* @return \WP_REST_Response
52+
*/
53+
public static function article($request)
54+
{
55+
$url = add_query_arg(
56+
'slug',
57+
$request->get_param('slug'),
58+
'https://wordpress.org/documentation/wp-json/wp/v2/articles'
59+
);
60+
$response = \wp_remote_get($url);
61+
if (\is_wp_error($response)) {
62+
wp_send_json_error($response->get_error_message(), 404);
63+
}
64+
65+
return new \WP_REST_Response(
66+
['data' => json_decode(\wp_remote_retrieve_body($response), true)],
67+
\wp_remote_retrieve_response_code($response)
68+
);
69+
}
70+
71+
/**
72+
* Attempts to find a redirect URL from the old docs site
73+
*
74+
* @param \WP_REST_Request $request - The request.
75+
* @return \WP_REST_Response
76+
*/
77+
public static function getRedirect($request)
78+
{
79+
$url = 'https://wordpress.org' . $request->get_param('path');
80+
$response = \wp_remote_head($url);
81+
$location = \wp_remote_retrieve_header($response, 'location');
82+
if (\is_wp_error($response)) {
83+
wp_send_json_error(\__('Page not found', 'extendify'), 404);
84+
}
85+
86+
// No redirect, we're done.
87+
if (empty($location)) {
88+
return new \WP_REST_Response(['data' => $url], 200);
89+
}
90+
91+
// Keep going until no more redirects.
92+
$request->set_param('path', \wp_parse_url($location, PHP_URL_PATH));
93+
return self::getRedirect($request);
94+
}
95+
}

extendify-sdk/app/Assist/Controllers/TourController.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace Extendify\Assist\Controllers;
77

8+
use Extendify\Http;
9+
810
if (!defined('ABSPATH')) {
911
die('No direct access.');
1012
}
@@ -14,6 +16,20 @@
1416
*/
1517
class TourController
1618
{
19+
/**
20+
* Return tasks from either database or source.
21+
*
22+
* @return \WP_REST_Response
23+
*/
24+
public static function fetchTours()
25+
{
26+
$response = Http::get('/tours');
27+
return new \WP_REST_Response(
28+
$response,
29+
wp_remote_retrieve_response_code($response)
30+
);
31+
}
32+
1733
/**
1834
* Return the data
1935
*

extendify-sdk/app/Http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function getBaseUrl($request)
182182
return Config::$config['api']['onboarding-dev'];
183183
}
184184

185-
// Onborarding local request.
185+
// Onboarding local request.
186186
if ($request->get_header('x_extendify_onboarding_local_mode') === 'true') {
187187
return Config::$config['api']['onboarding-local'];
188188
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public static function getTemplate($request)
7373
{
7474
$response = Http::get('/templates', $request->get_params());
7575
if (\is_wp_error($response)) {
76-
// TODO: Maybe handle errors better here, or higher up in the Http class.
7776
wp_send_json_error(['message' => $response->get_error_message()], 400);
7877
}
7978

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-blob', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-media-utils', 'wp-primitives'), 'version' => '09f2d61efa85d2c568f9');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'wp-blob', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-media-utils', 'wp-primitives'), 'version' => 'c987551fd8bf562a5c07');

extendify-sdk/public/build/extendify-assist.css

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extendify-sdk/public/build/extendify-assist.js

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'c2841a19b37c9813a48d');
1+
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '068afe52713d9fc69df0');

extendify-sdk/public/build/extendify-onboarding.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)