Extend the WPdeposit

Since WPdeposit version 1.8 a list of custom actions and filters are now available.

View the entire list. In this article I will go over the special, and probably most wanted, actions & filters.

Add a settings tab

To add a new settings tab in the WPdeposit plugin use the following hooks:

  • wpds_add_setting_tab_title_before or wpds_add_setting_tab_title_after (puts the tab in front or at the back of all the other tabs)
  • wpds_add_setting_tab_content

Example:

add_action('wpds_add_setting_tab_title_before', 'extwpds_add_settings_tab_title');
add_action('wpds_add_setting_tab_content', 'extwpds_add_settings_tab_content');
function extwpds_add_settings_tab_title(){        
	echo '<a id="tab_5" class="nav-tab" href="javascript:void(0);">New tab</a>';    
}
function extwpds_add_settings_tab_content(){        
	?>        
	<div class="tab_box box_tab_5">            
	lorem ipsum content goes here bla bla ....        
	</div><!-- .box_tab_4 -->        
	<?php    
}

Add a column in the transaction table

If you wish to add more data in the transition table use the following hooks:

  • wpds_add_backend_transaction_list_column_title
  • wpds_add_backend_transaction_list_column_content

Example:

add_action('wpds_add_backend_transaction_list_column_title', 'extwpds_add_col_title');        
add_action('wpds_add_backend_transaction_list_column_content', 'extwpds_add_col_content');
function extwpds_add_col_title(){        
	echo '<th>A new column</th>';    
}
function extwpds_add_col_content(){        
	echo '<td>lorem ipsum content column goes here</td>';    
}

Run code after bank transaction (pending payment)

If you wish to run some code when a bank payment is made you can use the following short code:

  • wpds_process_pending_bank_payment

Example:

add_action('wpds_process_pending_bank_payment', 'bank_pending_payment');
function bank_pending_payment(){
//run some code
}

Filters

How to add a new custom payment gateway

If you wish to add your own custom payment gateway you can use the following short code:

  • wpdeposit_payment_gateways

For this filter we wrote a more extensive article. View the tutorial.

Add extra fields to the current Payment Gateways

If you need extra fields for the current WPdeposit payment gateways like paypal you can use the following short codes:

  • wpds_update_gateway_settings
  • wpds_update_gateway_settings (action hook to save the new fields)

Example:

add_filter('wpds_paypal_form_fields', array($this, 'extwpds_add_extra_paypal_fields'));
add_action('wpds_update_gateway_settings', array($this, 'save_extra_paypal_fields'));

function extwpds_add_extra_paypal_fields($fields)    
{        
	if (isset($fields['fields'])) {            
		$fields['fields'][] = array(                
			'type' => 'textfield',                
			'name' => 'testfield',                
			'label' => 'Test Field',                
			'extra_options' => array('size' => 50, 'class' => 'input_field')            
		);        
	}        
	return $fields;    
}
function save_extra_paypal_fields($post)    {        
	//first you would normally need to validate the input        
	update_option(WPDEPOSIT_NAME . '_testfield', $post['testfield']);    
}