LLMS_REST_Database_Resource::update( array $data )

Update a resource.


Parameters Parameters

$data

(array) (Required) Array of data to update.

  • 'id'
    (int) (Required). Resource ID.


Top ↑

Return Return

([type])


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-database-resource.php

	public function update( $data ) {

		if ( empty( $data['id'] ) ) {
			// Translators: %s = name of the resource type (for example: "API Key").
			return new WP_Error( 'llms_rest_' . $this->id . '_missing_id', sprintf( __( 'No %s ID was supplied.', 'lifterlms' ), $this->get_i18n_name() ) );
		}

		$obj = $this->get( $data['id'] );
		if ( ! $obj || ! $obj->exists() ) {
			// Translators: %s = name of the resource type (for example: "API Key").
			return new WP_Error( 'llms_rest_' . $this->id . '_invalid_' . $this->id, sprintf( __( 'The requested %s could not be located.', 'lifterlms' ), $this->get_i18n_name() ) );
		}

		$data = $this->update_prepare( $data );
		if ( is_wp_error( $data ) ) {
			return $data;
		}

		return $this->save( $obj, $data );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.