Tag Archives: wordpress

Shortcode Revolution for WordPress

During our work on various WordPress installations I have figured out that we repeatedly create (oh well, kind of copy/paste) layout elements, dynamic stuff like lightboxes and sliders, pieces of code in custom plugins, and so on.

Some of these codes slowly turned into a library so we decided to go ahead and package them into a new free plugin called Shortcode Revolution. (You can check it at our site or directly at the WordPress repo)

This is just a very first version so there is hopefully a lot more to come. But let’s have a brief look at what’s available:

Posts, Related Posts, and Comments

UI for posts / comments shortcode

This allows you to create widgets that contain posts related to a topic, searched by ID or tag, related to the currently shown post, and so on.

There are 3 handy layout modes: simple list, default (with a thumbnail and excerpt), and a carousel / slider.

And above this paragraph you see a slider / carousel of 3 posts related to this one.

Popup / Lightbox

modal box UI

This is such a frequent task, and this plugin really makes it easy. Just enter your contents, some clickable text and probably some custom CSS classes. Voila, the popup is created.

Click me!

Columns and Grids

Columns / Grids UI

I mean, it’s typical that the content on the web normally just stays in one column. But who said it should always be that?

Do you remember newsletters? I hope our readers are not all that young. Newsletters (the paper ones!) typically have content flowing in multuple columns. That’s not typical for the web not because it’s bad but because it was hard thing to do in the past.

Now with the new CSS techniques it’s not that hard. But you don’t always want to write CSS especially when you are writing a blog post, do you? This is where the columns shortcode comes handy!

The shortcode also allows you to create a grid. In the grid the content does not flow in the columns. Instead, each piece stays in its own grid cell. Like this:

Hey, I’m the first item

And I am number two

They can all be different

And can contain images (look right)

Chart from a personality quiz

This at left is from our quiz plugin WatuPRO

Third line, item 1

And number two

The ninth item goes here

Tabs

Tabs UI

Tabs allow you to place content within, well, tabs. What does it mean? Look at this:

As I told you, you can  arrange content in tabs 🙂 Just click on one of these tabs and you’ll see the content related to each one.
just a chartLet’s just have a chart here to look smart.

Buttons

Create buttons UI

There isn’t so much to explain here. You get an easy to use UI to create all kind of buttons.

Tables

create tables from CSV

This one is super simple – it creates table from an uploaded CSV file. Technically you can use a remove or a dynamic CSV as well – just replace the uploaded file URL with the remote one.

Tables aren’t that much fascinating – I am sure you have seem some! So no demo for this shortcode.

Flashcards / Flipcards

Create flashcard shortcodes

There cards have a front and a back side and reveal the back when the user clicks on them. Simple:

Here’s a Math task:

2 + 2*3?

Of course it’s 8 because multiplication has a higher priority than addition 🙂

Who is she?

Adriana Lima

You can even combine shortcodes together like I did above. I placed two flashcard shortcodes in a grid so they can be side by side.

Data Shortcodes

creating a data shortcode

They are excellent for creating profile pages in communities, author pages, widgets containing some user data, and so on.

Custom Shortcodes

Just any content that you may want in many places on your site. Custom HTML, shortcodes, media, formulas, whatever. Easily repeatable and editable in one place.

Enjoy the plugin – it’s free and can save you many hours of work. Let us know your feedback, feature requests, and bug reports (yes, even bug reports!).

Forget Moodle: WordPress Can Power Your Educational Portal (Updated 2021)

Updated in 2021: It’s surprising how many of the old plugins were no longer active. Things in the web change fast! I have updated this post with the most recent and updated alternatives.

No doubt Moodle is the standard open-source solution for building educational communities and portals. It’s been around for years, it has a huge community, regular updates and contributions. It’s really good.

But forget about it. Use WordPress.

I’m not writing this to bash Moodle. I appreciate the efforts that the community puts in it. Contributing to Moodle is in my plans as well. However, 90% of people who use it can achieve nearly the same functionality with WordPress and several plugins. Advantages?

  • WordPress is easier to install, update, and use
  • It has an even larger community and more contemporary interface
  • More free plugins
  • Easier to host (less demanding in resources)
  • A lot more premium plugins and themes
  • A lot more developers available for customization

