Skip to content

Commit

Permalink
fix: change meta key
Browse files Browse the repository at this point in the history
  • Loading branch information
girishpanchal30 committed Dec 20, 2024
1 parent 1e6c0d1 commit 50e8d5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -1528,9 +1528,10 @@ private function run_job( $job, $max ) {
$items_found[ $item['item_url'] ] = $item['item_title'];

$duplicate_tag_value = array();
$mark_duplicate_key = 'item_url';
if ( 'yes' === $import_remove_duplicates && ! $is_duplicate ) {
if ( ! empty( $mark_duplicate_tag ) ) {
$mark_duplicate_tag = explode( ',', $mark_duplicate_tag );
$mark_duplicate_tag = is_string( $mark_duplicate_tag ) ? explode( ',', $mark_duplicate_tag ) : $mark_duplicate_tag;
$mark_duplicate_tag = array_map( 'trim', $mark_duplicate_tag );
$duplicate_tag_value = array_map(
function ( $tag ) use ( $item_obj, $item ) {
Expand All @@ -1547,16 +1548,15 @@ function ( $tag ) use ( $item_obj, $item ) {
if ( ! empty( $duplicate_tag_value ) ) {
$duplicate_tag_value = implode( ' ', $duplicate_tag_value );
$duplicate_tag_value = substr( sanitize_key( wp_strip_all_tags( $duplicate_tag_value ) ), 0, apply_filters( 'feedzy_mark_duplicate_content_limit', 256 ) );
$mark_duplicate_tag = md5( implode( '', $mark_duplicate_tag ) );
$mark_duplicate_key = 'mark_duplicate';
} else {
$duplicate_tag_value = esc_url_raw( $item['item_url'] );
$mark_duplicate_tag = 'item_url';
}

$is_duplicate_post = $this->is_duplicate_post( $import_post_type, 'feedzy_' . $mark_duplicate_tag, $duplicate_tag_value );
$is_duplicate_post = $this->is_duplicate_post( $import_post_type, 'feedzy_' . $mark_duplicate_key, $duplicate_tag_value );
if ( ! empty( $is_duplicate_post ) ) {
foreach ( $is_duplicate_post as $p ) {
$found_duplicates[] = get_post_meta( $p, 'feedzy_' . $mark_duplicate_tag, true );
$found_duplicates[ $item_hash ] = get_post_meta( $p, 'feedzy_' . $mark_duplicate_key, true );
$duplicates[ $item['item_url'] ] = $item['item_title'];
wp_delete_post( $p, true );
}
}
Expand Down Expand Up @@ -2091,9 +2091,9 @@ function( $term ) {
update_post_meta( $new_post_id, 'feedzy_job', $job->ID );
update_post_meta( $new_post_id, 'feedzy_item_author', sanitize_text_field( $author ) );

// Verify that the `$mark_duplicate_tag` does not match `'item_url'` to ensure the condition applies only when a different tag is specified.
if ( $mark_duplicate_tag && 'item_url' !== $mark_duplicate_tag ) {
update_post_meta( $new_post_id, 'feedzy_' . $mark_duplicate_tag, $duplicate_tag_value );
// Verify that the `$mark_duplicate_key` does not match `'item_url'` to ensure the condition applies only when a different tag is specified.
if ( $mark_duplicate_key && 'item_url' !== $mark_duplicate_key ) {
update_post_meta( $new_post_id, 'feedzy_' . $mark_duplicate_key, $duplicate_tag_value );
}

// we can use this to associate the items that were imported in a particular run.
Expand Down
2 changes: 1 addition & 1 deletion tests/test-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function test_feedzy_imports( $random_name1, $random_name2, $urls, $magic

// Check found duplicates items.
if ( $check_duplicate ) {
$this->assertNotEmpty( get_post_meta( $created[0]->ID, 'feedzy_' . md5( 'item_author' ), true ) );
$this->assertNotEmpty( get_post_meta( $created[0]->ID, 'feedzy_mark_duplicate', true ) );
}

// Check Post Delete
Expand Down

0 comments on commit 50e8d5c

Please sign in to comment.