Skip to content

Commit

Permalink
WC Post Types, Blocks: Add support for private speakers & sessions (#994
Browse files Browse the repository at this point in the history
)

* WC Post Types: Show private sessions in API response

See #717

* WC Post Types: Show all attached speakers on a session

* Blocks: Speaker Sessions: Show private sessions in speaker block
  • Loading branch information
ryelle committed May 13, 2024
1 parent 51f0927 commit b67909d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function render( $attributes, $content, $block ) {
'meta_value' => $post_ID,
'orderby' => 'title',
'order' => 'asc',
'post_status' => array( 'publish', 'private' ),
);

$sessions = get_posts( $session_args );
Expand Down
2 changes: 2 additions & 0 deletions public_html/wp-content/plugins/wc-post-types/inc/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ function prepare_session_query_args( $args, $request ) {
$args['orderby'] = 'meta_value_num';
}

$args['post_status'] = array( 'publish', 'private' );

return $args;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,7 @@ public function manage_post_types_columns_output( $column, $post_id ) {
if ( ! empty( $speakers_ids ) ) {
$speakers = get_posts( array(
'post_type' => 'wcb_speaker',
'post_status' => array( 'publish', 'draft' ),
'post_status' => 'any',
'posts_per_page' => -1,
'post__in' => $speakers_ids,
) );
Expand All @@ -1937,12 +1937,12 @@ public function manage_post_types_columns_output( $column, $post_id ) {
$output = array();

foreach ( $speakers as $speaker ) {
$is_draft = ( 'draft' === $speaker->post_status ) ? __( ' (draft)', 'wordcamporg' ) : '';
$status_label = ( 'publish' !== $speaker->post_status ) ? get_post_status_object( $speaker->post_status )->label . ': ' : '';
$output[] = sprintf(
'<a href="%1$s">%2$s%3$s</a>',
esc_url( get_edit_post_link( $speaker->ID ) ),
esc_html( apply_filters( 'the_title', $speaker->post_title ) ),
$is_draft
$status_label,
esc_html( apply_filters( 'the_title', $speaker->post_title ) )
);
}

Expand Down

0 comments on commit b67909d

Please sign in to comment.