Need I say anything else? Just look at the downloads – Moodle is more than 70MB zipped! Way too much code and stuff, maybe good, but you don’t need most. The latest WordPress installation file is just 15 MB at the moment.

The most important Moodle functions can be replaced with similar, sometimes better, free and premium WordPress plugins and/or themes. On top of that you can add some more of WordPress awesomeness – SEO plugins, caching plugins, tons of little widgets and so on. And, you can still host a regular blog along with the educational suite if you wish.

Here is how to replicate the most important Moodle functions in WordPress:

Courses

The core of Moodle is creating courses, assigning user groups to them, course reports, assignments. There are two great WordPress plugins that will handle this in one or another way:

TeachPress is properly maintained and up-to date plugin for creating courses with enrollments and publication management.  It has only one version that’s entirely free. Scroll down their site to see a bunch of screenshots and get an idea what you can do with it.

On the other hand if you want to run education suite that’s more of a community thing, you may want to first install BuddyPress. This thing is huge: it turns your WordPress site into a social network and then you can go further and extend it with more plugins and themes. (Right, this means to extend a plugin with plugins).  So once you extend WordPress with BuddyPress you can add educational capabilities with the great BuddyPress ScholarPress Courseware. It’s also fully open-source and free, well supported and frequently updated plugin. Allows managing courses, lectures, basic quizzes, assignments, and schedule calendars.

Now there is also the completely free Namaste! LMS which is also built by us. We have huge plans on it, so it’s worth taking a look!

Screenshots of Namaste! LMS

Namaste! LMS

If you are interested in further researching the LMS space, check this list from 2021.

As these all-in-one plugins sometimes don’t have exactly what you need and may be clumsy in some areas, there are more niche-ones that can handle individual tasks better.

Exams and Tests

This is the area where Watu comes in place (and sometimes you will prefer its premium version). Watu lets you create exams with single-choice, multiple-choices, or open-end questions. Assign grades, points, display results instantly. In the premium version you can also keep stats of the taken exams, limit by user group and categories, email user results, set times, assign certificates and so on.

WatuPRO Screenshot

The Pro version has more question types, advanced grading system, and so on. Regardless the very powerful features, it’s pretty easy to get started with:

You may also want to check Quiz and Survey Master which is probably less easy to use but has some interesting features.

Our Chained quiz has unique chained logic features so it’s worth having a look for some specific learning sites!

Assignments

One great plugin for handling assignments is Cleverness To-Do List. Tasks can be assigned to different users along with deadlines, various permissions etc. Regular assignments for whole groups can be handled by adding a post to a selected group and connecting it with an exam.

