get_var( $wpdb->prepare( 'SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema = %s AND table_name LIKE %s', DB_NAME, $wpdb->esc_like( $wpdb->prefix ) . '%' ) ); $db_size_mb = $db_size / 1024 / 1024; if ( $db_size_mb > 1000 ) { $complexity_score += 25; $factors[] = __( 'Very large database (over 1GB)', '0-day-analytics' ); } elseif ( $db_size_mb > 500 ) { $complexity_score += 15; $factors[] = __( 'Large database (500MB-1GB)', '0-day-analytics' ); } elseif ( $db_size_mb > 100 ) { $complexity_score += 5; $factors[] = __( 'Medium database size', '0-day-analytics' ); } // Factor 2: Plugin count. $plugin_count = count( get_option( 'active_plugins', array() ) ); if ( $plugin_count > 40 ) { $complexity_score += 20; $factors[] = sprintf( /* translators: %d: number of plugins */ __( 'Many active plugins (%d)', '0-day-analytics' ), $plugin_count ); } elseif ( $plugin_count > 25 ) { $complexity_score += 10; $factors[] = sprintf( /* translators: %d: number of plugins */ __( 'Above average plugin count (%d)', '0-day-analytics' ), $plugin_count ); } // Factor 3: Custom tables. $core_table_count = 12; $total_tables = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM information_schema.TABLES WHERE table_schema = %s AND table_name LIKE %s', DB_NAME, $wpdb->esc_like( $wpdb->prefix ) . '%' ) ); $custom_table_count = max( 0, $total_tables - $core_table_count ); if ( $custom_table_count > 30 ) { $complexity_score += 15; $factors[] = sprintf( /* translators: %d: number of custom tables */ __( 'Many custom database tables (%d)', '0-day-analytics' ), $custom_table_count ); } elseif ( $custom_table_count > 10 ) { $complexity_score += 5; } // Factor 4: Multisite. if ( is_multisite() ) { $complexity_score += 30; $factors[] = __( 'Multisite installation', '0-day-analytics' ); } // Factor 5: E-commerce. if ( class_exists( 'WooCommerce' ) ) { $complexity_score += 15; $factors[] = __( 'WooCommerce store', '0-day-analytics' ); } // Factor 6: Membership/LMS. $membership_plugins = array( 'memberpress/memberpress.php', 'learnpress/learnpress.php', 'learndash/learndash.php', 'pmpro/paid-memberships-pro.php', ); foreach ( $membership_plugins as $plugin ) { if ( is_plugin_active( $plugin ) ) { $complexity_score += 10; $factors[] = __( 'Membership or LMS site', '0-day-analytics' ); break; } } // Factor 7: MU-Plugins. if ( is_dir( WPMU_PLUGIN_DIR ) ) { $mu_files = glob( WPMU_PLUGIN_DIR . '/*.php' ); if ( ! empty( $mu_files ) ) { $complexity_score += 5; $factors[] = __( 'Has must-use plugins', '0-day-analytics' ); } } // Determine complexity level. $complexity_level = 'simple'; if ( $complexity_score >= 60 ) { $complexity_level = 'complex'; } elseif ( $complexity_score >= 30 ) { $complexity_level = 'moderate'; } $details = array( 'complexity_score' => $complexity_score, 'complexity_level' => $complexity_level, 'factors' => $factors, 'database_size_mb' => round( $db_size_mb, 2 ), 'plugin_count' => $plugin_count, 'custom_tables' => $custom_table_count, 'is_multisite' => is_multisite(), ); if ( 'complex' === $complexity_level ) { return static::warning( sprintf( /* translators: %d: complexity score */ __( 'This site has high migration complexity (score: %d/100). Plan carefully and consider professional migration services for a smooth transition.', '0-day-analytics' ), min( 100, $complexity_score ) ), ! empty( $factors ) ? sprintf( /* translators: %s: list of complexity factors */ __( 'Key factors: %s. Test thoroughly on a staging site before going live.', '0-day-analytics' ), implode( ', ', $factors ) ) : __( 'Test thoroughly on a staging site before going live.', '0-day-analytics' ), $details ); } if ( 'moderate' === $complexity_level ) { return static::info( sprintf( /* translators: %d: complexity score */ __( 'This site has moderate migration complexity (score: %d/100). Standard migration tools should work, but allow extra time for testing.', '0-day-analytics' ), $complexity_score ), $details ); } return static::pass( sprintf( /* translators: %d: complexity score */ __( 'This site has low migration complexity (score: %d/100). A standard migration process should work smoothly.', '0-day-analytics' ), $complexity_score ), $details ); } } }