-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MOOSE-168]: Add misting post type register logic
- Loading branch information
1 parent
95915b2
commit bde205e
Showing
14 changed files
with
1,039 additions
and
789 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
90 changes: 0 additions & 90 deletions
90
wp-content/plugins/core/src/Object_Meta/Meta_Repository.php
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
wp-content/plugins/core/src/Post_Types/Meta_Box_Handlers/ACF.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Plugin\Post_Types\Meta_Box_Handlers; | ||
|
||
use Tribe\Plugin\Post_Types\Post_Type_Config; | ||
|
||
class ACF implements Meta_Box_Handler_Interface { | ||
|
||
/** | ||
* Registers the meta boxes for a post type. | ||
* | ||
* @param \Tribe\Plugin\Post_Types\Post_Type_Config $config | ||
*/ | ||
public function register_meta_boxes( Post_Type_Config $config ): void { | ||
if ( ! function_exists( 'acf_add_local_field_group' ) ) { | ||
return; | ||
} | ||
|
||
acf_add_local_field_group( $config->get_meta_boxes() ); | ||
} | ||
|
||
/** | ||
* Hooks the meta box handler class to the required filters/actions if needed. | ||
*/ | ||
public function hook(): void { | ||
add_filter( Meta_Box_Handler_Interface::INSTANCE_FILTER, function () { | ||
return $this; | ||
} ); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
wp-content/plugins/core/src/Post_Types/Meta_Box_Handlers/CMB2.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Plugin\Post_Types\Meta_Box_Handlers; | ||
|
||
use Tribe\Plugin\Post_Types\Post_Type_Config; | ||
|
||
class CMB2 implements Meta_Box_Handler_Interface { | ||
|
||
protected Post_Type_Config $config; | ||
|
||
/** | ||
* Registers the meta boxes for a post type. | ||
* | ||
* @param \Tribe\Plugin\Post_Types\Post_Type_Config $config | ||
*/ | ||
public function register_meta_boxes( Post_Type_Config $config ): void { | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* Hooks the meta box handler class to the required filters/actions if needed. | ||
*/ | ||
public function hook(): void { | ||
add_filter( Meta_Box_Handler_Interface::INSTANCE_FILTER, function () { | ||
return $this; | ||
} ); | ||
|
||
$config = $this->config; | ||
|
||
add_filter( 'cmb2_meta_boxes', static function ( $meta_boxes ) use ( $config ) { | ||
$post_type_meta_boxes = $config->get_meta_boxes(); | ||
$post_type_meta_boxes = apply_filters( "tribe_{$config->post_type()}_meta_boxes", $post_type_meta_boxes ); | ||
$meta_boxes = array_merge( $meta_boxes, $post_type_meta_boxes ); | ||
|
||
return $meta_boxes; | ||
} ); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
wp-content/plugins/core/src/Post_Types/Meta_Box_Handlers/Meta_Box_Handler_Interface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tribe\Plugin\Post_Types\Meta_Box_Handlers; | ||
|
||
use Tribe\Plugin\Post_Types\Post_Type_Config; | ||
|
||
interface Meta_Box_Handler_Interface { | ||
|
||
public const INSTANCE_FILTER = 'tribe_libs_meta_box_handler'; | ||
|
||
/** | ||
* Hooks the meta box handler class to the required filters/actions if needed. | ||
*/ | ||
public function hook(): void; | ||
|
||
/** | ||
* Registers the meta boxes for a post type. | ||
* | ||
* @param \Tribe\Plugin\Post_Types\Post_Type_Config $config | ||
*/ | ||
public function register_meta_boxes( Post_Type_Config $config ): void; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.