PHP Класс SimpleHistory

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$gettextLatestTranslations Used to store latest translations used by __() Required to automagically determine orginal text and text domain for calls like this SimpleLogger()->log( __("My translated message") );

Открытые методы

Метод Описание
__construct ( )
addWelcomeLogMessage ( ) Greet users to version 2! Is only called after database has been upgraded, so only on first install (or upgrade).
add_admin_bar_menu_item ( $wp_admin_bar ) Adds a "View history" item/shortcut to the admin bar
add_admin_bar_network_menu_item ( $wp_admin_bar ) Adds a "View history" item/shortcut to the network admin, on blogs where Simple History is installed
add_admin_pages ( ) Add pages (history page and settings page)
add_dashboard_widget ( ) Maybe add a dashboard widget, requires current user to have view history capability and a setting to show dashboard to be set
add_default_settings_tabs ( ) Adds default tabs to settings
add_js_templates ( $hook ) Output JS templated into footer
add_settings ( ) * Add setting sections and settings for the settings page Also maybe save some settings before outputing them
api ( ) Base url is: wp-admin/admin-ajax.php?action=simple_history_api
check_for_upgrade ( ) Check if plugin version have changed, i.e. has been upgraded If upgrade is detected then maybe modify database and so on for that version
clear_log ( ) Removes all items from the log
dashboard_widget_output ( ) Output html for the dashboard widget
does_database_have_data ( ) : boolean Check if the database has data/rows
ends_with ( string $haystack, string $needle ) Returns true if $haystack ends with $needle
enqueue_admin_scripts ( $hook ) Enqueue styles and scripts for Simple History but only to our own pages.
filter_gettext ( $translated_text, $untranslated_text, $domain ) During the load of info for a logger we want to get a reference to the untranslated text too, because that's the version we want to store in the database.
filter_gettext_storeLatestTranslations ( $translation, $text, $domain )
filter_gettext_with_context ( $translated_text, $untranslated_text, $context, $domain ) Store messages with context
filter_option_page_capability ( $capability )
getInstantiatedDropins ( )
getInstantiatedLoggerBySlug ( $slug = "" )
getInstantiatedLoggers ( )
getLogLevelTranslated ( string $loglevel ) : string Return translated loglevel
getLogRowDetailsOutput ( $row )
getLogRowHTMLOutput ( array $oneLogRow, $args ) : string Returns the HTML output for a log row, to be used in the GUI/Activity Feed
getLogRowHeaderOutput ( array $row ) : string Return header output for a log row Uses the getLogRowHeaderOutput of the logger that logged the row with fallback to SimpleLogger if logger is not available
getLogRowPlainTextOutput ( array $row ) : string Return plain text output for a log row Uses the getLogRowPlainTextOutput of the logger that logged the row with fallback to SimpleLogger if logger is not available
getLoggersThatUserCanRead ( integer $user_id = "", string $format = "array" ) : array Check which loggers a user has the right to read and return an array with all loggers they are allowed to read
getSettingsTabs ( )
get_avatar ( string $email, integer $size = '96', string $default = '', string $alt = false ) : string Retrieve the avatar for a user who provided a user ID or email address.
get_cache_incrementor ( $refresh = false ) : string https://www.tollmanz.com/invalidation-schemes/
get_clear_history_interval ( ) : integer How old log entried are allowed to be.
get_instance ( ) : SimpleHistory Get singleton intance
get_num_events_last_n_days ( $period_days = 28 ) Number of rows the last n days
get_num_events_per_day_last_n_days ( $period_days = 28 ) get_num_events_last_n_days
get_pager_size ( ) : integer Gets the pager size, i.e. the number of items to show on each page in the history
get_pager_size_dashboard ( ) : integer Gets the pager size, i.e. the number of items to show on each page in the history
get_unique_events_for_days ( $days = 7 ) Number of unique events the last n days
get_view_history_capability ( ) : string Return capability required to view history = for who will the History page be added
get_view_settings_capability ( ) : string Return capability required to view settings
history_page_output ( ) Output for page with the history
init ( )
is_on_our_own_pages ( $hook = "" )
json_encode ( $value ) Works like json_encode, but adds JSON_PRETTY_PRINT if the current php version supports it i.e. PHP is 5.4.0 or greated
load_dropins ( ) Load built in dropins from all files in /dropins and instantiates them
load_loggers ( ) Load built in loggers from all files in /loggers and instantiates them
load_plugin_textdomain ( ) Load language files.
maybe_purge_db ( ) Runs the purge_db() method sometimes We don't want to call it each time because it performs SQL queries
onAdminFooter ( )
onAdminHead ( )
on_filter_simple_history_log ( $message = null, array $context = null, string $level = "info" ) Log a message
output_quick_stats ( ) Quick stats above the log Uses filter "simple_history/history_page/before_gui" to output its contents
plugin_action_links ( $actions, $b, $c, $d ) Show a link to our settings page on the Plugins -> Installed Plugins screen
purge_db ( ) Removes old entries from the db
registerSettingsTab ( $arr_tab_settings )
register_dropin ( $dropinClassName ) Register an external dropin so Simple History knows about it.
register_logger ( $loggerClassName ) Register an external logger so Simple History knows about it.
setting_show_as_page ( ) : boolean Should simple history be shown as a page Defaults to true
setting_show_on_dashboard ( ) : boolean Get setting if plugin should be visible on dasboard.
settings_field_clear_log ( ) Settings section to clear database
settings_field_number_of_items ( ) Settings field for how many rows/items to show in log on the log page
settings_field_number_of_items_dashboard ( ) Settings field for how many rows/items to show in log on the dashboard
settings_field_where_to_show ( ) Settings field for where to show the log, page or dashboard
settings_output_general ( )
settings_output_log ( )
settings_output_styles_example ( )
settings_page_output ( ) Output HTML for the settings page Called from add_options_page
settings_section_output ( ) Content for section intro. Leave it be, even if empty.
setup_cron ( )
setup_variables ( ) Setup variables and things
testlog_old ( )

