Skip to content

Commit

Permalink
Add the front page content
Browse files Browse the repository at this point in the history
See #2
  • Loading branch information
adamwoodnz committed Oct 3, 2024
1 parent 64d5ba3 commit 475837a
Show file tree
Hide file tree
Showing 6 changed files with 314 additions and 21 deletions.
30 changes: 29 additions & 1 deletion source/wp-content/themes/wporg-make-2024/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace WordPressdotorg\Theme\Make_2024;

/**
* Blocks.
*/
require_once __DIR__ . '/inc/block-hooks.php';

/**
* Actions and filters.
*/
Expand All @@ -11,6 +16,7 @@

add_filter( 'document_title_parts', __NAMESPACE__ . '\make_add_frontpage_name_to_title' );
add_filter( 'post_class', __NAMESPACE__ . '\make_home_site_classes', 10, 3 );
add_filter( 'post_type_link', __NAMESPACE__ . '\replace_make_site_permalink', 10, 2 );
add_filter( 'the_posts', __NAMESPACE__ . '\make_handle_non_post_routes', 10, 2 );
add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\add_site_navigation_menus' );
add_filter( 'wporg_noindex_request', __NAMESPACE__ . '\make_noindex' );
Expand All @@ -27,7 +33,7 @@ function make_enqueue_scripts() {
wp_enqueue_style(
'wporg-make-2024-style',
$style_uri,
array( 'wporg-parent-2021-style', 'wporg-global-fonts' ),
array( 'wporg-parent-2021-style', 'wporg-global-fonts', 'dashicons' ),
filemtime( $style_path )
);
wp_style_add_data( 'wporg-make-2024-style', 'path', $style_path );
Expand Down Expand Up @@ -173,3 +179,25 @@ function make_noindex( $noindex ) {

return $noindex;
}

/**
* Filters to replace '/make_site/' permalinks with the corresponding Make site URL.
*
* @param string $permalink The post's permalink.
* @param WP_Post $post The post object.
* @return string The filtered permalink.
*/
function replace_make_site_permalink( $permalink, $post ) {
if ( false !== strpos( $permalink, 'make_site' ) ) {
$makesites = make_site_get_network_sites();

$make_site_id = get_post_meta( $post->ID, 'make_site_id', true );
$url = $makesites[ $make_site_id ];

if ( $url ) {
$permalink = $url;
}
}

return $permalink;
}
51 changes: 51 additions & 0 deletions source/wp-content/themes/wporg-make-2024/inc/block-hooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Blocks hooks.
*/

namespace WordPressdotorg\Theme\Make_2024\Block_Hooks;

add_filter( 'render_block_core/query', __NAMESPACE__ . '\render_team_grid_block_query', 10, 2 );

/**
* Modifies the block content for team grid blocks, inserting a placeholder item to ensure the grid is complete.
*
* @param string $block_content The block content.
* @param array $block The block settings and attributes.
* @return string Modified block content.
*/
function render_team_grid_block_query( $block_content, $block ) {
if ( isset( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'wporg-make-team-grid' ) !== false ) {
$tags = wp_html_split( $block_content );
$count = 0;
$ul_close_index = -1;

foreach ( $tags as $index => $tag ) {
if ( false !== strpos( $tag, 'class="' ) && false !== strpos( $tag, 'make_site' ) ) {
$count++;
}
if ( 0 === strpos( $tag, '</ul>' ) ) {
$ul_close_index = $index;
break;
}
}

if ( -1 !== $ul_close_index ) {
$placeholder_class = 'make_site make_site-placeholder has-border-color has-light-grey-1-border-color';
// Calculate the number of empty slots
$remainder = ( 3 - ( $count % 3 ) ) % 3;
// We'll stretch the placeholder to span 2 columns if there are 2 empty slots.
if ( 2 === $remainder ) {
$placeholder_class .= ' make_site-placeholder-span-2';
}
$placeholder = '<li class="' . esc_attr( $placeholder_class ) . '" style="border-width:1px;"></li>';

// Insert the single placeholder item just before the closing </ul> tag.
array_splice( $tags, $ul_close_index, 0, $placeholder );

$block_content = implode( '', $tags );
}
}

return $block_content;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,55 @@

?>

<!-- wp:group {"style":{"spacing":{"margin":{"bottom":"var:preset|spacing|50"}}},"layout":{"type":"constrained","justifyContent":"left","contentSize":"750px"}} -->
<div class="wp-block-group" style="margin-bottom:var(--wp--preset--spacing--50)">
<!-- wp:group {"style":{"spacing":{"margin":{"bottom":"var:preset|spacing|30"}}},"layout":{"type":"constrained","justifyContent":"left","contentSize":"774px"}} -->
<div class="wp-block-group" style="margin-bottom:var(--wp--preset--spacing--30)">

<!-- wp:paragraph -->
<p><?php esc_html_e( 'Whether you’re a budding developer, a designer, or just like helping out, we’re always looking for people to help make WordPress even better.', 'make-wporg' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"style":{"spacing":{"margin":{"top":"0","bottom":"var:preset|spacing|10"}}}} -->
<h2 class="wp-block-heading" style="margin-top:0;margin-bottom:var(--wp--preset--spacing--10)"><?php esc_html_e( 'Teams', 'make-wporg' ); ?></h2>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2 class="wp-block-heading"><?php esc_html_e( 'Teams', 'make-wporg' ); ?></h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><?php esc_html_e( 'If you want to get involved in WordPress, this is the place to start. We’ve got blogs for each contributor group, general news, and upcoming events.', 'make-wporg' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:wporg/notice {"type":"info"} -->
<div class="wp-block-wporg-notice is-info-notice">
<div class="wp-block-wporg-notice__icon"></div>
<div class="wp-block-wporg-notice__content">
<p>
<?php echo wp_kses_post(
sprintf(
/* translators: 1: Contributor wizard link */
__( 'Not sure which contributor teams match your interests and abilities? Check out our <a href="%s">contributor wizard</a>.', 'make-wporg' ),
'https://make.wordpress.org/contribute/',
)
); ?>
</p>
</div>
</div>
<!-- /wp:wporg/notice -->

</div>
<!-- /wp:group -->

<!-- wp:query {"queryId":0,"query":{"perPage":1000,"postType":"make_site"},"align":"wide","className":"wporg-learn-site-grid"} -->
<div class="wp-block-query alignwide wporg-make-site-grid">
<!-- wp:query {"queryId":0,"query":{"perPage":100,"postType":"make_site","order":"asc","orderBy":"date"},"align":"wide","className":"wporg-make-team-grid"} -->
<div class="wp-block-query alignwide wporg-make-team-grid">

<!-- wp:post-template {"style":{"spacing":{"blockGap":"0"}},"layout":{"type":"grid","columnCount":3}} -->

<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20","left":"var:preset|spacing|20","right":"var:preset|spacing|20"}},"border":{"width":"1px"},"dimensions":{"minHeight":"100%"}},"borderColor":"light-grey-1","layout":{"type":"flex","orientation":"vertical","justifyContent":"stretch"}} -->
<div class="wp-block-group has-border-color has-light-grey-1-border-color" style="border-width:1px;min-height:100%;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)">

<!-- wp:post-title {"isLink":true,"style":{"spacing":{"margin":{"top":"0","bottom":"0"}},"elements":{"link":{"color":{"text":"var:preset|color|charcoal-1"}}}}} /-->

<!-- wp:post-template {"style":{"spacing":{"blockGap":"var:preset|spacing|50"}},"layout":{"type":"grid","columnCount":null,"minimumColumnWidth":"330px"}} -->
<!-- wp:post-content {"style":{"typography":{"lineHeight":"1.7"}},"fontSize":"small"} /-->

<!-- wp:post-title {"isLink":true} /-->
</div>
<!-- /wp:group -->

<!-- /wp:post-template -->

Expand Down
192 changes: 192 additions & 0 deletions source/wp-content/themes/wporg-make-2024/src/style/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,195 @@
* Note: only add styles here in cases where you can't achieve the style with
* templates or theme.json settings.
*/

.wporg-make-team-grid {
%blue-circle {
display: block;
content: "";
width: 32px;
height: 32px;
border: 1px solid var(--wp--preset--color--blueberry-1);
border-radius: 50%;
}

.make_site-placeholder {
display: none;
}

@media (min-width: 601px) {
.make_site-placeholder {
display: initial;
}

.make_site-placeholder-span-2 {
grid-column: 2 / 4;
}
}

.make_site {
margin: -0.5px;

&:hover:not(.make_site-placeholder) {
background-color: var(--wp--preset--color--light-grey-2);
}

.wp-block-post-title {
a {
display: flex;
justify-content: space-between;
align-items: center;

&::after {

@extend %blue-circle;

display: block;
/* stylelint-disable-next-line font-family-no-missing-generic-family-keyword */
font-family: dashicons;
content: "\f109";
font-weight: 400;
font-size: 20px;
line-height: 32px;
text-align: center;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: var(--wp--preset--color--blueberry-1);
}

&:hover {
text-decoration: none;
}
}
}

&.make-core .wp-block-post-title a::after {
content: "\f475";
}

&.make-mobile .wp-block-post-title a::after {
content: "\f470";
}

&.make-design .wp-block-post-title a::after {
content: "\f309";
}

&.make-accessibility .wp-block-post-title a::after {
content: "\f483";
}

&.make-polyglots .wp-block-post-title a::after {
content: "\f326";
}

&.make-support .wp-block-post-title a::after {
content: "\f125";
}

&.make-themes .wp-block-post-title a::after {
content: "\f100";
}

&.make-plugins .wp-block-post-title a::after {
content: "\f106";
}

&.make-docs .wp-block-post-title a::after {
content: "\f105";
}

&.make-community .wp-block-post-title a::after {
content: "\f307";
}

&.make-meta .wp-block-post-title a::after {
content: "\f325";
}

&.make-training .wp-block-post-title a::after {
content: "\f118";
}

&.make-flow .wp-block-post-title a::after {
content: "\f115";
}

&.make-tv .wp-block-post-title a::after {
content: "\f235";
}

&.make-marketing .wp-block-post-title a::after {
content: "\f130";
}

&.make-media-corps .wp-block-post-title a::after {
content: "\f130";
}

&.make-cli .wp-block-post-title a::after {
content: "\f345";
}

&.make-hosting .wp-block-post-title a::after {
content: "\f176";
}

&.make-tide .wp-block-post-title a::after {
content: "\f10d";
}

&.make-photos .wp-block-post-title a::after {
content: "\f306";
}

&.make-sustainability .wp-block-post-title a::after {
content: "\f11f";
}

&.make-openverse .wp-block-post-title,
&.make-performance .wp-block-post-title {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr;

&::after {

@extend %blue-circle;
grid-column: 1 / 2;
grid-row: 1 / 2;
justify-self: end;
align-self: center;
}

a {
grid-column: 1 / 2;
grid-row: 1 / 2;

&::after {
font-family: inherit;
content: ".";
text-indent: -999px;
width: 20px;
height: 20px;
mask-repeat: no-repeat;
mask-position: bottom;
mask-size: 20px;
display: inline-block;
background-color: currentColor;
vertical-align: top;
margin-right: 6px;
}
}
}

&.make-openverse .wp-block-post-title a::after {
/* stylelint-disable-next-line function-url-quotes */
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M14.2044 9.30232C15.8203 9.30232 17.1303 7.98102 17.1303 6.35112C17.1303 4.72132 15.8203 3.40002 14.2044 3.40002C12.5885 3.40002 11.2785 4.72132 11.2785 6.35112C11.2785 7.98102 12.5885 9.30232 14.2044 9.30232ZM2.79999 6.35112C2.79999 7.97512 4.09939 9.30232 5.70739 9.30232V3.40002C4.09939 3.40002 2.79999 4.71902 2.79999 6.35112ZM7.03919 6.35112C7.03919 7.97512 8.33859 9.30232 9.94659 9.30232V3.40002C8.34679 3.40002 7.03919 4.71902 7.03919 6.35112ZM14.2044 16.5975C15.8203 16.5975 17.1303 15.2762 17.1303 13.6463C17.1303 12.0165 15.8203 10.6952 14.2044 10.6952C12.5885 10.6952 11.2785 12.0165 11.2785 13.6463C11.2785 15.2762 12.5885 16.5975 14.2044 16.5975ZM7.03919 13.6414C7.03919 15.2671 8.33859 16.5958 9.94659 16.5958V10.6952C8.34669 10.6952 7.03919 12.0156 7.03919 13.6414ZM2.79999 13.6414C2.79999 15.2754 4.09939 16.5958 5.70739 16.5958V10.6952C4.09939 10.6952 2.79999 12.0156 2.79999 13.6414Z' fill='%233858E9'/%3E%3C/svg%3E");
}

&.make-performance .wp-block-post-title a::after {
/* stylelint-disable-next-line function-url-quotes */
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M8.34251 4.43616H5.85528C5.56166 4.43616 5.32336 4.67446 5.32336 4.96807V7.45531C5.32336 7.74892 5.56166 7.98722 5.85528 7.98722H8.34251C8.63613 7.98722 8.87443 7.74892 8.87443 7.45531V4.96807C8.87443 4.67446 8.63613 4.43616 8.34251 4.43616Z' fill='%233858E9'/%3E%3Cpath d='M8.87443 12.5447V15.0319C8.87443 15.1723 8.81911 15.3085 8.71911 15.4085C8.61911 15.5085 8.48294 15.5638 8.34251 15.5638H5.85528C5.71485 15.5638 5.57868 15.5085 5.47868 15.4085C5.37868 15.3085 5.32336 15.1723 5.32336 15.0319V10.4851C5.32336 10.4 5.34464 10.317 5.38294 10.2425C5.38932 10.2298 5.39783 10.217 5.40422 10.2042C5.4489 10.134 5.50847 10.0745 5.58081 10.0298L8.06379 8.5319C8.15741 8.47445 8.26592 8.44892 8.37656 8.4553C8.48507 8.46169 8.58932 8.50424 8.67443 8.57232C8.72975 8.61701 8.77443 8.6702 8.80847 8.7319C8.84251 8.7936 8.86379 8.86169 8.87017 8.9319C8.87443 8.9553 8.87443 8.97871 8.87443 9.00424V10.1489C8.87443 10.1489 8.87443 10.1638 8.87443 10.1723V12.5298C8.87443 12.5298 8.87443 12.5383 8.87443 12.5447Z' fill='%233858E9'/%3E%3Cpath d='M14.6766 6.4319V10.0149C14.6766 10.0851 14.6638 10.1532 14.6362 10.2191C14.6085 10.283 14.5702 10.3425 14.5213 10.3915L13.0575 11.8553C13.0085 11.9042 12.9489 11.9447 12.8851 11.9702C12.8213 11.9979 12.7511 12.0106 12.6809 12.0106H9.88299C9.74256 12.0106 9.60639 11.9553 9.50639 11.8553C9.40639 11.7553 9.35107 11.6191 9.35107 11.4787V8.99148C9.35107 8.85105 9.40639 8.71488 9.50639 8.61488C9.60639 8.51488 9.74256 8.45956 9.88299 8.45956H12.666C12.666 8.45956 12.9021 8.45956 12.9021 8.22339C12.9021 7.98722 12.666 7.98722 12.666 7.98722H9.88299C9.74256 7.98722 9.60639 7.9319 9.50639 7.8319C9.40639 7.7319 9.35107 7.59573 9.35107 7.45531V4.96807C9.35107 4.82765 9.40639 4.69148 9.50639 4.59148C9.60639 4.49148 9.74256 4.43616 9.88299 4.43616H12.6809C12.7511 4.43616 12.8192 4.44892 12.8851 4.47658C12.9489 4.50424 13.0085 4.54254 13.0575 4.59148L14.5213 6.05531C14.5702 6.10424 14.6106 6.16382 14.6362 6.22765C14.6638 6.29148 14.6766 6.36169 14.6766 6.4319Z' fill='%233858E9'/%3E%3C/svg%3E");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<!-- wp:group {"tagName":"main","layout":{"type":"constrained"},"className":"entry-content","style":{"spacing":{"blockGap":"0px"}}} -->
<main class="wp-block-group entry-content">

<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"left":"var:preset|spacing|edge-space","right":"var:preset|spacing|edge-space","top":"var:preset|spacing|20","bottom":"var:preset|spacing|60"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group alignfull" style="padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--edge-space);padding-left:var(--wp--preset--spacing--edge-space);padding-bottom:var(--wp--preset--spacing--60)">
<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"left":"var:preset|spacing|edge-space","right":"var:preset|spacing|edge-space","top":"var:preset|spacing|60","bottom":"var:preset|spacing|60"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group alignfull" style="padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--edge-space);padding-left:var(--wp--preset--spacing--edge-space);padding-bottom:var(--wp--preset--spacing--60)">

<!-- wp:pattern {"slug":"wporg-make-2024/front-page-content"} /-->

Expand Down
Loading

0 comments on commit 475837a

Please sign in to comment.