Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function duplicate_post_plugin_upgrade() {
'new_draft' => '1',
'clone' => '1',
'rewrite_republish' => '1',
]
],
);
add_option( 'duplicate_post_show_link_in', $show_links_in_defaults );

Expand Down Expand Up @@ -228,7 +228,7 @@ function duplicate_post_show_update_notice() {
$title = sprintf(
/* translators: %s: Yoast Duplicate Post. */
esc_html__( 'You\'ve successfully installed %s!', 'duplicate-post' ),
'Yoast Duplicate Post'
'Yoast Duplicate Post',
);

$img_path = plugins_url( '/duplicate_post_yoast_icon-125x125.png', __FILE__ );
Expand Down Expand Up @@ -453,7 +453,7 @@ function duplicate_post_copy_attachments( $new_id, $post ) {
'numberposts' => -1,
'post_status' => 'any',
'post_parent' => $post->ID,
]
],
);
// Clone old attachments.
foreach ( $children as $child ) {
Expand Down Expand Up @@ -518,7 +518,7 @@ function duplicate_post_copy_children( $new_id, $post, $status = '' ) {
'numberposts' => -1,
'post_status' => 'any',
'post_parent' => $post->ID,
]
],
);

foreach ( $children as $child ) {
Expand All @@ -543,7 +543,7 @@ function duplicate_post_copy_comments( $new_id, $post ) {
'post_id' => $post->ID,
'order' => 'ASC',
'orderby' => 'comment_date_gmt',
]
],
);

$old_id_to_new = [];
Expand Down Expand Up @@ -619,8 +619,8 @@ function duplicate_post_create_duplicate( $post, $status = '', $parent_id = '' )
wp_die(
esc_html(
__( 'Copy features for this post type are not enabled in options page', 'duplicate-post' ) . ': '
. $post->post_type
)
. $post->post_type,
),
);
}

Expand Down
7 changes: 2 additions & 5 deletions common-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ function duplicate_post_clone_post_link( $link = null, $before = '', $after = ''
return;
}

if ( $link === null ) {
$link = __( 'Copy to a new draft', 'duplicate-post' );
}

$link = '<a class="post-clone-link" href="' . esc_url( $url ) . '">' . esc_html( $link ) . '</a>';
$link ??= __( 'Copy to a new draft', 'duplicate-post' );
$link = '<a class="post-clone-link" href="' . esc_url( $url ) . '">' . esc_html( $link ) . '</a>';

/**
* Filter on the clone link HTML.
Expand Down
4 changes: 2 additions & 2 deletions compat/wpml-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function duplicate_post_wpml_copy_translations( $post_id, $post, $status = '' )
'post_' . $translation->post_type,
$new_trid,
$code,
$current_language
$current_language,
);
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ function duplicate_wpml_string_packages() { // phpcs:ignore WordPress.NamingConv
$new_string->id,
$language,
$translated_string['value'],
$translated_string['status']
$translated_string['status'],
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"require-dev": {
"yoast/wp-test-utils": "^1.2.0",
"yoast/yoastcs": "^3.2.0"
"yoast/yoastcs": "^3.3.0"
},
"autoload": {
"classmap": [
Expand Down
4 changes: 2 additions & 2 deletions config/composer/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private static function check_cs_for_changed_files( $compare ) {
$command = \sprintf(
'composer check-cs-warnings -- %s %s',
\implode( ' ', \array_map( 'escapeshellarg', $php_files ) ),
$extra_args
$extra_args,
);
\system( $command, $exit_code );

Expand Down Expand Up @@ -196,7 +196,7 @@ private static function filter_files( array $files, string $extension ): array {
$files,
static function ( $file ) use ( $extension ) {
return \substr( $file, ( 0 - \strlen( $extension ) ) ) === $extension;
}
},
);
}
}
2 changes: 1 addition & 1 deletion duplicate-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function duplicate_post_plugin_actions( $actions ) {
menu_page_url( 'duplicatepost', false ),
/* translators: Hidden accessibility text. */
'aria-label="' . __( 'Settings for Duplicate Post', 'duplicate-post' ) . '"',
esc_html__( 'Settings', 'duplicate-post' )
esc_html__( 'Settings', 'duplicate-post' ),
),
];

