MainWP Child Reports - Version 2.0.5

Version Description

  • 8-31-2020 =
  • Fixed: jQuery warning
  • Fixed: Compatibility issues with MySQL 8
  • Fixed: An issue with logging maintenance tasks
Download this release

Release Info

Developer mainwp
Plugin Icon 128x128 MainWP Child Reports
Version 2.0.5
Comparing to
See all releases

Code changes from version 2.0.4 to 2.0.5

Files changed (61) hide show
  1. classes/class-admin.php +158 -167
  2. classes/class-alerts.php +29 -29
  3. classes/class-author.php +27 -14
  4. classes/class-cli.php +9 -0
  5. classes/class-connector.php +6 -0
  6. classes/class-connectors.php +13 -5
  7. classes/class-date-interval.php +9 -1
  8. classes/class-db-driver-wpdb.php +16 -1
  9. classes/class-db-driver.php +5 -0
  10. classes/class-db.php +9 -2
  11. classes/class-export.php +13 -4
  12. classes/class-exporter.php +6 -0
  13. classes/class-filter-input.php +50 -7
  14. classes/class-form-generator.php +6 -0
  15. classes/class-install.php +92 -64
  16. classes/class-list-table.php +208 -75
  17. classes/class-live-update.php +6 -0
  18. classes/class-log.php +30 -29
  19. classes/class-mainwp-child-report-helper.php +161 -44
  20. classes/class-network.php +94 -66
  21. classes/class-plugin.php +31 -54
  22. classes/class-preview-list-table.php +5 -0
  23. classes/class-query.php +8 -0
  24. classes/class-record.php +84 -31
  25. classes/class-settings.php +7 -1
  26. classes/class-uninstall.php +19 -0
  27. classes/debug.log +0 -42
  28. connectors/class-connector-acf.php +35 -27
  29. connectors/class-connector-bbpress.php +20 -4
  30. connectors/class-connector-blogs.php +26 -20
  31. connectors/class-connector-buddypress.php +293 -96
  32. connectors/class-connector-comments.php +9 -0
  33. connectors/class-connector-edd.php +190 -89
  34. connectors/class-connector-editor.php +18 -4
  35. connectors/class-connector-gravityforms.php +218 -123
  36. connectors/class-connector-installer.php +105 -54
  37. connectors/class-connector-jetpack.php +133 -73
  38. connectors/class-connector-mainwp-backups.php +95 -36
  39. connectors/class-connector-mainwp-maintenance.php +59 -16
  40. connectors/class-connector-mainwp-sucuri.php +21 -4
  41. connectors/class-connector-mainwp-wordfence.php +50 -10
  42. connectors/class-connector-media.php +15 -0
  43. connectors/class-connector-menus.php +19 -10
  44. connectors/class-connector-posts.php +10 -1
  45. connectors/class-connector-settings.php +58 -40
  46. connectors/class-connector-taxonomies.php +28 -13
  47. connectors/class-connector-user-switching.php +6 -0
  48. connectors/class-connector-users.php +16 -3
  49. connectors/class-connector-widgets.php +36 -14
  50. connectors/class-connector-woocommerce.php +138 -105
  51. connectors/class-connector-wordpress-seo.php +85 -42
  52. exporters/class-exporter-csv.php +10 -12
  53. exporters/class-exporter-json.php +6 -0
  54. includes/db-updates.php +15 -12
  55. includes/feeds/atom.php +2 -0
  56. includes/feeds/json.php +2 -0
  57. includes/feeds/rss-2.0.php +2 -0
  58. includes/functions.php +20 -12
  59. mainwp-child-reports.php +9 -3
  60. readme.txt +9 -4
  61. ui/js/admin.js +1 -2
classes/class-admin.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
 
3
  namespace WP_MainWP_Stream;
4
 
@@ -8,111 +9,55 @@ use DateInterval;
8
  use \WP_CLI;
9
  use \WP_Roles;
10
 
 
 
 
 
11
  class Admin {
12
 
13
- /**
14
- * Hold Plugin class
15
- *
16
- * @var Plugin
17
- */
18
  public $plugin;
19
 
20
- /**
21
- * Holds Network class
22
- *
23
- * @var Network
24
- */
25
  public $network;
26
 
27
- /**
28
- * Holds Live Update class
29
- *
30
- * @var Live_Update
31
- */
32
  public $live_update;
33
 
34
- /**
35
- * Holds Export class
36
- *
37
- * @var Export
38
- */
39
  public $export;
40
 
41
- /**
42
- * Menu page screen id
43
- *
44
- * @var string
45
- */
46
  public $screen_id = array();
47
 
48
- /**
49
- * List table object
50
- *
51
- * @var List_Table
52
- */
53
  public $list_table = null;
54
 
55
- /**
56
- * Option to disable access to Stream
57
- *
58
- * @var bool
59
- */
60
  public $disable_access = false;
61
 
62
- /**
63
- * Class applied to the body of the admin screen
64
- *
65
- * @var string
66
- */
67
  public $admin_body_class = 'wp_mainwp_stream_screen';
68
 
69
- /**
70
- * Slug of the records page
71
- *
72
- * @var string
73
- */
74
  public $records_page_slug = 'mainwp-reports-page';
75
 
76
- /**
77
- * Slug of the settings page
78
- *
79
- * @var string
80
- */
81
  public $settings_page_slug = 'mainwp-reports-settings';
82
 
83
- /**
84
- * Parent page of the records and settings pages
85
- *
86
- * @var string
87
- */
88
  public $admin_parent_page = 'options-general.php';
89
 
90
- /**
91
- * Capability name for viewing records
92
- *
93
- * @var string
94
- */
95
  public $view_cap = 'view_stream';
96
 
97
- /**
98
- * Capability name for viewing settings
99
- *
100
- * @var string
101
- */
102
  public $settings_cap = 'manage_options';
103
 
104
- /**
105
- * Total amount of authors to pre-load
106
- *
107
- * @var int
108
- */
109
  public $preload_users_max = 50;
110
 
111
- /**
112
- * Admin notices, collected and displayed on proper action
113
- *
114
- * @var array
115
- */
116
  public $notices = array();
117
 
118
  /**
@@ -216,7 +161,7 @@ class Admin {
216
  }
217
 
218
  /**
219
- * Load admin classes
220
  *
221
  * @action init
222
  */
@@ -244,7 +189,7 @@ class Admin {
244
  }
245
 
246
  /**
247
- * Handle notice messages according to the appropriate context (WP-CLI or the WP Admin)
248
  *
249
  * @param string $message Message to output.
250
  * @param bool $is_error If the message is error_level (true) or warning (false).
@@ -271,11 +216,19 @@ class Admin {
271
  }
272
 
273
  /**
274
- * Show an error or other message in the WP Admin
275
  *
276
  * @action shutdown
277
  */
278
  public function admin_notices() {
 
 
 
 
 
 
 
 
279
  global $allowedposttags;
280
 
281
  $custom = array(
@@ -301,34 +254,35 @@ class Admin {
301
  }
302
 
303
  /**
304
- * Register menu page
305
  *
306
  * @action admin_menu
307
  *
308
  * @return void
 
309
  */
310
- // DISABLED
311
- public function register_menu() {
312
  /**
313
- * Filter the main admin menu title
314
  *
315
- * @return string
316
  */
317
  $main_menu_title = apply_filters( 'wp_mainwp_stream_admin_menu_title', esc_html__( 'MainWP Child Reports', 'mainwp-child-reports' ) );
318
 
319
  /**
320
- * Filter the main admin menu position
321
  *
322
- * Note: Using longtail decimal string to reduce the chance of position conflicts, see Codex
323
  *
324
- * @return string
325
  */
326
  $main_menu_position = apply_filters( 'wp_mainwp_stream_menu_position', '2.999999' );
327
 
328
  /**
329
- * Filter the main admin page title
330
  *
331
- * @return string
332
  */
333
  $main_page_title = apply_filters( 'wp_mainwp_stream_admin_page_title', esc_html__( 'Reports Records', 'mainwp-child-reports' ) );
334
 
@@ -344,16 +298,16 @@ class Admin {
344
 
345
  /**
346
  * Fires before submenu items are added to the Stream menu
347
- * allowing plugins to add menu items before Settings
348
  *
349
  * @return void
350
  */
351
  do_action( 'wp_mainwp_stream_admin_menu' );
352
 
353
  /**
354
- * Filter the Settings admin page title
355
  *
356
- * @return string
357
  */
358
  $settings_page_title = apply_filters( 'wp_mainwp_stream_settings_form_title', esc_html__( 'Reports Settings', 'mainwp-child-reports' ) );
359
 
@@ -367,6 +321,7 @@ class Admin {
367
  );
368
 
369
  if ( isset( $this->screen_id['main'] ) ) {
 
370
  /**
371
  * Fires just before the Stream list table is registered.
372
  *
@@ -385,11 +340,11 @@ class Admin {
385
  }
386
 
387
  /**
388
- * Enqueue scripts/styles for admin screen
389
  *
390
  * @action admin_enqueue_scripts
391
  *
392
- * @param string $hook
393
  *
394
  * @return void
395
  */
@@ -503,9 +458,9 @@ class Admin {
503
  }
504
 
505
  /**
506
- * Check whether or not the current admin screen belongs to Stream
507
  *
508
- * @return bool
509
  */
510
  public function is_stream_screen() {
511
  if ( is_admin() && false !== strpos( wp_mainwp_stream_filter_input( INPUT_GET, 'page' ), $this->records_page_slug ) ) {
@@ -521,13 +476,13 @@ class Admin {
521
  }
522
 
523
  /**
524
- * Add a specific body class to all Stream admin screens
525
  *
526
- * @param string $classes CSS classes to output to body
527
  *
528
  * @filter admin_body_class
529
  *
530
- * @return string
531
  */
532
  public function admin_body_class( $classes ) {
533
  $stream_classes = array();
@@ -536,14 +491,14 @@ class Admin {
536
  $stream_classes[] = $this->admin_body_class;
537
 
538
  if ( isset( $_GET['page'] ) ) { // CSRF okay
539
- $stream_classes[] = sanitize_key( $_GET['page'] ); // input var okay, CSRF okay
540
  }
541
  }
542
 
543
  /**
544
- * Filter the Stream admin body classes
545
  *
546
- * @return array
547
  */
548
  $stream_classes = apply_filters( 'wp_mainwp_stream_admin_body_classes', $stream_classes );
549
  $stream_classes = implode( ' ', array_map( 'trim', $stream_classes ) );
@@ -552,7 +507,7 @@ class Admin {
552
  }
553
 
554
  /**
555
- * Add menu styles for various WP Admin skins
556
  *
557
  * @uses \wp_add_inline_style()
558
  *
@@ -628,8 +583,6 @@ class Admin {
628
  \wp_add_inline_style( 'wp-admin', $css );
629
  }
630
 
631
-
632
-
633
  /**
634
  * Handle the convert AJAX request to convert logs.
635
  *
@@ -662,11 +615,19 @@ class Admin {
662
  //
663
  // exit;
664
  // }
665
-
666
- private function convert_old_records() {
667
-
 
 
 
 
 
 
 
668
  global $wpdb;
669
- // Get only the author_meta values that are double-serialized
 
670
  $wpdb->query( "RENAME TABLE {$wpdb->base_prefix}mainwp_stream TO {$wpdb->base_prefix}mainwp_stream_tmp, {$wpdb->base_prefix}mainwp_stream_context TO {$wpdb->base_prefix}mainwp_stream_context_tmp" );
671
 
672
  // $plugin = wp_mainwp_stream_get_instance();
@@ -733,7 +694,7 @@ class Admin {
733
  }
734
  include_once $this->plugin->locations['inc_dir'] . 'db-updates.php';
735
 
736
- // force to repair
737
  if ( function_exists( 'wp_mainwp_stream_update_auto_352')) {
738
 
739
  wp_mainwp_stream_update_auto_352( true, true );
@@ -756,7 +717,7 @@ class Admin {
756
  /**
757
  * Handle the reset AJAX request to reset logs.
758
  *
759
- * @return bool
760
  */
761
  public function wp_ajax_reset() {
762
  check_ajax_referer( 'stream_nonce_reset', 'wp_mainwp_stream_nonce_reset' );
@@ -787,9 +748,14 @@ class Admin {
787
 
788
  exit;
789
  }
790
-
791
-
792
- private function erase_stream_records() {
 
 
 
 
 
793
  global $wpdb;
794
 
795
  $where = '';
@@ -807,16 +773,25 @@ class Admin {
807
  );
808
  }
809
 
810
- public function purge_schedule_setup() {
 
 
 
811
  if ( ! wp_next_scheduled( 'wp_mainwp_stream_auto_purge' ) ) {
812
  wp_schedule_event( time(), 'twicedaily', 'wp_mainwp_stream_auto_purge' );
813
  }
814
  }
815
 
816
- public function purge_scheduled_action() {
 
 
 
 
 
 
817
  global $wpdb;
818
 
819
- // Don't purge when in Network Admin unless Stream is network activated
820
  if (
821
  is_multisite()
822
  &&
@@ -860,19 +835,21 @@ class Admin {
860
  }
861
 
862
  /**
863
- * @param array $links
864
- * @param string $file
 
 
865
  *
866
  * @filter plugin_action_links
867
  *
868
- * @return array
869
  */
870
  public function plugin_action_links( $links, $file ) {
871
  if ( plugin_basename( $this->plugin->locations['dir'] . 'stream.php' ) !== $file ) {
872
  return $links;
873
  }
874
 
875
- // Also don't show links in Network Admin if Stream isn't network enabled
876
  if ( is_network_admin() && is_multisite() && ! is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) {
877
  return $links;
878
  }
@@ -906,11 +883,12 @@ class Admin {
906
  return $links;
907
  }
908
 
909
- /**
910
- * Render main page
911
- */
912
- // DISABLED
913
- public function render_list_table() {
 
914
  $this->list_table->prepare_items();
915
  ?>
916
  <div class="wrap">
@@ -921,10 +899,11 @@ class Admin {
921
  }
922
 
923
  /**
924
- * Render settings page
 
 
925
  */
926
- // DISABLED
927
- public function render_settings_page() {
928
  $option_key = $this->plugin->settings->option_key;
929
  $form_action = apply_filters( 'wp_mainwp_stream_settings_form_action', admin_url( 'options.php' ) );
930
 
@@ -982,10 +961,11 @@ class Admin {
982
  }
983
 
984
  /**
985
- * Instantiate the list table
 
 
986
  */
987
- // DISABLED
988
- public function register_list_table() {
989
  $this->list_table = new List_Table(
990
  $this->plugin, array(
991
  'screen' => $this->screen_id['main'],
@@ -996,12 +976,12 @@ class Admin {
996
  /**
997
  * Check if a particular role has access
998
  *
999
- * @param string $role
1000
  *
1001
- * @return bool
 
1002
  */
1003
- // DISABLED
1004
- private function role_can_view( $role ) {
1005
  if ( in_array( $role, $this->plugin->settings->options['general_role_access'], true ) ) {
1006
  return true;
1007
  }
@@ -1010,19 +990,22 @@ class Admin {
1010
  }
1011
 
1012
  /**
1013
- * Filter user caps to dynamically grant our view cap based on allowed roles
1014
  *
1015
- * @param $allcaps
1016
- * @param $caps
1017
- * @param $args
1018
- * @param $user
1019
  *
1020
  * @filter user_has_cap
1021
  *
1022
- * @return array
 
 
1023
  */
1024
- // DISABLED
1025
- public function filter_user_caps( $allcaps, $caps, $args, $user = null ) {
 
1026
  global $wp_roles;
1027
 
1028
  $_wp_roles = isset( $wp_roles ) ? $wp_roles : new WP_Roles();
@@ -1059,18 +1042,18 @@ class Admin {
1059
  }
1060
 
1061
  /**
1062
- * Filter role caps to dynamically grant our view cap based on allowed roles
1063
  *
1064
  * @filter role_has_cap
1065
  *
1066
- * @param $allcaps
1067
- * @param $cap
1068
- * @param $role
1069
  *
1070
- * @return array
 
1071
  */
1072
- // DISABLED
1073
- public function filter_role_caps( $allcaps, $cap, $role ) {
1074
  $stream_view_caps = array( $this->view_cap );
1075
 
1076
  if ( in_array( $cap, $stream_view_caps, true ) && $this->role_can_view( $role ) ) {
@@ -1081,6 +1064,8 @@ class Admin {
1081
  }
1082
 
1083
  /**
 
 
1084
  * @action wp_ajax_wp_mainwp_stream_filters
1085
  */
1086
  public function ajax_filters() {
@@ -1129,7 +1114,13 @@ class Admin {
1129
  die();
1130
  }
1131
 
1132
- public function get_users_record_meta( $authors ) {
 
 
 
 
 
 
1133
  $authors_records = array();
1134
 
1135
  foreach ( $authors as $user_id => $args ) {
@@ -1148,13 +1139,13 @@ class Admin {
1148
  }
1149
 
1150
  /**
1151
- * Get user meta in a way that is also safe for VIP
1152
  *
1153
- * @param int $user_id
1154
- * @param string $meta_key
1155
- * @param bool $single (optional)
1156
  *
1157
- * @return mixed
1158
  */
1159
  public function get_user_meta( $user_id, $meta_key, $single = true ) {
1160
  if ( wp_mainwp_stream_is_vip() && function_exists( 'get_user_attribute' ) ) {
@@ -1165,14 +1156,14 @@ class Admin {
1165
  }
1166
 
1167
  /**
1168
- * Update user meta in a way that is also safe for VIP
1169
  *
1170
- * @param int $user_id
1171
- * @param string $meta_key
1172
- * @param mixed $meta_value
1173
- * @param mixed $prev_value (optional)
1174
  *
1175
- * @return int|bool
1176
  */
1177
  public function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
1178
  if ( wp_mainwp_stream_is_vip() && function_exists( 'update_user_attribute' ) ) {
@@ -1183,13 +1174,13 @@ class Admin {
1183
  }
1184
 
1185
  /**
1186
- * Delete user meta in a way that is also safe for VIP
1187
  *
1188
- * @param int $user_id
1189
- * @param string $meta_key
1190
- * @param mixed $meta_value (optional)
1191
  *
1192
- * @return bool
1193
  */
1194
  public function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
1195
  if ( wp_mainwp_stream_is_vip() && function_exists( 'delete_user_attribute' ) ) {
1
  <?php
2
+ /** MainWP Child Reports Admin. */
3
 
4
  namespace WP_MainWP_Stream;
5
 
9
  use \WP_CLI;
10
  use \WP_Roles;
11
 
12
+ /**
13
+ * Class Admin.
14
+ * @package WP_MainWP_Stream
15
+ */
16
  class Admin {
17
 
18
+ /** @var Plugin Hold Plugin class. */
 
 
 
 
19
  public $plugin;
20
 
21
+ /** @var Network Holds Network class. */
 
 
 
 
22
  public $network;
23
 
24
+ /** @var Live_Update Holds Live Update class. */
 
 
 
 
25
  public $live_update;
26
 
27
+ /** @var Export Holds Export class. */
 
 
 
 
28
  public $export;
29
 
30
+ /** @var string Menu page screen id. */
 
 
 
 
31
  public $screen_id = array();
32
 
33
+ /** @var List_Table List table object. */
 
 
 
 
34
  public $list_table = null;
35
 
36
+ /** @var bool Option to disable access to Stream. */
 
 
 
 
37
  public $disable_access = false;
38
 
39
+ /** @var string Class applied to the body of the admin screen. */
 
 
 
 
40
  public $admin_body_class = 'wp_mainwp_stream_screen';
41
 
42
+ /** @var string Slug of the records page. */
 
 
 
 
43
  public $records_page_slug = 'mainwp-reports-page';
44
 
45
+ /** @var string Slug of the settings page. */
 
 
 
 
46
  public $settings_page_slug = 'mainwp-reports-settings';
47
 
48
+ /** @var string Parent page of the records and settings pages. */
 
 
 
 
49
  public $admin_parent_page = 'options-general.php';
50
 
51
+ /** @var string Capability name for viewing records. */
 
 
 
 
52
  public $view_cap = 'view_stream';
53
 
54
+ /** @var string Capability name for viewing settings. */
 
 
 
 
55
  public $settings_cap = 'manage_options';
56
 
57
+ /** @var int Total amount of authors to pre-load. */
 
 
 
 
58
  public $preload_users_max = 50;
59
 
60
+ /** @var array Admin notices, collected and displayed on proper action. */
 
 
 
 
61
  public $notices = array();
62
 
63
  /**
161
  }
162
 
163
  /**
164
+ * Load admin classes.
165
  *
166
  * @action init
167
  */
189
  }
190
 
191
  /**
192
+ * Handle notice messages according to the appropriate context (WP-CLI or the WP Admin).
193
  *
194
  * @param string $message Message to output.
195
  * @param bool $is_error If the message is error_level (true) or warning (false).
216
  }
217
 
218
  /**
219
+ * Show an error or other message in the WP Admin.
220
  *
221
  * @action shutdown
222
  */
223
  public function admin_notices() {
224
+
225
+ /**
226
+ * WordPress core white list of html tags and attributes
227
+ * that WordPress allows in posts used for sanitizing post_content.
228
+ *
229
+ * @global object $allowedposttags
230
+ *
231
+ */
232
  global $allowedposttags;
233
 
234
  $custom = array(
254
  }
255
 
256
  /**
257
+ * Register menu page.
258
  *
259
  * @action admin_menu
260
  *
261
  * @return void
262
+ * @deprecated Disabled.
263
  */
264
+ public function register_menu() {
265
+
266
  /**
267
+ * Filter the main admin menu title.
268
  *
269
+ * @return string Return main menu title.
270
  */
271
  $main_menu_title = apply_filters( 'wp_mainwp_stream_admin_menu_title', esc_html__( 'MainWP Child Reports', 'mainwp-child-reports' ) );
272
 
273
  /**
274
+ * Filter the main admin menu position.
275
  *
276
+ * Note: Using longtail decimal string to reduce the chance of position conflicts, see Codex.
277
  *
278
+ * @return string Return menue position.
279
  */
280
  $main_menu_position = apply_filters( 'wp_mainwp_stream_menu_position', '2.999999' );
281
 
282
  /**
283
+ * Filter the main admin page title.
284
  *
285
+ * @return string Return Main page title.
286
  */
287
  $main_page_title = apply_filters( 'wp_mainwp_stream_admin_page_title', esc_html__( 'Reports Records', 'mainwp-child-reports' ) );
288
 
298
 
299
  /**
300
  * Fires before submenu items are added to the Stream menu
301
+ * allowing plugins to add menu items before Settings.
302
  *
303
  * @return void
304
  */
305
  do_action( 'wp_mainwp_stream_admin_menu' );
306
 
307
  /**
308
+ * Filter the Settings admin page title.
309
  *
310
+ * @return string Return settings page title.
311
  */
312
  $settings_page_title = apply_filters( 'wp_mainwp_stream_settings_form_title', esc_html__( 'Reports Settings', 'mainwp-child-reports' ) );
313
 
321
  );
322
 
323
  if ( isset( $this->screen_id['main'] ) ) {
324
+
325
  /**
326
  * Fires just before the Stream list table is registered.
327
  *
340
  }
341
 
342
  /**
343
+ * Enqueue scripts/styles for admin screen.
344
  *
345
  * @action admin_enqueue_scripts
346
  *
347
+ * @param string $hook Page hook.
348
  *
349
  * @return void
350
  */
458
  }
459
 
460
  /**
461
+ * Check whether or not the current admin screen belongs to Stream.
462
  *
463
+ * @return bool TRUE|FALSE.
464
  */
465
  public function is_stream_screen() {
466
  if ( is_admin() && false !== strpos( wp_mainwp_stream_filter_input( INPUT_GET, 'page' ), $this->records_page_slug ) ) {
476
  }
477
 
478
  /**
479
+ * Add a specific body class to all Stream admin screens.
480
  *
481
+ * @param string $classes CSS classes to output to body.
482
  *
483
  * @filter admin_body_class
484
  *
485
+ * @return string Return body class.
486
  */
487
  public function admin_body_class( $classes ) {
488
  $stream_classes = array();
491
  $stream_classes[] = $this->admin_body_class;
492
 
493
  if ( isset( $_GET['page'] ) ) { // CSRF okay
494
+ $stream_classes[] = sanitize_key( $_GET['page'] ); // input var okay, CSRF okay.
495
  }
496
  }
497
 
498
  /**
499
+ * Filter the Stream admin body classes.
500
  *
501
+ * @return array Stream array.
502
  */
503
  $stream_classes = apply_filters( 'wp_mainwp_stream_admin_body_classes', $stream_classes );
504
  $stream_classes = implode( ' ', array_map( 'trim', $stream_classes ) );
507
  }
508
 
509
  /**
510
+ * Add menu styles for various WP Admin skins.
511
  *
512
  * @uses \wp_add_inline_style()
513
  *
583
  \wp_add_inline_style( 'wp-admin', $css );
584
  }
585
 
 
 
586
  /**
587
  * Handle the convert AJAX request to convert logs.
588
  *
615
  //
616
  // exit;
617
  // }
618
+
619
+ /**
620
+ * Convert old records.
621
+ *
622
+ * @return mixed
623
+ * @throws \Exception
624
+ */
625
+ private function convert_old_records() {
626
+
627
+ /** @global object $wpdb WordPress database object. */
628
  global $wpdb;
629
+
630
+ // Get only the author_meta values that are double-serialized.
631
  $wpdb->query( "RENAME TABLE {$wpdb->base_prefix}mainwp_stream TO {$wpdb->base_prefix}mainwp_stream_tmp, {$wpdb->base_prefix}mainwp_stream_context TO {$wpdb->base_prefix}mainwp_stream_context_tmp" );
632
 
633
  // $plugin = wp_mainwp_stream_get_instance();
694
  }
695
  include_once $this->plugin->locations['inc_dir'] . 'db-updates.php';
696
 
697
+ // force to repair.
698
  if ( function_exists( 'wp_mainwp_stream_update_auto_352')) {
699
 
700
  wp_mainwp_stream_update_auto_352( true, true );
717
  /**
718
  * Handle the reset AJAX request to reset logs.
719
  *
720
+ * @return bool TRUE|FASLE.
721
  */
722
  public function wp_ajax_reset() {
723
  check_ajax_referer( 'stream_nonce_reset', 'wp_mainwp_stream_nonce_reset' );
748
 
749
  exit;
750
  }
751
+
752
+
753
+ /**
754
+ * Erase stream records.
755
+ */
756
+ private function erase_stream_records() {
757
+
758
+ /** @global object $wpdb WordPress database object. */
759
  global $wpdb;
760
 
761
  $where = '';
773
  );
774
  }
775
 
776
+ /**
777
+ * Purge Schedule Setup.
778
+ */
779
+ public function purge_schedule_setup() {
780
  if ( ! wp_next_scheduled( 'wp_mainwp_stream_auto_purge' ) ) {
781
  wp_schedule_event( time(), 'twicedaily', 'wp_mainwp_stream_auto_purge' );
782
  }
783
  }
784
 
785
+ /**
786
+ * Purge Scheduled action.
787
+ * @throws \Exception
788
+ */
789
+ public function purge_scheduled_action() {
790
+
791
+ /** @global object $wpdb WordPress database object. */
792
  global $wpdb;
793
 
794
+ // Don't purge when in Network Admin unless Stream is network activated.
795
  if (
796
  is_multisite()
797
  &&
835
  }
836
 
837
  /**
838
+ * Plugin action links.
839
+ *
840
+ * @param array $links Action links array.
841
+ * @param string $file Plugin file URL.
842
  *
843
  * @filter plugin_action_links
844
  *
845
+ * @return array Plugin action links array.
846
  */
847
  public function plugin_action_links( $links, $file ) {
848
  if ( plugin_basename( $this->plugin->locations['dir'] . 'stream.php' ) !== $file ) {
849
  return $links;
850
  }
851
 
852
+ // Also don't show links in Network Admin if Stream isn't network enabled.
853
  if ( is_network_admin() && is_multisite() && ! is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) {
854
  return $links;
855
  }
883
  return $links;
884
  }
885
 
886
+ /**
887
+ * Render main page.
888
+ *
889
+ * @deprecated Disabled.
890
+ */
891
+ public function render_list_table() {
892
  $this->list_table->prepare_items();
893
  ?>
894
  <div class="wrap">
899
  }
900
 
901
  /**
902
+ * Render settings page.
903
+ *
904
+ * @deprecated Disabled.
905
  */
906
+ public function render_settings_page() {
 
907
  $option_key = $this->plugin->settings->option_key;
908
  $form_action = apply_filters( 'wp_mainwp_stream_settings_form_action', admin_url( 'options.php' ) );
909
 
961
  }
962
 
963
  /**
964
+ * Instantiate the list table.
965
+ *
966
+ * @deprecated Disabled.
967
  */
968
+ public function register_list_table() {
 
969
  $this->list_table = new List_Table(
970
  $this->plugin, array(
971
  'screen' => $this->screen_id['main'],
976
  /**
977
  * Check if a particular role has access
978
  *
979
+ * @param string $role User role.
980
  *
981
+ * @return bool TRUE|FALSE
982
+ * @deprecated Disabled.
983
  */
984
+ private function role_can_view( $role ) {
 
985
  if ( in_array( $role, $this->plugin->settings->options['general_role_access'], true ) ) {
986
  return true;
987
  }
990
  }
991
 
992
  /**
993
+ * Filter user caps to dynamically grant our view cap based on allowed roles.
994
  *
995
+ * @param array $allcaps All capabilities.
996
+ * @param array $caps Capabilities.
997
+ * @param array $args Arguments.
998
+ * @param string $user User.
999
  *
1000
  * @filter user_has_cap
1001
  *
1002
+ * @return array All capabilities.
1003
+ *
1004
+ * @deprecated Disabled.
1005
  */
1006
+ public function filter_user_caps($allcaps, $caps, $args, $user = null ) {
1007
+
1008
+ /** @global object $wp_roles Core class used to implement a user roles API. */
1009
  global $wp_roles;
1010
 
1011
  $_wp_roles = isset( $wp_roles ) ? $wp_roles : new WP_Roles();
1042
  }
1043
 
1044
  /**
1045
+ * Filter role caps to dynamically grant our view cap based on allowed roles.
1046
  *
1047
  * @filter role_has_cap
1048
  *
1049
+ * @param array $allcaps All capabilities.
1050
+ * @param array $cap Capabilities.
1051
+ * @param string $role User role.
1052
  *
1053
+ * @return array All capabilities.
1054
+ * @deprecated Disabled.
1055
  */
1056
+ public function filter_role_caps($allcaps, $cap, $role ) {
 
1057
  $stream_view_caps = array( $this->view_cap );
1058
 
1059
  if ( in_array( $cap, $stream_view_caps, true ) && $this->role_can_view( $role ) ) {
1064
  }
1065
 
1066
  /**
1067
+ * Ajax stream filters.
1068
+ *
1069
  * @action wp_ajax_wp_mainwp_stream_filters
1070
  */
1071
  public function ajax_filters() {
1114
  die();
1115
  }
1116
 
1117
+ /**
1118
+ * Get users record meta.
1119
+ *
1120
+ * @param array $authors Authors array.
1121
+ * @return array Return author records.
1122
+ */
1123
+ public function get_users_record_meta($authors ) {
1124
  $authors_records = array();
1125
 
1126
  foreach ( $authors as $user_id => $args ) {
1139
  }
1140
 
1141
  /**
1142
+ * Get user meta in a way that is also safe for VIP.
1143
  *
1144
+ * @param int $user_id User ID.
1145
+ * @param string $meta_key Meta Key.
1146
+ * @param bool $single Single record check. (optional).
1147
  *
1148
+ * @return array|bool Return user meta array or FALSE on failure.
1149
  */
1150
  public function get_user_meta( $user_id, $meta_key, $single = true ) {
1151
  if ( wp_mainwp_stream_is_vip() && function_exists( 'get_user_attribute' ) ) {
1156
  }
1157
 
1158
  /**
1159
+ * Update user meta in a way that is also safe for VIP.
1160
  *
1161
+ * @param int $user_id User ID.
1162
+ * @param string $meta_key Meta Key.
1163
+ * @param mixed $meta_value Meta value.
1164
+ * @param mixed $prev_value Previouse Meta value. (optional).
1165
  *
1166
+ * @return int|bool Return ID of record updated or FALSE on failure.
1167
  */
1168
  public function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
1169
  if ( wp_mainwp_stream_is_vip() && function_exists( 'update_user_attribute' ) ) {
1174
  }
1175
 
1176
  /**
1177
+ * Delete user meta in a way that is also safe for VIP.
1178
  *
1179
+ * @param int $user_id User ID.
1180
+ * @param string $meta_key Meta Key.
1181
+ * @param mixed $meta_value Meta value (optional).
1182
  *
1183
+ * @return bool TRUE|FALSE.
1184
  */
1185
  public function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
1186
  if ( wp_mainwp_stream_is_vip() && function_exists( 'delete_user_attribute' ) ) {
classes/class-alerts.php CHANGED
@@ -1,52 +1,49 @@
1
  <?php
2
  /**
3
- * Alerts feature class.
4
- *
5
- * @package WP_MainWP_Stream
6
  */
7
 
8
  namespace WP_MainWP_Stream;
9
 
10
  /**
11
- * Class Alerts
12
- *
13
  * @package WP_MainWP_Stream
14
  */
15
  class Alerts {
16
 
17
  /**
18
- * Alerts post type slug
19
  */
20
  const POST_TYPE = 'wp_mainwp_alerts';
21
 
22
  /**
23
- * Triggered Alerts meta key for Records
24
  */
25
  const ALERTS_TRIGGERED_META_KEY = 'wp_mainwp_alerts_triggered';
26
 
27
  /**
28
- * Hold Plugin class
29
  *
30
  * @var Plugin
31
  */
32
  public $plugin;
33
 
34
  /**
35
- * Post meta prefix
36
  *
37
  * @var string
38
  */
39
  public $meta_prefix = 'wp_mainwp_stream';
40
 
41
  /**
42
- * Alert Types
43
  *
44
  * @var array
45
  */
46
  public $alert_types = array();
47
 
48
  /**
49
- * Alert Triggers
50
  *
51
  * @var array
52
  */
@@ -109,7 +106,7 @@ class Alerts {
109
  }
110
 
111
  /**
112
- * Load alert_type classes
113
  *
114
  * @return void
115
  */
@@ -155,7 +152,7 @@ class Alerts {
155
  }
156
 
157
  /**
158
- * Load alert_type classes
159
  *
160
  * @return void
161
  */
@@ -199,7 +196,7 @@ class Alerts {
199
  }
200
 
201
  /**
202
- * Checks whether a Alert Type class is valid
203
  *
204
  * @param Alert_Type $alert_type The class to check.
205
  *
@@ -218,7 +215,7 @@ class Alerts {
218
  }
219
 
220
  /**
221
- * Checks whether a Alert Trigger class is valid
222
  *
223
  * @param Alert_Trigger $alert_trigger The class to check.
224
  *
@@ -267,7 +264,7 @@ class Alerts {
267
  }
268
 
269
  /**
270
- * Register scripts for page load
271
  *
272
  * @action admin_enqueue_scripts
273
  *
@@ -297,7 +294,7 @@ class Alerts {
297
  }
298
 
299
  /**
300
- * Register custom post type
301
  *
302
  * @action init
303
  *
@@ -369,7 +366,7 @@ class Alerts {
369
  }
370
 
371
  /**
372
- * Return alert object of the given ID
373
  *
374
  * @param string $post_id Post ID for the alert.
375
  *
@@ -401,13 +398,14 @@ class Alerts {
401
  }
402
 
403
  /**
404
- * Add custom post type to menu
405
  *
406
  * @action admin_menu
407
  *
408
  * @return void
 
 
409
  */
410
- // DISABLED
411
  public function register_menu() {
412
  add_submenu_page(
413
  $this->plugin->admin->records_page_slug,
@@ -432,6 +430,8 @@ class Alerts {
432
  * @return bool
433
  */
434
  public function change_menu_link_url() {
 
 
435
  global $submenu;
436
 
437
  $parent = 'wp_mainwp_stream';
@@ -471,7 +471,7 @@ class Alerts {
471
  }
472
 
473
  /**
474
- * Display Alert Type Meta Box
475
  *
476
  * @param \WP_Post|array $post Post object for current alert.
477
  *
@@ -510,7 +510,7 @@ class Alerts {
510
  }
511
 
512
  /**
513
- * Returns settings form HTML for AJAX use
514
  *
515
  * @action wp_ajax_load_alerts_settings
516
  *
@@ -554,7 +554,7 @@ class Alerts {
554
  }
555
 
556
  /**
557
- * Display Trigger Meta Box
558
  *
559
  * @param \WP_Post|array $post Post object for current alert.
560
  *
@@ -575,7 +575,7 @@ class Alerts {
575
  }
576
 
577
  /**
578
- * Display Submit Box
579
  *
580
  * @param \WP_Post $post Post object for current alert.
581
  *
@@ -635,7 +635,7 @@ class Alerts {
635
  }
636
 
637
  /**
638
- * Display Status Box
639
  *
640
  * @return void
641
  */
@@ -661,7 +661,7 @@ class Alerts {
661
  }
662
 
663
  /**
664
- * Return all notification values
665
  *
666
  * @return array
667
  */
@@ -696,7 +696,7 @@ class Alerts {
696
  }
697
 
698
  /**
699
- * Save a new alert
700
  */
701
  public function save_new_alert() {
702
  check_ajax_referer( 'save_alert', 'wp_mainwp_alerts_nonce' );
@@ -764,7 +764,7 @@ class Alerts {
764
  }
765
 
766
  /**
767
- *
768
  */
769
  public function get_new_alert_triggers_notifications() {
770
  ob_start();
@@ -790,7 +790,7 @@ class Alerts {
790
  }
791
 
792
  /**
793
- * Add action links to Stream drop row in admin list screen
794
  *
795
  * @filter wp_mainwp_stream_action_links_{connector}
796
  *
1
  <?php
2
  /**
3
+ * MainWP Child Reports Alerts feature class.
 
 
4
  */
5
 
6
  namespace WP_MainWP_Stream;
7
 
8
  /**
9
+ * Class Alerts.
 
10
  * @package WP_MainWP_Stream
11
  */
12
  class Alerts {
13
 
14
  /**
15
+ * Alerts post type slug.
16
  */
17
  const POST_TYPE = 'wp_mainwp_alerts';
18
 
19
  /**
20
+ * Triggered Alerts meta key for Records.
21
  */
22
  const ALERTS_TRIGGERED_META_KEY = 'wp_mainwp_alerts_triggered';
23
 
24
  /**
25
+ * Hold Plugin class.
26
  *
27
  * @var Plugin
28
  */
29
  public $plugin;
30
 
31
  /**
32
+ * Post meta prefix.
33
  *
34
  * @var string
35
  */
36
  public $meta_prefix = 'wp_mainwp_stream';
37
 
38
  /**
39
+ * Alert Types.
40
  *
41
  * @var array
42
  */
43
  public $alert_types = array();
44
 
45
  /**
46
+ * Alert Triggers.
47
  *
48
  * @var array
49
  */
106
  }
107
 
108
  /**
109
+ * Load alert_type classes.
110
  *
111
  * @return void
112
  */
152
  }
153
 
154
  /**
155
+ * Load alert_type classes.
156
  *
157
  * @return void
158
  */
196
  }
197
 
198
  /**
199
+ * Checks whether a Alert Type class is valid.
200
  *
201
  * @param Alert_Type $alert_type The class to check.
202
  *
215
  }
216
 
217
  /**
218
+ * Checks whether a Alert Trigger class is valid.
219
  *
220
  * @param Alert_Trigger $alert_trigger The class to check.
221
  *
264
  }
265
 
266
  /**
267
+ * Register scripts for page load.
268
  *
269
  * @action admin_enqueue_scripts
270
  *
294
  }
295
 
296
  /**
297
+ * Register custom post type.
298
  *
299
  * @action init
300
  *
366
  }
367
 
368
  /**
369
+ * Return alert object of the given ID.
370
  *
371
  * @param string $post_id Post ID for the alert.
372
  *
398
  }
399
 
400
  /**
401
+ * Add custom post type to menu.
402
  *
403
  * @action admin_menu
404
  *
405
  * @return void
406
+ *
407
+ * @deprecated DISABLED
408
  */
 
409
  public function register_menu() {
410
  add_submenu_page(
411
  $this->plugin->admin->records_page_slug,
430
  * @return bool
431
  */
432
  public function change_menu_link_url() {
433
+
434
+ /** @global object $submenu WordPress submenu array. */
435
  global $submenu;
436
 
437
  $parent = 'wp_mainwp_stream';
471
  }
472
 
473
  /**
474
+ * Display Alert Type Meta Box.
475
  *
476
  * @param \WP_Post|array $post Post object for current alert.
477
  *
510
  }
511
 
512
  /**
513
+ * Returns settings form HTML for AJAX use.
514
  *
515
  * @action wp_ajax_load_alerts_settings
516
  *
554
  }
555
 
556
  /**
557
+ * Display Trigger Meta Box.
558
  *
559
  * @param \WP_Post|array $post Post object for current alert.
560
  *
575
  }
576
 
577
  /**
578
+ * Display Submit Box.
579
  *
580
  * @param \WP_Post $post Post object for current alert.
581
  *
635
  }
636
 
637
  /**
638
+ * Display Status Box.
639
  *
640
  * @return void
641
  */
661
  }
662
 
663
  /**
664
+ * Return all notification values.
665
  *
666
  * @return array
667
  */
696
  }
697
 
698
  /**
699
+ * Save a new alert.
700
  */
701
  public function save_new_alert() {
702
  check_ajax_referer( 'save_alert', 'wp_mainwp_alerts_nonce' );
764
  }
765
 
766
  /**
767
+ * Get new alert triggers notifications.
768
  */
769
  public function get_new_alert_triggers_notifications() {
770
  ob_start();
790
  }
791
 
792
  /**
793
+ * Add action links to Stream drop row in admin list screen.
794
  *
795
  * @filter wp_mainwp_stream_action_links_{connector}
796
  *
classes/class-author.php CHANGED
@@ -1,20 +1,21 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Author {
5
- /**
6
- * @var int
7
- */
8
  public $id;
9
 
10
- /**
11
- * @var array
12
- */
13
  public $meta = array();
14
 
15
- /**
16
- * @var \WP_User
17
- */
18
  protected $user;
19
 
20
  /**
@@ -33,13 +34,19 @@ class Author {
33
  }
34
 
35
  /**
36
- * Get various user meta data
37
  *
38
  * @param string $name
39
  *
40
- * @throws \Exception
41
  *
42
- * @return string
 
 
 
 
 
 
43
  */
44
  public function __get( $name ) {
45
  if ( 'display_name' === $name ) {
@@ -60,7 +67,11 @@ class Author {
60
  }
61
 
62
  /**
63
- * @return string
 
 
 
 
64
  */
65
  public function __toString() {
66
  return $this->get_display_name();
@@ -69,7 +80,7 @@ class Author {
69
  /**
70
  * Get the display name of the user
71
  *
72
- * @return string
73
  */
74
  public function get_display_name() {
75
  if ( 0 === $this->id ) {
@@ -178,6 +189,8 @@ class Author {
178
  * @return string
179
  */
180
  public function get_role() {
 
 
181
  global $wp_roles;
182
 
183
  $user_role = '';
1
  <?php
2
+ /** MainWP Child Reports author. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Author.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Author {
11
+
12
+ /** @var int User ID. */
 
13
  public $id;
14
 
15
+ /** @var array User meta data. */
 
 
16
  public $meta = array();
17
 
18
+ /** @var \WP_User WordPress User. */
 
 
19
  protected $user;
20
 
21
  /**
34
  }
35
 
36
  /**
37
+ * Get various user meta data.
38
  *
39
  * @param string $name
40
  *
41
+ * @throws \Exception Error message.
42
  *
43
+ * @return string $name
44
+ *
45
+ * @uses \WP_MainWP_Stream\Author::get_display_name()
46
+ * @uses \WP_MainWP_Stream\Author::get_avatar_img()
47
+ * @uses \WP_MainWP_Stream\Author::get_avatar_src()
48
+ * @uses \WP_MainWP_Stream\Author::get_role()
49
+ * @uses \WP_MainWP_Stream\Author::get_agent()
50
  */
51
  public function __get( $name ) {
52
  if ( 'display_name' === $name ) {
67
  }
68
 
69
  /**
70
+ * Get author's display name.
71
+ *
72
+ * @return string Return author name.
73
+ *
74
+ * @uses \WP_MainWP_Stream\Author::get_display_name()
75
  */
76
  public function __toString() {
77
  return $this->get_display_name();
80
  /**
81
  * Get the display name of the user
82
  *
83
+ * @return string Return User Login or Display Names.
84
  */
85
  public function get_display_name() {
86
  if ( 0 === $this->id ) {
189
  * @return string
190
  */
191
  public function get_role() {
192
+
193
+ /** @global object $wp_roles Core class used to implement a user roles API. */
194
  global $wp_roles;
195
 
196
  $user_role = '';
classes/class-cli.php CHANGED
@@ -7,6 +7,10 @@
7
 
8
  namespace WP_MainWP_Stream;
9
 
 
 
 
 
10
  class CLI extends \WP_CLI_Command {
11
 
12
  /**
@@ -88,6 +92,11 @@ class CLI extends \WP_CLI_Command {
88
  * @see WP_MainWP_Stream_Query
89
  * @see https://github.com/wp-stream/stream/wiki/WP-CLI-Command
90
  * @see https://github.com/wp-stream/stream/wiki/Query-Reference
 
 
 
 
 
91
  */
92
  public function query( $args, $assoc_args ) {
93
  unset( $args );
7
 
8
  namespace WP_MainWP_Stream;
9
 
10
+ /**
11
+ * Class CLI.
12
+ * @package WP_MainWP_Stream
13
+ */
14
  class CLI extends \WP_CLI_Command {
15
 
16
  /**
92
  * @see WP_MainWP_Stream_Query
93
  * @see https://github.com/wp-stream/stream/wiki/WP-CLI-Command
94
  * @see https://github.com/wp-stream/stream/wiki/Query-Reference
95
+ *
96
+ * @param array $args Query arguments.
97
+ * @param array $assoc_args Association arguments.
98
+ *
99
+ * @uses \WP_MainWP_Stream\CLI::connection()
100
  */
101
  public function query( $args, $assoc_args ) {
102
  unset( $args );
classes/class-connector.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  abstract class Connector {
5
  /**
6
  * Connector slug
1
  <?php
2
+ /** MainWP Child Reports connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  abstract class Connector {
11
  /**
12
  * Connector slug
classes/class-connectors.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connectors {
5
  /**
6
  * Hold Plugin class
@@ -87,11 +93,13 @@ class Connectors {
87
  'mainwp-wordfence',
88
  );
89
 
 
 
90
  $classes = array();
91
  foreach ( $connectors as $connector ) {
92
  include_once $this->plugin->locations['dir'] . '/connectors/class-connector-' . $connector . '.php';
93
- $class_name = sprintf( '\WP_MainWP_Stream\Connector_%s', str_replace( '-', '_', $connector ) );
94
- if ( ! class_exists( $class_name ) ) {
95
  continue;
96
  }
97
  $class = new $class_name( $this->plugin->log );
@@ -102,12 +110,12 @@ class Connectors {
102
  }
103
 
104
  // Check if the Connector is allowed to be registered in the WP Admin
105
- if ( is_admin() && ! $class->register_admin ) {
106
  continue;
107
  }
108
 
109
  // Check if the Connector is allowed to be registered in the WP Frontend
110
- if ( ! is_admin() && ! $class->register_frontend ) {
111
  continue;
112
  }
113
 
@@ -212,5 +220,5 @@ class Connectors {
212
  * @param Connectors $connectors The Connectors object
213
  */
214
  do_action( 'wp_mainwp_stream_after_connectors_registration', $labels, $this );
215
- }
216
  }
1
  <?php
2
+ /** MainWP Child Reports connectors. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connectors.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connectors {
11
  /**
12
  * Hold Plugin class
93
  'mainwp-wordfence',
94
  );
95
 
96
+ $is_dashboard_request = wp_mainwp_stream_is_dashboard_request();
97
+
98
  $classes = array();
99
  foreach ( $connectors as $connector ) {
100
  include_once $this->plugin->locations['dir'] . '/connectors/class-connector-' . $connector . '.php';
101
+ $class_name = sprintf( '\WP_MainWP_Stream\Connector_%s', str_replace( '-', '_', $connector ) );
102
+ if ( ! class_exists( $class_name ) ) {
103
  continue;
104
  }
105
  $class = new $class_name( $this->plugin->log );
110
  }
111
 
112
  // Check if the Connector is allowed to be registered in the WP Admin
113
+ if ( is_admin() && ! $class->register_admin && ! $is_dashboard_request ) {
114
  continue;
115
  }
116
 
117
  // Check if the Connector is allowed to be registered in the WP Frontend
118
+ if ( ! is_admin() && ! $class->register_frontend && ! $is_dashboard_request ) {
119
  continue;
120
  }
121
 
220
  * @param Connectors $connectors The Connectors object
221
  */
222
  do_action( 'wp_mainwp_stream_after_connectors_registration', $labels, $this );
223
+ }
224
  }
classes/class-date-interval.php CHANGED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
4
  // Load Carbon to Handle dates much easier
@@ -8,6 +10,10 @@ if ( ! class_exists( 'Carbon\Carbon' ) ) {
8
 
9
  use Carbon\Carbon;
10
 
 
 
 
 
11
  class Date_Interval {
12
  /**
13
  * Contains an array of all available intervals
@@ -25,7 +31,9 @@ class Date_Interval {
25
  }
26
 
27
  /**
28
- * @return mixed
 
 
29
  */
30
  public function get_predefined_intervals() {
31
  $timezone = get_option( 'timezone_string' );
1
  <?php
2
+ /** MainWP Child Reports date intervals. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
  // Load Carbon to Handle dates much easier
10
 
11
  use Carbon\Carbon;
12
 
13
+ /**
14
+ * Class Date_Interval.
15
+ * @package WP_MainWP_Stream
16
+ */
17
  class Date_Interval {
18
  /**
19
  * Contains an array of all available intervals
31
  }
32
 
33
  /**
34
+ * Get predefined intervals.
35
+ *
36
+ * @return mixed Predefined intervals.
37
  */
38
  public function get_predefined_intervals() {
39
  $timezone = get_option( 'timezone_string' );
classes/class-db-driver-wpdb.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class DB_Driver_WPDB implements DB_Driver {
5
  /**
6
  * Holds Query class
@@ -29,7 +35,9 @@ class DB_Driver_WPDB implements DB_Driver {
29
  public function __construct() {
30
  $this->query = new Query( $this );
31
 
 
32
  global $wpdb;
 
33
  $prefix = apply_filters( 'wp_mainwp_stream_db_tables_prefix', $wpdb->base_prefix );
34
 
35
  $this->table = $prefix . 'mainwp_stream';
@@ -38,7 +46,7 @@ class DB_Driver_WPDB implements DB_Driver {
38
  $wpdb->mainwp_stream = $this->table;
39
  $wpdb->mainwp_streammeta = $this->table_meta;
40
 
41
- // Hack for get_metadata
42
  $wpdb->recordmeta = $this->table_meta;
43
  }
44
 
@@ -50,6 +58,8 @@ class DB_Driver_WPDB implements DB_Driver {
50
  * @return int
51
  */
52
  public function insert_record( $data ) {
 
 
53
  global $wpdb;
54
 
55
  if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
@@ -86,6 +96,8 @@ class DB_Driver_WPDB implements DB_Driver {
86
  * @return array
87
  */
88
  public function insert_meta( $record_id, $key, $val ) {
 
 
89
  global $wpdb;
90
 
91
  $result = $wpdb->insert(
@@ -123,7 +135,10 @@ class DB_Driver_WPDB implements DB_Driver {
123
  * @return array
124
  */
125
  public function get_column_values( $column ) {
 
 
126
  global $wpdb;
 
127
  return (array) $wpdb->get_results(
128
  "SELECT DISTINCT $column FROM $wpdb->mainwp_stream", // @codingStandardsIgnoreLine can't prepare column name
129
  'ARRAY_A'
1
  <?php
2
+ /** MainWP Child Reports WPDB Driver. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class DB_Driver_WPDB.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class DB_Driver_WPDB implements DB_Driver {
11
  /**
12
  * Holds Query class
35
  public function __construct() {
36
  $this->query = new Query( $this );
37
 
38
+ /** @global object $wpdb WordPress Database instance. */
39
  global $wpdb;
40
+
41
  $prefix = apply_filters( 'wp_mainwp_stream_db_tables_prefix', $wpdb->base_prefix );
42
 
43
  $this->table = $prefix . 'mainwp_stream';
46
  $wpdb->mainwp_stream = $this->table;
47
  $wpdb->mainwp_streammeta = $this->table_meta;
48
 
49
+ // Hack for get_metadata.
50
  $wpdb->recordmeta = $this->table_meta;
51
  }
52
 
58
  * @return int
59
  */
60
  public function insert_record( $data ) {
61
+
62
+ /** @global object $wpdb WordPress Database instance. */
63
  global $wpdb;
64
 
65
  if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
96
  * @return array
97
  */
98
  public function insert_meta( $record_id, $key, $val ) {
99
+
100
+ /** @global object $wpdb WordPress Database instance. */
101
  global $wpdb;
102
 
103
  $result = $wpdb->insert(
135
  * @return array
136
  */
137
  public function get_column_values( $column ) {
138
+
139
+ /** @global object $wpdb WordPress Database instance. */
140
  global $wpdb;
141
+
142
  return (array) $wpdb->get_results(
143
  "SELECT DISTINCT $column FROM $wpdb->mainwp_stream", // @codingStandardsIgnoreLine can't prepare column name
144
  'ARRAY_A'
classes/class-db-driver.php CHANGED
@@ -1,6 +1,11 @@
1
  <?php
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  interface DB_Driver {
5
  /**
6
  * Insert a record
1
  <?php
2
+ /** MainWP Child Reports database driver. */
3
  namespace WP_MainWP_Stream;
4
 
5
+ /**
6
+ * Interface DB_Driver.
7
+ * @package WP_MainWP_Stream
8
+ */
9
  interface DB_Driver {
10
  /**
11
  * Insert a record
classes/class-db.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class DB {
5
  /**
6
  * Hold the Driver class
@@ -26,10 +32,11 @@ class DB {
26
  */
27
  public function __construct( $driver ) {
28
  $this->driver = $driver;
29
-
 
30
  global $wpdb;
31
 
32
- $this->wpdb = &$wpdb;
33
 
34
  }
35
 
1
  <?php
2
+ /** MainWP Child Reports Database. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class DB.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class DB {
11
  /**
12
  * Hold the Driver class
32
  */
33
  public function __construct( $driver ) {
34
  $this->driver = $driver;
35
+
36
+ /** @global object $wpdb WordPress Database instance. */
37
  global $wpdb;
38
 
39
+ $this->wpdb = &$wpdb;
40
 
41
  }
42
 
classes/class-export.php CHANGED
@@ -1,6 +1,11 @@
1
  <?php
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Export {
5
  /**
6
  * Hold Plugin class
@@ -71,14 +76,18 @@ class Export {
71
  }
72
 
73
  /**
74
- * Add Export options to record actions menu
75
- *
76
- * @return array
 
 
 
 
77
  */
78
  public function actions_menu_export_items( $action_menu_items ) {
79
  foreach ( $this->get_exporters() as $exporter ) {
80
  $action = 'export-' . $exporter->slug;
81
- // translators: Placeholder refers to an export format (e.g. "CSV")
82
  $action_menu_items[ $action ] = sprintf( __( 'Export as %s', 'mainwp-child-reports' ), $exporter->name );
83
  }
84
 
1
  <?php
2
+ /** MainWP Child Reports export. */
3
  namespace WP_MainWP_Stream;
4
 
5
+ /**
6
+ * Class Export.
7
+ * @package WP_MainWP_Stream
8
+ */
9
  class Export {
10
  /**
11
  * Hold Plugin class
76
  }
77
 
78
  /**
79
+ * Add Export options to record actions menu.
80
+ *
81
+ * @param array $action_menu_items Action menu items.
82
+ *
83
+ * @return array $action_menu_items Return Action Menu Items.
84
+ *
85
+ * @uses \WP_MainWP_Stream\Author::get_exporters()
86
  */
87
  public function actions_menu_export_items( $action_menu_items ) {
88
  foreach ( $this->get_exporters() as $exporter ) {
89
  $action = 'export-' . $exporter->slug;
90
+ // translators: Placeholder refers to an export format (e.g. "CSV").
91
  $action_menu_items[ $action ] = sprintf( __( 'Export as %s', 'mainwp-child-reports' ), $exporter->name );
92
  }
93
 
classes/class-exporter.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  abstract class Exporter {
5
  /**
6
  * Exporter name
1
  <?php
2
+ /** MainWP Child Reports Exporter. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Exporter.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  abstract class Exporter {
11
  /**
12
  * Exporter name
classes/class-filter-input.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Filter_Input {
 
 
5
  public static $filter_callbacks = array(
6
  FILTER_DEFAULT => null,
7
- // Validate
8
  FILTER_VALIDATE_BOOLEAN => 'is_bool',
9
  FILTER_VALIDATE_EMAIL => 'is_email',
10
  FILTER_VALIDATE_FLOAT => 'is_float',
@@ -12,7 +20,7 @@ class Filter_Input {
12
  FILTER_VALIDATE_IP => array( __CLASS__, 'is_ip_address' ),
13
  FILTER_VALIDATE_REGEXP => array( __CLASS__, 'is_regex' ),
14
  FILTER_VALIDATE_URL => 'wp_http_validate_url',
15
- // Sanitize
16
  FILTER_SANITIZE_EMAIL => 'sanitize_email',
17
  FILTER_SANITIZE_ENCODED => 'esc_url_raw',
18
  FILTER_SANITIZE_NUMBER_FLOAT => 'floatval',
@@ -20,10 +28,20 @@ class Filter_Input {
20
  FILTER_SANITIZE_SPECIAL_CHARS => 'htmlspecialchars',
21
  FILTER_SANITIZE_STRING => 'sanitize_text_field',
22
  FILTER_SANITIZE_URL => 'esc_url_raw',
23
- // Other
24
  FILTER_UNSAFE_RAW => null,
25
  );
26
 
 
 
 
 
 
 
 
 
 
 
27
  public static function super( $type, $variable_name, $filter = null, $options = array() ) {
28
  $super = null;
29
 
@@ -57,7 +75,17 @@ class Filter_Input {
57
  return $var;
58
  }
59
 
 
 
 
 
 
 
 
 
 
60
  public static function filter( $var, $filter = null, $options = array() ) {
 
61
  // Default filter is a sanitizer, not validator
62
  $filter_type = 'sanitizer';
63
 
@@ -70,9 +98,11 @@ class Filter_Input {
70
  $filter_callback = self::$filter_callbacks[ $filter ];
71
  $result = call_user_func( $filter_callback, $var );
72
 
73
- // filter_var / filter_input treats validation/sanitization filters the same
74
- // they both return output and change the var value, this shouldn't be the case here.
75
- // We'll do a boolean check on validation function, and let sanitizers change the value
 
 
76
  $filter_type = ( $filter < 500 ) ? 'validator' : 'sanitizer';
77
  if ( 'validator' === $filter_type ) { // Validation functions
78
  if ( ! $result ) {
@@ -83,7 +113,7 @@ class Filter_Input {
83
  }
84
  }
85
 
86
- // Detect FILTER_REQUIRE_ARRAY flag
87
  if ( isset( $var ) && is_int( $options ) && FILTER_REQUIRE_ARRAY === $options ) {
88
  if ( ! is_array( $var ) ) {
89
  $var = ( 'validator' === $filter_type ) ? false : null;
@@ -102,6 +132,12 @@ class Filter_Input {
102
  return $var;
103
  }
104
 
 
 
 
 
 
 
105
  public static function is_regex( $var ) {
106
  // @codingStandardsIgnoreStart
107
  $test = @preg_match( $var, '' );
@@ -110,6 +146,13 @@ class Filter_Input {
110
  return false !== $test;
111
  }
112
 
 
 
 
 
 
 
 
113
  public static function is_ip_address( $var ) {
114
  return false !== \WP_Http::is_ip_address( $var );
115
  }
1
  <?php
2
+ /** MainWP Child Reports filter input. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Filter_Input.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Filter_Input {
11
+
12
+ /** @var array $filter_callbacks Array of filter callbacks. */
13
  public static $filter_callbacks = array(
14
  FILTER_DEFAULT => null,
15
+ // Validate.
16
  FILTER_VALIDATE_BOOLEAN => 'is_bool',
17
  FILTER_VALIDATE_EMAIL => 'is_email',
18
  FILTER_VALIDATE_FLOAT => 'is_float',
20
  FILTER_VALIDATE_IP => array( __CLASS__, 'is_ip_address' ),
21
  FILTER_VALIDATE_REGEXP => array( __CLASS__, 'is_regex' ),
22
  FILTER_VALIDATE_URL => 'wp_http_validate_url',
23
+ // Sanitize.
24
  FILTER_SANITIZE_EMAIL => 'sanitize_email',
25
  FILTER_SANITIZE_ENCODED => 'esc_url_raw',
26
  FILTER_SANITIZE_NUMBER_FLOAT => 'floatval',
28
  FILTER_SANITIZE_SPECIAL_CHARS => 'htmlspecialchars',
29
  FILTER_SANITIZE_STRING => 'sanitize_text_field',
30
  FILTER_SANITIZE_URL => 'esc_url_raw',
31
+ // Other.
32
  FILTER_UNSAFE_RAW => null,
33
  );
34
 
35
+ /**
36
+ * Input type checker.
37
+ *
38
+ * @param $type
39
+ * @param $variable_name
40
+ * @param null $filter
41
+ * @param array $options
42
+ * @return array|bool|mixed|null
43
+ * @throws \Exception
44
+ */
45
  public static function super( $type, $variable_name, $filter = null, $options = array() ) {
46
  $super = null;
47
 
75
  return $var;
76
  }
77
 
78
+ /**
79
+ * Filter & sanitiser.
80
+ *
81
+ * @param $var
82
+ * @param null $filter
83
+ * @param array $options
84
+ * @return array|bool|mixed|null
85
+ * @throws \Exception
86
+ */
87
  public static function filter( $var, $filter = null, $options = array() ) {
88
+
89
  // Default filter is a sanitizer, not validator
90
  $filter_type = 'sanitizer';
91
 
98
  $filter_callback = self::$filter_callbacks[ $filter ];
99
  $result = call_user_func( $filter_callback, $var );
100
 
101
+ /**
102
+ * filter_var / filter_input treats validation/sanitization filters the same.
103
+ * They both return output and change the var value, this shouldn't be the case here.
104
+ * We'll do a boolean check on validation function, and let sanitizers change the value.
105
+ */
106
  $filter_type = ( $filter < 500 ) ? 'validator' : 'sanitizer';
107
  if ( 'validator' === $filter_type ) { // Validation functions
108
  if ( ! $result ) {
113
  }
114
  }
115
 
116
+ // Detect FILTER_REQUIRE_ARRAY flag.
117
  if ( isset( $var ) && is_int( $options ) && FILTER_REQUIRE_ARRAY === $options ) {
118
  if ( ! is_array( $var ) ) {
119
  $var = ( 'validator' === $filter_type ) ? false : null;
132
  return $var;
133
  }
134
 
135
+ /**
136
+ * Check if subject is equal to $var.
137
+ *
138
+ * @param string $var Pregmatch pattern.
139
+ * @return bool Return FALSE if $test equals false.
140
+ */
141
  public static function is_regex( $var ) {
142
  // @codingStandardsIgnoreStart
143
  $test = @preg_match( $var, '' );
146
  return false !== $test;
147
  }
148
 
149
+ /**
150
+ * Check for IP address.
151
+ *
152
+ * @param string $var String to check for IP address.
153
+ *
154
+ * @return bool Return FASLE if not an IP address.
155
+ */
156
  public static function is_ip_address( $var ) {
157
  return false !== \WP_Http::is_ip_address( $var );
158
  }
classes/class-form-generator.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Form_Generator {
5
 
6
  /**
1
  <?php
2
+ /** MainWP Child Reports form generator. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Form_Generator.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Form_Generator {
11
 
12
  /**
classes/class-install.php CHANGED
@@ -1,58 +1,42 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Install {
5
- /**
6
- * Hold Plugin class
7
- * @var Plugin
8
- */
9
  public $plugin;
10
 
11
- /**
12
- * Option key to store database version
13
- *
14
- * @var string
15
- */
16
  public $option_key = 'wp_mainwp_stream_db';
17
 
18
- /**
19
- * Holds version of database at last update
20
- *
21
- * @var string
22
- */
23
  public $db_version;
24
 
25
- /**
26
- * URL to the Stream Admin settings page.
27
- *
28
- * @var string
29
- */
30
  public $stream_url;
31
 
32
- /**
33
- * Array of version numbers that require database update
34
- *
35
- * @var array
36
- */
37
  public $update_versions;
38
 
39
- /**
40
- * Holds status of whether it's safe to run Stream or not
41
- *
42
- * @var bool
43
- */
44
  public $update_required = false;
45
 
46
- /**
47
- * Holds status of whether the database update worked
48
- *
49
- * @var bool
50
- */
51
  public $success_db;
52
 
53
- /**
54
- * Class constructor
55
- */
 
 
 
 
56
  public function __construct( $plugin ) {
57
  $this->plugin = $plugin;
58
 
@@ -74,8 +58,14 @@ class Install {
74
  * If database update required admin notice will be given
75
  * on the plugin update screen
76
  *
77
- * @return void
78
- */
 
 
 
 
 
 
79
  public function check() {
80
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
81
  return;
@@ -128,7 +118,17 @@ class Install {
128
  $this->update_db_option();
129
  }
130
 
 
 
 
 
 
 
 
 
131
  public function recreate_tables_if_not_exist() {
 
 
132
  global $wpdb;
133
 
134
  check_ajax_referer( 'stream_nonce_reset', 'wp_mainwp_stream_nonce_reset' );
@@ -146,7 +146,7 @@ class Install {
146
  if ( $missing_tables ) {
147
  $this->install( $this->plugin->get_version() );
148
 
149
- // for debugging only
150
  // if( $wpdb->last_error !== '') :
151
  // $str = htmlspecialchars( $wpdb->last_result, ENT_QUOTES );
152
  // $query = htmlspecialchars( $wpdb->last_query, ENT_QUOTES );
@@ -159,16 +159,20 @@ class Install {
159
 
160
  /**
161
  * Verify that the required DB tables exists
162
- *
163
- * @return void
 
 
 
164
  */
165
  public function verify_db() {
 
166
  /**
167
  * Filter will halt install() if set to true
168
  *
169
- * @param bool
170
  *
171
- * @return bool
172
  */
173
  if ( apply_filters( 'wp_mainwp_stream_no_tables', false ) ) {
174
  return;
@@ -183,12 +187,13 @@ class Install {
183
  */
184
  do_action( 'wp_mainwp_stream_before_db_notices' );
185
 
 
186
  global $wpdb;
187
 
188
  $database_message = '';
189
  $uninstall_message = '';
190
 
191
- // Check if all needed DB is present
192
  $missing_tables = array();
193
 
194
  foreach ( $this->plugin->db->get_table_names() as $table_name ) {
@@ -277,8 +282,12 @@ class Install {
277
  update_option( $this->option_key . '_registered_connectors', $current_versions );
278
  }
279
  }
280
-
281
-
 
 
 
 
282
  public static function get_old_child_report_db_version() {
283
 
284
  $version = get_site_option( 'mainwp_child_reports_db' );
@@ -287,14 +296,20 @@ class Install {
287
  }
288
 
289
  /**
290
- * @return string
 
 
291
  */
292
  public function get_db_version() {
293
  return get_site_option( $this->option_key );
294
  }
295
 
296
  /**
 
 
297
  * @return void
 
 
298
  */
299
  public function update_db_option() {
300
  if ( $this->success_db ) {
@@ -316,11 +331,14 @@ class Install {
316
  }
317
 
318
  /**
319
- * Added to the admin_notices hook when file plugin version is higher than database plugin version
320
  *
321
  * @action admin_notices
322
  *
323
  * @return void
 
 
 
324
  */
325
  public function update_notice_hook() {
326
  if ( ! current_user_can( $this->plugin->admin->view_cap ) ) {
@@ -344,7 +362,7 @@ class Install {
344
  }
345
 
346
  /**
347
- * Action hook callback function
348
  *
349
  * Adds the user controlled database upgrade routine to the plugins updated page.
350
  * When database update is complete page will refresh with dismissible message to user.
@@ -371,6 +389,9 @@ class Install {
371
  * updates the stream_db version number in the database and outputs a success and continue message
372
  *
373
  * @return void
 
 
 
374
  */
375
  public function prompt_update_status() {
376
  check_admin_referer( 'wp_mainwp_stream_update_db' );
@@ -397,14 +418,14 @@ class Install {
397
  }
398
 
399
  /**
400
- * Array of database versions that require and updates
401
  *
402
  * To add your own stream extension database update routine
403
- * use the filter and return the version that requires an update
404
  * You must also make the callback function available in the global namespace on plugins loaded
405
- * use the wp_mainwp_stream_update_{version_number} version number must be a string of characters that represent the version with no periods
406
  *
407
- * @return array
408
  */
409
  public function db_update_versions() {
410
  $db_update_versions = array(
@@ -418,21 +439,23 @@ class Install {
418
  /**
419
  * Filter to alter the DB update versions array
420
  *
421
- * @param array $db_update_versions
422
  *
423
- * @return array
424
  */
425
  return apply_filters( 'wp_mainwp_stream_db_update_versions', $db_update_versions );
426
  }
427
 
428
  /**
429
- * Database user controlled update routine
430
  *
431
- * @param int $db_version
432
- * @param int $current_version
433
- * @param array $update_args
434
  *
435
- * @return mixed Version number on success, true on no update needed, mysql error message on error
 
 
436
  */
437
  public function update( $db_version, $current_version, $update_args ) {
438
  $versions = $this->db_update_versions();
@@ -458,13 +481,18 @@ class Install {
458
  }
459
 
460
  /**
461
- * Initial database install routine
462
  *
463
- * @param string $current_version
464
  *
465
- * @return string
 
 
 
466
  */
467
  public function install( $current_version ) {
 
 
468
  global $wpdb;
469
 
470
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
1
  <?php
2
+ /** MainWP Child Reports install. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Install.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Install {
11
+
12
+ /** @var Plugin Hold Plugin class. */
 
 
13
  public $plugin;
14
 
15
+ /** @var string Option key to store database version. */
 
 
 
 
16
  public $option_key = 'wp_mainwp_stream_db';
17
 
18
+ /** @var string Holds version of database at last update */
 
 
 
 
19
  public $db_version;
20
 
21
+ /** @var string URL to the Stream Admin settings page. */
 
 
 
 
22
  public $stream_url;
23
 
24
+ /** @var array Array of version numbers that require database update. */
 
 
 
 
25
  public $update_versions;
26
 
27
+ /** @var bool Holds status of whether it's safe to run Stream or not. */
 
 
 
 
28
  public $update_required = false;
29
 
30
+ /** @var bool Holds status of whether the database update worked */
 
 
 
 
31
  public $success_db;
32
 
33
+ /**
34
+ * Install constructor.
35
+ *
36
+ * @param object $plugin Plugin class.
37
+ *
38
+ * @uses \WP_MainWP_Stream\Install::get_db_version()
39
+ */
40
  public function __construct( $plugin ) {
41
  $this->plugin = $plugin;
42
 
58
  * If database update required admin notice will be given
59
  * on the plugin update screen
60
  *
61
+ * @return
62
+ *
63
+ * @uses \WP_MainWP_Stream\Install::$plugin::get_version()
64
+ * @uses \WP_MainWP_Stream\Install::get_old_child_report_db_version()
65
+ * @uses \WP_MainWP_Stream\Install::update()
66
+ * @uses \WP_MainWP_Stream\Install::db_update_versions()
67
+ * @uses \WP_MainWP_Stream\Install::update_db_option()
68
+ */
69
  public function check() {
70
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
71
  return;
118
  $this->update_db_option();
119
  }
120
 
121
+ /**
122
+ * Recreate database tables if they do not already exist.
123
+ *
124
+ * @uses \WP_MainWP_Stream\Install::$plugin::db::get_table_names()
125
+ * @uses \WP_MainWP_Stream\Install::$plugin::get_version()
126
+ * @uses $wpdb::get_var()
127
+ * @uses $wpdb::prepare()
128
+ */
129
  public function recreate_tables_if_not_exist() {
130
+
131
+ /** @global object $wpdb WordPress Database. */
132
  global $wpdb;
133
 
134
  check_ajax_referer( 'stream_nonce_reset', 'wp_mainwp_stream_nonce_reset' );
146
  if ( $missing_tables ) {
147
  $this->install( $this->plugin->get_version() );
148
 
149
+ // for debugging only.
150
  // if( $wpdb->last_error !== '') :
151
  // $str = htmlspecialchars( $wpdb->last_result, ENT_QUOTES );
152
  // $query = htmlspecialchars( $wpdb->last_query, ENT_QUOTES );
159
 
160
  /**
161
  * Verify that the required DB tables exists
162
+ *
163
+ * @uses \WP_MainWP_Stream\Install::$plugin::db::get_table_names()
164
+ * @uses \WP_MainWP_Stream\Install::$plugin::admin::notice()
165
+ * @uses $wpdb::get_var()
166
+ * @uses $wpdb::prepare()
167
  */
168
  public function verify_db() {
169
+
170
  /**
171
  * Filter will halt install() if set to true
172
  *
173
+ * @param bool Whether or not to halt installation. Default: FALSE.
174
  *
175
+ * @return bool Return TRUE or FALSE.
176
  */
177
  if ( apply_filters( 'wp_mainwp_stream_no_tables', false ) ) {
178
  return;
187
  */
188
  do_action( 'wp_mainwp_stream_before_db_notices' );
189
 
190
+ /** @global object $wpdb WordPress Database. */
191
  global $wpdb;
192
 
193
  $database_message = '';
194
  $uninstall_message = '';
195
 
196
+ // Check if all needed DB is present.
197
  $missing_tables = array();
198
 
199
  foreach ( $this->plugin->db->get_table_names() as $table_name ) {
282
  update_option( $this->option_key . '_registered_connectors', $current_versions );
283
  }
284
  }
285
+
286
+ /**
287
+ * Get Child Reports old database version.
288
+ *
289
+ * @return string $version MainWP Child Reports old database version.
290
+ */
291
  public static function get_old_child_report_db_version() {
292
 
293
  $version = get_site_option( 'mainwp_child_reports_db' );
296
  }
297
 
298
  /**
299
+ * Get MainWP Child Reports Database version.
300
+ *
301
+ * @return string MainWP child Reports database version.
302
  */
303
  public function get_db_version() {
304
  return get_site_option( $this->option_key );
305
  }
306
 
307
  /**
308
+ * Update MaiNWP Child Reports database version.
309
+ *
310
  * @return void
311
+ *
312
+ * @uses \WP_MainWP_Stream\Install::$plugin::get_version()
313
  */
314
  public function update_db_option() {
315
  if ( $this->success_db ) {
331
  }
332
 
333
  /**
334
+ * Added to the admin_notices hook when plugin file version is higher than database plugin version.
335
  *
336
  * @action admin_notices
337
  *
338
  * @return void
339
+ *
340
+ * @uses \WP_MainWP_Stream\Install::prompt_update()
341
+ * @uses \WP_MainWP_Stream\Install::prompt_update_status()
342
  */
343
  public function update_notice_hook() {
344
  if ( ! current_user_can( $this->plugin->admin->view_cap ) ) {
362
  }
363
 
364
  /**
365
+ * Action hook callback function.
366
  *
367
  * Adds the user controlled database upgrade routine to the plugins updated page.
368
  * When database update is complete page will refresh with dismissible message to user.
389
  * updates the stream_db version number in the database and outputs a success and continue message
390
  *
391
  * @return void
392
+ *
393
+ * @uses \WP_MainWP_Stream\Install::update_db_option()
394
+ * @uses \WP_MainWP_Stream\Install::$plugin::get_version()
395
  */
396
  public function prompt_update_status() {
397
  check_admin_referer( 'wp_mainwp_stream_update_db' );
418
  }
419
 
420
  /**
421
+ * Array of database versions that require and updates.
422
  *
423
  * To add your own stream extension database update routine
424
+ * use the filter and return the version that requires an update.
425
  * You must also make the callback function available in the global namespace on plugins loaded
426
+ * use the wp_mainwp_stream_update_{version_number} version number must be a string of characters that represent the version with no periods.
427
  *
428
+ * @return array Return Database update versions array.
429
  */
430
  public function db_update_versions() {
431
  $db_update_versions = array(
439
  /**
440
  * Filter to alter the DB update versions array
441
  *
442
+ * @param array $db_update_versions Updated database versions.
443
  *
444
+ * @return array Return updated database versions.
445
  */
446
  return apply_filters( 'wp_mainwp_stream_db_update_versions', $db_update_versions );
447
  }
448
 
449
  /**
450
+ * Database user controlled update routine.
451
  *
452
+ * @param int $db_version New database version.
453
+ * @param int $current_version Current database version .
454
+ * @param array $update_args Update arguments.
455
  *
456
+ * @return mixed Version number on success, true on no update needed, mysql error message on error.
457
+ *
458
+ * @uses \WP_MainWP_Stream\Install::db_update_versions()
459
  */
460
  public function update( $db_version, $current_version, $update_args ) {
461
  $versions = $this->db_update_versions();
481
  }
482
 
483
  /**
484
+ * Initial database install routine.
485
  *
486
+ * @param string $current_version Current version.
487
  *
488
+ * @return string $current_version Current version.
489
+ *
490
+ * @uses \WP_MainWP_Stream\Install::plugin::get_version()
491
+ * @uses \dbDelta()
492
  */
493
  public function install( $current_version ) {
494
+
495
+ /** @global object $wpdb WordPress Database. */
496
  global $wpdb;
497
 
498
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
classes/class-list-table.php CHANGED
@@ -1,21 +1,24 @@
1
  <?php
 
2
 
3
  namespace WP_MainWP_Stream;
4
 
 
 
 
 
 
 
5
  class List_Table extends \WP_List_Table {
6
 
7
- /**
8
- * Hold Plugin class
9
- *
10
- * @var Plugin
11
- */
12
  public $plugin;
13
 
14
  /**
15
  * Class constructor.
16
  *
17
  * @param Plugin $plugin The main Plugin class.
18
- * @param array $args
19
  */
20
  public function __construct( $plugin, $args = array() ) {
21
  $this->plugin = $plugin;
@@ -23,7 +26,7 @@ class List_Table extends \WP_List_Table {
23
  $screen_id = isset( $args['screen'] ) ? $args['screen'] : null;
24
 
25
  /**
26
- * Filter the list table screen ID
27
  *
28
  * @return string
29
  */
@@ -46,7 +49,7 @@ class List_Table extends \WP_List_Table {
46
  )
47
  );
48
 
49
- // Check for default hidden columns
50
  $this->get_hidden_columns();
51
 
52
  add_filter( 'screen_settings', array(
@@ -61,13 +64,21 @@ class List_Table extends \WP_List_Table {
61
  set_screen_options();
62
  }
63
 
64
- public function extra_tablenav( $which ) {
 
 
 
 
 
65
  if ( 'top' === $which ) {
66
  echo $this->filters_form(); // xss ok
67
  }
68
  }
69
 
70
- public function no_items() {
 
 
 
71
  ?>
72
  <div class="stream-list-table-no-items">
73
  <p><?php esc_html_e( 'Sorry, no activity records were found.', 'mainwp-child-reports' ); ?></p>
@@ -75,12 +86,14 @@ class List_Table extends \WP_List_Table {
75
  <?php
76
  }
77
 
78
- public function get_columns() {
79
- /**
80
- * Allows devs to add new columns to table
81
- *
82
- * @return array
83
- */
 
 
84
  return apply_filters(
85
  'wp_mainwp_stream_list_table_columns',
86
  array(
@@ -94,21 +107,31 @@ class List_Table extends \WP_List_Table {
94
  );
95
  }
96
 
97
- public function get_sortable_columns() {
 
 
 
 
 
98
  return array(
99
  'date' => array( 'date', false ),
100
  );
101
  }
102
 
103
- public function get_hidden_columns() {
 
 
 
 
 
104
  $user = wp_get_current_user();
105
  if ( ! $user ) {
106
  return array();
107
  }
108
- // Directly checking the user meta; to check whether user has changed screen option or not
109
  $hidden = $this->plugin->admin->get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true );
110
 
111
- // If user meta is not found; add the default hidden column 'id'
112
  if ( ! $hidden ) {
113
  $hidden = array( 'id' );
114
  $this->plugin->admin->update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden );
@@ -117,7 +140,10 @@ class List_Table extends \WP_List_Table {
117
  return $hidden;
118
  }
119
 
120
- public function prepare_items() {
 
 
 
121
  $columns = $this->get_columns();
122
  $sortable = $this->get_sortable_columns();
123
  $hidden = $this->get_hidden_columns();
@@ -142,10 +168,15 @@ class List_Table extends \WP_List_Table {
142
  );
143
  }
144
 
145
- public function get_records() {
 
 
 
 
 
146
  $args = array();
147
 
148
- // Parse sorting params
149
  $order = wp_mainwp_stream_filter_input( INPUT_GET, 'order' );
150
  if ( $order ) {
151
  $args['order'] = $order;
@@ -187,11 +218,11 @@ class List_Table extends \WP_List_Table {
187
  'action',
188
  );
189
 
190
- // Add property fields to defaults, including their __in/__not_in variations
191
  foreach ( $properties as $property ) {
192
  $value = wp_mainwp_stream_filter_input( INPUT_GET, $property );
193
 
194
- // Allow 0 values
195
  if ( isset( $value ) && '' !== $value && false !== $value ) {
196
  $args[ $property ] = $value;
197
  }
@@ -227,15 +258,22 @@ class List_Table extends \WP_List_Table {
227
  }
228
 
229
  /**
230
- * Get last query found rows
231
  *
232
- * @return integer
233
  */
234
  public function get_total_found_rows() {
235
  return $this->plugin->db->get_found_records_count();
236
  }
237
 
238
- public function column_default( $item, $column_name ) {
 
 
 
 
 
 
 
239
  $out = '';
240
  $record = new Record( $item );
241
 
@@ -255,7 +293,7 @@ class List_Table extends \WP_List_Table {
255
  case 'summary':
256
  $out = $record->summary;
257
  $object_title = $record->get_object_title();
258
- // translators: Placeholder refers to the title of any object, like a Post (e.g. "Hello World")
259
  $view_all_text = $object_title ? sprintf( esc_html__( 'View all activity for "%s"', 'mainwp-child-reports' ), esc_attr( $object_title ) ) : esc_html__( 'View all activity for this object', 'mainwp-child-reports' );
260
 
261
  if ( $record->object_id ) {
@@ -325,7 +363,7 @@ class List_Table extends \WP_List_Table {
325
  default:
326
  /**
327
  * Registers new Columns to be inserted into the table. The cell contents of this column is set
328
- * below with 'wp_mainwp_stream_insert_column_default_'
329
  *
330
  * @return array
331
  */
@@ -337,16 +375,16 @@ class List_Table extends \WP_List_Table {
337
  /**
338
  * If column title inserted via wp_mainwp_stream_register_column_defaults ($column_title) exists
339
  * among columns registered with get_columns ($column_name) and there is an action associated
340
- * with this column, do the action
341
  *
342
  * Also, note that the action name must include the $column_title registered
343
- * with wp_mainwp_stream_register_column_defaults
344
  */
345
  if ( $column_title === $column_name && has_filter( "wp_mainwp_stream_insert_column_default_{$column_title}" ) ) {
346
  /**
347
  * Allows for the addition of content under a specified column.
348
  *
349
- * @param object $record Contents of the row
350
  *
351
  * @return string
352
  */
@@ -360,8 +398,8 @@ class List_Table extends \WP_List_Table {
360
  }
361
  }
362
 
363
- $allowed_tags = wp_kses_allowed_html( 'post' );
364
- $allowed_tags['time'] = array(
365
  'datetime' => true,
366
  'class' => true,
367
  );
@@ -370,11 +408,17 @@ class List_Table extends \WP_List_Table {
370
  echo wp_kses( $out, $allowed_tags );
371
  }
372
 
373
- public function get_action_links( $record ) {
 
 
 
 
 
 
374
  $out = '';
375
 
376
  /**
377
- * Filter allows modification of action links for a specific connector
378
  *
379
  * @param array
380
  * @param Record
@@ -384,7 +428,7 @@ class List_Table extends \WP_List_Table {
384
  $action_links = apply_filters( 'wp_mainwp_stream_action_links_' . $record->connector, array(), $record );
385
 
386
  /**
387
- * Filter allows addition of custom links for a specific connector
388
  *
389
  * @param array
390
  * @param Record
@@ -423,7 +467,16 @@ class List_Table extends \WP_List_Table {
423
  return $out;
424
  }
425
 
426
- public function column_link( $display, $key, $value = null, $title = null ) {
 
 
 
 
 
 
 
 
 
427
  $url = add_query_arg(
428
  array(
429
  'page' => $this->plugin->admin->records_page_slug,
@@ -447,7 +500,14 @@ class List_Table extends \WP_List_Table {
447
  );
448
  }
449
 
450
- public function get_term_title( $term, $type ) {
 
 
 
 
 
 
 
451
  if ( ! isset( $this->plugin->connectors->term_labels[ 'stream_' . $type ][ $term ] ) ) {
452
  return $term;
453
  }
@@ -456,22 +516,22 @@ class List_Table extends \WP_List_Table {
456
  }
457
 
458
  /**
459
- * Assembles records for display in search filters
460
  *
461
  * Gathers list of all users/connectors, then compares it to
462
  * results of existing records. All items that do not exist in records
463
  * get assigned a disabled value of "true".
464
  *
465
- * @param string $column List table column name
466
  *
467
- * @return array Options to be displayed in search filters
468
- */
 
469
  public function assemble_records( $column ) {
470
- // @todo eliminate special condition for authors, especially using a WP_User object as the value; should use string or stringifiable object
471
  if ( 'user_id' === $column ) {
472
  $all_records = array();
473
 
474
- // If the number of users exceeds the max users constant value then return an empty array and use AJAX instead
475
  $user_count = count_users();
476
  $total_users = $user_count['total_users'];
477
 
@@ -508,7 +568,7 @@ class List_Table extends \WP_List_Table {
508
  },
509
  get_super_admins()
510
  );
511
- $users = array_unique( array_merge( $users, $super_admins ) );
512
  }
513
 
514
  $users[] = new Author(
@@ -543,7 +603,7 @@ class List_Table extends \WP_List_Table {
543
  }
544
  }
545
 
546
- // Remove WP-CLI pseudo user if no records with user=0 exist
547
  if ( isset( $disabled_records[0] ) ) {
548
  unset( $disabled_records[0] );
549
  }
@@ -562,13 +622,18 @@ class List_Table extends \WP_List_Table {
562
  uasort( $active_records, $sort );
563
  uasort( $disabled_records, $sort );
564
 
565
- // Not using array_merge() in order to preserve the array index for the users dropdown which uses the user_id as the key
566
  $all_records = $active_records + $disabled_records;
567
 
568
  return $all_records;
569
  }
570
 
571
- public function get_filters() {
 
 
 
 
 
572
  $filters = array();
573
 
574
  $date_interval = new Date_Interval();
@@ -608,7 +673,12 @@ class List_Table extends \WP_List_Table {
608
  return apply_filters( 'wp_mainwp_stream_list_table_filters', $filters );
609
  }
610
 
611
- public function filters_form() {
 
 
 
 
 
612
  $filters = $this->get_filters();
613
 
614
  $filters_string = sprintf( '<input type="hidden" name="page" value="%s" />', $this->plugin->admin->records_page_slug );
@@ -675,14 +745,14 @@ class List_Table extends \WP_List_Table {
675
 
676
  $filters_string .= sprintf( '<input type="submit" id="record-query-submit" class="button" value="%s" />', __( 'Filter', 'mainwp-child-reports' ) );
677
 
678
- // Parse all query vars into an array
679
  $query_vars = array();
680
 
681
  if ( isset( $_SERVER['QUERY_STRING'] ) ) {
682
  parse_str( urldecode( $_SERVER['QUERY_STRING'] ), $query_vars );
683
  }
684
 
685
- // Ignore certain query vars and query vars that are empty
686
  foreach ( $query_vars as $query_var => $value ) {
687
  if ( '' === $value || 'page' === $query_var || 'paged' === $query_var ) {
688
  unset( $query_vars[ $query_var ] );
@@ -696,7 +766,7 @@ class List_Table extends \WP_List_Table {
696
  self_admin_url( $this->plugin->admin->admin_parent_page )
697
  );
698
 
699
- // Display reset action if records are being filtered
700
  if ( ! empty( $query_vars ) ) {
701
  $filters_string .= sprintf( '<a href="%s" id="record-query-reset"><span class="dashicons dashicons-dismiss"></span> <span class="record-query-reset-text">%s</span></a>', esc_url( $url ), __( 'Reset filters', 'mainwp-child-reports' ) );
702
  }
@@ -704,7 +774,17 @@ class List_Table extends \WP_List_Table {
704
  return sprintf( '<div class="alignleft actions">%s</div>', $filters_string ); // xss ok
705
  }
706
 
707
- public function filter_select( $name, $title, $items, $ajax = false ) {
 
 
 
 
 
 
 
 
 
 
708
  if ( $ajax ) {
709
  $out = sprintf(
710
  '<input type="hidden" name="%s" class="chosen-select" value="%s" data-placeholder="%s" />',
@@ -749,7 +829,7 @@ class List_Table extends \WP_List_Table {
749
  $out = sprintf(
750
  '<select name="%s" class="chosen-select" data-placeholder="%s">%s</select>',
751
  esc_attr( $name ),
752
- // translators: Placeholder refers to the title of the dropdown menu (e.g. "users")
753
  sprintf( esc_attr__( 'Show all %s', 'mainwp-child-reports' ), $title ),
754
  implode( '', $options )
755
  );
@@ -758,7 +838,13 @@ class List_Table extends \WP_List_Table {
758
  return $out;
759
  }
760
 
761
- public function filter_option( $args ) {
 
 
 
 
 
 
762
  $defaults = array(
763
  'value' => null,
764
  'selected' => null,
@@ -784,7 +870,12 @@ class List_Table extends \WP_List_Table {
784
  );
785
  }
786
 
787
- public function filter_search() {
 
 
 
 
 
788
  $search = null;
789
  if ( isset( $_GET['search'] ) ) { // CSRF okay
790
  $search = esc_attr( wp_unslash( $_GET['search'] ) ); // input var okay, CSRF okay
@@ -802,7 +893,13 @@ class List_Table extends \WP_List_Table {
802
  return $out;
803
  }
804
 
805
- public function filter_date( $items ) {
 
 
 
 
 
 
806
  wp_enqueue_style( 'jquery-ui' );
807
  wp_enqueue_style( 'wp-mainwp-stream-datepicker' );
808
  wp_enqueue_script( 'jquery-ui-datepicker' );
@@ -854,15 +951,15 @@ class List_Table extends \WP_List_Table {
854
  }
855
 
856
  /**
857
- * Output a Select dropdown of actions relating to the Stream records
858
  *
859
- * @return string
860
  */
861
  public function record_actions_form() {
862
  /**
863
- * Filter the records screen actions dropdown menu
864
  *
865
- * @return array Should be in the format of action_slug => 'Action Name'
866
  */
867
  $actions = apply_filters( 'wp_mainwp_stream_record_actions_menu', array() );
868
 
@@ -898,7 +995,10 @@ class List_Table extends \WP_List_Table {
898
  return ob_get_clean();
899
  }
900
 
901
- public function display() {
 
 
 
902
  $url = self_admin_url( $this->plugin->admin->admin_parent_page );
903
 
904
  echo '<form method="get" action="' . esc_url( $url ) . '" id="record-filter-form">';
@@ -911,7 +1011,12 @@ class List_Table extends \WP_List_Table {
911
  echo '</form>';
912
  }
913
 
914
- public function single_row( $item ) {
 
 
 
 
 
915
  $classes = apply_filters( 'wp_mainwp_stream_record_classes', array(), $item );
916
  $class_string = '';
917
  if ( ! empty( $classes ) ) {
@@ -923,7 +1028,12 @@ class List_Table extends \WP_List_Table {
923
  echo '</tr>';
924
  }
925
 
926
- public function display_tablenav( $which ) {
 
 
 
 
 
927
  if ( 'top' === $which ) :
928
  ?>
929
  <div class="tablenav <?php echo esc_attr( $which ); ?>">
@@ -951,7 +1061,15 @@ class List_Table extends \WP_List_Table {
951
  endif;
952
  }
953
 
954
- public function set_screen_option( $dummy, $option, $value ) {
 
 
 
 
 
 
 
 
955
  if ( 'edit_mainwp_stream_per_page' === $option ) {
956
  return $value;
957
  } else {
@@ -959,7 +1077,15 @@ class List_Table extends \WP_List_Table {
959
  }
960
  }
961
 
962
- public function set_live_update_option( $dummy, $option, $value ) {
 
 
 
 
 
 
 
 
963
  unset( $value );
964
 
965
  // @codingStandardsIgnoreStart
@@ -978,7 +1104,14 @@ class List_Table extends \WP_List_Table {
978
  return $dummy;
979
  }
980
 
981
- public function screen_controls( $status, $args ) {
 
 
 
 
 
 
 
982
  unset( $status );
983
  unset( $args );
984
 
@@ -1018,11 +1151,11 @@ class List_Table extends \WP_List_Table {
1018
  }
1019
 
1020
  /**
1021
- * This function is use to map List table column name with excluded setting keys
1022
  *
1023
- * @param string $column List table column name
1024
  *
1025
- * @return string setting name for that column
1026
  */
1027
  public function get_column_excluded_setting_key( $column ) {
1028
  switch ( $column ) {
@@ -1049,11 +1182,11 @@ class List_Table extends \WP_List_Table {
1049
  }
1050
 
1051
  /**
1052
- * Get users as dropdown items
1053
  *
1054
- * @param array $users
1055
  *
1056
- * @return array
1057
  */
1058
  public function get_users_dropdown_items( $users ) {
1059
  $record_meta = array();
1
  <?php
2
+ /** MainWP Child Reports list table. */
3
 
4
  namespace WP_MainWP_Stream;
5
 
6
+ use JMS\Serializer\Annotation\Type;
7
+
8
+ /**
9
+ * Class List_Table.
10
+ * @package WP_MainWP_Stream
11
+ */
12
  class List_Table extends \WP_List_Table {
13
 
14
+ /** @var Plugin Hold Plugin class. */
 
 
 
 
15
  public $plugin;
16
 
17
  /**
18
  * Class constructor.
19
  *
20
  * @param Plugin $plugin The main Plugin class.
21
+ * @param array $args Constructor arguments.
22
  */
23
  public function __construct( $plugin, $args = array() ) {
24
  $this->plugin = $plugin;
26
  $screen_id = isset( $args['screen'] ) ? $args['screen'] : null;
27
 
28
  /**
29
+ * @var $screen_id Filter the list table screen ID
30
  *
31
  * @return string
32
  */
49
  )
50
  );
51
 
52
+ // Check for default hidden columns.
53
  $this->get_hidden_columns();
54
 
55
  add_filter( 'screen_settings', array(
64
  set_screen_options();
65
  }
66
 
67
+ /**
68
+ * Extra table Navigation.
69
+ *
70
+ * @param string $which Which location.
71
+ */
72
+ public function extra_tablenav($which ) {
73
  if ( 'top' === $which ) {
74
  echo $this->filters_form(); // xss ok
75
  }
76
  }
77
 
78
+ /**
79
+ * No activity message.
80
+ */
81
+ public function no_items() {
82
  ?>
83
  <div class="stream-list-table-no-items">
84
  <p><?php esc_html_e( 'Sorry, no activity records were found.', 'mainwp-child-reports' ); ?></p>
86
  <?php
87
  }
88
 
89
+ /**
90
+ * Get columns.
91
+ *
92
+ * Allows devs to add new columns to table.
93
+ *
94
+ * @return array Return modified table columns.
95
+ */
96
+ public function get_columns() {
97
  return apply_filters(
98
  'wp_mainwp_stream_list_table_columns',
99
  array(
107
  );
108
  }
109
 
110
+ /**
111
+ * Get sortable columns.
112
+ *
113
+ * @return array[] Sortable columns array.
114
+ */
115
+ public function get_sortable_columns() {
116
  return array(
117
  'date' => array( 'date', false ),
118
  );
119
  }
120
 
121
+ /**
122
+ * Get hidden columns.
123
+ *
124
+ * @return array|bool|string[] Return $hidden Array of hidden columns.
125
+ */
126
+ public function get_hidden_columns() {
127
  $user = wp_get_current_user();
128
  if ( ! $user ) {
129
  return array();
130
  }
131
+ // Directly checking the user meta; to check whether user has changed screen option or not.
132
  $hidden = $this->plugin->admin->get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true );
133
 
134
+ // If user meta is not found; add the default hidden column 'id'.
135
  if ( ! $hidden ) {
136
  $hidden = array( 'id' );
137
  $this->plugin->admin->update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden );
140
  return $hidden;
141
  }
142
 
143
+ /**
144
+ * Prepare list items.
145
+ */
146
+ public function prepare_items() {
147
  $columns = $this->get_columns();
148
  $sortable = $this->get_sortable_columns();
149
  $hidden = $this->get_hidden_columns();
168
  );
169
  }
170
 
171
+ /**
172
+ * Get records.
173
+ *
174
+ * @return array Return record items.
175
+ */
176
+ public function get_records() {
177
  $args = array();
178
 
179
+ // Parse sorting params.
180
  $order = wp_mainwp_stream_filter_input( INPUT_GET, 'order' );
181
  if ( $order ) {
182
  $args['order'] = $order;
218
  'action',
219
  );
220
 
221
+ // Add property fields to defaults, including their __in/__not_in variations.
222
  foreach ( $properties as $property ) {
223
  $value = wp_mainwp_stream_filter_input( INPUT_GET, $property );
224
 
225
+ // Allow 0 values.
226
  if ( isset( $value ) && '' !== $value && false !== $value ) {
227
  $args[ $property ] = $value;
228
  }
258
  }
259
 
260
  /**
261
+ * Get total of found rows.
262
  *
263
+ * @return integer Return total of found rows.
264
  */
265
  public function get_total_found_rows() {
266
  return $this->plugin->db->get_found_records_count();
267
  }
268
 
269
+ /**
270
+ * Default Columns.
271
+ *
272
+ * @param array $item Row item.
273
+ * @param atring $column_name Column name.
274
+ * @throws \Exception Error message.
275
+ */
276
+ public function column_default( $item, $column_name ) {
277
  $out = '';
278
  $record = new Record( $item );
279
 
293
  case 'summary':
294
  $out = $record->summary;
295
  $object_title = $record->get_object_title();
296
+ // translators: Placeholder refers to the title of any object, like a Post (e.g. "Hello World").
297
  $view_all_text = $object_title ? sprintf( esc_html__( 'View all activity for "%s"', 'mainwp-child-reports' ), esc_attr( $object_title ) ) : esc_html__( 'View all activity for this object', 'mainwp-child-reports' );
298
 
299
  if ( $record->object_id ) {
363
  default:
364
  /**
365
  * Registers new Columns to be inserted into the table. The cell contents of this column is set
366
+ * below with 'wp_mainwp_stream_insert_column_default_' .
367
  *
368
  * @return array
369
  */
375
  /**
376
  * If column title inserted via wp_mainwp_stream_register_column_defaults ($column_title) exists
377
  * among columns registered with get_columns ($column_name) and there is an action associated
378
+ * with this column, do the action.
379
  *
380
  * Also, note that the action name must include the $column_title registered
381
+ * with wp_mainwp_stream_register_column_defaults.
382
  */
383
  if ( $column_title === $column_name && has_filter( "wp_mainwp_stream_insert_column_default_{$column_title}" ) ) {
384
  /**
385
  * Allows for the addition of content under a specified column.
386
  *
387
+ * @param object $record Contents of the row.
388
  *
389
  * @return string
390
  */
398
  }
399
  }
400
 
401
+ $allowed_tags = wp_kses_allowed_html( 'post' );
402
+ $allowed_tags['time'] = array(
403
  'datetime' => true,
404
  'class' => true,
405
  );
408
  echo wp_kses( $out, $allowed_tags );
409
  }
410
 
411
+ /**
412
+ * Get action links.
413
+ *
414
+ * @param array $record Record array.
415
+ * @return string Return Action link.
416
+ */
417
+ public function get_action_links( $record ) {
418
  $out = '';
419
 
420
  /**
421
+ * Filter allows modification of action links for a specific connector.
422
  *
423
  * @param array
424
  * @param Record
428
  $action_links = apply_filters( 'wp_mainwp_stream_action_links_' . $record->connector, array(), $record );
429
 
430
  /**
431
+ * Filter allows addition of custom links for a specific connector.
432
  *
433
  * @param array
434
  * @param Record
467
  return $out;
468
  }
469
 
470
+ /**
471
+ * Column link.
472
+ *
473
+ * @param string $display Whether or not to display.
474
+ * @param string $key Column key.
475
+ * @param string $value Column value.
476
+ * @param string $title Column title.
477
+ * @return string Return Column link html.
478
+ */
479
+ public function column_link( $display, $key, $value = null, $title = null ) {
480
  $url = add_query_arg(
481
  array(
482
  'page' => $this->plugin->admin->records_page_slug,
500
  );
501
  }
502
 
503
+ /**
504
+ * Get term title.
505
+ *
506
+ * @param string $term Term name.
507
+ * @param string $type Term Type.
508
+ * @return string Return Term title.
509
+ */
510
+ public function get_term_title($term, $type ) {
511
  if ( ! isset( $this->plugin->connectors->term_labels[ 'stream_' . $type ][ $term ] ) ) {
512
  return $term;
513
  }
516
  }
517
 
518
  /**
519
+ * Assembles records for display in search filters.
520
  *
521
  * Gathers list of all users/connectors, then compares it to
522
  * results of existing records. All items that do not exist in records
523
  * get assigned a disabled value of "true".
524
  *
525
+ * @param string $column List table column name.
526
  *
527
+ * @return array Options to be displayed in search filters.
528
+ * @todo eliminate special condition for authors, especially using a WP_User object as the value; should use string or stringifiable object.
529
+ */
530
  public function assemble_records( $column ) {
 
531
  if ( 'user_id' === $column ) {
532
  $all_records = array();
533
 
534
+ // If the number of users exceeds the max users constant value then return an empty array and use AJAX instead.
535
  $user_count = count_users();
536
  $total_users = $user_count['total_users'];
537
 
568
  },
569
  get_super_admins()
570
  );
571
+ $users = array_unique( array_merge( $users, $super_admins ) );
572
  }
573
 
574
  $users[] = new Author(
603
  }
604
  }
605
 
606
+ // Remove WP-CLI pseudo user if no records with user=0 exist.
607
  if ( isset( $disabled_records[0] ) ) {
608
  unset( $disabled_records[0] );
609
  }
622
  uasort( $active_records, $sort );
623
  uasort( $disabled_records, $sort );
624
 
625
+ // Not using array_merge() in order to preserve the array index for the users dropdown which uses the user_id as the key.
626
  $all_records = $active_records + $disabled_records;
627
 
628
  return $all_records;
629
  }
630
 
631
+ /**
632
+ * Get filters.
633
+ *
634
+ * @return array Return filters array.
635
+ */
636
+ public function get_filters() {
637
  $filters = array();
638
 
639
  $date_interval = new Date_Interval();
673
  return apply_filters( 'wp_mainwp_stream_list_table_filters', $filters );
674
  }
675
 
676
+ /**
677
+ * Filters form.
678
+ *
679
+ * @return string Return form html.
680
+ */
681
+ public function filters_form() {
682
  $filters = $this->get_filters();
683
 
684
  $filters_string = sprintf( '<input type="hidden" name="page" value="%s" />', $this->plugin->admin->records_page_slug );
745
 
746
  $filters_string .= sprintf( '<input type="submit" id="record-query-submit" class="button" value="%s" />', __( 'Filter', 'mainwp-child-reports' ) );
747
 
748
+ // Parse all query vars into an array.
749
  $query_vars = array();
750
 
751
  if ( isset( $_SERVER['QUERY_STRING'] ) ) {
752
  parse_str( urldecode( $_SERVER['QUERY_STRING'] ), $query_vars );
753
  }
754
 
755
+ // Ignore certain query vars and query vars that are empty.
756
  foreach ( $query_vars as $query_var => $value ) {
757
  if ( '' === $value || 'page' === $query_var || 'paged' === $query_var ) {
758
  unset( $query_vars[ $query_var ] );
766
  self_admin_url( $this->plugin->admin->admin_parent_page )
767
  );
768
 
769
+ // Display reset action if records are being filtered.
770
  if ( ! empty( $query_vars ) ) {
771
  $filters_string .= sprintf( '<a href="%s" id="record-query-reset"><span class="dashicons dashicons-dismiss"></span> <span class="record-query-reset-text">%s</span></a>', esc_url( $url ), __( 'Reset filters', 'mainwp-child-reports' ) );
772
  }
774
  return sprintf( '<div class="alignleft actions">%s</div>', $filters_string ); // xss ok
775
  }
776
 
777
+ /**
778
+ * Filter select.
779
+ *
780
+ * @param string $name Filter name.
781
+ * @param string $title Filter title.
782
+ * @param array $items filter items.
783
+ * @param false $ajax Whether or not to use ajax, DEFAULT: FALSE.
784
+ *
785
+ * @return string Return select html.
786
+ */
787
+ public function filter_select($name, $title, $items, $ajax = false ) {
788
  if ( $ajax ) {
789
  $out = sprintf(
790
  '<input type="hidden" name="%s" class="chosen-select" value="%s" data-placeholder="%s" />',
829
  $out = sprintf(
830
  '<select name="%s" class="chosen-select" data-placeholder="%s">%s</select>',
831
  esc_attr( $name ),
832
+ // translators: Placeholder refers to the title of the dropdown menu (e.g. "users").
833
  sprintf( esc_attr__( 'Show all %s', 'mainwp-child-reports' ), $title ),
834
  implode( '', $options )
835
  );
838
  return $out;
839
  }
840
 
841
+ /**
842
+ * Filter options.
843
+ *
844
+ * @param array $args Filter arguments.
845
+ * @return string Return filter options.
846
+ */
847
+ public function filter_option($args ) {
848
  $defaults = array(
849
  'value' => null,
850
  'selected' => null,
870
  );
871
  }
872
 
873
+ /**
874
+ * Filter search.
875
+ *
876
+ * @return string Return Search box html.
877
+ */
878
+ public function filter_search() {
879
  $search = null;
880
  if ( isset( $_GET['search'] ) ) { // CSRF okay
881
  $search = esc_attr( wp_unslash( $_GET['search'] ) ); // input var okay, CSRF okay
893
  return $out;
894
  }
895
 
896
+ /**
897
+ * Filter date.
898
+ *
899
+ * @param array $items Items array.
900
+ * @return false|string Return FALSE on failure or Filter date html.
901
+ */
902
+ public function filter_date($items ) {
903
  wp_enqueue_style( 'jquery-ui' );
904
  wp_enqueue_style( 'wp-mainwp-stream-datepicker' );
905
  wp_enqueue_script( 'jquery-ui-datepicker' );
951
  }
952
 
953
  /**
954
+ * Output a Select dropdown of actions relating to the Stream records.
955
  *
956
+ * @return string Return record actions form.
957
  */
958
  public function record_actions_form() {
959
  /**
960
+ * Filter the records screen actions dropdown menu.
961
  *
962
+ * @return array Should be in the format of action_slug => 'Action Name'.
963
  */
964
  $actions = apply_filters( 'wp_mainwp_stream_record_actions_menu', array() );
965
 
995
  return ob_get_clean();
996
  }
997
 
998
+ /**
999
+ * Display actions form.
1000
+ */
1001
+ public function display() {
1002
  $url = self_admin_url( $this->plugin->admin->admin_parent_page );
1003
 
1004
  echo '<form method="get" action="' . esc_url( $url ) . '" id="record-filter-form">';
1011
  echo '</form>';
1012
  }
1013
 
1014
+ /**
1015
+ * Single row content.
1016
+ *
1017
+ * @param array $item Row data.
1018
+ */
1019
+ public function single_row( $item ) {
1020
  $classes = apply_filters( 'wp_mainwp_stream_record_classes', array(), $item );
1021
  $class_string = '';
1022
  if ( ! empty( $classes ) ) {
1028
  echo '</tr>';
1029
  }
1030
 
1031
+ /**
1032
+ * Display table navigation.
1033
+ *
1034
+ * @param string $which Which location to dislay menu.
1035
+ */
1036
+ public function display_tablenav( $which ) {
1037
  if ( 'top' === $which ) :
1038
  ?>
1039
  <div class="tablenav <?php echo esc_attr( $which ); ?>">
1061
  endif;
1062
  }
1063
 
1064
+ /**
1065
+ * Set screen option.
1066
+ *
1067
+ * @param string $dummy Dummy value.
1068
+ * @param string $option Option to set.
1069
+ * @param string $value Value to set.
1070
+ * @return string Return screen option.
1071
+ */
1072
+ public function set_screen_option( $dummy, $option, $value ) {
1073
  if ( 'edit_mainwp_stream_per_page' === $option ) {
1074
  return $value;
1075
  } else {
1077
  }
1078
  }
1079
 
1080
+ /**
1081
+ * Set live update option.
1082
+ *
1083
+ * @param string $dummy Dummy value.
1084
+ * @param string $option Option to set.
1085
+ * @param string $value Value to set.
1086
+ * @return string Return screen option.
1087
+ */
1088
+ public function set_live_update_option($dummy, $option, $value ) {
1089
  unset( $value );
1090
 
1091
  // @codingStandardsIgnoreStart
1104
  return $dummy;
1105
  }
1106
 
1107
+ /**
1108
+ * Screen controls.
1109
+ *
1110
+ * @param string $status Status.
1111
+ * @param array $args Arguments.
1112
+ * @return false|string FALSE on failure, or live updates html.
1113
+ */
1114
+ public function screen_controls( $status, $args ) {
1115
  unset( $status );
1116
  unset( $args );
1117
 
1151
  }
1152
 
1153
  /**
1154
+ * This function is use to map List table column name with excluded setting keys.
1155
  *
1156
+ * @param string $column List table column name.
1157
  *
1158
+ * @return string setting name for that column.
1159
  */
1160
  public function get_column_excluded_setting_key( $column ) {
1161
  switch ( $column ) {
1182
  }
1183
 
1184
  /**
1185
+ * Get users as dropdown items.
1186
  *
1187
+ * @param array $users Users array.
1188
  *
1189
+ * @return array Dropdown array.
1190
  */
1191
  public function get_users_dropdown_items( $users ) {
1192
  $record_meta = array();
classes/class-live-update.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Live_Update {
5
  /**
6
  * Hold Plugin class
1
  <?php
2
+ /** MainWP Child Reports live update. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Live_Update.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Live_Update {
11
  /**
12
  * Hold Plugin class
classes/class-log.php CHANGED
@@ -1,29 +1,21 @@
1
  <?php
 
2
 
3
  namespace WP_MainWP_Stream;
4
 
 
 
 
 
5
  class Log {
6
 
7
- /**
8
- * Hold Plugin class
9
- *
10
- * @var Plugin
11
- */
12
  public $plugin;
13
 
14
- /**
15
- * Hold Current visitors IP Address.
16
- *
17
- * @var string
18
- */
19
  private $ip_address;
20
 
21
-
22
- /**
23
- * Previous Stream record ID, used for chaining same-session records
24
- *
25
- * @var int
26
- */
27
  private $prev_record;
28
 
29
  /**
@@ -47,7 +39,7 @@ class Log {
47
  }
48
 
49
  /**
50
- * Log handler
51
  *
52
  * @param Connector $connector Connector responsible for logging the event.
53
  * @param string $message sprintf-ready error message string.
@@ -56,11 +48,21 @@ class Log {
56
  * @param string $context Context of the event.
57
  * @param string $action Action of the event.
58
  * @param int $user_id User responsible for the event.
 
59
  *
60
- * @return mixed True if updated, otherwise false|WP_Error
 
 
 
 
 
 
 
61
  */
62
  public function log( $connector, $message, $args, $object_id, $context, $action, $user_id = null, $created_timestamp = 0 ) {
63
- global $wp_roles;
 
 
64
 
65
  if ( is_null( $user_id ) ) {
66
  $user_id = get_current_user_id();
@@ -114,7 +116,7 @@ class Log {
114
  $stream_meta['user_meta'] = $user_meta;
115
 
116
  // Get the current time in milliseconds.
117
- $iso_8601_extended_date = wp_mainwp_stream_get_iso_8601_extended_date( $created_timestamp ); // $created_timestamp = 0 is current time
118
 
119
  if ( ! empty( $user->roles ) ) {
120
  $roles = array_values( $user->roles );
@@ -131,7 +133,7 @@ class Log {
131
  'blog_id' => (int) apply_filters( 'wp_mainwp_stream_blog_id_logged', get_current_blog_id() ),
132
  'user_id' => (int) $user_id,
133
  'user_role' => (string) $role,
134
- 'created' => (string) $iso_8601_extended_date,
135
  'summary' => (string) vsprintf( $message, $args ),
136
  'connector' => (string) $connector,
137
  'context' => (string) $context,
@@ -143,8 +145,7 @@ class Log {
143
  if ( 0 === $recordarr['object_id'] ) {
144
  unset( $recordarr['object_id'] );
145
  }
146
-
147
-
148
  $result = $this->plugin->db->insert( $recordarr );
149
 
150
  // This is helpful in development environments:
@@ -154,7 +155,7 @@ class Log {
154
  }
155
 
156
  /**
157
- * This function is use to check whether or not a record should be excluded from the log.
158
  *
159
  * @param string $connector Name of the connector being logged.
160
  * @param string $context Name of the context being logged.
@@ -162,7 +163,7 @@ class Log {
162
  * @param \WP_User $user The user being logged.
163
  * @param string $ip IP address being logged.
164
  *
165
- * @return bool
166
  */
167
  public function is_record_excluded( $connector, $context, $action, $user = null, $ip = null ) {
168
  if ( is_null( $user ) ) {
@@ -260,19 +261,19 @@ class Log {
260
  * If true, the record is not logged.
261
  *
262
  * @param array $exclude_record Whether the record should excluded.
263
- * @param array $recordarr The record to log.
264
  *
265
- * @return bool
266
  */
267
  return apply_filters( 'wp_mainwp_stream_is_record_excluded', $exclude_record, $record );
268
  }
269
 
270
  /**
271
- * Helper function to send a full backtrace of calls to the PHP error log for debugging
272
  *
273
  * @param array $recordarr Record argument array.
274
  *
275
- * @return string
276
  */
277
  public function debug_backtrace( $recordarr ) {
278
  if ( version_compare( PHP_VERSION, '5.3.6', '<' ) ) {
1
  <?php
2
+ /** MainWP Child Reports log. */
3
 
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Log.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Log {
11
 
12
+ /** @var Plugin Hold Plugin class */
 
 
 
 
13
  public $plugin;
14
 
15
+ /** @var string Hold Current visitors IP Address. */
 
 
 
 
16
  private $ip_address;
17
 
18
+ /** @var int Previous Stream record ID, used for chaining same-session records. */
 
 
 
 
 
19
  private $prev_record;
20
 
21
  /**
39
  }
40
 
41
  /**
42
+ * Log handler.
43
  *
44
  * @param Connector $connector Connector responsible for logging the event.
45
  * @param string $message sprintf-ready error message string.
48
  * @param string $context Context of the event.
49
  * @param string $action Action of the event.
50
  * @param int $user_id User responsible for the event.
51
+ * @param int $created_timestamp 1|0 Whether or not the timestamp was created.
52
  *
53
+ * @return bool|WP_Error True if updated, otherwise false|WP_Error
54
+ *
55
+ * @uses \WP_MainWP_Stream\Author::get_current_agent()
56
+ * @uses \WP_MainWP_Stream\Author::get_display_name()
57
+ * @uses \WP_MainWP_Stream\Author::get_role()
58
+ * @uses \WP_MainWP_Stream\Log::is_record_excluded()
59
+ * @uses $wp_roles::is_role()
60
+ * @uses \WP_MainWP_Stream\Log::$plugin::db::insert()
61
  */
62
  public function log( $connector, $message, $args, $object_id, $context, $action, $user_id = null, $created_timestamp = 0 ) {
63
+
64
+ /** @global object $wp_roles Wordpress user roles object. */
65
+ global $wp_roles;
66
 
67
  if ( is_null( $user_id ) ) {
68
  $user_id = get_current_user_id();
116
  $stream_meta['user_meta'] = $user_meta;
117
 
118
  // Get the current time in milliseconds.
119
+ $created_mysql = wp_mainwp_stream_get_iso_8601_extended_date( $created_timestamp, 0, true ); // $created_timestamp = 0 is current time
120
 
121
  if ( ! empty( $user->roles ) ) {
122
  $roles = array_values( $user->roles );
133
  'blog_id' => (int) apply_filters( 'wp_mainwp_stream_blog_id_logged', get_current_blog_id() ),
134
  'user_id' => (int) $user_id,
135
  'user_role' => (string) $role,
136
+ 'created' => (string) $created_mysql,
137
  'summary' => (string) vsprintf( $message, $args ),
138
  'connector' => (string) $connector,
139
  'context' => (string) $context,
145
  if ( 0 === $recordarr['object_id'] ) {
146
  unset( $recordarr['object_id'] );
147
  }
148
+
 
149
  $result = $this->plugin->db->insert( $recordarr );
150
 
151
  // This is helpful in development environments:
155
  }
156
 
157
  /**
158
+ * This function is used to check whether or not a record should be excluded from the log.
159
  *
160
  * @param string $connector Name of the connector being logged.
161
  * @param string $context Name of the context being logged.
163
  * @param \WP_User $user The user being logged.
164
  * @param string $ip IP address being logged.
165
  *
166
+ * @return bool TRUE|FALSE.
167
  */
168
  public function is_record_excluded( $connector, $context, $action, $user = null, $ip = null ) {
169
  if ( is_null( $user ) ) {
261
  * If true, the record is not logged.
262
  *
263
  * @param array $exclude_record Whether the record should excluded.
264
+ * @param array $record The record to log.
265
  *
266
+ * @return bool TRUE|FALSE.
267
  */
268
  return apply_filters( 'wp_mainwp_stream_is_record_excluded', $exclude_record, $record );
269
  }
270
 
271
  /**
272
+ * Helper function to send a full backtrace of calls to the PHP error log for debugging.
273
  *
274
  * @param array $recordarr Record argument array.
275
  *
276
+ * @return string $output MainWP Pro Reports backtrace.
277
  */
278
  public function debug_backtrace( $recordarr ) {
279
  if ( version_compare( PHP_VERSION, '5.3.6', '<' ) ) {
classes/class-mainwp-child-report-helper.php CHANGED
@@ -1,16 +1,43 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class MainWP_Child_Report_Helper {
5
-
6
- public static $instance;
 
 
 
 
 
 
 
 
 
7
  public $branding_options = null;
 
 
8
  public $branding_title = null;
9
- public $setting_fields = array();
10
- public $plugin;
11
- public $list_table = null;
12
-
13
- function __construct( $plugin = null ) {
 
 
 
 
 
 
 
 
 
 
14
  $this->plugin = $plugin;
15
 
16
  add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
@@ -23,8 +50,16 @@ class MainWP_Child_Report_Helper {
23
  add_filter( 'wp_mainwp_stream_settings_option_fields', array( $this, 'get_hide_child_report_fields' ) );
24
  $this->init_branding_options();
25
  }
26
-
27
- public static function get_instance() {
 
 
 
 
 
 
 
 
28
  if ( empty( self::$instance ) ) {
29
  $class = __CLASS__;
30
  self::$instance = new $class;
@@ -33,31 +68,53 @@ class MainWP_Child_Report_Helper {
33
  return self::$instance;
34
  }
35
 
36
- public function admin_menu() {
 
 
 
37
  $opts = $this->branding_options;
38
- $hide = is_array($opts) && isset($opts['hide_child_reports']) && ($opts['hide_child_reports'] == 'hide');
39
  if ( ! $hide ) {
40
  // Register settings page
41
  add_filter( 'mainwp-child-init-subpages', array( $this, 'init_subpages' ) );
42
  }
43
  }
44
-
45
- function settings_form_action( $action ) {
 
 
 
 
 
 
46
  if ( is_network_admin() ) {
47
  $current_page = wp_mainwp_stream_filter_input( INPUT_GET, 'page' );
48
  $action = add_query_arg( array( 'action' => $current_page ), 'edit.php' );
49
  }
50
  return $action;
51
  }
52
-
 
 
 
 
 
53
  public function init_branding_options() {
54
  return $this->get_branding_options();
55
  }
56
 
 
 
 
 
 
57
  public function get_branding_options() {
58
  if ( $this->branding_options === null ) {
59
 
60
  $opts = get_option( 'mainwp_child_branding_settings' ); // settings from mainwp-child plugin
 
 
 
61
  // this is new update
62
  if ( is_array($opts) ) {
63
  if (isset($opts['cancelled_branding'])) { // if it was set
@@ -70,12 +127,7 @@ class MainWP_Child_Report_Helper {
70
  }
71
  $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
72
  } else { // to compatible will old code
73
- $opts = array();
74
- $opts['hide'] = get_option( 'mainwp_branding_child_hide' );
75
- $opts['branding_header'] = get_option( 'mainwp_branding_plugin_header' );
76
- $cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
77
- $opts['cancelled_branding'] = $cancelled_branding;
78
- $branding_header = $opts['branding_header'];
79
  }
80
 
81
  if ( ! $cancelled_branding && ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) ) {
@@ -90,8 +142,14 @@ class MainWP_Child_Report_Helper {
90
  return $this->branding_options;
91
  }
92
 
93
-
94
- public function modify_plugin_header( $plugins ) {
 
 
 
 
 
 
95
  $_opts = $this->branding_options;
96
  $is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
97
  $cancelled_branding = isset( $_opts['cancelled_branding'] ) ? $_opts['cancelled_branding'] : false;
@@ -117,8 +175,15 @@ class MainWP_Child_Report_Helper {
117
  return $plugins;
118
  }
119
  }
120
-
121
- public function update_plugin_header( $plugins, $header ) {
 
 
 
 
 
 
 
122
  $plugin_key = '';
123
  foreach ( $plugins as $key => $value ) {
124
  $plugin_slug = basename( $key, '.php' );
@@ -141,8 +206,13 @@ class MainWP_Child_Report_Helper {
141
 
142
  return $plugins;
143
  }
144
-
145
- public function is_branding() {
 
 
 
 
 
146
 
147
  $_opts = $this->branding_options;
148
  $is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
@@ -152,7 +222,7 @@ class MainWP_Child_Report_Helper {
152
  if ( $cancelled_branding ) {
153
  return false;
154
  }
155
- // hide
156
  if ( 'T' === $is_hide ) {
157
  return true;
158
  }
@@ -163,8 +233,15 @@ class MainWP_Child_Report_Helper {
163
 
164
  }
165
 
166
-
167
- public function plugin_row_meta( $plugin_meta, $plugin_file ) {
 
 
 
 
 
 
 
168
  if ( WP_MAINWP_STREAM_PLUGIN !== $plugin_file ) {
169
  return $plugin_meta;
170
  }
@@ -184,8 +261,14 @@ class MainWP_Child_Report_Helper {
184
 
185
  return $plugin_meta;
186
  }
187
-
188
- public function init_subpages( $subPages = array() ) {
 
 
 
 
 
 
189
 
190
  if ( is_network_admin() && ! is_plugin_active_for_network( WP_MAINWP_STREAM_PLUGIN ) ) {
191
  return $subPages;
@@ -204,8 +287,14 @@ class MainWP_Child_Report_Helper {
204
 
205
  return $subPages;
206
  }
207
-
208
- public static function hook_updraftplus_save_last_backup($last_backup) {
 
 
 
 
 
 
209
 
210
  if (!is_array($last_backup))
211
  return $last_backup;
@@ -252,11 +341,22 @@ class MainWP_Child_Report_Helper {
252
  return $last_backup;
253
  }
254
 
255
- public static function hook_reports_log($ext_name = '') {
 
 
 
 
 
256
  do_action('mainwp_child_log', $ext_name);
257
  }
258
 
259
- public function get_hide_child_report_fields( $fields ) {
 
 
 
 
 
 
260
 
261
  $branding_text = $this->get_branding_title();
262
  $branding_name = !empty($branding_text) ? $branding_text : 'MainWP Child';
@@ -276,29 +376,41 @@ class MainWP_Child_Report_Helper {
276
  return $fields;
277
 
278
  }
279
-
280
- public function register_list_table() {
 
 
 
281
  $this->list_table = new List_Table(
282
  $this->plugin, array(
283
  'screen' => 'settings_page_' . $this->plugin->admin->records_page_slug,
284
  )
285
  );
286
  }
287
-
288
- public function render_list_table() {
 
 
 
289
  $this->list_table->prepare_items();
290
  echo '<div class="mainwp_child_reports_wrap">';
291
  $this->list_table->display();
292
  echo '</div>';
293
  }
294
-
295
- public function render_reports_page() {
 
 
 
296
  do_action('mainwp-child-pageheader', 'reports-page');
297
  $this->render_list_table();
298
  do_action('mainwp-child-pagefooter', 'reports-page');
299
  }
300
 
301
- public function render_settings_page() {
 
 
 
302
  $option_key = $this->plugin->settings->option_key;
303
  $form_action = apply_filters( 'mainwp_wp_stream_settings_form_action', admin_url( 'options.php' ) );
304
  do_action('mainwp-child-pageheader', 'reports-settings');
@@ -317,8 +429,13 @@ class MainWP_Child_Report_Helper {
317
  <?php
318
  do_action('mainwp-child-pagefooter', 'reports-settings');
319
  }
320
-
321
- public function get_branding_title() {
 
 
 
 
 
322
  return $this->branding_title;
323
  }
324
  }
1
  <?php
2
+ /** MainWP Child Reports helper. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class MainWP_Child_Report_Helper.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class MainWP_Child_Report_Helper {
11
+
12
+ /**
13
+ * Public static variable to hold the single instance of the class.
14
+ *
15
+ * @var object $instance
16
+ */
17
+ public static $instance;
18
+
19
+ /**
20
+ * @var null Child Site branding options.
21
+ */
22
  public $branding_options = null;
23
+
24
+ /** @var string Child Site branding title. */
25
  public $branding_title = null;
26
+
27
+ /** @var array Settings fields. */
28
+ public $setting_fields = array();
29
+
30
+ /** @var string Plugin slug. */
31
+ public $plugin;
32
+
33
+ /** @var array List table array. */
34
+ public $list_table = null;
35
+
36
+ /**
37
+ * MainWP_Child_Report_Helper constructor.
38
+ * @param null $plugin
39
+ */
40
+ function __construct( $plugin = null ) {
41
  $this->plugin = $plugin;
42
 
43
  add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
50
  add_filter( 'wp_mainwp_stream_settings_option_fields', array( $this, 'get_hide_child_report_fields' ) );
51
  $this->init_branding_options();
52
  }
53
+
54
+ /**
55
+ * Method get_instance
56
+ *
57
+ * Create a public static instance.
58
+ *
59
+ * @static
60
+ * @return MainWP_Child_Report_Helper
61
+ */
62
+ public static function get_instance() {
63
  if ( empty( self::$instance ) ) {
64
  $class = __CLASS__;
65
  self::$instance = new $class;
68
  return self::$instance;
69
  }
70
 
71
+ /**
72
+ * Initiate admin menu.
73
+ */
74
+ public function admin_menu() {
75
  $opts = $this->branding_options;
76
+ $hide = is_array($opts) && isset( $opts['hide_child_reports']) && ($opts['hide_child_reports'] == 'hide');
77
  if ( ! $hide ) {
78
  // Register settings page
79
  add_filter( 'mainwp-child-init-subpages', array( $this, 'init_subpages' ) );
80
  }
81
  }
82
+
83
+ /**
84
+ * Form settings action.
85
+ *
86
+ * @param array $action Action to perform.
87
+ * @return array $action Action to perform.
88
+ */
89
+ function settings_form_action($action ) {
90
  if ( is_network_admin() ) {
91
  $current_page = wp_mainwp_stream_filter_input( INPUT_GET, 'page' );
92
  $action = add_query_arg( array( 'action' => $current_page ), 'edit.php' );
93
  }
94
  return $action;
95
  }
96
+
97
+ /**
98
+ * Initiate branding options.
99
+ *
100
+ * @return array|null Return branding options or Null.
101
+ */
102
  public function init_branding_options() {
103
  return $this->get_branding_options();
104
  }
105
 
106
+ /**
107
+ * Get branding options.
108
+ *
109
+ * @return array|null Return branding options or Null.
110
+ */
111
  public function get_branding_options() {
112
  if ( $this->branding_options === null ) {
113
 
114
  $opts = get_option( 'mainwp_child_branding_settings' ); // settings from mainwp-child plugin
115
+ $cancelled_branding = false;
116
+ $branding_header = array();
117
+
118
  // this is new update
119
  if ( is_array($opts) ) {
120
  if (isset($opts['cancelled_branding'])) { // if it was set
127
  }
128
  $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
129
  } else { // to compatible will old code
130
+ $opts = array();
 
 
 
 
 
131
  }
132
 
133
  if ( ! $cancelled_branding && ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) ) {
142
  return $this->branding_options;
143
  }
144
 
145
+
146
+ /**
147
+ * Modify Plugin header.
148
+ *
149
+ * @param array $plugins Plugins array.
150
+ * @return array Modified plugins array.
151
+ */
152
+ public function modify_plugin_header( $plugins ) {
153
  $_opts = $this->branding_options;
154
  $is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
155
  $cancelled_branding = isset( $_opts['cancelled_branding'] ) ? $_opts['cancelled_branding'] : false;
175
  return $plugins;
176
  }
177
  }
178
+
179
+ /**
180
+ * Update plugins header.
181
+ *
182
+ * @param array $plugins Plugins array.
183
+ * @param string $header Header to update.
184
+ * @return array Modified plugins array.
185
+ */
186
+ public function update_plugin_header($plugins, $header ) {
187
  $plugin_key = '';
188
  foreach ( $plugins as $key => $value ) {
189
  $plugin_slug = basename( $key, '.php' );
206
 
207
  return $plugins;
208
  }
209
+
210
+ /**
211
+ * Check if branding is enabled.
212
+ *
213
+ * @return bool TRUE|FALSE.
214
+ */
215
+ public function is_branding() {
216
 
217
  $_opts = $this->branding_options;
218
  $is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
222
  if ( $cancelled_branding ) {
223
  return false;
224
  }
225
+ // hide.
226
  if ( 'T' === $is_hide ) {
227
  return true;
228
  }
233
 
234
  }
235
 
236
+
237
+ /**
238
+ * Plugin row meta.
239
+ *
240
+ * @param array $plugin_meta Plugin meta data.
241
+ * @param string $plugin_file Plugin file.
242
+ * @return array $plugin_meta Return pugin meta data array.
243
+ */
244
+ public function plugin_row_meta($plugin_meta, $plugin_file ) {
245
  if ( WP_MAINWP_STREAM_PLUGIN !== $plugin_file ) {
246
  return $plugin_meta;
247
  }
261
 
262
  return $plugin_meta;
263
  }
264
+
265
+ /**
266
+ * Initiate subpages.
267
+ *
268
+ * @param array $subPages Subpages array.
269
+ * @return array Return subpages array, or
270
+ */
271
+ public function init_subpages($subPages = array() ) {
272
 
273
  if ( is_network_admin() && ! is_plugin_active_for_network( WP_MAINWP_STREAM_PLUGIN ) ) {
274
  return $subPages;
287
 
288
  return $subPages;
289
  }
290
+
291
+ /**
292
+ * Save UpdraftPlus last backup hook.
293
+ *
294
+ * @param array $last_backup last backup meta data.
295
+ * @return array $last_backup last backup meta data.
296
+ */
297
+ public static function hook_updraftplus_save_last_backup( $last_backup ) {
298
 
299
  if (!is_array($last_backup))
300
  return $last_backup;
341
  return $last_backup;
342
  }
343
 
344
+ /**
345
+ * Reports log hook.
346
+ *
347
+ * @param string $ext_name Extension name.
348
+ */
349
+ public static function hook_reports_log( $ext_name = '') {
350
  do_action('mainwp_child_log', $ext_name);
351
  }
352
 
353
+ /**
354
+ * Hide Child Reports Fields.
355
+ *
356
+ * @param array $fields Fields array.
357
+ * @return array $fields Return modified fields array.
358
+ */
359
+ public function get_hide_child_report_fields( $fields ) {
360
 
361
  $branding_text = $this->get_branding_title();
362
  $branding_name = !empty($branding_text) ? $branding_text : 'MainWP Child';
376
  return $fields;
377
 
378
  }
379
+
380
+ /**
381
+ * Register list table.
382
+ */
383
+ public function register_list_table() {
384
  $this->list_table = new List_Table(
385
  $this->plugin, array(
386
  'screen' => 'settings_page_' . $this->plugin->admin->records_page_slug,
387
  )
388
  );
389
  }
390
+
391
+ /**
392
+ * Render list table.
393
+ */
394
+ public function render_list_table() {
395
  $this->list_table->prepare_items();
396
  echo '<div class="mainwp_child_reports_wrap">';
397
  $this->list_table->display();
398
  echo '</div>';
399
  }
400
+
401
+ /**
402
+ * Render reports page.
403
+ */
404
+ public function render_reports_page() {
405
  do_action('mainwp-child-pageheader', 'reports-page');
406
  $this->render_list_table();
407
  do_action('mainwp-child-pagefooter', 'reports-page');
408
  }
409
 
410
+ /**
411
+ * Render settings page.
412
+ */
413
+ public function render_settings_page() {
414
  $option_key = $this->plugin->settings->option_key;
415
  $form_action = apply_filters( 'mainwp_wp_stream_settings_form_action', admin_url( 'options.php' ) );
416
  do_action('mainwp-child-pageheader', 'reports-settings');
429
  <?php
430
  do_action('mainwp-child-pagefooter', 'reports-settings');
431
  }
432
+
433
+ /**
434
+ * Get branding title.
435
+ *
436
+ * @return string|null Return branding title or Null
437
+ */
438
+ public function get_branding_title() {
439
  return $this->branding_title;
440
  }
441
  }
classes/class-network.php CHANGED
@@ -1,31 +1,45 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Network {
5
- /**
6
- * Hold Plugin class
7
- * @var Plugin
8
- */
9
  public $plugin;
10
 
11
- public $network_settings_page_slug = 'wp_mainwp_stream_network_settings';
 
 
 
 
12
 
13
- public $default_settings_page_slug = 'wp_mainwp_stream_default_settings';
 
 
 
 
 
 
 
14
 
15
- public function __construct( $plugin ) {
16
  $this->plugin = $plugin;
17
 
18
- // Always add default site_id/blog_id params when multisite
19
  if ( is_multisite() ) {
20
  add_filter( 'wp_mainwp_stream_query_args', array( $this, 'network_query_args' ) );
21
  }
22
 
23
- // Bail early if not network-activated
24
  if ( ! $this->is_network_activated() ) {
25
  return;
26
  }
27
 
28
- // Actions
29
  add_action( 'init', array( $this, 'ajax_network_admin' ) );
30
 
31
  // DISABLED
@@ -51,12 +65,14 @@ class Network {
51
  }
52
 
53
  /**
54
- * Workaround to get admin-ajax.php to know when the request is from the Network Admin
55
  *
56
- * @return bool
57
  *
58
  * @action init
59
- *
 
 
60
  * @see https://core.trac.wordpress.org/ticket/22589
61
  */
62
  public function ajax_network_admin() {
@@ -75,9 +91,9 @@ class Network {
75
  }
76
 
77
  /**
78
- * Builds a stdClass object used when displaying actions done in network administration
79
  *
80
- * @return object
81
  */
82
  public function get_network_blog() {
83
  $blog = new \stdClass();
@@ -88,9 +104,11 @@ class Network {
88
  }
89
 
90
  /**
91
- * Returns true if Stream is network activated, otherwise false
92
  *
93
- * @return bool
 
 
94
  */
95
  public function is_network_activated() {
96
  if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
@@ -105,9 +123,9 @@ class Network {
105
  }
106
 
107
  /**
108
- * Returns true if Stream is a must-use plugin, otherwise false
109
  *
110
- * @return bool
111
  */
112
  public function is_mustuse() {
113
 
@@ -121,12 +139,13 @@ class Network {
121
  }
122
 
123
  /**
124
- * Add Network Settings and Default Settings menu items
125
  *
126
- * @return array
 
 
127
  */
128
- // DISABLED
129
- public function admin_menu_screens() {
130
  if ( ! is_network_admin() ) {
131
  return;
132
  }
@@ -145,14 +164,13 @@ class Network {
145
  }
146
 
147
  /**
148
- * Remove records when records TTL is shortened
149
  *
150
- * @param string $option_key
151
- * @param array $old_value
152
- * @param array $new_value
153
  *
154
  * @action update_option_wp_stream
155
- * @return void
156
  */
157
  public function updated_option_ttl_remove_records( $option_key, $new_value, $old_value ) {
158
  unset( $option_key );
@@ -160,11 +178,11 @@ class Network {
160
  }
161
 
162
  /**
163
- * Adjust the action of the settings form when in the Network Admin
164
  *
165
- * @param $action
166
  *
167
- * @return string
168
  */
169
  public function settings_form_action( $action ) {
170
  if ( is_network_admin() ) {
@@ -182,9 +200,9 @@ class Network {
182
  /**
183
  * Add a description to each of the Settings pages in the Network Admin
184
  *
185
- * @param $description
186
  *
187
- * @return string
188
  */
189
  public function settings_form_description( $description ) {
190
  if ( ! is_network_admin() ) {
@@ -208,9 +226,11 @@ class Network {
208
  /**
209
  * Adjusts the settings fields displayed in various network admin screens
210
  *
211
- * @param $fields
212
  *
213
- * @return mixed
 
 
214
  */
215
  public function get_network_admin_fields( $fields ) {
216
  if ( ! $this->is_network_activated() ) {
@@ -247,7 +267,7 @@ class Network {
247
  )
248
  );
249
 
250
- // Remove settings based on context
251
  if ( $this->plugin->settings->network_options_key === $this->plugin->settings->option_key ) {
252
  $hidden_options = $network_hidden_options;
253
  } else {
@@ -266,7 +286,7 @@ class Network {
266
  }
267
  }
268
 
269
- // Add settings based on context
270
  if ( $this->plugin->settings->network_options_key === $this->plugin->settings->option_key ) {
271
  $new_fields['general']['fields'][] = array(
272
  'name' => 'site_access',
@@ -280,7 +300,7 @@ class Network {
280
  $fields = array_merge_recursive( $new_fields, $fields );
281
  }
282
 
283
- // Remove empty settings sections
284
  foreach ( $fields as $section_key => $section ) {
285
  if ( empty( $section['fields'] ) ) {
286
  unset( $fields[ $section_key ] );
@@ -291,11 +311,15 @@ class Network {
291
  }
292
 
293
  /**
294
- * Get translations of serialized Stream Network settings
295
  *
296
  * @filter wp_mainwp_stream_serialized_labels
297
  *
298
- * @return array Multidimensional array of fields
 
 
 
 
299
  */
300
  public function get_settings_translations( $labels ) {
301
  $network_key = $this->plugin->settings->network_options_key;
@@ -314,7 +338,7 @@ class Network {
314
  }
315
 
316
  /**
317
- * Wrapper for the settings API to work on the network settings page
318
  */
319
  public function network_options_action() {
320
  $allowed_referers = array(
@@ -371,13 +395,15 @@ class Network {
371
  }
372
 
373
  /**
374
- * Add the Site filter to the Network records screen
375
  *
376
  * @filter wp_mainwp_stream_list_table_filters
377
  *
378
- * @param $filters
379
  *
380
- * @return array
 
 
381
  */
382
  public function list_table_filters( $filters ) {
383
  if ( ! is_network_admin() || wp_is_large_network() ) {
@@ -386,7 +412,7 @@ class Network {
386
 
387
  $blogs = array();
388
 
389
- // Display network blog as the first option
390
  $network_blog = $this->get_network_blog();
391
 
392
  $blogs[ $network_blog->blog_id ] = array(
@@ -394,7 +420,7 @@ class Network {
394
  'disabled' => '',
395
  );
396
 
397
- // add all sites
398
  foreach ( wp_mainwp_stream_get_sites() as $blog ) {
399
  $blog_data = get_blog_details( $blog->blog_id );
400
 
@@ -413,11 +439,11 @@ class Network {
413
  }
414
 
415
  /**
416
- * Add the Site toggle to screen options in network admin
417
  *
418
- * @param $filters
419
  *
420
- * @return array
421
  */
422
  public function toggle_filters( $filters ) {
423
  if ( is_network_admin() ) {
@@ -428,11 +454,11 @@ class Network {
428
  }
429
 
430
  /**
431
- * Add the network suffix to the $screen_id when in the network admin
432
  *
433
- * @param $screen_id
434
  *
435
- * @return string
436
  */
437
  public function list_table_screen_id( $screen_id ) {
438
  if ( $screen_id && is_network_admin() ) {
@@ -445,22 +471,24 @@ class Network {
445
  }
446
 
447
  /**
448
- * Set blog_id for network admin activity
449
  *
450
- * @return int
 
 
451
  */
452
  public function blog_id_logged( $blog_id ) {
453
  return is_network_admin() ? 0 : $blog_id;
454
  }
455
 
456
  /**
457
- * Customize query args on multisite installs
458
  *
459
  * @filter wp_mainwp_stream_query_args
460
  *
461
- * @param array $args
462
  *
463
- * @return array
464
  */
465
  public function network_query_args( $args ) {
466
  $args['site_id'] = is_numeric( $args['site_id'] ) ? $args['site_id'] : get_current_site()->id;
@@ -470,13 +498,13 @@ class Network {
470
  }
471
 
472
  /**
473
- * Add site count to the page title in the network admin
474
  *
475
  * @filter wp_mainwp_stream_admin_page_title
476
  *
477
- * @param string $page_title
478
  *
479
- * @return string
480
  */
481
  public function network_admin_page_title( $page_title ) {
482
  if ( is_network_admin() ) {
@@ -489,11 +517,11 @@ class Network {
489
  }
490
 
491
  /**
492
- * Add the Site column to the network stream records
493
  *
494
- * @param $columns
495
  *
496
- * @return mixed
497
  */
498
  public function network_admin_columns( $columns ) {
499
  if ( is_network_admin() || $this->ajax_network_admin() ) {
@@ -510,11 +538,11 @@ class Network {
510
  }
511
 
512
  /**
513
- * Prevent the Blogs connector from loading when not in Network Admin
514
  *
515
- * @param $connectors
516
  *
517
- * @return mixed
518
  */
519
  public function hide_blogs_connector( $connectors ) {
520
  if ( ! is_network_admin() ) {
1
  <?php
2
+ /** MainWP Child Reports network. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Network.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Network {
11
+
12
+ /** @var Plugin Hold Plugin class */
 
 
13
  public $plugin;
14
 
15
+ /** @var string Network settings page slug. */
16
+ public $network_settings_page_slug = 'wp_mainwp_stream_network_settings';
17
+
18
+ /** @var string Default settings page slug. */
19
+ public $default_settings_page_slug = 'wp_mainwp_stream_default_settings';
20
 
21
+ /**
22
+ * Network constructor.
23
+ *
24
+ * @param Plugin $plugin Plugin class.
25
+ *
26
+ * @uses \WP_MainWP_Stream\Network::is_network_activated()
27
+ */
28
+ public function __construct( $plugin ) {
29
 
 
30
  $this->plugin = $plugin;
31
 
32
+ // Always add default site_id/blog_id params when multisite.
33
  if ( is_multisite() ) {
34
  add_filter( 'wp_mainwp_stream_query_args', array( $this, 'network_query_args' ) );
35
  }
36
 
37
+ // Bail early if not network-activated.
38
  if ( ! $this->is_network_activated() ) {
39
  return;
40
  }
41
 
42
+ // Actions.
43
  add_action( 'init', array( $this, 'ajax_network_admin' ) );
44
 
45
  // DISABLED
65
  }
66
 
67
  /**
68
+ * Workaround to get admin-ajax.php to know when the request is from the Network Admin.
69
  *
70
+ * @return bool TRUE|FASLE.
71
  *
72
  * @action init
73
+ *
74
+ * @return bool|WP_NETWORK_ADMIN Return FALSE or WP_NETWORK_ADMIN global variable.
75
+ *
76
  * @see https://core.trac.wordpress.org/ticket/22589
77
  */
78
  public function ajax_network_admin() {
91
  }
92
 
93
  /**
94
+ * Builds a stdClass object used when displaying actions done in network administration.
95
  *
96
+ * @return object $blog Return \stdClass()
97
  */
98
  public function get_network_blog() {
99
  $blog = new \stdClass();
104
  }
105
 
106
  /**
107
+ * Check if Stream Network activated.
108
  *
109
+ * @return bool Returns true if Stream is network activated, otherwise false.
110
+ *
111
+ * @uses \WP_MainWP_Stream\Network::is_mustuse()
112
  */
113
  public function is_network_activated() {
114
  if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
123
  }
124
 
125
  /**
126
+ * Check if Stream is a must-use plugin.
127
  *
128
+ * @return bool Returns true if Stream is a must-use plugin, otherwise false
129
  */
130
  public function is_mustuse() {
131
 
139
  }
140
 
141
  /**
142
+ * Add Network Settings and Default Settings menu items.
143
  *
144
+ * @return array|void Returns render settings page or does nothing.
145
+ *
146
+ * @deprecated DISABLED
147
  */
148
+ public function admin_menu_screens() {
 
149
  if ( ! is_network_admin() ) {
150
  return;
151
  }
164
  }
165
 
166
  /**
167
+ * Remove records when records TTL is shortened.
168
  *
169
+ * @param string $option_key Option Key to remove.
170
+ * @param array $new_value New Option Key value.
171
+ * @param array $old_value Old Option Key value.
172
  *
173
  * @action update_option_wp_stream
 
174
  */
175
  public function updated_option_ttl_remove_records( $option_key, $new_value, $old_value ) {
176
  unset( $option_key );
178
  }
179
 
180
  /**
181
+ * Adjust the action of the settings form when in the Network Admin.
182
  *
183
+ * @param $action Settings form Action.
184
  *
185
+ * @return string $action Return new action.
186
  */
187
  public function settings_form_action( $action ) {
188
  if ( is_network_admin() ) {
200
  /**
201
  * Add a description to each of the Settings pages in the Network Admin
202
  *
203
+ * @param $description Settings page description.
204
  *
205
+ * @return string $description Return the correct setting page description.
206
  */
207
  public function settings_form_description( $description ) {
208
  if ( ! is_network_admin() ) {
226
  /**
227
  * Adjusts the settings fields displayed in various network admin screens
228
  *
229
+ * @param array $fields Settings fields.
230
  *
231
+ * @return array $fields Return adjusted settings fields.
232
+ *
233
+ * @uses \WP_MainWP_Stream\Network::is_network_activated()
234
  */
235
  public function get_network_admin_fields( $fields ) {
236
  if ( ! $this->is_network_activated() ) {
267
  )
268
  );
269
 
270
+ // Remove settings based on context.
271
  if ( $this->plugin->settings->network_options_key === $this->plugin->settings->option_key ) {
272
  $hidden_options = $network_hidden_options;
273
  } else {
286
  }
287
  }
288
 
289
+ // Add settings based on context.
290
  if ( $this->plugin->settings->network_options_key === $this->plugin->settings->option_key ) {
291
  $new_fields['general']['fields'][] = array(
292
  'name' => 'site_access',
300
  $fields = array_merge_recursive( $new_fields, $fields );
301
  }
302
 
303
+ // Remove empty settings sections.
304
  foreach ( $fields as $section_key => $section ) {
305
  if ( empty( $section['fields'] ) ) {
306
  unset( $fields[ $section_key ] );
311
  }
312
 
313
  /**
314
+ * Get translations of serialized Stream Network settings.
315
  *
316
  * @filter wp_mainwp_stream_serialized_labels
317
  *
318
+ * @param array $labels Filed labels.
319
+ *
320
+ * @return array $labels Multidimensional array of fields
321
+ *
322
+ * @uses \WP_MainWP_Stream\Network::$plugin::settings::get_fields()
323
  */
324
  public function get_settings_translations( $labels ) {
325
  $network_key = $this->plugin->settings->network_options_key;
338
  }
339
 
340
  /**
341
+ * Wrapper for the settings API to work on the network settings page.
342
  */
343
  public function network_options_action() {
344
  $allowed_referers = array(
395
  }
396
 
397
  /**
398
+ * Add the Site filters to the Network records screen.
399
  *
400
  * @filter wp_mainwp_stream_list_table_filters
401
  *
402
+ * @param array $filters Site filter.
403
  *
404
+ * @return array $filters Return site filters.
405
+ *
406
+ * @uses \WP_MainWP_Stream\Network::get_network_blog()
407
  */
408
  public function list_table_filters( $filters ) {
409
  if ( ! is_network_admin() || wp_is_large_network() ) {
412
 
413
  $blogs = array();
414
 
415
+ // Display network blog as the first option.
416
  $network_blog = $this->get_network_blog();
417
 
418
  $blogs[ $network_blog->blog_id ] = array(
420
  'disabled' => '',
421
  );
422
 
423
+ // Add all sites.
424
  foreach ( wp_mainwp_stream_get_sites() as $blog ) {
425
  $blog_data = get_blog_details( $blog->blog_id );
426
 
439
  }
440
 
441
  /**
442
+ * Add the Site toggle to screen options in network admin.
443
  *
444
+ * @param array $filters Site filters.
445
  *
446
+ * @return array $filters Site filters.
447
  */
448
  public function toggle_filters( $filters ) {
449
  if ( is_network_admin() ) {
454
  }
455
 
456
  /**
457
+ * Add the network suffix to the $screen_id when in the network admin.
458
  *
459
+ * @param string $screen_id Screen ID.
460
  *
461
+ * @return string Return $screen_id the altered screen ID.
462
  */
463
  public function list_table_screen_id( $screen_id ) {
464
  if ( $screen_id && is_network_admin() ) {
471
  }
472
 
473
  /**
474
+ * Set blog_id for network admin activity.
475
  *
476
+ * @param int $blog_id Blog ID.
477
+ *
478
+ * @return int $blog_id Blog ID.
479
  */
480
  public function blog_id_logged( $blog_id ) {
481
  return is_network_admin() ? 0 : $blog_id;
482
  }
483
 
484
  /**
485
+ * Customize query args on multisite installs.
486
  *
487
  * @filter wp_mainwp_stream_query_args
488
  *
489
+ * @param array $args Query arguments.
490
  *
491
+ * @return array $args Return Multisite query arguments.
492
  */
493
  public function network_query_args( $args ) {
494
  $args['site_id'] = is_numeric( $args['site_id'] ) ? $args['site_id'] : get_current_site()->id;
498
  }
499
 
500
  /**
501
+ * Add site count to the page title in the network admin.
502
  *
503
  * @filter wp_mainwp_stream_admin_page_title
504
  *
505
+ * @param string $page_title Current page title.
506
  *
507
+ * @return string $page_title Return altered page title.
508
  */
509
  public function network_admin_page_title( $page_title ) {
510
  if ( is_network_admin() ) {
517
  }
518
 
519
  /**
520
+ * Add the Site column to the network stream records.
521
  *
522
+ * @param arrray $columns Current site columns.
523
  *
524
+ * @return array $columns Return updated site columns.
525
  */
526
  public function network_admin_columns( $columns ) {
527
  if ( is_network_admin() || $this->ajax_network_admin() ) {
538
  }
539
 
540
  /**
541
+ * Prevent the Blogs connector from loading when not in Network Admin.
542
  *
543
+ * @param array $connectors Connectors array.
544
  *
545
+ * @return array $connectors Return difference array.
546
  */
547
  public function hide_blogs_connector( $connectors ) {
548
  if ( ! is_network_admin() ) {
classes/class-plugin.php CHANGED
@@ -1,76 +1,53 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Plugin {
5
- /**
6
- * Plugin version number
7
- *
8
- * @const string
9
- */
10
  const VERSION = '3.5.5';
11
 
12
- /**
13
- * WP-CLI command
14
- *
15
- * @const string
16
- */
17
  const WP_CLI_COMMAND = 'mainwp_stream';
18
 
19
- /**
20
- * @var Admin
21
- */
22
  public $admin;
23
 
24
- /**
25
- * @var Alerts
26
- */
27
  public $alerts;
28
 
29
- /**
30
- * @var Alerts_List
31
- */
32
  public $alerts_list;
33
 
34
- /**
35
- * @var Connectors
36
- */
37
  public $connectors;
38
 
39
- /**
40
- * @var DB
41
- */
42
  public $db;
43
 
44
- /**
45
- * @var Log
46
- */
47
  public $log;
48
 
49
- /**
50
- * @var Settings
51
- */
52
  public $settings;
53
 
54
- /**
55
- * @var Install
56
- */
57
  public $install;
58
 
59
- /**
60
- * URLs and Paths used by the plugin
61
- *
62
- * @var array
63
- */
64
  public $locations = array();
65
 
66
 
67
- /**
68
- * @var Child_Helper
69
- */
70
  public $child_helper;
71
 
72
  /**
73
- * Class constructor
74
  */
75
  public function __construct() {
76
  $locate = $this->locate_plugin();
@@ -85,10 +62,10 @@ class Plugin {
85
 
86
  spl_autoload_register( array( $this, 'autoload' ) );
87
 
88
- // Load helper functions
89
  require_once $this->locations['inc_dir'] . 'functions.php';
90
 
91
- // Load DB helper interface/class
92
  $driver_class = apply_filters( 'wp_mainwp_stream_db_driver', '\WP_MainWP_Stream\DB_Driver_WPDB' );
93
  $driver = null;
94
 
@@ -111,20 +88,20 @@ class Plugin {
111
  );
112
  }
113
 
114
- // Load languages
115
  add_action( 'plugins_loaded', array( $this, 'i18n' ) );
116
 
117
  // Load logger class
118
  $this->log = apply_filters( 'wp_mainwp_stream_log_handler', new Log( $this ) );
119
 
120
- // Load settings and connectors after widgets_init and before the default init priority
121
  add_action( 'init', array( $this, 'init' ), 9 );
122
 
123
 
124
- // Change DB driver after plugin loaded if any add-ons want to replace
125
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 20 );
126
 
127
- // Load admin area classes
128
  if ( is_admin() || ( defined( 'WP_MAINWP_STREAM_DEV_DEBUG' ) && WP_MAINWP_STREAM_DEV_DEBUG ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
129
  $this->admin = new Admin( $this );
130
  $this->install = $driver->setup_storage( $this );
@@ -133,14 +110,14 @@ class Plugin {
133
  }
134
  $this->child_helper = new MainWP_Child_Report_Helper( $this );
135
 
136
- // Load WP-CLI command
137
  if ( defined( 'WP_CLI' ) && WP_CLI ) {
138
  \WP_CLI::add_command( self::WP_CLI_COMMAND, 'WP_MainWP_Stream\CLI' );
139
  }
140
  }
141
 
142
  /**
143
- * Autoloader for classes
144
  *
145
  * @param string $class
146
  */
@@ -177,8 +154,8 @@ class Plugin {
177
  load_plugin_textdomain( 'mainwp-child-reports', false, dirname( $this->locations['plugin'] ) . '/languages/' );
178
  }
179
 
180
- /*
181
- * Load Settings, Notifications, and Connectors
182
  *
183
  * @action init
184
  */
@@ -217,7 +194,7 @@ class Plugin {
217
  }
218
 
219
  /**
220
- * Change plugin database driver in case driver plugin loaded after stream
221
  */
222
  public function plugins_loaded() {
223
  // Load DB helper interface/class
1
  <?php
2
+ /** MainWP Child Reports plugin. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Plugin.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Plugin {
11
+
12
+ /** @const string Plugin version number. */
 
 
 
13
  const VERSION = '3.5.5';
14
 
15
+ /** @const string WP-CLI command. */
 
 
 
 
16
  const WP_CLI_COMMAND = 'mainwp_stream';
17
 
18
+ /** @var \WP_MainWP_Stream\Admin Admin class. */
 
 
19
  public $admin;
20
 
21
+ /** @var \WP_MainWP_Stream\Alerts Alerts class. */
 
 
22
  public $alerts;
23
 
24
+ /** @var \WP_MainWP_Stream\Alerts_List Alerts_List class. */
 
 
25
  public $alerts_list;
26
 
27
+ /** @var \WP_MainWP_Stream\Connectors Connectors class. */
 
 
28
  public $connectors;
29
 
30
+ /** @var \WP_MainWP_Stream\DB DB Class. */
 
 
31
  public $db;
32
 
33
+ /** @var \WP_MainWP_Stream\Log Log Class. */
 
 
34
  public $log;
35
 
36
+ /** @var \WP_MainWP_Stream\Settings Settings class. */
 
 
37
  public $settings;
38
 
39
+ /** @var \WP_MainWP_Stream\Install Install class. */
 
 
40
  public $install;
41
 
42
+ /** @var array URLs and Paths used by the plugin. */
 
 
 
 
43
  public $locations = array();
44
 
45
 
46
+ /** @var \WP_MainWP_Stream\Child_Helper Child_Helper class. */
 
 
47
  public $child_helper;
48
 
49
  /**
50
+ * Class constructor.
51
  */
52
  public function __construct() {
53
  $locate = $this->locate_plugin();
62
 
63
  spl_autoload_register( array( $this, 'autoload' ) );
64
 
65
+ // Load helper functions.
66
  require_once $this->locations['inc_dir'] . 'functions.php';
67
 
68
+ // Load DB helper interface/class.
69
  $driver_class = apply_filters( 'wp_mainwp_stream_db_driver', '\WP_MainWP_Stream\DB_Driver_WPDB' );
70
  $driver = null;
71
 
88
  );
89
  }
90
 
91
+ // Load languages.
92
  add_action( 'plugins_loaded', array( $this, 'i18n' ) );
93
 
94
  // Load logger class
95
  $this->log = apply_filters( 'wp_mainwp_stream_log_handler', new Log( $this ) );
96
 
97
+ // Load settings and connectors after widgets_init and before the default init priority.
98
  add_action( 'init', array( $this, 'init' ), 9 );
99
 
100
 
101
+ // Change DB driver after plugin loaded if any add-ons want to replace.
102
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 20 );
103
 
104
+ // Load admin area classes.
105
  if ( is_admin() || ( defined( 'WP_MAINWP_STREAM_DEV_DEBUG' ) && WP_MAINWP_STREAM_DEV_DEBUG ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
106
  $this->admin = new Admin( $this );
107
  $this->install = $driver->setup_storage( $this );
110
  }
111
  $this->child_helper = new MainWP_Child_Report_Helper( $this );
112
 
113
+ // Load WP-CLI command.
114
  if ( defined( 'WP_CLI' ) && WP_CLI ) {
115
  \WP_CLI::add_command( self::WP_CLI_COMMAND, 'WP_MainWP_Stream\CLI' );
116
  }
117
  }
118
 
119
  /**
120
+ * Autoloader for classes.
121
  *
122
  * @param string $class
123
  */
154
  load_plugin_textdomain( 'mainwp-child-reports', false, dirname( $this->locations['plugin'] ) . '/languages/' );
155
  }
156
 
157
+ /**
158
+ * Load Settings, Notifications, and Connectors.
159
  *
160
  * @action init
161
  */
194
  }
195
 
196
  /**
197
+ * Change plugin database driver in case driver plugin loaded after stream.
198
  */
199
  public function plugins_loaded() {
200
  // Load DB helper interface/class
classes/class-preview-list-table.php CHANGED
@@ -1,7 +1,12 @@
1
  <?php
 
2
 
3
  namespace WP_MainWP_Stream;
4
 
 
 
 
 
5
  class Preview_List_Table extends List_Table {
6
 
7
  /**
1
  <?php
2
+ /** MainWP CHild Reports preview list table. */
3
 
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Preview_List_Table.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Preview_List_Table extends List_Table {
11
 
12
  /**
classes/class-query.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Query {
5
  /**
6
  * Hold the number of records found
@@ -17,6 +23,8 @@ class Query {
17
  * @return array Stream Records
18
  */
19
  public function query( $args ) {
 
 
20
  global $wpdb;
21
 
22
  $join = '';
1
  <?php
2
+ /** MainWP Child Reports query. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Query.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Query {
11
  /**
12
  * Hold the number of records found
23
  * @return array Stream Records
24
  */
25
  public function query( $args ) {
26
+
27
+ /** @global object $wpdb WordPress Database instance. */
28
  global $wpdb;
29
 
30
  $join = '';
classes/class-record.php CHANGED
@@ -1,23 +1,62 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Record {
5
- public $ID;
6
- public $created;
7
- public $site_id;
8
- public $blog_id;
9
- public $object_id;
10
- public $user_id;
11
- public $user_role;
12
- public $user_meta;
13
- public $summary;
14
- public $connector;
15
- public $context;
16
- public $action;
17
- public $ip;
18
- public $meta;
19
-
20
- public function __construct( $item ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  $this->ID = isset( $item->ID ) ? $item->ID : null;
22
  $this->created = isset( $item->created ) ? $item->created : null;
23
  $this->site_id = isset( $item->site_id ) ? $item->site_id : null;
@@ -38,7 +77,12 @@ class Record {
38
  }
39
  }
40
 
41
- public function save() {
 
 
 
 
 
42
  if ( ! $this->validate() ) {
43
  return new \WP_Error( 'validation-error', esc_html__( 'Could not validate record data.', 'mainwp-child-reports' ) );
44
  }
@@ -46,7 +90,12 @@ class Record {
46
  return wp_mainwp_stream_get_instance()->db->insert( (array) $this );
47
  }
48
 
49
- public function populate( array $raw ) {
 
 
 
 
 
50
  $keys = get_class_vars( $this );
51
  $data = array_intersect_key( $raw, $keys );
52
  foreach ( $data as $key => $val ) {
@@ -54,30 +103,35 @@ class Record {
54
  }
55
  }
56
 
57
- public function validate() {
 
 
 
 
 
58
  return true;
59
  }
60
 
61
  /**
62
- * Query record meta
63
  *
64
- * @param string $meta_key (optional)
65
- * @param bool $single (optional)
66
  *
67
- * @return array
68
  */
69
  public function get_meta( $meta_key = '', $single = false ) {
70
  return get_metadata( 'record', $this->ID, $meta_key, $single );
71
  }
72
 
73
  /**
74
- * Update record meta
75
  *
76
- * @param string $meta_key
77
- * @param mixed $meta_value
78
- * @param mixed $prev_value (optional)
79
  *
80
- * @return bool
81
  */
82
  public function update_meta( $meta_key, $meta_value, $prev_value = '' ) {
83
  return update_metadata( 'record', $this->ID, $meta_key, $meta_value, $prev_value );
@@ -85,9 +139,8 @@ class Record {
85
 
86
  /**
87
  * Determine the title of an object that a record is for.
88
- *
89
- * @param object Record object
90
- * @return mixed The title of the object as a string, otherwise false
91
  */
92
  public function get_object_title() {
93
  if ( ! isset( $this->object_id ) || empty( $this->object_id ) ) {
1
  <?php
2
+ /** MainWP Child Reports record. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Record.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Record {
11
+
12
+ /** @var mixed|null Record ID. */
13
+ public $ID;
14
+
15
+ /** @var mixed|null Record Timestamp. */
16
+ public $created;
17
+
18
+ /** @var mixed|null Child Site ID. */
19
+ public $site_id;
20
+
21
+ /** @var mixed|null Blog ID. */
22
+ public $blog_id;
23
+
24
+ /** @var mixed|null Object ID. */
25
+ public $object_id;
26
+
27
+ /** @var mixed|null User ID. */
28
+ public $user_id;
29
+
30
+ /** @var mixed|null User Role. */
31
+ public $user_role;
32
+
33
+ /** @var mixed|null User Meta. */
34
+ public $user_meta;
35
+
36
+ /** @var mixed|null Record summary. */
37
+ public $summary;
38
+
39
+ /** @var mixed|null Connector to use. */
40
+ public $connector;
41
+
42
+ /** @var mixed|null Context of action. */
43
+ public $context;
44
+
45
+ /** @var mixed|null Action to perform. */
46
+ public $action;
47
+
48
+ /** @var mixed|null User IP address. */
49
+ public $ip;
50
+
51
+ /** @var mixed|null Meta Data. */
52
+ public $meta;
53
+
54
+ /**
55
+ * Record constructor.
56
+ *
57
+ * @param array $item Record.
58
+ */
59
+ public function __construct( $item ) {
60
  $this->ID = isset( $item->ID ) ? $item->ID : null;
61
  $this->created = isset( $item->created ) ? $item->created : null;
62
  $this->site_id = isset( $item->site_id ) ? $item->site_id : null;
77
  }
78
  }
79
 
80
+ /**
81
+ * Save Record.
82
+ *
83
+ * @return false|int|\WP_Error Return FALSE on failure along with error message or return ID of record updated.
84
+ */
85
+ public function save() {
86
  if ( ! $this->validate() ) {
87
  return new \WP_Error( 'validation-error', esc_html__( 'Could not validate record data.', 'mainwp-child-reports' ) );
88
  }
90
  return wp_mainwp_stream_get_instance()->db->insert( (array) $this );
91
  }
92
 
93
+ /**
94
+ * Populate array.
95
+ *
96
+ * @param array $raw Raw data.
97
+ */
98
+ public function populate(array $raw ) {
99
  $keys = get_class_vars( $this );
100
  $data = array_intersect_key( $raw, $keys );
101
  foreach ( $data as $key => $val ) {
103
  }
104
  }
105
 
106
+ /**
107
+ * Validation method.
108
+ *
109
+ * @return bool Default: true.
110
+ */
111
+ public function validate() {
112
  return true;
113
  }
114
 
115
  /**
116
+ * Query record meta.
117
  *
118
+ * @param string $meta_key Meta Key (optional).
119
+ * @param bool $single Whether or not this is a single record (optional). Default: false.
120
  *
121
+ * @return array Return record query.
122
  */
123
  public function get_meta( $meta_key = '', $single = false ) {
124
  return get_metadata( 'record', $this->ID, $meta_key, $single );
125
  }
126
 
127
  /**
128
+ * Update record meta.
129
  *
130
+ * @param string $meta_key Meta Key
131
+ * @param mixed $meta_value Meta value.
132
+ * @param mixed $prev_value Prev Meta value (optional).
133
  *
134
+ * @return bool Return TRUE if record has been updated successfully or FALSE on failure.
135
  */
136
  public function update_meta( $meta_key, $meta_value, $prev_value = '' ) {
137
  return update_metadata( 'record', $this->ID, $meta_key, $meta_value, $prev_value );
139
 
140
  /**
141
  * Determine the title of an object that a record is for.
142
+ *
143
+ * @return string|bool The title of the object as a string, otherwise false.
 
144
  */
145
  public function get_object_title() {
146
  if ( ! isset( $this->object_id ) || empty( $this->object_id ) ) {
classes/class-settings.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
 
3
  namespace WP_MainWP_Stream;
4
 
@@ -6,6 +7,10 @@ use \WP_Roles;
6
  use \WP_User;
7
  use \WP_User_Query;
8
 
 
 
 
 
9
  class Settings {
10
 
11
  /**
@@ -1170,7 +1175,8 @@ class Settings {
1170
  * Get translations of serialized Stream settings
1171
  *
1172
  * @filter wp_mainwp_stream_serialized_labels
1173
- *
 
1174
  * @return array Multidimensional array of fields
1175
  */
1176
  public function get_settings_translations( $labels ) {
1
  <?php
2
+ /** MainWP Child Report settings. */
3
 
4
  namespace WP_MainWP_Stream;
5
 
7
  use \WP_User;
8
  use \WP_User_Query;
9
 
10
+ /**
11
+ * Class Settings.
12
+ * @package WP_MainWP_Stream
13
+ */
14
  class Settings {
15
 
16
  /**
1175
  * Get translations of serialized Stream settings
1176
  *
1177
  * @filter wp_mainwp_stream_serialized_labels
1178
+ * @param array $labels Labels array.
1179
+ *
1180
  * @return array Multidimensional array of fields
1181
  */
1182
  public function get_settings_translations( $labels ) {
classes/class-uninstall.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Uninstall {
5
  /**
6
  * Hold Plugin class
@@ -22,6 +28,10 @@ class Uninstall {
22
  */
23
  public $user_meta;
24
 
 
 
 
 
25
  public function __construct( $plugin ) {
26
  $this->plugin = $plugin;
27
 
@@ -83,6 +93,8 @@ class Uninstall {
83
  * Delete the Stream database tables
84
  */
85
  private function delete_all_records() {
 
 
86
  global $wpdb;
87
 
88
  $wpdb->query( "DROP TABLE {$wpdb->mainwp_stream}" );
@@ -99,6 +111,7 @@ class Uninstall {
99
  return;
100
  }
101
 
 
102
  global $wpdb;
103
 
104
  $wpdb->query(
@@ -117,6 +130,8 @@ class Uninstall {
117
  * Delete all options
118
  */
119
  private function delete_all_options() {
 
 
120
  global $wpdb;
121
 
122
  // Wildcard matches
@@ -151,6 +166,7 @@ class Uninstall {
151
  return;
152
  }
153
 
 
154
  global $wpdb;
155
 
156
  // Wildcard matches
@@ -166,6 +182,8 @@ class Uninstall {
166
  * Delete all user meta
167
  */
168
  private function delete_all_user_meta() {
 
 
169
  global $wpdb;
170
 
171
  // Wildcard matches
@@ -189,6 +207,7 @@ class Uninstall {
189
  return;
190
  }
191
 
 
192
  global $wpdb;
193
 
194
  // Wildcard matches
1
  <?php
2
+ /** MainWP Child Reports uninstall. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Uninstall.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Uninstall {
11
  /**
12
  * Hold Plugin class
28
  */
29
  public $user_meta;
30
 
31
+ /**
32
+ * Uninstall constructor.
33
+ * @param object $plugin Plugin class.
34
+ */
35
  public function __construct( $plugin ) {
36
  $this->plugin = $plugin;
37
 
93
  * Delete the Stream database tables
94
  */
95
  private function delete_all_records() {
96
+
97
+ /** @global object $wpdb WordPress Database instance. */
98
  global $wpdb;
99
 
100
  $wpdb->query( "DROP TABLE {$wpdb->mainwp_stream}" );
111
  return;
112
  }
113
 
114
+ /** @global object $wpdb WordPress Database instance. */
115
  global $wpdb;
116
 
117
  $wpdb->query(
130
  * Delete all options
131
  */
132
  private function delete_all_options() {
133
+
134
+ /** @global object $wpdb WordPress Database instance. */
135
  global $wpdb;
136
 
137
  // Wildcard matches
166
  return;
167
  }
168
 
169
+ /** @global object $wpdb WordPress Database instance. */
170
  global $wpdb;
171
 
172
  // Wildcard matches
182
  * Delete all user meta
183
  */
184
  private function delete_all_user_meta() {
185
+
186
+ /** @global object $wpdb WordPress Database instance. */
187
  global $wpdb;
188
 
189
  // Wildcard matches
207
  return;
208
  }
209
 
210
+ /** @global object $wpdb WordPress Database instance. */
211
  global $wpdb;
212
 
213
  // Wildcard matches
classes/debug.log DELETED
@@ -1,42 +0,0 @@
1
- [08-Nov-2019 11:30:04 UTC] =========000000000=========1573212604
2
- [08-Nov-2019 11:30:04 UTC] =========3333333333=========Array
3
- (
4
- [0] => stdClass Object
5
- (
6
- [ID] => 508
7
- [site_id] => 1
8
- [blog_id] => 1
9
- [object_id] =>
10
- [user_id] => 1
11
- [user_role] => administrator
12
- [summary] => Sucuri scan successful!
13
- [created] => 2019-11-05 15:05:55
14
- [connector] => mainwp_sucuri
15
- [context] => sucuri_scan
16
- [action] => sucuri_scan
17
- [ip] => 112.213.89.26
18
- )
19
-
20
- )
21
-
22
- [08-Nov-2019 11:30:05 UTC] =========000000000=========1573212593
23
- [08-Nov-2019 11:30:05 UTC] =========3333333333=========Array
24
- (
25
- [0] => stdClass Object
26
- (
27
- [ID] => 508
28
- [site_id] => 1
29
- [blog_id] => 1
30
- [object_id] =>
31
- [user_id] => 1
32
- [user_role] => administrator
33
- [summary] => Sucuri scan successful!
34
- [created] => 2019-11-05 15:05:55
35
- [connector] => mainwp_sucuri
36
- [context] => sucuri_scan
37
- [action] => sucuri_scan
38
- [ip] => 112.213.89.26
39
- )
40
-
41
- )
42
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
connectors/class-connector-acf.php CHANGED
@@ -1,23 +1,31 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
 
4
  class Connector_ACF extends Connector {
 
5
  /**
6
- * Connector slug
7
  *
8
  * @var string
9
  */
10
  public $name = 'acf';
11
 
12
  /**
13
- * Holds tracked plugin minimum version required
14
  *
15
  * @const string
16
  */
17
  const PLUGIN_MIN_VERSION = '4.3.8';
18
 
19
  /**
20
- * Actions registered for this connector
21
  *
22
  * @var array
23
  */
@@ -35,14 +43,14 @@ class Connector_ACF extends Connector {
35
  );
36
 
37
  /**
38
- * Cached location rules, used in shutdown callback to verify changes in meta
39
  *
40
  * @var array
41
  */
42
  public $cached_location_rules = array();
43
 
44
  /**
45
- * Cached field values updates, used by shutdown callback to verify actual changes
46
  *
47
  * @var array
48
  */
@@ -50,7 +58,7 @@ class Connector_ACF extends Connector {
50
 
51
 
52
  /**
53
- * Check if plugin dependencies are satisfied and add an admin notice if not
54
  *
55
  * @return bool
56
  */
@@ -66,7 +74,7 @@ class Connector_ACF extends Connector {
66
  }
67
 
68
  /**
69
- * Return translated connector label
70
  *
71
  * @return string Translated connector label
72
  */
@@ -75,7 +83,7 @@ class Connector_ACF extends Connector {
75
  }
76
 
77
  /**
78
- * Return translated action labels
79
  *
80
  * @return array Action label translations
81
  */
@@ -89,7 +97,7 @@ class Connector_ACF extends Connector {
89
  }
90
 
91
  /**
92
- * Return translated context labels
93
  *
94
  * @return array Context label translations
95
  */
@@ -104,13 +112,13 @@ class Connector_ACF extends Connector {
104
  }
105
 
106
  /**
107
- * Register the connector
108
  */
109
  public function register() {
110
  add_filter( 'wp_mainwp_stream_log_data', array( $this, 'log_override' ) );
111
 
112
  /**
113
- * Allow devs to disable logging values of rendered forms
114
  *
115
  * @return bool
116
  */
@@ -122,7 +130,7 @@ class Connector_ACF extends Connector {
122
  }
123
 
124
  /**
125
- * Add action links to Stream drop row in admin list screen
126
  *
127
  * @filter wp_mainwp_stream_action_links_{connector}
128
  *
@@ -139,7 +147,7 @@ class Connector_ACF extends Connector {
139
  }
140
 
141
  /**
142
- * Track addition of post meta
143
  *
144
  * @action added_post_meta
145
  */
@@ -148,7 +156,7 @@ class Connector_ACF extends Connector {
148
  }
149
 
150
  /**
151
- * Track updating post meta
152
  *
153
  * @action updated_post_meta
154
  */
@@ -157,7 +165,7 @@ class Connector_ACF extends Connector {
157
  }
158
 
159
  /**
160
- * Track deletion of post meta
161
  *
162
  * Note: Using delete_post_meta instead of deleted_post_meta to be able to
163
  * capture old field value
@@ -169,7 +177,7 @@ class Connector_ACF extends Connector {
169
  }
170
 
171
  /**
172
- * Track addition of user meta
173
  *
174
  * @action added_user_meta
175
  */
@@ -178,7 +186,7 @@ class Connector_ACF extends Connector {
178
  }
179
 
180
  /**
181
- * Track updating user meta
182
  *
183
  * @action updated_user_meta
184
  */
@@ -187,7 +195,7 @@ class Connector_ACF extends Connector {
187
  }
188
 
189
  /**
190
- * Track deletion of user meta
191
  *
192
  * Note: Using delete_user_meta instead of deleted_user_meta to be able to
193
  * capture old field value
@@ -199,7 +207,7 @@ class Connector_ACF extends Connector {
199
  }
200
 
201
  /**
202
- * Track addition of post/user meta
203
  *
204
  * @param string $type Type of object, post or user
205
  * @param string $action Added, updated, deleted
@@ -337,7 +345,7 @@ class Connector_ACF extends Connector {
337
  }
338
 
339
  /**
340
- * Track changes to ACF values within rendered post meta forms
341
  *
342
  * @param string $type Type of object, post or user
343
  * @param string $action Added, updated, deleted
@@ -423,7 +431,7 @@ class Connector_ACF extends Connector {
423
  }
424
 
425
  /**
426
- * Track changes to rules, complements post-meta updates
427
  *
428
  * @action shutdown
429
  */
@@ -459,7 +467,7 @@ class Connector_ACF extends Connector {
459
  }
460
 
461
  /**
462
- * Override connector log for our own Settings / Actions
463
  *
464
  * @param array $data
465
  *
@@ -481,7 +489,7 @@ class Connector_ACF extends Connector {
481
 
482
  /**
483
  * Track changes to custom field values updates, saves filtered values to be
484
- * processed by callback_updated_post_meta
485
  *
486
  * @param string $value
487
  * @param int $post_id
@@ -525,7 +533,7 @@ class Connector_ACF extends Connector {
525
  }
526
 
527
  /**
528
- * Track addition of new options
529
  *
530
  * @param string $key Option name
531
  * @param string $value Option value
@@ -535,7 +543,7 @@ class Connector_ACF extends Connector {
535
  }
536
 
537
  /**
538
- * Track addition of new options
539
  *
540
  * @param $key
541
  * @param $old
@@ -547,7 +555,7 @@ class Connector_ACF extends Connector {
547
  }
548
 
549
  /**
550
- * Track addition of new options
551
  *
552
  * @param $key
553
  */
@@ -556,7 +564,7 @@ class Connector_ACF extends Connector {
556
  }
557
 
558
  /**
559
- * Determines the type of option that is saved
560
  *
561
  * @param $key
562
  * @return string
1
  <?php
2
+ /** MainWP ACF Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+
7
+ /**
8
+ * Class Connector_ACF
9
+ * @package WP_MainWP_Stream
10
+ */
11
  class Connector_ACF extends Connector {
12
+
13
  /**
14
+ * Connector slug.
15
  *
16
  * @var string
17
  */
18
  public $name = 'acf';
19
 
20
  /**
21
+ * Holds tracked plugin minimum version required.
22
  *
23
  * @const string
24
  */
25
  const PLUGIN_MIN_VERSION = '4.3.8';
26
 
27
  /**
28
+ * Actions registered for this connector.
29
  *
30
  * @var array
31
  */
43
  );
44
 
45
  /**
46
+ * Cached location rules, used in shutdown callback to verify changes in meta.
47
  *
48
  * @var array
49
  */
50
  public $cached_location_rules = array();
51
 
52
  /**
53
+ * Cached field values updates, used by shutdown callback to verify actual changes.
54
  *
55
  * @var array
56
  */
58
 
59
 
60
  /**
61
+ * Check if plugin dependencies are satisfied and add an admin notice if not.
62
  *
63
  * @return bool
64
  */
74
  }
75
 
76
  /**
77
+ * Return translated connector label.
78
  *
79
  * @return string Translated connector label
80
  */
83
  }
84
 
85
  /**
86
+ * Return translated action labels.
87
  *
88
  * @return array Action label translations
89
  */
97
  }
98
 
99
  /**
100
+ * Return translated context labels.
101
  *
102
  * @return array Context label translations
103
  */
112
  }
113
 
114
  /**
115
+ * Register the connector.
116
  */
117
  public function register() {
118
  add_filter( 'wp_mainwp_stream_log_data', array( $this, 'log_override' ) );
119
 
120
  /**
121
+ * Allow devs to disable logging values of rendered forms.
122
  *
123
  * @return bool
124
  */
130
  }
131
 
132
  /**
133
+ * Add action links to Stream drop row in admin list screen.
134
  *
135
  * @filter wp_mainwp_stream_action_links_{connector}
136
  *
147
  }
148
 
149
  /**
150
+ * Track addition of post meta.
151
  *
152
  * @action added_post_meta
153
  */
156
  }
157
 
158
  /**
159
+ * Track updating post meta.
160
  *
161
  * @action updated_post_meta
162
  */
165
  }
166
 
167
  /**
168
+ * Track deletion of post meta.
169
  *
170
  * Note: Using delete_post_meta instead of deleted_post_meta to be able to
171
  * capture old field value
177
  }
178
 
179
  /**
180
+ * Track addition of user meta.
181
  *
182
  * @action added_user_meta
183
  */
186
  }
187
 
188
  /**
189
+ * Track updating user meta.
190
  *
191
  * @action updated_user_meta
192
  */
195
  }
196
 
197
  /**
198
+ * Track deletion of user meta.
199
  *
200
  * Note: Using delete_user_meta instead of deleted_user_meta to be able to
201
  * capture old field value
207
  }
208
 
209
  /**
210
+ * Track addition of post/user meta.
211
  *
212
  * @param string $type Type of object, post or user
213
  * @param string $action Added, updated, deleted
345
  }
346
 
347
  /**
348
+ * Track changes to ACF values within rendered post meta forms.
349
  *
350
  * @param string $type Type of object, post or user
351
  * @param string $action Added, updated, deleted
431
  }
432
 
433
  /**
434
+ * Track changes to rules, complements post-meta updates.
435
  *
436
  * @action shutdown
437
  */
467
  }
468
 
469
  /**
470
+ * Override connector log for our own Settings / Actions.
471
  *
472
  * @param array $data
473
  *
489
 
490
  /**
491
  * Track changes to custom field values updates, saves filtered values to be
492
+ * processed by callback_updated_post_meta.
493
  *
494
  * @param string $value
495
  * @param int $post_id
533
  }
534
 
535
  /**
536
+ * Track addition of new options.
537
  *
538
  * @param string $key Option name
539
  * @param string $value Option value
543
  }
544
 
545
  /**
546
+ * Track addition of new options.
547
  *
548
  * @param $key
549
  * @param $old
555
  }
556
 
557
  /**
558
+ * Track addition of new options.
559
  *
560
  * @param $key
561
  */
564
  }
565
 
566
  /**
567
+ * Determines the type of option that is saved.
568
  *
569
  * @param $key
570
  * @return string
connectors/class-connector-bbpress.php CHANGED
@@ -1,7 +1,14 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_BbPress extends Connector {
 
5
  /**
6
  * Connector slug
7
  *
@@ -10,14 +17,14 @@ class Connector_BbPress extends Connector {
10
  public $name = 'bbpress';
11
 
12
  /**
13
- * Holds tracked plugin minimum version required
14
  *
15
  * @const string
16
  */
17
  const PLUGIN_MIN_VERSION = '2.5.4';
18
 
19
  /**
20
- * Actions registered for this connector
21
  *
22
  * @var array
23
  */
@@ -26,7 +33,7 @@ class Connector_BbPress extends Connector {
26
  );
27
 
28
  /**
29
- * Tracked option keys
30
  *
31
  * @var array
32
  */
@@ -35,23 +42,29 @@ class Connector_BbPress extends Connector {
35
  );
36
 
37
  /**
38
- * Flag to stop logging update logic twice
39
  *
40
  * @var bool
41
  */
42
  public $is_update = false;
43
 
44
  /**
 
 
45
  * @var bool
46
  */
47
  public $_deleted_activity = false;
48
 
49
  /**
 
 
50
  * @var array
51
  */
52
  public $_delete_activity_args = array();
53
 
54
  /**
 
 
55
  * @var bool
56
  */
57
  public $ignore_activity_bulk_deletion = false;
@@ -140,6 +153,9 @@ class Connector_BbPress extends Connector {
140
  return $links;
141
  }
142
 
 
 
 
143
  public function register() {
144
  parent::register();
145
 
1
  <?php
2
+ /** MainWp Child Reports BBPress Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_BbPress.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_BbPress extends Connector {
11
+
12
  /**
13
  * Connector slug
14
  *
17
  public $name = 'bbpress';
18
 
19
  /**
20
+ * Holds tracked plugin minimum version required.
21
  *
22
  * @const string
23
  */
24
  const PLUGIN_MIN_VERSION = '2.5.4';
25
 
26
  /**
27
+ * Actions registered for this connector.
28
  *
29
  * @var array
30
  */
33
  );
34
 
35
  /**
36
+ * Tracked option keys.
37
  *
38
  * @var array
39
  */
42
  );
43
 
44
  /**
45
+ * Flag to stop logging update logic twice.
46
  *
47
  * @var bool
48
  */
49
  public $is_update = false;
50
 
51
  /**
52
+ * Flag for deleted activity.
53
+ *
54
  * @var bool
55
  */
56
  public $_deleted_activity = false;
57
 
58
  /**
59
+ * Delete activity arguments.
60
+ *
61
  * @var array
62
  */
63
  public $_delete_activity_args = array();
64
 
65
  /**
66
+ * Ignore bulk deletion activity.
67
+ *
68
  * @var bool
69
  */
70
  public $ignore_activity_bulk_deletion = false;
153
  return $links;
154
  }
155
 
156
+ /**
157
+ * Register log data.
158
+ */
159
  public function register() {
160
  parent::register();
161
 
connectors/class-connector-blogs.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Blogs extends Connector {
5
  /**
6
  * Connector slug
@@ -32,14 +38,14 @@ class Connector_Blogs extends Connector {
32
  );
33
 
34
  /**
35
- * Register connector in the WP Frontend
36
  *
37
  * @var bool
38
  */
39
  public $register_frontend = false;
40
 
41
  /**
42
- * Return translated connector label
43
  *
44
  * @return string
45
  */
@@ -48,7 +54,7 @@ class Connector_Blogs extends Connector {
48
  }
49
 
50
  /**
51
- * Return translated action labels
52
  *
53
  * @return array
54
  */
@@ -62,7 +68,7 @@ class Connector_Blogs extends Connector {
62
  }
63
 
64
  /**
65
- * Return translated context labels
66
  *
67
  * @return array
68
  */
@@ -83,7 +89,7 @@ class Connector_Blogs extends Connector {
83
  }
84
 
85
  /**
86
- * Add action links to Stream drop row in admin list screen
87
  *
88
  * @filter wp_mainwp_stream_action_links_{connector}
89
  *
@@ -118,7 +124,7 @@ class Connector_Blogs extends Connector {
118
  }
119
 
120
  /**
121
- * Blog created
122
  *
123
  * @action wpmu_new_blog
124
  *
@@ -144,7 +150,7 @@ class Connector_Blogs extends Connector {
144
  }
145
 
146
  /**
147
- * Blog registered
148
  *
149
  * @action wpmu_activate_blog
150
  *
@@ -172,7 +178,7 @@ class Connector_Blogs extends Connector {
172
  }
173
 
174
  /**
175
- * User added to a blog
176
  *
177
  * @action add_user_to_blog
178
  *
@@ -189,7 +195,7 @@ class Connector_Blogs extends Connector {
189
  }
190
 
191
  $this->log(
192
- // translators: Placeholders refer to a user's display name, a site name, and a user role (e.g. "Jane Doe", "FooBar Blog", "subscriber")
193
  _x(
194
  '%1$s was added to the "%2$s" site with %3$s capabilities',
195
  '1. User\'s name, 2. Site name, 3. Role',
@@ -207,7 +213,7 @@ class Connector_Blogs extends Connector {
207
  }
208
 
209
  /**
210
- * User removed from a blog
211
  *
212
  * @action remove_user_from_blog
213
  *
@@ -240,7 +246,7 @@ class Connector_Blogs extends Connector {
240
  }
241
 
242
  /**
243
- * Blog marked as spam
244
  *
245
  * @action make_spam_blog
246
  *
@@ -251,7 +257,7 @@ class Connector_Blogs extends Connector {
251
  }
252
 
253
  /**
254
- * Blog not marked as spam
255
  *
256
  * @action make_ham_blog
257
  *
@@ -262,7 +268,7 @@ class Connector_Blogs extends Connector {
262
  }
263
 
264
  /**
265
- * Blog marked as mature
266
  *
267
  * @action mature_blog
268
  *
@@ -273,7 +279,7 @@ class Connector_Blogs extends Connector {
273
  }
274
 
275
  /**
276
- * Blog not marked as mature
277
  *
278
  * @action unmature_blog
279
  *
@@ -284,7 +290,7 @@ class Connector_Blogs extends Connector {
284
  }
285
 
286
  /**
287
- * Blog marked as archived
288
  *
289
  * @action archive_blog
290
  *
@@ -295,7 +301,7 @@ class Connector_Blogs extends Connector {
295
  }
296
 
297
  /**
298
- * Blog not marked as archived
299
  *
300
  * @action unarchive_blog
301
  *
@@ -306,7 +312,7 @@ class Connector_Blogs extends Connector {
306
  }
307
 
308
  /**
309
- * Blog marked as deleted
310
  *
311
  * @action make_delete_blog
312
  *
@@ -317,7 +323,7 @@ class Connector_Blogs extends Connector {
317
  }
318
 
319
  /**
320
- * Blog not marked as deleted
321
  *
322
  * @action undelete_blog
323
  *
@@ -328,7 +334,7 @@ class Connector_Blogs extends Connector {
328
  }
329
 
330
  /**
331
- * Blog marked as public or private
332
  *
333
  * @action update_blog_public
334
  *
@@ -346,7 +352,7 @@ class Connector_Blogs extends Connector {
346
  }
347
 
348
  /**
349
- * Blog updated
350
  *
351
  * @action update_blog_status
352
  *
1
  <?php
2
+ /** MainWP Child Reports blogs connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_Blogs.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_Blogs extends Connector {
11
  /**
12
  * Connector slug
38
  );
39
 
40
  /**
41
+ * Register connector in the WP Frontend.
42
  *
43
  * @var bool
44
  */
45
  public $register_frontend = false;
46
 
47
  /**
48
+ * Return translated connector label.
49
  *
50
  * @return string
51
  */
54
  }
55
 
56
  /**
57
+ * Return translated action labels.
58
  *
59
  * @return array
60
  */
68
  }
69
 
70
  /**
71
+ * Return translated context labels.
72
  *
73
  * @return array
74
  */
89
  }
90
 
91
  /**
92
+ * Add action links to Stream drop row in admin list screen.
93
  *
94
  * @filter wp_mainwp_stream_action_links_{connector}
95
  *
124
  }
125
 
126
  /**
127
+ * Blog created.
128
  *
129
  * @action wpmu_new_blog
130
  *
150
  }
151
 
152
  /**
153
+ * Blog registered.
154
  *
155
  * @action wpmu_activate_blog
156
  *
178
  }
179
 
180
  /**
181
+ * User added to a blog.
182
  *
183
  * @action add_user_to_blog
184
  *
195
  }
196
 
197
  $this->log(
198
+ // translators: Placeholders refer to a user's display name, a site name, and a user role (e.g. "Jane Doe", "FooBar Blog", "subscriber").
199
  _x(
200
  '%1$s was added to the "%2$s" site with %3$s capabilities',
201
  '1. User\'s name, 2. Site name, 3. Role',
213
  }
214
 
215
  /**
216
+ * User removed from a blog.
217
  *
218
  * @action remove_user_from_blog
219
  *
246
  }
247
 
248
  /**
249
+ * Blog marked as spam.
250
  *
251
  * @action make_spam_blog
252
  *
257
  }
258
 
259
  /**
260
+ * Blog not marked as spam.
261
  *
262
  * @action make_ham_blog
263
  *
268
  }
269
 
270
  /**
271
+ * Blog marked as mature.
272
  *
273
  * @action mature_blog
274
  *
279
  }
280
 
281
  /**
282
+ * Blog not marked as mature.
283
  *
284
  * @action unmature_blog
285
  *
290
  }
291
 
292
  /**
293
+ * Blog marked as archived.
294
  *
295
  * @action archive_blog
296
  *
301
  }
302
 
303
  /**
304
+ * Blog not marked as archived.
305
  *
306
  * @action unarchive_blog
307
  *
312
  }
313
 
314
  /**
315
+ * Blog marked as deleted.
316
  *
317
  * @action make_delete_blog
318
  *
323
  }
324
 
325
  /**
326
+ * Blog not marked as deleted.
327
  *
328
  * @action undelete_blog
329
  *
334
  }
335
 
336
  /**
337
+ * Blog marked as public or private.
338
  *
339
  * @action update_blog_public
340
  *
352
  }
353
 
354
  /**
355
+ * Blog updated.
356
  *
357
  * @action update_blog_status
358
  *
connectors/class-connector-buddypress.php CHANGED
@@ -1,28 +1,25 @@
1
  <?php
 
2
 
3
  namespace WP_MainWP_Stream;
4
 
 
 
 
 
5
  class Connector_BuddyPress extends Connector {
6
 
7
- /**
8
- * Connector slug
9
- *
10
- * @var string
11
- */
12
  public $name = 'buddypress';
13
 
14
- /**
15
- * Holds tracked plugin minimum version required
16
- *
17
- * @const string
18
- */
19
  const PLUGIN_MIN_VERSION = '2.0.1';
20
 
21
- /**
22
- * Actions registered for this connector
23
- *
24
- * @var array
25
- */
26
  public $actions = array(
27
  'update_option',
28
  'add_option',
@@ -60,43 +57,29 @@ class Connector_BuddyPress extends Connector {
60
  'xprofile_groups_deleted_group',
61
  );
62
 
63
- /**
64
- * Tracked option keys
65
- *
66
- * @var array
67
- */
68
  public $options = array(
69
  'bp-active-components' => null,
70
  'bp-pages' => null,
71
  'buddypress' => null,
72
  );
73
 
74
- /**
75
- * Flag to stop logging update logic twice
76
- *
77
- * @var bool
78
- */
79
  public $is_update = false;
80
 
81
- /**
82
- * @var bool
83
- */
84
  public $_deleted_activity = false;
85
 
86
- /**
87
- * @var array
88
- */
89
  public $_delete_activity_args = array();
90
 
91
- /**
92
- * @var bool
93
- */
94
  public $ignore_activity_bulk_deletion = false;
95
 
96
  /**
97
- * Check if plugin dependencies are satisfied and add an admin notice if not
98
  *
99
- * @return bool
100
  */
101
  public function is_dependency_satisfied() {
102
  if ( class_exists( 'BuddyPress' ) && version_compare( \BuddyPress::instance()->version, self::PLUGIN_MIN_VERSION, '>=' ) ) {
@@ -107,18 +90,18 @@ class Connector_BuddyPress extends Connector {
107
  }
108
 
109
  /**
110
- * Return translated connector label
111
  *
112
- * @return string Translated connector label
113
  */
114
  public function get_label() {
115
  return esc_html_x( 'BuddyPress', 'buddypress', 'mainwp-child-reports' );
116
  }
117
 
118
  /**
119
- * Return translated action labels
120
  *
121
- * @return array Action label translations
122
  */
123
  public function get_action_labels() {
124
  return array(
@@ -135,9 +118,9 @@ class Connector_BuddyPress extends Connector {
135
  }
136
 
137
  /**
138
- * Return translated context labels
139
  *
140
- * @return array Context label translations
141
  */
142
  public function get_context_labels() {
143
  return array(
@@ -149,14 +132,14 @@ class Connector_BuddyPress extends Connector {
149
  }
150
 
151
  /**
152
- * Add action links to Stream drop row in admin list screen
153
  *
154
- * @filter wp_mainwp_stream_action_links_{connector}
155
  *
156
- * @param array $links Previous links registered
157
- * @param object $record Stream record
158
  *
159
- * @return array Action links
160
  */
161
  public function action_links( $links, $record ) {
162
  if ( in_array( $record->context, array( 'components' ), true ) ) {
@@ -200,7 +183,7 @@ class Connector_BuddyPress extends Connector {
200
  );
201
 
202
  if ( $group ) {
203
- // Build actions URLs
204
  $base_url = \bp_get_admin_url( 'admin.php?page=bp-groups&amp;gid=' . $group_id );
205
  $delete_url = wp_nonce_url( $base_url . '&amp;action=delete', 'bp-groups-delete' );
206
  $edit_url = $base_url . '&amp;action=edit';
@@ -285,7 +268,10 @@ class Connector_BuddyPress extends Connector {
285
  return $links;
286
  }
287
 
288
- public function register() {
 
 
 
289
  parent::register();
290
 
291
  $this->options = array_merge(
@@ -335,31 +321,74 @@ class Connector_BuddyPress extends Connector {
335
  );
336
  }
337
 
338
- public function callback_update_option( $option, $old, $new ) {
 
 
 
 
 
 
 
339
  $this->check( $option, $old, $new );
340
  }
341
 
342
- public function callback_add_option( $option, $val ) {
 
 
 
 
 
 
343
  $this->check( $option, null, $val );
344
  }
345
 
346
- public function callback_delete_option( $option ) {
 
 
 
 
 
347
  $this->check( $option, null, null );
348
  }
349
 
350
- public function callback_update_site_option( $option, $old, $new ) {
 
 
 
 
 
 
 
351
  $this->check( $option, $old, $new );
352
  }
353
 
354
- public function callback_add_site_option( $option, $val ) {
 
 
 
 
 
 
355
  $this->check( $option, null, $val );
356
  }
357
 
358
- public function callback_delete_site_option( $option ) {
 
 
 
 
 
359
  $this->check( $option, null, null );
360
  }
361
 
362
- public function check( $option, $old_value, $new_value ) {
 
 
 
 
 
 
 
363
  if ( ! array_key_exists( $option, $this->options ) ) {
364
  return;
365
  }
@@ -388,7 +417,13 @@ class Connector_BuddyPress extends Connector {
388
  }
389
  }
390
 
391
- public function check_bp_active_components( $old_value, $new_value ) {
 
 
 
 
 
 
392
  $options = array();
393
 
394
  if ( ! is_array( $old_value ) || ! is_array( $new_value ) ) {
@@ -413,7 +448,7 @@ class Connector_BuddyPress extends Connector {
413
 
414
  $this->log(
415
  sprintf(
416
- // translators: Placeholder refers to component title (e.g. "Members")
417
  __( '"%1$s" component %2$s', 'mainwp-child-reports' ),
418
  $components[ $option ]['title'],
419
  $actions[ $option_value ]
@@ -431,7 +466,13 @@ class Connector_BuddyPress extends Connector {
431
  }
432
  }
433
 
434
- public function check_bp_pages( $old_value, $new_value ) {
 
 
 
 
 
 
435
  $options = array();
436
 
437
  if ( ! is_array( $old_value ) || ! is_array( $new_value ) ) {
@@ -459,7 +500,7 @@ class Connector_BuddyPress extends Connector {
459
 
460
  $this->log(
461
  sprintf(
462
- // translators: Placeholders refer to a directory page, and a page title (e.g. "Register", "Registration" )
463
  __( '"%1$s" page set to "%2$s"', 'mainwp-child-reports' ),
464
  $pages[ $option ],
465
  $page
@@ -478,7 +519,12 @@ class Connector_BuddyPress extends Connector {
478
  }
479
  }
480
 
481
- public function callback_bp_before_activity_delete( $args ) {
 
 
 
 
 
482
  if ( empty( $args['id'] ) ) { // Bail if we're deleting in bulk
483
  $this->_delete_activity_args = $args;
484
 
@@ -490,12 +536,17 @@ class Connector_BuddyPress extends Connector {
490
  $this->_deleted_activity = $activity;
491
  }
492
 
493
- public function callback_bp_activity_deleted_activities( $activities_ids ) {
 
 
 
 
 
494
  if ( 1 === count( $activities_ids ) && isset( $this->_deleted_activity ) ) { // Single activity deletion
495
  $activity = $this->_deleted_activity;
496
  $this->log(
497
  sprintf(
498
- // translators: Placeholder refers to an activity title (e.g. "Update")
499
  __( '"%s" activity deleted', 'mainwp-child-reports' ),
500
  strip_tags( $activity->action )
501
  ),
@@ -509,9 +560,14 @@ class Connector_BuddyPress extends Connector {
509
  $activity->component,
510
  'deleted'
511
  );
512
- } else { // Bulk deletion
513
- // Sometimes some objects removal are followed by deleting relevant
514
- // activities, so we probably don't need to track those
 
 
 
 
 
515
  if ( $this->ignore_activity_bulk_deletion ) {
516
  $this->ignore_activity_bulk_deletion = false;
517
 
@@ -519,7 +575,7 @@ class Connector_BuddyPress extends Connector {
519
  }
520
  $this->log(
521
  sprintf(
522
- // translators: Placeholder refers to an activity title (e.g. "Update")
523
  __( '"%s" activities were deleted', 'mainwp-child-reports' ),
524
  count( $activities_ids )
525
  ),
@@ -535,7 +591,13 @@ class Connector_BuddyPress extends Connector {
535
  }
536
  }
537
 
538
- public function callback_bp_activity_mark_as_spam( $activity, $by ) {
 
 
 
 
 
 
539
  unset( $by );
540
 
541
  $this->log(
@@ -556,12 +618,19 @@ class Connector_BuddyPress extends Connector {
556
  );
557
  }
558
 
559
- public function callback_bp_activity_mark_as_ham( $activity, $by ) {
 
 
 
 
 
 
 
560
  unset( $by );
561
 
562
  $this->log(
563
  sprintf(
564
- // translators: Placeholder refers to an activity title (e.g. "Update")
565
  __( 'Unmarked activity "%s" as spam', 'mainwp-child-reports' ),
566
  strip_tags( $activity->action )
567
  ),
@@ -577,7 +646,13 @@ class Connector_BuddyPress extends Connector {
577
  );
578
  }
579
 
580
- public function callback_bp_activity_admin_edit_after( $activity, $error ) {
 
 
 
 
 
 
581
  unset( $error );
582
 
583
  $this->log(
@@ -598,7 +673,15 @@ class Connector_BuddyPress extends Connector {
598
  );
599
  }
600
 
601
- public function group_action( $group, $action, $meta = array(), $message = null ) {
 
 
 
 
 
 
 
 
602
  if ( is_numeric( $group ) ) {
603
  $group = \groups_get_group(
604
  array(
@@ -663,45 +746,92 @@ class Connector_BuddyPress extends Connector {
663
  );
664
  }
665
 
666
- public function callback_groups_create_group( $group_id, $member, $group ) {
 
 
 
 
 
 
 
667
  unset( $group_id );
668
  unset( $member );
669
 
670
  $this->group_action( $group, 'created' );
671
  }
672
 
673
- public function callback_groups_update_group( $group_id, $group ) {
 
 
 
 
 
 
674
  unset( $group_id );
675
 
676
  $this->group_action( $group, 'updated' );
677
  }
678
 
679
- public function callback_groups_before_delete_group( $group_id ) {
 
 
 
 
 
680
  $this->ignore_activity_bulk_deletion = true;
681
  $this->group_action( $group_id, 'deleted' );
682
  }
683
 
684
- public function callback_groups_details_updated( $group_id ) {
 
 
 
 
 
685
  $this->is_update = true;
686
  $this->group_action( $group_id, 'updated' );
687
  }
688
 
689
- public function callback_groups_settings_updated( $group_id ) {
 
 
 
 
 
690
  if ( $this->is_update ) {
691
  return;
692
  }
693
  $this->group_action( $group_id, 'updated' );
694
  }
695
 
696
- public function callback_groups_leave_group( $group_id, $user_id ) {
 
 
 
 
 
 
697
  $this->group_action( $group_id, 'left', compact( 'user_id' ) );
698
  }
699
 
700
- public function callback_groups_join_group( $group_id, $user_id ) {
 
 
 
 
 
 
701
  $this->group_action( $group_id, 'joined', compact( 'user_id' ) );
702
  }
703
 
704
- public function callback_groups_promote_member( $group_id, $user_id, $status ) {
 
 
 
 
 
 
 
705
  $group = \groups_get_group(
706
  array(
707
  'group_id' => $group_id,
@@ -713,7 +843,7 @@ class Connector_BuddyPress extends Connector {
713
  'mod' => esc_html_x( 'Moderator', 'buddypress', 'mainwp-child-reports' ),
714
  );
715
  $message = sprintf(
716
- // translators: Placeholders refer to a user's display name, a user role, and a group name (e.g. "Jane Doe", "subscriber", "Favourites")
717
  __( 'Promoted "%1$s" to "%2$s" in "%3$s"', 'mainwp-child-reports' ),
718
  $user->display_name,
719
  $roles[ $status ],
@@ -722,7 +852,13 @@ class Connector_BuddyPress extends Connector {
722
  $this->group_action( $group_id, 'promoted', compact( 'user_id', 'status' ), $message );
723
  }
724
 
725
- public function callback_groups_demote_member( $group_id, $user_id ) {
 
 
 
 
 
 
726
  $group = \groups_get_group(
727
  array(
728
  'group_id' => $group_id,
@@ -730,7 +866,7 @@ class Connector_BuddyPress extends Connector {
730
  );
731
  $user = new \WP_User( $user_id );
732
  $message = sprintf(
733
- // translators: Placeholders refer to a user's display name, a user role, and a group name (e.g. "Jane Doe", "Member", "Favourites")
734
  __( 'Demoted "%1$s" to "%2$s" in "%3$s"', 'mainwp-child-reports' ),
735
  $user->display_name,
736
  _x( 'Member', 'buddypress', 'mainwp-child-reports' ),
@@ -739,19 +875,45 @@ class Connector_BuddyPress extends Connector {
739
  $this->group_action( $group_id, 'demoted', compact( 'user_id' ), $message );
740
  }
741
 
742
- public function callback_groups_ban_member( $group_id, $user_id ) {
 
 
 
 
 
 
743
  $this->group_action( $group_id, 'banned', compact( 'user_id' ) );
744
  }
745
 
746
- public function callback_groups_unban_member( $group_id, $user_id ) {
 
 
 
 
 
 
747
  $this->group_action( $group_id, 'unbanned', compact( 'user_id' ) );
748
  }
749
 
750
- public function callback_groups_remove_member( $group_id, $user_id ) {
 
 
 
 
 
 
751
  $this->group_action( $group_id, 'removed', compact( 'user_id' ) );
752
  }
753
 
754
- public function field_action( $field, $action, $meta = array(), $message = null ) {
 
 
 
 
 
 
 
 
755
  $replacements = array(
756
  $field->name,
757
  );
@@ -790,16 +952,33 @@ class Connector_BuddyPress extends Connector {
790
  );
791
  }
792
 
793
- public function callback_xprofile_field_after_save( $field ) {
 
 
 
 
 
794
  $action = isset( $field->id ) ? 'updated' : 'created';
795
  $this->field_action( $field, $action );
796
  }
797
 
798
- public function callback_xprofile_fields_deleted_field( $field ) {
 
 
 
 
799
  $this->field_action( $field, 'deleted' );
800
  }
801
 
802
- public function field_group_action( $group, $action, $meta = array(), $message = null ) {
 
 
 
 
 
 
 
 
803
  $replacements = array(
804
  $group->name,
805
  );
@@ -837,27 +1016,45 @@ class Connector_BuddyPress extends Connector {
837
  );
838
  }
839
 
840
- public function callback_xprofile_group_after_save( $group ) {
 
 
 
 
 
 
 
841
  global $wpdb;
 
842
  // a bit hacky, due to inconsistency with BP action scheme, see callback_xprofile_field_after_save for correct behavior
843
  $action = ( $group->id === $wpdb->insert_id ) ? 'created' : 'updated';
844
  $this->field_group_action( $group, $action );
845
  }
846
 
847
- public function callback_xprofile_groups_deleted_group( $group ) {
 
 
 
 
 
848
  $this->field_group_action( $group, 'deleted' );
849
  }
850
 
851
- private function bp_get_directory_pages() {
 
 
 
 
 
852
  $bp = \buddypress();
853
  $directory_pages = array();
854
 
855
- // Loop through loaded components and collect directories
856
  if ( is_array( $bp->loaded_components ) ) {
857
  foreach ( $bp->loaded_components as $component_slug => $component_id ) {
858
- // Only components that need directories should be listed here
859
  if ( isset( $bp->{$component_id} ) && ! empty( $bp->{$component_id}->has_directory ) ) {
860
- // component->name was introduced in BP 1.5, so we must provide a fallback
861
  $directory_pages[ $component_id ] = ! empty( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $component_id );
862
  }
863
  }
1
  <?php
2
+ /** MainWP BuddyPress Connector. */
3
 
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_BuddyPress
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_BuddyPress extends Connector {
11
 
12
+ /** @var string Connector slug */
 
 
 
 
13
  public $name = 'buddypress';
14
 
15
+ /**
16
+ * Defines plugin minimum version required.
17
+ *
18
+ * @const ( string ) Holds tracked plugin minimum version required.
19
+ */
20
  const PLUGIN_MIN_VERSION = '2.0.1';
21
 
22
+ /** @var array Actions registered for this connector. */
 
 
 
 
23
  public $actions = array(
24
  'update_option',
25
  'add_option',
57
  'xprofile_groups_deleted_group',
58
  );
59
 
60
+ /** @var array Tracked option keys. */
 
 
 
 
61
  public $options = array(
62
  'bp-active-components' => null,
63
  'bp-pages' => null,
64
  'buddypress' => null,
65
  );
66
 
67
+ /** @var bool Flag to stop logging update logic twice */
 
 
 
 
68
  public $is_update = false;
69
 
70
+ /** @var bool Whether activity was deleted. */
 
 
71
  public $_deleted_activity = false;
72
 
73
+ /** @var array Holds deleted activity arguments. */
 
 
74
  public $_delete_activity_args = array();
75
 
76
+ /** @var bool Whenter or not to ignore bulk activity deletion. */
 
 
77
  public $ignore_activity_bulk_deletion = false;
78
 
79
  /**
80
+ * Check if plugin dependencies are satisfied and add an admin notice if not.
81
  *
82
+ * @return bool Return TRUE|FASLE.
83
  */
84
  public function is_dependency_satisfied() {
85
  if ( class_exists( 'BuddyPress' ) && version_compare( \BuddyPress::instance()->version, self::PLUGIN_MIN_VERSION, '>=' ) ) {
90
  }
91
 
92
  /**
93
+ * Return translated connector label.
94
  *
95
+ * @return string Translated connector label.
96
  */
97
  public function get_label() {
98
  return esc_html_x( 'BuddyPress', 'buddypress', 'mainwp-child-reports' );
99
  }
100
 
101
  /**
102
+ * Return translated action labels.
103
  *
104
+ * @return array Action label translations.
105
  */
106
  public function get_action_labels() {
107
  return array(
118
  }
119
 
120
  /**
121
+ * Return translated context labels.
122
  *
123
+ * @return array Context label translations.
124
  */
125
  public function get_context_labels() {
126
  return array(
132
  }
133
 
134
  /**
135
+ * Add action links to Stream drop row in admin list screen.
136
  *
137
+ * @filter wp_mainwp_stream_action_links_{connector}.
138
  *
139
+ * @param array $links Previous links registered.
140
+ * @param object $record Stream record.
141
  *
142
+ * @return array Action links.
143
  */
144
  public function action_links( $links, $record ) {
145
  if ( in_array( $record->context, array( 'components' ), true ) ) {
183
  );
184
 
185
  if ( $group ) {
186
+ // Build actions URLs.
187
  $base_url = \bp_get_admin_url( 'admin.php?page=bp-groups&amp;gid=' . $group_id );
188
  $delete_url = wp_nonce_url( $base_url . '&amp;action=delete', 'bp-groups-delete' );
189
  $edit_url = $base_url . '&amp;action=edit';
268
  return $links;
269
  }
270
 
271
+ /**
272
+ * Register with parent class.
273
+ */
274
+ public function register() {
275
  parent::register();
276
 
277
  $this->options = array_merge(
321
  );
322
  }
323
 
324
+ /**
325
+ * Update option callback.
326
+ *
327
+ * @param string $option Option to update.
328
+ * @param string $old Old option value.
329
+ * @param string $new New option value.
330
+ */
331
+ public function callback_update_option($option, $old, $new ) {
332
  $this->check( $option, $old, $new );
333
  }
334
 
335
+ /**
336
+ * Add option callback.
337
+ *
338
+ * @param string $option Option to update.
339
+ * @param string $val Option value.
340
+ */
341
+ public function callback_add_option($option, $val ) {
342
  $this->check( $option, null, $val );
343
  }
344
 
345
+ /**
346
+ * Delete option callback.
347
+ *
348
+ * @param string $option Option to update.
349
+ */
350
+ public function callback_delete_option($option ) {
351
  $this->check( $option, null, null );
352
  }
353
 
354
+ /**
355
+ * Update site option callback.
356
+ *
357
+ * @param string $option Option to update.
358
+ * @param string $old Old option value.
359
+ * @param string $new New option value.
360
+ */
361
+ public function callback_update_site_option($option, $old, $new ) {
362
  $this->check( $option, $old, $new );
363
  }
364
 
365
+ /**
366
+ * Add site option callback.
367
+ *
368
+ * @param string $option Option to update.
369
+ * @param string $val Option value.
370
+ */
371
+ public function callback_add_site_option($option, $val ) {
372
  $this->check( $option, null, $val );
373
  }
374
 
375
+ /**
376
+ * Delete site option callback.
377
+ *
378
+ * @param string $option Option to update.
379
+ */
380
+ public function callback_delete_site_option($option ) {
381
  $this->check( $option, null, null );
382
  }
383
 
384
+ /**
385
+ * Check if option values exist.
386
+ *
387
+ * @param string $option Option to update.
388
+ * @param string $old_value Old option value.
389
+ * @param string $new_value New option value.
390
+ */
391
+ public function check($option, $old_value, $new_value ) {
392
  if ( ! array_key_exists( $option, $this->options ) ) {
393
  return;
394
  }
417
  }
418
  }
419
 
420
+ /**
421
+ * Check active components.
422
+ *
423
+ * @param string $old_value Old option value.
424
+ * @param string $new_value New option value.
425
+ */
426
+ public function check_bp_active_components($old_value, $new_value ) {
427
  $options = array();
428
 
429
  if ( ! is_array( $old_value ) || ! is_array( $new_value ) ) {
448
 
449
  $this->log(
450
  sprintf(
451
+ // translators: Placeholder refers to component title (e.g. "Members").
452
  __( '"%1$s" component %2$s', 'mainwp-child-reports' ),
453
  $components[ $option ]['title'],
454
  $actions[ $option_value ]
466
  }
467
  }
468
 
469
+ /**
470
+ * Check buddypress pages.
471
+ *
472
+ * @param string $old_value Old option value.
473
+ * @param string $new_value New option value.
474
+ */
475
+ public function check_bp_pages($old_value, $new_value ) {
476
  $options = array();
477
 
478
  if ( ! is_array( $old_value ) || ! is_array( $new_value ) ) {
500
 
501
  $this->log(
502
  sprintf(
503
+ // translators: Placeholders refer to a directory page, and a page title (e.g. "Register", "Registration" ).
504
  __( '"%1$s" page set to "%2$s"', 'mainwp-child-reports' ),
505
  $pages[ $option ],
506
  $page
519
  }
520
  }
521
 
522
+ /**
523
+ * Buddypress before delete activity callback.
524
+ *
525
+ * @param array $args Deletion arguments.
526
+ */
527
+ public function callback_bp_before_activity_delete($args ) {
528
  if ( empty( $args['id'] ) ) { // Bail if we're deleting in bulk
529
  $this->_delete_activity_args = $args;
530
 
536
  $this->_deleted_activity = $activity;
537
  }
538
 
539
+ /**
540
+ * Buddypress delete activities callback.
541
+ *
542
+ * @param array $activities_ids Activity IDs
543
+ */
544
+ public function callback_bp_activity_deleted_activities($activities_ids ) {
545
  if ( 1 === count( $activities_ids ) && isset( $this->_deleted_activity ) ) { // Single activity deletion
546
  $activity = $this->_deleted_activity;
547
  $this->log(
548
  sprintf(
549
+ // translators: Placeholder refers to an activity title (e.g. "Update").
550
  __( '"%s" activity deleted', 'mainwp-child-reports' ),
551
  strip_tags( $activity->action )
552
  ),
560
  $activity->component,
561
  'deleted'
562
  );
563
+ } else {
564
+
565
+ /**
566
+ * Bulk deletion.
567
+ *
568
+ * Sometimes some objects removal are followed by deleting relevant
569
+ * activities, so we probably don't need to track those.
570
+ */
571
  if ( $this->ignore_activity_bulk_deletion ) {
572
  $this->ignore_activity_bulk_deletion = false;
573
 
575
  }
576
  $this->log(
577
  sprintf(
578
+ // translators: Placeholder refers to an activity title (e.g. "Update").
579
  __( '"%s" activities were deleted', 'mainwp-child-reports' ),
580
  count( $activities_ids )
581
  ),
591
  }
592
  }
593
 
594
+ /**
595
+ * Buddypress mark as spam callback.
596
+ *
597
+ * @param array $activity Activity to mark as spam.
598
+ * @param $by ID, item_id, type, user_id.
599
+ */
600
+ public function callback_bp_activity_mark_as_spam($activity, $by ) {
601
  unset( $by );
602
 
603
  $this->log(
618
  );
619
  }
620
 
621
+
622
+ /**
623
+ * Buddypress mark as ham callback.
624
+ *
625
+ * @param array $activity Activity to mark as spam.
626
+ * @param $by ID, item_id, type, user_id.
627
+ */
628
+ public function callback_bp_activity_mark_as_ham($activity, $by ) {
629
  unset( $by );
630
 
631
  $this->log(
632
  sprintf(
633
+ // translators: Placeholder refers to an activity title (e.g. "Update").
634
  __( 'Unmarked activity "%s" as spam', 'mainwp-child-reports' ),
635
  strip_tags( $activity->action )
636
  ),
646
  );
647
  }
648
 
649
+ /**
650
+ * Buddypress admin after edit activity callback.
651
+ *
652
+ * @param array $activity Activity to mark as spam.
653
+ * @param $error Error message.
654
+ */
655
+ public function callback_bp_activity_admin_edit_after($activity, $error ) {
656
  unset( $error );
657
 
658
  $this->log(
673
  );
674
  }
675
 
676
+ /**
677
+ * Group action.
678
+ *
679
+ * @param array $group Group array.
680
+ * @param strign $action Action to perform.
681
+ * @param array $meta Meta data.
682
+ * @param string $message Response message.
683
+ */
684
+ public function group_action($group, $action, $meta = array(), $message = null ) {
685
  if ( is_numeric( $group ) ) {
686
  $group = \groups_get_group(
687
  array(
746
  );
747
  }
748
 
749
+ /**
750
+ * Create groups callback.
751
+ *
752
+ * @param string $group_id Group ID.
753
+ * @param string $member Member data.
754
+ * @param array $group Buddypress group.
755
+ */
756
+ public function callback_groups_create_group($group_id, $member, $group ) {
757
  unset( $group_id );
758
  unset( $member );
759
 
760
  $this->group_action( $group, 'created' );
761
  }
762
 
763
+ /**
764
+ * Update group calback.
765
+ *
766
+ * @param string $group_id Group ID.
767
+ * @param array $group Buddypress group.
768
+ */
769
+ public function callback_groups_update_group($group_id, $group ) {
770
  unset( $group_id );
771
 
772
  $this->group_action( $group, 'updated' );
773
  }
774
 
775
+ /**
776
+ * Before delete groups callback.
777
+ *
778
+ * @param string $group_id Group ID.
779
+ */
780
+ public function callback_groups_before_delete_group($group_id ) {
781
  $this->ignore_activity_bulk_deletion = true;
782
  $this->group_action( $group_id, 'deleted' );
783
  }
784
 
785
+ /**
786
+ * Updated group details callback.
787
+ *
788
+ * @param string $group_id Group ID.
789
+ */
790
+ public function callback_groups_details_updated($group_id ) {
791
  $this->is_update = true;
792
  $this->group_action( $group_id, 'updated' );
793
  }
794
 
795
+ /**
796
+ * Updated group settings.
797
+ *
798
+ * @param string $group_id Group ID.
799
+ */
800
+ public function callback_groups_settings_updated($group_id ) {
801
  if ( $this->is_update ) {
802
  return;
803
  }
804
  $this->group_action( $group_id, 'updated' );
805
  }
806
 
807
+ /**
808
+ * Leave groups callback.
809
+ *
810
+ * @param string $group_id Group ID.
811
+ * @param string $user_id User ID.
812
+ */
813
+ public function callback_groups_leave_group($group_id, $user_id ) {
814
  $this->group_action( $group_id, 'left', compact( 'user_id' ) );
815
  }
816
 
817
+ /**
818
+ * Join group callback.
819
+ *
820
+ * @param string $group_id Group ID.
821
+ * @param string $user_id User ID.
822
+ */
823
+ public function callback_groups_join_group($group_id, $user_id ) {
824
  $this->group_action( $group_id, 'joined', compact( 'user_id' ) );
825
  }
826
 
827
+ /**
828
+ * Promote member.
829
+ *
830
+ * @param string $group_id Group ID.
831
+ * @param string $user_id User ID.
832
+ * @param string $status Member status.
833
+ */
834
+ public function callback_groups_promote_member($group_id, $user_id, $status ) {
835
  $group = \groups_get_group(
836
  array(
837
  'group_id' => $group_id,
843
  'mod' => esc_html_x( 'Moderator', 'buddypress', 'mainwp-child-reports' ),
844
  );
845
  $message = sprintf(
846
+ // translators: Placeholders refer to a user's display name, a user role, and a group name (e.g. "Jane Doe", "subscriber", "Favourites").
847
  __( 'Promoted "%1$s" to "%2$s" in "%3$s"', 'mainwp-child-reports' ),
848
  $user->display_name,
849
  $roles[ $status ],
852
  $this->group_action( $group_id, 'promoted', compact( 'user_id', 'status' ), $message );
853
  }
854
 
855
+ /**
856
+ * Demote member.
857
+ *
858
+ * @param string $group_id Group ID.
859
+ * @param string $user_id User ID.
860
+ */
861
+ public function callback_groups_demote_member($group_id, $user_id ) {
862
  $group = \groups_get_group(
863
  array(
864
  'group_id' => $group_id,
866
  );
867
  $user = new \WP_User( $user_id );
868
  $message = sprintf(
869
+ // translators: Placeholders refer to a user's display name, a user role, and a group name (e.g. "Jane Doe", "Member", "Favourites").
870
  __( 'Demoted "%1$s" to "%2$s" in "%3$s"', 'mainwp-child-reports' ),
871
  $user->display_name,
872
  _x( 'Member', 'buddypress', 'mainwp-child-reports' ),
875
  $this->group_action( $group_id, 'demoted', compact( 'user_id' ), $message );
876
  }
877
 
878
+ /**
879
+ * Ban member.
880
+ *
881
+ * @param string $group_id Group ID.
882
+ * @param string $user_id User ID.
883
+ */
884
+ public function callback_groups_ban_member($group_id, $user_id ) {
885
  $this->group_action( $group_id, 'banned', compact( 'user_id' ) );
886
  }
887
 
888
+ /**
889
+ * Unban member.
890
+ *
891
+ * @param string $group_id Group ID.
892
+ * @param string $user_id User ID.
893
+ */
894
+ public function callback_groups_unban_member($group_id, $user_id ) {
895
  $this->group_action( $group_id, 'unbanned', compact( 'user_id' ) );
896
  }
897
 
898
+ /**
899
+ * Remove member.
900
+ *
901
+ * @param string $group_id Group ID.
902
+ * @param string $user_id User ID.
903
+ */
904
+ public function callback_groups_remove_member($group_id, $user_id ) {
905
  $this->group_action( $group_id, 'removed', compact( 'user_id' ) );
906
  }
907
 
908
+ /**
909
+ * Field action.
910
+ *
911
+ * @param string $field Form field.
912
+ * @param string $action Action to perform.
913
+ * @param array $meta Meta data.
914
+ * @param null $message Response message.
915
+ */
916
+ public function field_action($field, $action, $meta = array(), $message = null ) {
917
  $replacements = array(
918
  $field->name,
919
  );
952
  );
953
  }
954
 
955
+ /**
956
+ * XPROFILE save field calback.
957
+ *
958
+ * @param string $field Form field.
959
+ */
960
+ public function callback_xprofile_field_after_save($field ) {
961
  $action = isset( $field->id ) ? 'updated' : 'created';
962
  $this->field_action( $field, $action );
963
  }
964
 
965
+ /**
966
+ * XPROFILE delete field callback.
967
+ * @param string $field Form field.
968
+ */
969
+ public function callback_xprofile_fields_deleted_field($field ) {
970
  $this->field_action( $field, 'deleted' );
971
  }
972
 
973
+ /**
974
+ * Field group action.
975
+ *
976
+ * @param string $group Form field group.
977
+ * @param string $action Action to perform.
978
+ * @param array $meta Meta data.
979
+ * @param null $message Response message.
980
+ */
981
+ public function field_group_action($group, $action, $meta = array(), $message = null ) {
982
  $replacements = array(
983
  $group->name,
984
  );
1016
  );
1017
  }
1018
 
1019
+ /**
1020
+ * XPROFILE save group calback.
1021
+ *
1022
+ * @param string $group Form field group.
1023
+ */
1024
+ public function callback_xprofile_group_after_save($group ) {
1025
+
1026
+ /** @global object $wpdb WordPress Database instance. */
1027
  global $wpdb;
1028
+
1029
  // a bit hacky, due to inconsistency with BP action scheme, see callback_xprofile_field_after_save for correct behavior
1030
  $action = ( $group->id === $wpdb->insert_id ) ? 'created' : 'updated';
1031
  $this->field_group_action( $group, $action );
1032
  }
1033
 
1034
+ /**
1035
+ * XPROFILE delete groups callback.
1036
+ *
1037
+ * @param string $group Form field group.
1038
+ */
1039
+ public function callback_xprofile_groups_deleted_group($group ) {
1040
  $this->field_group_action( $group, 'deleted' );
1041
  }
1042
 
1043
+ /**
1044
+ * Buddypress get directory pages.
1045
+ *
1046
+ * @return array Directory pages array.
1047
+ */
1048
+ private function bp_get_directory_pages() {
1049
  $bp = \buddypress();
1050
  $directory_pages = array();
1051
 
1052
+ // Loop through loaded components and collect directories.
1053
  if ( is_array( $bp->loaded_components ) ) {
1054
  foreach ( $bp->loaded_components as $component_slug => $component_id ) {
1055
+ // Only components that need directories should be listed here.
1056
  if ( isset( $bp->{$component_id} ) && ! empty( $bp->{$component_id}->has_directory ) ) {
1057
+ // component->name was introduced in BP 1.5, so we must provide a fallback.
1058
  $directory_pages[ $component_id ] = ! empty( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $component_id );
1059
  }
1060
  }
connectors/class-connector-comments.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Comments extends Connector {
5
  /**
6
  * Connector slug
@@ -603,7 +609,10 @@ class Connector_Comments extends Connector {
603
  * @param array $comment_data
604
  */
605
  public function callback_comment_duplicate_trigger( $comment_data ) {
 
 
606
  global $wpdb;
 
607
  unset( $comment_data );
608
 
609
  $comment_id = $wpdb->last_result[0]->comment_ID;
1
  <?php
2
+ /** MainWP Child Reports comments connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_Comments.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_Comments extends Connector {
11
  /**
12
  * Connector slug
609
  * @param array $comment_data
610
  */
611
  public function callback_comment_duplicate_trigger( $comment_data ) {
612
+
613
+ /** @global object $wpdb WordPress Database instance. */
614
  global $wpdb;
615
+
616
  unset( $comment_data );
617
 
618
  $comment_id = $wpdb->last_result[0]->comment_ID;
connectors/class-connector-edd.php CHANGED
@@ -1,28 +1,25 @@
1
  <?php
 
2
 
3
  namespace WP_MainWP_Stream;
4
 
 
 
 
 
5
  class Connector_EDD extends Connector {
6
 
7
- /**
8
- * Connector slug
9
- *
10
- * @var string
11
- */
12
  public $name = 'edd';
13
 
14
  /**
15
- * Holds tracked plugin minimum version required
16
  *
17
- * @const string
18
  */
19
  const PLUGIN_MIN_VERSION = '1.8.8';
20
 
21
- /**
22
- * Actions registered for this connector
23
- *
24
- * @var array
25
- */
26
  public $actions = array(
27
  'update_option',
28
  'add_option',
@@ -43,45 +40,27 @@ class Connector_EDD extends Connector {
43
  'delete_user_meta',
44
  );
45
 
46
- /**
47
- * Tracked option keys
48
- *
49
- * @var array
50
- */
51
  public $options = array();
52
 
53
- /**
54
- * Tracking registered Settings, with overridden data
55
- *
56
- * @var array
57
- */
58
  public $options_override = array();
59
 
60
- /**
61
- * Tracking user meta updates related to this connector
62
- *
63
- * @var array
64
- */
65
  public $user_meta = array(
66
  'edd_user_public_key',
67
  );
68
 
69
- /**
70
- * Flag status changes to not create duplicate entries
71
- * @var bool
72
- */
73
  public $is_discount_status_change = false;
74
 
75
- /**
76
- * Flag status changes to not create duplicate entries
77
- * @var bool
78
- */
79
  public $is_payment_status_change = false;
80
 
81
  /**
82
- * Check if plugin dependencies are satisfied and add an admin notice if not
83
  *
84
- * @return bool
85
  */
86
  public function is_dependency_satisfied() {
87
  if ( class_exists( 'Easy_Digital_Downloads' ) && defined( 'EDD_VERSION' ) && version_compare( EDD_VERSION, self::PLUGIN_MIN_VERSION, '>=' ) ) {
@@ -92,18 +71,18 @@ class Connector_EDD extends Connector {
92
  }
93
 
94
  /**
95
- * Return translated connector label
96
  *
97
- * @return string Translated connector label
98
  */
99
  public function get_label() {
100
  return esc_html_x( 'Easy Digital Downloads', 'edd', 'mainwp-child-reports' );
101
  }
102
 
103
  /**
104
- * Return translated action labels
105
  *
106
- * @return array Action label translations
107
  */
108
  public function get_action_labels() {
109
  return array(
@@ -121,9 +100,9 @@ class Connector_EDD extends Connector {
121
  }
122
 
123
  /**
124
- * Return translated context labels
125
  *
126
- * @return array Context label translations
127
  */
128
  public function get_context_labels() {
129
  return array(
@@ -138,14 +117,14 @@ class Connector_EDD extends Connector {
138
  }
139
 
140
  /**
141
- * Add action links to Stream drop row in admin list screen
142
  *
143
- * @filter wp_mainwp_stream_action_links_{connector}
144
  *
145
- * @param array $links Previous links registered
146
- * @param object $record Stream record
147
  *
148
- * @return array Action links
149
  */
150
  public function action_links( $links, $record ) {
151
  if ( in_array( $record->context, array( 'downloads' ), true ) ) {
@@ -155,7 +134,7 @@ class Connector_EDD extends Connector {
155
  $post_type_label = get_post_type_labels( get_post_type_object( 'edd_discount' ) )->singular_name;
156
  $base = admin_url( 'edit.php?post_type=download&page=edd-discounts' );
157
 
158
- // translators: Placeholder refers to a post type (e.g. "Post")
159
  $links[ sprintf( esc_html__( 'Edit %s', 'mainwp-child-reports' ), $post_type_label ) ] = add_query_arg(
160
  array(
161
  'edd-action' => 'edit_discount',
@@ -165,7 +144,7 @@ class Connector_EDD extends Connector {
165
  );
166
 
167
  if ( 'active' === get_post( $record->object_id )->post_status ) {
168
- // translators: Placeholder refers to a post type (e.g. "Post")
169
  $links[ sprintf( esc_html__( 'Deactivate %s', 'mainwp-child-reports' ), $post_type_label ) ] = add_query_arg(
170
  array(
171
  'edd-action' => 'deactivate_discount',
@@ -174,7 +153,7 @@ class Connector_EDD extends Connector {
174
  $base
175
  );
176
  } else {
177
- // translators: Placeholder refers to a post type (e.g. "Post")
178
  $links[ sprintf( esc_html__( 'Activate %s', 'mainwp-child-reports' ), $post_type_label ) ] = add_query_arg(
179
  array(
180
  'edd-action' => 'activate_discount',
@@ -226,7 +205,10 @@ class Connector_EDD extends Connector {
226
  return $links;
227
  }
228
 
229
- public function register() {
 
 
 
230
  parent::register();
231
 
232
  add_filter( 'wp_mainwp_stream_log_data', array( $this, 'log_override' ) );
@@ -236,31 +218,73 @@ class Connector_EDD extends Connector {
236
  );
237
  }
238
 
239
- public function callback_update_option( $option, $old, $new ) {
 
 
 
 
 
 
 
240
  $this->check( $option, $old, $new );
241
  }
242
 
243
- public function callback_add_option( $option, $val ) {
 
 
 
 
 
 
244
  $this->check( $option, null, $val );
245
  }
246
 
247
- public function callback_delete_option( $option ) {
 
 
 
 
 
248
  $this->check( $option, null, null );
249
  }
250
 
251
- public function callback_update_site_option( $option, $old, $new ) {
 
 
 
 
 
 
 
252
  $this->check( $option, $old, $new );
253
  }
254
-
255
- public function callback_add_site_option( $option, $val ) {
 
 
 
 
 
256
  $this->check( $option, null, $val );
257
  }
258
 
259
- public function callback_delete_site_option( $option ) {
 
 
 
 
 
260
  $this->check( $option, null, null );
261
  }
262
 
263
- public function check( $option, $old_value, $new_value ) {
 
 
 
 
 
 
 
264
  if ( ! array_key_exists( $option, $this->options ) ) {
265
  return;
266
  }
@@ -288,7 +312,13 @@ class Connector_EDD extends Connector {
288
  }
289
  }
290
 
291
- public function check_edd_settings( $old_value, $new_value ) {
 
 
 
 
 
 
292
  $options = array();
293
 
294
  if ( ! is_array( $old_value ) || ! is_array( $new_value ) ) {
@@ -299,7 +329,7 @@ class Connector_EDD extends Connector {
299
  $options[ $field_key ] = $field_value;
300
  }
301
 
302
- //TODO: Check this exists first
303
  $settings = \edd_get_registered_settings();
304
 
305
  foreach ( $options as $option => $option_value ) {
@@ -324,7 +354,7 @@ class Connector_EDD extends Connector {
324
  }
325
 
326
  $this->log(
327
- // translators: Placeholder refers to a setting title (e.g. "Language")
328
  __( '"%s" setting updated', 'mainwp-child-reports' ),
329
  array(
330
  'option_title' => $field['name'],
@@ -341,11 +371,11 @@ class Connector_EDD extends Connector {
341
  }
342
 
343
  /**
344
- * Override connector log for our own Settings / Actions
345
  *
346
- * @param array $data
347
  *
348
- * @return array|bool
349
  */
350
  public function log_override( $data ) {
351
  if ( ! is_array( $data ) ) {
@@ -370,14 +400,14 @@ class Connector_EDD extends Connector {
370
  $data['context'] = 'discounts';
371
  $data['connector'] = $this->name;
372
  } elseif ( 'posts' === $data['connector'] && 'edd_payment' === $data['context'] ) {
373
- // Payment posts operations
374
- return false; // Do not track payments, they're well logged!
375
  } elseif ( 'posts' === $data['connector'] && 'edd_log' === $data['context'] ) {
376
- // Logging operations
377
- return false; // Do not track notes, because they're basically logs
378
  } elseif ( 'comments' === $data['connector'] && 'edd_payment' === $data['context'] ) {
379
- // Payment notes ( comments ) operations
380
- return false; // Do not track notes, because they're basically logs
381
  } elseif ( 'taxonomies' === $data['connector'] && 'download_category' === $data['context'] ) {
382
  $data['connector'] = $this->name;
383
  } elseif ( 'taxonomies' === $data['connector'] && 'download_tag' === $data['context'] ) {
@@ -391,12 +421,18 @@ class Connector_EDD extends Connector {
391
  return $data;
392
  }
393
 
394
- public function callback_edd_pre_update_discount_status( $code_id, $new_status ) {
 
 
 
 
 
 
395
  $this->is_discount_status_change = true;
396
 
397
  $this->log(
398
  sprintf(
399
- // translators: Placeholders refer to a discount title, and a status (e.g. "Mother's Day", "activated")
400
  __( '"%1$s" discount %2$s', 'mainwp-child-reports' ),
401
  get_post( $code_id )->post_title,
402
  'active' === $new_status ? esc_html__( 'activated', 'mainwp-child-reports' ) : esc_html__( 'deactivated', 'mainwp-child-reports' )
@@ -411,27 +447,47 @@ class Connector_EDD extends Connector {
411
  );
412
  }
413
 
414
- private function callback_edd_generate_pdf() {
 
 
 
415
  $this->report_generated( 'pdf' );
416
  }
417
 
418
- public function callback_edd_earnings_export() {
 
 
 
419
  $this->report_generated( 'earnings' );
420
  }
421
 
422
- public function callback_edd_payment_export() {
 
 
 
423
  $this->report_generated( 'payments' );
424
  }
425
 
426
- public function callback_edd_email_export() {
 
 
 
427
  $this->report_generated( 'emails' );
428
  }
429
 
430
- public function callback_edd_downloads_history_export() {
 
 
 
431
  $this->report_generated( 'download-history' );
432
  }
433
 
434
- private function report_generated( $type ) {
 
 
 
 
 
435
  $label = '';
436
 
437
  if ( 'pdf' === $type ) {
@@ -448,7 +504,7 @@ class Connector_EDD extends Connector {
448
 
449
  $this->log(
450
  sprintf(
451
- // translators: Placeholder refers to a report title (e.g. "Sales and Earnings")
452
  __( 'Generated %s report', 'mainwp-child-reports' ),
453
  $label
454
  ),
@@ -461,7 +517,10 @@ class Connector_EDD extends Connector {
461
  );
462
  }
463
 
464
- public function callback_edd_export_settings() {
 
 
 
465
  $this->log(
466
  __( 'Exported Settings', 'mainwp-child-reports' ),
467
  array(),
@@ -471,7 +530,10 @@ class Connector_EDD extends Connector {
471
  );
472
  }
473
 
474
- public function callback_edd_import_settings() {
 
 
 
475
  $this->log(
476
  __( 'Imported Settings', 'mainwp-child-reports' ),
477
  array(),
@@ -481,20 +543,52 @@ class Connector_EDD extends Connector {
481
  );
482
  }
483
 
484
- public function callback_update_user_meta( $meta_id, $object_id, $meta_key, $_meta_value ) {
 
 
 
 
 
 
 
 
485
  unset( $meta_id );
486
  $this->meta( $object_id, $meta_key, $_meta_value );
487
  }
488
 
489
- public function callback_add_user_meta( $object_id, $meta_key, $_meta_value ) {
 
 
 
 
 
 
 
490
  $this->meta( $object_id, $meta_key, $_meta_value, true );
491
  }
492
 
493
- public function callback_delete_user_meta( $meta_id, $object_id, $meta_key, $_meta_value ) {
 
 
 
 
 
 
 
 
494
  $this->meta( $object_id, $meta_key, null );
495
  }
496
 
497
- public function meta( $object_id, $key, $value, $is_add = false ) {
 
 
 
 
 
 
 
 
 
498
  if ( ! in_array( $key, $this->user_meta, true ) ) {
499
  return false;
500
  }
@@ -511,7 +605,14 @@ class Connector_EDD extends Connector {
511
  ), $object_id, $value, $is_add );
512
  }
513
 
514
- private function meta_edd_user_public_key( $user_id, $value, $is_add = false ) {
 
 
 
 
 
 
 
515
  if ( is_null( $value ) ) {
516
  $action = 'revoked';
517
  $action_title = esc_html__( 'revoked', 'mainwp-child-reports' );
@@ -525,7 +626,7 @@ class Connector_EDD extends Connector {
525
 
526
  $this->log(
527
  sprintf(
528
- // translators: Placeholder refers to a status (e.g. "revoked")
529
  __( 'User API Key %s', 'mainwp-child-reports' ),
530
  $action_title
531
  ),
1
  <?php
2
+ /** EDD Connector. */
3
 
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_EDD
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_EDD extends Connector {
11
 
12
+ /** @var string Connector slug */
 
 
 
 
13
  public $name = 'edd';
14
 
15
  /**
16
+ * Defines plugin minimum version required.
17
  *
18
+ * @const ( string ) Holds tracked plugin minimum version required.
19
  */
20
  const PLUGIN_MIN_VERSION = '1.8.8';
21
 
22
+ /** @var array Actions registered for this connector. */
 
 
 
 
23
  public $actions = array(
24
  'update_option',
25
  'add_option',
40
  'delete_user_meta',
41
  );
42
 
43
+ /** @var array Tracked option keys. */
 
 
 
 
44
  public $options = array();
45
 
46
+ /** @var array Tracking registered Settings, with overridden data. */
 
 
 
 
47
  public $options_override = array();
48
 
49
+ /** @var array Tracking user meta updates related to this connector. */
 
 
 
 
50
  public $user_meta = array(
51
  'edd_user_public_key',
52
  );
53
 
54
+ /** @var bool Flag status changes to not create duplicate entries. */
 
 
 
55
  public $is_discount_status_change = false;
56
 
57
+ /** @var bool Flag status changes to not create duplicate entries. */
 
 
 
58
  public $is_payment_status_change = false;
59
 
60
  /**
61
+ * Check if plugin dependencies are satisfied and add an admin notice if not.
62
  *
63
+ * @return bool Return TRUE|FALSE.
64
  */
65
  public function is_dependency_satisfied() {
66
  if ( class_exists( 'Easy_Digital_Downloads' ) && defined( 'EDD_VERSION' ) && version_compare( EDD_VERSION, self::PLUGIN_MIN_VERSION, '>=' ) ) {
71
  }
72
 
73
  /**
74
+ * Return translated connector label.
75
  *
76
+ * @return string Translated connector label.
77
  */
78
  public function get_label() {
79
  return esc_html_x( 'Easy Digital Downloads', 'edd', 'mainwp-child-reports' );
80
  }
81
 
82
  /**
83
+ * Return translated action labels.
84
  *
85
+ * @return array Action label translations.
86
  */
87
  public function get_action_labels() {
88
  return array(
100
  }
101
 
102
  /**
103
+ * Return translated context labels.
104
  *
105
+ * @return array Context label translations.
106
  */
107
  public function get_context_labels() {
108
  return array(
117
  }
118
 
119
  /**
120
+ * Add action links to Stream drop row in admin list screen.
121
  *
122
+ * @filter wp_mainwp_stream_action_links_{connector}.
123
  *
124
+ * @param array $links Previous links registered.
125
+ * @param object $record Stream record.
126
  *
127
+ * @return array Action links.
128
  */
129
  public function action_links( $links, $record ) {
130
  if ( in_array( $record->context, array( 'downloads' ), true ) ) {
134
  $post_type_label = get_post_type_labels( get_post_type_object( 'edd_discount' ) )->singular_name;
135
  $base = admin_url( 'edit.php?post_type=download&page=edd-discounts' );
136
 
137
+ // translators: Placeholder refers to a post type (e.g. "Post").
138
  $links[ sprintf( esc_html__( 'Edit %s', 'mainwp-child-reports' ), $post_type_label ) ] = add_query_arg(
139
  array(
140
  'edd-action' => 'edit_discount',
144
  );
145
 
146
  if ( 'active' === get_post( $record->object_id )->post_status ) {
147
+ // translators: Placeholder refers to a post type (e.g. "Post").
148
  $links[ sprintf( esc_html__( 'Deactivate %s', 'mainwp-child-reports' ), $post_type_label ) ] = add_query_arg(
149
  array(
150
  'edd-action' => 'deactivate_discount',
153
  $base
154
  );
155
  } else {
156
+ // translators: Placeholder refers to a post type (e.g. "Post").
157
  $links[ sprintf( esc_html__( 'Activate %s', 'mainwp-child-reports' ), $post_type_label ) ] = add_query_arg(
158
  array(
159
  'edd-action' => 'activate_discount',
205
  return $links;
206
  }
207
 
208
+ /**
209
+ * Register with parent class.
210
+ */
211
+ public function register() {
212
  parent::register();
213
 
214
  add_filter( 'wp_mainwp_stream_log_data', array( $this, 'log_override' ) );
218
  );
219
  }
220
 
221
+ /**
222
+ * Update options callback.
223
+ *
224
+ * @param string $option Option to update.
225
+ * @param string $old Old option value.
226
+ * @param string $new New option value.
227
+ */
228
+ public function callback_update_option($option, $old, $new ) {
229
  $this->check( $option, $old, $new );
230
  }
231
 
232
+ /**
233
+ * Add option callback.
234
+ *
235
+ * @param string $option Option to update.
236
+ * @param string $val Option value.
237
+ */
238
+ public function callback_add_option($option, $val ) {
239
  $this->check( $option, null, $val );
240
  }
241
 
242
+ /**
243
+ * Delete option callback.
244
+ *
245
+ * @param string $option Option to update.
246
+ */
247
+ public function callback_delete_option($option ) {
248
  $this->check( $option, null, null );
249
  }
250
 
251
+ /**
252
+ * Update site option callback.
253
+ *
254
+ * @param string $option Option to update.
255
+ * @param string $old Old option value.
256
+ * @param string $new New option value.
257
+ */
258
+ public function callback_update_site_option($option, $old, $new ) {
259
  $this->check( $option, $old, $new );
260
  }
261
+ /**
262
+ * Add site option callback.
263
+ *
264
+ * @param string $option Option to update.
265
+ * @param string $val Option value.
266
+ */
267
+ public function callback_add_site_option($option, $val ) {
268
  $this->check( $option, null, $val );
269
  }
270
 
271
+ /**
272
+ * Delete site option callback.
273
+ *
274
+ * @param string $option Option to update.
275
+ */
276
+ public function callback_delete_site_option($option ) {
277
  $this->check( $option, null, null );
278
  }
279
 
280
+ /**
281
+ * Check if option value already exists.
282
+ *
283
+ * @param string $option Option to update.
284
+ * @param string $old_value Old option value.
285
+ * @param string $new_value New option value.
286
+ */
287
+ public function check($option, $old_value, $new_value ) {
288
  if ( ! array_key_exists( $option, $this->options ) ) {
289
  return;
290
  }
312
  }
313
  }
314
 
315
+ /**
316
+ * Check EDD settings.
317
+ *
318
+ * @param string $old_value Old option value.
319
+ * @param string $new_value New option value.
320
+ */
321
+ public function check_edd_settings($old_value, $new_value ) {
322
  $options = array();
323
 
324
  if ( ! is_array( $old_value ) || ! is_array( $new_value ) ) {
329
  $options[ $field_key ] = $field_value;
330
  }
331
 
332
+ /** TODO: Check this exists first. */
333
  $settings = \edd_get_registered_settings();
334
 
335
  foreach ( $options as $option => $option_value ) {
354
  }
355
 
356
  $this->log(
357
+ // translators: Placeholder refers to a setting title (e.g. "Language").
358
  __( '"%s" setting updated', 'mainwp-child-reports' ),
359
  array(
360
  'option_title' => $field['name'],
371
  }
372
 
373
  /**
374
+ * Override connector log for our own Settings / Actions.
375
  *
376
+ * @param array $data Post or downloads data.
377
  *
378
+ * @return array|bool Return posts or downloads data, or FALSE on faliure.
379
  */
380
  public function log_override( $data ) {
381
  if ( ! is_array( $data ) ) {
400
  $data['context'] = 'discounts';
401
  $data['connector'] = $this->name;
402
  } elseif ( 'posts' === $data['connector'] && 'edd_payment' === $data['context'] ) {
403
+ // Payment posts operations.
404
+ return false; // Do not track payments, they're well logged!.
405
  } elseif ( 'posts' === $data['connector'] && 'edd_log' === $data['context'] ) {
406
+ // Logging operations.
407
+ return false; // Do not track notes, because they're basically logs.
408
  } elseif ( 'comments' === $data['connector'] && 'edd_payment' === $data['context'] ) {
409
+ // Payment notes ( comments ) operations.
410
+ return false; // Do not track notes, because they're basically logs.
411
  } elseif ( 'taxonomies' === $data['connector'] && 'download_category' === $data['context'] ) {
412
  $data['connector'] = $this->name;
413
  } elseif ( 'taxonomies' === $data['connector'] && 'download_tag' === $data['context'] ) {
421
  return $data;
422
  }
423
 
424
+ /**
425
+ * Add pre-update discount status callback.
426
+ *
427
+ * @param string $code_id Code ID.
428
+ * @param string $new_status New status.
429
+ */
430
+ public function callback_edd_pre_update_discount_status($code_id, $new_status ) {
431
  $this->is_discount_status_change = true;
432
 
433
  $this->log(
434
  sprintf(
435
+ // translators: Placeholders refer to a discount title, and a status (e.g. "Mother's Day", "activated").
436
  __( '"%1$s" discount %2$s', 'mainwp-child-reports' ),
437
  get_post( $code_id )->post_title,
438
  'active' === $new_status ? esc_html__( 'activated', 'mainwp-child-reports' ) : esc_html__( 'deactivated', 'mainwp-child-reports' )
447
  );
448
  }
449
 
450
+ /**
451
+ * EDD generated PDF callback.
452
+ */
453
+ private function callback_edd_generate_pdf() {
454
  $this->report_generated( 'pdf' );
455
  }
456
 
457
+ /**
458
+ * EDD earnings export callback.
459
+ */
460
+ public function callback_edd_earnings_export() {
461
  $this->report_generated( 'earnings' );
462
  }
463
 
464
+ /**
465
+ * EDD payments export callback.
466
+ */
467
+ public function callback_edd_payment_export() {
468
  $this->report_generated( 'payments' );
469
  }
470
 
471
+ /**
472
+ * EDD email export callback.
473
+ */
474
+ public function callback_edd_email_export() {
475
  $this->report_generated( 'emails' );
476
  }
477
 
478
+ /**
479
+ * EDD downloads history export callback.
480
+ */
481
+ public function callback_edd_downloads_history_export() {
482
  $this->report_generated( 'download-history' );
483
  }
484
 
485
+ /**
486
+ * Generated report.
487
+ *
488
+ * @param string $type PDF type.
489
+ */
490
+ private function report_generated($type ) {
491
  $label = '';
492
 
493
  if ( 'pdf' === $type ) {
504
 
505
  $this->log(
506
  sprintf(
507
+ // translators: Placeholder refers to a report title (e.g. "Sales and Earnings").
508
  __( 'Generated %s report', 'mainwp-child-reports' ),
509
  $label
510
  ),
517
  );
518
  }
519
 
520
+ /**
521
+ * EDD export settings callback.
522
+ */
523
+ public function callback_edd_export_settings() {
524
  $this->log(
525
  __( 'Exported Settings', 'mainwp-child-reports' ),
526
  array(),
530
  );
531
  }
532
 
533
+ /**
534
+ * EDD import settings callback.
535
+ */
536
+ public function callback_edd_import_settings() {
537
  $this->log(
538
  __( 'Imported Settings', 'mainwp-child-reports' ),
539
  array(),
543
  );
544
  }
545
 
546
+ /**
547
+ * Update user meta callback.
548
+ *
549
+ * @param string $meta_id Meta ID.
550
+ * @param string $object_id Object ID.
551
+ * @param string $meta_key Meta Key.
552
+ * @param string $_meta_value Meta value.
553
+ */
554
+ public function callback_update_user_meta($meta_id, $object_id, $meta_key, $_meta_value ) {
555
  unset( $meta_id );
556
  $this->meta( $object_id, $meta_key, $_meta_value );
557
  }
558
 
559
+ /**
560
+ * Add user meta callback.
561
+ *
562
+ * @param string $object_id Object ID.
563
+ * @param string $meta_key Meta Key.
564
+ * @param string $_meta_value Meta value.
565
+ */
566
+ public function callback_add_user_meta($object_id, $meta_key, $_meta_value ) {
567
  $this->meta( $object_id, $meta_key, $_meta_value, true );
568
  }
569
 
570
+ /**
571
+ * Delete user meta callback.
572
+ *
573
+ * @param string $meta_id Meta ID.
574
+ * @param string $object_id Object ID.
575
+ * @param string $meta_key Meta Key.
576
+ * @param string $_meta_value Meta value.
577
+ */
578
+ public function callback_delete_user_meta($meta_id, $object_id, $meta_key, $_meta_value ) {
579
  $this->meta( $object_id, $meta_key, null );
580
  }
581
 
582
+ /**
583
+ * Check if meta option was added.
584
+ *
585
+ * @param $object_id Object ID.
586
+ * @param $key Object key.
587
+ * @param $value Object value.
588
+ * @param bool $is_add Check if option was added. TRUE|FALSE.
589
+ * @return bool|mixed Return respose array or FALSE on failure.
590
+ */
591
+ public function meta($object_id, $key, $value, $is_add = false ) {
592
  if ( ! in_array( $key, $this->user_meta, true ) ) {
593
  return false;
594
  }
605
  ), $object_id, $value, $is_add );
606
  }
607
 
608
+ /**
609
+ * EDD user public key callback.
610
+ *
611
+ * @param string $user_id User ID.
612
+ * @param string $value Public key.
613
+ * @param bool $is_add Whether the key was added or not. TRUE|FASLE.
614
+ */
615
+ private function meta_edd_user_public_key($user_id, $value, $is_add = false ) {
616
  if ( is_null( $value ) ) {
617
  $action = 'revoked';
618
  $action_title = esc_html__( 'revoked', 'mainwp-child-reports' );
626
 
627
  $this->log(
628
  sprintf(
629
+ // translators: Placeholder refers to a status (e.g. "revoked").
630
  __( 'User API Key %s', 'mainwp-child-reports' ),
631
  $action_title
632
  ),
connectors/class-connector-editor.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Editor extends Connector {
5
  /**
6
  * Connector slug
@@ -115,7 +121,7 @@ class Connector_Editor extends Connector {
115
  * @return string Translated string
116
  */
117
  public function get_message() {
118
- // translators: Placeholders refer to a file name, and a theme / plugin name (e.g. "index.php", "Stream")
119
  return _x(
120
  '"%1$s" in "%2$s" updated',
121
  '1: File name, 2: Theme/plugin name',
@@ -285,9 +291,17 @@ class Connector_Editor extends Connector {
285
  return $output;
286
  }
287
 
288
- /**
289
- * @filter wp_redirect
290
- */
 
 
 
 
 
 
 
 
291
  public function log_changes( $location ) {
292
  if ( ! empty( $this->edited_file ) ) {
293
  // TODO: phpcs fix
1
  <?php
2
+ /** MainWP Editor Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_Editor
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_Editor extends Connector {
11
  /**
12
  * Connector slug
121
  * @return string Translated string
122
  */
123
  public function get_message() {
124
+ // translators: Placeholders refer to a file name, and a theme / plugin name (e.g. "index.php", "Stream").
125
  return _x(
126
  '"%1$s" in "%2$s" updated',
127
  '1: File name, 2: Theme/plugin name',
291
  return $output;
292
  }
293
 
294
+ /**
295
+ * Log Changes.
296
+ *
297
+ * @filter wp_redirect
298
+ *
299
+ * @param string $location Log location.
300
+ * @return string $location Log location.
301
+ *
302
+ * @uses \WP_MainWP_Stream\Connector_Editor::get_context()
303
+ * @uses \WP_MainWP_Stream\Connector_Editor::get_message()
304
+ */
305
  public function log_changes( $location ) {
306
  if ( ! empty( $this->edited_file ) ) {
307
  // TODO: phpcs fix
connectors/class-connector-gravityforms.php CHANGED
@@ -1,26 +1,21 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_GravityForms extends Connector {
5
- /**
6
- * Connector slug
7
- *
8
- * @var string
9
- */
10
  public $name = 'gravityforms';
11
 
12
- /**
13
- * Holds tracked plugin minimum version required
14
- *
15
- * @const string
16
- */
17
  const PLUGIN_MIN_VERSION = '1.9.14';
18
 
19
- /**
20
- * Actions registered for this connector
21
- *
22
- * @var array
23
- */
24
  public $actions = array(
25
  'gform_after_save_form',
26
  'gform_pre_confirmation_save',
@@ -50,24 +45,16 @@ class Connector_GravityForms extends Connector {
50
  'delete_site_option',
51
  );
52
 
53
- /**
54
- * Tracked option keys
55
- *
56
- * @var array
57
- */
58
  public $options = array();
59
 
60
- /**
61
- * Tracking registered Settings, with overridden data
62
- *
63
- * @var array
64
- */
65
  public $options_override = array();
66
 
67
  /**
68
  * Check if plugin dependencies are satisfied and add an admin notice if not
69
  *
70
- * @return bool
71
  */
72
  public function is_dependency_satisfied() {
73
  if ( class_exists( 'GFForms' ) && version_compare( \GFCommon::$version, self::PLUGIN_MIN_VERSION, '>=' ) ) {
@@ -78,18 +65,18 @@ class Connector_GravityForms extends Connector {
78
  }
79
 
80
  /**
81
- * Return translated connector label
82
  *
83
- * @return string Translated connector label
84
  */
85
  public function get_label() {
86
  return esc_html_x( 'Gravity Forms', 'gravityforms', 'mainwp-child-reports' );
87
  }
88
 
89
  /**
90
- * Return translated action labels
91
  *
92
- * @return array Action label translations
93
  */
94
  public function get_action_labels() {
95
  return array(
@@ -111,9 +98,9 @@ class Connector_GravityForms extends Connector {
111
  }
112
 
113
  /**
114
- * Return translated context labels
115
  *
116
- * @return array Context label translations
117
  */
118
  public function get_context_labels() {
119
  return array(
@@ -126,14 +113,14 @@ class Connector_GravityForms extends Connector {
126
  }
127
 
128
  /**
129
- * Add action links to Stream drop row in admin list screen
130
  *
131
- * @filter wp_mainwp_stream_action_links_{connector}
132
  *
133
- * @param array $links Previous links registered
134
- * @param object $record Stream record
135
  *
136
- * @return array Action links
137
  */
138
  public function action_links( $links, $record ) {
139
  if ( 'forms' === $record->context ) {
@@ -176,7 +163,10 @@ class Connector_GravityForms extends Connector {
176
  return $links;
177
  }
178
 
179
- public function register() {
 
 
 
180
  parent::register();
181
 
182
  $this->options = array(
@@ -203,10 +193,10 @@ class Connector_GravityForms extends Connector {
203
  }
204
 
205
  /**
206
- * Track Create/Update actions on Forms
207
  *
208
- * @param array $form
209
- * @param bool $is_new
210
  * @return void
211
  */
212
  public function callback_gform_after_save_form( $form, $is_new ) {
@@ -215,7 +205,7 @@ class Connector_GravityForms extends Connector {
215
 
216
  $this->log(
217
  sprintf(
218
- // translators: Placeholders refer to a form title, and a status (e.g. "Contact Form", "created")
219
  __( '"%1$s" form %2$s', 'mainwp-child-reports' ),
220
  $title,
221
  $is_new ? esc_html__( 'created', 'mainwp-child-reports' ) : esc_html__( 'updated', 'mainwp-child-reports' )
@@ -232,12 +222,12 @@ class Connector_GravityForms extends Connector {
232
  }
233
 
234
  /**
235
- * Track saving form confirmations
236
  *
237
- * @param array $confirmation
238
- * @param array $form
239
- * @param bool $is_new
240
- * @return array
241
  */
242
  public function callback_gform_pre_confirmation_save( $confirmation, $form, $is_new = true ) {
243
  if ( ! isset( $is_new ) ) {
@@ -265,12 +255,12 @@ class Connector_GravityForms extends Connector {
265
  }
266
 
267
  /**
268
- * Track saving form notifications
269
  *
270
- * @param array $notification
271
- * @param array $form
272
- * @param bool $is_new
273
- * @return array
274
  */
275
  public function callback_gform_pre_notification_save( $notification, $form, $is_new = true ) {
276
  if ( ! isset( $is_new ) ) {
@@ -298,16 +288,16 @@ class Connector_GravityForms extends Connector {
298
  }
299
 
300
  /**
301
- * Track deletion of notifications
302
  *
303
- * @param array $notification
304
- * @param array $form
305
  * @return void
306
  */
307
  public function callback_gform_pre_notification_deleted( $notification, $form ) {
308
  $this->log(
309
  sprintf(
310
- // translators: Placeholders refer to a notification name, and a form title (e.g. "Email", "Contact Form")
311
  __( '"%1$s" notification deleted from "%2$s"', 'mainwp-child-reports' ),
312
  $notification['name'],
313
  $form['title']
@@ -323,10 +313,10 @@ class Connector_GravityForms extends Connector {
323
  }
324
 
325
  /**
326
- * Track deletion of confirmations
327
  *
328
- * @param array $confirmation
329
- * @param array $form
330
  * @return void
331
  */
332
  public function callback_gform_pre_confirmation_deleted( $confirmation, $form ) {
@@ -348,17 +338,17 @@ class Connector_GravityForms extends Connector {
348
  }
349
 
350
  /**
351
- * Track status change of confirmations
352
  *
353
- * @param array $confirmation
354
- * @param array $form
355
- * @param bool $is_active
356
  * @return void
357
  */
358
  public function callback_gform_confirmation_status( $confirmation, $form, $is_active ) {
359
  $this->log(
360
  sprintf(
361
- // translators: Placeholders refer to a confirmation name, a status, and a form title (e.g. "Email", "activated", "Contact Form")
362
  __( '"%1$s" confirmation %2$s from "%3$s"', 'mainwp-child-reports' ),
363
  $confirmation['name'],
364
  $is_active ? esc_html__( 'activated', 'mainwp-child-reports' ) : esc_html__( 'deactivated', 'mainwp-child-reports' ),
@@ -376,17 +366,17 @@ class Connector_GravityForms extends Connector {
376
  }
377
 
378
  /**
379
- * Track status change of notifications
380
  *
381
- * @param array $notification
382
- * @param array $form
383
- * @param bool $is_active
384
  * @return void
385
  */
386
  public function callback_gform_notification_status( $notification, $form, $is_active ) {
387
  $this->log(
388
  sprintf(
389
- // translators: Placeholders refer to a notification name, a status, and a form title (e.g. "Email", "activated", "Contact Form")
390
  __( '"%1$s" notification %2$s from "%3$s"', 'mainwp-child-reports' ),
391
  $notification['name'],
392
  $is_active ? esc_html__( 'activated', 'mainwp-child-reports' ) : esc_html__( 'deactivated', 'mainwp-child-reports' ),
@@ -403,31 +393,74 @@ class Connector_GravityForms extends Connector {
403
  );
404
  }
405
 
406
- public function callback_update_option( $option, $old, $new ) {
 
 
 
 
 
 
 
407
  $this->check( $option, $old, $new );
408
  }
409
 
410
- public function callback_add_option( $option, $val ) {
 
 
 
 
 
 
411
  $this->check( $option, null, $val );
412
  }
413
 
414
- public function callback_delete_option( $option ) {
 
 
 
 
 
415
  $this->check( $option, null, null );
416
  }
417
 
418
- public function callback_update_site_option( $option, $old, $new ) {
 
 
 
 
 
 
 
419
  $this->check( $option, $old, $new );
420
  }
421
 
422
- public function callback_add_site_option( $option, $val ) {
 
 
 
 
 
 
423
  $this->check( $option, null, $val );
424
  }
425
 
426
- public function callback_delete_site_option( $option ) {
 
 
 
 
 
427
  $this->check( $option, null, null );
428
  }
429
 
430
- public function check( $option, $old_value, $new_value ) {
 
 
 
 
 
 
 
431
  if ( ! array_key_exists( $option, $this->options ) ) {
432
  return;
433
  }
@@ -450,13 +483,19 @@ class Connector_GravityForms extends Connector {
450
  }
451
  }
452
 
453
- public function check_rg_gforms_key( $old_value, $new_value ) {
 
 
 
 
 
 
454
  $is_update = ( $new_value && strlen( $new_value ) );
455
  $option = 'rg_gforms_key';
456
 
457
  $this->log(
458
  sprintf(
459
- // translators: Placeholder refers to a status (e.g. "updated")
460
  __( 'Gravity Forms license key %s', 'mainwp-child-reports' ),
461
  $is_update ? esc_html__( 'updated', 'mainwp-child-reports' ) : esc_html__( 'deleted', 'mainwp-child-reports' )
462
  ),
@@ -467,10 +506,18 @@ class Connector_GravityForms extends Connector {
467
  );
468
  }
469
 
470
- public function callback_gform_post_export_entries( $form, $start_date, $end_date, $fields ) {
 
 
 
 
 
 
 
 
471
  unset( $fields );
472
  $this->log(
473
- // translators: Placeholder refers to a form title (e.g. "Contact Form")
474
  __( '"%s" form entries exported', 'mainwp-child-reports' ),
475
  array(
476
  'form_title' => $form['title'],
@@ -484,13 +531,18 @@ class Connector_GravityForms extends Connector {
484
  );
485
  }
486
 
487
- public function callback_gform_forms_post_import( $forms ) {
 
 
 
 
 
488
  $forms_total = count( $forms );
489
  $forms_ids = wp_list_pluck( $forms, 'id' );
490
  $forms_titles = wp_list_pluck( $forms, 'title' );
491
 
492
  $this->log(
493
- // translators: Placeholder refers to a number of forms (e.g. "42")
494
  _n( '%d form imported', '%d forms imported', $forms_total, 'mainwp-child-reports' ),
495
  array(
496
  'count' => $forms_total,
@@ -503,11 +555,19 @@ class Connector_GravityForms extends Connector {
503
  );
504
  }
505
 
506
- public function callback_gform_export_separator( $dummy, $form_id ) {
 
 
 
 
 
 
 
 
507
  $form = $this->get_form( $form_id );
508
 
509
  $this->log(
510
- // translators: Placeholder refers to a form title (e.g. "Contact Form")
511
  __( '"%s" form exported', 'mainwp-child-reports' ),
512
  array(
513
  'form_title' => $form['title'],
@@ -521,12 +581,19 @@ class Connector_GravityForms extends Connector {
521
  return $dummy;
522
  }
523
 
524
- public function callback_gform_export_options( $dummy, $forms ) {
 
 
 
 
 
 
 
525
  $ids = wp_list_pluck( $forms, 'id' );
526
  $titles = wp_list_pluck( $forms, 'title' );
527
 
528
  $this->log(
529
- // translators: Placeholder refers to a number of forms (e.g. "42")
530
  _n( 'Export process started for %d form', 'Export process started for %d forms', count( $forms ), 'mainwp-child-reports' ),
531
  array(
532
  'count' => count( $forms ),
@@ -541,12 +608,17 @@ class Connector_GravityForms extends Connector {
541
  return $dummy;
542
  }
543
 
544
- public function callback_gform_delete_lead( $lead_id ) {
 
 
 
 
 
545
  $lead = $this->get_lead( $lead_id );
546
  $form = $this->get_form( $lead['form_id'] );
547
 
548
  $this->log(
549
- // translators: Placeholders refer to an ID, and a form title (e.g. "42", "Contact Form")
550
  __( 'Lead #%1$d from "%2$s" deleted', 'mainwp-child-reports' ),
551
  array(
552
  'lead_id' => $lead_id,
@@ -559,7 +631,17 @@ class Connector_GravityForms extends Connector {
559
  );
560
  }
561
 
562
- public function callback_gform_post_note_added( $note_id, $lead_id, $user_id, $user_name, $note, $note_type ) {
 
 
 
 
 
 
 
 
 
 
563
  unset( $user_id );
564
  unset( $user_name );
565
  unset( $note );
@@ -569,7 +651,7 @@ class Connector_GravityForms extends Connector {
569
  $form = $this->get_form( $lead['form_id'] );
570
 
571
  $this->log(
572
- // translators: Placeholders refer to an ID, another ID, and a form title (e.g. "42", "7", "Contact Form")
573
  __( 'Note #%1$d added to lead #%2$d on "%3$s" form', 'mainwp-child-reports' ),
574
  array(
575
  'note_id' => $note_id,
@@ -583,7 +665,13 @@ class Connector_GravityForms extends Connector {
583
  );
584
  }
585
 
586
- public function callback_gform_pre_note_deleted( $note_id, $lead_id ) {
 
 
 
 
 
 
587
  $lead = $this->get_lead( $lead_id );
588
  $form = $this->get_form( $lead['form_id'] );
589
 
@@ -602,7 +690,14 @@ class Connector_GravityForms extends Connector {
602
  );
603
  }
604
 
605
- public function callback_gform_update_status( $lead_id, $status, $prev = '' ) {
 
 
 
 
 
 
 
606
  $lead = $this->get_lead( $lead_id );
607
  $form = $this->get_form( $lead['form_id'] );
608
 
@@ -623,7 +718,7 @@ class Connector_GravityForms extends Connector {
623
 
624
  $this->log(
625
  sprintf(
626
- // translators: Placeholders refer to an ID, a status, and a form title (e.g. "42", "activated", "Contact Form")
627
  __( 'Lead #%1$d %2$s on "%3$s" form', 'mainwp-child-reports' ),
628
  $lead_id,
629
  $actions[ $status ],
@@ -643,10 +738,10 @@ class Connector_GravityForms extends Connector {
643
  }
644
 
645
  /**
646
- * Callback fired when an entry is read/unread
647
  *
648
- * @param int $lead_id
649
- * @param int $status
650
  * @return void
651
  */
652
  public function callback_gform_update_is_read( $lead_id, $status ) {
@@ -656,7 +751,7 @@ class Connector_GravityForms extends Connector {
656
 
657
  $this->log(
658
  sprintf(
659
- // translators: Placeholders refer to an ID, a status, and a form title (e.g. "42", "unread", "Contact Form")
660
  __( 'Entry #%1$d marked as %2$s on form #%3$d ("%4$s")', 'mainwp-child-reports' ),
661
  $lead_id,
662
  $status,
@@ -678,8 +773,8 @@ class Connector_GravityForms extends Connector {
678
  /**
679
  * Callback fired when an entry is starred/unstarred
680
  *
681
- * @param int $lead_id
682
- * @param int $status
683
  * @return void
684
  */
685
  public function callback_gform_update_is_starred( $lead_id, $status ) {
@@ -690,7 +785,7 @@ class Connector_GravityForms extends Connector {
690
 
691
  $this->log(
692
  sprintf(
693
- // translators: Placeholders refer to an ID, a status, and a form title (e.g. "42", "starred", "Contact Form")
694
  __( 'Entry #%1$d %2$s on form #%3$d ("%4$s")', 'mainwp-child-reports' ),
695
  $lead_id,
696
  $status,
@@ -710,9 +805,9 @@ class Connector_GravityForms extends Connector {
710
  }
711
 
712
  /**
713
- * Callback fired when a form is deleted
714
  *
715
- * @param int $form_id Form ID
716
  * @return void
717
  */
718
  public function callback_gform_before_delete_form( $form_id ) {
@@ -720,9 +815,9 @@ class Connector_GravityForms extends Connector {
720
  }
721
 
722
  /**
723
- * Callback fired when a form is trashed
724
  *
725
- * @param int $form_id Form ID
726
  * @return void
727
  */
728
  public function callback_gform_post_form_trashed( $form_id ) {
@@ -730,9 +825,9 @@ class Connector_GravityForms extends Connector {
730
  }
731
 
732
  /**
733
- * Callback fired when a form is restored
734
  *
735
- * @param int $form_id Form ID
736
  * @return void
737
  */
738
  public function callback_gform_post_form_restored( $form_id ) {
@@ -740,9 +835,9 @@ class Connector_GravityForms extends Connector {
740
  }
741
 
742
  /**
743
- * Callback fired when a form is activated
744
  *
745
- * @param int $form_id Form ID
746
  * @return void
747
  */
748
  public function callback_gform_post_form_activated( $form_id ) {
@@ -750,9 +845,9 @@ class Connector_GravityForms extends Connector {
750
  }
751
 
752
  /**
753
- * Callback fired when a form is deactivated
754
  *
755
- * @param int $form_id Form ID
756
  * @return void
757
  */
758
  public function callback_gform_post_form_deactivated( $form_id ) {
@@ -760,9 +855,9 @@ class Connector_GravityForms extends Connector {
760
  }
761
 
762
  /**
763
- * Callback fired when a form is duplicated
764
  *
765
- * @param int $form_id Form ID
766
  * @return void
767
  */
768
  public function callback_gform_post_form_duplicated( $form_id ) {
@@ -770,9 +865,9 @@ class Connector_GravityForms extends Connector {
770
  }
771
 
772
  /**
773
- * Callback fired when a form's views are reset
774
  *
775
- * @param int $form_id Form ID
776
  * @return void
777
  */
778
  public function callback_gform_post_form_views_deleted( $form_id ) {
@@ -780,10 +875,10 @@ class Connector_GravityForms extends Connector {
780
  }
781
 
782
  /**
783
- * Track status change of forms
784
  *
785
- * @param int $form_id
786
- * @param string $action
787
  * @return void
788
  */
789
  public function log_form_action( $form_id, $action ) {
@@ -823,20 +918,20 @@ class Connector_GravityForms extends Connector {
823
  }
824
 
825
  /**
826
- * Helper function to get a single entry
827
  *
828
- * @param int $lead_id Lead ID
829
- * @return array
830
  */
831
  private function get_lead( $lead_id ) {
832
  return \GFFormsModel::get_lead( $lead_id );
833
  }
834
 
835
  /**
836
- * Helper function to get a single form
837
  *
838
- * @param int $form_id Form ID
839
- * @return array
840
  */
841
  private function get_form( $form_id ) {
842
  return \GFFormsModel::get_form_meta( $form_id );
1
  <?php
2
+ /** GravityForms Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_GravityForms
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_GravityForms extends Connector {
11
+
12
+ /** @var string Connector slug. */
 
 
 
13
  public $name = 'gravityforms';
14
 
15
+ /** @const string Holds tracked plugin minimum version required. */
 
 
 
 
16
  const PLUGIN_MIN_VERSION = '1.9.14';
17
 
18
+ /** @var array Actions registered for this connector. */
 
 
 
 
19
  public $actions = array(
20
  'gform_after_save_form',
21
  'gform_pre_confirmation_save',
45
  'delete_site_option',
46
  );
47
 
48
+ /** @var array Tracked option keys. */
 
 
 
 
49
  public $options = array();
50
 
51
+ /** @var array Tracking registered Settings, with overridden data. */
 
 
 
 
52
  public $options_override = array();
53
 
54
  /**
55
  * Check if plugin dependencies are satisfied and add an admin notice if not
56
  *
57
+ * @return bool Return TRUE|FALSE.
58
  */
59
  public function is_dependency_satisfied() {
60
  if ( class_exists( 'GFForms' ) && version_compare( \GFCommon::$version, self::PLUGIN_MIN_VERSION, '>=' ) ) {
65
  }
66
 
67
  /**
68
+ * Return translated connector label.
69
  *
70
+ * @return string Translated connector label.
71
  */
72
  public function get_label() {
73
  return esc_html_x( 'Gravity Forms', 'gravityforms', 'mainwp-child-reports' );
74
  }
75
 
76
  /**
77
+ * Return translated action labels.
78
  *
79
+ * @return array Action label translations.
80
  */
81
  public function get_action_labels() {
82
  return array(
98
  }
99
 
100
  /**
101
+ * Return translated context labels.
102
  *
103
+ * @return array Context label translations.
104
  */
105
  public function get_context_labels() {
106
  return array(
113
  }
114
 
115
  /**
116
+ * Add action links to Stream drop row in admin list screen.
117
  *
118
+ * @filter wp_mainwp_stream_action_links_{connector}.
119
  *
120
+ * @param array $links Previous links registered.
121
+ * @param object $record Stream record.
122
  *
123
+ * @return array Action links.
124
  */
125
  public function action_links( $links, $record ) {
126
  if ( 'forms' === $record->context ) {
163
  return $links;
164
  }
165
 
166
+ /**
167
+ * Register with parent class.
168
+ */
169
+ public function register() {
170
  parent::register();
171
 
172
  $this->options = array(
193
  }
194
 
195
  /**
196
+ * Track Create/Update actions on Forms.
197
  *
198
+ * @param array $form Forms array.
199
+ * @param bool $is_new Check if is new action.
200
  * @return void
201
  */
202
  public function callback_gform_after_save_form( $form, $is_new ) {
205
 
206
  $this->log(
207
  sprintf(
208
+ // translators: Placeholders refer to a form title, and a status (e.g. "Contact Form", "created").
209
  __( '"%1$s" form %2$s', 'mainwp-child-reports' ),
210
  $title,
211
  $is_new ? esc_html__( 'created', 'mainwp-child-reports' ) : esc_html__( 'updated', 'mainwp-child-reports' )
222
  }
223
 
224
  /**
225
+ * Track saving form confirmations.
226
  *
227
+ * @param array $confirmation Confirmations array.
228
+ * @param array $form Forms array.
229
+ * @param bool $is_new Check if new submission.
230
+ * @return array Return response array.
231
  */
232
  public function callback_gform_pre_confirmation_save( $confirmation, $form, $is_new = true ) {
233
  if ( ! isset( $is_new ) ) {
255
  }
256
 
257
  /**
258
+ * Track saving form notifications.
259
  *
260
+ * @param array $notification Notifications array.
261
+ * @param array $form Form array.
262
+ * @param bool $is_new Check if new form post.
263
+ * @return array Return response array.
264
  */
265
  public function callback_gform_pre_notification_save( $notification, $form, $is_new = true ) {
266
  if ( ! isset( $is_new ) ) {
288
  }
289
 
290
  /**
291
+ * Track deletion of notifications.
292
  *
293
+ * @param array $notification Notifications array.
294
+ * @param array $form Forms array.
295
  * @return void
296
  */
297
  public function callback_gform_pre_notification_deleted( $notification, $form ) {
298
  $this->log(
299
  sprintf(
300
+ // translators: Placeholders refer to a notification name, and a form title (e.g. "Email", "Contact Form").
301
  __( '"%1$s" notification deleted from "%2$s"', 'mainwp-child-reports' ),
302
  $notification['name'],
303
  $form['title']
313
  }
314
 
315
  /**
316
+ * Track deletion of confirmations.
317
  *
318
+ * @param array $confirmation Confirmation array.
319
+ * @param array $form Form array.
320
  * @return void
321
  */
322
  public function callback_gform_pre_confirmation_deleted( $confirmation, $form ) {
338
  }
339
 
340
  /**
341
+ * Track status change of confirmations.
342
  *
343
+ * @param array $confirmation Confirmation array.
344
+ * @param array $form Forms array.
345
+ * @param bool $is_active Check if is active.
346
  * @return void
347
  */
348
  public function callback_gform_confirmation_status( $confirmation, $form, $is_active ) {
349
  $this->log(
350
  sprintf(
351
+ // translators: Placeholders refer to a confirmation name, a status, and a form title (e.g. "Email", "activated", "Contact Form").
352
  __( '"%1$s" confirmation %2$s from "%3$s"', 'mainwp-child-reports' ),
353
  $confirmation['name'],
354
  $is_active ? esc_html__( 'activated', 'mainwp-child-reports' ) : esc_html__( 'deactivated', 'mainwp-child-reports' ),
366
  }
367
 
368
  /**
369
+ * Track status change of notifications.
370
  *
371
+ * @param array $notification Notifications array.
372
+ * @param array $form Forms array.
373
+ * @param bool $is_active Check if active.
374
  * @return void
375
  */
376
  public function callback_gform_notification_status( $notification, $form, $is_active ) {
377
  $this->log(
378
  sprintf(
379
+ // translators: Placeholders refer to a notification name, a status, and a form title (e.g. "Email", "activated", "Contact Form").
380
  __( '"%1$s" notification %2$s from "%3$s"', 'mainwp-child-reports' ),
381
  $notification['name'],
382
  $is_active ? esc_html__( 'activated', 'mainwp-child-reports' ) : esc_html__( 'deactivated', 'mainwp-child-reports' ),
393
  );
394
  }
395
 
396
+ /**
397
+ * Update option contact callback.
398
+ *
399
+ * @param string $option Option to update.
400
+ * @param string $old Old value.
401
+ * @param string $new New value.
402
+ */
403
+ public function callback_update_option( $option, $old, $new ) {
404
  $this->check( $option, $old, $new );
405
  }
406
 
407
+ /**
408
+ * Add option callback.
409
+ *
410
+ * @param string $option Option to update.
411
+ * @param string $val Option value.
412
+ */
413
+ public function callback_add_option( $option, $val ) {
414
  $this->check( $option, null, $val );
415
  }
416
 
417
+ /**
418
+ * Delete option callback.
419
+ *
420
+ * @param $option Option to delete.
421
+ */
422
+ public function callback_delete_option( $option ) {
423
  $this->check( $option, null, null );
424
  }
425
 
426
+ /**
427
+ * Update site option callback.
428
+ *
429
+ * @param string $option Option to update.
430
+ * @param string $old Old value.
431
+ * @param string $new New value.
432
+ */
433
+ public function callback_update_site_option( $option, $old, $new ) {
434
  $this->check( $option, $old, $new );
435
  }
436
 
437
+ /**
438
+ * Add site option callback.
439
+ *
440
+ * @param string $option Option to update.
441
+ * @param string $val Option value.
442
+ */
443
+ public function callback_add_site_option( $option, $val ) {
444
  $this->check( $option, null, $val );
445
  }
446
 
447
+ /**
448
+ * Delete site option callback.
449
+ *
450
+ * @param string $option Option to update.
451
+ */
452
+ public function callback_delete_site_option( $option ) {
453
  $this->check( $option, null, null );
454
  }
455
 
456
+ /**
457
+ * Check if option exists.
458
+ *
459
+ * @param string $option Option to update.
460
+ * @param string $old_value Old value.
461
+ * @param string $new_value New value.
462
+ */
463
+ public function check( $option, $old_value, $new_value ) {
464
  if ( ! array_key_exists( $option, $this->options ) ) {
465
  return;
466
  }
483
  }
484
  }
485
 
486
+ /**
487
+ * Check Register GravityForms key.
488
+ *
489
+ * @param string $old_value Old value.
490
+ * @param string $new_value New value.
491
+ */
492
+ public function check_rg_gforms_key($old_value, $new_value ) {
493
  $is_update = ( $new_value && strlen( $new_value ) );
494
  $option = 'rg_gforms_key';
495
 
496
  $this->log(
497
  sprintf(
498
+ // translators: Placeholder refers to a status (e.g. "updated").
499
  __( 'Gravity Forms license key %s', 'mainwp-child-reports' ),
500
  $is_update ? esc_html__( 'updated', 'mainwp-child-reports' ) : esc_html__( 'deleted', 'mainwp-child-reports' )
501
  ),
506
  );
507
  }
508
 
509
+ /**
510
+ * GravityForms post export entries callback.
511
+ *
512
+ * @param array $form Form data array.
513
+ * @param int $start_date Start date.
514
+ * @param int $end_date End date.
515
+ * @param array $fields Form fields array.
516
+ */
517
+ public function callback_gform_post_export_entries( $form, $start_date, $end_date, $fields ) {
518
  unset( $fields );
519
  $this->log(
520
+ // translators: Placeholder refers to a form title (e.g. "Contact Form").
521
  __( '"%s" form entries exported', 'mainwp-child-reports' ),
522
  array(
523
  'form_title' => $form['title'],
531
  );
532
  }
533
 
534
+ /**
535
+ * GravityForms post import callback.
536
+ *
537
+ * @param $forms Forms array.
538
+ */
539
+ public function callback_gform_forms_post_import( $forms ) {
540
  $forms_total = count( $forms );
541
  $forms_ids = wp_list_pluck( $forms, 'id' );
542
  $forms_titles = wp_list_pluck( $forms, 'title' );
543
 
544
  $this->log(
545
+ // translators: Placeholder refers to a number of forms (e.g. "42").
546
  _n( '%d form imported', '%d forms imported', $forms_total, 'mainwp-child-reports' ),
547
  array(
548
  'count' => $forms_total,
555
  );
556
  }
557
 
558
+ /**
559
+ * GravityForms export separator callback.
560
+ *
561
+ * @param $dummy
562
+ * @param $form_id Form ID.
563
+ *
564
+ * @return mixed
565
+ */
566
+ public function callback_gform_export_separator( $dummy, $form_id ) {
567
  $form = $this->get_form( $form_id );
568
 
569
  $this->log(
570
+ // translators: Placeholder refers to a form title (e.g. "Contact Form").
571
  __( '"%s" form exported', 'mainwp-child-reports' ),
572
  array(
573
  'form_title' => $form['title'],
581
  return $dummy;
582
  }
583
 
584
+ /**
585
+ * GravityForms export options callback.
586
+ *
587
+ * @param $dummy
588
+ * @param $forms Forms array.
589
+ * @return mixed
590
+ */
591
+ public function callback_gform_export_options( $dummy, $forms ) {
592
  $ids = wp_list_pluck( $forms, 'id' );
593
  $titles = wp_list_pluck( $forms, 'title' );
594
 
595
  $this->log(
596
+ // translators: Placeholder refers to a number of forms (e.g. "42").
597
  _n( 'Export process started for %d form', 'Export process started for %d forms', count( $forms ), 'mainwp-child-reports' ),
598
  array(
599
  'count' => count( $forms ),
608
  return $dummy;
609
  }
610
 
611
+ /**
612
+ * GravityForms delete leads callback.
613
+ *
614
+ * @param $lead_id Lead ID.
615
+ */
616
+ public function callback_gform_delete_lead( $lead_id ) {
617
  $lead = $this->get_lead( $lead_id );
618
  $form = $this->get_form( $lead['form_id'] );
619
 
620
  $this->log(
621
+ // translators: Placeholders refer to an ID, and a form title (e.g. "42", "Contact Form").
622
  __( 'Lead #%1$d from "%2$s" deleted', 'mainwp-child-reports' ),
623
  array(
624
  'lead_id' => $lead_id,
631
  );
632
  }
633
 
634
+ /**
635
+ * GravityForms post note added callback.
636
+ *
637
+ * @param string $note_id Note ID.
638
+ * @param string $lead_id Lead ID.
639
+ * @param string $user_id User ID.
640
+ * @param string $user_name User Name.
641
+ * @param string $note Note.
642
+ * @param string $note_type Note type.
643
+ */
644
+ public function callback_gform_post_note_added( $note_id, $lead_id, $user_id, $user_name, $note, $note_type ) {
645
  unset( $user_id );
646
  unset( $user_name );
647
  unset( $note );
651
  $form = $this->get_form( $lead['form_id'] );
652
 
653
  $this->log(
654
+ // translators: Placeholders refer to an ID, another ID, and a form title (e.g. "42", "7", "Contact Form").
655
  __( 'Note #%1$d added to lead #%2$d on "%3$s" form', 'mainwp-child-reports' ),
656
  array(
657
  'note_id' => $note_id,
665
  );
666
  }
667
 
668
+ /**
669
+ * GravityForms pre note deleted callback.
670
+ *
671
+ * @param string $note_id Note ID.
672
+ * @param string $lead_id Lead ID.
673
+ */
674
+ public function callback_gform_pre_note_deleted($note_id, $lead_id ) {
675
  $lead = $this->get_lead( $lead_id );
676
  $form = $this->get_form( $lead['form_id'] );
677
 
690
  );
691
  }
692
 
693
+ /**
694
+ * GravityForm update status callback.
695
+ *
696
+ * @param string $lead_id Lead ID.
697
+ * @param string $status Update status.
698
+ * @param string $prev Trashed status.
699
+ */
700
+ public function callback_gform_update_status( $lead_id, $status, $prev = '' ) {
701
  $lead = $this->get_lead( $lead_id );
702
  $form = $this->get_form( $lead['form_id'] );
703
 
718
 
719
  $this->log(
720
  sprintf(
721
+ // translators: Placeholders refer to an ID, a status, and a form title (e.g. "42", "activated", "Contact Form").
722
  __( 'Lead #%1$d %2$s on "%3$s" form', 'mainwp-child-reports' ),
723
  $lead_id,
724
  $actions[ $status ],
738
  }
739
 
740
  /**
741
+ * Callback fired when an entry is read/unread.
742
  *
743
+ * @param int $lead_id Lead ID.
744
+ * @param int $status Read / unread status.
745
  * @return void
746
  */
747
  public function callback_gform_update_is_read( $lead_id, $status ) {
751
 
752
  $this->log(
753
  sprintf(
754
+ // translators: Placeholders refer to an ID, a status, and a form title (e.g. "42", "unread", "Contact Form").
755
  __( 'Entry #%1$d marked as %2$s on form #%3$d ("%4$s")', 'mainwp-child-reports' ),
756
  $lead_id,
757
  $status,
773
  /**
774
  * Callback fired when an entry is starred/unstarred
775
  *
776
+ * @param int $lead_id Leads ID.
777
+ * @param int $status Stared / unstared status.
778
  * @return void
779
  */
780
  public function callback_gform_update_is_starred( $lead_id, $status ) {
785
 
786
  $this->log(
787
  sprintf(
788
+ // translators: Placeholders refer to an ID, a status, and a form title (e.g. "42", "starred", "Contact Form").
789
  __( 'Entry #%1$d %2$s on form #%3$d ("%4$s")', 'mainwp-child-reports' ),
790
  $lead_id,
791
  $status,
805
  }
806
 
807
  /**
808
+ * Callback fired when a form is deleted.
809
  *
810
+ * @param int $form_id Form ID.
811
  * @return void
812
  */
813
  public function callback_gform_before_delete_form( $form_id ) {
815
  }
816
 
817
  /**
818
+ * Callback fired when a form is trashed.
819
  *
820
+ * @param int $form_id Form ID.
821
  * @return void
822
  */
823
  public function callback_gform_post_form_trashed( $form_id ) {
825
  }
826
 
827
  /**
828
+ * Callback fired when a form is restored.
829
  *
830
+ * @param int $form_id Form ID.
831
  * @return void
832
  */
833
  public function callback_gform_post_form_restored( $form_id ) {
835
  }
836
 
837
  /**
838
+ * Callback fired when a form is activated.
839
  *
840
+ * @param int $form_id Form ID.
841
  * @return void
842
  */
843
  public function callback_gform_post_form_activated( $form_id ) {
845
  }
846
 
847
  /**
848
+ * Callback fired when a form is deactivated.
849
  *
850
+ * @param int $form_id Form ID.
851
  * @return void
852
  */
853
  public function callback_gform_post_form_deactivated( $form_id ) {
855
  }
856
 
857
  /**
858
+ * Callback fired when a form is duplicated.
859
  *
860
+ * @param int $form_id Form ID.
861
  * @return void
862
  */
863
  public function callback_gform_post_form_duplicated( $form_id ) {
865
  }
866
 
867
  /**
868
+ * Callback fired when a form's views are reset.
869
  *
870
+ * @param int $form_id Form ID.
871
  * @return void
872
  */
873
  public function callback_gform_post_form_views_deleted( $form_id ) {
875
  }
876
 
877
  /**
878
+ * Track status change of forms.
879
  *
880
+ * @param int $form_id Form ID.
881
+ * @param string $action Form action.
882
  * @return void
883
  */
884
  public function log_form_action( $form_id, $action ) {
918
  }
919
 
920
  /**
921
+ * Helper function to get a single entry.
922
  *
923
+ * @param int $lead_id Lead ID.
924
+ * @return array Return Lead array.
925
  */
926
  private function get_lead( $lead_id ) {
927
  return \GFFormsModel::get_lead( $lead_id );
928
  }
929
 
930
  /**
931
+ * Helper function to get a single form.
932
  *
933
+ * @param int $form_id Form ID.
934
+ * @return array Return form meta array.
935
  */
936
  private function get_form( $form_id ) {
937
  return \GFFormsModel::get_form_meta( $form_id );
connectors/class-connector-installer.php CHANGED
@@ -1,20 +1,18 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Installer extends Connector {
5
 
6
- /**
7
- * Connector slug
8
- *
9
- * @var string
10
- */
11
  public $name = 'installer';
12
 
13
- /**
14
- * Actions registered for this connector
15
- *
16
- * @var array
17
- */
18
  public $actions = array(
19
  'upgrader_pre_install', // use to the current version of all plugins, before they are upgraded ( Net-Concept - Xavier NUEL )
20
  'upgrader_process_complete', // plugins::installed | themes::installed
@@ -31,28 +29,25 @@ class Connector_Installer extends Connector {
31
  //'mainwp_child_upgradePluginTheme'
32
  );
33
 
34
- public $old_plugins = array();
 
35
 
36
- /**
37
- * Register connector in the WP Frontend
38
- *
39
- * @var bool
40
- */
41
  public $register_frontend = false;
42
 
43
  /**
44
- * Return translated connector label
45
  *
46
- * @return string Translated connector label
47
  */
48
  public function get_label() {
49
  return esc_html__( 'Installer', 'mainwp-child-reports' );
50
  }
51
 
52
  /**
53
- * Return translated action labels
54
  *
55
- * @return array Action label translations
56
  */
57
  public function get_action_labels() {
58
  return array(
@@ -65,9 +60,9 @@ class Connector_Installer extends Connector {
65
  }
66
 
67
  /**
68
- * Return translated context labels
69
  *
70
- * @return array Context label translations
71
  */
72
  public function get_context_labels() {
73
  return array(
@@ -78,17 +73,19 @@ class Connector_Installer extends Connector {
78
  }
79
 
80
  /**
81
- * Add action links to Stream drop row in admin list screen
82
  *
83
- * @filter wp_mainwp_stream_action_links_{connector}
84
  *
85
- * @param array $links Previous links registered
86
- * @param object $record Stream record
87
  *
88
- * @return array Action links
89
  */
90
  public function action_links( $links, $record ) {
91
  if ( 'WordPress' === $record->context && 'updated' === $record->action ) {
 
 
92
  global $wp_version;
93
 
94
  $version = $record->get_meta( 'new_version', true );
@@ -104,9 +101,9 @@ class Connector_Installer extends Connector {
104
  }
105
 
106
  /**
107
- * Wrapper method for calling get_plugins()
108
  *
109
- * @return array
110
  */
111
  public function get_plugins() {
112
  if ( ! function_exists( 'get_plugins' ) ) {
@@ -117,14 +114,14 @@ class Connector_Installer extends Connector {
117
  }
118
 
119
  /**
120
- * Log plugin installations
121
  *
122
- * @action transition_post_status
123
  *
124
- * @param \WP_Upgrader $upgrader
125
- * @param array $extra
126
  *
127
- * @return bool
128
  */
129
  public function callback_upgrader_process_complete( $upgrader, $extra ) {
130
  $logs = array();
@@ -137,7 +134,7 @@ class Connector_Installer extends Connector {
137
  list( $error ) = reset( $errors );
138
  }
139
 
140
- // This would have failed down the road anyway
141
  if ( ! isset( $extra['type'] ) ) {
142
  return false;
143
  }
@@ -176,7 +173,7 @@ class Connector_Installer extends Connector {
176
  }
177
 
178
  $action = 'installed';
179
- // translators: Placeholders refer to a plugin/theme type, a plugin/theme name, and a plugin/theme version (e.g. "plugin", "Stream", "4.2")
180
  $message = _x(
181
  'Installed %1$s: %2$s %3$s',
182
  'Plugin/theme installation. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
@@ -186,7 +183,7 @@ class Connector_Installer extends Connector {
186
  $logs[] = compact( 'slug', 'name', 'version', 'message', 'action' );
187
  } elseif ( 'update' === $action ) {
188
  $action = 'updated';
189
- // translators: Placeholders refer to a plugin/theme type, a plugin/theme name, and a plugin/theme version (e.g. "plugin", "Stream", "4.2")
190
  $message = _x(
191
  'Updated %1$s: %2$s %3$s',
192
  'Plugin/theme update. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
@@ -208,7 +205,7 @@ class Connector_Installer extends Connector {
208
  $version = $plugin_data['Version'];
209
  //$old_version = $_plugins[ $slug ]['Version'];
210
 
211
- //( Net-Concept - Xavier NUEL ) : get old versions
212
  if (isset($this->old_plugins[$slug])) {
213
  $old_version = $this->old_plugins[$slug]['Version'];
214
  } else {
@@ -272,7 +269,13 @@ class Connector_Installer extends Connector {
272
  return true;
273
  }
274
 
275
- public function callback_activate_plugin( $slug, $network_wide ) {
 
 
 
 
 
 
276
  $_plugins = $this->get_plugins();
277
  $name = $_plugins[ $slug ]['Name'];
278
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
@@ -294,7 +297,12 @@ class Connector_Installer extends Connector {
294
  );
295
  }
296
 
297
- public function callback_deactivate_plugin( $slug, $network_wide ) {
 
 
 
 
 
298
  $_plugins = $this->get_plugins();
299
  $name = $_plugins[ $slug ]['Name'];
300
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
@@ -313,10 +321,16 @@ class Connector_Installer extends Connector {
313
  );
314
  }
315
 
316
- public function callback_switch_theme( $name, $theme ) {
 
 
 
 
 
 
317
  unset( $theme );
318
  $this->log(
319
- // translators: Placeholder refers to a theme name (e.g. "Twenty Seventeen")
320
  __( '"%s" theme activated', 'mainwp-child-reports' ),
321
  compact( 'name' ),
322
  null,
@@ -326,6 +340,8 @@ class Connector_Installer extends Connector {
326
  }
327
 
328
  /**
 
 
329
  * @todo Core needs a delete_theme hook
330
  */
331
  public function callback_delete_site_transient_update_themes() {
@@ -347,7 +363,7 @@ class Connector_Installer extends Connector {
347
  // @todo Can we get the name of the theme? Or has it already been eliminated
348
 
349
  $this->log(
350
- // translators: Placeholder refers to a theme name (e.g. "Twenty Seventeen")
351
  __( '"%s" theme deleted', 'mainwp-child-reports' ),
352
  compact( 'name' ),
353
  null,
@@ -357,6 +373,8 @@ class Connector_Installer extends Connector {
357
  }
358
 
359
  /**
 
 
360
  * @todo Core needs an uninstall_plugin hook
361
  * @todo This does not work in WP-CLI
362
  */
@@ -388,9 +406,12 @@ class Connector_Installer extends Connector {
388
  }
389
 
390
  /**
 
 
391
  * @param mixed $value
392
  *
393
  * @return mixed
 
394
  * @todo Core needs a delete_plugin hook
395
  * @todo This does not work in WP-CLI
396
  */
@@ -405,7 +426,7 @@ class Connector_Installer extends Connector {
405
  $network_wide = $data['Network'] ? esc_html__( 'network wide', 'mainwp-child-reports' ) : '';
406
 
407
  $this->log(
408
- // translators: Placeholder refers to a plugin name (e.g. "Stream")
409
  __( '"%s" plugin deleted', 'mainwp-child-reports' ),
410
  compact( 'name', 'plugin', 'network_wide' ),
411
  null,
@@ -419,7 +440,17 @@ class Connector_Installer extends Connector {
419
  return $value;
420
  }
421
 
422
- public function callback__core_updated_successfully( $new_version ) {
 
 
 
 
 
 
 
 
 
 
423
  global $pagenow, $wp_version;
424
 
425
  $old_version = $wp_version;
@@ -441,8 +472,14 @@ class Connector_Installer extends Connector {
441
  'updated'
442
  );
443
  }
444
-
445
- public function callback_mainwp_child_installPluginTheme( $args ) {
 
 
 
 
 
 
446
 
447
  $logs = array();
448
  $success = isset($args['success']) ? $args['success'] : 0;
@@ -509,10 +546,15 @@ class Connector_Installer extends Connector {
509
  $action
510
  );
511
  }
512
- }
513
-
514
-
515
- public function callback_mainwp_child_plugin_action( $args ) {
 
 
 
 
 
516
  if (!is_array($args) || !isset($args['action']))
517
  return;
518
  $action = $args['action'];
@@ -528,7 +570,12 @@ class Connector_Installer extends Connector {
528
  );
529
  }
530
  }
531
-
 
 
 
 
 
532
  public function callback_mainwp_child_theme_action($args) {
533
  if (!is_array($args) || !isset($args['action']))
534
  return;
@@ -545,8 +592,12 @@ class Connector_Installer extends Connector {
545
  }
546
  }
547
 
548
- // ( Net-Concept - Xavier NUEL ) : save all plugins versions before upgrade
549
- public function callback_upgrader_pre_install() {
 
 
 
 
550
  $this->old_plugins = $this->get_plugins();
551
  }
552
 
1
  <?php
2
+ /** Installer Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_Installer
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_Installer extends Connector {
11
 
12
+ /** @var string Connector slug. */
 
 
 
 
13
  public $name = 'installer';
14
 
15
+ /** @var array Actions registered for this connector. */
 
 
 
 
16
  public $actions = array(
17
  'upgrader_pre_install', // use to the current version of all plugins, before they are upgraded ( Net-Concept - Xavier NUEL )
18
  'upgrader_process_complete', // plugins::installed | themes::installed
29
  //'mainwp_child_upgradePluginTheme'
30
  );
31
 
32
+ /** @var array Old plugins array. */
33
+ public $old_plugins = array();
34
 
35
+ /** @var bool Register connector in the WP Frontend. */
 
 
 
 
36
  public $register_frontend = false;
37
 
38
  /**
39
+ * Return translated connector label.
40
  *
41
+ * @return string Translated connector label.
42
  */
43
  public function get_label() {
44
  return esc_html__( 'Installer', 'mainwp-child-reports' );
45
  }
46
 
47
  /**
48
+ * Return translated action labels.
49
  *
50
+ * @return array Action label translations.
51
  */
52
  public function get_action_labels() {
53
  return array(
60
  }
61
 
62
  /**
63
+ * Return translated context labels.
64
  *
65
+ * @return array Context label translations.
66
  */
67
  public function get_context_labels() {
68
  return array(
73
  }
74
 
75
  /**
76
+ * Add action links to Stream drop row in admin list screen.
77
  *
78
+ * @filter wp_mainwp_stream_action_links_{connector}.
79
  *
80
+ * @param array $links Previous links registered.
81
+ * @param object $record Stream record.
82
  *
83
+ * @return array Action links.
84
  */
85
  public function action_links( $links, $record ) {
86
  if ( 'WordPress' === $record->context && 'updated' === $record->action ) {
87
+
88
+ /** @global string $wp_version WordPress verison. */
89
  global $wp_version;
90
 
91
  $version = $record->get_meta( 'new_version', true );
101
  }
102
 
103
  /**
104
+ * Wrapper method for calling get_plugins().
105
  *
106
+ * @return array Installed plugins.
107
  */
108
  public function get_plugins() {
109
  if ( ! function_exists( 'get_plugins' ) ) {
114
  }
115
 
116
  /**
117
+ * Log plugin installations.
118
  *
119
+ * @action transition_post_status.
120
  *
121
+ * @param \WP_Upgrader $upgrader WP_Upgrader class object.
122
+ * @param array $extra Extra attributes array.
123
  *
124
+ * @return bool Return TRUE|FALSE.
125
  */
126
  public function callback_upgrader_process_complete( $upgrader, $extra ) {
127
  $logs = array();
134
  list( $error ) = reset( $errors );
135
  }
136
 
137
+ // This would have failed down the road anyway.
138
  if ( ! isset( $extra['type'] ) ) {
139
  return false;
140
  }
173
  }
174
 
175
  $action = 'installed';
176
+ // translators: Placeholders refer to a plugin/theme type, a plugin/theme name, and a plugin/theme version (e.g. "plugin", "Stream", "4.2").
177
  $message = _x(
178
  'Installed %1$s: %2$s %3$s',
179
  'Plugin/theme installation. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
183
  $logs[] = compact( 'slug', 'name', 'version', 'message', 'action' );
184
  } elseif ( 'update' === $action ) {
185
  $action = 'updated';
186
+ // translators: Placeholders refer to a plugin/theme type, a plugin/theme name, and a plugin/theme version (e.g. "plugin", "Stream", "4.2").
187
  $message = _x(
188
  'Updated %1$s: %2$s %3$s',
189
  'Plugin/theme update. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
205
  $version = $plugin_data['Version'];
206
  //$old_version = $_plugins[ $slug ]['Version'];
207
 
208
+ //( Net-Concept - Xavier NUEL ) : get old versions.
209
  if (isset($this->old_plugins[$slug])) {
210
  $old_version = $this->old_plugins[$slug]['Version'];
211
  } else {
269
  return true;
270
  }
271
 
272
+ /**
273
+ * Activate plugin callback.
274
+ *
275
+ * @param string $slug Plugin slug.
276
+ * @param $network_wide Check if network wide.
277
+ */
278
+ public function callback_activate_plugin($slug, $network_wide ) {
279
  $_plugins = $this->get_plugins();
280
  $name = $_plugins[ $slug ]['Name'];
281
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
297
  );
298
  }
299
 
300
+ /** Decativate plugin callback.
301
+ *
302
+ * @param string $slug Plugin slug.
303
+ * @param $network_wide Check if network wide.
304
+ */
305
+ public function callback_deactivate_plugin($slug, $network_wide ) {
306
  $_plugins = $this->get_plugins();
307
  $name = $_plugins[ $slug ]['Name'];
308
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
321
  );
322
  }
323
 
324
+ /**
325
+ * Switch theme callback.
326
+ *
327
+ * @param string $name Theme name.
328
+ * @param string $theme Theme slug.
329
+ */
330
+ public function callback_switch_theme($name, $theme ) {
331
  unset( $theme );
332
  $this->log(
333
+ // translators: Placeholder refers to a theme name (e.g. "Twenty Seventeen").
334
  __( '"%s" theme activated', 'mainwp-child-reports' ),
335
  compact( 'name' ),
336
  null,
340
  }
341
 
342
  /**
343
+ * Update theme & transient delete callback.
344
+ *
345
  * @todo Core needs a delete_theme hook
346
  */
347
  public function callback_delete_site_transient_update_themes() {
363
  // @todo Can we get the name of the theme? Or has it already been eliminated
364
 
365
  $this->log(
366
+ // translators: Placeholder refers to a theme name (e.g. "Twenty Seventeen").
367
  __( '"%s" theme deleted', 'mainwp-child-reports' ),
368
  compact( 'name' ),
369
  null,
373
  }
374
 
375
  /**
376
+ * Uninstall plugins callback.
377
+ *
378
  * @todo Core needs an uninstall_plugin hook
379
  * @todo This does not work in WP-CLI
380
  */
406
  }
407
 
408
  /**
409
+ * Pre set site transient update plugins callback.
410
+ *
411
  * @param mixed $value
412
  *
413
  * @return mixed
414
+ *
415
  * @todo Core needs a delete_plugin hook
416
  * @todo This does not work in WP-CLI
417
  */
426
  $network_wide = $data['Network'] ? esc_html__( 'network wide', 'mainwp-child-reports' ) : '';
427
 
428
  $this->log(
429
+ // translators: Placeholder refers to a plugin name (e.g. "Stream").
430
  __( '"%s" plugin deleted', 'mainwp-child-reports' ),
431
  compact( 'name', 'plugin', 'network_wide' ),
432
  null,
440
  return $value;
441
  }
442
 
443
+ /**
444
+ * Core updated successfully callback.
445
+ *
446
+ * @param $new_version New WordPress verison.
447
+ */
448
+ public function callback__core_updated_successfully($new_version ) {
449
+
450
+ /**
451
+ * @global string $pagenow Current page.
452
+ * @global string $wp_version WordPress version.
453
+ */
454
  global $pagenow, $wp_version;
455
 
456
  $old_version = $wp_version;
472
  'updated'
473
  );
474
  }
475
+
476
+ /**
477
+ * Child Site install Plugin or theme callback.
478
+ *
479
+ * @param array $args Success message.
480
+ * @return bool|void Return FALSE on failure.
481
+ */
482
+ public function callback_mainwp_child_installPluginTheme( $args ) {
483
 
484
  $logs = array();
485
  $success = isset($args['success']) ? $args['success'] : 0;
546
  $action
547
  );
548
  }
549
+ }
550
+
551
+
552
+ /**
553
+ * MainWP Plugin Action callback.
554
+ *
555
+ * @param $args Action arguments.
556
+ */
557
+ public function callback_mainwp_child_plugin_action( $args ) {
558
  if (!is_array($args) || !isset($args['action']))
559
  return;
560
  $action = $args['action'];
570
  );
571
  }
572
  }
573
+
574
+ /**
575
+ * MainWP Child Theme action callback.
576
+ *
577
+ * @param string $args MainWP Child Theme action.
578
+ */
579
  public function callback_mainwp_child_theme_action($args) {
580
  if (!is_array($args) || !isset($args['action']))
581
  return;
592
  }
593
  }
594
 
595
+ // ( Net-Concept - Xavier NUEL ) : save all plugins versions before upgrade.
596
+
597
+ /**
598
+ * Upgrader pre-instaler callback.
599
+ */
600
+ public function callback_upgrader_pre_install() {
601
  $this->old_plugins = $this->get_plugins();
602
  }
603
 
connectors/class-connector-jetpack.php CHANGED
@@ -1,26 +1,20 @@
1
  <?php
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Jetpack extends Connector {
5
- /**
6
- * Connector slug
7
- *
8
- * @var string
9
- */
10
  public $name = 'jetpack';
11
 
12
- /**
13
- * Holds tracked plugin minimum version required
14
- *
15
- * @const string
16
- */
17
  const PLUGIN_MIN_VERSION = '3.0.2';
18
 
19
- /**
20
- * Actions registered for this connector
21
- *
22
- * @var array
23
- */
24
  public $actions = array(
25
  'jetpack_log_entry',
26
  'sharing_get_services_state',
@@ -33,31 +27,19 @@ class Connector_Jetpack extends Connector {
33
  'wp_ajax_jetpack_post_by_email_disable',
34
  );
35
 
36
- /**
37
- * Register connector in the WP Frontend
38
- *
39
- * @var bool
40
- */
41
  public $register_frontend = false;
42
 
43
- /**
44
- * Tracked option keys
45
- *
46
- * @var array
47
- */
48
  public $options = array();
49
 
50
- /**
51
- * Tracking registered Settings, with overridden data
52
- *
53
- * @var array
54
- */
55
  public $options_override = array();
56
 
57
  /**
58
- * Check if plugin dependencies are satisfied and add an admin notice if not
59
  *
60
- * @return bool
61
  */
62
  public function is_dependency_satisfied() {
63
  if ( class_exists( 'Jetpack' ) && defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, self::PLUGIN_MIN_VERSION, '>=' ) ) {
@@ -68,18 +50,18 @@ class Connector_Jetpack extends Connector {
68
  }
69
 
70
  /**
71
- * Return translated connector label
72
  *
73
- * @return string Translated connector label
74
  */
75
  public function get_label() {
76
  return esc_html_x( 'Jetpack', 'jetpack', 'mainwp-child-reports' );
77
  }
78
 
79
  /**
80
- * Return translated action labels
81
- *
82
- * @return array Action label translations
83
  */
84
  public function get_action_labels() {
85
  return array(
@@ -96,9 +78,9 @@ class Connector_Jetpack extends Connector {
96
  }
97
 
98
  /**
99
- * Return translated context labels
100
  *
101
- * @return array Context label translations
102
  */
103
  public function get_context_labels() {
104
  return array(
@@ -129,14 +111,14 @@ class Connector_Jetpack extends Connector {
129
  }
130
 
131
  /**
132
- * Add action links to Stream drop row in admin list screen
133
  *
134
- * @filter wp_mainwp_stream_action_links_{connector}
135
  *
136
- * @param array $links Previous links registered
137
- * @param object $record Stream record
138
  *
139
- * @return array Action links
140
  */
141
  public function action_links( $links, $record ) {
142
  // @todo provide proper action links
@@ -187,7 +169,10 @@ class Connector_Jetpack extends Connector {
187
  return $links;
188
  }
189
 
190
- public function register() {
 
 
 
191
  parent::register();
192
 
193
  add_filter( 'wp_mainwp_stream_log_data', array( $this, 'log_override' ) );
@@ -310,13 +295,14 @@ class Connector_Jetpack extends Connector {
310
  }
311
 
312
  /**
313
- * Track Jetpack log entries
 
314
  * Includes:
315
  * - Activation/Deactivation of modules
316
  * - Registration/Disconnection of blogs
317
  * - Authorization/unlinking of users
318
  *
319
- * @param array $entry
320
  */
321
  public function callback_jetpack_log_entry( array $entry ) {
322
  if ( isset( $entry['code'] ) ) {
@@ -416,9 +402,9 @@ class Connector_Jetpack extends Connector {
416
  }
417
 
418
  /**
419
- * Track visible/enabled sharing services ( buttons )
420
  *
421
- * @param string $state
422
  */
423
  public function callback_sharing_get_services_state( $state ) {
424
  $this->log(
@@ -430,20 +416,38 @@ class Connector_Jetpack extends Connector {
430
  );
431
  }
432
 
433
- public function callback_update_option( $option, $old, $new ) {
 
 
 
 
 
 
 
434
  $this->check( $option, $old, $new );
435
  }
436
 
437
- public function callback_add_option( $option, $val ) {
 
 
 
 
 
 
438
  $this->check( $option, null, $val );
439
  }
440
 
441
- public function callback_delete_option( $option ) {
 
 
 
 
 
442
  $this->check( $option, null, null );
443
  }
444
 
445
  /**
446
- * Track Monitor module notification status
447
  */
448
  public function callback_jetpack_module_configuration_load_monitor() {
449
  $active = wp_mainwp_stream_filter_input( INPUT_POST, 'receive_jetpack_monitor_notification' );
@@ -467,19 +471,33 @@ class Connector_Jetpack extends Connector {
467
  );
468
  }
469
 
470
- public function callback_wp_ajax_jetpack_post_by_email_enable() {
 
 
 
471
  $this->track_post_by_email( true );
472
  }
473
 
474
- public function callback_wp_ajax_jetpack_post_by_email_regenerate() {
 
 
 
475
  $this->track_post_by_email( null );
476
  }
477
 
478
- public function callback_wp_ajax_jetpack_post_by_email_disable() {
 
 
 
479
  $this->track_post_by_email( false );
480
  }
481
 
482
- public function track_post_by_email( $status ) {
 
 
 
 
 
483
  if ( true === $status ) {
484
  $action = esc_html__( 'enabled', 'mainwp-child-reports' );
485
  } elseif ( false === $status ) {
@@ -491,7 +509,7 @@ class Connector_Jetpack extends Connector {
491
  $user = wp_get_current_user();
492
 
493
  $this->log(
494
- // translators: Placeholders refer to a user display name, and a status (e.g. "Jane Doe", "enabled")
495
  __( '%1$s %2$s Post by Email', 'mainwp-child-reports' ),
496
  array(
497
  'user_displayname' => $user->display_name,
@@ -504,7 +522,14 @@ class Connector_Jetpack extends Connector {
504
  );
505
  }
506
 
507
- public function check( $option, $old_value, $new_value ) {
 
 
 
 
 
 
 
508
  if ( ! array_key_exists( $option, $this->options ) ) {
509
  return;
510
  }
@@ -526,7 +551,13 @@ class Connector_Jetpack extends Connector {
526
  }
527
  }
528
 
529
- public function check_jetpack_options( $old_value, $new_value ) {
 
 
 
 
 
 
530
  $options = array();
531
 
532
  if ( ! is_array( $old_value ) || ! is_array( $new_value ) ) {
@@ -544,7 +575,7 @@ class Connector_Jetpack extends Connector {
544
  continue;
545
  }
546
 
547
- if ( 0 === $option_value ) { // Skip updated array with updated members, we'll be logging those instead
548
  continue;
549
  }
550
 
@@ -564,7 +595,15 @@ class Connector_Jetpack extends Connector {
564
  }
565
  }
566
 
567
- public function check_hide_gplus( $old_value, $new_value ) {
 
 
 
 
 
 
 
 
568
  $status = ! is_null( $new_value );
569
 
570
  if ( $status && $old_value ) {
@@ -572,7 +611,7 @@ class Connector_Jetpack extends Connector {
572
  }
573
 
574
  $this->log(
575
- // translators: Placeholder refers to a status (e.g. "enabled")
576
  __( 'G+ profile display %s', 'mainwp-child-reports' ),
577
  array(
578
  'action' => $status ? esc_html__( 'enabled', 'mainwp-child-reports' ) : esc_html__( 'disabled', 'mainwp-child-reports' ),
@@ -583,7 +622,13 @@ class Connector_Jetpack extends Connector {
583
  );
584
  }
585
 
586
- public function check_gplus_authors( $old_value, $new_value ) {
 
 
 
 
 
 
587
  unset( $old_value );
588
 
589
  $user = wp_get_current_user();
@@ -603,7 +648,13 @@ class Connector_Jetpack extends Connector {
603
  );
604
  }
605
 
606
- public function check_sharedaddy_disable_resources( $old_value, $new_value ) {
 
 
 
 
 
 
607
  if ( $old_value === $new_value ) {
608
  return;
609
  }
@@ -621,18 +672,18 @@ class Connector_Jetpack extends Connector {
621
  }
622
 
623
  /**
624
- * Override connector log for our own Settings / Actions
625
  *
626
- * @param array $data
627
  *
628
- * @return array|bool
629
  */
630
  public function log_override( $data ) {
631
  if ( ! is_array( $data ) ) {
632
  return $data;
633
  }
634
 
635
- // Handling our Settings
636
  if ( 'settings' === $data['connector'] && isset( $this->options_override[ $data['args']['option'] ] ) ) {
637
  if ( isset( $data['args']['option_key'] ) ) {
638
  $overrides = $this->options_override[ $data['args']['option'] ][ $data['args']['option_key'] ];
@@ -663,15 +714,24 @@ class Connector_Jetpack extends Connector {
663
  return $data;
664
  }
665
 
666
- private function get_settings_def( $key, $value = null ) {
667
- // Sharing
 
 
 
 
 
 
 
668
  if ( 0 === strpos( $key, 'publicize_connections::' ) ) {
 
 
669
  global $publicize_ui;
670
 
671
  $name = str_replace( 'publicize_connections::', '', $key );
672
 
673
  return array(
674
- // translators: Placeholders refer to a service, and a status (e.g. "Facebook", "added")
675
  'message' => esc_html__( '%1$s connection %2$s', 'mainwp-child-reports' ),
676
  'meta' => array(
677
  'connection' => $publicize_ui->publicize->get_service_label( $name ),
@@ -696,7 +756,7 @@ class Connector_Jetpack extends Connector {
696
  }
697
 
698
  return array(
699
- // translators: Placeholder refers to a setting name (e.g. "Language")
700
  'message' => esc_html__( '"%s" setting updated', 'mainwp-child-reports' ),
701
  'meta' => array(
702
  'option_name' => $options[ $name ],
1
  <?php
2
+ /** Jetpack Connector. */
3
  namespace WP_MainWP_Stream;
4
 
5
+ /**
6
+ * Class Connector_Jetpack
7
+ * @package WP_MainWP_Stream
8
+ */
9
  class Connector_Jetpack extends Connector {
10
+
11
+ /** @var string Connector slug. */
 
 
 
12
  public $name = 'jetpack';
13
 
14
+ /** @const string Holds tracked plugin minimum version required. */
 
 
 
 
15
  const PLUGIN_MIN_VERSION = '3.0.2';
16
 
17
+ /** @var array Actions registered for this connector. */
 
 
 
 
18
  public $actions = array(
19
  'jetpack_log_entry',
20
  'sharing_get_services_state',
27
  'wp_ajax_jetpack_post_by_email_disable',
28
  );
29
 
30
+ /** @var bool Register connector in the WP Frontend. */
 
 
 
 
31
  public $register_frontend = false;
32
 
33
+ /** @var array Tracked option keys. */
 
 
 
 
34
  public $options = array();
35
 
36
+ /** @var array Tracking registered Settings, with overridden data */
 
 
 
 
37
  public $options_override = array();
38
 
39
  /**
40
+ * Check if plugin dependencies are satisfied and add an admin notice if not.
41
  *
42
+ * @return bool Return TRUE|FALSE.
43
  */
44
  public function is_dependency_satisfied() {
45
  if ( class_exists( 'Jetpack' ) && defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, self::PLUGIN_MIN_VERSION, '>=' ) ) {
50
  }
51
 
52
  /**
53
+ * Return translated connector label.
54
  *
55
+ * @return string Translated connector label.
56
  */
57
  public function get_label() {
58
  return esc_html_x( 'Jetpack', 'jetpack', 'mainwp-child-reports' );
59
  }
60
 
61
  /**
62
+ * Return translated action labels.
63
+ *.
64
+ * @return array Action label translations.
65
  */
66
  public function get_action_labels() {
67
  return array(
78
  }
79
 
80
  /**
81
+ * Return translated context labels.
82
  *
83
+ * @return array Context label translations.
84
  */
85
  public function get_context_labels() {
86
  return array(
111
  }
112
 
113
  /**
114
+ * Add action links to Stream drop row in admin list screen.
115
  *
116
+ * @filter wp_mainwp_stream_action_links_{connector}.
117
  *
118
+ * @param array $links Previous links registered.
119
+ * @param object $record Stream record.
120
  *
121
+ * @return array Action links.
122
  */
123
  public function action_links( $links, $record ) {
124
  // @todo provide proper action links
169
  return $links;
170
  }
171
 
172
+ /**
173
+ * Register with parent class.
174
+ */
175
+ public function register() {
176
  parent::register();
177
 
178
  add_filter( 'wp_mainwp_stream_log_data', array( $this, 'log_override' ) );
295
  }
296
 
297
  /**
298
+ * Track Jetpack log entries.
299
+ *
300
  * Includes:
301
  * - Activation/Deactivation of modules
302
  * - Registration/Disconnection of blogs
303
  * - Authorization/unlinking of users
304
  *
305
+ * @param array $entry Jetpack log entry.
306
  */
307
  public function callback_jetpack_log_entry( array $entry ) {
308
  if ( isset( $entry['code'] ) ) {
402
  }
403
 
404
  /**
405
+ * Track visible/enabled sharing services ( buttons ).
406
  *
407
+ * @param string $state Services state.
408
  */
409
  public function callback_sharing_get_services_state( $state ) {
410
  $this->log(
416
  );
417
  }
418
 
419
+ /**
420
+ * Check update option callback.
421
+ *
422
+ * @param string $option Update option to update.
423
+ * @param string $old Old option value.
424
+ * @param string $new New option value.
425
+ */
426
+ public function callback_update_option( $option, $old, $new ) {
427
  $this->check( $option, $old, $new );
428
  }
429
 
430
+ /**
431
+ * Add option callback.
432
+ *
433
+ * @param string $option Option to add.
434
+ * @param string $val option value.
435
+ */
436
+ public function callback_add_option( $option, $val ) {
437
  $this->check( $option, null, $val );
438
  }
439
 
440
+ /**
441
+ * Delete option callback.
442
+ *
443
+ * @param string $option Option to delete.
444
+ */
445
+ public function callback_delete_option( $option ) {
446
  $this->check( $option, null, null );
447
  }
448
 
449
  /**
450
+ * Track Monitor module notification status.
451
  */
452
  public function callback_jetpack_module_configuration_load_monitor() {
453
  $active = wp_mainwp_stream_filter_input( INPUT_POST, 'receive_jetpack_monitor_notification' );
471
  );
472
  }
473
 
474
+ /**
475
+ * Jetpack post by email enabled calback.
476
+ */
477
+ public function callback_wp_ajax_jetpack_post_by_email_enable() {
478
  $this->track_post_by_email( true );
479
  }
480
 
481
+ /**
482
+ * Jetpack post by email regeneration callback.
483
+ */
484
+ public function callback_wp_ajax_jetpack_post_by_email_regenerate() {
485
  $this->track_post_by_email( null );
486
  }
487
 
488
+ /**
489
+ * Jetpack post by email disabled callback.
490
+ */
491
+ public function callback_wp_ajax_jetpack_post_by_email_disable() {
492
  $this->track_post_by_email( false );
493
  }
494
 
495
+ /**
496
+ * Track post by email status.
497
+ *
498
+ * @param string $status Email status.
499
+ */
500
+ public function track_post_by_email( $status ) {
501
  if ( true === $status ) {
502
  $action = esc_html__( 'enabled', 'mainwp-child-reports' );
503
  } elseif ( false === $status ) {
509
  $user = wp_get_current_user();
510
 
511
  $this->log(
512
+ // translators: Placeholders refer to a user display name, and a status (e.g. "Jane Doe", "enabled").
513
  __( '%1$s %2$s Post by Email', 'mainwp-child-reports' ),
514
  array(
515
  'user_displayname' => $user->display_name,
522
  );
523
  }
524
 
525
+ /**
526
+ * Check if option already exists.
527
+ *
528
+ * @param string $option Option to check.
529
+ * @param string $old_value Old option value.
530
+ * @param string $new_value New option value.
531
+ */
532
+ public function check( $option, $old_value, $new_value ) {
533
  if ( ! array_key_exists( $option, $this->options ) ) {
534
  return;
535
  }
551
  }
552
  }
553
 
554
+ /**
555
+ * Check Jetpack options.
556
+ *
557
+ * @param string $old_value Old option value.
558
+ * @param string $new_value New option value.
559
+ */
560
+ public function check_jetpack_options($old_value, $new_value ) {
561
  $options = array();
562
 
563
  if ( ! is_array( $old_value ) || ! is_array( $new_value ) ) {
575
  continue;
576
  }
577
 
578
+ if ( 0 === $option_value ) { // Skip updated array with updated members, we'll be logging those instead.
579
  continue;
580
  }
581
 
595
  }
596
  }
597
 
598
+ /**
599
+ * Check hide Google Plus profile.
600
+ *
601
+ * @param string $old_value Old option value.
602
+ * @param string $new_value New option value.
603
+ *
604
+ * @return bool Return FALSE on failure.
605
+ */
606
+ public function check_hide_gplus( $old_value, $new_value ) {
607
  $status = ! is_null( $new_value );
608
 
609
  if ( $status && $old_value ) {
611
  }
612
 
613
  $this->log(
614
+ // translators: Placeholder refers to a status (e.g. "enabled").
615
  __( 'G+ profile display %s', 'mainwp-child-reports' ),
616
  array(
617
  'action' => $status ? esc_html__( 'enabled', 'mainwp-child-reports' ) : esc_html__( 'disabled', 'mainwp-child-reports' ),
622
  );
623
  }
624
 
625
+ /**
626
+ * Check Google Plus Authors.
627
+ *
628
+ * @param string $old_value Old option value.
629
+ * @param string $new_value New option value.
630
+ */
631
+ public function check_gplus_authors($old_value, $new_value ) {
632
  unset( $old_value );
633
 
634
  $user = wp_get_current_user();
648
  );
649
  }
650
 
651
+ /**
652
+ * Check ShareDaddy disable resources.
653
+ *
654
+ * @param string $old_value Old option value.
655
+ * @param string $new_value New option value.
656
+ */
657
+ public function check_sharedaddy_disable_resources($old_value, $new_value ) {
658
  if ( $old_value === $new_value ) {
659
  return;
660
  }
672
  }
673
 
674
  /**
675
+ * Override connector log for our own Settings / Actions.
676
  *
677
+ * @param array $data Log data.
678
  *
679
+ * @return array|bool Updated Log data on success, of FALSE on failure.
680
  */
681
  public function log_override( $data ) {
682
  if ( ! is_array( $data ) ) {
683
  return $data;
684
  }
685
 
686
+ // Handling our Settings.
687
  if ( 'settings' === $data['connector'] && isset( $this->options_override[ $data['args']['option'] ] ) ) {
688
  if ( isset( $data['args']['option_key'] ) ) {
689
  $overrides = $this->options_override[ $data['args']['option'] ][ $data['args']['option_key'] ];
714
  return $data;
715
  }
716
 
717
+ /**
718
+ * Get settings deffin
719
+ * @param string $key Options Key.
720
+ * @param string $value Options value.
721
+ *
722
+ * @return array|bool Return success array, or FALSE on failure.
723
+ */
724
+ private function get_settings_def($key, $value = null ) {
725
+ // Sharing.
726
  if ( 0 === strpos( $key, 'publicize_connections::' ) ) {
727
+
728
+ /** @global object $publicize_ui JetPack Publicize ui. */
729
  global $publicize_ui;
730
 
731
  $name = str_replace( 'publicize_connections::', '', $key );
732
 
733
  return array(
734
+ // translators: Placeholders refer to a service, and a status (e.g. "Facebook", "added").
735
  'message' => esc_html__( '%1$s connection %2$s', 'mainwp-child-reports' ),
736
  'meta' => array(
737
  'connection' => $publicize_ui->publicize->get_service_label( $name ),
756
  }
757
 
758
  return array(
759
+ // translators: Placeholder refers to a setting name (e.g. "Language").
760
  'message' => esc_html__( '"%s" setting updated', 'mainwp-child-reports' ),
761
  'meta' => array(
762
  'option_name' => $options[ $name ],
connectors/class-connector-mainwp-backups.php CHANGED
@@ -1,19 +1,18 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_MainWP_Backups extends Connector {
5
- /**
6
- * Connector slug
7
- *
8
- * @var string
9
- */
10
  public $name = 'mainwp_backups';
11
 
12
- /**
13
- * Actions registered for this connector
14
- *
15
- * @var array
16
- */
17
  public $actions = array(
18
  'mainwp_backup',
19
  'mainwp_reports_backupbuddy_backup',
@@ -25,18 +24,18 @@ class Connector_MainWP_Backups extends Connector {
25
  );
26
 
27
  /**
28
- * Return translated connector label
29
  *
30
- * @return string Translated connector label
31
  */
32
  public function get_label() {
33
  return __( 'MainWP Backups', 'default' );
34
  }
35
 
36
  /**
37
- * Return translated action labels
38
  *
39
- * @return array Action label translations
40
  */
41
  public function get_action_labels() {
42
  return array(
@@ -51,36 +50,48 @@ class Connector_MainWP_Backups extends Connector {
51
  }
52
 
53
  /**
54
- * Return translated context labels
55
  *
56
- * @return array Context label translations
57
  */
58
  public function get_context_labels() {
59
  return array(
60
  'backups' => __( 'Backups', 'mainwp-child-reports' ),
61
  );
62
  }
63
-
64
- public function register() {
 
 
 
65
  parent::register();
66
  }
67
 
68
 
69
  /**
70
- * Add action links to Stream drop row in admin list screen
71
  *
72
  * @filter wp_stream_action_links_{connector}
73
  *
74
- * @param array $links Previous links registered
75
- * @param int $record Stream record
76
  *
77
- * @return array Action links
78
  */
79
  public function action_links( $links, $record ) {
80
  return $links;
81
  }
82
 
83
- public function callback_mainwp_backup( $destination, $message, $size, $status, $type ) {
 
 
 
 
 
 
 
 
 
84
  $this->log(
85
  $message,
86
  compact( 'destination', 'status', 'type', 'size' ),
@@ -89,8 +100,15 @@ class Connector_MainWP_Backups extends Connector {
89
  'mainwp_backup'
90
  );
91
  }
92
-
93
- public function callback_mainwp_reports_backupbuddy_backup( $message, $type , $backup_time = 0) {
 
 
 
 
 
 
 
94
  $this->log(
95
  $message,
96
  compact('type', 'backup_time'),
@@ -98,9 +116,18 @@ class Connector_MainWP_Backups extends Connector {
98
  'backups',
99
  'backupbuddy_backup'
100
  );
101
- }
102
-
103
- public function callback_mainwp_reports_backupwordpress_backup($destination, $message, $status, $type, $backup_time = 0) {
 
 
 
 
 
 
 
 
 
104
  $this->log(
105
  $message,
106
  compact('destination', 'status', 'type', 'backup_time'),
@@ -108,10 +135,17 @@ class Connector_MainWP_Backups extends Connector {
108
  'backups',
109
  'backupwordpress_backup'
110
  );
111
- }
112
-
113
-
114
- public function callback_mainwp_reports_backwpup_backup( $message, $type, $backup_time ) {
 
 
 
 
 
 
 
115
  $this->log(
116
  $message,
117
  compact( 'type', 'backup_time' ),
@@ -120,8 +154,17 @@ class Connector_MainWP_Backups extends Connector {
120
  'backwpup_backup'
121
  );
122
  }
123
-
124
- public function callback_updraftplus_backup($destination, $message, $status, $type, $backup_time) {
 
 
 
 
 
 
 
 
 
125
  $this->log(
126
  $message,
127
  compact('destination', 'status', 'type', 'backup_time'),
@@ -130,8 +173,15 @@ class Connector_MainWP_Backups extends Connector {
130
  'updraftplus_backup'
131
  );
132
  }
133
-
134
- public function callback_mainwp_reports_wptimecapsule_backup( $message, $type, $backup_time ) {
 
 
 
 
 
 
 
135
  $this->log(
136
  $message,
137
  compact( 'type', 'backup_time' ),
@@ -141,6 +191,15 @@ class Connector_MainWP_Backups extends Connector {
141
  );
142
  }
143
 
 
 
 
 
 
 
 
 
 
144
  public function callback_wpvivid_backup($destination, $message, $status, $type, $backup_time){
145
  $this->log(
146
  $message,
1
  <?php
2
+ /** MainWP Backups Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_MainWP_Backups
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_MainWP_Backups extends Connector {
11
+
12
+ /** @var string Connector slug. */
 
 
 
13
  public $name = 'mainwp_backups';
14
 
15
+ /** @var array Actions registered for this connector. */
 
 
 
 
16
  public $actions = array(
17
  'mainwp_backup',
18
  'mainwp_reports_backupbuddy_backup',
24
  );
25
 
26
  /**
27
+ * Return translated connector label.
28
  *
29
+ * @return string Translated connector label.
30
  */
31
  public function get_label() {
32
  return __( 'MainWP Backups', 'default' );
33
  }
34
 
35
  /**
36
+ * Return translated action labels.
37
  *
38
+ * @return array Action label translations.
39
  */
40
  public function get_action_labels() {
41
  return array(
50
  }
51
 
52
  /**
53
+ * Return translated context labels.
54
  *
55
+ * @return array Context label translations.
56
  */
57
  public function get_context_labels() {
58
  return array(
59
  'backups' => __( 'Backups', 'mainwp-child-reports' ),
60
  );
61
  }
62
+
63
+ /**
64
+ * Register with parent class.
65
+ */
66
+ public function register() {
67
  parent::register();
68
  }
69
 
70
 
71
  /**
72
+ * Add action links to Stream drop row in admin list screen.
73
  *
74
  * @filter wp_stream_action_links_{connector}
75
  *
76
+ * @param array $links Previous links registered.
77
+ * @param int $record Stream record.
78
  *
79
+ * @return array Action links.
80
  */
81
  public function action_links( $links, $record ) {
82
  return $links;
83
  }
84
 
85
+ /**
86
+ * Rord MainWP Backup log.
87
+ *
88
+ * @param string $destination Backup destination.
89
+ * @param string $message Log message.
90
+ * @param string $size Size of backup.
91
+ * @param string $status Backup status.
92
+ * @param sting $type Type of backup.
93
+ */
94
+ public function callback_mainwp_backup($destination, $message, $size, $status, $type ) {
95
  $this->log(
96
  $message,
97
  compact( 'destination', 'status', 'type', 'size' ),
100
  'mainwp_backup'
101
  );
102
  }
103
+
104
+ /**
105
+ * Record MainWP BackupBuddy backup log.
106
+ *
107
+ * @param $message Log message.
108
+ * @param sting $type Type of backup.
109
+ * @param int $backup_time Backup time.
110
+ */
111
+ public function callback_mainwp_reports_backupbuddy_backup($message, $type , $backup_time = 0) {
112
  $this->log(
113
  $message,
114
  compact('type', 'backup_time'),
116
  'backups',
117
  'backupbuddy_backup'
118
  );
119
+ }
120
+
121
+ /**
122
+ * Record MainWP BackupWordpress backup log.
123
+ *
124
+ * @param string $destination Backup destination.
125
+ * @param string $message Log message.
126
+ * @param string $status Backup status.
127
+ * @param sting $type Type of backup.
128
+ * @param int $backup_time Bakcup time.
129
+ */
130
+ public function callback_mainwp_reports_backupwordpress_backup($destination, $message, $status, $type, $backup_time = 0) {
131
  $this->log(
132
  $message,
133
  compact('destination', 'status', 'type', 'backup_time'),
135
  'backups',
136
  'backupwordpress_backup'
137
  );
138
+ }
139
+
140
+
141
+ /**
142
+ * Record MainWP BackupWPup backup log.
143
+ *
144
+ * @param string $message Log message.
145
+ * @param sting $type Type of backup.
146
+ * @param int $backup_time Bakcup time.
147
+ */
148
+ public function callback_mainwp_reports_backwpup_backup($message, $type, $backup_time ) {
149
  $this->log(
150
  $message,
151
  compact( 'type', 'backup_time' ),
154
  'backwpup_backup'
155
  );
156
  }
157
+
158
+ /**
159
+ * Record MainWP UpdraftPlus backups log.
160
+ *
161
+ * @param string $destination Backup destination.
162
+ * @param strign $message Log message.
163
+ * @param string $status Backup status.
164
+ * @param string $type Backup type.
165
+ * @param int $backup_time Backup time.
166
+ */
167
+ public function callback_updraftplus_backup($destination, $message, $status, $type, $backup_time) {
168
  $this->log(
169
  $message,
170
  compact('destination', 'status', 'type', 'backup_time'),
173
  'updraftplus_backup'
174
  );
175
  }
176
+
177
+ /**
178
+ * Record MainWP WPTimeCapsule backups log.
179
+ *
180
+ * @param strign $message Log message.
181
+ * @param string $type Backup type.
182
+ * @param int $backup_time Backup time.
183
+ */
184
+ public function callback_mainwp_reports_wptimecapsule_backup($message, $type, $backup_time ) {
185
  $this->log(
186
  $message,
187
  compact( 'type', 'backup_time' ),
191
  );
192
  }
193
 
194
+ /**
195
+ * Record MainWP WPvivid backup log.
196
+ *
197
+ * @param string $destination Backup destination.
198
+ * @param strign $message Log message.
199
+ * @param string $status Backup status.
200
+ * @param string $type Backup type.
201
+ * @param int $backup_time Backup time.
202
+ */
203
  public function callback_wpvivid_backup($destination, $message, $status, $type, $backup_time){
204
  $this->log(
205
  $message,
connectors/class-connector-mainwp-maintenance.php CHANGED
@@ -1,48 +1,91 @@
1
  <?php
 
2
 
3
  namespace WP_MainWP_Stream;
4
 
 
 
 
 
 
5
  class Connector_MainWP_Maintenance extends Connector {
6
 
 
7
  public $name = 'mainwp_maintenance';
8
 
 
9
  public $actions = array(
10
- 'mainwp_reports_maintenance',
11
  );
12
 
 
 
 
 
 
13
  public function get_label() {
14
  return __( 'Maintenance', 'default' );
15
  }
16
 
 
 
 
 
 
17
  public function get_action_labels() {
18
- return array(
19
- 'maintenance' => __( 'Maintenance', 'default' ),
20
- );
21
  }
22
 
 
 
 
 
 
23
  public function get_context_labels() {
24
- return array(
25
- 'mainwp_maintenance' => __( 'Maintenance', 'default' ),
26
- );
27
  }
28
 
 
 
 
29
  public function register() {
30
  parent::register();
31
  }
32
-
 
 
 
 
 
 
 
 
33
  public function action_links( $links, $record ) {
34
- if (isset($record->object_id)) {
35
- }
36
- return $links;
37
  }
38
-
39
- public function callback_mainwp_reports_maintenance( $message, $log_time, $details, $result = '') {
 
 
 
 
 
 
 
 
 
40
  $this->log(
41
  $message,
42
- compact('log_time', 'details' , 'result'),
43
  0,
44
  'mainwp_maintenance',
45
- 'maintenance'
46
  );
47
- }
48
  }
1
  <?php
2
+ /** MainWP Maintenaince Connector. */
3
 
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_MainWP_Maintenance
8
+ *
9
+ * @package WP_MainWP_Stream
10
+ */
11
  class Connector_MainWP_Maintenance extends Connector {
12
 
13
+ /** @var string Connector slug. */
14
  public $name = 'mainwp_maintenance';
15
 
16
+ /** @var string[] Actions registered for this connector. */
17
  public $actions = array(
18
+ 'mainwp_reports_maintenance',
19
  );
20
 
21
+ /**
22
+ * Return translated connector label.
23
+ *
24
+ * @return string Translated connector label.
25
+ */
26
  public function get_label() {
27
  return __( 'Maintenance', 'default' );
28
  }
29
 
30
+ /**
31
+ * Return translated action labels.
32
+ *
33
+ * @return array Action label translations.
34
+ */
35
  public function get_action_labels() {
36
+ return array(
37
+ 'maintenance' => __( 'Maintenance', 'default' ),
38
+ );
39
  }
40
 
41
+ /**
42
+ * Return translated context labels
43
+ *
44
+ * @return array Context label translations
45
+ */
46
  public function get_context_labels() {
47
+ return array(
48
+ 'mainwp_maintenance' => __( 'Maintenance', 'default' ),
49
+ );
50
  }
51
 
52
+ /**
53
+ * Register with parent class.
54
+ */
55
  public function register() {
56
  parent::register();
57
  }
58
+
59
+ /**
60
+ * Add action links to Stream drop row in admin list screen.
61
+ *
62
+ * @param array $links Previous links registered.
63
+ * @param object $record Stream record.
64
+ *
65
+ * @return array Action links.
66
+ */
67
  public function action_links( $links, $record ) {
68
+ if ( isset( $record->object_id ) ) {
69
+ }
70
+ return $links;
71
  }
72
+
73
+ /**
74
+ * Record MainWP Maintenance reports.
75
+ *
76
+ * @param string $message Error messages.
77
+ * @param string $log_time Maintenance Log Time.
78
+ * @param array $details Maintenance details array.
79
+ * @param string $result Maintenance results.
80
+ * @param string $revisions Maintenance revisions.
81
+ */
82
+ public function callback_mainwp_reports_maintenance( $message, $log_time, $details, $result = '', $revisions = 0 ) {
83
  $this->log(
84
  $message,
85
+ compact( 'log_time', 'details', 'result', 'revisions' ),
86
  0,
87
  'mainwp_maintenance',
88
+ 'maintenance'
89
  );
90
+ }
91
  }
connectors/class-connector-mainwp-sucuri.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_MainWP_Sucuri extends Connector {
5
 
6
  /**
@@ -50,7 +56,10 @@ class Connector_MainWP_Sucuri extends Connector {
50
  );
51
  }
52
 
53
- public function register() {
 
 
 
54
  parent::register();
55
  }
56
 
@@ -60,15 +69,23 @@ class Connector_MainWP_Sucuri extends Connector {
60
  * @filter wp_stream_action_links_{connector}
61
  *
62
  * @param array $links Previous links registered
63
- * @param int $record Stream record
64
  *
65
- * @return array Action links
66
  */
67
  public function action_links( $links, $record ) {
68
  return $links;
69
  }
70
 
71
- public function callback_mainwp_reports_sucuri_scan( $data, $scan_status, $scan_data, $scan_time = 0) {
 
 
 
 
 
 
 
 
72
 
73
  $message = '';
74
  if ( 'success' === $scan_status ) {
1
  <?php
2
+ /** MainWP Sucuri Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_MainWP_Sucuri
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_MainWP_Sucuri extends Connector {
11
 
12
  /**
56
  );
57
  }
58
 
59
+ /**
60
+ * Register connector with parent class.
61
+ */
62
+ public function register() {
63
  parent::register();
64
  }
65
 
69
  * @filter wp_stream_action_links_{connector}
70
  *
71
  * @param array $links Previous links registered
72
+ * @param int $record Stream record
73
  *
74
+ * @return array Action links
75
  */
76
  public function action_links( $links, $record ) {
77
  return $links;
78
  }
79
 
80
+ /**
81
+ * Callback for MainWP reports Sucuri Scan.
82
+ *
83
+ * @param array $data Scan Results array.
84
+ * @param string $scan_status Status of current scan.
85
+ * @param array $scan_data Scan data.
86
+ * @param int $scan_time The current time of scan.
87
+ */
88
+ public function callback_mainwp_reports_sucuri_scan($data, $scan_status, $scan_data, $scan_time = 0) {
89
 
90
  $message = '';
91
  if ( 'success' === $scan_status ) {
connectors/class-connector-mainwp-wordfence.php CHANGED
@@ -1,41 +1,81 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_MainWP_Wordfence extends Connector {
5
 
6
- public $name = 'mainwp_wordfence';
 
7
 
8
- public $actions = array(
 
9
  'mainwp_reports_wordfence_scan',
10
  );
11
 
12
- public function get_label() {
 
 
 
 
 
13
  return __( 'Wordfence', 'default' );
14
  }
15
 
16
- public function get_action_labels() {
 
 
 
 
 
17
  return array(
18
  'wordfence_scan' => __( 'Wordfence scan', 'default' ),
19
  );
20
  }
21
 
22
- public function get_context_labels() {
 
 
 
 
 
23
  return array(
24
  'wordfence_scan' => __( 'Wordfence scan', 'mainwp-child-reports' ),
25
  );
26
  }
27
 
28
- public function register() {
 
29
  parent::register();
30
  }
31
-
32
- public function action_links( $links, $record ) {
 
 
 
 
 
 
 
 
33
  if (isset($record->object_id)) {
34
  }
35
  return $links;
36
  }
37
-
38
- public function callback_mainwp_reports_wordfence_scan( $message, $scan_time, $details, $result = '') {
 
 
 
 
 
 
 
 
39
  $this->log(
40
  $message,
41
  compact('scan_time', 'result', 'details'),
1
  <?php
2
+ /** MainWP WordFence Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_MainWP_Wordfence.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_MainWP_Wordfence extends Connector {
11
 
12
+ /** @var string Connector slug. */
13
+ public $name = 'mainwp_wordfence';
14
 
15
+ /** @var string[] Actions registered for this connector. */
16
+ public $actions = array(
17
  'mainwp_reports_wordfence_scan',
18
  );
19
 
20
+ /**
21
+ * Get translated connector label.
22
+ *
23
+ * @return mixed Translated connector label.
24
+ */
25
+ public function get_label() {
26
  return __( 'Wordfence', 'default' );
27
  }
28
 
29
+ /**
30
+ * Get translated action labels.
31
+ *
32
+ * @return array Return translated action labels.
33
+ */
34
+ public function get_action_labels() {
35
  return array(
36
  'wordfence_scan' => __( 'Wordfence scan', 'default' ),
37
  );
38
  }
39
 
40
+ /**
41
+ * Get Context label translations.
42
+ *
43
+ * @return array Context label translations.
44
+ */
45
+ public function get_context_labels() {
46
  return array(
47
  'wordfence_scan' => __( 'Wordfence scan', 'mainwp-child-reports' ),
48
  );
49
  }
50
 
51
+ /** Register with parent class. */
52
+ public function register() {
53
  parent::register();
54
  }
55
+
56
+ /**
57
+ * Add action links.
58
+ *
59
+ * @param array $links Previous links registered.
60
+ * @param Record $record Stream record.
61
+ *
62
+ * @return array Action links.
63
+ */
64
+ public function action_links($links, $record ) {
65
  if (isset($record->object_id)) {
66
  }
67
  return $links;
68
  }
69
+
70
+ /**
71
+ * Record Wordfence scan data.
72
+ *
73
+ * @param $message
74
+ * @param string $scan_time Wordfence scan time.
75
+ * @param array $details Scan details array.
76
+ * @param string $result Scan result.
77
+ */
78
+ public function callback_mainwp_reports_wordfence_scan($message, $scan_time, $details, $result = '') {
79
  $this->log(
80
  $message,
81
  compact('scan_time', 'result', 'details'),
connectors/class-connector-media.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Media extends Connector {
5
  /**
6
  * Connector slug
@@ -236,6 +242,15 @@ class Connector_Media extends Connector {
236
  );
237
  }
238
 
 
 
 
 
 
 
 
 
 
239
  public function callback_wp_save_image_file( $dummy, $filename, $image, $mime_type, $post_id ) {
240
  return $this->callback_wp_save_image_editor_file( $dummy, $filename, $image, $mime_type, $post_id );
241
  }
1
  <?php
2
+ /** MainWP Child Reports media connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_Media.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_Media extends Connector {
11
  /**
12
  * Connector slug
242
  );
243
  }
244
 
245
+ /**
246
+ * WP save image file callback.
247
+ *
248
+ * @param $dummy
249
+ * @param $filename
250
+ * @param $image
251
+ * @param $mime_type
252
+ * @param $post_id
253
+ */
254
  public function callback_wp_save_image_file( $dummy, $filename, $image, $mime_type, $post_id ) {
255
  return $this->callback_wp_save_image_editor_file( $dummy, $filename, $image, $mime_type, $post_id );
256
  }
connectors/class-connector-menus.php CHANGED
@@ -1,16 +1,22 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Menus extends Connector {
5
  /**
6
- * Connector slug
7
  *
8
  * @var string
9
  */
10
  public $name = 'menus';
11
 
12
  /**
13
- * Actions registered for this connector
14
  *
15
  * @var array
16
  */
@@ -21,7 +27,7 @@ class Connector_Menus extends Connector {
21
  );
22
 
23
  /**
24
- * Register connector in the WP Frontend
25
  *
26
  * @var bool
27
  */
@@ -37,7 +43,7 @@ class Connector_Menus extends Connector {
37
  }
38
 
39
  /**
40
- * Return translated action labels
41
  *
42
  * @return array Action label translations
43
  */
@@ -52,7 +58,7 @@ class Connector_Menus extends Connector {
52
  }
53
 
54
  /**
55
- * Return translated context labels
56
  *
57
  * @return array Context label translations
58
  */
@@ -72,6 +78,9 @@ class Connector_Menus extends Connector {
72
  return $labels;
73
  }
74
 
 
 
 
75
  public function register() {
76
  parent::register();
77
 
@@ -79,7 +88,7 @@ class Connector_Menus extends Connector {
79
  }
80
 
81
  /**
82
- * Add action links to Stream drop row in admin list screen
83
  *
84
  * @filter wp_mainwp_stream_action_links_{connector}
85
  *
@@ -102,7 +111,7 @@ class Connector_Menus extends Connector {
102
  }
103
 
104
  /**
105
- * Tracks creation of menus
106
  *
107
  * @action wp_create_nav_menu
108
  *
@@ -123,7 +132,7 @@ class Connector_Menus extends Connector {
123
  }
124
 
125
  /**
126
- * Tracks menu updates
127
  *
128
  * @action wp_update_nav_menu
129
  *
@@ -148,7 +157,7 @@ class Connector_Menus extends Connector {
148
  }
149
 
150
  /**
151
- * Tracks menu deletion
152
  *
153
  * @action delete_nav_menu
154
  *
@@ -173,7 +182,7 @@ class Connector_Menus extends Connector {
173
  }
174
 
175
  /**
176
- * Track assignment to menu locations
177
  *
178
  * @action update_option_theme_mods_{$stylesheet}
179
  *
1
  <?php
2
+ /** MainWP Child Reports Menus Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_Menus.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_Menus extends Connector {
11
  /**
12
+ * Connector slug.
13
  *
14
  * @var string
15
  */
16
  public $name = 'menus';
17
 
18
  /**
19
+ * Actions registered for this connector.
20
  *
21
  * @var array
22
  */
27
  );
28
 
29
  /**
30
+ * Register connector in the WP Frontend.
31
  *
32
  * @var bool
33
  */
43
  }
44
 
45
  /**
46
+ * Return translated action labels.
47
  *
48
  * @return array Action label translations
49
  */
58
  }
59
 
60
  /**
61
+ * Return translated context labels.
62
  *
63
  * @return array Context label translations
64
  */
78
  return $labels;
79
  }
80
 
81
+ /**
82
+ * Register MainWP Child Reports stylesheet.
83
+ */
84
  public function register() {
85
  parent::register();
86
 
88
  }
89
 
90
  /**
91
+ * Add action links to Stream drop row in admin list screen.
92
  *
93
  * @filter wp_mainwp_stream_action_links_{connector}
94
  *
111
  }
112
 
113
  /**
114
+ * Tracks creation of menus.
115
  *
116
  * @action wp_create_nav_menu
117
  *
132
  }
133
 
134
  /**
135
+ * Tracks menu updates.
136
  *
137
  * @action wp_update_nav_menu
138
  *
157
  }
158
 
159
  /**
160
+ * Tracks menu deletion.
161
  *
162
  * @action delete_nav_menu
163
  *
182
  }
183
 
184
  /**
185
+ * Track assignment to menu locations.
186
  *
187
  * @action update_option_theme_mods_{$stylesheet}
188
  *
connectors/class-connector-posts.php CHANGED
@@ -1,6 +1,11 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
4
  class Connector_Posts extends Connector {
5
  /**
6
  * Connector slug
@@ -56,6 +61,8 @@ class Connector_Posts extends Connector {
56
  * @return array Context label translations
57
  */
58
  public function get_context_labels() {
 
 
59
  global $wp_post_types;
60
 
61
  $post_types = wp_filter_object_list( $wp_post_types, array(), null, 'label' );
@@ -322,7 +329,7 @@ class Connector_Posts extends Connector {
322
  *
323
  * @action deleted_post
324
  *
325
- * $param integer $post_id
326
  */
327
  public function callback_deleted_post( $post_id ) {
328
  $post = get_post( $post_id );
@@ -407,7 +414,9 @@ class Connector_Posts extends Connector {
407
  $operator = ( $previous ) ? '<' : '>';
408
  $order = ( $previous ) ? 'DESC' : 'ASC';
409
 
 
410
  global $wpdb;
 
411
  // @codingStandardsIgnoreStart
412
  $revision_id = $wpdb->get_var( // db call okay
413
  $wpdb->prepare(
1
  <?php
2
+ /** MainWP Child Reports posts connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class . @package WP_MainWP_Stream
8
+ */
9
  class Connector_Posts extends Connector {
10
  /**
11
  * Connector slug
61
  * @return array Context label translations
62
  */
63
  public function get_context_labels() {
64
+
65
+ /** @global object $wp_post_types The global array that stores the post type objects. */
66
  global $wp_post_types;
67
 
68
  $post_types = wp_filter_object_list( $wp_post_types, array(), null, 'label' );
329
  *
330
  * @action deleted_post
331
  *
332
+ * @param integer $post_id Post ID.
333
  */
334
  public function callback_deleted_post( $post_id ) {
335
  $post = get_post( $post_id );
414
  $operator = ( $previous ) ? '<' : '>';
415
  $order = ( $previous ) ? 'DESC' : 'ASC';
416
 
417
+ /** @global object $wpdb WordPress Database instance. */
418
  global $wpdb;
419
+
420
  // @codingStandardsIgnoreStart
421
  $revision_id = $wpdb->get_var( // db call okay
422
  $wpdb->prepare(
connectors/class-connector-settings.php CHANGED
@@ -1,23 +1,32 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
- // not used
 
 
 
 
 
 
4
  class Connector_Settings extends Connector {
 
5
  /**
6
- * Prefix for the highlight URL hash
7
  *
8
  * @const string
9
  */
10
  const HIGHLIGHT_FIELD_URL_HASH_PREFIX = 'wp-mainwp-stream-highlight:';
11
 
12
  /**
13
- * Connector slug
14
  *
15
  * @var string
16
  */
17
  public $name = 'settings';
18
 
19
  /**
20
- * Actions registered for this connector
21
  *
22
  * @var array
23
  */
@@ -31,14 +40,14 @@ class Connector_Settings extends Connector {
31
  );
32
 
33
  /**
34
- * Labels used for WordPress Settings
35
  *
36
  * @var array
37
  */
38
  public $labels = array();
39
 
40
  /**
41
- * Option names used in options-permalink.php
42
  *
43
  * @var array
44
  */
@@ -49,7 +58,7 @@ class Connector_Settings extends Connector {
49
  );
50
 
51
  /**
52
- * Option names used in network/settings.php
53
  *
54
  * @var array
55
  */
@@ -82,14 +91,14 @@ class Connector_Settings extends Connector {
82
  );
83
 
84
  /**
85
- * Register connector in the WP Frontend
86
  *
87
  * @var bool
88
  */
89
  public $register_frontend = false;
90
 
91
  /**
92
- * Register all context hooks
93
  *
94
  * @return void
95
  */
@@ -97,7 +106,7 @@ class Connector_Settings extends Connector {
97
  parent::register();
98
 
99
  $this->labels = array(
100
- // General
101
  'blogname' => esc_html__( 'Site Title', 'mainwp-child-reports' ),
102
  'blogdescription' => esc_html__( 'Tagline', 'mainwp-child-reports' ),
103
  'gmt_offset' => esc_html__( 'Timezone', 'mainwp-child-reports' ),
@@ -111,7 +120,7 @@ class Connector_Settings extends Connector {
111
  'date_format' => esc_html__( 'Date Format', 'mainwp-child-reports' ),
112
  'time_format' => esc_html__( 'Time Format', 'mainwp-child-reports' ),
113
  'start_of_week' => esc_html__( 'Week Starts On', 'mainwp-child-reports' ),
114
- // Writing
115
  'use_smilies' => esc_html__( 'Formatting', 'mainwp-child-reports' ),
116
  'use_balanceTags' => esc_html__( 'Formatting', 'mainwp-child-reports' ),
117
  'default_category' => esc_html__( 'Default Post Category', 'mainwp-child-reports' ),
@@ -122,7 +131,7 @@ class Connector_Settings extends Connector {
122
  'default_email_category' => esc_html__( 'Default Mail Category', 'mainwp-child-reports' ),
123
  'default_link_category' => esc_html__( 'Default Link Category', 'mainwp-child-reports' ),
124
  'ping_sites' => esc_html__( 'Update Services', 'mainwp-child-reports' ),
125
- // Reading
126
  'show_on_front' => esc_html__( 'Front page displays', 'mainwp-child-reports' ),
127
  'page_on_front' => esc_html__( 'Front page displays', 'mainwp-child-reports' ),
128
  'page_for_posts' => esc_html__( 'Front page displays', 'mainwp-child-reports' ),
@@ -130,7 +139,7 @@ class Connector_Settings extends Connector {
130
  'posts_per_rss' => esc_html__( 'Syndication feeds show the most recent', 'mainwp-child-reports' ),
131
  'rss_use_excerpt' => esc_html__( 'For each article in a feed, show', 'mainwp-child-reports' ),
132
  'blog_public' => esc_html__( 'Search Engine Visibility', 'mainwp-child-reports' ),
133
- // Discussion
134
  'default_pingback_flag' => esc_html__( 'Default article settings', 'mainwp-child-reports' ),
135
  'default_ping_status' => esc_html__( 'Default article settings', 'mainwp-child-reports' ),
136
  'default_comment_status' => esc_html__( 'Default article settings', 'mainwp-child-reports' ),
@@ -154,7 +163,7 @@ class Connector_Settings extends Connector {
154
  'show_avatars' => esc_html__( 'Show Avatars', 'mainwp-child-reports' ),
155
  'avatar_rating' => esc_html__( 'Maximum Rating', 'mainwp-child-reports' ),
156
  'avatar_default' => esc_html__( 'Default Avatar', 'mainwp-child-reports' ),
157
- // Media
158
  'thumbnail_size_w' => esc_html__( 'Thumbnail size', 'mainwp-child-reports' ),
159
  'thumbnail_size_h' => esc_html__( 'Thumbnail size', 'mainwp-child-reports' ),
160
  'thumbnail_crop' => esc_html__( 'Thumbnail size', 'mainwp-child-reports' ),
@@ -163,11 +172,11 @@ class Connector_Settings extends Connector {
163
  'large_size_w' => esc_html__( 'Large size', 'mainwp-child-reports' ),
164
  'large_size_h' => esc_html__( 'Large size', 'mainwp-child-reports' ),
165
  'uploads_use_yearmonth_folders' => esc_html__( 'Uploading Files', 'mainwp-child-reports' ),
166
- // Permalinks
167
  'permalink_structure' => esc_html__( 'Permalink Settings', 'mainwp-child-reports' ),
168
  'category_base' => esc_html__( 'Category base', 'mainwp-child-reports' ),
169
  'tag_base' => esc_html__( 'Tag base', 'mainwp-child-reports' ),
170
- // Network
171
  'registrationnotification' => esc_html__( 'Registration notification', 'mainwp-child-reports' ),
172
  'registration' => esc_html__( 'Allow new registrations', 'mainwp-child-reports' ),
173
  'add_new_users' => esc_html__( 'Add New Users', 'mainwp-child-reports' ),
@@ -191,11 +200,11 @@ class Connector_Settings extends Connector {
191
  'WPLANG' => esc_html__( 'Network Language', 'mainwp-child-reports' ),
192
  'blog_count' => esc_html__( 'Blog Count', 'mainwp-child-reports' ),
193
  'user_count' => esc_html__( 'User Count', 'mainwp-child-reports' ),
194
- // Other
195
  'wp_mainwp_stream_db' => esc_html__( 'Reports Database Version', 'mainwp-child-reports' ),
196
  );
197
 
198
- // These option labels are special and need to change based on multisite context
199
  if ( is_network_admin() ) {
200
  $this->labels['admin_email'] = esc_html__( 'Network Admin Email', 'mainwp-child-reports' );
201
  $this->labels['new_admin_email'] = esc_html__( 'Network Admin Email', 'mainwp-child-reports' );
@@ -207,6 +216,8 @@ class Connector_Settings extends Connector {
207
  }
208
 
209
  /**
 
 
210
  * @action update_option_theme_mods_{name}
211
  *
212
  * @param mixed $old_value
@@ -217,7 +228,7 @@ class Connector_Settings extends Connector {
217
  }
218
 
219
  /**
220
- * Return translated context label
221
  *
222
  * @return string Translated context label
223
  */
@@ -226,7 +237,7 @@ class Connector_Settings extends Connector {
226
  }
227
 
228
  /**
229
- * Return translated action labels
230
  *
231
  * @return array Action label translations
232
  */
@@ -237,7 +248,7 @@ class Connector_Settings extends Connector {
237
  }
238
 
239
  /**
240
- * Return translated context labels
241
  *
242
  * @return array Context label translations
243
  */
@@ -270,7 +281,7 @@ class Connector_Settings extends Connector {
270
  }
271
 
272
  /**
273
- * Return context by option name and key
274
  *
275
  * @param string $option_name
276
  * @param string $key
@@ -306,7 +317,7 @@ class Connector_Settings extends Connector {
306
  }
307
 
308
  /**
309
- * Find out if the option key should be ignored and not logged
310
  *
311
  * @param string $option_name
312
  * @param string $key
@@ -329,7 +340,7 @@ class Connector_Settings extends Connector {
329
  }
330
 
331
  /**
332
- * Find out if the option should be ignored and not logged
333
  *
334
  * @param string $option_name
335
  *
@@ -354,7 +365,7 @@ class Connector_Settings extends Connector {
354
  }
355
 
356
  /**
357
- * Find out if array keys in the option should be logged separately
358
  *
359
  * @param mixed $value
360
  *
@@ -388,7 +399,7 @@ class Connector_Settings extends Connector {
388
  }
389
 
390
  /**
391
- * Enqueue jQuery Color plugin
392
  *
393
  * @action admin_enqueue_scripts
394
  * @return void
@@ -432,7 +443,7 @@ class Connector_Settings extends Connector {
432
  );
433
 
434
  /**
435
- * Filter allows for insertion of serialized labels
436
  *
437
  * @param array $lables Serialized labels
438
  * @return array Updated array of serialzed labels
@@ -447,7 +458,7 @@ class Connector_Settings extends Connector {
447
  }
448
 
449
  /**
450
- * Add action links to Stream drop row in admin list screen
451
  *
452
  * @filter wp_mainwp_stream_action_links_{connector}
453
  *
@@ -534,7 +545,9 @@ class Connector_Settings extends Connector {
534
  );
535
 
536
  if ( 'settings' !== $record->context && in_array( $record->context, array_keys( $context_labels ), true ) ) {
537
- global $submenu;
 
 
538
 
539
  $applicable_rules = array_filter(
540
  $rules,
@@ -588,13 +601,13 @@ class Connector_Settings extends Connector {
588
  }
589
 
590
  /**
591
- * Trigger this connector from WP CLI or the Customizer, only for known Settings
592
  *
593
  * @action update_option
594
  *
595
  * @param string $option
 
596
  * @param mixed $old_value
597
- * @param mixed $value
598
  */
599
  public function callback_update_option( $option, $value, $old_value ) {
600
  if ( ( defined( '\WP_CLI' ) && \WP_CLI || did_action( 'customize_save' ) ) && array_key_exists( $option, $this->labels ) ) {
@@ -603,7 +616,7 @@ class Connector_Settings extends Connector {
603
  }
604
 
605
  /**
606
- * Trigger this connector core tracker, only on options.php page
607
  *
608
  * @action whitelist_options
609
  *
@@ -618,7 +631,7 @@ class Connector_Settings extends Connector {
618
  }
619
 
620
  /**
621
- * Trigger this connector core tracker, only on options-permalink.php page
622
  *
623
  * @action update_option_permalink_structure
624
  *
@@ -631,20 +644,20 @@ class Connector_Settings extends Connector {
631
  }
632
 
633
  /**
634
- * Trigger this connector core tracker, only on network/settings.php page
635
  *
636
  * @action update_site_option
637
  *
638
  * @param string $option
 
639
  * @param mixed $old_value
640
- * @param mixed $value
641
  */
642
  public function callback_update_site_option( $option, $value, $old_value ) {
643
  $this->callback_updated_option( $option, $value, $old_value );
644
  }
645
 
646
  /**
647
- * Trigger this connector core tracker, only on options-permalink.php page
648
  *
649
  * @action update_option_category_base
650
  *
@@ -656,7 +669,7 @@ class Connector_Settings extends Connector {
656
  }
657
 
658
  /**
659
- * Trigger this connector core tracker, only on options-permalink.php page
660
  *
661
  * @action update_option_tag_base
662
  *
@@ -668,7 +681,7 @@ class Connector_Settings extends Connector {
668
  }
669
 
670
  /**
671
- * Track updated settings
672
  *
673
  * @action updated_option
674
  *
@@ -677,6 +690,11 @@ class Connector_Settings extends Connector {
677
  * @param mixed $value
678
  */
679
  public function callback_updated_option( $option, $old_value, $value ) {
 
 
 
 
 
680
  global $whitelist_options, $new_whitelist_options;
681
 
682
  if ( $this->is_option_ignored( $option ) ) {
@@ -813,7 +831,7 @@ class Connector_Settings extends Connector {
813
  }
814
 
815
  /**
816
- * Find out if array keys in the option should be logged separately
817
  *
818
  * @deprecated 3.0.6
819
  * @deprecated Use is_option_group()
@@ -831,7 +849,7 @@ class Connector_Settings extends Connector {
831
  }
832
 
833
  /**
834
- * Sanitize values, so that we don't store complex data, such as arrays or objects
835
  *
836
  * @param mixed $value
837
  * @return string
1
  <?php
2
+ /** MainWP Connector Settings. */
3
+
4
  namespace WP_MainWP_Stream;
5
+
6
+ /**
7
+ * Class Connector_Settings.
8
+ * @package WP_MainWP_Stream
9
+ *
10
+ *
11
+ */
12
  class Connector_Settings extends Connector {
13
+
14
  /**
15
+ * Prefix for the highlight URL hash.
16
  *
17
  * @const string
18
  */
19
  const HIGHLIGHT_FIELD_URL_HASH_PREFIX = 'wp-mainwp-stream-highlight:';
20
 
21
  /**
22
+ * Connector slug.
23
  *
24
  * @var string
25
  */
26
  public $name = 'settings';
27
 
28
  /**
29
+ * Actions registered for this connector.
30
  *
31
  * @var array
32
  */
40
  );
41
 
42
  /**
43
+ * Labels used for WordPress Settings.
44
  *
45
  * @var array
46
  */
47
  public $labels = array();
48
 
49
  /**
50
+ * Option names used in options-permalink.php.
51
  *
52
  * @var array
53
  */
58
  );
59
 
60
  /**
61
+ * Option names used in network/settings.php.
62
  *
63
  * @var array
64
  */
91
  );
92
 
93
  /**
94
+ * Register connector in the WP Frontend.
95
  *
96
  * @var bool
97
  */
98
  public $register_frontend = false;
99
 
100
  /**
101
+ * Register all context hooks.
102
  *
103
  * @return void
104
  */
106
  parent::register();
107
 
108
  $this->labels = array(
109
+ // General.
110
  'blogname' => esc_html__( 'Site Title', 'mainwp-child-reports' ),
111
  'blogdescription' => esc_html__( 'Tagline', 'mainwp-child-reports' ),
112
  'gmt_offset' => esc_html__( 'Timezone', 'mainwp-child-reports' ),
120
  'date_format' => esc_html__( 'Date Format', 'mainwp-child-reports' ),
121
  'time_format' => esc_html__( 'Time Format', 'mainwp-child-reports' ),
122
  'start_of_week' => esc_html__( 'Week Starts On', 'mainwp-child-reports' ),
123
+ // Writing.
124
  'use_smilies' => esc_html__( 'Formatting', 'mainwp-child-reports' ),
125
  'use_balanceTags' => esc_html__( 'Formatting', 'mainwp-child-reports' ),
126
  'default_category' => esc_html__( 'Default Post Category', 'mainwp-child-reports' ),
131
  'default_email_category' => esc_html__( 'Default Mail Category', 'mainwp-child-reports' ),
132
  'default_link_category' => esc_html__( 'Default Link Category', 'mainwp-child-reports' ),
133
  'ping_sites' => esc_html__( 'Update Services', 'mainwp-child-reports' ),
134
+ // Reading.
135
  'show_on_front' => esc_html__( 'Front page displays', 'mainwp-child-reports' ),
136
  'page_on_front' => esc_html__( 'Front page displays', 'mainwp-child-reports' ),
137
  'page_for_posts' => esc_html__( 'Front page displays', 'mainwp-child-reports' ),
139
  'posts_per_rss' => esc_html__( 'Syndication feeds show the most recent', 'mainwp-child-reports' ),
140
  'rss_use_excerpt' => esc_html__( 'For each article in a feed, show', 'mainwp-child-reports' ),
141
  'blog_public' => esc_html__( 'Search Engine Visibility', 'mainwp-child-reports' ),
142
+ // Discussion.
143
  'default_pingback_flag' => esc_html__( 'Default article settings', 'mainwp-child-reports' ),
144
  'default_ping_status' => esc_html__( 'Default article settings', 'mainwp-child-reports' ),
145
  'default_comment_status' => esc_html__( 'Default article settings', 'mainwp-child-reports' ),
163
  'show_avatars' => esc_html__( 'Show Avatars', 'mainwp-child-reports' ),
164
  'avatar_rating' => esc_html__( 'Maximum Rating', 'mainwp-child-reports' ),
165
  'avatar_default' => esc_html__( 'Default Avatar', 'mainwp-child-reports' ),
166
+ // Media.
167
  'thumbnail_size_w' => esc_html__( 'Thumbnail size', 'mainwp-child-reports' ),
168
  'thumbnail_size_h' => esc_html__( 'Thumbnail size', 'mainwp-child-reports' ),
169
  'thumbnail_crop' => esc_html__( 'Thumbnail size', 'mainwp-child-reports' ),
172
  'large_size_w' => esc_html__( 'Large size', 'mainwp-child-reports' ),
173
  'large_size_h' => esc_html__( 'Large size', 'mainwp-child-reports' ),
174
  'uploads_use_yearmonth_folders' => esc_html__( 'Uploading Files', 'mainwp-child-reports' ),
175
+ // Permalinks.
176
  'permalink_structure' => esc_html__( 'Permalink Settings', 'mainwp-child-reports' ),
177
  'category_base' => esc_html__( 'Category base', 'mainwp-child-reports' ),
178
  'tag_base' => esc_html__( 'Tag base', 'mainwp-child-reports' ),
179
+ // Network.
180
  'registrationnotification' => esc_html__( 'Registration notification', 'mainwp-child-reports' ),
181
  'registration' => esc_html__( 'Allow new registrations', 'mainwp-child-reports' ),
182
  'add_new_users' => esc_html__( 'Add New Users', 'mainwp-child-reports' ),
200
  'WPLANG' => esc_html__( 'Network Language', 'mainwp-child-reports' ),
201
  'blog_count' => esc_html__( 'Blog Count', 'mainwp-child-reports' ),
202
  'user_count' => esc_html__( 'User Count', 'mainwp-child-reports' ),
203
+ // Other.
204
  'wp_mainwp_stream_db' => esc_html__( 'Reports Database Version', 'mainwp-child-reports' ),
205
  );
206
 
207
+ // These option labels are special and need to change based on multisite context.
208
  if ( is_network_admin() ) {
209
  $this->labels['admin_email'] = esc_html__( 'Network Admin Email', 'mainwp-child-reports' );
210
  $this->labels['new_admin_email'] = esc_html__( 'Network Admin Email', 'mainwp-child-reports' );
216
  }
217
 
218
  /**
219
+ * Update theme modifications option.
220
+ *
221
  * @action update_option_theme_mods_{name}
222
  *
223
  * @param mixed $old_value
228
  }
229
 
230
  /**
231
+ * Return translated context label.
232
  *
233
  * @return string Translated context label
234
  */
237
  }
238
 
239
  /**
240
+ * Return translated action labels.
241
  *
242
  * @return array Action label translations
243
  */
248
  }
249
 
250
  /**
251
+ * Return translated context labels.
252
  *
253
  * @return array Context label translations
254
  */
281
  }
282
 
283
  /**
284
+ * Return context by option name and key.
285
  *
286
  * @param string $option_name
287
  * @param string $key
317
  }
318
 
319
  /**
320
+ * Find out if the option key should be ignored and not logged.
321
  *
322
  * @param string $option_name
323
  * @param string $key
340
  }
341
 
342
  /**
343
+ * Find out if the option should be ignored and not logged.
344
  *
345
  * @param string $option_name
346
  *
365
  }
366
 
367
  /**
368
+ * Find out if array keys in the option should be logged separately.
369
  *
370
  * @param mixed $value
371
  *
399
  }
400
 
401
  /**
402
+ * Enqueue jQuery Color plugin.
403
  *
404
  * @action admin_enqueue_scripts
405
  * @return void
443
  );
444
 
445
  /**
446
+ * Filter allows for insertion of serialized labels.
447
  *
448
  * @param array $lables Serialized labels
449
  * @return array Updated array of serialzed labels
458
  }
459
 
460
  /**
461
+ * Add action links to Stream drop row in admin list screen.
462
  *
463
  * @filter wp_mainwp_stream_action_links_{connector}
464
  *
545
  );
546
 
547
  if ( 'settings' !== $record->context && in_array( $record->context, array_keys( $context_labels ), true ) ) {
548
+
549
+ /** @global object $submenu WordPress submenu array. */
550
+ global $submenu;
551
 
552
  $applicable_rules = array_filter(
553
  $rules,
601
  }
602
 
603
  /**
604
+ * Trigger this connector from WP CLI or the Customizer, only for known Settings.
605
  *
606
  * @action update_option
607
  *
608
  * @param string $option
609
+ * @param mixed $value
610
  * @param mixed $old_value
 
611
  */
612
  public function callback_update_option( $option, $value, $old_value ) {
613
  if ( ( defined( '\WP_CLI' ) && \WP_CLI || did_action( 'customize_save' ) ) && array_key_exists( $option, $this->labels ) ) {
616
  }
617
 
618
  /**
619
+ * Trigger this connector core tracker, only on options.php page.
620
  *
621
  * @action whitelist_options
622
  *
631
  }
632
 
633
  /**
634
+ * Trigger this connector core tracker, only on options-permalink.php page.
635
  *
636
  * @action update_option_permalink_structure
637
  *
644
  }
645
 
646
  /**
647
+ * Trigger this connector core tracker, only on network/settings.php page.
648
  *
649
  * @action update_site_option
650
  *
651
  * @param string $option
652
+ * @param mixed $value
653
  * @param mixed $old_value
 
654
  */
655
  public function callback_update_site_option( $option, $value, $old_value ) {
656
  $this->callback_updated_option( $option, $value, $old_value );
657
  }
658
 
659
  /**
660
+ * Trigger this connector core tracker, only on options-permalink.php page.
661
  *
662
  * @action update_option_category_base
663
  *
669
  }
670
 
671
  /**
672
+ * Trigger this connector core tracker, only on options-permalink.php page.
673
  *
674
  * @action update_option_tag_base
675
  *
681
  }
682
 
683
  /**
684
+ * Track updated settings.
685
  *
686
  * @action updated_option
687
  *
690
  * @param mixed $value
691
  */
692
  public function callback_updated_option( $option, $old_value, $value ) {
693
+
694
+ /**
695
+ * @global object $whitelist_options Whitelist options.
696
+ * @global object $new_whitelist_options New Whitelist options.
697
+ */
698
  global $whitelist_options, $new_whitelist_options;
699
 
700
  if ( $this->is_option_ignored( $option ) ) {
831
  }
832
 
833
  /**
834
+ * Find out if array keys in the option should be logged separately.
835
  *
836
  * @deprecated 3.0.6
837
  * @deprecated Use is_option_group()
849
  }
850
 
851
  /**
852
+ * Sanitize values, so that we don't store complex data, such as arrays or objects.
853
  *
854
  * @param mixed $value
855
  * @return string
connectors/class-connector-taxonomies.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Taxonomies extends Connector {
5
  /**
6
  * Connector slug
@@ -10,7 +16,7 @@ class Connector_Taxonomies extends Connector {
10
  public $name = 'taxonomies';
11
 
12
  /**
13
- * Actions registered for this connector
14
  *
15
  * @var array
16
  */
@@ -22,28 +28,28 @@ class Connector_Taxonomies extends Connector {
22
  );
23
 
24
  /**
25
- * Cache term values before update, used by callback_edit_term/callback_edited_term
26
  *
27
  * @var Object
28
  */
29
  public $cached_term_before_update;
30
 
31
  /**
32
- * Cache taxonomy labels
33
  *
34
  * @var array
35
  */
36
  public $context_labels;
37
 
38
  /**
39
- * Register connector in the WP Frontend
40
  *
41
  * @var bool
42
  */
43
  public $register_frontend = false;
44
 
45
  /**
46
- * Return translated connector label
47
  *
48
  * @return string Translated connector label
49
  */
@@ -52,7 +58,7 @@ class Connector_Taxonomies extends Connector {
52
  }
53
 
54
  /**
55
- * Return translated action labels
56
  *
57
  * @return array Action label translations
58
  */
@@ -65,11 +71,13 @@ class Connector_Taxonomies extends Connector {
65
  }
66
 
67
  /**
68
- * Return translated context labels
69
  *
70
  * @return array Context label translations
71
  */
72
  public function get_context_labels() {
 
 
73
  global $wp_taxonomies;
74
 
75
  $labels = wp_list_pluck( $wp_taxonomies, 'labels' );
@@ -82,7 +90,7 @@ class Connector_Taxonomies extends Connector {
82
  }
83
 
84
  /**
85
- * Add action links to Stream drop row in admin list screen
86
  *
87
  * @filter wp_mainwp_stream_action_links_{connector}
88
  *
@@ -114,7 +122,7 @@ class Connector_Taxonomies extends Connector {
114
  }
115
 
116
  /**
117
- * Catch registration of taxonomies after inital loading, so we can cache its labels
118
  *
119
  * @action registered_taxonomy
120
  *
@@ -134,7 +142,7 @@ class Connector_Taxonomies extends Connector {
134
  }
135
 
136
  /**
137
- * Tracks creation of terms
138
  *
139
  * @action created_term
140
  *
@@ -167,7 +175,7 @@ class Connector_Taxonomies extends Connector {
167
  }
168
 
169
  /**
170
- * Tracks deletion of taxonomy terms
171
  *
172
  * @action delete_term
173
  *
@@ -200,7 +208,7 @@ class Connector_Taxonomies extends Connector {
200
  }
201
 
202
  /**
203
- * Tracks updates of taxonomy terms
204
  *
205
  * @action edit_term
206
  *
@@ -213,6 +221,13 @@ class Connector_Taxonomies extends Connector {
213
  $this->cached_term_before_update = get_term( $term_id, $taxonomy );
214
  }
215
 
 
 
 
 
 
 
 
216
  public function callback_edited_term( $term_id, $tt_id, $taxonomy ) {
217
  if ( in_array( $taxonomy, $this->get_excluded_taxonomies(), true ) ) {
218
  return;
@@ -243,7 +258,7 @@ class Connector_Taxonomies extends Connector {
243
  }
244
 
245
  /**
246
- * Constructs list of excluded taxonomies for the Taxonomies connector
247
  *
248
  * @return array List of excluded taxonomies
249
  */
1
  <?php
2
+ /** MainWP Child Reports taxonomies connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_Taxonomies.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_Taxonomies extends Connector {
11
  /**
12
  * Connector slug
16
  public $name = 'taxonomies';
17
 
18
  /**
19
+ * Actions registered for this connector.
20
  *
21
  * @var array
22
  */
28
  );
29
 
30
  /**
31
+ * Cache term values before update, used by callback_edit_term/callback_edited_term.
32
  *
33
  * @var Object
34
  */
35
  public $cached_term_before_update;
36
 
37
  /**
38
+ * Cache taxonomy labels.
39
  *
40
  * @var array
41
  */
42
  public $context_labels;
43
 
44
  /**
45
+ * Register connector in the WP Frontend.
46
  *
47
  * @var bool
48
  */
49
  public $register_frontend = false;
50
 
51
  /**
52
+ * Return translated connector label.
53
  *
54
  * @return string Translated connector label
55
  */
58
  }
59
 
60
  /**
61
+ * Return translated action labels.
62
  *
63
  * @return array Action label translations
64
  */
71
  }
72
 
73
  /**
74
+ * Return translated context labels.
75
  *
76
  * @return array Context label translations
77
  */
78
  public function get_context_labels() {
79
+
80
+ /** @global object $wp_taxonomies WordPress Taxonomies array. */
81
  global $wp_taxonomies;
82
 
83
  $labels = wp_list_pluck( $wp_taxonomies, 'labels' );
90
  }
91
 
92
  /**
93
+ * Add action links to Stream drop row in admin list screen.
94
  *
95
  * @filter wp_mainwp_stream_action_links_{connector}
96
  *
122
  }
123
 
124
  /**
125
+ * Catch registration of taxonomies after inital loading, so we can cache its labels.
126
  *
127
  * @action registered_taxonomy
128
  *
142
  }
143
 
144
  /**
145
+ * Tracks creation of terms.
146
  *
147
  * @action created_term
148
  *
175
  }
176
 
177
  /**
178
+ * Tracks deletion of taxonomy terms.
179
  *
180
  * @action delete_term
181
  *
208
  }
209
 
210
  /**
211
+ * Tracks updates of taxonomy terms.
212
  *
213
  * @action edit_term
214
  *
221
  $this->cached_term_before_update = get_term( $term_id, $taxonomy );
222
  }
223
 
224
+ /**
225
+ * Traks edited taxonomy terms.
226
+ *
227
+ * @param $term_id
228
+ * @param $tt_id
229
+ * @param $taxonomy
230
+ */
231
  public function callback_edited_term( $term_id, $tt_id, $taxonomy ) {
232
  if ( in_array( $taxonomy, $this->get_excluded_taxonomies(), true ) ) {
233
  return;
258
  }
259
 
260
  /**
261
+ * Constructs list of excluded taxonomies for the Taxonomies connector.
262
  *
263
  * @return array List of excluded taxonomies
264
  */
connectors/class-connector-user-switching.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_User_Switching extends Connector {
5
 
6
  /**
1
  <?php
2
+ /** MainWP Child Reports User Switching Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_User_Switching.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_User_Switching extends Connector {
11
 
12
  /**
connectors/class-connector-users.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Users extends Connector {
5
 
6
  /**
@@ -111,6 +117,7 @@ class Connector_Users extends Connector {
111
  return array();
112
  }
113
 
 
114
  global $wp_roles;
115
 
116
  $roles = $wp_roles->get_names();
@@ -199,10 +206,14 @@ class Connector_Users extends Connector {
199
  return;
200
  }
201
 
 
202
  global $wp_roles;
203
 
204
  $this->log(
205
- // translators: Placeholders refer to a user display name, a user role, and another user role (e.g. "Jane Doe", "editor", "subscriber")
 
 
 
206
  _x(
207
  '%1$s\'s role was changed from %2$s to %3$s',
208
  '1: User display name, 2: Old role, 3: New role',
@@ -276,8 +287,9 @@ class Connector_Users extends Connector {
276
  * @param int $expire
277
  * @param int $expiration
278
  * @param int $user_id
 
 
279
  */
280
- // DISABLED
281
  public function callback_set_logged_in_cookie( $logged_in_cookie, $expire, $expiration, $user_id ) {
282
  unset( $logged_in_cookie );
283
  unset( $expire );
@@ -301,8 +313,9 @@ class Connector_Users extends Connector {
301
  * Log user logout
302
  *
303
  * @action clear_auth_cookie
 
 
304
  */
305
- // DISABLED
306
  public function callback_clear_auth_cookie() {
307
  $user = wp_get_current_user();
308
 
1
  <?php
2
+ /** MainWP Child Reports Users Connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_Users.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_Users extends Connector {
11
 
12
  /**
117
  return array();
118
  }
119
 
120
+ /** @global object $wp_roles Core class used to implement a user roles API. */
121
  global $wp_roles;
122
 
123
  $roles = $wp_roles->get_names();
206
  return;
207
  }
208
 
209
+ /** @global object $wp_roles Core class used to implement a user roles API. */
210
  global $wp_roles;
211
 
212
  $this->log(
213
+ /**
214
+ * translators: Placeholders refer to a user display name,
215
+ * a user role, and another user role (e.g. "Jane Doe", "editor", "subscriber").
216
+ */
217
  _x(
218
  '%1$s\'s role was changed from %2$s to %3$s',
219
  '1: User display name, 2: Old role, 3: New role',
287
  * @param int $expire
288
  * @param int $expiration
289
  * @param int $user_id
290
+ *
291
+ * @derecated DISABLED
292
  */
 
293
  public function callback_set_logged_in_cookie( $logged_in_cookie, $expire, $expiration, $user_id ) {
294
  unset( $logged_in_cookie );
295
  unset( $expire );
313
  * Log user logout
314
  *
315
  * @action clear_auth_cookie
316
+ *
317
+ * @deprecated DISABLED
318
  */
 
319
  public function callback_clear_auth_cookie() {
320
  $user = wp_get_current_user();
321
 
connectors/class-connector-widgets.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Widgets extends Connector {
5
 
6
  /**
@@ -71,6 +77,8 @@ class Connector_Widgets extends Connector {
71
  * @return array Context label translations
72
  */
73
  public function get_context_labels() {
 
 
74
  global $wp_registered_sidebars;
75
 
76
  $labels = array();
@@ -98,6 +106,8 @@ class Connector_Widgets extends Connector {
98
  public function action_links( $links, $record ) {
99
  $sidebar = $record->get_meta( 'sidebar_id', true );
100
  if ( $sidebar ) {
 
 
101
  global $wp_registered_sidebars;
102
 
103
  if ( array_key_exists( $sidebar, $wp_registered_sidebars ) ) {
@@ -151,8 +161,10 @@ class Connector_Widgets extends Connector {
151
  }
152
 
153
  /**
154
- * @param array $old
155
- * @param array $new
 
 
156
  */
157
  protected function handle_sidebars_widgets_changes( $old, $new ) {
158
  unset( $old['array_version'] );
@@ -715,9 +727,11 @@ class Connector_Widgets extends Connector {
715
  }
716
 
717
  /**
718
- * @param string $widget_id
 
 
719
  *
720
- * @return string
721
  */
722
  public function get_widget_title( $widget_id ) {
723
  $instance = $this->get_widget_instance( $widget_id );
@@ -725,9 +739,11 @@ class Connector_Widgets extends Connector {
725
  }
726
 
727
  /**
728
- * @param string $widget_id
 
 
729
  *
730
- * @return string|null
731
  */
732
  public function get_widget_name( $widget_id ) {
733
  $widget_obj = $this->get_widget_object( $widget_id );
@@ -735,9 +751,11 @@ class Connector_Widgets extends Connector {
735
  }
736
 
737
  /**
738
- * @param $widget_id
 
 
739
  *
740
- * @return array|null
741
  */
742
  public function parse_widget_id( $widget_id ) {
743
  if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) {
@@ -751,11 +769,15 @@ class Connector_Widgets extends Connector {
751
  }
752
 
753
  /**
754
- * @param string $widget_id
 
 
755
  *
756
- * @return \WP_Widget|null
757
  */
758
  public function get_widget_object( $widget_id ) {
 
 
759
  global $wp_widget_factory;
760
 
761
  $parsed_widget_id = $this->parse_widget_id( $widget_id );
@@ -779,11 +801,11 @@ class Connector_Widgets extends Connector {
779
  }
780
 
781
  /**
782
- * Returns widget instance settings
783
  *
784
- * @param string $widget_id Widget ID, ex: pages-1
785
  *
786
- * @return array|null Widget instance
787
  */
788
  public function get_widget_instance( $widget_id ) {
789
  $instance = null;
@@ -812,7 +834,7 @@ class Connector_Widgets extends Connector {
812
  /**
813
  * Get global sidebars widgets
814
  *
815
- * @return array
816
  */
817
  public function get_sidebars_widgets() {
818
  /**
1
  <?php
2
+ /** MainWP Child Reports widget connector. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Connector_Widgets.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Connector_Widgets extends Connector {
11
 
12
  /**
77
  * @return array Context label translations
78
  */
79
  public function get_context_labels() {
80
+
81
+ /** @global object $wp_registered_sidebars WordPress registered sidebars array. */
82
  global $wp_registered_sidebars;
83
 
84
  $labels = array();
106
  public function action_links( $links, $record ) {
107
  $sidebar = $record->get_meta( 'sidebar_id', true );
108
  if ( $sidebar ) {
109
+
110
+ /** @global object $wp_registered_sidebars WordPress registered sidebars array. */
111
  global $wp_registered_sidebars;
112
 
113
  if ( array_key_exists( $sidebar, $wp_registered_sidebars ) ) {
161
  }
162
 
163
  /**
164
+ * Sidebar widget changes handler.
165
+ *
166
+ * @param array $old Old version array.
167
+ * @param array $new New version array
168
  */
169
  protected function handle_sidebars_widgets_changes( $old, $new ) {
170
  unset( $old['array_version'] );
727
  }
728
 
729
  /**
730
+ * Get widget title.
731
+ *
732
+ * @param string $widget_id Widget ID.
733
  *
734
+ * @return string Return widgt title.
735
  */
736
  public function get_widget_title( $widget_id ) {
737
  $instance = $this->get_widget_instance( $widget_id );
739
  }
740
 
741
  /**
742
+ * Get widget name.
743
+ *
744
+ * @param string $widget_id Widget ID.
745
  *
746
+ * @return string|null Return widget name or Null on failure.
747
  */
748
  public function get_widget_name( $widget_id ) {
749
  $widget_obj = $this->get_widget_object( $widget_id );
751
  }
752
 
753
  /**
754
+ * Parse widget ID.
755
+ *
756
+ * @param string $widget_id Widget ID.
757
  *
758
+ * @return array|null Return widget identification array.
759
  */
760
  public function parse_widget_id( $widget_id ) {
761
  if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) {
769
  }
770
 
771
  /**
772
+ * Get WP Widget object.
773
+ *
774
+ * @param string $widget_id Widget ID.
775
  *
776
+ * @return \WP_Widget|null Return \WP_Widget or Null on failure.
777
  */
778
  public function get_widget_object( $widget_id ) {
779
+
780
+ /** @global object $wp_widget_factory Singleton that registers and instantiates WP_Widget classes. */
781
  global $wp_widget_factory;
782
 
783
  $parsed_widget_id = $this->parse_widget_id( $widget_id );
801
  }
802
 
803
  /**
804
+ * Returns widget instance settings.
805
  *
806
+ * @param string $widget_id Widget ID, ex: pages-1.
807
  *
808
+ * @return array|null Widget instance.
809
  */
810
  public function get_widget_instance( $widget_id ) {
811
  $instance = null;
834
  /**
835
  * Get global sidebars widgets
836
  *
837
+ * @return array Return sidebar widgets array.
838
  */
839
  public function get_sidebars_widgets() {
840
  /**
connectors/class-connector-woocommerce.php CHANGED
@@ -1,24 +1,20 @@
1
  <?php
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_Woocommerce extends Connector {
5
- /**
6
- * Context name
7
- * @var string
8
- */
9
  public $name = 'woocommerce';
10
 
11
- /**
12
- * Holds tracked plugin minimum version required
13
- *
14
- * @const string
15
- */
16
  const PLUGIN_MIN_VERSION = '2.1.10';
17
 
18
- /**
19
- * Actions registered for this context
20
- * @var array
21
- */
22
  public $actions = array(
23
  'wp_mainwp_stream_record_array',
24
  //'updated_option',
@@ -33,7 +29,8 @@ class Connector_Woocommerce extends Connector {
33
  'woocommerce_tax_rate_deleted',
34
  );
35
 
36
- public $taxonomies = array(
 
37
  'product_type',
38
  'product_cat',
39
  'product_tag',
@@ -41,22 +38,30 @@ class Connector_Woocommerce extends Connector {
41
  'shop_order_status',
42
  );
43
 
44
- public $post_types = array(
 
45
  'product',
46
  'product_variation',
47
  'shop_order',
48
  'shop_coupon',
49
  );
50
 
51
- private $order_update_logged = false;
 
52
 
53
- private $settings_pages = array();
 
54
 
55
- private $settings = array();
 
56
 
57
- private $plugin_version = null;
 
58
 
59
- public function register() {
 
 
 
60
  parent::register();
61
 
62
  add_filter( 'wp_mainwp_stream_posts_exclude_post_types', array( $this, 'exclude_order_post_types' ) );
@@ -66,11 +71,13 @@ class Connector_Woocommerce extends Connector {
66
  }
67
 
68
  /**
69
- * Check if plugin dependencies are satisfied and add an admin notice if not
70
  *
71
- * @return bool
72
  */
73
  public function is_dependency_satisfied() {
 
 
74
  global $woocommerce;
75
 
76
  if ( class_exists( 'WooCommerce' ) && version_compare( $woocommerce->version, self::PLUGIN_MIN_VERSION, '>=' ) ) {
@@ -82,18 +89,18 @@ class Connector_Woocommerce extends Connector {
82
  }
83
 
84
  /**
85
- * Return translated context label
86
  *
87
- * @return string Translated context label
88
  */
89
  public function get_label() {
90
  return esc_html_x( 'WooCommerce', 'woocommerce', 'mainwp-child-reports' );
91
  }
92
 
93
  /**
94
- * Return translated action labels
95
  *
96
- * @return array Action label translations
97
  */
98
  public function get_action_labels() {
99
  return array(
@@ -105,9 +112,9 @@ class Connector_Woocommerce extends Connector {
105
  }
106
 
107
  /**
108
- * Return translated context labels
109
  *
110
- * @return array Context label translations
111
  */
112
  public function get_context_labels() {
113
  $context_labels = array();
@@ -134,9 +141,9 @@ class Connector_Woocommerce extends Connector {
134
  }
135
 
136
  /**
137
- * Return settings used by WooCommerce that aren't registered
138
  *
139
- * @return array Custom settings with translated title and page
140
  */
141
  public function get_custom_settings() {
142
  $custom_settings = array(
@@ -202,14 +209,14 @@ class Connector_Woocommerce extends Connector {
202
  }
203
 
204
  /**
205
- * Add action links to Stream drop row in admin list screen
206
  *
207
- * @filter wp_mainwp_stream_action_links_{connector}
208
  *
209
- * @param array $links Previous links registered
210
- * @param Record $record Stream record
211
  *
212
- * @return array Action links
213
  */
214
  public function action_links( $links, $record ) {
215
  if ( in_array( $record->context, $this->post_types, true ) && get_post( $record->object_id ) ) {
@@ -253,13 +260,13 @@ class Connector_Woocommerce extends Connector {
253
 
254
  /**
255
  * Prevent the Stream Posts connector from logging orders
256
- * so that we can handle them differently here
257
  *
258
- * @filter wp_mainwp_stream_posts_exclude_post_types
259
  *
260
- * @param array $post_types Ignored post types
261
  *
262
- * @return array Filtered post types
263
  */
264
  public function exclude_order_post_types( $post_types ) {
265
  $post_types[] = 'shop_order';
@@ -269,13 +276,13 @@ class Connector_Woocommerce extends Connector {
269
 
270
  /**
271
  * Prevent the Stream Comments connector from logging status
272
- * change comments on orders
273
  *
274
- * @filter wp_mainwp_stream_commnent_exclude_comment_types
275
  *
276
- * @param array $comment_types Ignored post types
277
  *
278
- * @return array Filtered post types
279
  */
280
  public function exclude_order_comment_types( $comment_types ) {
281
  $comment_types[] = 'order_note';
@@ -284,31 +291,32 @@ class Connector_Woocommerce extends Connector {
284
  }
285
 
286
  /**
287
- * Log Order major status changes ( creating / updating / trashing )
288
  *
289
- * @action transition_post_status
290
  *
291
- * @param string $new
292
- * @param string $old
293
- * @param \WP_Post $post
294
  */
295
  public function callback_transition_post_status( $new, $old, $post ) {
296
- // Only track orders
 
297
  if ( 'shop_order' !== $post->post_type ) {
298
  return;
299
  }
300
 
301
- // Don't track customer actions
302
  if ( ! is_admin() ) {
303
  return;
304
  }
305
 
306
- // Don't track minor status change actions
307
  if ( in_array( wp_mainwp_stream_filter_input( INPUT_GET, 'action' ), array( 'mark_processing', 'mark_on-hold', 'mark_completed' ), true ) || defined( 'DOING_AJAX' ) ) {
308
  return;
309
  }
310
 
311
- // Don't log updates when more than one happens at the same time
312
  if ( $post->ID === $this->order_update_logged ) {
313
  return;
314
  }
@@ -316,7 +324,7 @@ class Connector_Woocommerce extends Connector {
316
  if ( in_array( $new, array( 'auto-draft', 'draft', 'inherit' ), true ) ) {
317
  return;
318
  } elseif ( 'auto-draft' === $old && 'publish' === $new ) {
319
- // translators: Placeholder refers to an order title (e.g. "Order #42")
320
  $message = esc_html_x(
321
  '%s created',
322
  'Order title',
@@ -324,7 +332,7 @@ class Connector_Woocommerce extends Connector {
324
  );
325
  $action = 'created';
326
  } elseif ( 'trash' === $new ) {
327
- // translators: Placeholder refers to an order title (e.g. "Order #42")
328
  $message = esc_html_x(
329
  '%s trashed',
330
  'Order title',
@@ -332,7 +340,7 @@ class Connector_Woocommerce extends Connector {
332
  );
333
  $action = 'trashed';
334
  } elseif ( 'trash' === $old && 'publish' === $new ) {
335
- // translators: Placeholder refers to an order title (e.g. "Order #42")
336
  $message = esc_html_x(
337
  '%s restored from the trash',
338
  'Order title',
@@ -340,7 +348,7 @@ class Connector_Woocommerce extends Connector {
340
  );
341
  $action = 'untrashed';
342
  } else {
343
- // translators: Placeholder refers to an order title (e.g. "Order #42")
344
  $message = esc_html_x(
345
  '%s updated',
346
  'Order title',
@@ -374,21 +382,22 @@ class Connector_Woocommerce extends Connector {
374
  }
375
 
376
  /**
377
- * Log order deletion
378
  *
379
  * @action deleted_post
380
  *
381
- * @param int $post_id
382
  */
383
  public function callback_deleted_post( $post_id ) {
 
384
  $post = get_post( $post_id );
385
 
386
- // We check if post is an instance of WP_Post as it doesn't always resolve in unit testing
387
  if ( ! ( $post instanceof \WP_Post ) || 'shop_order' !== $post->post_type ) {
388
  return;
389
  }
390
 
391
- // Ignore auto-drafts that are deleted by the system, see issue-293
392
  if ( 'auto-draft' === $post->post_status ) {
393
  return;
394
  }
@@ -398,7 +407,7 @@ class Connector_Woocommerce extends Connector {
398
  $order_type_name = esc_html__( 'order', 'mainwp-child-reports' );
399
 
400
  $this->log(
401
- // translators: Placeholder refers to an order title (e.g. "Order #42")
402
  _x(
403
  '"%s" deleted from trash',
404
  'Order title',
@@ -415,21 +424,22 @@ class Connector_Woocommerce extends Connector {
415
  }
416
 
417
  /**
418
- * Log Order minor status changes ( pending / on-hold / failed / processing / completed / refunded / cancelled )
419
  *
420
- * @action woocommerce_order_status_changed
421
  *
422
- * @param int $order_id
423
- * @param string $old
424
- * @param string $new
425
  */
426
  public function callback_woocommerce_order_status_changed( $order_id, $old, $new ) {
427
- // Don't track customer actions
 
428
  if ( ! is_admin() ) {
429
  return;
430
  }
431
 
432
- // Don't track new statuses
433
  if ( empty( $old ) ) {
434
  return;
435
  }
@@ -444,7 +454,10 @@ class Connector_Woocommerce extends Connector {
444
  $old_status_name = $old_status->name;
445
  }
446
 
447
- // translators: Placeholders refer to an order title, and order status, and another order status (e.g. "Order #42", "processing", "complete")
 
 
 
448
  $message = esc_html_x(
449
  '%1$s status changed from %2$s to %3$s',
450
  '1. Order title, 2. Old status, 3. New status',
@@ -473,16 +486,16 @@ class Connector_Woocommerce extends Connector {
473
  }
474
 
475
  /**
476
- * Log adding a product attribute
477
  *
478
  * @action woocommerce_attribute_added
479
  *
480
- * @param int $attribute_id
481
- * @param array $attribute
482
  */
483
  public function callback_woocommerce_attribute_added( $attribute_id, $attribute ) {
484
  $this->log(
485
- // translators: Placeholder refers to a term name (e.g. "color")
486
  _x(
487
  '"%s" product attribute created',
488
  'Term name',
@@ -496,12 +509,12 @@ class Connector_Woocommerce extends Connector {
496
  }
497
 
498
  /**
499
- * Log updating a product attribute
500
  *
501
  * @action woocommerce_attribute_updated
502
  *
503
- * @param int $attribute_id
504
- * @param array $attribute
505
  */
506
  public function callback_woocommerce_attribute_updated( $attribute_id, $attribute ) {
507
  $this->log(
@@ -519,12 +532,12 @@ class Connector_Woocommerce extends Connector {
519
  }
520
 
521
  /**
522
- * Log deleting a product attribute
523
  *
524
  * @action woocommerce_attribute_updated
525
  *
526
- * @param int $attribute_id
527
- * @param string $attribute_name
528
  */
529
  public function callback_woocommerce_attribute_deleted( $attribute_id, $attribute_name ) {
530
  $this->log(
@@ -544,16 +557,16 @@ class Connector_Woocommerce extends Connector {
544
  }
545
 
546
  /**
547
- * Log adding a tax rate
548
  *
549
  * @action woocommerce_tax_rate_added
550
  *
551
- * @param int $tax_rate_id
552
- * @param array $tax_rate
553
  */
554
  public function callback_woocommerce_tax_rate_added( $tax_rate_id, $tax_rate ) {
555
  $this->log(
556
- // translators: Placeholder refers to a tax rate name (e.g. "GST")
557
  _x(
558
  '"%4$s" tax rate created',
559
  'Tax rate name',
@@ -567,16 +580,17 @@ class Connector_Woocommerce extends Connector {
567
  }
568
 
569
  /**
570
- * Log updating a tax rate
571
  *
572
  * @action woocommerce_tax_rate_updated
573
  *
574
- * @param int $tax_rate_id
575
- * @param array $tax_rate
576
  */
577
  public function callback_woocommerce_tax_rate_updated( $tax_rate_id, $tax_rate ) {
 
578
  $this->log(
579
- // translators: Placeholder refers to a tax rate name (e.g. "GST")
580
  _x(
581
  '"%4$s" tax rate updated',
582
  'Tax rate name',
@@ -590,13 +604,15 @@ class Connector_Woocommerce extends Connector {
590
  }
591
 
592
  /**
593
- * Log deleting a tax rate
594
  *
595
  * @action woocommerce_tax_rate_updated
596
  *
597
- * @param int $tax_rate_id
598
  */
599
  public function callback_woocommerce_tax_rate_deleted( $tax_rate_id ) {
 
 
600
  global $wpdb;
601
 
602
  $tax_rate_name = $wpdb->get_var(
@@ -609,7 +625,7 @@ class Connector_Woocommerce extends Connector {
609
  );
610
 
611
  $this->log(
612
- // translators: Placeholder refers to a tax rate name (e.g. "GST")
613
  _x(
614
  '"%s" tax rate deleted',
615
  'Tax rate name',
@@ -625,13 +641,13 @@ class Connector_Woocommerce extends Connector {
625
  }
626
 
627
  /**
628
- * Filter records and take-over our precious data
629
  *
630
  * @filter wp_mainwp_stream_record_array
631
  *
632
- * @param array $recordarr Record data to be inserted
633
  *
634
- * @return array Filtered record data
635
  */
636
  public function callback_wp_mainwp_stream_record_array( $recordarr ) {
637
  foreach ( $recordarr as $key => $record ) {
@@ -639,7 +655,7 @@ class Connector_Woocommerce extends Connector {
639
  continue;
640
  }
641
 
642
- // Change connector::posts records
643
  if ( 'posts' === $record['connector'] && in_array( $record['context'], $this->post_types, true ) ) {
644
  $recordarr[ $key ]['connector'] = $this->name;
645
  } elseif ( 'taxonomies' === $record['connector'] && in_array( $record['context'], $this->taxonomies, true ) ) {
@@ -656,7 +672,14 @@ class Connector_Woocommerce extends Connector {
656
  return $recordarr;
657
  }
658
 
659
- public function callback_updated_option( $option_key, $old_value, $value ) {
 
 
 
 
 
 
 
660
  $options = array( $option_key );
661
 
662
  if ( is_array( $old_value ) || is_array( $value ) ) {
@@ -690,7 +713,12 @@ class Connector_Woocommerce extends Connector {
690
  }
691
  }
692
 
693
- public function get_woocommerce_settings_fields() {
 
 
 
 
 
694
  if ( ! defined( 'WC_VERSION' ) || ! class_exists( 'WC_Admin_Settings' ) ) {
695
  return false;
696
  }
@@ -706,14 +734,19 @@ class Connector_Woocommerce extends Connector {
706
  $settings = $settings_transient['settings'];
707
  $settings_pages = $settings_transient['settings_pages'];
708
  } else {
 
 
709
  global $woocommerce;
710
 
711
  $settings = array();
712
  $settings_pages = array();
713
 
714
  foreach ( \WC_Admin_Settings::get_settings_pages() as $page ) {
715
- // Get ID / Label of the page, since they're protected, by hacking into
716
- // the callback filter for 'woocommerce_settings_tabs_array'
 
 
 
717
  $info = $page->add_settings_page( array() );
718
  $page_id = key( $info );
719
  $page_label = current( $info );
@@ -725,7 +758,7 @@ class Connector_Woocommerce extends Connector {
725
 
726
  $settings_pages[ $page_id ] = $page_label;
727
 
728
- // Remove non-fields ( sections, titles and whatever )
729
  $fields = array();
730
 
731
  foreach ( $sections as $section_key => $section_label ) {
@@ -748,18 +781,18 @@ class Connector_Woocommerce extends Connector {
748
  }
749
  }
750
 
751
- // Store fields in the global array to be searched later
752
  $settings = array_merge( $settings, $fields );
753
  }
754
 
755
- // Provide additional context for each of the settings pages
756
  array_walk(
757
  $settings_pages, function( &$value ) {
758
  $value .= ' ' . esc_html__( 'Settings', 'mainwp-child-reports' );
759
  }
760
  );
761
 
762
- // Load Payment Gateway Settings
763
  $payment_gateway_settings = array();
764
  $payment_gateways = $woocommerce->payment_gateways();
765
 
@@ -778,7 +811,7 @@ class Connector_Woocommerce extends Connector {
778
 
779
  $settings = array_merge( $settings, $payment_gateway_settings );
780
 
781
- // Load Shipping Method Settings
782
  $shipping_method_settings = array();
783
  $shipping_methods = $woocommerce->shipping();
784
 
@@ -797,7 +830,7 @@ class Connector_Woocommerce extends Connector {
797
 
798
  $settings = array_merge( $settings, $shipping_method_settings );
799
 
800
- // Load Email Settings
801
  $email_settings = array();
802
  $emails = $woocommerce->mailer();
803
 
@@ -816,7 +849,7 @@ class Connector_Woocommerce extends Connector {
816
 
817
  $settings = array_merge( $settings, $email_settings );
818
 
819
- // Tools page
820
  $tools_page = array(
821
  'tools' => esc_html__( 'Tools', 'mainwp-child-reports' ),
822
  );
1
  <?php
2
+ /** MainWp WooCommerce Connector. */
3
  namespace WP_MainWP_Stream;
4
 
5
+ /**
6
+ * Class Connector_Woocommerce
7
+ * @package WP_MainWP_Stream
8
+ */
9
  class Connector_Woocommerce extends Connector {
10
+
11
+ /** @var string Connector Slug. */
 
 
12
  public $name = 'woocommerce';
13
 
14
+ /** @const string Holds WooCommerce Plugin minimum required version. */
 
 
 
 
15
  const PLUGIN_MIN_VERSION = '2.1.10';
16
 
17
+ /** @var array Actions registered for this context. */
 
 
 
18
  public $actions = array(
19
  'wp_mainwp_stream_record_array',
20
  //'updated_option',
29
  'woocommerce_tax_rate_deleted',
30
  );
31
 
32
+ /** @var string[] Array of taxonomies. */
33
+ public $taxonomies = array(
34
  'product_type',
35
  'product_cat',
36
  'product_tag',
38
  'shop_order_status',
39
  );
40
 
41
+ /** @var string[] Array of post types. */
42
+ public $post_types = array(
43
  'product',
44
  'product_variation',
45
  'shop_order',
46
  'shop_coupon',
47
  );
48
 
49
+ /** @var bool Return TRUE if order update has logged, or FALSE on failure. */
50
+ private $order_update_logged = false;
51
 
52
+ /** @var array Holds settings pages. */
53
+ private $settings_pages = array();
54
 
55
+ /** @var array Settings array. */
56
+ private $settings = array();
57
 
58
+ /** @var string Current WooCommerce plugin version. */
59
+ private $plugin_version = null;
60
 
61
+ /**
62
+ * Register WooCommerce Connector with parent class.
63
+ */
64
+ public function register() {
65
  parent::register();
66
 
67
  add_filter( 'wp_mainwp_stream_posts_exclude_post_types', array( $this, 'exclude_order_post_types' ) );
71
  }
72
 
73
  /**
74
+ * Check if plugin dependencies are satisfied.
75
  *
76
+ * @return bool Return TRUE if dependencies were satisfied, FALSE if not.
77
  */
78
  public function is_dependency_satisfied() {
79
+
80
+ /** @global object $woocommerce WooCommerce class instance. */
81
  global $woocommerce;
82
 
83
  if ( class_exists( 'WooCommerce' ) && version_compare( $woocommerce->version, self::PLUGIN_MIN_VERSION, '>=' ) ) {
89
  }
90
 
91
  /**
92
+ * Return translated context .
93
  *
94
+ * @return string Translated context label.
95
  */
96
  public function get_label() {
97
  return esc_html_x( 'WooCommerce', 'woocommerce', 'mainwp-child-reports' );
98
  }
99
 
100
  /**
101
+ * Return translated action labels.
102
  *
103
+ * @return array Action label translations.
104
  */
105
  public function get_action_labels() {
106
  return array(
112
  }
113
 
114
  /**
115
+ * Return translated context labels.
116
  *
117
+ * @return array Context label translations.
118
  */
119
  public function get_context_labels() {
120
  $context_labels = array();
141
  }
142
 
143
  /**
144
+ * Return settings used by WooCommerce that aren't registered.
145
  *
146
+ * @return array Custom settings with translated title and page.
147
  */
148
  public function get_custom_settings() {
149
  $custom_settings = array(
209
  }
210
 
211
  /**
212
+ * Add action links to Stream drop row in admin list screen.
213
  *
214
+ * @filter wp_mainwp_stream_action_links_{connector}.
215
  *
216
+ * @param array $links Previous links registered.
217
+ * @param Record $record Stream record.
218
  *
219
+ * @return array Action links.
220
  */
221
  public function action_links( $links, $record ) {
222
  if ( in_array( $record->context, $this->post_types, true ) && get_post( $record->object_id ) ) {
260
 
261
  /**
262
  * Prevent the Stream Posts connector from logging orders
263
+ * so that we can handle them differently here.
264
  *
265
+ * @filter wp_mainwp_stream_posts_exclude_post_types.
266
  *
267
+ * @param array $post_types Ignored post types.
268
  *
269
+ * @return array Filtered post types.
270
  */
271
  public function exclude_order_post_types( $post_types ) {
272
  $post_types[] = 'shop_order';
276
 
277
  /**
278
  * Prevent the Stream Comments connector from logging status
279
+ * change comments on orders.
280
  *
281
+ * @filter wp_mainwp_stream_commnent_exclude_comment_types.
282
  *
283
+ * @param array $comment_types Ignored post types.
284
  *
285
+ * @return array Filtered post types.
286
  */
287
  public function exclude_order_comment_types( $comment_types ) {
288
  $comment_types[] = 'order_note';
291
  }
292
 
293
  /**
294
+ * Log Order major status changes ( creating / updating / trashing ).
295
  *
296
+ * @action transition_post_status.
297
  *
298
+ * @param string $new Post status.
299
+ * @param string $old Post status.
300
+ * @param \WP_Post $post WP_Posts object.
301
  */
302
  public function callback_transition_post_status( $new, $old, $post ) {
303
+
304
+ // Only track orders.
305
  if ( 'shop_order' !== $post->post_type ) {
306
  return;
307
  }
308
 
309
+ // Don't track customer actions.
310
  if ( ! is_admin() ) {
311
  return;
312
  }
313
 
314
+ // Don't track minor status change actions.
315
  if ( in_array( wp_mainwp_stream_filter_input( INPUT_GET, 'action' ), array( 'mark_processing', 'mark_on-hold', 'mark_completed' ), true ) || defined( 'DOING_AJAX' ) ) {
316
  return;
317
  }
318
 
319
+ // Don't log updates when more than one happens at the same time.
320
  if ( $post->ID === $this->order_update_logged ) {
321
  return;
322
  }
324
  if ( in_array( $new, array( 'auto-draft', 'draft', 'inherit' ), true ) ) {
325
  return;
326
  } elseif ( 'auto-draft' === $old && 'publish' === $new ) {
327
+ // translators: Placeholder refers to an order title (e.g. "Order #42").
328
  $message = esc_html_x(
329
  '%s created',
330
  'Order title',
332
  );
333
  $action = 'created';
334
  } elseif ( 'trash' === $new ) {
335
+ // translators: Placeholder refers to an order title (e.g. "Order #42").
336
  $message = esc_html_x(
337
  '%s trashed',
338
  'Order title',
340
  );
341
  $action = 'trashed';
342
  } elseif ( 'trash' === $old && 'publish' === $new ) {
343
+ // translators: Placeholder refers to an order title (e.g. "Order #42").
344
  $message = esc_html_x(
345
  '%s restored from the trash',
346
  'Order title',
348
  );
349
  $action = 'untrashed';
350
  } else {
351
+ // translators: Placeholder refers to an order title (e.g. "Order #42").
352
  $message = esc_html_x(
353
  '%s updated',
354
  'Order title',
382
  }
383
 
384
  /**
385
+ * Log order deletion.
386
  *
387
  * @action deleted_post
388
  *
389
+ * @param int $post_id Post ID.
390
  */
391
  public function callback_deleted_post( $post_id ) {
392
+
393
  $post = get_post( $post_id );
394
 
395
+ // We check if post is an instance of WP_Post as it doesn't always resolve in unit testing.
396
  if ( ! ( $post instanceof \WP_Post ) || 'shop_order' !== $post->post_type ) {
397
  return;
398
  }
399
 
400
+ // Ignore auto-drafts that are deleted by the system, see issue-293.
401
  if ( 'auto-draft' === $post->post_status ) {
402
  return;
403
  }
407
  $order_type_name = esc_html__( 'order', 'mainwp-child-reports' );
408
 
409
  $this->log(
410
+ // translators: Placeholder refers to an order title (e.g. "Order #42").
411
  _x(
412
  '"%s" deleted from trash',
413
  'Order title',
424
  }
425
 
426
  /**
427
+ * Log Order minor status changes ( pending / on-hold / failed / processing / completed / refunded / cancelled ).
428
  *
429
+ * @action woocommerce_order_status_changed.
430
  *
431
+ * @param int $order_id Order ID.
432
+ * @param string $old Post status.
433
+ * @param string $new Post status.
434
  */
435
  public function callback_woocommerce_order_status_changed( $order_id, $old, $new ) {
436
+
437
+ // Don't track customer actions.
438
  if ( ! is_admin() ) {
439
  return;
440
  }
441
 
442
+ // Don't track new statuses.
443
  if ( empty( $old ) ) {
444
  return;
445
  }
454
  $old_status_name = $old_status->name;
455
  }
456
 
457
+ /**
458
+ * translators: Placeholders refer to an order title, and order status,
459
+ * and another order status (e.g. "Order #42", "processing", "complete").
460
+ */
461
  $message = esc_html_x(
462
  '%1$s status changed from %2$s to %3$s',
463
  '1. Order title, 2. Old status, 3. New status',
486
  }
487
 
488
  /**
489
+ * Log adding a product attribute.
490
  *
491
  * @action woocommerce_attribute_added
492
  *
493
+ * @param int $attribute_id Attribute ID.
494
+ * @param array $attribute Attribute array.
495
  */
496
  public function callback_woocommerce_attribute_added( $attribute_id, $attribute ) {
497
  $this->log(
498
+ // translators: Placeholder refers to a term name (e.g. "color").
499
  _x(
500
  '"%s" product attribute created',
501
  'Term name',
509
  }
510
 
511
  /**
512
+ * Log updating a product.
513
  *
514
  * @action woocommerce_attribute_updated
515
  *
516
+ * @param int $attribute_id Attribute ID.
517
+ * @param array $attribute Attribute array.
518
  */
519
  public function callback_woocommerce_attribute_updated( $attribute_id, $attribute ) {
520
  $this->log(
532
  }
533
 
534
  /**
535
+ * Log deleting a product attribute.
536
  *
537
  * @action woocommerce_attribute_updated
538
  *
539
+ * @param int $attribute_id Attribute ID.
540
+ * @param string $attribute_name Attribute name.
541
  */
542
  public function callback_woocommerce_attribute_deleted( $attribute_id, $attribute_name ) {
543
  $this->log(
557
  }
558
 
559
  /**
560
+ * Log adding a tax rate.
561
  *
562
  * @action woocommerce_tax_rate_added
563
  *
564
+ * @param int $tax_rate_id Tax rate ID.
565
+ * @param array $tax_rate Tax rate array.
566
  */
567
  public function callback_woocommerce_tax_rate_added( $tax_rate_id, $tax_rate ) {
568
  $this->log(
569
+ // translators: Placeholder refers to a tax rate name (e.g. "GST").
570
  _x(
571
  '"%4$s" tax rate created',
572
  'Tax rate name',
580
  }
581
 
582
  /**
583
+ * Log updating a tax rate.
584
  *
585
  * @action woocommerce_tax_rate_updated
586
  *
587
+ * @param int $tax_rate_id Tax rate ID.
588
+ * @param array $tax_rate Tax rate array.
589
  */
590
  public function callback_woocommerce_tax_rate_updated( $tax_rate_id, $tax_rate ) {
591
+
592
  $this->log(
593
+ // translators: Placeholder refers to a tax rate name (e.g. "GST").
594
  _x(
595
  '"%4$s" tax rate updated',
596
  'Tax rate name',
604
  }
605
 
606
  /**
607
+ * Log deleting a tax rate.
608
  *
609
  * @action woocommerce_tax_rate_updated
610
  *
611
+ * @param int $tax_rate_id Tax rate ID.
612
  */
613
  public function callback_woocommerce_tax_rate_deleted( $tax_rate_id ) {
614
+
615
+ /** @global object $wpdb WordPress DB object. */
616
  global $wpdb;
617
 
618
  $tax_rate_name = $wpdb->get_var(
625
  );
626
 
627
  $this->log(
628
+ // translators: Placeholder refers to a tax rate name (e.g. "GST").
629
  _x(
630
  '"%s" tax rate deleted',
631
  'Tax rate name',
641
  }
642
 
643
  /**
644
+ * Filter records and take-over our precious data.
645
  *
646
  * @filter wp_mainwp_stream_record_array
647
  *
648
+ * @param array $recordarr Record data to be inserted.
649
  *
650
+ * @return array Filtered record data.
651
  */
652
  public function callback_wp_mainwp_stream_record_array( $recordarr ) {
653
  foreach ( $recordarr as $key => $record ) {
655
  continue;
656
  }
657
 
658
+ // Change connector::posts records.
659
  if ( 'posts' === $record['connector'] && in_array( $record['context'], $this->post_types, true ) ) {
660
  $recordarr[ $key ]['connector'] = $this->name;
661
  } elseif ( 'taxonomies' === $record['connector'] && in_array( $record['context'], $this->taxonomies, true ) ) {
672
  return $recordarr;
673
  }
674
 
675
+ /**
676
+ * Updated option callback.
677
+ *
678
+ * @param string $option_key Option Key.
679
+ * @param string $old_value Old options value.
680
+ * @param string $value New options value.
681
+ */
682
+ public function callback_updated_option($option_key, $old_value, $value ) {
683
  $options = array( $option_key );
684
 
685
  if ( is_array( $old_value ) || is_array( $value ) ) {
713
  }
714
  }
715
 
716
+ /**
717
+ * Get WooCommerce settings fileds.
718
+ *
719
+ * @return array|bool Return WooCommerce settings array, or FALSE on failure.
720
+ */
721
+ public function get_woocommerce_settings_fields() {
722
  if ( ! defined( 'WC_VERSION' ) || ! class_exists( 'WC_Admin_Settings' ) ) {
723
  return false;
724
  }
734
  $settings = $settings_transient['settings'];
735
  $settings_pages = $settings_transient['settings_pages'];
736
  } else {
737
+
738
+ /** @global object $woocommerce WooCommerce class instance. */
739
  global $woocommerce;
740
 
741
  $settings = array();
742
  $settings_pages = array();
743
 
744
  foreach ( \WC_Admin_Settings::get_settings_pages() as $page ) {
745
+
746
+ /**
747
+ * Get ID / Label of the page, since they're protected, by hacking into
748
+ * the callback filter for 'woocommerce_settings_tabs_array'.
749
+ */
750
  $info = $page->add_settings_page( array() );
751
  $page_id = key( $info );
752
  $page_label = current( $info );
758
 
759
  $settings_pages[ $page_id ] = $page_label;
760
 
761
+ // Remove non-fields .
762
  $fields = array();
763
 
764
  foreach ( $sections as $section_key => $section_label ) {
781
  }
782
  }
783
 
784
+ // Store fields in the global array to be searched later.
785
  $settings = array_merge( $settings, $fields );
786
  }
787
 
788
+ // Provide additional context for each of the settings pages.
789
  array_walk(
790
  $settings_pages, function( &$value ) {
791
  $value .= ' ' . esc_html__( 'Settings', 'mainwp-child-reports' );
792
  }
793
  );
794
 
795
+ // Load Payment Gateway Settings.
796
  $payment_gateway_settings = array();
797
  $payment_gateways = $woocommerce->payment_gateways();
798
 
811
 
812
  $settings = array_merge( $settings, $payment_gateway_settings );
813
 
814
+ // Load Shipping Method Settings.
815
  $shipping_method_settings = array();
816
  $shipping_methods = $woocommerce->shipping();
817
 
830
 
831
  $settings = array_merge( $settings, $shipping_method_settings );
832
 
833
+ // Load Email Settings.
834
  $email_settings = array();
835
  $emails = $woocommerce->mailer();
836
 
849
 
850
  $settings = array_merge( $settings, $email_settings );
851
 
852
+ // Tools page.
853
  $tools_page = array(
854
  'tools' => esc_html__( 'Tools', 'mainwp-child-reports' ),
855
  );
connectors/class-connector-wordpress-seo.php CHANGED
@@ -1,27 +1,20 @@
1
  <?php
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Connector_WordPress_SEO extends Connector {
5
 
6
- /**
7
- * Connector slug
8
- *
9
- * @var string
10
- */
11
  public $name = 'wordpressseo';
12
 
13
- /**
14
- * Holds tracked plugin minimum version required
15
- *
16
- * @const string
17
- */
18
  const PLUGIN_MIN_VERSION = '1.5.3.3';
19
 
20
- /**
21
- * Actions registered for this connector
22
- *
23
- * @var array
24
- */
25
  public $actions = array(
26
  'wpseo_handle_import',
27
  'wpseo_import',
@@ -31,15 +24,11 @@ class Connector_WordPress_SEO extends Connector {
31
  'deleted_post_meta',
32
  );
33
 
34
- /**
35
- * Tracking registered Settings, with overridden data
36
- *
37
- * @var array
38
- */
39
  public $option_groups = array();
40
 
41
  /**
42
- * Check if plugin dependencies are satisfied and add an admin notice if not
43
  *
44
  * @return bool
45
  */
@@ -52,18 +41,18 @@ class Connector_WordPress_SEO extends Connector {
52
  }
53
 
54
  /**
55
- * Return translated connector label
56
  *
57
- * @return string Translated connector label
58
  */
59
  public function get_label() {
60
  return esc_html_x( 'WordPress SEO', 'wordpress-seo', 'mainwp-child-reports' );
61
  }
62
 
63
  /**
64
- * Return translated action labels
65
  *
66
- * @return array Action label translations
67
  */
68
  public function get_action_labels() {
69
  return array(
@@ -77,9 +66,9 @@ class Connector_WordPress_SEO extends Connector {
77
  }
78
 
79
  /**
80
- * Return translated context labels
81
  *
82
- * @return array Context label translations
83
  */
84
  public function get_context_labels() {
85
  return array(
@@ -100,14 +89,14 @@ class Connector_WordPress_SEO extends Connector {
100
  }
101
 
102
  /**
103
- * Add action links to Stream drop row in admin list screen
104
  *
105
- * @filter wp_mainwp_stream_action_links_{connector}
106
  *
107
- * @param array $links Previous links registered
108
- * @param Record $record Stream record
109
  *
110
- * @return array Action links
111
  */
112
  public function action_links( $links, $record ) {
113
  // Options
@@ -182,6 +171,9 @@ class Connector_WordPress_SEO extends Connector {
182
  return $links;
183
  }
184
 
 
 
 
185
  public function register() {
186
  if ( is_network_admin() && ! is_plugin_active_for_network( 'wordpress-seo/wordpress-seo-main.php' ) ) {
187
  return;
@@ -200,6 +192,11 @@ class Connector_WordPress_SEO extends Connector {
200
  add_filter( 'wp_mainwp_stream_log_data', array( $this, 'log_override' ) );
201
  }
202
 
 
 
 
 
 
203
  public function admin_enqueue_scripts( $hook ) {
204
  if ( 0 === strpos( $hook, 'seo_page_' ) ) {
205
  $stream = wp_mainwp_stream_get_instance();
@@ -209,7 +206,7 @@ class Connector_WordPress_SEO extends Connector {
209
  }
210
 
211
  /**
212
- * Track importing settings from other plugins
213
  */
214
  public function callback_wpseo_handle_import() {
215
  $imports = array(
@@ -245,7 +242,10 @@ class Connector_WordPress_SEO extends Connector {
245
  }
246
  }
247
 
248
- public function callback_wpseo_import() {
 
 
 
249
  $opts = wp_mainwp_stream_filter_input( INPUT_POST, 'wpseo' );
250
 
251
  if ( wp_mainwp_stream_filter_input( INPUT_POST, 'wpseo_export' ) ) {
@@ -279,7 +279,10 @@ class Connector_WordPress_SEO extends Connector {
279
  }
280
  }
281
 
282
- public function callback_seo_page_wpseo_files() {
 
 
 
283
  if ( wp_mainwp_stream_filter_input( INPUT_POST, 'create_robots' ) ) {
284
  $message = esc_html__( 'Tried creating robots.txt file', 'mainwp-child-reports' );
285
  } elseif ( wp_mainwp_stream_filter_input( INPUT_POST, 'submitrobots' ) ) {
@@ -299,20 +302,53 @@ class Connector_WordPress_SEO extends Connector {
299
  }
300
  }
301
 
302
- public function callback_added_post_meta( $meta_id, $object_id, $meta_key, $meta_value ) {
 
 
 
 
 
 
 
 
303
  unset( $meta_id );
304
  $this->meta( $object_id, $meta_key, $meta_value );
305
  }
306
- public function callback_updated_post_meta( $meta_id, $object_id, $meta_key, $meta_value ) {
 
 
 
 
 
 
 
 
 
307
  unset( $meta_id );
308
  $this->meta( $object_id, $meta_key, $meta_value );
309
  }
310
- public function callback_deleted_post_meta( $meta_id, $object_id, $meta_key, $meta_value ) {
 
 
 
 
 
 
 
 
 
311
  unset( $meta_id );
312
  $this->meta( $object_id, $meta_key, $meta_value );
313
  }
314
 
315
- private function meta( $object_id, $meta_key, $meta_value ) {
 
 
 
 
 
 
 
316
  $prefix = \WPSEO_Meta::$meta_prefix;
317
 
318
  \WPSEO_Metabox::translate_meta_boxes();
@@ -357,9 +393,9 @@ class Connector_WordPress_SEO extends Connector {
357
  }
358
 
359
  /**
360
- * Override connector log for our own Settings / Actions
361
  *
362
- * @param array $data
363
  *
364
  * @return array|bool
365
  */
@@ -368,6 +404,7 @@ class Connector_WordPress_SEO extends Connector {
368
  return $data;
369
  }
370
 
 
371
  global $pagenow;
372
 
373
  if ( 'options.php' === $pagenow && 'settings' === $data['connector'] && wp_mainwp_stream_filter_input( INPUT_POST, '_wp_http_referer' ) ) {
@@ -398,7 +435,13 @@ class Connector_WordPress_SEO extends Connector {
398
  return $data;
399
  }
400
 
401
- private function settings_labels( $option ) {
 
 
 
 
 
 
402
  $labels = array(
403
  // wp-content/plugins/wordpress-seo/admin/pages/dashboard.php:
404
  'yoast_tracking' => esc_html_x( "Allow tracking of this WordPress install's anonymous data.", 'wordpress-seo', 'mainwp-child-reports' ), # type = checkbox
1
  <?php
2
+ /** Yoast SEO Connector. */
3
  namespace WP_MainWP_Stream;
4
 
5
+ /**
6
+ * Class Connector_WordPress_SEO
7
+ * @package WP_MainWP_Stream
8
+ */
9
  class Connector_WordPress_SEO extends Connector {
10
 
11
+ /** @var string Connector slug. */
 
 
 
 
12
  public $name = 'wordpressseo';
13
 
14
+ /** @const string Holds tracked plugin minimum version required. */
 
 
 
 
15
  const PLUGIN_MIN_VERSION = '1.5.3.3';
16
 
17
+ /** @var Actions registered for this connector. */
 
 
 
 
18
  public $actions = array(
19
  'wpseo_handle_import',
20
  'wpseo_import',
24
  'deleted_post_meta',
25
  );
26
 
27
+ /** @var array Tracking registered Settings, with overridden data */
 
 
 
 
28
  public $option_groups = array();
29
 
30
  /**
31
+ * Check if plugin dependencies are satisfied and add an admin notice if not.
32
  *
33
  * @return bool
34
  */
41
  }
42
 
43
  /**
44
+ * Return translated connector label.
45
  *
46
+ * @return string Translated connector label.
47
  */
48
  public function get_label() {
49
  return esc_html_x( 'WordPress SEO', 'wordpress-seo', 'mainwp-child-reports' );
50
  }
51
 
52
  /**
53
+ * Return translated action labels.
54
  *
55
+ * @return array Action label translations.
56
  */
57
  public function get_action_labels() {
58
  return array(
66
  }
67
 
68
  /**
69
+ * Return translated context labels.
70
  *
71
+ * @return array Context label translations.
72
  */
73
  public function get_context_labels() {
74
  return array(
89
  }
90
 
91
  /**
92
+ * Add action links to Stream drop row in admin list screen.
93
  *
94
+ * @filter wp_mainwp_stream_action_links_{connector}.
95
  *
96
+ * @param array $links Previous links registered.
97
+ * @param Record $record Stream record.
98
  *
99
+ * @return array Action links.
100
  */
101
  public function action_links( $links, $record ) {
102
  // Options
171
  return $links;
172
  }
173
 
174
+ /**
175
+ * Register with parent class.
176
+ */
177
  public function register() {
178
  if ( is_network_admin() && ! is_plugin_active_for_network( 'wordpress-seo/wordpress-seo-main.php' ) ) {
179
  return;
192
  add_filter( 'wp_mainwp_stream_log_data', array( $this, 'log_override' ) );
193
  }
194
 
195
+ /**
196
+ * Enqueue admin scripts.
197
+ *
198
+ * @param string $hook Page hook.
199
+ */
200
  public function admin_enqueue_scripts( $hook ) {
201
  if ( 0 === strpos( $hook, 'seo_page_' ) ) {
202
  $stream = wp_mainwp_stream_get_instance();
206
  }
207
 
208
  /**
209
+ * Track importing settings from other plugins.
210
  */
211
  public function callback_wpseo_handle_import() {
212
  $imports = array(
242
  }
243
  }
244
 
245
+ /**
246
+ * Yoast SEO import callback.
247
+ */
248
+ public function callback_wpseo_import() {
249
  $opts = wp_mainwp_stream_filter_input( INPUT_POST, 'wpseo' );
250
 
251
  if ( wp_mainwp_stream_filter_input( INPUT_POST, 'wpseo_export' ) ) {
279
  }
280
  }
281
 
282
+ /**
283
+ * Yoast SEO files page callback.
284
+ */
285
+ public function callback_seo_page_wpseo_files() {
286
  if ( wp_mainwp_stream_filter_input( INPUT_POST, 'create_robots' ) ) {
287
  $message = esc_html__( 'Tried creating robots.txt file', 'mainwp-child-reports' );
288
  } elseif ( wp_mainwp_stream_filter_input( INPUT_POST, 'submitrobots' ) ) {
302
  }
303
  }
304
 
305
+ /**
306
+ * Record Yoast SEO added post meta log.
307
+ *
308
+ * @param string $meta_id Meta ID.
309
+ * @param string $object_id Object ID.
310
+ * @param string $meta_key Meta Key.
311
+ * @param string $meta_value Meta value.
312
+ */
313
+ public function callback_added_post_meta($meta_id, $object_id, $meta_key, $meta_value ) {
314
  unset( $meta_id );
315
  $this->meta( $object_id, $meta_key, $meta_value );
316
  }
317
+
318
+ /**
319
+ * Record Yoast SEO update post meta log.
320
+ *
321
+ * @param string $meta_id Meta ID.
322
+ * @param string $object_id Object ID.
323
+ * @param string $meta_key Meta Key.
324
+ * @param string $meta_value Meta value.
325
+ */
326
+ public function callback_updated_post_meta($meta_id, $object_id, $meta_key, $meta_value ) {
327
  unset( $meta_id );
328
  $this->meta( $object_id, $meta_key, $meta_value );
329
  }
330
+
331
+ /**
332
+ * Record Yoast SEO delete posts meta log.
333
+ *
334
+ * @param string $meta_id Meta ID.
335
+ * @param string $object_id Object ID.
336
+ * @param string $meta_key Meta Key.
337
+ * @param string $meta_value Meta value.
338
+ */
339
+ public function callback_deleted_post_meta($meta_id, $object_id, $meta_key, $meta_value ) {
340
  unset( $meta_id );
341
  $this->meta( $object_id, $meta_key, $meta_value );
342
  }
343
 
344
+ /**
345
+ * Record Yoast SEO meta log.
346
+ *
347
+ * @param string $object_id Object ID.
348
+ * @param string $meta_key Meta Key.
349
+ * @param string $meta_value Meta value.
350
+ */
351
+ private function meta($object_id, $meta_key, $meta_value ) {
352
  $prefix = \WPSEO_Meta::$meta_prefix;
353
 
354
  \WPSEO_Metabox::translate_meta_boxes();
393
  }
394
 
395
  /**
396
+ * Override connector log for our own Settings / Actions.
397
  *
398
+ * @param array $data Log data.
399
  *
400
  * @return array|bool
401
  */
404
  return $data;
405
  }
406
 
407
+ /** @global object $pagenow Pagenow object. */
408
  global $pagenow;
409
 
410
  if ( 'options.php' === $pagenow && 'settings' === $data['connector'] && wp_mainwp_stream_filter_input( INPUT_POST, '_wp_http_referer' ) ) {
435
  return $data;
436
  }
437
 
438
+ /**
439
+ * Set settings labels.
440
+ *
441
+ * @param $option
442
+ * @return array|bool|mixed Return labels array on success, FALSE on failure, error message on failure.
443
+ */
444
+ private function settings_labels( $option ) {
445
  $labels = array(
446
  // wp-content/plugins/wordpress-seo/admin/pages/dashboard.php:
447
  'yoast_tracking' => esc_html_x( "Allow tracking of this WordPress install's anonymous data.", 'wordpress-seo', 'mainwp-child-reports' ), # type = checkbox
exporters/class-exporter-csv.php CHANGED
@@ -1,27 +1,25 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Exporter_CSV extends Exporter {
5
- /**
6
- * Exporter name
7
- *
8
- * @var string
9
- */
10
  public $name = 'CSV';
11
 
12
- /**
13
- * Exporter slug
14
- *
15
- * @var string
16
- */
17
  public $slug = 'csv';
18
 
19
  /**
20
- * Outputs CSV data for download
21
  *
22
  * @param array $data Array of data to output.
23
  * @param array $columns Column names included in data set.
24
- * @return void
25
  */
26
  public function output_file( $data, $columns ) {
27
  if ( ! defined( 'WP_MAINWP_STREAM_TESTS' ) || ( defined( 'WP_MAINWP_STREAM_TESTS' ) && ! WP_MAINWP_STREAM_TESTS ) ) {
1
  <?php
2
+ /** MainWP Child Reports CSV exporter. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Exporter_CSV
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Exporter_CSV extends Exporter {
11
+
12
+ /** @var string Exporter name. */
 
 
 
13
  public $name = 'CSV';
14
 
15
+ /** @var string Exporter slug. */
 
 
 
 
16
  public $slug = 'csv';
17
 
18
  /**
19
+ * Outputs CSV data for download.
20
  *
21
  * @param array $data Array of data to output.
22
  * @param array $columns Column names included in data set.
 
23
  */
24
  public function output_file( $data, $columns ) {
25
  if ( ! defined( 'WP_MAINWP_STREAM_TESTS' ) || ( defined( 'WP_MAINWP_STREAM_TESTS' ) && ! WP_MAINWP_STREAM_TESTS ) ) {
exporters/class-exporter-json.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
 
2
  namespace WP_MainWP_Stream;
3
 
 
 
 
 
4
  class Exporter_JSON extends Exporter {
5
  /**
6
  * Exporter name
1
  <?php
2
+ /** MainWP Child Reports JSON exporter. */
3
+
4
  namespace WP_MainWP_Stream;
5
 
6
+ /**
7
+ * Class Exporter_JSON.
8
+ * @package WP_MainWP_Stream
9
+ */
10
  class Exporter_JSON extends Exporter {
11
  /**
12
  * Exporter name
includes/db-updates.php CHANGED
@@ -1,15 +1,21 @@
1
  <?php
2
  /**
3
- * Version 3.5.2
4
  *
5
  * To fix meta data.
 
 
 
 
6
  *
7
- * @param string $db_version
8
- * @param string $current_version
9
  *
10
- * @return string
11
  */
12
- function wp_mainwp_stream_update_auto_352( $db_version, $current_version ) {
 
 
13
  global $wpdb;
14
 
15
  $first_correct = $wpdb->get_results(
@@ -31,7 +37,7 @@ function wp_mainwp_stream_update_auto_352( $db_version, $current_version ) {
31
  return; // this is correct conversion
32
  }
33
 
34
- // to get first correct meta id
35
  $sql = $wpdb->prepare(
36
  "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_meta
37
  WHERE record_id = %d ORDER BY meta_id ASC LIMIT 1",
@@ -55,11 +61,9 @@ function wp_mainwp_stream_update_auto_352( $db_version, $current_version ) {
55
  $rows_per_round = 5000;
56
 
57
  $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream WHERE 1 = 1 " .
58
- $where . $orderby .
59
- $wpdb->prepare( " LIMIT %d, %d", $starting_row, $rows_per_round ) );
60
  $stop = false;
61
-
62
-
63
  $fix_what = array(
64
  'plugin_updated',
65
  'plugin_activated_deactivated',
@@ -71,8 +75,7 @@ function wp_mainwp_stream_update_auto_352( $db_version, $current_version ) {
71
  'wordfence_scan',
72
  'sucuri_scan'
73
  );
74
-
75
-
76
  while ( ! empty( $stream_entries ) ) {
77
 
78
  foreach( $fix_what as $fix_value ) {
1
  <?php
2
  /**
3
+ * MainWP WP Stream Database Update Version 3.5.2
4
  *
5
  * To fix meta data.
6
+ */
7
+
8
+ /**
9
+ * MainWP WP Stream Database Update Version 3.5.2
10
  *
11
+ * @param string $db_version New Database version.
12
+ * @param string $current_version Current Database version.
13
  *
14
+ * @return string $current_version Current WP Stream Database version.
15
  */
16
+ function wp_mainwp_stream_update_auto_352( $db_version, $current_version ) {
17
+
18
+ /** @global object $wpdb WordPress Database objcet. */
19
  global $wpdb;
20
 
21
  $first_correct = $wpdb->get_results(
37
  return; // this is correct conversion
38
  }
39
 
40
+ // First get correct meta id.
41
  $sql = $wpdb->prepare(
42
  "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_meta
43
  WHERE record_id = %d ORDER BY meta_id ASC LIMIT 1",
61
  $rows_per_round = 5000;
62
 
63
  $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream WHERE 1 = 1 " .
64
+ $where . $orderby . $wpdb->prepare( " LIMIT %d, %d", $starting_row, $rows_per_round ) );
 
65
  $stop = false;
66
+
 
67
  $fix_what = array(
68
  'plugin_updated',
69
  'plugin_activated_deactivated',
75
  'wordfence_scan',
76
  'sucuri_scan'
77
  );
78
+
 
79
  while ( ! empty( $stream_entries ) ) {
80
 
81
  foreach( $fix_what as $fix_value ) {
includes/feeds/atom.php CHANGED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  header( 'Content-Type: ' . feed_content_type( 'atom' ) . '; charset=' . get_option( 'blog_charset' ), true );
3
  printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_charset' ) ) );
4
  ?>
1
  <?php
2
+ /** MainWP Child Reports atom feed. */
3
+
4
  header( 'Content-Type: ' . feed_content_type( 'atom' ) . '; charset=' . get_option( 'blog_charset' ), true );
5
  printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_charset' ) ) );
6
  ?>
includes/feeds/json.php CHANGED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  header( 'Content-type: application/json; charset=' . get_option( 'blog_charset' ), true );
3
  if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
4
  echo wp_mainwp_stream_json_encode( $records ); // xss ok
1
  <?php
2
+ /** MainWP Child Reports JSON feed. */
3
+
4
  header( 'Content-type: application/json; charset=' . get_option( 'blog_charset' ), true );
5
  if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
6
  echo wp_mainwp_stream_json_encode( $records ); // xss ok
includes/feeds/rss-2.0.php CHANGED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  header( 'Content-Type: ' . feed_content_type( 'rss-http' ) . '; charset=' . get_option( 'blog_charset' ), true );
3
  printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_charset' ) ) );
4
  ?>
1
  <?php
2
+ /** MainWp Child Reports RRS Feed. */
3
+
4
  header( 'Content-Type: ' . feed_content_type( 'rss-http' ) . '; charset=' . get_option( 'blog_charset' ), true );
5
  printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_charset' ) ) );
6
  ?>
includes/functions.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Gets a specific external variable by name and optionally filters it.
4
  *
@@ -37,8 +38,10 @@ function wp_mainwp_stream_filter_var( $var, $filter = null, $options = array() )
37
  *
38
  * @param int|bool $time Seconds since unix epoc
39
  * @param int $offset Hour offset
 
40
  *
41
  * @return string an ISO 8601 extended formatted time
 
42
  */
43
  function wp_mainwp_stream_get_iso_8601_extended_date( $time = false, $offset = 0, $mysql_date_string = false ) {
44
  if ( $time ) {
@@ -48,25 +51,20 @@ function wp_mainwp_stream_get_iso_8601_extended_date( $time = false, $offset = 0
48
  }
49
 
50
  $micro_seconds = sprintf( '%06d', ( $microtime - floor( $microtime ) ) * 1000000 );
51
- $offset_string = sprintf( 'Etc/GMT%s%s', $offset < 0 ? '+' : '-', abs( $offset ) );
52
 
53
  $timezone = new DateTimeZone( $offset_string );
54
- $date = new DateTime( date( 'Y-m-d H:i:s.' . $micro_seconds, $microtime ), $timezone );
55
-
56
  if ( $mysql_date_string ) {
57
  return $date->format( 'Y-m-d H:i:s' );
58
  }
59
-
60
- return sprintf(
61
- '%s%03d%s',
62
- $date->format( 'Y-m-d\TH:i:s.' ),
63
- floor( $date->format( 'u' ) / 1000 ),
64
- $date->format( 'O' )
65
- );
66
  }
67
 
68
  /**
69
- * Encode to JSON in a way that is also backwards compatible
70
  *
71
  * @param mixed $data
72
  * @param int $options (optional)
@@ -91,7 +89,7 @@ function wp_mainwp_stream_json_encode( $data, $options = 0, $depth = 512 ) {
91
  }
92
 
93
  /**
94
- * Return an array of sites for a network in a way that is also backwards compatible
95
  *
96
  * @param string|array $args
97
  *
@@ -119,6 +117,15 @@ function wp_mainwp_stream_is_vip() {
119
  return function_exists( 'wpcom_vip_load_plugin' );
120
  }
121
 
 
 
 
 
 
 
 
 
 
122
  /**
123
  * True if native WP Cron is enabled, otherwise false
124
  *
@@ -128,6 +135,7 @@ function wp_mainwp_stream_is_cron_enabled() {
128
  return ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ? false : true;
129
  }
130
 
 
131
  /**
132
  * Get the asset min suffix if defined.
133
  *
1
  <?php
2
+ /** MainWP Child Reports default functions. */
3
  /**
4
  * Gets a specific external variable by name and optionally filters it.
5
  *
38
  *
39
  * @param int|bool $time Seconds since unix epoc
40
  * @param int $offset Hour offset
41
+ * @param bool $mysql_date_string Whether to use mysql date string.
42
  *
43
  * @return string an ISO 8601 extended formatted time
44
+ * @throws Exception Error message.
45
  */
46
  function wp_mainwp_stream_get_iso_8601_extended_date( $time = false, $offset = 0, $mysql_date_string = false ) {
47
  if ( $time ) {
51
  }
52
 
53
  $micro_seconds = sprintf( '%06d', ( $microtime - floor( $microtime ) ) * 1000000 );
54
+ $offset_string = sprintf( 'Etc/GMT%s%d', $offset < 0 ? '+' : '-', abs( $offset ) );
55
 
56
  $timezone = new DateTimeZone( $offset_string );
57
+ $date = new DateTime( gmdate( 'Y-m-d H:i:s.' . $micro_seconds, $microtime ), $timezone );
58
+
59
  if ( $mysql_date_string ) {
60
  return $date->format( 'Y-m-d H:i:s' );
61
  }
62
+
63
+ return $date->format( 'Y-m-d\TH:i:sO' );
 
 
 
 
 
64
  }
65
 
66
  /**
67
+ * Encode to JSON in a way that is also backwards compatible.
68
  *
69
  * @param mixed $data
70
  * @param int $options (optional)
89
  }
90
 
91
  /**
92
+ * Return an array of sites for a network in a way that is also backwards compatible.
93
  *
94
  * @param string|array $args
95
  *
117
  return function_exists( 'wpcom_vip_load_plugin' );
118
  }
119
 
120
+ /**
121
+ * True if it is mainwp dashboard request
122
+ *
123
+ * @return bool
124
+ */
125
+ function wp_mainwp_stream_is_dashboard_request() {
126
+ return ( isset( $_POST['mainwpsignature'] ) && isset( $_POST['function'] ) ) ? true : false;
127
+ }
128
+
129
  /**
130
  * True if native WP Cron is enabled, otherwise false
131
  *
135
  return ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ? false : true;
136
  }
137
 
138
+
139
  /**
140
  * Get the asset min suffix if defined.
141
  *
mainwp-child-reports.php CHANGED
@@ -1,14 +1,20 @@
1
  <?php
2
- /*
 
 
3
  * Plugin Name: MainWP Child Reports
4
  * Plugin URI: https://mainwp.com/
5
  * Description: The MainWP Child Report plugin tracks Child sites for the MainWP Client Reports Extension. The plugin is only useful if you are using MainWP and the Client Reports Extension.
6
  * Author: MainWP
7
  * Author URI: https://mainwp.com
8
- * Version: 2.0.4
 
 
 
 
9
  */
10
 
11
- /*
12
  * Credit to the Stream Plugin which the MainWP Child Reports plugin is built on.
13
  *
14
  * Plugin Name: Stream
1
  <?php
2
+ /**
3
+ * MainWP Child Reports.
4
+ *
5
  * Plugin Name: MainWP Child Reports
6
  * Plugin URI: https://mainwp.com/
7
  * Description: The MainWP Child Report plugin tracks Child sites for the MainWP Client Reports Extension. The plugin is only useful if you are using MainWP and the Client Reports Extension.
8
  * Author: MainWP
9
  * Author URI: https://mainwp.com
10
+ * Version: 2.0.5
11
+ * Requires at least: 3.6
12
+ * Text Domain: mainwp-child-reports
13
+ * License: GPLv3 or later
14
+ * License URI: https://www.gnu.org/licenses/gpl-3.0.html
15
  */
16
 
17
+ /**
18
  * Credit to the Stream Plugin which the MainWP Child Reports plugin is built on.
19
  *
20
  * Plugin Name: Stream
readme.txt CHANGED
@@ -5,11 +5,11 @@ Author: mainwp
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 3.6
8
- Tested up to: 5.4.1
9
  Requires PHP: 5.6
10
- Stable tag: 2.0.4
11
- License: GPLv2 or later
12
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
14
  The MainWP Child Report plugin tracks changes to Child sites for the Client Reports Extension.
15
 
@@ -36,6 +36,11 @@ Credit to the [Stream Plugin](https://wordpress.org/plugins/stream/) which the M
36
 
37
  == Changelog ==
38
 
 
 
 
 
 
39
  = 2.0.4 - 4-30-2020 =
40
  * Fixed: an issue with logging themes updates
41
  * Fixed: an issue with logging created posts
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 3.6
8
+ Tested up to: 5.5
9
  Requires PHP: 5.6
10
+ Stable tag: 2.0.5
11
+ License: GPLv3 or later
12
+ License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
14
  The MainWP Child Report plugin tracks changes to Child sites for the Client Reports Extension.
15
 
36
 
37
  == Changelog ==
38
 
39
+ = 2.0.5 - 8-31-2020 =
40
+ * Fixed: jQuery warning
41
+ * Fixed: Compatibility issues with MySQL 8
42
+ * Fixed: An issue with logging maintenance tasks
43
+
44
  = 2.0.4 - 4-30-2020 =
45
  * Fixed: an issue with logging themes updates
46
  * Fixed: an issue with logging created posts
ui/js/admin.js CHANGED
@@ -141,8 +141,7 @@ jQuery(
141
  }
142
  );
143
 
144
- $( window ).load(
145
- function() {
146
  $( '.settings_page_mainwp-reports-page input[type="search"]' ).off( 'mousedown' );
147
  }
148
  );
141
  }
142
  );
143
 
144
+ $( window ).on( "load", function() {
 
145
  $( '.settings_page_mainwp-reports-page input[type="search"]' ).off( 'mousedown' );
146
  }
147
  );