Skip to content

Instantly share code, notes, and snippets.

@paulgibbs
Created February 11, 2014 19:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulgibbs/0e72acf38d59ba111ca5 to your computer and use it in GitHub Desktop.
Save paulgibbs/0e72acf38d59ba111ca5 to your computer and use it in GitHub Desktop.
Base plugin/example extension for adding support for other plugins to the Achievements plugin for WordPress. https://wordpress.org/plugins/achievements/
<?php
/**
* Welcome to your first Achievements extension.
*
* Edit this base plugin, and then save it in /plugins/. You'll want to start by replacing
* the example class/function prefixes, and fill in the actions that you want to integrate
* into Achievements in the constructor's `$this->actions` array.
*
* For more information, see http://achievementsapp.com/developers/adding-other-plugins/.
* For support, post on https://wordpress.org/support/plugin/achievements/.
*
* Version 1.
*/
if ( ! defined( 'ABSPATH' ) ) exit;
// This safely loads your extension.
function pg_init_your_extension() {
achievements()->extensions->your_extension = new PG_Your_Extension;
// Tell the world that your custom extension is ready
do_action( 'pg_init_your_extension' );
}
add_action( 'dpa_ready', 'pg_init_your_extension' );
// This is the actual extension.
class PG_Your_Extension extends DPA_Extension {
public function __construct() {
/**
* Key/value pairs = action name/action description.
* Replace these with the actions that you want to add support for.
*/
$this->actions = array(
'eat_pizza' => __( 'The user eats a pizza', 'your_textdomain' ),
'eat_cakes' => __( 'The user eats all the cakes', 'your_textdomain' ),
);
/**
* These bits of information are important. `id` should be a short, unique string for the name of your extension or plugin.
* Don't include any spaces, punctuation, or other weird characters.
*
* Incrementing the version number won't do anything automatically. Look at the `do_update()` method in the `PG_Your_Extension` class.
*/
$this->id = 'your-plugin';
$this->version = 1;
// All the rest of this is information to populate the details for your plugin in the [wp-admin > Achievements > Supported Plugins] screen.
$this->contributors = array(
array(
'name' => 'Paul Gibbs',
'gravatar_url' => 'http://www.gravatar.com/avatar/3bc9ab796299d67ce83dceb9554f75df',
'profile_url' => 'http://profiles.wordpress.org/DJPaul/',
),
);
$this->description = __( 'This is a sample Achievements extension for a fake plugin called "your-plugin".', 'achievements' );
$this->name = __( 'Your Extension', 'your_textdomain' );
$this->image_url = trailingslashit( achievements()->includes_url ) . 'admin/images/buddypress.png';
$this->rss_url = 'http://buddypress.org/blog/feed/';
$this->small_image_url = trailingslashit( achievements()->includes_url ) . 'admin/images/buddypress-small.png';
$this->wporg_url = 'http://wordpress.org/plugins/your-extension/';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment