From a826572e28ca0ed56fdf7fffbd56cd3a3dd0b732 Mon Sep 17 00:00:00 2001 From: Brede Basualdo Date: Thu, 20 Mar 2025 15:20:45 -0300 Subject: [PATCH 1/3] Add extra code to Custom Post Type to allow to be viewed and used in Admin Panel. Add info for support WP fields with the CPT. --- .../ServicesProvider/custom-post-types.mdx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pages/docs/ServicesProvider/custom-post-types.mdx b/pages/docs/ServicesProvider/custom-post-types.mdx index d88dee5..0852c6b 100644 --- a/pages/docs/ServicesProvider/custom-post-types.mdx +++ b/pages/docs/ServicesProvider/custom-post-types.mdx @@ -55,6 +55,31 @@ class MyCustomPostType extends WordPressCustomPostTypeServiceProvider { */ protected $plural = 'Starships'; + /** + * Whether to include the post type in the REST API. + * Set this to true for the post type to be available in the block editor. + * + * @var bool + */ + protected $showInRest = true; + + /** + * Whether to generate a default UI for managing this post type in the admin. + * If not set, the default is inherited from public. + * + * @var bool + */ + protected $showUI = true; + + /** + * An alias for calling add_post_type_support() directly. Defaults to title and editor. + * See {@link add_post_type_support()} for documentation. + * + * @var array + */ + protected $supports = ['title', 'editor', 'thumbnail', 'excerpt']; // etc.. + + /** * You may override this method in order to register your own actions and filters. * From 5ab7cb7f3d351895fc3887086801e892b8198add Mon Sep 17 00:00:00 2001 From: Brede Basualdo Date: Mon, 24 Mar 2025 20:49:22 -0300 Subject: [PATCH 2/3] add documentation support for Columns on Custom Taxonomy --- .../custom-taxonomy-types.mdx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pages/docs/ServicesProvider/custom-taxonomy-types.mdx b/pages/docs/ServicesProvider/custom-taxonomy-types.mdx index 832f417..17c4848 100644 --- a/pages/docs/ServicesProvider/custom-taxonomy-types.mdx +++ b/pages/docs/ServicesProvider/custom-taxonomy-types.mdx @@ -56,3 +56,27 @@ Add this new Service Provider to the list of providers in the `/config/plugin.ph 'custom_taxonomy_types' => [ '\WPKirk\CustomTaxonomyTypes\MyCustomTaxonomy' ], ``` + +## Columns +You may add columns to your Custom Taxonomy Type by adding the following code to your Service Provider: +```php filename="plugin/CustomTaxonomyTypes/MyCustomTaxonomy.php" copy +public function registerColumns() +{ + return [ + 'my_new_column_name' => 'Column Name', + ]; +} +``` + +and also set the Column Content (where you can process the output), is *mandatory* to use `return` and not an `echo` statement + +```php filename="plugin/CustomTaxonomyTypes/MyCustomTaxonomy.php" copy +public function columnContent($string, $column_name, $term_id) + { + if ($column_name === 'my_new_column_name') { + //... your logic here + return 'your_new_content_here'; + } + return $string; + } +``` \ No newline at end of file From 648a2ffb196dda84e92e5edeff9a0c397083bd71 Mon Sep 17 00:00:00 2001 From: Brede Basualdo Date: Tue, 1 Apr 2025 13:49:18 -0300 Subject: [PATCH 3/3] small typo fix for the example of seeding. without the semi-colon the code produces an error. --- pages/docs/DatabaseORM/seeding.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/docs/DatabaseORM/seeding.mdx b/pages/docs/DatabaseORM/seeding.mdx index 9ba5499..f9b2dd8 100644 --- a/pages/docs/DatabaseORM/seeding.mdx +++ b/pages/docs/DatabaseORM/seeding.mdx @@ -86,7 +86,7 @@ return new class extends Seeder { VALUES (1,'','Mauritania','MR','Mauritanian Ouguiya','','','MRO',0.00,'africa','publish')"); } -} +}; ``` ## WordPress prefix @@ -130,7 +130,7 @@ return new class extends Seeder { VALUES (1,'','Mauritania','MR','Mauritanian Ouguiya','','','MRO',0.00,'africa','publish')"); } -} +}; ``` In this case the table name will be `my_plugin_products`. @@ -169,7 +169,7 @@ return new class extends Seeder { ] ); } -} +}; ``` ### Remove the WordPress prefix @@ -208,7 +208,7 @@ return new class extends Seeder { ] ); } -} +}; ``` In the Model class, you have to set to false the second parameter of the `DB::getTableName` method.