1 of 47

Destination Full-Site EditingAll the Steps Monmouth University Took �to Prepare for the Future of WordPress

Steve Graboski (he/him)

Full-Stack Developer

Marketing and Communications

www.monmouth.edu

2 of 47

Rebuilding our WP Theme (2021-2022)

  • Cleaner use of fonts, easier to read.
  • Hero section: huge image, stand-out header, styled buttons
  • We’re focused on improvement, with an eye toward staying modern.

www.monmouth.edu

6/29/23

3 of 47

Interconnected Nav, prints via Full-Site Editor

Isolated Menus (2015)

Connected Menus (2022)

www.monmouth.edu

6/29/23

4 of 47

Site Editor (aka, Full-Site Editor)

  • Officially released with WordPress 5.9 on Jan. 25, 2022.
  • No-code template creation and editing.
  • We’re banking on reaping the rewards of Full-Site Editor. Other higher-education sites could find the same benefits.

www.monmouth.edu

6/29/23

5 of 47

Simple Edits, No Codebase Changes Required

www.monmouth.edu

6/29/23

6 of 47

Easily Change Static Parts of Template

www.monmouth.edu

6/29/23

7 of 47

You Can Create and Edit �Full Templates

  • Without changing any code you can
    • Create New Templates (Posts, Pages, Archives)
    • Edit Pre-Existing FSE Templates
  • Upshot: Save time, focus energy on bigger projects.
    • Quicker Edits
    • Approved workers won’t need to code to alter themes.

www.monmouth.edu

6/29/23

8 of 47

What’s with These New Template Files?

  • How can static HTML be powerful enough for a theme?
  • Where’s “The Loop”?
  • Where does information about the post go (get_the_ID, get_the_title)?

www.monmouth.edu

6/29/23

9 of 47

It’s all Blocks!

www.monmouth.edu

6/29/23

�<!-- wp:post-content {”layout”: {“type”:”constrained”}} /-->

  • This line of code will be the content of a given page!
    • Equivalent of “the_content()” from classic PHP-based themes.

  • New blocks made specifically for theming! For example:

10 of 47

How We Accidentally Prepared for FSE

  • Step One: We dabbled in the Block Editor (2017)
  • Step Two: Began the transition to the Block Editor (Early 2019)
  • Step Three: Built blocks, moved whole site to new editor (2019-Now)
  • Step Four: Everything learned geared us up for FSE (2022-Now)

www.monmouth.edu

6/29/23

11 of 47

Show of hands! (Even if you’re at home!)

  • Raise your hand if:
    • Dabbled in the Block Editor?
    • Began to transition to the Block Editor?
    • Built their own blocks?

www.monmouth.edu

6/29/23

  • Successful Transition Requires All Three.
  • Don’t rush! Move forward in steps.

12 of 47

Why Prepare Now?

  • The Block Editor is WordPress’s future.
    • Classic Editor to lose support in 2024 (was 2021, 2022, now 2024… maybe).
    • At some point, it’s coming. Best time to start the transition is now!
  • No word on if/when Classic Themes will phase out, but it’s possible.
  • Best to stay current. Avoid deadline scares and reap the benefits of both the Block Editor and the Full-Site Editor!

www.monmouth.edu

6/29/23

13 of 47

2017: Gutenberg

  • June 2017: WordPress announces Gutenberg
    • WordPress began moving away from a text-focused writing experience toward a drag-and-drop editor.
  • Same time: Our team was switching to WordPress
    • We leaned toward WP in part to empower our editors to build pages with one of the best editing experiences.
    • This new drag-and-drop editor could be even more powerful, easy-to-use.

www.monmouth.edu

6/29/23

14 of 47

Old Editor: Text Focused

  • Static toolbar for modifying text like in a word processor.
    • Bold and Italic, Alignment, Headings
  • Other buttons for typical features.
    • Media, Hyperlinks
  • Shortcodes for dynamic content
    • [tool attr=‘value’]Content[/tool]

www.monmouth.edu

6/29/23

15 of 47

Block Editor: Block-Focused

  • At first blush, it looks text-focused.
    • Only text entries appear:
      • Title
      • Paragraph
  • But hit the plus icon and…

www.monmouth.edu

6/29/23

16 of 47

Way More Options Than Before!

Text Blocks

Layout/Design Blocks

www.monmouth.edu

6/29/23

Media Blocks

17 of 47

Easy Customizations

  • Less windows to cycle through for simple changes like size, captions, and alt-text of media items.
  • Drag-and-drop interface makes rearranging elements quick and painless.

www.monmouth.edu

6/29/23

18 of 47

The First Step: Dabble

  • At this stage, it’s simply about becoming familiar with the Block Editor.
  • Consider all the blocks WordPress offers.

www.monmouth.edu

6/29/23

19 of 47

