PluginProbe
Post Duplicator / 2.26
Post Duplicator v2.26
3.0.16 trunk 1.1 2.0 2.2 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.3 2.30 2.31 2.32 2.33 2.34 2.35 2.36 2.37 2.38 All 52 releases
post-duplicator / includes / functions.php

functions.php in Post Duplicator 2.26, at includes/functions.php

55 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Return a value from the options table if it exists,
5 * or return a default value
6 *
7 * @since 2.15
8 */
9 function get_mtphr_post_duplicator_settings() {
10
11 // Get the options
12 $settings = get_option('mtphr_post_duplicator_settings', array());
13
14 $defaults = array(
15 'post_duplication' => 'all_users',
16 'post_author' => 'current_user',
17 'status' => 'same',
18 'type' => 'same',
19 'timestamp' => 'current',
20 'title' => __('Copy', 'post-duplicator'),
21 'slug' => 'copy',
22 'time_offset' => false,
23 'time_offset_days' => 0,
24 'time_offset_hours' => 0,
25 'time_offset_minutes' => 0,
26 'time_offset_seconds' => 0,
27 'time_offset_direction' => 'newer'
28 );
29
30 // Filter the settings
31 $settings = apply_filters( 'mtphr_post_duplicator_settings', $settings );
32
33 // Return the settings
34 return wp_parse_args( $settings, $defaults );
35 }
36
37
38 function mtphr_post_duplicator_submitbox( $post ) {
39 if( $post->post_status == 'publish' ) {
40 $settings = get_mtphr_post_duplicator_settings();
41 if ( 'current_user' === $settings['post_duplication'] ) {
42 if ( get_current_user_id() != $post->post_author ) {
43 return false;
44 }
45 }
46 $post_type = get_post_type_object( $post->post_type );
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 }
54 }
55 add_action( 'post_submitbox_misc_actions', 'mtphr_post_duplicator_submitbox' );