|
@@ 1336-1379 (lines=44) @@
|
| 1333 |
|
// Check only is true but there's not a post yet. |
| 1334 |
|
return null; |
| 1335 |
|
} // End if(). |
| 1336 |
|
} else { |
| 1337 |
|
// There is no method by which to check the post. we can check other ways here. |
| 1338 |
|
$params[ $key ] = array( |
| 1339 |
|
'value' => $value, |
| 1340 |
|
'method_modify' => $methods['method_modify'], |
| 1341 |
|
'method_read' => $methods['method_read'], |
| 1342 |
|
); |
| 1343 |
|
|
| 1344 |
|
// If we have a title, use it to check for existing post. |
| 1345 |
|
if ( isset( $params['post_title']['value'] ) ) { |
| 1346 |
|
$title = $params['post_title']['value']; |
| 1347 |
|
} |
| 1348 |
|
|
| 1349 |
|
// If we have content, use it to check for existing post. |
| 1350 |
|
if ( isset( $params['post_content']['value'] ) ) { |
| 1351 |
|
$content = $params['post_content']['value']; |
| 1352 |
|
} else { |
| 1353 |
|
$content = ''; |
| 1354 |
|
} |
| 1355 |
|
|
| 1356 |
|
// If we have a date, use it to check for existing post. |
| 1357 |
|
if ( isset( $params['post_date']['value'] ) ) { |
| 1358 |
|
$date = $params['post_date']['value']; |
| 1359 |
|
} else { |
| 1360 |
|
$date = ''; |
| 1361 |
|
} |
| 1362 |
|
|
| 1363 |
|
$existing_id = post_exists( $title, $content, $date ); // Returns an id if there is a result. Returns 0 if not. |
| 1364 |
|
|
| 1365 |
|
// Post does not exist after more checking. maybe we want to create it. |
| 1366 |
|
if ( 0 === $existing_id && false === $check_only ) { |
| 1367 |
|
$result = $this->post_create( $params, $id_field, $post_type ); |
| 1368 |
|
return $result; |
| 1369 |
|
} elseif ( true === $check_only ) { |
| 1370 |
|
// We are just checking to see if there is a match. |
| 1371 |
|
return $existing_id; |
| 1372 |
|
} else { |
| 1373 |
|
// Post does exist based on fields, and we aren't doing a check only. we want to update the wp post here. |
| 1374 |
|
$post_id = $existing_id; |
| 1375 |
|
} |
| 1376 |
|
|
| 1377 |
|
return $result; |
| 1378 |
|
|
| 1379 |
|
} // End if(). |
| 1380 |
|
|
| 1381 |
|
if ( isset( $post_id ) ) { |
| 1382 |
|
foreach ( $params as $key => $value ) { |
|
@@ 1656-1699 (lines=44) @@
|
| 1653 |
|
// Check only is true but there's not an attachment yet. |
| 1654 |
|
return null; |
| 1655 |
|
} // End if(). |
| 1656 |
|
} else { |
| 1657 |
|
// There is no method by which to check the post. we can check other ways here. |
| 1658 |
|
$params[ $key ] = array( |
| 1659 |
|
'value' => $value, |
| 1660 |
|
'method_modify' => $methods['method_modify'], |
| 1661 |
|
'method_read' => $methods['method_read'], |
| 1662 |
|
); |
| 1663 |
|
|
| 1664 |
|
// If we have a title, use it to check for existing post. |
| 1665 |
|
if ( isset( $params['post_title']['value'] ) ) { |
| 1666 |
|
$title = $params['post_title']['value']; |
| 1667 |
|
} |
| 1668 |
|
|
| 1669 |
|
// If we have content, use it to check for existing post. |
| 1670 |
|
if ( isset( $params['post_content']['value'] ) ) { |
| 1671 |
|
$content = $params['post_content']['value']; |
| 1672 |
|
} else { |
| 1673 |
|
$content = ''; |
| 1674 |
|
} |
| 1675 |
|
|
| 1676 |
|
// If we have a date, use it to check for existing post. |
| 1677 |
|
if ( isset( $params['post_date']['value'] ) ) { |
| 1678 |
|
$date = $params['post_date']['value']; |
| 1679 |
|
} else { |
| 1680 |
|
$date = ''; |
| 1681 |
|
} |
| 1682 |
|
|
| 1683 |
|
$existing_id = post_exists( $title, $content, $date ); // Returns an id if there is a result. Returns 0 if not. |
| 1684 |
|
|
| 1685 |
|
// Attachment does not exist after more checking. maybe we want to create it. |
| 1686 |
|
if ( 0 === $existing_id && false === $check_only ) { |
| 1687 |
|
$result = $this->attachment_create( $params ); |
| 1688 |
|
return $result; |
| 1689 |
|
} elseif ( true === $check_only ) { |
| 1690 |
|
// We are just checking to see if there is a match. |
| 1691 |
|
return $existing_id; |
| 1692 |
|
} else { |
| 1693 |
|
// Attachment does exist based on fields, and we aren't doing a check only. we want to update the wp attachment here. |
| 1694 |
|
$attachment_id = $existing_id; |
| 1695 |
|
} |
| 1696 |
|
|
| 1697 |
|
return $result; |
| 1698 |
|
|
| 1699 |
|
} // End if(). |
| 1700 |
|
|
| 1701 |
|
if ( isset( $attachment_id ) ) { |
| 1702 |
|
foreach ( $params as $key => $value ) { |