Skip to content

Commit

Permalink
- Make Content Overview default date filters to 1 month back and 1 mo…
Browse files Browse the repository at this point in the history
…nth ahead #1503
  • Loading branch information
olatechpro committed Dec 20, 2023
1 parent f6626f0 commit 9469b3f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
12 changes: 6 additions & 6 deletions modules/content-overview/content-overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -864,11 +864,11 @@ public function update_user_filters()
}

if (! $user_filters['start_date']) {
$user_filters['start_date'] = date('Y-m-d'); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
$user_filters['start_date'] = date('Y-m-d', strtotime('-30 days')); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
}

if (! $user_filters['end_date']) {
$user_filters['end_date'] = date('Y-m-d', strtotime($user_filters['start_date'] . ' +10 day'));
$user_filters['end_date'] = date('Y-m-d', strtotime($user_filters['start_date'] . ' +30 day'));
}

$user_filters = apply_filters('PP_Content_Overview_filter_values', $user_filters, $current_user_filters);
Expand Down Expand Up @@ -914,13 +914,13 @@ public function handle_form_date_range_change()

$date_format = 'Y-m-d';
$user_filters['start_date'] = $use_today_as_start_date
? current_time($date_format)
? date($date_format, strtotime('-30 days'))
: date($date_format, strtotime(sanitize_text_field($_REQUEST['pp-content-overview-start-date_hidden']))); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date

$user_filters['end_date'] = $_REQUEST['pp-content-overview-end-date_hidden'];

if ($use_today_as_start_date || (empty(trim($user_filters['end_date']))) || (strtotime($user_filters['start_date']) > strtotime($user_filters['end_date']))) {
$user_filters['end_date'] = date($date_format, strtotime($user_filters['start_date'] . ' +10 day'));
$user_filters['end_date'] = date($date_format, strtotime($user_filters['start_date'] . ' +30 day'));
}

$this->update_user_meta($current_user->ID, self::USERMETA_KEY_PREFIX . 'filters', $user_filters);
Expand Down Expand Up @@ -1165,8 +1165,8 @@ class="button-secondary button"/>
} ?>
<?php
$date_format = 'Y-m-d';
$reset_start_date = current_time($date_format);
$reset_end_date = date($date_format, strtotime($reset_start_date . ' +10 day'));
$reset_start_date = date($date_format, strtotime('-30 days'));
$reset_end_date = date($date_format, strtotime($reset_start_date . ' +30 day'));

$filtered_start_date = $reset_start_date;
$filtered_start_date_timestamp = strtotime($filtered_start_date);
Expand Down
24 changes: 13 additions & 11 deletions modules/modules-settings/modules-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,19 @@ public function print_configure_view()

<?php if (!defined('PUBLISHPRESS_STATUSES_VERSION')) :?>
<br />
<p>
<?php
printf(
esc_html__('For custom post statuses, install the %1$sPublishPress Statuses%2$s plugin. %3$sLearn more...%4$s', 'publishpress'),
'<a href="https://wordpress.org/plugins/publishpress-statuses" target="_blank">',
'</a>',
'<a href="https://publishpress.com/blog/publishpress-statuses/statuses-launch/" target="_blank">',
'</a>'
);
?>
</p>
<div class="pp-notice">
<p>
<?php
printf(
esc_html__('For custom post statuses, install the %1$sPublishPress Statuses%2$s plugin. %3$sLearn more...%4$s', 'publishpress'),
'<a href="https://wordpress.org/plugins/publishpress-statuses" target="_blank">',
'</a>',
'<a href="https://publishpress.com/blog/publishpress-statuses/statuses-launch/" target="_blank">',
'</a>'
);
?>
</p>
</div>
<?php endif;?>
</td>
</tr>
Expand Down

0 comments on commit 9469b3f

Please sign in to comment.