Crazy Bone - Version 0.5.0

Version Description

Download this release

Release Info

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

Code changes from version 0.4.2 to 0.5.0

Files changed (2) hide show
  1. plugin.php +37 -22
  2. readme.txt +6 -2
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.4.2
8
  Author URI: http://dogmap.jp/
9
  Text Domain: user-login-log
10
  Domain Path: /languages/
@@ -34,14 +34,16 @@ if (!class_exists('DetectBrowsersController'))
34
  if (!class_exists('DetectCountriesController'))
35
  require_once( dirname(__FILE__) . '/includes/detect_countries.php' );
36
 
37
- load_plugin_textdomain(user_login_log::TEXT_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/languages/');
38
 
39
- class user_login_log {
40
  const USER_META_KEY = 'user_login_log';
41
  const TEXT_DOMAIN = 'user-login-log';
42
  const LIST_PER_PAGE = 20;
43
  const DEBUG_MODE = false;
44
 
 
 
45
  const SEC_MINUITE = 60;
46
  const SEC_HOUR = 3600;
47
  const SEC_DAY = 86400;
@@ -52,33 +54,37 @@ class user_login_log {
52
  private $admin_action;
53
  private $plugin_version;
54
 
 
 
55
  function __construct(){
56
  global $wpdb;
57
 
 
 
58
  $this->ull_table = $wpdb->prefix.$this->ull_table;
59
  $this->admin_action = admin_url('profile.php') . '?page=' . plugin_basename(__FILE__);
60
 
61
  $data = get_file_data(__FILE__, array('version' => 'Version'));
62
  $this->plugin_version = isset($data['version']) ? $data['version'] : '';
63
 
64
- add_action('wp_login', array(&$this, 'user_login_log'), 10, 2);
65
- add_action('wp_authenticate', array(&$this, 'wp_authenticate_log'), 10, 2);
66
- add_action('login_form_logout', array(&$this, 'user_logout_log'));
67
 
68
- add_action('admin_enqueue_scripts', array(&$this,'enqueue_scripts'));
69
- add_action('wp_enqueue_scripts', array(&$this,'enqueue_scripts'));
70
 
71
- add_action('admin_bar_init', array(&$this, 'admin_bar_init'), 9999);
72
- add_action('admin_menu', array(&$this,'add_admin_menu'));
73
 
74
- add_action('wp_ajax_ull_info', array(&$this, 'ajax_info'));
75
- add_action('wp_ajax_nopriv_ull_info', array(&$this, 'ajax_info'));
76
 
77
- add_action('wp_ajax_dismiss-ull-wp-pointer', array(&$this, 'ajax_dismiss'));
78
- add_action('wp_ajax_nopriv_dismiss-ull-wp-pointer', array(&$this, 'ajax_dismiss'));
79
 
80
- register_activation_hook(__FILE__, array(&$this, 'activate'));
81
- register_deactivation_hook(__FILE__, array(&$this, 'deactivate'));
82
  }
83
 
84
  public function activate(){
@@ -125,14 +131,21 @@ CREATE TABLE `{$this->ull_table}` (
125
  }
126
 
127
  public function admin_bar_init() {
128
- add_action('admin_bar_menu', array(&$this, 'customize_admin_bar_menu'), 9999);
129
  wp_enqueue_style('user_login_log', plugins_url('css/user_login_log.css', __FILE__), array(), $this->plugin_version);
130
 
131
- add_action('admin_footer', array(&$this, 'footer_js'));
132
- add_action('wp_footer', array(&$this, 'footer_js'));
 
 
 
133
  }
134
 
135
  public function customize_admin_bar_menu($wp_admin_bar){
 
 
 
 
136
  $title = $this->login_info();
137
  if ($title === false)
138
  return;
@@ -356,6 +369,8 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
356
 
357
  // Add Admin Menu
358
  public function add_admin_menu() {
 
 
359
  $parent = 'profile.php';
360
  $page_title = __('Login Log', self::TEXT_DOMAIN);
361
  $menu_title = $page_title;
@@ -364,7 +379,7 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
364
  $parent,
365
  $page_title,
366
  array($this,'option_page'),
367
- 'level_0',
368
  $menu_title,
369
  $file
370
  );
@@ -543,7 +558,7 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
543
  echo '<select name="user_id">'."\n";
544
  printf('<option value="%d"%s>%s</option>'."\n", -1, $selected_user_id == -1 ? $selectd : '', __('All Users', self::TEXT_DOMAIN));
545
  printf('<option value="%d"%s>%s</option>'."\n", 0, $selected_user_id == 0 ? $selectd : '', __('Unknown', self::TEXT_DOMAIN));
546
- $users = $wpdb->get_results("select ID, user_login from `{$wpdb->users}` order by ID");
547
  foreach((array)$users as $user) {
548
  printf('<option value="%d"%s>%s</option>'."\n", $user->ID, $selected_user_id == $user->ID ? $selectd : '', $user->user_login);
549
  }
@@ -944,4 +959,4 @@ if ($errors != 'invalid_username')
944
  }
945
  }
946
 
947
- new user_login_log();
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/
34
  if (!class_exists('DetectCountriesController'))
35
  require_once( dirname(__FILE__) . '/includes/detect_countries.php' );
36
 
37
+ load_plugin_textdomain(crazy_bone::TEXT_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/languages/');
38
 
39
+ class crazy_bone {
40
  const USER_META_KEY = 'user_login_log';
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
+
47
  const SEC_MINUITE = 60;
48
  const SEC_HOUR = 3600;
49
  const SEC_DAY = 86400;
54
  private $admin_action;
55
  private $plugin_version;
56
 
57
+ static $instance;
58
+
59
  function __construct(){
60
  global $wpdb;
61
 
62
+ self::$instance = $this;
63
+
64
  $this->ull_table = $wpdb->prefix.$this->ull_table;
65
  $this->admin_action = admin_url('profile.php') . '?page=' . plugin_basename(__FILE__);
66
 
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'));
73
 
74
+ add_action('admin_enqueue_scripts', array($this,'enqueue_scripts'));
75
+ add_action('wp_enqueue_scripts', array($this,'enqueue_scripts'));
76
 
77
+ add_action('admin_bar_init', array($this, 'admin_bar_init'), 9999);
78
+ add_action('admin_menu', array($this,'add_admin_menu'));
79
 
80
+ add_action('wp_ajax_ull_info', array($this, 'ajax_info'));
81
+ add_action('wp_ajax_nopriv_ull_info', array($this, 'ajax_info'));
82
 
83
+ add_action('wp_ajax_dismiss-ull-wp-pointer', array($this, 'ajax_dismiss'));
84
+ add_action('wp_ajax_nopriv_dismiss-ull-wp-pointer', array($this, 'ajax_dismiss'));
85
 
86
+ register_activation_hook(__FILE__, array($this, 'activate'));
87
+ register_deactivation_hook(__FILE__, array($this, 'deactivate'));
88
  }
89
 
90
  public function activate(){
131
  }
132
 
133
  public function admin_bar_init() {
134
+ add_action('admin_bar_menu', array($this, 'customize_admin_bar_menu'), 9999);
135
  wp_enqueue_style('user_login_log', plugins_url('css/user_login_log.css', __FILE__), array(), $this->plugin_version);
136
 
137
+ $realtime_check = apply_filters('crazy_bone::realtime_check', true);
138
+ if ($realtime_check) {
139
+ add_action('admin_footer', array($this, 'footer_js'));
140
+ add_action('wp_footer', array($this, 'footer_js'));
141
+ }
142
  }
143
 
144
  public function customize_admin_bar_menu($wp_admin_bar){
145
+ $capability = apply_filters('crazy_bone::admin_menu_capability', self::ADMIN_MENU_CAPABILITY);
146
+ if (!current_user_can($capability))
147
+ return;
148
+
149
  $title = $this->login_info();
150
  if ($title === false)
151
  return;
369
 
370
  // Add Admin Menu
371
  public function add_admin_menu() {
372
+ $capability = apply_filters('crazy_bone::admin_menu_capability', self::ADMIN_MENU_CAPABILITY);
373
+
374
  $parent = 'profile.php';
375
  $page_title = __('Login Log', self::TEXT_DOMAIN);
376
  $menu_title = $page_title;
379
  $parent,
380
  $page_title,
381
  array($this,'option_page'),
382
+ $capability,
383
  $menu_title,
384
  $file
385
  );
558
  echo '<select name="user_id">'."\n";
559
  printf('<option value="%d"%s>%s</option>'."\n", -1, $selected_user_id == -1 ? $selectd : '', __('All Users', self::TEXT_DOMAIN));
560
  printf('<option value="%d"%s>%s</option>'."\n", 0, $selected_user_id == 0 ? $selectd : '', __('Unknown', self::TEXT_DOMAIN));
561
+ $users = $wpdb->get_results("select ID, user_login from `{$wpdb->users}` order by user_login");
562
  foreach((array)$users as $user) {
563
  printf('<option value="%d"%s>%s</option>'."\n", $user->ID, $selected_user_id == $user->ID ? $selectd : '', $user->user_login);
564
  }
959
  }
960
  }
961
 
962
+ new crazy_bone();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wokamoto, megumithemes
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJCY7XB8F4&lc=JP&item_name=WordPress%20Plugins&item_number=wp%2dplugins&currency_code=JPY&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: log, login, users
5
  Requires at least: 3.5
6
- Tested up to: 3.5.1
7
- Stable tag: 0.4.2
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.4.0 - May 17, 2013**
38
 
39
  Added Summary page.
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJCY7XB8F4&lc=JP&item_name=WordPress%20Plugins&item_number=wp%2dplugins&currency_code=JPY&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
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
 
35
  == Changelog ==
36
 
37
+ **0.5.0 - Aug. 14, 2013**
38
+
39
+ Added custom filter ( 'crazy_bone::admin_menu_capability', 'crazy_bone::realtime_check' )
40
+
41
  **0.4.0 - May 17, 2013**
42
 
43
  Added Summary page.