Simple History - Version 2.7.4

Version Description

(Jule 2016) =

  • Log a warning message if a plugin gets disabled automatically by WordPress because of any of these errors: "Plugin file does not exist.", "Invalid plugin path.", "The plugin does not have a valid header."
  • Fix warning error if on_wp_login() was called without second argument.
  • Fix options diff not being shown correctly.
  • Fix notice if no message key did exist for a log message.
Download this release

Release Info

Developer eskapism
Plugin Icon 128x128 Simple History
Version 2.7.4
Comparing to
See all releases

Code changes from version 2.7.3 to 2.7.4

index.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://simple-history.com
5
  Text Domain: simple-history
6
  Domain Path: /languages
7
  Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
8
- Version: 2.7.3
9
  Author: Pär Thernström
10
  Author URI: http://simple-history.com/
11
  License: GPL2
@@ -42,7 +42,7 @@ if ( version_compare( phpversion(), "5.3", ">=") ) {
42
  // register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
43
 
44
  if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
45
- define( 'SIMPLE_HISTORY_VERSION', '2.7.3' );
46
  }
47
 
48
  if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
5
  Text Domain: simple-history
6
  Domain Path: /languages
7
  Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
8
+ Version: 2.7.4
9
  Author: Pär Thernström
10
  Author URI: http://simple-history.com/
11
  License: GPL2
42
  // register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
43
 
44
  if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
45
+ define( 'SIMPLE_HISTORY_VERSION', '2.7.4' );
46
  }
47
 
48
  if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
