| @@ 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. |
|
| @@ 149-164 (lines=16) @@ | ||
| 146 | * |
|
| 147 | * @return $this |
|
| 148 | */ |
|
| 149 | public function save() |
|
| 150 | { |
|
| 151 | if (! $this->id) { |
|
| 152 | $result = wp_insert_user($this->object); |
|
| 153 | } else { |
|
| 154 | $result = wp_update_user($this->object); |
|
| 155 | } |
|
| 156 | ||
| 157 | if (is_wp_error($result)) { |
|
| 158 | throw new WP_ErrorException($result); |
|
| 159 | } |
|
| 160 | ||
| 161 | $this->setId($result)->refresh(); |
|
| 162 | ||
| 163 | return $this; |
|
| 164 | } |
|
| 165 | ||
| 166 | /** |
|
| 167 | * Delete the modeled record from the database. |
|