$value) { if (is_array($value)){ $result = array_merge($result, genius_flatten_array_and_remove_duplicates($value));} else {$result[$key] = $value;} } // Remove duplicate entries. $return = array_unique($result); return $return; } /** * Add featured image as background image to post navigation elements. * * @see wp_add_inline_style() */ function genius_post_nav_background() { if ( ! is_single() ) { return; } $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); $css = ''; if ( is_attachment() && 'attachment' == $previous->post_type ) { return; } if ( $previous && has_post_thumbnail( $previous->ID ) ) { $prevThumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), 'genius-navigation' ); $css .= ' .post-navigation .nav-previous { background-image: url(' . esc_url( $prevThumb[0] ) . '); } '; } if ( $next && has_post_thumbnail( $next->ID ) ) { $nextThumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), 'genius-navigation' ); $css .= ' .post-navigation .nav-next { background-image: url(' . esc_url( $nextThumb[0] ) . '); } '; } wp_add_inline_style( 'genius-style', $css ); } add_action( 'wp_enqueue_scripts', 'genius_post_nav_background' );