Version Description
- Multiple data sanitization updates
Download this release
Release Info
Developer | metaphorcreations |
Plugin | Post Duplicator |
Version | 2.25 |
Comparing to | |
See all releases |
Code changes from version 2.24 to 2.25
- assets/js/pd-admin.js +11 -11
- includes/ajax.php +7 -6
- includes/edit.php +2 -2
- includes/functions.php +1 -1
- includes/notices.php +5 -5
- includes/scripts.php +10 -15
- includes/settings.php +54 -54
- m4c-postduplicator.php +3 -3
- metaboxer/images/attachment-audio.png +0 -0
- metaboxer/images/attachment-delete.png +0 -0
- metaboxer/images/attachment-image.png +0 -0
- metaboxer/images/attachment-preview.png +0 -0
- metaboxer/images/attachment-settings.png +0 -0
- metaboxer/images/attachment-video.png +0 -0
- metaboxer/images/attachment-vimeo.png +0 -0
- metaboxer/images/attachment-youtube.png +0 -0
- metaboxer/metaboxer-class.php +0 -186
- metaboxer/metaboxer.js +0 -2
- metaboxer/metaboxer.php +37 -43
- readme.txt +5 -2
assets/js/pd-admin.js
CHANGED
@@ -6,7 +6,7 @@ jQuery( document ).ready( function() {
|
|
6 |
* Creates an ajax request that creates a new post,
|
7 |
* duplicating all the data and custom meta.
|
8 |
*
|
9 |
-
* @since 2.
|
10 |
*/
|
11 |
|
12 |
jQuery( 'body' ).on( 'click', '.m4c-duplicate-post', function( e ) {
|
@@ -21,18 +21,18 @@ jQuery( document ).ready( function() {
|
|
21 |
original_id: jQuery(this).data('postid'),
|
22 |
security: jQuery(this).attr('rel')
|
23 |
};
|
24 |
-
|
25 |
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
26 |
jQuery.post( ajaxurl, data, function( response ) {
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
33 |
}
|
34 |
-
|
35 |
-
window.location.href = location;
|
36 |
-
});
|
37 |
});
|
38 |
});
|
6 |
* Creates an ajax request that creates a new post,
|
7 |
* duplicating all the data and custom meta.
|
8 |
*
|
9 |
+
* @since 2.25
|
10 |
*/
|
11 |
|
12 |
jQuery( 'body' ).on( 'click', '.m4c-duplicate-post', function( e ) {
|
21 |
original_id: jQuery(this).data('postid'),
|
22 |
security: jQuery(this).attr('rel')
|
23 |
};
|
24 |
+
|
25 |
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
26 |
jQuery.post( ajaxurl, data, function( response ) {
|
27 |
+
if ( response.duplicate_id ) {
|
28 |
+
var location = window.location.href;
|
29 |
+
if( location.split('?').length > 1 ) {
|
30 |
+
location = location + '&post-duplicated='+response.duplicate_id;
|
31 |
+
} else {
|
32 |
+
location = location + '?post-duplicated='+response.duplicate_id;
|
33 |
+
}
|
34 |
+
window.location.href = location;
|
35 |
}
|
36 |
+
}, 'json' );
|
|
|
|
|
37 |
});
|
38 |
});
|
includes/ajax.php
CHANGED
@@ -93,7 +93,7 @@ function mtphr_duplicate_post( $original_id, $args=array(), $do_action=true ) {
|
|
93 |
|
94 |
|
95 |
/* --------------------------------------------------------- */
|
96 |
-
/* !Ajax duplicate post - 2.
|
97 |
/* --------------------------------------------------------- */
|
98 |
|
99 |
function m4c_duplicate_post() {
|
@@ -102,13 +102,14 @@ function m4c_duplicate_post() {
|
|
102 |
check_ajax_referer( 'm4c_ajax_file_nonce', 'security' );
|
103 |
|
104 |
// Get variables
|
105 |
-
$original_id = $_POST['original_id'];
|
106 |
|
107 |
// Duplicate the post
|
108 |
$duplicate_id = mtphr_duplicate_post( $original_id );
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
113 |
}
|
114 |
add_action( 'wp_ajax_m4c_duplicate_post', 'm4c_duplicate_post' );
|
93 |
|
94 |
|
95 |
/* --------------------------------------------------------- */
|
96 |
+
/* !Ajax duplicate post - 2.25 */
|
97 |
/* --------------------------------------------------------- */
|
98 |
|
99 |
function m4c_duplicate_post() {
|
102 |
check_ajax_referer( 'm4c_ajax_file_nonce', 'security' );
|
103 |
|
104 |
// Get variables
|
105 |
+
$original_id = intval( $_POST['original_id'] );
|
106 |
|
107 |
// Duplicate the post
|
108 |
$duplicate_id = mtphr_duplicate_post( $original_id );
|
109 |
+
|
110 |
+
$data = array(
|
111 |
+
'duplicate_id' => esc_attr( $duplicate_id ),
|
112 |
+
);
|
113 |
+
wp_send_json( $data );
|
114 |
}
|
115 |
add_action( 'wp_ajax_m4c_duplicate_post', 'm4c_duplicate_post' );
|
includes/edit.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Add a duplicate post link.
|
5 |
*
|
6 |
-
* @since 2.
|
7 |
*/
|
8 |
function mtphr_post_duplicator_action_row_link( $post ) {
|
9 |
|
@@ -32,7 +32,7 @@ function mtphr_post_duplicator_action_row_link( $post ) {
|
|
32 |
$nonce = wp_create_nonce( 'm4c_ajax_file_nonce' );
|
33 |
|
34 |
// Return the link
|
35 |
-
return '<a class="m4c-duplicate-post" rel="'
|
36 |
}
|
37 |
|
38 |
// Add the duplicate link to post actions
|
3 |
/**
|
4 |
* Add a duplicate post link.
|
5 |
*
|
6 |
+
* @since 2.25
|
7 |
*/
|
8 |
function mtphr_post_duplicator_action_row_link( $post ) {
|
9 |
|
32 |
$nonce = wp_create_nonce( 'm4c_ajax_file_nonce' );
|
33 |
|
34 |
// Return the link
|
35 |
+
return '<a class="m4c-duplicate-post" rel="'.esc_attr( $nonce ).'" href="#" data-postid="'.esc_attr( $post->ID ).'">'.wp_kses_post( $label ).'</a>';
|
36 |
}
|
37 |
|
38 |
// Add the duplicate link to post actions
|
includes/functions.php
CHANGED
@@ -47,7 +47,7 @@ function mtphr_post_duplicator_submitbox( $post ) {
|
|
47 |
$nonce = wp_create_nonce( 'm4c_ajax_file_nonce' );
|
48 |
?>
|
49 |
<div class="misc-pub-section misc-pub-duplicator" id="duplicator">
|
50 |
-
<a class="m4c-duplicate-post button button-small" rel="<?php echo $nonce; ?>" href="#" data-postid="<?php echo $post->ID; ?>"><?php
|
51 |
</div>
|
52 |
<?php
|
53 |
}
|
47 |
$nonce = wp_create_nonce( 'm4c_ajax_file_nonce' );
|
48 |
?>
|
49 |
<div class="misc-pub-section misc-pub-duplicator" id="duplicator">
|
50 |
+
<a class="m4c-duplicate-post button button-small" rel="<?php echo esc_attr( $nonce ); ?>" href="#" data-postid="<?php echo esc_attr( $post->ID ); ?>"><?php esc_html_e( sprintf( __( 'Duplicate %s', 'post-duplicator' ), $post_type->labels->singular_name ) ); ?></a><span class="spinner" style="float:none;margin-top:2px;margin-left:4px;"></span>
|
51 |
</div>
|
52 |
<?php
|
53 |
}
|
includes/notices.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
|
3 |
/* --------------------------------------------------------- */
|
4 |
-
/* !Create an admin notice that a post has been duplicated - 2.
|
5 |
/* --------------------------------------------------------- */
|
6 |
|
7 |
function mtphr_post_duplicator_notice() {
|
8 |
|
9 |
-
$duplicated_id = isset($_GET['post-duplicated']) ?
|
10 |
if( $duplicated_id != '' ) {
|
11 |
|
12 |
$settings = get_mtphr_post_duplicator_settings();
|
13 |
|
14 |
// Get the post type object
|
15 |
-
$duplicated_post = get_post($duplicated_id);
|
16 |
$post_type = get_post_type_object( $duplicated_post->post_type );
|
17 |
|
18 |
// Set the button label
|
19 |
$pt = $post_type->labels->singular_name;
|
20 |
-
$link = '<a href="'.get_edit_post_link($duplicated_id).'">'.
|
21 |
$label = sprintf( __( 'Successfully Duplicated! You can edit your new %1$s %2$s.', 'post-duplicator' ), $pt, $link );
|
22 |
|
23 |
?>
|
24 |
<div class="updated">
|
25 |
-
<p><?php echo $label; ?></p>
|
26 |
</div>
|
27 |
<?php
|
28 |
}
|
1 |
<?php
|
2 |
|
3 |
/* --------------------------------------------------------- */
|
4 |
+
/* !Create an admin notice that a post has been duplicated - 2.25 */
|
5 |
/* --------------------------------------------------------- */
|
6 |
|
7 |
function mtphr_post_duplicator_notice() {
|
8 |
|
9 |
+
$duplicated_id = isset( $_GET['post-duplicated'] ) ? intval( $_GET['post-duplicated'] ) : '';
|
10 |
if( $duplicated_id != '' ) {
|
11 |
|
12 |
$settings = get_mtphr_post_duplicator_settings();
|
13 |
|
14 |
// Get the post type object
|
15 |
+
$duplicated_post = get_post( $duplicated_id );
|
16 |
$post_type = get_post_type_object( $duplicated_post->post_type );
|
17 |
|
18 |
// Set the button label
|
19 |
$pt = $post_type->labels->singular_name;
|
20 |
+
$link = '<a href="'.get_edit_post_link( $duplicated_id ).'">'.esc_html__( 'here', 'post-duplicator' ).'</a>';
|
21 |
$label = sprintf( __( 'Successfully Duplicated! You can edit your new %1$s %2$s.', 'post-duplicator' ), $pt, $link );
|
22 |
|
23 |
?>
|
24 |
<div class="updated">
|
25 |
+
<p><?php echo wp_kses_post( $label ); ?></p>
|
26 |
</div>
|
27 |
<?php
|
28 |
}
|
includes/scripts.php
CHANGED
@@ -1,30 +1,25 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
add_action( 'admin_enqueue_scripts', 'mtphr_post_duplicator_metaboxer_scripts' );
|
4 |
/**
|
5 |
* Load the metaboxer scripts
|
6 |
*
|
7 |
-
* @since 2.
|
8 |
*/
|
9 |
function mtphr_post_duplicator_metaboxer_scripts( $hook ) {
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
// Load the style sheet
|
14 |
-
wp_register_style( 'mtphr-post-duplicator-metaboxer', plugins_url().'/post-duplicator/metaboxer/metaboxer.css', false, MTPHR_POST_DUPLICATOR_VERSION );
|
15 |
-
wp_enqueue_style( 'mtphr-post-duplicator-metaboxer' );
|
16 |
}
|
17 |
}
|
|
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
add_action( 'admin_enqueue_scripts', 'm4c_duplicate_post_scripts' );
|
23 |
/**
|
24 |
* Add the necessary jquery.
|
25 |
*
|
26 |
-
* @since 2.
|
27 |
*/
|
28 |
function m4c_duplicate_post_scripts( $hook_suffix ) {
|
29 |
-
|
30 |
-
|
|
|
|
1 |
<?php
|
2 |
|
|
|
3 |
/**
|
4 |
* Load the metaboxer scripts
|
5 |
*
|
6 |
+
* @since 2.25
|
7 |
*/
|
8 |
function mtphr_post_duplicator_metaboxer_scripts( $hook ) {
|
9 |
+
if( $hook == 'tools_page_mtphr_post_duplicator_settings_menu' ) {
|
10 |
+
$version = WP_DEBUG ? time() : MTPHR_POST_DUPLICATOR_VERSION;
|
11 |
+
wp_enqueue_style( 'mtphr-post-duplicator-metaboxer', plugins_url().'/post-duplicator/metaboxer/metaboxer.css', false, $version );
|
|
|
|
|
|
|
12 |
}
|
13 |
}
|
14 |
+
add_action( 'admin_enqueue_scripts', 'mtphr_post_duplicator_metaboxer_scripts' );
|
15 |
|
|
|
|
|
|
|
|
|
16 |
/**
|
17 |
* Add the necessary jquery.
|
18 |
*
|
19 |
+
* @since 2.25
|
20 |
*/
|
21 |
function m4c_duplicate_post_scripts( $hook_suffix ) {
|
22 |
+
$version = WP_DEBUG ? time() : MTPHR_POST_DUPLICATOR_VERSION;
|
23 |
+
wp_enqueue_script( 'mtphr-post-duplicator', plugins_url().'/post-duplicator/assets/js/pd-admin.js', array('jquery'), $version );
|
24 |
+
}
|
25 |
+
add_action( 'admin_enqueue_scripts', 'm4c_duplicate_post_scripts' );
|
includes/settings.php
CHANGED
@@ -9,11 +9,11 @@ add_action( 'admin_menu', 'mtphr_post_duplicator_settings_page' );
|
|
9 |
function mtphr_post_duplicator_settings_page() {
|
10 |
|
11 |
add_management_page(
|
12 |
-
|
13 |
-
|
14 |
-
'administrator',
|
15 |
-
'mtphr_post_duplicator_settings_menu',
|
16 |
-
'mtphr_post_duplicator_settings_display'
|
17 |
);
|
18 |
}
|
19 |
|
@@ -29,110 +29,110 @@ add_action( 'admin_init', 'mtphr_post_duplicator_initialize_settings' );
|
|
29 |
function mtphr_post_duplicator_initialize_settings() {
|
30 |
|
31 |
$settings['post_duplication'] = array(
|
32 |
-
'title' =>
|
33 |
'type' => 'radio',
|
34 |
'options' => array(
|
35 |
-
'all_users' =>
|
36 |
-
'current_user' =>
|
37 |
),
|
38 |
'display' => 'inline',
|
39 |
'default' => 'all_users'
|
40 |
);
|
41 |
|
42 |
$settings['post_author'] = array(
|
43 |
-
'title' =>
|
44 |
'type' => 'radio',
|
45 |
'options' => array(
|
46 |
-
'current_user' =>
|
47 |
-
'original_user' =>
|
48 |
),
|
49 |
'display' => 'inline',
|
50 |
'default' => 'current_user'
|
51 |
);
|
52 |
|
53 |
$settings['status'] = array(
|
54 |
-
'title' =>
|
55 |
'type' => 'select',
|
56 |
'options' => array(
|
57 |
-
'same' =>
|
58 |
-
'draft' =>
|
59 |
-
'publish' =>
|
60 |
-
'pending' =>
|
61 |
),
|
62 |
'default' => 'draft'
|
63 |
);
|
64 |
|
65 |
$settings['type'] = array(
|
66 |
-
'title' =>
|
67 |
'type' => 'select',
|
68 |
'options' => mtphr_post_duplicator_post_types(),
|
69 |
'default' => 'same'
|
70 |
);
|
71 |
|
72 |
$settings['timestamp'] = array(
|
73 |
-
'title' =>
|
74 |
'type' => 'radio',
|
75 |
'options' => array(
|
76 |
-
'duplicate' =>
|
77 |
-
'current' =>
|
78 |
),
|
79 |
'display' => 'inline',
|
80 |
'default' => 'current'
|
81 |
);
|
82 |
|
83 |
$settings['title'] = array(
|
84 |
-
'title' =>
|
85 |
-
'description' =>
|
86 |
'type' => 'text',
|
87 |
'display' => 'inline',
|
88 |
-
'default' =>
|
89 |
);
|
90 |
|
91 |
$settings['slug'] = array(
|
92 |
-
'title' =>
|
93 |
-
'description' =>
|
94 |
'type' => 'text',
|
95 |
'display' => 'inline',
|
96 |
'default' => 'copy'
|
97 |
);
|
98 |
|
99 |
$settings['time_offset'] = array(
|
100 |
-
'title' =>
|
101 |
'type' => 'checkbox',
|
102 |
'append' => array(
|
103 |
'time_offset_days' => array(
|
104 |
'type' => 'text',
|
105 |
'size' => 2,
|
106 |
-
'after' =>
|
107 |
'text_align' => 'right',
|
108 |
'default' => 0
|
109 |
),
|
110 |
'time_offset_hours' => array(
|
111 |
'type' => 'text',
|
112 |
'size' => 2,
|
113 |
-
'after' =>
|
114 |
'text_align' => 'right',
|
115 |
'default' => 0
|
116 |
),
|
117 |
'time_offset_minutes' => array(
|
118 |
'type' => 'text',
|
119 |
'size' => 2,
|
120 |
-
'after' =>
|
121 |
'text_align' => 'right',
|
122 |
'default' => 0
|
123 |
),
|
124 |
'time_offset_seconds' => array(
|
125 |
'type' => 'text',
|
126 |
'size' => 2,
|
127 |
-
'after' =>
|
128 |
'text_align' => 'right',
|
129 |
'default' => 0
|
130 |
),
|
131 |
'time_offset_direction' => array(
|
132 |
'type' => 'select',
|
133 |
'options' => array(
|
134 |
-
'newer' =>
|
135 |
-
'older' =>
|
136 |
),
|
137 |
'default' => 'newer'
|
138 |
)
|
@@ -174,19 +174,19 @@ function mtphr_post_duplicator_initialize_settings() {
|
|
174 |
*/
|
175 |
function mtphr_post_duplicator_settings_sanitize( $fields ) {
|
176 |
$sanitized_fields = array(
|
177 |
-
'post_duplication' => isset( $fields['post_duplication'] )
|
178 |
-
'post_author' => isset( $fields['post_author'] )
|
179 |
-
'status' => isset( $fields['status'] )
|
180 |
-
'type' => isset( $fields['type'] )
|
181 |
-
'timestamp' => isset( $fields['timestamp'] )
|
182 |
-
'title' => isset( $fields['title'] )
|
183 |
-
'slug' => isset( $fields['slug'] )
|
184 |
-
'time_offset' => isset( $fields['time_offset'] )
|
185 |
-
'time_offset_days' => isset( $fields['time_offset_days'] )
|
186 |
-
'time_offset_hours' => isset( $fields['time_offset_hours'] )
|
187 |
-
'time_offset_minutes' => isset( $fields['time_offset_minutes'] )
|
188 |
-
'time_offset_seconds' => isset( $fields['
|
189 |
-
'time_offset_direction' => isset( $fields['time_offset_direction'] )
|
190 |
);
|
191 |
return $sanitized_fields;
|
192 |
}
|
@@ -227,7 +227,7 @@ function mtphr_post_duplicator_settings_display() {
|
|
227 |
* @since 2.0
|
228 |
*/
|
229 |
function mtphr_post_duplicator_settings_callback() {
|
230 |
-
echo '<h4>' .
|
231 |
}
|
232 |
|
233 |
|
@@ -252,19 +252,19 @@ function mtphr_post_duplicator_field_display( $args ) {
|
|
252 |
}
|
253 |
if( isset($args['type']) ) {
|
254 |
|
255 |
-
echo '<div class="mtphr-post-duplicator-metaboxer-field mtphr-post-duplicator-metaboxer-'
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
|
262 |
echo '<div>';
|
263 |
}
|
264 |
|
265 |
// Add a descriptions
|
266 |
-
if( isset($args['description']) ) {
|
267 |
-
echo '<span class="description"><small>'
|
268 |
}
|
269 |
}
|
270 |
|
9 |
function mtphr_post_duplicator_settings_page() {
|
10 |
|
11 |
add_management_page(
|
12 |
+
esc_html__('Post Duplicator', 'post-duplicator'), // The value used to populate the browser's title bar when the menu page is active
|
13 |
+
esc_html__('Post Duplicator', 'post-duplicator'), // The label of this submenu item displayed in the menu
|
14 |
+
'administrator', // What roles are able to access this submenu item
|
15 |
+
'mtphr_post_duplicator_settings_menu', // The ID used to represent this submenu item
|
16 |
+
'mtphr_post_duplicator_settings_display' // The callback function used to render the options for this submenu item
|
17 |
);
|
18 |
}
|
19 |
|
29 |
function mtphr_post_duplicator_initialize_settings() {
|
30 |
|
31 |
$settings['post_duplication'] = array(
|
32 |
+
'title' => esc_html__( 'Post Duplication', 'post-duplicator' ),
|
33 |
'type' => 'radio',
|
34 |
'options' => array(
|
35 |
+
'all_users' => esc_html__('Allow Duplication of All Users', 'post-duplicator'),
|
36 |
+
'current_user' => esc_html__('Limit to Current User', 'post-duplicator')
|
37 |
),
|
38 |
'display' => 'inline',
|
39 |
'default' => 'all_users'
|
40 |
);
|
41 |
|
42 |
$settings['post_author'] = array(
|
43 |
+
'title' => esc_html__( 'Post Author', 'post-duplicator' ),
|
44 |
'type' => 'radio',
|
45 |
'options' => array(
|
46 |
+
'current_user' => esc_html__('Current User', 'post-duplicator'),
|
47 |
+
'original_user' => esc_html__('Original Post Author', 'post-duplicator'),
|
48 |
),
|
49 |
'display' => 'inline',
|
50 |
'default' => 'current_user'
|
51 |
);
|
52 |
|
53 |
$settings['status'] = array(
|
54 |
+
'title' => esc_html__( 'Post Status', 'post-duplicator' ),
|
55 |
'type' => 'select',
|
56 |
'options' => array(
|
57 |
+
'same' => esc_html__('Same as original', 'post-duplicator'),
|
58 |
+
'draft' => esc_html__('Draft', 'post-duplicator'),
|
59 |
+
'publish' => esc_html__('Published', 'post-duplicator'),
|
60 |
+
'pending' => esc_html__('Pending', 'post-duplicator')
|
61 |
),
|
62 |
'default' => 'draft'
|
63 |
);
|
64 |
|
65 |
$settings['type'] = array(
|
66 |
+
'title' => esc_html__( 'Post Type', 'post-duplicator' ),
|
67 |
'type' => 'select',
|
68 |
'options' => mtphr_post_duplicator_post_types(),
|
69 |
'default' => 'same'
|
70 |
);
|
71 |
|
72 |
$settings['timestamp'] = array(
|
73 |
+
'title' => esc_html__( 'Post Date', 'post-duplicator' ),
|
74 |
'type' => 'radio',
|
75 |
'options' => array(
|
76 |
+
'duplicate' => esc_html__('Duplicate Timestamp', 'post-duplicator'),
|
77 |
+
'current' => esc_html__('Current Time', 'post-duplicator')
|
78 |
),
|
79 |
'display' => 'inline',
|
80 |
'default' => 'current'
|
81 |
);
|
82 |
|
83 |
$settings['title'] = array(
|
84 |
+
'title' => esc_html__( 'Duplicate Title', 'post-duplicator' ),
|
85 |
+
'description' => esc_html__('String that should be appended to the duplicate post\'s title', 'post-duplicator'),
|
86 |
'type' => 'text',
|
87 |
'display' => 'inline',
|
88 |
+
'default' => esc_html__('Copy', 'post-duplicator')
|
89 |
);
|
90 |
|
91 |
$settings['slug'] = array(
|
92 |
+
'title' => esc_html__( 'Duplicate Slug', 'post-duplicator' ),
|
93 |
+
'description' => esc_html__('String that should be appended to the duplicate post\'s slug', 'post-duplicator'),
|
94 |
'type' => 'text',
|
95 |
'display' => 'inline',
|
96 |
'default' => 'copy'
|
97 |
);
|
98 |
|
99 |
$settings['time_offset'] = array(
|
100 |
+
'title' => esc_html__( 'Offset Date', 'post-duplicator' ),
|
101 |
'type' => 'checkbox',
|
102 |
'append' => array(
|
103 |
'time_offset_days' => array(
|
104 |
'type' => 'text',
|
105 |
'size' => 2,
|
106 |
+
'after' => esc_html__(' days', 'post-duplicator'),
|
107 |
'text_align' => 'right',
|
108 |
'default' => 0
|
109 |
),
|
110 |
'time_offset_hours' => array(
|
111 |
'type' => 'text',
|
112 |
'size' => 2,
|
113 |
+
'after' => esc_html__(' hours', 'post-duplicator'),
|
114 |
'text_align' => 'right',
|
115 |
'default' => 0
|
116 |
),
|
117 |
'time_offset_minutes' => array(
|
118 |
'type' => 'text',
|
119 |
'size' => 2,
|
120 |
+
'after' => esc_html__(' minutes', 'post-duplicator'),
|
121 |
'text_align' => 'right',
|
122 |
'default' => 0
|
123 |
),
|
124 |
'time_offset_seconds' => array(
|
125 |
'type' => 'text',
|
126 |
'size' => 2,
|
127 |
+
'after' => esc_html__(' seconds', 'post-duplicator'),
|
128 |
'text_align' => 'right',
|
129 |
'default' => 0
|
130 |
),
|
131 |
'time_offset_direction' => array(
|
132 |
'type' => 'select',
|
133 |
'options' => array(
|
134 |
+
'newer' => esc_html__('newer', 'post-duplicator'),
|
135 |
+
'older' => esc_html__('older', 'post-duplicator')
|
136 |
),
|
137 |
'default' => 'newer'
|
138 |
)
|
174 |
*/
|
175 |
function mtphr_post_duplicator_settings_sanitize( $fields ) {
|
176 |
$sanitized_fields = array(
|
177 |
+
'post_duplication' => isset( $fields['post_duplication'] ) ? esc_attr( $fields['post_duplication'] ) : 'all_users',
|
178 |
+
'post_author' => isset( $fields['post_author'] ) ? esc_attr( $fields['post_author'] ) : 'current_user',
|
179 |
+
'status' => isset( $fields['status'] ) ? esc_attr( $fields['status'] ) : 'draft',
|
180 |
+
'type' => isset( $fields['type'] ) ? esc_attr( $fields['type'] ) : 'same',
|
181 |
+
'timestamp' => isset( $fields['timestamp'] ) ? esc_attr( $fields['timestamp'] ) : 'current',
|
182 |
+
'title' => isset( $fields['title'] ) ? sanitize_text_field( $fields['title'] ) : '',
|
183 |
+
'slug' => isset( $fields['slug'] ) ? sanitize_title_with_dashes( $fields['slug'] ) : '',
|
184 |
+
'time_offset' => isset( $fields['time_offset'] ) ? esc_attr( $fields['time_offset'] ) : false,
|
185 |
+
'time_offset_days' => isset( $fields['time_offset_days'] ) ? intval( $fields['time_offset_days'] ) : 0,
|
186 |
+
'time_offset_hours' => isset( $fields['time_offset_hours'] ) ? intval( $fields['time_offset_hours'] ) : 0,
|
187 |
+
'time_offset_minutes' => isset( $fields['time_offset_minutes'] ) ? intval( $fields['time_offset_minutes'] ) : 0,
|
188 |
+
'time_offset_seconds' => isset( $fields['time_offset_seconds'] ) ? intval( $fields['time_offset_seconds'] ) : 0,
|
189 |
+
'time_offset_direction' => isset( $fields['time_offset_direction'] ) ? esc_attr( $fields['time_offset_direction'] ) : 'newer',
|
190 |
);
|
191 |
return $sanitized_fields;
|
192 |
}
|
227 |
* @since 2.0
|
228 |
*/
|
229 |
function mtphr_post_duplicator_settings_callback() {
|
230 |
+
echo '<h4>' . esc_html__( 'Customize the settings for duplicated posts.', 'post-duplicator' ) . '</h4>';
|
231 |
}
|
232 |
|
233 |
|
252 |
}
|
253 |
if( isset($args['type']) ) {
|
254 |
|
255 |
+
echo '<div class="mtphr-post-duplicator-metaboxer-field mtphr-post-duplicator-metaboxer-' . esc_attr( $args['type'] ) . '">';
|
256 |
+
|
257 |
+
// Call the function to display the field
|
258 |
+
if ( function_exists('mtphr_post_duplicator_metaboxer_'.$args['type']) ) {
|
259 |
+
call_user_func( 'mtphr_post_duplicator_metaboxer_'.$args['type'], $args, $value );
|
260 |
+
}
|
261 |
|
262 |
echo '<div>';
|
263 |
}
|
264 |
|
265 |
// Add a descriptions
|
266 |
+
if( isset( $args['description'] ) ) {
|
267 |
+
echo '<span class="description"><small>' . wp_kses_post( $args['description'] ) . '</small></span>';
|
268 |
}
|
269 |
}
|
270 |
|
m4c-postduplicator.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Post Duplicator
|
4 |
Description: Creates functionality to duplicate any and all post types, including taxonomies & custom fields
|
5 |
-
Version: 2.
|
6 |
Author: Metaphor Creations
|
7 |
Author URI: http://www.metaphorcreations.com
|
8 |
Text Domain: post-duplicator
|
@@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
30 |
|
31 |
|
32 |
/**Define Widget Constants */
|
33 |
-
define ( 'MTPHR_POST_DUPLICATOR_VERSION', '2.
|
34 |
define ( 'MTPHR_POST_DUPLICATOR_DIR', plugin_dir_path(__FILE__) );
|
35 |
|
36 |
|
@@ -58,7 +58,7 @@ if ( is_admin() ) {
|
|
58 |
// Load Metaboxer
|
59 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'includes/helpers.php' );
|
60 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'metaboxer/metaboxer.php' );
|
61 |
-
require_once( MTPHR_POST_DUPLICATOR_DIR.'metaboxer/metaboxer-class.php' );
|
62 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'includes/scripts.php' );
|
63 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'includes/ajax.php' );
|
64 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'includes/edit.php' );
|
2 |
/*
|
3 |
Plugin Name: Post Duplicator
|
4 |
Description: Creates functionality to duplicate any and all post types, including taxonomies & custom fields
|
5 |
+
Version: 2.25
|
6 |
Author: Metaphor Creations
|
7 |
Author URI: http://www.metaphorcreations.com
|
8 |
Text Domain: post-duplicator
|
30 |
|
31 |
|
32 |
/**Define Widget Constants */
|
33 |
+
define ( 'MTPHR_POST_DUPLICATOR_VERSION', '2.25' );
|
34 |
define ( 'MTPHR_POST_DUPLICATOR_DIR', plugin_dir_path(__FILE__) );
|
35 |
|
36 |
|
58 |
// Load Metaboxer
|
59 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'includes/helpers.php' );
|
60 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'metaboxer/metaboxer.php' );
|
61 |
+
//require_once( MTPHR_POST_DUPLICATOR_DIR.'metaboxer/metaboxer-class.php' );
|
62 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'includes/scripts.php' );
|
63 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'includes/ajax.php' );
|
64 |
require_once( MTPHR_POST_DUPLICATOR_DIR.'includes/edit.php' );
|
metaboxer/images/attachment-audio.png
DELETED
Binary file
|
metaboxer/images/attachment-delete.png
DELETED
Binary file
|
metaboxer/images/attachment-image.png
DELETED
Binary file
|
metaboxer/images/attachment-preview.png
DELETED
Binary file
|
metaboxer/images/attachment-settings.png
DELETED
Binary file
|
metaboxer/images/attachment-video.png
DELETED
Binary file
|
metaboxer/images/attachment-vimeo.png
DELETED
Binary file
|
metaboxer/images/attachment-youtube.png
DELETED
Binary file
|
metaboxer/metaboxer-class.php
DELETED
@@ -1,186 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This is where the metabox magic happens.
|
4 |
-
*
|
5 |
-
* @package Ditty News Ticker
|
6 |
-
* @author Metaphor Creations
|
7 |
-
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
|
8 |
-
* @link http://www.metaphorcreations.com/plugins/metatools
|
9 |
-
**/
|
10 |
-
|
11 |
-
/* Version 1.1 - 10/18/2012 */
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Create the metabox class
|
18 |
-
*
|
19 |
-
* @since 1.0.0
|
20 |
-
*/
|
21 |
-
if( !class_exists('MTPHR_POST_DUPLICATOR_MetaBoxer') ) {
|
22 |
-
|
23 |
-
class MTPHR_POST_DUPLICATOR_MetaBoxer {
|
24 |
-
|
25 |
-
public function __construct( $meta_box ) {
|
26 |
-
|
27 |
-
if ( !is_admin() ) return;
|
28 |
-
|
29 |
-
// Save the meta box data
|
30 |
-
$this->mb = $meta_box;
|
31 |
-
$this->mb_fields = &$this->mb['fields'];
|
32 |
-
|
33 |
-
add_action( 'add_meta_boxes', array(&$this, 'mtphr_post_duplicator_metaboxer_add') );
|
34 |
-
add_action( 'save_post', array(&$this, 'mtphr_post_duplicator_metaboxer_save') );
|
35 |
-
}
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Create the metaboxes
|
42 |
-
*
|
43 |
-
* @since 1.0.0
|
44 |
-
*/
|
45 |
-
public function mtphr_post_duplicator_metaboxer_add() {
|
46 |
-
|
47 |
-
foreach ( $this->mb['page'] as $page ) {
|
48 |
-
add_meta_box( $this->mb['id'], $this->mb['title'], array(&$this, 'mtphr_post_duplicator_metaboxer_render_content'), $page, $this->mb['context'], $this->mb['priority'] );
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Render the metabox content
|
57 |
-
*
|
58 |
-
* @since 1.0.0
|
59 |
-
*/
|
60 |
-
public function mtphr_post_duplicator_metaboxer_render_content() {
|
61 |
-
?>
|
62 |
-
<table style="width:100%;" class="mtphr-post-duplicator-metaboxer-admin-fields wrap">
|
63 |
-
<?php
|
64 |
-
foreach( $this->mb_fields as $field ) {
|
65 |
-
|
66 |
-
if ( isset( $field['id'] ) ) {
|
67 |
-
// Create a nonce field
|
68 |
-
echo'<input type="hidden" name="'.$field['id'].'_noncename" id="'.$field['id'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';
|
69 |
-
}
|
70 |
-
|
71 |
-
// Output the field
|
72 |
-
mtphr_post_duplicator_metaboxer_container( $field, $this->mb['context'] );
|
73 |
-
}
|
74 |
-
?>
|
75 |
-
</table>
|
76 |
-
<?php
|
77 |
-
}
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Save the field values
|
84 |
-
*
|
85 |
-
* @since 1.0.0
|
86 |
-
*/
|
87 |
-
public function mtphr_post_duplicator_metaboxer_save( $post_id ) {
|
88 |
-
|
89 |
-
global $post;
|
90 |
-
|
91 |
-
foreach( $this->mb_fields as $field ) {
|
92 |
-
|
93 |
-
if ( isset($field['id']) ) {
|
94 |
-
|
95 |
-
if ( isset($_POST[$field['id'].'_noncename']) ) {
|
96 |
-
|
97 |
-
// Verify the nonce and return if false
|
98 |
-
if ( !wp_verify_nonce($_POST[$field['id'].'_noncename'], plugin_basename(__FILE__)) ) {
|
99 |
-
return $post_id;
|
100 |
-
}
|
101 |
-
|
102 |
-
// Make sure the user can edit pages & posts
|
103 |
-
if ( 'page' == $_POST['post_type'] ) {
|
104 |
-
if ( !current_user_can('edit_page', $post_id) ) {
|
105 |
-
return $post_id;
|
106 |
-
}
|
107 |
-
} else {
|
108 |
-
if ( !current_user_can('edit_post', $post_id) ) {
|
109 |
-
return $post_id;
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
// Store the user data or set as empty string
|
114 |
-
$data = ( isset($_POST[$field['id']]) ) ? $_POST[$field['id']] : '';
|
115 |
-
|
116 |
-
// Update the meta
|
117 |
-
mtphr_post_duplicator_metaboxer_update_meta( $post_id, $field['id'], $field['type'], $data );
|
118 |
-
|
119 |
-
// Save appended fields
|
120 |
-
mtphr_post_duplicator_metaboxer_save_appended( $post_id, $field );
|
121 |
-
|
122 |
-
// Save row fields
|
123 |
-
mtphr_post_duplicator_metaboxer_save_rows( $post_id, $field );
|
124 |
-
}
|
125 |
-
}
|
126 |
-
}
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Save the row field values
|
132 |
-
*
|
133 |
-
* @since 1.0.0
|
134 |
-
*/
|
135 |
-
function mtphr_post_duplicator_metaboxer_save_rows( $post_id, $field ) {
|
136 |
-
|
137 |
-
if( isset($field['rows']) ) {
|
138 |
-
|
139 |
-
foreach( $field['rows'] as $id => $row ) {
|
140 |
-
|
141 |
-
$row_id = $row['id'];
|
142 |
-
|
143 |
-
// Store the user data or set as empty string
|
144 |
-
$data = ( isset($_POST[$row_id]) ) ? $_POST[$row_id] : '';
|
145 |
-
|
146 |
-
// Update the meta
|
147 |
-
mtphr_post_duplicator_metaboxer_update_meta( $post_id, $row_id, $row['type'], $data );
|
148 |
-
|
149 |
-
// Save appended fields
|
150 |
-
mtphr_post_duplicator_metaboxer_save_appended( $post_id, $row );
|
151 |
-
}
|
152 |
-
}
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Save the appended field values
|
157 |
-
*
|
158 |
-
* @since 1.0.0
|
159 |
-
*/
|
160 |
-
function mtphr_post_duplicator_metaboxer_save_appended( $post_id, $field ) {
|
161 |
-
|
162 |
-
if( isset($field['append']) ) {
|
163 |
-
|
164 |
-
foreach( $field['append'] as $id => $append ) {
|
165 |
-
|
166 |
-
// Store the user data or set as empty string
|
167 |
-
$data = ( isset($_POST[$id]) ) ? $_POST[$id] : '';
|
168 |
-
|
169 |
-
// Update the meta
|
170 |
-
mtphr_post_duplicator_metaboxer_update_meta( $post_id, $id, $append['type'], $data );
|
171 |
-
}
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Update the meta
|
177 |
-
*
|
178 |
-
* @since 1.0.0
|
179 |
-
*/
|
180 |
-
function mtphr_post_duplicator_metaboxer_update_meta( $post_id, $id, $type, $data ) {
|
181 |
-
|
182 |
-
// Update the post meta
|
183 |
-
update_post_meta( $post_id, $id, $data );
|
184 |
-
}
|
185 |
-
|
186 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
metaboxer/metaboxer.js
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
jQuery(document).ready( function($) {
|
2 |
-
});
|
|
|
|
metaboxer/metaboxer.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
/**
|
13 |
* Create a field container and switch.
|
14 |
*
|
15 |
-
* @since
|
16 |
*/
|
17 |
function mtphr_post_duplicator_metaboxer_container( $field, $context ) {
|
18 |
|
@@ -22,7 +22,7 @@ function mtphr_post_duplicator_metaboxer_container( $field, $context ) {
|
|
22 |
$value = ( get_post_meta( $post->ID, $field['id'], true ) != '' ) ? get_post_meta( $post->ID, $field['id'], true ) : $default;
|
23 |
$display = isset( $field['display'] ) ? $field['display'] : '';
|
24 |
?>
|
25 |
-
<tr class="mtphr-post-duplicator-metaboxer-field mtphr-post-duplicator-metaboxer-field-<?php
|
26 |
|
27 |
<?php
|
28 |
$content_class = 'mtphr-post-duplicator-metaboxer-field-content mtphr-post-duplicator-metaboxer-field-content-full mtphr-post-duplicator-metaboxer-'.$field['type'].' clearfix';
|
@@ -39,8 +39,8 @@ function mtphr_post_duplicator_metaboxer_container( $field, $context ) {
|
|
39 |
<?php if( $context == 'side' || $display == 'vertical' ) { ?><td><table><tr><?php } ?>
|
40 |
|
41 |
<td class="mtphr-post-duplicator-metaboxer-label">
|
42 |
-
<?php if( isset($field['name']) ) { ?><label for="<?php
|
43 |
-
<?php if( isset($field['description']) ) { ?><small><?php
|
44 |
</td>
|
45 |
|
46 |
<?php if( $context == 'side' || $display == 'vertical' ) { echo '</tr>'; } ?>
|
@@ -51,7 +51,7 @@ function mtphr_post_duplicator_metaboxer_container( $field, $context ) {
|
|
51 |
|
52 |
<?php if( $label ) { if( $context == 'side' || $display == 'vertical' ) { echo '<tr>'; } } ?>
|
53 |
|
54 |
-
<td<?php
|
55 |
<?php
|
56 |
// Call the function to display the field
|
57 |
if ( function_exists('mtphr_post_duplicator_metaboxer_'.$field['type']) ) {
|
@@ -72,7 +72,7 @@ function mtphr_post_duplicator_metaboxer_container( $field, $context ) {
|
|
72 |
/**
|
73 |
* Append fields
|
74 |
*
|
75 |
-
* @since
|
76 |
*/
|
77 |
function mtphr_post_duplicator_metaboxer_append_field( $field ) {
|
78 |
|
@@ -110,9 +110,9 @@ function mtphr_post_duplicator_metaboxer_append_field( $field ) {
|
|
110 |
}
|
111 |
|
112 |
// Call the function to display the field
|
113 |
-
if ( function_exists('mtphr_post_duplicator_metaboxer_'
|
114 |
-
echo '<div class="mtphr-post-duplicator-metaboxer-appended mtphr-post-duplicator-metaboxer'
|
115 |
-
call_user_func( 'mtphr_post_duplicator_metaboxer_'
|
116 |
echo '</div>';
|
117 |
}
|
118 |
}
|
@@ -126,14 +126,14 @@ function mtphr_post_duplicator_metaboxer_append_field( $field ) {
|
|
126 |
/**
|
127 |
* Renders a select field.
|
128 |
*
|
129 |
-
* @since
|
130 |
*/
|
131 |
function mtphr_post_duplicator_metaboxer_select( $field, $value='' ) {
|
132 |
|
133 |
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
134 |
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
135 |
|
136 |
-
|
137 |
|
138 |
if( $field['options'] ) {
|
139 |
|
@@ -147,13 +147,10 @@ function mtphr_post_duplicator_metaboxer_select( $field, $value='' ) {
|
|
147 |
$name = $option;
|
148 |
$val = $key;
|
149 |
}
|
150 |
-
|
151 |
-
$output .= '<option value="'.$val.'" '.$selected.'>'.stripslashes( $name ).'</option>';
|
152 |
}
|
153 |
}
|
154 |
-
|
155 |
-
|
156 |
-
echo $output;
|
157 |
|
158 |
// Add appended fields
|
159 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
@@ -164,13 +161,12 @@ function mtphr_post_duplicator_metaboxer_select( $field, $value='' ) {
|
|
164 |
/**
|
165 |
* Renders a radio custom field.
|
166 |
*
|
167 |
-
* @since
|
168 |
*/
|
169 |
function mtphr_post_duplicator_metaboxer_radio( $field, $value='' ) {
|
170 |
|
171 |
if( isset($field['options']) ) {
|
172 |
|
173 |
-
$output = '';
|
174 |
$break = '<br/>';
|
175 |
if ( isset($field['display']) ) {
|
176 |
if( $field['display'] == 'inline' ) {
|
@@ -178,13 +174,10 @@ function mtphr_post_duplicator_metaboxer_radio( $field, $value='' ) {
|
|
178 |
}
|
179 |
}
|
180 |
foreach( $field['options'] as $i => $option ) {
|
181 |
-
|
182 |
-
$output .= '<label><input name="'.$field['id'].'" id="'.$field['id'].'" type="radio" value="'.$i.'" '.$checked.' /> '.$option.'</label>'.$break;
|
183 |
}
|
184 |
}
|
185 |
|
186 |
-
echo $output;
|
187 |
-
|
188 |
// Add appended fields
|
189 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
190 |
}
|
@@ -194,15 +187,16 @@ function mtphr_post_duplicator_metaboxer_radio( $field, $value='' ) {
|
|
194 |
/**
|
195 |
* Renders a checkbox.
|
196 |
*
|
197 |
-
* @since
|
198 |
*/
|
199 |
function mtphr_post_duplicator_metaboxer_checkbox( $field, $value='' ) {
|
200 |
|
201 |
-
$output = '';
|
202 |
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
203 |
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
204 |
|
205 |
if( isset($field['options']) ) {
|
|
|
|
|
206 |
|
207 |
$break = '<br/>';
|
208 |
if ( isset($field['display']) ) {
|
@@ -211,22 +205,25 @@ function mtphr_post_duplicator_metaboxer_checkbox( $field, $value='' ) {
|
|
211 |
}
|
212 |
}
|
213 |
foreach( $field['options'] as $i => $option ) {
|
214 |
-
|
215 |
-
|
216 |
}
|
217 |
|
|
|
|
|
218 |
} else {
|
219 |
|
220 |
-
|
221 |
-
|
|
|
222 |
if( isset($field['label']) ) {
|
223 |
-
|
224 |
}
|
225 |
-
|
|
|
|
|
226 |
}
|
227 |
|
228 |
-
echo $before.$output.$after;
|
229 |
-
|
230 |
// Add appended fields
|
231 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
232 |
}
|
@@ -236,16 +233,15 @@ function mtphr_post_duplicator_metaboxer_checkbox( $field, $value='' ) {
|
|
236 |
/**
|
237 |
* Renders an text field.
|
238 |
*
|
239 |
-
* @since
|
240 |
*/
|
241 |
function mtphr_post_duplicator_metaboxer_text( $field, $value='' ) {
|
242 |
$size = ( isset($field['size']) ) ? $field['size'] : 40;
|
243 |
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
244 |
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
245 |
$text_align = ( isset($field['text_align']) ) ? ' style="text-align:'.$field['text_align'].'"' : '' ;
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
// Add appended fields
|
250 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
251 |
}
|
@@ -255,13 +251,12 @@ function mtphr_post_duplicator_metaboxer_text( $field, $value='' ) {
|
|
255 |
/**
|
256 |
* Renders a textarea.
|
257 |
*
|
258 |
-
* @since
|
259 |
*/
|
260 |
function mtphr_post_duplicator_metaboxer_textarea( $field, $value='' ) {
|
261 |
$rows = ( isset($field['rows']) ) ? $field['rows'] : 5;
|
262 |
$cols = ( isset($field['cols']) ) ? $field['cols'] : 40;
|
263 |
-
|
264 |
-
echo $output;
|
265 |
|
266 |
// Add appended fields
|
267 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
@@ -272,15 +267,14 @@ function mtphr_post_duplicator_metaboxer_textarea( $field, $value='' ) {
|
|
272 |
/**
|
273 |
* Renders an number field.
|
274 |
*
|
275 |
-
* @since
|
276 |
*/
|
277 |
function mtphr_post_duplicator_metaboxer_number( $field, $value='' ) {
|
278 |
$style = ( isset($field['style']) ) ? ' style="'.$field['style'].'"' : '';
|
279 |
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
280 |
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
// Add appended fields
|
285 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
286 |
}
|
12 |
/**
|
13 |
* Create a field container and switch.
|
14 |
*
|
15 |
+
* @since 2.25
|
16 |
*/
|
17 |
function mtphr_post_duplicator_metaboxer_container( $field, $context ) {
|
18 |
|
22 |
$value = ( get_post_meta( $post->ID, $field['id'], true ) != '' ) ? get_post_meta( $post->ID, $field['id'], true ) : $default;
|
23 |
$display = isset( $field['display'] ) ? $field['display'] : '';
|
24 |
?>
|
25 |
+
<tr class="mtphr-post-duplicator-metaboxer-field mtphr-post-duplicator-metaboxer-field-<?php esc_attr_e( $field['type'] ); ?> mtphr-post-duplicator-metaboxer<?php esc_attr_e( $field['id'] ); ?><?php if( isset($field['class']) ) { esc_attr_e( ' ' . $field['class'] ); } ?> clearfix">
|
26 |
|
27 |
<?php
|
28 |
$content_class = 'mtphr-post-duplicator-metaboxer-field-content mtphr-post-duplicator-metaboxer-field-content-full mtphr-post-duplicator-metaboxer-'.$field['type'].' clearfix';
|
39 |
<?php if( $context == 'side' || $display == 'vertical' ) { ?><td><table><tr><?php } ?>
|
40 |
|
41 |
<td class="mtphr-post-duplicator-metaboxer-label">
|
42 |
+
<?php if( isset($field['name']) ) { ?><label for="<?php esc_attr_e( $field['id'] ); ?>"><?php esc_html_e( $field['name'] ); ?></label><?php } ?>
|
43 |
+
<?php if( isset($field['description']) ) { ?><small><?php esc_html_e( $field['description'] ); ?></small><?php } ?>
|
44 |
</td>
|
45 |
|
46 |
<?php if( $context == 'side' || $display == 'vertical' ) { echo '</tr>'; } ?>
|
51 |
|
52 |
<?php if( $label ) { if( $context == 'side' || $display == 'vertical' ) { echo '<tr>'; } } ?>
|
53 |
|
54 |
+
<td<?php esc_html_e( $content_span ); ?> class="<?php esc_attr_e( $content_class ); ?>" id="<?php esc_attr_e( $post->ID ); ?>">
|
55 |
<?php
|
56 |
// Call the function to display the field
|
57 |
if ( function_exists('mtphr_post_duplicator_metaboxer_'.$field['type']) ) {
|
72 |
/**
|
73 |
* Append fields
|
74 |
*
|
75 |
+
* @since 2.25
|
76 |
*/
|
77 |
function mtphr_post_duplicator_metaboxer_append_field( $field ) {
|
78 |
|
110 |
}
|
111 |
|
112 |
// Call the function to display the field
|
113 |
+
if ( function_exists('mtphr_post_duplicator_metaboxer_' . esc_attr( $field['type'] ) ) ) {
|
114 |
+
echo '<div class="mtphr-post-duplicator-metaboxer-appended mtphr-post-duplicator-metaboxer' . esc_attr( $field['id'] ) . '">';
|
115 |
+
call_user_func( 'mtphr_post_duplicator_metaboxer_' . esc_attr( $field['type'] ), $field, $value );
|
116 |
echo '</div>';
|
117 |
}
|
118 |
}
|
126 |
/**
|
127 |
* Renders a select field.
|
128 |
*
|
129 |
+
* @since 2.25
|
130 |
*/
|
131 |
function mtphr_post_duplicator_metaboxer_select( $field, $value='' ) {
|
132 |
|
133 |
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
134 |
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
135 |
|
136 |
+
echo wp_kses_post( $before ) . '<select name="'.esc_attr( $field['id'] ).'" id="'.esc_attr( $field['id'] ).'">';
|
137 |
|
138 |
if( $field['options'] ) {
|
139 |
|
147 |
$name = $option;
|
148 |
$val = $key;
|
149 |
}
|
150 |
+
echo '<option value="'.esc_attr( $val ).'" '.selected( $val, $value, false ).'>'.stripslashes( wp_kses_post( $name ) ).'</option>';
|
|
|
151 |
}
|
152 |
}
|
153 |
+
echo '</select>' . wp_kses_post( $after );
|
|
|
|
|
154 |
|
155 |
// Add appended fields
|
156 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
161 |
/**
|
162 |
* Renders a radio custom field.
|
163 |
*
|
164 |
+
* @since 2.25
|
165 |
*/
|
166 |
function mtphr_post_duplicator_metaboxer_radio( $field, $value='' ) {
|
167 |
|
168 |
if( isset($field['options']) ) {
|
169 |
|
|
|
170 |
$break = '<br/>';
|
171 |
if ( isset($field['display']) ) {
|
172 |
if( $field['display'] == 'inline' ) {
|
174 |
}
|
175 |
}
|
176 |
foreach( $field['options'] as $i => $option ) {
|
177 |
+
echo '<label><input name="'.esc_attr( $field['id'] ).'" id="'.esc_attr( $field['id'] ).'" type="radio" value="'.esc_attr( $i ).'" '.checked( $value, $i, false ).' /> '.wp_kses_post( $option ).'</label>'.wp_kses_post( $break );
|
|
|
178 |
}
|
179 |
}
|
180 |
|
|
|
|
|
181 |
// Add appended fields
|
182 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
183 |
}
|
187 |
/**
|
188 |
* Renders a checkbox.
|
189 |
*
|
190 |
+
* @since 2.25
|
191 |
*/
|
192 |
function mtphr_post_duplicator_metaboxer_checkbox( $field, $value='' ) {
|
193 |
|
|
|
194 |
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
195 |
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
196 |
|
197 |
if( isset($field['options']) ) {
|
198 |
+
|
199 |
+
echo wp_kses_post( $before );
|
200 |
|
201 |
$break = '<br/>';
|
202 |
if ( isset($field['display']) ) {
|
205 |
}
|
206 |
}
|
207 |
foreach( $field['options'] as $i => $option ) {
|
208 |
+
|
209 |
+
echo '<label><input name="'.esc_attr( $field['id'] ).'['.esc_attr( $i ).']" id="'.esc_attr( $field['id'] ).'['.esc_attr( $i ).']" type="checkbox" value="1" '.checked( $value[$i], '1', false ).' /> '.wp_kses_post( $option ).'</label>'.wp_kses_post( $break );
|
210 |
}
|
211 |
|
212 |
+
echo wp_kses_post( $after );
|
213 |
+
|
214 |
} else {
|
215 |
|
216 |
+
echo wp_kses_post( $before );
|
217 |
+
|
218 |
+
echo '<label><input name="'.esc_attr( $field['id'] ).'" id="'.esc_attr( $field['id'] ).'" type="checkbox" value="1" '.checked( $value, '1', false ).' />';
|
219 |
if( isset($field['label']) ) {
|
220 |
+
echo ' '.wp_kses_post( $field['label'] );
|
221 |
}
|
222 |
+
echo '</label>';
|
223 |
+
|
224 |
+
echo wp_kses_post( $after );
|
225 |
}
|
226 |
|
|
|
|
|
227 |
// Add appended fields
|
228 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
229 |
}
|
233 |
/**
|
234 |
* Renders an text field.
|
235 |
*
|
236 |
+
* @since 2.25
|
237 |
*/
|
238 |
function mtphr_post_duplicator_metaboxer_text( $field, $value='' ) {
|
239 |
$size = ( isset($field['size']) ) ? $field['size'] : 40;
|
240 |
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
241 |
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
242 |
$text_align = ( isset($field['text_align']) ) ? ' style="text-align:'.$field['text_align'].'"' : '' ;
|
243 |
+
echo wp_kses_post( $before ).'<input name="'.esc_attr( $field['id'] ).'" id="'.esc_attr( $field['id'] ).'" type="text" value="'.esc_attr( $value ).'" size="'.esc_attr( $size ).'"'.wp_kses_post( $text_align ).'>'.wp_kses_post( $after );
|
244 |
+
|
|
|
245 |
// Add appended fields
|
246 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
247 |
}
|
251 |
/**
|
252 |
* Renders a textarea.
|
253 |
*
|
254 |
+
* @since 2.25
|
255 |
*/
|
256 |
function mtphr_post_duplicator_metaboxer_textarea( $field, $value='' ) {
|
257 |
$rows = ( isset($field['rows']) ) ? $field['rows'] : 5;
|
258 |
$cols = ( isset($field['cols']) ) ? $field['cols'] : 40;
|
259 |
+
echo '<textarea name="'.esc_attr( $field['id'] ).'" id="'.esc_attr( $field['id'] ).'" rows="'.esc_attr( $rows ).'" cols="'.esc_attr( $cols ).'">'.wp_kses_post( $value ).'</textarea>';
|
|
|
260 |
|
261 |
// Add appended fields
|
262 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
267 |
/**
|
268 |
* Renders an number field.
|
269 |
*
|
270 |
+
* @since 2.25
|
271 |
*/
|
272 |
function mtphr_post_duplicator_metaboxer_number( $field, $value='' ) {
|
273 |
$style = ( isset($field['style']) ) ? ' style="'.$field['style'].'"' : '';
|
274 |
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
275 |
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
276 |
+
echo wp_kses_post( $before ).'<input name="'.esc_attr( $field['id'] ).'" id="'.esc_attr( $field['id'] ).'" type="number" value="'.esc_attr( $value ).'" class="small-text"'.wp_kses_post( $style ).'>'.wp_kses_post( $after );
|
277 |
+
|
|
|
278 |
// Add appended fields
|
279 |
mtphr_post_duplicator_metaboxer_append_field($field);
|
280 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: metaphorcreations
|
|
3 |
Tags: posts, post, duplicate, duplication
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 5.8.2
|
6 |
-
Stable tag:
|
7 |
License: GPL2
|
8 |
|
9 |
Creates functionality to duplicate any and all post types, including taxonomies & custom fields.
|
@@ -41,6 +41,9 @@ Check out the 'Installation' tab.
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
44 |
= 2.24 =
|
45 |
* Settings sanitization updates
|
46 |
|
@@ -138,4 +141,4 @@ Must upgrade in order for the plugin to work. The file paths where initially wro
|
|
138 |
|
139 |
== Upgrade Notice ==
|
140 |
|
141 |
-
|
3 |
Tags: posts, post, duplicate, duplication
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 5.8.2
|
6 |
+
Stable tag: 2.25
|
7 |
License: GPL2
|
8 |
|
9 |
Creates functionality to duplicate any and all post types, including taxonomies & custom fields.
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 2.25 =
|
45 |
+
* Multiple data sanitization updates
|
46 |
+
|
47 |
= 2.24 =
|
48 |
* Settings sanitization updates
|
49 |
|
141 |
|
142 |
== Upgrade Notice ==
|
143 |
|
144 |
+
Multiple data sanitization updates
|