Git Product home page Git Product logo

poet's Introduction

Poet

Latest Stable Version Total Downloads Build Status

Poet provides simple configuration-based post type, taxonomy, editor color palette, block category, block pattern and block registration/modification.

Features

  • Dead simple post type and taxonomy registration, modification, and unregistering powered by Extended CPTs.
  • Easy editor color palette configuration including built-in support for webpack-palette-plugin.
  • Blocks registered are rendered using Laravel Blade on the frontend.
  • Block Patterns registered can have their content defined using Laravel Blade too.
  • Add additional block categories with nothing more than a slug.
  • Move parent admin menu items to the Tools submenu using their page slug.

Requirements

Installation

Install via Composer:

$ composer require log1x/poet

Getting Started

Start with publishing the Poet configuration file using Acorn:

$ wp acorn vendor:publish --provider="Log1x\Poet\PoetServiceProvider"

Usage

Registering a Post Type

All configuration related to Poet is located in config/poet.php. Here you will find an example Book post type pre-configured with a few common settings:

'post' => [
    'book' => [
        'enter_title_here' => 'Enter book title',
        'menu_icon' => 'dashicons-book-alt',
        'supports' => ['title', 'editor', 'author', 'revisions', 'thumbnail'],
        'show_in_rest' => true,
        'has_archive' => false,
        'labels' => [
            'singular' => 'Book',
            'plural' => 'Books',
        ],
    ],
],

In it's simplest form, a post type can be created by simply passing a string:

'post' => [
    'book',
],

To modify an existing post type, simply treat it as if you are creating a new post type passing only the configuration options you wish to change:

'post' => [
    'post' => [
        'labels' => [
            'singular' => 'Article',
            'plural' => 'Articles',
        ],
    ],
],

It is also possible to unregister an existing post type by simply passing false:

'post' => [
    'book' => false,
],

Please note that some built-in post types (e.g. Post) can not be conventionally unregistered.

For additional configuration options for post types, please see:

Note: Do not nest configuration in a config key like shown in the Extended CPTs documentation.

Registering a Taxonomy

Registering a taxonomy is similar to a post type. Looking in config/poet.php, you will see a Genre taxonomy accompanying the default Book post type:

'taxonomy' => [
    'genre' => [
        'links' => ['book'],
        'meta_box' => 'radio',
    ],
],

The most relevent configuration option is links which defines the post type the taxonomy is connected to. If no link is specified, it will default to post.

To view an archive for the Genre taxonomy, copy the Blade template called archive.blade.php to a new file called taxonomy-genre.blade.php.

In it's simplest form, you can simply pass a string. The example below would create a Topic taxonomy for the Post post type:

'taxonomy' => [
    'topic',
],

As with post types, to modify an existing taxonomy, simply pass only the configuration options you wish to change:

'taxonomy' => [
    'category' => [
        'labels' => [
            'singular' => 'Section',
            'plural' => 'Sections',
        ],
    ],
],

Also like post types, you can easily unregister an existing taxonomy by simply passing false:

'taxonomy' => [
    'post_tag' => false,
    'category' => false,
],

For additional configuration options for taxonomies, please see:

Note: Do not nest configuration in a config key like shown in the Extended CPTs documentation.

Registering a Block

Poet provides an easy way to register a Gutenberg block with the editor using an accompanying Blade view for rendering the block on the frontend.

Blocks are registered using the namespace/label defined when registering the block with the editor.

If no namespace is provided, the current theme's text domain will be used instead.

Registering a block in most cases is as simple as:

'block' => [
    'sage/accordion',
],

Creating a Block View

Given the block sage/accordion, your accompanying Blade view would be located at views/blocks/accordion.blade.php.

Block views have the following variables available:

  • $data – An object containing the block data.
  • $content – A string containing the InnerBlocks content. Returns null when empty.

By default, when checking if $content is empty, it is passed through a method to remove all tags and whitespace before evaluating. This assures that editor bloat like nbsp; or empty <p></p> tags do not cause $content to always return true when used in a conditional.

If you do not want this behavior on a particular block, simply register it as an array:

