/**
  * Outputs a JSON-encoded list of posts and terms on the blog.
  * 
  * @since 6.0
  */
 function jlsuggest_autocomplete()
 {
     if (!function_exists('json_encode')) {
         die;
     }
     if (!current_user_can('manage_options')) {
         die;
     }
     $items = array();
     $include = empty($_GET['types']) ? array() : explode(',', $_GET['types']);
     if ((!$include || in_array('home', $include)) && sustr::ihas($_GET['q'], 'home')) {
         $items[] = array('text' => __('Home', 'seo-ultimate'), 'isheader' => true);
         $items[] = array('text' => __('Blog Homepage', 'seo-ultimate'), 'value' => 'obj_home', 'selectedtext' => __('Blog Homepage', 'seo-ultimate'));
     }
     $posttypeobjs = get_post_types(array('public' => true), 'objects');
     foreach ($posttypeobjs as $posttypeobj) {
         if ($include && !in_array('posttype', $include) && !in_array('posttype_' . $posttypeobj->name, $include)) {
             continue;
         }
         $stati = get_available_post_statuses($posttypeobj->name);
         suarr::remove_value($stati, 'auto-draft');
         $stati = implode(',', $stati);
         $posts = get_posts(array('orderby' => 'title', 'order' => 'ASC', 'post_status' => $stati, 'numberposts' => -1, 'post_type' => $posttypeobj->name, 'post_mime_type' => isset($_GET['post_mime_type']) ? $_GET['post_mime_type'] : '', 'sentence' => 1, 's' => $_GET['q']));
         if (count($posts)) {
             $items[] = array('text' => $posttypeobj->labels->name, 'isheader' => true);
             foreach ($posts as $post) {
                 $items[] = array('text' => $post->post_title, 'value' => 'obj_posttype_' . $posttypeobj->name . '/' . $post->ID, 'selectedtext' => $post->post_title . '<span class="type">&nbsp;&mdash;&nbsp;' . $posttypeobj->labels->singular_name . '</span>');
             }
         }
     }
     $taxonomyobjs = suwp::get_taxonomies();
     foreach ($taxonomyobjs as $taxonomyobj) {
         if ($include && !in_array('taxonomy', $include) && !in_array('taxonomy_' . $posttypeobj->name, $include)) {
             continue;
         }
         $terms = get_terms($taxonomyobj->name, array('search' => $_GET['q']));
         if (count($terms)) {
             $items[] = array('text' => $taxonomyobj->labels->name, 'isheader' => true);
             foreach ($terms as $term) {
                 $items[] = array('text' => $term->name, 'value' => 'obj_taxonomy_' . $taxonomyobj->name . '/' . $term->term_id, 'selectedtext' => $term->name . '<span class="type"> &mdash; ' . $taxonomyobj->labels->singular_name . '</span>');
             }
         }
     }
     if (!$include || in_array('author', $include)) {
         $authors = get_users(array('search' => $_GET['q'], 'fields' => array('ID', 'user_login')));
         if (count($authors)) {
             $items[] = array('text' => __('Author Archives', 'seo-ultimate'), 'isheader' => true);
             foreach ($authors as $author) {
                 $items[] = array('text' => $author->user_login, 'value' => 'obj_author/' . $author->ID, 'selectedtext' => $author->user_login . '<span class="type"> &mdash; ' . __('Author', 'seo-ultimate') . '</span>');
             }
         }
     }
     if ($this->module_exists('internal-link-aliases') && (!$include || in_array('internal-link-alias', $include))) {
         $aliases = $this->get_setting('aliases', array(), 'internal-link-aliases');
         $alias_dir = $this->get_setting('alias_dir', 'go', 'internal-link-aliases');
         if (is_array($aliases) && count($aliases)) {
             $header_outputted = false;
             foreach ($aliases as $alias_id => $alias) {
                 if ($alias['to']) {
                     $h_alias_to = su_esc_html($alias['to']);
                     $to_rel_url = "/{$alias_dir}/{$h_alias_to}/";
                     if (strpos($alias['from'], $_GET['q']) !== false || strpos($to_rel_url, $_GET['q']) !== false) {
                         if (!$header_outputted) {
                             $items[] = array('text' => __('Link Masks', 'seo-ultimate'), 'isheader' => true);
                             $header_outputted = true;
                         }
                         $items[] = array('text' => $to_rel_url, 'value' => 'obj_internal-link-alias/' . $alias_id, 'selectedtext' => $to_rel_url . '<span class="type"> &mdash; ' . __('Link Mask', 'seo-ultimate') . '</span>');
                     }
                 }
             }
         }
     }
     echo json_encode($items);
     die;
 }