' . $number . ' ' . $title;
endif;
elseif ( is_singular( 'sp_staff' ) ):
$role = get_post_meta( $id, 'sp_role', true );
if ( $role != null ):
$title = '' . $role . ' ' . $title;
endif;
elseif ( is_singular( 'sp_event' ) && get_option( 'sportspress_event_show_logos', 'yes' ) == 'yes' ):
$teams = get_post_meta( $id, 'sp_team' );
if ( $teams ):
$title .= '
';
foreach ( $teams as $team ):
$title .= get_the_post_thumbnail( $team, 'sportspress-fit-icon' ) . ' ';
endforeach;
$title .= '
';
endif;
endif;
endif;
return $title;
}
add_filter( 'the_title', 'sportspress_the_title', 10, 2 );
function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
global $typenow;
if ( is_admin() ):
if ( is_sp_config_type( $typenow ) ):
switch ( $untranslated_text ):
case 'Excerpt':
$translated_text = __( 'Description', 'sportspress' );
break;
case 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. Learn more about manual excerpts.':
$translated_text = __( 'The description is not prominent by default; however, some themes may show it.', 'sportspress' );
break;
case 'Slug':
$translated_text = ( in_array( $typenow, array( 'sp_column', 'sp_statistic' ) ) ) ? __( 'Key', 'sportspress' ) : __( 'Variable', 'sportspress' );
break;
endswitch;
endif;
if ( in_array( $typenow, array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) ) ):
switch ( $untranslated_text ):
case 'Author':
$translated_text = __( 'User', 'sportspress' );
break;
endswitch;
endif;
if ( in_array( $typenow, array( 'sp_player', 'sp_staff' ) ) ):
switch ( $untranslated_text ):
case 'Featured Image':
$translated_text = __( 'Photo', 'sportspress' );
break;
case 'Set Featured Image':
$translated_text = __( 'Select Photo', 'sportspress' );
break;
case 'Set featured image':
$translated_text = __( 'Add photo', 'sportspress' );
break;
case 'Remove featured image':
$translated_text = __( 'Remove photo', 'sportspress' );
break;
endswitch;
endif;
if ( in_array( $typenow, array( 'sp_team' ) ) ):
switch ( $untranslated_text ):
case 'Featured Image':
$translated_text = __( 'Logo', 'sportspress' );
break;
case 'Set Featured Image':
$translated_text = __( 'Select Logo', 'sportspress' );
break;
case 'Set featured image':
$translated_text = __( 'Add logo', 'sportspress' );
break;
case 'Remove featured image':
$translated_text = __( 'Remove logo', 'sportspress' );
break;
endswitch;
endif;
if ( in_array( $typenow, array( 'sp_event' ) ) ):
switch ( $untranslated_text ):
case 'Publish immediately':
$translated_text = __( 'Date/Time:', 'sportspress' ) . ' ' . __( 'Now', 'sportspress' ) . '';
break;
endswitch;
endif;
else:
if ( ! current_theme_supports( 'sportspress' ) && $untranslated_text == 'Archives' && is_tax( 'sp_venue' ) ):
$slug = get_query_var( 'sp_venue' );
if ( $slug ):
$venue = get_term_by( 'slug', $slug, 'sp_venue' );
$translated_text = $venue->name;
endif;
endif;
endif;
return $translated_text;
}
add_filter( 'gettext', 'sportspress_gettext', 20, 3 );
function sportspress_pre_get_posts( $query ) {
if ( is_admin() ):
if ( isset( $query->query[ 'orderby' ] ) || isset( $query->query[ 'order' ] ) ):
return $query;
endif;
$post_type = $query->query['post_type'];
if ( is_sp_config_type( $post_type ) ):
$query->set( 'orderby', 'menu_order' );
$query->set( 'order', 'ASC' );
endif;
else:
if ( isset( $query->query[ 'sp_venue' ] ) ):
$GLOBALS[ 'wp_post_statuses' ][ 'future' ]->public = true;
endif;
endif;
return $query;
}
add_filter('pre_get_posts', 'sportspress_pre_get_posts');
function sp_posts_where( $where, $that ) {
global $wpdb;
if( 'sp_event' == $that->query_vars['post_type'] && is_archive() )
$where = str_replace( "{$wpdb->posts}.post_status = 'publish'", "{$wpdb->posts}.post_status = 'publish' OR $wpdb->posts.post_status = 'future'", $where );
return $where;
}
add_filter( 'posts_where', 'sp_posts_where', 2, 10 );
function sportspress_sanitize_title( $title ) {
if ( isset( $_POST ) && array_key_exists( 'taxonomy', $_POST ) ):
return $title;
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && is_sp_config_type( $_POST['post_type'] ) ):
$key = isset( $_POST['sp_key'] ) ? $_POST['sp_key'] : null;
if ( ! $key ) $key = isset( $_POST['sp_default_key'] ) ? $_POST['sp_default_key'] : null;
if ( ! $key ) $key = $_POST['post_title'];
$id = sp_array_value( $_POST, 'post_ID', 'var' );
$title = sp_get_eos_safe_slug( $key, $id );
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && $_POST['post_type'] == 'sp_event' ):
// Auto slug generation
if ( $_POST['post_title'] == '' && ( $_POST['post_name'] == '' || is_int( $_POST['post_name'] ) ) ):
$title = '';
endif;
endif;
return $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;
$content = do_shortcode( $content );
return $content;
}
add_filter( 'widget_text', 'sportspress_widget_text', 9 );
function sportspress_post_updated_messages( $messages ) {
global $typenow, $post;
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_metric', 'sp_performance' ) ) ):
$obj = get_post_type_object( $typenow );
for ( $i = 0; $i <= 10; $i++ ):
$messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
' ' .
__( 'View All', 'sportspress' ) . '';
endfor;
elseif ( in_array( $typenow, array( 'sp_event', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ):
$obj = get_post_type_object( $typenow );
$messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
' ' . $obj->labels->view_item . '';
$messages['post'][4] = __( 'Changes saved.', 'sportspress' );
$messages['post'][6] = __( 'Success!', 'sportspress' ) .
' ' . $obj->labels->view_item . '';
$messages['post'][7] = __( 'Changes saved.', 'sportspress' );
$messages['post'][8] = __( 'Success!', 'sportspress' ) .
' ' .
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '';
$messages['post'][9] = sprintf(
__( 'Scheduled for: %1$s.', 'sportspress' ),
date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) .
' ' .
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '';
$messages['post'][10] = __( 'Success!', 'sportspress' ) .
' ' .
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '';
endif;
return $messages;
}
add_filter('post_updated_messages', 'sportspress_post_updated_messages');