WP_Paused_Extensions_Storage::set() WordPress Method

This is the WP_Paused_Extensions_Storage::set() method. It is used to store a paused extension in the database.

WP_Paused_Extensions_Storage::set( string $extension, array $error ) #

Records an extension error.


Description

Only one error is stored per extension, with subsequent errors for the same extension overriding the previously stored error.


Top ↑

Parameters

$extension

(string)(Required)Plugin or theme directory name.

$error

(array)(Required)Error information returned by error_get_last().

  • 'type'
    (int) The error type.
  • 'file'
    (string) The name of the file in which the error occurred.
  • 'line'
    (int) The line number in which the error occurred.
  • 'message'
    (string) The error message.


Top ↑

Return

(bool) True on success, false on failure.


Top ↑

Source

File: wp-includes/class-wp-paused-extensions-storage.php

	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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.