Skip to content

Commit c757948

Browse files
author
Miika Arponen
committed
RediPress 2.0 integration
1 parent 005f265 commit c757948

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
9+
### Changed
10+
- Google Map to be queryable to RediPress.
11+
- Everything compatible with RediPress 2.0, which is a breaking change in the integration.
12+
713
## [1.37.0] - 2021-11-30
814

915
### Changed

src/Field.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,14 @@ public function export( bool $register = false, $parent = null ) : ?array {
286286
if ( $this->get_is_user() ) {
287287
switch ( $filter['filter'] ) {
288288
case 'redipress/schema_fields':
289-
$filter['filter'] = 'redipress/user_schema_fields';
289+
$filter['filter'] = 'redipress/index/users/schema_fields';
290+
break;
291+
}
292+
}
293+
else {
294+
switch ( $filter['filter'] ) {
295+
case 'redipress/schema_fields':
296+
$filter['filter'] = 'redipress/index/posts/schema_fields';
290297
break;
291298
}
292299
}
@@ -873,7 +880,7 @@ private function redipress_add_queryable_internal() {
873880
}
874881

875882
if ( strpos( $post_id, 'block_' ) !== false &&
876-
! ( $post_id = \Geniem\RediPress\Index\Index::indexing() ) // phpcs:ignore
883+
! ( $post_id = \Geniem\RediPress\Index\PostIndex::indexing() ) // phpcs:ignore
877884
) {
878885
$document_uri = filter_input( INPUT_SERVER, 'DOCUMENT_URI', \FILTER_SANITIZE_STRING );
879886

@@ -914,7 +921,7 @@ private function redipress_add_queryable_internal() {
914921
$users = true;
915922
}
916923
elseif ( is_numeric( $post_id ) ) {
917-
$doc_id = \Geniem\RediPress\Index\Index::get_document_id( get_post( $post_id ) );
924+
$doc_id = \Geniem\RediPress\Index\PostIndex::get_document_id( get_post( $post_id ) );
918925
}
919926
elseif ( strpos( $post_id, 'block_' ) !== false ) {
920927
if ( ! ( $post_id = \Geniem\RediPress\Index\Index::indexing() ) ) {
@@ -923,7 +930,7 @@ private function redipress_add_queryable_internal() {
923930
$post_id = basename( $document_uri );
924931
}
925932

926-
$doc_id = \Geniem\RediPress\Index\Index::get_document_id( get_post( $post_id ) );
933+
$doc_id = \Geniem\RediPress\Index\PostIndex::get_document_id( get_post( $post_id ) );
927934
}
928935

929936
if ( ! empty( $doc_id ) ) {
@@ -955,6 +962,7 @@ private function redipress_add_queryable_internal() {
955962
];
956963

957964
$this->filters['redipress_schema_fields'] = [
965+
// This gets changed to the proper filter in the export method.
958966
'filter' => 'redipress/schema_fields',
959967
'function' => function( $fields ) {
960968

src/Field/GoogleMap.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,29 @@ class GoogleMap extends \Geniem\ACF\Field {
4545
*/
4646
protected $height;
4747

48+
/**
49+
* What type the RediPress index field should be.
50+
*
51+
* @var string
52+
*/
53+
protected $redipress_field_type = 'Geo';
54+
55+
/**
56+
* Constructor.
57+
*
58+
* @param string $label Label for the field.
59+
* @param string|null $key Key for the field.
60+
* @param string|null $name Name for the field.
61+
* @throws \Geniem\ACF\Exception Throw error if mandatory property is not set.
62+
*/
63+
public function __construct( string $label, string $key = null, string $name = null ) {
64+
parent::__construct( $label, $key, $name );
65+
66+
$this->redipress_queryable_filter = function( $value ) {
67+
return $value['lat'] . ',' . $value['lng'];
68+
};
69+
}
70+
4871
/**
4972
* Set center_lat variable
5073
*

src/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ public function register() {
488488
\acf_add_local_field_group( $exported );
489489

490490
$this->registered = true;
491-
});
491+
}, 15 );
492492
}
493493
}
494494

0 commit comments

Comments
 (0)