The validated entry. */ private function validateSubentries( $entry ) { if ( ! isset( $entry['languages'] ) ) { return $entry; } foreach ( $entry['languages'] as $index => $subentry ) { if ( empty( $subentry['language'] ) || empty( $subentry['location'] ) ) { unset( $entry['languages'][ $index ] ); } } return $entry; } /** * Checks whether the given post should be excluded. * * @since 4.2.4 * * @param int $postId The post ID. * @return bool Whether the post should be excluded. */ private function isExcludedPost( $postId ) { static $excludedPostIds = null; if ( null === $excludedPostIds ) { $excludedPostIds = explode( ', ', aioseo()->sitemap->helpers->excludedPosts() ); $excludedPostIds = array_map( function ( $postId ) { return (int) $postId; }, $excludedPostIds ); } if ( in_array( $postId, $excludedPostIds, true ) ) { return true; } // Let's also check if the post is published and not password-protected. $post = get_post( $postId ); if ( ! is_a( $post, 'WP_Post' ) ) { return true; } if ( ! empty( $post->post_password ) || 'publish' !== $post->post_status ) { return true; } // Now, we must also check for noindex. $metaData = aioseo()->meta->metaData->getMetaData( $post ); if ( ! empty( $metaData->robots_noindex ) ) { return true; } return false; } /** * Checks whether the given term should be excluded. * * @since 4.2.4 * * @param int $termId The term ID. * @return bool Whether the term should be excluded. */ private function isExcludedTerm( $termId ) { static $excludedTermIds = null; if ( null === $excludedTermIds ) { $excludedTermIds = explode( ', ', aioseo()->sitemap->helpers->excludedTerms() ); $excludedTermIds = array_map( function ( $termId ) { return (int) $termId; }, $excludedTermIds ); } if ( in_array( $termId, $excludedTermIds, true ) ) { return true; } // Now, we must also check for noindex. $term = get_term( $termId ); if ( ! is_a( $term, 'WP_Term' ) ) { return true; } // At least one post must be assigned to the term. $posts = aioseo()->core->db->start( 'term_relationships' ) ->select( 'object_id' ) ->where( 'term_taxonomy_id =', $term->term_taxonomy_id ) ->limit( 1 ) ->run() ->result(); if ( empty( $posts ) ) { return true; } $metaData = aioseo()->meta->metaData->getMetaData( $term ); if ( ! empty( $metaData->robots_noindex ) ) { return true; } return false; } }