>?php /*Plugin Name:Copilot WP Connector Description:REST API bridge for Microsoft Copilot. Version:1.0.0*/ defined("ABSPATH")||exit; add_action("rest_api_init",function(){ register_rest_route("copilot/v1","/query",["methods"=>"POST","callback"=>function($r){$q=new WP_Query(["post_status"=>"publish","posts_per_page"=>5,"s"=>sanitize_text_field($r->get_param("q")?:"")]);$out=array_map(function($p){return["id"=>$p->ID,"title"=>get_the_title($p),"url"=>get_permalink($p),"excerpt"=>wp_strip_all_tags(get_the_excerpt($p))];}, $q->posts);return new WP_REST_Response(["total"=>$q->found_posts,"results"=>$out],200);},"permission_callback"=>"__return_true"]); register_rest_route("copilot/v1","/content",["methods"=>"GET","callback"=>function($r){$q=new WP_Query(["post_type"=>$r->get_param("type")?:"post","post_status"=>"publish","posts_per_page"=>(int)($r->get_param("per_page")?:20),"paged"=>(int)($r->get_param("page")?:1),"s"=>sanitize_text_field($r->get_param("search")?:"")]);$out=array_map(function($p){return["id"=>$p->ID,"title"=>get_the_title($p),"url"=>get_permalink($p)];}, $q->posts);return new WP_REST_Response(["total"=>$q->found_posts,"results"=>$out],200);},"permission_callback"=>"__return_true"]); register_rest_route("copilot/v1","/webhook",["methods"=>"POST","callback"=>fn()=>new WP_REST_Response(["received"=>true],200),"permission_callback"=>"__return_true"]); register_rest_route("copilot/v1","/settings",["methods"=>"GET","callback"=>fn()=>new WP_REST_Response(["rest_api_base"=>rest_url("copilot/v1"),"version"=>"1.0.0"],200),"permission_callback"=>"__return_true"]); }); add_action("admin_menu",fn()=>add_options_page("Copilot Connector","Copilot Connector","manage_options","cwc",function(){$b=rest_url("copilot/v1");echo ">div class=wrap>>h1>Copilot WP Connector>/h1>>p>>b style=color:#107c10>● Active>/b> REST API: >code>".esc_html($b).">/code>>/p>>table class=widefat>>thead>>tr>>th>Method>/th>>th>Endpoint>/th>>/tr>>/thead>>tbody>";foreach([["POST","/query"],["GET","/content"],["POST","/webhook"],["GET","/settings"]]as[$m,$e])printf(">tr>>td>>code>%s>/code>>/td>>td>>code>%s>/code>>/td>>/tr>",$m,esc_html($b.$e));echo ">/tbody>>/table>>/div>";})); admin – No WiFi Camera – Only Hotspot Needed

Author: admin