Skip to content

Commit

Permalink
Resolve array to string conversion notices.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Jul 4, 2024
1 parent 75a23d7 commit 7cdc43b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 3 additions & 7 deletions includes/classes/PullListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,10 @@ public function prepare_items() {
$current_page = $this->get_pagenum();

// Support 'View all' filtering for internal connections.
if ( is_a( $connection_now, '\Distributor\InternalConnections\NetworkSiteConnection' ) ) {
if ( empty( $connection_now->pull_post_type ) || 'all' === $connection_now->pull_post_type ) {
$post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' );
} else {
$post_type = $connection_now->pull_post_type;
}
if ( empty( $connection_now->pull_post_type ) || 'all' === $connection_now->pull_post_type ) {
$post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' );
} else {
$post_type = ! empty( $connection_now->pull_post_type ) ? $connection_now->pull_post_type : array( 'post', 'page' );
$post_type = $connection_now->pull_post_type;
}

$remote_get_args = [
Expand Down
14 changes: 10 additions & 4 deletions includes/pull-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,19 +475,25 @@ function dashboard() {
$connection_now->pull_post_type = '';
$connection_now->pull_post_types = \Distributor\Utils\available_pull_post_types( $connection_now, $connection_type );

// Ensure we have at least one post type to pull.
$connection_now->pull_post_type = '';
if ( ! empty( $connection_now->pull_post_types ) ) {
$connection_now->pull_post_type = 'all';
}

// Set the post type we want to pull (if any)
// This is either from a query param, "post" post type, or the first in the list
foreach ( $connection_now->pull_post_types as $post_type ) {
if ( ! empty( $_GET['pull_post_type'] ) ) { // @codingStandardsIgnoreLine No nonce needed here.
if ( ! empty( $_GET['pull_post_type'] ) ) {
if ( 'all' === $_GET['pull_post_type'] ) {
$connection_now->pull_post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' );
$connection_now->pull_post_type = 'all';
break;
} elseif ( $_GET['pull_post_type'] === $post_type['slug'] ) { // @codingStandardsIgnoreLine Comparing values, no nonce needed.
} elseif ( $_GET['pull_post_type'] === $post_type['slug'] ) {
$connection_now->pull_post_type = $post_type['slug'];
break;
}
} else {
$connection_now->pull_post_type = ! empty( $post_type['slug'] ) ? $post_type['slug'] : 'post';
$connection_now->pull_post_type = ! empty( $post_type['slug'] ) ? $post_type['slug'] : 'all';
break;
}
}
Expand Down

0 comments on commit 7cdc43b

Please sign in to comment.