Blog

Developing Plugins for Startups: Treato Case Study

This article is the first in a series of articles focused on WordPress plugin development for startups using GenerateWP tools. This time we will talk about Treato.com, a healthcare startup providing usable insights from aggregated patient experiences. We will learn how to develop a WordPress plugin meets the customer needs.

Introduction

So, I live in Israel. You may have heard that Israel is also called “The Startup Nation“. We have a very large and diverse tech industry with tens of thousands of startups.

As a WordPress developer, I provide development services to many local and global companies, from Israel and abroad. Most of the tools in GenerateWP have been developed following the work for my clients – to expedite the development process in my next projects.

In this series of posts, called “Developing Plugins for Startups”, I will show you how easy it is to develop WordPress plugins. Each time I will bring a case study based on a real project. In this post I will show you how I created a plugin for one of my oldest clients – Treato.com.

Why I choose to write about treato plugin? because WordPress 4.3 deprecated PHP4 style constructors, and I decided to rewrite the entire plugin using the newly introduced Widgets Generator. The entire process was so fast and easy, It took me no more than 30 minutes to create and test the plugin.

About Treato

Treato has a patented semantic technology aggregates health related content around the web to generate useful insights about users’ medications, diseases and symptoms. Basically, it’s a healthcare google, they collect and analyze patient experiences written in forums and blog posts.

With billions of collected posts in their system, patients can receive insight about side effects, drug comparisons, which drugs people feel work, and much more.

Treato Widget

Treato has a healthcare widget that can be embedded in external sites. The widget is a search engine that other sites can use in their sidebars. The widget makes it easier to search for drugs and medicines to see what patients are saying about different treatments, side-effects and so on.

Many sites use treato search widget. It’s free and easy to embed – it’s a simple iframe:

If you use this code in your site you will see treato search engine:

Treato Search
Treato Search

Treato WordPress Plugin

My task was to develop an easy-to-use WordPress Plugin. It was done using WordPress widget API, and built with Widgets Generator.

In addition to the simple search box, the plugin had to allow site owners to choose a default drug/medicine/condition as a search term, or to use the post title. On top of that, the plugin had to show a “powered by treato” link.

If you develop plugins for a living, you know that WordPress has strict rules about “powered by” links:

The plugin must not embed external links on the public site (like a “powered by” link) without explicitly asking the user’s permission. Any such options in the plugin must default to NOT show the link.

This means that the widget will have a checkbox asking user permission to show the “powered by treato” link. And the option will be OFF by default.

Widget Structure

Our sidebar widget will have 4 main fields:

  • Widget Title – text field.
  • Treato Search – multiple options: (1) Simple search box (2) Custom search result (3) Post Title.
  • Custom Search Result – text field.
  • Powered by – true/false checkbox.

The final result will be:

Treato Widget
Treato Widget

Widget Generator

Building the plugin with the Widget Generator is very easy – we will start with the general settings, then we will add the fields to the widgets back-end setting, and finally we will create the output code for the front-end.

Lets start with the basics – class name, prefix and text domain for translation strings:

Treato Widgets General Settings
Treato Widgets General Settings

Moving to the widget appearance in the back end – ID, title, description and class:

Treato Widget Appearance
Treato Widget Appearance

So far, we created a basic wrapper/container for the widget:

Treato Widget Preview
Treato Widget Preview

Defining the 1st field – widget title:

Treato Widget Field 1 - Widget Title
Treato Widget Field 1 – Widget Title

Defining the 2nd field – multiple options search term:

Treato Widget Field 2 - Search Term
Treato Widget Field 2 – Search Term

Defining the 3rd field – custom search result:

Treato Widget Field 3 - Custom Search Result
Treato Widget Field 3 – Custom Search Result

Defining the 4th field – Powered by checkbox.:

Treato Widget Field 4 - Powered by checkbox
Treato Widget Field 4 – Powered by checkbox

In two short minutes we finished creating the back-end form. The widget will look like this:

Treato Widget
Treato Widget

Lastly, we will add an output code for the front end:

Treato Widget Output Code
Treato Widget Output Code

The output code retrieves widget data from the database and present the treato widget on the site.

The final widget code generated by GenerateWP:

View snippet Clone snippet Download snippet

The plugin code with the header information can be found here. The entire plugin is available for download from the WordPress Plugin Repository.

The “Developing Plugins for Startups” Series

In the next posts in this series, I will present more case studies. In each new post I will select a different startup, write about their needs and teach you to use different tools to develop WordPress plugins. Hopefully, my case studies will help you on your projects.

I would love to hear your thoughts…

Rami Yushuvaev

I'm an entrepreneur, a web developer and a blogger. I’ve contributed code to each and every release since WordPress 2.8. I'm the Hebrew GTE responsible for the translation and the release of WordPress Hebrew version. The founder GenerateWP.com and several other WordPress related projects. I work mainly with Israeli startups, providing plugin development services.

Leave a Reply