Fix notice if term is not found

Fixes #11005
This commit is contained in:
Mike Jolley 2016-05-31 11:17:28 +01:00
parent 19c6b0fead
commit b8d76baa99
1 changed files with 9 additions and 8 deletions

View File

@ -147,20 +147,21 @@ function wc_products_rss_feed() {
} elseif ( is_tax( 'product_cat' ) ) {
$term = get_term_by('slug', esc_attr( get_query_var('product_cat') ), 'product_cat');
$term = get_term_by( 'slug', esc_attr( get_query_var('product_cat') ), 'product_cat' );
$feed = add_query_arg('product_cat', $term->slug, get_post_type_archive_feed_link( 'product' ));
echo '<link rel="alternate" type="application/rss+xml" title="' . esc_attr( sprintf( __( 'New products added to %s', 'woocommerce' ), $term->name ) ) . '" href="' . esc_url( $feed ) . '" />';
if ( $term ) {
$feed = add_query_arg( 'product_cat', $term->slug, get_post_type_archive_feed_link( 'product' ) );
echo '<link rel="alternate" type="application/rss+xml" title="' . esc_attr( sprintf( __( 'New products added to %s', 'woocommerce' ), $term->name ) ) . '" href="' . esc_url( $feed ) . '" />';
}
} elseif ( is_tax( 'product_tag' ) ) {
$term = get_term_by('slug', esc_attr( get_query_var('product_tag') ), 'product_tag');
$feed = add_query_arg('product_tag', $term->slug, get_post_type_archive_feed_link( 'product' ));
echo '<link rel="alternate" type="application/rss+xml" title="' . sprintf(__( 'New products tagged %s', 'woocommerce' ), urlencode($term->name)) . '" href="' . esc_url( $feed ) . '" />';
if ( $term ) {
$feed = add_query_arg('product_tag', $term->slug, get_post_type_archive_feed_link( 'product' ));
echo '<link rel="alternate" type="application/rss+xml" title="' . sprintf(__( 'New products tagged %s', 'woocommerce' ), urlencode($term->name)) . '" href="' . esc_url( $feed ) . '" />';
}
}
}