Version Description
- 1-30-2019 =
- Fixed: an issue with cleaning the plugin database tables on some setups
- Updated: MySQL query improvements
Download this release
Release Info
Developer | mainwp |
Plugin | MainWP Child Reports |
Version | 1.9.2 |
Comparing to | |
See all releases |
Code changes from version 1.9.1 to 1.9.2
- includes/admin.php +3 -39
- includes/connector.php +2 -2
- includes/install.php +35 -38
- includes/settings.php +29 -27
- mainwp-child-reports.php +127 -56
- readme.txt +6 -2
includes/admin.php
CHANGED
@@ -7,7 +7,6 @@ class MainWP_WP_Stream_Admin {
|
|
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';
|
@@ -24,11 +23,6 @@ class MainWP_WP_Stream_Admin {
|
|
24 |
|
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' ) );
|
34 |
|
@@ -64,19 +58,6 @@ class MainWP_WP_Stream_Admin {
|
|
64 |
add_action('mainwp_child_reports_log', array( __CLASS__, 'hook_reports_log' ), 10, 1);
|
65 |
}
|
66 |
|
67 |
-
public static function get_branding_title() {
|
68 |
-
if (self::$brandingTitle === null) {
|
69 |
-
$cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
|
70 |
-
$branding_header = get_option( 'mainwp_branding_plugin_header' );
|
71 |
-
if ( ! $cancelled_branding && ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) ) {
|
72 |
-
self::$brandingTitle = stripslashes( $branding_header['name'] );
|
73 |
-
} else {
|
74 |
-
self::$brandingTitle = '';
|
75 |
-
}
|
76 |
-
}
|
77 |
-
return self::$brandingTitle;
|
78 |
-
}
|
79 |
-
|
80 |
public static function admin_notices() {
|
81 |
$message = mainwp_wp_stream_filter_input( INPUT_GET, 'message' );
|
82 |
|
@@ -90,7 +71,7 @@ class MainWP_WP_Stream_Admin {
|
|
90 |
}
|
91 |
}
|
92 |
|
93 |
-
|
94 |
|
95 |
if (!is_array($last_backup))
|
96 |
return $last_backup;
|
@@ -161,23 +142,6 @@ class MainWP_WP_Stream_Admin {
|
|
161 |
return $value;
|
162 |
}
|
163 |
|
164 |
-
public static function init_subpages($subPages = array()) {
|
165 |
-
if ( is_network_admin() && ! is_plugin_active_for_network( MAINWP_WP_STREAM_PLUGIN ) ) {
|
166 |
-
return $subPages;
|
167 |
-
}
|
168 |
-
|
169 |
-
$branding_text = MainWP_WP_Stream_Admin::get_branding_title();
|
170 |
-
if (empty($branding_text)) {
|
171 |
-
$branding_text = 'Child Reports';
|
172 |
-
} else {
|
173 |
-
$branding_text = $branding_text . ' Reports';
|
174 |
-
}
|
175 |
-
|
176 |
-
$subPages[] = array('title' => $branding_text, 'slug' => 'reports-page' , 'callback' => array( __CLASS__, 'render_reports_page' ) , 'load_callback' => array( __CLASS__, 'register_list_table' ));
|
177 |
-
$subPages[] = array('title' => $branding_text . ' Settings', 'slug' => 'reports-settings' , 'callback' => array( __CLASS__, 'render_reports_settings' ) );
|
178 |
-
return $subPages;
|
179 |
-
}
|
180 |
-
|
181 |
public static function admin_enqueue_scripts( $hook ) {
|
182 |
// wp_register_script( 'select2', MAINWP_WP_STREAM_URL . 'ui/select2/select2.min.js', array( 'jquery' ), '3.4.5', true );
|
183 |
// wp_register_style( 'select2', MAINWP_WP_STREAM_URL . 'ui/select2/select2.css', array(), '3.4.5' );
|
@@ -330,7 +294,7 @@ class MainWP_WP_Stream_Admin {
|
|
330 |
|
331 |
if ( current_user_can( self::SETTINGS_CAP ) ) {
|
332 |
self::erase_stream_records();
|
333 |
-
MainWP_WP_Stream_Install::check_to_copy_data();
|
334 |
wp_redirect(
|
335 |
add_query_arg(
|
336 |
array(
|
@@ -448,7 +412,7 @@ class MainWP_WP_Stream_Admin {
|
|
448 |
ON `context`.`record_id` = `stream`.`ID`
|
449 |
LEFT JOIN {$wpdb->mainwp_reportsmeta} AS `meta`
|
450 |
ON `meta`.`record_id` = `stream`.`ID`
|
451 |
-
WHERE `stream`.`type` =
|
452 |
{$where};" ;
|
453 |
|
454 |
|
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-reports-page';
|
23 |
|
24 |
self::$disable_access = apply_filters( 'mainwp_wp_stream_disable_admin_access', false );
|
25 |
|
|
|
|
|
|
|
|
|
|
|
26 |
// Admin notices
|
27 |
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
|
28 |
|
58 |
add_action('mainwp_child_reports_log', array( __CLASS__, 'hook_reports_log' ), 10, 1);
|
59 |
}
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
public static function admin_notices() {
|
62 |
$message = mainwp_wp_stream_filter_input( INPUT_GET, 'message' );
|
63 |
|
71 |
}
|
72 |
}
|
73 |
|
74 |
+
public static function hookUpdraftplusSaveLastBackup($last_backup) {
|
75 |
|
76 |
if (!is_array($last_backup))
|
77 |
return $last_backup;
|
142 |
return $value;
|
143 |
}
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
public static function admin_enqueue_scripts( $hook ) {
|
146 |
// wp_register_script( 'select2', MAINWP_WP_STREAM_URL . 'ui/select2/select2.min.js', array( 'jquery' ), '3.4.5', true );
|
147 |
// wp_register_style( 'select2', MAINWP_WP_STREAM_URL . 'ui/select2/select2.css', array(), '3.4.5' );
|
294 |
|
295 |
if ( current_user_can( self::SETTINGS_CAP ) ) {
|
296 |
self::erase_stream_records();
|
297 |
+
//MainWP_WP_Stream_Install::check_to_copy_data();
|
298 |
wp_redirect(
|
299 |
add_query_arg(
|
300 |
array(
|
412 |
ON `context`.`record_id` = `stream`.`ID`
|
413 |
LEFT JOIN {$wpdb->mainwp_reportsmeta} AS `meta`
|
414 |
ON `meta`.`record_id` = `stream`.`ID`
|
415 |
+
WHERE `stream`.`type` = 'stream'
|
416 |
{$where};" ;
|
417 |
|
418 |
|
includes/connector.php
CHANGED
@@ -61,7 +61,7 @@ abstract class MainWP_WP_Stream_Connector {
|
|
61 |
if ($hide_child_plugins == 'yes') {
|
62 |
return false;
|
63 |
} else {
|
64 |
-
$branding_text =
|
65 |
if (!empty($branding_text)) {
|
66 |
if ($args['slug'] == 'mainwp-child/mainwp-child.php') {
|
67 |
$args['name'] = $branding_text;
|
@@ -88,7 +88,7 @@ abstract class MainWP_WP_Stream_Connector {
|
|
88 |
$child_context = 'updraftplus_backups';
|
89 |
} elseif ( isset($contexts['wptimecapsule_backups']) ) {
|
90 |
$child_context = 'wptimecapsule_backups';
|
91 |
-
}
|
92 |
|
93 |
if ( !empty($child_context) ) {
|
94 |
if (is_array($args)) {
|
61 |
if ($hide_child_plugins == 'yes') {
|
62 |
return false;
|
63 |
} else {
|
64 |
+
$branding_text = MainWP_WP_Stream::get_instance()->get_branding_title();
|
65 |
if (!empty($branding_text)) {
|
66 |
if ($args['slug'] == 'mainwp-child/mainwp-child.php') {
|
67 |
$args['name'] = $branding_text;
|
88 |
$child_context = 'updraftplus_backups';
|
89 |
} elseif ( isset($contexts['wptimecapsule_backups']) ) {
|
90 |
$child_context = 'wptimecapsule_backups';
|
91 |
+
}
|
92 |
|
93 |
if ( !empty($child_context) ) {
|
94 |
if (is_array($args)) {
|
includes/install.php
CHANGED
@@ -36,50 +36,47 @@ class MainWP_WP_Stream_Install {
|
|
36 |
|
37 |
self::$table_prefix = $wpdb->prefix;
|
38 |
self::$import_connectors = array('comment', 'editor', 'installer', 'media', 'menus', 'posts', 'users', 'widgets');
|
39 |
-
|
|
|
40 |
}
|
41 |
|
42 |
-
|
43 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
44 |
return;
|
45 |
}
|
46 |
|
47 |
global $wpdb;
|
48 |
|
49 |
-
if (
|
50 |
-
$wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "mainwp_stream_meta'" ) !== $wpdb->prefix . "mainwp_stream_meta"
|
51 |
-
) {
|
52 |
-
self::$db_version = false;
|
53 |
-
} else {
|
54 |
-
if (false === get_option('mainwp_creport_first_time_activated')) {
|
55 |
-
$sql = "SELECT MIN( created ) AS first_time " .
|
56 |
-
"FROM {$wpdb->prefix}mainwp_stream " .
|
57 |
-
"WHERE created != '0000-00-00 00:00:00'";
|
58 |
-
$result = $wpdb->get_results( $sql, ARRAY_A );
|
59 |
-
$time = time();
|
60 |
-
if (isset($result[0]) && !empty($result[0]['first_time'])) {
|
61 |
-
$time = strtotime( $result[0]['first_time'] );
|
62 |
-
}
|
63 |
-
update_option('mainwp_creport_first_time_activated', $time);
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
if ( empty( self::$db_version ) ) {
|
68 |
self::install( self::$current );
|
69 |
-
self::copy_stream_db();
|
70 |
-
}
|
|
|
|
|
71 |
self::check_updates();
|
72 |
update_site_option( self::KEY, self::$current );
|
73 |
}
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
public static function check_to_copy_data() {
|
81 |
$stream_db_version = get_site_option( 'wp_stream_db' ); // store db version of the plugin stream 1.4.9
|
82 |
-
update_option('mainwp_child_reports_check_to_copy_data', 'yes');
|
83 |
return;
|
84 |
}
|
85 |
|
@@ -225,20 +222,20 @@ class MainWP_WP_Stream_Install {
|
|
225 |
// }
|
226 |
|
227 |
if ( ! isset( $_REQUEST['mainwp_wp_stream_update'] ) ) {
|
228 |
-
self::prompt_copy_data();
|
229 |
} else {
|
230 |
-
check_admin_referer( 'mainwp_wp_stream_update_db' );
|
231 |
-
if ( isset( $_REQUEST['mainwp_reports_copy_db_submit'] ) ) {
|
232 |
-
self::copy_stream_db();
|
233 |
-
|
234 |
-
} else if ( isset( $_REQUEST['mainwp_reports_continue_submit'] ) ) {
|
235 |
-
update_option('mainwp_child_reports_check_to_copy_data', '');
|
236 |
-
}
|
237 |
}
|
238 |
|
239 |
-
if ('yes' == get_option('mainwp_child_reports_copied_data_ok')) {
|
240 |
-
self::prompt_copy_data_status();
|
241 |
-
}
|
242 |
}
|
243 |
|
244 |
public static function prompt_copy_data() {
|
36 |
|
37 |
self::$table_prefix = $wpdb->prefix;
|
38 |
self::$import_connectors = array('comment', 'editor', 'installer', 'media', 'menus', 'posts', 'users', 'widgets');
|
39 |
+
//add_action( 'init', array( __CLASS__ , 'check' ) );
|
40 |
+
self::check();
|
41 |
}
|
42 |
|
43 |
+
public static function check() {
|
44 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
45 |
return;
|
46 |
}
|
47 |
|
48 |
global $wpdb;
|
49 |
|
50 |
+
// if ( empty( self::$db_version ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
self::install( self::$current );
|
52 |
+
// self::copy_stream_db();
|
53 |
+
// }
|
54 |
+
|
55 |
+
if ( version_compare( self::$db_version, self::$current, '!=') ) {
|
56 |
self::check_updates();
|
57 |
update_site_option( self::KEY, self::$current );
|
58 |
}
|
59 |
|
60 |
+
if (false === get_option('mainwp_creport_first_time_activated')) {
|
61 |
+
$sql = "SELECT MIN( created ) AS first_time " .
|
62 |
+
"FROM {$wpdb->prefix}mainwp_stream " .
|
63 |
+
"WHERE created != '0000-00-00 00:00:00'";
|
64 |
+
$result = $wpdb->get_results( $sql, ARRAY_A );
|
65 |
+
$time = time();
|
66 |
+
if (isset($result[0]) && !empty($result[0]['first_time'])) {
|
67 |
+
$time = strtotime( $result[0]['first_time'] );
|
68 |
+
}
|
69 |
+
update_option('mainwp_creport_first_time_activated', $time);
|
70 |
+
}
|
71 |
+
|
72 |
+
// if ('yes' == get_option('mainwp_child_reports_check_to_copy_data', false)) {
|
73 |
+
// add_action( 'all_admin_notices', array( __CLASS__, 'update_notice_hook' ) );
|
74 |
+
// }
|
75 |
}
|
76 |
|
77 |
public static function check_to_copy_data() {
|
78 |
$stream_db_version = get_site_option( 'wp_stream_db' ); // store db version of the plugin stream 1.4.9
|
79 |
+
//update_option('mainwp_child_reports_check_to_copy_data', 'yes');
|
80 |
return;
|
81 |
}
|
82 |
|
222 |
// }
|
223 |
|
224 |
if ( ! isset( $_REQUEST['mainwp_wp_stream_update'] ) ) {
|
225 |
+
// self::prompt_copy_data();
|
226 |
} else {
|
227 |
+
// check_admin_referer( 'mainwp_wp_stream_update_db' );
|
228 |
+
// if ( isset( $_REQUEST['mainwp_reports_copy_db_submit'] ) ) {
|
229 |
+
// self::copy_stream_db();
|
230 |
+
//
|
231 |
+
// } else if ( isset( $_REQUEST['mainwp_reports_continue_submit'] ) ) {
|
232 |
+
// //update_option('mainwp_child_reports_check_to_copy_data', '');
|
233 |
+
// }
|
234 |
}
|
235 |
|
236 |
+
// if ('yes' == get_option('mainwp_child_reports_copied_data_ok')) {
|
237 |
+
// self::prompt_copy_data_status();
|
238 |
+
// }
|
239 |
}
|
240 |
|
241 |
public static function prompt_copy_data() {
|
includes/settings.php
CHANGED
@@ -168,24 +168,26 @@ class MainWP_WP_Stream_Settings {
|
|
168 |
return apply_filters( 'mainwp_wp_stream_settings_option_key', $option_key );
|
169 |
}
|
170 |
|
171 |
-
public static function get_fields() {
|
172 |
-
if ( empty( self::$fields ) ) {
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
178 |
$chk_desc = 'If selected, the ' . $branding_name . ' Reports plugin will be left out from reports for this site.';
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
self::$fields = array(
|
186 |
'general' => array(
|
187 |
'title' => esc_html__( 'General', 'default' ),
|
188 |
-
'fields' => array(
|
189 |
array(
|
190 |
'name' => 'records_ttl',
|
191 |
'title' => esc_html__( 'Keep Records for', 'mainwp-child-reports' ),
|
@@ -201,10 +203,10 @@ class MainWP_WP_Stream_Settings {
|
|
201 |
'type' => 'select',
|
202 |
'choices' => array( '0' => '0', '30' => '30', '60' => '60', '90' => '90', '120' => '120'),
|
203 |
'desc' => '',
|
204 |
-
'default' => 30,
|
205 |
'current_value' => array( '30' ),
|
206 |
'after_field' => esc_html__( 'minutes', 'mainwp-child-reports' ) . $checkbox_hide_childs, // to add checkbox
|
207 |
-
),
|
208 |
array(
|
209 |
'name' => 'delete_all_records',
|
210 |
'title' => 'Reset ' . $branding_name . ' Reports Database',
|
@@ -221,7 +223,7 @@ class MainWP_WP_Stream_Settings {
|
|
221 |
),
|
222 |
),
|
223 |
),
|
224 |
-
);
|
225 |
}
|
226 |
|
227 |
return self::$fields;
|
@@ -270,7 +272,7 @@ class MainWP_WP_Stream_Settings {
|
|
270 |
public static function register_settings() {
|
271 |
$sections = self::get_fields();
|
272 |
|
273 |
-
register_setting( self::$option_key, self::$option_key, array( 'MainWP_WP_Stream_Settings', 'sanitize_settings' ) );
|
274 |
|
275 |
foreach ( $sections as $section_name => $section ) {
|
276 |
add_settings_section(
|
@@ -298,16 +300,16 @@ class MainWP_WP_Stream_Settings {
|
|
298 |
}
|
299 |
}
|
300 |
}
|
301 |
-
|
302 |
public static function sanitize_settings( $input ) {
|
303 |
if (isset($_POST['mainwp_creport_hide_child_plugins'])) {
|
304 |
update_option('mainwp_creport_hide_child_plugins', 'yes');
|
305 |
} else {
|
306 |
update_option('mainwp_creport_hide_child_plugins', 'no');
|
307 |
-
}
|
308 |
return $input;
|
309 |
}
|
310 |
-
|
311 |
public static function updated_option_trigger_flush_rules( $old_value, $new_value ) {
|
312 |
if ( is_array( $new_value ) && is_array( $old_value ) ) {
|
313 |
$new_value = ( array_key_exists( 'general_private_feeds', $new_value ) ) ? $new_value['general_private_feeds'] : 0;
|
@@ -334,8 +336,8 @@ class MainWP_WP_Stream_Settings {
|
|
334 |
$nonce = isset( $field['nonce'] ) ? $field['nonce'] : null;
|
335 |
$current_value = self::$options[ $section . '_' . $name ];
|
336 |
$option_key = self::$option_key;
|
337 |
-
|
338 |
-
|
339 |
if ( is_callable( $current_value ) ) {
|
340 |
$current_value = call_user_func( $current_value );
|
341 |
}
|
@@ -410,11 +412,11 @@ class MainWP_WP_Stream_Settings {
|
|
410 |
}
|
411 |
$output .= '</fieldset></div>';
|
412 |
break;
|
413 |
-
case 'select':
|
414 |
-
$current_value = (array) self::$options[ $section . '_' . $name ];
|
415 |
$default_value = isset( $default['value'] ) ? $default['value'] : '-1';
|
416 |
$default_name = isset( $default['name'] ) ? $default['name'] : 'Choose Setting';
|
417 |
-
|
418 |
$output = sprintf(
|
419 |
'<select name="%1$s[%2$s_%3$s]" id="%1$s_%2$s_%3$s">',
|
420 |
esc_attr( $option_key ),
|
@@ -633,7 +635,7 @@ class MainWP_WP_Stream_Settings {
|
|
633 |
|
634 |
return $return_labels;
|
635 |
}
|
636 |
-
|
637 |
public static function get_active_connectors() {
|
638 |
$excluded_connectors = self::get_excluded_by_key( 'connectors' );
|
639 |
$active_connectors = array_diff( array_keys( self::get_terms_labels( 'connector' ) ), $excluded_connectors );
|
168 |
return apply_filters( 'mainwp_wp_stream_settings_option_key', $option_key );
|
169 |
}
|
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 |
+
|
176 |
+
$branding_text = MainWP_WP_Stream::get_instance()->get_branding_title();
|
177 |
+
$branding_name = !empty($branding_text) ? $branding_text : 'MainWP Child';
|
178 |
+
$chk_label = 'Hide ' . $branding_name . ' Reports from reports';
|
179 |
+
|
180 |
$chk_desc = 'If selected, the ' . $branding_name . ' Reports plugin will be left out from reports for this site.';
|
181 |
+
$hide_child_plugins = get_option('mainwp_creport_hide_child_plugins', 'yes');
|
182 |
+
// to fix can not set default checked checkbox
|
183 |
+
$checkbox_hide_childs = '<tr><th scope="row"><label for="mainwp_creport_hide_child_plugins">' . $chk_label;
|
184 |
+
$checkbox_hide_childs .= '</label></th><td><label><input name="mainwp_creport_hide_child_plugins" id="mainwp_creport_hide_child_plugins" value="1" type="checkbox" ' . ($hide_child_plugins == 'yes' ? 'checked' : '') . '> ';
|
185 |
+
$checkbox_hide_childs .= '</label><p class="description">' . $chk_desc . '</p></td></tr>';
|
186 |
+
|
187 |
self::$fields = array(
|
188 |
'general' => array(
|
189 |
'title' => esc_html__( 'General', 'default' ),
|
190 |
+
'fields' => array(
|
191 |
array(
|
192 |
'name' => 'records_ttl',
|
193 |
'title' => esc_html__( 'Keep Records for', 'mainwp-child-reports' ),
|
203 |
'type' => 'select',
|
204 |
'choices' => array( '0' => '0', '30' => '30', '60' => '60', '90' => '90', '120' => '120'),
|
205 |
'desc' => '',
|
206 |
+
'default' => 30,
|
207 |
'current_value' => array( '30' ),
|
208 |
'after_field' => esc_html__( 'minutes', 'mainwp-child-reports' ) . $checkbox_hide_childs, // to add checkbox
|
209 |
+
),
|
210 |
array(
|
211 |
'name' => 'delete_all_records',
|
212 |
'title' => 'Reset ' . $branding_name . ' Reports Database',
|
223 |
),
|
224 |
),
|
225 |
),
|
226 |
+
);
|
227 |
}
|
228 |
|
229 |
return self::$fields;
|
272 |
public static function register_settings() {
|
273 |
$sections = self::get_fields();
|
274 |
|
275 |
+
register_setting( self::$option_key, self::$option_key, array( 'MainWP_WP_Stream_Settings', 'sanitize_settings' ) );
|
276 |
|
277 |
foreach ( $sections as $section_name => $section ) {
|
278 |
add_settings_section(
|
300 |
}
|
301 |
}
|
302 |
}
|
303 |
+
|
304 |
public static function sanitize_settings( $input ) {
|
305 |
if (isset($_POST['mainwp_creport_hide_child_plugins'])) {
|
306 |
update_option('mainwp_creport_hide_child_plugins', 'yes');
|
307 |
} else {
|
308 |
update_option('mainwp_creport_hide_child_plugins', 'no');
|
309 |
+
}
|
310 |
return $input;
|
311 |
}
|
312 |
+
|
313 |
public static function updated_option_trigger_flush_rules( $old_value, $new_value ) {
|
314 |
if ( is_array( $new_value ) && is_array( $old_value ) ) {
|
315 |
$new_value = ( array_key_exists( 'general_private_feeds', $new_value ) ) ? $new_value['general_private_feeds'] : 0;
|
336 |
$nonce = isset( $field['nonce'] ) ? $field['nonce'] : null;
|
337 |
$current_value = self::$options[ $section . '_' . $name ];
|
338 |
$option_key = self::$option_key;
|
339 |
+
|
340 |
+
|
341 |
if ( is_callable( $current_value ) ) {
|
342 |
$current_value = call_user_func( $current_value );
|
343 |
}
|
412 |
}
|
413 |
$output .= '</fieldset></div>';
|
414 |
break;
|
415 |
+
case 'select':
|
416 |
+
$current_value = (array) self::$options[ $section . '_' . $name ];
|
417 |
$default_value = isset( $default['value'] ) ? $default['value'] : '-1';
|
418 |
$default_name = isset( $default['name'] ) ? $default['name'] : 'Choose Setting';
|
419 |
+
|
420 |
$output = sprintf(
|
421 |
'<select name="%1$s[%2$s_%3$s]" id="%1$s_%2$s_%3$s">',
|
422 |
esc_attr( $option_key ),
|
635 |
|
636 |
return $return_labels;
|
637 |
}
|
638 |
+
|
639 |
public static function get_active_connectors() {
|
640 |
$excluded_connectors = self::get_excluded_by_key( 'connectors' );
|
641 |
$active_connectors = array_diff( array_keys( self::get_terms_labels( 'connector' ) ), $excluded_connectors );
|
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.9.
|
9 |
*/
|
10 |
|
11 |
/**
|
@@ -27,18 +27,17 @@
|
|
27 |
*/
|
28 |
|
29 |
class MainWP_WP_Stream {
|
30 |
-
|
31 |
const VERSION = '0.0.4'; // to check for update
|
32 |
-
|
33 |
public static $instance;
|
34 |
-
|
35 |
public $db = null;
|
36 |
-
|
37 |
public $network = null;
|
38 |
-
|
39 |
public static $notices = array();
|
40 |
|
41 |
-
|
|
|
|
|
|
|
42 |
define( 'MAINWP_WP_STREAM_PLUGIN', plugin_basename( __FILE__ ) );
|
43 |
define( 'MAINWP_WP_STREAM_DIR', plugin_dir_path( __FILE__ ) );
|
44 |
define( 'MAINWP_WP_STREAM_URL', plugin_dir_url( __FILE__ ) );
|
@@ -48,6 +47,13 @@ class MainWP_WP_Stream {
|
|
48 |
// Load filters polyfill
|
49 |
require_once MAINWP_WP_STREAM_INC_DIR . 'filter-input.php';
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
// Load DB helper class
|
52 |
require_once MAINWP_WP_STREAM_INC_DIR . 'db.php';
|
53 |
$this->db = new MainWP_WP_Stream_DB;
|
@@ -98,14 +104,78 @@ class MainWP_WP_Stream {
|
|
98 |
add_action( 'plugins_loaded', array( 'MainWP_WP_Stream_Live_Update', 'load' ) );
|
99 |
add_filter( 'plugin_row_meta', array( &$this, 'plugin_row_meta' ), 10, 2 );
|
100 |
// branding proccess
|
101 |
-
|
102 |
-
|
103 |
-
add_filter( 'all_plugins', array( $this, 'branding_child_plugin' ) );
|
104 |
-
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
add_action( 'plugins_loaded', array( __CLASS__, 'i18n' ) );
|
110 |
self::notice( __( 'MainWP Child Report requires PHP version 5.3+, plugin is currently NOT ACTIVE.', 'mainwp-child-reports' ) );
|
111 |
}
|
@@ -122,10 +192,6 @@ class MainWP_WP_Stream {
|
|
122 |
|
123 |
public function verify_database_present() {
|
124 |
|
125 |
-
if ( apply_filters( 'mainwp_wp_stream_no_tables', false ) ) {
|
126 |
-
return;
|
127 |
-
}
|
128 |
-
|
129 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
130 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
131 |
}
|
@@ -162,9 +228,8 @@ class MainWP_WP_Stream {
|
|
162 |
$uninstall_message = sprintf( __( 'Please <a href="%s">uninstall</a> the MainWP Child Reports plugin and activate it again.', 'mainwp-child-reports' ), admin_url( 'plugins.php#mainwp-child-reports' ) );
|
163 |
}
|
164 |
|
165 |
-
do_action( 'mainwp_wp_stream_before_db_notices' );
|
166 |
-
|
167 |
if ( ! empty( $database_message ) ) {
|
|
|
168 |
self::notice( $database_message );
|
169 |
if ( ! empty( $uninstall_message ) ) {
|
170 |
self::notice( $uninstall_message );
|
@@ -204,41 +269,67 @@ class MainWP_WP_Stream {
|
|
204 |
}
|
205 |
}
|
206 |
|
207 |
-
public
|
208 |
-
|
209 |
-
$class = __CLASS__;
|
210 |
-
self::$instance = new $class;
|
211 |
-
}
|
212 |
-
|
213 |
-
return self::$instance;
|
214 |
}
|
215 |
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
foreach ( $plugins as $key => $value ) {
|
219 |
$plugin_slug = basename( $key, '.php' );
|
220 |
if ( 'mainwp-child-reports' === $plugin_slug ) {
|
221 |
unset( $plugins[ $key ] );
|
222 |
}
|
223 |
}
|
224 |
-
|
225 |
return $plugins;
|
226 |
}
|
227 |
|
228 |
-
$
|
229 |
-
|
230 |
-
return $this->update_child_header( $plugins, $header );
|
231 |
} else {
|
232 |
return $plugins;
|
233 |
}
|
234 |
}
|
235 |
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
return $plugin_meta;
|
239 |
}
|
240 |
|
241 |
-
if ( !
|
242 |
return $plugin_meta;
|
243 |
}
|
244 |
// hide View details links
|
@@ -254,27 +345,7 @@ class MainWP_WP_Stream {
|
|
254 |
return $plugin_meta;
|
255 |
}
|
256 |
|
257 |
-
|
258 |
-
$cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
|
259 |
-
if ( $cancelled_branding ) {
|
260 |
-
return false;
|
261 |
-
}
|
262 |
-
|
263 |
-
// hide
|
264 |
-
if ( 'T' === get_option( 'mainwp_branding_child_hide' ) ) {
|
265 |
-
return true;
|
266 |
-
}
|
267 |
-
// branding
|
268 |
-
$header = get_option( 'mainwp_branding_plugin_header' );
|
269 |
-
if ( is_array( $header ) && ! empty( $header['name'] ) ) {
|
270 |
-
return true;
|
271 |
-
}
|
272 |
-
|
273 |
-
return false;
|
274 |
-
}
|
275 |
-
|
276 |
-
|
277 |
-
public function update_child_header( $plugins, $header ) {
|
278 |
$plugin_key = '';
|
279 |
foreach ( $plugins as $key => $value ) {
|
280 |
$plugin_slug = basename( $key, '.php' );
|
@@ -286,7 +357,7 @@ class MainWP_WP_Stream {
|
|
286 |
|
287 |
if ( ! empty( $plugin_key ) ) {
|
288 |
$plugin_data['Name'] = stripslashes( $header['name'] . " reports" );
|
289 |
-
|
290 |
$plugin_data['Author'] = stripslashes( $header['author'] );
|
291 |
$plugin_data['AuthorURI'] = stripslashes( $header['authoruri'] );
|
292 |
if ( ! empty( $header['pluginuri'] ) ) {
|
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.9.2
|
9 |
*/
|
10 |
|
11 |
/**
|
27 |
*/
|
28 |
|
29 |
class MainWP_WP_Stream {
|
|
|
30 |
const VERSION = '0.0.4'; // to check for update
|
|
|
31 |
public static $instance;
|
|
|
32 |
public $db = null;
|
33 |
+
private $plugin_slug;
|
34 |
public $network = null;
|
|
|
35 |
public static $notices = array();
|
36 |
|
37 |
+
public $branding_options = null;
|
38 |
+
public $branding_title = null;
|
39 |
+
|
40 |
+
private function __construct() {
|
41 |
define( 'MAINWP_WP_STREAM_PLUGIN', plugin_basename( __FILE__ ) );
|
42 |
define( 'MAINWP_WP_STREAM_DIR', plugin_dir_path( __FILE__ ) );
|
43 |
define( 'MAINWP_WP_STREAM_URL', plugin_dir_url( __FILE__ ) );
|
47 |
// Load filters polyfill
|
48 |
require_once MAINWP_WP_STREAM_INC_DIR . 'filter-input.php';
|
49 |
|
50 |
+
$_opts = $this->init_branding_options();
|
51 |
+
$hide = is_array($_opts) && isset($_opts['hide_child_reports']) && ($_opts['hide_child_reports'] == 'hide');
|
52 |
+
if ( ! $hide ) {
|
53 |
+
// Register settings page
|
54 |
+
add_filter( 'mainwp-child-init-subpages', array( $this, 'init_subpages' ) );
|
55 |
+
}
|
56 |
+
|
57 |
// Load DB helper class
|
58 |
require_once MAINWP_WP_STREAM_INC_DIR . 'db.php';
|
59 |
$this->db = new MainWP_WP_Stream_DB;
|
104 |
add_action( 'plugins_loaded', array( 'MainWP_WP_Stream_Live_Update', 'load' ) );
|
105 |
add_filter( 'plugin_row_meta', array( &$this, 'plugin_row_meta' ), 10, 2 );
|
106 |
// branding proccess
|
107 |
+
add_filter( 'all_plugins', array( $this, 'modify_plugin_header' ) );
|
108 |
+
}
|
|
|
|
|
109 |
|
110 |
+
public static function get_instance() {
|
111 |
+
if ( empty( self::$instance ) ) {
|
112 |
+
$class = __CLASS__;
|
113 |
+
self::$instance = new $class;
|
114 |
+
}
|
115 |
+
|
116 |
+
return self::$instance;
|
117 |
}
|
118 |
|
119 |
+
public function init_branding_options() {
|
120 |
+
return $this->get_branding_options();
|
121 |
+
}
|
122 |
+
|
123 |
+
public function get_branding_options() {
|
124 |
+
if ( $this->branding_options === null ) {
|
125 |
+
|
126 |
+
$opts = get_option( 'mainwp_child_branding_options' ); // settings from mainwp-child plugin
|
127 |
+
// this is new update
|
128 |
+
if ( is_array($opts) ) {
|
129 |
+
if (isset($opts['cancelled_branding'])) { // if it was set
|
130 |
+
$cancelled_branding = $opts['cancelled_branding'];
|
131 |
+
} else {
|
132 |
+
$disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
|
133 |
+
$preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
|
134 |
+
$cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding;
|
135 |
+
$opts['cancelled_branding'] = $cancelled_branding;
|
136 |
+
}
|
137 |
+
$branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
|
138 |
+
} else { // to compatible will old code
|
139 |
+
$opts = array();
|
140 |
+
$opts['hide'] = get_option( 'mainwp_branding_child_hide' );
|
141 |
+
$opts['branding_header'] = get_option( 'mainwp_branding_plugin_header' );
|
142 |
+
$cancelled_branding = ( get_option( 'mainwp_child_branding_disconnected' ) === 'yes' ) && ! get_option( 'mainwp_branding_preserve_branding' );
|
143 |
+
$opts['cancelled_branding'] = $cancelled_branding;
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( ! $cancelled_branding && ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) ) {
|
147 |
+
$this->branding_title = stripslashes( $branding_header['name'] );
|
148 |
+
} else {
|
149 |
+
$this->branding_title = '';
|
150 |
+
}
|
151 |
+
|
152 |
+
$this->branding_options = $opts;
|
153 |
+
}
|
154 |
+
|
155 |
+
return $this->branding_options;
|
156 |
+
}
|
157 |
+
|
158 |
+
public function init_subpages( $subPages = array() ) {
|
159 |
+
|
160 |
+
if ( is_network_admin() && ! is_plugin_active_for_network( MAINWP_WP_STREAM_PLUGIN ) ) {
|
161 |
+
return $subPages;
|
162 |
+
}
|
163 |
+
|
164 |
+
$branding_text = $this->branding_title;
|
165 |
+
|
166 |
+
if (empty($branding_text)) {
|
167 |
+
$branding_text = 'Child Reports';
|
168 |
+
} else {
|
169 |
+
$branding_text = $branding_text . ' Reports';
|
170 |
+
}
|
171 |
+
|
172 |
+
$subPages[] = array('title' => $branding_text, 'slug' => 'reports-page' , 'callback' => array( 'MainWP_WP_Stream_Admin', 'render_reports_page' ) , 'load_callback' => array( 'MainWP_WP_Stream_Admin', 'register_list_table' ));
|
173 |
+
$subPages[] = array('title' => $branding_text . ' Settings', 'slug' => 'reports-settings' , 'callback' => array( 'MainWP_WP_Stream_Admin', 'render_reports_settings' ) );
|
174 |
+
|
175 |
+
return $subPages;
|
176 |
+
}
|
177 |
+
|
178 |
+
static function fail_php_version() {
|
179 |
add_action( 'plugins_loaded', array( __CLASS__, 'i18n' ) );
|
180 |
self::notice( __( 'MainWP Child Report requires PHP version 5.3+, plugin is currently NOT ACTIVE.', 'mainwp-child-reports' ) );
|
181 |
}
|
192 |
|
193 |
public function verify_database_present() {
|
194 |
|
|
|
|
|
|
|
|
|
195 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
196 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
197 |
}
|
228 |
$uninstall_message = sprintf( __( 'Please <a href="%s">uninstall</a> the MainWP Child Reports plugin and activate it again.', 'mainwp-child-reports' ), admin_url( 'plugins.php#mainwp-child-reports' ) );
|
229 |
}
|
230 |
|
|
|
|
|
231 |
if ( ! empty( $database_message ) ) {
|
232 |
+
do_action( 'mainwp_wp_stream_before_db_notices' );
|
233 |
self::notice( $database_message );
|
234 |
if ( ! empty( $uninstall_message ) ) {
|
235 |
self::notice( $uninstall_message );
|
269 |
}
|
270 |
}
|
271 |
|
272 |
+
public function get_branding_title() {
|
273 |
+
return $this->branding_title;
|
|
|
|
|
|
|
|
|
|
|
274 |
}
|
275 |
|
276 |
+
|
277 |
+
public function modify_plugin_header( $plugins ) {
|
278 |
+
$_opts = $this->branding_options;
|
279 |
+
$is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
|
280 |
+
$cancelled_branding = isset( $_opts['cancelled_branding'] ) ? $_opts['cancelled_branding'] : false;
|
281 |
+
$branding_header = isset( $_opts['branding_header'] ) ? $_opts['branding_header'] : '';
|
282 |
+
|
283 |
+
if ( $cancelled_branding ) {
|
284 |
+
return $plugins;
|
285 |
+
}
|
286 |
+
|
287 |
+
if ( 'T' === $is_hide ) {
|
288 |
foreach ( $plugins as $key => $value ) {
|
289 |
$plugin_slug = basename( $key, '.php' );
|
290 |
if ( 'mainwp-child-reports' === $plugin_slug ) {
|
291 |
unset( $plugins[ $key ] );
|
292 |
}
|
293 |
}
|
|
|
294 |
return $plugins;
|
295 |
}
|
296 |
|
297 |
+
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
|
298 |
+
return $this->update_plugin_header( $plugins, $branding_header );
|
|
|
299 |
} else {
|
300 |
return $plugins;
|
301 |
}
|
302 |
}
|
303 |
|
304 |
+
|
305 |
+
public function is_branding() {
|
306 |
+
|
307 |
+
$_opts = $this->branding_options;
|
308 |
+
$is_hide = isset( $_opts['hide'] ) ? $_opts['hide'] : '';
|
309 |
+
$cancelled_branding = isset( $_opts['cancelled_branding'] ) ? $_opts['cancelled_branding'] : false;
|
310 |
+
$branding_header = isset( $_opts['branding_header'] ) ? $_opts['branding_header'] : array();
|
311 |
+
|
312 |
+
if ( $cancelled_branding ) {
|
313 |
+
return false;
|
314 |
+
}
|
315 |
+
// hide
|
316 |
+
if ( 'T' === $is_hide ) {
|
317 |
+
return true;
|
318 |
+
}
|
319 |
+
if ( is_array( $branding_header ) && !empty( $branding_header['name'] ) ) {
|
320 |
+
return true;
|
321 |
+
}
|
322 |
+
return false;
|
323 |
+
|
324 |
+
}
|
325 |
+
|
326 |
+
|
327 |
+
public function plugin_row_meta( $plugin_meta, $plugin_file ) {
|
328 |
+
if ( $this->plugin_slug !== $plugin_file ) {
|
329 |
return $plugin_meta;
|
330 |
}
|
331 |
|
332 |
+
if ( ! $this->is_branding() ) {
|
333 |
return $plugin_meta;
|
334 |
}
|
335 |
// hide View details links
|
345 |
return $plugin_meta;
|
346 |
}
|
347 |
|
348 |
+
public function update_plugin_header( $plugins, $header ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
$plugin_key = '';
|
350 |
foreach ( $plugins as $key => $value ) {
|
351 |
$plugin_slug = basename( $key, '.php' );
|
357 |
|
358 |
if ( ! empty( $plugin_key ) ) {
|
359 |
$plugin_data['Name'] = stripslashes( $header['name'] . " reports" );
|
360 |
+
$plugin_data['Description'] = stripslashes( $header['description'] );
|
361 |
$plugin_data['Author'] = stripslashes( $header['author'] );
|
362 |
$plugin_data['AuthorURI'] = stripslashes( $header['authoruri'] );
|
363 |
if ( ! empty( $header['pluginuri'] ) ) {
|
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: 5.0
|
10 |
-
Stable tag: 1.9.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.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 |
= 1.9.1 - 11-13-2018 =
|
40 |
* Fixed: an issue with missing data fields
|
41 |
* Updated: WooCommerce order notes excluded from showing as comments
|
6 |
Author URI: https://mainwp.com
|
7 |
Plugin URI: https://mainwp.com
|
8 |
Requires at least: 3.6
|
9 |
+
Tested up to: 5.0.3
|
10 |
+
Stable tag: 1.9.2
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
36 |
|
37 |
== Changelog ==
|
38 |
|
39 |
+
= 1.9.2 - 1-30-2019 =
|
40 |
+
* Fixed: an issue with cleaning the plugin database tables on some setups
|
41 |
+
* Updated: MySQL query improvements
|
42 |
+
|
43 |
= 1.9.1 - 11-13-2018 =
|
44 |
* Fixed: an issue with missing data fields
|
45 |
* Updated: WooCommerce order notes excluded from showing as comments
|