Legislator Lookup WordPress Plugin

There is nothing better than building a tool that can be used by many people. We were approached by New Futures to build a website a few months ago for their Smart Start campaign. One of their requirements was a tool to help their visitors look up their state representatives. We accomplished this by building a plugin for WordPress which New Futures has agreed to allow us to release to the public. Their investment in this plugin will now increase in value every time someone uses this plugin! Download the zip, check out the code on GitLab

This plugin provides a set of shortcodes to build pages that look up US state representatives using Open State API data.

The [legislator-lookup] shortcode creates an address input field that uses Google Places API to auto complete addresses.

The [legislator-results] is used to display the results of the search.

Currently both shortcodes need to appear on the same page to function properly. Here’s what they look like in the editor:

The legislator-lookup shortcode accepts two attributes:

  • placeholder which changes the default text in the address input.
  • submitValue which changes the default submit button text.

The legislator-results shortcode accepts one attribute:

  • accordion which controls the representative result boxes appearing collapsed and opening one at a time. Default is true, set to false to disable.

The legislator-results is an “enclosing” tag, meaning it can be wrapped around content in the editor. Anything the shortcode wraps will appear next to the results. This can be used to give users a script to follow or some context for what to do after they search.

 

The post Legislator Lookup WordPress Plugin appeared first on Good Good Work.

Leave a Reply

Your email address will not be published. Required fields are marked *