Skip to content
blobaugh edited this page Feb 7, 2013 · 11 revisions

Naming conventions

Prefix all wpet hooks with 'wpet'

Hooks should be named as similar to WordPress built-in hooks as possible to make it more clear as to what each does, E.G. admin_menu adds menus to wp-admin and wpet_admin_menu adds to the wp-admin Tickets menu

Administrative

wpet_admin_menu

Add/Remove submenu items from the Tickets menu in wp-admin.

Sends an array of menu items. Uses the same format as the WordPress add_submenu_page()

In WPET.class.php

Example

add_filter( 'wpet_admin_menu', $menu );
public function menu( $menu ) {
    $menu[] = array( 'asf', 'asf', 'add_users', 'asf', array( &$this, 'vtReporting' ) );
    return $menu;
}

wpet_admin_page_icon

Change the WPET logo for white labeling

Example

add_filter( 'wpet_admin_page_icon', 'update_icon' );
function( $icon ) {
   return '<a href="http://9seeds.com/" target="_blank"><div id="seeds-icon"></div></a>';
}

Adding/Updating data

Hooks that fire when adding or updating data

DATATYPE_add

Fires only for selected datatypes, such as wpet_attendees_add or wpet_coupons_add. Fires on both add and updates

Sends in an array of data to be stored in the database. An element named 'meta' may contain an array of post metadata that will automagically be added/updated as well.

Example

add_filter( 'wpet_coupons_add', 'add_coupon' );
function add_coupon( $coupons ) {
    $coupons[] = array(
       'post_name' => 'coupon-code',
       'post_title' => 'Coupon Name',
       'meta' => array(
                   'amount' => '5.00'
                   'type' => 'flat-rate',
                   'package' => 42
                 )
    );
    return $coupons;
}

wpet_add

Fires anytime anything is added/updated.

Sends in the array to be stored in the database. Uses standard post field. Any meta can be added as an array attached to the 'meta' element.

Example

 add_filter( 'wpet_add', 'do_stuff' );
 /* see DATATYPE_add for more code */

Currency

wpet_currencies

Add/Remove currencies that are available for use. This data is used to populate currency selection boxes. Payment gateways will update the list of valid currencies based upon which currencies are valid for use with the gateway.

Sends an array of arrays of currencies

Example

add_filter( 'wpet_currencies', 'set_currencies' );
function defaultCurrencies( $currencies ) {
	$currencies[] = array(
			'display' => 'United States Dollar',
			'code' => 'USD',
			'symbol' => '$',
			'location' => 'before',
			'dec_point' => '.',
			'thousands_sep' => ','
		);
	
            $currencies[] = array(
			'display' => 'Afghan Afghani',
			'code' => 'AFN',
			'symbol' => 'Afs',
			'location' => 'after',
			'dec_point' => '.',
			'thousands_sep' => ','
	    );
           return $currencies;

Instructions

wpet_instructions

Add instructions to the Instructions page in wp-admin

Sends an array of instruction items as an associative array containing elements title and text.

Each instructions should have a tab it belongs to, the display title for the new instructions section ( If left blank the instructions will show under the last heading printed ), and the instructions text

Example

add_filter( 'wpet_instructions', 'defaultInstructions' );
function defaultInstructions( $instructions ) {

    $instructions[] = array(
	'tab'	=> 'getting_started',
	'title' => 'Getting Started',
	'text'	=> 'This is how you start getting started :P'
    );
       return $instructions;
}

wpet_instructions_tabs

Builds the tabs for the instructions page, and sets up the computer friendly tab references

Sends an associative array of identifier => display values

Example

add_filter( 'wpet_instructions_tabs', 'setup_tabs' );
function defaultTabs( $tabs ) {
        $tabs['getting_started'] = 'Getting Started';
    $tabs['payment_gateways'] = 'Payment Gateways';
    $tabs['design'] = 'Design';
    $tabs['extras'] = 'Extras';

    return $tabs;
}

Settings

wpet_settings

Add settings to the Settings page in wp-admin

Sends an array of settings items as an associative array containing elements title and text.

Each setting should have a tab it belongs to, the display title for the new settings section ( If left blank the settings will show under the last heading printed ), and the settings text

Example

add_filter( 'wpet_settings', 'defaultSettings' );
function defaultSettings( $settings ) {

    $settings[] = array(
	'tab'	=> 'social_networks',
	'title' => 'Social Networks',
	'text'	=> 'Twitter Handle: <input ....'
    );
       return $settings;
}

wpet_settings_tabs

Builds the tabs for the settings page, and sets up the computer friendly tab references

Sends an associative array of identifier => display values

Example

add_filter( 'wpet_settings_tabs', 'setup_tabs' );
function setup_tabs( $tabs ) {
        $tabs['general'] = 'General';
    $tabs['social_networks'] = 'Social Networks';

    return $tabs;
}