'block' => [
    'sage/accordion' => ['strip' => false],
],

If you need to register block attributes using PHP on a particular block, simply pass the attributes in an array when registering:

'block' => [
    'sage/accordion' => [
        'attributes' => [
            'title' => [
                'default' => 'Lorem ipsum',
                'type' => 'string',
            ],
        ],
    ],
],

Consider an accordion block that is registered with a title and className attribute. Your view might look something like this:

<div class="wp-block-accordion {{ $data->className ?? '' }}">
  @isset ($data->title)
    <h2>{!! $data->title !!}</h2>
  @endisset

  <div>
    {!! $content ?? 'Please feed me InnerBlocks.' !!}
  </div>
</div>

Registering a Block Category

Poet provides an easy to way register, modify, and unregister Gutenberg block categories. Looking in the config, you will see a commented out example for a Call to Action category:

'block_category' => [
    'cta' => [
        'title' => 'Call to Action',
        'icon' => 'star-filled',
    ],
],

This would result in a block category with a slug of cta. Once your block category is registered, you must register a block to its slug before the category will appear in the editor.

In it's simplest form, you can simply pass a string:

'block_category' => [
    'my-cool-blocks',
],

which would result in a my-cool-blocks category automatically converting the slug to title case.

You can also specify the title by passing a value to your slug:

'block_category' => [
    'my-cool-blocks' => 'Best Blocks, World.',
],

Like post types and taxonomies, modifying an existing block category is the same as registering one:

'block_category' => [
    'layouts' => 'Sections',
    'common' => ['icon' => 'star-filled'],
],

You can unregister an existing block category by simply passing false:

'block_category' => [
    'common' => false,
],

Registering a Block Pattern

Poet can also register Block Patterns for you, with an optional Blade view for the content.

Patterns are registered using the namespace/label defined when registering the pattern with the editor.

If no namespace is provided, the current theme's text domain will be used instead.

Registering a block in most cases is as simple as:

'block_pattern' => [
    'sage/hero' => [
        'title' => 'Page Hero',
        'description' => 'Draw attention to the main focus of the page, and highlight key CTAs',
        'categories' => ['all'],
    ],
],

You can register the actual content for the pattern here as well, using the content key. Or leave it blank to use a corresponding blade view.

'block_pattern' => [
    'sage/fake-paragraph' => [
        'title' => 'Fake Paragraph',
        'description' => 'Filler content used instead of actual content for testing purposes',
        'categories' => ['all'],
        'content' => '<!-- wp:paragraph --><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione nulla culpa repudiandae nisi nostrum et, labore earum repellendus porro, mollitia voluptas quam? Modi sint tempore deleniti nesciunt ab, perferendis et.</p><!-- /wp:paragraph -->',
    ],
],

Creating a Pattern View

Given the block sage/fake-paragraph, if no content key is defined, then your accompanying Blade view would be located at views/block-patterns/fake-paragraph.blade.php.

This Block Pattern view may look like this:

<!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione nulla culpa repudiandae nisi nostrum et, labore earum repellendus porro, mollitia voluptas quam? Modi sint tempore deleniti nesciunt ab, perferendis et.</p>
<!-- /wp:paragraph -->

Registering a Block Pattern Category

Block Pattern Categories can be added with the following code in the poet config:

'block_pattern_category' => [
    'all' => [
        'label' => 'All Patterns',
    ],
],

You can specify all category properties such as label, as per the block editor handbook.

Note: Currently, if no Block Pattern Categories are available at all, the Block Patterns tab in the editor will crash when clicked on.

Registering an Editor Color Palette

Poet attempts to simplify registering a color palette with the editor a bit by not requiring such strict, fragile array markup.

While you can of course pass said array directly, you are also able to register colors by simply passing a slug along with a color and letting Poet handle the rest.

'palette' => [
    'red' => '#ff0000',
    'blue' => '#0000ff',
],

Alternatively to passing an array, Poet also accepts a JSON file containing your color palette. Poet will generally look for this file in dist/ by default.

'palette' => 'colors.json',

