Skip to content

Commit a287730

Browse files
committed
Blockify everything, prefering HTML+blocks rather than patterns.
1 parent 26128cb commit a287730

File tree

25 files changed

+2046
-210
lines changed

25 files changed

+2046
-210
lines changed

wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/client/components/_plugin-card.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.plugin-card {
22
background-color: #f9f9f9;
33
margin-bottom: 4%;
4+
margin-block-start: 0;
45
padding: 15px 15px 8px;
56
vertical-align: top;
67

wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515

1616
// Block Files
17-
require_once( __DIR__ . '/src/blocks/archive-page/index.php' );
1817
require_once( __DIR__ . '/src/blocks/filter-bar/index.php' );
1918
require_once( __DIR__ . '/src/blocks/front-page/index.php' );
20-
require_once( __DIR__ . '/src/blocks/search-page/index.php' );
2119
require_once( __DIR__ . '/src/blocks/single-plugin/index.php' );
20+
require_once( __DIR__ . '/src/blocks/plugin-card/index.php' );
21+
require_once( __DIR__ . '/src/blocks/missing-template-tag/index.php' );
2222

2323
// Block Configs
2424
require_once( __DIR__ . '/inc/block-config.php' );
@@ -425,6 +425,7 @@ function strong_archive_title( $term ) {
425425
return '<strong>' . $term . '</strong>';
426426
}
427427
add_action( 'wp_head', function() {
428+
// TODO: This no longer fires, as it's rendered before `wp_head` when using blocks.
428429
add_filter( 'post_type_archive_title', __NAMESPACE__ . '\strong_archive_title' );
429430
add_filter( 'single_term_title', __NAMESPACE__ . '\strong_archive_title' );
430431
add_filter( 'single_cat_title', __NAMESPACE__ . '\strong_archive_title' );
Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +0,0 @@
1-
<?php
2-
/**
3-
* The main template file.
4-
*
5-
* This is the most generic template file in a WordPress theme
6-
* and one of the two required files for a theme (the other being style.css).
7-
* It is used to display a page when nothing more specific matches a query.
8-
* E.g., it puts together the home page when no home.php file exists.
9-
*
10-
* @link https://codex.wordpress.org/Template_Hierarchy
11-
*
12-
* @package WordPressdotorg\Plugin_Directory\Theme
13-
*/
14-
15-
namespace WordPressdotorg\Plugin_Directory\Theme;
16-
17-
get_header();
18-
?>
19-
20-
<main id="main" class="site-main" role="main">
21-
22-
<?php
23-
if ( have_posts() ) :
24-
if ( is_home() && ! is_front_page() ) :
25-
?>
26-
<header>
27-
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
28-
</header>
29-
<?php
30-
endif;
31-
32-
/* Start the Loop */
33-
while ( have_posts() ) :
34-
the_post();
35-
36-
get_template_part( 'template-parts/plugin', 'index' );
37-
endwhile;
38-
39-
the_posts_pagination();
40-
41-
else :
42-
get_template_part( 'template-parts/no-results' );
43-
endif;
44-
?>
45-
46-
</main><!-- #main -->
47-
48-
<?php
49-
get_footer();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 2,
4+
"name": "wporg/missing-template-tag",
5+
"version": "0.1.0",
6+
"title": "Missing Template Tag",
7+
"category": "design",
8+
"icon": "",
9+
"description": "A block that executes a missing template tag.",
10+
"textdomain": "wporg",
11+
"attributes": {
12+
"function": {
13+
"type": "string",
14+
"enum": [
15+
"the_posts_pagination",
16+
"the_archive_description"
17+
]
18+
},
19+
"args": {
20+
"type": "array"
21+
}
22+
},
23+
"supports": {
24+
"html": false
25+
},
26+
"editorScript": "file:./index.js",
27+
"render": "file:./render.php"
28+
}

wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/src/blocks/search-page/index.php renamed to wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/js/build/blocks/missing-template-tag/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @package wporg
77
*/
88

9-
namespace WordPressdotorg\Theme\Plugins_2024\SearchPage;
9+
namespace WordPressdotorg\Theme\Plugins_2024\MissingTemplateTag;
1010

1111
add_action( 'init', __NAMESPACE__ . '\init' );
1212

@@ -18,5 +18,5 @@
1818
* @see https://developer.wordpress.org/reference/functions/register_block_type/
1919
*/
2020
function init() {
21-
register_block_type( __DIR__ . '/../../../js/build/blocks/search-page' );
21+
register_block_type( __DIR__ . '/../../../js/build/blocks/missing-template-tag' );
2222
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$function = $attributes['function'] ?? false;
4+
$args = $attributes['args'] ?? [];
5+
$valid_functions = [
6+
'the_posts_pagination',
7+
'the_archive_description'
8+
];
9+
10+
// Validated by block.json enum, but duplicated here.
11+
if ( $function && in_array( $function, $valid_functions ) && function_exists( $function ) ) {
12+
call_user_func_array( $function, $args );
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 2,
4+
"name": "wporg/plugin-card",
5+
"version": "0.1.0",
6+
"title": "Single Plugin Card",
7+
"category": "design",
8+
"icon": "",
9+
"description": "A block that displays the single plugin card",
10+
"textdomain": "wporg",
11+
"attributes": {},
12+
"supports": {
13+
"html": false
14+
},
15+
"usesContext": [
16+
"postId"
17+
],
18+
"editorScript": "file:./index.js",
19+
"render": "file:./render.php"
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Block Name: Single Plugin
4+
* Description: The content that is displayed on the single plugin page
5+
*
6+
* @package wporg
7+
*/
8+
9+
namespace WordPressdotorg\Theme\Plugins_2024\PluginCard;
10+
11+
add_action( 'init', __NAMESPACE__ . '\init' );
12+
13+
/**
14+
* Registers the block using the metadata loaded from the `block.json` file.
15+
* Behind the scenes, it registers also all assets so they can be enqueued
16+
* through the block editor in the corresponding context.
17+
*
18+
* @see https://developer.wordpress.org/reference/functions/register_block_type/
19+
*/
20+
function init() {
21+
register_block_type( __DIR__ . '/../../../js/build/blocks/plugin-card' );
22+
}
23+
24+
// TODO: Figure out how to add a post_class for wrapping a block...
25+
add_filter( 'render_block_core/post-template', function( $html, $block ) {
26+
// If the post-template has the 'plugin-cards' class, add the 'plugin-card' class to the child blocks
27+
if ( ! empty( $block['attrs']['className'] ) && str_contains( $block['attrs']['className'], 'plugin-cards' ) ) {
28+
$html = str_replace( 'class="wp-block-post ', 'class="wp-block-post plugin-card ', $html );
29+
}
30+
31+
return $html;
32+
}, 10, 2 );
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
get_template_part( 'template-parts/plugin' );
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-element'), 'version' => '43ab82ac4ef93561f4cc');
1+
<?php return array('dependencies' => array('react', 'wp-element'), 'version' => '4967f0d80ed01cf03524');

0 commit comments

Comments
 (0)