Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCBF automatic fixes #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 15 additions & 13 deletions class-copy-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function init() {
*/
function add_submenu_page() {
$post_types = get_post_types();
foreach( $post_types as $post_type ) {
if( post_type_supports( $post_type, 'writing-helper' ) ) {
foreach ( $post_types as $post_type ) {
if ( post_type_supports( $post_type, 'writing-helper' ) ) {
$post_type_obj = get_post_type_object( $post_type );

$submenu_page = 'edit.php';
Expand All @@ -31,7 +31,7 @@ function add_submenu_page() {

if ( $post_type == 'post' ) {
$submenu_page_label = __( 'Copy a Post', 'writing-helper' );
} else if ( $post_type == 'page' ) {
} elseif ( $post_type == 'page' ) {
$submenu_page_label = __( 'Copy a Page', 'writing-helper' );
} else {
$submenu_page_label = sprintf(
Expand Down Expand Up @@ -69,10 +69,9 @@ function get_candidate_posts( $post_type = 'post', $search_terms = '', $sticky =
'post_type' => $post_type,
'post_status' => array( 'publish', 'draft' ),
'posts_per_page' => 20,
'order_by' => 'date'
'order_by' => 'date',
);


if ( $sticky && ! empty( $sticky_posts ) ) {

// Including only sticky posts as required
Expand Down Expand Up @@ -105,8 +104,9 @@ function add_ajax_get_post_endpoint() {
exit;
}

if ( empty( $post_id ) )
if ( empty( $post_id ) ) {
die( '-1' );
}

$post = get_post( $post_id );

Expand All @@ -130,31 +130,33 @@ function add_ajax_stick_post_endpoint() {
$_REQUEST = stripslashes_deep( $_REQUEST );
$post_id = (int) $_REQUEST['post_id'];

if ( empty( $post_id ) )
if ( empty( $post_id ) ) {
die( '-1' );
}

// Get sticky posts for the blog.
$sticky_posts = (array) get_option( 'copy_a_post_sticky_posts' );

$existing = array_search( $post_id, $sticky_posts );
if ( false !== $existing ) {
unset( $sticky_posts[$existing] );
} else if ( count( $sticky_posts ) > 2 ) {
unset( $sticky_posts[ $existing ] );
} elseif ( count( $sticky_posts ) > 2 ) {
array_pop( $sticky_posts );
}

array_unshift( $sticky_posts, $post_id );
update_option( 'copy_a_post_sticky_posts', $sticky_posts );
update_option( 'copy_a_post_sticky_posts', $sticky_posts );

die( '1' );
}
die( '1' );
}

function add_ajax_record_stat_endpoint() {
$_REQUEST = stripslashes_deep( $_REQUEST );
$stat = $_REQUEST['stat'];

if ( empty( $stat ) )
if ( empty( $stat ) ) {
die( '-1' );
}

do_action( 'wh_copypost_ajax_stat', $stat );

Expand Down
Loading