开发者 |
BuckeyeInteractive
stevegrunwell |
---|---|
更新时间 | 2015年1月25日 10:24 |
捐献地址: | 去捐款 |
PHP版本: | 3.5.1 及以上 |
WordPress版本: | 3.6.1 |
版权: | GPLv2 or later |
[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 "Insert We The People Petition" button will open an overlay that will let you search the We The People petitions by title to find your issue.
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.
$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 $we_the_people
global variable. The api()
method accepts two arguments: the API method to call ('retrieve' or 'index' in version 1.0) and an array of arguments to pass to the API.
Documentation and code samples for the $we_the_people->api()
method can be found on this plugin's Github page.
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: title; ?> signaturesNeeded ); ?> We The People uses the following order to determine which template to use when displaying a petition: Shortcodes:
The We The People stylesheet and JavaScript file are enqueued in typical WordPress fashion when the plugin is loaded on WordPress init
. Dropping this function in your WordPress theme should prevent the default We The People assets from loading:
/*
* Prevent We The People from loading scripts and styles
* @uses wp_dequeue_script()
* @uses wp_dequeue_style()
/
function mytheme_disable_wtp_scripts_styles() {
wp_dequeue_script( 'we-the-people' );
wp_dequeue_style( 'we-the-people' );
}
add_action( 'init', 'mytheme_disable_wtp_scripts_styles' );
At this time the We The People API is read-only, meaning your readers would need to visit https://petitions.whitehouse.gov in order to sign a petition. The White House plans to release a write API sometime in the near future at which point this plugin will be upgraded to enable this capability.