'upstream_debug', 'title' => __( 'UpStream Debug Log', 'upstream' ), 'href' => admin_url( static::ADMIN_PAGE_URL_FRAGMENT . static::PAGE_SLUG ), ); $wp_admin_bar->add_menu( $args ); } /** * Admin menu hook * * @since 1.0.0 */ public static function admin_menu() { // Admin menu. add_submenu_page( admin_url( static::ADMIN_PAGE_URL_FRAGMENT . static::PAGE_SLUG ), __( 'Debug Log' ), __( 'Debug Log' ), 'activate_plugins', 'upstream_debug_log', array( __CLASS__, 'view_log_page' ) ); } /** * View log page * * @since 1.0.0 */ public static function view_log_page() { static::handle_actions(); global $wp_version; $is_log_found = file_exists( static::$path ); // Get all the plugins and versions. $plugins = get_plugins(); $plugins_data = array(); $server_data = wp_unslash( $_SERVER ); foreach ( $plugins as $plugin => $data ) { $plugins_data[ $plugin ] = ( is_plugin_active( $plugin ) ? 'ACTIVATED' : 'deactivated' ) . ' [' . $data['Version'] . ']'; } $user_info = get_userdata( wp_get_current_user()->ID ); $debug_data = array( 'php' => array( 'version' => PHP_VERSION, 'os' => PHP_OS, 'date_default_timezone_get' => date_default_timezone_get(), 'date(e)' => gmdate( 'e' ), 'date(T)' => gmdate( 'T' ), 'browser_str' => sanitize_text_field( $server_data['HTTP_USER_AGENT'] ), ), 'wordpress' => array( 'version' => $wp_version, 'date_format' => get_option( 'date_format' ), 'time_format' => get_option( 'time_format' ), 'timezone_string' => get_option( 'timezone_string' ), 'gmt_offset' => get_option( 'gmt_offset' ), 'plugins' => $plugins_data, ), 'user' => array( 'uid' => $user_info->ID, 'roles' => $user_info->roles, 'username' => $user_info->user_email, 'capabilities' => $user_info->allcaps, ), 'theme' => array( 'template' => get_template(), 'template_dir' => get_template_directory(), ), ); $context = array( 'label' => array( 'title' => __( 'UpStream Debug Log', 'upstream' ), 'file_info' => __( 'File info', 'upstream' ), 'path' => __( 'Path', 'upstream' ), 'log_content' => __( 'Log content', 'upstream' ), 'size' => __( 'Size', 'upstream' ), 'creation_time' => __( 'Created on', 'upstream' ), 'modification_time' => __( 'Modified on', 'upstream' ), 'delete_file' => __( 'Delete file', 'upstream' ), 'debug_data' => __( 'Debug data', 'upstream' ), 'log_file' => __( 'Log File', 'upstream' ), ), 'message' => array( 'log_not_found' => __( 'Log file not found.', 'upstream' ), 'contact_support_tip' => __( 'If you see any error or look for information regarding UpStream, please don\'t hesitate to contact the support team. E-mail us:', 'upstream' ), 'click_to_delete' => __( 'Click to delete the log file. Be careful, this operation can not be undone. ', 'upstream' ), ), 'contact_email' => 'help@upstreamplugin.com', 'link_delete' => admin_url( sprintf( 'admin.php?page=%s&action=%s&_wpnonce=%s', static::PAGE_SLUG, static::ACTION_DELETE_LOG, wp_create_nonce( static::ACTION_DELETE_LOG ) ) ), 'is_log_found' => $is_log_found, 'file' => array( 'path' => static::$path, 'size' => $is_log_found ? round( filesize( static::$path ) / 1024, 2 ) : 0, 'modification_time' => $is_log_found ? gmdate( 'Y-m-d H:i:s T O', filemtime( static::$path ) ) : '', 'content' => $is_log_found ? file_get_contents( static::$path ) : '', ), 'debug_data' => print_r( $debug_data, true ), 'messages' => static::$messages, ); ?>


getMessage(), $s->getTrace() ); } else { UpStream_Debug::write( print_r( $s, true ), debug_backtrace() ); } } }