Skip to content

Instantly share code, notes, and snippets.

View a1amin's full-sized avatar
👋
Assalamualaikum wa Rahmatullah!

Al-Amin Khan a1amin

👋
Assalamualaikum wa Rahmatullah!
View GitHub Profile
@a1amin
a1amin / functions.php
Created September 4, 2025 17:59
Directorist - Advanced Location Archive
<?php
/**
* Shortcode: [directorist_advanced_location ...any directorist_location attrs...]
*
* Works on a Directorist location archive where the current term slug
* is available via get_query_var('atbdp_location').
*/
add_shortcode('directorist_advanced_location', function ($atts = [], $content = null) {
// Keep original attributes to pass through to [directorist_location]
@a1amin
a1amin / function.php
Created September 30, 2024 05:18
Directorist - Related listings based on location
add_filter( 'directorist_related_listing_args', function ( $args ) {
$atbd_locs = get_the_terms(get_the_ID(), ATBDP_LOCATION);
$atbd_locs_ids = [];
if ( !empty( $atbd_locs ) ) {
foreach ( $atbd_locs as $atbd_loc ) {
$atbd_locs_ids[] = $atbd_loc->term_id;
}
}
@a1amin
a1amin / function.php
Last active September 26, 2024 04:59
FIX - Multiple Default Directories Issue with WPML
/*
Issue Screenshot: https://share.cleanshot.com/9Bj4SRjS
*/
add_action( 'admin_init', 'atbdp_listing_default_type' );
function atbdp_listing_default_type() {
$default_directory_id = 534; // add directory type id
@a1amin
a1amin / function.php
Created July 28, 2024 07:19
Directorist - Hide Email Fields for Non-Logged In User
/**
Sidebar
*/
add_filter( 'get_the_author_user_email', function ( $value, $user_id, $original_user_id ) {
if ( ! is_user_logged_in() ) {
return '';
}
return $value;
@a1amin
a1amin / function.php
Created July 15, 2024 15:43
Directorist - Eliminate Decimal Point from Pricing
add_filter( 'atbdp_format_amount', 'modify_price_format', 10, 4 );
function modify_price_format( $default, $price, $decimals, $currency_settings ){
if( ! $price ) {
return $default;
}
return number_format_i18n( (float) $price, 0 );
}
@a1amin
a1amin / function
Created May 5, 2024 01:57
Directorist - Search bar at the left sidebar solution in archive page for third party themes. Might need few adjustment while implementing depending on the layout.
.directorist-archive-adv-filter.directorist-advanced-filter{
display: block !important;
}
.directorist-listings-header__left>a{
display: none;
}
@media only screen and (min-width: 768px) {
.directorist-archive-contents{
display: flex;
flex-wrap: wrap;
@a1amin
a1amin / function.php
Created April 3, 2024 08:01
Directorist - Custom Listing URL including the Location SLUG
add_filter( 'atbdp_register_listing_post_type_arguments', function( $args ){
$args[ 'rewrite' ][ 'slug' ] = $args[ 'rewrite' ][ 'slug' ] . "/%" . ATBDP_LOCATION . "%";
return $args;
} );
add_filter( 'post_type_link', function( $post_link, $post ){
$location = get_the_terms( $post, ATBDP_LOCATION );
$city = $location ? $location[0]->slug : 'city';
$post_link = str_replace( '%' . ATBDP_LOCATION . '%', $city, $post_link );
return $post_link;
@a1amin
a1amin / function.php
Last active September 16, 2024 05:39
Directorist - Meta value search with in search bar
add_filter('atbdp_listing_search_query_argument', 'directorist_updated_args_for_searchbar');
function directorist_updated_args_for_searchbar($args)
{
if (isset($_GET['q']) && !empty($_GET['q'])) :
$post_per_page = $args['posts_per_page'];
$args['posts_per_page'] = -1;
$args1 = $args;
$args1['fields'] = 'ids';
$post_args1 = new WP_Query($args1);
@a1amin
a1amin / fee-plans.php
Last active March 13, 2024 04:09
Directorist - Add custom field to the user table on dashboard (backend)
<?php
// Add New Column
add_filter( 'manage_users_columns', function( $columns ){
$columns['user_vat_number'] = 'Vat Number';
return $columns;
} );
// Manipulate the column value
add_filter( 'manage_users_custom_column', function( $column_value, $column_name, $user_id ){
@a1amin
a1amin / fee-plans.php
Created March 5, 2024 06:00
Directorist - Restrict user to create only one post
/*----------------------------------------------*/
/* See screenshot: https://prnt.sc/eRlTV5FQLNrP */
/*----------------------------------------------*/
$used_free_plan = apply_filters( 'directorist_any_plan_used_once', $used_free_plan, $value->ID );