Skip to content

Commit

Permalink
Merge pull request #131 from Yoast/JRF/CS/else-on-new-line
Browse files Browse the repository at this point in the history
CS: else(if) must be on new line
  • Loading branch information
jrfnl authored Mar 22, 2021
2 parents fff381a + fc0a327 commit cb5f386
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@

<!-- Demanding Yoda conditions is stupid. -->
<exclude name="WordPress.PHP.YodaConditions"/>

<!-- YoastCS demands else on new line. -->
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"/>
</rule>

<config name="testVersion" value="5.5-"/>
Expand Down
3 changes: 2 additions & 1 deletion compat/duplicate-post-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function duplicate_post_classic_editor_clone_link( $url, $post_id, $context, $dr
|| ( $draft && function_exists( 'has_blocks' ) && ! has_blocks( $post ) ) ) {
if ( $context === 'display' ) {
$url .= '&amp;classic-editor';
} else {
}
else {
$url .= '&classic-editor';
}
}
Expand Down
27 changes: 18 additions & 9 deletions duplicate-post-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function duplicate_post_admin_init() {
if ( intval( get_site_option( 'duplicate_post_show_notice' ) ) === 1 ) {
if ( is_multisite() ) {
add_action( 'network_admin_notices', 'duplicate_post_show_update_notice' );
} else {
}
else {
add_action( 'admin_notices', 'duplicate_post_show_update_notice' );
}
add_action( 'wp_ajax_duplicate_post_dismiss_notice', 'duplicate_post_dismiss_notice' );
Expand Down Expand Up @@ -349,7 +350,8 @@ function duplicate_post_copy_post_meta_info( $new_id, $post ) {
$meta_blacklist = get_option( 'duplicate_post_blacklist' );
if ( $meta_blacklist === '' ) {
$meta_blacklist = [];
} else {
}
else {
$meta_blacklist = explode( ',', $meta_blacklist );
$meta_blacklist = array_filter( $meta_blacklist );
$meta_blacklist = array_map( 'trim', $meta_blacklist );
Expand Down Expand Up @@ -386,7 +388,8 @@ function duplicate_post_copy_post_meta_info( $new_id, $post ) {
$meta_keys[] = $meta_key;
}
}
} else {
}
else {
$meta_keys = array_diff( $post_meta_keys, $meta_blacklist );
}

Expand Down Expand Up @@ -420,7 +423,8 @@ function duplicate_post_copy_post_meta_info( $new_id, $post ) {
function duplicate_post_addslashes_deep( $value ) {
if ( function_exists( 'map_deep' ) ) {
return map_deep( $value, 'duplicate_post_addslashes_to_strings_only' );
} else {
}
else {
return wp_slash( $value );
}
}
Expand Down Expand Up @@ -645,7 +649,8 @@ function duplicate_post_create_duplicate( $post, $status = '', $parent_id = '' )
if ( ! empty( $suffix ) ) {
$suffix = ' ' . $suffix;
}
} else {
}
else {
$title = ' ';
}
$title = trim( $prefix . $title . $suffix );
Expand All @@ -660,14 +665,16 @@ function duplicate_post_create_duplicate( $post, $status = '', $parent_id = '' )

if ( intval( get_option( 'duplicate_post_copystatus' ) ) === 0 ) {
$new_post_status = 'draft';
} else {
}
else {
if ( $new_post_status === 'publish' || $new_post_status === 'future' ) {
// Check if the user has the right capability.
if ( is_post_type_hierarchical( $post->post_type ) ) {
if ( ! current_user_can( 'publish_pages' ) ) {
$new_post_status = 'pending';
}
} else {
}
else {
if ( ! current_user_can( 'publish_posts' ) ) {
$new_post_status = 'pending';
}
Expand All @@ -684,7 +691,8 @@ function duplicate_post_create_duplicate( $post, $status = '', $parent_id = '' )
if ( current_user_can( 'edit_others_pages' ) ) {
$new_post_author_id = $post->post_author;
}
} else {
}
else {
if ( current_user_can( 'edit_others_posts' ) ) {
$new_post_author_id = $post->post_author;
}
Expand Down Expand Up @@ -743,7 +751,8 @@ function duplicate_post_create_duplicate( $post, $status = '', $parent_id = '' )

if ( $post->post_type === 'page' || is_post_type_hierarchical( $post->post_type ) ) {
do_action( 'dp_duplicate_page', $new_post_id, $post, $status );
} else {
}
else {
do_action( 'dp_duplicate_post', $new_post_id, $post, $status );
}

Expand Down
3 changes: 2 additions & 1 deletion duplicate-post-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function duplicate_post_get_clone_post_link( $id = 0, $context = 'display', $dra

if ( $draft ) {
return $link_builder->build_new_draft_link( $post, $context );
} else {
}
else {
return $link_builder->build_clone_link( $post, $context );
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/class-post-duplicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ public function copy_post_meta_info( $new_id, $post, $options ) {
$meta_keys[] = $meta_key;
}
}
} else {
}
else {
$meta_keys = \array_diff( $post_meta_keys, $meta_excludelist );
}

Expand Down Expand Up @@ -315,7 +316,8 @@ public function generate_copy_title( \WP_Post $post, array $options ) {
if ( ! empty( $suffix ) ) {
$suffix = ' ' . $suffix;
}
} else {
}
else {
$title = '';
}
return \trim( $prefix . $title . $suffix );
Expand All @@ -340,7 +342,8 @@ public function generate_copy_status( \WP_Post $post, array $options ) {
if ( ! \current_user_can( 'publish_pages' ) ) {
$new_post_status = 'pending';
}
} else {
}
else {
if ( ! \current_user_can( 'publish_posts' ) ) {
$new_post_status = 'pending';
}
Expand Down Expand Up @@ -368,7 +371,8 @@ public function generate_copy_author( \WP_Post $post, array $options ) {
if ( \current_user_can( 'edit_others_pages' ) ) {
$new_post_author_id = $post->post_author;
}
} else {
}
else {
if ( \current_user_can( 'edit_others_posts' ) ) {
$new_post_author_id = $post->post_author;
}
Expand Down
3 changes: 2 additions & 1 deletion src/class-post-republisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public function clean_up_after_redirect() {

if ( \intval( \get_post_meta( $copy_id, '_dp_has_been_republished', true ) ) === 1 ) {
$this->delete_copy( $copy_id, $post_id );
} else {
}
else {
\wp_die( \esc_html__( 'An error occurred while deleting the Rewrite & Republish copy.', 'duplicate-post' ) );
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/class-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public static function get_edit_or_view_link( $post ) {
\esc_attr( \sprintf( \__( 'Edit &#8220;%s&#8221;', 'default' ), $title ) ),
$title
);
} elseif ( \is_post_type_viewable( $post_type_object ) ) {
}
elseif ( \is_post_type_viewable( $post_type_object ) ) {
if ( \in_array( $post->post_status, [ 'pending', 'draft', 'future' ], true ) ) {
if ( $can_edit_post ) {
$preview_link = \get_preview_post_link( $post );
Expand All @@ -136,7 +137,8 @@ public static function get_edit_or_view_link( $post ) {
$title
);
}
} elseif ( $post->post_status !== 'trash' ) {
}
elseif ( $post->post_status !== 'trash' ) {
return \sprintf(
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
\get_permalink( $post->ID ),
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/class-link-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,15 @@ public function clone_link_action_handler() {
if ( ! $sendback || strpos( $sendback, 'post.php' ) !== false || strpos( $sendback, 'post-new.php' ) !== false ) {
if ( $post_type === 'attachment' ) {
$sendback = \admin_url( 'upload.php' );
} else {
}
else {
$sendback = \admin_url( 'edit.php' );
if ( ! empty( $post_type ) ) {
$sendback = \add_query_arg( 'post_type', $post_type, $sendback );
}
}
} else {
}
else {
$sendback = \remove_query_arg( [ 'trashed', 'untrashed', 'deleted', 'cloned', 'ids' ], $sendback );
}

Expand Down
6 changes: 4 additions & 2 deletions src/ui/class-admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public function admin_bar_render() {
'href' => $this->link_builder->build_rewrite_and_republish_link( $post ),
]
);
} else {
}
else {
if ( $show_new_draft ) {
$wp_admin_bar->add_menu(
[
Expand Down Expand Up @@ -167,7 +168,8 @@ public function get_current_post() {

if ( \is_admin() ) {
$post = \get_post();
} else {
}
else {
$post = $wp_the_query->get_queried_object();
}

Expand Down
3 changes: 2 additions & 1 deletion src/ui/class-link-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public function build_link( $post, $context, $action_name ) {

if ( $context === 'display' ) {
$action = '?action=' . $action_name . '&amp;post=' . $post->ID;
} else {
}
else {
$action = '?action=' . $action_name . '&post=' . $post->ID;
}

Expand Down

0 comments on commit cb5f386

Please sign in to comment.