Expand Down
2 changes: 1 addition & 1 deletion options.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$duplicate_post_options_page = new Options_Page(
new Options(),
new Options_Form_Generator( new Options_Inputs() ),
new Asset_Manager()
new Asset_Manager(),
);

$duplicate_post_options_page->register_hooks();
8 changes: 4 additions & 4 deletions src/admin/options-form-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function generate_options_input( array $options, $parent_option = '' ) {
$option,
$option_values['value'],
$id,
$this->is_checked( $option, $option_values, $parent_option )
$this->is_checked( $option, $option_values, $parent_option ),
);

$output .= \sprintf( '<label for="%s">%s</label>', $id, \esc_html( $option_values['label'] ) );
Expand Down Expand Up @@ -176,7 +176,7 @@ public function generate_taxonomy_exclusion_list() {
'checked' => \in_array( $taxonomy->name, $taxonomies_blacklist, true ),
'label' => $taxonomy->labels->name . ' [' . $taxonomy->name . ']',
],
]
],
);
$output .= '</div>';
}
Expand Down Expand Up @@ -212,7 +212,7 @@ public function generate_roles_permission_list() {
'checked' => $role->has_cap( 'copy_posts' ),
'label' => \translate_user_role( $display_name ),
],
]
],
);
}
}
Expand Down Expand Up @@ -246,7 +246,7 @@ public function generate_post_types_list() {
'checked' => $this->is_post_type_enabled( $post_type_object->name ),
'label' => $post_type_object->labels->name,
],
]
],
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/admin/options-inputs.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function input( $type, $name, $value, $id, $attributes = '' ) {
\esc_attr( $name ),
\esc_attr( $id ),
\esc_attr( $value ),
$attributes
$attributes,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/admin/options-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function register_menu() {
\__( 'Duplicate Post', 'duplicate-post' ),
'manage_options',
'duplicatepost',
[ $this, 'generate_page' ]
[ $this, 'generate_page' ],
);

\add_action( $page_hook, [ $this, 'enqueue_assets' ] );
Expand Down
4 changes: 2 additions & 2 deletions src/admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function get_options_for_tab( $tab, $fieldset = '' ) {
$options,
static function ( $option ) use ( $tab ) {
return \array_key_exists( 'tab', $option ) && $option['tab'] === $tab;
}
},
);

if ( empty( $options ) ) {
Expand All @@ -50,7 +50,7 @@ static function ( $option ) use ( $tab ) {
$options,
static function ( $option ) use ( $fieldset ) {
return \array_key_exists( 'fieldset', $option ) && $option['fieldset'] === $fieldset;
}
},
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/admin/views/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class="nav-tab"
'<code>',
'</code>',
'<a href="' . \esc_url( 'https://developer.yoast.com/duplicate-post/functions-template-tags#duplicate_post_clone_post_link' ) . '">',
'</a>'
'</a>',
);
?>
</p>
Expand Down
14 changes: 7 additions & 7 deletions src/handlers/check-changes-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function check_changes_action_handler() {
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] )
|| ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'duplicate_post_check_changes' ) ) ) {
\wp_die(
\esc_html__( 'No post has been supplied!', 'duplicate-post' )
\esc_html__( 'No post has been supplied!', 'duplicate-post' ),
);
return;
}
Expand All @@ -82,9 +82,9 @@ public function check_changes_action_handler() {
\sprintf(
/* translators: %s: post ID. */
\__( 'Changes overview failed, could not find post with ID %s.', 'duplicate-post' ),
$id
)
)
$id,
),
),
);
return;
}
Expand All @@ -94,8 +94,8 @@ public function check_changes_action_handler() {
if ( ! $this->original ) {
\wp_die(
\esc_html(
\__( 'Changes overview failed, could not find original post.', 'duplicate-post' )
)
\__( 'Changes overview failed, could not find original post.', 'duplicate-post' ),
),
);
return;
}
Expand All @@ -109,7 +109,7 @@ public function check_changes_action_handler() {
\printf(
/* translators: %s: original item link (to view or edit) or title. */
\esc_html__( 'Compare changes of duplicated post with the original (&#8220;%s&#8221;)', 'duplicate-post' ),
Utils::get_edit_or_view_link( $this->original ) // phpcs:ignore WordPress.Security.EscapeOutput
Utils::get_edit_or_view_link( $this->original ), // phpcs:ignore WordPress.Security.EscapeOutput
);
?>
</h1>
Expand Down
36 changes: 18 additions & 18 deletions src/handlers/link-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@ public function new_draft_link_action_handler() {
\wp_die(
\esc_html(
\__( 'Copy creation failed, could not find original:', 'duplicate-post' ) . ' '
. $id
)
. $id,
),
);
}

