Skip to content

Commit

Permalink
Transfer search query params to export link.
Browse files Browse the repository at this point in the history
  • Loading branch information
doekenorg committed Mar 4, 2024
1 parent 8cf066f commit 8ab3cf1
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions includes/widgets/class-gravityview-widget-export-link.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class GravityView_Widget_Export_Link extends Widget {
*
* @since $ver$
*/
public const WIDGET_ID = 'export_link_widget';
public const WIDGET_ID = 'export_link';

/**
* A short description.
Expand Down Expand Up @@ -121,7 +121,7 @@ public function __construct() {
public function hide_description_picker( array $items, GravityView_Admin_View_Item $view_item ): array {
if (
! $view_item instanceof GravityView_Admin_View_Widget
|| rgar( $items[0], 'value' ) !== $this->widget_description
|| rgar( $items[0] ?? [], 'value' ) !== $this->widget_description
) {
return $items;
}
Expand All @@ -136,6 +136,8 @@ public function hide_description_picker( array $items, GravityView_Admin_View_It
* @since $ver$
*/
public function render_frontend( $widget_args, $content = '', $context = '' ): void {
global $wp_query;

if (
! $context instanceof Template_Context
|| ! $this->pre_render_frontend( $context )
Expand Down Expand Up @@ -163,11 +165,24 @@ public function render_frontend( $widget_args, $content = '', $context = '' ): v
$use_labels = (bool) rgar( $widget_args, 'use_labels', false );
$classes = (string) rgar( $widget_args, 'classes', '' );

$page_query_params = array_filter(
$_GET,
static function ( string $value, string $key ): bool {
return 'mode' === $key || preg_match( '/^filter_?/i', $key );
},
ARRAY_FILTER_USE_BOTH
);

$rest_url = add_query_arg(
[
'_nonce' => $nonce,
'use_labels' => $use_labels,
],
array_filter(
array_merge(
$page_query_params,
[
'_nonce' => $nonce,
'use_labels' => $use_labels,
]
)
),
sprintf( '%sgravityview/v1/views/%d/entries.%s', get_rest_url(), $view->ID, $type )
);

Expand Down

0 comments on commit 8ab3cf1

Please sign in to comment.