Author Archives: Zac

About Zac

Educator, Business Owner, Yogi and More

Create Additional Search Keywords for Your Gutenberg Editor Blocks

While working on my Gutenberg Editor Development Course I stumbled upon a cool feature for Gutenberg Blocks that let’s someone to find your block using words not found in the title of your block.

Searching for Blocks in Gutenberg

One of the easiest ways to find a specific block in Gutenberg is by using the search field.  By default, if your title has a keyword someone searches for, it will show your block in the results.

Sometimes though, we want our block to show for keywords that are not included in our title.

gutenberg-search-for-block-feature

Here is an example of searching for “Image” and receiving multiple matching blocks

You can see in the example above that if we search for an “Image” block we get blocks that do not have “Image” in the title.

This is accomplished using the “keywords” parameter when registering your block.

Using the Keyword Setting When Creating a Block in Gutenberg

When you create a block using registerBlockType() you can set a parameter called “keyword.”  This parameter takes an array of words that if searched for, will include your block in the results.

custom-keyword-gutenberg-block.png

Custom keyword allows block to be searched for using keywords not found in the block title

In the example above we have added extra keywords to a custom block.

Here is the code to make this work.  (Notice we are also escaping them using the wp.i18n library for localization).

This allows us to have our block show up for the search terms “zac,” “fire,” and “fuego,” which are not found in our block title.

I would suggest looking at what keywords the default WordPress blocks use and leverage some of those keywords in your blocks.

Learn More About Gutenberg Development

If you would like to learn more about creating custom blocks or developing with Gutenberg in general, please check out my Gutenberg Development Course!

How to Add Custom Icons to Gutenberg Editor Blocks in WordPress Using Dashicons or SVG

While working on my upcoming Gutenberg Editor Development Course I came across the question, “How do you create a custom icon for a block in the new Gutenberg editor.”  This post explains my process in figuring this out 🙂

Block Icons in the Gutenberg Editor

With the new Gutenberg editor in WordPress you have the option to select an icon to go along with your custom block.

Screen Shot 2017-12-07 at 4.51.01 PM

Example of icons with default block.

Using Default WordPress Dashicons as Block Icons

When you use registerBlockType() to create a new block, one of the parameters is “icon”.  You can use any default WordPress Dashicons as an icon.

In the example below we are using one of the default dashicons named “admin-settings“.  That will give us a settings icon like this.

default-gutenberg-icon.png

Example of custom block with ‘admin-settings’ dashicon

Here is the code to make that work (focus just on the icon parameter):

Interestingly, if you look in the Gutenberg Core file ‘components/dashicon/index.js‘ you will see that dashicons are not being used the same way in blocks as they are in as in places like admin menus.  Instead, there is a case statement against each default argument, assigning it the proper SVG path.

gutenberg-dashicon-case-statement.png

Example of Dashicon component in Gutenberg Core assigning default SVG paths.

Creating Custom Gutenberg Block Icons Using SVG Paths

A lot of folks are going to want to create custom icons like this one.

custom-gutenberg-icon.png

Example of Custom Block with Custom SVG Icon

In the example above, I used an SVG icon from this collection here.  You can also create you own custom icons.

What you want to do is get the SVG path for your custom icon and create a custom SVG icon using that path.

Here is the code example from the image above.  Pay attention to the top, where iconEl is created then passed as the value to the registerBlockType() icon parameter.

You can use this model in your own code and simply replace the path ‘d’ value with the path for your own custom icon svg.

To Learn More About Gutenberg Development

To learn more about creating custom blocks and more with the new Gutenberg editor for WordPress, check out my Gutenberg Development Course.

“It works!” DesktopServer not working solution for Apache on Mac

I am not sure what I did to cause this problem, but recently, all of my DesktopServer server sites, including localhost began displaying the message: “It works!”

I contacted the lovely folks at DesktopServer and got this quick fix (for Macs):

This solved the problem and I’m back up and running.  Since I couldn’t find the solution online before I contacted support, I thought I would share 🙂

WordCamp New York 2017 JavaScript Workshop

WCNYC 2017.png

It’s been a good number of years since I last attended a WordCamp New York.  But it holds a warm place in my heart.  My first WordCamp was WordCamp New York 2008 🙂

This year, my good friend, David Parsons, took up the lead organizer role and put on a great WordCamp New York.

From the venue to the speakers, it all went very smooth and had a nice local camp feel.

Reflections From the JavaScript Workshop

IMG_20171022_003310_556.jpg

My workshop was an adaptation of a similar workshop I have been doing at a number of other camps this year.

