How We Built A New Home For Wordpress Com Developers Using The Twenty Twenty Four Theme


In the last few weeks, our team here at WordPress.com has rebuilt developer.wordpress.com from the ground up. If you build or design websites for other people, in any capacity, bookmark this site. It’s your new home for docs, resources, the latest news about developer features, and more. 
Rather than creating a unique, custom theme, we went all-in on using Twenty Twenty-Four, which is the default theme for all WordPress sites. 
That’s right, with a combination of built-in Site Editor functionalities and traditional PHP templates, we were able to create a site from scratch to house all of our developer resources. 
Below, I outline exactly how our team did it.
A Twenty Twenty-Four Child Theme The developer.wordpress.com site has existed for years, but we realized that it needed an overhaul in order to modernize the look and feel of the site with our current branding, as well as accommodate our new developer documentation. 
You’ll probably agree that the site needed a refresh; here’s what developer.wordpress.com looked like two weeks ago:
Once we decided to redesign and rebuild the site, we had two options: 1) build it entirely from scratch or 2) use an existing theme. 
We knew we wanted to use Full Site Editing (FSE) because it would allow us to easily use existing patterns and give our content team the best writing and editing experience without them having to commit code.
We considered starting from scratch and using the official “Create Block Theme” plugin. Building a new theme from scratch is a great option if you need something tailored to your specific needs, but Twenty Twenty-Four was already close to what we wanted, and it would give us a headstart because we can inherit most styles, templates, and code from the parent theme.
We quickly decided on a hybrid theme approach: we would use FSE as much as possible but still fall back to CSS and classic PHP templates where needed (like for our Docs custom post type).
With this in mind, we created a minimal child theme based on Twenty Twenty-Four.
Spin up a scaffold with @wordpress/create-block We initialized our new theme by running npx @wordpress/create-block@latest wpcom-developer. 
This gave us a folder with example code, build scripts, and a plugin that would load a custom block.
If you only need a custom block (not a theme), you’re all set.
But we’re building a theme here! Let’s work on that next.
Modify the setup into a child theme First, we deleted wpcom-developer.php, the file responsible for loading our block via a plugin. We also added a functions.php file and a style.css file with the expected syntax required to identify this as a child theme. 
Despite being a CSS file, we’re not adding any styles to the style.css file. Instead, you can think of it like a documentation file where Template: twentytwentyfour specifies that the new theme we’re creating is a child theme of Twenty Twenty-Four.
/* Theme Name: wpcom-developer Theme URI: https://developer.wordpress.com Description: Twenty Twenty-Four Child theme for Developer.WordPress.com Author: Automattic Author URI: https://automattic.com Template: twentytwentyfour Version: 1.0.0 */ We removed all of the demo files in the “src” folder and added two folders inside: one for CSS and one for JS, each containing an empty file that will be the entry point for building our code.
The theme folder structure now looked like this:
The build scripts in @wordpress/create-block can build SCSS/CSS and TS/JS out of the box. It uses Webpack behind the scenes and provides a standard configuration. We can extend the default configuration further with custom entry points and plugins by adding our own webpack.config.js file. 
By doing this, we can:
Build specific output files for certain sections of the site. In our case, we have both PHP templates and FSE templates from both custom code and our parent Twenty Twenty-Four theme. The FSE templates need minimal (if any) custom styling (thanks to theme.json), but our developer documentation area of the site uses a custom post type and page templates that require CSS. Remove empty JS files after building the *.asset.php files. Without this, an empty JS file will be generated for each CSS file. Since the build process in WordPress Scripts relies on Webpack, we have complete control over how we want to modify or extend the build process. 
Next, we installed the required packages:
​​npm install path webpack-remove-empty-scripts --save-dev Our webpack.config.js ended up looking similar to the code below. Notice that we’re simply extending the defaultConfig with a few extra properties.
Any additional entry points, in our case src/docs, can be added as a separate entry in the entry object.
// WordPress webpack config. const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); // Plugins. const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' ); // Utilities. const path = require( 'path' ); // Add any new entry points by extending the webpack config. module.exports = { ...defaultConfig, ...{ entry: { 'css/global': path.resolve( process.cwd(), 'src/css', 'global.scss' ), 'js/index': path.resolve( process.cwd(), 'src/js', 'index.js' ), }, plugins: [ // Include WP's plugin config. ...defaultConfig.plugins, // Removes the empty `.js` files generated by webpack but // sets it after WP has generated its `*.asset.php` file. new RemoveEmptyScriptsPlugin( { stage: RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS } ) ] } }; In functions.php, we enqueue our built assets and files depending on specific conditions. For example, we built separate CSS files for the docs area of the site, and we only enqueued those CSS files for our docs. 
<?php function wpcom_developer_enqueue_styles() : void { wp_enqueue_style( 'wpcom-developer-style', get_stylesheet_directory_uri() . '/build/css/global.css' ); } add_action( 'wp_enqueue_scripts', 'wpcom_developer_enqueue_styles' ); We didn’t need to register the style files from Twenty Twenty-Four, as WordPress handles these inline.
We did need to enqueue the styles for our classic, non-FSE templates (in the case of our developer docs) or any additional styles we wanted to add on top of the FSE styles.
To build the production JS and CSS locally, we run npm run build. 
For local development, you can run npm run start in one terminal window and npx wp-env start (using the wp-env package) in another to start a local WordPress development server running your theme.
While building this site, our team of designers, developers, and content writers used a WordPress.com staging site so that changes did not affect the existing developer.wordpress.com site until we were ready to launch this new theme.
theme.json Twenty Twenty-Four has a comprehensive theme.json file that defines its styles. By default, our hybrid theme inherits all of the style definitions from the parent (Twenty Twenty-Four) theme.json file. 
We selectively overwrote the parts we wanted to change (the color palette, fonts, and other brand elements), leaving the rest to be loaded from the parent theme. 
WordPress handles this merging, as well as any changes you make in the editor. 
Many of the default styles worked well for us, and we ended up with a compact theme.json file that defines colors, fonts, and gradients. Having a copy of the parent theme’s theme.json file makes it easier to see how colors are referenced.
You can change theme.json in your favorite code editor, or you can change it directly in the WordPress editor and then download the theme files from Gutenberg.
Why might you want to export your editor changes? Styles can then be transferred back to code to ensure they match and make it easier to distribute your theme or move it from a local development site to a live site. This ensures the FSE page templates are kept in code with version control. 
When we launched this new theme on production, the template files loaded from our theme directory; we didn’t need to import database records containing the template syntax or global styles.
Global styles in SCSS/CSS Global styles are added as CSS variables, and they can be referenced in CSS. Changing the value in theme.json will also ensure that the other colors are updated.
For example, here’s how we reference our “contrast” color as a border color:
border-color: var(--wp--preset--color--contrast); What about header.php and footer.php? Some plugins require these files in a theme, e.g. by calling get_header(), which does not automatically load the FSE header template. 
We did not want to recreate our header and footer to cover those cases; having just one source of truth is a lot better.
By using do_blocks(), we were able to render our needed header block. Here’s an example from a header template file:
<head> <?php wp_head(); $fse_header_block = do_blocks( '<!-- wp:template-part {"slug":"header","theme":"a8c/wpcom-developer","tagName":"header","area":"header", "className":"header-legacy"} /-->' ); ?> </head> <body <?php body_class(); ?>> <?php echo $fse_header_block; The new developer.wordpress.com site is now live! Check out our new-and-improved developer.wordpress.com site today, and leave a comment below telling us what you think. We’d love your feedback. 
Using custom code and staging sites are just two of the many developer features available to WordPress.com sites that we used to build our new and improved developer.wordpress.com.
If you’re a developer and interested in getting early access to other development-related features, click here to enable our “I am a developer” setting on your WordPress.com account.