loggers/SimpleLogger.php CHANGED
@@ -101,7 +101,7 @@ class SimpleLogger {
101
  * @return Mixed
102
  */
103
  function getInfoValueByKey( $key ) {
104
-
105
  $arr_info = $this->getInfo();
106
 
107
  return isset( $arr_info[ $key ] ) ? $arr_info[ $key ] : null;
@@ -142,7 +142,7 @@ class SimpleLogger {
142
 
143
  /**
144
  * Filter the context used to create the message from the message template
145
- *
146
  * @since 2.2.4
147
  */
148
  $context = apply_filters( "simple_history/logger/interpolate/context", $context, $message, $row );
@@ -392,10 +392,10 @@ class SimpleLogger {
392
 
393
  // $row->date is in GMT
394
  $date_datetime = new DateTime( $row->date );
395
-
396
  // Current datetime in GMT
397
  $time_current = strtotime( current_time("mysql", 1) );
398
-
399
  /**
400
  * Filter how many seconds as most that can pass since an
401
  * event occured to show "nn minutes ago" (human diff time-format) instead of exact date
@@ -437,7 +437,7 @@ class SimpleLogger {
437
  $str_when = sprintf(__('%1$s ago', 'simple-history'), $date_human_time_diff);
438
 
439
  }
440
-
441
  $item_permalink = admin_url("index.php?page=simple_history_page");
442
  if ( ! empty( $row->id ) ) {
443
  $item_permalink .= "#item/{$row->id}";
@@ -478,13 +478,13 @@ class SimpleLogger {
478
  // that "caused" this event
479
  $via_html = "";
480
  $logger_name_via = $this->getInfoValueByKey("name_via");
481
-
482
  if ( $logger_name_via ) {
483
-
484
  $via_html = "<span class='SimpleHistoryLogitem__inlineDivided SimpleHistoryLogitem__via'>";
485
  $via_html .= $logger_name_via;
486
  $via_html .= "</span>";
487
-
488
  }
489
 
490
  // Loglevel
@@ -498,8 +498,8 @@ class SimpleLogger {
498
 
499
  // Glue together final result
500
  $template = '
501
- %1$s
502
- %2$s
503
  %3$s
504
  ';
505
  #if ( ! $initiator_html ) {
@@ -546,7 +546,7 @@ class SimpleLogger {
546
  public function getLogRowPlainTextOutput($row) {
547
 
548
  $message = $row->message;
549
- $message_key = $row->context["_message_key"];
550
 
551
  // Message is translated here, but translation must be added in
552
  // plain text before
@@ -955,7 +955,7 @@ class SimpleLogger {
955
  * @since 2.3.1
956
  */
957
  $do_log = apply_filters( "simple_history/log/do_log", true, $level, $message, $context, $this );
958
-
959
  if ( $do_log === false ) {
960
  return $this;
961
  }
@@ -1278,7 +1278,7 @@ class SimpleLogger {
1278
  }
1279
 
1280
  }
1281
-
1282
  $this->lastInsertID = $history_inserted_id;
1283
 
1284
  $this->simpleHistory->get_cache_incrementor(true);
101
  * @return Mixed
102
  */
103
  function getInfoValueByKey( $key ) {
104
+
105
  $arr_info = $this->getInfo();
106
 
107
  return isset( $arr_info[ $key ] ) ? $arr_info[ $key ] : null;
142
 
143
  /**
144
  * Filter the context used to create the message from the message template
145
+ *
146
  * @since 2.2.4
147
  */
148
  $context = apply_filters( "simple_history/logger/interpolate/context", $context, $message, $row );
392
 
393
  // $row->date is in GMT
394
  $date_datetime = new DateTime( $row->date );
395
+
396
  // Current datetime in GMT
397
  $time_current = strtotime( current_time("mysql", 1) );
398
+
399
  /**
400
  * Filter how many seconds as most that can pass since an
401
  * event occured to show "nn minutes ago" (human diff time-format) instead of exact date
437
  $str_when = sprintf(__('%1$s ago', 'simple-history'), $date_human_time_diff);
438
 
439
  }
440
+
441
  $item_permalink = admin_url("index.php?page=simple_history_page");
442
  if ( ! empty( $row->id ) ) {
443
  $item_permalink .= "#item/{$row->id}";
478
  // that "caused" this event
479
  $via_html = "";
480
  $logger_name_via = $this->getInfoValueByKey("name_via");
481
+
482
  if ( $logger_name_via ) {
483
+
484
  $via_html = "<span class='SimpleHistoryLogitem__inlineDivided SimpleHistoryLogitem__via'>";
485
  $via_html .= $logger_name_via;
486
  $via_html .= "</span>";
487
+
488
  }
489
 
490
  // Loglevel
498
 
499
  // Glue together final result
500
  $template = '
501
+ %1$s
502
+ %2$s
503
  %3$s
504
  ';
505
  #if ( ! $initiator_html ) {
546
  public function getLogRowPlainTextOutput($row) {
547
 
548
  $message = $row->message;
549
+ $message_key = isset( $row->context["_message_key"] ) ? $row->context["_message_key"] : null;
550
 
551
  // Message is translated here, but translation must be added in
552
  // plain text before
955
  * @since 2.3.1
956
  */
957
  $do_log = apply_filters( "simple_history/log/do_log", true, $level, $message, $context, $this );
958
+
959
  if ( $do_log === false ) {
960
  return $this;
961
  }
1278
  }
1279
 
1280
  }
1281
+
1282
  $this->lastInsertID = $history_inserted_id;
1283
 
1284
  $this->simpleHistory->get_cache_incrementor(true);
loggers/SimpleOptionsLogger.php CHANGED
@@ -234,7 +234,7 @@ class SimpleOptionsLogger extends SimpleLogger
234
  }
235
 
236
  if ( strlen( $old_value ) > $trim_length ) {
237
- $trimmed_oldv_alue .= $more;
238
  }
239
 
240
  $output .= sprintf(
234
  }
235
 
236
  if ( strlen( $old_value ) > $trim_length ) {
237
+ $trimmed_old_value .= $more;
238
  }
239
 
240
  $output .= sprintf(
loggers/SimplePluginLogger.php CHANGED
@@ -78,6 +78,14 @@ class SimplePluginLogger extends SimpleLogger
78
  'Plugin was updated in bulk',
79
  'simple-history'
80
  ),
 
 
 
 
 
 
 
 
81
  ), // messages
82
  "labels" => array(
83
  "search" => array(
@@ -88,7 +96,8 @@ class SimplePluginLogger extends SimpleLogger
88
  'plugin_activated'
89
  ),
90
  _x("Deactivated plugins", "Plugin logger: search", "simple-history") => array(
91
- 'plugin_deactivated'
 
92
  ),
93
  _x("Installed plugins", "Plugin logger: search", "simple-history") => array(
94
  'plugin_installed'
@@ -167,8 +176,58 @@ class SimplePluginLogger extends SimpleLogger
167
  return $arr_headers;
168
  } );
169
 
 
 
 
 
