templates->$type; // Combine layout setting with available templates $templates = array_merge( array_flip( $layout ), $templates ); $templates = apply_filters( 'sportspress_' . $type . '_templates', $templates ); // Split templates into sections and tabs $slice = array_search( 'tabs', array_keys( $templates ) ); if ( $slice ) { $section_templates = array_slice( $templates, 0, $slice ); $tab_templates = array_slice( $templates, $slice ); } else { $section_templates = $templates; $tab_templates = array(); } ob_start(); // Before template hook do_action( 'sportspress_before_single_' . $type ); // Loop through sections if ( ! empty( $section_templates ) ) { foreach ( $section_templates as $key => $template ) { // Ignore templates that are unavailable or that have been turned off if ( ! is_array( $template ) ) { continue; } if ( ! isset( $template['option'] ) ) { continue; } if ( 'yes' !== get_option( $template['option'], sp_array_value( $template, 'default', 'yes' ) ) ) { continue; } // Render the template echo '
'; if ( 'content' === $key ) { echo wp_kses_post( $content ); // Template content hook do_action( 'sportspress_single_' . $type . '_content' ); } elseif ( 'excerpt' === $key ) { sp_get_template( 'post-excerpt.php', $atts ); } else { // call_user_func( $template['action'] ); sp_get_template( 'event-' . $key . '.php', $atts ); } echo '
'; } } // After template hook do_action( 'sportspress_after_single_' . $type ); $ob = ob_get_clean(); $tabs = ''; if ( ! empty( $tab_templates ) ) { $i = 0; $tab_content = ''; foreach ( $tab_templates as $key => $template ) { // Ignore templates that are unavailable or that have been turned off if ( ! is_array( $template ) ) { continue; } if ( ! isset( $template['option'] ) ) { continue; } if ( 'yes' !== get_option( $template['option'], sp_array_value( $template, 'default', 'yes' ) ) ) { continue; } // Put tab content into buffer ob_start(); if ( 'content' === $key ) { echo wp_kses_post( $content ); // Template content hook do_action( 'sportspress_single_' . $type . '_content' ); } elseif ( 'excerpt' === $key ) { sp_get_template( 'post-excerpt.php', $atts ); } else { // call_user_func( $template['action'] ); sp_get_template( 'event-' . $key . '.php', $atts ); } $buffer = ob_get_clean(); // Trim whitespace from buffer $buffer = trim( $buffer ); // Continue if tab content is empty if ( empty( $buffer ) ) { continue; } // Get template label $label = sp_array_value( $template, 'label', $template['title'] ); // Add to tabs $tabs .= '
  • ' . apply_filters( 'gettext', $label, $label, 'sportspress' ) . '
  • '; // Render the template $tab_content .= '
    ' . $buffer . '
    '; $i++; } $ob .= '
    '; if ( ! empty( $tabs ) ) { $ob .= ''; } $ob .= $tab_content; $ob .= '
    '; } echo wp_kses_post( $ob ); } }