-
Notifications
You must be signed in to change notification settings - Fork 7
Hooks
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
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
add_filter( 'wpet_admin_menu', $menu );
public function menu( $menu ) {
$menu[] = array( 'asf', 'asf', 'add_users', 'asf', array( &$this, 'vtReporting' ) );
return $menu;
}
Change the WPET logo for white labeling
add_filter( 'wpet_admin_page_icon', 'update_icon' );
function( $icon ) {
return '<a href="http://9seeds.com/" target="_blank"><div id="seeds-icon"></div></a>';
}
Hooks that fire when adding or updating data
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.
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;
}
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.
add_filter( 'wpet_add', 'do_stuff' );
/* see DATATYPE_add for more code */
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
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;
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
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;
}
Builds the tabs for the instructions page, and sets up the computer friendly tab references
Sends an associative array of identifier => display values
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;
}
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
add_filter( 'wpet_settings', 'defaultSettings' );
function defaultSettings( $settings ) {
$settings[] = array(
'tab' => 'social_networks',
'title' => 'Social Networks',
'text' => 'Twitter Handle: <input ....'
);
return $settings;
}
Builds the tabs for the settings page, and sets up the computer friendly tab references
Sends an associative array of identifier => display values
add_filter( 'wpet_settings_tabs', 'setup_tabs' );
function setup_tabs( $tabs ) {
$tabs['general'] = 'General';
$tabs['social_networks'] = 'Social Networks';
return $tabs;
}