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 '
'; + $this->echoSettingsCheckbox('einsatz_disable_blockeditor', 'Block-Editor für Einsatzberichte deaktivieren'); + echo '

Diese Einstellung betrifft nur WordPress 5.0 und neuer.

'; + echo '
'; + } + public function echoFieldUrlStructure() { echo '
'; @@ -228,5 +243,10 @@ public function registerSettings() 'einsatz_support_posttag', array('\abrain\Einsatzverwaltung\Utilities', 'sanitizeCheckbox') ); + register_setting( + 'einsatzvw_settings_advanced', + 'einsatz_disable_blockeditor', + array('\abrain\Einsatzverwaltung\Utilities', 'sanitizeCheckbox') + ); } } From 7c67deeee6003ded81c50b17659451cfcf79e4d5 Mon Sep 17 00:00:00 2001 From: Andreas Brain Date: Wed, 27 Feb 2019 23:02:53 +0100 Subject: [PATCH 5/5] Version 1.5.1 --- src/Core.php | 2 +- src/einsatzverwaltung.php | 2 +- src/readme.txt | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Core.php b/src/Core.php index 5613796c..eedbd8f0 100644 --- a/src/Core.php +++ b/src/Core.php @@ -11,7 +11,7 @@ */ class Core { - const VERSION = '1.5.0'; + const VERSION = '1.5.1'; const DB_VERSION = 40; /** diff --git a/src/einsatzverwaltung.php b/src/einsatzverwaltung.php index 80261c37..620f0a42 100644 --- a/src/einsatzverwaltung.php +++ b/src/einsatzverwaltung.php @@ -3,7 +3,7 @@ Plugin Name: Einsatzverwaltung Plugin URI: https://einsatzverwaltung.abrain.de Description: Verwaltung und Darstellung von Einsatzberichten der Feuerwehr und anderer Hilfsorganisationen -Version: 1.5.0 +Version: 1.5.1 Author: Andreas Brain Author URI: https://www.abrain.de License: GPLv2 diff --git a/src/readme.txt b/src/readme.txt index 325bcfbf..879a63fb 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -5,7 +5,7 @@ Tags: Feuerwehr, Hilfsorganisation, Öffentlichkeitsarbeit Requires at least: 4.7.0 Tested up to: 5.1 Requires PHP: 5.3.0 -Stable tag: 1.5.0 +Stable tag: 1.5.1 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -55,6 +55,10 @@ Nein, mehr gibt es [hier](https://einsatzverwaltung.abrain.de/faq/). == Changelog == += 1.5.1 = +* URLs für PATHINFO-Permalinks (beginnen mit /index.php/) repariert +* Block-Editor kann für Einsatzberichte deaktiviert werden + = 1.5.0 = * Grundlegende Unterstützung für den neuen Blockeditor * API teilweise aktiviert