We'll create fresh WordPress site with We The People installed. You have 20 minutes to test the plugin after that site we'll be deleted.
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 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.
The plugin includes a number of different ways to embed petitions from We The People:
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.
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.
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.
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:
Widgets: