Skip to content

Commit

Permalink
Prevent duplicate call for filters on page load #1754
Browse files Browse the repository at this point in the history
  • Loading branch information
olatechpro committed Sep 5, 2024
1 parent 40d4a1c commit 724da55
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/calendar/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,12 @@ public function get_filters()
*/
public function update_user_filters($request_filter = [])
{
global $pp_calendar_user_filters;

if (is_array($pp_calendar_user_filters)) {
return $pp_calendar_user_filters;
}

$user_filters = [
'weeks' => '',
'start_date' => '',
Expand Down Expand Up @@ -1330,6 +1336,8 @@ public function update_user_filters($request_filter = [])

$this->update_user_meta($current_user->ID, self::USERMETA_KEY_PREFIX . 'filters', $user_filters);

$pp_calendar_user_filters = $user_filters;

return $user_filters;
}

Expand Down
14 changes: 14 additions & 0 deletions modules/content-board/content-board.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,12 @@ public function get_selected_post_types()
*/
public function update_user_filters()
{
global $pp_content_board_user_filters;

if (is_array($pp_content_board_user_filters)) {
return $pp_content_board_user_filters;
}

$current_user = wp_get_current_user();

$user_filters = [
Expand Down Expand Up @@ -697,6 +703,8 @@ public function update_user_filters()

$this->update_user_meta($current_user->ID, self::USERMETA_KEY_PREFIX . 'filters', $user_filters);

$pp_content_board_user_filters = $user_filters;

return $user_filters;
}

Expand Down Expand Up @@ -3200,6 +3208,12 @@ public function posts_where_range($where = '')
*/
public function get_user_filters()
{
global $pp_content_board_user_filters;

if (is_array($pp_content_board_user_filters)) {
return $pp_content_board_user_filters;
}

$current_user = wp_get_current_user();
$user_filters = [];
$user_filters = $this->get_user_meta($current_user->ID, self::USERMETA_KEY_PREFIX . 'filters', true);
Expand Down
14 changes: 14 additions & 0 deletions modules/content-overview/content-overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,12 @@ public function get_selected_post_types()
*/
public function update_user_filters()
{
global $pp_content_overview_user_filters;

if (is_array($pp_content_overview_user_filters)) {
return $pp_content_overview_user_filters;
}

$current_user = wp_get_current_user();

$user_filters = [
Expand Down Expand Up @@ -716,6 +722,8 @@ public function update_user_filters()

$this->update_user_meta($current_user->ID, self::USERMETA_KEY_PREFIX . 'filters', $user_filters);

$pp_content_overview_user_filters = $user_filters;

return $user_filters;
}

Expand Down Expand Up @@ -3072,6 +3080,12 @@ public function column_post_title($post)
*/
public function get_user_filters()
{
global $pp_content_overview_user_filters;

if (is_array($pp_content_overview_user_filters)) {
return $pp_content_overview_user_filters;
}

$current_user = wp_get_current_user();
$user_filters = [];
$user_filters = $this->get_user_meta($current_user->ID, self::USERMETA_KEY_PREFIX . 'filters', true);
Expand Down

0 comments on commit 724da55

Please sign in to comment.