From 58d1ecc85925cf6381920433477b2608ce4584d3 Mon Sep 17 00:00:00 2001 From: Ashley Hitchcock Date: Tue, 4 Feb 2020 13:57:47 +0000 Subject: [PATCH] Feature/woocommerce (#20) * woocommerce product support --- wp-graphql-yoast-seo.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-graphql-yoast-seo.php b/wp-graphql-yoast-seo.php index 327db49..31c3c87 100755 --- a/wp-graphql-yoast-seo.php +++ b/wp-graphql-yoast-seo.php @@ -7,7 +7,7 @@ * Author URI: https://www.ashleyhitchcock.com * Text Domain: wp-graphql-yoast-seo * Domain Path: /languages - * Version: 3.0.2 + * Version: 3.1.0 * * @package WP_Graphql_YOAST_SEO */ @@ -22,6 +22,12 @@ $post_types = \WPGraphQL::get_allowed_post_types(); $taxonomies = \WPGraphQL::get_allowed_taxonomies(); + // If WooCommerce installed then add these post types and taxonomies + if ( class_exists( '\WooCommerce' ) ) { + array_push($post_types, 'product'); + array_push($taxonomies, 'productCategory'); + } + register_graphql_object_type('SEO', [ 'fields' => [ 'title' => ['type' => 'String'], @@ -39,6 +45,7 @@ ] ]); + if (!empty($post_types) && is_array($post_types)) { foreach ($post_types as $post_type) { $post_type_object = get_post_type_object($post_type);