Skip to content

Commit f884793

Browse files
authored
Merge pull request #3149 from wp-graphql/release/v1.27.0
release: v1.27.0
2 parents b288907 + 203e0c0 commit f884793

File tree

15 files changed

+295
-57
lines changed

15 files changed

+295
-57
lines changed

.distignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ phpstan.neon.dist
4343
phpunit.xml.dist
4444
README.md
4545
schema.graphql
46-
47-
48-
46+
webpack.config.js
47+
phpcs.xml.dist
48+
.wp-env.json
49+
.codeclimate.yml

.gitattributes

Lines changed: 0 additions & 33 deletions
This file was deleted.

.wp-env.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"core": "WordPress/WordPress",
3-
"plugins": [ "." ],
3+
"plugins": [
4+
"./tests/e2e/plugins/settings-page-spec/",
5+
"."
6+
],
47
"themes": [],
58
"port": 8888,
69
"config": {

CHANGELOG.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
# Changelog
22

3-
= 1.26.0 =
3+
## 1.27.0 =
44

5-
## New Features
5+
### New Features
6+
7+
- [#3143](https://github.com/wp-graphql/wp-graphql/pull/3143): feat: Enhance tab state management with query arguments and localStorage fallback
8+
9+
### Chores / Bugfixes
10+
11+
- [#3139](https://github.com/wp-graphql/wp-graphql/pull/3139): fix: `$settings_fields` param on "graphql_get_setting_section_field_value" filter not passing the correct type
12+
- [#3137](https://github.com/wp-graphql/wp-graphql/pull/3137): fix: WPGraphQL Settings page fails to load when "graphiql_enabled" setting is "off"
13+
- [#3133](https://github.com/wp-graphql/wp-graphql/pull/3133): build: clean up dist
14+
- [#3146](https://github.com/wp-graphql/wp-graphql/pull/3146): test: add e2e test coverage for tabs in the settings page
15+
16+
## 1.26.0 =
17+
18+
### New Features
619

720
- [#3125](https://github.com/wp-graphql/wp-graphql/pull/3125): refactor: improve query handling in AbstractConnectionResolver
821
- new: `graphql_connection_pre_get_query` filter

access-functions.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,21 +813,24 @@ static function ( \WPGraphQL\Admin\Settings\SettingsRegistry $registry ) use ( $
813813
* @since 0.13.0
814814
*/
815815
function get_graphql_setting( string $option_name, $default_value = '', $section_name = 'graphql_general_settings' ) {
816-
$section_fields = get_option( $section_name );
816+
$section_fields = get_option( $section_name, [] );
817817

818818
/**
819819
* Filter the section fields
820-
820+
*
821821
* @param array<string,mixed> $section_fields The values of the fields stored for the section
822822
* @param string $section_name The name of the section
823823
* @param mixed $default_value The default value for the option being retrieved
824824
*/
825825
$section_fields = apply_filters( 'graphql_get_setting_section_fields', $section_fields, $section_name, $default_value );
826826

827+
// ensure the filtered sections fields are an array before proceeding
828+
$section_fields = is_array( $section_fields ) ? $section_fields : [];
829+
827830
/**
828831
* Get the value from the stored data, or return the default
829832
*/
830-
$value = isset( $section_fields[ $option_name ] ) ? $section_fields[ $option_name ] : $default_value;
833+
$value = $section_fields[ $option_name ] ?? $default_value;
831834

832835
/**
833836
* Filter the value before returning it

constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function graphql_setup_constants() {
1818

1919
// Plugin version.
2020
if ( ! defined( 'WPGRAPHQL_VERSION' ) ) {
21-
define( 'WPGRAPHQL_VERSION', '1.26.0' );
21+
define( 'WPGRAPHQL_VERSION', '1.27.0' );
2222
}
2323

2424
// Plugin Folder Path.

readme.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: GraphQL, JSON, API, Gatsby, Faust, Headless, Decoupled, Svelte, React, Nex
44
Requires at least: 5.0
55
Tested up to: 6.5
66
Requires PHP: 7.1
7-
Stable tag: 1.26.0
7+
Stable tag: 1.27.0
88
License: GPL-3
99
License URI: https://www.gnu.org/licenses/gpl-3.0.html
1010

@@ -270,6 +270,19 @@ Composer dependencies are no longer versioned in Github. Recommended install sou
270270

271271
== Changelog ==
272272

273+
= 1.27.0 =
274+
275+
**New Features**
276+
277+
- [#3143](https://github.com/wp-graphql/wp-graphql/pull/3143): feat: Enhance tab state management with query arguments and localStorage fallback
278+
279+
**Chores / Bugfixes**
280+
281+
- [#3139](https://github.com/wp-graphql/wp-graphql/pull/3139): fix: `$settings_fields` param on "graphql_get_setting_section_field_value" filter not passing the correct type
282+
- [#3137](https://github.com/wp-graphql/wp-graphql/pull/3137): fix: WPGraphQL Settings page fails to load when "graphiql_enabled" setting is "off"
283+
- [#3133](https://github.com/wp-graphql/wp-graphql/pull/3133): build: clean up dist
284+
- [#3146](https://github.com/wp-graphql/wp-graphql/pull/3146): test: add e2e test coverage for tabs in the settings page
285+
273286
= 1.26.0 =
274287

275288
**New Features**

src/Admin/GraphiQL/GraphiQL.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,16 @@ public function init() {
5858
* @return void
5959
*/
6060
public function register_admin_bar_menu( WP_Admin_Bar $admin_bar ) {
61-
if ( ! current_user_can( 'manage_options' ) || 'off' === get_graphql_setting( 'show_graphiql_link_in_admin_bar' ) ) {
61+
62+
if ( 'off' === get_graphql_setting( 'graphiql_enabled' ) ) {
63+
return;
64+
}
65+
66+
if ( ! current_user_can( 'manage_options' ) ) {
67+
return;
68+
}
69+
70+
if ( 'off' === get_graphql_setting( 'show_graphiql_link_in_admin_bar' ) ) {
6271
return;
6372
}
6473

src/Admin/Settings/SettingsRegistry.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public function get_settings_fields() {
5757
* @return void
5858
*/
5959
public function admin_enqueue_scripts( string $hook_suffix ) {
60-
if ( 'graphql_page_graphql-settings' !== $hook_suffix ) {
60+
61+
// if the page is not the GraphQL Settings page, bail
62+
if ( 'graphql_page_graphql-settings' !== $hook_suffix && 'toplevel_page_graphql-settings' !== $hook_suffix ) {
6163
return;
6264
}
6365

@@ -677,37 +679,37 @@ public function show_forms() {
677679
/**
678680
* Tabbable JavaScript codes & Initiate Color Picker
679681
*
680-
* This code uses localstorage for displaying active tabs
682+
* This code uses URL hash fragments and localStorage for displaying active tabs
681683
*
682684
* @return void
683685
*/
684686
public function script() {
685687
?>
686688
<script>
687689
jQuery(document).ready(function ($) {
688-
//Initiate Color Picker
690+
// Initiate Color Picker
689691
$('.wp-color-picker-field').wpColorPicker();
690692

691693
// Switches option sections
692694
$('.group').hide();
693695
var activetab = '';
694-
if (typeof (localStorage) != 'undefined') {
695-
activetab = localStorage.getItem("activetab");
696-
}
696+
var urlHash = window.location.hash;
697697

698-
//if url has section id as hash then set it as active or override the current local storage value
699-
if (window.location.hash) {
700-
activetab = window.location.hash;
698+
if (urlHash) {
699+
activetab = urlHash;
701700
if (typeof (localStorage) != 'undefined') {
702701
localStorage.setItem("activetab", activetab);
703702
}
703+
} else if (typeof (localStorage) != 'undefined') {
704+
activetab = localStorage.getItem("activetab");
704705
}
705706

706707
if (activetab != '' && $(activetab).length) {
707708
$(activetab).fadeIn();
708709
} else {
709710
$('.group:first').fadeIn();
710711
}
712+
711713
$('.group .collapsed').each(function () {
712714
$(this).find('input:checked').parent().parent().parent().nextAll().each(
713715
function () {
@@ -724,13 +726,15 @@ function () {
724726
} else {
725727
$('.nav-tab-wrapper a:first').addClass('nav-tab-active');
726728
}
729+
727730
$('.nav-tab-wrapper a').click(function (evt) {
728731
$('.nav-tab-wrapper a').removeClass('nav-tab-active');
729732
$(this).addClass('nav-tab-active').blur();
730733
var clicked_group = $(this).attr('href');
731734
if (typeof (localStorage) != 'undefined') {
732-
localStorage.setItem("activetab", $(this).attr('href'));
735+
localStorage.setItem("activetab", clicked_group);
733736
}
737+
history.replaceState(null, '', clicked_group);
734738
$('.group').hide();
735739
$(clicked_group).fadeIn();
736740
evt.preventDefault();

src/WPGraphQL.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,24 @@ static function ( $interfaces, $config, $type ) {
335335
10,
336336
3
337337
);
338+
339+
/**
340+
* Prevent WPML from redirecting within WPGraphQL requests
341+
*
342+
* @see https://github.com/wp-graphql/wp-graphql/issues/1626#issue-769089073
343+
* @since @todo
344+
*/
345+
add_filter(
346+
'wpml_is_redirected',
347+
static function ( bool $is_redirect ) {
348+
if ( is_graphql_request() ) {
349+
return false;
350+
}
351+
return $is_redirect;
352+
},
353+
10,
354+
1
355+
);
338356
}
339357

340358
/**

0 commit comments

Comments
 (0)