Simple History - Version 2.1.6

Version Description

(August 2015) =

  • Updated: Danish translation updated. Thanks translator!
  • Fixed: Icon on settings page was a bit unaligned on WordPress not running the latest beta version (hrm, which I guess most of you were..)
  • Fixed: Possible php notice. Should fix https://wordpress.org/support/topic/simplehistoryphp-creates-debug-entries.
  • Changed: Logged messages are now trimmed by default (spaces and new lines will be removed from messages).
  • Updated: When installing and activating the plugin it will now add the same "plugin installed" and "plugin activated" message that other plugins get when they are installed. These events where not logged before because the plugin was not installed and could therefor not log its own installation. Solution was to log it manually. Works. Looks good. But perhaps a bit of cheating.
  • Added: A (hopefully) better welcome message when activating the plugin for the first time. Hopefully the new message makes new users understand a bit better why the log may be empty at first.
Download this release

Release Info

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

Code changes from version 2.1.5 to 2.1.6

css/styles.css CHANGED
@@ -695,7 +695,7 @@ Modal window with detailss
695
  }
696
 
697
  @media only screen and (max-width: 850px) {
698
-
699
  .SimpleHistory-modal__content {
700
  left: 10px; /* admin meny width is 160 px */
701
  }
@@ -797,7 +797,7 @@ Modal window with detailss
797
 
798
 
799
  @media only screen and (max-width: 850px) {
800
-
801
  .SimpleHistoryLogitem__moreDetails {
802
  margin-left: -60px;
803
  }
@@ -884,6 +884,11 @@ Modal window with detailss
884
  color: rgb(63, 147, 73);
885
  }
886
 
 
 
 
 
 
887
  /* if not hits when using filter function */
888
  .SimpleHistory--hasNoHits {
889
  }
@@ -908,4 +913,3 @@ Modal window with detailss
908
  margin-left: 13px;
909
  margin-right: 13px;
910
  }
911
-
695
  }
696
 
697
  @media only screen and (max-width: 850px) {
698
+
699
  .SimpleHistory-modal__content {
700
  left: 10px; /* admin meny width is 160 px */
701
  }
797
 
798
 
799
  @media only screen and (max-width: 850px) {
800
+
801
  .SimpleHistoryLogitem__moreDetails {
802
  margin-left: -60px;
803
  }
884
  color: rgb(63, 147, 73);
885
  }
886
 
887
+ /* For WP < 4.3 */
888
+ .branch-4-2 .SimpleHistoryPageHeadline__icon {
889
+ line-height: 18px;
890
+ }
891
+
892
  /* if not hits when using filter function */
893
  .SimpleHistory--hasNoHits {
894
  }
913
  margin-left: 13px;
914
  margin-right: 13px;
915
  }
 
