/**
  * @static
  * get_topics_suggestion
  */
 public static function get_topics_suggestion()
 {
     global $nc_controller;
     $query = sanitize_text_field($_GET['term']);
     $topics_array = array();
     if (!$nc_controller->check_nonce_capability("nc_get_topics_nonce")) {
         echo json_encode($topics_array);
         exit;
     }
     if (!empty($query)) {
         $topic_fields = array('topic.guid', 'topic.name');
         $options = array("fields" => $topic_fields, "autosuggest" => true);
         if (isset($_GET['pagesize'])) {
             $options['pagesize'] = absint($_GET['pagesize']);
         }
         try {
             $topics = NC_Plugin_Topic::search(NC_ACCESS_KEY, $query, $options);
         } catch (NC_Plugin_Exception $e) {
             $topics = null;
         }
         if ($topics) {
             foreach ($topics as $topic) {
                 $topics_array[] = array("id" => (string) $topic->guid, "text" => (string) $topic->name);
             }
         }
         echo json_encode($topics_array);
         exit;
     }
 }
 /**
  * NOTE: not using since v 1.0.2
  *  get suggested topics and
  * source from keyword
  *
  * get_suggested_topics_source
  */
 public function get_suggested_topics_source()
 {
     global $nc_controller;
     $result_array = array();
     // check nonce and capability
     if (!$nc_controller->check_nonce_capability("nc_get_source_topic_nonce")) {
         echo json_encode($result_array);
         exit;
     }
     $query = sanitize_text_field($_GET['query']);
     $source_fields = array('source.guid', 'source.name');
     $options = array("fields" => $source_fields, "autosuggest" => true, "pagesize" => 5, 'fulltext' => true);
     // get the sources
     $sources = NC_Plugin_Source::search(NC_ACCESS_KEY, $query, $options);
     if ($sources) {
         foreach ($sources as $source) {
             $result_array[] = array("guid" => (string) $source->guid, "name" => (string) $source->name, "category" => "Sources");
         }
     }
     $topics_fields = array('topic.guid', 'topic.name');
     $topics_options = array('fields' => $topics_fields, "autosuggest" => true, "pagesize" => 5);
     $topics = NC_Plugin_Topic::search(NC_ACCESS_KEY, $query, $topics_options);
     if ($topics) {
         foreach ($topics as $topic) {
             $result_array[] = array("guid" => (string) $topic->guid, "name" => (string) $topic->name, "category" => "Topics");
         }
     }
     echo json_encode($result_array);
     exit;
 }