Artikel ini hanyalah simpanan cache dari url asal penulis yang berkebarangkalian sudah terlalu lama atau sudah dibuang :

https://wordpress.com/blog/2024/02/29/new-developer-home/

Kempen Promosi dan Iklan
Kami memerlukan jasa baik anda untuk menyokong kempen pengiklanan dalam website kami. Serba sedikit anda telah membantu kami untuk mengekalkan servis percuma aggregating ini kepada semua.

Anda juga boleh memberikan sumbangan anda kepada kami dengan menghubungi kami di sini
Designlsm S Concept For The Alchemist S New London Victoria Bar

Designlsm S Concept For The Alchemist S New London Victoria Bar

papar berkaitan - pada 21/2/2024 - jumlah : 301 hits
Project The Alchemist Architects DesignLSM Location London UK Photographs by Courtesy of DesignLSM The Alchemist by DesignLSM DesignLSM the renowned multi disciplined design agency unveils one of its latest projects with immersive cocktail ...
How To Pick The Perfect Covering For Your Couch

How To Pick The Perfect Covering For Your Couch

papar berkaitan - pada 19/2/2024 - jumlah : 247 hits
Are you looking to breathe new life into your living room One of the quickest and most cost effective ways to do so is by changing the covering on your couch With a plethora of options The post appeared first on
Sng Wants Home Ministry To Issue New Sop For Speedier Crime Lab Results