Of course don’t forget that BuddyPress ScholarPress Courseware also has assignments module, and Namaste! LMS has assignments built in (and can be used as requirements to complete a lesson.

Chat

Chat plugins are abundant. You can use a simple self-hosted and free solution like 3CX Live Chat or get rid off the hosting hassles  and subscribe for something like LiveChat or ChatRoll.

If you only need a pretty simple thing then install a shoutbox like Schreikasten or Buddypress-Ajax-Chat and you are all set.

Polls

Polls are useful not just for educational sites but also in marketing and sales, or any other site that needs to get user feedback. But for educational suite perhaps the most useful will be WP-Polls (free).

Now if you want to relate poll answers to users and extract more detailed stats you may prefer to use a plugin for creating exams or surveys. Watu Quiz can also be used for polls.

Forums

There is no shortage of solutions here as well. While BBPress is the standard choice, you may wish to check ForumPress or wpForo Forum which is more up to date.

You may notice I sometimes favor paid versions. This is not just to encourage paying for quality stuff and helping WordPress developers to do their great job. If you are running a site that makes money, spending few bucks on a premium plugin may help you stay over the competition by having something they don’t have. Premium plugins usually come with high-class support too and are more user-friendly (well, not always, but most of them are).

Glossary

Glossary is another thing you would want to do even if your site is not educational portal. But speaking about education sites,  GM Tooltip Glossary is one of the best choices. The core plugin is entirely free but has several premium add-ons that are very well worth the money. Custom taxonomies can be petty important for example for a more advanced education site.

The simpler Glossary by Codeat is also and excellent choice and probably simpler to use.

Resources

Moodle has a Resource module which can display different media types along with a lesson or course. WordPress itself can handle resource listings in many ways – the simplest is just to use the rich text editor in a post or page and link to various files or media. Because of this, there aren’t any notable plugins for handling on-page resources. If you plan to list external resources you may want to check some directory plugins. In most cases the WordPress itself is good enough to handle this functionality by its core.

Survey

Although close to exams and quizzes, surveys have slightly different purpose. So the best plugin for adding surveys is probably WP Survey And Quiz Tool. A simpler solution is again Watu Quiz (besides its primary purpose is exams) and especially WatuPRO which has very powerful reporting features (and more are coming!).

There is also a good comparison post at Kinsta featuring some more plugins.

Wiki

Wikis can be very useful in learning communities as your members can save you a tremendous amount of work. (I guess I’d need to create Wiki on this blog, so members can write about wikis. How meta!).

An excellent premium wiki plugin was available from WPMUdev but they have retired the plugins 🙂

A decent simple alternative is Yada Wiki from the official WordPress repository. The plugin is frequently updated and probably going to continue being active.

Encyclopedia / Glossary / Wiki is probably a good alternative if you also want to run a glossary and don’t like the other alternatives.

Workshop

There are plenty of ways to handle workshops and events. If you need a simple thing Simple Events Calendar might be your choice. However a lot more powerful alternative is The Events Calendar and the Registrations module by Roundup WP. These are super powerul plugins and no surprise they are the most popular ones in this area.

If your workshops involve webinars you may need to use some webinar software too. The only decent plugin I found is quite pricey so you may prefer to use some hosted webinars solution outside of WordPress.

Yes, Moodle fans, some of these features are more complicated and rich in Moodle. But most of us don’t need that. WordPress works in 90% or so of the cases and most webmasters are more comfortable with it.

Update in 2021: When I wrote this article first almost 9 years ago this was true. WordPress and its education related plugins have advanced so much (so proud that we have contributed as well!) that it’s questionable if Moodle is still more powerful. I am of course open to criticism here because I am not an active Moodle user.

As for Moodle, it’s a great stuff if you really need what it offers and have the patience to learn working with it.

How To Use WordPress Filters and Actions To Extend Plugins Functionality

There are two main ways to extend or customize existing WordPress plugin without editing the code directly – filters and actions (as a whole called “hooks”). The WordPress Codex does a good work of documenting the functions for actions and filters. It does not do such a good job in giving easy to understand example how to actually use this to do something useful. We are going to fix the problem with this tutorial.

Before going further you must have one thing in mind – the plugin that you are going to customize must be customization-friendly and offer at least some hooks. Example of such plugin is our Namaste! LMS with its Developer’s API. If you are writing a plugin it’s good to think about adding do_action and apply_filters calls on the most important places.

In this tutorial I’m going to use a couple of examples from Namaste! LMS and our other developer-friendly plugin WatuPRO to illustrate the usage of only the 4 most important action / filter functions:

  • do_action
  • add_action
  • apply_filters
  • add_filter

Let’s go!

Filters

The below chart will give you basic idea how filters work. Then we’ll provide some examples.

filters

Filters are used mostly when you want some content to be modified before displayed or sent to user. You can apply filters on text but not only – there are a lot more creative ways to use filters. Here are a couple examples from Namaste! LMS:

1. All the places where courses are selected to be shown to the user in Namaste! LMS have this hook:
$courses = apply_filters('namaste-reorder-courses', $courses);

What does it do? It allows other plugins to apply changes directly to the $courses array. And Namaste! PRO uses exactly this filter to apply the custom order of courses to the array by catching the filter:

add_filter( 'namaste-reorder-courses', array('NamastePROCourses', 'reorder_filter'));

There are several things that you must understand here:

a) The “source” plugin (the one that you will be customizing) must provide the proper filter by calling apply_filters($tag, $value) on the variable that will be modified. The first argument is the tag of the filter. It’s just unique name that will then be used by other plugins in the add_filter($tag, $function) call. When the name matches, the function defined in add_filter will be executed over the content of $value from apply_filters in the other plugin. Thus you can modify the $value (in our cases $value is the variable $courses).