If you are using the Palette Webpack Plugin, you may also simply pass true to automatically use the generated palette.json during build.

'palette' => true,

Bug Reports

If you discover a bug in Poet, please open an issue.

Contributing

Contributing whether it be through PRs, reporting an issue, or suggesting an idea is encouraged and appreciated.

License

Poet is provided under the MIT License.

poet's People

Contributors

alexdanylyschyn avatar broskees avatar dotsam avatar huubl avatar jamiewarb avatar kellymears avatar log1x avatar marcelo2605 avatar mike-sheppard avatar ouun avatar szepeviktor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poet's Issues

Changing labels post not working

Hi,

When I add the code below to the Poet config it causes the label to show up blank. Any idea why?

...
'post' => [
    'post' => [
        'labels' => [
            'singular' => 'Article',
            'plural' => 'Articles',
        ],
    ],
],
...

compatibility with acorn and sage 10 beta 3

I used acorn as a plugin, but I guess with bedrock same bug happens when doing vendor:publish; poet isn't found by acorn.

How should we proceed now that acorn is outside sage theme folder?

Unable to publish the config/poet.php

Hi, I have a similar question to #23

But the proposed solutions did not work for me.


wp acorn vendor:publish --provider="Log1x\Poet\PoetServiceProvider"
No publishable resources for tag [].
Publishing complete.

wp acorn vendor:publish 
 Which provider or tag's files would you like to publish?:
  [0] Publish files from all providers and tags listed below
  [1] Provider: Roots\Acorn\Providers\AcornServiceProvider
  [2] Tag: acorn
 > 

I tried publishing everything, and I also tried wp acorn vendor:publish --tag=acorn:init but the poet.php file is not created into the config folder. Am I missing something ?

MediaCloud Plugin overrides Illuminate collapse() function

