File: /home/dmhkjfau/public_html/wp-content/plugins/wp-seopress/src/Actions/Api/Options/BotSettings.php
<?php // phpcs:ignore
namespace SEOPress\Actions\Api\Options;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use SEOPress\Core\Hooks\ExecuteHooks;
/**
* Bot Settings
*/
class BotSettings implements ExecuteHooks {
/**
* The Bot Settings hooks.
*
* @since 5.0.0
*/
public function hooks() {
add_action( 'rest_api_init', array( $this, 'register' ) );
}
/**
* The Bot Settings permission check.
*
* @param \WP_REST_Request $request The request.
*
* @since 5.5
*
* @return boolean
*/
public function permissionCheck( \WP_REST_Request $request ) {
return current_user_can( seopress_capability( 'manage_options', 'bot' ) );
}
/**
* The Bot Settings register.
*
* @since 5.5
*
* @return void
*/
public function register() {
register_rest_route(
'seopress/v1',
'/options/bot-settings',
array(
'methods' => 'GET',
'callback' => array( $this, 'processGet' ),
'permission_callback' => array( $this, 'permissionCheck' ),
)
);
}
/**
* The Bot Settings process get.
*
* @param \WP_REST_Request $request The request.
*
* @since 5.5
*/
public function processGet( \WP_REST_Request $request ) {
$options = get_option( 'seopress_bot_option_name' );
if ( empty( $options ) ) {
return new \WP_REST_Response( array() );
}
$data = array();
foreach ( $options as $key => $value ) {
$data[ $key ] = $value;
}
return new \WP_REST_Response( $data );
}
}