Duplicates the element setting.
Description
See also
Parameters
- $element_id
-
(int) (Required) New parent element ID to use for the element setting.
Return
(awsmug\Torro_Forms\DB_Objects\Element_Settings\Element_Setting|awsmug\Torro_Forms\DB_Objects\Element_Settings\WP_Error) New element setting object on success, error object on failure.
Source
File: src/db-objects/element-settings/element-setting.php
public function duplicate( $element_id ) { $new_element_setting = $this->manager->create(); foreach ( $this->to_json() as $key => $value ) { if ( 'id' === $key ) { continue; } if ( 'element_id' === $key ) { $new_element_setting->element_id = $element_id; continue; } $new_element_setting->$key = $value; } $status = $new_element_setting->sync_upstream(); if ( is_wp_error( $status ) ) { return $status; } return $new_element_setting; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |