Crazy Bone - Version 0.5.1

Version Description

Download this release

Release Info

Developer wokamoto
Plugin Icon wp plugin Crazy Bone
Version 0.5.1
Comparing to
See all releases

Code changes from version 0.5.0 to 0.5.1

Files changed (3) hide show
  1. plugin.php +17 -1
  2. readme.txt +5 -1
  3. uninstall.php +1 -0
plugin.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Crazy Bone
4
  Plugin URI: https://github.com/wokamoto/crazy-bone
5
  Description: Tracks user name, time of login, IP address and browser user agent.
6
  Author: wokamoto
7
- Version: 0.5.0
8
  Author URI: http://dogmap.jp/
9
  Text Domain: user-login-log
10
  Domain Path: /languages/
@@ -41,6 +41,7 @@ class crazy_bone {
41
  const TEXT_DOMAIN = 'user-login-log';
42
  const LIST_PER_PAGE = 20;
43
  const DEBUG_MODE = false;
 
44
 
45
  const ADMIN_MENU_CAPABILITY = 'level_0';
46
 
@@ -53,6 +54,7 @@ class crazy_bone {
53
  private $ull_table = 'user_login_log';
54
  private $admin_action;
55
  private $plugin_version;
 
56
 
57
  static $instance;
58
 
@@ -67,6 +69,12 @@ class crazy_bone {
67
  $data = get_file_data(__FILE__, array('version' => 'Version'));
68
  $this->plugin_version = isset($data['version']) ? $data['version'] : '';
69
 
 
 
 
 
 
 
70
  add_action('wp_login', array($this, 'user_login_log'), 10, 2);
71
  add_action('wp_authenticate', array($this, 'wp_authenticate_log'), 10, 2);
72
  add_action('login_form_logout', array($this, 'user_logout_log'));
@@ -90,11 +98,15 @@ class crazy_bone {
90
  public function activate(){
91
  global $wpdb;
92
 
 
 
 
93
  if ($wpdb->get_var("show tables like '{$this->ull_table}'") != $this->ull_table)
94
  $this->create_table();
95
  }
96
 
97
  public function deactivate(){
 
98
  }
99
 
100
  private function create_table(){
@@ -119,6 +131,9 @@ CREATE TABLE `{$this->ull_table}` (
119
  KEY `country_code` (`country_code`)
120
  )");
121
  }
 
 
 
122
  }
123
 
124
  public function enqueue_scripts(){
@@ -842,6 +857,7 @@ if ($errors != 'invalid_username')
842
  if (!empty($status))
843
  $sql .= $wpdb->prepare(" AND `activity_status` = %s", $status);
844
  $sql .= " GROUP BY `user_id`, `user_login`, `activity_status`, `activity_errors`";
 
845
  $total = intval($wpdb->get_var("SELECT count(*) from ({$sql}) as log"));
846
 
847
  // Pagination
4
  Plugin URI: https://github.com/wokamoto/crazy-bone
5
  Description: Tracks user name, time of login, IP address and browser user agent.
6
  Author: wokamoto
7
+ Version: 0.5.1
8
  Author URI: http://dogmap.jp/
9
  Text Domain: user-login-log
10
  Domain Path: /languages/
41
  const TEXT_DOMAIN = 'user-login-log';
42
  const LIST_PER_PAGE = 20;
43
  const DEBUG_MODE = false;
44
+ const OPTION_NAME = 'user-login-log';
45
 
46
  const ADMIN_MENU_CAPABILITY = 'level_0';
47
 
54
  private $ull_table = 'user_login_log';
55
  private $admin_action;
56
  private $plugin_version;
57
+ private $options;
58
 
59
  static $instance;
60
 
69
  $data = get_file_data(__FILE__, array('version' => 'Version'));
70
  $this->plugin_version = isset($data['version']) ? $data['version'] : '';
71
 
72
+ $this->options = get_option( self::OPTION_NAME, array() );
73
+ if (!is_array($this->options))
74
+ $this->options = array('installed' => false);
75
+ if (!isset($this->options['installed']) || !$this->options['installed'])
76
+ $this->activate();
77
+
78
  add_action('wp_login', array($this, 'user_login_log'), 10, 2);
79
  add_action('wp_authenticate', array($this, 'wp_authenticate_log'), 10, 2);
80
  add_action('login_form_logout', array($this, 'user_logout_log'));
98
  public function activate(){
99
  global $wpdb;
100
 
101
+ if (isset($this->options['installed']) && $this->options['installed'])
102
+ return;
103
+
104
  if ($wpdb->get_var("show tables like '{$this->ull_table}'") != $this->ull_table)
105
  $this->create_table();
106
  }
107
 
108
  public function deactivate(){
109
+ delete_option( self::OPTION_NAME );
110
  }
111
 
112
  private function create_table(){
131
  KEY `country_code` (`country_code`)
132
  )");
133
  }
134
+
135
+ $this->options['installed'] = true;
136
+ update_option( self::OPTION_NAME, $this->options );
137
  }
138
 
139
  public function enqueue_scripts(){
857
  if (!empty($status))
858
  $sql .= $wpdb->prepare(" AND `activity_status` = %s", $status);
859
  $sql .= " GROUP BY `user_id`, `user_login`, `activity_status`, `activity_errors`";
860
+ $sql .= " ORDER BY `user_login`, `user_id`";
861
  $total = intval($wpdb->get_var("SELECT count(*) from ({$sql}) as log"));
862
 
863
  // Pagination
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJ
4
  Tags: log, login, users
5
  Requires at least: 3.5
6
  Tested up to: 3.6
7
- Stable tag: 0.5.0
8
 
9
  Tracks user name, time of login, IP address and browser user agent.
10
 
@@ -34,6 +34,10 @@ none
34
 
35
  == Changelog ==
36
 
 
 
 
 
37
  **0.5.0 - Aug. 14, 2013**
38
 
39
  Added custom filter ( 'crazy_bone::admin_menu_capability', 'crazy_bone::realtime_check' )
4
  Tags: log, login, users
5
  Requires at least: 3.5
6
  Tested up to: 3.6
7
+ Stable tag: 0.5.1
8
 
9
  Tracks user name, time of login, IP address and browser user agent.
10
 
34
 
35
  == Changelog ==
36
 
37
+ **0.5.1 - Sep. 9, 2013**
38
+
39
+ Multisite support.
40
+
41
  **0.5.0 - Aug. 14, 2013**
42
 
43
  Added custom filter ( 'crazy_bone::admin_menu_capability', 'crazy_bone::realtime_check' )
uninstall.php CHANGED
@@ -6,6 +6,7 @@ if( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') )
6
 
7
  global $wpdb;
8
  $wpdb->query("delete from {$wpdb->usermeta} where meta_key like 'user_login_log%';");
 
9
 
10
  $ull_table = $wpdb->prefix.'user_login_log';
11
  if ($wpdb->get_var("show tables like '{$ull_table}'") != $ull_table)
6
 
7
  global $wpdb;
8
  $wpdb->query("delete from {$wpdb->usermeta} where meta_key like 'user_login_log%';");
9
+ delete_option( 'user-login-log' );
10
 
11
  $ull_table = $wpdb->prefix.'user_login_log';
12
  if ($wpdb->get_var("show tables like '{$ull_table}'") != $ull_table)