Skip to content

Commit 4448a54

Browse files
committed
All: Fix unexpected 'jquery.com' Algolia results on secondary sites
Such as https://learn.jquery.com, https://jquery.org. This was previously applied to all sites by default, and only overridden on `*.jqueryui` and `*.jquerymobile`, whereas it should be limited to strictly jquery.com and api.jquery.com.
1 parent 28344c9 commit 4448a54

File tree

5 files changed

+76
-18
lines changed

5 files changed

+76
-18
lines changed

sites.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ function jquery_sites() {
1313
'xfn-rel-me' => array(
1414
'https://social.lfx.dev/@jquery',
1515
),
16+
'algolia_docsearch' => array(
17+
'apiKey' => '3cfde9aca378c8aab554d5bf1b23489b',
18+
'indexName' => 'jquery',
19+
),
1620
'options' => array(
1721
'blogname' => 'jQuery',
1822
'description' => 'jQuery: The Write Less, Do More, JavaScript Library',
@@ -37,6 +41,10 @@ function jquery_sites() {
3741
'cookie_domain' => '.jquery.com',
3842
'body_class' => 'jquery',
3943
'logo_link' => 'https://jquery.com/',
44+
'algolia_docsearch' => array(
45+
'apiKey' => '3cfde9aca378c8aab554d5bf1b23489b',
46+
'indexName' => 'jquery',
47+
),
4048
'options' => array(
4149
'blogname' => 'jQuery API Documentation',
4250
'stylesheet' => 'api.jquery.com',
@@ -70,6 +78,10 @@ function jquery_sites() {
7078
'blog_id' => 6,
7179
'cookie_domain' => '.jqueryui.com',
7280
'body_class' => 'jquery-ui',
81+
'algolia_docsearch' => array(
82+
'apiKey' => '2fce35e56784bbb48c78d105739190c2',
83+
'indexName' => 'jqueryui',
84+
),
7385
'options' => array(
7486
'blogname' => 'jQuery UI',
7587
'description' => 'jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you\'re building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.',
@@ -94,6 +106,10 @@ function jquery_sites() {
94106
'cookie_domain' => '.jqueryui.com',
95107
'body_class' => 'jquery-ui',
96108
'logo_link' => 'https://jqueryui.com/',
109+
'algolia_docsearch' => array(
110+
'apiKey' => '2fce35e56784bbb48c78d105739190c2',
111+
'indexName' => 'jqueryui',
112+
),
97113
'options' => array(
98114
'blogname' => 'jQuery UI API Documentation',
99115
'stylesheet' => 'api.jqueryui.com',
@@ -107,6 +123,10 @@ function jquery_sites() {
107123
'cookie_domain' => '.jqueryui.com',
108124
'body_class' => 'jquery-ui',
109125
'logo_link' => 'https://jqueryui.com/',
126+
'algolia_docsearch' => array(
127+
'apiKey' => '2fce35e56784bbb48c78d105739190c2',
128+
'indexName' => 'jqueryui',
129+
),
110130
'options' => array(
111131
'blogname' => 'jQuery UI 1.8 Documentation',
112132
'stylesheet' => 'api.jqueryui.com',
@@ -121,6 +141,10 @@ function jquery_sites() {
121141
'cookie_domain' => '.jqueryui.com',
122142
'body_class' => 'jquery-ui',
123143
'logo_link' => 'https://jqueryui.com/',
144+
'algolia_docsearch' => array(
145+
'apiKey' => '2fce35e56784bbb48c78d105739190c2',
146+
'indexName' => 'jqueryui',
147+
),
124148
'options' => array(
125149
'blogname' => 'jQuery UI 1.9 Documentation',
126150
'stylesheet' => 'api.jqueryui.com',
@@ -148,6 +172,10 @@ function jquery_sites() {
148172
'blog_id' => 12,
149173
'cookie_domain' => '.jquerymobile.com',
150174
'body_class' => 'jquery-mobile',
175+
'algolia_docsearch' => array(
176+
'apiKey' => '207328b0f1c18555c9021d05157dd651',
177+
'indexName' => 'jquerymobile',
178+
),
151179
'options' => array(
152180
'blogname' => 'jQuery Mobile',
153181
'stylesheet' => 'jquerymobile.com',
@@ -162,6 +190,10 @@ function jquery_sites() {
162190
'cookie_domain' => '.jquerymobile.com',
163191
'body_class' => 'jquery-mobile',
164192
'logo_link' => 'https://jquerymobile.com/',
193+
'algolia_docsearch' => array(
194+
'apiKey' => '207328b0f1c18555c9021d05157dd651',
195+
'indexName' => 'jquerymobile',
196+
),
165197
'options' => array(
166198
'blogname' => 'jQuery Mobile API Documentation',
167199
'stylesheet' => 'api.jquerymobile.com',
@@ -229,6 +261,10 @@ function jquery_sites() {
229261
'cookie_domain' => '.jquerymobile.com',
230262
'body_class' => 'jquery-mobile',
231263
'logo_link' => 'https://jquerymobile.com/',
264+
'algolia_docsearch' => array(
265+
'apiKey' => '207328b0f1c18555c9021d05157dd651',
266+
'indexName' => 'jquerymobile',
267+
),
232268
'options' => array(
233269
'blogname' => 'jQuery Mobile 1.3 Documentation',
234270
'stylesheet' => 'api.jquerymobile.com',
@@ -243,6 +279,10 @@ function jquery_sites() {
243279
'cookie_domain' => '.jqueryui.com',
244280
'body_class' => 'jquery-ui',
245281
'logo_link' => 'https://jqueryui.com/',
282+
'algolia_docsearch' => array(
283+
'apiKey' => '2fce35e56784bbb48c78d105739190c2',
284+
'indexName' => 'jqueryui',
285+
),
246286
'options' => array(
247287
'blogname' => 'jQuery UI 1.10 Documentation',
248288
'stylesheet' => 'api.jqueryui.com',
@@ -257,6 +297,10 @@ function jquery_sites() {
257297
'cookie_domain' => '.jqueryui.com',
258298
'body_class' => 'jquery-ui',
259299
'logo_link' => 'https://jqueryui.com/',
300+
'algolia_docsearch' => array(
301+
'apiKey' => '2fce35e56784bbb48c78d105739190c2',
302+
'indexName' => 'jqueryui',
303+
),
260304
'options' => array(
261305
'blogname' => 'jQuery UI 1.12 Documentation',
262306
'stylesheet' => 'api.jqueryui.com',
@@ -271,6 +315,10 @@ function jquery_sites() {
271315
'cookie_domain' => '.jqueryui.com',
272316
'body_class' => 'jquery-ui',
273317
'logo_link' => 'https://jqueryui.com/',
318+
'algolia_docsearch' => array(
319+
'apiKey' => '2fce35e56784bbb48c78d105739190c2',
320+
'indexName' => 'jqueryui',
321+
),
274322
'options' => array(
275323
'blogname' => 'jQuery UI 1.11 Documentation',
276324
'stylesheet' => 'api.jqueryui.com',
@@ -285,6 +333,10 @@ function jquery_sites() {
285333
'cookie_domain' => '.jquerymobile.com',
286334
'body_class' => 'jquery-mobile',
287335
'logo_link' => 'https://jquerymobile.com/',
336+
'algolia_docsearch' => array(
337+
'apiKey' => '207328b0f1c18555c9021d05157dd651',
338+
'indexName' => 'jquerymobile',
339+
),
288340
'options' => array(
289341
'blogname' => 'jQuery Mobile 1.4 Documentation',
290342
'stylesheet' => 'api.jquerymobile.com',
@@ -311,6 +363,10 @@ function jquery_sites() {
311363
'cookie_domain' => '.jqueryui.com',
312364
'body_class' => 'jquery-ui',
313365
'logo_link' => 'https://jqueryui.com/',
366+
'algolia_docsearch' => array(
367+
'apiKey' => '2fce35e56784bbb48c78d105739190c2',
368+
'indexName' => 'jqueryui',
369+
),
314370
'options' => array(
315371
'blogname' => 'jQuery UI 1.13 Documentation',
316372
'stylesheet' => 'api.jqueryui.com',

themes/jquery/footer-mobile.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
</footer>
99

1010
<?php wp_footer(); ?>
11-
<!-- at the end of the BODY -->
12-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js" onload="document.querySelector('input[name=\'s\']') && docsearch({apiKey: '207328b0f1c18555c9021d05157dd651',
13-
indexName: 'jquerymobile',
14-
inputSelector: 'input[name=\'s\']',
15-
debug: true // Set debug to true if you want to inspect the dropdown
16-
})" async></script>
11+
<?php jq_the_algolia_docsearch(); ?>
1712

1813
</body>
1914
</html>

themes/jquery/footer-ui.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@
3636
</footer>
3737

3838
<?php wp_footer(); ?>
39-
<!-- at the end of the BODY -->
40-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js" onload="document.querySelector('input[name=\'s\']') && docsearch({apiKey: '2fce35e56784bbb48c78d105739190c2',
41-
indexName: 'jqueryui',
42-
inputSelector: 'input[name=\'s\']',
43-
debug: true // Set debug to true if you want to inspect the dropdown
44-
})" async></script>
39+
<?php jq_the_algolia_docsearch(); ?>
4540

4641
</body>
4742
</html>

themes/jquery/footer.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
</footer>
3838

3939
<?php wp_footer(); ?>
40-
<!-- at the end of the BODY -->
41-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js" onload="document.querySelector('input[name=\'s\']') && docsearch({apiKey: '3cfde9aca378c8aab554d5bf1b23489b',
42-
indexName: 'jquery',
43-
inputSelector: 'input[name=\'s\']',
44-
debug: true // Set debug to true if you want to inspect the dropdown
45-
})" async></script>
40+
<?php jq_the_algolia_docsearch(); ?>
4641
</body>
4742
</html>

themes/jquery/functions.jquery.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,20 @@ function jq_posts_per_page($limits) {
201201
return $limits;
202202
}
203203
add_filter('post_limits', 'jq_posts_per_page');
204+
205+
function jq_the_algolia_docsearch() {
206+
$sites = jquery_sites();
207+
$docsearch = isset( $sites[ JQUERY_LIVE_SITE ]['algolia_docsearch']['apiKey'] )
208+
? $sites[ JQUERY_LIVE_SITE ]['xfn-rel-me']['algolia_docsearch']
209+
: null;
210+
211+
if ( $docsearch ) :
212+
?>
213+
<script async src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js" onload='document.querySelector("input[name=\"s\"]") && docsearch({apiKey: <?php print json_encode($docsearch['apiKey']); ?>,
214+
indexName: <?php print json_encode($docsearch['indexName']); ?>,
215+
inputSelector: "input[name=\"s\"]",
216+
debug: true
217+
})'></script>
218+
<?php
219+
endif;
220+
}

0 commit comments

Comments
 (0)