141 | | /* translators: Do not translate LINK, EXPIRES, CAUSE, DETAILS, SITEURL, PAGEURL, SUPPORT: those are placeholders. */ |
| 141 | /** |
| 142 | * Filters the debug information included in the fatal error protection email. |
| 143 | * |
| 144 | * @since 5.3.0 |
| 145 | * |
| 146 | * @param $message array An associated array of debug information. |
| 147 | */ |
| 148 | $debug = apply_filters( 'recovery_email_debug_info', $this->get_debug( $extension ) ); |
| 149 | |
| 150 | /* translators: Do not translate LINK, EXPIRES, CAUSE, DETAILS, SITEURL, PAGEURL, SUPPORT. DEBUG: those are placeholders. */ |
| 277 | |
| 278 | /** |
| 279 | * Return the details for a single plugin based on the extension data from an error. |
| 280 | * |
| 281 | * @param array $extension The extension that caused the error. |
| 282 | * |
| 283 | * @return bool|array A plugin array {@see get_plugins()} or `false` if no plugin was found. |
| 284 | */ |
| 285 | private function get_plugin( $extension ) { |
| 286 | if ( ! function_exists( 'get_plugins' ) ) { |
| 287 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 288 | } |
| 289 | |
| 290 | $plugins = get_plugins(); |
| 291 | |
| 292 | // Assume plugin main file name first since it is a common convention. |
| 293 | if ( isset( $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ] ) ) { |
| 294 | return $plugins[ "{$extension['slug']}/{$extension['slug']}.php" ]; |
| 295 | } else { |
| 296 | foreach ( $plugins as $file => $plugin_data ) { |
| 297 | if ( 0 === strpos( $file, "{$extension['slug']}/" ) || $file === $extension['slug'] ) { |
| 298 | return $plugin_data; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | return false; |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * Return debug information in an easy to manipulate format. |
| 308 | * |
| 309 | * @param array $extension The extension that caused the error. |
| 310 | * |
| 311 | * @return array An associated array of debug information. |
| 312 | */ |
| 313 | private function get_debug( $extension ) { |
| 314 | $theme = wp_get_theme(); |
| 315 | $wp_version = get_bloginfo( 'version' ); |
| 316 | |
| 317 | if ( $extension ) { |
| 318 | $plugin = $this->get_plugin( $extension ); |
| 319 | } else { |
| 320 | $plugin = null; |
| 321 | } |
| 322 | |
| 323 | $debug = array( |
| 324 | // translators: %s: Current WordPress version number. |
| 325 | 'wp' => sprintf( |
| 326 | __( 'WordPress version %s' ), |
| 327 | $wp_version |
| 328 | ), |
| 329 | 'theme' => sprintf( |
| 330 | // translators: 1: Current active theme name. 2: Current active theme version. |
| 331 | __( 'Current theme: %1$s (version %2$s)' ), |
| 332 | $theme->get( 'Name' ), |
| 333 | $theme->get( 'Version' ) |
| 334 | ), |
| 335 | ); |
| 336 | |
| 337 | if ( null !== $plugin ) { |
| 338 | $debug['plugin'] = sprintf( |
| 339 | // translators: 1: The failing plugins name. 2: The failing plugins version. |
| 340 | __( 'Current plugin: %1$s (version %2$s)' ), |
| 341 | $plugin['Name'], |
| 342 | $plugin['Version'] |
| 343 | ); |
| 344 | } |
| 345 | |
| 346 | $debug['php'] = sprintf( |
| 347 | // translators: %s: The currently used PHP version. |
| 348 | __( 'PHP version %s' ), |
| 349 | PHP_VERSION |
| 350 | ); |
| 351 | |
| 352 | return $debug; |
| 353 | } |