Remove view counter
This commit is contained in:
@@ -74,8 +74,7 @@
|
||||
.post-type-sp_calendar .fixed .column-sp_season,
|
||||
.post-type-sp_event .fixed .column-sp_venue,
|
||||
.post-type-sp_calendar .fixed .column-sp_venue,
|
||||
.post-type-sp_player .fixed .column-sp_position,
|
||||
.fixed .column-sp_views {
|
||||
.post-type-sp_player .fixed .column-sp_position {
|
||||
width: 10%;
|
||||
}
|
||||
|
||||
@@ -435,7 +434,6 @@ table.sp_status_table td mark.yes {
|
||||
.fixed .column-sp_league,
|
||||
.fixed .column-sp_season,
|
||||
.fixed .column-sp_venue,
|
||||
.fixed .column-sp_views,
|
||||
.fixed .column-sp_position,
|
||||
.fixed .column-sp_player {
|
||||
display: none;
|
||||
|
||||
@@ -29,7 +29,6 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_calendar_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_calendar_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
add_filter( 'manage_edit-sp_calendar_sortable_columns', array( $this, 'custom_columns_sort' ) );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
@@ -51,7 +50,6 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_events' => __( 'Events', 'sportspress' ),
|
||||
'sp_views' => __( 'Views', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_calendar_admin_columns', $columns );
|
||||
}
|
||||
@@ -95,28 +93,9 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
$calendar = new SP_Calendar( $post_id );
|
||||
echo sizeof( $calendar->data() );
|
||||
break;
|
||||
case 'sp_views':
|
||||
echo sp_get_post_views( $post_id );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make columns sortable
|
||||
*
|
||||
* https://gist.github.com/906872
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $columns
|
||||
* @return array
|
||||
*/
|
||||
public function custom_columns_sort( $columns ) {
|
||||
$custom = array(
|
||||
'sp_views' => 'sp_views',
|
||||
);
|
||||
return wp_parse_args( $custom, $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,6 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_event_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_event_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
add_filter( 'manage_edit-sp_event_sortable_columns', array( $this, 'custom_columns_sort' ) );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
@@ -95,7 +94,6 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_views' => __( 'Views', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_event_admin_columns', $columns );
|
||||
}
|
||||
@@ -149,28 +147,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
case 'sp_venue':
|
||||
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
||||
break;
|
||||
case 'sp_views':
|
||||
echo sp_get_post_views( $post_id );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make columns sortable
|
||||
*
|
||||
* https://gist.github.com/906872
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $columns
|
||||
* @return array
|
||||
*/
|
||||
public function custom_columns_sort( $columns ) {
|
||||
$custom = array(
|
||||
'sp_views' => 'sp_views',
|
||||
);
|
||||
return wp_parse_args( $custom, $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,6 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_list_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_list_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
add_filter( 'manage_edit-sp_list_sortable_columns', array( $this, 'custom_columns_sort' ) );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
@@ -50,7 +49,6 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_player' => __( 'Players', 'sportspress' ),
|
||||
'sp_views' => __( 'Views', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_list_admin_columns', $columns );
|
||||
}
|
||||
@@ -83,28 +81,9 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_views':
|
||||
echo sp_get_post_views( $post_id );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make columns sortable
|
||||
*
|
||||
* https://gist.github.com/906872
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $columns
|
||||
* @return array
|
||||
*/
|
||||
public function custom_columns_sort( $columns ) {
|
||||
$custom = array(
|
||||
'sp_views' => 'sp_views',
|
||||
);
|
||||
return wp_parse_args( $custom, $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,6 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_player_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_player_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
add_filter( 'manage_edit-sp_player_sortable_columns', array( $this, 'custom_columns_sort' ) );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
@@ -67,7 +66,6 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
'sp_views' => __( 'Views', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_player_admin_columns', $columns );
|
||||
}
|
||||
@@ -113,28 +111,9 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
case 'sp_venue':
|
||||
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
||||
break;
|
||||
case 'sp_views':
|
||||
echo sp_get_post_views( $post_id );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make columns sortable
|
||||
*
|
||||
* https://gist.github.com/906872
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $columns
|
||||
* @return array
|
||||
*/
|
||||
public function custom_columns_sort( $columns ) {
|
||||
$custom = array(
|
||||
'sp_views' => 'sp_views',
|
||||
);
|
||||
return wp_parse_args( $custom, $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,6 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_staff_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_staff_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
add_filter( 'manage_edit-sp_staff_sortable_columns', array( $this, 'custom_columns_sort' ) );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
@@ -66,7 +65,6 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
'sp_views' => __( 'Views', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_staff_admin_columns', $columns );
|
||||
}
|
||||
@@ -107,28 +105,9 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
case 'sp_views':
|
||||
echo sp_get_post_views( $post_id );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make columns sortable
|
||||
*
|
||||
* https://gist.github.com/906872
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $columns
|
||||
* @return array
|
||||
*/
|
||||
public function custom_columns_sort( $columns ) {
|
||||
$custom = array(
|
||||
'sp_views' => 'sp_views',
|
||||
);
|
||||
return wp_parse_args( $custom, $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,6 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_table_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_table_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
add_filter( 'manage_edit-sp_table_sortable_columns', array( $this, 'custom_columns_sort' ) );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
@@ -49,7 +48,6 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_views' => __( 'Views', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_table_admin_columns', $columns );
|
||||
}
|
||||
@@ -69,28 +67,9 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||
case 'sp_team':
|
||||
echo sizeof( array_filter( get_post_meta( $post_id, 'sp_team' ) ) );
|
||||
break;
|
||||
case 'sp_views':
|
||||
echo sp_get_post_views( $post_id );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make columns sortable
|
||||
*
|
||||
* https://gist.github.com/906872
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $columns
|
||||
* @return array
|
||||
*/
|
||||
public function custom_columns_sort( $columns ) {
|
||||
$custom = array(
|
||||
'sp_views' => 'sp_views',
|
||||
);
|
||||
return wp_parse_args( $custom, $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,6 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_team_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_team_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
add_filter( 'manage_edit-sp_team_sortable_columns', array( $this, 'custom_columns_sort' ) );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
@@ -65,7 +64,6 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
'sp_views' => __( 'Views', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_team_admin_columns', $columns );
|
||||
}
|
||||
@@ -89,28 +87,9 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
case 'sp_views':
|
||||
echo sp_get_post_views( $post_id );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make columns sortable
|
||||
*
|
||||
* https://gist.github.com/906872
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $columns
|
||||
* @return array
|
||||
*/
|
||||
public function custom_columns_sort( $columns ) {
|
||||
$custom = array(
|
||||
'sp_views' => 'sp_views',
|
||||
);
|
||||
return wp_parse_args( $custom, $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,6 @@ class SP_Admin_CPT {
|
||||
public function __construct() {
|
||||
// Insert into X media browser
|
||||
add_filter( 'media_view_strings', array( $this, 'change_insert_into_post' ) );
|
||||
add_filter( 'request', array( $this, 'custom_columns_orderby' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,28 +62,6 @@ class SP_Admin_CPT {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom column orderby
|
||||
*
|
||||
* http://scribu.net/wordpress/custom-sortable-columns.html#comment-4732
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $vars
|
||||
* @return array
|
||||
*/
|
||||
public function custom_columns_orderby( $vars ) {
|
||||
if (isset( $vars['orderby'] )) :
|
||||
if ( 'sp_views' == $vars['orderby'] ) :
|
||||
$vars = array_merge( $vars, array(
|
||||
'meta_key' => 'sp_views',
|
||||
'orderby' => 'meta_value_num'
|
||||
) );
|
||||
endif;
|
||||
endif;
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
@@ -285,40 +285,6 @@ if ( !function_exists( 'sp_get_the_term_id' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sp_get_post_views' ) ) {
|
||||
function sp_get_post_views( $post_id ) {
|
||||
$count_key = 'sp_views';
|
||||
$count = get_post_meta( $post_id, $count_key, true );
|
||||
if ( $count == '' ):
|
||||
$count = 0;
|
||||
delete_post_meta( $post_id, $count_key );
|
||||
add_post_meta( $post_id, $count_key, '0' );
|
||||
endif;
|
||||
if ( $count == 1 )
|
||||
return __( '1 view', 'sportspress' );
|
||||
else
|
||||
return sprintf( __( '%s views', 'sportspress' ), $count );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sp_set_post_views' ) ) {
|
||||
function sp_set_post_views( $post_id ) {
|
||||
if ( is_preview() )
|
||||
return;
|
||||
|
||||
$count_key = 'sp_views';
|
||||
$count = get_post_meta( $post_id, $count_key, true );
|
||||
if ( $count == '' ):
|
||||
$count = 0;
|
||||
delete_post_meta( $post_id, $count_key );
|
||||
add_post_meta( $post_id, $count_key, '0' );
|
||||
else:
|
||||
$count++;
|
||||
update_post_meta( $post_id, $count_key, $count );
|
||||
endif;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sp_get_post_precision' ) ) {
|
||||
function sp_get_post_precision( $post_id ) {
|
||||
$precision = get_post_meta ( $post_id, 'sp_precision', true );
|
||||
|
||||
@@ -257,14 +257,6 @@ function sportspress_sanitize_title( $title ) {
|
||||
}
|
||||
add_filter( 'sanitize_title', 'sportspress_sanitize_title' );
|
||||
|
||||
function sportspress_content_post_views( $content ) {
|
||||
if ( is_single() || is_page() )
|
||||
sp_set_post_views( get_the_ID() );
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_content_post_views' );
|
||||
add_filter( 'get_the_content', 'sportspress_content_post_views' );
|
||||
|
||||
function sportspress_widget_text( $content ) {
|
||||
if ( ! preg_match( '/\[[\r\n\t ]*(countdown|events?(_|-)(results|details|performance|calendar|list|blocks)|team(_|-)columns|league(_|-)table|player(_|-)(metrics|performance|list|gallery))?[\r\n\t ].*?\]/', $content ) )
|
||||
return $content;
|
||||
|
||||
Reference in New Issue
Block a user