Skip to content

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

Open
@giovannetti-eric

Description

@giovannetti-eric

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.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions