c310352169848f49e91d780867d9c7d881be59b0.svn-base 4.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
<?php

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

class RAM_REST_Options_Controller  extends WP_REST_Controller{

    public function __construct() {
        
        $this->namespace     = 'watch-life-net/v1';
        $this->resource_name = 'options';
    }

    // Register our routes.
    public function register_routes() {
        register_rest_route( $this->namespace, '/' . $this->resource_name.'/enableComment', array(
            // Here we register the readable endpoint for collections.
            array(
                'methods'   => 'GET',
                'callback'  => array( $this, 'getEnableComment' ),
                'permission_callback' => array( $this, 'get_item_permissions_check' )
                 
            ),
            // Register our schema callback.
            'schema' => array( $this, 'get_public_item_schema' ),
        ) );

        register_rest_route( $this->namespace, '/' . $this->resource_name, array(
            // Here we register the readable endpoint for collections.
            array(
                'methods'   => 'GET',
                'callback'  => array( $this, 'get_item' ),
                'permission_callback' => array( $this, 'get_item_permissions_check' )
                 
            ),
            // Register our schema callback.
            'schema' => array( $this, 'get_public_item_schema' ),
        ) );
         

        register_rest_route( $this->namespace, '/' . $this->resource_name.'/homeconfig', array(
            // Here we register the readable endpoint for collections.
            array(
                'methods'   => 'GET',
                'callback'  => array( $this, 'get_homeconfig' ),
                'permission_callback' => array( $this, 'get_item_permissions_check' ),
            ),
            // Register our schema callback.
            'schema' => array( $this, 'get_public_item_schema' ),
        ) );

    }

    public function get_homeconfig($request)
    {
       
        $expand=get_option('minapper_expand_settings_page');
        $downloadfileDomain=get_option('wf_downloadfile_domain');
        $businessDomain=get_option('wf_business_domain');
        $result["downloadfileDomain"] =$downloadfileDomain;
        $result["businessDomain"] =$businessDomain;

        $zanImageurl=get_option('wf_zan_imageurl');
        $logoImageurl=get_option('wf_logo_imageurl');
        $result["zanImageurl"] =$zanImageurl;
        $result["logoImageurl"] =$logoImageurl;

        $swipe_nav =$expand['swipe_nav'];
        $selected_nav=$expand['selected_nav'];       
        $_expand['swipe_nav']=$swipe_nav;
        $_expand['selected_nav']=$selected_nav;      
        $result["expand"] =$_expand;
        $response = rest_ensure_response($result);
        return $response;
    
    }
    public function get_item($request)
    {
        $wf_enable_comment_option  =empty(get_option('wf_enable_comment_option'))?"0":get_option('wf_enable_comment_option');
        $interstitialAdId  =empty(get_option('wf_interstitial_ad_id'))?"":get_option('wf_interstitial_ad_id');
        $wf_enterprise_minapp  =empty(get_option('wf_enterprise_minapp'))?"0":get_option('wf_enterprise_minapp');
       
        $result["wf_enable_comment_option"]=$wf_enable_comment_option;
        $result["interstitialAdId"]=$interstitialAdId;
        $result["wf_enterprise_minapp"]=$wf_enterprise_minapp;
        $response = rest_ensure_response( $result);
        return $response;
    }

    public function getEnableComment($request)
    {
        $wf_enable_comment_option  =get_option('wf_enable_comment_option');
        $interstitial_ad_id  =get_option('wf_interstitial_ad_id');
        if(empty($wf_enable_comment_option ))
        {
            $result["code"]="success";
            $result["message"]= "获取是否开启评论成功";
            $result["status"]="200";
            $result["enableComment"]="0";
        }
        else
        {
            $result["code"]="success";
            $result["message"]= "获取是否开启评论成功";
            $result["status"]="200";
            $result["enableComment"]="1";
            
        }
        $response = rest_ensure_response( $result);
        return $response;
    }


    public function get_item_permissions_check($request ) {      
        
        return true;
    }



}