Skip to content

Commit

Permalink
(feat): theme tiles, enabled by setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike van den Hoek authored and mvdhoek1 committed Sep 30, 2024
1 parent f317b40 commit 9856691
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion config/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
],
],
Expand Down
6 changes: 6 additions & 0 deletions config/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
40 changes: 40 additions & 0 deletions config/theme_tiles_metabox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

return [
'tiles' => [
'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',
],
],
],
],
]
]
];
Binary file modified languages/pdc-base-nl_NL.mo
Binary file not shown.
29 changes: 26 additions & 3 deletions languages/pdc-base-nl_NL.po
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ msgstr "Pools"
msgid "Romanian"
msgstr "Roemeens"

#: config/metaboxes.php:233 config/metaboxes.php:250
#: config/metaboxes.php:233
#: config/metaboxes.php:250
#: config/theme_tiles_metabox.php:32
msgid "Icon"
msgstr "Icoon"

Expand Down Expand Up @@ -822,15 +824,24 @@ msgstr "Gebruik feedback formulier"
msgid "Used for displaying a feedback form, applies to themes, subthemes and pdc-items."
msgstr "Wordt gebruikt voor het weergeven van een feedback formulier, is van toepassing op thema's, subthema's en pdc-items."

#: config/settings.php:86
msgid "Theme tiles"
msgstr "Thema tegels"

#: config/settings.php:87
msgid "Enable theme tiles."
msgstr "Gebruik thema tegels"

#: config/settings.php:93
msgid "The Uniform Product list of names (upl)"
msgstr "De Uniforme Productnamenlijst (UPL)"

#: config/settings.php:90
#: config/settings.php:96
#: config/theme_tiles_metabox.php:27
msgid "URL"
msgstr "URL"

#: config/settings.php:91
#: config/settings.php:97
msgid "URL used for retrieving UPL terms."
msgstr "URL om de UPL termen op te halen."

Expand Down Expand Up @@ -946,6 +957,18 @@ msgstr "Eigenaar"
msgid "Owners"
msgstr "Eigenaren"

#: config/theme_tiles_metabox.php:6
msgid "Tiles"
msgstr "Tegels"

#: config/theme_tiles_metabox.php:18
msgid "Add new tile"
msgstr "Voeg nieuwe tegel toe"

#: config/theme_tiles_metabox.php:
msgid "Title"
msgstr "Titel"

#: src/Base/Foundation/DependencyChecker.php:70
msgid "The following plugins are required to use the PDC:"
msgstr "De volgende plugins zijn vereist om gebruik te maken van de PDC:"
Expand Down
26 changes: 24 additions & 2 deletions languages/pdc-base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ msgstr ""

#: config/metaboxes.php:233
#: config/metaboxes.php:250
#: config/theme_tiles_metabox.php:32
msgid "Icon"
msgstr ""

Expand Down Expand Up @@ -852,15 +853,24 @@ msgstr ""
msgid "Used for displaying a feedback form, applies to themes, subthemes and pdc-items."
msgstr ""

#: config/settings.php:86
msgid "Theme tiles"
msgstr ""

#: config/settings.php:87
msgid "Enable theme tiles."
msgstr ""

#: config/settings.php:93
msgid "The Uniform Product list of names (upl)"
msgstr ""

#: config/settings.php:90
#: config/settings.php:96
#: config/theme_tiles_metabox.php:27
msgid "URL"
msgstr ""

#: config/settings.php:91
#: config/settings.php:97
msgid "URL used for retrieving UPL terms."
msgstr ""

Expand Down Expand Up @@ -978,6 +988,18 @@ msgstr ""
msgid "Owners"
msgstr ""

#: config/theme_tiles_metabox.php:6
msgid "Tiles"
msgstr ""

#: config/theme_tiles_metabox.php:18
msgid "Add new tile"
msgstr ""

#: config/theme_tiles_metabox.php:
msgid "Title"
msgstr ""

#: src/Base/Foundation/DependencyChecker.php:70
msgid "The following plugins are required to use the PDC:"
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion pdc-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Yard | PDC Base
* Plugin URI: https://www.openwebconcept.nl/
* Description: Acts as foundation for other PDC related content plugins. This plugin implements actions to allow for other plugins to add and/or change Custom Posttypes, Metaboxes, Taxonomies, en Posts 2 posts relations.
* Version: 3.12.2
* Version: 3.13.0
* Author: Yard | Digital Agency
* Author URI: https://www.yard.nl/
* License: GPL-3.0
Expand Down
2 changes: 1 addition & 1 deletion src/Base/Foundation/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Plugin
*
* @var string
*/
public const VERSION = '3.12.2';
public const VERSION = '3.13.0';

/**
* Path to the root of the plugin.
Expand Down
9 changes: 9 additions & 0 deletions src/Base/Metabox/MetaboxServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public function registerMetaboxes(array $rwmbMetaboxes): array
$configMetaboxes = $this->getShowOnMetabox($configMetaboxes);
}

if ($this->plugin->settings->useThemeTiles()) {
$configMetaboxes = $this->getTilesMetabox($configMetaboxes);
}

if ($this->plugin->settings->useFeedbackForm()) {
$configMetaboxes = $this->getFeedbackFormMetabox($configMetaboxes);
}
Expand Down Expand Up @@ -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');
Expand Down
27 changes: 27 additions & 0 deletions src/Base/RestAPI/ThemaFields/TilesField.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace OWC\PDC\Base\RestAPI\ThemaFields;

use OWC\PDC\Base\RestAPI\ItemFields\ConnectedField;
use WP_Post;

/**
* Class for handling the thema fields.
*/
class TilesField extends ConnectedField
{
/**
* The condition for the creator.
*/
protected function condition(): callable
{
return function () {
return $this->plugin->settings->useThemeTiles();
};
}

public function create(WP_Post $post): array
{
return get_post_meta($post->ID, '_owc_pdc_tiles_group', true) ?: [];
}
}
10 changes: 9 additions & 1 deletion src/Base/Settings/SettingsPageOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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));
Expand Down

0 comments on commit 9856691

Please sign in to comment.