Polylang - Version 0.7.1

Version Description

(2012-02-06)

Download this release

Release Info

Developer Chouby
Plugin Icon 128x128 Polylang
Version 0.7.1
Comparing to
See all releases

Code changes from version 0.7 to 0.7.1

css/admin.css CHANGED
@@ -58,6 +58,10 @@
58
  width : 10%;
59
  }
60
 
 
 
 
 
61
  .pll_icon_add, .pll_icon_edit {
62
  display: block;
63
  width: 16px;
58
  width : 10%;
59
  }
60
 
61
+ th[class*='column-language_'] {
62
+ width: 24px;
63
+ }
64
+
65
  .pll_icon_add, .pll_icon_edit {
66
  display: block;
67
  width: 16px;
doc/documentation-en.odt CHANGED
Binary file
doc/documentation-en.pdf CHANGED
Binary file
flags/en_CA.png ADDED
Binary file
flags/es_CL.png ADDED
Binary file
flags/es_PE.png ADDED
Binary file
flags/pt_BR.png ADDED
Binary file
flags/vi.png ADDED
Binary file
flags/zh_TW.png ADDED
Binary file
include/admin-filters.php CHANGED
@@ -5,7 +5,6 @@ class Polylang_Admin_Filters extends Polylang_Base {
5
  private $options;
6
 
7
  function __construct() {
8
-
9
  // init options often needed
10
  $this->options = get_option('polylang');
11
 
@@ -98,15 +97,8 @@ class Polylang_Admin_Filters extends Polylang_Base {
98
 
99
  // setup js scripts & css styles
100
  function admin_enqueue_scripts() {
101
- wp_enqueue_script('polylang_admin', POLYLANG_URL .'/js/admin.js', array('jquery', 'wp-ajax-response'));
102
- wp_enqueue_style('polylang_admin', POLYLANG_URL .'/css/admin.css');
103
-
104
- // style languages columns in edit and edit-tags
105
- foreach ($this->get_languages_list() as $language)
106
- $classes[] = '.column-language_'.esc_attr($language->slug);
107
-
108
- if (isset($classes))
109
- echo '<style type="text/css">'.implode(',', $classes).' { width: 24px; }</style>';
110
  }
111
 
112
  // adds the language and translations columns (before the date column) in the posts and pages list table
@@ -199,7 +191,6 @@ class Polylang_Admin_Filters extends Polylang_Base {
199
  );
200
  include(PLL_INC.'/post-translations.php'); // allowing to determine the linked posts
201
  echo "</div>\n";
202
-
203
  }
204
 
205
  // ajax response for changing the language in the post metabox
@@ -414,7 +405,7 @@ class Polylang_Admin_Filters extends Polylang_Base {
414
  ($format = get_post_format($post_id)) ? set_post_format($tr_id, $format) : set_post_format($tr_id, '');
415
 
416
  // synchronize metas and allow plugins to do the same
417
- $metas = apply_filters('pll_copy_metas', array('_wp_page_template', '_thumbnail_id'));
418
  foreach ($metas as $meta) {
419
  if ($value = get_post_meta($post_id, $meta, true))
420
  update_post_meta($tr_id, $meta, get_post_meta($post_id, $meta, true));
@@ -468,7 +459,7 @@ class Polylang_Admin_Filters extends Polylang_Base {
468
  // I only want to filter the parent dropdown list when editing a term in a hierarchical taxonomy
469
  if (isset($_POST['action']) && $_POST['action'] == 'term_lang_choice' && !isset($args['class']))
470
  return $clauses;
471
-
472
  global $post_ID;
473
 
474
  // ajax response for changing the language in the post metabox (or in the edit-tags panels)
5
  private $options;
6
 
7
  function __construct() {
 
8
  // init options often needed
9
  $this->options = get_option('polylang');
10
 
97
 
98
  // setup js scripts & css styles
99
  function admin_enqueue_scripts() {
100
+ wp_enqueue_script('polylang_admin', POLYLANG_URL .'/js/admin.js', array('jquery', 'wp-ajax-response'), POLYLANG_VERSION);
101
+ wp_enqueue_style('polylang_admin', POLYLANG_URL .'/css/admin.css', array(), POLYLANG_VERSION);
 
 
 
 
 
 
 
102
  }
103
 
104
  // adds the language and translations columns (before the date column) in the posts and pages list table
191
  );
192
  include(PLL_INC.'/post-translations.php'); // allowing to determine the linked posts
193
  echo "</div>\n";
 
194
  }
195
 
196
  // ajax response for changing the language in the post metabox
405
  ($format = get_post_format($post_id)) ? set_post_format($tr_id, $format) : set_post_format($tr_id, '');
406
 
407
  // synchronize metas and allow plugins to do the same
408
+ $metas = apply_filters('pll_copy_post_metas', array('_wp_page_template', '_thumbnail_id'));
409
  foreach ($metas as $meta) {
410
  if ($value = get_post_meta($post_id, $meta, true))
411
  update_post_meta($tr_id, $meta, get_post_meta($post_id, $meta, true));
459
  // I only want to filter the parent dropdown list when editing a term in a hierarchical taxonomy
460
  if (isset($_POST['action']) && $_POST['action'] == 'term_lang_choice' && !isset($args['class']))
461
  return $clauses;
462
+
463
  global $post_ID;
464
 
465
  // ajax response for changing the language in the post metabox (or in the edit-tags panels)
include/admin.php CHANGED
@@ -385,15 +385,15 @@ class Polylang_Admin extends Polylang_Base {
385
  function validate_lang($lang = null) {
386
  // validate locale
387
  $loc = $_POST['description'];
388
- if ( !preg_match('#^[a-z]{2}$#', $loc) && !preg_match('#^[a-z]{2}_[A-Z]{2}$#', $loc) )
389
  $error = 1;
390
 
391
  // validate slug length
392
- if (strlen($_POST['slug']) != 2)
393
  $error = 2;
394
 
395
  // validate slug is unique
396
- if ($this->get_language($_POST['slug']) != null && isset($lang) && $lang->slug != $_POST['slug'])
397
  $error = 3;
398
 
399
  // validate name
385
  function validate_lang($lang = null) {
386
  // validate locale
387
  $loc = $_POST['description'];
388
+ if ( !preg_match('#^[a-z]{2,3}$#', $loc) && !preg_match('#^[a-z]{2,3}_[A-Z]{2,3}$#', $loc) )
389
  $error = 1;
390
 
391
  // validate slug length
392
+ if (!preg_match('#^[a-z]{2,3}$#', $_POST['slug']))
393
  $error = 2;
394
 
395
  // validate slug is unique
396
+ if ($this->get_language($_POST['slug']) != null && ( $lang === null || (isset($lang) && $lang->slug != $_POST['slug'])))
397
  $error = 3;
398
 
399
  // validate name
include/core.php CHANGED
@@ -249,7 +249,7 @@ class Polylang_Core extends Polylang_base {
249
  if ($this->page_on_front && $link_id = $this->get_post($this->page_on_front, $this->curlang))
250
  $url = _get_page_link($link_id);
251
  else
252
- $url = home_url('?lang='.$this->curlang->slug);
253
 
254
  wp_redirect($url);
255
  exit;
249
  if ($this->page_on_front && $link_id = $this->get_post($this->page_on_front, $this->curlang))
250
  $url = _get_page_link($link_id);
251
  else
252
+ $url = $this->add_language_to_link(home_url(), $this->curlang);
253
 
254
  wp_redirect($url);
255
  exit;
include/languages-form.php CHANGED
@@ -56,8 +56,8 @@ if (isset($_GET['error'])) {?>
56
  <select name="lang_list" id="lang_list">
57
  <option value=""></option>';<?php
58
  include(PLL_INC.'/languages.php');
59
- foreach ($languages as $key=>$lang) {
60
- printf("<option value='%s-%s-%s'>%s</option>\n", esc_attr($key), esc_attr($lang[0]), $lang[2] ? '1' : '0' , esc_html($lang[1]));
61
  } ?>
62
  </select>
63
  <p><?php _e('You can choose a language in the list or directly edit it below.', 'polylang');?></p>
@@ -71,14 +71,14 @@ if (isset($_GET['error'])) {?>
71
 
72
  <div class="form-field form-required">
73
  <label for="description"><?php _e('Locale', 'polylang');?></label><?php
74
- printf('<input name="description" id="description" type="text" value="%s" size="5" maxlength="5" aria-required="true" />',
75
  $action=='edit' ? esc_attr($edit_lang->description) : '');?>
76
  <p><?php _e('Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language.', 'polylang');?></p>
77
  </div>
78
 
79
  <div class="form-field">
80
  <label for="slug"><?php _e('Language code', 'polylang');?></label>
81
- <input name="slug" id="slug" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->slug);?>" size="2" maxlength="2"/>
82
  <p><?php _e('2-letters ISO 639-1 language code (for example: en)', 'polylang');?></p>
83
  </div>
84
 
56
  <select name="lang_list" id="lang_list">
57
  <option value=""></option>';<?php
58
  include(PLL_INC.'/languages.php');
59
+ foreach ($languages as $lg) {
60
+ printf('<option value="%1$s-%2$s-%3$s">%4$s - %2$s</option>'."\n", esc_attr($lg[0]), esc_attr($lg[1]), $lg[3] ? '1' : '0' , esc_html($lg[2]));
61
  } ?>
62
  </select>
63
  <p><?php _e('You can choose a language in the list or directly edit it below.', 'polylang');?></p>
71
 
72
  <div class="form-field form-required">
73
  <label for="description"><?php _e('Locale', 'polylang');?></label><?php
74
+ printf('<input name="description" id="description" type="text" value="%s" size="7" maxlength="7" aria-required="true" />',
75
  $action=='edit' ? esc_attr($edit_lang->description) : '');?>
76
  <p><?php _e('Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language.', 'polylang');?></p>
77
  </div>
78
 
79
  <div class="form-field">
80
  <label for="slug"><?php _e('Language code', 'polylang');?></label>
81
+ <input name="slug" id="slug" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->slug);?>" size="3" maxlength="3"/>
82
  <p><?php _e('2-letters ISO 639-1 language code (for example: en)', 'polylang');?></p>
83
  </div>
84
 
include/languages.php CHANGED
@@ -1,47 +1,57 @@
1
  <?php
 
 
 
 
 
2
  $languages = array(
3
- 'ar'=>array('ar','العربية','rtl'),
4
- 'bg'=>array('bg_BG','български'),
5
- 'bs'=>array('bs_BA','Bosanski'),
6
- 'ca'=>array('ca','Català'),
7
- 'cs'=>array('cs_CZ','Čeština'),
8
- 'da'=>array('da_DK','Dansk'),
9
- 'de'=>array('de_DE','Deutsch'),
10
- 'el'=>array('el','Ελληνικά'),
11
- 'en'=>array('en_US','English'),
12
- 'eo'=>array('eo','Esperanto'),
13
- 'es'=>array('es_ES','Español'),
14
- 'et'=>array('et','Eesti'),
15
- 'fa'=>array('fa_IR','فارسی','rtl'),
16
- 'fi'=>array('fi','Suomi'),
17
- 'fr'=>array('fr_FR','Français'),
18
- 'fy'=>array('fy','Frysk'),
19
- 'gl'=>array('gl_ES','Galego'),
20
- 'he'=>array('he_IL','עברית','rtl'),
21
- 'hr'=>array('hr','Hrvatski'),
22
- 'hu'=>array('hu_HU','Magyar'),
23
- 'id'=>array('id_ID','Bahasa Indonesia'),
24
- 'it'=>array('it_IT','Italiano'),
25
- 'ja'=>array('ja','日本語'),
26
- 'ko'=>array('ko_KR','한국어'),
27
- 'lv'=>array('lv','Latviešu valoda'),
28
- 'mk'=>array('mk_MK','македонски јазик'),
29
- 'my'=>array('my_MM','ဗမာစာ'),
30
- 'nb'=>array('nb_NO','Norsk'),
31
- 'nl'=>array('nl_NL','Nederlands'),
32
- 'pl'=>array('pl_PL','Polski'),
33
- 'pt'=>array('pt_PT','Português'),
34
- 'ru'=>array('ru_RU','Русский'),
35
- 'si'=>array('si_LK','සිංහල'),
36
- 'sk'=>array('sk_SK','Slovenčina'),
37
- 'sl'=>array('sl_SI','Slovenščina'),
38
- 'sq'=>array('sq','Shqip'),
39
- 'sr'=>array('sr_RS','Српски језик'),
40
- 'sv'=>array('sv_SE','Svenska'),
41
- 'th'=>array('th','ไทย'),
42
- 'tr'=>array('tr_TR','Türkçe'),
43
- 'ug'=>array('ug_CN','Uyƣurqə'),
44
- 'uk'=>array('uk','Українська'),
45
- 'zh'=>array('zh_CN','中文'),
 
 
 
 
 
46
  );
47
  ?>
1
  <?php
2
+ // for each language:
3
+ // [0] => ISO 639-1 language code
4
+ // [1] => WordPress locale
5
+ // [2] => name
6
+ // [3] => not set for ltr scripts, 'rtl' otherwise
7
  $languages = array(
8
+ array('ar', 'ar', 'العربية', 'rtl'),
9
+ array('bg', 'bg_BG', 'български'),
10
+ array('bs', 'bs_BA', 'Bosanski'),
11
+ array('ca', 'ca', 'Català'),
12
+ array('cs', 'cs_CZ', 'Čeština'),
13
+ array('da', 'da_DK', 'Dansk'),
14
+ array('de', 'de_DE', 'Deutsch'),
15
+ array('el', 'el', 'Ελληνικά'),
16
+ array('en', 'en_CA', 'English'),
17
+ array('en', 'en_US', 'English'),
18
+ array('eo', 'eo', 'Esperanto'),
19
+ array('es', 'es_CL', 'Español'),
20
+ array('es', 'es_ES', 'Español'),
21
+ array('es', 'es_PE', 'Español'),
22
+ array('et', 'et', 'Eesti'),
23
+ array('fa', 'fa_IR', 'فارسی', 'rtl'),
24
+ array('fi', 'fi', 'Suomi'),
25
+ array('fr', 'fr_FR', 'Français'),
26
+ array('fy', 'fy', 'Frysk'),
27
+ array('gl', 'gl_ES', 'Galego'),
28
+ array('he', 'he_IL', 'עברית', 'rtl'),
29
+ array('hr', 'hr', 'Hrvatski'),
30
+ array('hu', 'hu_HU', 'Magyar'),
31
+ array('id', 'id_ID', 'Bahasa Indonesia'),
32
+ array('it', 'it_IT', 'Italiano'),
33
+ array('ja', 'ja', '日本語'),
34
+ array('ko', 'ko_KR', '한국어'),
35
+ array('lv', 'lv', 'Latviešu valoda'),
36
+ array('mk', 'mk_MK', 'македонски јазик'),
37
+ array('my', 'my_MM', 'ဗမာစာ'),
38
+ array('nb', 'nb_NO', 'Norsk'),
39
+ array('nl', 'nl_NL', 'Nederlands'),
40
+ array('pl', 'pl_PL', 'Polski'),
41
+ array('pt', 'pt_BR', 'Português'),
42
+ array('pt', 'pt_PT', 'Português'),
43
+ array('ru', 'ru_RU', 'Русский'),
44
+ array('si', 'si_LK', 'සිංහල'),
45
+ array('sk', 'sk_SK', 'Slovenčina'),
46
+ array('sl', 'sl_SI', 'Slovenščina'),
47
+ array('sq', 'sq', 'Shqip'),
48
+ array('sr', 'sr_RS', 'Српски језик'),
49
+ array('sv', 'sv_SE', 'Svenska'),
50
+ array('th', 'th', 'ไทย'),
51
+ array('tr', 'tr_TR', 'Türkçe'),
52
+ array('ug', 'ug_CN', 'Uyƣurqə'),
53
+ array('uk', 'uk', 'Українська'),
54
+ array('zh', 'zh_CN', '中文'),
55
+ array('zh', 'zh_TW', '台灣'),
56
  );
57
  ?>
include/list-table.php CHANGED
@@ -70,7 +70,7 @@ class Polylang_List_Table extends WP_List_Table {
70
  */
71
 
72
  function prepare_items($data = array()) {
73
- $per_page = 5; // 5 languages per page
74
  $columns = $this->get_columns();
75
  $hidden = array();
76
  $sortable = $this->get_sortable_columns();
70
  */
71
 
72
  function prepare_items($data = array()) {
73
+ $per_page = 10; // 10 languages per page
74
  $columns = $this->get_columns();
75
  $hidden = array();
76
  $sortable = $this->get_sortable_columns();
js/admin.js CHANGED
@@ -1,3 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  jQuery(document).ready(function($) {
2
 
3
  // collect taxonomies - code partly copied from WordPress
@@ -51,95 +231,38 @@ jQuery(document).ready(function($) {
51
  });
52
 
53
  // modifies the language in the tag cloud
54
- jQuery('.polylang-tagcloud-link').each(function() {
55
  var id = $(this).attr('id');
56
- pll_tagbox(id, 0);
57
  });
58
 
59
  // modifies the language in the tags suggestion input
60
- pll_suggest();
61
  });
62
  });
63
 
64
- // replace WP class by our own
65
- jQuery('a.tagcloud-link').addClass('polylang-tagcloud-link');
66
- jQuery('a.tagcloud-link').removeClass('tagcloud-link');
67
-
68
- // copy paste WP code and just call our pll_tagbox instead of tagbox.get
69
- jQuery('.polylang-tagcloud-link').click( function() {
70
- var id = $(this).attr('id');
71
- pll_tagbox(id, 1);
72
-
73
- $(this).unbind().click(function(){
74
- $(this).siblings('.the-tagcloud').toggle();
75
- return false;
76
- });
77
- return false;
78
- });
79
 
80
- // now copy paste WP code
81
- // add the language in the $_POST variable
82
- // add an if else condition to allow modifying the tags outputed when switching the language
83
- function pll_tagbox(id, a) {
84
- var tax = id.substr(id.indexOf('-')+1);
85
-
86
- var data = {
87
- action: 'get-tagcloud',
88
- lang: jQuery('#post_lang_choice').attr('value'),
89
- tax: tax
90
  }
91
-
92
- $.post(ajaxurl, data, function(r, stat) {
93
- if ( 0 == r || 'success' != stat )
94
- r = wpAjax.broken;
95
-
96
- r = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>');
97
- $('a', r).click(function(){
98
- tagBox.flushTags( $(this).closest('.inside').children('.tagsdiv'), this);
 
 
99
  return false;
100
- });
101
-
102
- if (a == 1)
103
- $('#'+id).after(r);
104
- else {
105
- v = $('.the-tagcloud').css('display');
106
- $('.the-tagcloud').replaceWith(r);
107
- $('.the-tagcloud').css('display', v);
108
  }
109
  });
110
  }
111
 
112
- // replace WP class by our own
113
- jQuery('input.newtag').addClass('polylang-newtag');
114
- jQuery('input.newtag').removeClass('newtag');
115
- pll_suggest();
116
-
117
- // now copy paste WP code
118
- // add the language in the $_GET variable
119
- // add the unbind function to allow calling the function when the language is modified
120
- function pll_suggest() {
121
- ajaxtag = $('div.ajaxtag');
122
- $('input.polylang-newtag', ajaxtag).unbind().blur(function() {
123
- if ( this.value == '' )
124
- $(this).parent().siblings('.taghint').css('visibility', '');
125
- }).focus(function(){
126
- $(this).parent().siblings('.taghint').css('visibility', 'hidden');
127
- }).keyup(function(e){
128
- if ( 13 == e.which ) {
129
- tagBox.flushTags( $(this).closest('.tagsdiv') );
130
- return false;
131
- }
132
- }).keypress(function(e){
133
- if ( 13 == e.which ) {
134
- e.preventDefault();
135
- return false;
136
- }
137
- }).each(function(){
138
- var lang = jQuery('#post_lang_choice').attr('value');
139
- var tax = $(this).closest('div.tagsdiv').attr('id');
140
- $(this).suggest( ajaxurl + '?action=polylang-ajax-tag-search&lang=' + lang + '&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: "," } );
141
- });
142
- }
143
 
144
  // ajax for term edit
145
  jQuery('#term_lang_choice').change(function() {
@@ -167,14 +290,16 @@ jQuery(document).ready(function($) {
167
  });
168
  });
169
 
 
170
  // languages form
171
  // fills the fields based on dropdown list choice
172
  jQuery('#lang_list').change(function() {
173
  value = jQuery(this).attr('value').split('-');
 
174
  jQuery('input[name="slug"]').val(value[0]);
175
  jQuery('input[name="description"]').val(value[1]);
176
  jQuery('input[name="rtl"]').val([value[2]]);
177
- jQuery('input[name="name"]').val($("select option:selected").text());
178
  });
179
 
180
  });
1
+ var pll_tagBox;
2
+
3
+ // mainly copy paste of WP code
4
+ (function($){
5
+
6
+ pll_tagBox = {
7
+ clean : function(tags) {
8
+ return tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
9
+ },
10
+
11
+ parseTags : function(el) {
12
+ var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.tagsdiv'), thetags = taxbox.find('.the-tags'), current_tags = thetags.val().split(','), new_tags = [];
13
+ delete current_tags[num];
14
+
15
+ $.each( current_tags, function(key, val) {
16
+ val = $.trim(val);
17
+ if ( val ) {
18
+ new_tags.push(val);
19
+ }
20
+ });
21
+
22
+ thetags.val( this.clean( new_tags.join(',') ) );
23
+
24
+ this.quickClicks(taxbox);
25
+ return false;
26
+ },
27
+
28
+ quickClicks : function(el) {
29
+ var thetags = $('.the-tags', el),
30
+ tagchecklist = $('.tagchecklist', el),
31
+ id = $(el).attr('id'),
32
+ current_tags, disabled;
33
+
34
+ if ( !thetags.length )
35
+ return;
36
+
37
+ disabled = thetags.prop('disabled');
38
+
39
+ current_tags = thetags.val().split(',');
40
+ tagchecklist.empty();
41
+
42
+ $.each( current_tags, function( key, val ) {
43
+ var span, xbutton;
44
+
45
+ val = $.trim( val );
46
+
47
+ if ( ! val )
48
+ return;
49
+
50
+ // Create a new span, and ensure the text is properly escaped.
51
+ span = $('<span />').text( val );
52
+
53
+ // If tags editing isn't disabled, create the X button.
54
+ if ( ! disabled ) {
55
+ xbutton = $( '<a id="' + id + '-check-num-' + key + '" class="ntdelbutton">X</a>' );
56
+ xbutton.click( function(){ pll_tagBox.parseTags(this); });
57
+ span.prepend('&nbsp;').prepend( xbutton );
58
+ }
59
+
60
+ // Append the span to the tag list.
61
+ tagchecklist.append( span );
62
+ });
63
+ },
64
+
65
+ flushTags : function(el, a, f) {
66
+ a = a || false;
67
+ var text, tags = $('.the-tags', el), newtag = $('input.newtag', el), newtags;
68
+
69
+ text = a ? $(a).text() : newtag.val();
70
+ tagsval = tags.val();
71
+ newtags = tagsval ? tagsval + ',' + text : text;
72
+
73
+ newtags = this.clean( newtags );
74
+ newtags = array_unique_noempty( newtags.split(',') ).join(',');
75
+ tags.val(newtags);
76
+ this.quickClicks(el);
77
+
78
+ if ( !a )
79
+ newtag.val('');
80
+ if ( 'undefined' == typeof(f) )
81
+ newtag.focus();
82
+
83
+ return false;
84
+ },
85
+
86
+ get : function(id, a) {
87
+ var tax = id.substr(id.indexOf('-')+1);
88
+
89
+ // add the language in the $_POST variable
90
+ var data = {
91
+ action: 'get-tagcloud',
92
+ lang: jQuery('#post_lang_choice').attr('value'),
93
+ tax: tax
94
+ }
95
+
96
+ $.post(ajaxurl, data, function(r, stat) {
97
+ if ( 0 == r || 'success' != stat )
98
+ r = wpAjax.broken;
99
+
100
+ r = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>');
101
+ $('a', r).click(function(){
102
+ pll_tagBox.flushTags( $(this).closest('.inside').children('.tagsdiv'), this);
103
+ return false;
104
+ });
105
+
106
+ // add an if else condition to allow modifying the tags outputed when switching the language
107
+ if (a == 1)
108
+ $('#'+id).after(r);
109
+ else {
110
+ v = $('.the-tagcloud').css('display');
111
+ $('.the-tagcloud').replaceWith(r);
112
+ $('.the-tagcloud').css('display', v);
113
+ }
114
+ });
115
+ },
116
+
117
+ suggest : function() {
118
+ ajaxtag = $('div.ajaxtag');
119
+ // add the unbind function to allow calling the function when the language is modified
120
+ $('input.newtag', ajaxtag).unbind().blur(function() {
121
+ if ( this.value == '' )
122
+ $(this).parent().siblings('.taghint').css('visibility', '');
123
+ }).focus(function(){
124
+ $(this).parent().siblings('.taghint').css('visibility', 'hidden');
125
+ }).keyup(function(e){
126
+ if ( 13 == e.which ) {
127
+ pll_tagBox.flushTags( $(this).closest('.tagsdiv') );
128
+ return false;
129
+ }
130
+ }).keypress(function(e){
131
+ if ( 13 == e.which ) {
132
+ e.preventDefault();
133
+ return false;
134
+ }
135
+ }).each(function(){
136
+ // add the language in the $_GET variable
137
+ var lang = jQuery('#post_lang_choice').attr('value');
138
+ var tax = $(this).closest('div.tagsdiv').attr('id');
139
+ $(this).suggest( ajaxurl + '?action=polylang-ajax-tag-search&lang=' + lang + '&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: "," } );
140
+ });
141
+ },
142
+
143
+ init : function() {
144
+ var t = this, ajaxtag = $('div.ajaxtag');
145
+
146
+ $('.tagsdiv').each( function() {
147
+ pll_tagBox.quickClicks(this);
148
+ });
149
+
150
+ $('input.tagadd', ajaxtag).click(function(){
151
+ t.flushTags( $(this).closest('.tagsdiv') );
152
+ });
153
+
154
+ $('div.taghint', ajaxtag).click(function(){
155
+ $(this).css('visibility', 'hidden').parent().siblings('.newtag').focus();
156
+ });
157
+
158
+ pll_tagBox.suggest();
159
+
160
+ // save tags on post save/publish
161
+ $('#post').submit(function(){
162
+ $('div.tagsdiv').each( function() {
163
+ pll_tagBox.flushTags(this, false, 1);
164
+ });
165
+ });
166
+
167
+ // tag cloud
168
+ $('a.tagcloud-link').click(function(){
169
+ pll_tagBox.get( $(this).attr('id'), 1 );
170
+ $(this).unbind().click(function(){
171
+ $(this).siblings('.the-tagcloud').toggle();
172
+ return false;
173
+ });
174
+ return false;
175
+ });
176
+ }
177
+ };
178
+
179
+ })(jQuery);
180
+
181
  jQuery(document).ready(function($) {
182
 
183
  // collect taxonomies - code partly copied from WordPress
231
  });
232
 
233
  // modifies the language in the tag cloud
234
+ jQuery('.tagcloud-link').each(function() {
235
  var id = $(this).attr('id');
236
+ pll_tagBox.get(id, 0);
237
  });
238
 
239
  // modifies the language in the tags suggestion input
240
+ pll_tagBox.suggest();
241
  });
242
  });
243
 
244
+ // Tag box
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
 
246
+ // replace WP class by our own to avoid using tagBox functions
247
+ $('#side-sortables, #normal-sortables, #advanced-sortables').children('div.postbox').each(function(){
248
+ if ( this.id.indexOf('tagsdiv-') === 0 ) {
249
+ $(this).attr('id', 'pll-' + this.id);
 
 
 
 
 
 
250
  }
251
+ });
252
+
253
+ // copy paste WP code
254
+ // replace tagsdiv by pll-tagsdiv and tagBox by pll_tagBox
255
+ if ( $('#pll-tagsdiv-post_tag').length ) {
256
+ pll_tagBox.init();
257
+ } else {
258
+ $('#side-sortables, #normal-sortables, #advanced-sortables').children('div.postbox').each(function(){
259
+ if ( this.id.indexOf('pll-tagsdiv-') === 0 ) {
260
+ pll_tagBox.init();
261
  return false;
 
 
 
 
 
 
 
 
262
  }
263
  });
264
  }
265
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
 
267
  // ajax for term edit
268
  jQuery('#term_lang_choice').change(function() {
290
  });
291
  });
292
 
293
+
294
  // languages form
295
  // fills the fields based on dropdown list choice
296
  jQuery('#lang_list').change(function() {
297
  value = jQuery(this).attr('value').split('-');
298
+ selected = $("select option:selected").text().split(' - ');
299
  jQuery('input[name="slug"]').val(value[0]);
300
  jQuery('input[name="description"]').val(value[1]);
301
  jQuery('input[name="rtl"]').val([value[2]]);
302
+ jQuery('input[name="name"]').val(selected[0]);
303
  });
304
 
305
  });
polylang.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
- Version: 0.7
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
@@ -23,7 +23,7 @@ Description: Adds multilingual capability to Wordpress
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
 
26
- define('POLYLANG_VERSION', '0.7');
27
  define('PLL_MIN_WP_VERSION', '3.1');
28
 
29
  define('POLYLANG_DIR', dirname(__FILE__)); // our directory
@@ -247,6 +247,9 @@ class Polylang extends Polylang_Base {
247
  if (version_compare($options['version'], '0.7', '<'))
248
  $options['force_lang'] = 0; // option introduced in 0.7
249
 
 
 
 
250
  $options['version'] = POLYLANG_VERSION;
251
  update_option('polylang', $options);
252
  }
@@ -293,6 +296,16 @@ class Polylang extends Polylang_Base {
293
  if (!($listlanguages = $this->get_languages_list()))
294
  return $rules;
295
 
 
 
 
 
 
 
 
 
 
 
296
  // modifies the rules created by WordPress when '/language/' is removed in permalinks
297
  if ($options['rewrite']) {
298
  foreach ($listlanguages as $language) {
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
+ Version: 0.7.1
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
 
26
+ define('POLYLANG_VERSION', '0.7.1');
27
  define('PLL_MIN_WP_VERSION', '3.1');
28
 
29
  define('POLYLANG_DIR', dirname(__FILE__)); // our directory
247
  if (version_compare($options['version'], '0.7', '<'))
248
  $options['force_lang'] = 0; // option introduced in 0.7
249
 
250
+ if (version_compare($options['version'], '0.7.1', '<'))
251
+ $GLOBALS['wp_rewrite']->flush_rules(); // rewrite rules have been modified
252
+
253
  $options['version'] = POLYLANG_VERSION;
254
  update_option('polylang', $options);
255
  }
296
  if (!($listlanguages = $this->get_languages_list()))
297
  return $rules;
298
 
299
+ // put the default language at the end in case the language information is hidden for default language
300
+ // thanks to brbrbr http://wordpress.org/support/topic/plugin-polylang-rewrite-rules-not-correct
301
+ foreach ($listlanguages as $key => $language) {
302
+ if ($options['default_lang'] == $language->slug) {
303
+ unset ($listlanguages[$key]);
304
+ break;
305
+ }
306
+ }
307
+ $listlanguages[] = $language;
308
+
309
  // modifies the rules created by WordPress when '/language/' is removed in permalinks
310
  if ($options['rewrite']) {
311
  foreach ($listlanguages as $language) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: bilingual, language, i18n, international, l10n, localization, multilanguage, multilingual, multisite, translate, translation
5
  Requires at least: 3.1
6
  Tested up to: 3.3.1
7
- Stable tag: 0.7
8
 
9
  Polylang adds multilingual content management support to WordPress.
10
 
@@ -82,6 +82,16 @@ Yes. You have to use PNG or JPG files and name them with the WordPress locale co
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
 
 
 
 
 
85
  = 0.7 (2012-01-30) =
86
 
87
  * Add Hebrew translation contributed by [ArielK](http://www.arielk.net)
4
  Tags: bilingual, language, i18n, international, l10n, localization, multilanguage, multilingual, multisite, translate, translation
5
  Requires at least: 3.1
6
  Tested up to: 3.3.1
7
+ Stable tag: 0.7.1
8
 
9
  Polylang adds multilingual content management support to WordPress.
10
 
82
 
83
  == Changelog ==
84
 
85
+ = 0.7.1 (2012-02-06) =
86
+
87
+ * Allow using ISO 639-2 (3 characters) languages codes
88
+ * The predefined languages dropdown list now displays the locale to help differentiate some languages
89
+ * Add 5 new languages to predefined list
90
+ * Bug correction: the filter 'pll_copy_post_metas' does not work
91
+ * Bug correction: impossible to add a tag in the edit post panel
92
+ * Bug correction: rewrite rules not correct
93
+ * Bug correction: cache issue with css and js files
94
+
95
  = 0.7 (2012-01-30) =
96
 
97
  * Add Hebrew translation contributed by [ArielK](http://www.arielk.net)