b) The extending plugin must catch the filter with add_filter() call as explained above. But in order anything to happen the extending plugin should also define the function or method mentioned in the add_filter call (the second argument called $function). Look at the code again:

add_filter( 'namaste-reorder-courses', array('NamastePROCourses', 'reorder_filter'));

This means your customization plugin should have a class called NamastePROCourses with method called reorder_filter.

c) The apply_filters() call returns the modified $value which should also be returned by the function defined by add_filter(). It’s not important how exactly the method reorder_filter works but it must return the modified variable:

static function reorder_filter($courses) {
   // do something with $courses inside the method
   // not shown here

   return $courses; // return the modified variable
}

Only this way the $courses variable will be modified in the original plugin.

d) Multiple plugins can apply changes to the content using the same filter tag. So you can write your plugin that will for example add more properties to the $courses array, slice it, erase it, change it to something completely different and so on.

e) Do not rely on order of filters execution. When writing a custom plugin you should never assume that add_filter() calls from other plugins will be executed before or after your call.

f) If no filters are defined with add_filter for a given tag, then the apply_filters call will return the original variable.

2. As you saw from the above example, you can filter not just text but any kind of variable – in our case it was an array. The below example will demonstrate a smart trick using text. We need to allow external plugin to apply user-based restrictions to the SQL query that selects courses. instead of working with the courses array, we just use SQL variable string that will be applied to the query:

$filter_sql = '';
$filter_sql = apply_filters('namaste-course-select-sql', $filter_sql, $user_ID);

In the above example the variable $filter_sql (which is after that used inside the SQL query string) is first initialized as empty string. This way if no plugin defines add_filter on the namaste-course-select-sql tag, the string will remain empty and the query will remain as is. However if another plugin catches this filter and adds some SQL to it, the query which contains the $filter_sql variable will also be changed!

The above example also passes additional argument so the add_filter call needs two extra arguments:

add_filter( 'namaste-course-select-sql', array('NamastePROClass', 'course_select_sql'), 10, 2);

Check the add_filter documentation to understand why they are required.

Actions

Actions don’t return value and don’t let you modify variables but are probably even more powerful and easier to understand than filters. Actions let you notify other plugins that something in your plugin has happened. Then the other plugins can act based on it. You can also pass arguments to actions. The “source” plugin must call do_action($tag) and the receiving (customization) plugins must call add_action($tag, $function) with the same $tag to catch the action and call the $function. Here are a couple of examples:

1. Probably the most used action call in WatuPRO is the “waturpo_completed_exam” action called when a quiz is completed:

do_action('watupro_completed_exam', $taking_id);

This call sends the ID of the just taken quiz record so other plugins can use it. And they do. For example the Play Plugin catches this action to update user’s level, badges, points balance etc:

add_action('watupro_completed_exam', array($_user, 'update_meta'));

The variable $_user in this case is instance of the WatuPROPlayUser user object which has method update_meta. The method update_meta takes one argument – the taking ID – and does things with it:

function update_meta($taking_id){ /* do something here */}

Of course, just like with filters, the call to add_action must use the the same tag as the call to do_action to catch the action – in this case the tag is watupro_completed_exam.

2. Here’s a bit different example, this time from Namaste! LMS. At the end of creating the menu of the plugin we add the following simple do_action call, no arguments needed:

do_action('namaste_lms_admin_menu');

This lets other plugins hook their links under the Namaste! LMS menu so their extra options nicely align in it instead of creating more top-level menu links. This action is caught by Namaste! Reports, Namaste! Connect, Namaste! PRO, the InstaMojo integration plugin and many more. If you write your own plugin for Namaste! LMS I recommend using the same action (in case you need to add pages to the menu). Example call:

add_action('namaste_lms_admin_menu', array('NamastePRO', 'menu'));

Then the menu() function in NamastePRO class simply adds its own add_submenu_page() calls to add more links (note that the add_submenu_page() parent slug must also be properly defined).

Actions and filters give you huge options for customization and the best of it: without touching the code of the original plugin. Beautiful! Of course this is only possible if the original plugin defines do_action and add_filter calls in the proper places. If it doesn’t you can try to request the original developer to add some hoks. Most will not refuse because adding a hook here and there is not hard and makes the plugins easier to extend.

If there’s anything unclear in the above explanations, please ask in the comments.