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.
- 'id'
Return Return
([type])
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 ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.1 | Introduced. |