MainWP Child Reports - Version 1.1

Version Description

  • 4-28-2016 =
  • Updated: Support for the MainWP Child Plugin version 3.1.3
Download this release

Release Info

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

Code changes from version 1.0 to 1.1

connectors/installer.php CHANGED
@@ -425,7 +425,7 @@ class MainWP_WP_Stream_Connector_Installer extends MainWP_WP_Stream_Connector {
425
  global $pagenow, $wp_version;
426
 
427
  $old_version = $wp_version;
428
- $auto_updated = ( 'update-core.php' !== $pagenow );
429
 
430
  if ( $auto_updated ) {
431
  $message = __( 'WordPress auto-updated to %s', 'mainwp-child-reports' );
425
  global $pagenow, $wp_version;
426
 
427
  $old_version = $wp_version;
428
+ $auto_updated = ( 'update-core.php' !== $pagenow && !isset($_POST['mainwpsignature']));
429
 
430
  if ( $auto_updated ) {
431
  $message = __( 'WordPress auto-updated to %s', 'mainwp-child-reports' );
includes/admin.php CHANGED
@@ -7,11 +7,12 @@ class MainWP_WP_Stream_Admin {
7
  public static $list_table = null;
8
 
9
  public static $disable_access = false;
 
10
 
11
  const ADMIN_BODY_CLASS = 'mainwp_wp_stream_screen';
12
- const RECORDS_PAGE_SLUG = 'mainwp_wp_stream';
13
  const SETTINGS_PAGE_SLUG = 'mainwp_wp_stream_settings';
14
- const ADMIN_PARENT_PAGE = 'admin.php';
15
  const VIEW_CAP = 'view_stream';
16
  const SETTINGS_CAP = 'manage_options';
17
  const PRELOAD_AUTHORS_MAX = 50;
@@ -24,9 +25,9 @@ class MainWP_WP_Stream_Admin {
24
  self::$disable_access = apply_filters( 'mainwp_wp_stream_disable_admin_access', false );
25
 
26
  // Register settings page
27
- if (get_option('mainwp_creport_branding_stream_hide') !== "hide") {
28
- add_action( 'mainwp-child-subpages', array( __CLASS__, 'register_subpages' ) );
29
- }
30
 
31
  // Admin notices
32
  add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
@@ -39,7 +40,7 @@ class MainWP_WP_Stream_Admin {
39
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_menu_css' ) );
40
 
41
  // Reset MainWP Reports database
42
- add_action( 'wp_ajax_mainwp_wp_stream_reset', array( __CLASS__, 'wp_ajax_reset' ) );
43
 
44
  // Reset MainWP Reports settings
45
  add_action( 'wp_ajax_mainwp_wp_stream_defaults', array( __CLASS__, 'wp_ajax_defaults' ) );
@@ -58,8 +59,21 @@ class MainWP_WP_Stream_Admin {
58
  // Ajax author's name by ID
59
  add_action( 'wp_ajax_mainwp_wp_stream_get_filter_value_by_id', array( __CLASS__, 'get_filter_value_by_id' ) );
60
 
61
- add_filter('updraftplus_backup_complete', array( __CLASS__, 'hookUpdraftplusBackupComplete' ));
62
- add_action('hmbkp_backup_complete', array( __CLASS__, 'hookBackupWordpressComplete' ));
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
 
65
  public static function admin_notices() {
@@ -174,51 +188,24 @@ class MainWP_WP_Stream_Admin {
174
  }
175
  return $value;
176
  }
177
-
178
- public static function register_subpages($args = array()) {
179
- if ( is_network_admin() && ! is_plugin_active_for_network( MAINWP_WP_STREAM_PLUGIN ) ) {
180
- return false;
181
- }
182
-
183
- if ( self::$disable_access ) {
184
- return false;
 
 
 
 
 
 
 
 
185
  }
186
-
187
- $the_branding = isset($args['branding']) ? $args['branding'] : 'MainWP Child';
188
- $mainwp_child_menu_slug = isset($args['child_slug']) ? $args['child_slug'] : '';
189
-
190
- if (empty($mainwp_child_menu_slug))
191
- return false;
192
-
193
- if ($the_branding == 'MainWP')
194
- $the_branding .= ' Child';
195
-
196
- self::$screen_id['main'] = add_submenu_page(
197
- $mainwp_child_menu_slug,
198
- __( $the_branding . ' Reports', 'mainwp-child-reports' ),
199
- __( $the_branding . ' Reports', 'mainwp-child-reports' ),
200
- self::VIEW_CAP,
201
- self::RECORDS_PAGE_SLUG,
202
- array( __CLASS__, 'stream_page' )
203
- );
204
-
205
-
206
- self::$screen_id['settings'] = add_submenu_page(
207
- $mainwp_child_menu_slug,
208
- __( $the_branding . ' Reports Settings', 'mainwp-child-reports' ),
209
- __( $the_branding . ' Reports Settings', 'default' ),
210
- self::SETTINGS_CAP,
211
- self::SETTINGS_PAGE_SLUG,
212
- array( __CLASS__, 'render_page' )
213
- );
214
- // Register the list table early, so it associates the column headers with 'Screen settings'
215
- add_action( 'load-' . self::$screen_id['main'], array( __CLASS__, 'register_list_table' ) );
216
- do_action( 'mainwp_wp_stream_admin_menu_screens' );
217
-
218
- // Register the list table early, so it associates the column headers with 'Screen settings'
219
- add_action( 'load-' . self::$screen_id['main'], array( __CLASS__, 'register_list_table' ) );
220
- }
221
-
222
  public static function admin_enqueue_scripts( $hook ) {
223
  wp_register_script( 'select2', MAINWP_WP_STREAM_URL . 'ui/select2/select2.min.js', array( 'jquery' ), '3.4.5', true );
224
  wp_register_style( 'select2', MAINWP_WP_STREAM_URL . 'ui/select2/select2.css', array(), '3.4.5' );
@@ -234,12 +221,13 @@ class MainWP_WP_Stream_Admin {
234
  }
235
 
236
  wp_enqueue_style( 'mainwp-wp-stream-admin', MAINWP_WP_STREAM_URL . 'ui/admin.css', array(), MainWP_WP_Stream::VERSION );
237
-
238
  $script_screens = array( 'plugins.php', 'user-edit.php', 'user-new.php', 'profile.php' );
239
 
240
  if ( 'index.php' === $hook ) {
241
 
242
- } elseif ( in_array( $hook, self::$screen_id ) || in_array( $hook, $script_screens ) ) {
 
243
  wp_enqueue_script( 'select2' );
244
  wp_enqueue_style( 'select2' );
245
 
@@ -315,105 +303,62 @@ class MainWP_WP_Stream_Admin {
315
 
316
  return;
317
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
 
319
- public static function render_page() {
320
 
321
  $option_key = MainWP_WP_Stream_Settings::$option_key;
322
  $form_action = apply_filters( 'mainwp_wp_stream_settings_form_action', admin_url( 'options.php' ) );
323
-
324
- $page_title = apply_filters( 'mainwp_wp_stream_settings_form_title', get_admin_page_title() );
325
- $page_description = apply_filters( 'mainwp_wp_stream_settings_form_description', '' );
326
-
327
  $sections = MainWP_WP_Stream_Settings::get_fields();
328
- $active_tab = mainwp_wp_stream_filter_input( INPUT_GET, 'tab' );
329
-
330
  ?>
331
- <div class="wrap">
332
-
333
- <h2><?php echo esc_html( $page_title ); ?></h2>
334
-
335
- <?php if ( ! empty( $page_description ) ) : ?>
336
- <p><?php echo esc_html( $page_description ); ?></p>
337
- <?php endif; ?>
338
-
339
- <?php settings_errors() ?>
340
-
341
- <?php if ( count( $sections ) > 1 ) : ?>
342
- <h2 class="nav-tab-wrapper">
343
- <?php $i = 0 ?>
344
- <?php foreach ( $sections as $section => $data ) : ?>
345
- <?php $i ++ ?>
346
- <?php $is_active = ( ( 1 === $i && ! $active_tab ) || $active_tab === $section ) ?>
347
- <a href="<?php echo esc_url( add_query_arg( 'tab', $section ) ) ?>" class="nav-tab<?php if ( $is_active ) { echo esc_attr( ' nav-tab-active' ); } ?>">
348
- <?php echo esc_html( $data['title'] ) ?>
349
- </a>
350
- <?php endforeach; ?>
351
- </h2>
352
- <?php endif; ?>
353
-
354
- <div class="nav-tab-content" id="tab-content-settings">
355
- <br/><br/>
356
- <div class="postbox">
357
- <div class="inside">
358
-
359
  <form method="post" action="<?php echo esc_attr( $form_action ) ?>" enctype="multipart/form-data">
360
- <?php
361
- $i = 0;
362
- foreach ( $sections as $section => $data ) {
363
- $i++;
364
- $is_active = ( ( 1 === $i && ! $active_tab ) || $active_tab === $section );
365
- if ( $is_active ) {
366
- settings_fields( $option_key );
367
- do_settings_sections( $option_key );
368
- }
369
- }
370
- submit_button();
371
- ?>
372
  </form>
373
-
374
- </div>
375
- </div>
376
  </div>
377
  </div>
 
378
  <?php
 
379
  }
380
-
381
 
382
- public static function register_list_table() {
383
- require_once MAINWP_WP_STREAM_INC_DIR . 'list-table.php';
384
- self::$list_table = new MainWP_WP_Stream_List_Table( array( 'screen' => self::$screen_id['main'] ) );
385
- }
386
-
387
- public static function stream_page() {
388
- $page_title = __( 'MainWP Child Reports', 'mainwp-child-reports' );
389
-
390
- echo '<div class="wrap">';
391
-
392
- if ( is_network_admin() ) {
393
- $site_count = sprintf( _n( '1 site', '%d sites', get_blog_count(), 'mainwp-child-reports' ), get_blog_count() );
394
- printf( '<h2>%s (%s)</h2>', __( 'MainWP Child Reports', 'mainwp-child-reports' ), $site_count ); // xss ok
395
- } else {
396
- printf( '<h2>%s</h2>', __( 'MainWP Child Reports', 'mainwp-child-reports' ) ); // xss ok
397
- }
398
-
399
- self::$list_table->prepare_items();
400
- self::$list_table->display();
401
- echo '</div>';
402
- }
403
-
404
- public static function wp_ajax_reset() {
405
  check_ajax_referer( 'stream_nonce', 'mainwp_wp_stream_nonce' );
406
 
407
  if ( current_user_can( self::SETTINGS_CAP ) ) {
408
  self::erase_stream_records();
409
  MainWP_WP_Stream_Install::check_to_copy_data();
410
- wp_redirect(
411
  add_query_arg(
412
  array(
413
- 'page' => is_network_admin() ? 'mainwp_wp_stream_network_settings' : 'mainwp_wp_stream_settings',
414
- 'message' => 'child_reports_data_erased',
415
  ),
416
- is_plugin_active_for_network( MAINWP_WP_STREAM_PLUGIN ) ? network_admin_url( self::ADMIN_PARENT_PAGE ) : admin_url( self::ADMIN_PARENT_PAGE )
417
  )
418
  );
419
  exit;
7
  public static $list_table = null;
8
 
9
  public static $disable_access = false;
10
+ public static $brandingTitle = null;
11
 
12
  const ADMIN_BODY_CLASS = 'mainwp_wp_stream_screen';
13
+ const RECORDS_PAGE_SLUG = 'mainwp-reports-page';
14
  const SETTINGS_PAGE_SLUG = 'mainwp_wp_stream_settings';
15
+ const ADMIN_PARENT_PAGE = 'options-general.php';
16
  const VIEW_CAP = 'view_stream';
17
  const SETTINGS_CAP = 'manage_options';
18
  const PRELOAD_AUTHORS_MAX = 50;
25
  self::$disable_access = apply_filters( 'mainwp_wp_stream_disable_admin_access', false );
26
 
27
  // Register settings page
28
+ if (get_option('mainwp_creport_branding_stream_hide') !== "hide") {
29
+ add_filter( 'mainwp-child-init-subpages', array( __CLASS__, 'init_subpages' ) );
30
+ }
31
 
32
  // Admin notices
33
  add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
40
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_menu_css' ) );
41
 
42
  // Reset MainWP Reports database
43
+ add_action( 'wp_ajax_mainwp_wp_stream_reset', array( __CLASS__, 'ajax_reset_reports' ) );
44
 
45
  // Reset MainWP Reports settings
46
  add_action( 'wp_ajax_mainwp_wp_stream_defaults', array( __CLASS__, 'wp_ajax_defaults' ) );
59
  // Ajax author's name by ID
60
  add_action( 'wp_ajax_mainwp_wp_stream_get_filter_value_by_id', array( __CLASS__, 'get_filter_value_by_id' ) );
61
 
62
+ add_filter('updraftplus_backup_complete', array( __CLASS__, 'hookUpdraftplusBackupComplete' ));
63
+ add_action('hmbkp_backup_complete', array( __CLASS__, 'hookBackupWordpressComplete' ));
64
+ }
65
+
66
+ public static function get_branding_title() {
67
+ if (self::$brandingTitle === null) {
68
+ $cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
69
+ $branding_header = get_option( 'mainwp_branding_plugin_header' );
70
+ if ( ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) && ! $cancelled_branding ) {
71
+ self::$brandingTitle = stripslashes( $branding_header['name'] );
72
+ } else {
73
+ self::$brandingTitle = '';
74
+ }
75
+ }
76
+ return self::$brandingTitle;
77
  }
78
 
79
  public static function admin_notices() {
188
  }
189
  return $value;
190
  }
191
+
192
+ public static function init_subpages($subPages = array()) {
193
+ if ( is_network_admin() && ! is_plugin_active_for_network( MAINWP_WP_STREAM_PLUGIN ) ) {
194
+ return $subPages;
195
+ }
196
+
197
+ $title = MainWP_WP_Stream_Admin::get_branding_title();
198
+ if (empty($title)) {
199
+ $title = 'Child Reports';
200
+ } else {
201
+ $title = self::$brandingTitle . ' Reports';
202
+ }
203
+
204
+ $subPages[] = array('title' => $title, 'slug' => 'reports-page' , 'callback' => array( __CLASS__, 'render_reports_page' ) , 'load_callback' => array( __CLASS__, 'register_list_table' ));
205
+ $subPages[] = array('title' => $title . ' Settings', 'slug' => 'reports-settings' , 'callback' => array( __CLASS__, 'render_reports_settings' ) );
206
+ return $subPages;
207
  }
208
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  public static function admin_enqueue_scripts( $hook ) {
210
  wp_register_script( 'select2', MAINWP_WP_STREAM_URL . 'ui/select2/select2.min.js', array( 'jquery' ), '3.4.5', true );
211
  wp_register_style( 'select2', MAINWP_WP_STREAM_URL . 'ui/select2/select2.css', array(), '3.4.5' );
221
  }
222
 
223
  wp_enqueue_style( 'mainwp-wp-stream-admin', MAINWP_WP_STREAM_URL . 'ui/admin.css', array(), MainWP_WP_Stream::VERSION );
224
+
225
  $script_screens = array( 'plugins.php', 'user-edit.php', 'user-new.php', 'profile.php' );
226
 
227
  if ( 'index.php' === $hook ) {
228
 
229
+ } elseif ( in_array( $hook, self::$screen_id ) || in_array( $hook, $script_screens ) || $hook == 'settings_page_mainwp-reports-page' ) {
230
+
231
  wp_enqueue_script( 'select2' );
232
  wp_enqueue_style( 'select2' );
233
 
303
 
304
  return;
305
  }
306
+
307
+ public static function register_list_table() {
308
+ require_once MAINWP_WP_STREAM_INC_DIR . 'list-table.php';
309
+ self::$list_table = new MainWP_WP_Stream_List_Table( array( 'screen' => self::$screen_id['main'] ) );
310
+ }
311
+
312
+ public static function render_reports_page() {
313
+ do_action('mainwp-child-pageheader', 'reports-page');
314
+ self::$list_table->prepare_items();
315
+ echo '<div class="mainwp_child_reports_wrap">';
316
+ self::$list_table->display();
317
+ echo '</div>';
318
+ do_action('mainwp-child-pagefooter', 'reports-page');
319
+ }
320
 
321
+ public static function render_reports_settings() {
322
 
323
  $option_key = MainWP_WP_Stream_Settings::$option_key;
324
  $form_action = apply_filters( 'mainwp_wp_stream_settings_form_action', admin_url( 'options.php' ) );
 
 
 
 
325
  $sections = MainWP_WP_Stream_Settings::get_fields();
326
+ //settings_errors();
327
+ do_action('mainwp-child-pageheader', 'reports-settings')
328
  ?>
329
+ <div class="postbox">
330
+ <div class="inside">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  <form method="post" action="<?php echo esc_attr( $form_action ) ?>" enctype="multipart/form-data">
332
+ <?php
333
+ $i = 0;
334
+ foreach ( $sections as $section => $data ) {
335
+ $i++;
336
+ settings_fields( $option_key );
337
+ do_settings_sections( $option_key );
338
+ }
339
+ submit_button();
340
+ ?>
 
 
 
341
  </form>
 
 
 
342
  </div>
343
  </div>
344
+
345
  <?php
346
+ do_action('mainwp-child-pagefooter', 'reports-settings');
347
  }
 
348
 
349
+ public static function ajax_reset_reports() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  check_ajax_referer( 'stream_nonce', 'mainwp_wp_stream_nonce' );
351
 
352
  if ( current_user_can( self::SETTINGS_CAP ) ) {
353
  self::erase_stream_records();
354
  MainWP_WP_Stream_Install::check_to_copy_data();
355
+ wp_redirect(
356
  add_query_arg(
357
  array(
358
+ 'page' => 'mainwp-reports-settings',
359
+ 'message' => 'child_reports_data_erased'
360
  ),
361
+ admin_url( 'options-general.php' )
362
  )
363
  );
364
  exit;
includes/list-table.php CHANGED
@@ -457,7 +457,7 @@ class MainWP_WP_Stream_List_Table extends WP_List_Table {
457
  $user_id = get_current_user_id();
458
  $filters = $this->get_filters();
459
 
460
- $filters_string = sprintf( '<input type="hidden" name="page" value="%s"/>', 'mainwp_wp_stream' );
461
  $filters_string .= sprintf( '<span class="filter_info hidden">%s</span>', esc_html__( 'Show filter controls via the screen options tab above.', 'mainwp-child-reports' ) );
462
 
463
  foreach ( $filters as $name => $data ) {
@@ -580,7 +580,7 @@ class MainWP_WP_Stream_List_Table extends WP_List_Table {
580
  function display() {
581
  $url = self_admin_url( MainWP_WP_Stream_Admin::ADMIN_PARENT_PAGE );
582
 
583
- echo '<form method="get" action="' . esc_url( $url ) . '">';
584
  echo $this->filter_search(); // xss ok
585
 
586
  parent::display();
457
  $user_id = get_current_user_id();
458
  $filters = $this->get_filters();
459
 
460
+ $filters_string = sprintf( '<input type="hidden" name="page" value="%s"/>', 'mainwp-reports-page' );
461
  $filters_string .= sprintf( '<span class="filter_info hidden">%s</span>', esc_html__( 'Show filter controls via the screen options tab above.', 'mainwp-child-reports' ) );
462
 
463
  foreach ( $filters as $name => $data ) {
580
  function display() {
581
  $url = self_admin_url( MainWP_WP_Stream_Admin::ADMIN_PARENT_PAGE );
582
 
583
+ echo '<form method="get" action="' . esc_url( $url ) . '">';
584
  echo $this->filter_search(); // xss ok
585
 
586
  parent::display();
includes/live-update.php CHANGED
@@ -40,7 +40,7 @@ class MainWP_WP_Stream_Live_Update {
40
  }
41
  }
42
 
43
- public static function live_update( $response, $data ) {
44
  if ( ! isset( $data['wp-mainwp-stream-heartbeat-last-id'] ) ) {
45
  return;
46
  }
@@ -78,8 +78,8 @@ class MainWP_WP_Stream_Live_Update {
78
 
79
  public static function heartbeat_received( $response, $data ) {
80
  $option = get_option( 'dashboard_mainwp_stream_activity_options' );
81
- $enable_stream_update = ( 'off' !== get_user_meta( get_current_user_id(), 'stream_live_update_records', true ) );
82
- $enable_dashboard_update = ( 'off' !== ( $option['live_update'] ) );
83
 
84
  // Register list table
85
  require_once MAINWP_WP_STREAM_INC_DIR . 'list-table.php';
@@ -123,7 +123,7 @@ class MainWP_WP_Stream_Live_Update {
123
  $response['total_pages_i18n'] = number_format_i18n( $total_pages );
124
 
125
  $query_args['page'] = MainWP_WP_Stream_Admin::RECORDS_PAGE_SLUG;
126
- $query_args['paged'] = $total_pages;
127
 
128
  $response['last_page_link'] = add_query_arg( $query_args, admin_url( 'admin.php' ) );
129
  }
40
  }
41
  }
42
 
43
+ public static function live_update( $response, $data ) {
44
  if ( ! isset( $data['wp-mainwp-stream-heartbeat-last-id'] ) ) {
45
  return;
46
  }
78
 
79
  public static function heartbeat_received( $response, $data ) {
80
  $option = get_option( 'dashboard_mainwp_stream_activity_options' );
81
+ $enable_stream_update = true; //( 'off' !== get_user_meta( get_current_user_id(), 'stream_live_update_records', true ) );
82
+ $enable_dashboard_update = false; //( 'off' !== ( $option['live_update'] ) );
83
 
84
  // Register list table
85
  require_once MAINWP_WP_STREAM_INC_DIR . 'list-table.php';
123
  $response['total_pages_i18n'] = number_format_i18n( $total_pages );
124
 
125
  $query_args['page'] = MainWP_WP_Stream_Admin::RECORDS_PAGE_SLUG;
126
+ $query_args['paged'] = $total_pages;
127
 
128
  $response['last_page_link'] = add_query_arg( $query_args, admin_url( 'admin.php' ) );
129
  }
includes/query.php CHANGED
@@ -145,7 +145,7 @@ class MainWP_WP_Stream_Query {
145
  }
146
 
147
  if ( $args['created_greater_than'] ) {
148
- $where .= $wpdb->prepare( " AND $wpdb->mainwp_reports.created > %s", (int) $args['created_greater_than'] );
149
  }
150
 
151
  if ( $args['record__in'] ) {
145
  }
146
 
147
  if ( $args['created_greater_than'] ) {
148
+ $where .= $wpdb->prepare( " AND $wpdb->mainwp_reports.created > %s", date('Y-m-d H:i:s', $args['created_greater_than'] ) );
149
  }
150
 
151
  if ( $args['record__in'] ) {
includes/settings.php CHANGED
@@ -170,7 +170,11 @@ class MainWP_WP_Stream_Settings {
170
 
171
  public static function get_fields() {
172
  if ( empty( self::$fields ) ) {
173
- $fields = array(
 
 
 
 
174
  'general' => array(
175
  'title' => esc_html__( 'General', 'default' ),
176
  'fields' => array(
@@ -185,7 +189,7 @@ class MainWP_WP_Stream_Settings {
185
  ),
186
  array(
187
  'name' => 'delete_all_records',
188
- 'title' => esc_html__( 'Reset MainWP Child Reports Database', 'mainwp-child-reports' ),
189
  'type' => 'link',
190
  'href' => add_query_arg(
191
  array(
@@ -199,10 +203,10 @@ class MainWP_WP_Stream_Settings {
199
  ),
200
  ),
201
  ),
202
- );
203
  }
204
 
205
- return apply_filters( 'mainwp_wp_stream_options_fields', $fields );
206
  }
207
 
208
  public static function get_options() {
170
 
171
  public static function get_fields() {
172
  if ( empty( self::$fields ) ) {
173
+ if (!class_exists('MainWP_WP_Stream_Admin'))
174
+ require_once MAINWP_WP_STREAM_INC_DIR . 'admin.php';
175
+ $title = MainWP_WP_Stream_Admin::get_branding_title();
176
+ $title = !empty($title) ? 'Reset ' . $title . ' Reports Database' : esc_html__( 'Reset MainWP Child Reports Database', 'mainwp-child-reports' );
177
+ self::$fields = array(
178
  'general' => array(
179
  'title' => esc_html__( 'General', 'default' ),
180
  'fields' => array(
189
  ),
190
  array(
191
  'name' => 'delete_all_records',
192
+ 'title' => $title,
193
  'type' => 'link',
194
  'href' => add_query_arg(
195
  array(
203
  ),
204
  ),
205
  ),
206
+ );
207
  }
208
 
209
+ return self::$fields;
210
  }
211
 
212
  public static function get_options() {
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: 1.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: 1.1
9
  */
10
 
11
  /**
readme.txt CHANGED
@@ -6,8 +6,8 @@ Author: mainwp
6
  Author URI: https://mainwp.com
7
  Plugin URI: https://mainwp.com
8
  Requires at least: 3.6
9
- Tested up to: 4.5
10
- Stable tag: 1.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
  = 1.0 - 3-9-2016 =
40
  * Fixed: Issue with recreating tables
41
  * Fixed: Issue with recreating manually deleted tables
6
  Author URI: https://mainwp.com
7
  Plugin URI: https://mainwp.com
8
  Requires at least: 3.6
9
+ Tested up to: 4.5.1
10
+ Stable tag: 1.1
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
36
 
37
  == Changelog ==
38
 
39
+ = 1.1 - 4-28-2016 =
40
+ * Updated: Support for the MainWP Child Plugin version 3.1.3
41
+
42
  = 1.0 - 3-9-2016 =
43
  * Fixed: Issue with recreating tables
44
  * Fixed: Issue with recreating manually deleted tables
ui/admin.js CHANGED
@@ -315,58 +315,28 @@ jQuery(function( $ ) {
315
  }
316
  });
317
 
318
- // Admin page tabs
319
- var $tabs = $( '.nav-tab-wrapper' ),
320
- $panels = $( '.nav-tab-content table.form-table' ),
321
- $activeTab = $tabs.find( '.nav-tab-active' ),
322
- defaultIndex = $activeTab.length > 0 ? $tabs.find( 'a' ).index( $activeTab ) : 0,
323
- hashIndex = window.location.hash.match( /^#(\d+)$/ ),
324
- currentHash = ( null !== hashIndex ? hashIndex[ 1 ] : defaultIndex ),
325
- syncFormAction = function( index ) {
326
- var $optionsForm = $( 'input[name="option_page"][value^="mainwp_wp_stream"]' ).parent( 'form' );
327
- var currentAction = $optionsForm.attr( 'action' );
328
-
329
- $optionsForm.prop( 'action', currentAction.replace( /(^[^#]*).*$/, '$1#' + index ) );
330
- };
331
-
332
- $tabs.on( 'click', 'a', function() {
333
- var index = $tabs.find( 'a' ).index( $( this ) ),
334
- hashIndex = window.location.hash.match( /^#(\d+)$/ );
335
-
336
- $panels.hide().eq( index ).show();
337
- $tabs
338
- .find( 'a' )
339
- .removeClass( 'nav-tab-active' )
340
- .filter( $( this ) )
341
- .addClass( 'nav-tab-active' );
342
-
343
- if ( '' === window.location.hash || null !== hashIndex ) {
344
- window.location.hash = index;
345
- }
346
-
347
- syncFormAction( index );
348
- return false;
349
- });
350
- $tabs.children().eq( currentHash ).trigger( 'click' );
351
 
352
  // Heartbeat for Live Updates
353
  // runs only on stream page (not settings)
354
  $( document ).ready(function() {
355
  // Only run on page 1 when the order is desc and on page mainwp_wp_stream
356
  if (
357
- mainwp_wp_stream.current_screen.indexOf('_page_mainwp_wp_stream') == -1 ||
358
  '1' !== mainwp_wp_stream.current_page ||
359
  'asc' === mainwp_wp_stream.current_order
360
  ) {
361
  return;
362
  }
363
 
364
- var list_sel = '.mainwp_wp_stream_screen #the-list';
365
 
366
  // Set initial beat to fast. WP is designed to slow this to 15 seconds after 2.5 minutes.
367
  wp.heartbeat.interval( 'fast' );
368
 
369
- $( document ).on( 'heartbeat-send.child_reports', function( e, data ) {
 
 
 
370
  data['wp-mainwp-stream-heartbeat'] = 'live-update';
371
  var last_item = $( list_sel + ' tr:first .column-id' );
372
  var last_id = 1;
@@ -374,11 +344,10 @@ jQuery(function( $ ) {
374
  last_id = ( '' === last_item.text() ) ? 1 : last_item.text();
375
  }
376
  var last_created_item = $( list_sel + ' tr:first .column-date span.timestamp' );
377
- var last_created = 0;
378
  if ( last_created_item.length !== 0 ) {
379
- last_created = last_created_item.data['timestamp'];
380
- }
381
-
382
  data['wp-mainwp-stream-heartbeat-last-id'] = last_id;
383
  data['wp-mainwp-stream-heartbeat-last-created'] = last_created;
384
  data['wp-mainwp-stream-heartbeat-query'] = mainwp_wp_stream.current_query;
315
  }
316
  });
317
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
 
319
  // Heartbeat for Live Updates
320
  // runs only on stream page (not settings)
321
  $( document ).ready(function() {
322
  // Only run on page 1 when the order is desc and on page mainwp_wp_stream
323
  if (
324
+ mainwp_wp_stream.current_screen.indexOf('_mainwp-reports-page') == -1 ||
325
  '1' !== mainwp_wp_stream.current_page ||
326
  'asc' === mainwp_wp_stream.current_order
327
  ) {
328
  return;
329
  }
330
 
331
+ var list_sel = '.mainwp_child_reports_wrap #the-list';
332
 
333
  // Set initial beat to fast. WP is designed to slow this to 15 seconds after 2.5 minutes.
334
  wp.heartbeat.interval( 'fast' );
335
 
336
+ $( document ).on( 'heartbeat-send.child_reports', function( e, data ) {
337
+ if ($(list_sel).length == 0)
338
+ return;
339
+
340
  data['wp-mainwp-stream-heartbeat'] = 'live-update';
341
  var last_item = $( list_sel + ' tr:first .column-id' );
342
  var last_id = 1;
344
  last_id = ( '' === last_item.text() ) ? 1 : last_item.text();
345
  }
346
  var last_created_item = $( list_sel + ' tr:first .column-date span.timestamp' );
347
+ var last_created = 0;
348
  if ( last_created_item.length !== 0 ) {
349
+ last_created = last_created_item.attr('timestamp');
350
+ }
 
351
  data['wp-mainwp-stream-heartbeat-last-id'] = last_id;
352
  data['wp-mainwp-stream-heartbeat-last-created'] = last_created;
353
  data['wp-mainwp-stream-heartbeat-query'] = mainwp_wp_stream.current_query;