Skip to content

Commit e825a65

Browse files
committed
Merge branch 'master' into components
2 parents 64765f4 + a2eb7ef commit e825a65

27 files changed

+435
-114
lines changed

CHANGELOG.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,46 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
* `Geniem\ACF\Renderer\PHP`: Uses PHP files as templates.
1717
* `Geniem\ACF\Renderer\Dust`: Uses Dust.js template files.
1818

19+
## [1.41.2]
20+
21+
### Fixed
22+
- Fix MultisiteTaxonomy and Multitaxonomy compatibility with ACF v6.3.1.
23+
24+
## [1.41.1]
25+
26+
### Fixed
27+
- Fix MultisitePostObject compatibility with ACF v6.3
28+
29+
## [1.41.0]
30+
31+
### Added
32+
- Support for ACF native bidirectional relationships. See https://www.advancedcustomfields.com/resources/bidirectional-relationships/.
33+
34+
## [1.40.0]
35+
36+
### Added
37+
- Added a filter `codifier/callable-renderer/render/data` for CallableRenderer->render() $data. For example this makes possible to identify fields inside commonly used custom renderer.
38+
39+
## [1.39.1]
40+
41+
### Fixed
42+
- Fix PHP 8.2 deprecations (no dynamic properties, string interpolation {$var} instead of ${var}).
43+
- Replace deprecated acf_esc_attr_e with acf_esc_attrs.
44+
- Use shorthand array notation.
45+
46+
## [1.39.0]
47+
48+
### Added
49+
- Add support for block parent attribute.
50+
51+
## [1.38.4]
52+
53+
- Fix previous tag pointing to earlier commit.
54+
55+
## [1.38.3]
56+
### Fixed
57+
- Fixes undefined method error in RediPress functionalities
58+
1959
## [1.38.2]
2060
### Fixed
2161
- Fixes "Automatic conversion of false to array is deprecated" on Dust.php
@@ -468,7 +508,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
468508
## [1.2.4] - 2018-01-31
469509

470510
### Fixed
471-
- Fixed a bug that occured after the change made in 1.2.3.
511+
- Fixed a bug that occurred after the change made in 1.2.3.
472512

473513
## [1.2.3] - 2018-01-30
474514

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,11 @@
3535
},
3636
"require-dev": {
3737
"victorjonsson/markdowndocs": "^1.3"
38+
},
39+
"config": {
40+
"allow-plugins": {
41+
"composer/installers": true,
42+
"dealerdirect/phpcodesniffer-composer-installer": true
43+
}
3844
}
3945
}

composer.lock

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/classes.md

Lines changed: 15 additions & 13 deletions
Large diffs are not rendered by default.

plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: ACF Codifier
44
Plugin URI: https://github.com/devgeniem/acf-codifier
55
Description: A helper class to make defining ACF field groups and fields easier in the code.
6-
Version: 1.38.0
6+
Version: 1.41.2
77
Author: Miika Arponen / Geniem Oy
88
Author URI: https://geniem.fi
99
License: GPL-3.0

readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ $pseudo->add_field( $some_field )
233233
->add_field( $another_field );
234234
```
235235

236+
#### Bidirectional relationships
237+
238+
Codifier supports bidirectional relationships for the field types ACF is supporting the feature (currently PostObject, Relationship, Taxonomy and User).
239+
240+
```php
241+
$field->set_bidirectional()
242+
->set_bidirectional_targets( [ 'field_name_or_key' ] );
243+
```
244+
236245
## Gutenberg
237246

238247
Codifier has a feature to register Gutenberg blocks using ACF's register block feature internally. It works in a very similar fashion than the basic field creation in Codifier as well.

src/Block.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ class Block implements GroupableInterface {
114114
*/
115115
protected $styles = [];
116116

117+
/**
118+
* An array of parent blocks for the block.
119+
*
120+
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#parent-optional
121+
*
122+
* @var array|null
123+
*/
124+
protected $parent = null;
125+
117126
/**
118127
* The renderer for this block.
119128
*
@@ -335,7 +344,7 @@ public function remove_post_type( string $post_type ) : self {
335344
}
336345

337346
/**
338-
* Setter for the post_ ypes.
347+
* Setter for the post_types.
339348
*
340349
* @param array $post_types The post types to set.
341350
* @return self
@@ -449,6 +458,27 @@ public function get_styles() : array {
449458
return $this->styles;
450459
}
451460

461+
/**
462+
* Setter for the parent of the block.
463+
*
464+
* @param array|null $parent Array of parent blocks or null.
465+
* @return self
466+
*/
467+
public function set_parent( ?array $parent ) : self {
468+
$this->parent = $parent;
469+
470+
return $this;
471+
}
472+
473+
/**
474+
* Getter for the parent of the block.
475+
*
476+
* @return array|null
477+
*/
478+
public function get_parent() : ?array {
479+
return $this->parent;
480+
}
481+
452482
/**
453483
* Add a data filtering function for the block
454484
*
@@ -546,6 +576,7 @@ protected function register_block() {
546576
'align' => $this->get_align(),
547577
'supports' => $this->get_supports(),
548578
'styles' => $this->get_styles(),
579+
'parent' => $this->get_parent(),
549580
];
550581

551582
if ( ! empty( $this->get_post_types() ) ) {

src/Field.php

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,48 @@ abstract class Field {
3737
*/
3838
protected $instructions;
3939

40+
/**
41+
* Field type.
42+
*
43+
* @var string
44+
*/
45+
protected $type;
46+
47+
/**
48+
* Field wrapper.
49+
*
50+
* @var array
51+
*/
52+
protected $wrapper = [];
53+
54+
/**
55+
* Registered.
56+
*
57+
* @var string
58+
*/
59+
protected $registered;
60+
61+
/**
62+
* No key.
63+
*
64+
* @var boolean
65+
*/
66+
protected $no_key;
67+
68+
/**
69+
* Parent.
70+
*
71+
* @var mixed
72+
*/
73+
protected $parent;
74+
75+
/**
76+
* Fields var.
77+
*
78+
* @var mixed
79+
*/
80+
protected $fields_var;
81+
4082
/**
4183
* Field required status.
4284
*
@@ -135,6 +177,13 @@ abstract class Field {
135177
*/
136178
protected $redipress_field_type = 'Text';
137179

180+
/**
181+
* Codifier unique ID.
182+
*
183+
* @var string
184+
*/
185+
protected $codifier_unique_id;
186+
138187
/**
139188
* Store registered field keys to warn if there are duplicates.
140189
*
@@ -805,7 +854,7 @@ protected static function redipress_include_search_filter( $value, $post_id, arr
805854

806855
if ( is_string( $redipress_value ) || is_array( $redipress_value ) || is_int( $redipress_value ) ) {
807856
if ( strpos( $post_id, 'block_' ) !== false &&
808-
! ( $post_id = \Geniem\RediPress\Index\Index::indexing() ) // phpcs:ignore
857+
! ( $post_id = \Geniem\RediPress\Index\PostIndex::indexing() ) // phpcs:ignore
809858
) {
810859
$document_uri = filter_input( INPUT_SERVER, 'DOCUMENT_URI', \FILTER_SANITIZE_STRING );
811860

@@ -829,7 +878,7 @@ protected static function redipress_include_search_filter( $value, $post_id, arr
829878
* @param string $field_name Optional field name to RediSearch index. Defaults to field name.
830879
* @param float $weight Optional weight for the search field.
831880
* @param string $method The method to use with multiple values. Defaults to "use_last".
832-
* Possibilites: use_last, concat, concat_with_spaces, sum, custom (needs filter).
881+
* Possibilities: use_last, concat, concat_with_spaces, sum, custom (needs filter).
833882
* @return self
834883
*/
835884
public function redipress_add_queryable(
@@ -841,10 +890,10 @@ public function redipress_add_queryable(
841890
return $this;
842891
}
843892

844-
$this->redipress_add_queryable = true;
845-
$this->redipress_add_queryable_field_name = $field_name;
846-
$this->redipress_add_queryable_weight = $weight;
847-
$this->redipress_add_queryable_method = $method;
893+
$this->redipress_add_queryable = true;
894+
$this->redipress_add_queryable_field_name = $field_name;
895+
$this->redipress_add_queryable_field_weight = $weight;
896+
$this->redipress_add_queryable_method = $method;
848897

849898
add_action( 'codifier/export/key=' . $this->key, \Closure::fromCallable( [ $this, 'redipress_add_queryable_internal' ] ) );
850899

@@ -855,8 +904,6 @@ public function redipress_add_queryable(
855904
* An internal function to be run with the add queryable functionality.
856905
*/
857906
private function redipress_add_queryable_internal() {
858-
$field_name = $this->redipress_add_queryable_field_name;
859-
$weight = $this->redipress_add_queryable_weight;
860907
$method = $this->redipress_add_queryable_method;
861908

862909
if ( ! $method ) {
@@ -924,7 +971,7 @@ private function redipress_add_queryable_internal() {
924971
$doc_id = \Geniem\RediPress\Index\PostIndex::get_document_id( get_post( $post_id ) );
925972
}
926973
elseif ( strpos( $post_id, 'block_' ) !== false ) {
927-
if ( ! ( $post_id = \Geniem\RediPress\Index\Index::indexing() ) ) {
974+
if ( ! ( $post_id = \Geniem\RediPress\Index\PostIndex::indexing() ) ) {
928975
$document_uri = filter_input( INPUT_SERVER, 'DOCUMENT_URI', \FILTER_SANITIZE_STRING );
929976

930977
$post_id = basename( $document_uri );
@@ -973,7 +1020,7 @@ private function redipress_add_queryable_internal() {
9731020
];
9741021

9751022
if ( $this->redipress_field_type === 'Text' ) {
976-
$field_args['weight'] = $this->redipress_add_queryable_weight;
1023+
$field_args['weight'] = $this->redipress_add_queryable_field_weight;
9771024
}
9781025

9791026
if ( class_exists( $type ) ) {

src/Field/Accordion.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ class Accordion extends GroupableField implements PseudoGroupableField {
1616
*/
1717
protected $type = 'accordion';
1818

19+
/**
20+
* Field layout
21+
*
22+
* @var string
23+
*/
24+
protected $layout;
25+
1926
/**
2027
* Fields inside the tab
2128
*

0 commit comments

Comments
 (0)