MainWP Child Reports - Version 2.0.1

Version Description

  • 12-13-2019 =
  • Fixed: data Child Reports conversion problem
Download this release

Release Info

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

Code changes from version 2.0 to 2.0.1

classes/class-admin.php CHANGED
@@ -177,6 +177,14 @@ class Admin {
177
  'wp_ajax_reset',
178
  )
179
  );
 
 
 
 
 
 
 
 
180
 
181
  // Uninstall Streams and Deactivate plugin.
182
  $uninstall = $this->plugin->db->driver->purge_storage( $this->plugin );
@@ -612,6 +620,96 @@ class Admin {
612
  \wp_add_inline_style( 'wp-admin', $css );
613
  }
614
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
615
  /**
616
  * Handle the reset AJAX request to reset logs.
617
  *
@@ -644,7 +742,8 @@ class Admin {
644
 
645
  exit;
646
  }
647
-
 
648
  private function erase_stream_records() {
649
  global $wpdb;
650
 
177
  'wp_ajax_reset',
178
  )
179
  );
180
+
181
+ // Reset Streams database.
182
+ // add_action(
183
+ // 'wp_ajax_wp_mainwp_stream_convert', array(
184
+ // $this,
185
+ // 'wp_ajax_convert',
186
+ // )
187
+ // );
188
 
189
  // Uninstall Streams and Deactivate plugin.
190
  $uninstall = $this->plugin->db->driver->purge_storage( $this->plugin );
620
  \wp_add_inline_style( 'wp-admin', $css );
621
  }
622
 
623
+
624
+
625
+ /**
626
+ * Handle the convert AJAX request to convert logs.
627
+ *
628
+ * @return bool
629
+ */
630
+ // public function wp_ajax_convert() {
631
+ // check_ajax_referer( 'stream_nonce_convert', 'wp_mainwp_stream_nonce_convert' );
632
+ //
633
+ // if ( ! current_user_can( $this->settings_cap ) ) {
634
+ // wp_die(
635
+ // esc_html__( "You don't have sufficient privileges to do this action.", 'mainwp-child-reports' )
636
+ // );
637
+ // }
638
+ //
639
+ // $this->convert_old_records();
640
+ //
641
+ // if ( defined( 'WP_MAINWP_STREAM_TESTS' ) && WP_MAINWP_STREAM_TESTS ) {
642
+ // return true;
643
+ // }
644
+ //
645
+ // wp_redirect(
646
+ // add_query_arg(
647
+ // array(
648
+ // 'page' => is_network_admin() ? $this->network->network_settings_page_slug : $this->settings_page_slug,
649
+ // 'message' => 'data_converted',
650
+ // ),
651
+ // self_admin_url( $this->admin_parent_page )
652
+ // )
653
+ // );
654
+ //
655
+ // exit;
656
+ // }
657
+
658
+ private function convert_old_records() {
659
+
660
+ global $wpdb;
661
+ // Get only the author_meta values that are double-serialized
662
+ $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" );
663
+
664
+ // $plugin = wp_mainwp_stream_get_instance();
665
+ // $plugin->install->install( $current_version );
666
+
667
+ $date = new DateTime( 'now', $timezone = new DateTimeZone( 'UTC' ) );
668
+ $date->modify('-3 month');
669
+ //$where = " AND `created` < STR_TO_DATE(" . $wpdb->prepare('%s', $date->format( 'Y-m-d H:i:s' )) . ", '%Y-%m-%d %H:%i:%s') ";
670
+ $where = "";
671
+ $orderby = ' ORDER BY ID DESC ';
672
+
673
+ $starting_row = 0;
674
+ $rows_per_round = 2;
675
+
676
+ $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_tmp WHERE 1 = 1 " . $where . $orderby . $wpdb->prepare( " LIMIT %d, %d", $starting_row, $rows_per_round ) );
677
+
678
+ while ( ! empty( $stream_entries ) ) {
679
+ foreach ( $stream_entries as $entry ) {
680
+ $context = $wpdb->get_row(
681
+ $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_context_tmp WHERE record_id = %s LIMIT 1", $entry->ID )
682
+ );
683
+
684
+ $new_entry = array(
685
+ 'site_id' => $entry->site_id,
686
+ 'blog_id' => $entry->blog_id,
687
+ 'user_id' => $entry->author,
688
+ 'user_role' => $entry->author_role,
689
+ 'summary' => $entry->summary,
690
+ 'created' => $entry->created,
691
+ 'connector' => $context->connector,
692
+ 'context' => $context->context,
693
+ 'action' => $context->action,
694
+ 'ip' => $entry->ip,
695
+ );
696
+
697
+ if ( $entry->object_id && 0 !== $entry->object_id ) {
698
+ $new_entry['object_id'] = $entry->object_id;
699
+ }
700
+
701
+ $wpdb->insert( $wpdb->base_prefix . 'mainwp_stream', $new_entry );
702
+
703
+ }
704
+ $starting_row += $rows_per_round;
705
+ $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_tmp WHERE 1 = 1 " . $where . $orderby . $wpdb->prepare( "LIMIT %d, %d", $starting_row, $rows_per_round ) );
706
+
707
+ }
708
+
709
+ // $wpdb->query( "DROP TABLE {$wpdb->base_prefix}mainwp_stream_tmp, {$wpdb->base_prefix}mainwp_stream_context_tmp" );
710
+ return $current_version;
711
+ }
712
+
713
  /**
714
  * Handle the reset AJAX request to reset logs.
715
  *
742
 
743
  exit;
744
  }
745
+
746
+
747
  private function erase_stream_records() {
748
  global $wpdb;
749
 
classes/class-connectors.php CHANGED
@@ -64,7 +64,7 @@ class Connectors {
64
  'media',
65
  'menus',
66
  'posts',
67
- 'settings',
68
  'taxonomies',
69
  'users',
70
  'widgets',
64
  'media',
65
  'menus',
66
  'posts',
67
+ //'settings',
68
  'taxonomies',
69
  'users',
70
  'widgets',
classes/class-install.php CHANGED
@@ -381,6 +381,7 @@ class Install {
381
  '3.0.0', /* @version 3.0.0 Drop the stream_context table, changes to stream table */
382
  '3.0.2', /* @version 3.0.2 Fix uppercase values in stream table, connector column */
383
  '3.0.8', /* @version 3.0.8 Increase size of user role IDs, user_roll column */
 
384
  );
385
 
386
  /**
381
  '3.0.0', /* @version 3.0.0 Drop the stream_context table, changes to stream table */
382
  '3.0.2', /* @version 3.0.2 Fix uppercase values in stream table, connector column */
383
  '3.0.8', /* @version 3.0.8 Increase size of user role IDs, user_roll column */
384
+ '3.5.0', /* @version 3.5.0 Fix connector values */
385
  );
386
 
387
  /**
classes/class-plugin.php CHANGED
@@ -7,7 +7,7 @@ class Plugin {
7
  *
8
  * @const string
9
  */
10
- const VERSION = '3.5';
11
 
12
  /**
13
  * WP-CLI command
7
  *
8
  * @const string
9
  */
10
+ const VERSION = '3.5.1';
11
 
12
  /**
13
  * WP-CLI command
classes/class-query.php CHANGED
@@ -81,22 +81,26 @@ class Query {
81
 
82
  if ( ! empty( $args['date_from'] ) ) {
83
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', strtotime( $args['date_from'] . ' 00:00:00' ) ) );
84
- $where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) >= %s", $date );
 
85
  }
86
 
87
  if ( ! empty( $args['date_to'] ) ) {
88
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', strtotime( $args['date_to'] . ' 23:59:59' ) ) );
89
- $where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) <= %s", $date );
 
90
  }
91
 
92
  if ( ! empty( $args['date_after'] ) ) {
93
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', strtotime( $args['date_after'] ) ) );
94
- $where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) > %s", $date );
 
95
  }
96
 
97
  if ( ! empty( $args['date_before'] ) ) {
98
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', strtotime( $args['date_before'] ) ) );
99
- $where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) < %s", $date );
 
100
  }
101
 
102
 
@@ -104,9 +108,11 @@ class Query {
104
  if ( ! empty( $args['created'] ) ) {
105
  $created = strtotime( $args['created'] );
106
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', $created + 5 ) );
107
- $where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) <= %s", $date );
 
108
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', $created - 5 ) );
109
- $where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) >= %s", $date );
 
110
  }
111
 
112
  /**
@@ -199,6 +205,12 @@ class Query {
199
  */