170
  }
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  /**
173
  * Show readme from github in a modal win
174
  */
78
  'Plugin was updated in bulk',
79
  'simple-history'
80
  ),
81
+
82
+ // plugin disabled due to some error
83
+ 'plugin_disabled_because_error' => _x(
84
+ 'Deactivated a plugin because of an error: {error_message}',
85
+ 'Plugin was disabled because of an error',
86
+ 'simple-history'
87
+ ),
88
+
89
  ), // messages
90
  "labels" => array(
91
  "search" => array(
96
  'plugin_activated'
97
  ),
98
  _x("Deactivated plugins", "Plugin logger: search", "simple-history") => array(
99
+ 'plugin_deactivated',
100
+ 'plugin_disabled_because_error'
101
  ),
102
  _x("Installed plugins", "Plugin logger: search", "simple-history") => array(
103
  'plugin_installed'
176
  return $arr_headers;
177
  } );
178
 
179
+ // There is no way to ue a filter and detect a plugin that is disabled because it can't be found or similar error.
180
+ // So we hook into gettext and look for the usage of the error that is returned when this happens.
181
+ add_filter( 'gettext', array( $this, "on_gettext" ), 10, 3 );
182
+
183
  }
184
 
185
+ /**
186
+ *
187
+ * There is no way to ue a filter and detect a plugin that is disabled because it can't be found or similar error.
188
+ * we hook into gettext and look for the usage of the error that is returned when this happens.
189
+ */
190
+ function on_gettext( $translation, $text, $domain ) {
191
+
192
+ // The errors we can get is:
193
+ // return new WP_Error('plugin_invalid', __('Invalid plugin path.'));
194
+ // return new WP_Error('plugin_not_found', __('Plugin file does not exist.'));
195
+ // return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.'));
196
+
197
+ // We only act on page plugins.php
198
+ global $pagenow;
199
+
200
+ if ( ! isset( $pagenow ) || $pagenow !== "plugins.php" ) {
201
+ return $translation;
202
+ }
203
+
204
+ // We only act if the untranslated text is among the following ones
205
+ // (Literally these, no translation)
206
+ $untranslated_texts = array(
207
+ "Plugin file does not exist.",
208
+ "Invalid plugin path.",
209
+ "The plugin does not have a valid header."
210
+ );
211
+
212
+ if ( ! in_array( $text, $untranslated_texts )) {
213
+ return $translation;
214
+ }
215
+
216
+ // We don't know what plugin that was that got this error and currently there does not seem to be a way to determine that
217
+ // So that's why we use such generic log messages
218
+ $this->warningMessage(
219
+ "plugin_disabled_because_error",
220
+ array(
221
+ "_initiator" => SimpleLoggerLogInitiators::WORDPRESS,
222
+ "error_message" => $text
223
+ )
224
+ );
225
+
226
+ return $translation;
227
+
228
+ } //on_gettext
229
+
230
+
231
  /**
232
  * Show readme from github in a modal win
233
  */