Oct 2017: Post-Dabble

  • Impressive, but needed more dev time.
    • As expected: still not truly part of official WordPress.
  • We eyed the official release of the editor.
    • WordPress 5.0, November 2018.

www.monmouth.edu

6/29/23

20 of 47

Step Two: Transition to Block Editor

  • Chart your Block-based future.
    • Take a section of your site, and restrict it to the block editor.
    • Consider the best places to start. What part of your website can you transition without having to delve too far into Block creation.

www.monmouth.edu

6/29/23

21 of 47

2019: Our University Magazine, Monmouth

  • Our magazine team puts stock in staying current.
    • Spring 2017, they redesigned their print look, asked us to develop a website to match.
  • What’s more current than the future? Feb 2019, we moved our first site to the block editor.

www.monmouth.edu

6/29/23

22 of 47

A Few Extra Blocks

  • Articles are mostly images and text. Didn’t need to code a ton of bespoke blocks.
  • The few we made were simple.
    • Hero (headlines, bylines, media)
    • Aside (text that floats right)
    • Question and Answer (for consistent style of each question and answer)

www.monmouth.edu

6/29/23

23 of 47

The Third Step: Building Blocks

  • WordPress offers plenty of blocks for you to craft your pages.
  • Inevitably, there will be something you want to include that just isn’t there.
  • Look over your entire site, and consider what blocks you’ll need to add to make the Classic Editor completely unnecessary.

www.monmouth.edu

6/29/23

24 of 47

Designing Blocks

  • Please note: This is a very brief overview.
  • Don’t stress the little details.
  • More than anything, consider the data—what information you’ll need to capture, rather than knowing exactly how you’ll grab it.
    • Design is king.

www.monmouth.edu

6/29/23

25 of 47

Consider a “Presentation” Block

  • What parts of the presentation will you present to the reader? Will there be different types of presentations that need unique looks? And what form will all this data take?
    • The presentation’s title (a string)
    • The presentation’s description (a string, multiple paragraphs)
    • Is it a featured presentation? (true or false, a boolean)
    • What else?

www.monmouth.edu

6/29/23

26 of 47

First Big Thing: Describe the Attributes

attributes: {

featured: {

type: ‘boolean’,

default: false

},

title: {

type: ‘string’,

default: ’’

}}

  • When you configure your block, you’ll describe the format of your data.
  • Include in the block’s JavaScript and PHP files.

www.monmouth.edu

6/29/23

27 of 47

Second Big Thing: Manipulating Attributes (JS)

  • The “edit” property (JSX)
  • Tells WordPress how we want the author to interact with the block.
  • We take “components” that WordPress supplies, and use them to manipulate the “attributes” we declared earlier.

<div>

<ToggleControllabel=“Is This Featured?”checked={ attributes.featured }� onChange={ () => {setAttributes( {� featured: !attributes.featured� } )} }� />

</div>

www.monmouth.edu

6/29/23

28 of 47

Deciding How to Show your Block to Readers

  • Render with JavaScript
    • Laying out attribute data in JSX as though it were HTML.
    • But, you will need to update the post for every change.
  • Render with PHP.
    • Define a render function when registering the block with PHP.
    • Best way to include data from outside the Block Editor (REST API, or the global $post variable).
    • Should be your go-to for your Full-Site Editor custom blocks.

www.monmouth.edu

6/29/23

29 of 47

2019 to Now: The Block Editor Rules

  • With our feet wet, we were ready to move the entire University site to the Block Editor.
  • We made Block Editor the default across the various departments and divisions of Monmouth University.
  • Looked over entire site, and determined what blocks we would need.
    • Would it be a feature we use regularly that would otherwise involve extra CSS, JS?
    • Was there a shortcode for it?
      • Ex: [shortcode attr=val /]

www.monmouth.edu

6/29/23

30 of 47

Accordion (Shortcode)

  • Was a shortcode, wonky to use.
  • Even with extra UI (Shortcake), hard to work with.
    • Extra pop-ups to go through.
    • Hard to re-arrange.

www.monmouth.edu

6/29/23

31 of 47

Accordion (Block)

  • Now, all you have to do is add the block and enter the content.
  • To re-arrange, just drag and drop like every other element.

www.monmouth.edu

6/29/23

32 of 47

Contact Block (More Advanced)

  • Grabs info from the University’s employee directory site.
  • Automatically displays the contact details: styled, linked, and with a headshot.
  • Similar shortcode, but had to know directory post’s ID.

www.monmouth.edu

6/29/23

33 of 47

Contact Block (More Advanced)

  • REST-API autocomplete.
  • Quicker for authoring pages.
    • No need to go to the directory site and find the post ID.
  • This one required a deeper understanding of Blocks.
    • All the better to prepare for FSE.

www.monmouth.edu

6/29/23

34 of 47

