Skip to content

Commit 9b80c0e

Browse files
committed
Renaming some frontend configuration to better support usage across the calendar
1 parent d8bd649 commit 9b80c0e

File tree

3 files changed

+14
-44
lines changed

3 files changed

+14
-44
lines changed

modules/calendar/calendar.php

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,28 +1807,28 @@ public function get_calendar_post_stati() {
18071807
return apply_filters( 'ef_calendar_post_stati', $final_statuses );
18081808
}
18091809

1810-
public function get_calendar_dropdown_users() {
1811-
$users_dropdown_args = array(
1810+
public function get_calendar_users() {
1811+
$users_args = array(
18121812
'orderby' => 'display_name',
18131813
'order' => 'ASC',
18141814
'blog_id' => get_current_blog_id()
18151815
);
18161816

1817-
$users_dropdown_args = apply_filters( 'ef_calendar_dropdown_users_args', $users_dropdown_args );
1817+
$users_args = apply_filters( 'ef_calendar_dropdown_users_args', $users_args );
18181818

1819-
return get_users( $users_dropdown_args );
1819+
return get_users( $users_args );
18201820
}
18211821

1822-
public function get_calendar_categories_dropdown() {
1823-
$categories_dropdown_args = array(
1822+
public function get_calendar_categories() {
1823+
$categories_args = array(
18241824
'orderby' => 'id',
18251825
'order' => 'ASC',
18261826
'hide_empty' => 0,
18271827
'hierarchical' => 0,
18281828
'taxonomy' => 'category'
18291829
);
18301830

1831-
return get_terms( $categories_dropdown_args );
1831+
return get_terms( $categories_args );
18321832
}
18331833

18341834
public function get_calendar_frontend_config() {
@@ -1837,48 +1837,18 @@ public function get_calendar_frontend_config() {
18371837
$all_post_types = get_post_types( null, 'objects' );
18381838

18391839
$config = array(
1840-
'POST_STATI' => array_merge(
1841-
array(
1842-
array(
1843-
'label' => 'Unpublish',
1844-
'name' => 'unpublish'
1845-
)
1846-
),
1847-
array_map(
1848-
function( $item ) {
1849-
return array(
1850-
'name' => $item->name,
1851-
'label' => $item->label,
1852-
);
1853-
},
1854-
$this->get_calendar_post_stati()
1855-
)
1856-
),
1840+
'POST_STATI' => $this->get_calendar_post_stati(),
18571841
'USERS' => array_map(
18581842
function( $item ) {
18591843
return array(
18601844
'id' => $item->ID,
18611845
'display_name' => $item->display_name,
18621846
);
18631847
},
1864-
$this->get_calendar_dropdown_users()
1865-
),
1866-
'CATEGORIES' => array_map(
1867-
function( $item ) {
1868-
return array(
1869-
'term_id' => $item->term_id,
1870-
'name' => $item->name,
1871-
'parent' => $item->parent
1872-
);
1873-
},
1874-
$this->get_calendar_categories_dropdown()
1848+
$this->get_calendar_users()
18751849
),
1876-
'CALENDAR_POST_TYPES' => array_map( function ( $item ) use ( $all_post_types ) {
1877-
return array(
1878-
'name' => $all_post_types[ $item ]->name,
1879-
'label' => $all_post_types[ $item ]->label
1880-
);
1881-
}, $this->get_post_types_for_module( $this->module ) ),
1850+
'CATEGORIES' => $this->get_calendar_categories(),
1851+
'POST_TYPES' => $this->get_post_types_for_module( $this->module ),
18821852
'NUM_WEEKS' => array(
18831853
'MAX' => $this->max_weeks,
18841854
'DEFAULT' => $this->total_weeks,

modules/calendar/lib/dist/calendar.react.build.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/calendar/lib/react/calendar.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ const filters = [
9393
},
9494
];
9595

96-
if ( EF_CALENDAR.CALENDAR_POST_TYPES && EF_CALENDAR.CALENDAR_POST_TYPES.length > 1 ) {
96+
if ( EF_CALENDAR.POST_TYPES && EF_CALENDAR.POST_TYPES.length > 1 ) {
9797
filters.push( {
9898
name: 'cpt',
9999
filterType: 'select',
100100
label: __( 'Select a type', 'edit-flow' ),
101101
options: [ { value: '', label: __( 'Select a type', 'edit-flow' ) } ]
102-
.concat( EF_CALENDAR.CALENDAR_POST_TYPES.map( ( { name: value, label } ) => ( { value, label } ) ) ),
102+
.concat( EF_CALENDAR.POST_TYPES.map( ( { name: value, label } ) => ( { value, label } ) ) ),
103103
initialValue: EF_CALENDAR.FILTERS.cpt,
104104
} );
105105
}

0 commit comments

Comments
 (0)