Skip to content

Commit 2923aef

Browse files
FJiskraFilip Jiskra
andauthored
Pes 470 url fixes (#113)
* PES-470: url fixes * PES-470: url fixes - version change * PES-470: url fixes - request factory update * PES-470: url fixes - request factory update * PES-470: url fixes - CR * PES-470: url fixes - CR * PES-470: url fixes - version fix Co-authored-by: Filip Jiskra <[email protected]>
1 parent fd6a4b7 commit 2923aef

File tree

11 files changed

+49
-29
lines changed

11 files changed

+49
-29
lines changed

packetery/languages/packetery-cs_CZ.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is distributed under the GNU General Public License v3.0.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Packeta 1.0.1\n"
5+
"Project-Id-Version: Packeta 1.0.2\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/packetery\n"
77
"POT-Creation-Date: 2021-11-24T11:09:52+01:00\n"
88
"PO-Revision-Date: 2021-11-24 11:13+0100\n"

packetery/languages/packetery-en_US.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is distributed under the GNU General Public License v3.0.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Packeta 1.0.1\n"
5+
"Project-Id-Version: Packeta 1.0.2\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/packetery\n"
77
"POT-Creation-Date: 2021-11-24T11:09:52+01:00\n"
88
"PO-Revision-Date: 2021-11-24 11:13+0100\n"

packetery/languages/packetery.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is distributed under the GNU General Public License v3.0.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Packeta 1.0.1\n"
5+
"Project-Id-Version: Packeta 1.0.2\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/packetery\n"
77
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
88
"Language-Team: LANGUAGE <[email protected]>\n"

packetery/packetery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Plugin Name: Packeta
1010
* Description: With the help of our official plugin, You can choose pickup points of Packeta and it's external carriers in all of Europe, or utilize address delivery for 25 countries in the European Union, straight from the cart in Your eshop. You can submit all of Your orders to Packeta with one click.
11-
* Version: 1.0.1
11+
* Version: 1.0.2
1212
* Author: Zásilkovna s.r.o.
1313
* Author URI: https://www.zasilkovna.cz/
1414
* Text Domain: packetery

packetery/readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: packeta
33
Tags: WooCommerce, shipping
44
Requires at least: 5.3
55
Tested up to: 5.8.1
6-
Stable tag: 1.0.1
6+
Stable tag: 1.0.2
77
Requires PHP: 7.2
88
License: GPLv3
99
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -71,6 +71,9 @@ We are constantly working on adding new features. You can find a list of feature
7171
Please contact us at [email protected] .
7272

7373
== Changelog ==
74+
= 1.0.2 =
75+
* Fixed: broken relative URLs in multiple places
76+
7477
= 1.0.1 =
7578
* Fixed: user no longer sees messages from other sessions
7679
* Updated: logger no longer deletes older records

packetery/src/Packetery/Module/Carrier/CountryListingPage.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function render(): void {
7070
$carriersUpdateParams = [];
7171
if ( $this->httpRequest->getQuery( 'update_carriers' ) ) {
7272
set_transient( 'packetery_run_update_carriers', true );
73-
if ( wp_safe_redirect( $this->httpRequest->getUrl()->withQueryParameter( 'update_carriers', null )->getRelativeUrl() ) ) {
73+
if ( wp_safe_redirect( add_query_arg( [ 'page' => OptionsPage::SLUG ], get_admin_url( null, 'admin.php' ) ) ) ) {
7474
exit;
7575
}
7676
}
@@ -83,7 +83,13 @@ public function render(): void {
8383
delete_transient( 'packetery_run_update_carriers' );
8484
}
8585

86-
$carriersUpdateParams['link'] = $this->httpRequest->getUrl()->withQueryParameter( 'update_carriers', '1' )->getRelativeUrl();
86+
$carriersUpdateParams['link'] = add_query_arg(
87+
[
88+
'page' => OptionsPage::SLUG,
89+
'update_carriers' => '1',
90+
],
91+
get_admin_url( null, 'admin.php' )
92+
);
8793
$carriersUpdateParams['lastUpdate'] = $this->getLastUpdate();
8894

8995
$countries = $this->getActiveCountries();
@@ -112,7 +118,13 @@ private function getActiveCountries(): array {
112118
$countriesFinal[] = [
113119
'code' => $country,
114120
'name' => \Locale::getDisplayRegion( '-' . $country, get_locale() ),
115-
'url' => get_admin_url( null, 'admin.php?page=packeta-country&code=' . $country ),
121+
'url' => add_query_arg(
122+
[
123+
'page' => OptionsPage::SLUG,
124+
'code' => $country,
125+
],
126+
get_admin_url( null, 'admin.php' )
127+
),
116128
];
117129
}
118130

packetery/src/Packetery/Module/Carrier/OptionsPage.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
class OptionsPage {
2727

2828
public const FORM_FIELD_NAME = 'name';
29+
public const SLUG = 'packeta-country';
2930

3031
/**
3132
* PacketeryLatte_engine.
@@ -104,7 +105,7 @@ public function register(): void {
104105
__( 'Carrier settings', 'packetery' ),
105106
__( 'Carrier settings', 'packetery' ),
106107
'manage_options',
107-
'packeta-country',
108+
self::SLUG,
108109
array(
109110
$this,
110111
'render',
@@ -124,7 +125,6 @@ private function createForm( array $carrierData ): Form {
124125
$optionId = Checkout::CARRIER_PREFIX . $carrierData['id'];
125126

126127
$form = $this->formFactory->create( $optionId );
127-
$form->setAction( $this->httpRequest->getUrl()->getRelativeUrl() );
128128

129129
$form->addCheckbox(
130130
'active',
@@ -213,7 +213,16 @@ public function updateOptions( Form $form ): void {
213213
update_option( Checkout::CARRIER_PREFIX . $options['id'], $options );
214214
$this->messageManager->flash_message( __( 'settingsSaved', 'packetery' ) );
215215

216-
if ( wp_safe_redirect( $this->httpRequest->getUrl()->getRelativeUrl(), 303 ) ) {
216+
if ( wp_safe_redirect(
217+
add_query_arg(
218+
[
219+
'page' => self::SLUG,
220+
'code' => $this->httpRequest->getQuery( 'code' ),
221+
],
222+
get_admin_url( null, 'admin.php' )
223+
),
224+
303
225+
) ) {
217226
exit;
218227
}
219228
}

packetery/src/Packetery/Module/Options/Exporter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
class Exporter {
2323

2424
public const OPTION_LAST_SETTINGS_EXPORT = 'packetery_last_settings_export';
25+
public const ACTION_EXPORT_SETTINGS = 'export-settings';
2526

2627
/**
2728
* Http request.
@@ -87,7 +88,7 @@ public function __construct(
8788
public function outputExportTxt(): void {
8889
if (
8990
$this->httpRequest->getQuery( 'page' ) !== 'packeta-options' ||
90-
$this->httpRequest->getQuery( 'action' ) !== 'export-settings'
91+
$this->httpRequest->getQuery( 'action' ) !== self::ACTION_EXPORT_SETTINGS
9192
) {
9293
return;
9394
}

packetery/src/Packetery/Module/Options/Page.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Packetery\Module\FormFactory;
1313
use PacketeryLatte\Engine;
1414
use PacketeryNette\Forms\Form;
15-
use PacketeryNette\Http;
1615

1716
/**
1817
* Class Page
@@ -49,26 +48,17 @@ class Page {
4948
*/
5049
private $formFactory;
5150

52-
/**
53-
* Http request.
54-
*
55-
* @var Http\Request
56-
*/
57-
private $httpRequest;
58-
5951
/**
6052
* Plugin constructor.
6153
*
62-
* @param Engine $latte_engine PacketeryLatte_engine.
63-
* @param Provider $optionsProvider Options provider.
64-
* @param FormFactory $formFactory Form factory.
65-
* @param Http\Request $httpRequest Http request.
54+
* @param Engine $latte_engine PacketeryLatte_engine.
55+
* @param Provider $optionsProvider Options provider.
56+
* @param FormFactory $formFactory Form factory.
6657
*/
67-
public function __construct( Engine $latte_engine, Provider $optionsProvider, FormFactory $formFactory, Http\Request $httpRequest ) {
58+
public function __construct( Engine $latte_engine, Provider $optionsProvider, FormFactory $formFactory ) {
6859
$this->latte_engine = $latte_engine;
6960
$this->optionsProvider = $optionsProvider;
7061
$this->formFactory = $formFactory;
71-
$this->httpRequest = $httpRequest;
7262
}
7363

7464
/**
@@ -211,7 +201,13 @@ public function render(): void {
211201

212202
$latteParams['apiPasswordLink'] = trim( $this->latte_engine->renderToString( PACKETERY_PLUGIN_DIR . '/template/options/help-block-link.latte', [ 'href' => 'https://client.packeta.com/support' ] ) );
213203
$latteParams['senderLink'] = trim( $this->latte_engine->renderToString( PACKETERY_PLUGIN_DIR . '/template/options/help-block-link.latte', [ 'href' => 'https://client.packeta.com/senders' ] ) );
214-
$latteParams['exportLink'] = $this->httpRequest->getUrl()->withQueryParameter( 'action', 'export-settings' )->getRelativeUrl();
204+
$latteParams['exportLink'] = add_query_arg(
205+
[
206+
'page' => 'packeta-options',
207+
'action' => Exporter::ACTION_EXPORT_SETTINGS,
208+
],
209+
get_admin_url( null, 'admin.php' )
210+
);
215211

216212
$lastExport = null;
217213
$lastExportOption = get_option( Exporter::OPTION_LAST_SETTINGS_EXPORT );

packetery/src/Packetery/Module/Order/LabelPrint.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ public function outputLabelsPdf(): void {
215215
*/
216216
public function createForm( int $maxOffset ): Form {
217217
$form = $this->formFactory->create();
218-
$form->setAction( $this->httpRequest->getUrl()->getRelativeUrl() );
219218

220219
$availableOffsets = [];
221220
for ( $i = 0; $i <= $maxOffset; $i ++ ) {

0 commit comments

Comments
 (0)