However, I learned one important thing this time.

It is important to take the time at the beginning to address who needs to “Learn JavaScript Deeply” from a programmer’s perspective and who just needs to know what it is capable of doing.

I noticed that some people loved learning vanilla JavaScript fundamentals and how to integrate with the WordPress REST API.  However, some people hung around through several hours of the workshop with not really realizing they did not need to learn JavaScript deeply as a developer. Some of these people were just savy website owners.

This supports something I have been saying for a while:

Compared to HTML and CSS, which you can learn a little and do a lot, with JavaScript you have to learn a lot to do a little.

All that said, for folks who wanted to learn JavaScript more deeply (or even just for the first time) I think the workshop went great.

Changes I’m Making for Next Time

There are a few modifications I am going to make for next time though:

  • Add a note at the beginning about “Who Should Be Learning JavaScript Deeply” and who can just learn to “Speak JavaScript”
  • With the decoupled Vanilla JS and WP REST API practice project we will just use fetch instead of introducing Axios or jQuery.
  • Inside of WordPress, when we import our decoupled example into a WordPress theme I am just going to show how to use jQuery AJAX.
  • Rather than try to teach the Backbone client I am just going to mention it at the end.  After teaching it for a while, I think it is best to know some Backbone before trying to use this.

You can view the slides and example files from the workshop here.

Learn More JavaScript!

WCNYC 2017 (1).png

Want to learn more JavaScript?

Head over the JavaScript for WordPress to learn about my Master Course to help you learn JavaScript more deeply.

Data Visualization Talk at WooConf

Wow!  What an honor to attend the 3rd annual WooConf!  Last year I did a workshop on WooCommerce Theme Development.  This year it was all JavaScript, API, and Data Visualization.

I was a little unsure going into the event how the talk would go.  Originally it was a workshop using the Woo API and Chart.js and D3.  However, shortly before the event started, the format was switched to a standard 50 minutes talk.

A Big Thanks!

Luckily, I think that everything went well.  I did a lot of research on Data Visualization as well as related JavaScript libraries.  A big thanks go out to all the folks at the conference who gave me insights into how they do data visualization with their work.  Also shoutout to K. Adam White’s talk at WCEU on data visualization.

Come Out Next Year!

If WooCommerce is how you make your living, you might look into attending WooConf next year.  They put on an amazing conference and I highly recommend it, not just for the talks, but for the networking as well.

Want to learn more about WooCommerce development?  Checkout my WooCommerce Theme Development Course.

WordCamp Ann Arbor 2017 JavaScript Workshop

My First WCA2

Zac Gordon teaching JavaScript at WordCamp Ann Arbor

When I put out the call at the beginning of 2017 that I would like to start doing more JavaScript workshops, my good friend Kyle Maurer, from WordCamp Ann Arbor, was one of the first to invite me to come do a workshop.

The Workshop

I have continued to refine the JavaScript for WordPress workshop I have been doing and I think it continues to evolve into a solid workshop covering JS and WP API fundamentals while also building something practical.

In the workshop we cover the following:

  1. JavaScript Language Basics (Programming 101 w JS)
  2. The Document Object Model
  3. Events with the DOM & JavaScript
  4. The WordPress REST API
  5. How to pull the API into JavaScript in a stand alone and theme environment

Of course there was still more I would have liked to include, but I think we did a really good job.

Slide Deck and Resources

20171013_115246

Super Fun Getting to Know Some Students Working in the Field!

You can check out the slide deck and resources for the workshop over here on my 2017 WordCamp Ann Arbor landing page.

A Reflection on WCA2 Social Activities

One of the nice things that WordCamp Ann Arbor did well and a little different was to have non WordPress related breakout sessions on the first day where folks could group up and go on a range of activities from a walk through the Arboretum to Pub Crawling.

20171013_180427

Hanging out with WordCampers at WCA2 2017

At first I was hesitant of these plans, but it turns out it was brilliant and the perfect chance to know some other attendees more deeply.  I had a great time and enjoyed getting to know folks better.

Overall, great job WCA2!  I had heard about your camp for a while and you did not disappoint.  There is rumored to be four Michigan camps in 2018 so I look forward to making it back!

Congrats and well done to all the organizers for WCA2 2017!!!

Zac Gordon Advanced JavaScript Topics Talk at WordCamp San José Costa Rica

Teaching JavaScript Deeply at WordCamp San José 2017

WordCamp San José

¡Pura Vida! Is the best way to start my review of attending WordCamp San José (formally WordCamp Costa Rica).

