Creating a Remove duplicates plugin that works
-
Hi
I’ve been trying to get a plugin that’d work to no avail.
FeedWP remove duplicates doesn’t work at all, the others consider all my posts as duplicates- ie don’t work either.That’s the code of FeedWPremoveDuplicate`
<?php
/*
Plugin Name: FeedWordPress Duplicate Post Filter
Plugin URI: https://www.byte-me.org/
Description: Checks DB to see if any previous posts have the same title and one of the same guid or post_date_gmt attributes. If it does, it skip that post.
Author: Mark Allen
Version: 1.3
*//*
Copyright (C) 2008, 2009 by Mark R. Allen
All rights reserved.Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:* Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of Mark Allen nor the names of any contributors may be used to
endorse or promote products derived from this software without specific prior written
permission.*/
function fwpdpf_check_duplicate ( $post )
{
global $wpdb;$handle;
$debug = 0;if ( $debug )
{
$wpdb->show_errors();$handle = fopen(“duplicate_post_filter.log”, “a+”);
}$sql = $wpdb->prepare( “
SELECT ID FROM $wpdb->posts
WHERE
(post_title = ‘%s’ OR post_title = ‘%s’) AND
(guid = ‘%s’) OR
post_date_gmt like %s”,
esc_html($post[‘post_title’]),
$post[‘post_title’],
$post[‘guid’],
gmdate(‘Y-m-d’, $post[‘epoch’][‘issued’]).”%”
);if ( $debug )
{
fprintf($handle, “%s”, $sql);
}$wpdb->query( $sql );
if($wpdb->num_rows) //Already posted; discard
{
if ( $debug )
{
fprintf($handle, “%s”, “…skipped”);
fclose($handle);
}
return NULL;
}// Otherwise continue to process.
if ( $debug )
{
fclose($handle);
}return $post;
}add_action(‘syndicated_post’, ‘fwpdpf_check_duplicate’);
?>`Could anyone help me make this work? PhP is beyond my poor understanding…I’ve tried trust me.
- The topic ‘Creating a Remove duplicates plugin that works’ is closed to new replies.