WordCamp Orange County 2017 JavaScript, Vue, React, Redux, GraphQL & WordPress API Workshops

Wow #WCOC

I have had the wonderful opportunity to attend a number of WordCamps, so it is always exciting when I attend a new (to me) amazing WordCamp. WordCamp Orange County 2017 was one of those Camps.

Props to all of the organizers and attendees for representing so well the diverse and deep nature of the WordPress Community all coming together to help each other (and have fun). So many great talks, and I personally learned a ton from showing up and asking a lot of questions ūüôā

WordCamp Orange County was also one of the Camps to reach out to me in response to my tweet asking if any WordCamps wanted a workshop on JavaScript and the WordPress REST API so I was excited to take part in their series of JavaScript and WordPress API Workshops.

Planning The Workshops

Jason Bahl, Jacob Arriola and myself  all did two hour workshops that spanned the following JavaScript and WordPress API topics:

  • Vanilla JavaScript
  • VueJS
  • React & Redux
  • GraphQL and
  • The WordPress REST API

I want to thank Jacob and Jason for the backdoor Slack discussions before the Camp figuring out how we can tie our three workshops together and best plan everything.

Two hours is also not a lot of time to lead a workshop because ideally a workshop has time for the following:

  1. Setting up the local development environment and getting the practice exercises and slides
  2. Time to both code along with the instructor and time to practice what they learned on their own or in groups
  3. Ability for attendees to receive assistance if they fall behind or have questions

If you’re looking to plan a WordCamp JavaScript talk or workshop track I recommend you encourage the presenters to discuss and organize their talks a bit during Camp planning stages for the best flow for attendees. This also happened with the WordCamp Miami Learn Deeply Tracks and that made a huge difference there as well.

I will say that even though we did feel we could have done more with more time, the workshops were a success in my opinion, and I think that other WordCamps should definitely follow the example of WordCamp Orange County and WordCamp Miami with planning JavaScripty talk or workshop tracks ūüôā

 

Zac’s Workshop – Vanilla JavaScript and (a little WP API)

I went up first with a workshop on Vanilla JavaScript. After a quick JS 101 pop quiz,  the workshop focused on DOM and Event fundamentals that can often be tricky or frustrating without an understand how the DOM API really works under the hood with JavaScript.

I got some feedback from folks who use jQuery regularly that this gave them some ideas for how they could do a few more things with VanillaJS that they had previously just used jQuery for. I’m not anti jQuery, especially since it is already loaded in so many places in WordPress, but, I do think it’s powerful to know how things work under the hood with Vanilla JavaScript.

I’m excited to continue to improve this workshop as I continue my JavaScript Workshop Tour at more WordCamps this year.

Jacob Arriola’s VueJS Workshop

Jacob did a great job not only delivering his workshop, but completely theming the project to the WCOC 2017 Super Hero Theme. Way to go above and beyond mate ūüėČ Jacob has been using VueJS at work for Zeek Interactive and you can tell he likes it’s ease of use combined with incredible power. (Side note, Arron Holbrook, also listed below, was a huge help in refining the plugin and wp apis section of my upcoming Udemy course, tx mate!)

Attendees got a chance to build out a Vue app and learn about the essentials of the framework. I overheard a number of folks talk about how well Jacob explained things and how easy Vue is to use. I definitely think this will inspire a number of companies to spin up small Vue projects in the coming moons.

Jacob is an active member of the WordPress and JavaScript community in the WCOC area and I definitely recommend you say hi and start a conversation with him next time you see him.

 

Jason’s React, Redux & GraphQL Workshop

WordCamp Orange County was lucky to have Jason leading a workshop that got into all of this, especially GraphQL.  Like Jacob, Jason presented a really strong case for working with the React, Redux and GraphQL stack in decoupled environments with WordPress.

He did a ton of prep work for this talk, including writing out a series of blog posts walking through everything he covered. Jason has done a lot of work in the arena of bringing GraphQL to WordPress and his workshop was amazing.

Jason went over getting up and running with React and then introduced Redux in a really clear and structured way that showed how you can save on queries to the API. The app he everyone got to build was a Netflix style site and it really showed off the power of these tools in action.

The part that I was most interested in hearing about was GraphQL and I was not disappointed. First, Jason showed how much more performant GraphQL is compared to the internal REST API for decoupled projects (10 times?!!). Then he showed how we can leverage GraphQL for grabbing data into our app and plugging it into the React / Redux architecture.

I highly suggest you go check out this tutorial series and follow GraphQL on Twitter.

 

My Overall Thoughts on JavaScript Workshops and Tracks at WordCamps

I am very grateful to be involved with the WordPress Community during these days of more interest in and talks and workshops coming out on JavaScript and API Driven WordPress Development.

If you help organize or influence your local WordCamp, I encourage you to follow the example of WordCamp Orange County and WordCamp Miami in helping your community become more inspired and confident with JavaScript and WP REST API (or GraphQL ;))

Leverage your local community of experts (both within WordPress and outside of it) and feel free to reach out to me for ideas or involvement ūüôā

