Skip to content

Instantly share code, notes, and snippets.

View kadimi's full-sized avatar
I love programming...

Nabil Kadimi kadimi

I love programming...
View GitHub Profile
@kadimi
kadimi / sp_get_event_tournaments_with_example.php
Created April 15, 2023 00:16
Add links to tournaments on events
<?php
function sp_get_event_tournaments($event_id)
{
return get_posts([
'post_type' => 'sp_tournament',
'posts_per_page' => -1,
'meta_query' => [
[
'key' => 'sp_event',
@kadimi
kadimi / sp_get_players_by_team.php
Created April 11, 2023 17:46
SportsPress - Get Players by Team
<?php
function sp_get_players_by_team($team, $current_or_past_or_all = 'all')
{
switch ($current_or_past_or_all) {
case 'current':
$team_key = 'sp_current_team';
break;
case 'past':
$team_key = 'sp_past_team';
@kadimi
kadimi / sportspress-add-player-list-automatically.php
Last active March 24, 2023 13:16
For SportsPress - Add a player list on the fly to the current team.
<?php
/**
* Add a player list on the fly to the current team.
*/
add_action(
'init',
function () {
/**
@kadimi
kadimi / sportspress-custom-past-events-list-columns.php
Created January 29, 2023 18:49
SportsPress - Customize past events list columns
<?php
/**
* Customize past events list columns.
*/
add_action( 'init', function() {
/**
* Desired columns.
*
@kadimi
kadimi / sportspress-fix-offense-defense-stats.php
Last active October 14, 2022 14:34
Fix SportsPress player stats (offense/defense)
<?php
add_filter( 'sportspress_player_data_event_args', function( $args ) {
foreach ( $args[ 'meta_query' ] as &$m ) {
if ( true
&& is_array( $m )
&& array_key_exists( 'key', $m )
&& in_array($m[ 'key' ], [ 'sp_offense', 'sp_defense' ] )
) {
$m = null;
@kadimi
kadimi / sportspress-translate-read-more.php
Created October 5, 2022 13:44
SportsPress - Translate "Read more..."
<?php
add_filter( 'gettext', function( $translated_text, $text, $domain ) {
if ( 'mega-slider' === $domain ) {
if ( 'Read more...' === $text ) {
return 'YOUR TEXT HERE';
}
}
return $translated_text;
}, 10, 3 );
@kadimi
kadimi / removeEndingSubString.js
Created June 26, 2022 15:38
Remove ending substring from a string
/**
* `removeEndingSubString` removes a substring from the end of a string.
*
* It will only remove the exact substring. So if the string doesn't end
* with the substring, nothing happens and the original string is returned
* as is.
*
* @link https://kadimi.com/ | https://gist.github.com/kadimi/32bb8f4cc56224343992806fd0898322
* @author Nabil Kadimi
*
@kadimi
kadimi / no-frontpage-sidebar.php
Last active June 3, 2022 15:11
Remove the sidebar from the front page only - Compatible with ThemeBoy themes.
<?php
/**
* Remove the sidebar from the front page only - Compatible with ThemeBoy themes.
*
* @author Nabil Kadimi
*/
add_filter( 'option_themeboy', function( $value ) {
return is_front_page() ? [ 'sidebar' => 'no' ] + ( array ) $value : $value;
} );
@kadimi
kadimi / sporspress-cursomize-player-details.php
Created April 9, 2022 15:57
SportsPress - Customize Player Details
<?php
add_filter( 'sportspress_player_details', function( $data ) {
$labels_from_to = [
'موضع' => 'المركز',
'الفريق الحالي' => 'النادي',
'المواسم' => 'الموسم الرياضي',
];
@kadimi
kadimi / playlist-dl.sh
Created February 12, 2022 16:48
playlist-dl
youtube-dl -o '%(uploader)s - %(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'