Skip to content

Instantly share code, notes, and snippets.

View itsmereal's full-sized avatar
🤔

Al-Mamun Talukder itsmereal

🤔
View GitHub Profile
@itsmereal
itsmereal / Readme.md
Created February 19, 2025 20:48
Customize wp_dropdown_pages() Option Labels

Customize wp_dropdown_pages() Option Labels

This WordPress snippet modifies the default output of wp_dropdown_pages() to display page options in the format:

{Page Title} - {slug} ({ID})

Instead of the default page title, each option in the dropdown will now include the page’s slug and ID for better clarity. This is useful for administrators working with multiple pages that might have similar titles.

Usage:

Simply add this snippet to your theme’s functions.php or a custom plugin, and it will automatically apply to all wp_dropdown_pages() calls on your site.

@itsmereal
itsmereal / functions.php
Created August 19, 2024 18:06
Add Class to Gravity Form Hidden Fields
<?php
add_filter( 'gform_field_input', function ( $input, $field, $value, $lead_id, $form_id ) {
if ( $field->inputName !== '' && $field->type == 'hidden' ) {
$input = "<input type='hidden' id='input_{$form_id}_{$field->id}' name='input_{$field->id}' class='{$field->inputName}' value='{$value}'>";
}
return $input;
@itsmereal
itsmereal / functions.php
Created December 22, 2020 09:23
Advanced Custom Fields Conditional Required Field - itsmereal.com
<?php
/**
* ACF Conditional Required Field
*/
function validate_property_size_field( $valid, $value, $field, $input ){
// bail early if value is already invalid
if ( ! $valid ) { return $valid; }
@itsmereal
itsmereal / wc-new-account-notify-admin.php
Last active October 30, 2020 17:59 — forked from woogists/wc-new-account-notify-admin.php
[General Snippets] Notify admin when a new customer account is created and user meta data is saved
<?php
/**
* Notify admin when a new customer account is created and user meta data is saved
* So, you can show user meta data like 'billing_phone' in the email
*/
add_action( 'woocommerce_checkout_update_user_meta', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id ) {
wp_send_new_user_notifications( $customer_id, 'admin' );
@itsmereal
itsmereal / functions.php
Last active July 3, 2020 19:07
Filter for using ACF Repeater Field on Meta Query
<?php
/**
* Filter ACF Meta so repeater fields can be used in meta_query
* Here 'repeater_field' is the repeater field name
*/
function cts_filter_acf_meta( $where ) {
$where = str_replace( "meta_key = 'repeater_field_$", "meta_key LIKE 'repeater_field_%", $where);
return $where;
@itsmereal
itsmereal / style.css
Created July 1, 2020 14:10
Enfold Theme Select2 CSS Fix
.select2-container--default .select2-selection--single {
border-radius: 0 !important;
border-color: #ccc !important;
background-color: #fcfcfc;
height: 36px !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height: 36px !important;
}
@itsmereal
itsmereal / script.js
Created June 25, 2020 06:45
Add '0' to string if HH:MM.SS string is not formatted with double digit seconds
var str = '31:21.92';
var markS = str.match('[^.]*$'); // Find everything after '.'
if (markS.toString().length < 2) { // Check lenght of output
console.log(markS);
console.log(str + '0'); // When oput is less than 2 it needs an extra 0
} else {
console.log(markS);
console.log('It\'s OK');
}
@itsmereal
itsmereal / markup.html
Last active May 13, 2020 11:33
Load Wistia video after preview is clicked in an iframe. Modified from https://stackoverflow.com/a/47715361
<!-- data-embed is wistia video id -->
<!-- extract data-thumb https://wistia.com/support/developers/extracting-thumbnails -->
<div class="wistia" data-embed="919q2r7d8r" data-thumb="6b08c24a857370a2a85a9b22539429340df8db0b">
<div class="play-button"></div>
</div>
<?php
// Add a custom menu item with the URL "_SITEURL_/test" and label "[test]" to see it in action
add_filter('wp_nav_menu', 'menu_shortcodes');
function menu_shortcodes( $menu ){
return str_replace('_SITEURL_',preg_replace("~^(?:f|ht)tps?://~i", '', home_url() ), do_shortcode( $menu ) );
}
@itsmereal
itsmereal / functions.php
Last active December 26, 2015 08:19
BuddyPress Notifications Code prepared for drop down menu. Added CSS for simple navigation output
<?php
function bp_notification_badge() {
if ( is_user_logged_in() ) {
echo '<ul class="noti_nav">';
$notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id() );