200
  $order = esc_sql( $args['order'] );
201
  $orderby = esc_sql( $args['orderby'] );
 
 
 
 
 
 
202
  $orderable = array( 'ID', 'site_id', 'blog_id', 'object_id', 'user_id', 'user_role', 'summary', 'created', 'connector', 'context', 'action' );
203
 
204
  if ( in_array( $orderby, $orderable, true ) ) {
@@ -212,7 +224,7 @@ class Query {
212
  }
213
 
214
  $orderby = "ORDER BY {$orderby} {$order}";
215
-
216
  /**
217
  * PARSE FIELDS PARAMETER
218
  */
81
 
82
  if ( ! empty( $args['date_from'] ) ) {
83
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', strtotime( $args['date_from'] . ' 00:00:00' ) ) );
84
+ //$where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) >= %s", $date );
85
+ $where .= " AND ($wpdb->mainwp_stream.created >= STR_TO_DATE(" . $wpdb->prepare('%s', $date) . ", '%Y-%m-%d %H:%i:%s'))";
86
  }
87
 
88
  if ( ! empty( $args['date_to'] ) ) {
89
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', strtotime( $args['date_to'] . ' 23:59:59' ) ) );
90
+ //$where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) <= %s", $date );
91
+ $where .= " AND ($wpdb->mainwp_stream.created <= STR_TO_DATE(" . $wpdb->prepare('%s', $date) . ", '%Y-%m-%d %H:%i:%s'))";
92
  }
93
 
94
  if ( ! empty( $args['date_after'] ) ) {
95
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', strtotime( $args['date_after'] ) ) );
96
+ //$where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) > %s", $date );
97
+ $where .= " AND ($wpdb->mainwp_stream.created > STR_TO_DATE(" . $wpdb->prepare('%s', $date) . ", '%Y-%m-%d %H:%i:%s'))";
98
  }
99
 
100
  if ( ! empty( $args['date_before'] ) ) {
101
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', strtotime( $args['date_before'] ) ) );
102
+ //$where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) < %s", $date );
103
+ $where .= " AND ($wpdb->mainwp_stream.created < STR_TO_DATE(" . $wpdb->prepare('%s', $date) . ", '%Y-%m-%d %H:%i:%s'))";
104
  }
105
 
106
 
108
  if ( ! empty( $args['created'] ) ) {
109
  $created = strtotime( $args['created'] );
110
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', $created + 5 ) );
111
+ //$where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) <= %s", $date );
112
+ $where .= " AND ($wpdb->mainwp_stream.created <= STR_TO_DATE(" . $wpdb->prepare('%s', $date) . ", '%Y-%m-%d %H:%i:%s'))";
113
  $date = get_gmt_from_date( date( 'Y-m-d H:i:s', $created - 5 ) );
114
+ //$where .= $wpdb->prepare( " AND DATE($wpdb->mainwp_stream.created) >= %s", $date );
115
+ $where .= " AND ($wpdb->mainwp_stream.created >= STR_TO_DATE(" . $wpdb->prepare('%s', $date) . ", '%Y-%m-%d %H:%i:%s'))";
116
  }
117
 
118
  /**
205
  */
206
  $order = esc_sql( $args['order'] );
207
  $orderby = esc_sql( $args['orderby'] );
208
+
209
+ // to fix order by created
210
+ if ($orderby == 'date') {
211
+ $orderby = 'created';
212
+ }
213
+
214
  $orderable = array( 'ID', 'site_id', 'blog_id', 'object_id', 'user_id', 'user_role', 'summary', 'created', 'connector', 'context', 'action' );
215
 
216
  if ( in_array( $orderby, $orderable, true ) ) {
224
  }
225
 
226
  $orderby = "ORDER BY {$orderby} {$order}";
227
+
228
  /**
229
  * PARSE FIELDS PARAMETER
230
  */
classes/class-settings.php CHANGED
@@ -301,7 +301,7 @@ class Settings {
301
  'type' => 'number',
302
  'class' => 'small-text',
303
  'desc' => esc_html__( 'Maximum number of days to keep activity records.', 'mainwp-child-reports' ),
304
- 'default' => 30,
305
  'min' => 1,
306
  'max' => 999,
307
  'step' => 1,
@@ -357,6 +357,22 @@ class Settings {
357
  'default' => 0,
358
  'sticky' => 'bottom',
359
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  ),
361
  ),
362
  );
