| @@ 229-244 (lines=16) @@ | ||
| 226 | * |
|
| 227 | * @return $this |
|
| 228 | */ |
|
| 229 | public function save() |
|
| 230 | { |
|
| 231 | if (! $this->id) { |
|
| 232 | $result = wp_insert_post($this->object->to_array(), true); |
|
| 233 | } else { |
|
| 234 | $result = wp_update_post($this->object, true); |
|
| 235 | } |
|
| 236 | ||
| 237 | if (is_wp_error($result)) { |
|
| 238 | throw new WP_ErrorException($result); |
|
| 239 | } |
|
| 240 | ||
| 241 | $this->setId($result)->refresh(); |
|
| 242 | ||
| 243 | return $this; |
|
| 244 | } |
|
| 245 | ||
| 246 | /** |
|
| 247 | * Permanently delete the post from the database. |
|
| @@ 160-175 (lines=16) @@ | ||
| 157 | * |
|
| 158 | * @return $this |
|
| 159 | */ |
|
| 160 | public function save() |
|
| 161 | { |
|
| 162 | if (! $this->id) { |
|
| 163 | $result = wp_insert_user($this->object); |
|
| 164 | } else { |
|
| 165 | $result = wp_update_user($this->object); |
|
| 166 | } |
|
| 167 | ||
| 168 | if (is_wp_error($result)) { |
|
| 169 | throw new WP_ErrorException($result); |
|
| 170 | } |
|
| 171 | ||
| 172 | $this->setId($result)->refresh(); |
|
| 173 | ||
| 174 | return $this; |
|
| 175 | } |
|
| 176 | ||
| 177 | /** |
|
| 178 | * Delete the modeled record from the database. |
|