__( 'Article templates', 'karma-docs' ) ) ); /** * Filters the article templates (slug => title, description, content). * * @param array $templates Templates. */ $templates = (array) apply_filters( 'kdocs_article_templates', self::templates() ); foreach ( $templates as $slug => $template ) { register_block_pattern( 'karma-docs/' . $slug, array( 'title' => $template['title'], 'description' => $template['description'], 'content' => $template['content'], 'categories' => array( 'karma-docs-templates' ), 'blockTypes' => array( 'core/post-content' ), 'postTypes' => array( PostTypes::ARTICLE ), ) ); } } /** * Heading block. * * @param string $text Text. * @return string */ private static function h2( $text ) { return "\n
" . esc_html( $text ) . "
\n\n\n"; } /** * List block. * * @param string[] $items Items. * @param bool $ordered Ordered. * @return string */ private static function items( array $items, $ordered = false ) { $tag = $ordered ? 'ol' : 'ul'; $attrs = $ordered ? ' {"ordered":true}' : ''; $out = "\n<{$tag} class=\"wp-block-list\">"; foreach ( $items as $item ) { $out .= "\n| " . esc_html__( 'Name', 'karma-docs' ) . ' | ' . esc_html__( 'Type', 'karma-docs' ) . ' | ' . esc_html__( 'Default', 'karma-docs' ) . ' | ' . esc_html__( 'Description', 'karma-docs' ) . " |
|---|---|---|---|
\n\n\n",
),
'release-notes' => array(
'title' => __( 'Release notes', 'karma-docs' ),
'description' => __( 'What changed in a release.', 'karma-docs' ),
'content' => self::p( __( 'Release date and a one-line summary.', 'karma-docs' ) )
. self::h2( __( 'New', 'karma-docs' ) )
. self::items( array( '…' ) )
. self::h2( __( 'Improved', 'karma-docs' ) )
. self::items( array( '…' ) )
. self::h2( __( 'Fixed', 'karma-docs' ) )
. self::items( array( '…' ) )
. self::callout( 'warning', __( 'Breaking changes and what to do about them.', 'karma-docs' ) ),
),
);
}
}