Skip to content

Instantly share code, notes, and snippets.

@brinyemp4
brinyemp4 / How the challenge was solved?
Created April 18, 2023 21:40
A usecase of rebase with solution
Question: Let's say I have a stable project on `master` branch having commit message "A-message", my 2 team members are working on 2 individual features - `useragent` (commit message "B-message") & `base64` (commit message "C-message"). They both have raised 2 different pull requests and I have to take care of both of them, then following solution is helpful.
Challenge is how to set commit history in such manner that over `master` branch, I will have the following sequence.
```
C-message
B-message
A-message
```
Solution:
@brinyemp4
brinyemp4 / functions.php
Last active August 5, 2025 20:46
Country State dropdown on WordPress [inspired from WooCommerce] without any external plugin [Only theme template code & assuming reg-country form field & wrapper]
<?php
function iws_get_states_from_country() {
$states = iws_get_woocommerce_states($_GET['country']);
$response = array();
$response['fieldType'] = count($states)>0?'select':'text';
$response['states'] = $states;
echo json_encode($response);
wp_die();
}
add_action('wp_ajax_get_states_from_country', 'iws_get_states_from_country');
@brinyemp4
brinyemp4 / functions.php
Created August 5, 2025 21:13
Custom registration & profile fields in WordPress without plugin [Only theme template code]
<?php
// Shown only one field example, add more fields as needed
/**
* If you have WooCommerce plugin installed then use the following to display fields on the registration form
* If not then check actions/hooks/filters used on your registration page
* To display registration form fields
*/
function iws_extra_register_fields() {
@brinyemp4
brinyemp4 / functions.php
Created August 5, 2025 21:16
Change default WP registration url
<?php
function iws_load_register_url() {
return site_url('/register');
}
add_filter('register_url', 'iws_load_register_url', 10);
?>
@brinyemp4
brinyemp4 / functions.php
Created August 5, 2025 21:17
Change default WP lost password url
<?php
function iws_load_lostpassword_url() {
return site_url('/reset-password');
}
add_filter('lostpassword_url', 'iws_load_lostpassword_url', 10);
?>