From 05f51d103a91a02ae8332bf78744f3e4d67021e7 Mon Sep 17 00:00:00 2001
From: Andreas Brain
Date: Wed, 27 Feb 2019 12:23:58 +0100
Subject: [PATCH 1/5] Neueste WordPress-Version ist 5.1
---
.travis.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index db5e1e14..0981693f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,6 +18,7 @@ env:
- WP_VERSION=4.8.8 WP_MULTISITE=0
- WP_VERSION=4.9.9 WP_MULTISITE=0
- WP_VERSION=5.0.3 WP_MULTISITE=0
+ - WP_VERSION=5.1 WP_MULTISITE=0
- WP_VERSION=nightly WP_MULTISITE=0
stages:
@@ -46,7 +47,7 @@ jobs:
script: ./vendor/bin/phpunit --no-coverage --exclude-group unittests
- stage: validate
name: 'Latest versions'
- env: WP_VERSION=5.0.3 WP_MULTISITE=0
+ env: WP_VERSION=5.1 WP_MULTISITE=0
php: '7.3'
before_install: composer require phpunit/phpunit:5.7.* --dev
before_script:
From c0587c8d5b8035ddb8f791dc94ef6e3c2f7f2d7e Mon Sep 17 00:00:00 2001
From: Andreas Brain
Date: Wed, 27 Feb 2019 22:08:15 +0100
Subject: [PATCH 2/5] =?UTF-8?q?Links=20f=C3=BCr=20PATHINFO-Permalinks=20wu?=
=?UTF-8?q?rden=20nicht=20korrekt=20generiert?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.travis.yml | 8 +++++++
src/PermalinkController.php | 13 +++++++++--
tests/PermalinkControllerTest.php | 39 +++++++++++++++++++++++++++++++
tests/bootstrap.php | 6 +++++
4 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 0981693f..aa7b05bb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -58,6 +58,14 @@ jobs:
script: ./vendor/bin/phpunit
after_script:
- ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT
+ - stage: test
+ name: 'Latest versions, pretty permalinks'
+ env: WP_VERSION=5.1 WP_MULTISITE=0 WP_TESTS_PERMALINK=PRETTY
+ php: '7.3'
+ - stage: test
+ name: 'Latest versions, PATHINFO permalinks'
+ env: WP_VERSION=5.1 WP_MULTISITE=0 WP_TESTS_PERMALINK=PATHINFO
+ php: '7.3'
matrix:
exclude:
diff --git a/src/PermalinkController.php b/src/PermalinkController.php
index 3ac3325b..4ad8e2f3 100644
--- a/src/PermalinkController.php
+++ b/src/PermalinkController.php
@@ -47,7 +47,7 @@ public function addRewriteRules(Report $report)
$this->reportRewriteSlug = $report->rewriteSlug;
// add rules for paginated year archive
- $base = ltrim($wp_rewrite->front, '/') . $this->reportRewriteSlug;
+ $base = $this->getRewriteBase();
add_rewrite_rule(
$base . '/(\d{4})/page/(\d{1,})/?$',
'index.php?post_type=einsatz&year=$matches[1]&paged=$matches[2]',
@@ -140,6 +140,15 @@ public function filterRequest($queryvars)
return $this->modifyQueryVars($queryvars, $this->reportPermalink);
}
+ /**
+ * @return string
+ */
+ public function getRewriteBase()
+ {
+ global $wp_rewrite;
+ return ltrim($wp_rewrite->front, '/') . $this->reportRewriteSlug;
+ }
+
/**
* Returns the regular expression necessary to disassemble the selector (part of the URL specifying a single report)
*
@@ -160,7 +169,7 @@ public function getSelectorRegEx($permalink)
*/
public function getPermalink($selector)
{
- $path = sprintf('%s/%s', $this->reportRewriteSlug, $selector);
+ $path = sprintf('%s/%s', $this->getRewriteBase(), $selector);
return home_url(user_trailingslashit($path));
}
diff --git a/tests/PermalinkControllerTest.php b/tests/PermalinkControllerTest.php
index db100d16..73a8f1eb 100644
--- a/tests/PermalinkControllerTest.php
+++ b/tests/PermalinkControllerTest.php
@@ -24,6 +24,45 @@ public function testBuildSelector()
$this->assertEquals("prefix/$report->post_name/suffix", $controller->buildSelector($report, 'prefix/%postname%/suffix'));
}
+ public function testGetPermalink()
+ {
+ $controller = new PermalinkController();
+ $report = $this->createMock('abrain\Einsatzverwaltung\Types\Report');
+ $report->rewriteSlug = 'customrewriteslug';
+ $controller->addRewriteRules($report);
+
+ if (getenv('WP_TESTS_PERMALINK') === 'PRETTY') {
+ $this->assertEquals(
+ 'http://example.org/customrewriteslug/some-unique-selector/',
+ $controller->getPermalink('some-unique-selector')
+ );
+ } elseif (getenv('WP_TESTS_PERMALINK') === 'PATHINFO') {
+ $this->assertEquals(
+ 'http://example.org/index.php/customrewriteslug/some-unique-selector/',
+ $controller->getPermalink('some-unique-selector')
+ );
+ }
+ }
+
+ /**
+ * @group unittests
+ */
+ public function testGetRewriteBase()
+ {
+ $controller = new PermalinkController();
+ $report = $this->createMock('abrain\Einsatzverwaltung\Types\Report');
+ $report->rewriteSlug = 'customrewriteslug';
+ $controller->addRewriteRules($report);
+
+ if (getenv('WP_TESTS_PERMALINK') === 'PRETTY') {
+ $this->assertEquals('customrewriteslug', $controller->getRewriteBase());
+ } elseif (getenv('WP_TESTS_PERMALINK') === 'PATHINFO') {
+ $this->assertEquals('index.php/customrewriteslug', $controller->getRewriteBase());
+ } else {
+ $this->assertEquals('', $controller->getRewriteBase());
+ }
+ }
+
/**
* @dataProvider queryVarTests
* @param string $input
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 1c3eb3fa..0ffd87dd 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -17,6 +17,12 @@
// Zeitzone setzen
update_option('timezone_string', 'Europe/Berlin');
date_default_timezone_set('Europe/Berlin');
+
+ if (getenv('WP_TESTS_PERMALINK') === 'PRETTY') {
+ update_option('permalink_structure', '/%year%/%monthnum%/%postname%/');
+ } elseif (getenv('WP_TESTS_PERMALINK') === 'PATHINFO') {
+ update_option('permalink_structure', '/index.php/%year%/%monthnum%/%postname%/');
+ }
});
require $_tests_dir . '/includes/bootstrap.php';
From 4e74096ee248f36477e00d937b899b1d3532a17a Mon Sep 17 00:00:00 2001
From: Andreas Brain
Date: Wed, 27 Feb 2019 22:18:29 +0100
Subject: [PATCH 3/5] =?UTF-8?q?=C3=9Cberspringe=20Test,=20wenn=20PHPUnit?=
=?UTF-8?q?=204.8=20verwendet=20wird?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
tests/PermalinkControllerTest.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/PermalinkControllerTest.php b/tests/PermalinkControllerTest.php
index 73a8f1eb..80a3051f 100644
--- a/tests/PermalinkControllerTest.php
+++ b/tests/PermalinkControllerTest.php
@@ -24,6 +24,11 @@ public function testBuildSelector()
$this->assertEquals("prefix/$report->post_name/suffix", $controller->buildSelector($report, 'prefix/%postname%/suffix'));
}
+ /**
+ * @group unittests
+ * It's not completely a unit test, but that way this test is skipped for the old PHP/PHPUnit version which doesn't
+ * support createMock().
+ */
public function testGetPermalink()
{
$controller = new PermalinkController();
From 2cdeb56e062a0eea258a0177fa0cec2825068a38 Mon Sep 17 00:00:00 2001
From: Andreas Brain
Date: Wed, 27 Feb 2019 22:58:41 +0100
Subject: [PATCH 4/5] =?UTF-8?q?Option=20zum=20Deaktivieren=20des=20Block-E?=
=?UTF-8?q?ditors=20hinzugef=C3=BCgt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Admin/Initializer.php | 17 +++++++++++++++++
src/Settings/Pages/Advanced.php | 20 ++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/src/Admin/Initializer.php b/src/Admin/Initializer.php
index 532c9edb..66c81efb 100644
--- a/src/Admin/Initializer.php
+++ b/src/Admin/Initializer.php
@@ -9,6 +9,7 @@
use abrain\Einsatzverwaltung\Options;
use abrain\Einsatzverwaltung\PermalinkController;
use abrain\Einsatzverwaltung\Settings\MainPage;
+use abrain\Einsatzverwaltung\Types\Report;
use abrain\Einsatzverwaltung\Utilities;
/**
@@ -34,6 +35,7 @@ public function __construct(Data $data, Options $options, Utilities $utilities,
add_filter('dashboard_glance_items', array($this, 'addReportsToDashboard'));
add_filter('plugin_row_meta', array($this, 'pluginMetaLinks'), 10, 2);
add_filter("plugin_action_links_{$pluginBasename}", array($this,'addActionLinks'));
+ add_filter('use_block_editor_for_post_type', array($this, 'useBlockEditorForReports'), 10, 2);
$reportListTable = new ReportListTable();
add_filter('manage_edit-einsatz_columns', array($reportListTable, 'filterColumnsEinsatz'));
@@ -216,4 +218,19 @@ public function displayAdminNotices()
echo 'Anpassung durchführen
';
}
}
+
+ /**
+ * @param bool $useBlockEditor
+ * @param string $postType
+ *
+ * @return bool
+ */
+ public function useBlockEditorForReports($useBlockEditor, $postType)
+ {
+ if ($postType === Report::SLUG && get_option('einsatz_disable_blockeditor', '0') === '1') {
+ return false;
+ }
+
+ return $useBlockEditor;
+ }
}
diff --git a/src/Settings/Pages/Advanced.php b/src/Settings/Pages/Advanced.php
index 33548ff7..9d817a09 100644
--- a/src/Settings/Pages/Advanced.php
+++ b/src/Settings/Pages/Advanced.php
@@ -61,6 +61,13 @@ public function addSettingsFields()
$this->settingsApiPage,
'einsatzvw_settings_advreport'
);
+ add_settings_field(
+ 'einsatzvw_advreport_gutenberg',
+ 'Gutenberg',
+ array($this, 'echoFieldGutenberg'),
+ $this->settingsApiPage,
+ 'einsatzvw_settings_advreport'
+ );
}
public function addSettingsSections()
@@ -144,6 +151,14 @@ public function echoFieldCoreFeatures()
echo '';
}
+ public function echoFieldGutenberg()
+ {
+ echo '';
+ }
+
public function echoFieldUrlStructure()
{
echo '