This repository has been archived by the owner on Jun 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultilingual-site.patch
124 lines (115 loc) · 4.67 KB
/
multilingual-site.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
diff -ruN includes/class-algolia-utils.php wp-search-with-algolia/includes/class-algolia-utils.php
--- includes/class-algolia-utils.php 2020-10-07 20:07:22.000000000 +0800
+++ wp-search-with-algolia/includes/class-algolia-utils.php 2022-12-14 19:42:45.021490000 +0800
@@ -128,9 +128,14 @@
if ( ! $info ) {
continue;
}
-
+
+ $url = str_replace(
+ 'http://localhost',
+ 'https://mylivesite.com',
+ $info[0]
+ );
$images[ $size ] = array(
- 'url' => $info[0],
+ 'url' => $url,
'width' => $info[1],
'height' => $info[2],
);
diff -ruN includes/indices/class-algolia-posts-index.php wp-search-with-algolia/includes/indices/class-algolia-posts-index.php
--- includes/indices/class-algolia-posts-index.php 2022-05-18 19:05:20.000000000 +0800
+++ wp-search-with-algolia/includes/indices/class-algolia-posts-index.php 2022-11-26 00:45:31.038463100 +0800
@@ -219,7 +219,13 @@
$shared_attributes['images'] = Algolia_Utils::get_post_images( $post->ID );
- $shared_attributes['permalink'] = get_permalink( $post );
+ $permalink = get_permalink( $post );
+ $permalink = str_replace(
+ 'http://localhost',
+ 'https://mylivesite.com',
+ $permalink
+ );
+ $shared_attributes['permalink'] = $permalink;
$shared_attributes['post_mime_type'] = $post->post_mime_type;
// Push all taxonomies by default, including custom ones.
diff -ruN includes/indices/class-algolia-searchable-posts-index.php wp-search-with-algolia/includes/indices/class-algolia-searchable-posts-index.php
--- includes/indices/class-algolia-searchable-posts-index.php 2022-05-18 19:05:20.000000000 +0800
+++ wp-search-with-algolia/includes/indices/class-algolia-searchable-posts-index.php 2022-11-26 00:45:31.056187700 +0800
@@ -213,7 +213,13 @@
$shared_attributes['images'] = Algolia_Utils::get_post_images( $post->ID );
- $shared_attributes['permalink'] = get_permalink( $post );
+ $permalink = get_permalink( $post );
+ $permalink = str_replace(
+ 'http://localhost',
+ 'https://mylivesite.com',
+ $permalink
+ );
+ $shared_attributes['permalink'] = $permalink;
$shared_attributes['post_mime_type'] = $post->post_mime_type;
// Push all taxonomies by default, including custom ones.
diff -ruN includes/indices/class-algolia-terms-index.php wp-search-with-algolia/includes/indices/class-algolia-terms-index.php
--- includes/indices/class-algolia-terms-index.php 2022-05-18 19:05:20.000000000 +0800
+++ wp-search-with-algolia/includes/indices/class-algolia-terms-index.php 2022-12-14 17:44:32.274802000 +0800
@@ -98,9 +98,21 @@
$record['slug'] = $item->slug;
$record['posts_count'] = (int) $item->count;
if ( function_exists( 'wpcom_vip_get_term_link' ) ) {
- $record['permalink'] = wpcom_vip_get_term_link( $item );
+ $permalink = wpcom_vip_get_term_link( $item );
+ $permalink = str_replace(
+ 'http://localhost',
+ 'https://mylivesite.com',
+ $permalink
+ );
+ $record['permalink'] = $permalink;
} else {
- $record['permalink'] = get_term_link( $item );
+ $permalink = get_term_link( $item );
+ $permalink = str_replace(
+ 'http://localhost',
+ 'https://mylivesite.com',
+ $permalink
+ );
+ $record['permalink'] = $permalink;
}
$record = (array) apply_filters( 'algolia_term_record', $record, $item );
diff -ruN templates/autocomplete.php wp-search-with-algolia/templates/autocomplete.php
--- templates/autocomplete.php 2022-11-14 14:17:00.000000000 +0800
+++ wp-search-with-algolia/templates/autocomplete.php 2022-11-26 00:45:31.089648800 +0800
@@ -108,6 +108,11 @@
attributesToSnippet: [
'content:10'
],
+ facetFilters: [
+ [
+ 'taxonomies.language:<?php echo pll_current_language('name'); ?>'
+ ]
+ ],
highlightPreTag: '__ais-highlight__',
highlightPostTag: '__/ais-highlight__'
} ),
@@ -154,6 +159,7 @@
var config = {
debug: algolia.debug,
+ detachedMediaQuery: '',
hint: false,
openOnFocus: true,
appendTo: 'body',
diff -ruN templates/instantsearch.php wp-search-with-algolia/templates/instantsearch.php
--- templates/instantsearch.php 2022-10-31 15:55:46.000000000 +0800
+++ wp-search-with-algolia/templates/instantsearch.php 2022-12-14 20:38:01.370232800 +0800
@@ -160,6 +164,14 @@
sortBy: ['isRefined:desc', 'count:desc', 'name:asc'],
limit: 10,
}),
+
+ /* Languages refinement widget */
+ instantsearch.widgets.menu({
+ container: '#facet-languages',
+ attribute: 'taxonomies.language',
+ sortBy: ['isRefined:desc', 'count:desc', 'name:asc'],
+ limit: 3,
+ }),
/* Categories refinement widget */
instantsearch.widgets.hierarchicalMenu({