<?php

if(!defined('ABSPATH'))
    exit;

class SyrusRestApi {

    public function initialize() {

        $this->register_routes();
    }

    private function register_routes() {
        register_rest_route( 'syrus/v1', "/theme-version",[
            'methods' => 'GET',
            'callback' => [$this,'rest_api_version'],
            'permission_callback' => '__return_true'
        ]);
        
        register_rest_route( 'syrus/v1', "/site-language",[
            'methods' => 'GET',
            'callback' => [$this,'rest_api_language'],
            'permission_callback' => '__return_true'
        ]);
        
        register_rest_route( 'syrus/v1', "/site-timezone",[
            'methods' => 'GET',
            'callback' => [$this,'rest_api_timezone'],
            'permission_callback' => '__return_true'
        ]);
    }

    public function rest_api_version(WP_REST_Request $request) {
        echo json_encode([
          'version' => wp_get_theme('syrus')->get('Version')
        ]);
    }
      
    public function rest_api_language(WP_REST_Request $request) {
        echo json_encode([
            'language' => get_bloginfo('language')
        ]);
    }
    
    public function rest_api_timezone(WP_REST_Request $request) {
        echo json_encode([
            'timezone' => get_option('timezone_string')
        ]);
    }

}