Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Player Stats
- function get_apps_data( $playerID ) {
- $apps = 0; // Total appearances.
- $subs = 0; // Total sub-appearances.
- $goals = 0; // Total goals.
- $query = new WP_Query( array( 'post_type' => 'match' ) );
- $posts = $query->posts;
- foreach($posts as $post) {
- for ( $n = 1; $n <= 18; $n++ ) {
- // Check if the player is $playerID
- $pl = get_post_meta( $post->ID, 'pl' . $n, true );
- if ( $playerID == $pl ) {
- $apps++;
- // Check his sub-out appearance.
- $so = get_post_meta( $post->ID, 'so' . $n, true );
- $subs += $so ? 1 : 0;
- // Check his sub-in appearance.
- $si = get_post_meta( $post->ID, 'si' . $n, true );
- $subs += $si ? 1 : 0;
- }
- // Check if he scored goal {$n}-th.
- $s = get_post_meta( $post->ID, 's' . $n, true );
- if ( $playerID == $s ) {
- $goals++;
- }
- }
- }
- wp_reset_query();
- return compact( 'apps', 'subs', 'goals' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement