-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: WooGraphQL settings tab added. (#726)
* feat: WooGraphQL settings tab added. * chore: WPCS compliance met * bugfix: Order Item Node ID implemented. * chore: Deprecated "AppContext::getLoader" calls replaced. * chore: WPCS compliance met. * fix: DownloadableItem "id" field implemented
- Loading branch information
Showing
19 changed files
with
1,169 additions
and
805 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Defines WooGraphQL's general settings. | ||
* | ||
* @package WPGraphQL\WooCommerce\Admin | ||
*/ | ||
|
||
namespace WPGraphQL\WooCommerce\Admin; | ||
|
||
/** | ||
* General class | ||
*/ | ||
class General extends Section { | ||
|
||
/** | ||
* Returns General settings fields. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_fields() { | ||
return [ | ||
[ | ||
'name' => 'disable_ql_session_handler', | ||
'label' => __( 'Disable QL Session Handler', 'wp-graphql-woocommerce' ), | ||
'desc' => __( 'The QL Session Handler takes over management of WooCommerce Session Management on WPGraphQL request replacing the usage of HTTP Cookies with JSON Web Tokens.', 'wp-graphql-woocommerce' ), | ||
'type' => 'checkbox', | ||
'default' => 'off', | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* The section defines the root functionality for a settings section | ||
* | ||
* @package WPGraphQL\WooCommerce\Admin | ||
*/ | ||
|
||
namespace WPGraphQL\WooCommerce\Admin; | ||
|
||
/** | ||
* Section class | ||
*/ | ||
abstract class Section { | ||
|
||
/** | ||
* Returns Section settings fields. | ||
* | ||
* @return array | ||
*/ | ||
abstract public static function get_fields(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Defines WooGraphQL's substitutions settings. | ||
* | ||
* @package WPGraphQL\WooCommerce\Admin | ||
*/ | ||
|
||
namespace WPGraphQL\WooCommerce\Admin; | ||
|
||
use WPGraphQL\WooCommerce\WP_GraphQL_WooCommerce as WooGraphQL; | ||
|
||
/** | ||
* General class | ||
*/ | ||
class Substitutions extends Section { | ||
|
||
/** | ||
* Return option list of valid GraphQL types for products. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_dropdown_list() { | ||
$graphql_types = []; | ||
foreach ( WooGraphQL::get_enabled_product_types() as $type ) { | ||
$graphql_types[ $type ] = $type; | ||
} | ||
return $graphql_types; | ||
} | ||
|
||
/** | ||
* Returns General settings fields. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_fields() { | ||
$type_labels = wc_get_product_types(); | ||
$registered_types = array_keys( WooGraphQL::get_enabled_product_types() ); | ||
$all_types = array_keys( $type_labels ); | ||
|
||
$unregistered_types = array_diff( $registered_types, $all_types ); | ||
$fields = []; | ||
foreach ( $unregistered_types as $product_type ) { | ||
$fields[] = [ | ||
'name' => "{$product_type}_substitution_type", | ||
'label' => sprintf( | ||
/* translators: product type */ | ||
__( 'Substitution type for %s', 'wp-graphql-woocommerce' ), | ||
$type_labels[ $product_type ] | ||
), | ||
'desc' => sprintf( | ||
/* translators: product type */ | ||
__( 'Set a replacement GraphQL type for %s because it\'s unregistered', 'wp-graphql-woocommerce' ), | ||
$type_labels[ $product_type ] | ||
), | ||
'type' => 'select', | ||
'options' => self::get_dropdown_list(), | ||
]; | ||
} | ||
|
||
return $fields; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Initializes a WooGraphQL Pro admin settings. | ||
* | ||
* @package WPGraphQL\WooCommerce\Pro | ||
* @since 1.0.0 | ||
*/ | ||
|
||
namespace WPGraphQL\WooCommerce; | ||
|
||
use WPGraphQL\Admin\Settings\Settings; | ||
use WPGraphQL\WooCommerce\Admin\General; | ||
use WPGraphQL\WooCommerce\Admin\Substitutions; | ||
|
||
/** | ||
* Class Admin | ||
*/ | ||
class Admin { | ||
|
||
/** | ||
* Admin constructor | ||
*/ | ||
public function __construct() { | ||
add_action( 'graphql_register_settings', [ $this, 'register_settings' ] ); | ||
} | ||
|
||
/** | ||
* Registers the WooGraphQL Settings tab. | ||
* | ||
* @param Settings $manager Settings Manager. | ||
* @return void | ||
*/ | ||
public function register_settings( Settings $manager ) { | ||
$manager->settings_api->register_section( | ||
'woographql_settings', | ||
[ 'title' => __( 'WooGraphQL', 'wp-graphql-woocommerce' ) ] | ||
); | ||
|
||
$manager->settings_api->register_fields( | ||
'woographql_settings', | ||
General::get_fields(), | ||
); | ||
|
||
$manager->settings_api->register_fields( | ||
'woographql_settings', | ||
Substitutions::get_fields(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.