Приватные методы

Метод Описание
add_admin_actions ( )
getLogRowSenderImageOutput ( array $row ) : string

Описание методов

__construct() публичный Метод

public __construct ( )

addWelcomeLogMessage() публичный Метод

Not called after only plugin activation.

add_admin_bar_menu_item() публичный Метод

Useful because Simple History is something at least the author of this plugin often use on a site :)
С версии: 2.7.1
public add_admin_bar_menu_item ( $wp_admin_bar )

add_admin_bar_network_menu_item() публичный Метод

Useful because Simple History is something at least the author of this plugin often use on a site :)
С версии: 2.7.1
public add_admin_bar_network_menu_item ( $wp_admin_bar )

add_admin_pages() публичный Метод

Add pages (history page and settings page)
public add_admin_pages ( )

add_dashboard_widget() публичный Метод

Maybe add a dashboard widget, requires current user to have view history capability and a setting to show dashboard to be set

add_default_settings_tabs() публичный Метод

Adds default tabs to settings

add_js_templates() публичный Метод

Output JS templated into footer
public add_js_templates ( $hook )

add_settings() публичный Метод

* Add setting sections and settings for the settings page Also maybe save some settings before outputing them
public add_settings ( )

api() публичный Метод

Examples: http://playground-root.ep/wp-admin/admin-ajax.php?action=simple_history_api&posts_per_page=5&paged=1&format=html
public api ( )

check_for_upgrade() публичный Метод

Check if plugin version have changed, i.e. has been upgraded If upgrade is detected then maybe modify database and so on for that version
public check_for_upgrade ( )

clear_log() публичный Метод

Removes all items from the log
public clear_log ( )

dashboard_widget_output() публичный Метод

Output html for the dashboard widget

does_database_have_data() публичный Метод

Check if the database has data/rows
С версии: 2.1.6
public does_database_have_data ( ) : boolean
Результат boolean True if database is not empty, false if database is empty = contains no data

ends_with() публичный статический Метод

Returns true if $haystack ends with $needle
public static ends_with ( string $haystack, string $needle )
$haystack string
$needle string

