7/24/2014 - 9:27 AM

Wordpress Duplicate Title Checker plugin (updated version)

Wordpress Duplicate Title Checker plugin (updated version)

=== Duplicate Title Checker ===
Contributors: ketanajani, fuchsws, certainlyakey
Donate link: http://www.webconfines.com
More info: http://wordpress.org/support/topic/suggestions-35?replies=2
Tags: duplicate title checker, duplicate title checker wordpress, wordpress check duplicate title, duplicate title SEO, prevent duplicate title wordpress, WP duplicate title, duplicate title error wordpress, duplicate title validation wordpress, validate title for duplication wordpress, title validation wordpress, WP title checker, duplicate post title checker, custom post type title checker, wordpress unique title, wordpress alert on duplicate title, title,duplicate, checker, check, wordpress
Requires at least: 3.0
Tested up to: 3.8
Stable tag: 0.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

This plugin provides alert message for duplicate post title and unique post title when adding new post.

== Description ==

Wordpress allows to enter same title for multiple posts. Sometimes we already used a title and we are not aware of that and when we create another post with same name, wordpress by default is not providing alert that this title is already used.
The benefit of default functionality is that wordpress allows multiple posts with same title and automatically generate unique URLs for duplicate posts which is very helpful.

But what if we need that each post should have unique post title and there are huge number of posts already created ?

In this case this plugin can be used to check that title we are using for new post is unique or not. Right now this plugin is only for post but with minor modification it can be used with custom post types and pages. Although this plugin allows to create multiple posts with same title as it just provides alert that the title used is not unique

If you need any information on plugin and suggestions for how to customize for custom post types or pages than please let us know here http://www.webconfines.com/contact-us

== Installation ==

How to install Duplicate Title Checker:

1. Upload the folder `duplicate-title-checker` to the `/wp-content/plugins/` directory.
1. Activate the plugin through the 'Plugins' menu in WordPress.
1. Create new post with title already exists.

== Frequently Asked Questions ==
= How it will work? =
Install and activate plugin, then create new post with title that is already exists, once you enter title and press tab or move to another field it will show highlighted message for duplication.
= Can I expand this plugin? =
Yes you can customize or expand plugin to also check uniqueness of title for custom post types and pages with minor changes.
= Can I save post with duplicate title after alert =
Yes, this plugin only provide message that this title is duplicate but same time it also allow to save the post with duplicate title and it will work as default wordpress functionality.
= Does this plugin provides message for unique title? =
Yes, this plugin provide unique title message.
= Support available? =
No, but if you need any suggestions how to customize this plugin then you can let us know here http://www.webconfines.com/contact-us
= What are limitations of this plugin? =
It is only available for posts

== Changelog ==

= 1.1 =
= 1.0 =
* Initial

== Upgrade Notice ==
Nothing yet
    // Post function
    function checkTitle(title, id,post_type) {
        var data = {
            action: 'title_check',
            post_title: title,
            post_type: post_type,
            post_id: id

        //var ajaxurl = 'wp-admin/admin-ajax.php';
        $.post(ajaxurl, data, function(response) {
            if (response != 'Post title seems to be unique') {
                $('#poststuff').prepend('<div id=\"message\" class=\"updated fade\" style=\"color:red\"><p>'+response+'</p></div>');

    // Add button to "Check Titles" below title field in post editor
    //$('#edit-slug-box').append('<span id="check-title-btn"><a class="button" href="#">Check Title</a></span>');

    // Click function to initiate post function
    $('#title').change(function() {
        var title = $('#title').val();
        var id = $('#post_ID').val();
        var post_type = $('#post_type').val();
        checkTitle(title, id,post_type);

	Plugin Name: Duplicate Title Checker (zip all related files to upload it)
	Plugin URI: http://wordpress.org/extend/plugins/duplicate-title-checker/
	Description: This plugin provides alert message for duplicate post title and unique post title when adding new post.
	Author: Ketan Ajani, improved by fuchsws and certainlyakey (see http://wordpress.org/support/topic/suggestions-35?replies=2)
	Version: 1.1
	Author URI: http://www.webconfines.com
//////////////////////////this is duplicate title check///////////////////////////////////

	//jQuery to send AJAX request - only available on the post editing page
	function duplicate_titles_enqueue_scripts( $hook ) {

		if( !in_array( $hook, array( 'post.php', 'post-new.php' ) ) )

		wp_enqueue_script( 'duptitles',wp_enqueue_script( 'duptitles',plugins_url().'/duplicate-title-checker/duptitles.js',array( 'jquery' )), array( 'jquery' )  );
	add_action( 'admin_enqueue_scripts', 'duplicate_titles_enqueue_scripts', 2000 );

	add_action('wp_ajax_title_check', 'duplicate_title_check_callback');

function duplicate_title_check_callback() {

	function title_check() {

		$title = $_POST['post_title'];
		$post_id = $_POST['post_id'];
		$post_type = $_POST['post_type'];

		global $wpdb;

		$sim_titles = "SELECT post_title,ID FROM $wpdb->posts WHERE post_type = '{$post_type}' AND post_title LIKE '%{$title}%' AND ID != {$post_id} ";

		$sim_results = $wpdb->get_results($sim_titles);

		if($sim_results) {
			$titles = '<ul>';
			foreach ( $sim_results as $the_title )
				$titles .= '<li><a href="'. get_edit_post_link($the_title->ID) .'" target="_blank">'.$the_title->post_title.'</a></li>';
			$titles .= '</ul>';

			return 'Post title seems to exist already: '.$titles;
		  else {
		 	return 'Post title seems to be unique';
	echo title_check();

	function disable_autosave() {
	add_action( 'wp_print_scripts', 'disable_autosave' );