Organizers Roberto Remedios and Alfredo “El Puas” invited me to do a workshop at WordCamp San José 2017 earlier this year while we were all hanging out at WordCamp Miami (also a great camp to attend).

What started as a JavaScript workshop turned into a talk on advanced JavaScript and sitting in on a JavaScript panel with two other amazing speakers.

Un Poco Sobre WordCamp San José

IMG_2367.JPG

WordCamp San José 2017 took place at La Universidad Latina de San José, Costa Rica.  More than 350 people attended two days of talks with three tracks.

WordCamp San José Talk from Johana about Brand

Most of talks were in Spanish and topics covered everything from Marketing to Development (w plenty of JS) and everything in between.  Many of the talks also included sing language interpretation and a good group benefiting from it.

DSC_0569.JPG

The layout of the venue was great, with a big open area for the sponsors right in front of the three rooms for the talks.  The main sponsors had cool seating areas and the food included amazing breakfast, lunch and treats!

Screen Shot 2017-09-07 at 10.14.39 PM.png

Let’s not forget about the after party either.  The camp hosted everyone with music, food and great atmosphere at a nearby restaurant / club with a pool and hammocks (not pictured).

My JavaScript and WordPress REST API Workshop

Continuing with my 2017 JavaScript Workshop Tour, I ran a 3 hr workshop on the Friday day before the two day of talks. You can see the slides and example files for the workshop here.

Zac Gordon Costa Rica WordCamp San Jose JavaScript Workshop.png

The workshop covered the following:

  1. JavaScript Language Basics
  2. The Document Object Model
  3. Events in JavaScript
  4. The WordPress REST API
  5. Using JavaScript and the API in WP Themes

Unfortunately, my Spanish was not quite good enough to give the workshop in Spanish so props to all the bi-lingual attendees for following the talk, along with questions, in English.

Zac Gordon JavaScript and WordPress REST API Workshop San José WordCamp Costa Rica.JPG

I like the 3hr time span for a workshop.  It let’s you really cover fundamentals and give time for practice.  Big thanks to the organizers and attendees for inviting me down to do this workshop.

Next year I am going to try to do it en Español 🙂

My First “Advanced JavaScript Topics” WordCamp Talk

A few moons before the camp started, the organizers asked if I would like to do a talk in addition to the workshop.  I knew I would be recording my Advanced JavaScript Topics section of my Master Course so I submitted an open ended talk entitled “Interesting Things About JavaScript” that was actually a JavaScript homage to Andrew Nacin’s Advanced WordPress Topics talk.

Zac Gordon Advanced JavaScript Topics Talk at WordCamp San José Costa Rica

The talk included a number of different intermediate, advanced, new and, well, interesting things, about JavaScript that I am going into more depth on in my Master Course.

The slides might not be as helpful without the explanations but you may still gleam some things from flicking through the deck 🙂

5 + 1 Question JavaScript Panel

As an added bonus I got to sit in on a panel on JavaScript with Elio Rivero from Automattic and Gabo Esquivel who heads up the JavaScript community in San José.

Zac Gordon JavaScript Panel WordCamp San José w Elio and Gabo

The questions were basically something like this (but in Spanish except for my answers):

  • Panelist Intros
  • Advice for JavaScript beginners (I said CodeAcademy, Treehouse, Wes Bos and of course my free JavaScript videos)
  • Top 3 Good JavaScript Practices (I suggested Testing, Coding Standards and Keep on Learning)
  • Favorite JS Framework and why (Choose the best tool for the job, I like Vue for it’s architecture and ease and React for Gutenberg Blocks etc,  If I was building a huge app or plugin I would also consider Angular)
  • Most challenge JavaScript project (Teaching JavaScript Deeply!)
  • JavaScript for WordPress in 2018 (Gutenberg, JS Widgets, More w Customizer, Keep Learning JavaScript)

Overall a Great Camp with Lots of JavaScript

Muchas gracias a los organizadores y voluntarios de WordCamp San José 2017.  It won the 2017 WordCamp Award for food (rice, beans and real cooked food is soo good) in my opinion.

WordCamp San José 2017 Volunteers

It also had a ton of talks on JavaScript in addition to mine, like Cross Platform React, CSS in JS, Calypso, Angular, GraphQL and even a demo of Caldera Forms in action, which I am definitely checking out for my next WP project that needs JS driven forms.

I am going to start a rumor that in 2018 you may see more than one large WordCamp in Central America around the same time period.  I highly suggest you attend and get some of this Pura Vida WordCamp energía!