Aventyret / solarplexus

Wordpress Block that is useful when building news sites
GNU General Public License v2.0
6 stars 1 forks source link

PHP-config for splx-blocks #15

Closed markusfinell closed 1 year ago

markusfinell commented 2 years ago

Enable a php-based config setup. This will support dynamic values like including any post type, and translatable strings.

add_filter( 'splx_config', 'my_splx_config' );

function my_splx_config( $config ) {
  $allowed_post_types = get_post_type_slugs(); // some function to get post type slugs

  $config[] = [
    'id' => 'my-example-dynamic',
    'title' => __( 'My dynamic posts or pages example', 'splx' ),
    'type' => 'dynamic',
    'icon' => 'smiley',
    'allowed_post_types' => $allowed_post_types,
    'allowed_taxonomies' => [ 'category' ],
    'number_of_posts' => [ 2, 8 ],
  ];

  return $config;
}
perarnborg commented 2 years ago

Make sure to add this to docs (this is what is left to do on this card)

perarnborg commented 1 year ago

Note that the implementation of this is sligtly changes since #27

perarnborg commented 1 year ago

This was done in https://github.com/Aventyret/solarplexus/commit/0596385744e8ef6c6a806f6e3a96d804630c949e