Skip to content

Instantly share code, notes, and snippets.

Avatar
I love programming...

Nabil Kadimi kadimi

I love programming...
View GitHub Profile
@kadimi
kadimi / wp-disable-comment-on-all-attachments.sh
Last active Sep 8, 2021
Disable comments on all attachments using WP-CLI - #wordpress #spam
View wp-disable-comment-on-all-attachments.sh
# /bin/sh
# Disable comments on all attachment posts using WP-CLI - #wordpress #spam
wp post update --comment_status=closed $(wp post list --post_type=attachment --format=ids)
#
# Sample Output
# =============
# Success: Updated post 3.
View rei-landlist-carousel-autoplay-speed.php
@kadimi
kadimi / ninja-forms-allow-curly-brackets-in-notifications.php
Created May 2, 2021
Allow curly brackets in Ninja Forms notifications.
View ninja-forms-allow-curly-brackets-in-notifications.php
<?php
/**
* Allow text between brackets in Ninja Forms notifications.
*
* - How to Use: wrap the text you want to put inside curly brackets in double square brackets, e.g. `[[tag]]`.
* - Setup: Add this code to your website (I recommend using the plugin Code Snippets).
*
* @author Nabil @ REI Conversion
*/
add_filter( 'ninja_forms_action_email_message', function($message) {
@kadimi
kadimi / sp_bp_sportspress_tab_slug.php
Last active Oct 16, 2020
Custom slug for the SportsPress tab on a BuddyPress profile
View sp_bp_sportspress_tab_slug.php
<?php
/**
* Change this line.
*/
define( 'Custom_BP_SprotsPress_Tab_Slug', 'change-this' );
/**
* Do not change below this line.
@kadimi
kadimi / sort_players_by_title_in_event_editing_pages.php
Created Jul 19, 2020
SportsPress - Sort players by title in event editing pages
View sort_players_by_title_in_event_editing_pages.php
<?php
// SportsPress - Sort players by title in event editing pages
add_action( 'admin_init', function() {
add_filter( 'pre_get_posts', function( $query ) {
if(
get_current_screen()->parent_file === 'edit.php?post_type=sp_player'
&& $query->get( 'post_type' ) === 'sp_player'
) {
$query->set( 'orderby', 'title' );
@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(); ?>