Skip to content

Commit

Permalink
Merge pull request #133 from Yoast/JRF/CS/operator-placement
Browse files Browse the repository at this point in the history
 CS: consistent placement of operators
  • Loading branch information
jrfnl authored Mar 22, 2021
2 parents 055ca45 + 8feb652 commit a3dd0c6
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 47 deletions.
11 changes: 5 additions & 6 deletions duplicate-post-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,9 @@ function duplicate_post_show_update_notice() {
}

$current_screen = get_current_screen();
if (
empty( $current_screen ) ||
empty( $current_screen->base ) ||
( $current_screen->base !== 'dashboard' && $current_screen->base !== 'plugins' )
if ( empty( $current_screen )
|| empty( $current_screen->base )
|| ( $current_screen->base !== 'dashboard' && $current_screen->base !== 'plugins' )
) {
return;
}
Expand Down Expand Up @@ -629,8 +628,8 @@ function duplicate_post_create_duplicate( $post, $status = '', $parent_id = '' )
if ( ! duplicate_post_is_post_type_enabled( $post->post_type ) && $post->post_type !== 'attachment' ) {
wp_die(
esc_html(
__( 'Copy features for this post type are not enabled in options page', 'duplicate-post' ) . ': ' .
$post->post_type
__( 'Copy features for this post type are not enabled in options page', 'duplicate-post' ) . ': '
. $post->post_type
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/class-check-changes-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public function register_hooks() {
public function check_changes_action_handler() {
global $wp_version;

if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || // Input var okay.
( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'duplicate_post_check_changes' ) ) ) { // Input var okay.
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) // Input var okay.
|| ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'duplicate_post_check_changes' ) ) ) { // Input var okay.
\wp_die(
\esc_html__( 'No post has been supplied!', 'duplicate-post' )
);
Expand Down
12 changes: 6 additions & 6 deletions src/handlers/class-link-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public function new_draft_link_action_handler() {
\wp_die( \esc_html__( 'Current user is not allowed to copy posts.', 'duplicate-post' ) );
}

if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || // Input var okay.
( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'duplicate_post_new_draft' ) ) ) { // Input var okay.
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) // Input var okay.
|| ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'duplicate_post_new_draft' ) ) ) { // Input var okay.
\wp_die( \esc_html__( 'No post to duplicate has been supplied!', 'duplicate-post' ) );
}

Expand Down Expand Up @@ -118,8 +118,8 @@ public function clone_link_action_handler() {
\wp_die( \esc_html__( 'Current user is not allowed to copy posts.', 'duplicate-post' ) );
}

if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || // Input var okay.
( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'duplicate_post_clone' ) ) ) { // Input var okay.
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) // Input var okay.
|| ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'duplicate_post_clone' ) ) ) { // Input var okay.
\wp_die( \esc_html__( 'No post to duplicate has been supplied!', 'duplicate-post' ) );
}

Expand Down Expand Up @@ -192,8 +192,8 @@ public function rewrite_link_action_handler() {
\wp_die( \esc_html__( 'Current user is not allowed to copy posts.', 'duplicate-post' ) );
}

if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || // Input var okay.
( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'duplicate_post_rewrite' ) ) ) { // Input var okay.
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) // Input var okay.
|| ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'duplicate_post_rewrite' ) ) ) { // Input var okay.
\wp_die( \esc_html__( 'No post to duplicate has been supplied!', 'duplicate-post' ) );
}

