PHP 8.2.31
Preview: Settings.php Size: 2.06 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/src/Internal/Api/Settings.php

<?php

declare(strict_types=1);

namespace Automattic\WooCommerce\Internal\Api;

/**
 * Settings handling for the GraphQL API.
 *
 * Registers the "GraphQL" section under WooCommerce - Settings - Advanced.
 * Only active when Main::is_enabled() returns true (feature flag on and
 * PHP 8.1+), so the section is hidden when the feature is disabled.
 */
class Settings {
	/**
	 * Identifier for the GraphQL section under the Advanced settings tab.
	 */
	public const SECTION_ID = 'graphql';

	/**
	 * Register the filter hooks that expose the GraphQL settings section.
	 */
	public function register(): void {
		add_filter( 'woocommerce_get_sections_advanced', array( $this, 'add_section' ) );
		add_filter( 'woocommerce_get_settings_advanced', array( $this, 'add_settings' ), 10, 2 );
	}

	/**
	 * Append the GraphQL section to the Advanced settings tab.
	 *
	 * @param array $sections Existing sections keyed by id.
	 * @return array
	 */
	public function add_section( array $sections ): array {
		if ( Main::is_enabled() ) {
			$sections[ self::SECTION_ID ] = __( 'GraphQL', 'woocommerce' );
		}
		return $sections;
	}

	/**
	 * Provide the settings fields for the GraphQL section.
	 *
	 * @param array  $settings   Existing settings for the current section.
	 * @param string $section_id Current section id.
	 * @return array
	 */
	public function add_settings( array $settings, string $section_id ): array {
		if ( self::SECTION_ID !== $section_id || ! Main::is_enabled() ) {
			return $settings;
		}

		return array(
			array(
				'title' => __( 'GraphQL', 'woocommerce' ),
				'desc'  => __( 'Configure the WooCommerce GraphQL API.', 'woocommerce' ),
				'type'  => 'title',
				'id'    => 'woocommerce_graphql_options',
			),
			array(
				'title'   => __( 'Enable GET endpoint', 'woocommerce' ),
				'desc'    => __( 'Allow GraphQL queries over GET in addition to POST', 'woocommerce' ),
				'id'      => Main::OPTION_GET_ENDPOINT_ENABLED,
				'default' => 'yes',
				'type'    => 'checkbox',
			),
			array(
				'type' => 'sectionend',
				'id'   => 'woocommerce_graphql_options',
			),
		);
	}
}

Directory Contents

Dirs: 2 × Files: 7

Name Size Perms Modified Actions
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
Schema DIR
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
21.50 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
2.09 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
12.55 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
4.68 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
7.14 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
2.06 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
7.68 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).