-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathField.php
More file actions
1346 lines (1144 loc) · 37.1 KB
/
Field.php
File metadata and controls
1346 lines (1144 loc) · 37.1 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* ACF Codifier Field class
*/
namespace Geniem\ACF;
/**
* Class Field
*/
abstract class Field {
/**
* Field label.
*
* @var string
*/
protected $label;
/**
* Field key.
*
* @var string
*/
protected $key;
/**
* Field name.
*
* @var string
*/
protected $name;
/**
* Field instructions.
*
* @var string
*/
protected $instructions;
/**
* Field type.
*
* @var string
*/
protected $type;
/**
* Field wrapper.
*
* @var array
*/
protected $wrapper = [];
/**
* Registered.
*
* @var string
*/
protected $registered;
/**
* No key.
*
* @var boolean
*/
protected $no_key;
/**
* Parent.
*
* @var mixed
*/
protected $parent;
/**
* Fields var.
*
* @var mixed
*/
protected $fields_var;
/**
* Field required status.
*
* @var boolean
*/
protected $required = 0;
/**
* Conditional logic attached to the field.
*
* @var array
*/
protected $conditional_logic = [];
/**
* Default value for the field.
*
* @var mixed
*/
protected $default_value;
/**
* Filters and actions to be hooked.
*
* @var array
*/
protected $filters = [];
/**
* Whether to hide the label or not
*
* @var boolean
*/
protected $hide_label = false;
/**
* Default filter arguments
*
* @var array
*/
protected $default_filter_arguments = [];
/**
* Whether the field should be included in RediPress search index or not.
*
* @var boolean
*/
protected $redipress_include_search = false;
/**
* The callback that should be run when indexing the field.
*
* @var callable
*/
protected $redipress_include_search_callback = null;
/**
* Whether the field is queryable in RediPress or not.
*
* @var boolean
*/
protected $redipress_add_queryable = false;
/**
* With what name should the field be indexed into RediSearch.
*
* @var string
*/
protected $redipress_add_queryable_field_name;
/**
* With what weight should a text field be indexed into RediSearch.
*
* @var float
*/
protected $redipress_add_queryable_field_weight;
/**
* The method with which the data is saved into RediSearch.
*
* @var string|callable
*/
protected $redipress_add_queryable_method;
/**
* A possible filter method for the value before inserting to RediSearch.
*
* @var callable
*/
protected $redipress_queryable_filter;
/**
* What type the RediPress index field should be. Defaults to 'Text'.
*
* @var string
*/
protected $redipress_field_type = 'Text';
/**
* Codifier unique ID.
*
* @var string
*/
protected $codifier_unique_id;
/**
* Store registered field keys to warn if there are duplicates.
*
* @var array
*/
static protected $keys = [];
/**
* A static variable to store if we are indexing for Redipress or not.
*
* @var boolean
*/
static public $indexing = false;
/**
* Field type.
*
* @var string
*/
protected $type = '';
/**
* Field wrapper.
*
* @var array
*/
protected $wrapper = [];
/**
* Registered field as a string for debugging purposes.
*
* @var string
*/
protected $registered = '';
/**
* Possible parent field object.
*
* @var mixed
*/
protected $parent;
/**
* Fields variable name.
*
* @var string
*/
protected $fields_var = '';
/**
* 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 ) {
// Force the inheriting class to have a property type.
if ( ! isset( $this->type ) ) {
throw new \Geniem\ACF\Exception( 'Geniem\ACF\Field: the extending class must have property "type"' );
}
if ( empty( $label ) ) {
throw new \Geniem\ACF\Exception( 'Geniem\ACF\Field: label can\'t be empty' );
}
$this->label = $label;
$this->key = $key ?? $label;
$this->name = $name ?? $label;
$this->wrapper = [
'width' => '',
'class' => [],
'id' => '',
];
$this->default_filter_arguments = [
'priority' => 10,
'accepted_args' => 1,
'no_suffix' => false,
];
if ( WP_DEBUG === true ) {
$debug_backtrace = debug_backtrace();
if ( ! empty( $debug_backtrace[1]['file'] ) && ! empty( $debug_backtrace[1]['line'] ) ) {
$this->registered = $debug_backtrace[1]['file'] . ' at line ' . $debug_backtrace[1]['line'];
}
}
}
/**
* Checks if the field's key is unique within the project scope. Throws a notice if not.
*
* @return void
*/
protected function check_for_unique_key() {
$key = $this->key;
$hash = spl_object_hash( $this );
// Bail early if key not needed.
if ( property_exists( $this, 'no_key' ) && $this->no_key ) {
return;
}
if ( ! isset( self::$keys[ $key ] ) ) {
// Save backtrace data if we want to debug.
if ( ! empty( $this->registered ) ) {
self::$keys[ $key ] = [];
self::$keys[ $key ]['string'] = $this->registered;
self::$keys[ $key ]['hash'] = $hash;
}
// Otherwise just save the info that this key has already been used.
else {
self::$keys[ $key ] = '';
}
}
elseif ( ! is_string( self::$keys[ $key ] ) && self::$keys[ $key ]['hash'] !== $hash ) {
trigger_error( 'ACF Codifier: field key "' . $key . '" defined in ' . $this->registered . ' is already in use within another field which was defined in ' . self::$keys[ $key ]['string'] . '.', E_USER_NOTICE );
}
elseif ( isset( self::$keys[ $key ]['hash'] ) && self::$keys[ $key ]['hash'] !== $hash ) {
trigger_error( 'ACF Codifier: field key "' . $key . '" is already in use within another field.', E_USER_NOTICE );
}
}
/**
* Prevent raw cloning.
*
* @return void
*/
protected function __clone() {}
/**
* Clone method
*
* Forces the developer to give new key to cloned field.
*
* @param string $key Field key.
* @param string $name Field name (optional).
* @return Geniem\ACF\Field
*/
public function clone( string $key, string $name = null ) {
$clone = clone $this;
$clone->set_key( $key );
if ( ! empty( $name ) ) {
$clone->set_name( $name );
}
return $clone;
}
/**
* Export field in ACF's native format.
*
* @param boolean $register Whether the field is to be registered.
* @param mixed $parent Possible parent object.
*
* @throws Exception Throws an exception if a key or a name is not defined.
*
* @return array
*/
public function export( bool $register = false, $parent = null ) : ?array {
if ( empty( $this->key ) ) {
throw new Exception( 'Field ' . $this->label . ' does not have a key defined.' );
}
if ( empty( $this->name ) ) {
throw new Exception( 'Field ' . $this->label . ' does not have a name defined.' );
}
\do_action( 'codifier/export/key=' . $this->key );
$this->parent = $parent;
if ( $register && ! empty( $this->filters ) ) {
array_walk( $this->filters, function( $filter ) use ( $parent ) {
$filter = wp_parse_args( $filter, $this->default_filter_arguments );
if ( substr( $filter['filter'], 0, 10 ) === 'redipress/' ) {
if ( $this->get_is_user() ) {
switch ( $filter['filter'] ) {
case 'redipress/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;
}
}
}
if ( $filter['no_suffix'] ) {
add_filter( $filter['filter'], $filter['function'], $filter['priority'], $filter['accepted_args'] );
}
else {
add_filter( $filter['filter'] . $this->key, $filter['function'], $filter['priority'], $filter['accepted_args'] );
}
});
}
if ( $register && $this->redipress_get_queryable_status() === true ) {
add_filter( 'acf/format_value/key=' . $this->key, \Closure::fromCallable( [ __CLASS__, 'redipress_additional_field' ] ), 10, 3 );
}
if ( $register && $this->hide_label ) {
\Geniem\ACF\Codifier::hide_label( $this );
}
$obj = get_object_vars( $this );
// Remove unnecessary properties from the exported array.
unset( $obj['fields_var'] );
unset( $obj['filters'] );
unset( $obj['parent'] );
if ( \property_exists( $this, 'fields_var' ) && ! empty( $obj[ $this->fields_var ] ) ) {
$obj[ $this->fields_var ] = array_map( function( $field ) use ( $register ) {
return $field->export( $register, $this );
}, $obj[ $this->fields_var ] );
$obj[ $this->fields_var ] = array_values( $obj[ $this->fields_var ] );
}
// Convert the wrapper class array to a space-separated string.
if ( isset( $obj['wrapper']['class'] ) && ! empty( $obj['wrapper']['class'] ) ) {
$obj['wrapper']['class'] = implode( ' ', $obj['wrapper']['class'] );
}
else {
$obj['wrapper']['class'] = '';
}
// If we are registering the field, check that its key is unique.
if ( $register ) {
$this->check_for_unique_key();
}
if ( ! empty( $obj['conditional_logic'] ) ) {
foreach ( $obj['conditional_logic'] as &$group ) {
if ( count( $group ) > 0 ) {
foreach ( $group as &$rule ) {
if ( ! is_string( $rule['field'] ) ) {
$rule['field'] = $rule['field']->get_key();
}
}
}
}
}
return $obj;
}
/**
* Get field group
*
* @param mixed $parent Parent object.
*
* @return \Geniem\ACF\Group
*/
protected function get_field_group( $parent ) : ?\Geniem\ACF\Group {
if ( $parent instanceof \Geniem\ACF\Group ) {
return $parent;
}
else {
return $this->get_field_group( $parent->parent );
}
}
/**
* If the field is for user or not
*
* @return bool
*/
protected function get_is_user() : bool {
if ( empty( $this->parent ) ) {
return false;
}
$field_group = $this->get_field_group( $this->parent );
$rules = $field_group->get_rule_groups();
if ( empty( $rules ) ) {
return false;
}
$flatten = array_merge( ...$rules );
return array_reduce( $flatten, function( $carry, $item ) : bool {
if ( $carry ) {
return true;
}
if ( substr( $item['param'], 0, 5 ) === 'user_' && $item['operator'] === '==' ) {
return true;
}
return false;
}, false );
}
/**
* Set label for the field.
*
* @param string $label Label to be set.
* @return self
*/
public function set_label( string $label ) {
$this->label = $label;
return $this;
}
/**
* Get the label of the field.
*
* @return string
*/
public function get_label() {
return $this->label;
}
/**
* Set key for the field.
*
* @param string $key Key to be set.
* @return self
*/
public function set_key( string $key ) {
$this->key = $key;
return $this;
}
/**
* Get the key of the field.
*
* @return string
*/
public function get_key() {
return $this->key;
}
/**
* Set name for the field.
*
* @param string $name Name to be set.
* @return self
*/
public function set_name( string $name ) {
$this->name = $name;
return $this;
}
/**
* Get the name of the field.
*
* @return string
*/
public function get_name() {
return $this->name;
}
/**
* Get the type of the field.
*
* @return string
*/
public function get_type() {
return $this->type;
}
/**
* Set instruction text for the field.
*
* @param string $instructions Instructions.
* @return self
*/
public function set_instructions( string $instructions ) {
$this->instructions = $instructions;
return $this;
}
/**
* Get the instruction text of the field.
*
* @return string
*/
public function get_instructions() {
return $this->instructions;
}
/**
* Set the field to be required.
*
* @return self
*/
public function set_required() {
$this->required = 1;
return $this;
}
/**
* Set the field to be unrequired.
*
* @return self
*/
public function set_unrequired() {
$this->required = 0;
return $this;
}
/**
* Get the required status of the field.
*
* @return boolean
*/
public function get_required() {
return (boolean) $this->required;
}
/**
* Add a conditional logic for the field.
*
* @param \Geniem\ACF\ConditionalLogicGroup $group The conditional logic group to be added.
* @return self
*/
public function add_conditional_logic( \Geniem\ACF\ConditionalLogicGroup $group ) {
$rules = $group->get_rules();
if ( count( $rules ) > 0 ) {
$this->conditional_logic[] = $rules;
}
return $this;
}
/**
* Get the conditional logic group that have been added to the group.
*
* @return \Geniem\ACF\ConditionalLogicGroup
*/
public function get_conditional_logic() {
return $this->conditional_logic;
}
/**
* Set the wrapper width in percents.
*
* @param integer $width Width to be set.
* @return self
*/
public function set_wrapper_width( int $width ) {
$this->wrapper['width'] = $width;
return $this;
}
/**
* Get the wrapper width.
*
* @return int
*/
public function get_wrapper_width() {
return $this->wrapper['width'];
}
/**
* Set classes to be added for the field.
*
* @param mixed $classes The classes to be added either as an array or as a space-separated string.
* @throws \Geniem\ACF\Exception Throw error if mandatory property is not set.
* @return self
*/
public function set_wrapper_classes( $classes ) {
if ( is_string( $classes ) ) {
$this->wrapper['class'] = explode( ' ', $classes );
}
elseif ( is_array( $classes ) ) {
$this->wrapper['class'] = $classes;
}
else {
throw new \Geniem\ACF\Exception( 'Geniem\ACF\Field: set_wrapper_classes() argument must be an array or a string' );
}
return $this;
}
/**
* Add a single wrapper class to be added for the field.
*
* @param string $class Class to be added.
* @return self
*/
public function add_wrapper_class( string $class ) {
$this->wrapper['class'][] = $class;
return $this;
}
/**
* Remove a single wrapper class from the field.
*
* @param string $class Class to be removed.
* @return self
*/
public function remove_wrapper_class( string $class ) {
$position = array_search( $class, $this->wrapper['class'], true );
if ( ( $position !== false ) ) {
unset( $this->wrapper['class'][ $position ] );
}
return $this;
}
/**
* Get all wrapper classes that have been added for the field.
*
* @return array
*/
public function get_wrapper_classes() {
return $this->wrapper['class'];
}
/**
* Add a wrapper id for the field.
*
* @param string $id Id to be added.
* @return self
*/
public function set_wrapper_id( string $id ) {
$this->wrapper['id'] = $id;
return $this;
}
/**
* Get the id that has been added for the field.
*
* @return string
*/
public function get_wrapper_id() {
return $this->wrapper['id'];
}
/**
* Set the default value for the field.
*
* @param mixed $value The default value.
* @return self
*/
public function set_default_value( $value ) {
$this->default_value = $value;
return $this;
}
/**
* Get the default value of the field.
*
* @return mixed
*/
public function get_default_value() {
return $this->default_value;
}
/**
* Hide the field label in the admin side
*
* @return self
*/
public function hide_label() {
$this->hide_label = true;
return $this;
}
/**
* Show the field label in the admin side
*
* @return self
*/
public function show_label() {
$this->hide_label = false;
return $this;
}
/**
* Get the label visibility status
*
* @return boolean
*/
public function get_label_visibility() {
return $this->hide_label;
}
/**
* Unset a previously set filter.
*
* @param string $filter The key for the filter to be unset.
* @return self
*/
public function unset_filter( $filter ) {
unset( $this->filters[ $filter ] );
return $this;
}
/**
* Add a filter method for the value before inserting it into RediSearch.
*
* @param callable $filter The filter method.
* @return self
*/
public function redipress_queryable_filter( callable $filter ) {
$this->redipress_queryable_filter = $filter;
return $this;
}
/**
* Include this field's value in the RediPress search index.
*
* @param callable $callback Possible callback to run the value through before inserting into index.
* @return self
*/
public function redipress_include_search( callable $callback = null ) {
$this->redipress_include_search = true;
$this->redipress_include_search_callback = $callback;
$this->filters['redipress_include_search'] = [
'filter' => 'acf/update_value/key=',
'function' => \Closure::fromCallable( [ __CLASS__, 'redipress_include_search_filter' ] ),
'priority' => 10,
'accepted_args' => 3,
];
return $this;
}
/**
* Exclude this field's value in the RediPress search index.
*
* @return self
*/
public function redipress_exclude_search() {
$this->redipress_include_search = false;
unset( $this->filters['redipress_include_search'] );
unset( $this->redipress_include_search_callback );
return $this;
}
/**
* Get RediPress search index status of this field.
*
* @return boolean
*/
public function redipress_get_search_status() : bool {
return isset( $this->filters['redipress_include_search'] );
}
/**
* Use RediPress formatting functions in all suitable fields.
*
* @return void
*/
public static function redipress_use_include_search_filter() {
add_filter( 'acf/format_value', \Closure::fromCallable(( [ __CLASS__, 'redipress_include_search_filter' ] ) ), 10, 3 );
}
/**
* Include the field's value in RediPress search index.
*
* @param mixed $value Field's value.
* @param integer $post_id Post ID.
* @param array $field ACF field object as an array.
* @return mixed
*/
protected static function redipress_include_search_filter( $value, $post_id, array $field ) {
if ( ! empty( $field['redipress_include_search'] ) && $field['redipress_include_search'] === true ) {
if ( \method_exists( '\\Geniem\\RediPress\\Index\\Index', 'store' ) ) {
if ( ! empty( $field['redipress_include_search_callback'] ) ) {
$redipress_value = ( $field['redipress_include_search_callback'] )( $value );
}
else {
$redipress_value = $value;
}
if ( is_string( $redipress_value ) || is_array( $redipress_value ) || is_int( $redipress_value ) ) {
if ( strpos( $post_id, 'block_' ) !== false &&
! ( $post_id = \Geniem\RediPress\Index\PostIndex::indexing() ) // phpcs:ignore
) {
$document_uri = filter_input( INPUT_SERVER, 'DOCUMENT_URI', \FILTER_SANITIZE_STRING );
$post_id = basename( $document_uri );
}
\Geniem\RediPress\Index\Index::store( $post_id, 'search_index', $redipress_value, 'concat_with_spaces' );
}
else {
\trigger_error( 'ACF Codifier: RediPress search include failed for "' . $field['key'] . '", value is not a string or an array.', \E_USER_WARNING );
}
}
}
return $value;
}
/**
* Add this field's value as a queryable value to RediSearch index.
*
* @param string $field_name Optional field name to RediSearch index. Defaults to field name.
* @param float $weight Optional weight for the search field.
* @param string $method The method to use with multiple values. Defaults to "use_last".
* Possibilities: use_last, concat, concat_with_spaces, sum, custom (needs filter).
* @return self
*/
public function redipress_add_queryable(
string $field_name = null,
float $weight = 1.0,
string $method = null
) {
if ( ! \method_exists( '\\Geniem\\RediPress\\Index\\Index', 'store' ) ) {
return $this;
}
$this->redipress_add_queryable = true;
$this->redipress_add_queryable_field_name = $field_name;
$this->redipress_add_queryable_field_weight = $weight;
$this->redipress_add_queryable_method = $method;
add_action( 'codifier/export/key=' . $this->key, \Closure::fromCallable( [ $this, 'redipress_add_queryable_internal' ] ) );
return $this;
}
/**
* An internal function to be run with the add queryable functionality.
*/
private function redipress_add_queryable_internal() {
$method = $this->redipress_add_queryable_method;
if ( ! $method ) {
if ( $this->redipress_field_type === 'Tag' ) {
$method = 'array_merge';
}
else {
$method = 'use_last';
}
}
$this->filters['redipress_add_queryable'] = [
'filter' => 'acf/format_value/key=',
'function' => function( $value, $post_id, $field ) use ( $method ) {
if ( $this->redipress_add_queryable === true ) {
if ( ! empty( $this->redipress_queryable_filter ) ) {
$redipress_value = ( $this->redipress_queryable_filter )( $value );
}
else {
$redipress_value = $value;
}
if ( strpos( $post_id, 'block_' ) !== false &&
! ( $post_id = \Geniem\RediPress\Index\PostIndex::indexing() ) // phpcs:ignore
) {
$document_uri = filter_input( INPUT_SERVER, 'DOCUMENT_URI', \FILTER_SANITIZE_STRING );
$post_id = basename( $document_uri );
}
\Geniem\RediPress\Index\Index::store(
$post_id,
$this->redipress_add_queryable_field_name ?? $field['name'],
$redipress_value,
$method
);
}
return $value;
},
'priority' => 11,
'accepted_args' => 3,
];
$this->filters['redipress_add_queryable_single'] = [
'filter' => 'acf/update_value/key=',
'function' => function( $value, $post_id, $field ) {
$users = false;
if ( $this->get_is_user() ) {
$user_id = str_replace( 'user_', '', $post_id );
$user = get_user_by( 'id', $user_id );
// If the user does not exist, we don't know what to do so just bail out.
if ( ! $user ) {
return $value;
}