PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
← All changes | app/Assist/Controllers/DomainsSuggestionController.php +17 -10 3.0.5 → 3.2.2 View file →
@@ -5,8 +5,9 @@
5 5 */
6 6
7 7 namespace Extendify\Assist\Controllers;
8 8
9 +use Extendify\Constants;
9 10 use Extendify\Shared\Services\Sanitizer;
10 11
11 12 defined('ABSPATH') || die('No direct access.');
12 13
@@ -16,15 +17,8 @@
16 17
17 18 class DomainsSuggestionController
18 19 {
19 20 /**
20 - * The url for the server.
21 - *
22 - * @var string
23 - */
24 - public static $host = 'https://ai.extendify.com';
25 -
26 - /**
27 21 * The list of url strings in the site name to block from using the api.
28 22 *
29 23 * @var array
30 24 */
@@ -65,12 +59,21 @@
65 59 if (!self::hasValidSiteTitle($siteName)) {
66 60 return new \WP_REST_Response([]);
67 61 }
68 62
63 + $cleanedSiteTitle = self::cleanSiteTitle($siteName);
64 + if ($cleanedSiteTitle === '') {
65 + return new \WP_REST_Response([]);
66 + }
67 +
69 68 $siteProfile = \get_option('extendify_site_profile', []);
69 + if (empty($siteProfile)) {
70 + return new \WP_REST_Response([]);
71 + }
72 +
70 73 $businessDescription = ($siteProfile['description'] ?? '');
71 74 $data = [
72 - 'query' => self::cleanSiteTitle($siteName),
75 + 'query' => $cleanedSiteTitle,
73 76 'devbuild' => defined('EXTENDIFY_DEVMODE')
74 77 ? constant('EXTENDIFY_DEVMODE')
75 78 : is_readable(EXTENDIFY_PATH . '.devbuild'),
76 79 'siteId' => \get_option('extendify_site_id', ''),
@@ -83,9 +86,9 @@
83 86 'siteProfile' => $siteProfile,
84 87 ];
85 88
86 89 $response = \wp_remote_post(
87 - sprintf('%s/api/domains/suggest', static::$host),
90 + sprintf('%s/api/domains/suggest', Constants::AI_HOST),
88 91 [
89 92 'body' => \wp_json_encode($data),
90 93 'headers' => ['Content-Type' => 'application/json'],
91 94 ]
@@ -115,9 +118,13 @@
115 118 * @return string
116 119 */
117 120 public static function cleanSiteTitle($siteTitle)
118 121 {
119 - return preg_replace('/[^\p{L}\p{N}\s\-]+/u', '', html_entity_decode($siteTitle));
122 + return trim(preg_replace(
123 + '/[^\p{L}\p{N}\s\-]+/u',
124 + '',
125 + html_entity_decode($siteTitle, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401)
126 + ));
120 127 }
121 128
122 129 /**
123 130 * Check if the site Title is part of the blocked list.