$name, 'singular_name' => $singular_name, 'all_items' => $name, 'add_new' => sprintf( __( 'Add %s', 'sportspress' ), $singular_name ), 'add_new_item' => sprintf( __( 'Add New %s', 'sportspress' ), $singular_name ), 'edit_item' => sprintf( __( 'Edit %s', 'sportspress' ), $singular_name ), 'new_item' => sprintf( __( 'New %s', 'sportspress' ), $singular_name ), 'view_item' => sprintf( __( 'View %s', 'sportspress' ), $singular_name ), 'search_items' => sprintf( __( 'Search %s', 'sportspress' ), $name ), 'not_found' => sprintf( __( 'No %s found', 'sportspress' ), $lowercase_name ), 'not_found_in_trash' => sprintf( __( 'No %s found in trash', 'sportspress' ), $lowercase_name ), 'parent_item_colon' => sprintf( __( 'Parent %s', 'sportspress' ), $singular_name ) . ':' ); return $labels; } } if ( !function_exists( 'sp_tax_labels' ) ) { function sp_tax_labels( $name, $singular_name, $lowercase_name = null ) { if ( !$lowercase_name ) $lowercase_name = $name; $labels = array( 'name' => $name, 'singular_name' => $singular_name, 'all_items' => sprintf( __( 'All %s', 'sportspress' ), $name ), 'edit_item' => sprintf( __( 'Edit %s', 'sportspress' ), $singular_name ), 'view_item' => sprintf( __( 'View %s', 'sportspress' ), $singular_name ), 'update_item' => sprintf( __( 'Update %s', 'sportspress' ), $singular_name ), 'add_new_item' => sprintf( __( 'Add New %s', 'sportspress' ), $singular_name ), 'new_item_name' => sprintf( __( 'New %s Name', 'sportspress' ), $singular_name ), 'parent_item' => sprintf( __( 'Parent %s', 'sportspress' ), $singular_name ), 'parent_item_colon' => sprintf( __( 'Parent %s', 'sportspress' ), $singular_name ) . ':', 'search_items' => sprintf( __( 'Search %s', 'sportspress' ), $name ), 'not_found' => sprintf( __( 'No %s found', 'sportspress' ), $lowercase_name ) ); return $labels; } } if ( !function_exists( 'sp_get_the_term_id' ) ) { function sp_get_the_term_id( $post_id, $taxonomy, $index ) { $terms = get_the_terms( $post_id, $taxonomy ); if ( is_array( $terms ) && array_key_exists( $index, $terms ) ): $term = $terms[0]; if ( is_object( $term ) && property_exists( $term, 'term_id' ) ) return $term->term_id; else return 0; else: return 0; endif; } } if ( !function_exists( 'sp_dropdown_taxonomies' ) ) { function sp_dropdown_taxonomies( $args = array() ) { $defaults = array( 'show_option_all' => false, 'show_option_none' => false, 'taxonomy' => null, 'name' => null, 'selected' => null ); $args = array_merge( $defaults, $args ); $terms = get_terms( $args['taxonomy'] ); $name = ( $args['name'] ) ? $args['name'] : $args['taxonomy']; if ( $terms ) { printf( '' ); } } } if ( !function_exists( 'sp_dropdown_pages' ) ) { function sp_dropdown_pages( $args = array() ) { $defaults = array( 'show_option_all' => false, 'show_option_none' => false, 'name' => 'page_id', 'selected' => null, 'numberposts' => -1, 'posts_per_page' => -1, 'child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'hierarchical' => 1, 'exclude' => null, 'include' => null, 'meta_key' => null, 'meta_value' => null, 'authors' => null, 'exclude_tree' => null, 'post_type' => 'page' ); $args = array_merge( $defaults, $args ); $name = $args['name']; unset( $args['name'] ); $posts = get_posts( $args ); if ( $posts ) { printf( '' ); } } } if ( !function_exists( 'sp_the_posts' ) ) { function sp_the_posts( $post_id = null, $meta = 'post', $before = '', $sep = ', ', $after = '', $delimiter = ' - ' ) { if ( ! isset( $post_id ) ) global $post_id; $ids = get_post_meta( $post_id, $meta, false ); if ( ( $key = array_search( 0, $ids ) ) !== false ) unset( $ids[ $key ] ); $i = 0; $count = count( $ids ); if ( isset( $ids ) && $ids && is_array( $ids ) && !empty( $ids ) ): foreach ( $ids as $id ): if ( !$id ) continue; if ( !empty( $before ) ): if ( is_array( $before ) && array_key_exists( $i, $before ) ) echo $before[ $i ] . ' - '; else echo $before; endif; $parents = get_post_ancestors( $id ); $parents = array_combine( array_keys( $parents ), array_reverse( array_values( $parents ) ) ); foreach ( $parents as $parent ): if ( !in_array( $parent, $ids ) ) edit_post_link( get_the_title( $parent ), '', '', $parent ); echo $delimiter; endforeach; $title = get_the_title( $id ); if ( empty( $title ) ) $title = __( '(no title)', 'sportspress' ); edit_post_link( $title, '', '', $id ); if ( !empty( $after ) ): if ( is_array( $after ) ): if ( array_key_exists( $i, $after ) && $after[ $i ] != '' ): echo ' - ' . $after[ $i ]; endif; else: echo $after; endif; endif; if ( ++$i !== $count ) echo $sep; endforeach; endif; } } if ( !function_exists( 'sp_the_plain_terms' ) ) { function sp_the_plain_terms( $id, $taxonomy ) { $terms = get_the_terms( $id, $taxonomy ); $arr = array(); foreach( $terms as $term ): $arr[] = $term->name; endforeach; echo implode( ', ', $arr ); } } if ( !function_exists( 'sp_post_checklist' ) ) { function sp_post_checklist( $post_id = null, $meta = 'post', $display = 'block', $filter = null, $index = null ) { if ( ! isset( $post_id ) ) global $post_id; ?>
', sizeof( $parents ) ); ?>
$type, 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'exclude' => $postid ); $vars = get_posts( $args ); // Add extra vars to the array if ( isset( $defaults ) && is_array( $defaults ) ): foreach ( $defaults as $key => $value ): $arr[ $key ] = $value; endforeach; endif; // Add vars to the array if ( isset( $variations ) && is_array( $variations ) ): foreach ( $vars as $var ): if ( $totals ) $arr[ '$' . $var->post_name ] = $var->post_title; foreach ( $variations as $key => $value ): $arr[ '$' . $var->post_name . $key ] = $var->post_title . ' ' . $value; endforeach; endforeach; else: foreach ( $vars as $var ): '$' . $arr[ $var->post_name ] = $var->post_title; endforeach; endif; return (array) $arr; } } if ( !function_exists( 'sp_get_equation_selector' ) ) { function sp_get_equation_selector( $postid, $selected = null, $groups = array() ) { if ( ! isset( $postid ) ) return; // Initialize options array $options = array(); // Add groups to options foreach ( $groups as $group ): switch ( $group ): case 'player_event': $options[ __( 'Events', 'sportspress' ) ] = array( '$eventsattended' => __( 'Attended', 'sportspress' ), '$eventsplayed' => __( 'Played', 'sportspress' ) ); break; case 'team_event': $options[ __( 'Events', 'sportspress' ) ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ) ); break; case 'result': $options[ __( 'Results', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_result', array( 'for' => '→', 'against' => '←' ), null, false ); break; case 'outcome': $options[ __( 'Outcomes', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_outcome', array( 'max' => '↑', 'min' => '↓' ) ); break; case 'stat': $options[ __( 'Statistics', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_stat' ); break; case 'metric': $options[ __( 'Metrics', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_metric' ); break; endswitch; endforeach; // Create array of operators $operators = array( '+' => '+', '-' => '−', '*' => '×', '/' => '÷', '(' => '(', ')' => ')' ); // Add operators to options $options[ __( 'Operators', 'sportspress' ) ] = $operators; // Create array of constants $max = 10; $constants = array(); for ( $i = 1; $i <= $max; $i ++ ): $constants[$i] = $i; endfor; // Add constants to options $options[ __( 'Constants', 'sportspress' ) ] = (array) $constants; ?> $post_type, 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ); if ( $independent ): $args['meta_query'] = array( array( 'key' => 'sp_equation', 'value'=>'' ) ); endif; $vars = get_posts( $args ); $output = array(); foreach ( $vars as $var ): $output[ $var->post_name ] = $var->post_title; endforeach; return $output; } } if ( !function_exists( 'sp_get_var_equations' ) ) { function sp_get_var_equations( $post_type ) { $args = array( 'post_type' => $post_type, 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ); $vars = get_posts( $args ); $output = array(); foreach ( $vars as $var ): $equation = get_post_meta( $var->ID, 'sp_equation', true ); $output[ $var->post_name ] = $equation; endforeach; return $output; } } if ( !function_exists( 'sp_league_table' ) ) { function sp_league_table( $columns = array(), $data = array(), $placeholders = array() ) { ?> $team_stats ): if ( !$team_id ) continue; $div = get_term( $team_id, 'sp_div' ); ?> $label ): $value = sp_array_value( $team_stats, $column, '' ); $placeholder = sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $column, 0 ); ?>
$player_stats ): if ( !$player_id ) continue; $div = get_term( $player_id, 'sp_div' ); ?> $label ): $value = sp_array_value( $player_stats, $column, '' ); $placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 ); ?>
$div_stats ): if ( !$div_id ) continue; $div = get_term( $div_id, 'sp_div' ); ?> $label ): $value = sp_array_value( $div_stats, $column, '' ); $placeholder = sp_array_value( sp_array_value( $placeholders, $div_id, array() ), $column, 0 ); ?>
name; ?>
$team_stats ): if ( empty( $team_stats ) ): ?> $div_stats ): if ( !$div_id ) continue; $div = get_term( $div_id, 'sp_div' ); ?> $label ): $value = sp_array_value( $div_stats, $column, '' ); $placeholder = sp_array_value( sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $div_id, array() ), $column, 0 ); ?>
name; ?>
$team_results ): if ( !$team_id ) continue; ?> $label ): $value = sp_array_value( $team_results, $column, '' ); ?>
'sp_outcome', 'name' => 'sp_results[' . $team_id . '][outcome]', 'show_option_none' => __( '-- Not set --', 'sportspress' ), 'option_none_value' => 0, 'sort_order' => 'ASC', 'sort_column' => 'menu_order', 'selected' => $value ); sp_dropdown_pages( $args ); ?>
$player_metrics ): if ( !$player_id ) continue; ?> $label ): $value = sp_array_value( $player_metrics, $column, '' ); ?> $label ): $player_id = 0; $player_metrics = $data[0]; $value = sp_array_value( $player_metrics, $column, '' ); ?>

+ labels->singular_name ); ?>

' . $value . ''; break; case 'checkbox': echo ''; break; default: echo ''; break; endswitch; } } ?>