Bridging the gap between
WordPress developers and content creators
Brian DeConinck
NC State University
Office of Information Technology
The Problem
Our Solution
The
Future!
Free
Multisite
Premium
Multisite
OIT
ORIED
DASA
OFA
Major Campus Multisites
Unit-Level Multisites
Stand-Alone
Single Installations + Small Multisites
Rest of Campus?
2
But this system works!
... Mostly.
Option #1
Add a bunch of templates
Regular WP Editor
Theme Options
Coded Directly Into Template
You start adding more and more page templates, and each one has its own special rules.
This is not sustainable for us.
Advanced Custom Fields is great. It's a useful tool for certain situations.
Advanced Custom Fields makes parts of this easier. But it doesn't solve two core problems:
Developer time required to build templates
It's not a true WYSIWYG experience.
There are WordPress developers who swear by ACF.
By the end of this presentation, I think you'll see why our way is better.
When a client asks for something special and we don't have time, there are two easy answers...
"NO."
Option #2
"There's a plugin for that."
... and more.
Page-building plugins are powerful tools.
It's irresponsible to give them to content creators without proper training, especially for accessibility and branding.
Shortcodes + Shortcake
WordPress sees your shortcode and replaces it with a pre-defined block of HTML
function major_link_shortcode($atts, $content = null) {
extract(shortcode_atts(array(
'url' => null,
), $atts));
return sprintf(
'<a href="%s" class="major-link">%s <img src="arrow.svg"
aria-hidden="true" />',
$url,
$content
);
}
function register_shortcode(){
add_shortcode('major-link', 'major_link_shortcode');
}
add_action('init', 'register_shortcode');
[major-link url="https://www.ncsu.edu/"]Visit the NC State Homepage[/major-link]
Problem solved, everyone is happy!
... Right?
Define a user interface for your shortcode and preview it in the WordPress WYSIWYG
shortcode_ui_register_for_shortcode(
'major-link',
array(
'label' => 'Major Link',
'listItemImage' => 'dashicons-arrow-right-alt',
'inner_content' => array(
'label' => 'Link Text',
'description' => 'Enter the text that will
be clicked on.',
),
'attrs' => array(
array(
'label' => 'URL',
'attr' => 'url',
'type' => 'url',
'description' => 'Enter your destination
URL.',
)
)
)
);
But...
Even if the Shortcake project is abandoned (and it won't be), shortcodes themselves are well-supported and will continue to render.
Or, you know, next week. You should still pay attention during the other sessions.