A WordPress-centric search engine for devs and theme authors



wp_record_extension_error ›

Since5.1.0
Deprecatedn/a
wp_record_extension_error ( $error )
Parameters:
  • (array) $error Error that was triggered.
    Required: Yes
Returns:
  • (bool) Whether the error was correctly recorded.
Defined at:
Codex:

Records the extension error as a database option.



Source

function wp_record_extension_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 ( 0 === strpos( $error_file, $wp_plugin_dir ) ) {
		$callback = 'wp_paused_plugins';
		$path     = str_replace( $wp_plugin_dir . '/', '', $error_file );
	} else {
		foreach ( $wp_theme_directories as $theme_directory ) {
			$theme_directory = wp_normalize_path( $theme_directory );
			if ( 0 === strpos( $error_file, $theme_directory ) ) {
				$callback = 'wp_paused_themes';
				$path     = str_replace( $theme_directory . '/', '', $error_file );
			}
		}
	}

	if ( empty( $callback ) || empty( $path ) ) {
		return false;
	}

	$parts     = explode( '/', $path );
	$extension = array_shift( $parts );

	return call_user_func( $callback )->record( $extension, $error );
}