MainWP Child Reports - Version 2.0.7

Version Description

  • 2-4-2021 =
  • Fixed: An issue with logging deleted plugins
  • Updated: exclusion rules for certain custom post types
Download this release

Release Info

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

Code changes from version 2.0.6 to 2.0.7

classes/class-mainwp-child-report-helper.php CHANGED
@@ -5,91 +5,92 @@ 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
- *
39
- * Run each time the class is called.
40
- *
41
- * @param null $plugin
42
- */
43
- function __construct( $plugin = null ) {
44
  $this->plugin = $plugin;
45
-
46
- add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
47
  add_filter( 'mainwp_wp_stream_settings_form_action', array( $this, 'settings_form_action' ) );
48
- add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hook_updraftplus_save_last_backup' ));
49
  // hmbkp_backup_complete
50
- add_action('mainwp_child_reports_log', array( __CLASS__, 'hook_reports_log' ), 10, 1);
51
  add_filter( 'all_plugins', array( $this, 'modify_plugin_header' ) );
52
  add_filter( 'plugin_row_meta', array( &$this, 'plugin_row_meta' ), 10, 2 );
53
- add_filter( 'wp_mainwp_stream_settings_option_fields', array( $this, 'get_hide_child_report_fields' ) );
54
- $this->init_branding_options();
55
  }
56
 
57
- /**
58
- * Method get_instance
59
- *
60
- * Create a public static instance.
61
- *
62
- * @static
63
- * @return MainWP_Child_Report_Helper
64
- */
65
- public static function get_instance() {
66
  if ( empty( self::$instance ) ) {
67
- $class = __CLASS__;
68
- self::$instance = new $class;
69
  }
70
 
71
  return self::$instance;
72
  }
73
 
74
- /**
75
- * Initiate admin menu.
76
- */
77
- public function admin_menu() {
78
- $opts = $this->branding_options;
79
- $hide = is_array($opts) && isset( $opts['hide_child_reports']) && ($opts['hide_child_reports'] == 'hide');
80
- if ( ! $hide ) {
81
- // Register settings page
82
- add_filter( 'mainwp_child_init_subpages', array( $this, 'init_subpages' ) );
83
  }
84
  }
85
 
