/**
  * Get set of sitemap link data.
  *
  * @param string $type         Sitemap type.
  * @param int    $max_entries  Entries per sitemap.
  * @param int    $current_page Current page of the sitemap.
  *
  * @return array
  */
 public function get_sitemap_links($type, $max_entries, $current_page)
 {
     global $wpdb;
     $links = array();
     $taxonomy = get_taxonomy($type);
     if ($taxonomy === false || !$this->is_valid_taxonomy($taxonomy->name) || !$taxonomy->public) {
         return $links;
     }
     $steps = $max_entries;
     $offset = $current_page > 1 ? ($current_page - 1) * $max_entries : 0;
     /** This filter is documented in inc/sitemaps/class-taxonomy-sitemap-provider.php */
     $hide_empty = apply_filters('wpseo_sitemap_exclude_empty_terms', true, $taxonomy);
     $terms = get_terms($taxonomy->name, array('hide_empty' => $hide_empty));
     $terms = array_splice($terms, $offset, $steps);
     if (empty($terms)) {
         $terms = array();
     }
     // Grab last modified date.
     $sql = "\n\t\t\tSELECT MAX(p.post_modified_gmt) AS lastmod\n\t\t\tFROM\t{$wpdb->posts} AS p\n\t\t\tINNER JOIN {$wpdb->term_relationships} AS term_rel\n\t\t\t\tON\t\tterm_rel.object_id = p.ID\n\t\t\tINNER JOIN {$wpdb->term_taxonomy} AS term_tax\n\t\t\t\tON\t\tterm_tax.term_taxonomy_id = term_rel.term_taxonomy_id\n\t\t\t\tAND\t\tterm_tax.taxonomy = %s\n\t\t\t\tAND\t\tterm_tax.term_id = %d\n\t\t\tWHERE\tp.post_status IN ('publish','inherit')\n\t\t\t\tAND\t\tp.post_password = ''\n\t\t";
     foreach ($terms as $term) {
         $url = array();
         $tax_noindex = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'noindex');
         $tax_sitemap_inc = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'sitemap_include');
         if ($tax_noindex === 'noindex' && $tax_sitemap_inc !== 'always') {
             continue;
         }
         if ($tax_sitemap_inc === 'never') {
             continue;
         }
         $url['loc'] = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'canonical');
         if (!is_string($url['loc']) || $url['loc'] === '') {
             $url['loc'] = get_term_link($term, $term->taxonomy);
             if ($this->options['trailingslash'] === true) {
                 $url['loc'] = trailingslashit($url['loc']);
             }
         }
         if ($term->count > 10) {
             $url['pri'] = 0.6;
         } elseif ($term->count > 3) {
             $url['pri'] = 0.4;
         } else {
             $url['pri'] = 0.2;
         }
         $url['mod'] = $wpdb->get_var($wpdb->prepare($sql, $term->taxonomy, $term->term_id));
         $url['chf'] = WPSEO_Sitemaps::filter_frequency($term->taxonomy . '_term', 'weekly', $url['loc']);
         $url['images'] = $this->image_parser->get_term_images($term);
         /** This filter is documented at inc/sitemaps/class-post-type-sitemap-provider.php */
         $url = apply_filters('wpseo_sitemap_entry', $url, 'term', $term);
         if (!empty($url)) {
             $links[] = $url;
         }
     }
     return $links;
 }
 /**
  * Produce array of URL parts for given post object.
  *
  * @param object $post Post object to get URL parts for.
  *
  * @return array|bool
  */
 protected function get_url($post)
 {
     $url = array();
     /**
      * Filter the URL Yoast SEO uses in the XML sitemap.
      *
      * Note that only absolute local URLs are allowed as the check after this removes external URLs.
      *
      * @param string $url  URL to use in the XML sitemap
      * @param object $post Post object for the URL.
      */
     $url['loc'] = apply_filters('wpseo_xml_sitemap_post_url', get_permalink($post), $post);
     /**
      * Do not include external URLs.
      *
      * @see https://wordpress.org/plugins/page-links-to/ can rewrite permalinks to external URLs.
      */
     if (false === strpos($url['loc'], $this->get_home_url())) {
         return false;
     }
     $modified = max($post->post_modified_gmt, $post->post_date_gmt);
     if ($modified !== '0000-00-00 00:00:00') {
         $url['mod'] = $modified;
     }
     $url['chf'] = WPSEO_Sitemaps::filter_frequency($post->post_type . '_single', 'weekly', $url['loc']);
     $canonical = WPSEO_Meta::get_value('canonical', $post->ID);
     if ($canonical !== '' && $canonical !== $url['loc']) {
         /*
         Let's assume that if a canonical is set for this page and it's different from
            the URL of this post, that page is either already in the XML sitemap OR is on
            an external site, either way, we shouldn't include it here.
         */
         return false;
     }
     unset($canonical);
     if ($this->options['trailingslash'] === true && $post->post_type !== 'post') {
         $url['loc'] = trailingslashit($url['loc']);
     }
     $url['pri'] = $this->calculate_priority($post);
     $url['images'] = $this->image_parser->get_images($post);
     return $url;
 }