enqueue_admin_scripts() публичный Метод

Only adds scripts to pages where the log is shown or the settings page.
public enqueue_admin_scripts ( $hook )

filter_gettext() публичный Метод

During the load of info for a logger we want to get a reference to the untranslated text too, because that's the version we want to store in the database.
public filter_gettext ( $translated_text, $untranslated_text, $domain )

filter_gettext_storeLatestTranslations() публичный Метод

public filter_gettext_storeLatestTranslations ( $translation, $text, $domain )

filter_gettext_with_context() публичный Метод

Store messages with context
public filter_gettext_with_context ( $translated_text, $untranslated_text, $context, $domain )

filter_option_page_capability() публичный Метод

public filter_option_page_capability ( $capability )

getInstantiatedDropins() публичный Метод

getInstantiatedLoggerBySlug() публичный Метод

public getInstantiatedLoggerBySlug ( $slug = "" )

getInstantiatedLoggers() публичный Метод

getLogLevelTranslated() публичный Метод

Return translated loglevel
С версии: 2.0.14
public getLogLevelTranslated ( string $loglevel ) : string
$loglevel string
Результат string translated loglevel

getLogRowDetailsOutput() публичный Метод

public getLogRowDetailsOutput ( $row )

getLogRowHTMLOutput() публичный Метод

Returns the HTML output for a log row, to be used in the GUI/Activity Feed
public getLogRowHTMLOutput ( array $oneLogRow, $args ) : string
$oneLogRow array SimpleHistoryLogQuery array with data from SimpleHistoryLogQuery
Результат string

getLogRowHeaderOutput() публичный Метод

Loggers are discouraged to override this in the loggers, because the output should be the same for all items in the gui
public getLogRowHeaderOutput ( array $row ) : string
$row array
Результат string

getLogRowPlainTextOutput() публичный Метод

Return plain text output for a log row Uses the getLogRowPlainTextOutput of the logger that logged the row with fallback to SimpleLogger if logger is not available
public getLogRowPlainTextOutput ( array $row ) : string
$row array
Результат string

getLoggersThatUserCanRead() публичный Метод

Check which loggers a user has the right to read and return an array with all loggers they are allowed to read
public getLoggersThatUserCanRead ( integer $user_id = "", string $format = "array" ) : array
$user_id integer Id of user to get loggers for. Defaults to current user id.
$format string format to return loggers in. Default is array. Can also be "sql"
Результат array

getSettingsTabs() публичный Метод

public getSettingsTabs ( )

get_avatar() публичный Метод

A modified version of the function that comes with WordPress, but we want to allow/show gravatars even if they are disabled in discussion settings
С версии: 2.0
public get_avatar ( string $email, integer $size = '96', string $default = '', string $alt = false ) : string
$email string email address
$size integer Size of the avatar image
$default string URL to a default image to use if no avatar is available
$alt string Alternative text to use in image tag. Defaults to blank
Результат string tag for the user's avatar

get_cache_incrementor() публичный статический Метод

https://www.tollmanz.com/invalidation-schemes/
public static get_cache_incrementor ( $refresh = false ) : string
$refresh bool
Результат string

get_clear_history_interval() публичный Метод

0 = don't delete old entries.
public get_clear_history_interval ( ) : integer
Результат integer Number of days.

get_instance() публичный статический Метод

Get singleton intance
public static get_instance ( ) : SimpleHistory
Результат SimpleHistory instance

get_num_events_last_n_days() публичный Метод

Number of rows the last n days
public get_num_events_last_n_days ( $period_days = 28 )

get_num_events_per_day_last_n_days() публичный Метод

get_num_events_last_n_days
public get_num_events_per_day_last_n_days ( $period_days = 28 )

get_pager_size() публичный Метод

Gets the pager size, i.e. the number of items to show on each page in the history
public get_pager_size ( ) : integer
Результат integer

get_pager_size_dashboard() публичный Метод

Gets the pager size, i.e. the number of items to show on each page in the history
С версии: 2.12
public get_pager_size_dashboard ( ) : integer
Результат integer