86
- /**
87
- * Form settings action.
88
- *
89
- * @param array $action Action to perform.
90
- * @return array $action Action to perform.
91
- */
92
- function settings_form_action($action ) {
93
  if ( is_network_admin() ) {
94
  $current_page = wp_mainwp_stream_filter_input( INPUT_GET, 'page' );
95
  $action = add_query_arg( array( 'action' => $current_page ), 'edit.php' );
@@ -97,70 +98,70 @@ class MainWP_Child_Report_Helper {
97
  return $action;
98
  }
99
 
100
- /**
101
- * Initiate branding options.
102
- *
103
- * @return array|null Return branding options or Null.
104
- */
105
- public function init_branding_options() {
106
- return $this->get_branding_options();
107
- }
108
-
109
- /**
110
- * Get branding options.
111
- *
112
- * @return array|null Return branding options or Null.
113
- */
114
- public function get_branding_options() {
115
- if ( $this->branding_options === null ) {
116
-
117
- $opts = get_option( 'mainwp_child_branding_settings' ); // settings from mainwp-child plugin
118
- $cancelled_branding = false;
119
- $branding_header = array();
120
-
121
- // this is new update
122
- if ( is_array($opts) ) {
123
- if (isset($opts['cancelled_branding'])) { // if it was set
124
- $cancelled_branding = $opts['cancelled_branding'];
125
- } else {
126
- $disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
127
- $preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
128
- $cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding;
129
- $opts['cancelled_branding'] = $cancelled_branding;
130
- }
131
- $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
132
- } else { // to compatible will old code
133
- $opts = array();
134
- }
135
-
136
- if ( ! $cancelled_branding && ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) ) {
137
- $this->branding_title = stripslashes( $branding_header['name'] );
138
- } else {
139
- $this->branding_title = '';
140
- }
141
-
142
- $this->branding_options = $opts;
143
- }
144
-
145
- return $this->branding_options;
146
- }
147
-
148
-
149
- /**
150
- * Modify Plugin header.
151
- *
152
- * @param array $plugins Plugins array.
153
- * @return array Modified plugins array.
154
- */
155
- public function modify_plugin_header( $plugins ) {
156
- $_opts = $this->branding_options;
157
- $is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
158
- $cancelled_branding = isset( $_opts['cancelled_branding'] ) ? $_opts['cancelled_branding'] : false;
159
- $branding_header = isset( $_opts['branding_header'] ) ? $_opts['branding_header'] : '';
160
-
161
- if ( $cancelled_branding ) {
162
- return $plugins;
163
- }
164
 
165
  if ( 'T' === $is_hide ) {
166
  foreach ( $plugins as $key => $value ) {
@@ -179,14 +180,14 @@ class MainWP_Child_Report_Helper {
179
  }
180
  }
181
 
182
- /**
183
- * Update plugins header.
184
- *
185
- * @param array $plugins Plugins array.
186
- * @param string $header Header to update.
187
- * @return array Modified plugins array.
188
- */
189
- public function update_plugin_header($plugins, $header ) {
190
  $plugin_key = '';
191
  foreach ( $plugins as $key => $value ) {
192
  $plugin_slug = basename( $key, '.php' );
@@ -197,8 +198,8 @@ class MainWP_Child_Report_Helper {
197
  }
198
 
199
  if ( ! empty( $plugin_key ) ) {
200
- $plugin_data['Name'] = stripslashes( $header['name'] . " reports" );
201
- $plugin_data['Description'] = stripslashes( $header['description'] );
202
  $plugin_data['Author'] = stripslashes( $header['author'] );
203
  $plugin_data['AuthorURI'] = stripslashes( $header['authoruri'] );
204
  if ( ! empty( $header['pluginuri'] ) ) {
@@ -210,49 +211,49 @@ class MainWP_Child_Report_Helper {
210
  return $plugins;
211
  }
212
 
213
- /**
214
- * Check if branding is enabled.
215
- *
216
- * @return bool TRUE|FALSE.
217
- */
218
- public function is_branding() {
219
-
220
- $_opts = $this->branding_options;
221
- $is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
222
- $cancelled_branding = isset( $_opts['cancelled_branding'] ) ? $_opts['cancelled_branding'] : false;
223
- $branding_header = isset( $_opts['branding_header'] ) ? $_opts['branding_header'] : array();
224
-
225
- if ( $cancelled_branding ) {
226
- return false;
227
- }
228
- // hide.
229
- if ( 'T' === $is_hide ) {
230
- return true;
231
- }
232
- if ( is_array( $branding_header ) && !empty( $branding_header['name'] ) ) {
233
- return true;
234
- }
235
- return false;
236
-
237
- }
238
-
239
-
240
- /**
241
- * Plugin row meta.
242
- *
243
- * @param array $plugin_meta Plugin meta data.
244
- * @param string $plugin_file Plugin file.
245
- * @return array $plugin_meta Return pugin meta data array.
246
- */
247
- public function plugin_row_meta($plugin_meta, $plugin_file ) {
248
- if ( WP_MAINWP_STREAM_PLUGIN !== $plugin_file ) {
249
  return $plugin_meta;
250
  }
251
 
252
  if ( ! $this->is_branding() ) {
253
  return $plugin_meta;
254
  }
255
- // hide View details links
256
  $meta_total = count( $plugin_meta );
257
  for ( $i = 0; $i < $meta_total; $i++ ) {
258
  $str_meta = $plugin_meta[ $i ];
@@ -265,107 +266,124 @@ class MainWP_Child_Report_Helper {
265
  return $plugin_meta;
266
  }
267
 
268
- /**
269
- * Initiate subpages.
270
- *
271
- * @param array $subPages Subpages array.
272
- * @return array Return subpages array, or
273
- */
274
- public function init_subpages($subPages = array() ) {
275
-
276
- if ( is_network_admin() && ! is_plugin_active_for_network( WP_MAINWP_STREAM_PLUGIN ) ) {
277
- return $subPages;
278
- }
279
-
280
- $branding_text = $this->branding_title;
281
-
282
- if (empty($branding_text)) {
283
- $branding_text = 'Child Reports';
284
- } else {
285
- $branding_text = $branding_text . ' Reports';
286
- }
287
-
288
- $subPages[] = array('title' => $branding_text, 'slug' => 'reports-page' , 'callback' => array( $this, 'render_reports_page' ) , 'load_callback' => array( $this, 'register_list_table' ));
289
- $subPages[] = array('title' => $branding_text . ' Settings', 'slug' => 'reports-settings' , 'callback' => array( $this, 'render_settings_page' ) );
290
-
291
- return $subPages;
292
- }
293
-
294
- /**
295
- * Save UpdraftPlus last backup hook.
296
- *
297
- * @param array $last_backup last backup meta data.
298
- * @return array $last_backup last backup meta data.
299
- */
300
- public static function hook_updraftplus_save_last_backup( $last_backup ) {
301
-
302
- if (!is_array($last_backup))
 
 
 
 
 
 
 
 
 
303
  return $last_backup;
 
304
 
305
- if (isset($last_backup['backup_time'])) {
306
- if (empty($last_backup['success']))
307
- return $last_backup;
308
 
309
- $backup_time = $last_backup['backup_time'];
310
- $backup = $last_backup['backup_array'];
 
311
 
312
- $message = "";
313
- $backup_type = "";
314
- if (isset($backup['db'])) {
315
- $message .= "database, ";
316
- $backup_type .= "database, ";
317
- }
318
- if (isset($backup['plugins'])) {
319
- $message .= "plugins, ";
320
- $backup_type .= "plugins, ";
321
- }
322
 
323
- if (isset($backup['themes'])) {
324
- $message .= "themes, ";
325
- $backup_type .= "themes, ";
326
- }
327
 
328
- $message = rtrim($message, ', ');
329
- $message = "Updraftplus backup " . $message ." finished";
 
 
 
 
 
 
330
 
331
- $backup_type = rtrim($backup_type, ', ');
 
 
 
332
 
333
- $size = "N/A";
334
- if (isset($backup['db-size'])) {
335
- $size = $backup['db-size'];
336
- } else if (isset($backup['themes-size'])) {
337
- $size = $backup['themes-size'];
338
- }
339
- $destination = "";
 
 
340
 
341
- // to logging updraftplus backup
342
- do_action("updraftplus_backup", $destination , $message, __('Finished', 'mainwp-child-reports'), $backup_type, $backup_time);
 
 
 
 
 
 
 
343
  }
344
  return $last_backup;
345
  }
346
 
347
- /**
348
- * Reports log hook.
349
- *
350
- * @param string $ext_name Extension name.
351
- */
352
- public static function hook_reports_log( $ext_name = '') {
353
- do_action('mainwp_child_log', $ext_name);
354
  }
355
 
356
- /**
357
- * Hide Child Reports Fields.
358
- *
359
- * @param array $fields Fields array.
360
- * @return array $fields Return modified fields array.
361
- */
362
- public function get_hide_child_report_fields( $fields ) {
363
-
364
  $branding_text = $this->get_branding_title();
365
- $branding_name = !empty($branding_text) ? $branding_text : 'MainWP Child';
366
- $chkbox_label = 'Hide ' . $branding_name . ' Reports from reports';
367
- $chkbox_desc = 'If selected, the ' . $branding_name . ' Reports plugin will be left out from reports for this site.';
368
-
369
  $new_fields['general']['fields'][] = array(
370
  'name' => 'hide_child_plugins',
371
  'title' => $chkbox_label,
@@ -377,70 +395,71 @@ class MainWP_Child_Report_Helper {
377
 
378
  $fields = array_merge_recursive( $new_fields, $fields );
379
  return $fields;
380
-
381
  }
382
 
383
- /**
384
- * Register list table.
385
- *
386
- * @uses \WP_MainWP_Stream\List_Table
387
- */
388
- public function register_list_table() {
389
  $this->list_table = new List_Table(
390
- $this->plugin, array(
 
391
  'screen' => 'settings_page_' . $this->plugin->admin->records_page_slug,
392
  )
393
- );
394
  }
395
 
396
- /**
397
- * Render list table.
398
- */
399
- public function render_list_table() {
400
  $this->list_table->prepare_items();
401
  echo '<div class="mainwp_child_reports_wrap">';
402
  $this->list_table->display();
403
  echo '</div>';
404
  }
405
 
406
- /**
407
- * Render reports page.
408
- */
409
- public function render_reports_page() {
410
- do_action('mainwp-child-pageheader', 'reports-page');
411
- $this->render_list_table();
412
- do_action('mainwp-child-pagefooter', 'reports-page');
413
  }
414
 
415
- /**
416
- * Render settings page.
417
- */
418
- public function render_settings_page() {
419
  $option_key = $this->plugin->settings->option_key;
420
- $form_action = apply_filters( 'mainwp_wp_stream_settings_form_action', admin_url( 'options.php' ) );
421
- do_action('mainwp-child-pageheader', 'reports-settings');
422
  ?>
423
  <div class="postbox">
424
  <div class="inside">
425
- <form method="post" action="<?php echo esc_attr( $form_action ) ?>" enctype="multipart/form-data">
426
- <?php
427
  settings_fields( $option_key );
428
- do_settings_sections( $option_key );
429
  submit_button();
430
  ?>
431
  </form>
432
  </div>
433
  </div>
434
- <?php
435
- do_action('mainwp-child-pagefooter', 'reports-settings');
436
  }
437
 
438
- /**
439
- * Get branding title.
440
- *
441
- * @return string|null Return branding title or Null
442
- */
443
- public function get_branding_title() {
444
  return $this->branding_title;
445
  }
446
- }
5
 
6
  /**
7
  * Class MainWP_Child_Report_Helper.
8
+ *
9
  * @package WP_MainWP_Stream
10
  */
11
  class MainWP_Child_Report_Helper {
12
 
13
+ /**
14
+ * Public static variable to hold the single instance of the class.
15
+ *
16
+ * @var object $instance
17
+ */
18
+ public static $instance;
19
+
20
+ /**
21
+ * @var null Child Site branding options.
22
+ */
23
+ public $branding_options = null;
24
+
25
+ /** @var string Child Site branding title. */
26
+ public $branding_title = null;
27
+
28
+ /** @var array Settings fields. */
29
+ public $setting_fields = array();
30
+
31
+ /** @var string Plugin slug. */
32
+ public $plugin;
33
+
34
+ /** @var array List table array. */
35
+ public $list_table = null;
36
+
37
+ /**
38
+ * MainWP_Child_Report_Helper constructor.
39
+ *
40
+ * Run each time the class is called.
41
+ *
42
+ * @param null $plugin
43
+ */
44
+ function __construct( $plugin = null ) {
45
  $this->plugin = $plugin;
46
+
47
+ add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
48
  add_filter( 'mainwp_wp_stream_settings_form_action', array( $this, 'settings_form_action' ) );
49
+ add_filter( 'updraftplus_save_last_backup', array( __CLASS__, 'hook_updraftplus_save_last_backup' ) );
50
  // hmbkp_backup_complete
51
+ add_action( 'mainwp_child_reports_log', array( __CLASS__, 'hook_reports_log' ), 10, 1 );
52
  add_filter( 'all_plugins', array( $this, 'modify_plugin_header' ) );
53
  add_filter( 'plugin_row_meta', array( &$this, 'plugin_row_meta' ), 10, 2 );
54
+ add_filter( 'wp_mainwp_stream_settings_option_fields', array( $this, 'get_hide_child_report_fields' ) );
55
+ $this->init_branding_options();
56
  }
57
 
58
+ /**
59
+ * Method get_instance
60
+ *
61
+ * Create a public static instance.
62
+ *
63
+ * @static
64
+ * @return MainWP_Child_Report_Helper
65
+ */
66
+ public static function get_instance() {
67
  if ( empty( self::$instance ) ) {
68
+ $class = __CLASS__;
69
+ self::$instance = new $class();
70
  }
71
 
72
  return self::$instance;
73
  }
74
 
75
+ /**
76
+ * Initiate admin menu.
77
+ */
78
+ public function admin_menu() {
79
+ $opts = $this->branding_options;
80
+ $hide = is_array( $opts ) && isset( $opts['hide_child_reports'] ) && ( $opts['hide_child_reports'] == 'hide' );
81
+ if ( ! $hide ) {
82
+ // Register settings page
83
+ add_filter( 'mainwp_child_init_subpages', array( $this, 'init_subpages' ) );
84
  }
85
  }
86
 
87
+ /**
88
+ * Form settings action.
89
+ *
90
+ * @param array $action Action to perform.
91
+ * @return array $action Action to perform.
92
+ */
93
+ function settings_form_action( $action ) {
94
  if ( is_network_admin() ) {
95
  $current_page = wp_mainwp_stream_filter_input( INPUT_GET, 'page' );
96
  $action = add_query_arg( array( 'action' => $current_page ), 'edit.php' );
98
  return $action;
99
  }
100
 
101
+ /**
102
+ * Initiate branding options.
103
+ *
104
+ * @return array|null Return branding options or Null.
105
+ */
106
+ public function init_branding_options() {
107
+ return $this->get_branding_options();
108
+ }
109
+
110
+ /**
111
+ * Get branding options.
112
+ *
113
+ * @return array|null Return branding options or Null.
114
+ */
115
+ public function get_branding_options() {
116
+ if ( $this->branding_options === null ) {
117
+
118
+ $opts = get_option( 'mainwp_child_branding_settings' ); // settings from mainwp-child plugin
119
+ $cancelled_branding = false;
120
+ $branding_header = array();
121
+
122
+ // this is new update
123
+ if ( is_array( $opts ) ) {
124
+ if ( isset( $opts['cancelled_branding'] ) ) { // if it was set
125
+ $cancelled_branding = $opts['cancelled_branding'];
126
+ } else {
127
+ $disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
128
+ $preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
129
+ $cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding;
130
+ $opts['cancelled_branding'] = $cancelled_branding;
131
+ }
132
+ $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
133
+ } else { // to compatible will old code
134
+ $opts = array();
135
+ }
136
+
137
+ if ( ! $cancelled_branding && ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) ) {
138
+ $this->branding_title = stripslashes( $branding_header['name'] );
139
+ } else {
140
+ $this->branding_title = '';
141
+ }
142
+
143
+ $this->branding_options = $opts;
144
+ }
145
+
146
+ return $this->branding_options;
147
+ }
148
+
149
+
150
+ /**
151
+ * Modify Plugin header.
152
+ *
153
+ * @param array $plugins Plugins array.
154
+ * @return array Modified plugins array.
155
+ */
156
+ public function modify_plugin_header( $plugins ) {
157
+ $_opts = $this->branding_options;
158
+ $is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
159
+ $cancelled_branding = isset( $_opts['cancelled_branding'] ) ? $_opts['cancelled_branding'] : false;
160
+ $branding_header = isset( $_opts['branding_header'] ) ? $_opts['branding_header'] : '';
161
+
162
+ if ( $cancelled_branding ) {
163
+ return $plugins;
164
+ }
165
 
166
  if ( 'T' === $is_hide ) {
167
  foreach ( $plugins as $key => $value ) {
180
  }
181
  }
182
 
183
+ /**
184
+ * Update plugins header.
185
+ *
186
+ * @param array $plugins Plugins array.
187
+ * @param string $header Header to update.
188
+ * @return array Modified plugins array.
189
+ */
190
+ public function update_plugin_header( $plugins, $header ) {
191
  $plugin_key = '';
192
  foreach ( $plugins as $key => $value ) {
193
  $plugin_slug = basename( $key, '.php' );
198
  }
199
 
200
  if ( ! empty( $plugin_key ) ) {
201
+ $plugin_data['Name'] = stripslashes( $header['name'] . ' reports' );
202
+ $plugin_data['Description'] = stripslashes( $header['description'] );
203
  $plugin_data['Author'] = stripslashes( $header['author'] );
204
  $plugin_data['AuthorURI'] = stripslashes( $header['authoruri'] );
205
  if ( ! empty( $header['pluginuri'] ) ) {
211
  return $plugins;
212
  }
213
 
214
+ /**
215
+ * Check if branding is enabled.
216
+ *
217
+ * @return bool TRUE|FALSE.
218
+ */
219
+ public function is_branding() {
220
+
221
+ $_opts = $this->branding_options;
222
+ $is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
223
+ $cancelled_branding = isset( $_opts['cancelled_branding'] ) ? $_opts['cancelled_branding'] : false;
224
+ $branding_header = isset( $_opts['branding_header'] ) ? $_opts['branding_header'] : array();
225
+
226
+ if ( $cancelled_branding ) {
227
+ return false;
228
+ }
229
+ // hide.
230
+ if ( 'T' === $is_hide ) {
231
+ return true;
232
+ }
233
+ if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
234
+ return true;
235
+ }
236
+ return false;
237
+
238
+ }
239
+
240
+
241
+ /**
242
+ * Plugin row meta.
243
+ *
244
+ * @param array $plugin_meta Plugin meta data.
245
+ * @param string $plugin_file Plugin file.
246
+ * @return array $plugin_meta Return pugin meta data array.
247
+ */
248
+ public function plugin_row_meta( $plugin_meta, $plugin_file ) {
249
+ if ( WP_MAINWP_STREAM_PLUGIN !== $plugin_file ) {
250
  return $plugin_meta;
251
  }
252
 
253
  if ( ! $this->is_branding() ) {
254
  return $plugin_meta;
255
  }
256
+ // hide View details links
257
  $meta_total = count( $plugin_meta );
258
  for ( $i = 0; $i < $meta_total; $i++ ) {
259
  $str_meta = $plugin_meta[ $i ];
266
  return $plugin_meta;
267
  }
268
 
269
+ /**
270
+ * Initiate subpages.
271
+ *
272
+ * @param array $subPages Subpages array.
273
+ * @return array Return subpages array, or
274
+ */
275
+ public function init_subpages( $subPages = array() ) {
276
+
277
+ if ( is_network_admin() && ! is_plugin_active_for_network( WP_MAINWP_STREAM_PLUGIN ) ) {
278
+ return $subPages;
279
+ }
280
+
281
+ $branding_text = $this->branding_title;
282
+
283
+ if ( empty( $branding_text ) ) {
284
+ $branding_text = 'Child Reports';
285
+ } else {
286
+ $branding_text = $branding_text . ' Reports';
287
+ }
288
+
289
+ $subPages[] = array(
290
+ 'title' => $branding_text,
291
+ 'slug' => 'reports-page',
292
+ 'callback' => array( $this, 'render_reports_page' ),
293
+ 'load_callback' => array( $this, 'register_list_table' ),
294
+ );
295
+ $subPages[] = array(
296
+ 'title' => $branding_text . ' Settings',
297
+ 'slug' => 'reports-settings',
298
+ 'callback' => array( $this, 'render_settings_page' ),
299
+ );
300
+
301
+ return $subPages;
302
+ }
303
+
304
+ /**
305
+ * Save UpdraftPlus last backup hook.
306
+ *
307
+ * @param array $last_backup last backup meta data.
308
+ * @return array $last_backup last backup meta data.
309
+ */
310
+ public static function hook_updraftplus_save_last_backup( $last_backup ) {
311
+
312
+ if ( ! is_array( $last_backup ) ) {
313
  return $last_backup;
314
+ }
315
 
316
+ if ( isset( $last_backup['backup_time'] ) ) {
 
 
317
 
318
+ if ( empty( $last_backup['success'] ) ) {
319
+ return $last_backup;
320
+ }
321
 
322
+ $backup_time = $last_backup['backup_time'];
323
+ $backup = $last_backup['backup_array'];
 
 
 
 
 
 
 
 
324
 
325
+ $message = '';
326
+ $backup_type = '';
 
 
327
 
328
+ if ( isset( $backup['db'] ) ) {
329
+ $message .= __( 'database', 'mainwp-child-reports' ) . ', ';
330
+ $backup_type .= __( 'database', 'mainwp-child-reports' ) . ', ';
331
+ }
332
+ if ( isset( $backup['plugins'] ) ) {
333
+ $message .= __( 'plugins', 'mainwp-child-reports' ) . ', ';
334
+ $backup_type .= __( 'plugins', 'mainwp-child-reports' ) . ', ';
335
+ }
336
 
337
+ if ( isset( $backup['themes'] ) ) {
338
+ $message .= __( 'themes', 'mainwp-child-reports' ) . ', ';
339
+ $backup_type .= __( 'themes', 'mainwp-child-reports' ) . ', ';
340
+ }
341
 
342
+ if ( isset( $backup['uploads'] ) && ! empty( $backup['uploads-size'] ) ) {
343
+ $message .= __( 'uploads', 'mainwp-child-reports' ) . ', ';
344
+ $backup_type .= __( 'uploads', 'mainwp-child-reports' ) . ', ';
345
+ }
346
+
347
+ if ( isset( $backup['others'] ) && ! empty( $backup['others-size'] ) ) {
348
+ $message .= __( 'others', 'mainwp-child-reports' ) . ', ';
349
+ $backup_type .= __( 'others', 'mainwp-child-reports' ) . ', ';
350
+ }
351
 
352
+ $message = rtrim( $message, ', ' );
353
+ $message = __( 'Updraftplus backup', 'mainwp-child-reports' ) . ' ' . $message . ' ' . __( 'finished', 'mainwp-child-reports' );
354
+
355
+ $backup_type = rtrim( $backup_type, ', ' );
356
+
357
+ $destination = '';
358
+
359
+ // to logging updraftplus backup
360
+ do_action( 'updraftplus_backup', $destination, $message, __( 'Finished', 'mainwp-child-reports' ), $backup_type, $backup_time );
361
  }
362
  return $last_backup;
363
  }
364
 
365
+ /**
366
+ * Reports log hook.
367
+ *
368
+ * @param string $ext_name Extension name.
369
+ */
370
+ public static function hook_reports_log( $ext_name = '' ) {
371
+ do_action( 'mainwp_child_log', $ext_name );
372
  }
373
 
374
+ /**
375
+ * Hide Child Reports Fields.
376
+ *
377
+ * @param array $fields Fields array.
378
+ * @return array $fields Return modified fields array.
379
+ */
380
+ public function get_hide_child_report_fields( $fields ) {
381
+
382
  $branding_text = $this->get_branding_title();
383
+ $branding_name = ! empty( $branding_text ) ? $branding_text : 'MainWP Child';
384
+ $chkbox_label = 'Hide ' . $branding_name . ' Reports from reports';
385
+ $chkbox_desc = 'If selected, the ' . $branding_name . ' Reports plugin will be left out from reports for this site.';
386
+
387
  $new_fields['general']['fields'][] = array(
388
  'name' => 'hide_child_plugins',
389
  'title' => $chkbox_label,
395
 
396
  $fields = array_merge_recursive( $new_fields, $fields );
397
  return $fields;
398
+
399
  }
400
 
401
+ /**
402
+ * Register list table.
403
+ *
404
+ * @uses \WP_MainWP_Stream\List_Table
405
+ */
406
+ public function register_list_table() {
407
  $this->list_table = new List_Table(
408
+ $this->plugin,
409
+ array(
410
  'screen' => 'settings_page_' . $this->plugin->admin->records_page_slug,
411
  )
412
+ );
413
  }
414
 
415
+ /**
416
+ * Render list table.
417
+ */
418
+ public function render_list_table() {
419
  $this->list_table->prepare_items();
420
  echo '<div class="mainwp_child_reports_wrap">';
421
  $this->list_table->display();
422
  echo '</div>';
423
  }
424
 
425
+ /**
426
+ * Render reports page.
427
+ */
428
+ public function render_reports_page() {
429
+ do_action( 'mainwp-child-pageheader', 'reports-page' );
430
+ $this->render_list_table();
431
+ do_action( 'mainwp-child-pagefooter', 'reports-page' );
432
  }
433
 
434
+ /**
435
+ * Render settings page.
436
+ */
437
+ public function render_settings_page() {
438
  $option_key = $this->plugin->settings->option_key;
439
+ $form_action = apply_filters( 'mainwp_wp_stream_settings_form_action', admin_url( 'options.php' ) );
440
+ do_action( 'mainwp-child-pageheader', 'reports-settings' );
441
  ?>
442
  <div class="postbox">
443
  <div class="inside">
444
+ <form method="post" action="<?php echo esc_attr( $form_action ); ?>" enctype="multipart/form-data">
445
+ <?php
446
  settings_fields( $option_key );
447
+ do_settings_sections( $option_key );
448
  submit_button();
449
  ?>
450
  </form>
451
  </div>
452
  </div>
453
+ <?php
454
+ do_action( 'mainwp-child-pagefooter', 'reports-settings' );
455
  }
456
 
457
+ /**
458
+ * Get branding title.
459
+ *
460
+ * @return string|null Return branding title or Null
461
+ */
462
+ public function get_branding_title() {
463
  return $this->branding_title;
464
  }
465
+ }
connectors/class-connector-installer.php CHANGED
@@ -5,6 +5,7 @@ namespace WP_MainWP_Stream;
5
 
6
  /**
7
  * Class Connector_Installer
 
8
  * @package WP_MainWP_Stream
9
  *
10
  * @uses \WP_MainWP_Stream\Connector
@@ -23,17 +24,17 @@ class Connector_Installer extends Connector {
23
  'switch_theme', // themes::activated
24
  'delete_site_transient_update_themes', // themes::deleted
25
  'pre_option_uninstall_plugins', // plugins::deleted
26
- 'pre_set_site_transient_update_plugins',
 
27
  '_core_updated_successfully',
28
  'mainwp_child_installPluginTheme',
29
  'mainwp_child_plugin_action',
30
  'mainwp_child_theme_action',
31
- //'mainwp_child_upgradePluginTheme'
32
  );
33
 
34
- /** @var array Old plugins array. */
35
- public $old_plugins = array();
36
-
37
  /** @var bool Register connector in the WP Frontend. */
38
  public $register_frontend = false;
39
 
@@ -121,7 +122,7 @@ class Connector_Installer extends Connector {
121
  * @action transition_post_status.
122
  *
123
  * @param \WP_Upgrader $upgrader WP_Upgrader class object.
124
- * @param array $extra Extra attributes array.
125
  *
126
  * @return bool Return TRUE|FALSE.
127
  */
@@ -143,7 +144,7 @@ class Connector_Installer extends Connector {
143
 
144
  $type = $extra['type'];
145
  $action = $extra['action'];
146
-
147
  if ( ! in_array( $type, array( 'plugin', 'theme' ), true ) ) {
148
  return false;
149
  }
@@ -199,28 +200,27 @@ class Connector_Installer extends Connector {
199
  $slugs = array( $upgrader->skin->plugin );
200
  }
201
 
202
- //$_plugins = $this->get_plugins();
203
 
204
  foreach ( $slugs as $slug ) {
205
  $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $slug );
206
  $name = $plugin_data['Name'];
207
  $version = $plugin_data['Version'];
208
- //$old_version = $_plugins[ $slug ]['Version'];
209
-
210
- //( Net-Concept - Xavier NUEL ) : get old versions.
211
- if (isset($this->old_plugins[$slug])) {
212
- $old_version = $this->old_plugins[$slug]['Version'];
213
  } else {
214
- //$old_version = ''; // Hummm... will this happen ?
215
  $old_version = $upgrader->skin->plugin_info['Version']; // to fix old version
216
- }
217
-
218
- if (version_compare($version, $old_version, '>')) {
219
- $logs[] = compact('slug', 'name', 'old_version', 'version', 'message', 'action');
220
  }
221
-
222
 
223
- //$logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
 
 
 
 
224
  }
225
  } else { // theme
226
  if ( isset( $extra['bulk'] ) && true === $extra['bulk'] ) {
@@ -230,16 +230,17 @@ class Connector_Installer extends Connector {
230
  }
231
 
232
  foreach ( $slugs as $slug ) {
233
- $theme = wp_get_theme( $slug );
234
- $stylesheet = $theme['Stylesheet Dir'] . '/style.css';
235
- $theme_data = get_file_data(
236
- $stylesheet, array(
 
237
  'Version' => 'Version',
238
  )
239
  );
240
- $name = $theme['Name'];
241
- //$old_version = $theme['Version'];
242
- $old_version = $upgrader->skin->theme_info->get('Version'); // to fix old version //$theme['Version'];
243
  $version = $theme_data['Version'];
244
 
245
  $logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
@@ -271,20 +272,21 @@ class Connector_Installer extends Connector {
271
  return true;
272
  }
273
 
274
- /**
275
- * Activate plugin callback.
276
- *
277
- * @param string $slug Plugin slug.
278
- * @param $network_wide Check if network wide.
279
- */
280
- public function callback_activate_plugin($slug, $network_wide ) {
281
  $_plugins = $this->get_plugins();
282
  $name = $_plugins[ $slug ]['Name'];
283
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
284
-
285
- if (empty($name))
286
  return;
287
-
 
288
  $this->log(
289
  // 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)
290
  _x(
@@ -299,13 +301,13 @@ class Connector_Installer extends Connector {
299
  );
300
  }
301
 
302
- /** Decativate plugin callback.
303
- *
304
- * @param string $slug Plugin slug.
305
- * @param $network_wide Check if network wide.
306
- */
307
- public function callback_deactivate_plugin($slug, $network_wide ) {
308
- $_plugins = $this->get_plugins();
309
  $name = $_plugins[ $slug ]['Name'];
310
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
311
 
@@ -323,13 +325,13 @@ class Connector_Installer extends Connector {
323
  );
324
  }
325
 
326
- /**
327
- * Switch theme callback.
328
- *
329
- * @param string $name Theme name.
330
- * @param string $theme Theme slug.
331
- */
332
- public function callback_switch_theme($name, $theme ) {
333
  unset( $theme );
334
  $this->log(
335
  // translators: Placeholder refers to a theme name (e.g. "Twenty Seventeen").
@@ -342,8 +344,8 @@ class Connector_Installer extends Connector {
342
  }
343
 
344
  /**
345
- * Update theme & transient delete callback.
346
- *
347
  * @todo Core needs a delete_theme hook
348
  */
349
  public function callback_delete_site_transient_update_themes() {
@@ -375,84 +377,69 @@ class Connector_Installer extends Connector {
375
  }
376
 
377
  /**
378
- * Uninstall plugins callback.
379
- *
380
  * @todo Core needs an uninstall_plugin hook
381
  * @todo This does not work in WP-CLI
382
  */
383
  public function callback_pre_option_uninstall_plugins() {
384
- if (
385
- 'delete-selected' !== wp_mainwp_stream_filter_input( INPUT_GET, 'action' )
386
- &&
387
- 'delete-selected' !== wp_mainwp_stream_filter_input( INPUT_POST, 'action2' )
388
- ) {
389
  return false;
390
  }
391
-
392
- // @codingStandardsIgnoreStart
393
- $type = isset( $_POST['action2'] ) ? INPUT_POST : INPUT_GET;
394
- // @codingStandardsIgnoreEnd
395
-
396
- $plugins = wp_mainwp_stream_filter_input( $type, 'checked' );
397
- $_plugins = $this->get_plugins();
398
-
399
- $plugins_to_delete = array();
400
-
401
- foreach ( (array) $plugins as $plugin ) {
402
- $plugins_to_delete[ $plugin ] = $_plugins[ $plugin ];
403
- }
404
-
405
  update_option( 'wp_mainwp_stream_plugins_to_delete', $plugins_to_delete );
406
-
407
  return false;
408
  }
409
 
410
  /**
411
- * Pre set site transient update plugins callback.
412
- *
413
- * @param mixed $value
414
  *
415
- * @return mixed
416
- *
417
- * @todo Core needs a delete_plugin hook
418
  * @todo This does not work in WP-CLI
419
  */
420
- public function callback_pre_set_site_transient_update_plugins( $value ) {
421
- $plugins_to_delete = get_option( 'wp_mainwp_stream_plugins_to_delete' );
422
- if ( ! wp_mainwp_stream_filter_input( INPUT_POST, 'verify-delete' ) || ! $plugins_to_delete ) {
423
- return $value;
424
- }
425
-
426
- foreach ( $plugins_to_delete as $plugin => $data ) {
427
- $name = $data['Name'];
428
- $network_wide = $data['Network'] ? esc_html__( 'network wide', 'mainwp-child-reports' ) : '';
429
 
430
- $this->log(
431
- // translators: Placeholder refers to a plugin name (e.g. "Stream").
432
- __( '"%s" plugin deleted', 'mainwp-child-reports' ),
433
- compact( 'name', 'plugin', 'network_wide' ),
434
- null,
435
- 'plugins',
436
- 'deleted'
437
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  }
439
-
440
- delete_option( 'wp_mainwp_stream_plugins_to_delete' );
441
-
442
- return $value;
443
  }
444
 
445
- /**
446
- * Core updated successfully callback.
447
- *
448
- * @param $new_version New WordPress verison.
449
- */
450
- public function callback__core_updated_successfully($new_version ) {
451
-
452
- /**
453
- * @global string $pagenow Current page.
454
- * @global string $wp_version WordPress version.
455
- */
456
  global $pagenow, $wp_version;
457
 
458
  $old_version = $wp_version;
@@ -470,25 +457,26 @@ class Connector_Installer extends Connector {
470
  $message,
471
  compact( 'new_version', 'old_version', 'auto_updated' ),
472
  null,
473
- 'wordpress',
474
  'updated'
475
  );
476
  }
477
 
478
- /**
479
- * Child Site install Plugin or theme callback.
480
- *
481
- * @param array $args Success message.
482
- * @return bool|void Return FALSE on failure.
483
- */
484
- public function callback_mainwp_child_installPluginTheme( $args ) {
485
-
486
- $logs = array();
487
- $success = isset($args['success']) ? $args['success'] : 0;
488
  $error = null;
489
 
490
  if ( ! $success ) {
491
- $errors = $args['errors'];;
 
492
  }
493
 
494
  // This would have failed down the road anyway
@@ -504,14 +492,15 @@ class Connector_Installer extends Connector {
504
  }
505
 
506
  if ( 'install' === $action ) {
507
- if ( 'plugin' === $type) {
508
- if ( !isset($args['Name']) || empty($args['Name']))
509
- return;
 
510
  $slug = $args['slug'];
511
  $name = $args['Name'];
512
  $version = $args['Version'];
513
  } else { // theme
514
- $slug = $args['slug'];
515
  if ( ! $slug ) {
516
  return;
517
  }
@@ -532,132 +521,76 @@ class Connector_Installer extends Connector {
532
  }
533
 
534
  $context = $type . 's';
535
-
536
  foreach ( $logs as $log ) {
537
  $name = isset( $log['name'] ) ? $log['name'] : null;
538
  $version = isset( $log['version'] ) ? $log['version'] : null;
539
  $slug = isset( $log['slug'] ) ? $log['slug'] : null;
540
  $old_version = isset( $log['old_version'] ) ? $log['old_version'] : null;
541
  $message = isset( $log['message'] ) ? $log['message'] : null;
542
- $action = isset( $log['action'] ) ? $log['action'] : null;
543
  $this->log(
544
  $message,
545
  compact( 'type', 'name', 'version', 'slug', 'success', 'error', 'old_version' ),
546
  null,
547
  $context,
548
- $action
549
  );
550
  }
551
  }
552
 
553
 
554
- /**
555
- * MainWP Plugin Action callback.
556
- *
557
- * @param $args Action arguments.
558
- */
559
- public function callback_mainwp_child_plugin_action( $args ) {
560
- if (!is_array($args) || !isset($args['action']))
561
- return;
562
- $action = $args['action'];
563
- if ($action == 'delete') {
564
- $name = $args['Name'];
565
- $network_wide = '';
566
- $this->log(
567
- __( '"%s" plugin deleted', 'mainwp-child-reports' ),
568
- compact( 'name', 'plugin' ),
569
- null,
570
- 'plugins',
571
- 'deleted'
572
- );
573
- }
 
574
  }
575
 
576
- /**
577
- * MainWP Child Theme action callback.
578
- *
579
- * @param string $args MainWP Child Theme action.
580
- */
581
- public function callback_mainwp_child_theme_action($args) {
582
- if (!is_array($args) || !isset($args['action']))
583
- return;
584
- $action = $args['action'];
585
- $name = $args['Name'];
586
- if ($action == 'delete') {
587
- $this->log(
588
- __( '"%s" theme deleted', 'mainwp-child-reports' ),
589
- compact( 'name' ),
590
- null,
591
- 'themes',
592
- 'deleted'
593
- );
594
- }
 
595
  }
596
-
597
  // ( Net-Concept - Xavier NUEL ) : save all plugins versions before upgrade.
598
 
599
- /**
600
- * Upgrader pre-instaler callback.
601
- */
602
- public function callback_upgrader_pre_install() {
603
- $this->old_plugins = $this->get_plugins();
604
  }
605
-
606
- // public function callback_mainwp_child_upgradePluginTheme( $extra ) {
607
- // $logs = array();
608
- //
609
- // if ( ! isset( $extra['type'] ) ) {
610
- // return false;
611
- // }
612
- //
613
- // $type = $extra['type'];
614
- // $action = $extra['action'];
615
- //
616
- // if ( ! in_array( $type, array( 'plugin', 'theme' ) ) ) {
617
- // return;
618
- // }
619
- //
620
- // if ( 'update' === $action ) {
621
- // if ( 'plugin' === $type ) {
622
- // $slug = $extra['slug'];
623
- // $name = $extra['name'];
624
- // $version = $extra['version'];
625
- // $old_version = $extra['old_version'];
626
- // } else { // theme
627
- // $name = $extra['name'];
628
- // $version = $extra['version'];
629
- // $old_version = $extra['old_version'];
630
- // }
631
- //
632
- // $action = 'updated';
633
- // $message = _x(
634
- // 'Updated %1$s: %2$s %3$s',
635
- // 'Plugin/theme update. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
636
- // 'mainwp_child_reports'
637
- // );
638
- // $logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
639
- // } else {
640
- // return false;
641
- // }
642
- //
643
- // $context = $type . 's';
644
- //
645
- // foreach ( $logs as $log ) {
646
- // $name = isset( $log['name'] ) ? $log['name'] : null;
647
- // $version = isset( $log['version'] ) ? $log['version'] : null;
648
- // $slug = isset( $log['slug'] ) ? $log['slug'] : null;
649
- // $old_version = isset( $log['old_version'] ) ? $log['old_version'] : null;
650
- // $message = isset( $log['message'] ) ? $log['message'] : null;
651
- // $action = isset( $log['action'] ) ? $log['action'] : null;
652
- // $this->log(
653
- // $message,
654
- // compact( 'type', 'name', 'version', 'slug', 'success', 'error', 'old_version' ),
655
- // null,
656
- // $context,
657
- // $action
658
- // );
659
- // }
660
- // }
661
-
662
-
663
  }
5
 
6
  /**
7
  * Class Connector_Installer
8
+ *
9
  * @package WP_MainWP_Stream
10
  *
11
  * @uses \WP_MainWP_Stream\Connector
24
  'switch_theme', // themes::activated
25
  'delete_site_transient_update_themes', // themes::deleted
26
  'pre_option_uninstall_plugins', // plugins::deleted
27
+ 'deleted_plugin',
28
+ // 'pre_set_site_transient_update_plugins',
29
  '_core_updated_successfully',
30
  'mainwp_child_installPluginTheme',
31
  'mainwp_child_plugin_action',
32
  'mainwp_child_theme_action',
 
33
  );
34
 
35
+ /** @var array Old plugins array. */
36
+ public $old_plugins = array();
37
+
38
  /** @var bool Register connector in the WP Frontend. */
39
  public $register_frontend = false;
40
 
122
  * @action transition_post_status.
123
  *
124
  * @param \WP_Upgrader $upgrader WP_Upgrader class object.
125
+ * @param array $extra Extra attributes array.
126
  *
127
  * @return bool Return TRUE|FALSE.
128
  */
144
 
145
  $type = $extra['type'];
146
  $action = $extra['action'];
147
+
148
  if ( ! in_array( $type, array( 'plugin', 'theme' ), true ) ) {
149
  return false;
150
  }
200
  $slugs = array( $upgrader->skin->plugin );
201
  }
202
 
203
+ // $_plugins = $this->get_plugins();
204
 
205
  foreach ( $slugs as $slug ) {
206
  $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $slug );
207
  $name = $plugin_data['Name'];
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 {
215
+ // $old_version = ''; // Hummm... will this happen ?
216
  $old_version = $upgrader->skin->plugin_info['Version']; // to fix old version
 
 
 
 
217
  }
 
218
 
219
+ if ( version_compare( $version, $old_version, '>' ) ) {
220
+ $logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
221
+ }
222
+
223
+ // $logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
224
  }
225
  } else { // theme
226
  if ( isset( $extra['bulk'] ) && true === $extra['bulk'] ) {
230
  }
231
 
232
  foreach ( $slugs as $slug ) {
233
+ $theme = wp_get_theme( $slug );
234
+ $stylesheet = $theme['Stylesheet Dir'] . '/style.css';
235
+ $theme_data = get_file_data(
236
+ $stylesheet,
237
+ array(
238
  'Version' => 'Version',
239
  )
240
  );
241
+ $name = $theme['Name'];
242
+ // $old_version = $theme['Version'];
243
+ $old_version = $upgrader->skin->theme_info->get( 'Version' ); // to fix old version //$theme['Version'];
244
  $version = $theme_data['Version'];
245
 
246
  $logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
272
  return true;
273
  }
274
 
275
+ /**
276
+ * Activate plugin callback.
277
+ *
278
+ * @param string $slug Plugin slug.
279
+ * @param $network_wide Check if network wide.
280
+ */
281
+ public function callback_activate_plugin( $slug, $network_wide ) {
282
  $_plugins = $this->get_plugins();
283
  $name = $_plugins[ $slug ]['Name'];
284
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
285
+
286
+ if ( empty( $name ) ) {
287
  return;
288
+ }
289
+
290
  $this->log(
291
  // 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)
292
  _x(
301
  );
302
  }
303
 
304
+ /** Decativate plugin callback.
305
+ *
306
+ * @param string $slug Plugin slug.
307
+ * @param $network_wide Check if network wide.
308
+ */
309
+ public function callback_deactivate_plugin( $slug, $network_wide ) {
310
+ $_plugins = $this->get_plugins();
311
  $name = $_plugins[ $slug ]['Name'];
312
  $network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child-reports' ) : null;
313
 
325
  );
326
  }
327
 
328
+ /**
329
+ * Switch theme callback.
330
+ *
331
+ * @param string $name Theme name.
332
+ * @param string $theme Theme slug.
333
+ */
334
+ public function callback_switch_theme( $name, $theme ) {
335
  unset( $theme );
336
  $this->log(
337
  // translators: Placeholder refers to a theme name (e.g. "Twenty Seventeen").
344
  }
345
 
346
  /**
347
+ * Update theme & transient delete callback.
348
+ *
349
  * @todo Core needs a delete_theme hook
350
  */
351
  public function callback_delete_site_transient_update_themes() {
377
  }
378
 
379
  /**
380
+ * Uninstall plugins callback.
381
+ *
382
  * @todo Core needs an uninstall_plugin hook
383
  * @todo This does not work in WP-CLI
384
  */
385
  public function callback_pre_option_uninstall_plugins() {
386
+ if ( ! isset( $_POST['action'] ) || 'delete-plugin' !== $_POST['action'] ) {
 
 
 
 
387
  return false;
388
  }
389
+ $plugin = $_POST['plugin'];
390
+ $_plugins = $this->get_plugins();
391
+ $plugins_to_delete = array();
392
+ $plugins_to_delete[ $plugin ] = isset( $_plugins[ $plugin ] ) ? $_plugins[ $plugin ] : array();
 
 
 
 
 
 
 
 
 
 
393
  update_option( 'wp_mainwp_stream_plugins_to_delete', $plugins_to_delete );
 
394
  return false;
395
  }
396
 
397
  /**
398
+ * Uninstall plugins callback.
 
 
399
  *
400
+ * @todo Core needs an uninstall_plugin hook
 
 
401
  * @todo This does not work in WP-CLI
402
  */
403
+ public function callback_deleted_plugin( $plugin_file, $deleted ) {
404
+ if ( $deleted ) {
 
 
 
 
 
 
 
405
 
406
+ if ( ! isset( $_POST['action'] ) || 'delete-plugin' !== $_POST['action'] ) {
407
+ return;
408
+ }
409
+ $plugins_to_delete = get_option( 'wp_mainwp_stream_plugins_to_delete' );
410
+ if ( ! $plugins_to_delete ) {
411
+ return;
412
+ }
413
+ foreach ( $plugins_to_delete as $plugin => $data ) {
414
+ if ( $plugin_file == $plugin ) {
415
+ $name = $data['Name'];
416
+ $network_wide = $data['Network'] ? esc_html__( 'network wide', 'mainwp-child-reports' ) : '';
417
+
418
+ $this->log(
419
+ // translators: Placeholder refers to a plugin name (e.g. "Stream").
420
+ __( '"%s" plugin deleted', 'mainwp-child-reports' ),
421
+ compact( 'name', 'plugin', 'network_wide' ),
422
+ null,
423
+ 'plugins',
424
+ 'deleted'
425
+ );
426
+ }
427
+ }
428
+ delete_option( 'wp_mainwp_stream_plugins_to_delete' );
429
  }
 
 
 
 
430
  }
431
 
432
+ /**
433
+ * Core updated successfully callback.
434
+ *
435
+ * @param $new_version New WordPress verison.
436
+ */
437
+ public function callback__core_updated_successfully( $new_version ) {
438
+
439
+ /**
440
+ * @global string $pagenow Current page.
441
+ * @global string $wp_version WordPress version.
442
+ */
443
  global $pagenow, $wp_version;
444
 
445
  $old_version = $wp_version;
457
  $message,
458
  compact( 'new_version', 'old_version', 'auto_updated' ),
459
  null,
460
+ 'WordPress',
461
  'updated'
462
  );
463
  }
464
 
465
+ /**
466
+ * Child Site install Plugin or theme callback.
467
+ *
468
+ * @param array $args Success message.
469
+ * @return bool|void Return FALSE on failure.
470
+ */
471
+ public function callback_mainwp_child_installPluginTheme( $args ) {
472
+
473
+ $logs = array();
474
+ $success = isset( $args['success'] ) ? $args['success'] : 0;
475
  $error = null;
476
 
477
  if ( ! $success ) {
478
+ $errors = $args['errors'];
479
+
480
  }
481
 
482
  // This would have failed down the road anyway
492
  }
493
 
494
  if ( 'install' === $action ) {
495
+ if ( 'plugin' === $type ) {
496
+ if ( ! isset( $args['Name'] ) || empty( $args['Name'] ) ) {
497
+ return;
498
+ }
499
  $slug = $args['slug'];
500
  $name = $args['Name'];
501
  $version = $args['Version'];
502
  } else { // theme
503
+ $slug = $args['slug'];
504
  if ( ! $slug ) {
505
  return;
506
  }
521
  }
522
 
523
  $context = $type . 's';
524
+
525
  foreach ( $logs as $log ) {
526
  $name = isset( $log['name'] ) ? $log['name'] : null;
527
  $version = isset( $log['version'] ) ? $log['version'] : null;
528
  $slug = isset( $log['slug'] ) ? $log['slug'] : null;
529
  $old_version = isset( $log['old_version'] ) ? $log['old_version'] : null;
530
  $message = isset( $log['message'] ) ? $log['message'] : null;
531
+ $action = isset( $log['action'] ) ? $log['action'] : null;
532
  $this->log(
533
  $message,
534
  compact( 'type', 'name', 'version', 'slug', 'success', 'error', 'old_version' ),
535
  null,
536
  $context,
537
+ $action
538
  );
539
  }
540
  }
541
 
542
 
543
+ /**
544
+ * MainWP Plugin Action callback.
545
+ *
546
+ * @param $args Action arguments.
547
+ */
548
+ public function callback_mainwp_child_plugin_action( $args ) {
549
+ if ( ! is_array( $args ) || ! isset( $args['action'] ) ) {
550
+ return;
551
+ }
552
+ $action = $args['action'];
553
+ if ( $action == 'delete' ) {
554
+ $name = $args['Name'];
555
+ $network_wide = '';
556
+ $this->log(
557
+ __( '"%s" plugin deleted', 'mainwp-child-reports' ),
558
+ compact( 'name', 'plugin' ),
559
+ null,
560
+ 'plugins',
561
+ 'deleted'
562
+ );
563
+ }
564
  }
565
 
566
+ /**
567
+ * MainWP Child Theme action callback.
568
+ *
569
+ * @param string $args MainWP Child Theme action.
570
+ */
571
+ public function callback_mainwp_child_theme_action( $args ) {
572
+ if ( ! is_array( $args ) || ! isset( $args['action'] ) ) {
573
+ return;
574
+ }
575
+ $action = $args['action'];
576
+ $name = $args['Name'];
577
+ if ( $action == 'delete' ) {
578
+ $this->log(
579
+ __( '"%s" theme deleted', 'mainwp-child-reports' ),
580
+ compact( 'name' ),
581
+ null,
582
+ 'themes',
583
+ 'deleted'
584
+ );
585
+ }
586
  }
587
+
588
  // ( Net-Concept - Xavier NUEL ) : save all plugins versions before upgrade.
589
 
590
+ /**
591
+ * Upgrader pre-instaler callback.
592
+ */
593
+ public function callback_upgrader_pre_install() {
594
+ $this->old_plugins = $this->get_plugins();
595
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  }
connectors/class-connector-mainwp-backups.php CHANGED
@@ -162,6 +162,8 @@ class Connector_MainWP_Backups extends Connector {
162
  /**
163
  * Record MainWP UpdraftPlus backups log.
164
  *
 
 
165
  * @param string $destination Backup destination.
166
  * @param strign $message Log message.
167
  * @param string $status Backup status.
162
  /**
163
  * Record MainWP UpdraftPlus backups log.
164
  *
165
+ * Not used.
166
+ *
167
  * @param string $destination Backup destination.
168
  * @param strign $message Log message.
169
  * @param string $status Backup status.
connectors/class-connector-posts.php CHANGED
@@ -379,6 +379,9 @@ class Connector_Posts extends Connector {
379
  'nav_menu_item',
380
  'attachment',
381
  'revision',
 
 
 
382
  )
383
  );
384
  }
379
  'nav_menu_item',
380
  'attachment',
381
  'revision',
382
+ 'seopress_404',
383
+ 'seopress_bot',
384
+ 'seopress_schemas'
385
  )
386
  );
387
  }
mainwp-child-reports.php CHANGED
@@ -7,7 +7,7 @@
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.6
11
  * Requires at least: 3.6
12
  * Text Domain: mainwp-child-reports
13
  * License: GPLv3 or later
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.7
11
  * Requires at least: 3.6
12
  * Text Domain: mainwp-child-reports
13
  * License: GPLv3 or later
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.5.1
9
- Requires PHP: 5.6
10
- Stable tag: 2.0.6
11
  License: GPLv3 or later
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
@@ -36,6 +36,10 @@ Credit to the [Stream Plugin](https://wordpress.org/plugins/stream/) which the M
36
 
37
  == Changelog ==
38
 
 
 
 
 
39
  = 2.0.6 - 10-29-2020 =
40
  * Added: PHP Docs blocks
41
  * Updated: MainWP Child 4.1 compatibility
5
  Author URI: https://mainwp.com
6
  Plugin URI: https://mainwp.com
7
  Requires at least: 3.6
8
+ Tested up to: 5.8
9
+ Requires PHP: 7.0
10
+ Stable tag: 2.0.7
11
  License: GPLv3 or later
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
36
 
37
  == Changelog ==
38
 
39
+ = 2.0.7 - 2-4-2021 =
40
+ * Fixed: An issue with logging deleted plugins
41
+ * Updated: exclusion rules for certain custom post types
42
+
43
  = 2.0.6 - 10-29-2020 =
44
  * Added: PHP Docs blocks
45
  * Updated: MainWP Child 4.1 compatibility