Reaching out as I'm not sure how to solve this one. MediaCloud's (https://mediacloud.press/) uses similar Illuminate classes that define the collapse() method and it seems to be overriding Poet's use of collapse() directly from the Illuminate vendor. I've reached out to MediaPress to see if this is something they can resolve, but haven't heard back. I was curious if this is something that is a scoping issue or similar. I've actually never run into this before.

Of course, I'm happy to help resolve, test, etc., but this is a bit out of my comfort zone on where a solution might be. Appreciate your work and really want to give Poet a try!

Renaming default 'post' post_type

Hey @Log1x 👋🏻 not an urgent one, but wanted to drop a note in case anyone else is having/fixed this issue.

I haven't had a chance to dig in completely to figure out why, but since upgrading to WP 5.8 + latest poet (v2.0.4) renaming the default post_type throws this notice + the 'Articles' label disappears in the admin sidebar.

Screenshot 2021-09-06 at 17 58 38

E_NOTICE Trying to get property 'name_admin_bar' of non-object
File: site/web/wp/wp-includes/admin-bar.php
Line: 851 

Poet config

<?php
return [
    'post' => [
        'post' => [
            'labels' => [
                'singular' => 'Article',
                'plural'   => 'Articles',
            ],
        ],
    ],
];

^ removing this label override gets rid of the notice + Posts appears in the admin sidebar as you'd expect.

Cheers!

Manually publish

Not an issue. More of a question.

For the life of me I cannot get WP CLI to work with m Roots/Trellis/Sage 10x. Therefore I cannot, I get the below command to work.

$ wp acorn vendor:publish --provider="Log1x\Poet\PoetServiceProvider"

How would this command be pulled off manually? Could I simply copy and past the class into the Provider folder? Also in what config file would I add the poet.php file? The only config directory I see is in the Bedrock portion of the stack.

'anchors' functionality always runs

Due to an operator precedence order introduced in the last version, the 'anchors' functionality runs for all post types by default and cannot be disabled.

! $anchors = Arr::get($value, 'anchors') ||

This isn't a huge deal for a single post, but looping through a collection of posts, the larger the content is, the more time the parser takes up, slowing down some sites significantly.

I see that you have #16 open for v1.2.0, but wanted to get this issue in and a PR for the current version as it looks like 1.2.0 will have some breaking changes.

Blocks not showing up in WP editor

Hi Brandon,

I'm unable to get the blocks to work in the editor.
What I noticed is that the CPT books from the /config/poet.php does show up. These are the steps I took. Not that I did them both on my existing sage 10 project and a clean install of a sage 10 project. Both with the same result.

  • composer require log1x/poet
  • wp acorn vendor:publish --provider="Log1x\Poet\PoetServiceProvider" returned Unable to locate publishable resources. (this happens to all packages I try to install with vendor:publish)
  • So I manually copied /config/poet.php
  • CPT books shows up. Letting me think the config works.
  • Added a block like described in the readme So:
  • Added accordion with the attributes
  • added the example code to /resources/views/blocks/accordion.blade.php

With this I don's see the block in the editor.
I also changed the namespace and block name to check with more unique names.

Is there something I'm not doing right?

Check pattern content before return pattern blade view

Pattern content provided in the block pattern registration arguments are ignored. So this doesn' work:

'block_pattern' => [
    'sage/hero' => [
        'title' => 'Page Hero',
        'description' => 'Draw attention to the main focus of the page, and highlight key CTAs',
        'content' => '<!-- wp:paragraph --><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione nulla culpa repudiandae nisi nostrum et, labore earum repellendus porro, mollitia voluptas quam? Modi sint tempore deleniti nesciunt ab, perferendis et.</p><!-- /wp:paragraph -->',
        'categories' => ['all'],
    ],
],

$view = 'block-patterns.' . Str::after($key, '/');

Discourse ref

$content is empty when the only content is an img

Hi there,

First off, thanks for creating this module, it's hugely helpful in getting up and running with custom blocks in Sage!

I've written a custom carousel block which allows a custom carousel-slide block as its inner blocks. Each carousel-slide block can accepts a single core/image block.

The blade template shows $content as empty unless the image has a caption.

I had a quick look at poet/src/Modules/BlockModule.php - it seems isEmpty() returns true when an image alone is used.
The block markup saved in the db is as follows (with the attributes removed for easier reading):

<!-- wp:sage/carousel -->
<div class="wp-block-sage-carousel"><!-- wp:sage/carousel-slide -->
  <div><!-- wp:image -->
  <figure class="wp-block-image size-large"><img src="/app/uploads/2022/08/Image-Filename.jpeg" alt="" class="wp-image-259"/></figure>
  <!-- /wp:image --></div>
  <!-- /wp:sage/carousel-slide -->
  
  <!-- wp:sage/carousel-slide -->
  <div><!-- wp:image -->
  <figure class="wp-block-image size-large"><img src="/app/uploads/2022/08/Another-Image-Filename.jpg" alt="" class="wp-image-262"/></figure>
  <!-- /wp:image --></div>
  <!-- /wp:sage/carousel-slide --></div>
<!-- /wp:sage/carousel -->

Is there something different I need to do here?
I'm pretty new to Sage 10, Laravel, and block development so please excuse me if I'm missing something entirely!

Other labels change to English when extending post

I'm using Wordpress in Dutch. When changing the singular and plural labels of post the other labels (Add new etc.) change to the English defaults. I expected that only the specified label would change. Is it possible to only extend the given labels?

'post' => [
    'post' => [
        'labels' => [
            'singular' => 'Artikel',
            'plural' => 'Artikelen',
        ],
    ],
],

Unable to modify default 'category' taxonomy

Similar to the #36 issue, this also happening to WordPress default taxonomy.

ErrorException:
Attempt to read property "menu_name" on array
File: wp/wp-admin/menu.php
Line: 179

Poet:

'category' => [
    'links' => ['series', 'series-queue', 'chapter'], // This also doesn't work, unable to link CPT
    'meta_box' => 'radio',
    'labels' => [
        'singular' => 'Series',
        'plural' => 'Series',
    ],
],

Removing the default taxonomy is work fine, though.

Translating post type label and slug

Hi,
I have this code in my poet.php file:
'calendar' => [ 'enter_title_here' => 'Enter calendar month or year', 'menu_icon' => 'dashicons-calendar-alt', 'supports' => ['title', 'revisions', 'page-attributes'], 'show_in_rest' => true, 'hierarchical' => true, 'has_archive' => false, 'labels' => [ 'singular' => __('Calendar', 'sage'), 'plural' => __('Calendars', 'sage'), ], ],

I've generated a pot file, and translated it, but it doesn't seem to work: slug and labels remain in english even on my french website

taxonomies defined by poet aren't available to acf-composer

I am building a block with acf that depends on some terms defined in poet. But they aren't available.

I changed priority of init to 4 and it works, but I don't know if it's the correct approach.

        add_filter('init', function () {
            foreach ($this->modules as $module) {
                if ($module instanceof AbstractModule) {
                    continue;
                }

                new $module($this->app, $this->config);
            }
        }, 4);

Registered block not available in block library

Problem

When registering a block in config/poet.php it is not available in the block library.

Note: Registered post types, taxonomies, block patterns and block pattern categories work as expected.

Expected result

Based on the Registering a Block docs, I expect that uncommenting the default block example should result in an “Accordion” block being available in the block library.

I’m sure I’m missing an obvious step but if not, I wanted to provide my steps to reproduce.

Steps to reproduce

Environment

  • Wordpress >= 6.0.3
  • Sage = 10.3.1
  • Poet = 2.0.7
  • Node >= 16
  • Composer = 2
  • PHP >= 7.4

Setup

  1. Create a clean WordPress install
  2. Install Sage 10.3.1
  3. Install Poet
  4. Uncomment the block example in the config/poet.php file
  5. Add a new post and attempt to add the new accordion block

Note: I have also tested adding a accordion.blade.php file to resources/views/blocks/ and views/blocks/ directories.

Unable to publish the config/poet.php file

Hello,

I am trying this package in one task with Sage-10 & facing the issue with publishing it by the given command wp acorn vendor:publish --provider="Log1x\Poet\PoetServiceProvider".

Error: "Unable to locate publishable resources."

Can you please suggest any other way to publish it? or any help to fix it.

Thanks.

The custom block is not working

Hi,

Is there full detailed documentation? From the GitHub readme, it is unclear where I need to run that starter command or what the full preview of config/poet.php looks like.

I tried to set it up like this.

  1. Created a new file poet.php under config.
  2. Added this to the poet.php.
<?php
    return array(
	    'block'          => array(
		    'sage/callout',
	    ),
	    'block_category' => array(
		    'custom' => array(
			    'title' => 'Custom Blocks',
			    'icon'  => 'star-filled',
		    ),
	    ),
    );
  1. In the theme root folder, ran this command.
    wp acorn vendor:publish --provider="Log1x\Poet\PoetServiceProvider"

The log message says:

No publishable resources for tag [].
Publishing complete.

And I went to page editor, I am not seeing the new block expected.

Is there anything I am doing wrong?

Looking for help!

Thanks in advance!

Register fields with WP GraphQL

I am trying to register custom fields to the wp-graphql plugin with ACF. Per the documentation, fields can be registered in PHP by adding:
'show_in_graphql' => true, 'graphql_field_name' => 'myGroup',

I added these attributes to the admin_cols collection of the custom post type, and it doesn't seem to be recognized by wp-graphql. I'm not sure if this is an issue with poet, extended-cpts or wp-graphql, but any suggestions would be appreciated.

doesn't seem to work over localwp

when i use this:
wp acorn vendor:publish --provider="Log1x\Poet\PoetServiceProvider"

this is the result:
PHP Warning: Use of undefined constant WP_CONTENT_DIR - assumed 'WP_CONTENT_DIR' (this will throw an Error in a future version of PHP) in /mnt/c/Users/fran/Local Sites/hghill/app/public/wp-includes/load.php on
line 115

Error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Action hook localizing a cpt

Trying to localize the cpt, I was able to do it by using the following action:

add_action('after_setup_theme', function () {
    load_theme_textdomain('sage', get_template_directory() . '/resources/lang');
}, 4);

The problem is that if I use 5 and more in the priority, it doesn't get localized and I don't understand why, as it doesn't happen when using the extended-cpt on my own.
I was digging in the code to see in which action hook the cpt is registered, but I didn't understand the process with acorn.
So, how should we hook the textdomain? I think the answer should be present in the docs.

Thanks!

Feature Request: Block pattern support

Hey @Log1x , I've started to play with block patterns from WP5.5 a fair bit recently and found them pretty useful! I was wondering if you'd thought of adding a nice way to generate/register them with acf-composer?

My current sage10 implementation looks a bit like this:

# setup.php

add_action('init', function() {
    $block_patterns = [
        'article-intro' => [
            'title'       => 'Article intro columns',
            'description' => 'Article intro columns',
        ],
        'article-subheading-highlight' => [
            'title'       => 'Article subheading highlight',
            'description' => 'Article subheading highlight',
        ],
    ];

    foreach($block_patterns as $pattern_slug => $pattern_data) {
        $pattern_data['content'] = Roots\view("block-patterns.{$pattern_slug}")->toHtml();
        register_block_pattern("acf/{$pattern_slug}", $pattern_data);
    }
});
# views/block-patterns/article-intro.blade.php

<!-- wp:columns -->
<div class="wp-block-columns c-article-3-columns c-article-3-columns--intro">
  <!-- wp:column {"width":20} -->
  <div class="wp-block-column" style="flex-basis:20%">
    <!-- wp:acf/share-block {"id":"block_5f31616234a5d","name":"acf/share-block","data":{"field_share_block_layout":"aside","field_share_block_heading_color":"","field_share_block_color":"#e55eb0","field_share_block_background_color":"","field_share_block_section_id":""},"align":"full","mode":"preview"} /-->
  </div>
  <!-- /wp:column -->

  <!-- wp:column -->
  <div class="wp-block-column">
    <!-- wp:heading -->
    <h2>Section title</h2>
    <!-- /wp:heading -->

    <!-- wp:paragraph -->
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione nulla culpa repudiandae nisi nostrum et, labore earum repellendus porro, mollitia voluptas quam? Modi sint tempore deleniti nesciunt ab, perferendis et.</p>
    <!-- /wp:paragraph -->

    <!-- wp:paragraph -->
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione nulla culpa repudiandae nisi nostrum et, labore earum repellendus porro, mollitia voluptas quam? Modi sint tempore deleniti nesciunt ab, perferendis et.</p>
    <!-- /wp:paragraph -->
  </div>
   <!-- /wp:column -->

  <!-- wp:column {"width":20} -->
  <div class="wp-block-column" style="flex-basis:20%">
    <!-- wp:image {"id":479,"sizeSlug":"large"} -->
    <figure class="wp-block-image size-large">
        <img src="https://source.unsplash.com/random" alt="" class="wp-image-479"/>
    </figure>
    <!-- /wp:image -->
  </div>
  <!-- /wp:column -->
</div>
<!-- /wp:columns -->

Cheers!

Query CPT by Taxonomy

Hello,

Is there any documentation, best practices, or code examples for how to configure Poet so that custom post types can be queried by taxonomies?

My goal is to:

  • Register a CPT (say 'book')
  • Register taxonomies (say 'genre', 'language')
  • Query the CPT by a single taxonomy (say 'genre/horror')

I've been digging around to see how this should be done, however I have yet to find an answer so I thought I would open an issue and see if anyone can advise. In the meantime, I'll keep digging 😄

Gutenberg Block Category

Poet config is shipping this array index:

'block_categories' => [
        // 'cta' => [
        //     'title' => 'Call to Action',
        //     'icon' => 'star-filled',
        // ],
    ],

The documentation show instead:

'block_category' => [
    'cta' => [
        'title' => 'Call to Action',
        'icon' => 'star-filled',
    ],
],

It seems block_category is the right index.

WordPress 5.8 block_categories deprecated

Hi there,

upgrading to WordPress 5.8 we catch an exception.

ErrorException (E_USER_DEPRECATED)
block_categories è <strong>deprecata</strong> dalla versione 5.8.0! Al suo posto utilizza block_categories_all.

Error including functions in config file

I'm using Poet to register a custom post type, and assign a few columns to it. Based on the Poet and Extended CPT, i've put together the code below. It works, but does display an error when I run wp acorn optimize: Your configuration files are not serializable and Call to undefined method Closure::__set_state().

I’ve tried using a value function: value(function() { echo 'example thing to echo'; }) which stops the error but doesn’t display in the column and i’ve also tried including the function outside of the object, which again stopped the error but doesn’t display anything.

Do you have suggestions of how columns can be added with Poet without causing this error? Thanks! 🙂

...
'post' => [
        'our-work' => [
            'enter_title_here' => 'Enter Project Name',
            'menu_icon' => 'dashicons-media-document',
            'supports' => ['title', 'editor', 'revisions', 'excerpt', 'thumbnail'],
            'show_in_rest' => true,
            'has_archive' => false,
            'menu_position' => 7,
            'public' => true,
            'show_in_rest' => true,
            'labels' => [
                'singular' => 'Post',
                'plural' => 'Work',
            ],
            'rewrite' => [
                'slug' => 'our-work',
                'with_front' => false
            ],
            'admin_cols' => [
                'tagline' => [
                    'title'    => 'Tagline',
                    'function' => function () {
                        echo 'test';
                    },
                ],
                'featured_image' => [
                    'title'          => 'Feature Image',
                    'featured_image' => 'medium',
                    'height'         => 40,
                ],
                'post_excerpt' => [
                    'title'    => 'Excerpt',
                    'function' => function () {
                        echo 'test';
                    },
                ]
            ],
        ],
    ],
...

Sage as requirement?

Shouldn't this kind of functionality be rather done inside a site plugin than in the theme?
What if the theme has to be switched? Custom post types, taxonomies, and such would not work anymore.

Callback for custom fields in CPT

Hey ... is there a way to add a callback in Poet to define custom fields for a custom post type (CPT);
AND if possible, could you give me an example/guide on how to integrate the callback?
That would be wonderful.
Thank you very much!

... I see that it could apparently be quite feasible ...
public $register_meta_box_cb
/vendor/johnbillion/args/src/register_post_type.php

Query vars not working aside post_types archives pages

Hi guys, whats up?

I have a problem and i'll try to explain the best I can.

I have a post called article, i have created an archive for this post_type, its called on the route: 'https://siteurl.com/previous-editions'

This url lists the articles paginated by terms, so for example, i have an taxonomy with the slug 'edition', and this tax has its terms, all the terms have only posts with the post_type 'article'. Each page has 9 terms.

My main problem is in a functionality that I'm creating that the user searches for a specific term using the term slug(ex: edition-1). The way i thought to make this works was to add an form with one input that gets the term slug and submit it as a query params. So the url will be like this: 'https://siteurl.com/previous-editions/?edition=1'  and now instead of the query return all 9 terms related to the page it will only bring 1 term with the given slug, in this case, the term with edition-1.

But after the form submits, it throws an error and says that the page was not found, but it shouldn't happen because its the same page and the same url with only the query params as an extra.

So in the poet post configuration is there a way to allow using query params without throwing this error???

return [
    'post' => [
        'article' => [
              'enter_title_here' => 'Insert the article title',
              'can_export'          => true,
              'capability_type'     => 'post',
              'exclude_from_search' => false,
              'has_archive'         => 'previous-editions',
              'hierarchical'        => false,
              'menu_icon'           => 'dashicons-book',
              'public'              => true,
              'publicly_queryable'  => true,
              'query_var'           => true,
              'rewrite'             => [
                                          'slug'       => 'magazine/%edition%',
                                          'with_front' => true,
                                          'pages'      => true,
                                          'feeds'      => true,
                                       ],
              'show_in_menu'        => true,
              'show_in_nav_menus'   => false,
              'show_ui'             => true,
              'taxonomies'          => ['post_tag'],
              'supports'            => ['title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'revisions'],
           ],
  ],
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.