$tab_name ) {
$tab_url = add_query_arg( array(
'tab' => $tab_id
) );
$tab_url = remove_query_arg( array(
'mashsb-message'
), $tab_url );
$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
echo '' . wp_kses_post( $tab_name ) . '';
}
?>
$value ) {
$result[ $key ] = mashsb_object_to_array( $value );
}
return $result;
}
return $data;
}
/**
* Process a settings import from a json file
*
* @since 2.1.6
* @return void
*/
function mashsb_tools_import_export_process_import() {
if( empty( $_POST['mashsb_import_nonce'] ) )
return;
if( ! wp_verify_nonce( $_POST['mashsb_import_nonce'], 'mashsb_import_nonce' ) )
return;
if( ! current_user_can( 'update_plugins' ) )
return;
if( mashsb_get_file_extension( $_FILES['import_file']['name'] ) != 'json' ) {
wp_die( esc_html__( 'Please upload a valid .json file', 'mashsb' ) );
}
$import_file = $_FILES['import_file']['tmp_name'];
if( empty( $import_file ) ) {
wp_die( esc_html__( 'Please upload a file to import', 'mashsb' ) );
}
// Retrieve the settings from the file and convert the json object to an array
$settings = mashsb_object_to_array( json_decode( file_get_contents( $import_file ) ) );
update_option( 'mashsb_settings', $settings );
wp_safe_redirect( admin_url( 'admin.php?page=mashsb-tools&mashsb-message=settings-imported' ) ); exit;
}
add_action( 'mashsb_import_settings', 'mashsb_tools_import_export_process_import' );
/**
* Display the system info tab
*
* @since 2.1.6
* @return void
* @change 2.3.1
*/
function mashsb_tools_sysinfo_display() {
if( ! current_user_can( 'update_plugins' ) ) {
return;
}
?>
Name . ' ' . $theme_data->Version;
}
$return = '### Begin System Info ###' . "\n\n";
// Start with the basics...
$return .= '-- Site Info' . "\n\n";
$return .= 'Site URL: ' . site_url() . "\n";
$return .= 'Home URL: ' . home_url() . "\n";
$return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
$return = apply_filters( 'mashsb_sysinfo_after_site_info', $return );
// The local users' browser information, handled by the Browser class
$return .= "\n" . '-- User Browser' . "\n\n";
$return .= $browser;
$return = apply_filters( 'mashsb_sysinfo_after_user_browser', $return );
// WordPress configuration
$return .= "\n" . '-- WordPress Configuration' . "\n\n";
$return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
$return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
$return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
$return .= 'Active Theme: ' . $theme . "\n";
$return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
// Only show page specs if frontpage is set to 'page'
if( get_option( 'show_on_front' ) == 'page' ) {
$front_page_id = get_option( 'page_on_front' );
$blog_page_id = get_option( 'page_for_posts' );
$return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
$return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
}
// Make sure wp_remote_post() is working
$request['cmd'] = '_notify-validate';
$params = array(
'sslverify' => false,
'timeout' => 60,
'user-agent' => 'MASHSB/' . MASHSB_VERSION,
'body' => $request
);
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
$WP_REMOTE_POST = 'wp_remote_post() works';
} else {
$WP_REMOTE_POST = 'wp_remote_post() does not work';
}
$return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
$return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
$return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
$return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
$return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
$return = apply_filters( 'mashsb_sysinfo_after_wordpress_config', $return );
// MASHSB configuration
$return .= "\n" . '-- MASHSB Configuration' . "\n\n";
$return .= 'Version: ' . MASHSB_VERSION . "\n";
$return .= 'Upgraded From: ' . get_option( 'mashsb_version_upgraded_from', 'None' ) . "\n";
$return = apply_filters( 'mashsb_sysinfo_after_mashsb_config', $return );
// WordPress active plugins
$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
$plugins = get_plugins();
$active_plugins = get_option( 'active_plugins', array() );
foreach( $plugins as $plugin_path => $plugin ) {
if( !in_array( $plugin_path, $active_plugins ) )
continue;
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
}
$return = apply_filters( 'mashsb_sysinfo_after_wordpress_plugins', $return );
// WordPress inactive plugins
$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
foreach( $plugins as $plugin_path => $plugin ) {
if( in_array( $plugin_path, $active_plugins ) )
continue;
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
}
$return = apply_filters( 'mashsb_sysinfo_after_wordpress_plugins_inactive', $return );
if( is_multisite() ) {
// WordPress Multisite active plugins
$return .= "\n" . '-- Network Active Plugins' . "\n\n";
$plugins = wp_get_active_network_plugins();
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
foreach( $plugins as $plugin_path ) {
$plugin_base = plugin_basename( $plugin_path );
if( !array_key_exists( $plugin_base, $active_plugins ) )
continue;
$plugin = get_plugin_data( $plugin_path );
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
}
$return = apply_filters( 'mashsb_sysinfo_after_wordpress_ms_plugins', $return );
}
// Server configuration (really just versioning)
$return .= "\n" . '-- Webserver Configuration' . "\n\n";
$return .= 'PHP Version: ' . PHP_VERSION . "\n";
$return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
$return .= 'Webserver Info: ' . esc_html($_SERVER['SERVER_SOFTWARE']) . "\n";
$return = apply_filters( 'mashsb_sysinfo_after_webserver_config', $return );
// PHP configs... now we're getting to the important stuff
$return .= "\n" . '-- PHP Configuration' . "\n\n";
$return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
$return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
$return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
$return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
$return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
$return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
$return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
$return = apply_filters( 'mashsb_sysinfo_after_php_config', $return );
// PHP extensions and such
$return .= "\n" . '-- PHP Extensions' . "\n\n";
$return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
$return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
$return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
$return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
$return = apply_filters( 'mashsb_sysinfo_after_php_ext', $return );
$return .= "\n" . '### End System Info ###';
return $return;
}