From 985669175cefb07268bf6b83d6df43df245fbb16 Mon Sep 17 00:00:00 2001 From: Mike van den Hoek Date: Fri, 9 Aug 2024 14:45:43 +0200 Subject: [PATCH] (feat): theme tiles, enabled by setting --- CHANGELOG.md | 6 +++ config/api.php | 3 +- config/settings.php | 6 +++ config/theme_tiles_metabox.php | 40 ++++++++++++++++++++ languages/pdc-base-nl_NL.mo | Bin 18154 -> 18416 bytes languages/pdc-base-nl_NL.po | 29 ++++++++++++-- languages/pdc-base.pot | 26 ++++++++++++- pdc-base.php | 2 +- src/Base/Foundation/Plugin.php | 2 +- src/Base/Metabox/MetaboxServiceProvider.php | 9 +++++ src/Base/RestAPI/ThemaFields/TilesField.php | 27 +++++++++++++ src/Base/Settings/SettingsPageOptions.php | 10 ++++- 12 files changed, 151 insertions(+), 9 deletions(-) create mode 100644 config/theme_tiles_metabox.php create mode 100644 src/Base/RestAPI/ThemaFields/TilesField.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ae2f61..64ad880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## Version [3.13.0] (2024-08-09) + +### Feat + +- Theme tiles, enabled by setting. + ## Version [3.12.2] (2024-08-19) ### Feat diff --git a/config/api.php b/config/api.php index 22d11cb..cfa3d17 100644 --- a/config/api.php +++ b/config/api.php @@ -58,7 +58,8 @@ 'subthemes' => OWC\PDC\Base\RestAPI\ThemaFields\ThemaField::class, 'yoast' => OWC\PDC\Base\RestAPI\ItemFields\Yoast::class, 'date_modified' => OWC\PDC\Base\RestAPI\ItemFields\DateModified::class, - 'hide_feedback_form' => OWC\PDC\Base\RestAPI\SharedFields\HideFeedbackForm::class + 'hide_feedback_form' => OWC\PDC\Base\RestAPI\SharedFields\HideFeedbackForm::class, + 'tiles' => OWC\PDC\Base\RestAPI\ThemaFields\TilesField::class ], ], ], diff --git a/config/settings.php b/config/settings.php index 3b13191..08b5170 100644 --- a/config/settings.php +++ b/config/settings.php @@ -81,6 +81,12 @@ 'desc' => __('Used for displaying a feedback form, applies to themes, subthemes and pdc-items.', 'pdc-base'), 'id' => 'setting_pdc_use_feedback_form', 'type' => 'checkbox', + ], + 'pdc_use_theme_tiles' => [ + 'name' => __('Theme tiles', 'pdc-base'), + 'desc' => __('Enable theme tiles.', 'pdc-base'), + 'id' => 'setting_pdc_use_theme_tiles', + 'type' => 'checkbox', ], 'upl_heading' => [ 'type' => 'heading', diff --git a/config/theme_tiles_metabox.php b/config/theme_tiles_metabox.php new file mode 100644 index 0000000..28fc37b --- /dev/null +++ b/config/theme_tiles_metabox.php @@ -0,0 +1,40 @@ + [ + 'id' => 'pdc_tiles', + 'title' => __('Tiles', 'pdc-base'), + 'post_types' => ['pdc-category'], + 'context' => 'normal', + 'priority' => 'low', + 'autosave' => true, + 'fields' => [ + 'tiles' => [ + 'group' => [ + 'id' => 'pdc_tiles_group', + 'type' => 'group', + 'clone' => true, + 'sort_clone' => true, + 'add_button' => __('Add new tile', 'pdc-base'), + 'fields' => [ + [ + 'id' => 'pdc_tile_title', + 'name' => __('Title', 'pdc-base'), + 'type' => 'text', + ], + [ + 'id' => 'pdc_tile_url', + 'name' => __('URL', 'pdc-base'), + 'type' => 'url', + ], + [ + 'id' => 'pdc_tile_icon', + 'name' => __('Icon', 'pdc-base'), + 'type' => 'text', + ], + ], + ], + ], + ] + ] +]; diff --git a/languages/pdc-base-nl_NL.mo b/languages/pdc-base-nl_NL.mo index 16dd885e0ee2d66d512cddbf0dae2106fb53bc57..4e61002619dbd33ff2b3125019e5927ac704d3ac 100644 GIT binary patch delta 5401 zcmZA533OG(0mkvk9w3Iu9)aYsCO}yvYc*`L3k8&bK*g58BSZogcm^AV2W3%d1BHM= zK-LxrQb9wYCy~oZi##{buIgcW3U*+!yTaynw1D z0siatf>#)hyQCS}9%js-0AteXs@0fD4UFlCSs021cpBGY6lOPcorMw97vp2N+SUv4 zaq7EK*PlSXYA(C&e)Am#ebF>BrXDpX0N`KXSz zqXxVmc_woN!|@c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Vl#z zF&RvLMOYAT*~_c;SmjBw!&`I5_%-zdq+EYJ-m-6q2gr-Iy%x1pSIMK~A@Vo!1yLz< z@xCtS^%!}Dyi6*|9-^{=^d=?b5E)CViO$Dt#y9okGHEZ#RDMTR+K!X>8`5gq;-^Hb zq4GM>l0HE`Bq~eD2i_Y0HNrQE{!mOJ&yn`x44}5fw)E&MB9n5o$KgmB*=O@)$j`P~n z)&*N{@@@Nb+(&Y4d%9JR+dV|5ebeD7nVY5_Sxn#p#eGJ;Z~GQn#b;zUQq=6hJeaK^^mJA`g$Vj5{PjZwjBcq7Q0`h0#tmfq!2_l2YIHHn7GRQ`v z$M6^A4bns&Bppb532d+6aMF)-B`=ZoGM>uQWCrO>&Jv1a9&sz?msYXD)-U2;$P2c8 z0XvaPwjGC!WDNN$2_q_b#6vgetShowOnMetabox($configMetaboxes); } + if ($this->plugin->settings->useThemeTiles()) { + $configMetaboxes = $this->getTilesMetabox($configMetaboxes); + } + if ($this->plugin->settings->useFeedbackForm()) { $configMetaboxes = $this->getFeedbackFormMetabox($configMetaboxes); } @@ -78,6 +82,11 @@ protected function getShowOnMetabox(array $configMetaboxes): array return array_merge($configMetaboxes, $this->plugin->config->get('show_on_metabox')); } + protected function getTilesMetabox(array $configMetaboxes): array + { + return array_merge($configMetaboxes, $this->plugin->config->get('theme_tiles_metabox')); + } + protected function getFeedbackFormMetabox(array $configMetaboxes): array { $feedbackFormMetabox = $this->plugin->config->get('hide_feedback_form_metabox'); diff --git a/src/Base/RestAPI/ThemaFields/TilesField.php b/src/Base/RestAPI/ThemaFields/TilesField.php new file mode 100644 index 0000000..d611991 --- /dev/null +++ b/src/Base/RestAPI/ThemaFields/TilesField.php @@ -0,0 +1,27 @@ +plugin->settings->useThemeTiles(); + }; + } + + public function create(WP_Post $post): array + { + return get_post_meta($post->ID, '_owc_pdc_tiles_group', true) ?: []; + } +} diff --git a/src/Base/Settings/SettingsPageOptions.php b/src/Base/Settings/SettingsPageOptions.php index 1ecf4bd..a7ee29e 100644 --- a/src/Base/Settings/SettingsPageOptions.php +++ b/src/Base/Settings/SettingsPageOptions.php @@ -120,6 +120,13 @@ public function useFeedbackForm(): bool return boolval($setting); } + public function useThemeTiles(): bool + { + $setting = $this->settings['_owc_setting_pdc_use_theme_tiles'] ?? false; + + return boolval($setting); + } + /** * URL used for retrieving UPL terms. */ @@ -142,7 +149,8 @@ public static function make(): self '_owc_setting_use_escape_element' => 0, '_owc_setting_pdc_enable_show_on' => 0, '_owc_setting_pdc_use_feedback_form' => 0, - '_owc_upl_terms_url' => '' + '_owc_upl_terms_url' => '', + '_owc_setting_pdc_use_theme_tiles' => 0 ]; return new static(wp_parse_args(get_option('_owc_pdc_base_settings'), $defaultSettings));