loggers/SimpleUserLogger.php CHANGED
@@ -120,7 +120,7 @@ class SimpleUserLogger extends SimpleLogger {
120
  // User reaches reset password (from link or only from user created link)
121
  add_action( 'validate_password_reset', array( $this, "on_validate_password_reset" ), 10, 2 );
122
 
123
- add_action( 'retrieve_password_message', array( $this, "on_retrieve_password_message" ), 10, 4 );
124
 
125
  add_filter( 'insert_user_meta', array( $this, "on_insert_user_meta" ), 10, 3 );
126
 
@@ -129,11 +129,11 @@ class SimpleUserLogger extends SimpleLogger {
129
 
130
  /*
131
  * Called before the user is updated
132
- *
133
  * Filter a user's meta values and keys before the user is created or updated.
134
  *
135
  * Does not include contact methods. These are added using `wp_get_user_contact_methods( $user )`.
136
- *
137
  * @param array $meta {
138
  * Default meta values and keys for the user.
139
  *
@@ -163,7 +163,7 @@ class SimpleUserLogger extends SimpleLogger {
163
  if ( empty( $user ) || ! is_object( $user ) ) {
164
  return $meta;
165
  }
166
-
167
  // Make of copy of the posted data, because we change the keys
168
  $posted_data = $_POST;
169
  $posted_data = stripslashes_deep( $posted_data );
@@ -172,7 +172,7 @@ class SimpleUserLogger extends SimpleLogger {
172
  if ( ! function_exists( "_get_additional_user_keys" ) ) {
173
  return $meta;
174
  }
175
-
176
  // Get the default fields to include. This includes contact methods (including filter, so more could have been added)
177
  $arr_keys_to_check = _get_additional_user_keys( $user );
178
 
@@ -187,20 +187,20 @@ class SimpleUserLogger extends SimpleLogger {
187
  $posted_data["user_url"] = isset( $posted_data["url"] ) ? $posted_data["url"] : null;
188
  $posted_data["show_admin_bar_front"] = isset( $posted_data["admin_bar_front"] ) ? true : null;
189
  $posted_data["user_email"] = isset( $posted_data["email"] ) ? $posted_data["email"] : null;
190
-
191
  // Display name publicly as = POST "display_name"
192
  #var_dump($user->display_name);
193
 
194
  // Set vals for Enable keyboard shortcuts for comment moderation
195
  $posted_data['comment_shortcuts'] = isset( $posted_data['comment_shortcuts'] ) ? "true" : "false";
196
-
197
  // Set vals for Disable the visual editor when writing
198
  // posted val = string "false" = yes, disable
199
  $posted_data['rich_editing'] = isset( $posted_data['rich_editing'] ) ? "false" : "true";
200
-
201
  // Set vals for Show Toolbar when viewing site
202
  $posted_data['show_admin_bar_front'] = isset( $posted_data['admin_bar_front'] ) ? "true" : "false";
203
-
204
  // if checkbox is checked in admin then this is the saved value on the user object
205
  // @todo:
206
 
@@ -209,7 +209,7 @@ class SimpleUserLogger extends SimpleLogger {
209
  if ( ! empty( $posted_data['pass1'] ) && ! empty( $posted_data['pass2'] ) && $posted_data['pass1'] == $posted_data['pass2'] ) {
210
  $password_changed = 1;
211
  }
212
-
213
  // Check if role was changed
214
  //[role] => bbp_moderator
215
  $role_changed = false;
@@ -222,10 +222,10 @@ class SimpleUserLogger extends SimpleLogger {
222
  // Compare user role against currently editable roles
223
  $user_roles = array_intersect( array_values( $user->roles ), array_keys( get_editable_roles() ) );
224
  $old_role = reset( $user_roles );
225
-
226
  $role_changed = $new_role != $old_role;
227
  }
228
-
229
  // Will contain the differences
230
  $user_data_diff = array();
231
 
@@ -245,7 +245,7 @@ class SimpleUserLogger extends SimpleLogger {
245
  }
246
 
247
  $user_data_diff = $this->add_diff($user_data_diff, $one_key_to_check, $old_val, $new_val);
248
-
249
  }
250
 
251
  // Setup basic context
@@ -282,7 +282,7 @@ class SimpleUserLogger extends SimpleLogger {
282
 
283
  }
284
 
285
-
286
  $this->infoMessage("user_updated_profile", $context);
287
 
288
  return $meta;
@@ -295,9 +295,9 @@ class SimpleUserLogger extends SimpleLogger {
295
  *
296
  */
297
  function on_retrieve_password_message( $message, $key, $user_login, $user_data ) {
298
-
299
  if ( isset( $_GET["action"] ) && ( "lostpassword" == $_GET["action"] ) ) {
300
-
301
  $context = array(
302
  "_initiator" => SimpleLoggerLogInitiators::WEB_USER,
303
  "message" => $message,
@@ -336,14 +336,14 @@ class SimpleUserLogger extends SimpleLogger {
336
  User resets password
337
  $errors empty
338
  $user user object
339
- $_post
340
 
341
  */
342
 
343
  $context = array();
344
 
345
  if ( is_a( $user, "WP_User") ) {
346
-
347
  $context["_initiator"] = SimpleLoggerLogInitiators::WP_USER;
348
  $context["_user_id"] = $user->ID;
349
  $context["_user_login"] = $user->user_login;
@@ -352,7 +352,7 @@ class SimpleUserLogger extends SimpleLogger {
352
  }
353
 
354
  if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) {
355
-
356
  // $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) );
357
  // user failed to reset password
358
 
@@ -360,8 +360,8 @@ class SimpleUserLogger extends SimpleLogger {
360
 
361
 
362
  if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) {
363
-
364
- // login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url(
365
  $this->infoMessage( "user_password_reseted", $context );
366
 
367
 
@@ -478,7 +478,7 @@ class SimpleUserLogger extends SimpleLogger {
478
  $context["edit_profile_link"] = get_edit_user_link( $wp_user->ID );
479
 
480
  $use_you = apply_filters("simple_history/user_logger/plain_text_output_use_you", true);
481
-
482
  //error_log( serialize( $current_user_id) ); // int 1
483
  //error_log( serialize( $context["_user_id"]) ); // string 1
484
 
@@ -522,7 +522,7 @@ class SimpleUserLogger extends SimpleLogger {
522
  }
523
 
524
  // if user_updated_profile
525
-
526
  } else if ( "user_created" == $context["_message_key"] ) {
527
 
528
  // A user was created. Create link of username that goes to user profile.
@@ -539,13 +539,13 @@ class SimpleUserLogger extends SimpleLogger {
539
  $msg = __('Created user <a href="{edit_profile_link}">{created_user_login} ({created_user_email})</a> with role {created_user_role}', "simple-history");
540
 
541
  $output = $this->interpolate(
542
- $msg,
543
- $context,
544
  $row
545
  );
546
 
547
  } else {
548
-
549
  // User does not exist any longer, keep original message
550
 
551
 
@@ -563,7 +563,7 @@ class SimpleUserLogger extends SimpleLogger {
563
  * @param string $user_login
564
  * @param object $user
565
  */
566
- function on_wp_login($user_login, $user) {
567
 
568
  $context = array(
569
  "user_login" => $user_login
@@ -572,9 +572,9 @@ class SimpleUserLogger extends SimpleLogger {
572
  if ( isset( $user_login ) ) {
573
 
574
  $user_obj = get_user_by( "login", $user_login );
575
-
576
  } else if ( isset( $user ) && isset( $user->ID ) ) {
577
-
578
  $user_obj = get_user_by( "id", $user->ID );
579
 
580
  }
@@ -602,7 +602,7 @@ class SimpleUserLogger extends SimpleLogger {
602
  // Could not get any info about the user logging in
603
  $this->warningMessage("user_unknown_logged_in", $context);
604
  }
605
-
606
  }
607
 
608
  /**
@@ -617,7 +617,7 @@ class SimpleUserLogger extends SimpleLogger {
617
 
618
  /**
619
  * User is edited
620
- *
621
  * Called immediately after an existing user is updated.
622
  * @param int $user_id User ID.
623
  * @param object $old_user_data Object containing user's data prior to update.
@@ -639,7 +639,7 @@ class SimpleUserLogger extends SimpleLogger {
639
  "old_user_data" => $old_user_data
640
  );
641
 
642
-
643
  $this->infoMessage("user_updated_profile", $context);
644
  */
645
 
@@ -730,7 +730,7 @@ class SimpleUserLogger extends SimpleLogger {
730
 
731
  /**
732
  * Attempt to login to user that does not exist
733
- *
734
  * @param $user (null or WP_User or WP_Error) (required) null indicates no process has authenticated the user yet. A WP_Error object indicates another process has failed the authentication. A WP_User object indicates another process has authenticated the user.
735
  * @param $username The user's username.
736
  * @param $password The user's password (encrypted)
@@ -744,9 +744,9 @@ class SimpleUserLogger extends SimpleLogger {
744
 
745
  // If already auth ok
746
  if ( is_a( $user, 'WP_User' ) ) {
747
-
748
  $wp_user = $user;
749
-
750
  } else {
751
 
752
  // If username is not a user in the system then this
@@ -791,7 +791,7 @@ class SimpleUserLogger extends SimpleLogger {
791
  return $user;
792
 
793
  }
794
-
795
  /**
796
  * Add diff to array if old and new values are different
797
  *
@@ -814,7 +814,7 @@ class SimpleUserLogger extends SimpleLogger {
814
 
815
  /**
816
  * Return more info about an logged event
817
- * Supports so far:
818
  */
819
  function getLogRowDetailsOutput( $row ) {
820
 
@@ -884,7 +884,7 @@ class SimpleUserLogger extends SimpleLogger {
884
  foreach ( $arr_user_keys_to_show_diff_for as $key => $val ) {
885
 
886
  if ( isset( $context["user_prev_{$key}"] ) && isset( $context["user_new_{$key}"] ) ) {
887
-
888
  $user_old_value = $context["user_prev_{$key}"];
889
  $user_new_value = $context["user_new_{$key}"];
890
 
@@ -892,9 +892,9 @@ class SimpleUserLogger extends SimpleLogger {
892
  '<tr>
893
  <td>%1$s</td>
894
  <td>%2$s</td>
895
- </tr>',
896
  $val["title"],
897
- sprintf(
898
  '<ins class="SimpleHistoryLogitem__keyValueTable__addedThing">%1$s</ins> <del class="SimpleHistoryLogitem__keyValueTable__removedThing">%2$s</del>',
899
  esc_html( $user_new_value ), // 1
900
  esc_html( $user_old_value ) // 2
@@ -912,7 +912,7 @@ class SimpleUserLogger extends SimpleLogger {
912
  '<tr>
913
  <td>%1$s</td>
914
  <td>%2$s</td>
915
- </tr>',
916
  _x("Password", "User logger", "simple-history"),
917
  _x("Changed", "User logger", "simple-history")
918
  );
@@ -962,9 +962,9 @@ class SimpleUserLogger extends SimpleLogger {
962
  '<tr>
963
  <td>%1$s</td>
964
  <td>%2$s</td>
965
- </tr>',
966
  _x("Notification", "User logger", "simple-history"),
967
- sprintf(
968
  '<ins class="SimpleHistoryLogitem__keyValueTable__addedThing">%1$s</ins>',
969
  esc_html( $sent_status ) // 1
970
  )
@@ -978,9 +978,9 @@ class SimpleUserLogger extends SimpleLogger {
978
  '<tr>
979
  <td>%1$s</td>
980
  <td>%2$s</td>
981
- </tr>',
982
  $val["title"],
983
- sprintf(
984
  '<ins class="SimpleHistoryLogitem__keyValueTable__addedThing">%1$s</ins>',
985
  esc_html( $context[ $key ] ) // 1
986
  )
120
  // User reaches reset password (from link or only from user created link)
121
  add_action( 'validate_password_reset', array( $this, "on_validate_password_reset" ), 10, 2 );
122
 
123
+ add_action( 'retrieve_password_message', array( $this, "on_retrieve_password_message" ), 10, 4 );
124
 
125
  add_filter( 'insert_user_meta', array( $this, "on_insert_user_meta" ), 10, 3 );
126
 
129
 
130
  /*
131
  * Called before the user is updated
132
+ *
133
  * Filter a user's meta values and keys before the user is created or updated.
134
  *
135
  * Does not include contact methods. These are added using `wp_get_user_contact_methods( $user )`.
136
+ *
137
  * @param array $meta {
138
  * Default meta values and keys for the user.
139
  *
163
  if ( empty( $user ) || ! is_object( $user ) ) {
164
  return $meta;
165
  }
166
+
167
  // Make of copy of the posted data, because we change the keys
168
  $posted_data = $_POST;
169
  $posted_data = stripslashes_deep( $posted_data );
172
  if ( ! function_exists( "_get_additional_user_keys" ) ) {
173
  return $meta;
174
  }
175
+
176
  // Get the default fields to include. This includes contact methods (including filter, so more could have been added)
177
  $arr_keys_to_check = _get_additional_user_keys( $user );
178
 
187
  $posted_data["user_url"] = isset( $posted_data["url"] ) ? $posted_data["url"] : null;
188
  $posted_data["show_admin_bar_front"] = isset( $posted_data["admin_bar_front"] ) ? true : null;
189
  $posted_data["user_email"] = isset( $posted_data["email"] ) ? $posted_data["email"] : null;
190
+
191
  // Display name publicly as = POST "display_name"
192
  #var_dump($user->display_name);
193
 
194
  // Set vals for Enable keyboard shortcuts for comment moderation
195
  $posted_data['comment_shortcuts'] = isset( $posted_data['comment_shortcuts'] ) ? "true" : "false";
196
+
197
  // Set vals for Disable the visual editor when writing
198
  // posted val = string "false" = yes, disable
199
  $posted_data['rich_editing'] = isset( $posted_data['rich_editing'] ) ? "false" : "true";
200
+
201
  // Set vals for Show Toolbar when viewing site
202
  $posted_data['show_admin_bar_front'] = isset( $posted_data['admin_bar_front'] ) ? "true" : "false";
203
+
204
  // if checkbox is checked in admin then this is the saved value on the user object
205
  // @todo:
206
 
209
  if ( ! empty( $posted_data['pass1'] ) && ! empty( $posted_data['pass2'] ) && $posted_data['pass1'] == $posted_data['pass2'] ) {
210
  $password_changed = 1;
211
  }
212
+
213
  // Check if role was changed
214
  //[role] => bbp_moderator
215
  $role_changed = false;
222
  // Compare user role against currently editable roles
223
  $user_roles = array_intersect( array_values( $user->roles ), array_keys( get_editable_roles() ) );
224
  $old_role = reset( $user_roles );
225
+
226
  $role_changed = $new_role != $old_role;
227
  }
228
+
229
  // Will contain the differences
230
  $user_data_diff = array();
231
 
245
  }
246
 
247
  $user_data_diff = $this->add_diff($user_data_diff, $one_key_to_check, $old_val, $new_val);
248
+
249
  }
250
 
251
  // Setup basic context
282
 
283
  }
284
 
285
+
286
  $this->infoMessage("user_updated_profile", $context);
287
 
288
  return $meta;
295
  *
296
  */
297
  function on_retrieve_password_message( $message, $key, $user_login, $user_data ) {
298
+
299
  if ( isset( $_GET["action"] ) && ( "lostpassword" == $_GET["action"] ) ) {
300
+
301
  $context = array(
302
  "_initiator" => SimpleLoggerLogInitiators::WEB_USER,
303
  "message" => $message,
336
  User resets password
337
  $errors empty
338
  $user user object
339
+ $_post
340
 
341
  */
342
 
343
  $context = array();
344
 
345
  if ( is_a( $user, "WP_User") ) {
346
+
347
  $context["_initiator"] = SimpleLoggerLogInitiators::WP_USER;
348
  $context["_user_id"] = $user->ID;
349
  $context["_user_login"] = $user->user_login;
352
  }
353
 
354
  if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) {
355
+
356
  // $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) );
357
  // user failed to reset password
358
 
360
 
361
 
362
  if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) {
363
+
364
+ // login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url(
365
  $this->infoMessage( "user_password_reseted", $context );
366
 
367
 
478
  $context["edit_profile_link"] = get_edit_user_link( $wp_user->ID );
479
 
480
  $use_you = apply_filters("simple_history/user_logger/plain_text_output_use_you", true);
481
+
482
  //error_log( serialize( $current_user_id) ); // int 1
483
  //error_log( serialize( $context["_user_id"]) ); // string 1
484
 
522
  }
523
 
524
  // if user_updated_profile
525
+
526
  } else if ( "user_created" == $context["_message_key"] ) {
527
 
528
  // A user was created. Create link of username that goes to user profile.
539
  $msg = __('Created user <a href="{edit_profile_link}">{created_user_login} ({created_user_email})</a> with role {created_user_role}', "simple-history");
540
 
541
  $output = $this->interpolate(
542
+ $msg,
543
+ $context,
544
  $row
545
  );
546
 
547
  } else {
548
+
549
  // User does not exist any longer, keep original message
550
 
551
 
563
  * @param string $user_login
564
  * @param object $user
565
  */
566
+ function on_wp_login( $user_login = null, $user = null) {
567
 
568
  $context = array(
569
  "user_login" => $user_login
572
  if ( isset( $user_login ) ) {
573
 
574
  $user_obj = get_user_by( "login", $user_login );
575
+
576
  } else if ( isset( $user ) && isset( $user->ID ) ) {
577
+
578
  $user_obj = get_user_by( "id", $user->ID );
579
 
580
  }
602
  // Could not get any info about the user logging in
603
  $this->warningMessage("user_unknown_logged_in", $context);
604
  }
605
+
606
  }
607
 
608
  /**
617
 
618
  /**
619
  * User is edited
620
+ *
621
  * Called immediately after an existing user is updated.
622
  * @param int $user_id User ID.
623
  * @param object $old_user_data Object containing user's data prior to update.
639
  "old_user_data" => $old_user_data
640
  );
641
 
642
+
643
  $this->infoMessage("user_updated_profile", $context);
644
  */
645
 
730
 
731
  /**
732
  * Attempt to login to user that does not exist
733
+ *
734
  * @param $user (null or WP_User or WP_Error) (required) null indicates no process has authenticated the user yet. A WP_Error object indicates another process has failed the authentication. A WP_User object indicates another process has authenticated the user.
735
  * @param $username The user's username.
736
  * @param $password The user's password (encrypted)
744
 
745
  // If already auth ok
746
  if ( is_a( $user, 'WP_User' ) ) {
747
+
748
  $wp_user = $user;
749
+
750
  } else {
751
 
752
  // If username is not a user in the system then this
791
  return $user;
792
 
793
  }
794
+
795
  /**
796
  * Add diff to array if old and new values are different
797
  *
814
 
815
  /**
816
  * Return more info about an logged event
817
+ * Supports so far:
818
  */
819
  function getLogRowDetailsOutput( $row ) {
820
 
884
  foreach ( $arr_user_keys_to_show_diff_for as $key => $val ) {
885
 
886
  if ( isset( $context["user_prev_{$key}"] ) && isset( $context["user_new_{$key}"] ) ) {
887
+
888
  $user_old_value = $context["user_prev_{$key}"];
889
  $user_new_value = $context["user_new_{$key}"];
890
 
892
  '<tr>
893
  <td>%1$s</td>
894
  <td>%2$s</td>
895
+ </tr>',
896
  $val["title"],
897
+ sprintf(
898
  '<ins class="SimpleHistoryLogitem__keyValueTable__addedThing">%1$s</ins> <del class="SimpleHistoryLogitem__keyValueTable__removedThing">%2$s</del>',
899
  esc_html( $user_new_value ), // 1
900
  esc_html( $user_old_value ) // 2
912
  '<tr>
913
  <td>%1$s</td>
914
  <td>%2$s</td>
915
+ </tr>',
916
  _x("Password", "User logger", "simple-history"),
917
  _x("Changed", "User logger", "simple-history")
918
  );
962
  '<tr>
963
  <td>%1$s</td>
964
  <td>%2$s</td>
965
+ </tr>',
966
  _x("Notification", "User logger", "simple-history"),
967
+ sprintf(
968
  '<ins class="SimpleHistoryLogitem__keyValueTable__addedThing">%1$s</ins>',
969
  esc_html( $sent_status ) // 1
970
  )
978
  '<tr>
979
  <td>%1$s</td>
980
  <td>%2$s</td>
981
+ </tr>',
982
  $val["title"],
983
+ sprintf(
984
  '<ins class="SimpleHistoryLogitem__keyValueTable__addedThing">%1$s</ins>',
985
  esc_html( $context[ $key ] ) // 1
986
  )
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Simple History ===
2
  Contributors: eskapism
3
  Donate link: http://eskapism.se/sida/donate/
4
- Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin, syslog, feed, activity, stream, audit trail, brute-force
5
  Requires at least: 4.5.1
6
  Tested up to: 4.5.2
7
- Stable tag: 2.7.3
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
@@ -147,6 +147,13 @@ A simple way to see any uncommon activity, for example an increased number of lo
147
 
148
  ## Changelog
149
 
 
 
 
 
 
 
 
150
  = 2.7.3 (June 2016) =
151
 
152
  - Removed the usage of the mb_* functions and mbstring is no longer a requirement.
1
  === Simple History ===
2
  Contributors: eskapism
3
  Donate link: http://eskapism.se/sida/donate/
4
+ Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, dashboard, admin, syslog, feed, activity, stream, audit trail, brute-force
5
  Requires at least: 4.5.1
6
  Tested up to: 4.5.2
7
+ Stable tag: 2.7.4
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
147
 
148
  ## Changelog
149
 
150
+ = 2.7.4 (Jule 2016) =
151
+
152
+ - Log a warning message if a plugin gets disabled automatically by WordPress because of any of these errors: "Plugin file does not exist.", "Invalid plugin path.", "The plugin does not have a valid header."
153
+ - Fix warning error if `on_wp_login()` was called without second argument.
154
+ - Fix options diff not being shown correctly.
155
+ - Fix notice if no message key did exist for a log message.
156
+
157
  = 2.7.3 (June 2016) =
158
 
159
  - Removed the usage of the mb_* functions and mbstring is no longer a requirement.