Happy JavaScripting!

How to Redirect to Custom Page After Completing a LearnDash Course

One of the features I recently finished for the my redesign of my JavaScript for WordPress site was to have users taken to a special page once they complete a course.

You can do this a number of ways, but here is how I did it:

 

1. Setup Congratulations Pages for Each Course

The first thing I¬†did was create a parent page called Congratulations with the url of “/congrats.”

Then I created Child Pages, one for each course.  Those pages looked something like this.

Screen Shot 2017-06-02 at 2.29.43 PM.png

You can see the badge displayed and the number of points earned (I use BadgeOS and BadgeOS LearnDash Add-on).

The most important thing I did was give each page the same slug as the course it is tied to.¬† If I didn’t do this, then the next step wouldn’t work as coded.

 

2. Add This Code to Your Functions.php

The next step was to find the LearnDash hook that fires when a LearnDash course completes.

Luckily there is a¬†learndash_course_completion_url hook that let’s return a URL and the redirect happens automatically.

This code gets the slug for the completed course and then creates a new URL string of “/congrats/course-slug.”

NOTE: This will only work if you you did these two things from Step 1.

  • Create a parent page with the URL slug of “congrats”
  • Create child pages for each course using the same URL slug as the course

 

Hope this Helps!

If you have a LearnDash account you can access the list of Action and Filter Hooks here.  Since that page is password protected, thought I would share this snippet with you.

Hope it helps!

Get Lesson Object for a Topic in LearnDash

While customizing LearnDash I came across an issue in the topic.php file where the $lesson_post variable was returning null even when there was a parent lesson for the topic.

So, after digging around at the LearnDash source code a bit I came up with this simple solution to grab the lesson whenever I needed using the topic post which is accessible via $post.

Not sure if others will find this helpful, but there are not a ton of extensive docs or articles on developing for LearnDash so wanted to share ūüôā

Local from Flywheel Saves Database SQL Files When Site is Stopped

I was recently following some troubleshooting steps for Local and removed the docker component that Local automatically sets up via an app called VirtualBox, which it installs during setup.

Right after I did this I realized that I may have also deleted all of the databases for my sites.  Turns out I did.

NOTE: If you remove a site in Local as part of testing, I suggest you do not delete the associated files as well (ie app/public etc).

Luckily, Local has a nice feature that automatically backs up all of your database tables whenever you stop a site.

Since Local stalled and wasn’t stopped properly, I did loose a little bit of data, but not too much ūüôā

Screen Shot 2017-05-17 at 2.15.18 AM.png

Thanks Clay and the Local folks for helping me figure this out (check out the forum post).

If you’ve been liking Local, but also¬†notice it freezes up or doesn’t work sometimes, I feel you ūüôā

I haven’t done this in the past, but I may look into a DB¬†backup solution for local dev just in case of things like this (my files I save via Dropbox).

LearnDash and WordPress Groups

Add User to LearnDash Group When Orders a WooCommerce Product

LearnDash and WordPress Groups

I love the LearnDash LMS for WordPress. ¬†I use it over at¬†javascriptforwp.com¬†and not only is it powerful out of the box and with plugins, but it’s hooks allow for even more.

One thing LearnDash cannot do out of the box is sell access to Groups via WooCommerce.

A Group in LearnDash, amongst other things, let’s you assign a¬†group of courses to a group¬†of users. ¬†You can add courses over time and those users will automatically get access.

For my JavaScript for WordPress Master Course I wanted to switch from one gigantic course (hundreds of lessons) to a bunch of smaller courses that I could also sell individually.

To do this I setup a new Group in LearnDash called “Master Course”¬†and¬†added my new smaller courses to it. ¬†I also created¬†a new¬†WooCommerce Virtual Product called “Master Course.”

Then I simply added this code to my functions.php:

Here is what this code does:

  • Hook into¬†WooCommerce when an order is marked complete
  • Checks to see if that order includes my Master Course¬†WooCommerce product
  • If so, it adds that user who purchased the product to my LearnDash group

It’s pretty simple and shows the power of hooks in¬†WordPress.

To customize this for your own use you would have to add the Group and Product IDs to the corresponding variables on line 5 and 7.

One thing this doesn’t do is remove a person from a group if they cancel or are¬†refunded the order, since this is something I wanted to do manually. ¬†However, you could easily do this by hooking into the¬†woocommerce_order_status_cancelled or¬†woocommerce_order_status_refunded hooks.

A big thanks to Justin from LearnDash and Ernest from UncannyOwl, who is working on a plugin that will also allow for this functionality.

Learning HTML, CSS, PHP, jQuery & Hosting via WordPress

A few years ago I spoke at at WordCamp Phoenix about how you can learn Web Design and Web Development via WordPress.

This holds as true today as it did then.

A lot of WordPress Pros learn design and development through WordPress

Check Out My Talk

Have You Learned Design & Development From WordPress?

Chances are if you are reading or watching this you have learned some of these technologies through your work with WordPress.

If so, would love to hear about it!