Step Four: Closing the FSE Gap

  • Preparing for Block Editor means preparing for the Full-Site Editor.
  • Include /templates/index.html in theme folder. It’s a block theme!
  • Full-Site Editor is a Block Editor
    • Blocks for query loop, post content, featured image, so on.

www.monmouth.edu

6/29/23

35 of 47

Theme Blocks in Action: Post Content Block

www.monmouth.edu

6/29/23

�<!-- wp:post-content {”layout”: {“type”:”constrained”}} /-->

  • When you add a block to a template, it will look like this.
  • The new “post-content” block, with the layout’s type specified as “constrained”.
  • Great for “single” post/page/custom-post-type templates.

36 of 47

Archive Templates: Simpler than in PHP!

  • Query Loop
    • Post Template (for all queried)
      • Post Title
      • Post Excerpt
    • Query Pagination
      • Previous
      • Numbers
      • Next

<!-- wp:query -->

<div class="wp-block-query">

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

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

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

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

<!-- wp:query-pagination -->

<!-- wp:query-pagination-previous /-->

<!-- wp:query-pagination-numbers /-->

<!-- wp:query-pagination-next /-->

<!-- /wp:query-pagination -->

</div>

<!-- /wp:query -->

www.monmouth.edu

6/29/23

37 of 47

Adding Template Parts in Block Templates

<!-- wp:template-part {

"slug":”preheader",

} /-->

  • Or, just drag and drop the “Template Part” block in the Full Site Editor.

www.monmouth.edu

7/2/23

<!-- wp:template-part {

"slug":”header",

} /-->

<!-- wp:template-part {

"slug":”footer",

} /-->

38 of 47

You Can Replace PHP Templates Bit-by-Bit

  • At Monmouth, we took a hybrid approach when developing our 2022 themes.
  • Deadlines, folks!
  • Point being: not all or nothing!
    • Just include an index.php file in your theme folder.

Notice: PHP and Block Templates

www.monmouth.edu

6/29/23

39 of 47

Building Your Own Theme Blocks

  • If you can build Block Editor blocks, you can build FSE blocks.
  • Most of the time, you’ll want to render the block with PHP, not JavaScript.
    • PHP beats out JS for for displaying remote data and post content with theme blocks.

www.monmouth.edu

6/29/23

40 of 47

Alert Block (2022)

  • Checks remote system for any active alerts, displays them.
  • The draggable block just specifies where on the template the alerts bar should load.

www.monmouth.edu

6/29/23

41 of 47

SuperNav, Breadcrumb Blocks (2022)

  • Blocks tell WordPress where on the template they should load.

www.monmouth.edu

7/4/23

42 of 47

SuperNav in preheader.html (template part)

<!-- wp:group {"className":"mobilenav-body"} -->

<div class="wp-block-group mobilenav-body">

<!-- wp:mu/supernav {"theme_location":"sidebar"} /-->

</div>

<!-- /wp:group -->

www.monmouth.edu

7/2/23

43 of 47

Requirements for Block Building

  • WordPress introduces several new concepts.
    • Consult the documentation
    • Fantastic Tutorials (fullsiteediting.com, kinsta.com, css-tricks.com)
  • Some knowledge of React is a must, but not a ton!
    • A surface-level understanding will get you pretty far!
    • The more knowledge you have, the further you can take your blocks!

www.monmouth.edu

6/29/23

44 of 47

Strong Recommendations (Don’t Fret)

  • Learn some ES6
    • Arrow functions, array methods (map, reduce, filter).
  • Use JSX
    • Makes coding out layouts much easier (more to come shortly)
  • Transpile with a Build System
    • Allows your ES6 code to run on as many browsers as possible.
    • We use Babel with Webpack. Gulp, Make, others can work, too.

www.monmouth.edu

6/29/23

45 of 47

JSX and ES6 Plain JS

<InspectorControls>� <Panel>� <PanelBody>� <PanelRow>� <ToggleControl />� </PanelRow>� </PanelBody>� </Panel>�</InspectorControls>

wp.element.createElement(

InspectorControls,

{},

wp.element.createElement(

Panel,

{},

wp.element.createElement(

PanelBody,

{},

wp.element.createElement(

PanelRow,

{},

wp.element.createElement(

ToggleControl,

{)

)

) […]

www.monmouth.edu

6/29/23

46 of 47

A Free Plugin to Get Started: �Block Environment

  • Out of the box, includes support for ES6, JSX, Webpack and Babel.
    • Check the readme.md for setup and instructions.
  • Example blocks for both the Block Editor and the Full-Site Editor.
    • Plenty of comments describing how it all works.

www.monmouth.edu

6/29/23

47 of 47

Thank You!

Steve Graboski

Full-Stack Developer

Monmouth University

(https://www.monmouth.edu)

Linkedin | Github: @SJGraboski

Feedback: Link in Schedule

Block Environment (GitHub)

www.monmouth.edu

6/29/23