cp_action_gateway_values

This function executes in gateways/admin-gateway-values.php to allow gateways to hook into the admin gateway options.

To learn more about processing payments in ClassiPress, read this tutorial.

Usage

Your code should modify the global array $action_gateway_values;. This array is made up of instructions to ClassiPress of what to output. Each instruction contains a type parameter, as well as other properties based on the type.

<?php
function your_add_gateway_values(){
        global $action_gateway_values;
 
        $action_gateway_values = array(
            ....
        );
    }
    add_action( 'cp_action_gateway_values', 'bs_add_gateway_values' );

The available types are: tab, tabend, title, logo, text, select, checkbox, textarea, upload, logo, cat_checklist, price_per_cat, required_per_cat, notab, and notabend.

All of this data will be automatically saved to the database on submit, each field under the id attribute that you gave it. For instance, the follow field would be saved under the ‘your_option’ entry, and can be retrieved with get_option( 'your_option' );.

array('type' => 'text',
      'name' => __( 'Your Text Field', 'appthemes' ),
      'id' => 'your_option');

The other attributes for each entry are:

‘tip’ => Tooltip text
‘css’ => Inline styles to be applied to the field
‘req’ => 1 if required, 0 if not
‘min’ => Minimum number of characters allowed before saving data
‘js’ => Inline javascript
‘options’ => An array of dropdown options in value/name format

Checkout the example below to see how some of the types and attributes can be used.

Example: Simple Form

<?php
function bs_add_gateway_values(){
        global $action_gateway_values;
 
        $action_gateway_values = array(
            // Tab Start
            array( 'type' => 'tab',
                   'tabname' => __( 'BuyStuff', 'bs' ), 
                   'id' => ''),
            // Title
            array( 'type' => 'title',
                   'name' => __( 'BuyStuff Options', 'bs' ),
                   'id' => ''),
            // Logo/Picture
            array( 'type' => 'logo',
                   'name' => '<img src="src/to/logo.png" />',
                   'id' => ''),
            // Select Box
            array( 'type' => 'select',
                   'name' => __( 'Enable BuyStuff', 'bs' ),
                   'options' => array(  'yes' => __( 'Yes', 'bs' ),
                                        'no'  => __( 'No', 'bs')),
                   'desc' => __( 'You must have an active BuyStuff account.', 'bs' ),
                   'id' => 'bs_enable'),
            // Text Box
            array( 'type' => 'text',
                   'name' => __( 'BuyStuff Username', 'bs' ),
                   'desc' => __( 'Enter Your BuyStuff Username', 'bs' ),
                   'tip'  => __( 'This is your email address.', 'bs' ),
                   'id' => 'bs_username'),
            array( 'type' => 'tabend',
                   'id' => ''),
        );
    }
    add_action( 'cp_action_gateway_values', 'bs_add_gateway_values' );
?>

Changelog

  • since 1.1

Source File

cp_action_gateway_values()() is located in gateways/admin-gateway-values.php.

Your rating: none
Rating: 0 - 0 votes

Popular Add-ons

AdPoster Blocker

A simple but powerful plugin that blocks spammy new user regs and/or…


(5)
$19

2Checkout

Accept up to eight payment methods, fifteen languages, & twenty six…


(4)
$39

BetterMobile

Enhance the mobile experience of your ClassiPress website!


(3)
$10