Skip to content

Commit

Permalink
Fix old download filtering urls (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
doekenorg authored Jun 7, 2023
1 parent 0e85c5e commit c01ec01
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions gfexcel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: GravityExport Lite
* Version: 2.0.2
* Version: 2.0.3
* Plugin URI: https://gfexcel.com
* Description: Export all Gravity Forms entries to Excel (.xlsx) or CSV via a secret shareable URL.
* Author: GravityKit
Expand Down Expand Up @@ -29,7 +29,7 @@
}

if ( ! defined( 'GFEXCEL_PLUGIN_VERSION' ) ) {
define( 'GFEXCEL_PLUGIN_VERSION', '2.0.2' );
define( 'GFEXCEL_PLUGIN_VERSION', '2.0.3' );
}

if ( ! defined( 'GFEXCEL_MIN_PHP_VERSION' ) ) {
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: Gravity Forms, GravityForms, Excel, Export, Download, Entries, CSV
Requires at least: 4.0
Requires PHP: 7.2
Tested up to: 6.2
Stable tag: 2.0.2
Stable tag: 2.0.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -256,7 +256,11 @@ You can hide a row by adding a hook. Checkout this example:

== Changelog ==

= 2.0.2 on June 5,2023 =
= 2.0.3 on June 7, 2023 =

* Bugfix: Filtering on URL's didn't work on the old download URL structure anymore.

= 2.0.2 on June 5, 2023 =

* Bugfix: Attachments could have the wrong fields.

Expand Down
25 changes: 12 additions & 13 deletions src/Action/FilterRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,18 @@ public function getQueryVars($vars)
* @param array $query_vars the query vars.
* @return array the query vars.
*/
public function request($query_vars)
{
// only respond to a GFexcel URL.
if (!isset($query_vars[GFExcel::KEY_ACTION]) || $query_vars[GFExcel::KEY_ACTION] !== GFExcel::$slug) {
return $query_vars;
}

$this->parseDates($query_vars);
$this->parseFilters(\rgar($query_vars, self::FILTER, ''));
$this->parseEntry(\rgar($query_vars, self::ENTRY));

return $query_vars;
}
public function request( $query_vars ) {
// only respond to a GFexcel URL.
if ( ! in_array( $query_vars[ GFExcel::KEY_ACTION ] ?? null, GFExcel::$endpoints, true ) ) {
return $query_vars;
}

$this->parseDates( $query_vars );
$this->parseFilters( \rgar( $query_vars, self::FILTER, '' ) );
$this->parseEntry( \rgar( $query_vars, self::ENTRY ) );

return $query_vars;
}

/**
* Sets the search criteria on the hook for filtering.
Expand Down
10 changes: 5 additions & 5 deletions src/GFExcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class GFExcel
* @since 1.0.0
* @var string
*/
private $endpoints = array(
public static $endpoints = [
'gf-entries-in-excel',
'gravityexport-lite',
'gravityexport',
);
];

public const KEY_HASH = 'gfexcel_hash';

Expand Down Expand Up @@ -246,7 +246,7 @@ public function addPermalinkRules() {
$rewrite_rules = get_option( 'rewrite_rules' );
$flush_rules = false;

foreach ( $this->endpoints as $endpoint ) {
foreach ( self::$endpoints as $endpoint ) {

$endpoint_regex = '^' . $endpoint . '/(.+)/?$';

Expand Down Expand Up @@ -281,7 +281,7 @@ public function request($query_vars)
return $query_vars;
}

if ( ! in_array( $query_vars[ self::KEY_ACTION ], $this->endpoints, true ) ) {
if ( ! in_array( $query_vars[ self::KEY_ACTION ], self::$endpoints, true ) ) {
return $query_vars;
}

Expand Down Expand Up @@ -403,7 +403,7 @@ public function robotsTxt($output)
$path = (!empty($site_url['path'])) ? $site_url['path'] : '';

$lines = '';
foreach( $this->endpoints as $endpoint ) {
foreach( self::$endpoints as $endpoint ) {
$lines .= sprintf( 'Disallow: %s/%s/', esc_attr( $path ), $endpoint ) . "\n";
}

Expand Down

0 comments on commit c01ec01

Please sign in to comment.