PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.9.19.5
Pods – Custom Content Types and Fields v2.9.19.5
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / src / Pods / Config_Handler.php
pods / src / Pods Last commit date
API 2 days ago Admin 2 days ago Blocks 2 days ago CLI 2 days ago Data 2 days ago Integrations 2 days ago REST 2 days ago Theme 2 days ago Tools 2 days ago Whatsit 2 days ago Config_Handler.php 2 days ago Integration.php 2 days ago Permissions.php 2 days ago Pod_Manager.php 2 days ago Service_Provider.php 2 days ago Service_Provider_Base.php 2 days ago Service_Provider_Fallback.php 2 days ago Static_Cache.php 2 days ago Whatsit.php 2 days ago Wisdom_Tracker.php 2 days ago
Config_Handler.php
850 lines
1 <?php
2
3 namespace Pods;
4
5 use Spyc;
6
7 /**
8 * Class to handle registration of Pods configs and loading/saving of config files.
9 *
10 * @package Pods
11 */
12 class Config_Handler {
13
14 /**
15 * List of registered config types.
16 *
17 * @since 2.9.0
18 *
19 * @var array
20 */
21 protected $registered_config_types = [
22 'json' => 'json',
23 'yml' => 'yml',
24 ];
25
26 /**
27 * List of registered config item types.
28 *
29 * @since 2.9.0
30 *
31 * @var array
32 */
33 protected $registered_config_item_types = [
34 'pods' => 'pods',
35 'groups' => 'groups',
36 'fields' => 'fields',
37 'templates' => 'templates',
38 'pages' => 'pages',
39 'helpers' => 'helpers',
40 ];
41
42 /**
43 * List of registered paths.
44 *
45 * @since 2.9.0
46 *
47 * @var array
48 */
49 protected $registered_paths = [];
50
51 /**
52 * List of registered files.
53 *
54 * @since 2.9.0
55 *
56 * @var array
57 */
58 protected $registered_files = [];
59
60 /**
61 * List of registered Pods configs.
62 *
63 * @since 2.9.0
64 *
65 * @var array
66 */
67 protected $pods = [];
68
69 /**
70 * List of registered Pods Template configs.
71 *
72 * @since 2.9.0
73 *
74 * @var array
75 */
76 protected $templates = [];
77
78 /**
79 * List of registered Pods Page configs.
80 *
81 * @since 2.9.0
82 *
83 * @var array
84 */
85 protected $pages = [];
86
87 /**
88 * List of registered Pods Helper configs.
89 *
90 * @since 2.9.0
91 *
92 * @var array
93 */
94 protected $helpers = [];
95
96 /**
97 * Associative array list of other registered configs.
98 *
99 * @since 2.9.0
100 *
101 * @var array
102 */
103 protected $custom_configs = [];
104
105 /**
106 * List of config names for each file path.
107 *
108 * @since 2.9.0
109 *
110 * @var array
111 */
112 protected $file_path_configs = [];
113
114 /**
115 * Config constructor.
116 *
117 * @since 2.9.0
118 */
119 public function __construct() {
120 // Nothing to see here.
121 }
122
123 /**
124 * Setup initial registered paths and load configs.
125 *
126 * @since 2.9.0
127 */
128 public function setup() {
129 // Register theme.
130 $this->register_path( get_template_directory() );
131
132 if ( get_template_directory() !== get_stylesheet_directory() ) {
133 // Register child theme.
134 $this->register_path( get_stylesheet_directory() );
135 }
136
137 $this->load_configs();
138 $this->store_configs();
139 }
140
141 /**
142 * Register a config type.
143 *
144 * @since 2.9.0
145 *
146 * @param string $config_type Config type.
147 */
148 public function register_config_type( $config_type ) {
149 $config_type = sanitize_title( $config_type );
150 $config_type = str_replace( [ '/', DIRECTORY_SEPARATOR ], '-', $config_type );
151
152 $this->registered_config_types[ $config_type ] = $config_type;
153 }
154
155 /**
156 * Unregister a config type.
157 *
158 * @since 2.9.0
159 *
160 * @param string $config_type Config type.
161 */
162 public function unregister_config_type( $config_type ) {
163 $config_type = sanitize_title( $config_type );
164 $config_type = str_replace( [ '/', DIRECTORY_SEPARATOR ], '-', $config_type );
165
166 if ( isset( $this->registered_config_types[ $config_type ] ) ) {
167 unset( $this->registered_config_types[ $config_type ] );
168 }
169 }
170
171 /**
172 * Register a config item type.
173 *
174 * @since 2.9.0
175 *
176 * @param string $item_type Config item type.
177 */
178 public function register_config_item_type( $item_type ) {
179 $item_type = sanitize_title( $item_type );
180 $item_type = str_replace( [ '/', DIRECTORY_SEPARATOR ], '-', $item_type );
181
182 $this->registered_config_item_types[ $item_type ] = $item_type;
183 }
184
185 /**
186 * Unregister a config item type.
187 *
188 * @since 2.9.0
189 *
190 * @param string $item_type Config item type.
191 */
192 public function unregister_config_item_type( $item_type ) {
193 $item_type = sanitize_title( $item_type );
194 $item_type = str_replace( [ '/', DIRECTORY_SEPARATOR ], '-', $item_type );
195
196 if ( isset( $this->registered_config_item_types[ $item_type ] ) ) {
197 unset( $this->registered_config_item_types[ $item_type ] );
198 }
199 }
200
201 /**
202 * Register a config file path.
203 *
204 * @since 2.9.0
205 *
206 * @param string $path The config file path to use.
207 */
208 public function register_path( $path ) {
209 $path = trailingslashit( $path );
210
211 if ( 0 !== strpos( $path, ABSPATH ) ) {
212 $path = ABSPATH . $path;
213 }
214
215 $this->registered_paths[ $path ] = $path;
216 }
217
218 /**
219 * Unregister a config file path.
220 *
221 * @since 2.9.0
222 *
223 * @param string $path The config file path to use.
224 */
225 public function unregister_path( $path ) {
226 $path = trailingslashit( $path );
227
228 if ( 0 !== strpos( $path, ABSPATH ) ) {
229 $path = ABSPATH . $path;
230 }
231
232 if ( isset( $this->registered_paths[ $path ] ) ) {
233 unset( $this->registered_paths[ $path ] );
234 }
235 }
236
237 /**
238 * Register a config file.
239 *
240 * @since 2.9.0
241 *
242 * @param string $file Config file to use.
243 * @param string $config_type Config type to use.
244 */
245 public function register_file( $file, $config_type ) {
246 if ( ! isset( $this->registered_files[ $config_type ] ) ) {
247 $this->registered_files[ $config_type ] = [];
248 }
249
250 $this->registered_files[ $config_type ][ $file ] = $file;
251 }
252
253 /**
254 * Unregister a config file file.
255 *
256 * @since 2.9.0
257 *
258 * @param string $file Config file to use.
259 * @param string $config_type Config type to use.
260 */
261 public function unregister_file( $file, $config_type ) {
262 if ( isset( $this->registered_files[ $config_type ][ $file ] ) ) {
263 unset( $this->registered_files[ $config_type ][ $file ] );
264 }
265 }
266
267 /**
268 * Get file configs based on registered config types and config item types.
269 *
270 * @since 2.9.0
271 *
272 * @return array File configs.
273 */
274 protected function get_file_configs() {
275 $file_configs = [];
276
277 // Flesh out the config types.
278 foreach ( $this->registered_config_types as $config_type ) {
279 foreach ( $this->registered_config_item_types as $config_item_type ) {
280 $theme_support = false;
281
282 // Themes get pods.json / pods.yml support at root.
283 if ( 'pods' === $config_item_type ) {
284 $theme_support = true;
285 }
286
287 $path = sprintf( '%s.%s', $config_item_type, $config_type );
288
289 $file_configs[] = [
290 'type' => $config_type,
291 'file' => $path,
292 'item_type' => $config_item_type,
293 'theme_support' => $theme_support,
294 ];
295
296 // Prepend pods/ to path for theme paths.
297 $path = sprintf( 'pods%s%s', DIRECTORY_SEPARATOR, $path );
298
299 $file_configs[] = [
300 'type' => $config_type,
301 'file' => $path,
302 'item_type' => $config_item_type,
303 'theme_support' => true,
304 ];
305 }
306 }
307
308 return $file_configs;
309 }
310
311 /**
312 * Load configs from registered file paths.
313 *
314 * @since 2.9.0
315 */
316 protected function load_configs() {
317 /**
318 * Allow plugins/themes to hook into config loading.
319 *
320 * @since 2.9.0
321 *
322 * @param Config $pods_config Pods config object.
323 *
324 */
325 do_action( 'pods_config_pre_load_configs', $this );
326
327 $file_configs = $this->get_file_configs();
328
329 $theme_dirs = [
330 trailingslashit( get_template_directory() ) => true,
331 trailingslashit( get_stylesheet_directory() ) => true,
332 ];
333
334 $cached_found_configs = pods_transient_get( 'pods_config_handler_found_configs' );
335
336 if ( empty( $cached_found_configs ) ) {
337 $cached_found_configs = false;
338 }
339
340 $found_configs = [];
341
342 $refresh_cache = false;
343
344 foreach ( $this->registered_paths as $config_path ) {
345 foreach ( $file_configs as $file_config ) {
346 if ( empty( $file_config['theme_support'] ) && isset( $theme_dirs[ $config_path ] ) ) {
347 continue;
348 }
349
350 $file_path = $config_path . $file_config['file'];
351
352 if ( $cached_found_configs && ! isset( $cached_found_configs[ $file_path ] ) ) {
353 continue;
354 }
355
356 $found_config = $this->load_config_file( $file_path, $file_config['type'], $file_config );
357
358 if ( $found_config ) {
359 $found_configs[ $file_path ] = true;
360 } elseif ( $cached_found_configs ) {
361 $refresh_cache = true;
362 }
363 }
364 }
365
366 if (
367 $refresh_cache
368 || (
369 ! empty( $found_configs )
370 && $found_configs !== $cached_found_configs
371 )
372 ) {
373 pods_transient_set( 'pods_config_handler_found_configs', $found_configs, WEEK_IN_SECONDS );
374 }
375
376 foreach ( $this->registered_files as $config_type => $files ) {
377 foreach ( $files as $file ) {
378 $this->load_config_file( $file, $config_type );
379 }
380 }
381 }
382
383 /**
384 * Load the config file for a config type from a specific file path.
385 *
386 * @param string $file_path The config file path to use.
387 * @param string $config_type The config type to use.
388 * @param array $file_config File config.
389 *
390 * @return bool Whether the config file was found and loaded.
391 */
392 protected function load_config_file( $file_path, $config_type, array $file_config = [] ) {
393 if ( ! file_exists( $file_path ) || ! is_readable( $file_path ) ) {
394 return false;
395 }
396
397 $raw_config = file_get_contents( $file_path );
398
399 if ( empty( $raw_config ) ) {
400 return false;
401 }
402
403 $file_config['type'] = $config_type;
404
405 return $this->load_config( $config_type, $raw_config, $file_path, $file_config );
406 }
407
408 /**
409 * Load config from registered file path.
410 *
411 * @since 2.9.0
412 *
413 * @param string $config_type Config type.
414 * @param string $raw_config Raw config content.
415 * @param string $file_path The config file path to use.
416 * @param array $file_config File config.
417 *
418 * @return bool Whether the config was loaded.
419 */
420 protected function load_config( $config_type, $raw_config, $file_path, array $file_config ) {
421 $config = null;
422
423 if ( 'yml' === $config_type ) {
424 require_once PODS_DIR . 'vendor/mustangostang/spyc/Spyc.php';
425
426 $config = Spyc::YAMLLoadString( $raw_config );
427 } elseif ( 'json' === $config_type ) {
428 $config = json_decode( $raw_config, true );
429 } else {
430 /**
431 * Parse Pods config from a custom config type.
432 *
433 * @since 2.9.0
434 *
435 * @param array $config Config data.
436 * @param string $raw_config Raw config content.
437 */
438 $config = apply_filters( "pods_config_parse_{$config_type}", [], $raw_config );
439 }
440
441 /**
442 * Allow filtering the config for additional parsing customization.
443 *
444 * @since 2.9.0
445 *
446 * @param array $config Config data.
447 * @param string $config_type Config type.
448 * @param string $raw_config Raw config content.
449 */
450 $config = apply_filters( 'pods_config_parse', $config, $config_type, $raw_config );
451
452 if ( $config && is_array( $config ) ) {
453 $this->register_config( $config, $file_path, $file_config );
454
455 return true;
456 }
457
458 return false;
459 }
460
461 /**
462 * Register config for different item types.
463 *
464 * @since 2.9.0
465 *
466 * @param array $config Config data.
467 * @param string $file_path The config file path to use.
468 * @param array $file_config File config.
469 */
470 protected function register_config( array $config, $file_path, array $file_config = [] ) {
471 if ( ! isset( $this->file_path_configs[ $file_path ] ) ) {
472 $this->file_path_configs[ $file_path ] = [];
473 }
474
475 foreach ( $config as $item_type => $items ) {
476 if ( empty( $items ) || ! is_array( $items ) ) {
477 continue;
478 }
479
480 $supported_item_types = [
481 $item_type,
482 // We support all item types for pods configs.
483 'pods',
484 ];
485
486 // Skip if the item type is not supported for this config file.
487 if ( ! empty( $file_config['item_type'] ) && ! in_array( $file_config['item_type'], $supported_item_types, true ) ) {
488 continue;
489 }
490
491 if ( ! isset( $this->file_path_configs[ $file_path ][ $item_type ] ) ) {
492 $this->file_path_configs[ $file_path ][ $item_type ] = [];
493 }
494
495 if ( 'pods' === $item_type ) {
496 $this->register_config_pods( $items, $file_path );
497 } elseif ( 'groups' === $item_type ) {
498 $this->register_config_groups( $items, $file_path );
499 } elseif ( 'fields' === $item_type ) {
500 $this->register_config_fields( $items, $file_path );
501 } elseif ( 'templates' === $item_type ) {
502 $this->register_config_templates( $items, $file_path );
503 } elseif ( 'pages' === $item_type ) {
504 $this->register_config_pages( $items, $file_path );
505 } elseif ( 'helpers' === $item_type ) {
506 $this->register_config_helpers( $items, $file_path );
507 } else {
508 $this->register_config_custom_item_type( $item_type, $items, $file_path );
509 }
510 }
511
512 }
513
514 /**
515 * Register pod configs.
516 *
517 * @since 2.9.0
518 *
519 * @param array $items Config items.
520 * @param string $file_path The config file path to use.
521 */
522 protected function register_config_pods( array $items, $file_path = '' ) {
523 foreach ( $items as $item ) {
524 // Check if the item type and name exists.
525 if ( empty( $item['type'] ) || empty( $item['name'] ) ) {
526 continue;
527 }
528
529 if ( ! isset( $this->pods[ $item['type'] ] ) ) {
530 $this->pods[ $item['type'] ] = [];
531 }
532
533 if ( isset( $item['id'] ) ) {
534 unset( $item['id'] );
535 }
536
537 if ( empty( $item['groups'] ) ) {
538 $item['groups'] = [];
539 }
540
541 if ( empty( $item['fields'] ) ) {
542 $item['fields'] = [];
543 }
544
545 $item['_pods_file_source'] = $file_path;
546
547 $this->pods[ $item['type'] ][ $item['name'] ] = $item;
548
549 $this->file_path_configs[ $file_path ]['pods'] = $item['type'] . ':' . $item['name'];
550 }
551
552 }
553
554 /**
555 * Register pod field configs.
556 *
557 * @since 2.9.0
558 *
559 * @param array $items Config items.
560 * @param string $file_path The config file path to use.
561 */
562 protected function register_config_fields( array $items, $file_path = '' ) {
563 foreach ( $items as $item ) {
564 // Check if the pod name, pod type, item type, and item name exists.
565 if ( empty( $item['type'] ) || empty( $item['name'] ) || empty( $item['pod']['name'] ) || empty( $item['pod']['type'] ) ) {
566 continue;
567 }
568
569 if ( ! isset( $this->pods[ $item['pod']['type'] ] ) ) {
570 $this->pods[ $item['pod']['type'] ] = [];
571 }
572
573 if ( isset( $item['pod']['id'] ) ) {
574 unset( $item['pod']['id'] );
575 }
576
577 // Check if pod has been registered yet.
578 if ( ! isset( $this->pods[ $item['pod']['type'][ $item['pod']['name'] ] ] ) ) {
579 $this->pods[ $item['pod']['type'] ][ $item['pod']['name'] ] = $item['pod'];
580 }
581
582 // Check if pod has fields that have been registered yet.
583 if ( ! isset( $this->pods[ $item['pod']['type'][ $item['pod']['name'] ] ]['fields'] ) ) {
584 $this->pods[ $item['pod']['type'] ][ $item['pod']['name'] ]['fields'] = [];
585 }
586
587 if ( isset( $item['id'] ) ) {
588 unset( $item['id'] );
589 }
590
591 $item['_pods_file_source'] = $file_path;
592
593 $this->pods[ $item['pod']['type'] ][ $item['pod']['name'] ]['fields'][ $item['name'] ] = $item;
594
595 $this->file_path_configs[ $file_path ]['pods'] = $item['pod']['type'] . ':' . $item['pod']['name'] . ':' . $item['name'];
596 }
597
598 }
599
600 /**
601 * Register pod field configs.
602 *
603 * @since 2.9.14
604 *
605 * @param array $items Config items.
606 * @param string $file_path The config file path to use.
607 */
608 protected function register_config_groups( array $items, $file_path = '' ) {
609 foreach ( $items as $item ) {
610 // Check if the pod name, pod type, item type, and item name exists.
611 if ( empty( $item['type'] ) || empty( $item['name'] ) || empty( $item['pod']['name'] ) || empty( $item['pod']['type'] ) ) {
612 continue;
613 }
614
615 if ( ! isset( $this->pods[ $item['pod']['type'] ] ) ) {
616 $this->pods[ $item['pod']['type'] ] = [];
617 }
618
619 if ( isset( $item['pod']['id'] ) ) {
620 unset( $item['pod']['id'] );
621 }
622
623 // Check if pod has been registered yet.
624 if ( ! isset( $this->pods[ $item['pod']['type'][ $item['pod']['name'] ] ] ) ) {
625 $this->pods[ $item['pod']['type'] ][ $item['pod']['name'] ] = $item['pod'];
626 }
627
628 // Check if pod has groups that have been registered yet.
629 if ( ! isset( $this->pods[ $item['pod']['type'][ $item['pod']['name'] ] ]['groups'] ) ) {
630 $this->pods[ $item['pod']['type'] ][ $item['pod']['name'] ]['groups'] = [];
631 }
632
633 if ( isset( $item['id'] ) ) {
634 unset( $item['id'] );
635 }
636
637 $item['_pods_file_source'] = $file_path;
638
639 $this->pods[ $item['pod']['type'] ][ $item['pod']['name'] ]['groups'][ $item['name'] ] = $item;
640
641 $this->file_path_configs[ $file_path ]['pods'] = $item['pod']['type'] . ':' . $item['pod']['name'] . ':' . $item['name'];
642 }
643
644 }
645
646 /**
647 * Register template configs.
648 *
649 * @since 2.9.0
650 *
651 * @param array $items Config items.
652 * @param string $file_path The config file path to use.
653 */
654 protected function register_config_templates( array $items, $file_path = '' ) {
655 foreach ( $items as $item ) {
656 // Check if the item name exists.
657 if ( empty( $item['name'] ) ) {
658 continue;
659 }
660
661 if ( isset( $item['id'] ) ) {
662 unset( $item['id'] );
663 }
664
665 // Legacy support for old Template/Page/Helper objects.
666 $item['label'] = $item['name'];
667 $item['description'] = $item['code'];
668 $item['name'] = sanitize_title( $item['label'] );
669
670 unset( $item['code'] );
671
672 $item['_pods_file_source'] = $file_path;
673
674 $this->templates[ $item['label'] ] = $item;
675
676 $this->file_path_configs[ $file_path ]['templates'] = $item['label'];
677 }
678
679 }
680
681 /**
682 * Register page configs.
683 *
684 * @since 2.9.0
685 *
686 * @param array $items Config items.
687 * @param string $file_path The config file path to use.
688 */
689 protected function register_config_pages( array $items, $file_path = '' ) {
690 foreach ( $items as $item ) {
691 // Check if the item name exists.
692 if ( empty( $item['name'] ) ) {
693 continue;
694 }
695
696 if ( isset( $item['id'] ) ) {
697 unset( $item['id'] );
698 }
699
700 // Legacy support for old Template/Page/Helper objects.
701 $item['label'] = $item['name'];
702 $item['description'] = $item['code'];
703 $item['name'] = sanitize_title( $item['label'] );
704
705 unset( $item['code'] );
706
707 $item['_pods_file_source'] = $file_path;
708
709 $this->pages[ $item['name'] ] = $item;
710
711 $this->file_path_configs[ $file_path ]['pages'] = $item['name'];
712 }
713
714 }
715
716 /**
717 * Register helper configs.
718 *
719 * @since 2.9.0
720 *
721 * @param array $items Config items.
722 * @param string $file_path The config file path to use.
723 */
724 protected function register_config_helpers( array $items, $file_path = '' ) {
725 foreach ( $items as $item ) {
726 // Check if the item name exists.
727 if ( empty( $item['name'] ) ) {
728 continue;
729 }
730
731 if ( isset( $item['id'] ) ) {
732 unset( $item['id'] );
733 }
734
735 // Legacy support for old Template/Page/Helper objects.
736 $item['label'] = $item['name'];
737 $item['description'] = $item['code'];
738 $item['name'] = sanitize_title( $item['label'] );
739
740 unset( $item['code'] );
741
742 $item['_pods_file_source'] = $file_path;
743
744 $this->helpers[ $item['name'] ] = $item;
745
746 $this->file_path_configs[ $file_path ]['helpers'] = $item['name'];
747 }
748
749 }
750
751 /**
752 * Register config items for custom config item type.
753 *
754 * @since 2.9.0
755 *
756 * @param string $item_type Config Item type.
757 * @param array $items Config items.
758 * @param string $file_path The config file path to use.
759 */
760 protected function register_config_custom_item_type( $item_type, array $items, $file_path = '' ) {
761 if ( ! isset( $this->custom_configs[ $item_type ] ) ) {
762 $this->custom_configs[ $item_type ] = [];
763 }
764
765 foreach ( $items as $item ) {
766 /**
767 * Pre-process the item to be saved for a custom item type.
768 *
769 * @since 2.9.0
770 *
771 * @param string $item_type Item type.
772 * @param string $file_path The config file path to use.
773 *
774 * @param array $item Item to pre-process.
775 */
776 $item = apply_filters( 'pods_config_register_custom_item', $item, $item_type, $file_path );
777
778 // Check if the item name exists.
779 if ( empty( $item['name'] ) ) {
780 continue;
781 }
782
783 if ( isset( $item['id'] ) ) {
784 unset( $item['id'] );
785 }
786
787 $item['_pods_file_source'] = $file_path;
788
789 $this->custom_configs[ $item_type ][ $item['name'] ] = $item;
790
791 $this->file_path_configs[ $file_path ][ $item_type ] = $item['name'];
792 }
793
794 }
795
796 /**
797 * Store the registered configurations.
798 */
799 protected function store_configs() {
800 $mapped_object_types = [
801 'pods' => 'pod',
802 'templates' => 'template',
803 'pages' => 'page',
804 'helpers' => 'helper',
805 ];
806
807 foreach ( $this->registered_config_item_types as $config_item_type ) {
808 if ( 'pods' === $config_item_type ) {
809 $configs = $this->pods;
810 } elseif ( 'templates' === $config_item_type ) {
811 $configs = $this->templates;
812 } elseif ( 'pages' === $config_item_type ) {
813 $configs = $this->pages;
814 } elseif ( 'helpers' === $config_item_type ) {
815 $configs = $this->helpers;
816 } elseif ( isset( $this->custom_configs[ $config_item_type ] ) ) {
817 $configs = $this->custom_configs[ $config_item_type ];
818 } else {
819 continue;
820 }
821
822 $real_type = isset( $mapped_object_types[ $config_item_type ] )
823 ? $mapped_object_types[ $config_item_type ]
824 : $config_item_type;
825
826 foreach ( $configs as $key => $config ) {
827 if ( 'pod' === $real_type ) {
828 foreach ( $config as $pod ) {
829 $pod['object_type'] = $real_type;
830 $pod['object_storage_type'] = 'file';
831
832 pods_register_type( $key, $pod['name'], $pod );
833 }
834 } else {
835 $config['object_storage_type'] = 'file';
836
837 pods_register_object( $config, $real_type );
838 }
839 }
840 }
841 }
842
843 /**
844 * @todo Get list of configs that do not match DB.
845 * @todo Handle syncing changed configs to DB.
846 * @todo Handle syncing configs from DB to file.
847 */
848
849 }
850