Changeset 1013718
- Timestamp:
- 10/25/2014 07:05:35 AM (11 years ago)
- Location:
- duplicate-title-validate/trunk
- Files:
-
- 2 edited
-
duplicate-title-validate.php (modified) (9 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
duplicate-title-validate/trunk/duplicate-title-validate.php
r1003976 r1013718 1 1 <?php 2 2 3 3 /* 4 * Plugin Name: Duplicate Title validate4 * Plugin Name: Duplicate Title Validate 5 5 * Description: this plugin help , not allow publish Duplicate Title . 6 6 * Author: hasan movahed … … 8 8 * Author URI: http://www.wallfa.com 9 9 */ 10 10 11 11 /* 12 12 This program is free software; you can redistribute it and/or … … 14 14 as published by the Free Software Foundation; either version 2 15 15 of the License, or (at your option) any later version. 16 16 17 17 This program is distributed in the hope that it will be useful, 18 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 20 GNU General Public License for more details. 21 21 22 22 You should have received a copy of the GNU General Public License 23 23 along with this program; if not, write to the Free Software 24 24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 25 25 */ 26 26 27 27 //jQuery to send AJAX request 28 28 function duplicate_titles_enqueue_scripts( $hook ) { 29 29 30 30 if( !in_array( $hook, array( 'post.php', 'post-new.php' , 'edit.php'))) return; 31 31 wp_enqueue_script('duptitles', … … 36 36 add_action( 'admin_enqueue_scripts', 'duplicate_titles_enqueue_scripts', 2000 ); 37 37 add_action('wp_ajax_title_checks', 'duplicate_title_checks_callback'); 38 39 38 39 40 40 /// callback ajax 41 41 function duplicate_title_checks_callback() { 42 42 43 43 function title_checks() { 44 44 … … 47 47 $title = $_POST['post_title']; 48 48 $post_id = $_POST['post_id']; 49 49 50 50 $titles = "SELECT post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' 51 51 AND post_title = '{$title}' AND ID != {$post_id} "; 52 52 53 53 $results = $wpdb->get_results($titles); 54 54 55 55 if($results) { 56 return "<span style='color:red'>". _e( 'Please enter another title it\'s already exists' , 'dublicate-title-validate' ) ." </span>"; 57 //لطفا عنوان دیگری را انتخاب کنید این عنوان ثبت شده است . 56 return "<span style='color:red'>". _e( 'Duplicate title detected, please change the title.' , 'dublicate-title-validate' ) ." </span>"; 58 57 } else { 59 return '<span style="color:green">'._e('This title is unique ' , 'dublicate-title-validate').'</span>';58 return '<span style="color:green">'._e('This title is unique.' , 'dublicate-title-validate').'</span>'; 60 59 } 61 //عنوان انتخاب شده مورد تایید است .60 62 61 } 63 62 echo title_checks(); 64 63 die(); 65 64 } 66 65 67 66 // this chek backend title and if Duplicate update status draft . 68 67 function duplicate_titles_wallfa_bc( $post ) … … 71 70 $title = $_POST['post_title'] ; 72 71 $post_id = $post ; 73 74 75 72 73 74 76 75 $wtitles = "SELECT post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' 77 76 AND post_title = '{$title}' AND ID != {$post_id} " ; 78 77 79 78 $wresults = $wpdb->get_results( $wtitles ) ; 80 79 81 80 if ( $wresults ) 82 81 { … … 92 91 } 93 92 } 94 95 93 94 96 95 add_action( 'publish_post', 97 96 'duplicate_titles_wallfa_bc' ) ; 98 97 99 98 /// handel error for back end 100 99 function not_published_error_notice() { 101 100 if(isset($_GET['wallfaerror']) == 1 ){ 102 ?>101 ?> 103 102 <div class="updated"> 104 <p style='color:red' ><?php _e(' Posted considered to have been released as a duplicate' , 'dublicate-title-validate') ?></p>103 <p style='color:red' ><?php _e('Title used for this post appears to be a duplicate. Please modify the title. You may also want to revise the URL slug to make sure it is unique as well.' , 'dublicate-title-validate') ?></p> 105 104 </div> 106 105 <?php 107 //نوشته مورد نظر به دلیل داشتن عنوان تکراری منتشر نشد108 }}106 } 107 } 109 108 add_action( 'admin_notices', 'not_published_error_notice' ); 110 111 109 110 112 111 function duplicate_titles_wallfa_action_init() 113 112 { … … 115 114 load_plugin_textdomain('dublicate-title-validate',false,dirname(plugin_basename(__FILE__)).'/langs/'); 116 115 } 117 116 118 117 // Add actions 119 118 add_action('init', 'duplicate_titles_wallfa_action_init'); 120 121 122 123 119 120 121 122 124 123 function disable_autosave() 125 124 { … … 127 126 } 128 127 add_action( 'wp_print_scripts', 'disable_autosave' ) ; 129 128 130 129 ?> -
duplicate-title-validate/trunk/readme.txt
r1003999 r1013718 1 === duplicate-title-validation===1 === Duplicate Title Validate === 2 2 Tags: duplicate,title duplicate cheker 3 3 Requires at least: 3.0.1 … … 5 5 License: GPLv2 or later 6 6 License URI: http://www.gnu.org/licenses/gpl-2.0.html 7 8 this plugin help for duplicate title cheker in wordpress.9 7 8 This plugin tries to detect duplicate post titles and displays a warning when it detects an exact match. 9 10 10 == Description == 11 this plugin help for duplicate title validation and not allow published post to resolve this issue 12 11 12 This plugin tries to detect duplicate post titles. It displays a warning notice when an exact match is detected. It also stops users from publishing a post with a duplicate title and instead saves the post as a draft. It also reminds users to review the URL slug while changing a post title to make sure that URL slug is unique as well. 13 13 14 == Installation == 14 15 1. Upload \"duplicate-title-validate\" to the \"/wp-content/plugins/\" directory. 15 16 1. Activate the plugin through the \"Plugins\" menu in WordPress. 16 17 1. Enjoy 18 19 == Frequently Asked Questions == 20 21 = Translators = 22 23 * persian (fa) - [hasan movahed](http://www.wallfa.com/) 24 * English (en) - [Noumaan Yaqoob](http://www.wpbeginner.com/) 25 26 == Screenshots == 27 28 1. screenshot-1.png 29 30 == Upgrade Notice == 17 31 18 == Frequently Asked Questions == 19 20 = Translators = 21 22 * persian (fa) - [hasan movahed](http://www.wallfa.com/) 23 24 == Screenshots == 25 26 1. screenshot-1.png 32 = 0.1 = 33 Fixed English Error. 27 34 28 35 == Changelog == 36 29 37 = 0.1 = 30 38 * Initial release.
Note: See TracChangeset
for help on using the changeset viewer.