301
  'type' => 'number',
302
  'class' => 'small-text',
303
  'desc' => esc_html__( 'Maximum number of days to keep activity records.', 'mainwp-child-reports' ),
304
+ 'default' => 100,
305
  'min' => 1,
306
  'max' => 999,
307
  'step' => 1,
357
  'default' => 0,
358
  'sticky' => 'bottom',
359
  ),
360
+ // array(
361
+ // 'name' => 'convert_old_data',
362
+ // 'title' => esc_html__( 'Convert Old Data', 'mainwp-child-reports' ),
363
+ // 'type' => 'link',
364
+ // 'href' => add_query_arg(
365
+ // array(
366
+ // 'action' => 'wp_mainwp_stream_convert',
367
+ // 'wp_mainwp_stream_nonce_convert' => wp_create_nonce( 'stream_nonce_convert' ),
368
+ // ),
369
+ // admin_url( 'admin-ajax.php' )
370
+ // ),
371
+ // 'class' => 'warning',
372
+ // 'desc' => esc_html__( 'Warning: This will convert old data.', 'mainwp-child-reports' ),
373
+ // 'default' => 0,
374
+ // 'sticky' => 'bottom',
375
+ // ),
376
  ),
377
  ),
378
  );
connectors/class-connector-acf.php CHANGED
@@ -22,15 +22,15 @@ class Connector_ACF extends Connector {
22
  * @var array
23
  */
24
  public $actions = array(
25
- 'added_post_meta',
26
- 'updated_post_meta',
27
- 'delete_post_meta',
28
- 'added_user_meta',
29
- 'updated_user_meta',
30
- 'delete_user_meta',
31
- 'added_option',
32
- 'updated_option',
33
- 'deleted_option',
34
  'pre_post_update',
35
  );
36
 
22
  * @var array
23
  */
24
  public $actions = array(
25
+ //'added_post_meta',
26
+ //'updated_post_meta',
27
+ //'delete_post_meta',
28
+ //'added_user_meta',
29
+ //'updated_user_meta',
30
+ //'delete_user_meta',
31
+ //'added_option',
32
+ //'updated_option',
33
+ //'deleted_option',
34
  'pre_post_update',
35
  );
36
 
connectors/class-connector-installer.php CHANGED
@@ -28,7 +28,7 @@ class Connector_Installer extends Connector {
28
  'mainwp_child_installPluginTheme',
29
  'mainwp_child_plugin_action',
30
  'mainwp_child_theme_action',
31
- 'mainwp_child_upgradePluginTheme'
32
  );
33
 
34
  public $old_plugins = array();
@@ -275,7 +275,10 @@ class Connector_Installer extends Connector {
275
  $_plugins = $this->get_plugins();
276
  $name = $_plugins[ $slug ]['Name'];
277
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
278
-
 
 
 
279
  $this->log(
280
  // translators: Placeholders refer to a plugin name, and whether it is on a single site or network wide (e.g. "Stream", "network wide") (a single site results in a blank string)
281
  _x(
@@ -433,7 +436,7 @@ class Connector_Installer extends Connector {
433
  $message,
434
  compact( 'new_version', 'old_version', 'auto_updated' ),
435
  null,
436
- 'WordPress',
437
  'updated'
438
  );
439
  }
@@ -546,61 +549,61 @@ class Connector_Installer extends Connector {
546
  $this->old_plugins = $this->get_plugins();
547
  }
548
 
549
- public function callback_mainwp_child_upgradePluginTheme( $extra ) {
550
- $logs = array();
551
-
552
- if ( ! isset( $extra['type'] ) ) {
553
- return false;
554
- }
555
-
556
- $type = $extra['type'];
557
- $action = $extra['action'];
558
-
559
- if ( ! in_array( $type, array( 'plugin', 'theme' ) ) ) {
560
- return;
561
- }
562
-
563
- if ( 'update' === $action ) {
564
- if ( 'plugin' === $type ) {
565
- $slug = $extra['slug'];
566
- $name = $extra['name'];
567
- $version = $extra['version'];
568
- $old_version = $extra['old_version'];
569
- } else { // theme
570
- $name = $extra['name'];
571
- $version = $extra['version'];
572
- $old_version = $extra['old_version'];
573
- }
574
-
575
- $action = 'updated';
576
- $message = _x(
577
- 'Updated %1$s: %2$s %3$s',
578
- 'Plugin/theme update. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
579
- 'mainwp_child_reports'
580
- );
581
- $logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
582
- } else {
583
- return false;
584
- }
585
-
586
- $context = $type . 's';
587
-
588
- foreach ( $logs as $log ) {
589
- $name = isset( $log['name'] ) ? $log['name'] : null;
590
- $version = isset( $log['version'] ) ? $log['version'] : null;
591
- $slug = isset( $log['slug'] ) ? $log['slug'] : null;
592
- $old_version = isset( $log['old_version'] ) ? $log['old_version'] : null;
593
- $message = isset( $log['message'] ) ? $log['message'] : null;
594
- $action = isset( $log['action'] ) ? $log['action'] : null;
595
- $this->log(
596
- $message,
597
- compact( 'type', 'name', 'version', 'slug', 'success', 'error', 'old_version' ),
598
- null,
599
- $context,
600
- $action
601
- );
602
- }
603
- }
604
 
605
 
606
  }
28
  'mainwp_child_installPluginTheme',
29
  'mainwp_child_plugin_action',
30
  'mainwp_child_theme_action',
31
+ //'mainwp_child_upgradePluginTheme'
32
  );
33
 
34
  public $old_plugins = array();
275
  $_plugins = $this->get_plugins();
276
  $name = $_plugins[ $slug ]['Name'];
277
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
278
+
279
+ if (empty($name))
280
+ return;
281
+
282
  $this->log(
283
  // translators: Placeholders refer to a plugin name, and whether it is on a single site or network wide (e.g. "Stream", "network wide") (a single site results in a blank string)
284
  _x(
436
  $message,
437
  compact( 'new_version', 'old_version', 'auto_updated' ),
438
  null,
439
+ 'wordpress',
440
  'updated'
441
  );
442
  }
549
  $this->old_plugins = $this->get_plugins();
550
  }
