From 2c65715a2ad7b1da5c143d997c24cb8e2a320036 Mon Sep 17 00:00:00 2001 From: Merlijn van Lent Date: Mon, 23 Sep 2024 11:10:50 +0200 Subject: [PATCH] feat(feedback): Added wp plugin repo feedback, version bump. --- .gitignore | 1 + Includes/Pages/LastWeek.php | 2 +- Includes/Pages/Month.php | 8 ++++++-- Includes/Pages/Sitemap.php | 8 ++++++-- Includes/Pages/ThisWeek.php | 2 +- Includes/Pages/Today.php | 2 +- Includes/Pages/Year.php | 8 ++++++-- Includes/Pages/Yesterday.php | 2 +- Includes/PagesRepository.php | 10 +++++----- Includes/Plugin.php | 6 +++--- Includes/RewriteRules.php | 20 ++++++++++---------- Includes/Settings.php | 4 ++-- Includes/SettingsPage.php | 29 +++++++++++++++++++++-------- languages/vo-html-sitemap-nl_NL.mo | Bin 1375 -> 1317 bytes languages/vo-html-sitemap-nl_NL.po | 28 ++++++++++++++-------------- languages/vo-html-sitemap.pot | 25 +++++++++++-------------- readme.txt | 8 ++++---- templates/admin/settings.php | 26 ++++++++++++++++---------- templates/sitemap-day.php | 8 +++++--- templates/sitemap-month.php | 8 +++++--- templates/sitemap-range.php | 6 ++++-- templates/sitemap-year.php | 6 ++++-- templates/sitemap.php | 4 +++- vo-html-sitemap.php | 10 ++++++---- 24 files changed, 136 insertions(+), 95 deletions(-) diff --git a/.gitignore b/.gitignore index b9e244d..e19b37e 100644 --- a/.gitignore +++ b/.gitignore @@ -145,3 +145,4 @@ fabric.properties /dist/ /node_modules/ +/vo-html-sitemap.zip diff --git a/Includes/Pages/LastWeek.php b/Includes/Pages/LastWeek.php index daa1c3d..97d0219 100644 --- a/Includes/Pages/LastWeek.php +++ b/Includes/Pages/LastWeek.php @@ -42,7 +42,7 @@ public function getItems(array $parameters = []): array public function getLabel(): string { - return __('Last week', 'vo-html-sitemap'); + return __('Last week', 'vohtmlsitemap'); } public function getUrl(): string diff --git a/Includes/Pages/Month.php b/Includes/Pages/Month.php index d1416a9..49b7392 100644 --- a/Includes/Pages/Month.php +++ b/Includes/Pages/Month.php @@ -32,8 +32,12 @@ public function getItems(array $parameters = []): array $qh = QueryHelper::getInstance(); - $sql = "SELECT DAY(post_date) AS day FROM {$qh->wpdb->posts} WHERE YEAR(post_date) = %d AND MONTH(post_date) = %d AND post_type IN ({$qh->getPostTypesPreparableCount()}) AND post_status = 'publish' GROUP BY day ORDER BY day ASC"; - $days = $qh->query($sql, array_merge([$this->year->number, $this->number], $qh->getPostTypesPreparableValues())); + $days = $qh->wpdb->get_results( + $qh->wpdb->prepare( + "SELECT DAY(post_date) AS day FROM {$qh->wpdb->posts} WHERE YEAR(post_date) = %d AND MONTH(post_date) = %d AND post_type IN ({$qh->getPostTypesPreparableCount()}) AND post_status = 'publish' GROUP BY day ORDER BY day ASC", + array_merge([$this->year->number, $this->number], $qh->getPostTypesPreparableValues()) + ) + ); return $this->items = array_map(fn($day) => new Day($this->year, $this, $day->day), $days); } diff --git a/Includes/Pages/Sitemap.php b/Includes/Pages/Sitemap.php index ce96c5b..fed559f 100644 --- a/Includes/Pages/Sitemap.php +++ b/Includes/Pages/Sitemap.php @@ -33,8 +33,12 @@ public function getItems(array $parameters = []): array $qh = QueryHelper::getInstance(); - $sql = "SELECT YEAR(post_date) AS year FROM {$qh->wpdb->posts} WHERE post_type IN ({$qh->getPostTypesPreparableCount()}) AND post_status = 'publish' GROUP BY year ORDER BY year DESC"; - $years = $qh->query($sql, $qh->getPostTypesPreparableValues()); + $years = $qh->wpdb->get_results( + $qh->wpdb->prepare( + "SELECT YEAR(post_date) AS year FROM {$qh->wpdb->posts} WHERE post_type IN ({$qh->getPostTypesPreparableCount()}) AND post_status = 'publish' GROUP BY year ORDER BY year DESC", + $qh->getPostTypesPreparableValues() + ) + ); return $this->items = array_map(fn($year) => new Year($year->year), $years); } diff --git a/Includes/Pages/ThisWeek.php b/Includes/Pages/ThisWeek.php index 5e6f135..cf3c731 100644 --- a/Includes/Pages/ThisWeek.php +++ b/Includes/Pages/ThisWeek.php @@ -42,7 +42,7 @@ public function getItems(array $parameters = []): array public function getLabel(): string { - return __('This week', 'vo-html-sitemap'); + return __('This week', 'vohtmlsitemap'); } public function getUrl(): string diff --git a/Includes/Pages/Today.php b/Includes/Pages/Today.php index 9468719..23d00f9 100644 --- a/Includes/Pages/Today.php +++ b/Includes/Pages/Today.php @@ -45,7 +45,7 @@ public function getItems(array $parameters = []): array public function getLabel(): string { - return __('Today', 'vo-html-sitemap'); + return __('Today', 'vohtmlsitemap'); } public function getUrl(): string diff --git a/Includes/Pages/Year.php b/Includes/Pages/Year.php index b00d53c..be93e87 100644 --- a/Includes/Pages/Year.php +++ b/Includes/Pages/Year.php @@ -30,8 +30,12 @@ public function getItems(array $parameters = []): array $qh = QueryHelper::getInstance(); - $sql = "SELECT MONTH(post_date) AS month FROM {$qh->wpdb->posts} WHERE YEAR(post_date) = %d AND post_type IN ({$qh->getPostTypesPreparableCount()}) AND post_status = 'publish' GROUP BY month ORDER BY month ASC"; - $months = $qh->query($sql, array_merge([$this->number], $qh->getPostTypesPreparableValues())); + $months = $qh->wpdb->get_results( + $qh->wpdb->prepare( + "SELECT MONTH(post_date) AS month FROM {$qh->wpdb->posts} WHERE YEAR(post_date) = %d AND post_type IN ({$qh->getPostTypesPreparableCount()}) AND post_status = 'publish' GROUP BY month ORDER BY month ASC", + array_merge([$this->number], $qh->getPostTypesPreparableValues()) + ) + ); return $this->items = array_map(fn($month) => new Month($this, $month->month), $months); } diff --git a/Includes/Pages/Yesterday.php b/Includes/Pages/Yesterday.php index 578b921..a25fd46 100644 --- a/Includes/Pages/Yesterday.php +++ b/Includes/Pages/Yesterday.php @@ -45,7 +45,7 @@ public function getItems(array $parameters = []): array public function getLabel(): string { - return __('Yesterday', 'vo-html-sitemap'); + return __('Yesterday', 'vohtmlsitemap'); } public function getUrl(): string diff --git a/Includes/PagesRepository.php b/Includes/PagesRepository.php index ab6a65e..f928c8f 100644 --- a/Includes/PagesRepository.php +++ b/Includes/PagesRepository.php @@ -16,14 +16,14 @@ class PagesRepository { public static function resolve(): ?Page { - if (get_query_var('vo-html-sitemap', false) !== 'true') { + if (get_query_var('vohtmlsitemap', false) !== 'true') { return null; } - $range = get_query_var('vo-html-sitemap-range', false); - $day = get_query_var('vo-html-sitemap-day', false); - $month = get_query_var('vo-html-sitemap-month', false); - $year = get_query_var('vo-html-sitemap-year', false); + $range = get_query_var('vohtmlsitemap-range', false); + $day = get_query_var('vohtmlsitemap-day', false); + $month = get_query_var('vohtmlsitemap-month', false); + $year = get_query_var('vohtmlsitemap-year', false); if ($range !== false && ($range = self::getRangeBySlug($range))) { return $range; diff --git a/Includes/Plugin.php b/Includes/Plugin.php index e3fa323..0f18096 100644 --- a/Includes/Plugin.php +++ b/Includes/Plugin.php @@ -53,7 +53,7 @@ public function valiDateQuery(WP_Query $query): void $this->page = $page; - wp_enqueue_style('vo-html-sitemap'); + wp_enqueue_style('vohtmlsitemap'); if ($page->getLatestDateShown()->getTimestamp() < strtotime('-1 year')) { header('X-Robots-Tag: noindex'); @@ -73,11 +73,11 @@ public function enqueueAssets(): void { $rootUrl = plugin_dir_url(VOHTMLSITEMAP_FILE); - wp_register_style('vo-html-sitemap', $rootUrl . 'dist/main.css', [], VOHTMLSITEMAP_VERSION); + wp_register_style('vohtmlsitemap', $rootUrl . 'dist/main.css', [], VOHTMLSITEMAP_VERSION); } public function loadTextDomain(): void { - load_plugin_textdomain('vo-html-sitemap', false, dirname(plugin_basename(VOHTMLSITEMAP_FILE)) . '/languages'); + load_plugin_textdomain('vohtmlsitemap', false, dirname(plugin_basename(VOHTMLSITEMAP_FILE)) . '/languages'); } } diff --git a/Includes/RewriteRules.php b/Includes/RewriteRules.php index 6b01431..b5ff41b 100644 --- a/Includes/RewriteRules.php +++ b/Includes/RewriteRules.php @@ -29,18 +29,18 @@ public static function addRewriteRules(): void add_rewrite_rule( "^{$base}\/([0-9]{4})\/?([0-9]{1,2})\/([0-9]{1,2})$", - 'index.php?page_id=' . $page->ID . '&vo-html-sitemap=true&vo-html-sitemap-year=$matches[1]&vo-html-sitemap-month=$matches[2]&vo-html-sitemap-day=$matches[3]', + 'index.php?page_id=' . $page->ID . '&vohtmlsitemap=true&vohtmlsitemap-year=$matches[1]&vohtmlsitemap-month=$matches[2]&vohtmlsitemap-day=$matches[3]', 'top' ); add_rewrite_rule( "^{$base}\/([0-9]{4})\/([0-9]{1,2})$", - 'index.php?page_id=' . $page->ID . '&vo-html-sitemap=true&vo-html-sitemap-year=$matches[1]&vo-html-sitemap-month=$matches[2]', + 'index.php?page_id=' . $page->ID . '&vohtmlsitemap=true&vohtmlsitemap-year=$matches[1]&vohtmlsitemap-month=$matches[2]', 'top' ); add_rewrite_rule( "^{$base}\/([0-9]{4})$", - 'index.php?page_id=' . $page->ID . '&vo-html-sitemap=true&vo-html-sitemap-year=$matches[1]', + 'index.php?page_id=' . $page->ID . '&vohtmlsitemap=true&vohtmlsitemap-year=$matches[1]', 'top' ); @@ -52,24 +52,24 @@ public static function addRewriteRules(): void add_rewrite_rule( "^{$base}\/({$expression})$", - 'index.php?page_id=' . $page->ID . '&vo-html-sitemap=true&vo-html-sitemap-range=$matches[1]', + 'index.php?page_id=' . $page->ID . '&vohtmlsitemap=true&vohtmlsitemap-range=$matches[1]', 'top' ); add_rewrite_rule( "^{$base}$", - 'index.php?page_id=' . $page->ID . '&vo-html-sitemap=true', + 'index.php?page_id=' . $page->ID . '&vohtmlsitemap=true', 'top' ); } public static function addQueryVars(array $vars): array { - $vars[] = 'vo-html-sitemap'; - $vars[] = 'vo-html-sitemap-range'; - $vars[] = 'vo-html-sitemap-year'; - $vars[] = 'vo-html-sitemap-month'; - $vars[] = 'vo-html-sitemap-day'; + $vars[] = 'vohtmlsitemap'; + $vars[] = 'vohtmlsitemap-range'; + $vars[] = 'vohtmlsitemap-year'; + $vars[] = 'vohtmlsitemap-month'; + $vars[] = 'vohtmlsitemap-day'; return $vars; } diff --git a/Includes/Settings.php b/Includes/Settings.php index 13c4920..5876b78 100644 --- a/Includes/Settings.php +++ b/Includes/Settings.php @@ -6,11 +6,11 @@ class Settings { public static function getPostTypes(): array { - return array_filter(get_option('vo-html-sitemap-post-types', ['post' => true])); + return array_filter(get_option('vohtmlsitemap-post-types', ['post' => true])); } public static function getPageId(): int { - return get_option('vo-html-sitemap-page', 0); + return get_option('vohtmlsitemap-page', 0); } } diff --git a/Includes/SettingsPage.php b/Includes/SettingsPage.php index 1acd23d..3666c2b 100644 --- a/Includes/SettingsPage.php +++ b/Includes/SettingsPage.php @@ -12,7 +12,7 @@ public static function init(): void public static function registerSettings(): void { - register_setting('vo-html-sitemap-settings', 'vo-html-sitemap-post-types', [ + register_setting('vohtmlsitemap-settings', 'vohtmlsitemap-post-types', [ 'type' => 'array', 'sanitize_callback' => function ($value) { return array_map(function (string $type) use ($value) { @@ -24,7 +24,7 @@ public static function registerSettings(): void ] ]); - register_setting('vo-html-sitemap-settings', 'vo-html-sitemap-page', [ + register_setting('vohtmlsitemap-settings', 'vohtmlsitemap-page', [ 'type' => 'integer', 'sanitize_callback' => function ($value) { $id = (int) $value; @@ -36,21 +36,34 @@ public static function registerSettings(): void ]); add_settings_section( - 'vo-html-sitemap', - __('VO HTML Sitemap Settings', 'vo-html-sitemap'), + 'vohtmlsitemap', + __('VO HTML Sitemap Settings', 'vohtmlsitemap'), '__return_false', - 'vo-html-sitemap' + 'vohtmlsitemap' ); + + $settings = [ + 'vo-html-sitemap-post-types' => 'vohtmlsitemap-post-types', + 'vo-html-sitemap-page' => 'vohtmlsitemap-page' + ]; + + // rename old settings, if they exist + foreach ($settings as $old => $new) { + if ($value = get_option($old)) { + update_option($new, $value); + delete_option($old); + } + } } public static function addSubmenuPage(): void { add_submenu_page( 'options-general.php', - __('VO HTML Sitemap', 'vo-html-sitemap'), - __('HTML Sitemap', 'vo-html-sitemap'), + __('VO HTML Sitemap', 'vohtmlsitemap'), + __('HTML Sitemap', 'vohtmlsitemap'), 'manage_options', - 'vo-html-sitemap', + 'vohtmlsitemap', [self::class, 'renderSubmenuPage'] ); } diff --git a/languages/vo-html-sitemap-nl_NL.mo b/languages/vo-html-sitemap-nl_NL.mo index 5cf8199d21c6ce9d7c47ec5b69fcc32fc3c55e6b..bce099c5534a33c5339f671a344c31f8e64b01c9 100644 GIT binary patch delta 351 zcmXBQv1$TA5P;#?Q&G>TF$QAPLR1h50b@{zh3^osNM&tdXJa5DSfsKLRy)BaX>5H0 z8zGgAtx0X_kiyD;&V{*eZkXGhy&w0}9e!W=XTrK9vc#OY(cJK0_3;8Y?-SFTOiQqr#fR6uM zPh*|;5?*5)b-*6#ek0@{8KVv`MZM^USI>y7NtzVCFoYq-)d3Q=Y)U3>pH1>s|Bl{* hS-e|j+Zh`Pv`$-wB7pz^ delta 393 zcmY+Fon;!h6~jFpQ!u4(Sx=n5<&+zaSOd7T`BOh!9)r3c#3+khf%!77ESI@8wYKX zRoq4mnnsAcJ=}l%vEI!8^_hL~ E3n-f`m;e9( diff --git a/languages/vo-html-sitemap-nl_NL.po b/languages/vo-html-sitemap-nl_NL.po index 5e4227d..46ce78b 100644 --- a/languages/vo-html-sitemap-nl_NL.po +++ b/languages/vo-html-sitemap-nl_NL.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/vo-html-sitemap\n" -"POT-Creation-Date: 2024-08-26T08:46:04+00:00\n" -"PO-Revision-Date: 2024-08-26 10:46+0200\n" +"POT-Creation-Date: 2024-09-23T08:55:20+00:00\n" +"PO-Revision-Date: 2024-09-23 10:56+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: nl_NL\n" @@ -15,8 +15,9 @@ msgstr "" "X-Poedit-Basepath: .\n" #. Plugin Name of the plugin -msgid "Van Ons HTML Sitemap" -msgstr "Van Ons HTML Sitemap" +#: Includes/SettingsPage.php:63 +msgid "VO HTML Sitemap" +msgstr "VO HTML Sitemap" #. Description of the plugin msgid "Van Ons plugin to add a HTML sitemap to your site." @@ -50,30 +51,29 @@ msgstr "Gisteren" msgid "VO HTML Sitemap Settings" msgstr "VO HTML Sitemap Instellingen" -#: Includes/SettingsPage.php:50 -msgid "VO HTML Sitemap" -msgstr "VO HTML Sitemap" - -#: Includes/SettingsPage.php:51 +#: Includes/SettingsPage.php:64 msgid "HTML Sitemap" msgstr "HTML Sitemap" -#: templates/admin/settings.php:9 +#: templates/admin/settings.php:15 msgid "Post types" msgstr "Berichttypen" -#: templates/admin/settings.php:14 +#: templates/admin/settings.php:20 msgid "Post types to include in the sitemap" msgstr "Berichttypen die in de sitemap moeten worden opgenomen" -#: templates/admin/settings.php:29 +#: templates/admin/settings.php:35 msgid "Sitemap page" msgstr "Sitemap pagina" -#: templates/admin/settings.php:34 +#: templates/admin/settings.php:40 msgid "Select a page" msgstr "Selecteer een pagina" -#: templates/sitemap-range.php:24 +#: templates/sitemap-range.php:28 msgid "No posts found" msgstr "Geen berichten gevonden" + +#~ msgid "Van Ons HTML Sitemap" +#~ msgstr "Van Ons HTML Sitemap" diff --git a/languages/vo-html-sitemap.pot b/languages/vo-html-sitemap.pot index fa54455..b51d370 100644 --- a/languages/vo-html-sitemap.pot +++ b/languages/vo-html-sitemap.pot @@ -2,20 +2,21 @@ # This file is distributed under the MIT. msgid "" msgstr "" -"Project-Id-Version: Van Ons HTML Sitemap 1.0.0\n" +"Project-Id-Version: VO HTML Sitemap 1.0.2\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/vo-html-sitemap\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-08-26T08:46:04+00:00\n" +"POT-Creation-Date: 2024-09-23T08:55:20+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.5.0\n" -"X-Domain: vo-html-sitemap\n" +"X-Domain: vohtmlsitemap\n" #. Plugin Name of the plugin -msgid "Van Ons HTML Sitemap" +#: Includes/SettingsPage.php:63 +msgid "VO HTML Sitemap" msgstr "" #. Description of the plugin @@ -50,30 +51,26 @@ msgstr "" msgid "VO HTML Sitemap Settings" msgstr "" -#: Includes/SettingsPage.php:50 -msgid "VO HTML Sitemap" -msgstr "" - -#: Includes/SettingsPage.php:51 +#: Includes/SettingsPage.php:64 msgid "HTML Sitemap" msgstr "" -#: templates/admin/settings.php:9 +#: templates/admin/settings.php:15 msgid "Post types" msgstr "" -#: templates/admin/settings.php:14 +#: templates/admin/settings.php:20 msgid "Post types to include in the sitemap" msgstr "" -#: templates/admin/settings.php:29 +#: templates/admin/settings.php:35 msgid "Sitemap page" msgstr "" -#: templates/admin/settings.php:34 +#: templates/admin/settings.php:40 msgid "Select a page" msgstr "" -#: templates/sitemap-range.php:24 +#: templates/sitemap-range.php:28 msgid "No posts found" msgstr "" diff --git a/readme.txt b/readme.txt index 5a7a9bf..63f77ab 100644 --- a/readme.txt +++ b/readme.txt @@ -1,12 +1,12 @@ === VO HTML Sitemap === -Contributors: vanons +Contributors: vanonsopensource Donate link: https://van-ons.nl/ -Tags: 1.0.1 +Tags: sitemap, SEO, html Requires at least: 6.4 Tested up to: 6.6 -Stable tag: 1.0.1 +Stable tag: 1.0.2 Requires PHP: 8.0 License: MIT License URI: https://opensource.org/licenses/MIT -VO HTML Sitemap is a simple plugin that adds a HTML sitemap of your WordPress site. +VO HTML Sitemap is a simple plugin that adds a HTML sitemap to your WordPress site. diff --git a/templates/admin/settings.php b/templates/admin/settings.php index d223343..b7df024 100644 --- a/templates/admin/settings.php +++ b/templates/admin/settings.php @@ -1,21 +1,27 @@ + +
- - + +
- +
- + true]) as $type): ?>
@@ -25,15 +31,15 @@
- - + 'page', 'posts_per_page' => -1]) as $page): ?> - diff --git a/templates/sitemap-day.php b/templates/sitemap-day.php index bf2dadc..ac2f0f6 100644 --- a/templates/sitemap-day.php +++ b/templates/sitemap-day.php @@ -1,8 +1,10 @@
  • - +
  • diff --git a/templates/sitemap-year.php b/templates/sitemap-year.php index a358241..135ec49 100644 --- a/templates/sitemap-year.php +++ b/templates/sitemap-year.php @@ -1,7 +1,9 @@