if ( $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
\wp_die(
\esc_html__( 'You cannot create a copy of a post which is intended for Rewrite & Republish.', 'duplicate-post' )
\esc_html__( 'You cannot create a copy of a post which is intended for Rewrite & Republish.', 'duplicate-post' ),
);
}

$new_id = \duplicate_post_create_duplicate( $post, 'draft' );

if ( \is_wp_error( $new_id ) ) {
\wp_die(
\esc_html__( 'Copy creation failed, could not create a copy.', 'duplicate-post' )
\esc_html__( 'Copy creation failed, could not create a copy.', 'duplicate-post' ),
);
}

Expand All @@ -98,8 +98,8 @@ public function new_draft_link_action_handler() {
'cloned' => 1,
'ids' => $post->ID,
],
\admin_url( 'post.php?action=edit&post=' . $new_id . ( isset( $_GET['classic-editor'] ) ? '&classic-editor' : '' ) )
)
\admin_url( 'post.php?action=edit&post=' . $new_id . ( isset( $_GET['classic-editor'] ) ? '&classic-editor' : '' ) ),
),
);
exit();
}
Expand Down Expand Up @@ -129,22 +129,22 @@ public function clone_link_action_handler() {
\wp_die(
\esc_html(
\__( 'Copy creation failed, could not find original:', 'duplicate-post' ) . ' '
. $id
)
. $id,
),
);
}

if ( $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
\wp_die(
\esc_html__( 'You cannot create a copy of a post which is intended for Rewrite & Republish.', 'duplicate-post' )
\esc_html__( 'You cannot create a copy of a post which is intended for Rewrite & Republish.', 'duplicate-post' ),
);
}

$new_id = \duplicate_post_create_duplicate( $post );

if ( \is_wp_error( $new_id ) ) {
\wp_die(
\esc_html__( 'Copy creation failed, could not create a copy.', 'duplicate-post' )
\esc_html__( 'Copy creation failed, could not create a copy.', 'duplicate-post' ),
);
}

Expand Down Expand Up @@ -172,8 +172,8 @@ public function clone_link_action_handler() {
'cloned' => 1,
'ids' => $post->ID,
],
$sendback
)
$sendback,
),
);
exit();
}
Expand Down Expand Up @@ -203,22 +203,22 @@ public function rewrite_link_action_handler() {
\wp_die(
\esc_html(
\__( 'Copy creation failed, could not find original:', 'duplicate-post' ) . ' '
. $id
)
. $id,
),
);
}

if ( ! $this->permissions_helper->should_rewrite_and_republish_be_allowed( $post ) ) {
\wp_die(
\esc_html__( 'You cannot create a copy for Rewrite & Republish if the original is not published or if it already has a copy.', 'duplicate-post' )
\esc_html__( 'You cannot create a copy for Rewrite & Republish if the original is not published or if it already has a copy.', 'duplicate-post' ),
);
}

$new_id = $this->post_duplicator->create_duplicate_for_rewrite_and_republish( $post );

if ( \is_wp_error( $new_id ) ) {
\wp_die(
\esc_html__( 'Copy creation failed, could not create a copy.', 'duplicate-post' )
\esc_html__( 'Copy creation failed, could not create a copy.', 'duplicate-post' ),
);
}

Expand All @@ -228,8 +228,8 @@ public function rewrite_link_action_handler() {
'rewriting' => 1,
'ids' => $post->ID,
],
\admin_url( 'post.php?action=edit&post=' . $new_id . ( isset( $_GET['classic-editor'] ) ? '&classic-editor' : '' ) )
)
\admin_url( 'post.php?action=edit&post=' . $new_id . ( isset( $_GET['classic-editor'] ) ? '&classic-editor' : '' ) ),
),
);
exit();
}
Expand Down
Loading