Skip to content

Commit

Permalink
Merge pull request #88 from wp-graphql/release/v2.0.0-beta.5.0.0
Browse files Browse the repository at this point in the history
release: v2.0.0 beta.5.0.0
  • Loading branch information
jasonbahl authored Sep 25, 2023
2 parents 3b402e0 + a1fbd8f commit 2517a5b
Show file tree
Hide file tree
Showing 40 changed files with 3,070 additions and 558 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
-e SKIP_TESTS_CLEANUP=${{ matrix.coverage }} \
-e ACF_PRO=${{matrix.acf_pro }} \
-e ACF_LICENSE_KEY=${{secrets.ACF_LICENSE_KEY}} \
-e ACF_VERSION=${{matrix.ACF_VERSION}} \
-e ACF_VERSION=${{matrix.acf_version}} \
-e ACF_EXTENDED_LICENSE_KEY=${{secrets.ACF_EXTENDED_LICENSE_KEY}} \
testing
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Changelog

## 2.0.0-beta.4.1.0
## 2.0.0-beta.5.0.0

[read more](https://github.com/wp-graphql/wpgraphql-acf/releases/tag/v2.0.0-beta.5.0.0)

### New Features

- [#81](https://github.com/wp-graphql/wpgraphql-acf/pull/81): feat: 🚀 ACF Blocks Support. Query ACF Blocks using WPGraphQL!! 🚀 (when [WPGraphQL Content Blocks v1.2.0+](https://github.com/wpengine/wp-graphql-content-blocks/releases/) is active)
- feat: ACF Options UI support. ACF Pro v6.2 has a new Options Page UI and now you can register those options pages to show in graphql from the UI.

### Chores / Bugfixes

- [#77](https://github.com/wp-graphql/wpgraphql-acf/pull/77): fix: js error when clone fields are added to a field group.
- [#80](https://github.com/wp-graphql/wpgraphql-acf/pull/81): ci: put the files in a subfolder when build zip in github
- fix: cloning an individual field applied the entire cloned field's group as an interface to the clonee field group.
- [#85](https://github.com/wp-graphql/wpgraphql-acf/pull/85): fix: TermNodes returning null when not array and fix type being set to generic TermNode in Taxonomy field


## v2.0.0-beta.4.0.0

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"slevomat/coding-standard": "^8.9",
"simpod/php-coveralls-mirror": "^3.0",
"phpstan/extension-installer": "^1.3",
"wp-cli/wp-cli-bundle": "^2.8",
"php-stubs/acf-pro-stubs": "6.*"
"php-stubs/acf-pro-stubs": "6.*",
"wp-cli/wp-cli-bundle": "^2.8"
},
"config": {
"platform": {
Expand Down
437 changes: 219 additions & 218 deletions composer.lock

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions docker/app.setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ PLUGINS_DIR=${PLUGINS_DIR-.}
ACF_LICENSE_KEY=${ACF_LICENSE_KEY-.}
ACF_VERSION=${ACF_VERSION-"latest"}
ACF_PRO=${ACF_PRO-false}
#WPGRAPHQL_CONTENT_BLOCKS=${WPGRAPHQL_CONTENT_BLOCKS-true}
#WPGRAPHQL_CONTENT_BLOCKS_VERSION=${WPGRAPHQL_CONTENT_BLOCKS_VERSION-"latest"}
#
#// fallback to hello.php as a hack. dont love this, but we have to pass a slug.
#export WPGRAPHQL_CONTENT_BLOCKS_PLUGIN_SLUG=${WPGRAPHQL_CONTENT_BLOCKS_PLUGIN_SLUG-'wp-graphql-content-blocks/wp-graphql-content-blocks.php'}

# Export the plugin slug for use when running the codeception tests
# (The slug is different for Free and Pro)
export ACF_PLUGIN_SLUG=${ACF_PLUGIN_SLUG-'advanced-custom-fields/acf.php'}
export ACF_EXTENDED_PLUGIN_SLUG=${ACF_PLUGIN_SLUG-'acf-extended/acf-extended.php'}


# If an ACF_VERSION is passed, use it, else the latest version will be downloaded
ACF_PRO_DOWNLOAD_VERSION=""

Expand Down Expand Up @@ -118,5 +124,27 @@ else

fi

#echo "WPGRAPHQL_CONTENT_BLOCKS: ${WPGRAPHQL_CONTENT_BLOCKS}"
#
## If WPGraphQL Content Blocks should be tested against
#if [[ 'true' = "${WPGRAPHQL_CONTENT_BLOCKS}" ]]; then
#
# WPGRAPHQL_CONTENT_BLOCKS_PLUGIN_SLUG='wp-graphql-content-blocks/wp-graphql-content-blocks.php';
#
# if [[ -z ${WPGRAPHQL_CONTENT_BLOCKS_VERSION} || "${WPGRAPHQL_CONTENT_BLOCKS_VERSION}" == "latest" ]]; then
# # Get latest release version of WPGraphQL Content Blocks
# echo "Getting the latest version of WPGraphQL Content Blocks"
# WPGRAPHQL_CONTENT_BLOCKS_VERSION=$(curl --location --request GET "https://api.github.com/repos/wpengine/wp-graphql-content-blocks/releases/latest" | jq '.tag_name' | tr -d '"' )
# fi
#
# echo "Installing WPGraphQL Content Blocks ${WPGRAPHQL_CONTENT_BLOCKS_VERSION}"
# wp plugin install "https://github.com/wpengine/wp-graphql-content-blocks/releases/download/${WPGRAPHQL_CONTENT_BLOCKS_VERSION}/wp-graphql-content-blocks.zip" --allow-root --activate
#
### If WPGRAPHQL_CONTENT_BLOCKS is not true, skip installing it
#else
# echo "Skipping installing WPGraphQL Content Blocks"
# WPGRAPHQL_CONTENT_BLOCKS_PLUGIN_SLUG='wp-graphql-content-blocks/wp-graphql-content-blocks.php';
#fi

## List the plugins that were activated to ensure ACF Free or Pro was properly activated
wp plugin list --allow-root
167 changes: 167 additions & 0 deletions src/Admin/OptionsPageRegistration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?php
namespace WPGraphQL\Acf\Admin;

use WPGraphQL\Utils\Utils;

class OptionsPageRegistration {

/**
* @return void
*/
public function init(): void {

// Add GraphQL columns to the ACF Options Page registration columns
// NOTE: the priority must be lower (a bigger number) than 10 to not conflict
// with the default ACF columns filter
add_filter( 'manage_acf-ui-options-page_posts_columns', [ $this, 'add_graphql_type_column' ], 20, 1 );

// Display the GraphQL Type in the ACF Taxonomy Registration Columns
add_action( 'manage_acf-ui-options-page_posts_custom_column', [ $this, 'render_graphql_columns' ], 10, 2 );

// Add registration fields to the ACF Options Pages output for exporting / saving as PHP
add_filter( 'acf/ui_options_page/registration_args', [ $this, 'add_registration_fields' ], 10, 2 );

// Add tha GraphQL Tab to the ACF Post Type registration screen
add_filter( 'acf/ui_options_page/additional_settings_tabs', [ $this, 'add_tabs' ] );

// Render the graphql settings tab in the ACF post type registration screen
add_action( 'acf/ui_options_page/render_settings_tab/graphql', [ $this, 'render_settings_tab' ] );
}

/**
* @param array $args
* @param array $post
*
* @return array
*/
public function add_registration_fields( array $args, array $post ) : array {
$show_in_graphql = false;

if ( isset( $args['show_in_graphql'] ) ) {
$show_in_graphql = $args['show_in_graphql'];
} elseif ( isset( $post['show_in_graphql'] ) ) {
$show_in_graphql = $post['show_in_graphql'];
}

$args['show_in_graphql'] = $show_in_graphql;

$graphql_type_name = '';

if ( ! empty( $args['graphql_type_name'] ) ) {
$graphql_type_name = $args['graphql_type_name'];
} elseif ( ! empty( $post['graphql_type_name'] ) ) {
$graphql_type_name = $post['graphql_type_name'];
} elseif ( isset( $args['page_title'] ) ) {
$graphql_type_name = Utils::format_field_name( $args['page_title'], false );
}

// if a graphql_single_name exists, use it, otherwise use the formatted version of the singular_name label
$args['graphql_type_name'] = $graphql_type_name;

return $args;
}

/**
* @param array $tabs
*
* @return array
*/
public function add_tabs( array $tabs ): array {
$tabs['graphql'] = __( 'GraphQL', 'wp-graphql-acf' );
return $tabs;
}

/**
* @param array $acf_ui_options_page
*
* @return void
*/
public function render_settings_tab( array $acf_ui_options_page ): void {
acf_render_field_wrap(
[
'type' => 'true_false',
'name' => 'show_in_graphql',
'key' => 'show_in_graphql',
'prefix' => 'acf_ui_options_page',
'value' => isset( $acf_ui_options_page['show_in_graphql'] ) && true === (bool) $acf_ui_options_page['show_in_graphql'] ? 1 : 0,
'ui' => true,
'label' => __( 'Show in GraphQL', 'wp-graphql-acf' ),
'instructions' => __( 'Whether to show the Post Type in the WPGraphQL Schema.', 'wp-graphql-acf' ),
'default' => false,
]
);

$graphql_type_name = $acf_ui_options_page['graphql_type_name'] ?? '';

if ( empty( $graphql_type_name ) ) {
$graphql_type_name = ! empty( $acf_ui_options_page['page_title'] ) ? Utils::format_field_name( $acf_ui_options_page['page_title'], true ) : '';
}

$graphql_type_name = ucfirst( Utils::format_field_name( $graphql_type_name, true ) );

acf_render_field_wrap(
[
'type' => 'text',
'name' => 'graphql_type_name',
'key' => 'graphql_type_name',
'prefix' => 'acf_ui_options_page',
'value' => $graphql_type_name,
'label' => __( 'GraphQL Type Name', 'wp-graphql-acf' ),
'instructions' => __( 'How the Options Page should be referenced in the GraphQL Schema.', 'wp-graphql-acf' ),
'default' => $graphql_type_name,
'required' => 1,
'conditions' => [
'field' => 'show_in_graphql',
'operator' => '==',
'value' => '1',
],
],
'div',
'field'
);
}

/**
* Given a list of columns, add "graphql_type" as a column.
*
* @param array $columns The columns on the post type table
*
* @return array
*/
public function add_graphql_type_column( array $columns ): array {
$columns['show_in_graphql'] = __( 'Show in GraphQL', 'wp-graphql-acf' );
$columns['graphql_type'] = __( 'GraphQL Type', 'wp-graphql-acf' );
return $columns;
}

/**
* Determine and echo the markup to show for the graphql_type column
*
* @param string $column_name The name of the column being rendered
* @param int $post_id The ID of the post the column is being displayed for
*
* @return void
*/
public function render_graphql_columns( string $column_name, int $post_id ): void {
$post_type = acf_get_internal_post_type( $post_id, 'acf-ui-options-page' );

// if there's no post type, bail early
if ( empty( $post_type ) ) {
return;
}

// Determine the output for the column
switch ( $column_name ) {
case 'graphql_type':
$graphql_type = Utils::format_type_name( \WPGraphQL\Acf\Utils::get_field_group_name( $post_type ) );
echo esc_html( $graphql_type );
break;
case 'show_in_graphql':
$show = isset( $post_type['show_in_graphql'] ) && true === (bool) $post_type['show_in_graphql'] ? 'true' : 'false';
echo esc_html( $show );
break;
default:
}
}

}
1 change: 0 additions & 1 deletion src/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ public function wpgraphql_admin_table_columns_html( string $column_name, int $po
$field_group = acf_get_field_group( $post_id );

if ( empty( $field_group ) ) {
echo null;
return;
}

Expand Down
Loading

0 comments on commit 2517a5b

Please sign in to comment.