Skip to content

Handle multiples states / provinces with same locale (country and language) #112

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

Open
giovannetti-eric opened this issue Apr 3, 2018 · 0 comments
Assignees
Milestone

Comments

@giovannetti-eric
Copy link

giovannetti-eric commented Apr 3, 2018

Hi,

First, thank you for this plugin.

My goal is to handle a global canadian website and an individual website for each canadian provinces in French and English. The problem I encounter is it's not possible to register the link between differents pages for websites they have the same locale (the field name is the same: msls_input_en_CA).

screen shot 2018-04-03 at 16 51 45

screen shot 2018-04-03 at 16 51 39

I used an documented action to generate the provinces list in the administration, but I didn't see an existing hook which can solve my problem:

add_action( 'msls_admin_language_section', 'my_msls_admin_language_section', 10, 2 );

function my_msls_admin_language_section( $page, $section ) {
  add_settings_field( 'provinces', __( 'Provinces' ), 'my_provinces', $page, $section );
}

function my_provinces() {

  $options = array(
    'ab' => 'Alberta',
    'bc' => 'British Columbia',
    'pe' => 'Prince Edward Island',
    'mb' => 'Manitoba',
    'nb' => 'New Brunswick',
    'ns' => 'Nova Scotia',
    'on' => 'Ontario',
    'qc' => 'Quebec',
    'sk' => 'Saskatchewan',
    'nl' => 'Newfoundland and Labrador',
    'nu' => 'Nunavut',
    'nt' => 'Northwest Territories',
    'yt' => 'Yukon'
  );

  $select = '<select id="provinces" name="msls[provinces]">';
  $select .= '<option></option>';

  foreach($options as $key => $option) {
    $selected = '';
    if(MslsOptions::instance()->provinces == $key) {
      $selected = 'selected="selected"';
    }

    $select .= '<option value="' . $key . '" ' . $selected . '>' . $option . '</option>';

  }

  $select .= '</select>';

  echo $select;
}

Did I miss a simple solution that could solve my problem?

Thanks.

@giovannetti-eric giovannetti-eric changed the title Handle multiples states/provinces with same locale (country and language) Handle multiples states / provinces with same locale (country and language) Apr 3, 2018
@lloc lloc self-assigned this Feb 24, 2025
@lloc lloc added this to the 3.0.0 milestone Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants