2021-03-01 03:57:53 +00:00
|
|
|
<?php
|
2022-07-27 18:01:18 +00:00
|
|
|
/**
|
|
|
|
* API initialization for beta testing.
|
|
|
|
*
|
|
|
|
* @package WC_Beta_Tester
|
|
|
|
*/
|
2021-03-04 02:36:13 +00:00
|
|
|
|
2022-07-27 18:01:18 +00:00
|
|
|
/**
|
|
|
|
* Register the test helper route.
|
|
|
|
*
|
|
|
|
* @param string $route Route path.
|
|
|
|
* @param string $callback Callback function name.
|
|
|
|
* @param array $additional_options Additional options passed to route registration.
|
|
|
|
*/
|
|
|
|
function register_woocommerce_admin_test_helper_rest_route( $route, $callback, $additional_options = array() ) {
|
|
|
|
add_action(
|
|
|
|
'rest_api_init',
|
|
|
|
function() use ( $route, $callback, $additional_options ) {
|
|
|
|
$default_options = array(
|
|
|
|
'methods' => 'POST',
|
|
|
|
'callback' => $callback,
|
|
|
|
'permission_callback' => function( $request ) {
|
|
|
|
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
|
|
|
|
return new \WP_Error(
|
|
|
|
'woocommerce_rest_cannot_edit',
|
|
|
|
__( 'Sorry, you cannot perform this action', 'woocommerce' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
);
|
2021-03-04 02:36:13 +00:00
|
|
|
|
2022-07-27 18:01:18 +00:00
|
|
|
$default_options = array_merge( $default_options, $additional_options );
|
2021-03-04 02:36:13 +00:00
|
|
|
|
2022-07-27 18:01:18 +00:00
|
|
|
register_rest_route(
|
|
|
|
'wc-admin-test-helper',
|
|
|
|
$route,
|
|
|
|
$default_options
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2021-03-03 06:27:47 +00:00
|
|
|
}
|
|
|
|
|
2021-03-01 03:57:53 +00:00
|
|
|
require( 'admin-notes/delete-all-notes.php' );
|
2021-03-03 06:27:47 +00:00
|
|
|
require( 'admin-notes/add-note.php' );
|
2021-03-04 00:56:39 +00:00
|
|
|
require( 'tools/trigger-wca-install.php' );
|
2021-05-24 17:50:44 +00:00
|
|
|
require( 'tools/trigger-cron-job.php' );
|
2021-04-28 23:53:07 +00:00
|
|
|
require( 'tools/run-wc-admin-daily.php' );
|
2021-03-03 06:05:45 +00:00
|
|
|
require( 'options/rest-api.php' );
|
2022-07-27 18:01:18 +00:00
|
|
|
require( 'tools/delete-all-products.php' );
|
2021-08-12 16:57:41 +00:00
|
|
|
require( 'tools/disable-wc-email.php' );
|
2021-11-17 22:08:52 +00:00
|
|
|
require( 'tools/trigger-update-callbacks.php' );
|
2022-07-27 18:01:18 +00:00
|
|
|
require( 'tracks/class-tracks-debug-log.php' );
|
2022-03-15 14:09:40 +00:00
|
|
|
require( 'features/features.php' );
|
2022-04-13 20:42:37 +00:00
|
|
|
require( 'rest-api-filters/rest-api-filters.php' );
|
|
|
|
require( 'rest-api-filters/hook.php' );
|