PHP Class Give_Logging, Give

A general use class for logging events and errors.
Since: 1.0
ファイルを表示 Open project: wordimpress/give Class Usage Examples

Public Methods

Method Description
__construct ( ) : void Class Constructor
add ( string $title = '', string $message = '', integer $parent, string $type = null ) : integer Create new log entry
delete_logs ( integer $object_id, string $type = null, array $meta_query = null ) : void Delete Logs
get_connected_logs ( array $args = [] ) : array | false Retrieve all connected logs
get_log_count ( integer $object_id, string $type = null, array $meta_query = null, array $date_query = null ) : integer Retrieve Log Count
get_logs ( integer $object_id, string $type = null, integer $paged = null ) : array Get Logs
insert_log ( array $log_data = [], array $log_meta = [] ) : integer Stores a log entry
log_types ( ) : array Log Types
register_post_type ( ) : void Log Post Type
register_taxonomy ( ) : void Log Type Taxonomy
update_log ( array $log_data = [], array $log_meta = [] ) : boolean Update and existing log item
valid_type ( string $type ) : boolean Check if a log type is valid

Method Details

__construct() public method

Set up the Give Logging Class.
Since: 1.0
public __construct ( ) : void
return void

add() public method

This is just a simple and fast way to log something. Use $this->insert_log() if you need to store custom meta data.
Since: 1.0
public add ( string $title = '', string $message = '', integer $parent, string $type = null ) : integer
$title string Log entry title. Default is empty.
$message string Log entry message. Default is empty.
$parent integer Log entry parent. Default is 0.
$type string Log type. Default is null.
return integer Log ID.

delete_logs() public method

Remove log entries connected to particular object ID.
Since: 1.0
public delete_logs ( integer $object_id, string $type = null, array $meta_query = null ) : void
$object_id integer Log object ID. Default is 0.
$type string Log type. Default is null.
$meta_query array Log meta query. Default is null.
return void

get_connected_logs() public method

Used for retrieving logs related to particular items, such as a specific donation.
Since: 1.0
public get_connected_logs ( array $args = [] ) : array | false
$args array Query arguments.
return array | false Array if logs were found, false otherwise.

get_log_count() public method

Retrieves number of log entries connected to particular object ID.
Since: 1.0
public get_log_count ( integer $object_id, string $type = null, array $meta_query = null, array $date_query = null ) : integer
$object_id integer Log object ID. Default is 0.
$type string Log type. Default is null.
$meta_query array Log meta query. Default is null.
$date_query array Log data query. Default is null.
return integer Log count.

get_logs() public method

Retrieves log items for a particular object ID.
Since: 1.0
public get_logs ( integer $object_id, string $type = null, integer $paged = null ) : array
$object_id integer Log object ID. Default is 0.
$type string Log type. Default is null.
$paged integer Page number Default is null.
return array An array of the connected logs.

insert_log() public method

Stores a log entry
Since: 1.0
public insert_log ( array $log_data = [], array $log_meta = [] ) : integer
$log_data array Log entry data.
$log_meta array Log entry meta.
return integer The ID of the newly created log item.

log_types() public method

Sets up the default log types and allows for new ones to be created.
Since: 1.0
public log_types ( ) : array
return array $terms

register_post_type() public method

Registers the 'give_log' Post Type.
Since: 1.0
public register_post_type ( ) : void
return void

register_taxonomy() public method

Registers the "Log Type" taxonomy. Used to determine the type of log entry.
Since: 1.0
public register_taxonomy ( ) : void
return void

update_log() public method

Update and existing log item
Since: 1.0
public update_log ( array $log_data = [], array $log_meta = [] ) : boolean
$log_data array Log entry data.
$log_meta array Log entry meta.
return boolean True if successful, false otherwise.

valid_type() public method

Checks to see if the specified type is in the registered list of types.
Since: 1.0
public valid_type ( string $type ) : boolean
$type string Log type.
return boolean Whether log type is valid.