wp-e-commerce/WP-e-Commerce — pull request #1562 by benhuson (2014-10-08 09:04:26+00:00)
Title: Purchase Log Action Links API

Relating to issue #1445

Hopefully the below will give you enough of an overview to try it out.

All API links and AJAX requests are nonced based on the action and validated before firing the 'wpsc_purchase_log_action-(action)' and 'wpsc_purchase_log_action_ajax-(action)' hooks.

## How to create a link

Use the 'wpsc_purchlogitem_links' filter to add your link as a WPSC_Purchase_Log_Action_Link instance.
This is implemented as a filter so that you can reorder, remove, replace links if required.
(delete and back links are added later and cannot be removed)

The example below shows how to:

* add a basic link
* add a link using the callback API
* add a link using the AJAX callback API

```
add_query_arg( 'log_id', $log_id, 'http://example.com' ),
'dashicon' => 'dashicons-arrow-right-alt'
) );

// API link example
// All array attributes are optional. Below we're just added a dashicon
$links[] = new WPSC_Purchase_Log_Action_Link( 'my_wpsc_api_log_action', __( 'My API Action Link', 'wpsc' ), $log_id, array(
'dashicon' => 'dashicons-arrow-right-alt'
) );

// AJAX link example
// Just add an AJAX parameter set to true.
// If AJAX is not available when the link is clicked it will use the normal API callback instead
$links[] = new WPSC_Purchase_Log_Action_Link( 'my_wpsc_ajax_log_action', __( 'My AJAX Action Link', 'wpsc' ), $log_id, array(
'dashicon' => 'dashicons-arrow-right-alt',
'ajax' => true
) );

return $links;
}
add_filter( 'wpsc_purchlogitem_links', 'my_wpsc_purchlogitem_links', 10, 2 );

?>
```

## How to handle a link callback

The following would handle the API link example above.

```

```

## How to handle an AJAX link callback

The following would handle the AJAX link example above.

```

```