From 66643e14af6d261a165d80093adc0f4a59dc0501 Mon Sep 17 00:00:00 2001 From: John Godley Date: Mon, 25 May 2015 10:00:38 +0100 Subject: [PATCH] Update readme --- audit-trail.php | 4 +- models/audit.php | 12 +- plugin.php | 333 ----------------------------------------------- readme.txt | 12 +- 4 files changed, 15 insertions(+), 346 deletions(-) delete mode 100644 plugin.php diff --git a/audit-trail.php b/audit-trail.php index e48ca8f..db58aa0 100644 --- a/audit-trail.php +++ b/audit-trail.php @@ -28,7 +28,6 @@ define( 'AUDIT_TRAIL_VERSION', '0.3' ); - /** * Audit Trail plugin * @@ -36,7 +35,8 @@ **/ class Audit_Trail { - var $auditor; + private static $instance = null; + private $auditor; static function init() { if ( is_null( self::$instance ) ) { diff --git a/models/audit.php b/models/audit.php index d164904..67f1a59 100644 --- a/models/audit.php +++ b/models/audit.php @@ -21,12 +21,12 @@ **/ class AT_Audit { - var $happened_at; - var $id; - var $operation; - var $ip; - var $item_id; - var $user_id; + public $happened_at; + public $id; + public $operation; + public $ip; + public $item_id; + public $user_id; /** * Constructor accepts an array of values with which to seed the object diff --git a/plugin.php b/plugin.php deleted file mode 100644 index 88c5e86..0000000 --- a/plugin.php +++ /dev/null @@ -1,333 +0,0 @@ -Display Rendering - * The class uses a similar technique to Ruby On Rails views, whereby the display HTML is kept - * in a separate directory and file from the main code. A display is 'rendered'(sent to the browser) - * or 'captured'(returned to the calling function). - * - * Template files are separated into two areas: admin and user. Admin templates are only for display in - * the WordPress admin interface, while user templates are typically for display on the site(although neither - * of these are enforced). All templates are PHP code, but are referred to without .php extension. - * - * The reason for this separation is that one golden rule of plugin creation is that someone will always want to change - * the formatting and style of your output. Rather than forcing them to modify the plugin(bad), or modify files within - * the plugin(equally bad), the class allows user templates to be overridden with files contained within the theme. - * - * An additional benefit is that it leads to code re-use, especially with regards to Ajax(i.e. your display code can be called from - * many locations) - * - * Template files are located within the 'view' subdirectory of the plugins base(specified when registering the plugin): - * - *
myplugin/view/admin
- * myplugin/view/myplugin
- * - * Admin templates are contained within 'admin', and user templates are contained within a directory of the same name as the plugin. - * - * User files can be overridden within the theme by creating a similar directory structure: - * - *
/themes/mytheme/view/myplugin
- * - * The class will first look in the theme and then defaults to the plugin. A plugin should always provide default templates. - * - *

Display Parameters

- * Also similar to Ruby On Rails, when you display a template you must supply the parameters that the template has access to. This tries - * to ensure a very clean separation between code and display. Parameters are supplied as an associative array mapping variable name to variable value. - * - * For example, - * - * array( 'message' => 'Your data was processed', 'items' => 103); - * - *

How it works in practice

- * You create a template file to display how many items have been processed. You store this in 'view/admin/processed.php': - * - *
<p>You processed <?php echo $items ?> items</p>
- * - * When you want to display this in your plugin you use: - * - *
 $this->render_admin( 'processed', array( 'items' => 100));
- * - * @package WordPress base library - * @author John Godley - * @copyright Copyright(C) John Godley - **/ - -class AT_Plugin { - /** - * Plugin name - * @var string - **/ - var $plugin_name; - - /** - * Plugin 'view' directory - * @var string Directory - **/ - var $plugin_base; - - /** - * Version URL(if enabled) - * @var string URL - **/ - var $version_url; - - /** - * Register your plugin with a name and base directory. This must be called once. - * - * @param string $name Name of your plugin. Is used to determine the plugin locale domain - * @param string $base Directory containing the plugin's 'view' files. - * @return void - **/ - function register_plugin( $name, $base ) { - $this->plugin_base = rtrim( dirname( $base ), '/' ); - $this->plugin_name = $name; - - $this->add_action( 'init', 'load_locale' ); - } - - /** - * Hook called to change the locale directory - * @return void - **/ - function load_locale() { - // Here we manually fudge the plugin locale as WP doesnt allow many options - $locale = get_locale(); - if( empty( $locale ) ) - $locale = 'en_US'; - - $mofile = dirname( __FILE__ )."/locale/$locale.mo"; - load_textdomain( $this->plugin_name, $mofile ); - } - - - /** - * Register a WordPress action and map it back to the calling object - * - * @param string $action Name of the action - * @param string $function Function name(optional) - * @param int $priority WordPress priority(optional) - * @param int $accepted_args Number of arguments the function accepts(optional) - * @return void - **/ - function add_action( $action, $function = '', $priority = 10, $accepted_args = 1 ) { - add_action( $action, array( &$this, $function == '' ? $action : $function ), $priority, $accepted_args ); - } - - - /** - * Register a WordPress filter and map it back to the calling object - * - * @param string $action Name of the action - * @param string $function Function name(optional) - * @param int $priority WordPress priority(optional) - * @param int $accepted_args Number of arguments the function accepts(optional) - * @return void - **/ - function add_filter( $filter, $function = '', $priority = 10, $accepted_args = 1 ) { - add_filter( $filter, array( &$this, $function == '' ? $filter : $function ), $priority, $accepted_args ); - } - - - /** - * Special activation function that takes into account the plugin directory - * - * @param string $pluginfile The plugin file location(i.e. __FILE__) - * @param string $function Optional function name, or default to 'activate' - * @return void - **/ - function register_activation( $pluginfile, $function = '' ) { - add_action( 'activate_'.basename( dirname( $pluginfile ) ).'/'.basename( $pluginfile ), array( &$this, $function == '' ? 'activate' : $function ) ); - } - - function register_ajax( $action, $function = '', $priority = 10 ) { - add_action( 'wp_ajax_'.$action, array( &$this, $function == '' ? $action : $function ), $priority ); - } - - /** - * Special deactivation function that takes into account the plugin directory - * - * @param string $pluginfile The plugin file location(i.e. __FILE__) - * @param string $function Optional function name, or default to 'deactivate' - * @return void - **/ - function register_deactivation( $pluginfile, $function = '' ) { - add_action( 'deactivate_'.basename( dirname( $pluginfile ) ).'/'.basename( $pluginfile ), array( &$this, $function == '' ? 'deactivate' : $function ) ); - } - - function register_plugin_settings( $pluginfile, $function = '' ) { - add_action( 'plugin_action_links_'.basename( dirname( $pluginfile ) ).'/'.basename( $pluginfile ), array( &$this, $function == '' ? 'plugin_settings' : $function ), 10, 4 ); - } - - /** - * Renders an admin section of display code - * - * @param string $ug_name Name of the admin file(without extension) - * @param string $array Array of variable name=>value that is available to the display code(optional) - * @return void - **/ - function render_admin( $ug_name, $ug_vars = array() ) { - global $plugin_base; - - foreach ( $ug_vars AS $key => $val ) { - $$key = $val; - } - - if ( file_exists( "{$this->plugin_base}/view/admin/$ug_name.php" ) ) - include "{$this->plugin_base}/view/admin/$ug_name.php"; - else - echo "

Rendering of admin template {$this->plugin_base}/view/admin/$ug_name.php failed

"; - } - - /** - * Renders a section of user display code. The code is first checked for in the current theme display directory - * before defaulting to the plugin - * - * @param string $ug_name Name of the admin file(without extension) - * @param string $array Array of variable name=>value that is available to the display code(optional) - * @return void - **/ - function render( $ug_name, $ug_vars = array() ) { - foreach ( $ug_vars AS $key => $val ) { - $$key = $val; - } - - if ( file_exists( TEMPLATEPATH."/view/{$this->plugin_name}/$ug_name.php" ) ) - include TEMPLATEPATH."/view/{$this->plugin_name}/$ug_name.php"; - elseif ( file_exists( "{$this->plugin_base}/view/{$this->plugin_name}/$ug_name.php" ) ) - include "{$this->plugin_base}/view/{$this->plugin_name}/$ug_name.php"; - else - echo "

Rendering of template $ug_name.php failed

"; - } - - /** - * Renders a section of user display code. The code is first checked for in the current theme display directory - * before defaulting to the plugin - * - * @param string $ug_name Name of the admin file(without extension) - * @param string $array Array of variable name=>value that is available to the display code(optional) - * @return void - **/ - function capture( $ug_name, $ug_vars = array() ) { - ob_start(); - - $this->render( $ug_name, $ug_vars ); - $output = ob_get_contents(); - - ob_end_clean(); - return $output; - } - - /** - * Captures an admin section of display code - * - * @param string $ug_name Name of the admin file(without extension) - * @param string $array Array of variable name=>value that is available to the display code(optional) - * @return string Captured code - **/ - function capture_admin( $ug_name, $ug_vars = array() ) { - ob_start(); - - $this->render_admin( $ug_name, $ug_vars ); - $output = ob_get_contents(); - - ob_end_clean(); - return $output; - } - - /** - * Display a standard error message(using CSS ID 'message' and classes 'fade' and 'error) - * - * @param string $message Message to display - * @return void - **/ - function render_error( $message ) { - ?> -
-

-
- -
-

-
- tags - * - * @param string $name Name of your plugin. Is used to determine the plugin locale domain - * @param string $base Directory containing the plugin's 'view' files. - * @return void - **/ -if ( !function_exists( 'pr' ) ) { - function pr( $thing ) { - echo '
';
-		print_r( $thing );
-		echo '
'; - } -} diff --git a/readme.txt b/readme.txt index ba9dd20..f64c859 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: johnny5 Donate link: http://urbangiraffe.com/contact/#donate Tags: admin, audit, log, version, diff -Requires at least: 3.1 -Tested up to: 4.1 +Requires at least: 3.5 +Tested up to: 4.2 Stable tag: trunk Audit Trail is a plugin to keep track of what is going on inside your blog by monitoring administration functions. @@ -52,6 +52,11 @@ Full documentation can be found on the [Audit Trail Page](http://urbangiraffe.co == Changelog == += 1.2.2 = +* Fix double-serialization of audit data +* Fix ignore user 0 to ignore all anonymous users +* Small code cleanup + = 1.2.1 = * Refresh for WP 4 * Italian translation by Massimiliano @@ -161,6 +166,3 @@ Full documentation can be found on the [Audit Trail Page](http://urbangiraffe.co = 0.1 = * Initial release - - -