551
 
552
+ // public function callback_mainwp_child_upgradePluginTheme( $extra ) {
553
+ // $logs = array();
554
+ //
555
+ // if ( ! isset( $extra['type'] ) ) {
556
+ // return false;
557
+ // }
558
+ //
559
+ // $type = $extra['type'];
560
+ // $action = $extra['action'];
561
+ //
562
+ // if ( ! in_array( $type, array( 'plugin', 'theme' ) ) ) {
563
+ // return;
564
+ // }
565
+ //
566
+ // if ( 'update' === $action ) {
567
+ // if ( 'plugin' === $type ) {
568
+ // $slug = $extra['slug'];
569
+ // $name = $extra['name'];
570
+ // $version = $extra['version'];
571
+ // $old_version = $extra['old_version'];
572
+ // } else { // theme
573
+ // $name = $extra['name'];
574
+ // $version = $extra['version'];
575
+ // $old_version = $extra['old_version'];
576
+ // }
577
+ //
578
+ // $action = 'updated';
579
+ // $message = _x(
580
+ // 'Updated %1$s: %2$s %3$s',
581
+ // 'Plugin/theme update. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
582
+ // 'mainwp_child_reports'
583
+ // );
584
+ // $logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
585
+ // } else {
586
+ // return false;
587
+ // }
588
+ //
589
+ // $context = $type . 's';
590
+ //
591
+ // foreach ( $logs as $log ) {
592
+ // $name = isset( $log['name'] ) ? $log['name'] : null;
593
+ // $version = isset( $log['version'] ) ? $log['version'] : null;
594
+ // $slug = isset( $log['slug'] ) ? $log['slug'] : null;
595
+ // $old_version = isset( $log['old_version'] ) ? $log['old_version'] : null;
596
+ // $message = isset( $log['message'] ) ? $log['message'] : null;
597
+ // $action = isset( $log['action'] ) ? $log['action'] : null;
598
+ // $this->log(
599
+ // $message,
600
+ // compact( 'type', 'name', 'version', 'slug', 'success', 'error', 'old_version' ),
601
+ // null,
602
+ // $context,
603
+ // $action
604
+ // );
605
+ // }
606
+ // }
607
 
