Skip to content

Conversation

@YvetteNikolov
Copy link
Contributor

Simon had hier toegevoegd dat je taxonomieën kon toevoegen aan de OpenPub items. Deze werden echter niet aan de API meegegeven. Dit voegt het wel toe.

Kan qua code style wellicht wat beter, ik hoor het graag.

$result = [];

foreach (array_keys($this->plugin->config->get('taxonomies')) as $taxonomy) {
$configTaxonomies = array_keys($this->plugin->config->get('taxonomies'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doet dit niet hetzelfde?

    /**
     * Create an additional field on an array.
     */
    public function create(WP_Post $post): array
    {
        $result = [];

		$taxonomies = apply_filters('owc/openpub-base/before-register-extended-taxonomies', $this->plugin->config->get('taxonomies'));

		if (! is_array($taxonomies) || 1 > count($taxonomies)) {
			return $result;
		}

		$taxonomiesKeys = array_unique(array_keys($taxonomies));

        foreach ($taxonomiesKeys as $taxonomy) {
            $result[$taxonomy] = $this->getTerms($post->ID, $taxonomy);
        }

        return $result;
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getest, werkt goed, veel beter zo

@YvetteNikolov YvetteNikolov force-pushed the feat/add-taxonomies-to-api branch from d051035 to e4d3ac2 Compare July 17, 2025 08:42
@YvetteNikolov YvetteNikolov merged commit c1718ae into master Jul 17, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants