Skip to content

Commit

Permalink
Calendar Settings: Separate groupings for Post Statuses, Revision Sta…
Browse files Browse the repository at this point in the history
…tuses
  • Loading branch information
agapetry committed Jan 29, 2025
1 parent d7b7a62 commit e863f33
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 9 additions & 2 deletions modules/calendar/library/calendar-methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function settings_show_posts_publish_time_option()
$statuses = [];

foreach ($customStatuses as $status) {
$statuses[$status->slug] = ['title' => $status->label, 'status_obj' => $status];
$statuses[$status->slug] = ['title' => $status->label, 'status_obj' => $status, 'for_revision' => !empty($status->for_revision)];
}
}

Expand Down Expand Up @@ -241,7 +241,14 @@ public function settings_show_posts_publish_time_option()
foreach ($statuses as $status => $arr_status) {
$id = esc_attr($status) . '-display-publish-time';

echo '<div><label for="' . $id . '">';
if ($arr_status['for_revision'] && empty($in_revisions_section)) {
$style = 'margin-top: 30px;';
$in_revisions_section = true;
} else {
$style = '';
}

echo '<div style="' . esc_attr($style) . '"><label for="' . $id . '">';
echo '<input id="' . $id . '" name="' . $field_name . '[' . esc_attr($status) . ']"';

if (isset($this->module->options->show_posts_publish_time[$status])) {
Expand Down
11 changes: 10 additions & 1 deletion publishpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,16 @@ public function getPostStatuses()

public function getCustomStatuses() {
if (class_exists('PublishPress_Statuses')) {
return \PublishPress_Statuses::getCustomStatuses([], 'object');
$customStatuses = \PublishPress_Statuses::getCustomStatuses(['for_revision' => false], 'object');

if (defined('PUBLISHPRESS_REVISIONS_VERSION') || defined('PUBLISHPRESS_REVISIONS_PRO_VERSION')) {
$customStatuses = array_merge(
$customStatuses,
\PublishPress_Statuses::getCustomStatuses(['for_revision' => true], 'object')
);
}

return $customStatuses;
} else {
return [];
}
Expand Down

0 comments on commit e863f33

Please sign in to comment.