Expand Down
26 changes: 13 additions & 13 deletions src/ui/class-row-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ public function add_clone_action_link( $actions, $post ) {

$title = \_draft_or_post_title( $post );

$actions['clone'] = '<a href="' . $this->link_builder->build_clone_link( $post->ID ) .
'" aria-label="' . \esc_attr(
$actions['clone'] = '<a href="' . $this->link_builder->build_clone_link( $post->ID )
. '" aria-label="' . \esc_attr(
/* translators: %s: Post title. */
\sprintf( \__( 'Clone &#8220;%s&#8221;', 'duplicate-post' ), $title )
) . '">' .
\esc_html_x( 'Clone', 'verb', 'duplicate-post' ) . '</a>';
) . '">'
. \esc_html_x( 'Clone', 'verb', 'duplicate-post' ) . '</a>';

return $actions;
}
Expand All @@ -111,13 +111,13 @@ public function add_new_draft_action_link( $actions, $post ) {

$title = \_draft_or_post_title( $post );

$actions['edit_as_new_draft'] = '<a href="' . $this->link_builder->build_new_draft_link( $post->ID ) .
'" aria-label="' . \esc_attr(
$actions['edit_as_new_draft'] = '<a href="' . $this->link_builder->build_new_draft_link( $post->ID )
. '" aria-label="' . \esc_attr(
/* translators: %s: Post title. */
\sprintf( \__( 'New draft of &#8220;%s&#8221;', 'duplicate-post' ), $title )
) . '">' .
\esc_html__( 'New Draft', 'duplicate-post' ) .
'</a>';
) . '">'
. \esc_html__( 'New Draft', 'duplicate-post' )
. '</a>';

return $actions;
}
Expand All @@ -142,12 +142,12 @@ public function add_rewrite_and_republish_action_link( $actions, $post ) {

$title = \_draft_or_post_title( $post );

$actions['rewrite'] = '<a href="' . $this->link_builder->build_rewrite_and_republish_link( $post->ID ) .
'" aria-label="' . \esc_attr(
$actions['rewrite'] = '<a href="' . $this->link_builder->build_rewrite_and_republish_link( $post->ID )
. '" aria-label="' . \esc_attr(
/* translators: %s: Post title. */
\sprintf( \__( 'Rewrite & Republish &#8220;%s&#8221;', 'duplicate-post' ), $title )
) . '">' .
\esc_html_x( 'Rewrite & Republish', 'verb', 'duplicate-post' ) . '</a>';
) . '">'
. \esc_html_x( 'Rewrite & Republish', 'verb', 'duplicate-post' ) . '</a>';

return $actions;
}
Expand Down
8 changes: 4 additions & 4 deletions src/watchers/class-bulk-actions-watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function add_bulk_clone_admin_notice() {
if ( ! empty( $_REQUEST['bulk_cloned'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$copied_posts = \intval( $_REQUEST['bulk_cloned'] ); // phpcs:ignore WordPress.Security.NonceVerification
\printf(
'<div id="message" class="notice notice-success fade"><p>' .
\esc_html(
'<div id="message" class="notice notice-success fade"><p>'
. \esc_html(
/* translators: %s: Number of posts copied. */
\_n(
'%s item copied.',
Expand All @@ -78,8 +78,8 @@ public function add_bulk_rewrite_and_republish_admin_notice() {
if ( ! empty( $_REQUEST['bulk_rewriting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$copied_posts = \intval( $_REQUEST['bulk_rewriting'] ); // phpcs:ignore WordPress.Security.NonceVerification
\printf(
'<div id="message" class="notice notice-success fade"><p>' .
\esc_html(
'<div id="message" class="notice notice-success fade"><p>'
. \esc_html(
/* translators: %s: Number of posts copied. */
\_n(
'%s post duplicated. You can now start rewriting your post in the duplicate of the original post. Once you choose to republish it your changes will be merged back into the original post.',
Expand Down
6 changes: 3 additions & 3 deletions src/watchers/class-copied-post-watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public function add_admin_notice() {
}

if ( $this->permissions_helper->has_rewrite_and_republish_copy( $post ) ) {
print '<div id="message" class="notice notice-warning is-dismissible fade"><p>' .
\esc_html( $this->get_notice_text( $post ) ) .
'</p></div>';
print '<div id="message" class="notice notice-warning is-dismissible fade"><p>'
. \esc_html( $this->get_notice_text( $post ) )
. '</p></div>';
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/watchers/class-link-actions-watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public function add_clone_admin_notice() {

$copied_posts = \intval( $_REQUEST['cloned'] ); // phpcs:ignore WordPress.Security.NonceVerification
\printf(
'<div id="message" class="notice notice-success fade"><p>' .
\esc_html(
'<div id="message" class="notice notice-success fade"><p>'
. \esc_html(
/* translators: %s: Number of posts copied. */
\_n(
'%s item copied.',
Expand All @@ -98,11 +98,11 @@ public function add_rewrite_and_republish_admin_notice() {
return;
}

print '<div id="message" class="notice notice-warning is-dismissible fade"><p>' .
\esc_html__(
'You can now start rewriting your post in this duplicate of the original post. If you click "Republish", your changes will be merged into the original post and you’ll be redirected there.',
'duplicate-post'
) . '</p></div>';
print '<div id="message" class="notice notice-warning is-dismissible fade"><p>'
. \esc_html__(
'You can now start rewriting your post in this duplicate of the original post. If you click "Republish", your changes will be merged into the original post and you’ll be redirected there.',
'duplicate-post'
) . '</p></div>';
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/watchers/class-original-post-watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public function add_admin_notice() {
}

if ( $this->permissions_helper->has_original_changed( $post ) ) {
print '<div id="message" class="notice notice-warning is-dismissible fade"><p>' .
\esc_html( $this->get_notice_text() ) .
'</p></div>';
print '<div id="message" class="notice notice-warning is-dismissible fade"><p>'
. \esc_html( $this->get_notice_text() )
. '</p></div>';
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/watchers/class-republished-post-watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public function add_admin_notice() {
}

if ( ! empty( $_REQUEST['dprepublished'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
echo '<div id="message" class="notice notice-success is-dismissible"><p>' .
\esc_html( $this->get_notice_text() ) .
'</p></div>';
echo '<div id="message" class="notice notice-success is-dismissible"><p>'
. \esc_html( $this->get_notice_text() )
. '</p></div>';
}
}

Expand Down

0 comments on commit a3dd0c6

Please sign in to comment.