Skip to content

Commit 561c578

Browse files
author
Mustafa Şükrü Kapusuz
committed
refactor: property, method renamings and comments
1 parent 1be9677 commit 561c578

6 files changed

+24
-17
lines changed

includes/indices/class-algolia-index.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
* @since 1.0.0
1919
*/
2020
abstract class Algolia_Index {
21-
protected $settings = [];
21+
/**
22+
* Default index settings
23+
*
24+
* @var array
25+
*/
26+
protected array $default_settings = [];
2227

2328
/**
2429
* The SearchClient instance.
@@ -686,8 +691,8 @@ protected function get_re_index_batch_size() {
686691
*
687692
* @return array
688693
*/
689-
public function get_settings() {
690-
$settings = (array) apply_filters( 'algolia_' . $this->get_id() . '_index_settings', $this->settings );
694+
public function get_default_settings() {
695+
$settings = (array) apply_filters( 'algolia_' . $this->get_id() . '_index_settings', $this->default_settings );
691696

692697
/**
693698
* Replacing `attributesToIndex` with `searchableAttributes` as

includes/indices/class-algolia-posts-index.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @since 1.0.0
1515
*/
1616
final class Algolia_Posts_Index extends Algolia_Index {
17-
protected $settings = [
17+
protected $default_settings = [
1818
'searchableAttributes' => array(
1919
'unordered(post_title)',
2020
'unordered(taxonomies)',
@@ -288,15 +288,16 @@ private function get_post_shared_attributes( WP_Post $post ) {
288288

289289
/**
290290
* Get settings.
291+
* Overridden to able to have "algolia_posts_index_settings" filter.
291292
*
292293
* @author WebDevStudios <contact@webdevstudios.com>
293294
* @since 1.0.0
294295
*
295296
* @return array
296297
*/
297-
public function get_settings() {
298-
$this->settings = (array) apply_filters( 'algolia_posts_index_settings', $this->settings, $this->post_type );
299-
return parent::get_settings();
298+
public function get_default_settings() {
299+
$this->default_settings = (array) apply_filters( 'algolia_posts_index_settings', $this->default_settings, $this->post_type );
300+
return parent::get_default_settings();
300301
}
301302

302303
/**

includes/indices/class-algolia-searchable-posts-index.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,15 @@ private function get_post_shared_attributes( WP_Post $post ) {
249249
/**
250250
* Get settings.
251251
*
252+
* Overridden to able to have "excerpt_length" WP filter hook for the attributesToSnippet.content
253+
*
252254
* @author WebDevStudios <contact@webdevstudios.com>
253255
* @since 1.0.0
254256
*
255257
* @return array
256258
*/
257-
public function get_settings() {
258-
// override settings prop to inject the WP Filter Hook.
259-
$this->settings = [
259+
public function get_default_settings() {
260+
$this->default_settings = [
260261
'searchableAttributes' => array(
261262
'unordered(post_title)',
262263
'unordered(taxonomies)',
@@ -282,7 +283,7 @@ public function get_settings() {
282283
'snippetEllipsisText' => '',
283284
];
284285

285-
return parent::get_settings();
286+
return parent::get_default_settings();
286287
}
287288

288289
/**

includes/indices/class-algolia-terms-index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @since 1.0.0
1515
*/
1616
final class Algolia_Terms_Index extends Algolia_Index {
17-
protected $settings = [
17+
protected $default_settings = [
1818
'searchableAttributes' => array(
1919
'unordered(name)',
2020
'unordered(description)',
@@ -138,10 +138,10 @@ protected function get_re_index_items_count() {
138138
*
139139
* @return array
140140
*/
141-
public function get_settings() {
141+
public function get_default_settings() {
142142
// override settings prop to have a custom WP filter hook for terms only
143-
$this->settings = apply_filters( 'algolia_terms_index_settings', $this->settings, $this->taxonomy );
144-
return parent::get_settings();
143+
$this->default_settings = apply_filters( 'algolia_terms_index_settings', $this->default_settings, $this->taxonomy );
144+
return parent::get_default_settings();
145145
}
146146

147147
/**

includes/indices/class-algolia-users-index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @since 1.0.0
1515
*/
1616
final class Algolia_Users_Index extends Algolia_Index {
17-
protected $settings = [
17+
protected $default_settings = [
1818
'searchableAttributes' => array(
1919
'unordered(display_name)',
2020
),

includes/indices/settings/class-algolia-primary-index-settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function set_algolia_index(): void {
2424
}
2525

2626
public function get_local_settings(): array {
27-
return $this->get_index()->get_settings();
27+
return $this->get_index()->get_default_settings();
2828
}
2929

3030
public function get_remote_settings(): array {

0 commit comments

Comments
 (0)