diff --git a/src/Arc/Console/stubs/controller.plain.stub b/src/Arc/Console/stubs/controller.plain.stub index 549f61f..86213dc 100644 --- a/src/Arc/Console/stubs/controller.plain.stub +++ b/src/Arc/Console/stubs/controller.plain.stub @@ -2,10 +2,13 @@ namespace DummyNamespace; +use Arc\Http\ValidatesRequests; use Illuminate\Http\Request; use DummyRootNamespace\Http\Controllers\Controller; class DummyClass extends Controller { + use ValidatesRequests; + // } diff --git a/src/Arc/CustomPostTypes/CustomPostTypeServiceProvider.php b/src/Arc/CustomPostTypes/CustomPostTypeServiceProvider.php new file mode 100644 index 0000000..a50134a --- /dev/null +++ b/src/Arc/CustomPostTypes/CustomPostTypeServiceProvider.php @@ -0,0 +1,29 @@ +app->make('wordpress.custom_post_types'); + $registrar->registerAll(); + } + + public function bootWithoutWordpress() + { + // No op + } + + public function register() + { + // Bind the custom post types handler + $this->app->instance( + 'wordpress.custom_post_types', + $this->app->make(CustomPostTypes::class) + ); + } +} diff --git a/src/Arc/CustomPostTypes/CustomPostTypes.php b/src/Arc/CustomPostTypes/CustomPostTypes.php index f6756c7..14d09a8 100644 --- a/src/Arc/CustomPostTypes/CustomPostTypes.php +++ b/src/Arc/CustomPostTypes/CustomPostTypes.php @@ -103,5 +103,40 @@ public function register(CustomPostType $customPostType) return $original; }); } + + if (method_exists($customPostType, 'adminColumnHeaders')) { + $this->registerAdminColumnHeaders($customPostType); + } + + if (method_exists($customPostType, 'adminColumnCells')) { + $this->registerAdminColumnCells($customPostType); + } + } + + public function registerAdminColumnHeaders($customPostType) + { + // Set values for admin columns + add_filter( + 'manage_edit-'.$customPostType->getSlug().'_columns', + function ($columns) use ($customPostType) { + $headers = []; + + foreach ($customPostType->adminColumnHeaders($columns) as $key => $value) { + $headers[$key] = __($value); + } + + return $headers; + } + ); + } + + public function registerAdminColumnCells($customPostType) + { + add_action( + 'manage_'.$customPostType->getSlug().'_posts_custom_column', + function ($column, $postId) use ($customPostType) { + echo $customPostType->adminColumnCells($column, $customPostType->find($postId)); + }, 10, 2 + ); } }