Skip to content

Commit

Permalink
RediPress compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Nomafin committed Jan 13, 2023
2 parents 41d556d + c757948 commit f64509b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.38.0]

### Changed
- Google Maps field to be queryable to RediPress.
- All mainline versions from now on require RediPress 2.0 if the integration is used.

## [1.37.2] - 2022-11-04

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
],
"conflict": {
"devgeniem/redipress": "<1.9"
"devgeniem/redipress": "<2.0"
},
"autoload": {
"psr-4": {"Geniem\\ACF\\": "src/"}
Expand Down
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: ACF Codifier
Plugin URI: https://github.com/devgeniem/acf-codifier
Description: A helper class to make defining ACF field groups and fields easier in the code.
Version: 1.37.1
Version: 1.38.0
Author: Miika Arponen / Geniem Oy
Author URI: https://geniem.fi
License: GPL-3.0
Expand Down
16 changes: 12 additions & 4 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,14 @@ public function export( bool $register = false, $parent = null ) : ?array {
if ( $this->get_is_user() ) {
switch ( $filter['filter'] ) {
case 'redipress/schema_fields':
$filter['filter'] = 'redipress/user_schema_fields';
$filter['filter'] = 'redipress/index/users/schema_fields';
break;
}
}
else {
switch ( $filter['filter'] ) {
case 'redipress/schema_fields':
$filter['filter'] = 'redipress/index/posts/schema_fields';
break;
}
}
Expand Down Expand Up @@ -873,7 +880,7 @@ private function redipress_add_queryable_internal() {
}

if ( strpos( $post_id, 'block_' ) !== false &&
! ( $post_id = \Geniem\RediPress\Index\Index::indexing() ) // phpcs:ignore
! ( $post_id = \Geniem\RediPress\Index\PostIndex::indexing() ) // phpcs:ignore
) {
$document_uri = filter_input( INPUT_SERVER, 'DOCUMENT_URI', \FILTER_SANITIZE_STRING );

Expand Down Expand Up @@ -914,7 +921,7 @@ private function redipress_add_queryable_internal() {
$users = true;
}
elseif ( is_numeric( $post_id ) ) {
$doc_id = \Geniem\RediPress\Index\Index::get_document_id( get_post( $post_id ) );
$doc_id = \Geniem\RediPress\Index\PostIndex::get_document_id( get_post( $post_id ) );
}
elseif ( strpos( $post_id, 'block_' ) !== false ) {
if ( ! ( $post_id = \Geniem\RediPress\Index\Index::indexing() ) ) {
Expand All @@ -923,7 +930,7 @@ private function redipress_add_queryable_internal() {
$post_id = basename( $document_uri );
}

$doc_id = \Geniem\RediPress\Index\Index::get_document_id( get_post( $post_id ) );
$doc_id = \Geniem\RediPress\Index\PostIndex::get_document_id( get_post( $post_id ) );
}

if ( ! empty( $doc_id ) ) {
Expand Down Expand Up @@ -955,6 +962,7 @@ private function redipress_add_queryable_internal() {
];

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

Expand Down
23 changes: 23 additions & 0 deletions src/Field/GoogleMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,29 @@ class GoogleMap extends \Geniem\ACF\Field {
*/
protected $height;

/**
* What type the RediPress index field should be.
*
* @var string
*/
protected $redipress_field_type = 'Geo';

/**
* Constructor.
*
* @param string $label Label for the field.
* @param string|null $key Key for the field.
* @param string|null $name Name for the field.
* @throws \Geniem\ACF\Exception Throw error if mandatory property is not set.
*/
public function __construct( string $label, string $key = null, string $name = null ) {
parent::__construct( $label, $key, $name );

$this->redipress_queryable_filter = function( $value ) {
return $value['lat'] . ',' . $value['lng'];
};
}

/**
* Set center_lat variable
*
Expand Down
2 changes: 1 addition & 1 deletion src/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public function register() {
\acf_add_local_field_group( $exported );

$this->registered = true;
});
}, 15 );
}
}

Expand Down

0 comments on commit f64509b

Please sign in to comment.