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