Sng Wants Home Ministry To Issue New Sop For Speedier Crime Lab Results

papar berkaitan - pada 4/3/2024 - jumlah : 167 hits
PARLIAMENT Julau MP Larry Sng has called on the Home Ministry to detail new standard operating procedures for criminal laboratory test reports This follows his close shave with the group of local gangsters in Julau late last month The Parti...
Small Changes Big Impact A Look At What S New In The Wordpress Editor

Small Changes Big Impact A Look At What S New In The Wordpress Editor

papar berkaitan - pada 21/2/2024 - jumlah : 181 hits
The WordPress project team is continuously improving the Site Editor your one stop shop for editing and designing your site The latest batch of updates Gutenberg and include a handful of small but powerful changes designed to improve both y...
15 Diy Early Spring Crafts To Decorate Your Home In The Season S Style

15 Diy Early Spring Crafts To Decorate Your Home In The Season S Style

papar berkaitan - pada 4/3/2024 - jumlah : 154 hits
Embrace the arrival of spring with open arms through 15 DIY Early Spring Crafts to Decorate Your Home in the Season s Style As nature awakens and buds unfurl let your living spaces bloom in tandem The post appeared first on
March 10 For Sighting Of Ramadan New Moon

March 10 For Sighting Of Ramadan New Moon

papar berkaitan - pada 4/3/2024 - jumlah : 153 hits
The visual sighting of the new moon as well as astronomical calculations will determine when the fasting month will begin PETALING JAYA The Conference of Rulers has set March 10 as the date for the sighting of the new moon for Ramadan marki...
Opinion Why Did Hassan Karim Say That The New King Is Out Of Line

Opinion Why Did Hassan Karim Say That The New King Is Out Of Line

papar berkaitan - pada 3/3/2024 - jumlah : 133 hits
Nehru Sathiamoorthy After hearing the Agong s speech during the opening of the Dewan Rakyat Pasir Gudang MP Hassan Karim has called out the new Agong by saying that the Agong has crossed the line Does Hassan Karim s statement have any merit...
Get Up To Rm 2800 Off For Your Holiday Treats The Traveloka Travel Fiesta

Get Up To Rm 2800 Off For Your Holiday Treats The Traveloka Travel Fiesta

papar berkaitan - pada 4/3/2024 - jumlah : 232 hits
The Traveloka Travel Fiesta offers fantastic Flights Hotels and Travel Activities discounts up to RM 2800 and various free giveaways to Maldives South Korea and Vietnam for those looking to explore more of Malaysia and the world during thei...
New Township For Bagan Datuk To House All Govt Offices

New Township For Bagan Datuk To House All Govt Offices

papar berkaitan - pada 4/3/2024 - jumlah : 161 hits
Ahmad Zahid Hamidi meeting members of the community at a back to school aid distribution programme in Bagan Datuk today BAGAN DATUK The government is acquiring land to develop a new township here called Bandar Baharu Bagan Datuk to expand t...
1 Ringgit Berapa Rupiah Faktor Yang Mempengaruhi Implikasinya

Bagaimana Ketidakpastian Mega Cap Mempengaruhi Penurunan S P Dan Nasdaq

Wanda Hara Hadiri Kajian Hanan Attaki Pakai Cadar Berbuntut Panjang Kasusnya Dibawa Ke Jalur Hukum

Mengopi Tepi Pantai Di Kopi Penunjuk Kijal Terengganu

Melaka Ke Muzium Kapal Selam Sekali Lagi

Transform Your Home With Art Placement That Speaks Volumes

Peniaga Pisang Goreng Mengaku Culik Dua Kanak Kanak Sebab Teringin Nak Ada Anak Perempuan

Kronologi Kes Zulfarhan Osman Zulkarnain



Kenapa Kita Gelarkan Masa Guna Istilah Second Minute Hour Day Week and Year

Biodata Ikhmal Nour Personaliti TikTok Terkenal

Apakah Fatwa Berkenaan Menanam Jambang dan Rambut Bagi Lelaki

Info Dan Sinopsis Drama Tonton Berepisod SeOfis Slot Samarinda TV3

Biodata Mek Yun Mek Kelate Personaliti TikTok Terkenal


Graduan Kejuruteraan Usahawan Sambal Acar Ikan Masin

Aktiviti Dengan Anak 003

Rasa Risau Dan Takut Terhadap Perkara Yang Masih Belum Berlaku Selalunya Adalah Berlebihan

Memahami Inflasi Dan Indikator Tren Dalam Pasar Keuangan

Lagu Tiktok Yang Viral Pada Bulan Julai 2024

Resepi Sotong Sumbat Telur