diff --git a/duplicate-post-admin.php b/duplicate-post-admin.php index 865400c5a..e8a252c4b 100644 --- a/duplicate-post-admin.php +++ b/duplicate-post-admin.php @@ -131,7 +131,7 @@ function duplicate_post_plugin_upgrade() { add_option('duplicate_post_copytitle','1'); add_option('duplicate_post_copydate','0'); add_option('duplicate_post_copystatus','0'); - add_option('duplicate_post_copyslug','1'); + add_option('duplicate_post_copyslug','0'); add_option('duplicate_post_copyexcerpt','1'); add_option('duplicate_post_copycontent','1'); add_option('duplicate_post_copythumbnail','1'); @@ -191,9 +191,10 @@ function duplicate_post_plugin_upgrade() { function duplicate_post_show_update_notice() { if(!current_user_can( 'manage_options')) return; $class = 'notice is-dismissible'; - $message = ''.esc_html__('Duplicate Post turns 10!', 'duplicate-post').' '.esc_html__('Serving the WordPress community since November 2007.', 'duplicate-post').'
'; - $message .= ''.esc_html__('Check out the new documentation', 'duplicate-post').' - '.sprintf(__('Please review the settings to make sure it works as you expect.', 'duplicate-post'), admin_url('options-general.php?page=duplicatepost')).'
'; - $message .= ''.sprintf(wp_kses(__('Help me develop the plugin and provide support by donating even a small sum.', 'duplicate-post'), array( 'a' => array( 'href' => array() ) ) ), "https://duplicate-post.lopo.it/donate").''; + $message = ''.sprintf(__("What's new in Duplicate Post version %s:", 'duplicate-post'), DUPLICATE_POST_CURRENT_VERSION).'
'; + $message .= esc_html__('Simple compatibility with Gutenberg user interface: enable "Admin bar" under the Settings', 'duplicate-post').' — '.esc_html__('"Slug" option unset by default on new installations', 'duplicate-post').'
'; + $message .= ''.easc_html__('Check out the documentation', 'duplicate-post').' — '.sprintf(__('Please review the settings to make sure it works as you expect.', 'duplicate-post'), admin_url('options-general.php?page=duplicatepost')).'
'; + $message .= esc_html__('Serving the WordPress community since November 2007.', 'duplicate-post').' '.sprintf(wp_kses(__('Help me develop the plugin and provide support by donating even a small sum.', 'duplicate-post'), array( 'a' => array( 'href' => array() ) ) ), "https://duplicate-post.lopo.it/donate").''; global $wp_version; if( version_compare($wp_version, '4.2') < 0 ){ $message .= ' | '.__('Dismiss this notice.').''; diff --git a/duplicate-post-common.php b/duplicate-post-common.php index 7f2dc40ec..a102d3771 100644 --- a/duplicate-post-common.php +++ b/duplicate-post-common.php @@ -103,34 +103,52 @@ function duplicate_post_admin_bar_render() { if(!is_admin_bar_showing()) return; global $wp_admin_bar; $current_object = get_queried_object(); - if ( empty($current_object) ) - return; - if ( ! empty( $current_object->post_type ) - && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) - && duplicate_post_is_current_user_allowed_to_copy() - && ( $post_type_object->show_ui || 'attachment' == $current_object->post_type ) - && (duplicate_post_is_post_type_enabled($current_object->post_type) ) ) - { - $wp_admin_bar->add_menu( array( - 'id' => 'new_draft', - 'title' => esc_attr__("Copy to a new draft", 'duplicate-post'), - 'href' => duplicate_post_get_clone_post_link( $current_object->ID ) - ) ); + if ( !empty($current_object) ){ + if ( ! empty( $current_object->post_type ) + && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) + && duplicate_post_is_current_user_allowed_to_copy() + && ( $post_type_object->show_ui || 'attachment' == $current_object->post_type ) + && (duplicate_post_is_post_type_enabled($current_object->post_type) ) ) + { + $wp_admin_bar->add_menu( array( + 'id' => 'new_draft', + 'title' => esc_attr__("Copy to a new draft", 'duplicate-post'), + 'href' => duplicate_post_get_clone_post_link( $current_object->ID ) + ) ); + } + } else if ( is_admin() && isset( $_GET['post'] )){ + $id = $_GET['post']; + $post = get_post($id); + if( duplicate_post_is_current_user_allowed_to_copy() + && duplicate_post_is_post_type_enabled($post->post_type)) { + $wp_admin_bar->add_menu( array( + 'id' => 'new_draft', + 'title' => esc_attr__("Copy to a new draft", 'duplicate-post'), + 'href' => duplicate_post_get_clone_post_link( $id ) + ) ); + } } } function duplicate_post_add_css() { if(!is_admin_bar_showing()) return; $current_object = get_queried_object(); - if ( empty($current_object) ) - return; - if ( ! empty( $current_object->post_type ) - && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) - && duplicate_post_is_current_user_allowed_to_copy() - && ( $post_type_object->show_ui || 'attachment' == $current_object->post_type ) - && (duplicate_post_is_post_type_enabled($current_object->post_type) ) ) - { - wp_enqueue_style ( 'duplicate-post', plugins_url('/duplicate-post.css', __FILE__)); + if ( !empty($current_object) ){ + if ( ! empty( $current_object->post_type ) + && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) + && duplicate_post_is_current_user_allowed_to_copy() + && ( $post_type_object->show_ui || 'attachment' == $current_object->post_type ) + && (duplicate_post_is_post_type_enabled($current_object->post_type) ) ) + { + wp_enqueue_style ( 'duplicate-post', plugins_url('/duplicate-post.css', __FILE__)); + } + } else if ( is_admin() && isset( $_GET['post'] )){ + $id = $_GET['post']; + $post = get_post($id); + if( duplicate_post_is_current_user_allowed_to_copy() + && duplicate_post_is_post_type_enabled($post->post_type)) { + wp_enqueue_style ( 'duplicate-post', plugins_url('/duplicate-post.css', __FILE__)); + } } } @@ -140,7 +158,8 @@ function duplicate_post_add_css() { function duplicate_post_init(){ if (get_option ( 'duplicate_post_show_adminbar' ) == 1) { add_action ( 'wp_before_admin_bar_render', 'duplicate_post_admin_bar_render' ); - add_action ( 'wp_enqueue_scripts', 'duplicate_post_add_css' ); + add_action ( 'wp_enqueue_scripts', 'duplicate_post_add_css' ); + add_action ( 'admin_enqueue_scripts', 'duplicate_post_add_css' ); } } diff --git a/duplicate-post-options.php b/duplicate-post-options.php index facef3af7..b55900d43 100644 --- a/duplicate-post-options.php +++ b/duplicate-post-options.php @@ -360,7 +360,7 @@ class="taxonomy_public)?'public':'private';?>"> + () = 0 ){ ?>