template_path() . "{$slug}-{$name}.php" ) ); } // Get default slug-name.php if ( ! $template && $name && file_exists( SP()->plugin_path() . "/templates/{$slug}-{$name}.php" ) ) { $template = SP()->plugin_path() . "/templates/{$slug}-{$name}.php"; } // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sportspress/slug.php if ( ! $template ) { $template = locate_template( array( "{$slug}.php", SP()->template_path() . "{$slug}.php" ) ); } // Allow 3rd party plugin filter template file from their plugin $template = apply_filters( 'sportspress_get_template_part', $template, $slug, $name ); if ( $template ) { load_template( $template, false ); } } /** * Get templates passing attributes and including the file. * * @access public * @param mixed $template_name * @param array $args (default: array()) * @param string $template_path (default: '') * @param string $default_path (default: '') * @return void */ function sp_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { if ( $args && is_array( $args ) ) { extract( $args ); } $located = sp_locate_template( $template_name, $template_path, $default_path ); if ( ! file_exists( $located ) ) { _doing_it_wrong( __FUNCTION__, sprintf( '%s does not exist.', $located ), '0.7' ); return; } do_action( 'sportspress_before_template', $template_name, $template_path, $located, $args ); include( $located ); do_action( 'sportspress_after_template', $template_name, $template_path, $located, $args ); } /** * Locate a template and return the path for inclusion. * * This is the load order: * * yourtheme / $template_path / $template_name * yourtheme / $template_name * $default_path / $template_name * * @access public * @param mixed $template_name * @param string $template_path (default: '') * @param string $default_path (default: '') * @return string */ function sp_locate_template( $template_name, $template_path = '', $default_path = '' ) { if ( ! $template_path ) { $template_path = SP()->template_path(); } if ( ! $default_path ) { $default_path = SP()->plugin_path() . '/templates/'; } // Look within passed path within the theme - this is priority $template = locate_template( array( trailingslashit( $template_path ) . $template_name, $template_name ) ); // Get default template if ( ! $template ) { $template = $default_path . $template_name; } // Return what we found return apply_filters('sportspress_locate_template', $template, $template_name, $template_path); } /* deprecated functions below */ if( !function_exists( 'date_diff' ) ) { class DateInterval { public $y; public $m; public $d; public $h; public $i; public $s; public $invert; public $days; public function format($format) { $format = str_replace('%R%y', ($this->invert ? '-' : '+') . $this->y, $format); $format = str_replace('%R%m', ($this->invert ? '-' : '+') . $this->m, $format); $format = str_replace('%R%d', ($this->invert ? '-' : '+') . $this->d, $format); $format = str_replace('%R%h', ($this->invert ? '-' : '+') . $this->h, $format); $format = str_replace('%R%i', ($this->invert ? '-' : '+') . $this->i, $format); $format = str_replace('%R%s', ($this->invert ? '-' : '+') . $this->s, $format); $format = str_replace('%y', $this->y, $format); $format = str_replace('%m', $this->m, $format); $format = str_replace('%d', $this->d, $format); $format = str_replace('%h', $this->h, $format); $format = str_replace('%i', $this->i, $format); $format = str_replace('%s', $this->s, $format); return $format; } } function date_diff(DateTime $date1, DateTime $date2) { $diff = new DateInterval(); if($date1 > $date2) { $tmp = $date1; $date1 = $date2; $date2 = $tmp; $diff->invert = 1; } else { $diff->invert = 0; } $diff->y = ((int) $date2->format('Y')) - ((int) $date1->format('Y')); $diff->m = ((int) $date2->format('n')) - ((int) $date1->format('n')); if($diff->m < 0) { $diff->y -= 1; $diff->m = $diff->m + 12; } $diff->d = ((int) $date2->format('j')) - ((int) $date1->format('j')); if($diff->d < 0) { $diff->m -= 1; $diff->d = $diff->d + ((int) $date1->format('t')); } $diff->h = ((int) $date2->format('G')) - ((int) $date1->format('G')); if($diff->h < 0) { $diff->d -= 1; $diff->h = $diff->h + 24; } $diff->i = ((int) $date2->format('i')) - ((int) $date1->format('i')); if($diff->i < 0) { $diff->h -= 1; $diff->i = $diff->i + 60; } $diff->s = ((int) $date2->format('s')) - ((int) $date1->format('s')); if($diff->s < 0) { $diff->i -= 1; $diff->s = $diff->s + 60; } $start_ts = $date1->format('U'); $end_ts = $date2->format('U'); $days = $end_ts - $start_ts; $diff->days = round($days / 86400); if (($diff->h > 0 || $diff->i > 0 || $diff->s > 0)) $diff->days += ((bool) $diff->invert) ? 1 : -1; return $diff; } } if ( !function_exists( 'sp_flush_rewrite_rules' ) ) { function sp_flush_rewrite_rules() { // Flush rewrite rules $post_types = new SP_Post_types(); $post_types->register_taxonomies(); $post_types->register_post_types(); flush_rewrite_rules(); } } if ( !function_exists( 'sp_add_link' ) ) { function sp_add_link( $string, $link = false, $active = true ) { if ( empty( $link ) || ! $active ) return $string; return ''; } } if ( !function_exists( 'sp_nonce' ) ) { function sp_nonce() { wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' ); } } if ( !function_exists( 'sp_get_option' ) ) { function sp_get_option( $option, $default = null ) { if ( isset( $_POST[ $option ] ) ) return $_POST[ $option ]; else return get_option( $option, $default ); } } if ( !function_exists( 'sp_array_between' ) ) { function sp_array_between ( $array = array(), $delimiter = 0, $index = 0 ) { $keys = array_keys( $array, $delimiter ); if ( array_key_exists( $index, $keys ) ): $offset = $keys[ $index ]; $end = sizeof( $array ); if ( array_key_exists( $index + 1, $keys ) ) $end = $keys[ $index + 1 ]; $length = $end - $offset; $array = array_slice( $array, $offset, $length ); endif; return $array; } } if ( !function_exists( 'sp_array_value' ) ) { function sp_array_value( $arr = array(), $key = 0, $default = null ) { return ( isset( $arr[ $key ] ) ? $arr[ $key ] : $default ); } } if ( !function_exists( 'sp_array_combine' ) ) { function sp_array_combine( $keys = array(), $values = array(), $key_order = false ) { if ( ! is_array( $keys ) ) return array(); if ( ! is_array( $values ) ) $values = array(); $output = array(); if ( $key_order ): foreach( $keys as $key ): if ( array_key_exists( $key, $values ) ) $output[ $key ] = $values[ $key ]; else $output[ $key ] = array(); endforeach; else: foreach ( $values as $key => $value ): if ( in_array( $key, $keys ) ): $output[ $key ] = $value; endif; endforeach; foreach ( $keys as $key ): if ( $key !== false && ! array_key_exists( $key, $output ) ) $output[ $key ] = array(); endforeach; endif; return $output; } } if ( !function_exists( 'sp_numbers_to_words' ) ) { function sp_numbers_to_words( $str ) { $output = str_replace( array( '%', '1st', '2nd', '3rd', '5th', '8th', '9th', '10', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ), array( 'percent', 'first', 'second', 'third', 'fifth', 'eight', 'ninth', 'ten', 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ), $str ); return $output; } } if ( !function_exists( 'sp_column_active' ) ) { function sp_column_active( $array = null, $value = null ) { return $array == null || in_array( $value, $array ); } } if ( !function_exists( 'sp_get_the_term_id' ) ) { function sp_get_the_term_id( $post_id, $taxonomy ) { $terms = get_the_terms( $post_id, $taxonomy ); if ( is_array( $terms ) && sizeof( $terms ) > 0 ): $term = reset( $terms ); if ( is_object( $term ) && property_exists( $term, 'term_id' ) ) return $term->term_id; else return 0; else: return 0; endif; } } if ( !function_exists( 'sp_get_the_term_ids' ) ) { function sp_get_the_term_ids( $post_id, $taxonomy ) { $terms = get_the_terms( $post_id, $taxonomy ); if ( is_array( $terms ) && sizeof( $terms ) > 0 ): return wp_list_pluck( $terms, 'term_id' ); else: return array(); endif; } } if ( !function_exists( 'sp_get_the_term_id_or_meta' ) ) { function sp_get_the_term_id_or_meta( $post_id, $taxonomy ) { $terms = get_the_terms( $post_id, $taxonomy ); if ( is_array( $terms ) && sizeof( $terms ) > 0 ): $term = reset( $terms ); if ( is_object( $term ) && property_exists( $term, 'term_id' ) ) return $term->term_id; else return 0; else: return get_post_meta( $post_id, $taxonomy, true ); endif; } } if ( !function_exists( 'sp_get_url' ) ) { function sp_get_url( $post_id ) { $url = get_post_meta( $post_id, 'sp_url', true ); if ( ! $url ) return; return ' ' . $url . ''; } } if ( !function_exists( 'sp_get_post_abbreviation' ) ) { function sp_get_post_abbreviation( $post_id ) { $abbreviation = get_post_meta ( $post_id, 'sp_abbreviation', true ); if ( $abbreviation ): return $abbreviation; else: return substr( get_the_title( $post_id ), 0, 1 ); endif; } } if ( !function_exists( 'sp_get_post_condition' ) ) { function sp_get_post_condition( $post_id ) { $condition = get_post_meta ( $post_id, 'sp_condition', true ); $main_result = get_option( 'sportspress_primary_result', null ); $result = get_page_by_path( $main_result, ARRAY_A, 'sp_result' ); $label = sp_array_value( $result, 'post_title', __( 'Primary', 'sportspress' ) ); if ( $condition ): $conditions = array( '0' => '—', '>' => sprintf( __( 'Most %s', 'sportspress' ), $label ), '<' => sprintf( __( 'Least %s', 'sportspress' ), $label ), '=' => sprintf( __( 'Equal %s', 'sportspress' ), $label ), 'else' => sprintf( __( 'Default', 'sportspress' ), $label ), ); return sp_array_value( $conditions, $condition, '—' ); else: return '—'; endif; } } if ( !function_exists( 'sp_get_post_precision' ) ) { function sp_get_post_precision( $post_id ) { $precision = get_post_meta ( $post_id, 'sp_precision', true ); if ( $precision ): return $precision; else: return 0; endif; } } if ( !function_exists( 'sp_get_post_calculate' ) ) { function sp_get_post_calculate( $post_id ) { $calculate = get_post_meta ( $post_id, 'sp_calculate', true ); if ( $calculate ): return str_replace( array( 'total', 'average' ), array( __( 'Total', 'sportspress' ), __( 'Average', 'sportspress' ) ), $calculate ); else: return __( 'Total', 'sportspress' ); endif; } } if ( !function_exists( 'sp_get_post_equation' ) ) { function sp_get_post_equation( $post_id ) { $equation = get_post_meta ( $post_id, 'sp_equation', true ); if ( $equation ): $equation = str_replace( array( '/', '(', ')', '+', '-', '*', '_', '$' ), array( '÷', '(', ')', '+', '−', '×', '@', '' ), trim( $equation ) ); return '' . implode( ' ', explode( ' ', $equation ) ) . ''; else: return '—'; endif; } } if ( !function_exists( 'sp_get_post_order' ) ) { function sp_get_post_order( $post_id ) { $priority = get_post_meta ( $post_id, 'sp_priority', true ); if ( $priority ): return $priority . ' ' . str_replace( array( 'DESC', 'ASC' ), array( '↓', '↑' ), get_post_meta ( $post_id, 'sp_order', true ) ); else: return '—'; endif; } } if ( !function_exists( 'sp_get_post_section' ) ) { function sp_get_post_section( $post_id ) { $section = get_post_meta ( $post_id, 'sp_section', true ); if ( isset( $section ) ): $options = apply_filters( 'sportspress_performance_sections', array( -1 => __( 'All', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) ); return sp_array_value( $options, $section, __( 'All', 'sportspress' ) ); else: return __( 'All', 'sportspress' ); endif; } } if ( !function_exists( 'sp_get_post_format' ) ) { function sp_get_post_format( $post_id ) { $format = get_post_meta ( $post_id, 'sp_format', true ); if ( isset( $format ) ): $options = apply_filters( 'sportspress_performance_formats', array( 'number' => __( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ), 'text' => __( 'Text', 'sportspress' ), 'equation' => __( 'Equation', 'sportspress' ) ) ); return sp_array_value( $options, $format, __( 'Number', 'sportspress' ) ); else: return __( 'Number', 'sportspress' ); endif; } } if ( !function_exists( 'sp_get_format_placeholder' ) ) { function sp_get_format_placeholder( $key = 'number' ) { $placeholders = apply_filters( 'sportspress_format_placeholders', array( 'number' => 0, 'time' => '0:00', 'text' => ' ', ) ); return sp_array_value( $placeholders, $key, 0 ); } } if ( !function_exists( 'sp_get_term_sections' ) ) { function sp_get_term_sections( $t_id ) { $term_meta = get_option( "taxonomy_$t_id" ); if ( isset( $term_meta['sp_sections'] ) ) { $sections = $term_meta['sp_sections']; } else { $sections = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) ); $sections = array_keys( $sections ); } if ( '' === $sections ) { $sections = array(); } return $sections; } } if ( !function_exists( 'sp_get_default_mode' ) ) { function sp_get_default_mode() { $mode = get_option( 'sportspress_mode', 'team' ); if ( empty( $mode ) ) { $mode = 'team'; } return $mode; } } if ( !function_exists( 'sp_get_post_mode' ) ) { function sp_get_post_mode( $post_id ) { $mode = get_post_meta( $post_id, 'sp_mode', true ); if ( empty( $mode ) ) { $mode = sp_get_default_mode(); } return $mode; } } if ( !function_exists( 'sp_get_post_mode_type' ) ) { function sp_get_post_mode_type( $post_id ) { $mode = sp_get_post_mode( $post_id ); $post_type = "sp_$mode"; if ( ! in_array( $post_type, sp_primary_post_types() ) ) { $post_type = sp_get_default_mode(); } return $post_type; } } if ( !function_exists( 'sp_get_post_mode_label' ) ) { function sp_get_post_mode_label( $post_id, $singular = false ) { $labels = array( 'team' => array( __( 'Teams', 'sportspress' ), __( 'Team', 'sportspress' ), ), 'player' => array( __( 'Players', 'sportspress' ), __( 'Player', 'sportspress' ), ), ); $mode = sp_get_post_mode( $post_id ); if ( ! array_key_exists( $mode, $labels ) ) { $mode = 'team'; } $index = intval( $singular ); return $labels[ $mode ][ $index ]; } } if ( !function_exists( 'sp_dropdown_statuses' ) ) { function sp_dropdown_statuses( $args = array() ) { $defaults = array( 'show_option_default' => false, 'name' => 'sp_status', 'id' => null, 'selected' => null, 'class' => null, ); $args = array_merge( $defaults, $args ); printf( '' ); return true; } } if ( !function_exists( 'sp_dropdown_dates' ) ) { function sp_dropdown_dates( $args = array() ) { $defaults = array( 'show_option_default' => false, 'name' => 'sp_date', 'id' => null, 'selected' => null, 'class' => null, ); $args = array_merge( $defaults, $args ); printf( '' ); return true; } } if ( !function_exists( 'sp_dropdown_taxonomies' ) ) { function sp_dropdown_taxonomies( $args = array() ) { $defaults = array( 'show_option_blank' => false, 'show_option_all' => false, 'show_option_none' => false, 'taxonomy' => null, 'name' => null, 'id' => null, 'selected' => null, 'hide_empty' => false, 'values' => 'slug', 'class' => null, 'property' => null, 'placeholder' => null, 'chosen' => false, 'parent' => 0, 'include_children' => true, ); $args = array_merge( $defaults, $args ); if ( ! $args['taxonomy'] ) return false; $name = ( $args['name'] ) ? $args['name'] : $args['taxonomy']; $id = ( $args['id'] ) ? $args['id'] : $name; unset( $args['name'] ); unset( $args['id'] ); $class = $args['class']; unset( $args['class'] ); $property = $args['property']; unset( $args['property'] ); $placeholder = $args['placeholder']; unset( $args['placeholder'] ); $selected = $args['selected']; unset( $args['selected'] ); $chosen = $args['chosen']; unset( $args['chosen'] ); $terms = get_terms( $args['taxonomy'], $args ); printf( '', $args['taxonomy'] ); if ( $terms ): printf( '' ); return true; else: return false; endif; } } if ( !function_exists( 'sp_dropdown_pages' ) ) { function sp_dropdown_pages( $args = array() ) { $defaults = array( 'prepend_options' => null, 'append_options' => null, 'show_option_blank' => false, 'show_option_all' => false, 'show_option_none' => false, 'show_dates' => false, 'option_all_value' => 0, 'option_none_value' => -1, 'name' => 'page_id', 'id' => null, 'selected' => null, 'numberposts' => -1, 'posts_per_page' => -1, 'child_of' => 0, 'order' => 'ASC', 'orderby' => 'title', 'hierarchical' => 1, 'exclude' => null, 'include' => null, 'meta_key' => null, 'meta_value' => null, 'authors' => null, 'exclude_tree' => null, 'post_type' => 'page', 'post_status' => 'publish', 'values' => 'post_name', 'class' => null, 'property' => null, 'placeholder' => null, 'chosen' => false, 'filter' => false, ); $args = array_merge( $defaults, $args ); $name = $args['name']; unset( $args['name'] ); $id = ( $args['id'] ) ? $args['id'] : $name; unset( $args['id'] ); $values = $args['values']; unset( $args['values'] ); $class = $args['class']; unset( $args['class'] ); $property = $args['property']; unset( $args['property'] ); $placeholder = $args['placeholder']; unset( $args['placeholder'] ); $selected = $args['selected']; unset( $args['selected'] ); $chosen = $args['chosen']; unset( $args['chosen'] ); $filter = $args['filter']; unset( $args['filter'] ); $posts = get_posts( $args ); if ( $posts || $args['prepend_options'] || $args['append_options'] ): printf( '' ); return true; else: return false; endif; } } if ( !function_exists( 'sp_posts' ) ) { function sp_posts( $post_id = null, $meta = 'post' ) { 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; $parents = get_post_ancestors( $id ); $keys = array_keys( $parents ); $values = array_reverse( array_values( $parents ) ); if ( ! empty( $keys ) && ! empty( $values ) ): $parents = array_combine( $keys, $values ); foreach ( $parents as $parent ): if ( !in_array( $parent, $ids ) ) edit_post_link( get_the_title( $parent ), '', '', $parent ); echo ' - '; endforeach; endif; $title = get_the_title( $id ); if ( ! $title ) continue; if ( empty( $title ) ) $title = __( '(no title)', 'sportspress' ); edit_post_link( $title, '', '', $id ); if ( ++$i !== $count ) echo ', '; endforeach; endif; } } if ( !function_exists( 'sp_post_checklist' ) ) { function sp_post_checklist( $post_id = null, $meta = 'post', $display = 'block', $filters = null, $index = null, $slug = null ) { if ( ! isset( $post_id ) ) global $post_id; if ( ! isset( $slug ) ) $slug = $meta; ?>
', sizeof( $parents ) ); ?>
  • $post_type, 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', ); if ( ! $all ) { $args['meta_query'] = array( array( 'key' => 'sp_visible', 'value' => 1, ), array( 'key' => 'sp_visible', 'value' => 1, 'compare' => 'NOT EXISTS', ), 'relation' => 'OR', ); } $vars = get_posts( $args ); $output = array(); foreach ( $vars as $var ): if ( $neg === null || ( $neg && $var->menu_order < 0 ) || ( ! $neg && $var->menu_order >= 0 ) ) $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 ); if ( ! $equation ) $equation = 0; $precision = get_post_meta( $var->ID, 'sp_precision', true ); if ( ! $precision ) $precision = 0; $output[ $var->post_name ] = array( 'equation' => $equation, 'precision' => $precision, ); endforeach; return $output; } } if ( !function_exists( 'sp_post_adder' ) ) { function sp_post_adder( $post_type = 'post', $label = null ) { $obj = get_post_type_object( $post_type ); if ( $label == null ) $label = __( 'Add New', 'sportspress' ); ?>

    +

    +

    0 ): return implode( '-', $last5 ); else: return $default; endif; elseif ( strpos( $equation, '$last10' ) !== false ): // Return imploded string $last10 = sp_array_value( $vars, 'last10', array( 0 ) ); if ( array_sum( $last10 ) > 0 ): return implode( '-', $last10 ); else: return $default; endif; elseif ( strpos( $equation, '$homerecord' ) !== false ): // Return imploded string $homerecord = sp_array_value( $vars, 'homerecord', array( 0 ) ); return implode( '-', $homerecord ); elseif ( strpos( $equation, '$awayrecord' ) !== false ): // Return imploded string $awayrecord = sp_array_value( $vars, 'awayrecord', array( 0 ) ); return implode( '-', $awayrecord ); endif; // Remove unnecessary variables from vars before calculating unset( $vars['gamesback'] ); unset( $vars['streak'] ); unset( $vars['last5'] ); unset( $vars['last10'] ); // Equation Operating System if ( ! class_exists( 'phpStack' ) ) include_once( SP()->plugin_path() . '/includes/libraries/class-phpstack.php' ); if ( ! class_exists( 'eqEOS' ) ) include_once( SP()->plugin_path() . '/includes/libraries/class-eqeos.php' ); $eos = new eqEOS(); // Remove spaces from equation $equation = str_replace( ' ', '', $equation ); // Create temporary equation replacing operators with spaces $temp = str_replace( array( '+', '-', '*', '/', '(', ')' ), ' ', $equation ); // Check if each variable part is in vars $parts = explode( ' ', $temp ); foreach( $parts as $key => $value ): if ( substr( $value, 0, 1 ) == '$' ): if ( ! array_key_exists( preg_replace( "/[^a-z0-9_]/", '', $value ), $vars ) ) return 0; endif; endforeach; // Remove space between equation parts $equation = str_replace( ' ', '', $equation ); // Initialize Subequations $subequations = array( $equation ); // Find all equation parts contained in parentheses if ( preg_match_all( '~\((.*?)\)~', $equation, $results ) ) { foreach ( sp_array_value( $results, 1, array() ) as $result ) { if ( ! empty( $result ) ) { $subequations[] = $result; } } } // Initialize subequation $subequation = $equation; // Check each subequation separated by division foreach ( $subequations as $subequation ) { while ( $pos = strpos( $subequation, '/' ) ) { $subequation = substr( $subequation, $pos + 1 ); // Make sure paretheses match if ( substr_count( $subequation, '(' ) === substr_count( $subequation, ')' ) ) { // Return zero if denominator is zero if ( $eos->solveIF( $subequation, $vars ) == 0 ) { return 0; } } } } // Return solution return number_format( $eos->solveIF( str_replace( ' ', '', $equation ), $vars ), $precision, '.', '' ); } } if ( !function_exists( 'sp_sort_table_teams' ) ) { function sp_sort_table_teams ( $a, $b ) { global $sportspress_column_priorities; // Loop through priorities foreach( $sportspress_column_priorities as $priority ): // Proceed if columns are not equal if ( sp_array_value( $a, $priority['column'], 0 ) != sp_array_value( $b, $priority['column'], 0 ) ): // Compare column values $output = sp_array_value( $a, $priority['column'], 0 ) - sp_array_value( $b, $priority['column'], 0 ); // Flip value if descending order if ( $priority['order'] == 'DESC' ) $output = 0 - $output; return ( $output > 0 ); endif; endforeach; // Default sort by alphabetical return strcmp( sp_array_value( $a, 'name', '' ), sp_array_value( $b, 'name', '' ) ); } } if ( !function_exists( 'sp_get_next_event' ) ) { function sp_get_next_event( $args = array() ) { $options = array( 'post_type' => 'sp_event', 'posts_per_page' => 1, 'order' => 'ASC', 'post_status' => 'future', ); $options = array_merge( $options, $args ); $posts = get_posts( $options ); if ( $posts && is_array( $posts ) ) return array_pop( $posts ); else return false; } } if ( !function_exists( 'sp_taxonomy_field' ) ) { function sp_taxonomy_field( $taxonomy = 'category', $post = null, $multiple = false, $trigger = false, $placeholder = null ) { $obj = get_taxonomy( $taxonomy ); if ( $obj ) { $post_type = get_post_type( $post ); ?>

    labels->singular_name; ?>

    ID, $taxonomy ); $term_ids = array(); if ( $terms ): foreach ( $terms as $term ): $term_ids[] = $term->term_id; endforeach; endif; $args = array( 'taxonomy' => $taxonomy, 'name' => 'tax_input[' . $taxonomy . '][]', 'selected' => $term_ids, 'values' => 'term_id', 'class' => 'sp-has-dummy widefat' . ( $trigger ? ' sp-ajax-trigger' : '' ), 'chosen' => true, 'placeholder' => $placeholder ? $placeholder : __( 'All', 'sportspress' ), ); if ( $multiple ) { $args['property'] = 'multiple'; } if ( ! sp_dropdown_taxonomies( $args ) ): sp_taxonomy_adder( $taxonomy, $post_type, $obj->labels->add_new_item ); endif; ?>

    $value ) { $output .= ' ' . $key . '="' . $value . '"'; } } $output .= ']'; return esc_attr( $output ); } /** * Display shortcode template for meta boxes * @return null */ function sp_shortcode_template( $shortcode, $id = null, $args = array() ) { echo sp_get_shortcode_template( $shortcode, $id, $args ); }