Skip to content
Merged
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
52 changes: 12 additions & 40 deletions modules/calendar/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1807,28 +1807,28 @@ public function get_calendar_post_stati() {
return apply_filters( 'ef_calendar_post_stati', $final_statuses );
}

public function get_calendar_dropdown_users() {
$users_dropdown_args = array(
public function get_calendar_users() {
$users_args = array(
'orderby' => 'display_name',
'order' => 'ASC',
'blog_id' => get_current_blog_id()
);

$users_dropdown_args = apply_filters( 'ef_calendar_dropdown_users_args', $users_dropdown_args );
$users_args = apply_filters( 'ef_calendar_dropdown_users_args', $users_args );

return get_users( $users_dropdown_args );
return get_users( $users_args );
}

public function get_calendar_categories_dropdown() {
$categories_dropdown_args = array(
public function get_calendar_categories() {
$categories_args = array(
'orderby' => 'id',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 0,
'taxonomy' => 'category'
);

return get_terms( $categories_dropdown_args );
return get_terms( $categories_args );
}

public function get_calendar_frontend_config() {
Expand All @@ -1837,47 +1837,19 @@ public function get_calendar_frontend_config() {
$all_post_types = get_post_types( null, 'objects' );

$config = array(
'POST_STATI' => array_merge(
array(
array(
'label' => 'Unpublish',
'name' => 'unpublish'
)
),
array_map(
function( $item ) {
return array(
'name' => $item->name,
'label' => $item->label,
);
},
$this->get_calendar_post_stati()
)
),
'POST_STATI' => $this->get_calendar_post_stati(),
'USERS' => array_map(
function( $item ) {
return array(
'id' => $item->ID,
'display_name' => $item->display_name,
);
},
$this->get_calendar_dropdown_users()
),
'CATEGORIES' => array_map(
function( $item ) {
return array(
'term_id' => $item->term_id,
'name' => $item->name,
'parent' => $item->parent
);
},
$this->get_calendar_categories_dropdown()
$this->get_calendar_users()
),
'CALENDAR_POST_TYPES' => array_map( function ( $item ) use ( $all_post_types ) {
return array(
'name' => $all_post_types[ $item ]->name,
'label' => $all_post_types[ $item ]->label
);
'CATEGORIES' => $this->get_calendar_categories(),
'POST_TYPES' => array_map( function ( $item ) use ( $all_post_types ) {
return $all_post_types[ $item ];
}, $this->get_post_types_for_module( $this->module ) ),
'NUM_WEEKS' => array(
'MAX' => $this->max_weeks,
Expand Down
2 changes: 1 addition & 1 deletion modules/calendar/lib/dist/calendar.react.build.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions modules/calendar/lib/react/calendar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ const filters = [
},
];

if ( EF_CALENDAR.CALENDAR_POST_TYPES && EF_CALENDAR.CALENDAR_POST_TYPES.length > 1 ) {
if ( EF_CALENDAR.POST_TYPES && EF_CALENDAR.POST_TYPES.length > 1 ) {
filters.push( {
name: 'cpt',
filterType: 'select',
label: __( 'Select a type', 'edit-flow' ),
options: [ { value: '', label: __( 'Select a type', 'edit-flow' ) } ]
.concat( EF_CALENDAR.CALENDAR_POST_TYPES.map( ( { name: value, label } ) => ( { value, label } ) ) ),
.concat( EF_CALENDAR.POST_TYPES.map( ( { name: value, label } ) => ( { value, label } ) ) ),
initialValue: EF_CALENDAR.FILTERS.cpt,
} );
}
Expand Down