Skip to content

Commit

Permalink
Applied patch from SVN
Browse files Browse the repository at this point in the history
  • Loading branch information
lopo committed Jun 20, 2019
1 parent a7133c4 commit 2b5497e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 36 deletions.
9 changes: 5 additions & 4 deletions duplicate-post-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 = '<strong>'.esc_html__('Duplicate Post turns 10!', 'duplicate-post').'</strong> '.esc_html__('Serving the WordPress community since November 2007.', 'duplicate-post').'<br/>';
$message .= '<em><a href="https://duplicate-post.lopo.it/">'.esc_html__('Check out the new 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/>';
$message .= '<strong>'.sprintf(wp_kses(__('Help me develop the plugin and provide support by <a href="%s">donating even a small sum</a>.', 'duplicate-post'), array( 'a' => array( 'href' => array() ) ) ), "https://duplicate-post.lopo.it/donate").'</strong>';
$message = '<strong>'.sprintf(__("What's new in Duplicate Post version %s:", 'duplicate-post'), DUPLICATE_POST_CURRENT_VERSION).'</strong><br/>';
$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').'<br/>';
$message .= '<em><a href="https://duplicate-post.lopo.it/">'.easc_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/>';
$message .= esc_html__('Serving the WordPress community since November 2007.', 'duplicate-post').' <strong>'.sprintf(wp_kses(__('Help me develop the plugin and provide support by <a href="%s">donating even a small sum</a>.', 'duplicate-post'), array( 'a' => array( 'href' => array() ) ) ), "https://duplicate-post.lopo.it/donate").'</strong>';
global $wp_version;
if( version_compare($wp_version, '4.2') < 0 ){
$message .= ' | <a id="duplicate-post-dismiss-notice" href="javascript:duplicate_post_dismiss_notice();">'.__('Dismiss this notice.').'</a>';
Expand Down
65 changes: 42 additions & 23 deletions duplicate-post-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__));
}
}
}

Expand All @@ -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' );
}
}

Expand Down
2 changes: 1 addition & 1 deletion duplicate-post-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class="taxonomy_<?php echo ($taxonomy->public)?'public':'private';?>">
<label><input type="checkbox" name="duplicate_post_show_submitbox" value="1" <?php if(get_option('duplicate_post_show_submitbox') == 1) echo 'checked="checked"'; ?>"/>
<?php esc_html_e("Edit screen", 'duplicate-post'); ?> </label>
<label><input type="checkbox" name="duplicate_post_show_adminbar" value="1" <?php if(get_option('duplicate_post_show_adminbar') == 1) echo 'checked="checked"'; ?>"/>
<?php esc_html_e("Admin bar", 'duplicate-post'); ?> </label>
<?php esc_html_e("Admin bar", 'duplicate-post'); ?> <small>(<?php esc_html_e("now works on Edit screen too — check this option to use with Gutenberg enabled", 'duplicate-post'); ?>)</small></label>
<?php global $wp_version;
if( version_compare($wp_version, '4.7') >= 0 ){ ?>
<label><input type="checkbox" name="duplicate_post_show_bulkactions" value="1" <?php if(get_option('duplicate_post_show_bulkactions') == 1) echo 'checked="checked"'; ?>"/>
Expand Down
6 changes: 3 additions & 3 deletions duplicate-post.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
width: 95px;
width: 52px;
padding: 0;
color: #999;
position: relative;
Expand All @@ -23,8 +23,8 @@
text-indent: 0;
font: 400 32px/1 dashicons;
speak: none;
top: 7px;
width: 95px;
top: 0px;
width: 52px;
text-align: center;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
Expand Down
4 changes: 2 additions & 2 deletions duplicate-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Duplicate Post
Plugin URI: https://duplicate-post.lopo.it/
Description: Clone posts and pages.
Version: 3.2.1
Version: 3.2.2
Author: Enrico Battocchi
Author URI: https://lopo.it
Text Domain: duplicate-post
Expand Down Expand Up @@ -31,7 +31,7 @@
}

// Version of the plugin
define('DUPLICATE_POST_CURRENT_VERSION', '3.2.1' );
define('DUPLICATE_POST_CURRENT_VERSION', '3.2.2' );


/**
Expand Down
16 changes: 13 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Donate link: https://duplicate-post.lopo.it/
Tags: duplicate post, copy, clone
Requires at least: 3.6
Tested up to: 4.9
Stable tag: 3.2.1
Stable tag: 3.2.2
Requires PHP: 5.2.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -23,7 +24,7 @@ How it works:

3. In 'Edit Posts'/'Edit Pages', you can click on 'New Draft' link below the post/page title.

4. On the post edit screen, you can click on 'Copy to a new draft' above "Cancel"/"Move to trash".
4. On the post edit screen, you can click on 'Copy to a new draft' above "Cancel"/"Move to trash" or in the admin bar.

5. While viewing a post as a logged in user, you can click on 'Copy to a new draft' in the admin bar.

Expand All @@ -35,6 +36,8 @@ Duplicate Post has many useful settings to customize its behavior and restrict i

**If you're a plugin developer**, I suggest you to read the [Developer's Guide](https://duplicate-post.lopo.it/docs/developers-guide/) to ensure compatibility between your plugin(s) and mine. Feel free to [contact me](https://duplicate-post.lopo.it/contact) so we can keep in touch and collaborate.

Duplicate Post does not collect any information outside your WordPress installation, therefore it's 100% GDPR compliant.

Thanks for all the suggestions, bug reports, translations and donations, they're frankly too many to be listed here!

== Installation ==
Expand Down Expand Up @@ -76,6 +79,9 @@ If Duplicate Post is still in English, or if there are some untraslated strings,

== Upgrade Notice ==

= 3.2.2 =
Adds compatibility with Gutenberg UI and fixes a problem with slugs on new installs

= 3.2.1 =
Fixes some problems with Multisite, WPML, revisions

Expand Down Expand Up @@ -141,6 +147,11 @@ New features and customization, WP 3.0 compatibility: you should upgrade if you

== Changelog ==

= 3.2.2 (2018-04-13) =
* The "Admin bar" option shows the link in the post edit screen too, so you can use the plugin with Gutenberg enabled
* Option for "Slug" not set by default on new installations
* Better display of icon in the Admin bar on small screens

= 3.2.1 (2017-11-25) =
* Fixing some issues of the 3.* trunk before major redesign
* Fixes issue when upgrading on multisite
Expand Down Expand Up @@ -300,4 +311,3 @@ If you find this useful and if you want to contribute, there are three ways:
1. You can [write me](https://duplicate-post.lopo.it/contact) and submit your bug reports, suggestions and requests for features;
2. If you want to translate it to your language (there are just a few lines of text), you can use the [translation project](https://translate.wordpress.org/projects/wp-plugins/duplicate-post);
3. Using the plugin is free, but if you want you can support my efforts by donating with PayPal [here](https://duplicate-post.lopo.it/donate)

0 comments on commit 2b5497e

Please sign in to comment.