On this page
WP_Paused_Extensions_Storage::set( string $extension, array $error ): bool
Records an extension error.
Description
Only one error is stored per extension, with subsequent errors for the same extension overriding the previously stored error.
Parameters
$extensionstring Required-
Plugin or theme directory name.
$errorarray Required-
Error information returned by
error_get_last().
typeintThe error type.filestringThe name of the file in which the error occurred.lineintThe line number in which the error occurred.messagestringThe error message.
Return
bool True on success, false on failure.
Source
File: wp-includes/class-wp-paused-extensions-storage.php. View all references
public function set( $extension, $error ) {
if ( ! $this->is_api_loaded() ) {
return false;
}
$option_name = $this->get_option_name();
if ( ! $option_name ) {
return false;
}
$paused_extensions = (array) get_option( $option_name, array() );
// Do not update if the error is already stored.
if ( isset( $paused_extensions[ $this->type ][ $extension ] ) && $paused_extensions[ $this->type ][ $extension ] === $error ) {
return true;
}
$paused_extensions[ $this->type ][ $extension ] = $error;
return update_option( $option_name, $paused_extensions );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Paused_Extensions_Storage::is_api_loaded() wp-includes/class-wp-paused-extensions-storage.php | Checks whether the underlying API to store paused extensions is loaded. |
| WP_Paused_Extensions_Storage::get_option_name() wp-includes/class-wp-paused-extensions-storage.php | Get the option name for storing paused extensions. |
| update_option() wp-includes/option.php | Updates the value of an option that was already added. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Changelog
| Version | Description |
|---|---|
| 5.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_paused_extensions_storage/set