Single visibility option for player profiles
This commit is contained in:
@@ -155,14 +155,6 @@
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.sp-admin-config-table .sp-visibility-icon {
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
.sp-admin-config-table .sp-visibility-icon-visible {
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.sportspress table.form-table .sp-color-option {
|
||||
max-width: 225px;
|
||||
}
|
||||
|
||||
@@ -29,9 +29,6 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
} else {
|
||||
$readonly = false;
|
||||
}
|
||||
|
||||
// Options
|
||||
$visibility_options = apply_filters( 'sportspress_statistic_visibility_options', array( 'sp_event', 'sp_player' ) );
|
||||
|
||||
// Post Meta
|
||||
$section = get_post_meta( $post->ID, 'sp_section', true );
|
||||
@@ -42,9 +39,9 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
if ( '' === $format ) {
|
||||
$format = 'number';
|
||||
}
|
||||
$visibility = get_post_meta( $post->ID, 'sp_visibility', true );
|
||||
if ( ! is_array( $visibility ) ) {
|
||||
$visibility = $visibility_options;
|
||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
||||
if ( '' === $visible ) {
|
||||
$visible = 1;
|
||||
}
|
||||
?>
|
||||
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||
@@ -74,16 +71,23 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Visibility', 'sportspress' ); ?></strong></p>
|
||||
<ul class="categorychecklist form-no-clear">
|
||||
<?php foreach ( $visibility_options as $option ) { $object = get_post_type_object( $option ); ?>
|
||||
<p>
|
||||
<strong><?php _e( 'Visible', 'sportspress' ); ?></strong>
|
||||
<i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Display in player profile?', 'sportspress' ); ?>"></i>
|
||||
</p>
|
||||
<ul class="sp-visible-selector">
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input name="sp_visibility[]" id="sp_visibility_<?php echo $option; ?>" type="checkbox" value="<?php echo $option; ?>" <?php checked( in_array( $option, $visibility ) ); ?>>
|
||||
<?php echo $object->labels->singular_name; ?>
|
||||
<input name="sp_visible" id="sp_visible_yes" type="radio" value="1" <?php checked( $visible ); ?>>
|
||||
<?php _e( 'Yes', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input name="sp_visible" id="sp_visible_no" type="radio" value="0" <?php checked( ! $visible ); ?>>
|
||||
<?php _e( 'No', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
@@ -95,6 +99,6 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
self::delete_duplicate( $_POST );
|
||||
update_post_meta( $post_id, 'sp_section', (int) sp_array_value( $_POST, 'sp_section', -1 ) );
|
||||
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'number' ) );
|
||||
update_post_meta( $post_id, 'sp_visibility', (array) sp_array_value( $_POST, 'sp_visibility', array() ) );
|
||||
update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1 ) );
|
||||
}
|
||||
}
|
||||
@@ -25,15 +25,12 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
|
||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||
$precision = get_post_meta( $post->ID, 'sp_precision', true );
|
||||
$section = get_post_meta( $post->ID, 'sp_section', true );
|
||||
$visibility = get_post_meta( $post->ID, 'sp_visibility', true );
|
||||
|
||||
// Options
|
||||
$visibility_options = apply_filters( 'sportspress_statistic_visibility_options', array( 'sp_event', 'sp_player' ) );
|
||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
||||
|
||||
// Defaults
|
||||
if ( '' === $precision ) $precision = 0;
|
||||
if ( '' === $section ) $section = -1;
|
||||
if ( ! is_array( $visibility ) ) $visibility = $visibility_options;
|
||||
if ( '' === $visible ) $visible = 1;
|
||||
?>
|
||||
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
@@ -55,16 +52,23 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Visibility', 'sportspress' ); ?></strong></p>
|
||||
<ul class="categorychecklist form-no-clear">
|
||||
<?php foreach ( $visibility_options as $option ) { $object = get_post_type_object( $option ); ?>
|
||||
<p>
|
||||
<strong><?php _e( 'Visible', 'sportspress' ); ?></strong>
|
||||
<i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Display in player profile?', 'sportspress' ); ?>"></i>
|
||||
</p>
|
||||
<ul class="sp-visible-selector">
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input name="sp_visibility[]" id="sp_visibility_<?php echo $option; ?>" type="checkbox" value="<?php echo $option; ?>" <?php checked( in_array( $option, $visibility ) ); ?>>
|
||||
<?php echo $object->labels->singular_name; ?>
|
||||
<input name="sp_visible" id="sp_visible_yes" type="radio" value="1" <?php checked( $visible ); ?>>
|
||||
<?php _e( 'Yes', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input name="sp_visible" id="sp_visible_no" type="radio" value="0" <?php checked( ! $visible ); ?>>
|
||||
<?php _e( 'No', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
@@ -76,7 +80,7 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
|
||||
self::delete_duplicate( $_POST );
|
||||
update_post_meta( $post_id, 'sp_section', (int) sp_array_value( $_POST, 'sp_section', -1 ) );
|
||||
update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) );
|
||||
update_post_meta( $post_id, 'sp_visibility', (array) sp_array_value( $_POST, 'sp_visibility', array() ) );
|
||||
update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1 ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
<?php
|
||||
$visibility_options = apply_filters( 'sportspress_statistic_visibility_options', array( 'sp_event', 'sp_player' ) );
|
||||
$visibility_labels = array();
|
||||
foreach ( $visibility_options as $option ) {
|
||||
$object = get_post_type_object( $option );
|
||||
$visibility_labels[ $option ] = $object->labels->singular_name;
|
||||
}
|
||||
$columns = get_option( 'sportspress_player_columns', 'auto' );
|
||||
?>
|
||||
|
||||
<div class="wrap sportspress sportspress-config-wrap">
|
||||
@@ -145,6 +140,11 @@ foreach ( $visibility_options as $option ) {
|
||||
<tbody>
|
||||
<?php
|
||||
$selection = get_option( 'sportspress_primary_performance', 0 );
|
||||
$mode = get_option( 'sportspress_event_performance_mode', 'values' );
|
||||
$colspan = 7;
|
||||
|
||||
if ( 'icons' === $mode ) $colspan ++;
|
||||
if ( 'auto' === $columns ) $colspan ++;
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'sp_performance',
|
||||
@@ -168,12 +168,19 @@ foreach ( $visibility_options as $option ) {
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="radio" scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
|
||||
<th class="icon" scope="col"><?php _e( 'Icon', 'sportspress' ); ?></th>
|
||||
<?php if ( 'icons' === $mode ) { ?>
|
||||
<th class="icon" scope="col"><?php _e( 'Icon', 'sportspress' ); ?></th>
|
||||
<?php } ?>
|
||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
|
||||
<th scope="col"><?php _e( 'Category', 'sportspress' ); ?></th>
|
||||
<th scope="col"><?php _e( 'Format', 'sportspress' ); ?></th>
|
||||
<th scope="col"><?php _e( 'Visibility', 'sportspress' ); ?></th>
|
||||
<?php if ( 'auto' === $columns ) { ?>
|
||||
<th scope="col">
|
||||
<?php _e( 'Visible', 'sportspress' ); ?>
|
||||
<i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Display in player profile?', 'sportspress' ); ?>"></i>
|
||||
</th>
|
||||
<?php } ?>
|
||||
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
|
||||
<th scope="col" class="edit"></th>
|
||||
</tr>
|
||||
@@ -181,8 +188,10 @@ foreach ( $visibility_options as $option ) {
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th class="radio"><input type="radio" class="sp-primary-performance-option" id="sportspress_primary_performance_0" name="sportspress_primary_performance" value="0" <?php checked( $selection, 0 ); ?>></th>
|
||||
<th class="icon"> </td>
|
||||
<th colspan="6"><label for="sportspress_primary_performance_0">
|
||||
<?php if ( 'icons' === $mode ) { ?>
|
||||
<th class="icon"> </td>
|
||||
<?php } ?>
|
||||
<th colspan="<?php echo $colspan - 1; ?>"><label for="sportspress_primary_performance_0">
|
||||
<?php
|
||||
if ( sizeof( $data ) > 0 ):
|
||||
$default = reset( $data );
|
||||
@@ -196,36 +205,38 @@ foreach ( $visibility_options as $option ) {
|
||||
</tfoot>
|
||||
<?php if ( $data ): $i = 0; foreach ( $data as $row ): ?>
|
||||
<?php
|
||||
$visibility = get_post_meta( $row->ID, 'sp_visibility', true );
|
||||
if ( ! is_array( $visibility ) ) $visibility = $visibility_options;
|
||||
$visible = get_post_meta( $row->ID, 'sp_visible', true );
|
||||
if ( '' === $visible ) $visible = 1;
|
||||
?>
|
||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||
<td class="radio"><input type="radio" class="sp-primary-performance-option" id="sportspress_primary_performance_<?php echo $row->post_name; ?>" name="sportspress_primary_performance" value="<?php echo $row->post_name; ?>" <?php checked( $selection, $row->post_name ); ?>></td>
|
||||
<td class="icon">
|
||||
<?php
|
||||
if ( has_post_thumbnail( $row->ID ) )
|
||||
$icon = get_the_post_thumbnail( $row->ID, 'sportspress-fit-mini' );
|
||||
else
|
||||
$icon = ' ';
|
||||
<?php if ( 'icons' === $mode ) { ?>
|
||||
<td class="icon">
|
||||
<?php
|
||||
if ( has_post_thumbnail( $row->ID ) )
|
||||
$icon = get_the_post_thumbnail( $row->ID, 'sportspress-fit-mini' );
|
||||
else
|
||||
$icon = ' ';
|
||||
|
||||
echo apply_filters( 'sportspress_performance_icon', $icon, $row->ID );
|
||||
?>
|
||||
</td>
|
||||
echo apply_filters( 'sportspress_performance_icon', $icon, $row->ID );
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||
<td><code><?php echo $row->post_name; ?></code></td>
|
||||
<td><?php echo sp_get_post_section( $row->ID ); ?></td>
|
||||
<td><?php echo sp_get_post_format( $row->ID ); ?></td>
|
||||
<td>
|
||||
<?php foreach ( $visibility_options as $option ) { ?>
|
||||
<span class="sp-icon-<?php echo $option; ?> sp-tip sp-visibility-icon<?php if ( in_array( $option, $visibility ) ) { ?> sp-visibility-icon-visible<?php } ?>" title="<?php echo sp_array_value( $visibility_labels, $option, $option ); ?>"></span>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php if ( 'auto' === $columns ) { ?>
|
||||
<td>
|
||||
<?php if ( $visible ) { ?><i class="dashicons dashicons-yes"></i><?php } else { ?> <?php } ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
|
||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; else: ?>
|
||||
<tr class="alternate">
|
||||
<td colspan="8"><?php _e( 'No results found.', 'sportspress' ); ?></td>
|
||||
<td colspan="<?php echo $colspan; ?>"><?php _e( 'No results found.', 'sportspress' ); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
@@ -353,6 +364,10 @@ foreach ( $visibility_options as $option ) {
|
||||
'order' => 'ASC'
|
||||
);
|
||||
$data = get_posts( $args );
|
||||
|
||||
$colspan = 6;
|
||||
|
||||
if ( 'auto' === $columns ) $colspan ++;
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
@@ -367,32 +382,37 @@ foreach ( $visibility_options as $option ) {
|
||||
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
|
||||
<th scope="col"><?php _e( 'Decimal Places', 'sportspress' ); ?></th>
|
||||
<th scope="col"><?php _e( 'Category', 'sportspress' ); ?></th>
|
||||
<th scope="col"><?php _e( 'Visibility', 'sportspress' ); ?></th>
|
||||
<?php if ( 'auto' === $columns ) { ?>
|
||||
<th scope="col">
|
||||
<?php _e( 'Visible', 'sportspress' ); ?>
|
||||
<i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Display in player profile?', 'sportspress' ); ?>"></i>
|
||||
</th>
|
||||
<?php } ?>
|
||||
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
|
||||
<th scope="col" class="edit"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php if ( $data ): $i = 0; foreach ( $data as $row ): ?>
|
||||
<?php
|
||||
$visibility = get_post_meta( $row->ID, 'sp_visibility', true );
|
||||
if ( ! is_array( $visibility ) ) $visibility = $visibility_options;
|
||||
$visible = get_post_meta( $row->ID, 'sp_visible', true );
|
||||
if ( '' === $visible ) $visible = 1;
|
||||
?>
|
||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||
<td><?php echo sp_get_post_equation( $row->ID ); ?></td>
|
||||
<td><?php echo sp_get_post_precision( $row->ID ); ?></td>
|
||||
<td><?php echo sp_get_post_section( $row->ID ); ?></td>
|
||||
<td>
|
||||
<?php foreach ( $visibility_options as $option ) { ?>
|
||||
<span class="sp-icon-<?php echo $option; ?> sp-tip sp-visibility-icon<?php if ( in_array( $option, $visibility ) ) { ?> sp-visibility-icon-visible<?php } ?>" title="<?php echo sp_array_value( $visibility_labels, $option, $option ); ?>"></span>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php if ( 'auto' === $columns ) { ?>
|
||||
<td>
|
||||
<?php if ( $visible ) { ?><i class="dashicons dashicons-yes"></i><?php } else { ?> <?php } ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
|
||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; else: ?>
|
||||
<tr class="alternate">
|
||||
<td colspan="7"><?php _e( 'No results found.', 'sportspress' ); ?></td>
|
||||
<td colspan="<?php echo $colspan; ?>"><?php _e( 'No results found.', 'sportspress' ); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
|
||||
@@ -134,8 +134,8 @@ class SP_Player extends SP_Custom_Post {
|
||||
if ( is_array( $posts ) ) {
|
||||
foreach ( $posts as $post ) {
|
||||
// Get visibility
|
||||
$visibility = get_post_meta( $post->ID, 'sp_visibility', true );
|
||||
if ( ! is_array( $visibility ) || in_array( 'sp_player', $visibility ) ) {
|
||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
||||
if ( '' === $visible || $visible ) {
|
||||
$usecolumns[] = $post->post_name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user