Skip to content

Commit

Permalink
Minor updates to clarify WPGraphQL support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbahl committed Jun 6, 2017
1 parent 4ae9dfe commit 2aa642e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Whenever a term is updated, the following data will be stored in the term's term

### WPGraphQL Support

This plugin provides support for WPGraphQL (https://github.com/wp-graphql/wp-graphql)
This plugin provides support for WPGraphQL version 0.0.12 and newer (https://github.com/wp-graphql/wp-graphql).

When querying terms, the termObjects now have a `created` and `modified` field.

Expand Down
15 changes: 13 additions & 2 deletions tests/test-wp-term-timestamps.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
*/

/**
* Sample test case.
* WP_Term_Timestamp_Tests.
*/
class WP_Term_Timestamp_Tests extends WP_UnitTestCase {

/**
* The admin user that is used to test creating and updating terms
* @var
*/
public $admin;

/**
Expand Down Expand Up @@ -143,7 +147,7 @@ public function testWPGraphQLSupport() {
/**
* Only run these tests if WPGraphQL is installed in the same environment where these tests are being run
*/
if ( function_exists( 'do_graphql_request' ) ) {
if ( function_exists( 'do_graphql_request' ) && defined( 'WPGRAPHQL_VERSION' ) && version_compare( WPGRAPHQL_VERSION, '0.0.12' ) >= 0 ) {

/**
* Set the current user to someone with permission to create terms
Expand Down Expand Up @@ -223,6 +227,13 @@ public function testWPGraphQLSupport() {
*/
$this->assertEquals( $actual, $expected );

} else {

/**
* Output the message to PHPUnit
*/
fwrite(STDERR, print_r( 'WPGraphQL is either not installed or the version is not compatible with this plugin', TRUE ) );

}

}
Expand Down
7 changes: 7 additions & 0 deletions wp-term-timestamps.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ public function prepare_meta_value( $term_id, $taxonomy ) {
*/
public function graphql_support() {

/**
* This plugin requires version 0.0.12 or higher of the WPGraphQL Plugin
*/
if ( defined( 'WPGRAPHQL_VERSION' ) && version_compare( WPGRAPHQL_VERSION, '0.0.12' ) >= 0 ) {
return;
}

/**
* Get the allowed WPGraphQL taxonomies
*/
Expand Down

0 comments on commit 2aa642e

Please sign in to comment.