pfeifferNet

Manage_PHP_Log extends Manage_Log
in package

Manage the system PHP error log.

  • Add tab and form to pNet tools page.
  • View the log.
  • Clear the log - if permissions allow.
  • Handle AJAX interaction.
Tags
since
5.13.0
uses
Manage_Log

Table of Contents

Constants

ACTION  = 'pnet_clear_php_log'
The wp_ajax hook action properties.
CAPABILITY  = 'edit_others_posts'
The user capability required to view logs.
CLEAR_CAPABILITY  = 'manage_options'
The user capability required to clear logs.
FORM_NAME  = 'view_log'
The name attribute of the form.
HANDLER  = 'clearLog'
The name of the javascript handler for the form.
NONCE_NAME  = 'token'
The nonce name for the form.
TARGET_TAB  = 'php_log'
Target tools page tab for this tool.
TOOL_CONTAINER  = 'form-manage-log.php'
Tool container partial.

Properties

$can_clear  : bool
The can clear log flag.
$form_vars  : array<string|int, mixed>
The variables used to render the form.
$instances  : array<string|int, object>
The array of instances of this class and sub-classes.
$log_file  : string
Fully qualified path to the log file.
$tool_container  : string
Fully qualified path to the tool container partial.

Methods

get_action()  : string
Return the action name.
get_instance()  : object
Creates and/or returns the instance of this class.
handle_ajax_request()  : void
The AJAX call handler.
render()  : void
Render the tool.
set_script_vars()  : array<string|int, mixed>
Filter the array of tools javascript values.
set_tab()  : array<string|int, mixed>
Create the target tab on the tools page if it doesn't exist.
__construct()  : void
Initialise the class.
get_entries()  : array<string|int, mixed>
Get entries from log file.
get_tab_name()  : string
Return the tab name.
init_tool()  : void
Initialise the tool form with required values and assets.
set_file_path()  : void
Set log file fully qualifed path.

Constants

ACTION

The wp_ajax hook action properties.

protected string ACTION = 'pnet_clear_php_log'
Tags
since
5.13.0

CAPABILITY

The user capability required to view logs.

protected string CAPABILITY = 'edit_others_posts'
Tags
since
6.0.0

CLEAR_CAPABILITY

The user capability required to clear logs.

protected string CLEAR_CAPABILITY = 'manage_options'
Tags
since
6.0.0

FORM_NAME

The name attribute of the form.

protected string FORM_NAME = 'view_log'
Tags
since
5.13.0

HANDLER

The name of the javascript handler for the form.

protected string HANDLER = 'clearLog'
Tags
since
6.0.0

NONCE_NAME

The nonce name for the form.

protected string NONCE_NAME = 'token'
Tags
since
6.1.0

TARGET_TAB

Target tools page tab for this tool.

protected string TARGET_TAB = 'php_log'
Tags
since
5.13.0

TOOL_CONTAINER

Tool container partial.

protected string TOOL_CONTAINER = 'form-manage-log.php'
Tags
since
5.13.0

Properties

$can_clear

The can clear log flag.

protected bool $can_clear = false
Tags
since
6.0.0

$form_vars

The variables used to render the form.

protected array<string|int, mixed> $form_vars = array('title' => '', 'description' => '')
  • Each tool may have its own set of variables other than these.

{ Array of variables used to render the form. @type string $title The title of the form. @type string $description The description for the form. }

Tags
since
6.1.0

$instances

The array of instances of this class and sub-classes.

protected static array<string|int, object> $instances = array()
Tags
since
6.1.0

$log_file

Fully qualified path to the log file.

protected string $log_file = ''
Tags
since
5.13.0

$tool_container

Fully qualified path to the tool container partial.

protected string $tool_container = ''
Tags
since
6.1.0

Methods

get_instance()

Creates and/or returns the instance of this class.

public static get_instance() : object
Tags
since
6.1.0
Return values
object

The instance of this class.

handle_ajax_request()

The AJAX call handler.

public handle_ajax_request() : void
Tags
since
5.13.0
throws
Exception

Thrown if unable to write the log file.

render()

Render the tool.

public render([string $tab = '' ]) : void
  • The priority set on this hook will determine the tool sequence down the page.
Parameters
$tab : string = ''

The slug of the active tab on tools page.

Tags
since
6.1.0
see
Tools::render()

set_script_vars()

Filter the array of tools javascript values.

public set_script_vars([array<string|int, mixed> $script_vars = array() ]) : array<string|int, mixed>
  • This is hooked from the pnet_tools_vars filter.
Parameters
$script_vars : array<string|int, mixed> = array()

The existing tools values provided by the filter.

Tags
since
5.13.0
see
Tools::get_inline_script()
Return values
array<string|int, mixed>

The modified tools vars.

set_tab()

Create the target tab on the tools page if it doesn't exist.

public set_tab([array<string|int, mixed> $tabs = array() ]) : array<string|int, mixed>
  • The priority set on this hook will determine the tab sequence across the page.
Parameters
$tabs : array<string|int, mixed> = array()

A set of key/value pairs for the admin tools page.

Tags
since
6.1.0
see
Tools::render()
Return values
array<string|int, mixed>

The (maybe) modified tabs array.

__construct()

Initialise the class.

protected __construct() : void
Tags
since
5.13.0

get_entries()

Get entries from log file.

protected get_entries() : array<string|int, mixed>
Tags
since
5.13.0
Return values
array<string|int, mixed>

The log entries.

get_tab_name()

Return the tab name.

protected get_tab_name() : string
Tags
since
6.1.0
Return values
string

The display name of the tab for this tool.

init_tool()

Initialise the tool form with required values and assets.

protected init_tool() : void
Tags
since
6.1.0

set_file_path()

Set log file fully qualifed path.

protected set_file_path() : void
Tags
since
5.13.0

        
On this page

Search results