We The People

plugin banner

Easily embed White House petitions from We The People into your WordPress site via shortcodes and widgets.

Author:Buckeye Interactive (profile at wordpress.org)
WordPress version required:3.5.1
WordPress version tested:4.1.40
Plugin version:2.0
Added to WordPress repository:01-06-2013
Last updated:25-01-2015
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:0
Rated by:0
Plugin URI:https://petitions.whitehouse.gov/
Total downloads:2 028
Active installs:10+
plugin download
Click to start download

In May 2013 the White House released an API for We The People, a petition application designed to give citizens a direct line to the White House. The White House has committed to issue an official, public response to petitions that cross a particular signature threshold.

This plugin allows WordPress site owners to search and embed petitions from We The People into WordPress. Perhaps you’re writing an opinion piece on a petition and want real-time statistics on signatures and any response from the White House. Maybe you’re a supporter of a particular issue and want to feature it on your sidebar to help promote awareness. The ease of WordPress with the totally customizable templates of the We The People plugin give you the power to share what’s important to you.

Special thanks

Special thanks goes out to the White House web team for building and opening the We The People API for the general public and for inviting Buckeye Interactive to the National Day of Civic Hacking to premiere this plugin.

Usage

The plugin includes a number of different ways to embed petitions from We The People:

Shortcodes

The simplest way to get started is through WordPress shortcodes. The syntax is as easy as: [wtp-petition id="123"].

Petitions IDs aren’t especially easy to uncover from the We The People site so the We The People plugin includes a TinyMCE button to help you. Clicking the button will open an overlay that will let you search the We The People petitions by title to find your issue. You may also limit your search results to open petitions.

Widget

To add a We The People petition to a WordPress dynamic sidebar go to Appearance > Widgets and drag a “WTP Petition” widget into the desired sidebar. Like the TinyMCE button the widget allows you to search for your desired petition by title and show only open petitions.

$GLOBALS[‘we-the-people’] global variable (advanced)

If you’re a developer and need more complete access to the We The People API you can use the api() method available through the $GLOBALS['we-the-people'] global variable. The api() method accepts two arguments: the API method to call (‘retrieve’ or ‘index’ in version 1.*) and an array of arguments to pass to the API.

Note: Before version 2.0, the plugin used a global $we_the_people variable. If you did customizations to We The People templates you’ll want to be sure to update this reference.

Full API documentation is available on the We The People API page. More developer-oriented documentation can be found in this plugin’s GitHub repository.

Styling the petition display

We The People has a built-in petition template but makes it easy to override in your theme. It may be easiest to copy templates/wtp-petition.php into your theme to get started but a very basic custom template might look something like this:

<div id="wtp-petition-<?php echo $petition->id; ?>" class="wtp-petition">
  <h2 class="petition-title"><?php echo $petition->title; ?></h2>
  <p>
    <strong><?php printf( __( '%d signatures.', 'my-theme' ), $petition->signaturesNeeded ); ?></strong>
    <a href="<?php echo $petition->url; ?>" title="<?php echo esc_attr( __( 'Sign this petition on We The People', 'we-the-people' ) ); ?>" class="sign-btn" rel="external"><?php _e( 'Sign this petition' ); ?></a>
  </p>
</div><!-- #wtp-petition-<?php echo $petition->id; ?> -->

We The People uses the following order to determine which template to use when displaying a petition:

Shortcodes:

  1. wtp-petition-{id}.php (child theme)
  2. wtp-petition.php (child theme)
  3. wtp-petition-{id}.php (parent theme)
  4. wtp-petition.php (parent theme)
  5. templates/wtp-petition.php (plugin)

Widgets:

  1. wtp-petition-widget-{id}.php (child theme)
  2. wtp-petition-widget.php (child theme)
  3. wtp-petition-widget-{id}.php (parent theme)
  4. wtp-petition-widget.php (parent theme)
  5. templates/wtp-petition-widget.php (plugin)

FAQ
ChangeLog