From 2015b4598e63b4975b2a92cda160cf1862225e39 Mon Sep 17 00:00:00 2001 From: Jarkko Uro Date: Thu, 29 Apr 2021 16:10:45 +0300 Subject: [PATCH 1/3] Add active type to languages resolver. --- src/LanguageRootQueries.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/LanguageRootQueries.php b/src/LanguageRootQueries.php index cd384b9..ce82a7e 100644 --- a/src/LanguageRootQueries.php +++ b/src/LanguageRootQueries.php @@ -55,6 +55,15 @@ function __action_graphql_register_types() } } + if (isset($fields['active'])) { + foreach ( + pll_languages_list(['fields' => 'active']) + as $index => $active + ) { + $languages[$index]['active'] = $active === false ? false : true; + } + } + return $languages; }, ]); From 46f6b45c7b1721b658a92f8695d3a40b54832f42 Mon Sep 17 00:00:00 2001 From: Jarkko Uro Date: Thu, 29 Apr 2021 16:11:11 +0300 Subject: [PATCH 2/3] Add active type to check if language is active. --- src/PolylangTypes.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/PolylangTypes.php b/src/PolylangTypes.php index a1f1b5e..10aab59 100644 --- a/src/PolylangTypes.php +++ b/src/PolylangTypes.php @@ -89,6 +89,13 @@ function __action_graphql_register_types() 'wp-graphql-polylang' ), ], + 'active' => [ + 'type' => 'Boolean', + 'description' => __( + 'Is language active.', + 'wp-graphql-polylang' + ), + ] ], ]); } From c069936ae5f1fb7b8cf7285906a8caa1316fcbc1 Mon Sep 17 00:00:00 2001 From: Esa-Matti Suuronen Date: Tue, 28 Sep 2021 17:18:42 +0300 Subject: [PATCH 3/3] prettier --- src/LanguageRootQueries.php | 17 +++++++++-------- src/PolylangTypes.php | 12 ++++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/LanguageRootQueries.php b/src/LanguageRootQueries.php index ce82a7e..469ff87 100644 --- a/src/LanguageRootQueries.php +++ b/src/LanguageRootQueries.php @@ -55,14 +55,15 @@ function __action_graphql_register_types() } } - if (isset($fields['active'])) { - foreach ( - pll_languages_list(['fields' => 'active']) - as $index => $active - ) { - $languages[$index]['active'] = $active === false ? false : true; - } - } + if (isset($fields['active'])) { + foreach ( + pll_languages_list(['fields' => 'active']) + as $index => $active + ) { + $languages[$index]['active'] = + $active === false ? false : true; + } + } return $languages; }, diff --git a/src/PolylangTypes.php b/src/PolylangTypes.php index 10aab59..7974a72 100644 --- a/src/PolylangTypes.php +++ b/src/PolylangTypes.php @@ -90,12 +90,12 @@ function __action_graphql_register_types() ), ], 'active' => [ - 'type' => 'Boolean', - 'description' => __( - 'Is language active.', - 'wp-graphql-polylang' - ), - ] + 'type' => 'Boolean', + 'description' => __( + 'Is language active.', + 'wp-graphql-polylang' + ), + ], ], ]); }