Add unique widget option to hide widgets when same as content
This commit is contained in:
@@ -149,6 +149,15 @@ class SP_Settings_General extends SP_Settings_Page {
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Widgets', 'sportspress' ),
|
||||
'desc' => __( 'Unique', 'sportspress' ),
|
||||
'id' => 'sportspress_widget_unique',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => __( 'Hide widget when same as content.', 'sportspress' ),
|
||||
),
|
||||
));
|
||||
|
||||
if ( apply_filters( 'sportspress_enable_header', false ) ) {
|
||||
|
||||
@@ -8,8 +8,14 @@ class SP_Widget_Event_Blocks extends WP_Widget {
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
extract($args);
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
|
||||
$id = empty($instance['id']) ? null : $instance['id'];
|
||||
if ( $id && 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
if ( 'blocks' == $format ) return;
|
||||
}
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
$caption = empty($instance['caption']) ? null : $instance['caption'];
|
||||
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
||||
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
||||
|
||||
@@ -8,8 +8,14 @@ class SP_Widget_Event_Calendar extends WP_Widget {
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
extract($args);
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
|
||||
$id = empty($instance['id']) ? null : $instance['id'];
|
||||
if ( $id && 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
if ( 'calendar' == $format ) return;
|
||||
}
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
||||
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
||||
$date_from = empty($instance['date_from']) ? 'default' : $instance['date_from'];
|
||||
|
||||
@@ -8,8 +8,14 @@ class SP_Widget_Event_List extends WP_Widget {
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
extract($args);
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
|
||||
$id = empty($instance['id']) ? null : $instance['id'];
|
||||
if ( $id && 'yes' == get_option( 'sportspress_widget_unique', 'no' ) && get_the_ID() === $id ) {
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
if ( 'list' == $format ) return;
|
||||
}
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
$caption = empty($instance['caption']) ? null : $instance['caption'];
|
||||
$status = empty($instance['status']) ? 'default' : $instance['status'];
|
||||
$date = empty($instance['date']) ? 'default' : $instance['date'];
|
||||
|
||||
@@ -8,8 +8,13 @@ class SP_Widget_League_Table 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 ) 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'];
|
||||
|
||||
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user