Skip to content

Instantly share code, notes, and snippets.

☕️
I love programming...

Nabil Kadimi kadimi

☕️
I love programming...
Block or report user

Report or block kadimi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kadimi
kadimi / sp_hide_event_forms.php
Created Feb 25, 2020
Do not show user results and user scores forms if the main result is set
View sp_hide_event_forms.php
<?
/**
* Do not show user results and user scores forms if the main result is set.
*/
add_filter( 'sportspress_event_templates', function( $templates ) {
if ( sp_get_main_results( get_the_ID() ) ) {
unset( $templates[ 'user_results' ] );
unset( $templates[ 'user_scores' ] );
}
@kadimi
kadimi / showing-venue-without-events.php
Last active Jan 29, 2020
Force showing venue without events
View showing-venue-without-events.php
<?php
/**
* Force showing venue without events.
*/
add_action( 'loop_no_results', function( $q ) {
/**
* Only once.
*/
@kadimi
kadimi / sp_create_player_lists.php
Last active Dec 4, 2019
Auto-create player lists in SportsPress
View sp_create_player_lists.php
<?php
/**
* Auto-create player lists in SportsPress.
*
* This code will generate player lists for teams without one.
* It's useful if your SportsPress site has a lot of teams and you don't
* want to create player lists one by one.
*
* The code will only work when the parameter `sp_create_player_lists` is
@kadimi
kadimi / taxonomy-venue.php
Created Aug 29, 2019
Venue archive template
View taxonomy-venue.php
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
@kadimi
kadimi / archive-sp_event.php
Last active Jul 13, 2019
SportsPress events archive template using event blocks
View archive-sp_event.php
<?php
/**
* The template for displaying archive pages.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package Rookie
*/
get_header(); ?>
@kadimi
kadimi / playlist-dl.sh
Last active May 17, 2019
Download Playlist
View playlist-dl.sh
youtube-dl -o '%(uploader)s - %(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'
@kadimi
kadimi / sp_players_import_all__teams_current.php
Last active Feb 22, 2019
SportsPress - Make all teams current when importing players
View sp_players_import_all__teams_current.php
<?php
/**
* Add this code to your website, I recommend adding it using the plugin Code Snippets.
* Disable or delete the snippet as soon as you finish importing players.
* `$treshold_in_seconds` should be a little higher than the import duration in seconds.
*
* @author Nabil Kadimi
* @link https://themeboy.com
*/
View sp_get_player_performance.php
<?php
/**
* Get player performance for event.
*
* @param int $player_id Player ID.
* @param int $team_id Team ID.
* @param int $event_id Event ID.
* @return array|false Array of player performance or false
* if one of the parameters is not valid.
View sp_event_results_order_by.php
<?php
// Add this code to your custom template event-results.php, after $data has been filled
$orderBy = 'goals';
$order = 'ASC'; // Or DESC
uasort( $data, function( $a, $b ) use ( $orderBy, $order ) {
return $order === 'DESC'
? $a[ $orderBy ] < $b [ $orderBy ]
@kadimi
kadimi / sp_event_list_players_by_position.php
Last active Dec 17, 2018
Add a column in event lists showing players by position
View sp_event_list_players_by_position.php
<?php
/**
* Example Usage.
*/
sp_event_list_players_by_position( 'team-1', 'Team 1' );
sp_event_list_players_by_position( 'team-2', 'Team 2' );
sp_event_list_players_by_position( 'team-3', 'Team 3' );
sp_event_list_players_by_position( 'team-4', 'Team 4' );
You can’t perform that action at this time.