get_unique_events_for_days() публичный Метод

Number of unique events the last n days
public get_unique_events_for_days ( $days = 7 )

get_view_history_capability() публичный Метод

Return capability required to view history = for who will the History page be added
С версии: 2.1.5
public get_view_history_capability ( ) : string
Результат string capability

get_view_settings_capability() публичный Метод

Return capability required to view settings
С версии: 2.1.5
public get_view_settings_capability ( ) : string
Результат string capability

history_page_output() публичный Метод

Output for page with the history
public history_page_output ( )

init() публичный Метод

С версии: 2.5.2
public init ( )

is_on_our_own_pages() публичный Метод

public is_on_our_own_pages ( $hook = "" )

json_encode() публичный статический Метод

Works like json_encode, but adds JSON_PRETTY_PRINT if the current php version supports it i.e. PHP is 5.4.0 or greated
public static json_encode ( $value )
$value array|object|string|whatever that is json_encode'able

load_dropins() публичный Метод

Load built in dropins from all files in /dropins and instantiates them
public load_dropins ( )

load_loggers() публичный Метод

Load built in loggers from all files in /loggers and instantiates them
public load_loggers ( )

load_plugin_textdomain() публичный Метод

Uses the method described here: http://geertdedeckere.be/article/loading-wordpress-language-files-the-right-way
С версии: 2.0

maybe_purge_db() публичный Метод

Runs the purge_db() method sometimes We don't want to call it each time because it performs SQL queries
С версии: 2.0.17
public maybe_purge_db ( )

onAdminFooter() публичный Метод

public onAdminFooter ( )

onAdminHead() публичный Метод

public onAdminHead ( )

on_filter_simple_history_log() публичный Метод

Function called when running filter "simple_history_log"
С версии: 2.13
public on_filter_simple_history_log ( $message = null, array $context = null, string $level = "info" )
$context array Optional context to add to the logged data
$level string The loglevel. Must be one of the existing ones. Defaults to "info".

output_quick_stats() публичный Метод

Quick stats above the log Uses filter "simple_history/history_page/before_gui" to output its contents
public output_quick_stats ( )

purge_db() публичный Метод

Removes old entries from the db
public purge_db ( )

registerSettingsTab() публичный Метод

public registerSettingsTab ( $arr_tab_settings )

register_dropin() публичный Метод

Does not load the dropin, so file with dropin class must be loaded already. See example-dropin.php for an example on how to use this.
С версии: 2.1
public register_dropin ( $dropinClassName )

register_logger() публичный Метод

Does not load the logger, so file with logger class must be loaded already. See example-logger.php for an example on how to use this.
С версии: 2.1
public register_logger ( $loggerClassName )

setting_show_as_page() публичный Метод

Should simple history be shown as a page Defaults to true
public setting_show_as_page ( ) : boolean
Результат boolean

setting_show_on_dashboard() публичный Метод

Defaults to true
public setting_show_on_dashboard ( ) : boolean
Результат boolean

settings_field_clear_log() публичный Метод

Settings section to clear database

settings_field_number_of_items() публичный Метод

Settings field for how many rows/items to show in log on the log page

settings_field_number_of_items_dashboard() публичный Метод

Settings field for how many rows/items to show in log on the dashboard

settings_field_where_to_show() публичный Метод

Settings field for where to show the log, page or dashboard

settings_output_general() публичный Метод

settings_output_log() публичный Метод

public settings_output_log ( )

settings_output_styles_example() публичный Метод

settings_page_output() публичный Метод

Output HTML for the settings page Called from add_options_page

settings_section_output() публичный Метод

Called from add_sections_setting.

setup_cron() публичный Метод

public setup_cron ( )

setup_variables() публичный Метод

Setup variables and things
public setup_variables ( )

testlog_old() публичный Метод

public testlog_old ( )

Описание свойств

$gettextLatestTranslations публичное свойство

Used to store latest translations used by __() Required to automagically determine orginal text and text domain for calls like this SimpleLogger()->log( __("My translated message") );
public $gettextLatestTranslations