inc/SimpleHistory.php CHANGED
@@ -70,51 +70,51 @@ class SimpleHistory {
70
  *
71
  * @param SimpleHistory $SimpleHistory This class.
72
  */
73
- do_action("simple_history/before_init", $this);
74
 
75
  $this->setup_variables();
76
 
77
  // Actions and filters, ordered by order specified in codex: http://codex.wordpress.org/Plugin_API/Action_Reference
78
- add_action('after_setup_theme', array($this, 'load_plugin_textdomain'));
79
- add_action('after_setup_theme', array($this, 'add_default_settings_tabs'));
80
-
81
  // Plugins and dropins are loaded using the "after_setup_theme" filter so
82
  // themes can use filters to modify the loading of them.
83
  // The drawback with this is that for example logouts done when plugins like
84
  // iThemes Security is installed is not logged, because those plugins fire wp_logout()
85
  // using filter "plugins_loaded", i.e. before simple history has loaded its filters.
86
- add_action('after_setup_theme', array($this, 'load_loggers'));
87
- add_action('after_setup_theme', array($this, 'load_dropins'));
88
 
89
  // Run before loading of loggers and before menu items are added
90
- add_action('after_setup_theme', array($this, 'check_for_upgrade'), 5);
91
 
92
- add_action('after_setup_theme', array($this, 'setup_cron'));
93
 
94
- add_action('admin_menu', array($this, 'add_admin_pages'));
95
- add_action('admin_menu', array($this, 'add_settings'));
96
 
97
- add_action('admin_footer', array($this, "add_js_templates"));
98
 
99
- add_action('wp_dashboard_setup', array($this, 'add_dashboard_widget'));
100
 
101
- add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
102
 
103
- add_action('admin_head', array($this, "onAdminHead"));
104
- add_action('admin_footer', array($this, "onAdminFooter"));
105
 
106
  // Filters and actions not called during regular boot
107
- add_filter("gettext", array($this, 'filter_gettext'), 20, 3);
108
- add_filter("gettext_with_context", array($this, 'filter_gettext_with_context'), 20, 4);
109
 
110
- add_filter('gettext', array( $this, "filter_gettext_storeLatestTranslations" ), 10, 3 );
111
 
112
- add_action('simple_history/history_page/before_gui', array($this, "output_quick_stats"));
113
- add_action('simple_history/dashboard/before_gui', array($this, "output_quick_stats"));
114
 
115
- add_action('wp_ajax_simple_history_api', array($this, 'api'));
116
 
117
- add_filter('plugin_action_links_simple-history/index.php', array($this, 'plugin_action_links'), 10, 4);
118
 
119
  /**
120
  * Fires after Simple History has done it's init stuff
@@ -123,12 +123,12 @@ class SimpleHistory {
123
  *
124
  * @param SimpleHistory $SimpleHistory This class.
125
  */
126
- do_action("simple_history/after_init", $this);
127
 
128
  // Add some extra info to each logged context when SIMPLE_HISTORY_LOG_DEBUG is set and true
129
- if ( defined("SIMPLE_HISTORY_LOG_DEBUG") && SIMPLE_HISTORY_LOG_DEBUG ) {
130
 
131
- add_filter("simple_history/log_argument/context", function($context, $level, $message, $logger) {
132
 
133
  $sh = SimpleHistory::get_instance();
134
  $context["_debug_get"] = $sh->json_encode( $_GET );
@@ -140,16 +140,16 @@ class SimpleHistory {
140
  global $argv;
141
  $context["_debug_argv"] = $sh->json_encode( $argv );
142
 
143
- $consts = get_defined_constants(true);
144
  $consts = $consts["user"];
145
  $context["_debug_user_constants"] = $sh->json_encode( $consts );
146
 
147
- $postdata = file_get_contents("php://input");
148
  $context["_debug_http_raw_post_data"] = $sh->json_encode( $postdata );
149
 
150
  return $context;
151
 
152
- }, 10, 4);
153
 
154
  }
155
 
@@ -171,7 +171,7 @@ class SimpleHistory {
171
 
172
  }
173
 
174
- function filter_gettext_storeLatestTranslations($translation, $text, $domain) {
175
 
176
  $array_max_size = 5;
177
 
@@ -187,9 +187,9 @@ class SimpleHistory {
187
  "domain" => $domain,
188
  );
189
 
190
- $arr_length = sizeof($sh_latest_translations);
191
- if ($arr_length > $array_max_size) {
192
- $sh_latest_translations = array_slice($sh_latest_translations, $arr_length - $array_max_size);
193
  }
194
 
195
  $this->gettextLatestTranslations = $sh_latest_translations;
@@ -200,53 +200,53 @@ class SimpleHistory {
200
 
201
  function setup_cron() {
202
 
203
- add_filter("simple_history/maybe_purge_db", array( $this, "maybe_purge_db") );
204
 
205
- if ( ! wp_next_scheduled('simple_history/maybe_purge_db') ) {
206
- wp_schedule_event(time(), 'daily', 'simple_history/maybe_purge_db');
207
- #error_log("not scheduled, so do schedule");
208
  } else {
209
- #error_log("is scheduled");
210
  }
211
 
212
  // Remove old schedule (only author dev sites should have it)
213
- $old_next_scheduled = wp_next_scheduled('simple_history/purge_db');
214
  if ( $old_next_scheduled ) {
215
- wp_unschedule_event($old_next_scheduled, 'simple_history/purge_db');
216
  }
217
 
218
  }
219
 
220
  public function testlog_old() {
221
 
222
- # Log that an email has been sent
223
- simple_history_add(array(
224
  "object_type" => "Email",
225
  "object_name" => "Hi there",
226
  "action" => "was sent",
227
- ));
228
 
229
- # Will show “Plugin your_plugin_name Edited” in the history log
230
- simple_history_add("action=edited&object_type=plugin&object_name=your_plugin_name");
231
 
232
- # Will show the history item "Starship USS Enterprise repaired"
233
- simple_history_add("action=repaired&object_type=Starship&object_name=USS Enterprise");
234
 
235
- # Log with some extra details about the email
236
- simple_history_add(array(
237
  "object_type" => "Email",
238
  "object_name" => "Hi there",
239
  "action" => "was sent",
240
  "description" => "The database query to generate the email took .3 seconds. This is email number 4 that is sent to this user",
241
- ));
242
 
243
  }
244
 
245
  public function onAdminHead() {
246
 
247
- if ($this->is_on_our_own_pages()) {
248
 
249
- do_action("simple_history/admin_head", $this);
250
 
251
  }
252
 
@@ -254,9 +254,9 @@ class SimpleHistory {
254
 
255
  public function onAdminFooter() {
256
 
257
- if ($this->is_on_our_own_pages()) {
258
 
259
- do_action("simple_history/admin_footer", $this);
260
 
261
  }
262
 
@@ -265,16 +265,16 @@ class SimpleHistory {
265
  /**
266
  * Output JS templated into footer
267
  */
268
- public function add_js_templates($hook) {
269
 
270
- if ($this->is_on_our_own_pages()) {
271
 
272
  ?>
273
  <script type="text/html" id="tmpl-simple-history-base">
274
 
275
  <div class="SimpleHistory__waitingForFirstLoad">
276
- <img src="<?php echo admin_url("/images/spinner.gif");?>" alt="" width="20" height="20">
277
- <?php echo _x("Loading history...", "Message visible while waiting for log to load from server the first time", "simple-history")?>
278
  </div>
279
 
280
  <div class="SimpleHistoryLogitemsWrap">
@@ -311,7 +311,7 @@ class SimpleHistory {
311
  href="#">‹</a>
312
  <span class="SimpleHistoryPaginationInput">
313
  <input class="SimpleHistoryPaginationCurrentPage" title="{{ data.strings.currentPage }}" type="text" name="paged" value="{{ data.api_args.paged }}" size="4">
314
- <?php _x("of", "page n of n", "simple-history")?>
315
  <span class="total-pages">{{ data.pages_count }}</span>
316
  </span>
317
  <a
@@ -335,7 +335,7 @@ class SimpleHistory {
335
  <div class="SimpleHistory-modal__background"></div>
336
  <div class="SimpleHistory-modal__content">
337
  <div class="SimpleHistory-modal__contentInner">
338
- <img class="SimpleHistory-modal__contentSpinner" src="<?php echo admin_url("/images/spinner.gif");?>" alt="">
339
  </div>
340
  <div class="SimpleHistory-modal__contentClose">
341
  <button class="button">✕</button>
@@ -354,7 +354,7 @@ class SimpleHistory {
354
  <div class="SimpleHistoryLogitem__firstcol"></div>
355
  <div class="SimpleHistoryLogitem__secondcol">
356
  <div class="SimpleHistoryLogitem__text">
357
- <?php _e('Sorry, but there are too many similar events to show.', "simple-history"); ?>
358
  <!-- <br>occasionsCount: {{ data.occasionsCount }}
359
  <br>occasionsCountMaxReturn: {{ data.occasionsCountMaxReturn }}
360
  <br>diff: {{ data.occasionsCount - data.occasionsCountMaxReturn }}
@@ -372,8 +372,8 @@ class SimpleHistory {
372
  <?php
373
 
374
  // Call plugins so they can add their js
375
- foreach ($this->instantiatedLoggers as $one_logger) {
376
- if (method_exists($one_logger["instance"], "adminJS")) {
377
  $one_logger["instance"]->adminJS();
378
  }
379
  }
@@ -398,20 +398,20 @@ class SimpleHistory {
398
  //sleep(2);
399
  //sleep(rand(0,3));
400
  $args = $_GET;
401
- unset($args["action"]);
402
 
403
  // Type = overview | ...
404
- $type = isset($_GET["type"]) ? $_GET["type"] : null;
405
 
406
- if (empty($args) || !$type) {
407
 
408
- wp_send_json_error(array(
409
- _x("Not enough args specified", "API: not enought arguments passed", "simple-history"),
410
- ));
411
 
412
  }
413
 
414
- if (isset($args["id"])) {
415
  $args["post__in"] = array(
416
  $args["id"],
417
  );
@@ -419,7 +419,7 @@ class SimpleHistory {
419
 
420
  $data = array();
421
 
422
- switch ($type) {
423
 
424
  case "overview":
425
  case "occasions":
@@ -427,23 +427,23 @@ class SimpleHistory {
427
 
428
  // API use SimpleHistoryLogQuery, so simply pass args on to that
429
  $logQuery = new SimpleHistoryLogQuery();
430
- $data = $logQuery->query($args);
431
 
432
  $data["api_args"] = $args;
433
 
434
  // Output can be array or HMTL
435
- if (isset($args["format"]) && "html" === $args["format"]) {
436
 
437
  $data["log_rows_raw"] = array();
438
 
439
- foreach ($data["log_rows"] as $key => $oneLogRow) {
440
 
441
  $args = array();
442
- if ($type == "single") {
443
  $args["type"] = "single";
444
  }
445
 
446
- $data["log_rows"][$key] = $this->getLogRowHTMLOutput($oneLogRow, $args);
447
  $data["num_queries"] = get_num_queries();
448
 
449
  }
@@ -460,7 +460,7 @@ class SimpleHistory {
460
 
461
  }
462
 
463
- wp_send_json_success($data);
464
 
465
  }
466
 
@@ -469,9 +469,9 @@ class SimpleHistory {
469
  * to the untranslated text too, because that's the version we want to store
470
  * in the database.
471
  */
472
- public function filter_gettext($translated_text, $untranslated_text, $domain) {
473
 
474
- if (isset($this->doFilterGettext) && $this->doFilterGettext) {
475
 
476
  $this->doFilterGettext_currentLogger->messages[] = array(
477
  "untranslated_text" => $untranslated_text,
@@ -489,9 +489,9 @@ class SimpleHistory {
489
  /**
490
  * Store messages with context
491
  */
492
- public function filter_gettext_with_context($translated_text, $untranslated_text, $context, $domain) {
493
 
494
- if (isset($this->doFilterGettext) && $this->doFilterGettext) {
495
 
496
  $this->doFilterGettext_currentLogger->messages[] = array(
497
  "untranslated_text" => $untranslated_text,
@@ -518,9 +518,9 @@ class SimpleHistory {
518
  $domain = 'simple-history';
519
 
520
  // The "plugin_locale" filter is also used in load_plugin_textdomain()
521
- $locale = apply_filters('plugin_locale', get_locale(), $domain);
522
- load_textdomain($domain, WP_LANG_DIR . '/simple-history/' . $domain . '-' . $locale . '.mo');
523
- load_plugin_textdomain($domain, FALSE, dirname($this->plugin_basename) . '/languages/');
524
 
525
  }
526
 
@@ -546,8 +546,8 @@ class SimpleHistory {
546
  public function get_view_history_capability() {
547
 
548
  $view_history_capability = "edit_pages";
549
- $view_history_capability = apply_filters("simple_history_view_history_capability", $view_history_capability);
550
- $view_history_capability = apply_filters("simple_history/view_history_capability", $view_history_capability);
551
 
552
  return $view_history_capability;
553
 
@@ -562,8 +562,8 @@ class SimpleHistory {
562
  public function get_view_settings_capability() {
563
 
564
  $view_settings_capability = "manage_options";
565
- $view_settings_capability = apply_filters("simple_history_view_settings_capability", $view_settings_capability);
566
- $view_settings_capability = apply_filters("simple_history/view_settings_capability", $view_settings_capability);
567
 
568
  return $view_settings_capability;
569
 
@@ -579,29 +579,29 @@ class SimpleHistory {
579
 
580
  array(
581
  "slug" => "settings",
582
- "name" => __("Settings", "simple-history"),
583
- "function" => array($this, "settings_output_general"),
584
  ),
585
 
586
  );
587
 
588
- if (defined("SIMPLE_HISTORY_DEV") && SIMPLE_HISTORY_DEV) {
589
 
590
  $arr_dev_tabs = array(
591
  array(
592
  "slug" => "log",
593
- "name" => __("Log (debug)", "simple-history"),
594
- "function" => array($this, "settings_output_log"),
595
  ),
596
  array(
597
  "slug" => "styles-example",
598
- "name" => __("Styles example (debug)", "simple-history"),
599
- "function" => array($this, "settings_output_styles_example"),
600
  ),
601
 
602
  );
603
 
604
- $this->arr_settings_tabs = array_merge($this->arr_settings_tabs, $arr_dev_tabs);
605
 
606
  }
607
 
@@ -615,7 +615,7 @@ class SimpleHistory {
615
  *
616
  * @since 2.1
617
  */
618
- function register_logger($loggerClassName) {
619
 
620
  $this->externalLoggers[] = $loggerClassName;
621
 
@@ -658,7 +658,7 @@ class SimpleHistory {
658
  *
659
  * @param array $loggersFiles Array with filenames
660
  */
661
- $loggersFiles = apply_filters("simple_history/loggers_files", $loggersFiles);
662
 
663
  // Array with slug of loggers to instantiate
664
  // Slug of logger must also be the name of the logger class
@@ -668,7 +668,7 @@ class SimpleHistory {
668
 
669
  $load_logger = true;
670
 
671
- $basename_no_suffix = basename($oneLoggerFile, ".php");
672
 
673
  /**
674
  * Filter to completely skip loading of a logger
@@ -678,7 +678,7 @@ class SimpleHistory {
678
  * @param bool if to load the logger. return false to not load it.
679
  * @param string slug of logger
680
  */
681
- $load_logger = apply_filters("simple_history/logger/load_logger", $load_logger, $basename_no_suffix );
682
 
683
  if ( ! $load_logger ) {
684
  continue;
@@ -699,9 +699,9 @@ class SimpleHistory {
699
  * @param array $arrLoggersToInstantiate Array with class names
700
  */
701
 
702
- do_action("simple_history/add_custom_logger", $this);
703
 
704
- $arrLoggersToInstantiate = array_merge($arrLoggersToInstantiate, $this->externalLoggers);
705
 
706
  /**
707
  * Filter the array with names of loggers to instantiate.
@@ -717,18 +717,18 @@ class SimpleHistory {
717
  *
718
  * @param array $arrLoggersToInstantiate Array with class names
719
  */
720
- $arrLoggersToInstantiate = apply_filters("simple_history/loggers_to_instantiate", $arrLoggersToInstantiate);
721
 
722
  // Instantiate each logger
723
- foreach ($arrLoggersToInstantiate as $oneLoggerName) {
724
 
725
- if (!class_exists($oneLoggerName)) {
726
  continue;
727
  }
728
 
729
- $loggerInstance = new $oneLoggerName($this);
730
 
731
- if (!is_subclass_of($loggerInstance, "SimpleLogger") && !is_a($loggerInstance, "SimpleLogger")) {
732
  continue;
733
  }
734
 
@@ -747,20 +747,27 @@ class SimpleHistory {
747
  // LoggerInfo contains all messages, both translated an not, by key.
748
  // Add messages to the loggerInstance
749
  $loopNum = 0;
750
- foreach ($loggerInfo["messages"] as $message_key => $message) {
 
 
751
 
752
- $loggerInstance->messages[$message_key] = $loggerInstance->messages[$loopNum];
753
- $loopNum++;
754
 
 
755
  }
756
 
757
  // Remove index keys, only keeping slug keys
758
- if (is_array($loggerInstance->messages)) {
759
- foreach ($loggerInstance->messages as $key => $val) {
760
- if (is_int($key)) {
761
- unset($loggerInstance->messages[$key]);
 
 
762
  }
 
763
  }
 
764
  }
765
 
766
  // Add logger to array of loggers
@@ -771,7 +778,7 @@ class SimpleHistory {
771
 
772
  }
773
 
774
- do_action("simple_history/loggers_loaded");
775
 
776
  }
777
 
@@ -804,14 +811,14 @@ class SimpleHistory {
804
  *
805
  * @param array $dropinsFiles Array with filenames
806
  */
807
- $dropinsFiles = apply_filters("simple_history/dropins_files", $dropinsFiles);
808
 
809
  $arrDropinsToInstantiate = array();
810
 
811
  foreach ( $dropinsFiles as $oneDropinFile ) {
812
 
813
  // path/path/simplehistory/dropins/SimpleHistoryDonateDropin.php => SimpleHistoryDonateDropin
814
- $oneDropinFileBasename = basename($oneDropinFile, ".php");
815
 
816
  $load_dropin = true;
817
 
@@ -824,7 +831,7 @@ class SimpleHistory {
824
  *
825
  * @param bool if to load the dropin. return false to not load it.
826
  */
827
- $load_dropin = apply_filters("simple_history/dropin/load_dropin_{$oneDropinFileBasename}", $load_dropin);
828
 
829
  /**
830
  * Filter to completely skip loading of a dropin
@@ -834,7 +841,7 @@ class SimpleHistory {
834
  * @param bool if to load the dropin. return false to not load it.
835
  * @param string slug of dropin
836
  */
837
- $load_dropin = apply_filters("simple_history/dropin/load_dropin", $load_dropin, $oneDropinFileBasename);
838
 
839
  if ( ! $load_dropin ) {
840
  continue;
@@ -853,18 +860,18 @@ class SimpleHistory {
853
  *
854
  * @param array $arrDropinsToInstantiate Array with class names
855
  */
856
- $arrDropinsToInstantiate = apply_filters("simple_history/dropins_to_instantiate", $arrDropinsToInstantiate);
857
 
858
  // Instantiate each dropin
859
- foreach ($arrDropinsToInstantiate as $oneDropinName) {
860
 
861
- if (!class_exists($oneDropinName)) {
862
  continue;
863
  }
864
 
865
  $this->instantiatedDropins[$oneDropinName] = array(
866
  "name" => $oneDropinName,
867
- "instance" => new $oneDropinName($this),
868
  );
869
  }
870
 
@@ -878,7 +885,7 @@ class SimpleHistory {
878
  */
879
  function get_pager_size() {
880
 
881
- $pager_size = get_option("simple_history_pager_size", 5);
882
 
883
  /**
884
  * Filter the pager size setting
@@ -887,7 +894,7 @@ class SimpleHistory {
887
  *
888
  * @param int $pager_size
889
  */
890
- $pager_size = apply_filters("simple_history/pager_size", $pager_size);
891
 
892
  return $pager_size;
893
 
@@ -896,16 +903,16 @@ class SimpleHistory {
896
  /**
897
  * Show a link to our settings page on the Plugins -> Installed Plugins screen
898
  */
899
- function plugin_action_links($actions, $b, $c, $d) {
900
 
901
  // Only add link if user has the right to view the settings page
902
  if ( ! current_user_can( $this->get_view_settings_capability() ) ) {
903
  return $actions;
904
  }
905
 
906
- $settings_page_url = menu_page_url(SimpleHistory::SETTINGS_MENU_SLUG, 0);
907
 
908
- $actions[] = "<a href='$settings_page_url'>" . __("Settings", "simple-history") . "</a>";
909
 
910
  return $actions;
911
 
@@ -927,10 +934,10 @@ class SimpleHistory {
927
  *
928
  * @param bool Show the page or not
929
  */
930
- $show_dashboard_widget = apply_filters("simple_history/show_dashboard_widget", true);
931
 
932
  if ( $show_dashboard_widget ) {
933
- wp_add_dashboard_widget("simple_history_dashboard_widget", __("Simple History", 'simple-history'), array($this, "dashboard_widget_output"));
934
  }
935
 
936
  }
@@ -950,9 +957,9 @@ class SimpleHistory {
950
  *
951
  * @param int $pager_size
952
  */
953
- $pager_size = apply_filters("simple_history/dashboard_pager_size", $pager_size);
954
 
955
- do_action("simple_history/dashboard/before_gui", $this);
956
 
957
  ?>
958
  <div class="SimpleHistoryGui"
@@ -962,23 +969,23 @@ class SimpleHistory {
962
 
963
  }
964
 
965
- function is_on_our_own_pages($hook = "") {
966
 
967
  $current_screen = get_current_screen();
968
 
969
- if ($current_screen && $current_screen->base == "settings_page_" . SimpleHistory::SETTINGS_MENU_SLUG) {
970
 
971
  return true;
972
 
973
- } else if ($current_screen && $current_screen->base == "dashboard_page_simple_history_page") {
974
 
975
  return true;
976
 
977
- } else if (($hook == "settings_page_" . SimpleHistory::SETTINGS_MENU_SLUG) || ($this->setting_show_on_dashboard() && $hook == "index.php") || ($this->setting_show_as_page() && $hook == "dashboard_page_simple_history_page")) {
978
 
979
  return true;
980
 
981
- } else if ($current_screen && $current_screen->base == "dashboard" && $this->setting_show_on_dashboard()) {
982
 
983
  return true;
984
 
@@ -992,35 +999,35 @@ class SimpleHistory {
992
  *
993
  * Only adds scripts to pages where the log is shown or the settings page.
994
  */
995
- function enqueue_admin_scripts($hook) {
996
 
997
- if ($this->is_on_our_own_pages()) {
998
 
999
  add_thickbox();
1000
 
1001
- wp_enqueue_style("simple_history_styles", SIMPLE_HISTORY_DIR_URL . "css/styles.css", false, SIMPLE_HISTORY_VERSION);
1002
- wp_enqueue_script("simple_history_script", SIMPLE_HISTORY_DIR_URL . "js/scripts.js", array("jquery", "backbone", "wp-util"), SIMPLE_HISTORY_VERSION, true);
1003
 
1004
- wp_enqueue_script("select2", SIMPLE_HISTORY_DIR_URL . "js/select2/select2.min.js", array("jquery"));
1005
- wp_enqueue_style("select2", SIMPLE_HISTORY_DIR_URL . "js/select2/select2.css");
1006
 
1007
  // Translations that we use in JavaScript
1008
- wp_localize_script('simple_history_script', 'simple_history_script_vars', array(
1009
- 'settingsConfirmClearLog' => __("Remove all log items?", 'simple-history'),
1010
  'pagination' => array(
1011
- 'goToTheFirstPage' => __("Go to the first page", 'simple-history'),
1012
- 'goToThePrevPage' => __("Go to the previous page", 'simple-history'),
1013
- 'goToTheNextPage' => __("Go to the next page", 'simple-history'),
1014
- 'goToTheLastPage' => __("Go to the last page", 'simple-history'),
1015
- 'currentPage' => __("Current page", 'simple-history'),
1016
  ),
1017
- "loadLogAPIError" => __("Oups, the log could not be loaded right now.", 'simple-history'),
1018
- "logNoHits" => __("Your search did not match any history events.", "simple-history"),
1019
- ));
1020
 
1021
  // Call plugins adminCSS-method, so they can add their CSS
1022
- foreach ($this->instantiatedLoggers as $one_logger) {
1023
- if (method_exists($one_logger["instance"], "adminCSS")) {
1024
  $one_logger["instance"]->adminCSS();
1025
  }
1026
  }
@@ -1033,13 +1040,13 @@ class SimpleHistory {
1033
  *
1034
  * @param SimpleHistory $SimpleHistory This class.
1035
  */
1036
- do_action("simple_history/enqueue_admin_scripts", $this);
1037
 
1038
  }
1039
 
1040
  }
1041
 
1042
- function filter_option_page_capability($capability) {
1043
  return $capability;
1044
  }
1045
 
@@ -1051,7 +1058,7 @@ class SimpleHistory {
1051
 
1052
  global $wpdb;
1053
 
1054
- $db_version = get_option("simple_history_db_version");
1055
  $table_name = $wpdb->prefix . SimpleHistory::DBTABLE;
1056
  $table_name_contexts = $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS;
1057
  $first_install = false;
@@ -1060,7 +1067,7 @@ class SimpleHistory {
1060
  // is a version of Simple History < 0.4
1061
  // or it's a first install
1062
  // Fix database not using UTF-8
1063
- if (false === $db_version) {
1064
 
1065
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1066
 
@@ -1096,16 +1103,16 @@ class SimpleHistory {
1096
  ) CHARACTER SET=utf8;";
1097
 
1098
  // Upgrade db / fix utf for varchars
1099
- dbDelta($sql);
1100
 
1101
  // Fix UTF-8 for table
1102
- $sql = sprintf('alter table %1$s charset=utf8;', $table_name);
1103
- $wpdb->query($sql);
1104
 
1105
  $db_version_prev = $db_version;
1106
  $db_version = 1;
1107
 
1108
- update_option("simple_history_db_version", $db_version);
1109
 
1110
  // We are not 100% sure that this is a first install,
1111
  // but it is at least a very old version that is being updated
@@ -1115,16 +1122,16 @@ class SimpleHistory {
1115
 
1116
  // If db version is 1 then upgrade to 2
1117
  // Version 2 added the action_description column
1118
- if (1 == intval($db_version)) {
1119
 
1120
  // Add column for action description in non-translatable free text
1121
  $sql = "ALTER TABLE {$table_name} ADD COLUMN action_description longtext";
1122
- $wpdb->query($sql);
1123
 
1124
  $db_version_prev = $db_version;
1125
  $db_version = 2;
1126
 
1127
- update_option("simple_history_db_version", $db_version);
1128
 
1129
  }
1130
 
@@ -1141,12 +1148,12 @@ class SimpleHistory {
1141
  ),
1142
  );
1143
 
1144
- foreach ($arr_options as $one_option) {
1145
 
1146
- if (false === ($option_value = get_option($one_option["name"]))) {
1147
 
1148
  // Value is not set in db, so set it to a default
1149
- update_option($one_option["name"], $one_option["default_value"]);
1150
 
1151
  }
1152
  }
@@ -1158,7 +1165,7 @@ class SimpleHistory {
1158
  *
1159
  * @since 2.0
1160
  */
1161
- if (2 == intval($db_version)) {
1162
 
1163
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1164
 
@@ -1185,7 +1192,7 @@ class SimpleHistory {
1185
  KEY loggerdate (logger, date)
1186
  ) CHARSET=utf8;";
1187
 
1188
- dbDelta($sql);
1189
 
1190
  // Add context table
1191
  $sql = "
@@ -1200,14 +1207,14 @@ class SimpleHistory {
1200
  ) CHARSET=utf8;
1201
  ";
1202
 
1203
- $wpdb->query($sql);
1204
 
1205
  $db_version_prev = $db_version;
1206
  $db_version = 3;
1207
- update_option("simple_history_db_version", $db_version);
1208
 
1209
  // Update old items to use SimpleLegacyLogger
1210
- $sql = sprintf('
1211
  UPDATE %1$s
1212
  SET
1213
  logger = "SimpleLegacyLogger",
@@ -1217,11 +1224,11 @@ class SimpleHistory {
1217
  $table_name
1218
  );
1219
 
1220
- $wpdb->query($sql);
1221
 
1222
  // Say welcome, however loggers are not added this early so we need to
1223
  // use a filter to load it later
1224
- add_action("simple_history/loggers_loaded", array($this, "addWelcomeLogMessage"));
1225
 
1226
  }// db version 2 » 3
1227
 
@@ -1233,11 +1240,11 @@ class SimpleHistory {
1233
  *
1234
  * @since 2.0
1235
  */
1236
- if (3 == intval($db_version)) {
1237
 
1238
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1239
 
1240
- $sql = sprintf('
1241
  ALTER TABLE %1$s
1242
  MODIFY `action` varchar(255) NULL,
1243
  MODIFY `object_type` varchar(255) NULL,
@@ -1248,33 +1255,102 @@ class SimpleHistory {
1248
  ',
1249
  $table_name
1250
  );
1251
- $wpdb->query($sql);
1252
 
1253
  $db_version_prev = $db_version;
1254
  $db_version = 4;
1255
 
1256
- update_option("simple_history_db_version", $db_version);
1257
 
1258
  }// end db version 3 » 4
1259
 
1260
- }// end check_for_upgrade
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1261
 
1262
  /**
1263
  * Greet users to version 2!
 
 
1264
  */
1265
  public function addWelcomeLogMessage() {
1266
 
1267
- SimpleLogger()->info(
1268
- "Welcome to Simple History 2! Hope you will enjoy this plugin.
1269
- Found bugs? Got great ideas? Send them to the plugin developer at par.thernstrom@gmail.com.",
1270
- array(
1271
- "_initiator" => SimpleLoggerLogInitiators::WORDPRESS,
1272
- )
1273
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1274
 
1275
  }
1276
 
1277
- public function registerSettingsTab($arr_tab_settings) {
1278
 
1279
  $this->arr_settings_tabs[] = $arr_tab_settings;
1280
 
@@ -1299,17 +1375,17 @@ class SimpleHistory {
1299
 
1300
  <h1 class="SimpleHistoryPageHeadline">
1301
  <div class="dashicons dashicons-backup SimpleHistoryPageHeadline__icon"></div>
1302
- <?php _e("Simple History Settings", "simple-history")?>
1303
  </h1>
1304
 
1305
  <?php
1306
- $active_tab = isset($_GET["selected-tab"]) ? $_GET["selected-tab"] : "settings";
1307
- $settings_base_url = menu_page_url(SimpleHistory::SETTINGS_MENU_SLUG, 0);
1308
  ?>
1309
 
1310
  <h2 class="nav-tab-wrapper">
1311
  <?php
1312
- foreach ($arr_settings_tabs as $one_tab) {
1313
 
1314
  $tab_slug = $one_tab["slug"];
1315
 
@@ -1317,7 +1393,7 @@ class SimpleHistory {
1317
  '<a href="%3$s" class="nav-tab %4$s">%1$s</a>',
1318
  $one_tab["name"], // 1
1319
  $tab_slug, // 2
1320
- esc_url( add_query_arg("selected-tab", $tab_slug, $settings_base_url) ), // 3
1321
  $active_tab == $tab_slug ? "nav-tab-active" : ""// 4
1322
  );
1323
 
@@ -1328,19 +1404,19 @@ class SimpleHistory {
1328
  <?php
1329
 
1330
  // Output contents for selected tab
1331
- $arr_active_tab = wp_filter_object_list($arr_settings_tabs, array("slug" => $active_tab));
1332
- $arr_active_tab = current($arr_active_tab);
1333
 
1334
  // We must have found an active tab and it must have a callable function
1335
- if (!$arr_active_tab || !is_callable($arr_active_tab["function"])) {
1336
- wp_die(__("No valid callback found", "simple-history"));
1337
  }
1338
 
1339
  $args = array(
1340
  "arr_active_tab" => $arr_active_tab,
1341
  );
1342
 
1343
- call_user_func_array($arr_active_tab["function"], $args);
1344
 
1345
  ?>
1346
 
@@ -1390,16 +1466,16 @@ class SimpleHistory {
1390
  *
1391
  * @param bool Show the page or not
1392
  */
1393
- $show_dashboard_page = apply_filters("simple_history/show_dashboard_page", true);
1394
 
1395
  if ( $show_dashboard_page ) {
1396
 
1397
  add_dashboard_page(
1398
  SimpleHistory::NAME,
1399
- _x("Simple History", 'dashboard menu name', 'simple-history'),
1400
  $this->get_view_history_capability(),
1401
  "simple_history_page",
1402
- array($this, "history_page_output")
1403
  );
1404
 
1405
  }
@@ -1408,17 +1484,17 @@ class SimpleHistory {
1408
 
1409
  // Add a settings page
1410
  $show_settings_page = true;
1411
- $show_settings_page = apply_filters("simple_history_show_settings_page", $show_settings_page);
1412
- $show_settings_page = apply_filters("simple_history/show_settings_page", $show_settings_page);
1413
 
1414
  if ( $show_settings_page ) {
1415
 
1416
  add_options_page(
1417
- __('Simple History Settings', "simple-history"),
1418
  SimpleHistory::NAME,
1419
  $this->get_view_settings_capability(),
1420
  SimpleHistory::SETTINGS_MENU_SLUG,
1421
- array($this, 'settings_page_output')
1422
  );
1423
 
1424
  }
@@ -1432,15 +1508,15 @@ class SimpleHistory {
1432
  function add_settings() {
1433
 
1434
  // Clear the log if clear button was clicked in settings
1435
- if (isset($_GET["simple_history_clear_log_nonce"]) && wp_verify_nonce($_GET["simple_history_clear_log_nonce"], 'simple_history_clear_log')) {
1436
 
1437
  $this->clear_log();
1438
- $msg = __("Cleared database", 'simple-history');
1439
- add_settings_error("simple_history_rss_feed_regenerate_secret", "simple_history_rss_feed_regenerate_secret", $msg, "updated");
1440
- set_transient('settings_errors', get_settings_errors(), 30);
1441
 
1442
- $goback = esc_url_raw( add_query_arg('settings-updated', 'true', wp_get_referer()) );
1443
- wp_redirect($goback);
1444
  exit;
1445
 
1446
  }
@@ -1451,7 +1527,7 @@ class SimpleHistory {
1451
  add_settings_section(
1452
  $settings_section_general_id,
1453
  "", // No title __("General", "simple-history"),
1454
- array($this, "settings_section_output"),
1455
  SimpleHistory::SETTINGS_MENU_SLUG// same slug as for options menu page
1456
  );
1457
 
@@ -1462,33 +1538,33 @@ class SimpleHistory {
1462
  // Checkboxes for where to show simple history
1463
  add_settings_field(
1464
  "simple_history_show_where",
1465
- __("Show history", "simple-history"),
1466
- array($this, "settings_field_where_to_show"),
1467
  SimpleHistory::SETTINGS_MENU_SLUG,
1468
  $settings_section_general_id
1469
  );
1470
 
1471
  // Nonces for show where inputs
1472
- register_setting("simple_history_settings_group", "simple_history_show_on_dashboard");
1473
- register_setting("simple_history_settings_group", "simple_history_show_as_page");
1474
 
1475
  // Dropdown number if items to show
1476
  add_settings_field(
1477
  "simple_history_number_of_items",
1478
- __("Number of items per page", "simple-history"),
1479
- array($this, "settings_field_number_of_items"),
1480
  SimpleHistory::SETTINGS_MENU_SLUG,
1481
  $settings_section_general_id
1482
  );
1483
 
1484
  // Nonces for number of items inputs
1485
- register_setting("simple_history_settings_group", "simple_history_pager_size");
1486
 
1487
  // Link to clear log
1488
  add_settings_field(
1489
  "simple_history_clear_log",
1490
- __("Clear log", "simple-history"),
1491
- array($this, "settings_field_clear_log"),
1492
  SimpleHistory::SETTINGS_MENU_SLUG,
1493
  $settings_section_general_id
1494
  );
@@ -1515,7 +1591,7 @@ class SimpleHistory {
1515
  *
1516
  * @param int $pager_size
1517
  */
1518
- $pager_size = apply_filters("simple_history/page_pager_size", $pager_size);
1519
 
1520
  ?>
1521
 
@@ -1523,7 +1599,7 @@ class SimpleHistory {
1523
 
1524
  <h1 class="SimpleHistoryPageHeadline">
1525
  <div class="dashicons dashicons-backup SimpleHistoryPageHeadline__icon"></div>
1526
- <?php echo _x("Simple History", 'history page headline', 'simple-history')?>
1527
  </h1>
1528
 
1529
  <?php
@@ -1534,7 +1610,7 @@ class SimpleHistory {
1534
  *
1535
  * @param SimpleHistory $SimpleHistory This class.
1536
  */
1537
- do_action("simple_history/history_page/before_gui", $this);
1538
  ?>
1539
 
1540
  <div class="SimpleHistoryGuiWrap">
@@ -1552,7 +1628,7 @@ class SimpleHistory {
1552
  *
1553
  * @param SimpleHistory $SimpleHistory This class.
1554
  */
1555
- do_action("simple_history/history_page/after_gui", $this);
1556
 
1557
  ?>
1558
 
@@ -1572,8 +1648,8 @@ class SimpleHistory {
1572
  */
1573
  function setting_show_on_dashboard() {
1574
 
1575
- $show_on_dashboard = get_option("simple_history_show_on_dashboard", 1);
1576
- $show_on_dashboard = apply_filters("simple_history_show_on_dashboard", $show_on_dashboard);
1577
  return (bool) $show_on_dashboard;
1578
 
1579
  }
@@ -1586,8 +1662,8 @@ class SimpleHistory {
1586
  */
1587
  function setting_show_as_page() {
1588
 
1589
- $setting = get_option("simple_history_show_as_page", 1);
1590
- $setting = apply_filters("simple_history_show_as_page", $setting);
1591
  return (bool) $setting;
1592
 
1593
  }
@@ -1626,12 +1702,12 @@ class SimpleHistory {
1626
  ?>
1627
 
1628
  <input <?php echo $show_on_dashboard ? "checked='checked'" : ""?> type="checkbox" value="1" name="simple_history_show_on_dashboard" id="simple_history_show_on_dashboard" class="simple_history_show_on_dashboard" />
1629
- <label for="simple_history_show_on_dashboard"><?php _e("on the dashboard", 'simple-history')?></label>
1630
 
1631
  <br />
1632
 
1633
  <input <?php echo $show_as_page ? "checked='checked'" : ""?> type="checkbox" value="1" name="simple_history_show_as_page" id="simple_history_show_as_page" class="simple_history_show_as_page" />
1634
- <label for="simple_history_show_as_page"><?php _e("as a page under the dashboard menu", 'simple-history')?></label>
1635
 
1636
  <?php
1637
  }
@@ -1641,19 +1717,19 @@ class SimpleHistory {
1641
  */
1642
  function settings_field_clear_log() {
1643
 
1644
- $clear_link = esc_url( add_query_arg("", "") );
1645
- $clear_link = wp_nonce_url($clear_link, "simple_history_clear_log", "simple_history_clear_log_nonce");
1646
  $clear_days = $this->get_clear_history_interval();
1647
 
1648
  echo "<p>";
1649
- if ($clear_days > 0) {
1650
- echo sprintf(__('Items in the database are automatically removed after %1$s days.', "simple-history"), $clear_days);
1651
  } else {
1652
- _e('Items in the database are kept forever.', 'simple-history');
1653
  }
1654
  echo "</p>";
1655
 
1656
- printf('<p><a class="button js-SimpleHistory-Settings-ClearLog" href="%2$s">%1$s</a></p>', __('Clear log now', 'simple-history'), $clear_link);
1657
  }
1658
 
1659
  /**
@@ -1672,8 +1748,8 @@ class SimpleHistory {
1672
  *
1673
  * @param $days Number of days of history to keep
1674
  */
1675
- $days = (int) apply_filters("simple_history_db_purge_days_interval", $days);
1676
- $days = (int) apply_filters("simple_history/db_purge_days_interval", $days);
1677
 
1678
  return $days;
1679
 
@@ -1693,25 +1769,25 @@ class SimpleHistory {
1693
 
1694
  // Get number of rows before delete
1695
  $sql_num_rows = "SELECT count(id) AS num_rows FROM {$tableprefix}{$simple_history_table}";
1696
- $num_rows = $wpdb->get_var($sql_num_rows, 0);
1697
 
1698
- #$sql = "DELETE FROM {$tableprefix}{$simple_history_table}";
1699
  $sql = "TRUNCATE {$tableprefix}{$simple_history_table}";
1700
- $wpdb->query($sql);
1701
 
1702
- #$sql = "DELETE FROM {$tableprefix}{$simple_history_context_table}";
1703
  $sql = "TRUNCATE {$tableprefix}{$simple_history_context_table}";
1704
- $wpdb->query($sql);
1705
 
1706
  // Zero state sucks
1707
  SimpleLogger()->info(
1708
- __("The log for Simple History was cleared ({num_rows} rows were removed).", "simple-history"),
1709
  array(
1710
  "num_rows" => $num_rows,
1711
  )
1712
  );
1713
 
1714
- $this->get_cache_incrementor(true);
1715
 
1716
  }
1717
 
@@ -1732,7 +1808,7 @@ class SimpleHistory {
1732
  // Let's go with sundays; purge the log on sundays
1733
 
1734
  // day of week, 1 = mon, 7 = sun
1735
- $day_of_week = date('N');
1736
  if ( 7 === (int) $day_of_week ) {
1737
 
1738
  $this->purge_db();
@@ -1750,17 +1826,17 @@ class SimpleHistory {
1750
 
1751
  $do_purge_history = true;
1752
 
1753
- $do_purge_history = apply_filters("simple_history_allow_db_purge", $do_purge_history);
1754
- $do_purge_history = apply_filters("simple_history/allow_db_purge", $do_purge_history);
1755
 
1756
- if (!$do_purge_history) {
1757
  return;
1758
  }
1759
 
1760
  $days = $this->get_clear_history_interval();
1761
 
1762
  // Never clear log if days = 0
1763
- if (0 == $days) {
1764
  return;
1765
  }
1766
 
@@ -1772,26 +1848,26 @@ class SimpleHistory {
1772
  // Get id of rows to delete
1773
  $sql = "SELECT id FROM {$table_name} WHERE DATE_ADD(date, INTERVAL $days DAY) < now()";
1774
 
1775
- $ids_to_delete = $wpdb->get_col($sql);
1776
 
1777
- if (empty($ids_to_delete)) {
1778
  // Nothing to delete
1779
  return;
1780
  }
1781
 
1782
- $sql_ids_in = implode(",", $ids_to_delete);
1783
 
1784
  // Add number of deleted rows to total_rows option
1785
- $prev_total_rows = (int) get_option("simple_history_total_rows", 0);
1786
- $total_rows = $prev_total_rows + sizeof($ids_to_delete);
1787
- update_option("simple_history_total_rows", $total_rows);
1788
 
1789
  // Remove rows + contexts
1790
  $sql_delete_history = "DELETE FROM {$table_name} WHERE id IN ($sql_ids_in)";
1791
  $sql_delete_history_context = "DELETE FROM {$table_name_contexts} WHERE history_id IN ($sql_ids_in)";
1792
 
1793
- $wpdb->query($sql_delete_history);
1794
- $wpdb->query($sql_delete_history_context);
1795
 
1796
  $message = _nx(
1797
  "Simple History removed one event that were older than {days} days",
@@ -1804,11 +1880,11 @@ class SimpleHistory {
1804
  $message,
1805
  array(
1806
  "days" => $days,
1807
- "num_rows" => sizeof($ids_to_delete),
1808
  )
1809
  );
1810
 
1811
- $this->get_cache_incrementor(true);
1812
 
1813
  }
1814
 
@@ -1820,24 +1896,24 @@ class SimpleHistory {
1820
  * @param array $row
1821
  * @return string
1822
  */
1823
- public function getLogRowPlainTextOutput($row) {
1824
 
1825
  $row_logger = $row->logger;
1826
  $logger = null;
1827
- $row->context = isset($row->context) && is_array($row->context) ? $row->context : array();
1828
 
1829
- if (!isset($row->context["_message_key"])) {
1830
  $row->context["_message_key"] = null;
1831
  }
1832
 
1833
  // Fallback to SimpleLogger if no logger exists for row
1834
- if (!isset($this->instantiatedLoggers[$row_logger])) {
1835
  $row_logger = "SimpleLogger";
1836
  }
1837
 
1838
  $logger = $this->instantiatedLoggers[$row_logger]["instance"];
1839
 
1840
- return $logger->getLogRowPlainTextOutput($row);
1841
 
1842
  }
1843
 
@@ -1852,20 +1928,20 @@ class SimpleHistory {
1852
  * @param array $row
1853
  * @return string
1854
  */
1855
- public function getLogRowHeaderOutput($row) {
1856
 
1857
  $row_logger = $row->logger;
1858
  $logger = null;
1859
- $row->context = isset($row->context) && is_array($row->context) ? $row->context : array();
1860
 
1861
  // Fallback to SimpleLogger if no logger exists for row
1862
- if (!isset($this->instantiatedLoggers[$row_logger])) {
1863
  $row_logger = "SimpleLogger";
1864
  }
1865
 
1866
  $logger = $this->instantiatedLoggers[$row_logger]["instance"];
1867
 
1868
- return $logger->getLogRowHeaderOutput($row);
1869
 
1870
  }
1871
 
@@ -1875,37 +1951,37 @@ class SimpleHistory {
1875
  * @param array $row
1876
  * @return string
1877
  */
1878
- private function getLogRowSenderImageOutput($row) {
1879
 
1880
  $row_logger = $row->logger;
1881
  $logger = null;
1882
- $row->context = isset($row->context) && is_array($row->context) ? $row->context : array();
1883
 
1884
  // Fallback to SimpleLogger if no logger exists for row
1885
- if (!isset($this->instantiatedLoggers[$row_logger])) {
1886
  $row_logger = "SimpleLogger";
1887
  }
1888
 
1889
  $logger = $this->instantiatedLoggers[$row_logger]["instance"];
1890
 
1891
- return $logger->getLogRowSenderImageOutput($row);
1892
 
1893
  }
1894
 
1895
- public function getLogRowDetailsOutput($row) {
1896
 
1897
  $row_logger = $row->logger;
1898
  $logger = null;
1899
- $row->context = isset($row->context) && is_array($row->context) ? $row->context : array();
1900
 
1901
  // Fallback to SimpleLogger if no logger exists for row
1902
- if (!isset($this->instantiatedLoggers[$row_logger])) {
1903
  $row_logger = "SimpleLogger";
1904
  }
1905
 
1906
  $logger = $this->instantiatedLoggers[$row_logger]["instance"];
1907
 
1908
- return $logger->getLogRowDetailsOutput($row);
1909
 
1910
  }
1911
 
@@ -1915,9 +1991,9 @@ class SimpleHistory {
1915
  *
1916
  * @param $value array|object|string|whatever that is json_encode'able
1917
  */
1918
- public static function json_encode($value) {
1919
 
1920
- return version_compare(PHP_VERSION, '5.4.0') >= 0 ? json_encode($value, JSON_PRETTY_PRINT) : json_encode($value);
1921
 
1922
  }
1923
 
@@ -1926,8 +2002,8 @@ class SimpleHistory {
1926
  * @param string $haystack
1927
  * @param string $needle
1928
  */
1929
- public static function ends_with($haystack, $needle) {
1930
- return $needle === substr($haystack, -strlen($needle));
1931
  }
1932
 
1933
  /**
@@ -1936,21 +2012,21 @@ class SimpleHistory {
1936
  * @param array $oneLogRow SimpleHistoryLogQuery array with data from SimpleHistoryLogQuery
1937
  * @return string
1938
  */
1939
- public function getLogRowHTMLOutput($oneLogRow, $args) {
1940
 
1941
  $defaults = array(
1942
  "type" => "overview", // or "single" to include more stuff
1943
  );
1944
 
1945
- $args = wp_parse_args($args, $defaults);
1946
 
1947
- $header_html = $this->getLogRowHeaderOutput($oneLogRow);
1948
- $plain_text_html = $this->getLogRowPlainTextOutput($oneLogRow);
1949
- $sender_image_html = $this->getLogRowSenderImageOutput($oneLogRow);
1950
 
1951
  // Details = for example thumbnail of media
1952
- $details_html = trim($this->getLogRowDetailsOutput($oneLogRow));
1953
- if ($details_html) {
1954
 
1955
  $details_html = sprintf(
1956
  '<div class="SimpleHistoryLogitem__details">%1$s</div>',
@@ -1963,27 +2039,27 @@ class SimpleHistory {
1963
  $occasions_count = $oneLogRow->subsequentOccasions - 1;
1964
  $occasions_html = "";
1965
 
1966
- if ($occasions_count > 0) {
1967
 
1968
  $occasions_html = '<div class="SimpleHistoryLogitem__occasions">';
1969
 
1970
  $occasions_html .= '<a href="#" class="SimpleHistoryLogitem__occasionsLink">';
1971
  $occasions_html .= sprintf(
1972
- _n('+%1$s similar event', '+%1$s similar events', $occasions_count, "simple-history"),
1973
  $occasions_count
1974
  );
1975
  $occasions_html .= '</a>';
1976
 
1977
  $occasions_html .= '<span class="SimpleHistoryLogitem__occasionsLoading">';
1978
  $occasions_html .= sprintf(
1979
- __('Loading…', "simple-history"),
1980
  $occasions_count
1981
  );
1982
  $occasions_html .= '</span>';
1983
 
1984
  $occasions_html .= '<span class="SimpleHistoryLogitem__occasionsLoaded">';
1985
  $occasions_html .= sprintf(
1986
- __('Showing %1$s more', "simple-history"),
1987
  $occasions_count
1988
  );
1989
  $occasions_html .= '</span>';
@@ -1994,36 +2070,36 @@ class SimpleHistory {
1994
 
1995
  // Add data atributes to log row, so plugins can do stuff
1996
  $data_attrs = "";
1997
- $data_attrs .= sprintf(' data-row-id="%1$d" ', $oneLogRow->id);
1998
- $data_attrs .= sprintf(' data-occasions-count="%1$d" ', $occasions_count);
1999
- $data_attrs .= sprintf(' data-occasions-id="%1$s" ', esc_attr( $oneLogRow->occasionsID ));
2000
 
2001
- if ( isset($oneLogRow->context["_server_remote_addr"]) ) {
2002
- $data_attrs .= sprintf(' data-ip-address="%1$s" ', esc_attr( $oneLogRow->context["_server_remote_addr"] ) );
2003
  }
2004
 
2005
- $arr_found_additional_ip_headers = $this->instantiatedLoggers["SimpleLogger"]["instance"]->get_event_ip_number_headers($oneLogRow);
2006
  if ( $arr_found_additional_ip_headers ) {
2007
- $data_attrs .= sprintf(' data-ip-address-multiple="1" ' );
2008
  }
2009
 
2010
- $data_attrs .= sprintf(' data-logger="%1$s" ', esc_attr( $oneLogRow->logger ) );
2011
- $data_attrs .= sprintf(' data-level="%1$s" ', esc_attr( $oneLogRow->level ) );
2012
- $data_attrs .= sprintf(' data-date="%1$s" ', esc_attr( $oneLogRow->date ) );
2013
- $data_attrs .= sprintf(' data-initiator="%1$s" ', esc_attr( $oneLogRow->initiator ) );
2014
 
2015
  if ( isset( $oneLogRow->context["_user_id"] ) ) {
2016
- $data_attrs .= sprintf(' data-initiator-user-id="%1$d" ', $oneLogRow->context["_user_id"] );
2017
  }
2018
 
2019
  // If type is single then include more details
2020
  $more_details_html = "";
2021
  if ( $args["type"] == "single" ) {
2022
 
2023
- $more_details_html = apply_filters("simple_history/log_html_output_details_single/html_before_context_table", $more_details_html, $oneLogRow);
2024
 
2025
- $more_details_html .= sprintf('<h2 class="SimpleHistoryLogitem__moreDetailsHeadline">%1$s</h2>', __("Context data", "simple-history"));
2026
- $more_details_html .= "<p>" . __("This is potentially useful meta data that a logger has saved.", "simple-history") . "</p>";
2027
  $more_details_html .= "<table class='SimpleHistoryLogitem__moreDetailsContext'>";
2028
  $more_details_html .= sprintf(
2029
  '<tr>
@@ -2034,7 +2110,7 @@ class SimpleHistory {
2034
  "Value"
2035
  );
2036
 
2037
- $logRowKeysToShow = array_fill_keys( array_keys( (array) $oneLogRow), true);
2038
 
2039
  /**
2040
  * Filter what keys to show from oneLogRow
@@ -2055,7 +2131,7 @@ class SimpleHistory {
2055
  * @param array with keys to show. key to show = key. value = boolean to show or not.
2056
  * @param object log row to show details from
2057
  */
2058
- $logRowKeysToShow = apply_filters("simple_history/log_html_output_details_table/row_keys_to_show", $logRowKeysToShow, $oneLogRow);
2059
 
2060
  // Hide some keys by default
2061
  unset(
@@ -2071,12 +2147,12 @@ class SimpleHistory {
2071
  foreach ( $oneLogRow as $rowKey => $rowVal ) {
2072
 
2073
  // Only columns from oneLogRow that exist in logRowKeysToShow will be outputed
2074
- if ( ! array_key_exists($rowKey, $logRowKeysToShow) || ! $logRowKeysToShow[$rowKey] ) {
2075
  continue;
2076
  }
2077
 
2078
  // skip arrays and objects and such
2079
- if (is_array($rowVal) || is_object($rowVal)) {
2080
  continue;
2081
  }
2082
 
@@ -2085,14 +2161,14 @@ class SimpleHistory {
2085
  <td>%1$s</td>
2086
  <td>%2$s</td>
2087
  </tr>',
2088
- esc_html($rowKey),
2089
- esc_html($rowVal)
2090
  );
2091
 
2092
  }
2093
 
2094
 
2095
- $logRowContextKeysToShow = array_fill_keys( array_keys( (array) $oneLogRow->context), true);
2096
  /*
2097
  error_log($this->json_encode($logRowContextKeysToShow));
2098
  Marker - 2 maj 2015 20:51:54
@@ -2134,12 +2210,12 @@ class SimpleHistory {
2134
  * @param array with keys to show. key to show = key. value = boolean to show or not.
2135
  * @param object log row to show details from
2136
  */
2137
- $logRowContextKeysToShow = apply_filters("simple_history/log_html_output_details_table/context_keys_to_show", $logRowContextKeysToShow, $oneLogRow);
2138
 
2139
  foreach ( $oneLogRow->context as $contextKey => $contextVal ) {
2140
 
2141
  // Only columns from context that exist in logRowContextKeysToShow will be outputed
2142
- if ( ! array_key_exists($contextKey, $logRowContextKeysToShow) || ! $logRowContextKeysToShow[$contextKey] ) {
2143
  continue;
2144
  }
2145
 
@@ -2148,15 +2224,15 @@ class SimpleHistory {
2148
  <td>%1$s</td>
2149
  <td>%2$s</td>
2150
  </tr>',
2151
- esc_html($contextKey),
2152
- esc_html($contextVal)
2153
  );
2154
 
2155
  }
2156
 
2157
  $more_details_html .= "</table>";
2158
 
2159
- $more_details_html = apply_filters("simple_history/log_html_output_details_single/html_after_context_table", $more_details_html, $oneLogRow);
2160
 
2161
  $more_details_html = sprintf(
2162
  '<div class="SimpleHistoryLogitem__moreDetails">%1$s</div>',
@@ -2172,7 +2248,7 @@ class SimpleHistory {
2172
  "SimpleHistoryLogitem--logger-{$oneLogRow->logger}",
2173
  );
2174
 
2175
- if (isset($oneLogRow->initiator) && !empty($oneLogRow->initiator)) {
2176
  $classes[] = "SimpleHistoryLogitem--initiator-" . $oneLogRow->initiator;
2177
  }
2178
 
@@ -2184,7 +2260,7 @@ class SimpleHistory {
2184
  $log_level_tag_html = sprintf(
2185
  ' <span class="SimpleHistoryLogitem--logleveltag SimpleHistoryLogitem--logleveltag-%1$s">%2$s</span>',
2186
  $oneLogRow->level,
2187
- $this->getLogLevelTranslated($oneLogRow->level)
2188
  );
2189
 
2190
  $plain_text_html .= $log_level_tag_html;
@@ -2196,7 +2272,7 @@ class SimpleHistory {
2196
  *
2197
  * @param $classes Array with classes
2198
  */
2199
- $classes = apply_filters("simple_history/logrowhtmloutput/classes", $classes);
2200
 
2201
  // Generate the HTML output for a row
2202
  $output = sprintf(
@@ -2223,19 +2299,19 @@ class SimpleHistory {
2223
  $oneLogRow->logger, // 7
2224
  $data_attrs, // 8 data attributes
2225
  $more_details_html, // 9
2226
- esc_attr( join(" ", $classes) ) // 10
2227
  );
2228
 
2229
  // Get the main message row.
2230
  // Should be as plain as possible, like plain text
2231
  // but with links to for example users and posts
2232
- #SimpleLoggerFormatter::getRowTextOutput($oneLogRow);
2233
 
2234
  // Get detailed HTML-based output
2235
  // May include images, lists, any cool stuff needed to view
2236
- #SimpleLoggerFormatter::getRowHTMLOutput($oneLogRow);
2237
 
2238
- return trim($output);
2239
 
2240
  }
2241
 
@@ -2246,76 +2322,76 @@ class SimpleHistory {
2246
  * @param string $loglevel
2247
  * @return string translated loglevel
2248
  */
2249
- function getLogLevelTranslated($loglevel) {
2250
 
2251
  $str_translated = "";
2252
 
2253
- switch ($loglevel) {
2254
 
2255
  // Lowercase
2256
  case "emergency":
2257
- $str_translated = _x("emergency", "Log level in gui", "simple-history");
2258
  break;
2259
 
2260
  case "alert":
2261
- $str_translated = _x("alert", "Log level in gui", "simple-history");
2262
  break;
2263
 
2264
  case "critical":
2265
- $str_translated = _x("critical", "Log level in gui", "simple-history");
2266
  break;
2267
 
2268
  case "error":
2269
- $str_translated = _x("error", "Log level in gui", "simple-history");
2270
  break;
2271
 
2272
  case "warning":
2273
- $str_translated = _x("warning", "Log level in gui", "simple-history");
2274
  break;
2275
 
2276
  case "notice":
2277
- $str_translated = _x("notice", "Log level in gui", "simple-history");
2278
  break;
2279
 
2280
  case "info":
2281
- $str_translated = _x("info", "Log level in gui", "simple-history");
2282
  break;
2283
 
2284
  case "debug":
2285
- $str_translated = _x("debug", "Log level in gui", "simple-history");
2286
  break;
2287
 
2288
  // Uppercase
2289
  case "Emergency":
2290
- $str_translated = _x("Emergency", "Log level in gui", "simple-history");
2291
  break;
2292
 
2293
  case "Alert":
2294
- $str_translated = _x("Alert", "Log level in gui", "simple-history");
2295
  break;
2296
 
2297
  case "Critical":
2298
- $str_translated = _x("Critical", "Log level in gui", "simple-history");
2299
  break;
2300
 
2301
  case "Error":
2302
- $str_translated = _x("Error", "Log level in gui", "simple-history");
2303
  break;
2304
 
2305
  case "Warning":
2306
- $str_translated = _x("Warning", "Log level in gui", "simple-history");
2307
  break;
2308
 
2309
  case "Notice":
2310
- $str_translated = _x("Notice", "Log level in gui", "simple-history");
2311
  break;
2312
 
2313
  case "Info":
2314
- $str_translated = _x("Info", "Log level in gui", "simple-history");
2315
  break;
2316
 
2317
  case "Debug":
2318
- $str_translated = _x("Debug", "Log level in gui", "simple-history");
2319
  break;
2320
 
2321
  default:
@@ -2336,19 +2412,19 @@ class SimpleHistory {
2336
  public function getInstantiatedDropins() {
2337
 
2338
  return $this->instantiatedDropins;
2339
-
2340
  }
2341
-
2342
 
2343
- public function getInstantiatedLoggerBySlug($slug = "") {
2344
 
2345
- if (empty($slug)) {
 
 
2346
  return false;
2347
  }
2348
 
2349
- foreach ($this->getInstantiatedLoggers() as $one_logger) {
2350
 
2351
- if ($slug == $one_logger["instance"]->slug) {
2352
  return $one_logger["instance"];
2353
  }
2354
 
@@ -2366,24 +2442,24 @@ class SimpleHistory {
2366
  * @param string $format format to return loggers in. Default is array.
2367
  * @return array
2368
  */
2369
- public function getLoggersThatUserCanRead($user_id = "", $format = "array") {
2370
 
2371
  $arr_loggers_user_can_view = array();
2372
 
2373
- if (!is_numeric($user_id)) {
2374
  $user_id = get_current_user_id();
2375
  }
2376
 
2377
  $loggers = $this->getInstantiatedLoggers();
2378
- foreach ($loggers as $one_logger) {
2379
 
2380
  $logger_capability = $one_logger["instance"]->getCapability();
2381
 
2382
  //$arr_loggers_user_can_view = apply_filters("simple_history/loggers_user_can_read", $user_id, $arr_loggers_user_can_view);
2383
- $user_can_read_logger = user_can($user_id, $logger_capability);
2384
- $user_can_read_logger = apply_filters("simple_history/loggers_user_can_read/can_read_single_logger", $user_can_read_logger, $one_logger["instance"], $user_id);
2385
 
2386
- if ($user_can_read_logger) {
2387
  $arr_loggers_user_can_view[] = $one_logger;
2388
  }
2389
 
@@ -2397,14 +2473,14 @@ class SimpleHistory {
2397
  * @param array $arr_loggers_user_can_view Array with loggers that user $user_id can read
2398
  * @param int user_id ID of user to check read capability for
2399
  */
2400
- $arr_loggers_user_can_view = apply_filters("simple_history/loggers_user_can_read", $arr_loggers_user_can_view, $user_id);
2401
 
2402
  // just return array with slugs in parenthesis suitable for sql-where
2403
- if ("sql" == $format) {
2404
 
2405
  $str_return = "(";
2406
 
2407
- foreach ($arr_loggers_user_can_view as $one_logger) {
2408
 
2409
  $str_return .= sprintf(
2410
  '"%1$s", ',
@@ -2413,7 +2489,7 @@ class SimpleHistory {
2413
 
2414
  }
2415
 
2416
- $str_return = rtrim($str_return, " ,");
2417
  $str_return .= ")";
2418
 
2419
  return $str_return;
@@ -2437,12 +2513,12 @@ class SimpleHistory {
2437
  * @param string $alt Alternative text to use in image tag. Defaults to blank
2438
  * @return string <img> tag for the user's avatar
2439
  */
2440
- function get_avatar($email, $size = '96', $default = '', $alt = false) {
2441
 
2442
  // WP setting for avatars is to show, so just use the built in function
2443
- if ( get_option('show_avatars') ) {
2444
 
2445
- $avatar = get_avatar($email, $size, $default, $alt);
2446
 
2447
  return $avatar;
2448
 
@@ -2450,19 +2526,19 @@ class SimpleHistory {
2450
 
2451
  // WP setting for avatar was to not show, but we do it anyway, using the same code as get_avatar() would have used
2452
 
2453
- if (false === $alt) {
2454
  $safe_alt = '';
2455
  } else {
2456
- $safe_alt = esc_attr($alt);
2457
  }
2458
 
2459
- if (!is_numeric($size)) {
2460
  $size = '96';
2461
  }
2462
 
2463
- if (empty($default)) {
2464
- $avatar_default = get_option('avatar_default');
2465
- if (empty($avatar_default)) {
2466
  $default = 'mystery';
2467
  } else {
2468
  $default = $avatar_default;
@@ -2470,52 +2546,52 @@ class SimpleHistory {
2470
 
2471
  }
2472
 
2473
- if (!empty($email)) {
2474
- $email_hash = md5(strtolower(trim($email)));
2475
  }
2476
 
2477
- if (is_ssl()) {
2478
  $host = 'https://secure.gravatar.com';
2479
  } else {
2480
- if (!empty($email)) {
2481
- $host = sprintf("http://%d.gravatar.com", (hexdec($email_hash[0]) % 2));
2482
  } else {
2483
  $host = 'http://0.gravatar.com';
2484
  }
2485
 
2486
  }
2487
 
2488
- if ('mystery' == $default) {
2489
  $default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}";
2490
  }
2491
  // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
2492
- elseif ('blank' == $default) {
2493
- $default = $email ? 'blank' : includes_url('images/blank.gif');
2494
- } elseif (!empty($email) && 'gravatar_default' == $default) {
2495
  $default = '';
2496
- } elseif ('gravatar_default' == $default) {
2497
  $default = "$host/avatar/?s={$size}";
2498
- } elseif (empty($email)) {
2499
  $default = "$host/avatar/?d=$default&amp;s={$size}";
2500
- } elseif (strpos($default, 'http://') === 0) {
2501
- $default = add_query_arg('s', $size, $default);
2502
  }
2503
 
2504
- if (!empty($email)) {
2505
  $out = "$host/avatar/";
2506
  $out .= $email_hash;
2507
  $out .= '?s=' . $size;
2508
- $out .= '&amp;d=' . urlencode($default);
2509
 
2510
- $rating = get_option('avatar_rating');
2511
- if (!empty($rating)) {
2512
  $out .= "&amp;r={$rating}";
2513
  }
2514
 
2515
- $out = str_replace('&#038;', '&amp;', esc_url($out));
2516
  $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
2517
  } else {
2518
- $out = esc_url($default);
2519
  $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
2520
  }
2521
 
@@ -2549,18 +2625,18 @@ class SimpleHistory {
2549
 
2550
  // Get number of events today
2551
  $logQuery = new SimpleHistoryLogQuery();
2552
- $logResults = $logQuery->query(array(
2553
  "posts_per_page" => 1,
2554
- "date_from" => strtotime("today"),
2555
- ));
2556
 
2557
  $total_row_count = (int) $logResults["total_row_count"];
2558
 
2559
  // Get sql query for where to read only loggers current user is allowed to read/view
2560
- $sql_loggers_in = $this->getLoggersThatUserCanRead(get_current_user_id(), "sql");
2561
 
2562
  // Get number of users today, i.e. events with wp_user as initiator
2563
- $sql_users_today = sprintf('
2564
  SELECT
2565
  DISTINCT(c.value) AS user_id
2566
  #h.id, h.logger, h.level, h.initiator, h.date
@@ -2573,18 +2649,18 @@ class SimpleHistory {
2573
  AND date > "%2$s"
2574
  ',
2575
  $sql_loggers_in,
2576
- date("Y-m-d H:i", strtotime("today")),
2577
  $wpdb->prefix . SimpleHistory::DBTABLE,
2578
  $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS
2579
  );
2580
 
2581
  $cache_key = "quick_stats_users_today_" . md5( serialize( $sql_loggers_in ) );
2582
  $cache_group = "simple-history-" . $this->get_cache_incrementor();
2583
- $results_users_today = wp_cache_get($cache_key, $cache_group );
2584
 
2585
  if ( false === $results_users_today ) {
2586
- $results_users_today = $wpdb->get_results($sql_users_today);
2587
- wp_cache_set($cache_key, $results_users_today, $cache_group );
2588
  }
2589
 
2590
  $count_users_today = sizeof( $results_users_today );
@@ -2597,14 +2673,14 @@ class SimpleHistory {
2597
  AND date > "%2$s"
2598
  ',
2599
  $sql_loggers_in,
2600
- date("Y-m-d H:i", strtotime("today")),
2601
  $wpdb->prefix . SimpleHistory::DBTABLE,
2602
  $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS
2603
  );
2604
 
2605
- $sql_other_sources_where = apply_filters("simple_history/quick_stats_where", $sql_other_sources_where);
2606
 
2607
- $sql_other_sources = sprintf('
2608
  SELECT
2609
  DISTINCT(h.initiator) AS initiator
2610
  FROM %3$s AS h
@@ -2612,28 +2688,28 @@ class SimpleHistory {
2612
  %5$s
2613
  ',
2614
  $sql_loggers_in,
2615
- date("Y-m-d H:i", strtotime("today")),
2616
  $wpdb->prefix . SimpleHistory::DBTABLE,
2617
  $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS,
2618
  $sql_other_sources_where // 5
2619
  );
2620
  // sf_d($sql_other_sources, '$sql_other_sources');
2621
 
2622
- $cache_key = "quick_stats_results_other_sources_today_" . md5( serialize($sql_other_sources) );
2623
- $results_other_sources_today = wp_cache_get($cache_key, $cache_group);
2624
 
2625
  if ( false === $results_other_sources_today ) {
2626
 
2627
- $results_other_sources_today = $wpdb->get_results($sql_other_sources);
2628
- wp_cache_set($cache_key, $results_other_sources_today, $cache_group);
2629
 
2630
  }
2631
 
2632
- $count_other_sources = sizeof($results_other_sources_today);
2633
 
2634
- #sf_d($logResults, '$logResults');
2635
- #sf_d($results_users_today, '$sql_users_today');
2636
- #sf_d($results_other_sources_today, '$results_other_sources_today');
2637
 
2638
  ?>
2639
  <div class="SimpleHistoryQuickStats">
@@ -2645,7 +2721,7 @@ class SimpleHistory {
2645
  // No results today at all
2646
  if ( $total_row_count == 0 ) {
2647
 
2648
- $msg_tmpl = __("No events today so far.", "simple-history");
2649
 
2650
  } else {
2651
 
@@ -2664,49 +2740,49 @@ class SimpleHistory {
2664
  // A single event existed and was from a user
2665
  // 1 event today from 1 user.
2666
  if ( $total_row_count == 1 && $count_users_today == 1 ) {
2667
- $msg_tmpl .= __('One event today from one user.', "simple-history");
2668
  }
2669
 
2670
  // A single event existed and was from another source
2671
  // 1 event today from 1 source.
2672
- if ( $total_row_count == 1 && !$count_users_today ) {
2673
- $msg_tmpl .= __('One event today from one source.', "simple-history");
2674
  }
2675
 
2676
  // Multiple events from a single user
2677
  // 3 events today from one user.
2678
- if ( $total_row_count > 1 && $count_users_today == 1 && !$count_other_sources ) {
2679
- $msg_tmpl .= __('%1$d events today from one user.', "simple-history");
2680
  }
2681
 
2682
  // Multiple events from only users
2683
  // 2 events today from 2 users.
2684
  if ( $total_row_count > 1 && $count_users_today == $total_row_count ) {
2685
- $msg_tmpl .= __('%1$d events today from %2$d users.', "simple-history");
2686
  }
2687
 
2688
  // Multiple events from 1 single user and 1 single other source
2689
  // 2 events today from 1 user and 1 other source.
2690
  if ( $total_row_count && 1 == $count_users_today && 1 == $count_other_sources ) {
2691
- $msg_tmpl .= __('%1$d events today from one user and one other source.', "simple-history");
2692
  }
2693
 
2694
  // Multiple events from multple users but from only 1 single other source
2695
  // 3 events today from 2 users and 1 other source.
2696
  if ( $total_row_count > 1 && $count_users_today > 1 && $count_other_sources == 1 ) {
2697
- $msg_tmpl .= __('%1$d events today from one user and one other source.', "simple-history");
2698
  }
2699
 
2700
  // Multiple events from 1 user but from multiple other source
2701
  // 3 events today from 1 user and 2 other sources.
2702
  if ( $total_row_count > 1 && 1 == $count_users_today && $count_other_sources > 1 ) {
2703
- $msg_tmpl .= __('%1$d events today from one user and %3$d other sources.', "simple-history");
2704
  }
2705
 
2706
  // Multiple events from multiple user and from multiple other sources
2707
  // 4 events today from 2 users and 2 other sources.
2708
  if ( $total_row_count > 1 && $count_users_today > 1 && $count_other_sources > 1 ) {
2709
- $msg_tmpl .= __('%1$s events today from %2$d users and %3$d other sources.', "simple-history");
2710
  }
2711
 
2712
  }
@@ -2783,7 +2859,7 @@ function SimpleLogger() {
2783
  * SimpleHistory()->info();
2784
  * instead
2785
  */
2786
- function simple_history_add($args) {
2787
 
2788
  $defaults = array(
2789
  "action" => null,
@@ -2799,7 +2875,7 @@ function simple_history_add($args) {
2799
 
2800
  $message = "{$context["object_type"]} {$context["object_name"]} {$context["action"]}";
2801
 
2802
- SimpleLogger()->info($message, $context);
2803
 
2804
  } // simple_history_add
2805
 
@@ -2847,23 +2923,23 @@ function simple_history_text_diff( $left_string, $right_string, $args = null ) {
2847
 
2848
  $args = wp_parse_args( $args, $defaults );
2849
 
2850
- if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) )
2851
- require( ABSPATH . WPINC . '/wp-diff.php' );
2852
 
2853
- $left_string = normalize_whitespace($left_string);
2854
- $right_string = normalize_whitespace($right_string);
2855
 
2856
- $left_lines = explode("\n", $left_string);
2857
- $right_lines = explode("\n", $right_string);
2858
- $text_diff = new Text_Diff($left_lines, $right_lines);
2859
 
2860
  $renderer = new WP_Text_Diff_Renderer_Table( $args );
2861
  $renderer->_leading_context_lines = $args["leading_context_lines"];
2862
  $renderer->_trailing_context_lines = $args["trailing_context_lines"];
2863
 
2864
- $diff = $renderer->render($text_diff);
2865
 
2866
- if ( !$diff )
2867
  return '';
2868
 
2869
  $r = "<table class='diff SimpleHistory__diff'>\n";
70
  *
71
  * @param SimpleHistory $SimpleHistory This class.
72
  */
73
+ do_action( "simple_history/before_init", $this );
74
 
75
  $this->setup_variables();
76
 
77
  // Actions and filters, ordered by order specified in codex: http://codex.wordpress.org/Plugin_API/Action_Reference
78
+ add_action( 'after_setup_theme', array( $this, 'load_plugin_textdomain' ) );
79
+ add_action( 'after_setup_theme', array( $this, 'add_default_settings_tabs' ) );
80
+
81
  // Plugins and dropins are loaded using the "after_setup_theme" filter so
82
  // themes can use filters to modify the loading of them.
83
  // The drawback with this is that for example logouts done when plugins like
84
  // iThemes Security is installed is not logged, because those plugins fire wp_logout()
85
  // using filter "plugins_loaded", i.e. before simple history has loaded its filters.
86
+ add_action( 'after_setup_theme', array( $this, 'load_loggers' ) );
87
+ add_action( 'after_setup_theme', array( $this, 'load_dropins' ) );
88
 
89
  // Run before loading of loggers and before menu items are added
90
+ add_action( 'after_setup_theme', array( $this, 'check_for_upgrade' ), 5 );
91
 
92
+ add_action( 'after_setup_theme', array( $this, 'setup_cron' ) );
93
 
94
+ add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
95
+ add_action( 'admin_menu', array( $this, 'add_settings' ) );
96
 
97
+ add_action( 'admin_footer', array( $this, "add_js_templates" ) );
98
 
99
+ add_action( 'wp_dashboard_setup', array( $this, 'add_dashboard_widget' ) );
100
 
101
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
102
 
103
+ add_action( 'admin_head', array( $this, "onAdminHead" ) );
104
+ add_action( 'admin_footer', array( $this, "onAdminFooter" ) );
105
 
106
  // Filters and actions not called during regular boot
107
+ add_filter( "gettext", array( $this, 'filter_gettext' ), 20, 3 );
108
+ add_filter( "gettext_with_context", array( $this, 'filter_gettext_with_context' ), 20, 4 );
109
 
110
+ add_filter( 'gettext', array( $this, "filter_gettext_storeLatestTranslations" ), 10, 3 );
111
 
112
+ add_action( 'simple_history/history_page/before_gui', array( $this, "output_quick_stats" ) );
113
+ add_action( 'simple_history/dashboard/before_gui', array( $this, "output_quick_stats" ) );
114
 
115
+ add_action( 'wp_ajax_simple_history_api', array( $this, 'api' ) );
116
 
117
+ add_filter( 'plugin_action_links_simple-history/index.php', array( $this, 'plugin_action_links' ), 10, 4 );
118
 
119
  /**
120
  * Fires after Simple History has done it's init stuff
123
  *
124
  * @param SimpleHistory $SimpleHistory This class.
125
  */
126
+ do_action( "simple_history/after_init", $this );
127
 
128
  // Add some extra info to each logged context when SIMPLE_HISTORY_LOG_DEBUG is set and true
129
+ if ( defined( "SIMPLE_HISTORY_LOG_DEBUG" ) && SIMPLE_HISTORY_LOG_DEBUG ) {
130
 
131
+ add_filter( "simple_history/log_argument/context", function( $context, $level, $message, $logger ) {
132
 
133
  $sh = SimpleHistory::get_instance();
134
  $context["_debug_get"] = $sh->json_encode( $_GET );
140
  global $argv;
141
  $context["_debug_argv"] = $sh->json_encode( $argv );
142
 
143
+ $consts = get_defined_constants( true );
144
  $consts = $consts["user"];
145
  $context["_debug_user_constants"] = $sh->json_encode( $consts );
146
 
147
+ $postdata = file_get_contents( "php://input" );
148
  $context["_debug_http_raw_post_data"] = $sh->json_encode( $postdata );
149
 
150
  return $context;
151
 
152
+ }, 10, 4 );
153
 
154
  }
155
 
171
 
172
  }
173
 
174
+ function filter_gettext_storeLatestTranslations( $translation, $text, $domain ) {
175
 
176
  $array_max_size = 5;
177
 
187
  "domain" => $domain,
188
  );
189
 
190
+ $arr_length = sizeof( $sh_latest_translations );
191
+ if ( $arr_length > $array_max_size ) {
192
+ $sh_latest_translations = array_slice( $sh_latest_translations, $arr_length - $array_max_size );
193
  }
194
 
195
  $this->gettextLatestTranslations = $sh_latest_translations;
200
 
201
  function setup_cron() {
202
 
203
+ add_filter( "simple_history/maybe_purge_db", array( $this, "maybe_purge_db" ) );
204
 
205
+ if ( ! wp_next_scheduled( 'simple_history/maybe_purge_db' ) ) {
206
+ wp_schedule_event( time(), 'daily', 'simple_history/maybe_purge_db' );
207
+ //error_log("not scheduled, so do schedule");
208
  } else {
209
+ //error_log("is scheduled");
210
  }
211
 
212
  // Remove old schedule (only author dev sites should have it)
213
+ $old_next_scheduled = wp_next_scheduled( 'simple_history/purge_db' );
214
  if ( $old_next_scheduled ) {
215
+ wp_unschedule_event( $old_next_scheduled, 'simple_history/purge_db' );
216
  }
217
 
218
  }
219
 
220
  public function testlog_old() {
221
 
222
+ // Log that an email has been sent
223
+ simple_history_add( array(
224
  "object_type" => "Email",
225
  "object_name" => "Hi there",
226
  "action" => "was sent",
227
+ ) );
228
 
229
+ // Will show “Plugin your_plugin_name Edited” in the history log
230
+ simple_history_add( "action=edited&object_type=plugin&object_name=your_plugin_name" );
231
 
232
+ // Will show the history item "Starship USS Enterprise repaired"
233
+ simple_history_add( "action=repaired&object_type=Starship&object_name=USS Enterprise" );
234
 
235
+ // Log with some extra details about the email
236
+ simple_history_add( array(
237
  "object_type" => "Email",
238
  "object_name" => "Hi there",
239
  "action" => "was sent",
240
  "description" => "The database query to generate the email took .3 seconds. This is email number 4 that is sent to this user",
241
+ ) );
242
 
243
  }
244
 
245
  public function onAdminHead() {
246
 
247
+ if ( $this->is_on_our_own_pages() ) {
248
 
249
+ do_action( "simple_history/admin_head", $this );
250
 
251
  }
252
 
254
 
255
  public function onAdminFooter() {
256
 
257
+ if ( $this->is_on_our_own_pages() ) {
258
 
259
+ do_action( "simple_history/admin_footer", $this );
260
 
261
  }
262
 
265
  /**
266
  * Output JS templated into footer
267
  */
268
+ public function add_js_templates( $hook ) {
269
 
270
+ if ( $this->is_on_our_own_pages() ) {
271
 
272
  ?>
273
  <script type="text/html" id="tmpl-simple-history-base">
274
 
275
  <div class="SimpleHistory__waitingForFirstLoad">
276
+ <img src="<?php echo admin_url( "/images/spinner.gif" );?>" alt="" width="20" height="20">
277
+ <?php echo _x( "Loading history...", "Message visible while waiting for log to load from server the first time", "simple-history" )?>
278
  </div>
279
 
280
  <div class="SimpleHistoryLogitemsWrap">
311
  href="#">‹</a>
312
  <span class="SimpleHistoryPaginationInput">
313
  <input class="SimpleHistoryPaginationCurrentPage" title="{{ data.strings.currentPage }}" type="text" name="paged" value="{{ data.api_args.paged }}" size="4">
314
+ <?php _x( "of", "page n of n", "simple-history" )?>
315
  <span class="total-pages">{{ data.pages_count }}</span>
316
  </span>
317
  <a
335
  <div class="SimpleHistory-modal__background"></div>
336
  <div class="SimpleHistory-modal__content">
337
  <div class="SimpleHistory-modal__contentInner">
338
+ <img class="SimpleHistory-modal__contentSpinner" src="<?php echo admin_url( "/images/spinner.gif" );?>" alt="">
339
  </div>
340
  <div class="SimpleHistory-modal__contentClose">
341
  <button class="button">✕</button>
354
  <div class="SimpleHistoryLogitem__firstcol"></div>
355
  <div class="SimpleHistoryLogitem__secondcol">
356
  <div class="SimpleHistoryLogitem__text">
357
+ <?php _e( 'Sorry, but there are too many similar events to show.', "simple-history" ); ?>
358
  <!-- <br>occasionsCount: {{ data.occasionsCount }}
359
  <br>occasionsCountMaxReturn: {{ data.occasionsCountMaxReturn }}
360
  <br>diff: {{ data.occasionsCount - data.occasionsCountMaxReturn }}
372
  <?php
373
 
374
  // Call plugins so they can add their js
375
+ foreach ( $this->instantiatedLoggers as $one_logger ) {
376
+ if ( method_exists( $one_logger["instance"], "adminJS" ) ) {
377
  $one_logger["instance"]->adminJS();
378
  }
379
  }
398
  //sleep(2);
399
  //sleep(rand(0,3));
400
  $args = $_GET;
401
+ unset( $args["action"] );
402
 
403
  // Type = overview | ...
404
+ $type = isset( $_GET["type"] ) ? $_GET["type"] : null;
405
 
406
+ if ( empty( $args ) || ! $type ) {
407
 
408
+ wp_send_json_error( array(
409
+ _x( "Not enough args specified", "API: not enought arguments passed", "simple-history" ),
410
+ ) );
411
 
412
  }
413
 
414
+ if ( isset( $args["id"] ) ) {
415
  $args["post__in"] = array(
416
  $args["id"],
417
  );
419
 
420
  $data = array();
421
 
422
+ switch ( $type ) {
423
 
424
  case "overview":
425
  case "occasions":
427
 
428
  // API use SimpleHistoryLogQuery, so simply pass args on to that
429
  $logQuery = new SimpleHistoryLogQuery();
430
+ $data = $logQuery->query( $args );
431
 
432
  $data["api_args"] = $args;
433
 
434
  // Output can be array or HMTL
435
+ if ( isset( $args["format"] ) && "html" === $args["format"] ) {
436
 
437
  $data["log_rows_raw"] = array();
438
 
439
+ foreach ( $data["log_rows"] as $key => $oneLogRow ) {
440
 
441
  $args = array();
442
+ if ( $type == "single" ) {
443
  $args["type"] = "single";
444
  }
445
 
446
+ $data["log_rows"][$key] = $this->getLogRowHTMLOutput( $oneLogRow, $args );
447
  $data["num_queries"] = get_num_queries();
448
 
449
  }
460
 
461
  }
462
 
463
+ wp_send_json_success( $data );
464
 
465
  }
466
 
469
  * to the untranslated text too, because that's the version we want to store
470
  * in the database.
471
  */
472
+ public function filter_gettext( $translated_text, $untranslated_text, $domain ) {
473
 
474
+ if ( isset( $this->doFilterGettext ) && $this->doFilterGettext ) {
475
 
476
  $this->doFilterGettext_currentLogger->messages[] = array(
477
  "untranslated_text" => $untranslated_text,
489
  /**
490
  * Store messages with context
491
  */
492
+ public function filter_gettext_with_context( $translated_text, $untranslated_text, $context, $domain ) {
493
 
494
+ if ( isset( $this->doFilterGettext ) && $this->doFilterGettext ) {
495
 
496
  $this->doFilterGettext_currentLogger->messages[] = array(
497
  "untranslated_text" => $untranslated_text,
518
  $domain = 'simple-history';
519
 
520
  // The "plugin_locale" filter is also used in load_plugin_textdomain()
521
+ $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
522
+ load_textdomain( $domain, WP_LANG_DIR . '/simple-history/' . $domain . '-' . $locale . '.mo' );
523
+ load_plugin_textdomain( $domain, FALSE, dirname( $this->plugin_basename ) . '/languages/' );
524
 
525
  }
526
 
546
  public function get_view_history_capability() {
547
 
548
  $view_history_capability = "edit_pages";
549
+ $view_history_capability = apply_filters( "simple_history_view_history_capability", $view_history_capability );
550
+ $view_history_capability = apply_filters( "simple_history/view_history_capability", $view_history_capability );
551
 
552
  return $view_history_capability;
553
 
562
  public function get_view_settings_capability() {
563
 
564
  $view_settings_capability = "manage_options";
565
+ $view_settings_capability = apply_filters( "simple_history_view_settings_capability", $view_settings_capability );
566
+ $view_settings_capability = apply_filters( "simple_history/view_settings_capability", $view_settings_capability );
567
 
568
  return $view_settings_capability;
569
 
579
 
580
  array(
581
  "slug" => "settings",
582
+ "name" => __( "Settings", "simple-history" ),
583
+ "function" => array( $this, "settings_output_general" ),
584
  ),
585
 
586
  );
587
 
588
+ if ( defined( "SIMPLE_HISTORY_DEV" ) && SIMPLE_HISTORY_DEV ) {
589
 
590
  $arr_dev_tabs = array(
591
  array(
592
  "slug" => "log",
593
+ "name" => __( "Log (debug)", "simple-history" ),
594
+ "function" => array( $this, "settings_output_log" ),
595
  ),
596
  array(
597
  "slug" => "styles-example",
598
+ "name" => __( "Styles example (debug)", "simple-history" ),
599
+ "function" => array( $this, "settings_output_styles_example" ),
600
  ),
601
 
602
  );
603
 
604
+ $this->arr_settings_tabs = array_merge( $this->arr_settings_tabs, $arr_dev_tabs );
605
 
606
  }
607
 
615
  *
616
  * @since 2.1
617
  */
618
+ function register_logger( $loggerClassName ) {
619
 
620
  $this->externalLoggers[] = $loggerClassName;
621
 
658
  *
659
  * @param array $loggersFiles Array with filenames
660
  */
661
+ $loggersFiles = apply_filters( "simple_history/loggers_files", $loggersFiles );
662
 
663
  // Array with slug of loggers to instantiate
664
  // Slug of logger must also be the name of the logger class
668
 
669
  $load_logger = true;
670
 
671
+ $basename_no_suffix = basename( $oneLoggerFile, ".php" );
672
 
673
  /**
674
  * Filter to completely skip loading of a logger
678
  * @param bool if to load the logger. return false to not load it.
679
  * @param string slug of logger
680
  */
681
+ $load_logger = apply_filters( "simple_history/logger/load_logger", $load_logger, $basename_no_suffix );
682
 
683
  if ( ! $load_logger ) {
684
  continue;
699
  * @param array $arrLoggersToInstantiate Array with class names
700
  */
701
 
702
+ do_action( "simple_history/add_custom_logger", $this );
703
 
704
+ $arrLoggersToInstantiate = array_merge( $arrLoggersToInstantiate, $this->externalLoggers );
705
 
706
  /**
707
  * Filter the array with names of loggers to instantiate.
717
  *
718
  * @param array $arrLoggersToInstantiate Array with class names
719
  */
720
+ $arrLoggersToInstantiate = apply_filters( "simple_history/loggers_to_instantiate", $arrLoggersToInstantiate );
721
 
722
  // Instantiate each logger
723
+ foreach ( $arrLoggersToInstantiate as $oneLoggerName ) {
724
 
725
+ if ( ! class_exists( $oneLoggerName ) ) {
726
  continue;
727
  }
728
 
729
+ $loggerInstance = new $oneLoggerName( $this );
730
 
731
+ if ( ! is_subclass_of( $loggerInstance, "SimpleLogger" ) && ! is_a( $loggerInstance, "SimpleLogger" ) ) {
732
  continue;
733
  }
734
 
747
  // LoggerInfo contains all messages, both translated an not, by key.
748
  // Add messages to the loggerInstance
749
  $loopNum = 0;
750
+ if ( is_array( $loggerInfo["messages"] ) ) {
751
+
752
+ foreach ( $loggerInfo["messages"] as $message_key => $message ) {
753
 
754
+ $loggerInstance->messages[$message_key] = $loggerInstance->messages[$loopNum];
755
+ $loopNum++;
756
 
757
+ }
758
  }
759
 
760
  // Remove index keys, only keeping slug keys
761
+ if ( is_array( $loggerInstance->messages ) ) {
762
+
763
+ foreach ( $loggerInstance->messages as $key => $val ) {
764
+
765
+ if ( is_int( $key ) ) {
766
+ unset( $loggerInstance->messages[$key] );
767
  }
768
+
769
  }
770
+
771
  }
772
 
773
  // Add logger to array of loggers
778
 
779
  }
780
 
781
+ do_action( "simple_history/loggers_loaded" );
782
 
783
  }
784
 
811
  *
812
  * @param array $dropinsFiles Array with filenames
813
  */
814
+ $dropinsFiles = apply_filters( "simple_history/dropins_files", $dropinsFiles );
815
 
816
  $arrDropinsToInstantiate = array();
817
 
818
  foreach ( $dropinsFiles as $oneDropinFile ) {
819
 
820
  // path/path/simplehistory/dropins/SimpleHistoryDonateDropin.php => SimpleHistoryDonateDropin
821
+ $oneDropinFileBasename = basename( $oneDropinFile, ".php" );
822
 
823
  $load_dropin = true;
824
 
831
  *
832
  * @param bool if to load the dropin. return false to not load it.
833
  */
834
+ $load_dropin = apply_filters( "simple_history/dropin/load_dropin_{$oneDropinFileBasename}", $load_dropin );
835
 
836
  /**
837
  * Filter to completely skip loading of a dropin
841
  * @param bool if to load the dropin. return false to not load it.
842
  * @param string slug of dropin
843
  */
844
+ $load_dropin = apply_filters( "simple_history/dropin/load_dropin", $load_dropin, $oneDropinFileBasename );
845
 
846
  if ( ! $load_dropin ) {
847
  continue;
860
  *
861
  * @param array $arrDropinsToInstantiate Array with class names
862
  */
863
+ $arrDropinsToInstantiate = apply_filters( "simple_history/dropins_to_instantiate", $arrDropinsToInstantiate );
864
 
865
  // Instantiate each dropin
866
+ foreach ( $arrDropinsToInstantiate as $oneDropinName ) {
867
 
868
+ if ( ! class_exists( $oneDropinName ) ) {
869
  continue;
870
  }
871
 
872
  $this->instantiatedDropins[$oneDropinName] = array(
873
  "name" => $oneDropinName,
874
+ "instance" => new $oneDropinName( $this ),
875
  );
876
  }
877
 
885
  */
886
  function get_pager_size() {
887
 
888
+ $pager_size = get_option( "simple_history_pager_size", 5 );
889
 
890
  /**
891
  * Filter the pager size setting
894
  *
895
  * @param int $pager_size
896
  */
897
+ $pager_size = apply_filters( "simple_history/pager_size", $pager_size );
898
 
899
  return $pager_size;
900
 
903
  /**
904
  * Show a link to our settings page on the Plugins -> Installed Plugins screen
905
  */
906
+ function plugin_action_links( $actions, $b, $c, $d ) {
907
 
908
  // Only add link if user has the right to view the settings page
909
  if ( ! current_user_can( $this->get_view_settings_capability() ) ) {
910
  return $actions;
911
  }
912
 
913
+ $settings_page_url = menu_page_url( SimpleHistory::SETTINGS_MENU_SLUG, 0 );
914
 
915
+ $actions[] = "<a href='$settings_page_url'>" . __( "Settings", "simple-history" ) . "</a>";
916
 
917
  return $actions;
918
 
934
  *
935
  * @param bool Show the page or not
936
  */
937
+ $show_dashboard_widget = apply_filters( "simple_history/show_dashboard_widget", true );
938
 
939
  if ( $show_dashboard_widget ) {
940
+ wp_add_dashboard_widget( "simple_history_dashboard_widget", __( "Simple History", 'simple-history' ), array( $this, "dashboard_widget_output" ) );
941
  }
942
 
943
  }
957
  *
958
  * @param int $pager_size
959
  */
960
+ $pager_size = apply_filters( "simple_history/dashboard_pager_size", $pager_size );
961
 
962
+ do_action( "simple_history/dashboard/before_gui", $this );
963
 
964
  ?>
965
  <div class="SimpleHistoryGui"
969
 
970
  }
971
 
972
+ function is_on_our_own_pages( $hook = "" ) {
973
 
974
  $current_screen = get_current_screen();
975
 
976
+ if ( $current_screen && $current_screen->base == "settings_page_" . SimpleHistory::SETTINGS_MENU_SLUG ) {
977
 
978
  return true;
979
 
980
+ } else if ( $current_screen && $current_screen->base == "dashboard_page_simple_history_page" ) {
981
 
982
  return true;
983
 
984
+ } else if ( ( $hook == "settings_page_" . SimpleHistory::SETTINGS_MENU_SLUG ) || ( $this->setting_show_on_dashboard() && $hook == "index.php" ) || ( $this->setting_show_as_page() && $hook == "dashboard_page_simple_history_page" ) ) {
985
 
986
  return true;
987
 
988
+ } else if ( $current_screen && $current_screen->base == "dashboard" && $this->setting_show_on_dashboard() ) {
989
 
990
  return true;
991
 
999
  *
1000
  * Only adds scripts to pages where the log is shown or the settings page.
1001
  */
1002
+ function enqueue_admin_scripts( $hook ) {
1003
 
1004
+ if ( $this->is_on_our_own_pages() ) {
1005
 
1006
  add_thickbox();
1007
 
1008
+ wp_enqueue_style( "simple_history_styles", SIMPLE_HISTORY_DIR_URL . "css/styles.css", false, SIMPLE_HISTORY_VERSION );
1009
+ wp_enqueue_script( "simple_history_script", SIMPLE_HISTORY_DIR_URL . "js/scripts.js", array( "jquery", "backbone", "wp-util" ), SIMPLE_HISTORY_VERSION, true );
1010
 
1011
+ wp_enqueue_script( "select2", SIMPLE_HISTORY_DIR_URL . "js/select2/select2.min.js", array( "jquery" ) );
1012
+ wp_enqueue_style( "select2", SIMPLE_HISTORY_DIR_URL . "js/select2/select2.css" );
1013
 
1014
  // Translations that we use in JavaScript
1015
+ wp_localize_script( 'simple_history_script', 'simple_history_script_vars', array(
1016
+ 'settingsConfirmClearLog' => __( "Remove all log items?", 'simple-history' ),
1017
  'pagination' => array(
1018
+ 'goToTheFirstPage' => __( "Go to the first page", 'simple-history' ),
1019
+ 'goToThePrevPage' => __( "Go to the previous page", 'simple-history' ),
1020
+ 'goToTheNextPage' => __( "Go to the next page", 'simple-history' ),
1021
+ 'goToTheLastPage' => __( "Go to the last page", 'simple-history' ),
1022
+ 'currentPage' => __( "Current page", 'simple-history' ),
1023
  ),
1024
+ "loadLogAPIError" => __( "Oups, the log could not be loaded right now.", 'simple-history' ),
1025
+ "logNoHits" => __( "Your search did not match any history events.", "simple-history" ),
1026
+ ) );
1027
 
1028
  // Call plugins adminCSS-method, so they can add their CSS
1029
+ foreach ( $this->instantiatedLoggers as $one_logger ) {
1030
+ if ( method_exists( $one_logger["instance"], "adminCSS" ) ) {
1031
  $one_logger["instance"]->adminCSS();
1032
  }
1033
  }
1040
  *
1041
  * @param SimpleHistory $SimpleHistory This class.
1042
  */
1043
+ do_action( "simple_history/enqueue_admin_scripts", $this );
1044
 
1045
  }
1046
 
1047
  }
1048
 
1049
+ function filter_option_page_capability( $capability ) {
1050
  return $capability;
1051
  }
1052
 
1058
 
1059
  global $wpdb;
1060
 
1061
+ $db_version = get_option( "simple_history_db_version" );
1062
  $table_name = $wpdb->prefix . SimpleHistory::DBTABLE;
1063
  $table_name_contexts = $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS;
1064
  $first_install = false;
1067
  // is a version of Simple History < 0.4
1068
  // or it's a first install
1069
  // Fix database not using UTF-8
1070
+ if ( false === $db_version ) {
1071
 
1072
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1073
 
1103
  ) CHARACTER SET=utf8;";
1104
 
1105
  // Upgrade db / fix utf for varchars
1106
+ dbDelta( $sql );
1107
 
1108
  // Fix UTF-8 for table
1109
+ $sql = sprintf( 'alter table %1$s charset=utf8;', $table_name );
1110
+ $wpdb->query( $sql );
1111
 
1112
  $db_version_prev = $db_version;
1113
  $db_version = 1;
1114
 
1115
+ update_option( "simple_history_db_version", $db_version );
1116
 
1117
  // We are not 100% sure that this is a first install,
1118
  // but it is at least a very old version that is being updated
1122
 
1123
  // If db version is 1 then upgrade to 2
1124
  // Version 2 added the action_description column
1125
+ if ( 1 == intval( $db_version ) ) {
1126
 
1127
  // Add column for action description in non-translatable free text
1128
  $sql = "ALTER TABLE {$table_name} ADD COLUMN action_description longtext";
1129
+ $wpdb->query( $sql );
1130
 
1131
  $db_version_prev = $db_version;
1132
  $db_version = 2;
1133
 
1134
+ update_option( "simple_history_db_version", $db_version );
1135
 
1136
  }
1137
 
1148
  ),
1149
  );
1150
 
1151
+ foreach ( $arr_options as $one_option ) {
1152
 
1153
+ if ( false === ( $option_value = get_option( $one_option["name"] ) ) ) {
1154
 
1155
  // Value is not set in db, so set it to a default
1156
+ update_option( $one_option["name"], $one_option["default_value"] );
1157
 
1158
  }
1159
  }
1165
  *
1166
  * @since 2.0
1167
  */
1168
+ if ( 2 == intval( $db_version ) ) {
1169
 
1170
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1171
 
1192
  KEY loggerdate (logger, date)
1193
  ) CHARSET=utf8;";
1194
 
1195
+ dbDelta( $sql );
1196
 
1197
  // Add context table
1198
  $sql = "
1207
  ) CHARSET=utf8;
1208
  ";
1209
 
1210
+ $wpdb->query( $sql );
1211
 
1212
  $db_version_prev = $db_version;
1213
  $db_version = 3;
1214
+ update_option( "simple_history_db_version", $db_version );
1215
 
1216
  // Update old items to use SimpleLegacyLogger
1217
+ $sql = sprintf( '
1218
  UPDATE %1$s
1219
  SET
1220
  logger = "SimpleLegacyLogger",
1224
  $table_name
1225
  );
1226
 
1227
+ $wpdb->query( $sql );
1228
 
1229
  // Say welcome, however loggers are not added this early so we need to
1230
  // use a filter to load it later
1231
+ add_action( "simple_history/loggers_loaded", array( $this, "addWelcomeLogMessage" ) );
1232
 
1233
  }// db version 2 » 3
1234
 
1240
  *
1241
  * @since 2.0
1242
  */
1243
+ if ( 3 == intval( $db_version ) ) {
1244
 
1245
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1246
 
1247
+ $sql = sprintf( '
1248
  ALTER TABLE %1$s
1249
  MODIFY `action` varchar(255) NULL,
1250
  MODIFY `object_type` varchar(255) NULL,
1255
  ',
1256
  $table_name
1257
  );
1258
+ $wpdb->query( $sql );
1259
 
1260
  $db_version_prev = $db_version;
1261
  $db_version = 4;
1262
 
1263
+ update_option( "simple_history_db_version", $db_version );
1264
 
1265
  }// end db version 3 » 4
1266
 
1267
+ } // end check_for_upgrade
1268
+
1269
+ /**
1270
+ * Check if the database has data/rows
1271
+ *
1272
+ * @since 2.1.6
1273
+ * @return bool True if database is not empty, false if database is empty = contains no data
1274
+ */
1275
+ function does_database_have_data() {
1276
+
1277
+ global $wpdb;
1278
+
1279
+ $tableprefix = $wpdb->prefix;
1280
+
1281
+ $simple_history_table = SimpleHistory::DBTABLE;
1282
+ $simple_history_context_table = SimpleHistory::DBTABLE_CONTEXTS;
1283
+
1284
+ $sql_data_exists = "SELECT id AS id_exists FROM {$tableprefix}{$simple_history_table} LIMIT 1";
1285
+ $data_exists = (bool) $wpdb->get_var( $sql_data_exists, 0 );
1286
+
1287
+ return $data_exists;
1288
+
1289
+ }
1290
 
1291
  /**
1292
  * Greet users to version 2!
1293
+ * Is only called after database has been upgraded, so only on first install (or upgrade).
1294
+ * Not called after only plugin activation.
1295
  */
1296
  public function addWelcomeLogMessage() {
1297
 
1298
+ $db_data_exists = $this->does_database_have_data();
1299
+ #$db_data_exists = false;
1300
+
1301
+ $pluginLogger = $this->getInstantiatedLoggerBySlug( "SimplePluginLogger" );
1302
+ if ( $pluginLogger ) {
1303
+
1304
+ // Add plugin installed message
1305
+ $context = array(
1306
+ "plugin_name" => "Simple History",
1307
+ "plugin_description" => "Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.",
1308
+ "plugin_url" => "http://simple-history.com",
1309
+ "plugin_version" => SIMPLE_HISTORY_VERSION,
1310
+ "plugin_author" => "Pär Thernström"
1311
+ );
1312
+
1313
+ $pluginLogger->infoMessage( "plugin_installed", $context );
1314
+
1315
+ // Add plugin activated message
1316
+ $context["plugin_slug"] = "simple-history";
1317
+ $context["plugin_title"] = '<a href="http://simple-history.com/">Simple History</a>';
1318
+
1319
+ $pluginLogger->infoMessage( "plugin_activated", $context );
1320
+
1321
+ }
1322
+
1323
+ if ( ! $db_data_exists ) {
1324
+
1325
+ $welcome_message_1 = "
1326
+ Welcome to Simple History!
1327
+
1328
+ This is the main history feed. It will contain events that this plugin has logged.
1329
+ ";
1330
+
1331
+ $welcome_message_2 ="
1332
+ Because Simple History was just recently installed, this feed does not contain much events yet. But keep the plugin activated and soon you will see detailed information about page edits, plugin updates, user logins, and much more.
1333
+ ";
1334
+
1335
+ SimpleLogger()->info(
1336
+ $welcome_message_2,
1337
+ array(
1338
+ "_initiator" => SimpleLoggerLogInitiators::WORDPRESS,
1339
+ )
1340
+ );
1341
+
1342
+ SimpleLogger()->info(
1343
+ $welcome_message_1,
1344
+ array(
1345
+ "_initiator" => SimpleLoggerLogInitiators::WORDPRESS,
1346
+ )
1347
+ );
1348
+
1349
+ }
1350
 
1351
  }
1352
 
1353
+ public function registerSettingsTab( $arr_tab_settings ) {
1354
 
1355
  $this->arr_settings_tabs[] = $arr_tab_settings;
1356
 
1375
 
1376
  <h1 class="SimpleHistoryPageHeadline">
1377
  <div class="dashicons dashicons-backup SimpleHistoryPageHeadline__icon"></div>
1378
+ <?php _e( "Simple History Settings", "simple-history" )?>
1379
  </h1>
1380
 
1381
  <?php
1382
+ $active_tab = isset( $_GET["selected-tab"] ) ? $_GET["selected-tab"] : "settings";
1383
+ $settings_base_url = menu_page_url( SimpleHistory::SETTINGS_MENU_SLUG, 0 );
1384
  ?>
1385
 
1386
  <h2 class="nav-tab-wrapper">
1387
  <?php
1388
+ foreach ( $arr_settings_tabs as $one_tab ) {
1389
 
1390
  $tab_slug = $one_tab["slug"];
1391
 
1393
  '<a href="%3$s" class="nav-tab %4$s">%1$s</a>',
1394
  $one_tab["name"], // 1
1395
  $tab_slug, // 2
1396
+ esc_url( add_query_arg( "selected-tab", $tab_slug, $settings_base_url ) ), // 3
1397
  $active_tab == $tab_slug ? "nav-tab-active" : ""// 4
1398
  );
1399
 
1404
  <?php
1405
 
1406
  // Output contents for selected tab
1407
+ $arr_active_tab = wp_filter_object_list( $arr_settings_tabs, array( "slug" => $active_tab ) );
1408
+ $arr_active_tab = current( $arr_active_tab );
1409
 
1410
  // We must have found an active tab and it must have a callable function
1411
+ if ( ! $arr_active_tab || ! is_callable( $arr_active_tab["function"] ) ) {
1412
+ wp_die( __( "No valid callback found", "simple-history" ) );
1413
  }
1414
 
1415
  $args = array(
1416
  "arr_active_tab" => $arr_active_tab,
1417
  );
1418
 
1419
+ call_user_func_array( $arr_active_tab["function"], $args );
1420
 
1421
  ?>
1422
 
1466
  *
1467
  * @param bool Show the page or not
1468
  */
1469
+ $show_dashboard_page = apply_filters( "simple_history/show_dashboard_page", true );
1470
 
1471
  if ( $show_dashboard_page ) {
1472
 
1473
  add_dashboard_page(
1474
  SimpleHistory::NAME,
1475
+ _x( "Simple History", 'dashboard menu name', 'simple-history' ),
1476
  $this->get_view_history_capability(),
1477
  "simple_history_page",
1478
+ array( $this, "history_page_output" )
1479
  );
1480
 
1481
  }
1484
 
1485
  // Add a settings page
1486
  $show_settings_page = true;
1487
+ $show_settings_page = apply_filters( "simple_history_show_settings_page", $show_settings_page );
1488
+ $show_settings_page = apply_filters( "simple_history/show_settings_page", $show_settings_page );
1489
 
1490
  if ( $show_settings_page ) {
1491
 
1492
  add_options_page(
1493
+ __( 'Simple History Settings', "simple-history" ),
1494
  SimpleHistory::NAME,
1495
  $this->get_view_settings_capability(),
1496
  SimpleHistory::SETTINGS_MENU_SLUG,
1497
+ array( $this, 'settings_page_output' )
1498
  );
1499
 
1500
  }
1508
  function add_settings() {
1509
 
1510
  // Clear the log if clear button was clicked in settings
1511
+ if ( isset( $_GET["simple_history_clear_log_nonce"] ) && wp_verify_nonce( $_GET["simple_history_clear_log_nonce"], 'simple_history_clear_log' ) ) {
1512
 
1513
  $this->clear_log();
1514
+ $msg = __( "Cleared database", 'simple-history' );
1515
+ add_settings_error( "simple_history_rss_feed_regenerate_secret", "simple_history_rss_feed_regenerate_secret", $msg, "updated" );
1516
+ set_transient( 'settings_errors', get_settings_errors(), 30 );
1517
 
1518
+ $goback = esc_url_raw( add_query_arg( 'settings-updated', 'true', wp_get_referer() ) );
1519
+ wp_redirect( $goback );
1520
  exit;
1521
 
1522
  }
1527
  add_settings_section(
1528
  $settings_section_general_id,
1529
  "", // No title __("General", "simple-history"),
1530
+ array( $this, "settings_section_output" ),
1531
  SimpleHistory::SETTINGS_MENU_SLUG// same slug as for options menu page
1532
  );
1533
 
1538
  // Checkboxes for where to show simple history
1539
  add_settings_field(
1540
  "simple_history_show_where",
1541
+ __( "Show history", "simple-history" ),
1542
+ array( $this, "settings_field_where_to_show" ),
1543
  SimpleHistory::SETTINGS_MENU_SLUG,
1544
  $settings_section_general_id
1545
  );
1546
 
1547
  // Nonces for show where inputs
1548
+ register_setting( "simple_history_settings_group", "simple_history_show_on_dashboard" );
1549
+ register_setting( "simple_history_settings_group", "simple_history_show_as_page" );
1550
 
1551
  // Dropdown number if items to show
1552
  add_settings_field(
1553
  "simple_history_number_of_items",
1554
+ __( "Number of items per page", "simple-history" ),
1555
+ array( $this, "settings_field_number_of_items" ),
1556
  SimpleHistory::SETTINGS_MENU_SLUG,
1557
  $settings_section_general_id
1558
  );
1559
 
1560
  // Nonces for number of items inputs
1561
+ register_setting( "simple_history_settings_group", "simple_history_pager_size" );
1562
 
1563
  // Link to clear log
1564
  add_settings_field(
1565
  "simple_history_clear_log",
1566
+ __( "Clear log", "simple-history" ),
1567
+ array( $this, "settings_field_clear_log" ),
1568
  SimpleHistory::SETTINGS_MENU_SLUG,
1569
  $settings_section_general_id
1570
  );
1591
  *
1592
  * @param int $pager_size
1593
  */
1594
+ $pager_size = apply_filters( "simple_history/page_pager_size", $pager_size );
1595
 
1596
  ?>
1597
 
1599
 
1600
  <h1 class="SimpleHistoryPageHeadline">
1601
  <div class="dashicons dashicons-backup SimpleHistoryPageHeadline__icon"></div>
1602
+ <?php echo _x( "Simple History", 'history page headline', 'simple-history' )?>
1603
  </h1>
1604
 
1605
  <?php
1610
  *
1611
  * @param SimpleHistory $SimpleHistory This class.
1612
  */
1613
+ do_action( "simple_history/history_page/before_gui", $this );
1614
  ?>
1615
 
1616
  <div class="SimpleHistoryGuiWrap">
1628
  *
1629
  * @param SimpleHistory $SimpleHistory This class.
1630
  */
1631
+ do_action( "simple_history/history_page/after_gui", $this );
1632
 
1633
  ?>
1634
 
1648
  */
1649
  function setting_show_on_dashboard() {
1650
 
1651
+ $show_on_dashboard = get_option( "simple_history_show_on_dashboard", 1 );
1652
+ $show_on_dashboard = apply_filters( "simple_history_show_on_dashboard", $show_on_dashboard );
1653
  return (bool) $show_on_dashboard;
1654
 
1655
  }
1662
  */
1663
  function setting_show_as_page() {
1664
 
1665
+ $setting = get_option( "simple_history_show_as_page", 1 );
1666
+ $setting = apply_filters( "simple_history_show_as_page", $setting );
1667
  return (bool) $setting;
1668
 
1669
  }
1702
  ?>
1703
 
1704
  <input <?php echo $show_on_dashboard ? "checked='checked'" : ""?> type="checkbox" value="1" name="simple_history_show_on_dashboard" id="simple_history_show_on_dashboard" class="simple_history_show_on_dashboard" />
1705
+ <label for="simple_history_show_on_dashboard"><?php _e( "on the dashboard", 'simple-history' )?></label>
1706
 
1707
  <br />
1708
 
1709
  <input <?php echo $show_as_page ? "checked='checked'" : ""?> type="checkbox" value="1" name="simple_history_show_as_page" id="simple_history_show_as_page" class="simple_history_show_as_page" />
1710
+ <label for="simple_history_show_as_page"><?php _e( "as a page under the dashboard menu", 'simple-history' )?></label>
1711
 
1712
  <?php
1713
  }
1717
  */
1718
  function settings_field_clear_log() {
1719
 
1720
+ $clear_link = esc_url( add_query_arg( "", "" ) );
1721
+ $clear_link = wp_nonce_url( $clear_link, "simple_history_clear_log", "simple_history_clear_log_nonce" );
1722
  $clear_days = $this->get_clear_history_interval();
1723
 
1724
  echo "<p>";
1725
+ if ( $clear_days > 0 ) {
1726
+ echo sprintf( __( 'Items in the database are automatically removed after %1$s days.', "simple-history" ), $clear_days );
1727
  } else {
1728
+ _e( 'Items in the database are kept forever.', 'simple-history' );
1729
  }
1730
  echo "</p>";
1731
 
1732
+ printf( '<p><a class="button js-SimpleHistory-Settings-ClearLog" href="%2$s">%1$s</a></p>', __( 'Clear log now', 'simple-history' ), $clear_link );
1733
  }
1734
 
1735
  /**
1748
  *
1749
  * @param $days Number of days of history to keep
1750
  */
1751
+ $days = (int) apply_filters( "simple_history_db_purge_days_interval", $days );
1752
+ $days = (int) apply_filters( "simple_history/db_purge_days_interval", $days );
1753
 
1754
  return $days;
1755
 
1769
 
1770
  // Get number of rows before delete
1771
  $sql_num_rows = "SELECT count(id) AS num_rows FROM {$tableprefix}{$simple_history_table}";
1772
+ $num_rows = $wpdb->get_var( $sql_num_rows, 0 );
1773
 
1774
+ //$sql = "DELETE FROM {$tableprefix}{$simple_history_table}";
1775
  $sql = "TRUNCATE {$tableprefix}{$simple_history_table}";
1776
+ $wpdb->query( $sql );
1777
 
1778
+ //$sql = "DELETE FROM {$tableprefix}{$simple_history_context_table}";
1779
  $sql = "TRUNCATE {$tableprefix}{$simple_history_context_table}";
1780
+ $wpdb->query( $sql );
1781
 
1782
  // Zero state sucks
1783
  SimpleLogger()->info(
1784
+ __( "The log for Simple History was cleared ({num_rows} rows were removed).", "simple-history" ),
1785
  array(
1786
  "num_rows" => $num_rows,
1787
  )
1788
  );
1789
 
1790
+ $this->get_cache_incrementor( true );
1791
 
1792
  }
1793
 
1808
  // Let's go with sundays; purge the log on sundays
1809
 
1810
  // day of week, 1 = mon, 7 = sun
1811
+ $day_of_week = date( 'N' );
1812
  if ( 7 === (int) $day_of_week ) {
1813
 
1814
  $this->purge_db();
1826
 
1827
  $do_purge_history = true;
1828
 
1829
+ $do_purge_history = apply_filters( "simple_history_allow_db_purge", $do_purge_history );
1830
+ $do_purge_history = apply_filters( "simple_history/allow_db_purge", $do_purge_history );
1831
 
1832
+ if ( ! $do_purge_history ) {
1833
  return;
1834
  }
1835
 
1836
  $days = $this->get_clear_history_interval();
1837
 
1838
  // Never clear log if days = 0
1839
+ if ( 0 == $days ) {
1840
  return;
1841
  }
1842
 
1848
  // Get id of rows to delete
1849
  $sql = "SELECT id FROM {$table_name} WHERE DATE_ADD(date, INTERVAL $days DAY) < now()";
1850
 
1851
+ $ids_to_delete = $wpdb->get_col( $sql );
1852
 
1853
+ if ( empty( $ids_to_delete ) ) {
1854
  // Nothing to delete
1855
  return;
1856
  }
1857
 
1858
+ $sql_ids_in = implode( ",", $ids_to_delete );
1859
 
1860
  // Add number of deleted rows to total_rows option
1861
+ $prev_total_rows = (int) get_option( "simple_history_total_rows", 0 );
1862
+ $total_rows = $prev_total_rows + sizeof( $ids_to_delete );
1863
+ update_option( "simple_history_total_rows", $total_rows );
1864
 
1865
  // Remove rows + contexts
1866
  $sql_delete_history = "DELETE FROM {$table_name} WHERE id IN ($sql_ids_in)";
1867
  $sql_delete_history_context = "DELETE FROM {$table_name_contexts} WHERE history_id IN ($sql_ids_in)";
1868
 
1869
+ $wpdb->query( $sql_delete_history );
1870
+ $wpdb->query( $sql_delete_history_context );
1871
 
1872
  $message = _nx(
1873
  "Simple History removed one event that were older than {days} days",
1880
  $message,
1881
  array(
1882
  "days" => $days,
1883
+ "num_rows" => sizeof( $ids_to_delete ),
1884
  )
1885
  );
1886
 
1887
+ $this->get_cache_incrementor( true );
1888
 
1889
  }
1890
 
1896
  * @param array $row
1897
  * @return string
1898
  */
1899
+ public function getLogRowPlainTextOutput( $row ) {
1900
 
1901
  $row_logger = $row->logger;
1902
  $logger = null;
1903
+ $row->context = isset( $row->context ) && is_array( $row->context ) ? $row->context : array();
1904
 
1905
+ if ( ! isset( $row->context["_message_key"] ) ) {
1906
  $row->context["_message_key"] = null;
1907
  }
1908
 
1909
  // Fallback to SimpleLogger if no logger exists for row
1910
+ if ( ! isset( $this->instantiatedLoggers[$row_logger] ) ) {
1911
  $row_logger = "SimpleLogger";
1912
  }
1913
 
1914
  $logger = $this->instantiatedLoggers[$row_logger]["instance"];
1915
 
1916
+ return $logger->getLogRowPlainTextOutput( $row );
1917
 
1918
  }
1919
 
1928
  * @param array $row
1929
  * @return string
1930
  */
1931
+ public function getLogRowHeaderOutput( $row ) {
1932
 
1933
  $row_logger = $row->logger;
1934
  $logger = null;
1935
+ $row->context = isset( $row->context ) && is_array( $row->context ) ? $row->context : array();
1936
 
1937
  // Fallback to SimpleLogger if no logger exists for row
1938
+ if ( ! isset( $this->instantiatedLoggers[$row_logger] ) ) {
1939
  $row_logger = "SimpleLogger";
1940
  }
1941
 
1942
  $logger = $this->instantiatedLoggers[$row_logger]["instance"];
1943
 
1944
+ return $logger->getLogRowHeaderOutput( $row );
1945
 
1946
  }
1947
 
1951
  * @param array $row
1952
  * @return string
1953
  */
1954
+ private function getLogRowSenderImageOutput( $row ) {
1955
 
1956
  $row_logger = $row->logger;
1957
  $logger = null;
1958
+ $row->context = isset( $row->context ) && is_array( $row->context ) ? $row->context : array();
1959
 
1960
  // Fallback to SimpleLogger if no logger exists for row
1961
+ if ( ! isset( $this->instantiatedLoggers[$row_logger] ) ) {
1962
  $row_logger = "SimpleLogger";
1963
  }
1964
 
1965
  $logger = $this->instantiatedLoggers[$row_logger]["instance"];
1966
 
1967
+ return $logger->getLogRowSenderImageOutput( $row );
1968
 
1969
  }
1970
 
1971
+ public function getLogRowDetailsOutput( $row ) {
1972
 
1973
  $row_logger = $row->logger;
1974
  $logger = null;
1975
+ $row->context = isset( $row->context ) && is_array( $row->context ) ? $row->context : array();
1976
 
1977
  // Fallback to SimpleLogger if no logger exists for row
1978
+ if ( ! isset( $this->instantiatedLoggers[$row_logger] ) ) {
1979
  $row_logger = "SimpleLogger";
1980
  }
1981
 
1982
  $logger = $this->instantiatedLoggers[$row_logger]["instance"];
1983
 
1984
+ return $logger->getLogRowDetailsOutput( $row );
1985
 
1986
  }
1987
 
1991
  *
1992
  * @param $value array|object|string|whatever that is json_encode'able
1993
  */
1994
+ public static function json_encode( $value ) {
1995
 
1996
+ return version_compare( PHP_VERSION, '5.4.0' ) >= 0 ? json_encode( $value, JSON_PRETTY_PRINT ) : json_encode( $value );
1997
 
1998
  }
1999
 
2002
  * @param string $haystack
2003
  * @param string $needle
2004
  */
2005
+ public static function ends_with( $haystack, $needle ) {
2006
+ return $needle === substr( $haystack, -strlen( $needle ) );
2007
  }
2008
 
2009
  /**
2012
  * @param array $oneLogRow SimpleHistoryLogQuery array with data from SimpleHistoryLogQuery
2013
  * @return string
2014
  */
2015
+ public function getLogRowHTMLOutput( $oneLogRow, $args ) {
2016
 
2017
  $defaults = array(
2018
  "type" => "overview", // or "single" to include more stuff
2019
  );
2020
 
2021
+ $args = wp_parse_args( $args, $defaults );
2022
 
2023
+ $header_html = $this->getLogRowHeaderOutput( $oneLogRow );
2024
+ $plain_text_html = $this->getLogRowPlainTextOutput( $oneLogRow );
2025
+ $sender_image_html = $this->getLogRowSenderImageOutput( $oneLogRow );
2026
 
2027
  // Details = for example thumbnail of media
2028
+ $details_html = trim( $this->getLogRowDetailsOutput( $oneLogRow ) );
2029
+ if ( $details_html ) {
2030
 
2031
  $details_html = sprintf(
2032
  '<div class="SimpleHistoryLogitem__details">%1$s</div>',
2039
  $occasions_count = $oneLogRow->subsequentOccasions - 1;
2040
  $occasions_html = "";
2041
 
2042
+ if ( $occasions_count > 0 ) {
2043
 
2044
  $occasions_html = '<div class="SimpleHistoryLogitem__occasions">';
2045
 
2046
  $occasions_html .= '<a href="#" class="SimpleHistoryLogitem__occasionsLink">';
2047
  $occasions_html .= sprintf(
2048
+ _n( '+%1$s similar event', '+%1$s similar events', $occasions_count, "simple-history" ),
2049
  $occasions_count
2050
  );
2051
  $occasions_html .= '</a>';
2052
 
2053
  $occasions_html .= '<span class="SimpleHistoryLogitem__occasionsLoading">';
2054
  $occasions_html .= sprintf(
2055
+ __( 'Loading…', "simple-history" ),
2056
  $occasions_count
2057
  );
2058
  $occasions_html .= '</span>';
2059
 
2060
  $occasions_html .= '<span class="SimpleHistoryLogitem__occasionsLoaded">';
2061
  $occasions_html .= sprintf(
2062
+ __( 'Showing %1$s more', "simple-history" ),
2063
  $occasions_count
2064
  );
2065
  $occasions_html .= '</span>';
2070
 
2071
  // Add data atributes to log row, so plugins can do stuff
2072
  $data_attrs = "";
2073
+ $data_attrs .= sprintf( ' data-row-id="%1$d" ', $oneLogRow->id );
2074
+ $data_attrs .= sprintf( ' data-occasions-count="%1$d" ', $occasions_count );
2075
+ $data_attrs .= sprintf( ' data-occasions-id="%1$s" ', esc_attr( $oneLogRow->occasionsID ) );
2076
 
2077
+ if ( isset( $oneLogRow->context["_server_remote_addr"] ) ) {
2078
+ $data_attrs .= sprintf( ' data-ip-address="%1$s" ', esc_attr( $oneLogRow->context["_server_remote_addr"] ) );
2079
  }
2080
 
2081
+ $arr_found_additional_ip_headers = $this->instantiatedLoggers["SimpleLogger"]["instance"]->get_event_ip_number_headers( $oneLogRow );
2082
  if ( $arr_found_additional_ip_headers ) {
2083
+ $data_attrs .= sprintf( ' data-ip-address-multiple="1" ' );
2084
  }
2085
 
2086
+ $data_attrs .= sprintf( ' data-logger="%1$s" ', esc_attr( $oneLogRow->logger ) );
2087
+ $data_attrs .= sprintf( ' data-level="%1$s" ', esc_attr( $oneLogRow->level ) );
2088
+ $data_attrs .= sprintf( ' data-date="%1$s" ', esc_attr( $oneLogRow->date ) );
2089
+ $data_attrs .= sprintf( ' data-initiator="%1$s" ', esc_attr( $oneLogRow->initiator ) );
2090
 
2091
  if ( isset( $oneLogRow->context["_user_id"] ) ) {
2092
+ $data_attrs .= sprintf( ' data-initiator-user-id="%1$d" ', $oneLogRow->context["_user_id"] );
2093
  }
2094
 
2095
  // If type is single then include more details
2096
  $more_details_html = "";
2097
  if ( $args["type"] == "single" ) {
2098
 
2099
+ $more_details_html = apply_filters( "simple_history/log_html_output_details_single/html_before_context_table", $more_details_html, $oneLogRow );
2100
 
2101
+ $more_details_html .= sprintf( '<h2 class="SimpleHistoryLogitem__moreDetailsHeadline">%1$s</h2>', __( "Context data", "simple-history" ) );
2102
+ $more_details_html .= "<p>" . __( "This is potentially useful meta data that a logger has saved.", "simple-history" ) . "</p>";
2103
  $more_details_html .= "<table class='SimpleHistoryLogitem__moreDetailsContext'>";
2104
  $more_details_html .= sprintf(
2105
  '<tr>
2110
  "Value"
2111
  );
2112
 
2113
+ $logRowKeysToShow = array_fill_keys( array_keys( (array) $oneLogRow ), true );
2114
 
2115
  /**
2116
  * Filter what keys to show from oneLogRow
2131
  * @param array with keys to show. key to show = key. value = boolean to show or not.
2132
  * @param object log row to show details from
2133
  */
2134
+ $logRowKeysToShow = apply_filters( "simple_history/log_html_output_details_table/row_keys_to_show", $logRowKeysToShow, $oneLogRow );
2135
 
2136
  // Hide some keys by default
2137
  unset(
2147
  foreach ( $oneLogRow as $rowKey => $rowVal ) {
2148
 
2149
  // Only columns from oneLogRow that exist in logRowKeysToShow will be outputed
2150
+ if ( ! array_key_exists( $rowKey, $logRowKeysToShow ) || ! $logRowKeysToShow[$rowKey] ) {
2151
  continue;
2152
  }
2153
 
2154
  // skip arrays and objects and such
2155
+ if ( is_array( $rowVal ) || is_object( $rowVal ) ) {
2156
  continue;
2157
  }
2158
 
2161
  <td>%1$s</td>
2162
  <td>%2$s</td>
2163
  </tr>',
2164
+ esc_html( $rowKey ),
2165
+ esc_html( $rowVal )
2166
  );
2167
 
2168
  }
2169
 
2170
 
2171
+ $logRowContextKeysToShow = array_fill_keys( array_keys( (array) $oneLogRow->context ), true );
2172
  /*
2173
  error_log($this->json_encode($logRowContextKeysToShow));
2174
  Marker - 2 maj 2015 20:51:54
2210
  * @param array with keys to show. key to show = key. value = boolean to show or not.
2211
  * @param object log row to show details from
2212
  */
2213
+ $logRowContextKeysToShow = apply_filters( "simple_history/log_html_output_details_table/context_keys_to_show", $logRowContextKeysToShow, $oneLogRow );
2214
 
2215
  foreach ( $oneLogRow->context as $contextKey => $contextVal ) {
2216
 
2217
  // Only columns from context that exist in logRowContextKeysToShow will be outputed
2218
+ if ( ! array_key_exists( $contextKey, $logRowContextKeysToShow ) || ! $logRowContextKeysToShow[$contextKey] ) {
2219
  continue;
2220
  }
2221
 
2224
  <td>%1$s</td>
2225
  <td>%2$s</td>
2226
  </tr>',
2227
+ esc_html( $contextKey ),
2228
+ esc_html( $contextVal )
2229
  );
2230
 
2231
  }
2232
 
2233
  $more_details_html .= "</table>";
2234
 
2235
+ $more_details_html = apply_filters( "simple_history/log_html_output_details_single/html_after_context_table", $more_details_html, $oneLogRow );
2236
 
2237
  $more_details_html = sprintf(
2238
  '<div class="SimpleHistoryLogitem__moreDetails">%1$s</div>',
2248
  "SimpleHistoryLogitem--logger-{$oneLogRow->logger}",
2249
  );
2250
 
2251
+ if ( isset( $oneLogRow->initiator ) && ! empty( $oneLogRow->initiator ) ) {
2252
  $classes[] = "SimpleHistoryLogitem--initiator-" . $oneLogRow->initiator;
2253
  }
2254
 
2260
  $log_level_tag_html = sprintf(
2261
  ' <span class="SimpleHistoryLogitem--logleveltag SimpleHistoryLogitem--logleveltag-%1$s">%2$s</span>',
2262
  $oneLogRow->level,
2263
+ $this->getLogLevelTranslated( $oneLogRow->level )
2264
  );
2265
 
2266
  $plain_text_html .= $log_level_tag_html;
2272
  *
2273
  * @param $classes Array with classes
2274
  */
2275
+ $classes = apply_filters( "simple_history/logrowhtmloutput/classes", $classes );
2276
 
2277
  // Generate the HTML output for a row
2278
  $output = sprintf(
2299
  $oneLogRow->logger, // 7
2300
  $data_attrs, // 8 data attributes
2301
  $more_details_html, // 9
2302
+ esc_attr( join( " ", $classes ) ) // 10
2303
  );
2304
 
2305
  // Get the main message row.
2306
  // Should be as plain as possible, like plain text
2307
  // but with links to for example users and posts
2308
+ //SimpleLoggerFormatter::getRowTextOutput($oneLogRow);
2309
 
2310
  // Get detailed HTML-based output
2311
  // May include images, lists, any cool stuff needed to view
2312
+ //SimpleLoggerFormatter::getRowHTMLOutput($oneLogRow);
2313
 
2314
+ return trim( $output );
2315
 
2316
  }
2317
 
2322
  * @param string $loglevel
2323
  * @return string translated loglevel
2324
  */
2325
+ function getLogLevelTranslated( $loglevel ) {
2326
 
2327
  $str_translated = "";
2328
 
2329
+ switch ( $loglevel ) {
2330
 
2331
  // Lowercase
2332
  case "emergency":
2333
+ $str_translated = _x( "emergency", "Log level in gui", "simple-history" );
2334
  break;
2335
 
2336
  case "alert":
2337
+ $str_translated = _x( "alert", "Log level in gui", "simple-history" );
2338
  break;
2339
 
2340
  case "critical":
2341
+ $str_translated = _x( "critical", "Log level in gui", "simple-history" );
2342
  break;
2343
 
2344
  case "error":
2345
+ $str_translated = _x( "error", "Log level in gui", "simple-history" );
2346
  break;
2347
 
2348
  case "warning":
2349
+ $str_translated = _x( "warning", "Log level in gui", "simple-history" );
2350
  break;
2351
 
2352
  case "notice":
2353
+ $str_translated = _x( "notice", "Log level in gui", "simple-history" );
2354
  break;
2355
 
2356
  case "info":
2357
+ $str_translated = _x( "info", "Log level in gui", "simple-history" );
2358
  break;
2359
 
2360
  case "debug":
2361
+ $str_translated = _x( "debug", "Log level in gui", "simple-history" );
2362
  break;
2363
 
2364
  // Uppercase
2365
  case "Emergency":
2366
+ $str_translated = _x( "Emergency", "Log level in gui", "simple-history" );
2367
  break;
2368
 
2369
  case "Alert":
2370
+ $str_translated = _x( "Alert", "Log level in gui", "simple-history" );
2371
  break;
2372
 
2373
  case "Critical":
2374
+ $str_translated = _x( "Critical", "Log level in gui", "simple-history" );
2375
  break;
2376
 
2377
  case "Error":
2378
+ $str_translated = _x( "Error", "Log level in gui", "simple-history" );
2379
  break;
2380
 
2381
  case "Warning":
2382
+ $str_translated = _x( "Warning", "Log level in gui", "simple-history" );
2383
  break;
2384
 
2385
  case "Notice":
2386
+ $str_translated = _x( "Notice", "Log level in gui", "simple-history" );
2387
  break;
2388
 
2389
  case "Info":
2390
+ $str_translated = _x( "Info", "Log level in gui", "simple-history" );
2391
  break;
2392
 
2393
  case "Debug":
2394
+ $str_translated = _x( "Debug", "Log level in gui", "simple-history" );
2395
  break;
2396
 
2397
  default:
2412
  public function getInstantiatedDropins() {
2413
 
2414
  return $this->instantiatedDropins;
2415
+
2416
  }
 
2417
 
 
2418
 
2419
+ public function getInstantiatedLoggerBySlug( $slug = "" ) {
2420
+
2421
+ if ( empty( $slug ) ) {
2422
  return false;
2423
  }
2424
 
2425
+ foreach ( $this->getInstantiatedLoggers() as $one_logger ) {
2426
 
2427
+ if ( $slug == $one_logger["instance"]->slug ) {
2428
  return $one_logger["instance"];
2429
  }
2430
 
2442
  * @param string $format format to return loggers in. Default is array.
2443
  * @return array
2444
  */
2445
+ public function getLoggersThatUserCanRead( $user_id = "", $format = "array" ) {
2446
 
2447
  $arr_loggers_user_can_view = array();
2448
 
2449
+ if ( ! is_numeric( $user_id ) ) {
2450
  $user_id = get_current_user_id();
2451
  }
2452
 
2453
  $loggers = $this->getInstantiatedLoggers();
2454
+ foreach ( $loggers as $one_logger ) {
2455
 
2456
  $logger_capability = $one_logger["instance"]->getCapability();
2457
 
2458
  //$arr_loggers_user_can_view = apply_filters("simple_history/loggers_user_can_read", $user_id, $arr_loggers_user_can_view);
2459
+ $user_can_read_logger = user_can( $user_id, $logger_capability );
2460
+ $user_can_read_logger = apply_filters( "simple_history/loggers_user_can_read/can_read_single_logger", $user_can_read_logger, $one_logger["instance"], $user_id );
2461
 
2462
+ if ( $user_can_read_logger ) {
2463
  $arr_loggers_user_can_view[] = $one_logger;
2464
  }
2465
 
2473
  * @param array $arr_loggers_user_can_view Array with loggers that user $user_id can read
2474
  * @param int user_id ID of user to check read capability for
2475
  */
2476
+ $arr_loggers_user_can_view = apply_filters( "simple_history/loggers_user_can_read", $arr_loggers_user_can_view, $user_id );
2477
 
2478
  // just return array with slugs in parenthesis suitable for sql-where
2479
+ if ( "sql" == $format ) {
2480
 
2481
  $str_return = "(";
2482
 
2483
+ foreach ( $arr_loggers_user_can_view as $one_logger ) {
2484
 
2485
  $str_return .= sprintf(
2486
  '"%1$s", ',
2489
 
2490
  }
2491
 
2492
+ $str_return = rtrim( $str_return, " ," );
2493
  $str_return .= ")";
2494
 
2495
  return $str_return;
2513
  * @param string $alt Alternative text to use in image tag. Defaults to blank
2514
  * @return string <img> tag for the user's avatar
2515
  */
2516
+ function get_avatar( $email, $size = '96', $default = '', $alt = false ) {
2517
 
2518
  // WP setting for avatars is to show, so just use the built in function
2519
+ if ( get_option( 'show_avatars' ) ) {
2520
 
2521
+ $avatar = get_avatar( $email, $size, $default, $alt );
2522
 
2523
  return $avatar;
2524
 
2526
 
2527
  // WP setting for avatar was to not show, but we do it anyway, using the same code as get_avatar() would have used
2528
 
2529
+ if ( false === $alt ) {
2530
  $safe_alt = '';
2531
  } else {
2532
+ $safe_alt = esc_attr( $alt );
2533
  }
2534
 
2535
+ if ( ! is_numeric( $size ) ) {
2536
  $size = '96';
2537
  }
2538
 
2539
+ if ( empty( $default ) ) {
2540
+ $avatar_default = get_option( 'avatar_default' );
2541
+ if ( empty( $avatar_default ) ) {
2542
  $default = 'mystery';
2543
  } else {
2544
  $default = $avatar_default;
2546
 
2547
  }
2548
 
2549
+ if ( ! empty( $email ) ) {
2550
+ $email_hash = md5( strtolower( trim( $email ) ) );
2551
  }
2552
 
2553
+ if ( is_ssl() ) {
2554
  $host = 'https://secure.gravatar.com';
2555
  } else {
2556
+ if ( ! empty( $email ) ) {
2557
+ $host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );
2558
  } else {
2559
  $host = 'http://0.gravatar.com';
2560
  }
2561
 
2562
  }
2563
 
2564
+ if ( 'mystery' == $default ) {
2565
  $default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}";
2566
  }
2567
  // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
2568
+ elseif ( 'blank' == $default ) {
2569
+ $default = $email ? 'blank' : includes_url( 'images/blank.gif' );
2570
+ } elseif ( ! empty( $email ) && 'gravatar_default' == $default ) {
2571
  $default = '';
2572
+ } elseif ( 'gravatar_default' == $default ) {
2573
  $default = "$host/avatar/?s={$size}";
2574
+ } elseif ( empty( $email ) ) {
2575
  $default = "$host/avatar/?d=$default&amp;s={$size}";
2576
+ } elseif ( strpos( $default, 'http://' ) === 0 ) {
2577
+ $default = add_query_arg( 's', $size, $default );
2578
  }
2579
 
2580
+ if ( ! empty( $email ) ) {
2581
  $out = "$host/avatar/";
2582
  $out .= $email_hash;
2583
  $out .= '?s=' . $size;
2584
+ $out .= '&amp;d=' . urlencode( $default );
2585
 
2586
+ $rating = get_option( 'avatar_rating' );
2587
+ if ( ! empty( $rating ) ) {
2588
  $out .= "&amp;r={$rating}";
2589
  }
2590
 
2591
+ $out = str_replace( '&#038;', '&amp;', esc_url( $out ) );
2592
  $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
2593
  } else {
2594
+ $out = esc_url( $default );
2595
  $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
2596
  }
2597
 
2625
 
2626
  // Get number of events today
2627
  $logQuery = new SimpleHistoryLogQuery();
2628
+ $logResults = $logQuery->query( array(
2629
  "posts_per_page" => 1,
2630
+ "date_from" => strtotime( "today" ),
2631
+ ) );
2632
 
2633
  $total_row_count = (int) $logResults["total_row_count"];
2634
 
2635
  // Get sql query for where to read only loggers current user is allowed to read/view
2636
+ $sql_loggers_in = $this->getLoggersThatUserCanRead( get_current_user_id(), "sql" );
2637
 
2638
  // Get number of users today, i.e. events with wp_user as initiator
2639
+ $sql_users_today = sprintf( '
2640
  SELECT
2641
  DISTINCT(c.value) AS user_id
2642
  #h.id, h.logger, h.level, h.initiator, h.date
2649
  AND date > "%2$s"
2650
  ',
2651
  $sql_loggers_in,
2652
+ date( "Y-m-d H:i", strtotime( "today" ) ),
2653
  $wpdb->prefix . SimpleHistory::DBTABLE,
2654
  $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS
2655
  );
2656
 
2657
  $cache_key = "quick_stats_users_today_" . md5( serialize( $sql_loggers_in ) );
2658
  $cache_group = "simple-history-" . $this->get_cache_incrementor();
2659
+ $results_users_today = wp_cache_get( $cache_key, $cache_group );
2660
 
2661
  if ( false === $results_users_today ) {
2662
+ $results_users_today = $wpdb->get_results( $sql_users_today );
2663
+ wp_cache_set( $cache_key, $results_users_today, $cache_group );
2664
  }
2665
 
2666
  $count_users_today = sizeof( $results_users_today );
2673
  AND date > "%2$s"
2674
  ',
2675
  $sql_loggers_in,
2676
+ date( "Y-m-d H:i", strtotime( "today" ) ),
2677
  $wpdb->prefix . SimpleHistory::DBTABLE,
2678
  $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS
2679
  );
2680
 
2681
+ $sql_other_sources_where = apply_filters( "simple_history/quick_stats_where", $sql_other_sources_where );
2682
 
2683
+ $sql_other_sources = sprintf( '
2684
  SELECT
2685
  DISTINCT(h.initiator) AS initiator
2686
  FROM %3$s AS h
2688
  %5$s
2689
  ',
2690
  $sql_loggers_in,
2691
+ date( "Y-m-d H:i", strtotime( "today" ) ),
2692
  $wpdb->prefix . SimpleHistory::DBTABLE,
2693
  $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS,
2694
  $sql_other_sources_where // 5
2695
  );
2696
  // sf_d($sql_other_sources, '$sql_other_sources');
2697
 
2698
+ $cache_key = "quick_stats_results_other_sources_today_" . md5( serialize( $sql_other_sources ) );
2699
+ $results_other_sources_today = wp_cache_get( $cache_key, $cache_group );
2700
 
2701
  if ( false === $results_other_sources_today ) {
2702
 
2703
+ $results_other_sources_today = $wpdb->get_results( $sql_other_sources );
2704
+ wp_cache_set( $cache_key, $results_other_sources_today, $cache_group );
2705
 
2706
  }
2707
 
2708
+ $count_other_sources = sizeof( $results_other_sources_today );
2709
 
2710
+ //sf_d($logResults, '$logResults');
2711
+ //sf_d($results_users_today, '$sql_users_today');
2712
+ //sf_d($results_other_sources_today, '$results_other_sources_today');
2713
 
2714
  ?>
2715
  <div class="SimpleHistoryQuickStats">
2721
  // No results today at all
2722
  if ( $total_row_count == 0 ) {
2723
 
2724
+ $msg_tmpl = __( "No events today so far.", "simple-history" );
2725
 
2726
  } else {
2727
 
2740
  // A single event existed and was from a user
2741
  // 1 event today from 1 user.
2742
  if ( $total_row_count == 1 && $count_users_today == 1 ) {
2743
+ $msg_tmpl .= __( 'One event today from one user.', "simple-history" );
2744
  }
2745
 
2746
  // A single event existed and was from another source
2747
  // 1 event today from 1 source.
2748
+ if ( $total_row_count == 1 && ! $count_users_today ) {
2749
+ $msg_tmpl .= __( 'One event today from one source.', "simple-history" );
2750
  }
2751
 
2752
  // Multiple events from a single user
2753
  // 3 events today from one user.
2754
+ if ( $total_row_count > 1 && $count_users_today == 1 && ! $count_other_sources ) {
2755
+ $msg_tmpl .= __( '%1$d events today from one user.', "simple-history" );
2756
  }
2757
 
2758
  // Multiple events from only users
2759
  // 2 events today from 2 users.
2760
  if ( $total_row_count > 1 && $count_users_today == $total_row_count ) {
2761
+ $msg_tmpl .= __( '%1$d events today from %2$d users.', "simple-history" );
2762
  }
2763
 
2764
  // Multiple events from 1 single user and 1 single other source
2765
  // 2 events today from 1 user and 1 other source.
2766
  if ( $total_row_count && 1 == $count_users_today && 1 == $count_other_sources ) {
2767
+ $msg_tmpl .= __( '%1$d events today from one user and one other source.', "simple-history" );
2768
  }
2769
 
2770
  // Multiple events from multple users but from only 1 single other source
2771
  // 3 events today from 2 users and 1 other source.
2772
  if ( $total_row_count > 1 && $count_users_today > 1 && $count_other_sources == 1 ) {
2773
+ $msg_tmpl .= __( '%1$d events today from one user and one other source.', "simple-history" );
2774
  }
2775
 
2776
  // Multiple events from 1 user but from multiple other source
2777
  // 3 events today from 1 user and 2 other sources.
2778
  if ( $total_row_count > 1 && 1 == $count_users_today && $count_other_sources > 1 ) {
2779
+ $msg_tmpl .= __( '%1$d events today from one user and %3$d other sources.', "simple-history" );
2780
  }
2781
 
2782
  // Multiple events from multiple user and from multiple other sources
2783
  // 4 events today from 2 users and 2 other sources.
2784
  if ( $total_row_count > 1 && $count_users_today > 1 && $count_other_sources > 1 ) {
2785
+ $msg_tmpl .= __( '%1$s events today from %2$d users and %3$d other sources.', "simple-history" );
2786
  }
2787
 
2788
  }
2859
  * SimpleHistory()->info();
2860
  * instead
2861
  */
2862
+ function simple_history_add( $args ) {
2863
 
2864
  $defaults = array(
2865
  "action" => null,
2875
 
2876
  $message = "{$context["object_type"]} {$context["object_name"]} {$context["action"]}";
2877
 
2878
+ SimpleLogger()->info( $message, $context );
2879
 
2880
  } // simple_history_add
2881
 
2923
 
2924
  $args = wp_parse_args( $args, $defaults );
2925
 
2926
+ if ( ! class_exists( 'WP_Text_Diff_Renderer_Table' ) )
2927
+ require ABSPATH . WPINC . '/wp-diff.php';
2928
 
2929
+ $left_string = normalize_whitespace( $left_string );
2930
+ $right_string = normalize_whitespace( $right_string );
2931
 
2932
+ $left_lines = explode( "\n", $left_string );
2933
+ $right_lines = explode( "\n", $right_string );
2934
+ $text_diff = new Text_Diff( $left_lines, $right_lines );
2935
 
2936
  $renderer = new WP_Text_Diff_Renderer_Table( $args );
2937
  $renderer->_leading_context_lines = $args["leading_context_lines"];
2938
  $renderer->_trailing_context_lines = $args["trailing_context_lines"];
2939
 
2940
+ $diff = $renderer->render( $text_diff );
2941
 
2942
+ if ( ! $diff )
2943
  return '';
2944
 
2945
  $r = "<table class='diff SimpleHistory__diff'>\n";
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.1.5
9
  Author: Pär Thernström
10
  Author URI: http://simple-history.com/
11
  License: GPL2
@@ -46,7 +46,7 @@ if ( version_compare( phpversion(), "5.3", ">=") ) {
46
  // register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
47
 
48
  if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
49
- define( 'SIMPLE_HISTORY_VERSION', '2.1.5' );
50
  }
51
 
52
  if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
@@ -105,4 +105,3 @@ if ( version_compare( phpversion(), "5.3", ">=") ) {
105
  }
106
 
107
  }
108
-
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.1.6
9
  Author: Pär Thernström
10
  Author URI: http://simple-history.com/
11
  License: GPL2
46
  // register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
47
 
48
  if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
49
+ define( 'SIMPLE_HISTORY_VERSION', '2.1.6' );
50
  }
51
 
52
  if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
105
  }
106
 
107
  }
 
languages/simple-history-da_DK.mo CHANGED
Binary file
languages/simple-history-da_DK.po CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Simple History v2.0.12\n"
4
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/Simple-History\n"
5
- "POT-Creation-Date: 2015-04-01 14:16:45+00:00\n"
6
- "PO-Revision-Date: 2015-04-13 12:20+0100\n"
7
  "Last-Translator: Thomas Blomberg Hansen <thomas@blomberg.it>\n"
8
  "Language-Team: \n"
9
  "Language: da_DK\n"
@@ -11,7 +11,7 @@ msgstr ""
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
14
- "X-Generator: Poedit 1.7.1\n"
15
  "X-Poedit-SourceCharset: utf-8\n"
16
  "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
17
  "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
@@ -34,36 +34,40 @@ msgstr ""
34
  "a> eller <a href=\"%2$s\">købe noget til mig på min Amazon wish list</a>."
35
 
36
  # @ simple-history
37
- #: dropins/SimpleHistoryFilterDropin.php:46
38
  msgid "Filter history"
39
  msgstr "Filtrer historik"
40
 
41
- #: dropins/SimpleHistoryFilterDropin.php:50
42
- #: dropins/SimpleHistoryFilterDropin.php:161
 
 
 
 
 
 
 
 
 
43
  msgid "Search events"
44
  msgstr "Søg i events"
45
 
46
  # @ simple-history
47
- #: dropins/SimpleHistoryFilterDropin.php:58
48
  msgid "All log levels"
49
  msgstr "Alle log niveauer"
50
 
51
  # @ simple-history
52
- #: dropins/SimpleHistoryFilterDropin.php:72
53
  msgid "All messages"
54
  msgstr "Alle beskeder"
55
 
56
  # @ simple-history
57
- #: dropins/SimpleHistoryFilterDropin.php:126
58
  msgid "All users"
59
  msgstr "Alle brugere"
60
 
61
- # @ simple-history
62
- #: dropins/SimpleHistoryFilterDropin.php:147
63
- msgid "All dates"
64
- msgstr "Alle datoer"
65
-
66
- #: dropins/SimpleHistoryFilterDropin.php:170
67
  msgid "Search"
68
  msgstr "Søg"
69
 
@@ -90,34 +94,34 @@ msgstr "Oprettet ny RSS url"
90
 
91
  # @ simple-history
92
  #: dropins/SimpleHistoryRSSDropin.php:150
93
- #: dropins/SimpleHistoryRSSDropin.php:277
94
  msgid "History for %s"
95
  msgstr "Historik fra %s"
96
 
97
  # @ simple-history
98
  #: dropins/SimpleHistoryRSSDropin.php:151
99
- #: dropins/SimpleHistoryRSSDropin.php:278
100
  msgid "WordPress History for %s"
101
  msgstr "WordPress historik fra %s"
102
 
103
- #: dropins/SimpleHistoryRSSDropin.php:201
104
  msgid "Severity level: %1$s"
105
  msgstr "Alvorlighedsniveau: %1$s"
106
 
107
  # begivenhed er måske ikke det rigtige ord.
108
- #: dropins/SimpleHistoryRSSDropin.php:214
109
  msgid "+%1$s occasion"
110
  msgid_plural "+%1$s occasions"
111
  msgstr[0] "+%1$s begivenhed"
112
  msgstr[1] "+%1$s begivenheder"
113
 
114
  # @ simple-history
115
- #: dropins/SimpleHistoryRSSDropin.php:281
116
  msgid "Wrong RSS secret"
117
  msgstr "Forkert RSS nøgle"
118
 
119
  # @ simple-history
120
- #: dropins/SimpleHistoryRSSDropin.php:282
121
  msgid ""
122
  "Your RSS secret for Simple History RSS feed is wrong. Please see WordPress "
123
  "settings for current link to the RSS feed."
@@ -126,7 +130,7 @@ msgstr ""
126
  "rigtige url under Indstillinger -> Simpel Historik."
127
 
128
  # @ simple-history
129
- #: dropins/SimpleHistoryRSSDropin.php:333
130
  msgid ""
131
  "You can generate a new address for the RSS feed. This is useful if you think "
132
  "that the address has fallen into the wrong hands."
@@ -135,12 +139,12 @@ msgstr ""
135
  "mistænker at url'en er faldet i de forkerte hænder."
136
 
137
  # @ simple-history
138
- #: dropins/SimpleHistoryRSSDropin.php:336
139
  msgid "Generate new address"
140
  msgstr "Generere ny url"
141
 
142
  # @ simple-history
143
- #: dropins/SimpleHistoryRSSDropin.php:364
144
  msgid ""
145
  "Simple History has a RSS feed which you can subscribe to and receive log "
146
  "updates. Make sure you only share the feed with people you trust, since it "
@@ -169,194 +173,202 @@ msgid "Stats"
169
  msgstr "Statistik"
170
 
171
  # @ simple-history
172
- #: dropins/SimpleHistorySidebarDropin.php:162 loggers/SimpleLogger.php:305
173
  msgid "Just now"
174
  msgstr "Lige nu"
175
 
 
 
 
 
 
 
 
 
176
  # @ simple-history
177
- #: inc/SimpleHistory.php:538 inc/SimpleHistory.php:821
178
  msgid "Settings"
179
  msgstr "Indstillinger"
180
 
181
  # @ simple-history
182
- #: inc/SimpleHistory.php:549
183
  msgid "Log (debug)"
184
  msgstr "Log (debug)"
185
 
186
  # @ simple-history
187
- #: inc/SimpleHistory.php:554
188
  msgid "Styles example (debug)"
189
  msgstr "Styles eksempel (debug)"
190
 
191
  # @ simple-history
192
  #. Plugin Name of the plugin/theme
193
- #: inc/SimpleHistory.php:846
194
  msgid "Simple History"
195
  msgstr "Simpel historik"
196
 
197
  # @ simple-history
198
- #: inc/SimpleHistory.php:924
199
  msgid "Remove all log items?"
200
  msgstr "Fjern alle log elementer?"
201
 
202
  # @ simple-history
203
- #: inc/SimpleHistory.php:926
204
  msgid "Go to the first page"
205
  msgstr "Gå til den første side"
206
 
207
  # @ simple-history
208
- #: inc/SimpleHistory.php:927
209
  msgid "Go to the previous page"
210
  msgstr "Gå til den forrige side"
211
 
212
  # @ simple-history
213
- #: inc/SimpleHistory.php:928
214
  msgid "Go to the next page"
215
  msgstr "Gå til den næste side"
216
 
217
  # @ simple-history
218
- #: inc/SimpleHistory.php:929
219
  msgid "Go to the last page"
220
  msgstr "Gå til den sidste side"
221
 
222
  # @ simple-history
223
- #: inc/SimpleHistory.php:930
224
  msgid "Current page"
225
  msgstr "Nuværende side"
226
 
227
  # @ simple-history
228
- #: inc/SimpleHistory.php:932
229
  msgid "Oups, the log could not be loaded right now."
230
  msgstr "Ups, loggen kunne ikke indlæses lige nu."
231
 
232
  # @ simple-history
233
- #: inc/SimpleHistory.php:933
234
  msgid "Your search did not match any history events."
235
  msgstr "Din søgning gav ingen resultater."
236
 
237
  # @ simple-history
238
- #: inc/SimpleHistory.php:1217 inc/SimpleHistory.php:1332
239
  msgid "Simple History Settings"
240
  msgstr "Simpel Historik opsætning"
241
 
242
  # @ simple-history
243
- #: inc/SimpleHistory.php:1251
244
  msgid "No valid callback found"
245
  msgstr "Ingen gyldig callback fundet "
246
 
247
  # @ simple-history
248
- #: inc/SimpleHistory.php:1353
249
  msgid "Cleared database"
250
  msgstr "Nulstillet database"
251
 
252
  # @ simple-history
253
- #: inc/SimpleHistory.php:1380
254
  msgid "Show history"
255
  msgstr "Vis historik"
256
 
257
  # @ simple-history
258
- #: inc/SimpleHistory.php:1393
259
  msgid "Number of items per page"
260
  msgstr "Antal elementer pr. side"
261
 
262
  # @ simple-history
263
- #: inc/SimpleHistory.php:1405
264
  msgid "Clear log"
265
  msgstr "Nulstil log"
266
 
267
  # @ simple-history
268
- #: inc/SimpleHistory.php:1544
269
  msgid "on the dashboard"
270
  msgstr "på kontrolpanelet"
271
 
272
  # @ simple-history
273
- #: inc/SimpleHistory.php:1549
274
  msgid "as a page under the dashboard menu"
275
  msgstr "som et undermenupunkt til Kontrolpanelet "
276
 
277
  # @ simple-history
278
- #: inc/SimpleHistory.php:1565
279
  msgid "Items in the database are automatically removed after %1$s days."
280
  msgstr "Elementer i databasen fjernes automatisk efter %1$s dage."
281
 
282
  # @ simple-history
283
- #: inc/SimpleHistory.php:1567
284
  msgid "Items in the database are kept forever."
285
  msgstr "Elementer i databasen gemmes for evigt."
286
 
287
  # @ simple-history
288
- #: inc/SimpleHistory.php:1571
289
  msgid "Clear log now"
290
  msgstr "Nulstil log nu"
291
 
292
- #: inc/SimpleHistory.php:1621
293
  msgid "The log for Simple History was cleared ({num_rows} rows were removed)."
294
  msgstr ""
295
  "Loggen for Simple Historik blev nulstillet ({num_rows} rækker blev fjernet)."
296
 
297
- #: inc/SimpleHistory.php:1885
298
  msgid "+%1$s similar event"
299
  msgid_plural "+%1$s similar events"
300
  msgstr[0] "+%1$s tilsvarende event"
301
  msgstr[1] "+%1$s tilsvarende events"
302
 
303
  # @ simple-history
304
- #: inc/SimpleHistory.php:1892
305
  msgid "Loading…"
306
  msgstr "Indlæser..."
307
 
308
  # @ simple-history
309
- #: inc/SimpleHistory.php:1899
310
  msgid "Showing %1$s more"
311
  msgstr "%1$s flere vises"
312
 
313
  # @ simple-history
314
- #: inc/SimpleHistory.php:1927
315
  msgid "Context data"
316
  msgstr "Kontekst data"
317
 
318
  # @ simple-history
319
- #: inc/SimpleHistory.php:1928
320
  msgid "This is potentially useful meta data that a logger has saved."
321
  msgstr "Dette er potentielt brugbar meta data, som en logger har gemt."
322
 
323
  # @ simple-history
324
- #: inc/SimpleHistory.php:2448
325
  msgid "No events today so far."
326
  msgstr "Endnu ingen events i dag."
327
 
328
- #: inc/SimpleHistory.php:2467
329
  msgid "One event today from one user."
330
  msgstr "Et event i dag, fra én bruger."
331
 
332
- #: inc/SimpleHistory.php:2473
333
  msgid "One event today from one source."
334
  msgstr "Et event i dag, fra én kilde"
335
 
336
  # @ simple-history
337
- #: inc/SimpleHistory.php:2479
338
  msgid "%1$d events today from one user."
339
  msgstr "%1$d events i dag fra én bruger."
340
 
341
  # @ simple-history
342
- #: inc/SimpleHistory.php:2485
343
  msgid "%1$d events today from %2$d users."
344
  msgstr "%1$d events i dag fra %2$d brugere."
345
 
346
- #: inc/SimpleHistory.php:2491 inc/SimpleHistory.php:2497
347
  msgid "%1$d events today from one user and one other source."
348
  msgstr "%1$d events i dag, fra én bruger og én kilde"
349
 
350
- #: inc/SimpleHistory.php:2503
351
  msgid "%1$d events today from one user and %3$d other sources."
352
  msgstr "%1$d events i dag, fra én bruger og %3$d kilder."
353
 
354
- #: inc/SimpleHistory.php:2509
355
  msgid "%1$s events today from %2$d users and %3$d other sources."
356
  msgstr "%1$s events i dag, fra %2$d brugere og %3$d kilder."
357
 
358
  # @ simple-history
359
- #: index.php:74
360
  msgid ""
361
  "Simple History is a great plugin, but to use it your server must have at "
362
  "least PHP 5.3 installed (you have version %s)."
@@ -419,29 +431,29 @@ msgid "%d occasions"
419
  msgstr "%d begivenheder"
420
 
421
  # @ simple-history
422
- #: loggers/SimpleLogger.php:212
423
  msgid "Deleted user (had id %1$s, email %2$s, login %3$s)"
424
  msgstr "Slettet bruger (havde ID %1$s, E-mail %2$s, brugernavn %3$s)"
425
 
426
  # @ simple-history
427
- #: loggers/SimpleLogger.php:227
428
  msgid "Anonymous web user"
429
  msgstr "Anonym besøgende"
430
 
431
  # @ simple-history
432
- #: loggers/SimpleLogger.php:235
433
  msgid "Anonymous user from %1$s"
434
  msgstr "Anonym bruger fra %1$s"
435
 
436
  # @ simple-history
437
  #. translators: Date format for log row header, see http:php.net/date
438
- #: loggers/SimpleLogger.php:310
439
  msgid "M j, Y \\a\\t G:i"
440
  msgstr "j. F Y \\k\\l\\. H:i"
441
 
442
  # @ simple-history
443
  #. translators: 1: last modified date and time in human time diff-format
444
- #: loggers/SimpleLogger.php:318
445
  msgid "%1$s ago"
446
  msgstr "%1$s siden"
447
 
@@ -461,34 +473,34 @@ msgid "Deleted {post_type} \"{attachment_title}\" (\"{attachment_filename}\")"
461
  msgstr "Slettet {post_type} \"{attachment_title}\" (\"{attachment_filename}\")"
462
 
463
  # @ simple-history
464
- #: loggers/SimpleMediaLogger.php:121
465
  msgid "Edited {post_type} <a href=\"{edit_link}\">\"{attachment_title}\"</a>"
466
  msgstr ""
467
  "Redigeret {post_type} <a href=\"{edit_link}\">\"{attachment_title}\"</a>"
468
 
469
  # @ simple-history
470
- #: loggers/SimpleMediaLogger.php:125
471
  msgid "Uploaded {post_type} <a href=\"{edit_link}\">\"{attachment_title}\"</a>"
472
  msgstr ""
473
  "Uploadet {post_type} <a href=\"{edit_link}\">\"{attachment_title}\"</a>"
474
 
475
  # @ simple-history
476
- #: loggers/SimpleMediaLogger.php:237
477
  msgid "{attachment_thumb}"
478
  msgstr "{attachment_thumb}"
479
 
480
  # @ simple-history
481
- #: loggers/SimpleMediaLogger.php:246
482
  msgid "{attachment_size_format}"
483
  msgstr "{attachment_size_format}"
484
 
485
  # @ simple-history
486
- #: loggers/SimpleMediaLogger.php:247
487
  msgid "{attachment_filetype_extension}"
488
  msgstr "{attachment_filetype_extension}"
489
 
490
  # @ simple-history
491
- #: loggers/SimpleMediaLogger.php:249
492
  msgid "{full_image_width} × {full_image_height}"
493
  msgstr "{full_image_width} × {full_image_height}"
494
 
@@ -523,12 +535,12 @@ msgid "Updated option \"{option}\""
523
  msgstr "Opdateret indstlling \"{option}\""
524
 
525
  # @ simple-history
526
- #: loggers/SimpleOptionsLogger.php:244 loggers/SimpleThemeLogger.php:571
527
  msgid "New value"
528
  msgstr "Ny værdi"
529
 
530
  # @ simple-history
531
- #: loggers/SimpleOptionsLogger.php:255 loggers/SimpleThemeLogger.php:583
532
  msgid "Old value"
533
  msgstr "Gammel værdi"
534
 
@@ -537,79 +549,132 @@ msgstr "Gammel værdi"
537
  msgid "Settings page"
538
  msgstr "Indstillinger side"
539
 
540
- #: loggers/SimplePluginLogger.php:177
541
  msgid "You don't have access to this page."
542
  msgstr "Du har ikke adgang til denne side."
543
 
544
- #: loggers/SimplePluginLogger.php:183 loggers/SimplePluginLogger.php:188
545
  msgid "Could not find GitHub repository."
546
  msgstr "Kunne ikke finde GitHub repository."
547
 
548
- #: loggers/SimplePluginLogger.php:208
549
- #, fuzzy
550
  msgid ""
551
  "<p>Viewing <code>readme</code> from repository <code><a target=\"_blank\" "
552
  "href=\"%1$s\">%2$s</a></code>.</p>"
553
  msgstr ""
554
- "<p>Læser <code>readme</code> fra repository <code><a target=\"_blank\" href="
555
  "\"%1$s\">%2$s</a></code>.</p>"
556
 
557
- #: loggers/SimplePluginLogger.php:281
558
  msgid "You do not have sufficient permissions to delete plugins for this site."
559
  msgstr ""
560
  "Du har ikke de nødvendige tilladelser til, at slette plugins på denne side."
561
 
562
- #: loggers/SimplePluginLogger.php:1129
563
  msgid "WordPress Plugin Repository"
564
  msgstr "WordPress Plugin Repository"
565
 
566
- #: loggers/SimplePluginLogger.php:1132
567
  msgid "Uploaded ZIP archive"
568
  msgstr "Uploaded ZIP fil"
569
 
570
  # @ simple-history
571
- #: loggers/SimplePostLogger.php:184
572
  msgid "Created {post_type} \"{post_title}\""
573
  msgstr "Tilføjet {post_type} \"{post_title}\""
574
 
575
  # @ simple-history
576
- #: loggers/SimplePostLogger.php:185
577
  msgid "Updated {post_type} \"{post_title}\""
578
  msgstr "Opdaterede {post_type} \"{post_title}\""
579
 
580
  # @ simple-history
581
- #: loggers/SimplePostLogger.php:186
582
  msgid "Restored {post_type} \"{post_title}\" from trash"
583
  msgstr "Gendannede {post_type} \"{post_title}\" fra papirkurven"
584
 
585
  # @ simple-history
586
- #: loggers/SimplePostLogger.php:187 loggers/SimplePostLogger.php:456
587
  msgid "Deleted {post_type} \"{post_title}\""
588
  msgstr "Slettede {post_type} \"{post_title}\""
589
 
590
  # @ simple-history
591
- #: loggers/SimplePostLogger.php:188
592
  msgid "Moved {post_type} \"{post_title}\" to the trash"
593
  msgstr "Flyttede {post_type} \"{post_title}\" til papirkurven"
594
 
595
  # @ simple-history
596
- #: loggers/SimplePostLogger.php:452
597
  msgid "Updated {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a>"
598
  msgstr "Opdaterede {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a>"
599
 
600
  # @ simple-history
601
- #: loggers/SimplePostLogger.php:460
602
  msgid "Created {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a>"
603
  msgstr "Tilføjede {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a>"
604
 
605
  # @ simple-history
606
- #: loggers/SimplePostLogger.php:465
607
  msgid ""
608
  "Moved {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a> to the trash"
609
  msgstr ""
610
  "Flyttede {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a> til "
611
  "papirkurven"
612
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
613
  # @ simple-history
614
  #: loggers/SimpleThemeLogger.php:27
615
  msgid "Switched theme to \"{theme_name}\" from \"{prev_theme_name}\""
@@ -647,7 +712,7 @@ msgid "Changed settings for the theme custom background"
647
  msgstr "Ændrede tema baggrund"
648
 
649
  # @ simple-history
650
- #: loggers/SimpleThemeLogger.php:533
651
  msgid "Section"
652
  msgstr "Sektion"
653
 
@@ -809,12 +874,62 @@ msgctxt "donate settings headline"
809
  msgid "Donate"
810
  msgstr "Donér"
811
 
812
- #: dropins/SimpleHistoryFilterDropin.php:52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
  msgctxt "Filter dropin: button to show more search options"
814
  msgid "Show options"
815
  msgstr "Vis flere muligheder"
816
 
817
- #: dropins/SimpleHistoryFilterDropin.php:162
818
  msgctxt "Filter dropin: button to hide more search options"
819
  msgid "Hide options"
820
  msgstr "Skjul muligheder"
@@ -930,38 +1045,48 @@ msgstr ""
930
  "En god anmeldelse, vil hjælpe nye brugere til at finde dette plugin. Det vil "
931
  "også gøre plugin forfatteren meget glad :)"
932
 
 
 
 
 
 
 
 
 
 
 
933
  # @ simple-history
934
- #: inc/SimpleHistory.php:282
935
  msgctxt ""
936
  "Message visible while waiting for log to load from server the first time"
937
  msgid "Loading history..."
938
  msgstr "Indlæser historik..."
939
 
940
  # @ simple-history
941
- #: inc/SimpleHistory.php:319
942
  msgctxt "page n of n"
943
  msgid "of"
944
  msgstr "af"
945
 
946
  # @ simple-history
947
- #: inc/SimpleHistory.php:390
948
  msgctxt "API: not enought arguments passed"
949
  msgid "Not enough args specified"
950
  msgstr "Der er ikke specificeret argumenter nok"
951
 
952
  # @ simple-history
953
- #: inc/SimpleHistory.php:1314
954
  msgctxt "dashboard menu name"
955
  msgid "Simple History"
956
  msgstr "Simpel Historik"
957
 
958
  # @ simple-history
959
- #: inc/SimpleHistory.php:1441
960
  msgctxt "history page headline"
961
  msgid "Simple History"
962
  msgstr "Simpel Historik"
963
 
964
- #: inc/SimpleHistory.php:1709
965
  msgctxt "simple-history"
966
  msgid "Simple History removed one event that were older than {days} days"
967
  msgid_plural ""
@@ -970,82 +1095,82 @@ msgstr[0] "Simpel Historik fjernede et event, der var ældre end {days} dage"
970
  msgstr[1] ""
971
  "Simpel Historik fjernede {num_events} events, der var ældre end {days} dage"
972
 
973
- #: inc/SimpleHistory.php:2064
974
  msgctxt "Log level in gui"
975
  msgid "emergency"
976
  msgstr "Nødstilfælde"
977
 
978
- #: inc/SimpleHistory.php:2068
979
  msgctxt "Log level in gui"
980
  msgid "alert"
981
  msgstr "alarm"
982
 
983
- #: inc/SimpleHistory.php:2072
984
  msgctxt "Log level in gui"
985
  msgid "critical"
986
  msgstr "kritisk"
987
 
988
- #: inc/SimpleHistory.php:2076
989
  msgctxt "Log level in gui"
990
  msgid "error"
991
  msgstr "fejl"
992
 
993
- #: inc/SimpleHistory.php:2080
994
  msgctxt "Log level in gui"
995
  msgid "warning"
996
  msgstr "advarsel"
997
 
998
- #: inc/SimpleHistory.php:2084
999
  msgctxt "Log level in gui"
1000
  msgid "notice"
1001
  msgstr "meddelelse"
1002
 
1003
- #: inc/SimpleHistory.php:2088
1004
  msgctxt "Log level in gui"
1005
  msgid "info"
1006
  msgstr "info"
1007
 
1008
- #: inc/SimpleHistory.php:2092
1009
  msgctxt "Log level in gui"
1010
  msgid "debug"
1011
  msgstr "debug"
1012
 
1013
- #: inc/SimpleHistory.php:2097
1014
  msgctxt "Log level in gui"
1015
  msgid "Emergency"
1016
  msgstr "Nødstilfælde"
1017
 
1018
- #: inc/SimpleHistory.php:2101
1019
  msgctxt "Log level in gui"
1020
  msgid "Alert"
1021
  msgstr "Alarm"
1022
 
1023
- #: inc/SimpleHistory.php:2105
1024
  msgctxt "Log level in gui"
1025
  msgid "Critical"
1026
  msgstr "Kritisk"
1027
 
1028
- #: inc/SimpleHistory.php:2109
1029
  msgctxt "Log level in gui"
1030
  msgid "Error"
1031
  msgstr "Fejl"
1032
 
1033
- #: inc/SimpleHistory.php:2113
1034
  msgctxt "Log level in gui"
1035
  msgid "Warning"
1036
  msgstr "Advarsel"
1037
 
1038
- #: inc/SimpleHistory.php:2117
1039
  msgctxt "Log level in gui"
1040
  msgid "Notice"
1041
  msgstr "Meddelse"
1042
 
1043
- #: inc/SimpleHistory.php:2121
1044
  msgctxt "Log level in gui"
1045
  msgid "Info"
1046
  msgstr "Info"
1047
 
1048
- #: inc/SimpleHistory.php:2125
1049
  msgctxt "Log level in gui"
1050
  msgid "Debug"
1051
  msgstr "Debug"
@@ -1462,31 +1587,41 @@ msgid "Created exports"
1462
  msgstr "Genereret eksporteringer"
1463
 
1464
  # @ simple-history
1465
- #: loggers/SimpleLogger.php:199
1466
  msgctxt "header output when initiator is the currently logged in user"
1467
  msgid "You"
1468
  msgstr "Dig"
1469
 
 
 
 
 
 
1470
  # @ simple-history
1471
  #: loggers/SimpleMediaLogger.php:31
1472
  msgctxt "Media logger: search"
1473
  msgid "Media"
1474
  msgstr "Medier"
1475
 
 
 
 
 
 
1476
  # @ simple-history
1477
- #: loggers/SimpleMediaLogger.php:33
1478
  msgctxt "Media logger: search"
1479
  msgid "Added media"
1480
  msgstr "Tilføjet medier"
1481
 
1482
  # @ simple-history
1483
- #: loggers/SimpleMediaLogger.php:36
1484
  msgctxt "Media logger: search"
1485
  msgid "Updated media"
1486
  msgstr "Opdateret medier"
1487
 
1488
  # @ simple-history
1489
- #: loggers/SimpleMediaLogger.php:39
1490
  msgctxt "Media logger: search"
1491
  msgid "Deleted media"
1492
  msgstr "Slettet medier"
@@ -1497,26 +1632,31 @@ msgctxt "Menu logger: search"
1497
  msgid "Menus"
1498
  msgstr "Menuer"
1499
 
 
 
 
 
 
1500
  # @ simple-history
1501
- #: loggers/SimpleMenuLogger.php:35
1502
  msgctxt "Menu updates logger: search"
1503
  msgid "Created menus"
1504
  msgstr "Tilføjet menuer"
1505
 
1506
  # @ simple-history
1507
- #: loggers/SimpleMenuLogger.php:38
1508
  msgctxt "Menu updates logger: search"
1509
  msgid "Edited menus"
1510
  msgstr "Redigeret menuer"
1511
 
1512
  # @ simple-history
1513
- #: loggers/SimpleMenuLogger.php:43
1514
  msgctxt "Menu updates logger: search"
1515
  msgid "Deleted menus"
1516
  msgstr "Slettet menuer"
1517
 
1518
  # @ simple-history
1519
- #: loggers/SimpleMenuLogger.php:328
1520
  msgctxt "menu logger"
1521
  msgid "%1$s menu item added"
1522
  msgid_plural "%1$s menu items added"
@@ -1524,7 +1664,7 @@ msgstr[0] "%1$s menupunkt tilføjet"
1524
  msgstr[1] "%1$s menupunkter tilføjet"
1525
 
1526
  # @ simple-history
1527
- #: loggers/SimpleMenuLogger.php:335
1528
  msgctxt "menu logger"
1529
  msgid "%1$s menu item removed"
1530
  msgid_plural "%1$s menu items removed"
@@ -1611,138 +1751,148 @@ msgctxt "Plugin logger: search"
1611
  msgid "Plugins"
1612
  msgstr "Plugins"
1613
 
 
 
 
 
 
1614
  # @ simple-history
1615
- #: loggers/SimplePluginLogger.php:86
1616
  msgctxt "Plugin logger: search"
1617
  msgid "Activated plugins"
1618
  msgstr "Aktiveret plugins"
1619
 
1620
  # @ simple-history
1621
- #: loggers/SimplePluginLogger.php:89
1622
  msgctxt "Plugin logger: search"
1623
  msgid "Deactivated plugins"
1624
  msgstr "Deaktiveret plugins"
1625
 
1626
  # @ simple-history
1627
- #: loggers/SimplePluginLogger.php:92
1628
  msgctxt "Plugin logger: search"
1629
  msgid "Installed plugins"
1630
  msgstr "Installeret plugins"
1631
 
1632
  # @ simple-history
1633
- #: loggers/SimplePluginLogger.php:95
1634
  msgctxt "Plugin logger: search"
1635
  msgid "Failed plugin installs"
1636
  msgstr "Mislykket plugin installeringer"
1637
 
1638
  # @ simple-history
1639
- #: loggers/SimplePluginLogger.php:98
1640
  msgctxt "Plugin logger: search"
1641
  msgid "Updated plugins"
1642
  msgstr "Opdateret plugins"
1643
 
1644
  # @ simple-history
1645
- #: loggers/SimplePluginLogger.php:102
1646
  msgctxt "Plugin logger: search"
1647
  msgid "Failed plugin updates"
1648
  msgstr "Mislykket plugin opdateringer"
1649
 
1650
  # @ simple-history
1651
- #: loggers/SimplePluginLogger.php:105
1652
  msgctxt "Plugin logger: search"
1653
  msgid "Edited plugin files"
1654
  msgstr "Redigeret plugin filer"
1655
 
1656
  # @ simple-history
1657
- #: loggers/SimplePluginLogger.php:108
1658
  msgctxt "Plugin logger: search"
1659
  msgid "Deleted plugins"
1660
  msgstr "Slettet plugins"
1661
 
1662
- #: loggers/SimplePluginLogger.php:1081
1663
  msgctxt "plugin logger - detailed output"
1664
  msgid "Description"
1665
  msgstr "Beskrivelse"
1666
 
1667
- #: loggers/SimplePluginLogger.php:1082
1668
  msgctxt "plugin logger - detailed output install source"
1669
  msgid "Source"
1670
  msgstr "Kilde"
1671
 
1672
- #: loggers/SimplePluginLogger.php:1083
1673
  msgctxt "plugin logger - detailed output install source"
1674
  msgid "Source file name"
1675
  msgstr "Kilde filnavn"
1676
 
1677
  # @ simple-history
1678
- #: loggers/SimplePluginLogger.php:1084
1679
  msgctxt "plugin logger - detailed output version"
1680
  msgid "Version"
1681
  msgstr "Version"
1682
 
1683
  # @ simple-history
1684
- #: loggers/SimplePluginLogger.php:1085
1685
  msgctxt "plugin logger - detailed output author"
1686
  msgid "Author"
1687
  msgstr "Forfatter"
1688
 
1689
  # @ simple-history
1690
- #: loggers/SimplePluginLogger.php:1086
1691
  msgctxt "plugin logger - detailed output url"
1692
  msgid "URL"
1693
  msgstr "URL"
1694
 
1695
  # @ simple-history
1696
- #: loggers/SimplePluginLogger.php:1194 loggers/SimplePluginLogger.php:1213
1697
- #: loggers/SimplePluginLogger.php:1252
1698
  msgctxt "plugin logger: plugin info thickbox title view all info"
1699
  msgid "View plugin info"
1700
  msgstr "Vis plugin info"
1701
 
1702
  # @ simple-history
1703
- #: loggers/SimplePluginLogger.php:1228
1704
  msgctxt "plugin logger: plugin info thickbox title"
1705
  msgid "View plugin info"
1706
  msgstr "Vis plugin info"
1707
 
1708
  # @ simple-history
1709
- #: loggers/SimplePluginLogger.php:1232
1710
  msgctxt "plugin logger: plugin info thickbox title"
1711
  msgid "View changelog"
1712
  msgstr "Vis changelog"
1713
 
1714
  # @ simple-history
1715
- #: loggers/SimplePostLogger.php:192
1716
  msgctxt "Post logger: search"
1717
  msgid "Posts & Pages"
1718
  msgstr "Indlæg & Sider"
1719
 
 
 
 
 
 
1720
  # @ simple-history
1721
- #: loggers/SimplePostLogger.php:194
1722
  msgctxt "Post logger: search"
1723
  msgid "Posts created"
1724
  msgstr "Indlæg tilføjet"
1725
 
1726
  # @ simple-history
1727
- #: loggers/SimplePostLogger.php:197
1728
  msgctxt "Post logger: search"
1729
  msgid "Posts updated"
1730
  msgstr "Indlæg opdateret"
1731
 
1732
  # @ simple-history
1733
- #: loggers/SimplePostLogger.php:200
1734
  msgctxt "Post logger: search"
1735
  msgid "Posts trashed"
1736
  msgstr "Indlæg flyttet til papirkurven"
1737
 
1738
  # @ simple-history
1739
- #: loggers/SimplePostLogger.php:203
1740
  msgctxt "Post logger: search"
1741
  msgid "Posts deleted"
1742
  msgstr "Indlæg slettet"
1743
 
1744
  # @ simple-history
1745
- #: loggers/SimplePostLogger.php:206
1746
  msgctxt "Post logger: search"
1747
  msgid "Posts restored"
1748
  msgstr "Indlæg gendannet"
@@ -1753,44 +1903,49 @@ msgctxt "Theme logger: search"
1753
  msgid "Themes & Widgets"
1754
  msgstr "Tema & Widgets"
1755
 
 
 
 
 
 
1756
  # @ simple-history
1757
- #: loggers/SimpleThemeLogger.php:39
1758
  msgctxt "Theme logger: search"
1759
  msgid "Switched themes"
1760
  msgstr "Skiftet temaer"
1761
 
1762
  # @ simple-history
1763
- #: loggers/SimpleThemeLogger.php:42
1764
  msgctxt "Theme logger: search"
1765
  msgid "Changed appearance of themes"
1766
  msgstr "Skiftet udseende på temaer"
1767
 
1768
  # @ simple-history
1769
- #: loggers/SimpleThemeLogger.php:45
1770
  msgctxt "Theme logger: search"
1771
  msgid "Added widgets"
1772
  msgstr "Tilføjet widgets"
1773
 
1774
  # @ simple-history
1775
- #: loggers/SimpleThemeLogger.php:48
1776
  msgctxt "Theme logger: search"
1777
  msgid "Removed widgets"
1778
  msgstr "Fjernet widgets"
1779
 
1780
  # @ simple-history
1781
- #: loggers/SimpleThemeLogger.php:51
1782
  msgctxt "Theme logger: search"
1783
  msgid "Changed widgets order"
1784
  msgstr "Ændret widget rækkefølge"
1785
 
1786
  # @ simple-history
1787
- #: loggers/SimpleThemeLogger.php:54
1788
  msgctxt "Theme logger: search"
1789
  msgid "Edited widgets"
1790
  msgstr "Ændret widgets"
1791
 
1792
  # @ simple-history
1793
- #: loggers/SimpleThemeLogger.php:57
1794
  msgctxt "Theme logger: search"
1795
  msgid "Background of themes changed"
1796
  msgstr "Baggrund og tema ændret"
2
  msgstr ""
3
  "Project-Id-Version: Simple History v2.0.12\n"
4
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/Simple-History\n"
5
+ "POT-Creation-Date: 2015-08-11 14:58+0100\n"
6
+ "PO-Revision-Date: 2015-08-11 15:06+0100\n"
7
  "Last-Translator: Thomas Blomberg Hansen <thomas@blomberg.it>\n"
8
  "Language-Team: \n"
9
  "Language: da_DK\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
14
+ "X-Generator: Poedit 1.8.1\n"
15
  "X-Poedit-SourceCharset: utf-8\n"
16
  "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
17
  "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
34
  "a> eller <a href=\"%2$s\">købe noget til mig på min Amazon wish list</a>."
35
 
36
  # @ simple-history
37
+ #: dropins/SimpleHistoryFilterDropin.php:89
38
  msgid "Filter history"
39
  msgstr "Filtrer historik"
40
 
41
+ # @ simple-history
42
+ #: dropins/SimpleHistoryFilterDropin.php:155
43
+ msgid "All dates"
44
+ msgstr "Alle datoer"
45
+
46
+ #: dropins/SimpleHistoryFilterDropin.php:216
47
+ msgid "Containing words"
48
+ msgstr "Indeholder ord"
49
+
50
+ #: dropins/SimpleHistoryFilterDropin.php:223
51
+ #: dropins/SimpleHistoryFilterDropin.php:365
52
  msgid "Search events"
53
  msgstr "Søg i events"
54
 
55
  # @ simple-history
56
+ #: dropins/SimpleHistoryFilterDropin.php:241
57
  msgid "All log levels"
58
  msgstr "Alle log niveauer"
59
 
60
  # @ simple-history
61
+ #: dropins/SimpleHistoryFilterDropin.php:269
62
  msgid "All messages"
63
  msgstr "Alle beskeder"
64
 
65
  # @ simple-history
66
+ #: dropins/SimpleHistoryFilterDropin.php:358
67
  msgid "All users"
68
  msgstr "Alle brugere"
69
 
70
+ #: dropins/SimpleHistoryFilterDropin.php:374
 
 
 
 
 
71
  msgid "Search"
72
  msgstr "Søg"
73
 
94
 
95
  # @ simple-history
96
  #: dropins/SimpleHistoryRSSDropin.php:150
97
+ #: dropins/SimpleHistoryRSSDropin.php:279
98
  msgid "History for %s"
99
  msgstr "Historik fra %s"
100
 
101
  # @ simple-history
102
  #: dropins/SimpleHistoryRSSDropin.php:151
103
+ #: dropins/SimpleHistoryRSSDropin.php:280
104
  msgid "WordPress History for %s"
105
  msgstr "WordPress historik fra %s"
106
 
107
+ #: dropins/SimpleHistoryRSSDropin.php:203
108
  msgid "Severity level: %1$s"
109
  msgstr "Alvorlighedsniveau: %1$s"
110
 
111
  # begivenhed er måske ikke det rigtige ord.
112
+ #: dropins/SimpleHistoryRSSDropin.php:216
113
  msgid "+%1$s occasion"
114
  msgid_plural "+%1$s occasions"
115
  msgstr[0] "+%1$s begivenhed"
116
  msgstr[1] "+%1$s begivenheder"
117
 
118
  # @ simple-history
119
+ #: dropins/SimpleHistoryRSSDropin.php:283
120
  msgid "Wrong RSS secret"
121
  msgstr "Forkert RSS nøgle"
122
 
123
  # @ simple-history
124
+ #: dropins/SimpleHistoryRSSDropin.php:284
125
  msgid ""
126
  "Your RSS secret for Simple History RSS feed is wrong. Please see WordPress "
127
  "settings for current link to the RSS feed."
130
  "rigtige url under Indstillinger -> Simpel Historik."
131
 
132
  # @ simple-history
133
+ #: dropins/SimpleHistoryRSSDropin.php:335
134
  msgid ""
135
  "You can generate a new address for the RSS feed. This is useful if you think "
136
  "that the address has fallen into the wrong hands."
139
  "mistænker at url'en er faldet i de forkerte hænder."
140
 
141
  # @ simple-history
142
+ #: dropins/SimpleHistoryRSSDropin.php:338
143
  msgid "Generate new address"
144
  msgstr "Generere ny url"
145
 
146
  # @ simple-history
147
+ #: dropins/SimpleHistoryRSSDropin.php:368
148
  msgid ""
149
  "Simple History has a RSS feed which you can subscribe to and receive log "
150
  "updates. Make sure you only share the feed with people you trust, since it "
173
  msgstr "Statistik"
174
 
175
  # @ simple-history
176
+ #: dropins/SimpleHistorySidebarDropin.php:165 loggers/SimpleLogger.php:366
177
  msgid "Just now"
178
  msgstr "Lige nu"
179
 
180
+ #: examples/example-logger.php:46
181
+ msgid "Got a 404-page when trying to visit \"{request_uri}\""
182
+ msgstr "Fik en 404 fejl side, da \"{request_uri}\" blev besøgt"
183
+
184
+ #: inc/SimpleHistory.php:370
185
+ msgid "Sorry, but there are too many similar events to show."
186
+ msgstr "Beklager, men der er for mange ens events."
187
+
188
  # @ simple-history
189
+ #: inc/SimpleHistory.php:573 inc/SimpleHistory.php:899
190
  msgid "Settings"
191
  msgstr "Indstillinger"
192
 
193
  # @ simple-history
194
+ #: inc/SimpleHistory.php:584
195
  msgid "Log (debug)"
196
  msgstr "Log (debug)"
197
 
198
  # @ simple-history
199
+ #: inc/SimpleHistory.php:589
200
  msgid "Styles example (debug)"
201
  msgstr "Styles eksempel (debug)"
202
 
203
  # @ simple-history
204
  #. Plugin Name of the plugin/theme
205
+ #: inc/SimpleHistory.php:924
206
  msgid "Simple History"
207
  msgstr "Simpel historik"
208
 
209
  # @ simple-history
210
+ #: inc/SimpleHistory.php:1000
211
  msgid "Remove all log items?"
212
  msgstr "Fjern alle log elementer?"
213
 
214
  # @ simple-history
215
+ #: inc/SimpleHistory.php:1002
216
  msgid "Go to the first page"
217
  msgstr "Gå til den første side"
218
 
219
  # @ simple-history
220
+ #: inc/SimpleHistory.php:1003
221
  msgid "Go to the previous page"
222
  msgstr "Gå til den forrige side"
223
 
224
  # @ simple-history
225
+ #: inc/SimpleHistory.php:1004
226
  msgid "Go to the next page"
227
  msgstr "Gå til den næste side"
228
 
229
  # @ simple-history
230
+ #: inc/SimpleHistory.php:1005
231
  msgid "Go to the last page"
232
  msgstr "Gå til den sidste side"
233
 
234
  # @ simple-history
235
+ #: inc/SimpleHistory.php:1006
236
  msgid "Current page"
237
  msgstr "Nuværende side"
238
 
239
  # @ simple-history
240
+ #: inc/SimpleHistory.php:1008
241
  msgid "Oups, the log could not be loaded right now."
242
  msgstr "Ups, loggen kunne ikke indlæses lige nu."
243
 
244
  # @ simple-history
245
+ #: inc/SimpleHistory.php:1009
246
  msgid "Your search did not match any history events."
247
  msgstr "Din søgning gav ingen resultater."
248
 
249
  # @ simple-history
250
+ #: inc/SimpleHistory.php:1293 inc/SimpleHistory.php:1408
251
  msgid "Simple History Settings"
252
  msgstr "Simpel Historik opsætning"
253
 
254
  # @ simple-history
255
+ #: inc/SimpleHistory.php:1327
256
  msgid "No valid callback found"
257
  msgstr "Ingen gyldig callback fundet "
258
 
259
  # @ simple-history
260
+ #: inc/SimpleHistory.php:1429
261
  msgid "Cleared database"
262
  msgstr "Nulstillet database"
263
 
264
  # @ simple-history
265
+ #: inc/SimpleHistory.php:1456
266
  msgid "Show history"
267
  msgstr "Vis historik"
268
 
269
  # @ simple-history
270
+ #: inc/SimpleHistory.php:1469
271
  msgid "Number of items per page"
272
  msgstr "Antal elementer pr. side"
273
 
274
  # @ simple-history
275
+ #: inc/SimpleHistory.php:1481
276
  msgid "Clear log"
277
  msgstr "Nulstil log"
278
 
279
  # @ simple-history
280
+ #: inc/SimpleHistory.php:1620
281
  msgid "on the dashboard"
282
  msgstr "på kontrolpanelet"
283
 
284
  # @ simple-history
285
+ #: inc/SimpleHistory.php:1625
286
  msgid "as a page under the dashboard menu"
287
  msgstr "som et undermenupunkt til Kontrolpanelet "
288
 
289
  # @ simple-history
290
+ #: inc/SimpleHistory.php:1641
291
  msgid "Items in the database are automatically removed after %1$s days."
292
  msgstr "Elementer i databasen fjernes automatisk efter %1$s dage."
293
 
294
  # @ simple-history
295
+ #: inc/SimpleHistory.php:1643
296
  msgid "Items in the database are kept forever."
297
  msgstr "Elementer i databasen gemmes for evigt."
298
 
299
  # @ simple-history
300
+ #: inc/SimpleHistory.php:1647
301
  msgid "Clear log now"
302
  msgstr "Nulstil log nu"
303
 
304
+ #: inc/SimpleHistory.php:1699
305
  msgid "The log for Simple History was cleared ({num_rows} rows were removed)."
306
  msgstr ""
307
  "Loggen for Simple Historik blev nulstillet ({num_rows} rækker blev fjernet)."
308
 
309
+ #: inc/SimpleHistory.php:1963
310
  msgid "+%1$s similar event"
311
  msgid_plural "+%1$s similar events"
312
  msgstr[0] "+%1$s tilsvarende event"
313
  msgstr[1] "+%1$s tilsvarende events"
314
 
315
  # @ simple-history
316
+ #: inc/SimpleHistory.php:1970
317
  msgid "Loading…"
318
  msgstr "Indlæser..."
319
 
320
  # @ simple-history
321
+ #: inc/SimpleHistory.php:1977
322
  msgid "Showing %1$s more"
323
  msgstr "%1$s flere vises"
324
 
325
  # @ simple-history
326
+ #: inc/SimpleHistory.php:2016
327
  msgid "Context data"
328
  msgstr "Kontekst data"
329
 
330
  # @ simple-history
331
+ #: inc/SimpleHistory.php:2017
332
  msgid "This is potentially useful meta data that a logger has saved."
333
  msgstr "Dette er potentielt brugbar meta data, som en logger har gemt."
334
 
335
  # @ simple-history
336
+ #: inc/SimpleHistory.php:2639
337
  msgid "No events today so far."
338
  msgstr "Endnu ingen events i dag."
339
 
340
+ #: inc/SimpleHistory.php:2658
341
  msgid "One event today from one user."
342
  msgstr "Et event i dag, fra én bruger."
343
 
344
+ #: inc/SimpleHistory.php:2664
345
  msgid "One event today from one source."
346
  msgstr "Et event i dag, fra én kilde"
347
 
348
  # @ simple-history
349
+ #: inc/SimpleHistory.php:2670
350
  msgid "%1$d events today from one user."
351
  msgstr "%1$d events i dag fra én bruger."
352
 
353
  # @ simple-history
354
+ #: inc/SimpleHistory.php:2676
355
  msgid "%1$d events today from %2$d users."
356
  msgstr "%1$d events i dag fra %2$d brugere."
357
 
358
+ #: inc/SimpleHistory.php:2682 inc/SimpleHistory.php:2688
359
  msgid "%1$d events today from one user and one other source."
360
  msgstr "%1$d events i dag, fra én bruger og én kilde"
361
 
362
+ #: inc/SimpleHistory.php:2694
363
  msgid "%1$d events today from one user and %3$d other sources."
364
  msgstr "%1$d events i dag, fra én bruger og %3$d kilder."
365
 
366
+ #: inc/SimpleHistory.php:2700
367
  msgid "%1$s events today from %2$d users and %3$d other sources."
368
  msgstr "%1$s events i dag, fra %2$d brugere og %3$d kilder."
369
 
370
  # @ simple-history
371
+ #: index.php:97
372
  msgid ""
373
  "Simple History is a great plugin, but to use it your server must have at "
374
  "least PHP 5.3 installed (you have version %s)."
431
  msgstr "%d begivenheder"
432
 
433
  # @ simple-history
434
+ #: loggers/SimpleLogger.php:234
435
  msgid "Deleted user (had id %1$s, email %2$s, login %3$s)"
436
  msgstr "Slettet bruger (havde ID %1$s, E-mail %2$s, brugernavn %3$s)"
437
 
438
  # @ simple-history
439
+ #: loggers/SimpleLogger.php:260
440
  msgid "Anonymous web user"
441
  msgstr "Anonym besøgende"
442
 
443
  # @ simple-history
444
+ #: loggers/SimpleLogger.php:293
445
  msgid "Anonymous user from %1$s"
446
  msgstr "Anonym bruger fra %1$s"
447
 
448
  # @ simple-history
449
  #. translators: Date format for log row header, see http:php.net/date
450
+ #: loggers/SimpleLogger.php:371
451
  msgid "M j, Y \\a\\t G:i"
452
  msgstr "j. F Y \\k\\l\\. H:i"
453
 
454
  # @ simple-history
455
  #. translators: 1: last modified date and time in human time diff-format
456
+ #: loggers/SimpleLogger.php:379
457
  msgid "%1$s ago"
458
  msgstr "%1$s siden"
459
 
473
  msgstr "Slettet {post_type} \"{attachment_title}\" (\"{attachment_filename}\")"
474
 
475
  # @ simple-history
476
+ #: loggers/SimpleMediaLogger.php:122
477
  msgid "Edited {post_type} <a href=\"{edit_link}\">\"{attachment_title}\"</a>"
478
  msgstr ""
479
  "Redigeret {post_type} <a href=\"{edit_link}\">\"{attachment_title}\"</a>"
480
 
481
  # @ simple-history
482
+ #: loggers/SimpleMediaLogger.php:126
483
  msgid "Uploaded {post_type} <a href=\"{edit_link}\">\"{attachment_title}\"</a>"
484
  msgstr ""
485
  "Uploadet {post_type} <a href=\"{edit_link}\">\"{attachment_title}\"</a>"
486
 
487
  # @ simple-history
488
+ #: loggers/SimpleMediaLogger.php:242
489
  msgid "{attachment_thumb}"
490
  msgstr "{attachment_thumb}"
491
 
492
  # @ simple-history
493
+ #: loggers/SimpleMediaLogger.php:251
494
  msgid "{attachment_size_format}"
495
  msgstr "{attachment_size_format}"
496
 
497
  # @ simple-history
498
+ #: loggers/SimpleMediaLogger.php:252
499
  msgid "{attachment_filetype_extension}"
500
  msgstr "{attachment_filetype_extension}"
501
 
502
  # @ simple-history
503
+ #: loggers/SimpleMediaLogger.php:254
504
  msgid "{full_image_width} × {full_image_height}"
505
  msgstr "{full_image_width} × {full_image_height}"
506
 
535
  msgstr "Opdateret indstlling \"{option}\""
536
 
537
  # @ simple-history
538
+ #: loggers/SimpleOptionsLogger.php:244 loggers/SimpleThemeLogger.php:572
539
  msgid "New value"
540
  msgstr "Ny værdi"
541
 
542
  # @ simple-history
543
+ #: loggers/SimpleOptionsLogger.php:255 loggers/SimpleThemeLogger.php:584
544
  msgid "Old value"
545
  msgstr "Gammel værdi"
546
 
549
  msgid "Settings page"
550
  msgstr "Indstillinger side"
551
 
552
+ #: loggers/SimplePluginLogger.php:178
553
  msgid "You don't have access to this page."
554
  msgstr "Du har ikke adgang til denne side."
555
 
556
+ #: loggers/SimplePluginLogger.php:184 loggers/SimplePluginLogger.php:189
557
  msgid "Could not find GitHub repository."
558
  msgstr "Kunne ikke finde GitHub repository."
559
 
560
+ #: loggers/SimplePluginLogger.php:209
 
561
  msgid ""
562
  "<p>Viewing <code>readme</code> from repository <code><a target=\"_blank\" "
563
  "href=\"%1$s\">%2$s</a></code>.</p>"
564
  msgstr ""
565
+ "<p>Læs <code>readme</code> fra repository <code><a target=\"_blank\" href="
566
  "\"%1$s\">%2$s</a></code>.</p>"
567
 
568
+ #: loggers/SimplePluginLogger.php:274
569
  msgid "You do not have sufficient permissions to delete plugins for this site."
570
  msgstr ""
571
  "Du har ikke de nødvendige tilladelser til, at slette plugins på denne side."
572
 
573
+ #: loggers/SimplePluginLogger.php:1122
574
  msgid "WordPress Plugin Repository"
575
  msgstr "WordPress Plugin Repository"
576
 
577
+ #: loggers/SimplePluginLogger.php:1125
578
  msgid "Uploaded ZIP archive"
579
  msgstr "Uploaded ZIP fil"
580
 
581
  # @ simple-history
582
+ #: loggers/SimplePostLogger.php:119
583
  msgid "Created {post_type} \"{post_title}\""
584
  msgstr "Tilføjet {post_type} \"{post_title}\""
585
 
586
  # @ simple-history
587
+ #: loggers/SimplePostLogger.php:120
588
  msgid "Updated {post_type} \"{post_title}\""
589
  msgstr "Opdaterede {post_type} \"{post_title}\""
590
 
591
  # @ simple-history
592
+ #: loggers/SimplePostLogger.php:121
593
  msgid "Restored {post_type} \"{post_title}\" from trash"
594
  msgstr "Gendannede {post_type} \"{post_title}\" fra papirkurven"
595
 
596
  # @ simple-history
597
+ #: loggers/SimplePostLogger.php:122 loggers/SimplePostLogger.php:687
598
  msgid "Deleted {post_type} \"{post_title}\""
599
  msgstr "Slettede {post_type} \"{post_title}\""
600
 
601
  # @ simple-history
602
+ #: loggers/SimplePostLogger.php:123
603
  msgid "Moved {post_type} \"{post_title}\" to the trash"
604
  msgstr "Flyttede {post_type} \"{post_title}\" til papirkurven"
605
 
606
  # @ simple-history
607
+ #: loggers/SimplePostLogger.php:683
608
  msgid "Updated {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a>"
609
  msgstr "Opdaterede {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a>"
610
 
611
  # @ simple-history
612
+ #: loggers/SimplePostLogger.php:691
613
  msgid "Created {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a>"
614
  msgstr "Tilføjede {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a>"
615
 
616
  # @ simple-history
617
+ #: loggers/SimplePostLogger.php:696
618
  msgid ""
619
  "Moved {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a> to the trash"
620
  msgstr ""
621
  "Flyttede {post_type} <a href=\"{edit_link}\">\"{post_title}\"</a> til "
622
  "papirkurven"
623
 
624
+ #: loggers/SimplePostLogger.php:748
625
+ msgid "Title"
626
+ msgstr "Titel"
627
+
628
+ #: loggers/SimplePostLogger.php:762
629
+ msgid "Content"
630
+ msgstr "Indhold"
631
+
632
+ #: loggers/SimplePostLogger.php:776
633
+ msgid "Status"
634
+ msgstr "Status"
635
+
636
+ #: loggers/SimplePostLogger.php:792
637
+ msgid "Publish date"
638
+ msgstr "Udgivet dato"
639
+
640
+ #: loggers/SimplePostLogger.php:807
641
+ msgid "Permalink"
642
+ msgstr "Permanent link"
643
+
644
+ #: loggers/SimplePostLogger.php:821
645
+ msgid "Comment status"
646
+ msgstr "Kommentar status"
647
+
648
+ #: loggers/SimplePostLogger.php:844
649
+ msgid "Author"
650
+ msgstr "Forfatter"
651
+
652
+ #: loggers/SimplePostLogger.php:846
653
+ msgid ""
654
+ "Changed from {prev_user_display_name} ({prev_user_email}) to "
655
+ "{new_user_display_name} ({new_user_email})"
656
+ msgstr ""
657
+ "Skiftede fra {prev_user_display_name} ({prev_user_email}) til "
658
+ "{new_user_display_name} ({new_user_email})"
659
+
660
+ #: loggers/SimplePostLogger.php:880
661
+ msgid "Changed from {prev_page_template} to {new_page_template}"
662
+ msgstr "Skiftede fra {prev_page_template} til {new_page_template}"
663
+
664
+ #: loggers/SimplePostLogger.php:882
665
+ msgid ""
666
+ "Changed from \"{prev_page_template_name}\" to \"{new_page_template_name}\""
667
+ msgstr ""
668
+ "Skiftede fra \"{prev_page_template_name}\" til \"{new_page_template_name}\""
669
+
670
+ #: loggers/SimplePostLogger.php:890
671
+ msgid "Template"
672
+ msgstr "Skabelon"
673
+
674
+ #: loggers/SimplePostLogger.php:934
675
+ msgid "Custom fields"
676
+ msgstr "Brugerdefineret felter"
677
+
678
  # @ simple-history
679
  #: loggers/SimpleThemeLogger.php:27
680
  msgid "Switched theme to \"{theme_name}\" from \"{prev_theme_name}\""
712
  msgstr "Ændrede tema baggrund"
713
 
714
  # @ simple-history
715
+ #: loggers/SimpleThemeLogger.php:534
716
  msgid "Section"
717
  msgstr "Sektion"
718
 
874
  msgid "Donate"
875
  msgstr "Donér"
876
 
877
+ #: dropins/SimpleHistoryExportDropin.php:23
878
+ msgctxt "Export dropin: Tab name on settings page"
879
+ msgid "Export"
880
+ msgstr "Eksport"
881
+
882
+ #: dropins/SimpleHistoryExportDropin.php:221
883
+ msgctxt "Export dropin: introtext"
884
+ msgid "The export function will export the full history."
885
+ msgstr "Eksport funktionen vil eksportere den fulde historik."
886
+
887
+ #: dropins/SimpleHistoryExportDropin.php:225
888
+ msgctxt "Export dropin: format"
889
+ msgid "Choose format to export to"
890
+ msgstr "Vælg formatet, der skal eksporteres til"
891
+
892
+ #: dropins/SimpleHistoryExportDropin.php:230
893
+ msgctxt "Export dropin: export format"
894
+ msgid "JSON"
895
+ msgstr "JSON"
896
+
897
+ #: dropins/SimpleHistoryExportDropin.php:237
898
+ msgctxt "Export dropin: export format"
899
+ msgid "CSV"
900
+ msgstr "CSV"
901
+
902
+ #: dropins/SimpleHistoryExportDropin.php:255
903
+ msgctxt "Export dropin: submit button"
904
+ msgid "Download Export File"
905
+ msgstr "Download eksport filen"
906
+
907
+ #: dropins/SimpleHistoryFilterDropin.php:162
908
+ msgctxt "Filter dropin: filter week"
909
+ msgid "Last 7 days"
910
+ msgstr "Sidste 7 dage"
911
+
912
+ #: dropins/SimpleHistoryFilterDropin.php:169
913
+ msgctxt "Filter dropin: filter week"
914
+ msgid "Last 14 days"
915
+ msgstr "Sidste 14 dage"
916
+
917
+ #: dropins/SimpleHistoryFilterDropin.php:176
918
+ msgctxt "Filter dropin: filter week"
919
+ msgid "Last 30 days"
920
+ msgstr "Sidste 30 dage"
921
+
922
+ #: dropins/SimpleHistoryFilterDropin.php:183
923
+ msgctxt "Filter dropin: filter week"
924
+ msgid "Last 60 days"
925
+ msgstr "Sidste 60 dage"
926
+
927
+ #: dropins/SimpleHistoryFilterDropin.php:225
928
  msgctxt "Filter dropin: button to show more search options"
929
  msgid "Show options"
930
  msgstr "Vis flere muligheder"
931
 
932
+ #: dropins/SimpleHistoryFilterDropin.php:366
933
  msgctxt "Filter dropin: button to hide more search options"
934
  msgid "Hide options"
935
  msgstr "Skjul muligheder"
1045
  "En god anmeldelse, vil hjælpe nye brugere til at finde dette plugin. Det vil "
1046
  "også gøre plugin forfatteren meget glad :)"
1047
 
1048
+ #: examples/example-logger.php:50
1049
+ msgctxt "User logger: 404"
1050
+ msgid "Pages not found (404 errors)"
1051
+ msgstr "Sider ikke fundet (404 fejl)"
1052
+
1053
+ #: examples/example-logger.php:52
1054
+ msgctxt "User logger: 404"
1055
+ msgid "Pages not found"
1056
+ msgstr "Sider ikke fundet"
1057
+
1058
  # @ simple-history
1059
+ #: inc/SimpleHistory.php:290
1060
  msgctxt ""
1061
  "Message visible while waiting for log to load from server the first time"
1062
  msgid "Loading history..."
1063
  msgstr "Indlæser historik..."
1064
 
1065
  # @ simple-history
1066
+ #: inc/SimpleHistory.php:327
1067
  msgctxt "page n of n"
1068
  msgid "of"
1069
  msgstr "af"
1070
 
1071
  # @ simple-history
1072
+ #: inc/SimpleHistory.php:422
1073
  msgctxt "API: not enought arguments passed"
1074
  msgid "Not enough args specified"
1075
  msgstr "Der er ikke specificeret argumenter nok"
1076
 
1077
  # @ simple-history
1078
+ #: inc/SimpleHistory.php:1390
1079
  msgctxt "dashboard menu name"
1080
  msgid "Simple History"
1081
  msgstr "Simpel Historik"
1082
 
1083
  # @ simple-history
1084
+ #: inc/SimpleHistory.php:1517
1085
  msgctxt "history page headline"
1086
  msgid "Simple History"
1087
  msgstr "Simpel Historik"
1088
 
1089
+ #: inc/SimpleHistory.php:1787
1090
  msgctxt "simple-history"
1091
  msgid "Simple History removed one event that were older than {days} days"
1092
  msgid_plural ""
1095
  msgstr[1] ""
1096
  "Simpel Historik fjernede {num_events} events, der var ældre end {days} dage"
1097
 
1098
+ #: inc/SimpleHistory.php:2248
1099
  msgctxt "Log level in gui"
1100
  msgid "emergency"
1101
  msgstr "Nødstilfælde"
1102
 
1103
+ #: inc/SimpleHistory.php:2252
1104
  msgctxt "Log level in gui"
1105
  msgid "alert"
1106
  msgstr "alarm"
1107
 
1108
+ #: inc/SimpleHistory.php:2256
1109
  msgctxt "Log level in gui"
1110
  msgid "critical"
1111
  msgstr "kritisk"
1112
 
1113
+ #: inc/SimpleHistory.php:2260
1114
  msgctxt "Log level in gui"
1115
  msgid "error"
1116
  msgstr "fejl"
1117
 
1118
+ #: inc/SimpleHistory.php:2264
1119
  msgctxt "Log level in gui"
1120
  msgid "warning"
1121
  msgstr "advarsel"
1122
 
1123
+ #: inc/SimpleHistory.php:2268
1124
  msgctxt "Log level in gui"
1125
  msgid "notice"
1126
  msgstr "meddelelse"
1127
 
1128
+ #: inc/SimpleHistory.php:2272
1129
  msgctxt "Log level in gui"
1130
  msgid "info"
1131
  msgstr "info"
1132
 
1133
+ #: inc/SimpleHistory.php:2276
1134
  msgctxt "Log level in gui"
1135
  msgid "debug"
1136
  msgstr "debug"
1137
 
1138
+ #: inc/SimpleHistory.php:2281
1139
  msgctxt "Log level in gui"
1140
  msgid "Emergency"
1141
  msgstr "Nødstilfælde"
1142
 
1143
+ #: inc/SimpleHistory.php:2285
1144
  msgctxt "Log level in gui"
1145
  msgid "Alert"
1146
  msgstr "Alarm"
1147
 
1148
+ #: inc/SimpleHistory.php:2289
1149
  msgctxt "Log level in gui"
1150
  msgid "Critical"
1151
  msgstr "Kritisk"
1152
 
1153
+ #: inc/SimpleHistory.php:2293
1154
  msgctxt "Log level in gui"
1155
  msgid "Error"
1156
  msgstr "Fejl"
1157
 
1158
+ #: inc/SimpleHistory.php:2297
1159
  msgctxt "Log level in gui"
1160
  msgid "Warning"
1161
  msgstr "Advarsel"
1162
 
1163
+ #: inc/SimpleHistory.php:2301
1164
  msgctxt "Log level in gui"
1165
  msgid "Notice"
1166
  msgstr "Meddelse"
1167
 
1168
+ #: inc/SimpleHistory.php:2305
1169
  msgctxt "Log level in gui"
1170
  msgid "Info"
1171
  msgstr "Info"
1172
 
1173
+ #: inc/SimpleHistory.php:2309
1174
  msgctxt "Log level in gui"
1175
  msgid "Debug"
1176
  msgstr "Debug"
1587
  msgstr "Genereret eksporteringer"
1588
 
1589
  # @ simple-history
1590
+ #: loggers/SimpleLogger.php:220
1591
  msgctxt "header output when initiator is the currently logged in user"
1592
  msgid "You"
1593
  msgstr "Dig"
1594
 
1595
+ #: loggers/SimpleLogger.php:311
1596
+ msgctxt "Event header output, when initiator is unknown"
1597
+ msgid "Other"
1598
+ msgstr "Anden"
1599
+
1600
  # @ simple-history
1601
  #: loggers/SimpleMediaLogger.php:31
1602
  msgctxt "Media logger: search"
1603
  msgid "Media"
1604
  msgstr "Medier"
1605
 
1606
+ #: loggers/SimpleMediaLogger.php:32
1607
+ msgctxt "Media logger: search"
1608
+ msgid "All media activity"
1609
+ msgstr "Alt medie aktivitet"
1610
+
1611
  # @ simple-history
1612
+ #: loggers/SimpleMediaLogger.php:34
1613
  msgctxt "Media logger: search"
1614
  msgid "Added media"
1615
  msgstr "Tilføjet medier"
1616
 
1617
  # @ simple-history
1618
+ #: loggers/SimpleMediaLogger.php:37
1619
  msgctxt "Media logger: search"
1620
  msgid "Updated media"
1621
  msgstr "Opdateret medier"
1622
 
1623
  # @ simple-history
1624
+ #: loggers/SimpleMediaLogger.php:40
1625
  msgctxt "Media logger: search"
1626
  msgid "Deleted media"
1627
  msgstr "Slettet medier"
1632
  msgid "Menus"
1633
  msgstr "Menuer"
1634
 
1635
+ #: loggers/SimpleMenuLogger.php:34
1636
+ msgctxt "Menu updates logger: search"
1637
+ msgid "All menu activity"
1638
+ msgstr "Alt menu aktivitet"
1639
+
1640
  # @ simple-history
1641
+ #: loggers/SimpleMenuLogger.php:36
1642
  msgctxt "Menu updates logger: search"
1643
  msgid "Created menus"
1644
  msgstr "Tilføjet menuer"
1645
 
1646
  # @ simple-history
1647
+ #: loggers/SimpleMenuLogger.php:39
1648
  msgctxt "Menu updates logger: search"
1649
  msgid "Edited menus"
1650
  msgstr "Redigeret menuer"
1651
 
1652
  # @ simple-history
1653
+ #: loggers/SimpleMenuLogger.php:44
1654
  msgctxt "Menu updates logger: search"
1655
  msgid "Deleted menus"
1656
  msgstr "Slettet menuer"
1657
 
1658
  # @ simple-history
1659
+ #: loggers/SimpleMenuLogger.php:329
1660
  msgctxt "menu logger"
1661
  msgid "%1$s menu item added"
1662
  msgid_plural "%1$s menu items added"
1664
  msgstr[1] "%1$s menupunkter tilføjet"
1665
 
1666
  # @ simple-history
1667
+ #: loggers/SimpleMenuLogger.php:336
1668
  msgctxt "menu logger"
1669
  msgid "%1$s menu item removed"
1670
  msgid_plural "%1$s menu items removed"
1751
  msgid "Plugins"
1752
  msgstr "Plugins"
1753
 
1754
+ #: loggers/SimplePluginLogger.php:85
1755
+ msgctxt "Plugin logger: search"
1756
+ msgid "All plugin activity"
1757
+ msgstr "Alt plugin aktivitet"
1758
+
1759
  # @ simple-history
1760
+ #: loggers/SimplePluginLogger.php:87
1761
  msgctxt "Plugin logger: search"
1762
  msgid "Activated plugins"
1763
  msgstr "Aktiveret plugins"
1764
 
1765
  # @ simple-history
1766
+ #: loggers/SimplePluginLogger.php:90
1767
  msgctxt "Plugin logger: search"
1768
  msgid "Deactivated plugins"
1769
  msgstr "Deaktiveret plugins"
1770
 
1771
  # @ simple-history
1772
+ #: loggers/SimplePluginLogger.php:93
1773
  msgctxt "Plugin logger: search"
1774
  msgid "Installed plugins"
1775
  msgstr "Installeret plugins"
1776
 
1777
  # @ simple-history
1778
+ #: loggers/SimplePluginLogger.php:96
1779
  msgctxt "Plugin logger: search"
1780
  msgid "Failed plugin installs"
1781
  msgstr "Mislykket plugin installeringer"
1782
 
1783
  # @ simple-history
1784
+ #: loggers/SimplePluginLogger.php:99
1785
  msgctxt "Plugin logger: search"
1786
  msgid "Updated plugins"
1787
  msgstr "Opdateret plugins"
1788
 
1789
  # @ simple-history
1790
+ #: loggers/SimplePluginLogger.php:103
1791
  msgctxt "Plugin logger: search"
1792
  msgid "Failed plugin updates"
1793
  msgstr "Mislykket plugin opdateringer"
1794
 
1795
  # @ simple-history
1796
+ #: loggers/SimplePluginLogger.php:106
1797
  msgctxt "Plugin logger: search"
1798
  msgid "Edited plugin files"
1799
  msgstr "Redigeret plugin filer"
1800
 
1801
  # @ simple-history
1802
+ #: loggers/SimplePluginLogger.php:109
1803
  msgctxt "Plugin logger: search"
1804
  msgid "Deleted plugins"
1805
  msgstr "Slettet plugins"
1806
 
1807
+ #: loggers/SimplePluginLogger.php:1074
1808
  msgctxt "plugin logger - detailed output"
1809
  msgid "Description"
1810
  msgstr "Beskrivelse"
1811
 
1812
+ #: loggers/SimplePluginLogger.php:1075
1813
  msgctxt "plugin logger - detailed output install source"
1814
  msgid "Source"
1815
  msgstr "Kilde"
1816
 
1817
+ #: loggers/SimplePluginLogger.php:1076
1818
  msgctxt "plugin logger - detailed output install source"
1819
  msgid "Source file name"
1820
  msgstr "Kilde filnavn"
1821
 
1822
  # @ simple-history
1823
+ #: loggers/SimplePluginLogger.php:1077
1824
  msgctxt "plugin logger - detailed output version"
1825
  msgid "Version"
1826
  msgstr "Version"
1827
 
1828
  # @ simple-history
1829
+ #: loggers/SimplePluginLogger.php:1078
1830
  msgctxt "plugin logger - detailed output author"
1831
  msgid "Author"
1832
  msgstr "Forfatter"
1833
 
1834
  # @ simple-history
1835
+ #: loggers/SimplePluginLogger.php:1079
1836
  msgctxt "plugin logger - detailed output url"
1837
  msgid "URL"
1838
  msgstr "URL"
1839
 
1840
  # @ simple-history
1841
+ #: loggers/SimplePluginLogger.php:1187 loggers/SimplePluginLogger.php:1206
1842
+ #: loggers/SimplePluginLogger.php:1245
1843
  msgctxt "plugin logger: plugin info thickbox title view all info"
1844
  msgid "View plugin info"
1845
  msgstr "Vis plugin info"
1846
 
1847
  # @ simple-history
1848
+ #: loggers/SimplePluginLogger.php:1221
1849
  msgctxt "plugin logger: plugin info thickbox title"
1850
  msgid "View plugin info"
1851
  msgstr "Vis plugin info"
1852
 
1853
  # @ simple-history
1854
+ #: loggers/SimplePluginLogger.php:1225
1855
  msgctxt "plugin logger: plugin info thickbox title"
1856
  msgid "View changelog"
1857
  msgstr "Vis changelog"
1858
 
1859
  # @ simple-history
1860
+ #: loggers/SimplePostLogger.php:127
1861
  msgctxt "Post logger: search"
1862
  msgid "Posts & Pages"
1863
  msgstr "Indlæg & Sider"
1864
 
1865
+ #: loggers/SimplePostLogger.php:128
1866
+ msgctxt "Post logger: search"
1867
+ msgid "All posts & pages activity"
1868
+ msgstr "Alt indlæg & sider aktivitet"
1869
+
1870
  # @ simple-history
1871
+ #: loggers/SimplePostLogger.php:130
1872
  msgctxt "Post logger: search"
1873
  msgid "Posts created"
1874
  msgstr "Indlæg tilføjet"
1875
 
1876
  # @ simple-history
1877
+ #: loggers/SimplePostLogger.php:133
1878
  msgctxt "Post logger: search"
1879
  msgid "Posts updated"
1880
  msgstr "Indlæg opdateret"
1881
 
1882
  # @ simple-history
1883
+ #: loggers/SimplePostLogger.php:136
1884
  msgctxt "Post logger: search"
1885
  msgid "Posts trashed"
1886
  msgstr "Indlæg flyttet til papirkurven"
1887
 
1888
  # @ simple-history
1889
+ #: loggers/SimplePostLogger.php:139
1890
  msgctxt "Post logger: search"
1891
  msgid "Posts deleted"
1892
  msgstr "Indlæg slettet"
1893
 
1894
  # @ simple-history
1895
+ #: loggers/SimplePostLogger.php:142
1896
  msgctxt "Post logger: search"
1897
  msgid "Posts restored"
1898
  msgstr "Indlæg gendannet"
1903
  msgid "Themes & Widgets"
1904
  msgstr "Tema & Widgets"
1905
 
1906
+ #: loggers/SimpleThemeLogger.php:38
1907
+ msgctxt "Theme logger: search"
1908
+ msgid "All theme activity"
1909
+ msgstr "Alt tema aktivitet"
1910
+
1911
  # @ simple-history
1912
+ #: loggers/SimpleThemeLogger.php:40
1913
  msgctxt "Theme logger: search"
1914
  msgid "Switched themes"
1915
  msgstr "Skiftet temaer"
1916
 
1917
  # @ simple-history
1918
+ #: loggers/SimpleThemeLogger.php:43
1919
  msgctxt "Theme logger: search"
1920
  msgid "Changed appearance of themes"
1921
  msgstr "Skiftet udseende på temaer"
1922
 
1923
  # @ simple-history
1924
+ #: loggers/SimpleThemeLogger.php:46
1925
  msgctxt "Theme logger: search"
1926
  msgid "Added widgets"
1927
  msgstr "Tilføjet widgets"
1928
 
1929
  # @ simple-history
1930
+ #: loggers/SimpleThemeLogger.php:49
1931
  msgctxt "Theme logger: search"
1932
  msgid "Removed widgets"
1933
  msgstr "Fjernet widgets"
1934
 
1935
  # @ simple-history
1936
+ #: loggers/SimpleThemeLogger.php:52
1937
  msgctxt "Theme logger: search"
1938
  msgid "Changed widgets order"
1939
  msgstr "Ændret widget rækkefølge"
1940
 
1941
  # @ simple-history
1942
+ #: loggers/SimpleThemeLogger.php:55
1943
  msgctxt "Theme logger: search"
1944
  msgid "Edited widgets"
1945
  msgstr "Ændret widgets"
1946
 
1947
  # @ simple-history
1948
+ #: loggers/SimpleThemeLogger.php:58
1949
  msgctxt "Theme logger: search"
1950
  msgid "Background of themes changed"
1951
  msgstr "Baggrund og tema ændret"
loggers/SimpleLogger.php CHANGED
@@ -182,7 +182,7 @@ class SimpleLogger {
182
  * @since 2.1
183
  */
184
  $use_you = apply_filters("simple_history/header_initiator_use_you", true);
185
-
186
  if ( $use_you && $is_current_user ) {
187
 
188
  $tmpl_initiator_html = '
@@ -855,6 +855,7 @@ class SimpleLogger {
855
  $sh_latest_translations = $this->simpleHistory->gettextLatestTranslations;
856
 
857
  if ( ! empty( $sh_latest_translations ) ) {
 
858
  if ( isset( $sh_latest_translations[ $message ] ) ) {
859
 
860
  // Translation of this phrase was found, so use original phrase instead of translated one
@@ -1020,6 +1021,9 @@ class SimpleLogger {
1020
 
1021
  }
1022
 
 
 
 
1023
  /**
1024
  * Filter data to be saved to db
1025
  *
@@ -1031,6 +1035,7 @@ class SimpleLogger {
1031
 
1032
  // Insert data into db
1033
  // sf_d($db_table, '$db_table');exit;
 
1034
  $result = $wpdb->insert($db_table, $data);
1035
 
1036
  // Only save context if able to store row
182
  * @since 2.1
183
  */
184
  $use_you = apply_filters("simple_history/header_initiator_use_you", true);
185
+
186
  if ( $use_you && $is_current_user ) {
187
 
188
  $tmpl_initiator_html = '
855
  $sh_latest_translations = $this->simpleHistory->gettextLatestTranslations;
856
 
857
  if ( ! empty( $sh_latest_translations ) ) {
858
+
859
  if ( isset( $sh_latest_translations[ $message ] ) ) {
860
 
861
  // Translation of this phrase was found, so use original phrase instead of translated one
1021
 
1022
  }
1023
 
1024
+ // Trim message
1025
+ $data["message"] = trim( $data["message"] );
1026
+
1027
  /**
1028
  * Filter data to be saved to db
1029
  *
1035
 
1036
  // Insert data into db
1037
  // sf_d($db_table, '$db_table');exit;
1038
+
1039
  $result = $wpdb->insert($db_table, $data);
1040
 
1041
  // Only save context if able to store row
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
5
  Requires at least: 3.6.0
6
  Tested up to: 4.3
7
- Stable tag: 2.1.5
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
@@ -29,7 +29,7 @@ activation and deactivation
29
  * **User profiles**<br>
30
  info about added, updated or removed users
31
  * **User logins**<br>
32
- see when a user login & logout
33
  * **Failed user logins**<br>
34
  see when someone has tried to log in, but failed. The log will then include ip address of the possible hacker.
35
 
@@ -76,6 +76,8 @@ if ( function_exists("SimpleLogger") ) {
76
  ?>
77
  `
78
 
 
 
79
  #### Translations/Languages
80
 
81
  So far Simple History is translated to:
@@ -117,6 +119,15 @@ initiated by a specific user.
117
 
118
  ## Changelog
119
 
 
 
 
 
 
 
 
 
 
120
  = 2.1.5 (August 2015) =
121
 
122
  - Fixed: It was not possible to modify the filters `simple_history/view_settings_capability` and `simple_history/view_history_capability` from the `functions.php`-file in a theme (filters where applied to early - they did however work from within a plugin!)
@@ -151,7 +162,7 @@ initiated by a specific user.
151
 
152
  = 2.1.1 (May 2015) =
153
 
154
- - Removed: filter `simple_history/dropins_dir` removed.
155
  - Changed: Dropins are not loaded from a `glob()` call anymore (just like plugins in the prev release)
156
  - Updated: Brazilian Portuguese translation updated.
157
  - Fixed: POT file updated for translators.
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: 3.6.0
6
  Tested up to: 4.3
7
+ Stable tag: 2.1.6
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
29
  * **User profiles**<br>
30
  info about added, updated or removed users
31
  * **User logins**<br>
32
+ see when a user login & logout. Also see when a user fails to login (good way to catch brute-force login attempts).
33
  * **Failed user logins**<br>
34
  see when someone has tried to log in, but failed. The log will then include ip address of the possible hacker.
35
 
76
  ?>
77
  `
78
 
79
+ Check out the [examples-folder](https://github.com/bonny/WordPress-Simple-History/tree/master/examples) for more examples.
80
+
81
  #### Translations/Languages
82
 
83
  So far Simple History is translated to:
119
 
120
  ## Changelog
121
 
122
+ = 2.1.6 (August 2015) =
123
+
124
+ - Updated: Danish translation updated. Thanks translator!
125
+ - Fixed: Icon on settings page was a bit unaligned on WordPress not running the latest beta version (hrm, which I guess most of you were..)
126
+ - Fixed: Possible php notice. Should fix https://wordpress.org/support/topic/simplehistoryphp-creates-debug-entries.
127
+ - Changed: Logged messages are now trimmed by default (spaces and new lines will be removed from messages).
128
+ - Updated: When installing and activating the plugin it will now add the same "plugin installed" and "plugin activated" message that other plugins get when they are installed. These events where not logged before because the plugin was not installed and could therefor not log its own installation. Solution was to log it manually. Works. Looks good. But perhaps a bit of cheating.
129
+ - Added: A (hopefully) better welcome message when activating the plugin for the first time. Hopefully the new message makes new users understand a bit better why the log may be empty at first.
130
+
131
  = 2.1.5 (August 2015) =
132
 
133
  - Fixed: It was not possible to modify the filters `simple_history/view_settings_capability` and `simple_history/view_history_capability` from the `functions.php`-file in a theme (filters where applied to early - they did however work from within a plugin!)
162
 
163
  = 2.1.1 (May 2015) =
164
 
165
+ - Removed: filter `simple_history/dropins_dir` removed.
166
  - Changed: Dropins are not loaded from a `glob()` call anymore (just like plugins in the prev release)
167
  - Updated: Brazilian Portuguese translation updated.
168
  - Fixed: POT file updated for translators.