Add unique widget option to hide widgets when same as content

This commit is contained in:
Brian Miyaji
2015-12-29 15:20:39 +11:00
parent bf5585d805
commit b37991d4f0
6 changed files with 43 additions and 3 deletions

View File

@@ -8,8 +8,16 @@ class SP_Widget_Player_Gallery extends WP_Widget {
function widget( $args, $instance ) {
extract($args);
$id = empty($instance['id']) ? 0 : $instance['id'];
if ( $id <= 0 ) return;
if ( 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
$format = get_post_meta( $id, 'sp_format', true );
if ( 'gallery' == $format ) return;
}
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$caption = empty($instance['caption']) ? null : $instance['caption'];
$number = empty($instance['number']) ? null : $instance['number'];