Version Description
Options to show original post + accessibility improvements
Download this release
Release Info
Developer | lopo |
Plugin | Duplicate Post |
Version | 3.2.4 |
Comparing to | |
See all releases |
Code changes from version 3.2.3 to 3.2.4
- donate.png +0 -0
- duplicate-post-admin.php +159 -17
- duplicate-post-common.php +58 -1
- duplicate-post-options.php +293 -52
- duplicate-post.php +10 -4
- duplicate_post_admin_script.js +35 -0
- readme.txt +12 -4
donate.png
DELETED
Binary file
|
duplicate-post-admin.php
CHANGED
@@ -45,7 +45,20 @@ function duplicate_post_admin_init(){
|
|
45 |
if (get_option('duplicate_post_show_submitbox') == 1){
|
46 |
add_action( 'post_submitbox_start', 'duplicate_post_add_duplicate_post_button' );
|
47 |
}
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
/**
|
50 |
* Connect actions to functions
|
51 |
*/
|
@@ -150,6 +163,9 @@ function duplicate_post_plugin_upgrade() {
|
|
150 |
add_option('duplicate_post_show_adminbar','1');
|
151 |
add_option('duplicate_post_show_submitbox','1');
|
152 |
add_option('duplicate_post_show_bulkactions','1');
|
|
|
|
|
|
|
153 |
|
154 |
$taxonomies_blacklist = get_option('duplicate_post_taxonomies_blacklist');
|
155 |
if ($taxonomies_blacklist == "") $taxonomies_blacklist = array();
|
@@ -191,15 +207,24 @@ function duplicate_post_plugin_upgrade() {
|
|
191 |
function duplicate_post_show_update_notice() {
|
192 |
if(!current_user_can( 'manage_options')) return;
|
193 |
$class = 'notice is-dismissible';
|
194 |
-
$message = '<strong>'.sprintf(__("What's new in Duplicate Post version %s:", 'duplicate-post'), DUPLICATE_POST_CURRENT_VERSION).'</strong
|
195 |
-
$message .=
|
196 |
-
$message .= '<
|
197 |
-
$message .=
|
|
|
|
|
|
|
198 |
global $wp_version;
|
199 |
if( version_compare($wp_version, '4.2') < 0 ){
|
200 |
-
$message .= '
|
201 |
-
}
|
202 |
-
echo '<div id="duplicate-post-notice" class="'.$class.'"
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
echo "<script>
|
204 |
function duplicate_post_dismiss_notice(){
|
205 |
var data = {
|
@@ -225,16 +250,132 @@ function duplicate_post_dismiss_notice() {
|
|
225 |
wp_die();
|
226 |
}
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
/**
|
229 |
* Add the link to action list for post_row_actions
|
230 |
*/
|
231 |
function duplicate_post_make_duplicate_link_row($actions, $post) {
|
232 |
if (duplicate_post_is_current_user_allowed_to_copy() && duplicate_post_is_post_type_enabled($post->post_type)) {
|
233 |
-
$
|
234 |
-
|
|
|
235 |
. '">' . esc_html__('Clone', 'duplicate-post') . '</a>';
|
236 |
-
$actions['edit_as_new_draft'] = '<a href="'. duplicate_post_get_clone_post_link( $post->ID ) .'"
|
237 |
-
.
|
238 |
. '">' . esc_html__('New Draft', 'duplicate-post') . '</a>';
|
239 |
}
|
240 |
return $actions;
|
@@ -251,7 +392,7 @@ function duplicate_post_add_duplicate_post_button() {
|
|
251 |
?>
|
252 |
<div id="duplicate-action">
|
253 |
<a class="submitduplicate duplication"
|
254 |
-
href="<?php echo duplicate_post_get_clone_post_link( $
|
255 |
</a>
|
256 |
</div>
|
257 |
<?php
|
@@ -464,7 +605,8 @@ function duplicate_post_copy_attachments($new_id, $post){
|
|
464 |
$cloned_child = array(
|
465 |
'ID' => $new_attachment_id,
|
466 |
'post_title' => $child->post_title,
|
467 |
-
'
|
|
|
468 |
'post_author' => $new_post_author->ID
|
469 |
);
|
470 |
wp_update_post( wp_slash($cloned_child) );
|
@@ -558,7 +700,7 @@ function duplicate_post_create_duplicate($post, $status = '', $parent_id = '') {
|
|
558 |
|
559 |
if ($title == ''){
|
560 |
// empty title
|
561 |
-
$title = __('Untitled');
|
562 |
}
|
563 |
if (get_option('duplicate_post_copystatus') == 0){
|
564 |
$new_post_status = 'draft';
|
@@ -651,8 +793,8 @@ function duplicate_post_create_duplicate($post, $status = '', $parent_id = '') {
|
|
651 |
//Add some links on the plugin page
|
652 |
function duplicate_post_add_plugin_links($links, $file) {
|
653 |
if ( $file == plugin_basename(dirname(__FILE__).'/duplicate-post.php') ) {
|
654 |
-
$links[] = '<a href="https://duplicate-post.lopo.it/">' . esc_html__('Documentation', 'duplicate-post') . '</a>';
|
655 |
-
$links[] = '<a href="https://duplicate-post.lopo.it/donate">' . esc_html__('Donate', 'duplicate-post') . '</a>';
|
656 |
}
|
657 |
return $links;
|
658 |
}
|
45 |
if (get_option('duplicate_post_show_submitbox') == 1){
|
46 |
add_action( 'post_submitbox_start', 'duplicate_post_add_duplicate_post_button' );
|
47 |
}
|
48 |
+
|
49 |
+
|
50 |
+
if(get_option('duplicate_post_show_original_column') == 1){
|
51 |
+
duplicate_post_show_original_column();
|
52 |
+
}
|
53 |
+
|
54 |
+
if(get_option('duplicate_post_show_original_in_post_states') == 1){
|
55 |
+
add_filter( 'display_post_states', 'duplicate_post_show_original_in_post_states', 10, 2);
|
56 |
+
}
|
57 |
+
|
58 |
+
if(get_option('duplicate_post_show_original_meta_box') == 1){
|
59 |
+
add_action('add_meta_boxes', 'duplicate_post_add_custom_box');
|
60 |
+
add_action( 'save_post', 'duplicate_post_save_quick_edit_data' );
|
61 |
+
}
|
62 |
/**
|
63 |
* Connect actions to functions
|
64 |
*/
|
163 |
add_option('duplicate_post_show_adminbar','1');
|
164 |
add_option('duplicate_post_show_submitbox','1');
|
165 |
add_option('duplicate_post_show_bulkactions','1');
|
166 |
+
add_option('duplicate_post_show_original_column','0');
|
167 |
+
add_option('duplicate_post_show_original_in_post_states','0');
|
168 |
+
add_option('duplicate_post_show_original_meta_box','0');
|
169 |
|
170 |
$taxonomies_blacklist = get_option('duplicate_post_taxonomies_blacklist');
|
171 |
if ($taxonomies_blacklist == "") $taxonomies_blacklist = array();
|
207 |
function duplicate_post_show_update_notice() {
|
208 |
if(!current_user_can( 'manage_options')) return;
|
209 |
$class = 'notice is-dismissible';
|
210 |
+
$message = '<p style="margin: 0;"><strong>'.sprintf(__("What's new in Duplicate Post version %s:", 'duplicate-post'), DUPLICATE_POST_CURRENT_VERSION).'</strong></p>';
|
211 |
+
$message .= '<ul style="margin: 0; list-style: inside disc;">';
|
212 |
+
$message .= '<li style="margin: 0;">'.esc_html__('New options to show the original in the post list or in the edit screen!', 'duplicate-post').'</li>';
|
213 |
+
$message .= '<li style="margin: 0;">'.esc_html__('Accessibility of the user interface has been improved', 'duplicate-post').'</li>';
|
214 |
+
$message .= '</ul>';
|
215 |
+
$message .= '<p style="margin: 0;"><em><a href="https://duplicate-post.lopo.it/">'.esc_html__('Check out the documentation', 'duplicate-post').'</a> — '.sprintf(__('Please <a href="%s">review the settings</a> to make sure it works as you expect.', 'duplicate-post'), admin_url('options-general.php?page=duplicatepost')).'</em><br/>';
|
216 |
+
$message .= esc_html__('Serving the WordPress community since November 2007.', 'duplicate-post').' <strong><a href="https://duplicate-post.lopo.it/donate/">'.esc_html__('Support the plugin by making a donation or becoming a patron!', 'duplicate-post').'</a></strong></p>';
|
217 |
global $wp_version;
|
218 |
if( version_compare($wp_version, '4.2') < 0 ){
|
219 |
+
$message .= '<a id="duplicate-post-dismiss-notice" href="javascript:duplicate_post_dismiss_notice();">'.__('Dismiss this notice.', 'default').'</a>';
|
220 |
+
}
|
221 |
+
echo '<div id="duplicate-post-notice" class="'.$class.'" style="display: flex; align-items: center;">
|
222 |
+
<svg xmlns="http://www.w3.org/2000/svg" style="padding: 0; margin: 10px 20px 10px 0;" width="80" height="80" viewBox="0 0 20 20">
|
223 |
+
<path d="M18.9 4.3c0.6 0 1.1 0.5 1.1 1.1v13.6c0 0.6-0.5 1.1-1.1 1.1h-10.7c-0.6 0-1.1-0.5-1.1-1.1v-3.2h-6.1c-0.6 0-1.1-0.5-1.1-1.1v-7.5c0-0.6 0.3-1.4 0.8-1.8l4.6-4.6c0.4-0.4 1.2-0.8 1.8-0.8h4.6c0.6 0 1.1 0.5 1.1 1.1v3.7c0.4-0.3 1-0.4 1.4-0.4h4.6zM12.9 6.7l-3.3 3.3h3.3v-3.3zM5.7 2.4l-3.3 3.3h3.3v-3.3zM7.9 9.6l3.5-3.5v-4.6h-4.3v4.6c0 0.6-0.5 1.1-1.1 1.1h-4.6v7.1h5.7v-2.9c0-0.6 0.3-1.4 0.8-1.8zM18.6 18.6v-12.9h-4.3v4.6c0 0.6-0.5 1.1-1.1 1.1h-4.6v7.1h10z"
|
224 |
+
fill="rgba(140,140,140,1)"/>
|
225 |
+
</svg>
|
226 |
+
<div style="margin: 0.5em 0">'.$message.'</div>
|
227 |
+
</div>';
|
228 |
echo "<script>
|
229 |
function duplicate_post_dismiss_notice(){
|
230 |
var data = {
|
250 |
wp_die();
|
251 |
}
|
252 |
|
253 |
+
function duplicate_post_show_original_column() {
|
254 |
+
$duplicate_post_types_enabled = get_option( 'duplicate_post_types_enabled', array( 'post', 'page' ) );
|
255 |
+
if ( ! is_array( $duplicate_post_types_enabled ) ) {
|
256 |
+
$duplicate_post_types_enabled = array( $duplicate_post_types_enabled );
|
257 |
+
}
|
258 |
+
|
259 |
+
if ( count( $duplicate_post_types_enabled ) ) {
|
260 |
+
foreach ( $duplicate_post_types_enabled as $enabled_post_type ) {
|
261 |
+
add_filter( "manage_{$enabled_post_type}_posts_columns", 'duplicate_post_add_original_column' );
|
262 |
+
add_action( "manage_{$enabled_post_type}_posts_custom_column", 'duplicate_post_show_original_item', 10, 2 );
|
263 |
+
}
|
264 |
+
add_action( 'quick_edit_custom_box', 'duplicate_post_quick_edit_remove_original', 10, 2 );
|
265 |
+
add_action( 'save_post', 'duplicate_post_save_quick_edit_data' );
|
266 |
+
add_action( 'admin_enqueue_scripts', 'duplicate_post_admin_enqueue_scripts' );
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
function duplicate_post_add_original_column( $post_columns ) {
|
271 |
+
$post_columns['duplicate_post_original_item'] = __( 'Original item', 'duplicate-post' );
|
272 |
+
return $post_columns;
|
273 |
+
}
|
274 |
+
|
275 |
+
function duplicate_post_show_original_item( $column_name, $post_id ) {
|
276 |
+
if ( 'duplicate_post_original_item' === $column_name ) {
|
277 |
+
$column_value = '<span data-no_original>-</span>';
|
278 |
+
$original_item = duplicate_post_get_original( $post_id );
|
279 |
+
if ( $original_item ) {
|
280 |
+
$column_value = duplicate_post_get_edit_or_view_link( $original_item );
|
281 |
+
}
|
282 |
+
echo $column_value;
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
function duplicate_post_quick_edit_remove_original( $column_name, $post_type ) {
|
287 |
+
if ( 'duplicate_post_original_item' != $column_name ) {
|
288 |
+
return;
|
289 |
+
}
|
290 |
+
|
291 |
+
printf(
|
292 |
+
'<fieldset class="inline-edit-col-right" id="duplicate_post_quick_edit_fieldset">
|
293 |
+
<div class="inline-edit-col">
|
294 |
+
<label class="alignleft">
|
295 |
+
<input type="checkbox" name="duplicate_post_remove_original" value="duplicate_post_remove_original">
|
296 |
+
<span class="checkbox-title">%s</span>
|
297 |
+
</label>
|
298 |
+
</div>
|
299 |
+
</fieldset>',
|
300 |
+
__(
|
301 |
+
'Delete reference to original item: <span class="duplicate_post_original_item_title_span"></span>',
|
302 |
+
'duplicate-post'
|
303 |
+
)
|
304 |
+
);
|
305 |
+
}
|
306 |
+
|
307 |
+
function duplicate_post_save_quick_edit_data( $post_id ) {
|
308 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
309 |
+
return $post_id;
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
313 |
+
return $post_id;
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( ! empty( $_POST['duplicate_post_remove_original'] ) ) {
|
317 |
+
delete_post_meta( $post_id, '_dp_original' );
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
function duplicate_post_show_original_in_post_states( $post_states, $post ){
|
322 |
+
$original_item = duplicate_post_get_original( $post->ID );
|
323 |
+
if ( $original_item ) {
|
324 |
+
// translators: Original item link (to view or edit) or title.
|
325 |
+
$post_states['duplicate_post_original_item'] = sprintf( __( 'Original: %s', 'duplicate-post' ), duplicate_post_get_edit_or_view_link( $original_item ) );
|
326 |
+
}
|
327 |
+
return $post_states;
|
328 |
+
}
|
329 |
+
|
330 |
+
function duplicate_post_admin_enqueue_scripts( $hook ) {
|
331 |
+
if ( 'edit.php' === $hook ) {
|
332 |
+
wp_enqueue_script( 'duplicate_post_admin_script', plugins_url( 'duplicate_post_admin_script.js', __FILE__ ), false, DUPLICATE_POST_CURRENT_VERSION, true );
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
function duplicate_post_add_custom_box(){
|
337 |
+
$screens = get_option('duplicate_post_types_enabled');
|
338 |
+
if(!is_array($screens)) $screens = array($screens);
|
339 |
+
foreach ($screens as $screen) {
|
340 |
+
add_meta_box(
|
341 |
+
'duplicate_post_show_original', // Unique ID
|
342 |
+
'Duplicate Post', // Box title
|
343 |
+
'duplicate_post_custom_box_html', // Content callback, must be of type callable
|
344 |
+
$screen, // Post type
|
345 |
+
'side'
|
346 |
+
);
|
347 |
+
}
|
348 |
+
}
|
349 |
+
|
350 |
+
function duplicate_post_custom_box_html( $post ) {
|
351 |
+
$original_item = duplicate_post_get_original( $post->ID );
|
352 |
+
if ( $original_item ) {
|
353 |
+
?>
|
354 |
+
<label>
|
355 |
+
<input type="checkbox" name="duplicate_post_remove_original" value="duplicate_post_remove_original">
|
356 |
+
<?php printf( __( 'Delete reference to original item: <span class="duplicate_post_original_item_title_span">%s</span>', 'duplicate-post' ), duplicate_post_get_edit_or_view_link( $original_item ) ); ?>
|
357 |
+
</label>
|
358 |
+
<?php
|
359 |
+
} else { ?>
|
360 |
+
<script>
|
361 |
+
(function(jQuery){
|
362 |
+
jQuery('#duplicate_post_show_original').hide();
|
363 |
+
})(jQuery);
|
364 |
+
</script>
|
365 |
+
<?php }
|
366 |
+
}
|
367 |
+
|
368 |
/**
|
369 |
* Add the link to action list for post_row_actions
|
370 |
*/
|
371 |
function duplicate_post_make_duplicate_link_row($actions, $post) {
|
372 |
if (duplicate_post_is_current_user_allowed_to_copy() && duplicate_post_is_post_type_enabled($post->post_type)) {
|
373 |
+
$title = _draft_or_post_title( $post );
|
374 |
+
$actions['clone'] = '<a href="'.duplicate_post_get_clone_post_link( $post->ID , 'display', false).'" aria-label="'
|
375 |
+
. esc_attr( sprintf( __('Clone “%s”', 'duplicate-post'), $title ) )
|
376 |
. '">' . esc_html__('Clone', 'duplicate-post') . '</a>';
|
377 |
+
$actions['edit_as_new_draft'] = '<a href="'. duplicate_post_get_clone_post_link( $post->ID ) .'" aria-label="'
|
378 |
+
. esc_attr( sprintf( __('Copy “%s” to a new draft', 'duplicate-post'), $title ) )
|
379 |
. '">' . esc_html__('New Draft', 'duplicate-post') . '</a>';
|
380 |
}
|
381 |
return $actions;
|
392 |
?>
|
393 |
<div id="duplicate-action">
|
394 |
<a class="submitduplicate duplication"
|
395 |
+
href="<?php echo esc_url( duplicate_post_get_clone_post_link( $id ) ); ?>"><?php esc_html_e('Copy to a new draft', 'duplicate-post'); ?>
|
396 |
</a>
|
397 |
</div>
|
398 |
<?php
|
605 |
$cloned_child = array(
|
606 |
'ID' => $new_attachment_id,
|
607 |
'post_title' => $child->post_title,
|
608 |
+
'post_excerpt' => $child->post_excerpt,
|
609 |
+
'post_content' => $child->post_content,
|
610 |
'post_author' => $new_post_author->ID
|
611 |
);
|
612 |
wp_update_post( wp_slash($cloned_child) );
|
700 |
|
701 |
if ($title == ''){
|
702 |
// empty title
|
703 |
+
$title = __('Untitled', 'default');
|
704 |
}
|
705 |
if (get_option('duplicate_post_copystatus') == 0){
|
706 |
$new_post_status = 'draft';
|
793 |
//Add some links on the plugin page
|
794 |
function duplicate_post_add_plugin_links($links, $file) {
|
795 |
if ( $file == plugin_basename(dirname(__FILE__).'/duplicate-post.php') ) {
|
796 |
+
$links[] = '<a href="https://duplicate-post.lopo.it/" aria-label="' . esc_attr__('Documentation for Duplicate Post', 'duplicate-post') . '">' . esc_html__('Documentation', 'duplicate-post') . '</a>';
|
797 |
+
$links[] = '<a href="https://duplicate-post.lopo.it/donate" aria-label="' . esc_attr__('Donate to support Duplicate Post', 'duplicate-post') . '">' . esc_html__('Donate', 'duplicate-post') . '</a>';
|
798 |
}
|
799 |
return $links;
|
800 |
}
|
duplicate-post-common.php
CHANGED
@@ -91,13 +91,70 @@ function duplicate_post_clone_post_link( $link = null, $before = '', $after = ''
|
|
91 |
*/
|
92 |
function duplicate_post_get_original($post = null , $output = OBJECT){
|
93 |
if ( !$post = get_post( $post ) )
|
94 |
-
return;
|
95 |
$original_ID = get_post_meta( $post->ID, '_dp_original');
|
96 |
if (empty($original_ID)) return null;
|
97 |
$original_post = get_post($original_ID[0], $output);
|
98 |
return $original_post;
|
99 |
}
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
// Admin bar
|
102 |
function duplicate_post_admin_bar_render() {
|
103 |
if(!is_admin_bar_showing()) return;
|
91 |
*/
|
92 |
function duplicate_post_get_original($post = null , $output = OBJECT){
|
93 |
if ( !$post = get_post( $post ) )
|
94 |
+
return null;
|
95 |
$original_ID = get_post_meta( $post->ID, '_dp_original');
|
96 |
if (empty($original_ID)) return null;
|
97 |
$original_post = get_post($original_ID[0], $output);
|
98 |
return $original_post;
|
99 |
}
|
100 |
|
101 |
+
function duplicate_post_get_edit_or_view_link( $post ){
|
102 |
+
$post = get_post( $post );
|
103 |
+
if ( ! $post )
|
104 |
+
return null;
|
105 |
+
|
106 |
+
$can_edit_post = current_user_can( 'edit_post', $post->ID );
|
107 |
+
$title = _draft_or_post_title( $post );
|
108 |
+
$post_type_object = get_post_type_object( $post->post_type );
|
109 |
+
|
110 |
+
if ( $can_edit_post && 'trash' != $post->post_status ) {
|
111 |
+
return sprintf(
|
112 |
+
'<a href="%s" aria-label="%s">%s</a>',
|
113 |
+
get_edit_post_link( $post->ID ),
|
114 |
+
esc_attr( sprintf( __( 'Edit “%s”', 'default' ), $title ) ),
|
115 |
+
$title
|
116 |
+
);
|
117 |
+
} else if ( duplicate_post_is_post_type_viewable( $post_type_object ) ) {
|
118 |
+
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
|
119 |
+
if ( $can_edit_post ) {
|
120 |
+
$preview_link = get_preview_post_link( $post );
|
121 |
+
return sprintf(
|
122 |
+
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
|
123 |
+
esc_url( $preview_link ),
|
124 |
+
esc_attr( sprintf( __( 'Preview “%s”', 'default' ), $title ) ),
|
125 |
+
$title
|
126 |
+
);
|
127 |
+
}
|
128 |
+
} elseif ( 'trash' != $post->post_status ) {
|
129 |
+
return sprintf(
|
130 |
+
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
|
131 |
+
get_permalink( $post->ID ),
|
132 |
+
/* translators: %s: post title */
|
133 |
+
esc_attr( sprintf( __( 'View “%s”', 'default' ), $title ) ),
|
134 |
+
$title
|
135 |
+
);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
return $title;
|
139 |
+
}
|
140 |
+
|
141 |
+
/*
|
142 |
+
* Workaround for is_post_type_viewable (introduced in WP 4.4)
|
143 |
+
*/
|
144 |
+
function duplicate_post_is_post_type_viewable( $post_type ) {
|
145 |
+
if ( function_exists( 'is_post_type_viewable' ) ){
|
146 |
+
return is_post_type_viewable( $post_type );
|
147 |
+
} else {
|
148 |
+
if ( is_scalar( $post_type ) ) {
|
149 |
+
$post_type = get_post_type_object( $post_type );
|
150 |
+
if ( ! $post_type ) {
|
151 |
+
return false;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
// Admin bar
|
159 |
function duplicate_post_admin_bar_render() {
|
160 |
if(!is_admin_bar_showing()) return;
|
duplicate-post-options.php
CHANGED
@@ -38,6 +38,9 @@ function duplicate_post_register_settings() { // whitelist options
|
|
38 |
register_setting( 'duplicate_post_group', 'duplicate_post_show_adminbar');
|
39 |
register_setting( 'duplicate_post_group', 'duplicate_post_show_submitbox');
|
40 |
register_setting( 'duplicate_post_group', 'duplicate_post_show_bulkactions');
|
|
|
|
|
|
|
41 |
register_setting( 'duplicate_post_group', 'duplicate_post_show_notice');
|
42 |
}
|
43 |
|
@@ -77,29 +80,196 @@ function duplicate_post_options() {
|
|
77 |
</h1>
|
78 |
|
79 |
<div
|
80 |
-
style="margin: 9px 15px 4px 0; padding: 5px 30px;
|
|
|
|
|
|
|
|
|
|
|
81 |
<p>
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
<br/>
|
86 |
-
<a href="https://duplicate-post.lopo.it/donate"><img id="donate-button" style="margin: 0px auto;" src="<?php echo plugins_url( 'donate.png', __FILE__ ); ?>" alt="Donate"/></a>
|
87 |
-
<br/>
|
88 |
-
<a href="https://duplicate-post.lopo.it/"><?php esc_html_e('Documentation', 'duplicate-post'); ?></a>
|
89 |
-
- <a href="https://translate.wordpress.org/projects/wp-plugins/duplicate-post"><?php esc_html_e('Translate', 'duplicate-post'); ?></a>
|
90 |
-
- <a href="https://wordpress.org/support/plugin/duplicate-post"><?php esc_html_e('Support Forum', 'duplicate-post'); ?></a>
|
91 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
</div>
|
93 |
|
94 |
|
95 |
<script>
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
function toggle_private_taxonomies(){
|
105 |
jQuery('.taxonomy_private').toggle(300);
|
@@ -113,11 +283,11 @@ function duplicate_post_options() {
|
|
113 |
</script>
|
114 |
|
115 |
<style>
|
116 |
-
|
117 |
margin: 22px 0 0 0;
|
118 |
}
|
119 |
|
120 |
-
|
121 |
color: #555;
|
122 |
box-shadow: none;
|
123 |
}
|
@@ -128,16 +298,16 @@ h2 .nav-tab:focus {
|
|
128 |
border: 1px solid #ccc;
|
129 |
border-top: 0px;
|
130 |
}
|
131 |
-
|
132 |
section {
|
133 |
display: none;
|
134 |
}
|
135 |
|
136 |
section:first-of-type {
|
137 |
display: block;
|
138 |
-
}
|
139 |
|
140 |
-
.no-js
|
141 |
display: none;
|
142 |
}
|
143 |
|
@@ -175,20 +345,43 @@ img#donate-button{
|
|
175 |
</style>
|
176 |
|
177 |
|
178 |
-
<form method="post" action="options.php" style="clear: both">
|
179 |
<?php settings_fields('duplicate_post_group'); ?>
|
180 |
|
181 |
-
<
|
182 |
-
<
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
-
<section
|
|
|
|
|
|
|
|
|
192 |
|
193 |
<table class="form-table">
|
194 |
<tr valign="top">
|
@@ -229,13 +422,13 @@ img#donate-button{
|
|
229 |
<?php esc_html_e("Password", 'default'); ?>
|
230 |
</label> <label> <input type="checkbox"
|
231 |
name="duplicate_post_copyattachments" value="1" <?php if(get_option('duplicate_post_copyattachments') == 1) echo 'checked="checked"'; ?>/>
|
232 |
-
<?php esc_html_e("Attachments", 'duplicate-post'); ?> <
|
233 |
</label> <label> <input type="checkbox"
|
234 |
name="duplicate_post_copychildren" value="1" <?php if(get_option('duplicate_post_copychildren') == 1) echo 'checked="checked"'; ?>/>
|
235 |
<?php esc_html_e("Children", 'duplicate-post'); ?>
|
236 |
</label> <label> <input type="checkbox"
|
237 |
name="duplicate_post_copycomments" value="1" <?php if(get_option('duplicate_post_copycomments') == 1) echo 'checked="checked"'; ?>/>
|
238 |
-
<?php esc_html_e("Comments", 'default'); ?> <
|
239 |
</label> <label> <input type="checkbox"
|
240 |
name="duplicate_post_copymenuorder" value="1" <?php if(get_option('duplicate_post_copymenuorder') == 1) echo 'checked="checked"'; ?>/>
|
241 |
<?php esc_html_e("Menu order", 'default'); ?>
|
@@ -243,41 +436,54 @@ img#donate-button{
|
|
243 |
</td>
|
244 |
</tr>
|
245 |
<tr valign="top">
|
246 |
-
<th scope="row"
|
|
|
|
|
|
|
247 |
</th>
|
248 |
-
<td><input type="text" name="duplicate_post_title_prefix"
|
249 |
-
value="<?php
|
250 |
</td>
|
251 |
<td><span class="description"><?php esc_html_e("Prefix to be added before the title, e.g. \"Copy of\" (blank for no prefix)", 'duplicate-post'); ?>
|
252 |
</span>
|
253 |
</td>
|
254 |
</tr>
|
255 |
<tr valign="top">
|
256 |
-
<th scope="row"
|
|
|
|
|
|
|
257 |
</th>
|
258 |
-
<td><input type="text" name="duplicate_post_title_suffix"
|
259 |
-
value="<?php
|
260 |
</td>
|
261 |
<td><span class="description"><?php esc_html_e("Suffix to be added after the title, e.g. \"(dup)\" (blank for no suffix)", 'duplicate-post'); ?>
|
262 |
</span>
|
263 |
</td>
|
264 |
</tr>
|
265 |
<tr valign="top">
|
266 |
-
<th scope="row"
|
|
|
|
|
|
|
267 |
</th>
|
268 |
-
<td><input type="text" name="duplicate_post_increase_menu_order_by"
|
269 |
-
value="<?php
|
270 |
</td>
|
271 |
<td><span class="description"><?php esc_html_e("Add this number to the original menu order (blank or zero to retain the value)", 'duplicate-post'); ?>
|
272 |
</span>
|
273 |
</td>
|
274 |
</tr>
|
275 |
<tr valign="top">
|
276 |
-
<th scope="row"
|
|
|
|
|
|
|
277 |
</th>
|
278 |
<td id="textfield"><input type="text"
|
279 |
name="duplicate_post_blacklist"
|
280 |
-
|
|
|
281 |
<td><span class="description"><?php esc_html_e("Comma-separated list of meta fields that must not be copied", 'duplicate-post'); ?><br />
|
282 |
<small><?php esc_html_e("You can use * to match zero or more alphanumeric characters or underscores: e.g. field*", 'duplicate-post'); ?>
|
283 |
</small> </span>
|
@@ -309,7 +515,12 @@ img#donate-button{
|
|
309 |
</tr>
|
310 |
</table>
|
311 |
</section>
|
312 |
-
<section
|
|
|
|
|
|
|
|
|
|
|
313 |
<table class="form-table">
|
314 |
<?php if ( current_user_can( 'promote_users' ) ){ ?>
|
315 |
<tr valign="top">
|
@@ -353,7 +564,12 @@ img#donate-button{
|
|
353 |
</tr>
|
354 |
</table>
|
355 |
</section>
|
356 |
-
<section
|
|
|
|
|
|
|
|
|
|
|
357 |
<table class="form-table">
|
358 |
<tr valign="top">
|
359 |
<th scope="row"><?php esc_html_e("Show links in", 'duplicate-post'); ?>
|
@@ -364,7 +580,7 @@ img#donate-button{
|
|
364 |
<label><input type="checkbox" name="duplicate_post_show_submitbox" value="1" <?php if(get_option('duplicate_post_show_submitbox') == 1) echo 'checked="checked"'; ?>/>
|
365 |
<?php esc_html_e("Edit screen", 'duplicate-post'); ?> </label>
|
366 |
<label><input type="checkbox" name="duplicate_post_show_adminbar" value="1" <?php if(get_option('duplicate_post_show_adminbar') == 1) echo 'checked="checked"'; ?>/>
|
367 |
-
<?php esc_html_e("Admin bar", 'duplicate-post'); ?> <
|
368 |
<?php global $wp_version;
|
369 |
if( version_compare($wp_version, '4.7') >= 0 ){ ?>
|
370 |
<label><input type="checkbox" name="duplicate_post_show_bulkactions" value="1" <?php if(get_option('duplicate_post_show_bulkactions') == 1) echo 'checked="checked"'; ?>/>
|
@@ -374,14 +590,39 @@ img#donate-button{
|
|
374 |
</tr>
|
375 |
<tr valign="top">
|
376 |
<td colspan="2"><span class="description"><?php esc_html_e("Whether the links are displayed for custom post types registered by themes or plugins depends on their use of standard WordPress UI elements", 'duplicate-post'); ?>
|
377 |
-
<br /> <?php printf(__('You can also use the template tag duplicate_post_clone_post_link( $link, $before, $after, $id ).
|
378 |
</span>
|
379 |
</td>
|
380 |
</tr>
|
381 |
<tr valign="top">
|
382 |
-
<th scope="row"><?php esc_html_e("Show
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
</th>
|
384 |
-
<td><input type="checkbox" name="duplicate_post_show_notice"
|
385 |
value="1" <?php if(get_option('duplicate_post_show_notice') == 1) echo 'checked="checked"'; ?>/>
|
386 |
</td>
|
387 |
</tr>
|
38 |
register_setting( 'duplicate_post_group', 'duplicate_post_show_adminbar');
|
39 |
register_setting( 'duplicate_post_group', 'duplicate_post_show_submitbox');
|
40 |
register_setting( 'duplicate_post_group', 'duplicate_post_show_bulkactions');
|
41 |
+
register_setting( 'duplicate_post_group', 'duplicate_post_show_original_column');
|
42 |
+
register_setting( 'duplicate_post_group', 'duplicate_post_show_original_in_post_states');
|
43 |
+
register_setting( 'duplicate_post_group', 'duplicate_post_show_original_meta_box');
|
44 |
register_setting( 'duplicate_post_group', 'duplicate_post_show_notice');
|
45 |
}
|
46 |
|
80 |
</h1>
|
81 |
|
82 |
<div
|
83 |
+
style="display: flex; align-items: center; margin: 9px 15px 4px 0; padding: 5px 30px; float: left; clear:left; border: solid 3px #cccccc; width: 600px;">
|
84 |
+
<svg xmlns="http://www.w3.org/2000/svg" style="padding: 0; margin: 10px 20px 10px 0;" width="80" height="80" viewBox="0 0 20 20">
|
85 |
+
<path d="M18.9 4.3c0.6 0 1.1 0.5 1.1 1.1v13.6c0 0.6-0.5 1.1-1.1 1.1h-10.7c-0.6 0-1.1-0.5-1.1-1.1v-3.2h-6.1c-0.6 0-1.1-0.5-1.1-1.1v-7.5c0-0.6 0.3-1.4 0.8-1.8l4.6-4.6c0.4-0.4 1.2-0.8 1.8-0.8h4.6c0.6 0 1.1 0.5 1.1 1.1v3.7c0.4-0.3 1-0.4 1.4-0.4h4.6zM12.9 6.7l-3.3 3.3h3.3v-3.3zM5.7 2.4l-3.3 3.3h3.3v-3.3zM7.9 9.6l3.5-3.5v-4.6h-4.3v4.6c0 0.6-0.5 1.1-1.1 1.1h-4.6v7.1h5.7v-2.9c0-0.6 0.3-1.4 0.8-1.8zM18.6 18.6v-12.9h-4.3v4.6c0 0.6-0.5 1.1-1.1 1.1h-4.6v7.1h10z"
|
86 |
+
fill="rgba(140,140,140,1)"/>
|
87 |
+
</svg>
|
88 |
+
<div>
|
89 |
<p>
|
90 |
+
<?php esc_html_e('Serving the WordPress community since November 2007.', 'duplicate-post'); ?>
|
91 |
+
<br/>
|
92 |
+
<strong><a href="https://duplicate-post.lopo.it/donate/"><?php esc_html_e('Support the plugin by making a donation or becoming a patron!', 'duplicate-post'); ?></a></strong>
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
</p>
|
94 |
+
<p>
|
95 |
+
<a href="https://duplicate-post.lopo.it/" aria-label="<?php esc_attr_e('Documentation for Duplicate Post', 'duplicate-post'); ?>"><?php esc_html_e('Documentation', 'duplicate-post'); ?></a>
|
96 |
+
- <a href="https://translate.wordpress.org/projects/wp-plugins/duplicate-post" aria-label="<?php esc_attr_e('Translate Duplicate Post', 'duplicate-post'); ?>"><?php esc_html_e('Translate', 'duplicate-post'); ?></a>
|
97 |
+
- <a href="https://wordpress.org/support/plugin/duplicate-post" aria-label="<?php esc_attr_e('Support forum for Duplicate Post', 'duplicate-post'); ?>"><?php esc_html_e('Support Forum', 'duplicate-post'); ?></a>
|
98 |
+
</p>
|
99 |
+
</div>
|
100 |
</div>
|
101 |
|
102 |
|
103 |
<script>
|
104 |
+
var tablist;
|
105 |
+
var tabs;
|
106 |
+
var panels;
|
107 |
+
|
108 |
+
// For easy reference
|
109 |
+
var keys = {
|
110 |
+
end: 35,
|
111 |
+
home: 36,
|
112 |
+
left: 37,
|
113 |
+
up: 38,
|
114 |
+
right: 39,
|
115 |
+
down: 40,
|
116 |
+
delete: 46
|
117 |
+
};
|
118 |
+
|
119 |
+
// Add or substract depending on key pressed
|
120 |
+
var direction = {
|
121 |
+
37: -1,
|
122 |
+
38: -1,
|
123 |
+
39: 1,
|
124 |
+
40: 1
|
125 |
+
};
|
126 |
+
|
127 |
+
|
128 |
+
function generateArrays () {
|
129 |
+
tabs = document.querySelectorAll('#duplicate_post_settings_form [role="tab"]');
|
130 |
+
panels = document.querySelectorAll('#duplicate_post_settings_form [role="tabpanel"]');
|
131 |
+
};
|
132 |
+
|
133 |
+
function addListeners (index) {
|
134 |
+
tabs[index].addEventListener('click', function(event){
|
135 |
+
var tab = event.target;
|
136 |
+
activateTab(tab, false);
|
137 |
+
});
|
138 |
+
tabs[index].addEventListener('keydown', function(event) {
|
139 |
+
var key = event.keyCode;
|
140 |
+
|
141 |
+
switch (key) {
|
142 |
+
case keys.end:
|
143 |
+
event.preventDefault();
|
144 |
+
// Activate last tab
|
145 |
+
activateTab(tabs[tabs.length - 1]);
|
146 |
+
break;
|
147 |
+
case keys.home:
|
148 |
+
event.preventDefault();
|
149 |
+
// Activate first tab
|
150 |
+
activateTab(tabs[0]);
|
151 |
+
break;
|
152 |
+
};
|
153 |
+
});
|
154 |
+
tabs[index].addEventListener('keyup', function(event) {
|
155 |
+
var key = event.keyCode;
|
156 |
+
|
157 |
+
switch (key) {
|
158 |
+
case keys.left:
|
159 |
+
case keys.right:
|
160 |
+
switchTabOnArrowPress(event);
|
161 |
+
break;
|
162 |
+
};
|
163 |
+
});
|
164 |
+
|
165 |
+
// Build an array with all tabs (<button>s) in it
|
166 |
+
tabs[index].index = index;
|
167 |
+
};
|
168 |
+
|
169 |
+
|
170 |
+
// Either focus the next, previous, first, or last tab
|
171 |
+
// depening on key pressed
|
172 |
+
function switchTabOnArrowPress (event) {
|
173 |
+
var pressed = event.keyCode;
|
174 |
+
|
175 |
+
for (x = 0; x < tabs.length; x++) {
|
176 |
+
tabs[x].addEventListener('focus', focusEventHandler);
|
177 |
+
};
|
178 |
+
|
179 |
+
if (direction[pressed]) {
|
180 |
+
var target = event.target;
|
181 |
+
if (target.index !== undefined) {
|
182 |
+
if (tabs[target.index + direction[pressed]]) {
|
183 |
+
tabs[target.index + direction[pressed]].focus();
|
184 |
+
}
|
185 |
+
else if (pressed === keys.left || pressed === keys.up) {
|
186 |
+
focusLastTab();
|
187 |
+
}
|
188 |
+
else if (pressed === keys.right || pressed == keys.down) {
|
189 |
+
focusFirstTab();
|
190 |
+
};
|
191 |
+
};
|
192 |
+
};
|
193 |
+
};
|
194 |
+
|
195 |
+
// Activates any given tab panel
|
196 |
+
function activateTab (tab, setFocus) {
|
197 |
+
setFocus = setFocus || true;
|
198 |
+
// Deactivate all other tabs
|
199 |
+
deactivateTabs();
|
200 |
+
|
201 |
+
// Remove tabindex attribute
|
202 |
+
tab.removeAttribute('tabindex');
|
203 |
+
|
204 |
+
// Set the tab as selected
|
205 |
+
tab.setAttribute('aria-selected', 'true');
|
206 |
+
|
207 |
+
tab.classList.add('nav-tab-active');
|
208 |
+
|
209 |
+
// Get the value of aria-controls (which is an ID)
|
210 |
+
var controls = tab.getAttribute('aria-controls');
|
211 |
+
|
212 |
+
// Remove hidden attribute from tab panel to make it visible
|
213 |
+
document.getElementById(controls).removeAttribute('hidden');
|
214 |
+
|
215 |
+
// Set focus when required
|
216 |
+
if (setFocus) {
|
217 |
+
tab.focus();
|
218 |
+
};
|
219 |
+
};
|
220 |
+
|
221 |
+
// Deactivate all tabs and tab panels
|
222 |
+
function deactivateTabs () {
|
223 |
+
for (t = 0; t < tabs.length; t++) {
|
224 |
+
tabs[t].setAttribute('tabindex', '-1');
|
225 |
+
tabs[t].setAttribute('aria-selected', 'false');
|
226 |
+
tabs[t].classList.remove('nav-tab-active');
|
227 |
+
tabs[t].removeEventListener('focus', focusEventHandler);
|
228 |
+
};
|
229 |
+
|
230 |
+
for (p = 0; p < panels.length; p++) {
|
231 |
+
panels[p].setAttribute('hidden', 'hidden');
|
232 |
+
};
|
233 |
+
};
|
234 |
+
|
235 |
+
// Make a guess
|
236 |
+
function focusFirstTab () {
|
237 |
+
tabs[0].focus();
|
238 |
+
};
|
239 |
+
|
240 |
+
// Make a guess
|
241 |
+
function focusLastTab () {
|
242 |
+
tabs[tabs.length - 1].focus();
|
243 |
+
};
|
244 |
+
|
245 |
+
//
|
246 |
+
function focusEventHandler (event) {
|
247 |
+
var target = event.target;
|
248 |
+
|
249 |
+
checkTabFocus(target);
|
250 |
+
};
|
251 |
+
|
252 |
+
// Only activate tab on focus if it still has focus after the delay
|
253 |
+
function checkTabFocus (target) {
|
254 |
+
focused = document.activeElement;
|
255 |
+
|
256 |
+
if (target === focused) {
|
257 |
+
activateTab(target, false);
|
258 |
+
};
|
259 |
+
};
|
260 |
+
|
261 |
+
document.addEventListener("DOMContentLoaded", function () {
|
262 |
+
tablist = document.querySelectorAll('#duplicate_post_settings_form [role="tablist"]')[0];
|
263 |
+
|
264 |
+
generateArrays();
|
265 |
+
|
266 |
+
// Bind listeners
|
267 |
+
for (i = 0; i < tabs.length; ++i) {
|
268 |
+
addListeners(i);
|
269 |
+
};
|
270 |
+
|
271 |
+
|
272 |
+
});
|
273 |
|
274 |
function toggle_private_taxonomies(){
|
275 |
jQuery('.taxonomy_private').toggle(300);
|
283 |
</script>
|
284 |
|
285 |
<style>
|
286 |
+
header.nav-tab-wrapper {
|
287 |
margin: 22px 0 0 0;
|
288 |
}
|
289 |
|
290 |
+
header .nav-tab:focus {
|
291 |
color: #555;
|
292 |
box-shadow: none;
|
293 |
}
|
298 |
border: 1px solid #ccc;
|
299 |
border-top: 0px;
|
300 |
}
|
301 |
+
/*
|
302 |
section {
|
303 |
display: none;
|
304 |
}
|
305 |
|
306 |
section:first-of-type {
|
307 |
display: block;
|
308 |
+
}*/
|
309 |
|
310 |
+
.no-js header.nav-tab-wrapper {
|
311 |
display: none;
|
312 |
}
|
313 |
|
345 |
</style>
|
346 |
|
347 |
|
348 |
+
<form method="post" action="options.php" style="clear: both" id="duplicate_post_settings_form">
|
349 |
<?php settings_fields('duplicate_post_group'); ?>
|
350 |
|
351 |
+
<header role="tablist" aria-label="<?php esc_attr_e('Settings sections', 'duplicate-post'); ?>" class="nav-tab-wrapper">
|
352 |
+
<button
|
353 |
+
type="button"
|
354 |
+
role="tab"
|
355 |
+
class="nav-tab nav-tab-active"
|
356 |
+
aria-selected="true"
|
357 |
+
aria-controls="what-tab"
|
358 |
+
id="what"><?php esc_html_e('What to copy', 'duplicate-post'); ?>
|
359 |
+
</button>
|
360 |
+
<button
|
361 |
+
type="button"
|
362 |
+
role="tab"
|
363 |
+
class="nav-tab"
|
364 |
+
aria-selected="false"
|
365 |
+
aria-controls="who-tab"
|
366 |
+
id="who"
|
367 |
+
tabindex="-1"><?php esc_html_e('Permissions', 'duplicate-post'); ?>
|
368 |
+
</button>
|
369 |
+
<button
|
370 |
+
type="button"
|
371 |
+
role="tab"
|
372 |
+
class="nav-tab"
|
373 |
+
aria-selected="false"
|
374 |
+
aria-controls="where-tab"
|
375 |
+
id="where"
|
376 |
+
tabindex="-1"><?php esc_html_e('Display', 'duplicate-post'); ?>
|
377 |
+
</button>
|
378 |
+
</header>
|
379 |
|
380 |
+
<section
|
381 |
+
tabindex="0"
|
382 |
+
role="tabpanel"
|
383 |
+
id="what-tab"
|
384 |
+
aria-labelledby="what">
|
385 |
|
386 |
<table class="form-table">
|
387 |
<tr valign="top">
|
422 |
<?php esc_html_e("Password", 'default'); ?>
|
423 |
</label> <label> <input type="checkbox"
|
424 |
name="duplicate_post_copyattachments" value="1" <?php if(get_option('duplicate_post_copyattachments') == 1) echo 'checked="checked"'; ?>/>
|
425 |
+
<?php esc_html_e("Attachments", 'duplicate-post'); ?> <span class="description">(<?php esc_html_e("you probably want this unchecked, unless you have very special requirements", 'duplicate-post'); ?>)</span>
|
426 |
</label> <label> <input type="checkbox"
|
427 |
name="duplicate_post_copychildren" value="1" <?php if(get_option('duplicate_post_copychildren') == 1) echo 'checked="checked"'; ?>/>
|
428 |
<?php esc_html_e("Children", 'duplicate-post'); ?>
|
429 |
</label> <label> <input type="checkbox"
|
430 |
name="duplicate_post_copycomments" value="1" <?php if(get_option('duplicate_post_copycomments') == 1) echo 'checked="checked"'; ?>/>
|
431 |
+
<?php esc_html_e("Comments", 'default'); ?> <span class="description">(<?php esc_html_e("except pingbacks and trackbacks", 'duplicate-post'); ?>)</span>
|
432 |
</label> <label> <input type="checkbox"
|
433 |
name="duplicate_post_copymenuorder" value="1" <?php if(get_option('duplicate_post_copymenuorder') == 1) echo 'checked="checked"'; ?>/>
|
434 |
<?php esc_html_e("Menu order", 'default'); ?>
|
436 |
</td>
|
437 |
</tr>
|
438 |
<tr valign="top">
|
439 |
+
<th scope="row">
|
440 |
+
<label for="duplicate_post_title_prefix">
|
441 |
+
<?php esc_html_e("Title prefix", 'duplicate-post'); ?>
|
442 |
+
</label>
|
443 |
</th>
|
444 |
+
<td><input type="text" name="duplicate_post_title_prefix" id="duplicate_post_title_prefix"
|
445 |
+
value="<?php form_option('duplicate_post_title_prefix'); ?>" />
|
446 |
</td>
|
447 |
<td><span class="description"><?php esc_html_e("Prefix to be added before the title, e.g. \"Copy of\" (blank for no prefix)", 'duplicate-post'); ?>
|
448 |
</span>
|
449 |
</td>
|
450 |
</tr>
|
451 |
<tr valign="top">
|
452 |
+
<th scope="row">
|
453 |
+
<label for="duplicate_post_title_suffix">
|
454 |
+
<?php esc_html_e("Title suffix", 'duplicate-post'); ?>
|
455 |
+
</label>
|
456 |
</th>
|
457 |
+
<td><input type="text" name="duplicate_post_title_suffix" id="duplicate_post_title_suffix"
|
458 |
+
value="<?php form_option('duplicate_post_title_suffix'); ?>" />
|
459 |
</td>
|
460 |
<td><span class="description"><?php esc_html_e("Suffix to be added after the title, e.g. \"(dup)\" (blank for no suffix)", 'duplicate-post'); ?>
|
461 |
</span>
|
462 |
</td>
|
463 |
</tr>
|
464 |
<tr valign="top">
|
465 |
+
<th scope="row">
|
466 |
+
<label for="duplicate_post_increase_menu_order_by">
|
467 |
+
<?php esc_html_e("Increase menu order by", 'duplicate-post'); ?>
|
468 |
+
</label>
|
469 |
</th>
|
470 |
+
<td><input type="text" name="duplicate_post_increase_menu_order_by" id="duplicate_post_increase_menu_order_by"
|
471 |
+
value="<?php form_option('duplicate_post_increase_menu_order_by'); ?>" />
|
472 |
</td>
|
473 |
<td><span class="description"><?php esc_html_e("Add this number to the original menu order (blank or zero to retain the value)", 'duplicate-post'); ?>
|
474 |
</span>
|
475 |
</td>
|
476 |
</tr>
|
477 |
<tr valign="top">
|
478 |
+
<th scope="row">
|
479 |
+
<label for="duplicate_post_blacklist">
|
480 |
+
<?php esc_html_e("Do not copy these fields", 'duplicate-post'); ?>
|
481 |
+
</label>
|
482 |
</th>
|
483 |
<td id="textfield"><input type="text"
|
484 |
name="duplicate_post_blacklist"
|
485 |
+
id="duplicate_post_blacklist"
|
486 |
+
value="<?php form_option('duplicate_post_blacklist'); ?>" /></td>
|
487 |
<td><span class="description"><?php esc_html_e("Comma-separated list of meta fields that must not be copied", 'duplicate-post'); ?><br />
|
488 |
<small><?php esc_html_e("You can use * to match zero or more alphanumeric characters or underscores: e.g. field*", 'duplicate-post'); ?>
|
489 |
</small> </span>
|
515 |
</tr>
|
516 |
</table>
|
517 |
</section>
|
518 |
+
<section
|
519 |
+
tabindex="0"
|
520 |
+
role="tabpanel"
|
521 |
+
id="who-tab"
|
522 |
+
aria-labelledby="who"
|
523 |
+
hidden="hidden">
|
524 |
<table class="form-table">
|
525 |
<?php if ( current_user_can( 'promote_users' ) ){ ?>
|
526 |
<tr valign="top">
|
564 |
</tr>
|
565 |
</table>
|
566 |
</section>
|
567 |
+
<section
|
568 |
+
tabindex="0"
|
569 |
+
role="tabpanel"
|
570 |
+
id="where-tab"
|
571 |
+
aria-labelledby="where"
|
572 |
+
hidden="hidden">
|
573 |
<table class="form-table">
|
574 |
<tr valign="top">
|
575 |
<th scope="row"><?php esc_html_e("Show links in", 'duplicate-post'); ?>
|
580 |
<label><input type="checkbox" name="duplicate_post_show_submitbox" value="1" <?php if(get_option('duplicate_post_show_submitbox') == 1) echo 'checked="checked"'; ?>/>
|
581 |
<?php esc_html_e("Edit screen", 'duplicate-post'); ?> </label>
|
582 |
<label><input type="checkbox" name="duplicate_post_show_adminbar" value="1" <?php if(get_option('duplicate_post_show_adminbar') == 1) echo 'checked="checked"'; ?>/>
|
583 |
+
<?php esc_html_e("Admin bar", 'duplicate-post'); ?> <span class="description">(<?php esc_html_e("now works on Edit screen too - check this option to use with Gutenberg enabled", 'duplicate-post'); ?>)</span></label>
|
584 |
<?php global $wp_version;
|
585 |
if( version_compare($wp_version, '4.7') >= 0 ){ ?>
|
586 |
<label><input type="checkbox" name="duplicate_post_show_bulkactions" value="1" <?php if(get_option('duplicate_post_show_bulkactions') == 1) echo 'checked="checked"'; ?>/>
|
590 |
</tr>
|
591 |
<tr valign="top">
|
592 |
<td colspan="2"><span class="description"><?php esc_html_e("Whether the links are displayed for custom post types registered by themes or plugins depends on their use of standard WordPress UI elements", 'duplicate-post'); ?>
|
593 |
+
<br /> <?php printf(__('You can also use the template tag duplicate_post_clone_post_link( $link, $before, $after, $id ). You can find more info about this on the <a href="%s">developer's guide for Duplicate Post</a>', 'duplicate-post'), 'https://duplicate-post.lopo.it/docs/developers-guide/functions-template-tags/duplicate_post_clone_post_link/'); ?>
|
594 |
</span>
|
595 |
</td>
|
596 |
</tr>
|
597 |
<tr valign="top">
|
598 |
+
<th scope="row"><?php esc_html_e("Show original item:", 'duplicate-post'); ?></th>
|
599 |
+
<td>
|
600 |
+
<label>
|
601 |
+
<input type="checkbox" name="duplicate_post_show_original_meta_box"
|
602 |
+
value="1" <?php if(get_option('duplicate_post_show_original_meta_box') == 1) echo 'checked="checked"'; ?>/>
|
603 |
+
<?php esc_html_e("In a metabox in the Edit screen [Classic editor]", 'duplicate-post'); ?>
|
604 |
+
<span class="description">(<?php esc_html_e("you'll also be able to delete the reference to the original item with a checkbox", 'duplicate-post'); ?>)</span>
|
605 |
+
</label>
|
606 |
+
<label>
|
607 |
+
<input type="checkbox" name="duplicate_post_show_original_column"
|
608 |
+
value="1" <?php if(get_option('duplicate_post_show_original_column') == 1) echo 'checked="checked"'; ?>/>
|
609 |
+
<?php esc_html_e("In a column in the Post list", 'duplicate-post'); ?>
|
610 |
+
<span class="description">(<?php esc_html_e("you'll also be able to delete the reference to the original item with a checkbox in Quick Edit", 'duplicate-post'); ?>)</span>
|
611 |
+
</label>
|
612 |
+
<label>
|
613 |
+
<input type="checkbox" name="duplicate_post_show_original_in_post_states"
|
614 |
+
value="1" <?php if(get_option('duplicate_post_show_original_in_post_states') == 1) echo 'checked="checked"'; ?>/>
|
615 |
+
<?php esc_html_e("After the title in the Post list", 'duplicate-post'); ?>
|
616 |
+
</label>
|
617 |
+
</td>
|
618 |
+
</tr>
|
619 |
+
<tr valign="top">
|
620 |
+
<th scope="row">
|
621 |
+
<label for="duplicate_post_show_notice">
|
622 |
+
<?php esc_html_e("Show update notice", 'duplicate-post'); ?>
|
623 |
+
</label>
|
624 |
</th>
|
625 |
+
<td><input type="checkbox" name="duplicate_post_show_notice" id="duplicate_post_show_notice"
|
626 |
value="1" <?php if(get_option('duplicate_post_show_notice') == 1) echo 'checked="checked"'; ?>/>
|
627 |
</td>
|
628 |
</tr>
|
duplicate-post.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: Duplicate Post
|
4 |
Plugin URI: https://duplicate-post.lopo.it/
|
5 |
-
Description: Clone posts and pages.
|
6 |
-
Version: 3.2.
|
7 |
Author: Enrico Battocchi
|
8 |
Author URI: https://lopo.it
|
9 |
Text Domain: duplicate-post
|
@@ -31,7 +31,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
31 |
}
|
32 |
|
33 |
// Version of the plugin
|
34 |
-
define('DUPLICATE_POST_CURRENT_VERSION', '3.2.
|
35 |
|
36 |
|
37 |
/**
|
@@ -46,7 +46,13 @@ add_action( 'plugins_loaded', 'duplicate_post_load_plugin_textdomain' );
|
|
46 |
add_filter("plugin_action_links_".plugin_basename(__FILE__), "duplicate_post_plugin_actions", 10, 4);
|
47 |
|
48 |
function duplicate_post_plugin_actions( $actions, $plugin_file, $plugin_data, $context ) {
|
49 |
-
array_unshift($actions,
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
return $actions;
|
51 |
}
|
52 |
|
2 |
/*
|
3 |
Plugin Name: Duplicate Post
|
4 |
Plugin URI: https://duplicate-post.lopo.it/
|
5 |
+
Description: Clone posts and pages.
|
6 |
+
Version: 3.2.4
|
7 |
Author: Enrico Battocchi
|
8 |
Author URI: https://lopo.it
|
9 |
Text Domain: duplicate-post
|
31 |
}
|
32 |
|
33 |
// Version of the plugin
|
34 |
+
define('DUPLICATE_POST_CURRENT_VERSION', '3.2.4' );
|
35 |
|
36 |
|
37 |
/**
|
46 |
add_filter("plugin_action_links_".plugin_basename(__FILE__), "duplicate_post_plugin_actions", 10, 4);
|
47 |
|
48 |
function duplicate_post_plugin_actions( $actions, $plugin_file, $plugin_data, $context ) {
|
49 |
+
array_unshift($actions,
|
50 |
+
sprintf('<a href="%s" aria-label="%s">%s</a>',
|
51 |
+
menu_page_url('duplicatepost', false),
|
52 |
+
esc_attr__( 'Settings for Duplicate Post', 'duplicate-post'),
|
53 |
+
esc_html__("Settings", 'default')
|
54 |
+
)
|
55 |
+
);
|
56 |
return $actions;
|
57 |
}
|
58 |
|
duplicate_post_admin_script.js
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function(jQuery) {
|
2 |
+
// we create a copy of the WP inline edit post function
|
3 |
+
var $wp_inline_edit = inlineEditPost.edit;
|
4 |
+
// and then we overwrite the function with our own code
|
5 |
+
inlineEditPost.edit = function( id ) {
|
6 |
+
// "call" the original WP edit function
|
7 |
+
// we don't want to leave WordPress hanging
|
8 |
+
$wp_inline_edit.apply( this, arguments );
|
9 |
+
// now we take care of our business
|
10 |
+
// get the post ID
|
11 |
+
var $post_id = 0;
|
12 |
+
if ( typeof( id ) == 'object' ) {
|
13 |
+
$post_id = parseInt( this.getId( id ) );
|
14 |
+
}
|
15 |
+
if ( $post_id > 0 ) {
|
16 |
+
// define the edit row.
|
17 |
+
var $edit_row = jQuery( '#edit-' + $post_id );
|
18 |
+
var $post_row = jQuery( '#post-' + $post_id );
|
19 |
+
|
20 |
+
// get the data.
|
21 |
+
var has_original = ( jQuery( '.duplicate_post_original_item span[data-no_original]', $post_row ).length === 0 );
|
22 |
+
var original = jQuery( '.duplicate_post_original_item', $post_row ).html();
|
23 |
+
|
24 |
+
// populate the data.
|
25 |
+
if ( has_original ) {
|
26 |
+
jQuery( '.duplicate_post_original_item_title_span', $edit_row ).html( original );
|
27 |
+
jQuery( '#duplicate_post_quick_edit_fieldset', $edit_row ).show();
|
28 |
+
} else {
|
29 |
+
jQuery( '#duplicate_post_quick_edit_fieldset', $edit_row ).hide();
|
30 |
+
jQuery( '.duplicate_post_original_item_title_span', $edit_row ).html( '' );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
};
|
34 |
+
|
35 |
+
})(jQuery);
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: lopo
|
|
3 |
Donate link: https://duplicate-post.lopo.it/
|
4 |
Tags: duplicate post, copy, clone
|
5 |
Requires at least: 3.6
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 3.2.
|
8 |
Requires PHP: 5.2.4
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -14,7 +14,7 @@ Copy posts of any type with a click!
|
|
14 |
== Description ==
|
15 |
|
16 |
This plugin allows users to clone posts of any type, or copy them to new drafts for further editing.
|
17 |
-
If you find this useful, [**please consider donating**](https://duplicate-post.lopo.it/) whatever sum you choose, **even just 10 cents**. Just a few cents from every user would help me develop the plugin and improve support.
|
18 |
|
19 |
How it works:
|
20 |
|
@@ -79,8 +79,11 @@ If Duplicate Post is still in English, or if there are some untraslated strings,
|
|
79 |
|
80 |
== Upgrade Notice ==
|
81 |
|
|
|
|
|
|
|
82 |
= 3.2.3 =
|
83 |
-
Fixes some bugs and incompatibilities with CF7, WPML, and custom post types with custom capabilities
|
84 |
|
85 |
= 3.2.2 =
|
86 |
Adds compatibility with Gutenberg UI and fixes a problem with slugs on new installs
|
@@ -150,6 +153,11 @@ New features and customization, WP 3.0 compatibility: you should upgrade if you
|
|
150 |
|
151 |
== Changelog ==
|
152 |
|
|
|
|
|
|
|
|
|
|
|
153 |
= 3.2.3 (2019-07-10) =
|
154 |
* Fixes incompatibility with previous versions of CF7
|
155 |
* Now roles without edit_posts capability but having equivalent capability for custom post types can be allowed to copy
|
3 |
Donate link: https://duplicate-post.lopo.it/
|
4 |
Tags: duplicate post, copy, clone
|
5 |
Requires at least: 3.6
|
6 |
+
Tested up to: 5.4
|
7 |
+
Stable tag: 3.2.4
|
8 |
Requires PHP: 5.2.4
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
14 |
== Description ==
|
15 |
|
16 |
This plugin allows users to clone posts of any type, or copy them to new drafts for further editing.
|
17 |
+
If you find this useful, [**please consider donating**](https://duplicate-post.lopo.it/donate/) whatever sum you choose, **even just 10 cents**. Just a few cents from every user would help me develop the plugin and improve support.
|
18 |
|
19 |
How it works:
|
20 |
|
79 |
|
80 |
== Upgrade Notice ==
|
81 |
|
82 |
+
= 3.2.4 =
|
83 |
+
Options to show original post + accessibility improvements
|
84 |
+
|
85 |
= 3.2.3 =
|
86 |
+
Fixes some bugs and incompatibilities with CF7, WPML, and custom post types with custom capabilities
|
87 |
|
88 |
= 3.2.2 =
|
89 |
Adds compatibility with Gutenberg UI and fixes a problem with slugs on new installs
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
+
= 3.2.4 (2019-12-10) =
|
157 |
+
* Options to show original item in post list (in a column or alongside post states) or in a metabox in the edit screen
|
158 |
+
* Accessibility improvements
|
159 |
+
* Small other fixes
|
160 |
+
|
161 |
= 3.2.3 (2019-07-10) =
|
162 |
* Fixes incompatibility with previous versions of CF7
|
163 |
* Now roles without edit_posts capability but having equivalent capability for custom post types can be allowed to copy
|