Code Duplication    Length = 26-26 lines in 2 locations

core/Datastore/Key_Value_Datastore.php 1 location

@@ 185-210 (lines=26) @@
182
	 *
183
	 * @param Field $field The field to save.
184
	 */
185
	public function save( Field $field ) {
186
		$value_set = $field->get_full_value();
187
188
		if ( empty( $value_set ) && $field->get_value_set()->keepalive() ) {
189
			$storage_key = $this->key_toolset->get_storage_key(
190
				$field->is_simple_root_field(),
191
				$this->get_full_hierarchy_for_field( $field ),
192
				$this->get_full_hierarchy_index_for_field( $field ),
193
				0,
194
				$this->key_toolset::KEEPALIVE_PROPERTY
195
			);
196
			$this->save_key_value_pair( $storage_key, '' );
197
		}
198
		foreach ( $value_set as $value_group_index => $values ) {
199
			foreach ( $values as $property => $value ) {
200
				$storage_key = $this->key_toolset->get_storage_key(
201
					$field->is_simple_root_field(),
202
					$this->get_full_hierarchy_for_field( $field ),
203
					$this->get_full_hierarchy_index_for_field( $field ),
204
					$value_group_index,
205
					$property
206
				);
207
				$this->save_key_value_pair( $storage_key, $value );
208
			}
209
		}
210
	}
211
}
212

core/Datastore/Theme_Options_Datastore.php 1 location

@@ 73-98 (lines=26) @@
70
	 *
71
	 * @param Field $field The field to save.
72
	 */
73
	public function save( Field $field ) {
74
		$value_set = $field->get_full_value();
75
76
		if ( empty( $value_set ) && $field->get_value_set()->keepalive() ) {
77
			$storage_key = $this->key_toolset->get_storage_key(
78
				$field->is_simple_root_field(),
79
				$this->get_full_hierarchy_for_field( $field ),
80
				$this->get_full_hierarchy_index_for_field( $field ),
81
				0,
82
				$this->key_toolset::KEEPALIVE_PROPERTY
83
			);
84
			$this->save_key_value_pair_with_autoload( $storage_key, '', $field->get_autoload() );
85
		}
86
		foreach ( $value_set as $value_group_index => $values ) {
87
			foreach ( $values as $property => $value ) {
88
				$storage_key = $this->key_toolset->get_storage_key(
89
					$field->is_simple_root_field(),
90
					$this->get_full_hierarchy_for_field( $field ),
91
					$this->get_full_hierarchy_index_for_field( $field ),
92
					$value_group_index,
93
					$property
94
				);
95
				$this->save_key_value_pair_with_autoload( $storage_key, $value, $field->get_autoload() );
96
			}
97
		}
98
	}
99
100
	/**
101
	 * Delete the field value(s)