WP_Recovery_Mode::get_extension_for_error()
Gets the extension that the error occurred in.
Метод класса: WP_Recovery_Mode{}
Хуков нет.
Возвращает
Массив|false
. Extension details.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_extension_for_error( $error );
- $error(массив) (обязательный)
- Error details from error_get_last().
Заметки
- Global. Массив. $wp_theme_directories
Список изменений
С версии 5.2.0 | Введена. |
Код WP_Recovery_Mode::get_extension_for_error() WP Recovery Mode::get extension for error WP 6.5.2
protected function get_extension_for_error( $error ) { global $wp_theme_directories; if ( ! isset( $error['file'] ) ) { return false; } if ( ! defined( 'WP_PLUGIN_DIR' ) ) { return false; } $error_file = wp_normalize_path( $error['file'] ); $wp_plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); if ( str_starts_with( $error_file, $wp_plugin_dir ) ) { $path = str_replace( $wp_plugin_dir . '/', '', $error_file ); $parts = explode( '/', $path ); return array( 'type' => 'plugin', 'slug' => $parts[0], ); } if ( empty( $wp_theme_directories ) ) { return false; } foreach ( $wp_theme_directories as $theme_directory ) { $theme_directory = wp_normalize_path( $theme_directory ); if ( str_starts_with( $error_file, $theme_directory ) ) { $path = str_replace( $theme_directory . '/', '', $error_file ); $parts = explode( '/', $path ); return array( 'type' => 'theme', 'slug' => $parts[0], ); } } return false; }