@@ 1187-1215 (lines=29) @@ | ||
1184 | ||
1185 | $post_id = wp_insert_post( $content, true ); // return an error instead of a 0 id |
|
1186 | ||
1187 | if ( is_wp_error( $post_id ) ) { |
|
1188 | $success = false; |
|
1189 | $errors = $post_id; |
|
1190 | } else { |
|
1191 | $success = true; |
|
1192 | $errors = array(); |
|
1193 | // If it's a custom post type, fix the methods. |
|
1194 | if ( isset( $params['RecordTypeId']['value'] ) ) { |
|
1195 | $params['RecordTypeId']['method_modify'] = 'update_post_meta'; |
|
1196 | $params['RecordTypeId']['method_read'] = 'get_post_meta'; |
|
1197 | } |
|
1198 | if ( is_array( $params ) && ! empty( $params ) ) { |
|
1199 | foreach ( $params as $key => $value ) { |
|
1200 | $method = $value['method_modify']; |
|
1201 | $meta_id = $method( $post_id, $key, $value['value'] ); |
|
1202 | if ( false === $meta_id ) { |
|
1203 | $success = false; |
|
1204 | $errors[] = array( |
|
1205 | 'key' => $key, |
|
1206 | 'value' => $value, |
|
1207 | ); |
|
1208 | } |
|
1209 | } |
|
1210 | } |
|
1211 | ||
1212 | // Developers can use this hook to set any other post data. |
|
1213 | do_action( $this->option_prefix . 'set_more_post_data', $post_id, $params, 'create' ); |
|
1214 | ||
1215 | } |
|
1216 | ||
1217 | if ( is_wp_error( $post_id ) ) { |
|
1218 | $success = false; |
|
@@ 1434-1462 (lines=29) @@ | ||
1431 | ||
1432 | $post_id = wp_update_post( $content, true ); // return an error instead of a 0 id |
|
1433 | ||
1434 | if ( is_wp_error( $post_id ) ) { |
|
1435 | $success = false; |
|
1436 | $errors = $post_id; |
|
1437 | } else { |
|
1438 | $success = true; |
|
1439 | $errors = array(); |
|
1440 | // If it's a custom post type, fix the methods. |
|
1441 | if ( isset( $params['RecordTypeId']['value'] ) ) { |
|
1442 | $params['RecordTypeId']['method_modify'] = 'update_post_meta'; |
|
1443 | $params['RecordTypeId']['method_read'] = 'get_post_meta'; |
|
1444 | } |
|
1445 | if ( is_array( $params ) && ! empty( $params ) ) { |
|
1446 | foreach ( $params as $key => $value ) { |
|
1447 | $method = $value['method_modify']; |
|
1448 | $meta_id = $method( $post_id, $key, $value['value'] ); |
|
1449 | if ( false === $meta_id ) { |
|
1450 | $success = false; |
|
1451 | $errors[] = array( |
|
1452 | 'key' => $key, |
|
1453 | 'value' => $value, |
|
1454 | ); |
|
1455 | } |
|
1456 | } |
|
1457 | } |
|
1458 | ||
1459 | // Developers can use this hook to set any other post data. |
|
1460 | do_action( $this->option_prefix . 'set_more_post_data', $post_id, $params, 'update' ); |
|
1461 | ||
1462 | } |
|
1463 | ||
1464 | $result = array( |
|
1465 | 'data' => array( |