608
 
609
  }
connectors/class-connector-settings.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  namespace WP_MainWP_Stream;
3
-
4
  class Connector_Settings extends Connector {
5
  /**
6
  * Prefix for the highlight URL hash
@@ -22,12 +22,12 @@ class Connector_Settings extends Connector {
22
  * @var array
23
  */
24
  public $actions = array(
25
- 'whitelist_options',
26
- 'update_option',
27
  'update_site_option',
28
  'update_option_permalink_structure',
29
- 'update_option_category_base',
30
- 'update_option_tag_base',
31
  );
32
 
33
  /**
@@ -243,14 +243,14 @@ class Connector_Settings extends Connector {
243
  */
244
  public function get_context_labels() {
245
  $context_labels = array(
246
- 'settings' => esc_html__( 'Settings', 'mainwp-child-reports' ),
247
  'general' => esc_html__( 'General', 'mainwp-child-reports' ),
248
  'writing' => esc_html__( 'Writing', 'mainwp-child-reports' ),
249
  'reading' => esc_html__( 'Reading', 'mainwp-child-reports' ),
250
  'discussion' => esc_html__( 'Discussion', 'mainwp-child-reports' ),
251
  'media' => esc_html__( 'Media', 'mainwp-child-reports' ),
252
  'permalink' => esc_html__( 'Permalinks', 'mainwp-child-reports' ),
253
- 'network' => esc_html__( 'Network', 'mainwp-child-reports' ),
254
  'wp_mainwp_stream' => esc_html__( 'Reports', 'mainwp-child-reports' ),
255
  'custom_background' => esc_html__( 'Custom Background', 'mainwp-child-reports' ),
256
  'custom_header' => esc_html__( 'Custom Header', 'mainwp-child-reports' ),
1
  <?php
2
  namespace WP_MainWP_Stream;
3
+ // not used
4
  class Connector_Settings extends Connector {
5
  /**
6
  * Prefix for the highlight URL hash
22
  * @var array
23
  */
24
  public $actions = array(
25
+ //'whitelist_options',
26
+ //'update_option',
27
  'update_site_option',
28
  'update_option_permalink_structure',
29
+ //'update_option_category_base',
30
+ //'update_option_tag_base',
31
  );
32
 
33
  /**
243
  */
244
  public function get_context_labels() {
245
  $context_labels = array(
246
+ //'settings' => esc_html__( 'Settings', 'mainwp-child-reports' ),
247
  'general' => esc_html__( 'General', 'mainwp-child-reports' ),
248
  'writing' => esc_html__( 'Writing', 'mainwp-child-reports' ),
249
  'reading' => esc_html__( 'Reading', 'mainwp-child-reports' ),
250
  'discussion' => esc_html__( 'Discussion', 'mainwp-child-reports' ),
251
  'media' => esc_html__( 'Media', 'mainwp-child-reports' ),
252
  'permalink' => esc_html__( 'Permalinks', 'mainwp-child-reports' ),
253
+ //'network' => esc_html__( 'Network', 'mainwp-child-reports' ),
254
  'wp_mainwp_stream' => esc_html__( 'Reports', 'mainwp-child-reports' ),
255
  'custom_background' => esc_html__( 'Custom Background', 'mainwp-child-reports' ),
256
  'custom_header' => esc_html__( 'Custom Header', 'mainwp-child-reports' ),
connectors/class-connector-widgets.php CHANGED
@@ -26,7 +26,7 @@ class Connector_Widgets extends Connector {
26
  */
27
  public $actions = array(
28
  'update_option_sidebars_widgets',
29
- 'updated_option',
30
  );
31
 
32
  /**
26
  */
27
  public $actions = array(
28
  'update_option_sidebars_widgets',
29
+ //'updated_option',
30
  );
31
 
32
  /**
connectors/class-connector-woocommerce.php CHANGED
@@ -21,7 +21,7 @@ class Connector_Woocommerce extends Connector {
21
  */
22
  public $actions = array(
23
  'wp_mainwp_stream_record_array',
24
- 'updated_option',
25
  'transition_post_status',
26
  'deleted_post',
27
  'woocommerce_order_status_changed',
21
  */
22
  public $actions = array(
23
  'wp_mainwp_stream_record_array',
24
+ //'updated_option',
25
  'transition_post_status',
26
  'deleted_post',
27
  'woocommerce_order_status_changed',
includes/db-updates.php CHANGED
@@ -1,4 +1,66 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
  * Version 3.0.8
4
  *
@@ -39,7 +101,7 @@ function wp_mainwp_stream_update_302( $db_version, $current_version ) {
39
  'ID' => $entry->ID,
40
  )
41
  );
42
- } else {
43
  $wpdb->update(
44
  $wpdb->base_prefix . 'mainwp_stream', array(
45
  'connector' => strtolower( $entry->connector ),
@@ -63,7 +125,7 @@ function wp_mainwp_stream_update_302( $db_version, $current_version ) {
63
  *
64
  * @return string
65
  */
66
- function wp_mainwp_stream_update_auto_300( $db_version, $current_version ) {
67
  global $wpdb;
68
 
69
  // Get only the author_meta values that are double-serialized
@@ -71,11 +133,11 @@ function wp_mainwp_stream_update_auto_300( $db_version, $current_version ) {
71
 
72
  $plugin = wp_mainwp_stream_get_instance();
73
  $plugin->install->install( $current_version );
74
-
75
- $date = new DateTime( 'now', $timezone = new DateTimeZone( 'UTC' ) );
76
- $date->modify('-3 month');
77
- $where = " AND `created` > STR_TO_DATE(" . $wpdb->prepare('%s', $date->format( 'Y-m-d H:i:s' )) . ", '%Y-%m-%d %H:%i:%s') ";
78
- $orderby = ' ORDER BY ID DESC ';
79
 
80
  $starting_row = 0;
81
  $rows_per_round = 5000;
@@ -87,7 +149,6 @@ function wp_mainwp_stream_update_auto_300( $db_version, $current_version ) {
87
  $context = $wpdb->get_row(
88
  $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_context_tmp WHERE record_id = %s LIMIT 1", $entry->ID )
89
  );
90
-
91
  $new_entry = array(
92
  'site_id' => $entry->site_id,
93
  'blog_id' => $entry->blog_id,
@@ -107,14 +168,21 @@ function wp_mainwp_stream_update_auto_300( $db_version, $current_version ) {
107
 
108
  $wpdb->insert( $wpdb->base_prefix . 'mainwp_stream', $new_entry );
109
 
 
 
 
 
 
 
 
 
 
110
  }
111
 
112
  $starting_row += $rows_per_round;
113
 
114
  $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_tmp WHERE 1 = 1 " . $where . $orderby . $wpdb->prepare( "LIMIT %d, %d", $starting_row, $rows_per_round ) );
115
  }
116
-
117
- $wpdb->query( "DROP TABLE {$wpdb->base_prefix}mainwp_stream_tmp, {$wpdb->base_prefix}mainwp_stream_context_tmp" );
118
-
119
  return $current_version;
120
  }
1
  <?php
2
+ /**
3
+ * Version 3.5.0
4
+ *
5
+ * To fix connector.
6
+ *
7
+ * @param string $db_version
8
+ * @param string $current_version
9
+ *
10
+ * @return string
11
+ */
12
+ function wp_mainwp_stream_update_auto_350($db_version, $current_version ) {
13
+
14
+ global $wpdb;
15
+
16
+ $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream" );
17
+ foreach ( $stream_entries as $entry ) {
18
+ $connector = $entry->connector;
19
+ $context = $entry->context;
20
+ $action = $entry->action;
21
+
22
+ if ( in_array( $connector, array('updraftplus_backups', 'backupbuddy_backups', 'backupwordpress_backups', 'backwpup_backups', 'wptimecapsule_backups') )) {
23
+ $context = 'backups';
24
+ $action = rtrim($connector, 's');
25
+ $connector = 'mainwp_backups';
26
+ }
27
+ else if ($connector == 'mainwp_maintenance')
28
+ {
29
+ $action = 'maintenance';
30
+ $context = 'mainwp_maintenance';
31
+ }
32
+ else if ($connector == 'mainwp_sucuri')
33
+ {
34
+ $action = 'sucuri_scan';
35
+ $context = 'sucuri_scan';
36
+ }
37
+ else if ($connector == 'wordfence_scan')
38
+ {
39
+ $action = 'wordfence_scan';
40
+ $context = 'wordfence_scan';
41
+ $connector = 'mainwp_wordfence';
42
+ }
43
+ else
44
+ {
45
+ continue;
46
+ }
47
+
48
+ $wpdb->update(
49
+ $wpdb->base_prefix . 'mainwp_stream', array(
50
+ 'connector' => $connector,
51
+ 'context' => $context,
52
+ 'action' => $action,
53
+ ), array(
54
+ 'ID' => $entry->ID,
55
+ )
56
+ );
57
+
58
+ }
59
+
60
+ return $current_version;
61
+
62
+ }
63
+
64
  /**
65
  * Version 3.0.8
66
  *
101
  'ID' => $entry->ID,
102
  )
103
  );
104
+ } else {
105
  $wpdb->update(
106
  $wpdb->base_prefix . 'mainwp_stream', array(
107
  'connector' => strtolower( $entry->connector ),
125
  *
126
  * @return string
127
  */
128
+ function wp_mainwp_stream_update_auto_300( $db_version, $current_version ) {
129
  global $wpdb;
130
 
131
  // Get only the author_meta values that are double-serialized
133
 
134
  $plugin = wp_mainwp_stream_get_instance();
135
  $plugin->install->install( $current_version );
136
+
137
+ $date = new DateTime( '2019-8-31 23:59:59', $timezone = new DateTimeZone( 'UTC' ) ); // fixed value, around 3 months ago
138
+
139
+ $where = " AND `created` > STR_TO_DATE(" . $wpdb->prepare('%s', $date->format( 'Y-m-d H:i:s' )) . ", '%Y-%m-%d %H:%i:%s') ";
140
+ $orderby = ' ORDER BY ID ASC '; // ASC importance
141
 
142
  $starting_row = 0;
143
  $rows_per_round = 5000;
149
  $context = $wpdb->get_row(
150
  $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_context_tmp WHERE record_id = %s LIMIT 1", $entry->ID )
151
  );
 
152
  $new_entry = array(
153
  'site_id' => $entry->site_id,
154
  'blog_id' => $entry->blog_id,
168
 
169
  $wpdb->insert( $wpdb->base_prefix . 'mainwp_stream', $new_entry );
170
 
171
+ if ( $new_insert_id = $wpdb->insert_id ) {
172
+ $wpdb->update(
173
+ $wpdb->base_prefix . 'mainwp_stream_meta', array(
174
+ 'record_id' => $new_insert_id,
175
+ ), array(
176
+ 'record_id' => $entry->ID,
177
+ )
178
+ );
179
+ }
180
  }
181
 
182
  $starting_row += $rows_per_round;
183
 
184
  $stream_entries = $wpdb->get_results( "SELECT * FROM {$wpdb->base_prefix}mainwp_stream_tmp WHERE 1 = 1 " . $where . $orderby . $wpdb->prepare( "LIMIT %d, %d", $starting_row, $rows_per_round ) );
185
  }
186
+ //$wpdb->query( "DROP TABLE {$wpdb->base_prefix}mainwp_stream_tmp, {$wpdb->base_prefix}mainwp_stream_context_tmp" );
 
 
187
  return $current_version;
188
  }
mainwp-child-reports.php CHANGED
@@ -5,7 +5,7 @@
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
9
  */
10
 
11
  /*
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.1
9
  */
10
 
11
  /*
readme.txt CHANGED
@@ -5,9 +5,9 @@ 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.3
9
  Requires PHP: 5.6
10
- Stable tag: 2.0
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -36,6 +36,9 @@ Credit to the [Stream Plugin](https://wordpress.org/plugins/stream/) which the M
36
 
37
  == Changelog ==
38
 
 
 
 
39
  = 2.0 - 12-9-2019 =
40
  * Added: support for the Pro Reports extension
41
  * Updated: plugin functionality for better performance
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 3.6
8
+ Tested up to: 5.3.1
9
  Requires PHP: 5.6
10
+ Stable tag: 2.0.1
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
36
 
37
  == Changelog ==
38
 
39
+ = 2.0.1 - 12-13-2019 =
40
+ * Fixed: data Child Reports conversion problem
41
+
42
  = 2.0 - 12-9-2019 =
43
  * Added: support for the Pro Reports extension
44
  * Updated: plugin functionality for better performance