Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dev filters to decide where to move the country fields (or not move) #53

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions js/countries-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ jQuery(document).ready(function($){
jQuery('#bstate').attr('data-value', 'shortcode');

//move #bcountry field and label above #bfirstname field and label
var bcountryDiv = jQuery('label[for="bcountry"]').closest('div');
bcountryDiv.insertBefore(jQuery('label[for="bfirstname"]').closest('div'));
if (pmpro_state_dropdowns.bcountry_before_field) {
var bcountryDiv = jQuery('label[for="bcountry"]').closest('div');
bcountryDiv.insertBefore(jQuery('label[for="' + pmpro_state_dropdowns.bcountry_before_field + '"]').closest('div'));
}

window.crs.init()
}

Expand All @@ -35,8 +38,11 @@ jQuery(document).ready(function($){
jQuery("#sstate").attr('data-value', 'shortcode');

//move #scountry field and label above #sfirstname field and label
var scountryDiv = jQuery('label[for="scountry"]').closest('div');
scountryDiv.insertBefore(jQuery('label[for="sfirstname"]').closest('div'));
if (pmpro_state_dropdowns.scountry_before_field) {
var scountryDiv = jQuery('label[for="scountry"]').closest('div');
scountryDiv.insertBefore(jQuery('label[for="' + pmpro_state_dropdowns.scountry_before_field + '"]').closest('div'));
}

window.crs.init()
}

Expand Down
3 changes: 3 additions & 0 deletions pmpro-state-dropdowns.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public static function enqueue_styles_scripts(){
$user_saved_countries['bstate'] = $morder->billing->state;
}

$user_saved_countries['bcountry_before_field'] = apply_filters( 'pmpro_state_dropdowns_bcountry_before_field', 'bfirstname' );
$user_saved_countries['scountry_before_field'] = apply_filters( 'pmpro_state_dropdowns_scountry_before_field', 'sfirstname' );

wp_localize_script( 'pmpro-countries-main', 'pmpro_state_dropdowns', $user_saved_countries );

/**
Expand Down