Object_Sync_Sf_Logging extends WP_Logging
Object_Sync_Sf_Logging class.
Table of Contents
- $enabled : bool
- The setting value for whether logging is enabled
- $file : string
- The main plugin file
- $option_prefix : string
- The plugin's prefix when saving options to the database
- $schedule_name : string
- The name of the schedule to prune logs
- $slug : string
- The plugin's slug so we can include it when necessary
- $statuses_to_log : array<string|int, mixed>
- Which statuses to log, from the settings value
- $version : string
- Current version of the plugin
- $wpdb : object
- Global object of `$wpdb`, the WordPress database
- __construct() : mixed
- Constructor for logging class
- add() : int
- Create new log entry
- add_prune_interval() : array<string|int, mixed>
- Add interval to wp schedules based on admin settings
- check_log_schedule() : mixed
- When the cron settings change, clear the relevant schedule
- get_connected_logs() : array<string|int, mixed>
- Retrieve all connected logs
- get_log_count() : int
- Retrieves number of log entries connected to particular object ID
- get_logs() : array<string|int, mixed>
- Easily retrieves log items for a particular object ID
- get_schedule_frequency() : array<string|int, mixed>
- Convert the schedule frequency from the admin settings into an array interval must be in seconds for the class to use it
- posts_filter() : mixed
- Filter log posts by the taxonomy from the dropdown when a value is present
- restrict_logs_by_type() : mixed
- Add a filter form for the log admin so we can filter by wp_log_type taxonomy values
- save_log_schedule() : mixed
- Save a cron schedule
- set_log_slug() : string
- Create a (probably unique) post name for logs in a more performant manner than wp_unique_post_slug().
- set_log_types() : array<string|int, mixed>
- Set terms for Salesforce logs
- set_log_visibility() : array<string|int, mixed>
- Set visibility for the post type
- set_prune_age() : string
- Set how often to prune the Salesforce logs
- set_prune_args() : array<string|int, mixed>
- Set arguments for only getting the Salesforce logs
- set_prune_option() : string
- Should logs be pruned at all?
- setup() : void
- Setup new log entry
- sortable_columns() : array<string|int, mixed>
- Make the Type column in the posts admin for this post type sortable
- type_column() : array<string|int, mixed>
- Add a Type column to the posts admin for this post type
- type_column_content() : mixed
- Add the content for the Type column in the posts admin for this post type
- init() : mixed
- Initialize. This creates a schedule for pruning logs, and also the custom content type
Properties
$enabled
The setting value for whether logging is enabled
public
bool
$enabled
$file
The main plugin file
public
string
$file
$option_prefix
The plugin's prefix when saving options to the database
public
string
$option_prefix
$schedule_name
The name of the schedule to prune logs
public
string
$schedule_name
$slug
The plugin's slug so we can include it when necessary
public
string
$slug
$statuses_to_log
Which statuses to log, from the settings value
public
array<string|int, mixed>
$statuses_to_log
$version
Current version of the plugin
public
string
$version
$wpdb
Global object of `$wpdb`, the WordPress database
public
object
$wpdb
Methods
__construct()
Constructor for logging class
public
__construct() : mixed
Return values
mixed —add()
Create new log entry
public
static add([string $title = '' ][, string $message = '' ], int $parent[, string $type = 'salesforce' ]) : int
This is just a simple and fast way to log something. Use self::insert_log() if you need to store custom meta data
Parameters
- $title : string = ''
-
A log post title.
- $message : string = ''
-
The log message.
- $parent : int
-
The parent WordPress object.
- $type : string = 'salesforce'
-
The type of log message; defaults to 'salesforce'.
Tags
Return values
int —The ID of the new log entry
add_prune_interval()
Add interval to wp schedules based on admin settings
public
add_prune_interval(array<string|int, mixed> $schedules) : array<string|int, mixed>
Parameters
- $schedules : array<string|int, mixed>
-
An array of scheduled cron items.
Return values
array<string|int, mixed> —$frequency
check_log_schedule()
When the cron settings change, clear the relevant schedule
public
check_log_schedule(string $old_value, string $new_value, string $option) : mixed
Parameters
- $old_value : string
-
Previous option value.
- $new_value : string
-
New option value.
- $option : string
-
Name of option.
Return values
mixed —get_connected_logs()
Retrieve all connected logs
public
static get_connected_logs([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Used for retrieving logs related to particular items, such as a specific purchase.
Parameters
- $args : array<string|int, mixed> = array()
-
An array of arguments for get_posts().
Tags
Return values
array<string|int, mixed> —/ false
get_log_count()
Retrieves number of log entries connected to particular object ID
public
static get_log_count(int $object_id[, string $type = 'salesforce' ][, array<string|int, mixed> $meta_query = null ]) : int
Parameters
- $object_id : int
-
A WordPress object ID.
- $type : string = 'salesforce'
-
The type of log item; defaults to 'salesforce' because that's the type of logs we create.
- $meta_query : array<string|int, mixed> = null
-
A WordPress meta query, parseable by WP_Meta_Query.
Tags
Return values
int —get_logs()
Easily retrieves log items for a particular object ID
public
static get_logs(int $object_id[, string $type = 'salesforce' ][, int $paged = null ]) : array<string|int, mixed>
Parameters
- $object_id : int
-
A WordPress object ID.
- $type : string = 'salesforce'
-
The type of log item; defaults to 'salesforce' because that's the type of logs we create.
- $paged : int = null
-
show which page of results we want.
Tags
Return values
array<string|int, mixed> —get_schedule_frequency()
Convert the schedule frequency from the admin settings into an array interval must be in seconds for the class to use it
public
get_schedule_frequency(string $unit, string $number) : array<string|int, mixed>
Parameters
- $unit : string
-
A unit of time.
- $number : string
-
The number of those units.
Return values
array<string|int, mixed> —posts_filter()
Filter log posts by the taxonomy from the dropdown when a value is present
public
posts_filter(object $query) : mixed
Parameters
- $query : object
-
the current WP query for the list table.
Return values
mixed —restrict_logs_by_type()
Add a filter form for the log admin so we can filter by wp_log_type taxonomy values
public
restrict_logs_by_type(string $post_type) : mixed
Parameters
- $post_type : string
-
what type of log we want to show.
Return values
mixed —save_log_schedule()
Save a cron schedule
public
save_log_schedule() : mixed
Return values
mixed —set_log_slug()
Create a (probably unique) post name for logs in a more performant manner than wp_unique_post_slug().
public
set_log_slug(string $override_slug, string $slug, int $post_ID, string $post_status, string $post_type) : string
Parameters
- $override_slug : string
-
Short-circuit return value.
- $slug : string
-
The desired slug (post_name).
- $post_ID : int
-
The post ID.
- $post_status : string
-
The post status.
- $post_type : string
-
The post type.
Return values
string —set_log_types()
Set terms for Salesforce logs
public
set_log_types(array<string|int, mixed> $terms) : array<string|int, mixed>
Parameters
- $terms : array<string|int, mixed>
-
An array of string log types in the WP_Logging class.
Return values
array<string|int, mixed> —$terms
set_log_visibility()
Set visibility for the post type
public
set_log_visibility(array<string|int, mixed> $log_args) : array<string|int, mixed>
Parameters
- $log_args : array<string|int, mixed>
-
The post arguments.
Return values
array<string|int, mixed> —$log_args
set_prune_age()
Set how often to prune the Salesforce logs
public
set_prune_age(string $how_old) : string
Parameters
- $how_old : string
-
How old the oldest non-pruned log items should be allowed to be.
Return values
string —$how_old
set_prune_args()
Set arguments for only getting the Salesforce logs
public
set_prune_args(array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed>
-
Argument array for get_posts determining what posts are eligible for pruning.
Return values
array<string|int, mixed> —$args
set_prune_option()
Should logs be pruned at all?
public
set_prune_option(string $should_we_prune) : string
Parameters
- $should_we_prune : string
-
Whether to prune old log items.
Return values
string —$should_we_prune Whether to prune old log items.
setup()
Setup new log entry
public
setup(string|array<string|int, mixed> $title_or_params[, string $message = '' ], mixed $trigger, int $parent[, string $status = '' ]) : void
Check and see if we should log anything, and if so, send it to add()
Parameters
- $title_or_params : string|array<string|int, mixed>
-
A log post title, or the full array of parameters.
- $message : string = ''
-
The log message.
- $trigger : mixed
- $parent : int
-
The parent WordPress object.
- $status : string = ''
-
The log status.
Tags
Return values
void —sortable_columns()
Make the Type column in the posts admin for this post type sortable
public
sortable_columns(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>
-
the sortable columns for the post list table.
Return values
array<string|int, mixed> —$columns
type_column()
Add a Type column to the posts admin for this post type
public
type_column(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>
-
the columns for the post list table.
Return values
array<string|int, mixed> —$columns
type_column_content()
Add the content for the Type column in the posts admin for this post type
public
type_column_content(string $column_name, int $post_id) : mixed
Parameters
- $column_name : string
-
the value for the type column on the list table.
- $post_id : int
-
the ID of the currently listed post in the table.
Return values
mixed —init()
Initialize. This creates a schedule for pruning logs, and also the custom content type
private
init() : mixed