show_in_graphql = isset( $data['cpt_custom_post_type']['show_in_graphql'] ) ? $data['cpt_custom_post_type']['show_in_graphql'] : false; $this->graphql_single_name = isset( $data['cpt_custom_post_type']['graphql_single_name'] ) ? \WPGraphQL\Utils\Utils::format_type_name( $data['cpt_custom_post_type']['graphql_single_name'] ) : ''; $this->graphql_plural_name = isset( $data['cpt_custom_post_type']['graphql_plural_name'] ) ? \WPGraphQL\Utils\Utils::format_type_name( $data['cpt_custom_post_type']['graphql_plural_name'] ) : ''; } /** * Capture taxonomy settings from form submission for saving * * @param array $data */ public function before_update_taxonomy( $data ) { $this->show_in_graphql = isset( $data['cpt_custom_tax']['show_in_graphql'] ) ? $data['cpt_custom_tax']['show_in_graphql'] : false; $this->graphql_single_name = isset( $data['cpt_custom_tax']['graphql_single_name'] ) ? \WPGraphQL\Utils\Utils::format_type_name( $data['cpt_custom_tax']['graphql_single_name'] ) : ''; $this->graphql_plural_name = isset( $data['cpt_custom_tax']['graphql_plural_name'] ) ? \WPGraphQL\Utils\Utils::format_type_name( $data['cpt_custom_tax']['graphql_plural_name'] ) : ''; } /** * Save values from form submission * * @param array $type * @param string $name * * @return array */ public function save_graphql_settings( $type, $name ) { $type[ $name ]['show_in_graphql'] = $this->show_in_graphql; $type[ $name ]['graphql_single_name'] = \WPGraphQL\Utils\Utils::format_type_name( $this->graphql_single_name ); $type[ $name ]['graphql_plural_name'] = \WPGraphQL\Utils\Utils::format_type_name( $this->graphql_plural_name ); return $type; } /** * Add settings fields to Custom Post Type UI form * * @param cptui_admin_ui $ui Admin UI instance. */ public function add_graphql_post_type_settings( $ui ) { $tab = ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) ? 'edit' : 'new'; // phpcs:ignore WordPress.Security.NonceVerification $current = []; $name_array = 'cpt_custom_post_type'; if ( 'edit' === $tab ) { $post_types = cptui_get_post_type_data(); $selected_post_type = cptui_get_current_post_type( false ); if ( $selected_post_type ) { if ( array_key_exists( $selected_post_type, $post_types ) ) { $current = $post_types[ $selected_post_type ]; } } } echo $this->get_setting_fields( $ui, $current, $name_array ); // phpcs:ignore. } /** * Add settings fields to Custom Post Type UI form * * @param cptui_admin_ui $ui Admin UI instance. */ public function add_taxonomy_graphql_settings( $ui ) { $tab = ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) ? 'edit' : 'new'; // phpcs:ignore WordPress.Security.NonceVerification $name_array = 'cpt_custom_tax'; $current = []; if ( 'edit' === $tab ) { $taxonomies = cptui_get_taxonomy_data(); $selected_taxonomy = cptui_get_current_taxonomy( false ); if ( $selected_taxonomy ) { if ( array_key_exists( $selected_taxonomy, $taxonomies ) ) { $current = $taxonomies[ $selected_taxonomy ]; } } } echo $this->get_setting_fields( $ui, $current, $name_array ); // phpcs:ignore. } /** * Get the settings fields to render for the form * * @param cptui_admin_ui $ui Admin UI instance. * @param array $current * @param string $name_array */ public function get_setting_fields( $ui, $current, $name_array ) { ?>
de-activate the "WPGraphQL for Custom Post Type UI" extension to proceed.', 'custom-post-type-ui' ), esc_url( $link ) ); ?>