Polylang - Version 2.8

Version Description

(2020-08-17) =

  • Pro: Add a language switcher block
  • Pro: Add compatibility with block image edition introduced in WP 5.5
  • Pro: Fix our private taxonomies being displayed in the ACF field group rules.
  • Pro: Fix incorrect flags loaded from the block editor
  • Pro: Fix SSO causing a wrong redirect when using subdomains (introduced in 2.7.4)
  • Pro: Fix a performance issue on the plugins list
  • Pro: Fix option to automatically duplicate media in all languages when uploading a new file not honored in block image
  • Use composer for autoload and Polylang Pro dependency on Polylang
  • Display a flag for each post in the posts list tables (same for terms). #515
  • Add test for the homepage translations to Site Health
  • Add debug information to Site Health
  • Add compatibility with the sitemaps introduced in WP 5.5 #451
  • Always filter WP_Query by the current language
  • Support wildcards in "admin-texts" parent keys in wpml-config.xml
  • Fix sticky posts showed for all languages when the admin language filter is active #469
  • Fix a performance issue on the pages list
  • Fix dependency to jQuery Migrate removed from WP 5.5 #539
  • Fix: output secure cookie when using a cache plugin and ssl #542
  • Fix the possibility to create 2 terms with the same name in the same language, without specifying the second slug.
  • Fix sticky posts appearing 2 times in WP 5.5
Download this release

Release Info

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

Code changes from version 2.7.4 to 2.8

Files changed (188) hide show
  1. admin/admin-base.php +4 -46
  2. admin/admin-block-editor.php +3 -0
  3. admin/admin-classic-editor.php +13 -2
  4. admin/admin-filters-columns.php +34 -11
  5. admin/admin-filters-media.php +3 -0
  6. admin/admin-filters-post-base.php +3 -0
  7. admin/admin-filters-post.php +6 -1
  8. admin/admin-filters-term.php +14 -7
  9. admin/admin-filters.php +3 -0
  10. admin/admin-links.php +3 -0
  11. admin/admin-model.php +3 -0
  12. admin/admin-nav-menu.php +3 -0
  13. admin/admin-notices.php +3 -0
  14. admin/admin-static-pages.php +32 -8
  15. admin/admin-strings.php +3 -0
  16. admin/admin.php +5 -93
  17. admin/view-translations-media.php +2 -1
  18. admin/view-translations-post.php +2 -1
  19. admin/view-translations-term.php +2 -1
  20. css/admin.css +0 -43
  21. css/admin.min.css +1 -1
  22. frontend/choose-lang-content.php +3 -0
  23. frontend/choose-lang-domain.php +3 -0
  24. frontend/choose-lang-url.php +3 -0
  25. frontend/choose-lang.php +4 -1
  26. frontend/frontend-auto-translate.php +3 -0
  27. frontend/frontend-filters-links.php +29 -9
  28. frontend/frontend-filters-search.php +7 -4
  29. frontend/frontend-filters.php +4 -1
  30. frontend/frontend-links.php +3 -0
  31. frontend/frontend-nav-menu.php +4 -1
  32. frontend/frontend-static-pages.php +3 -0
  33. frontend/frontend.php +3 -34
  34. include/api.php +29 -0
  35. include/base.php +41 -21
  36. include/cache.php +3 -0
  37. include/class-polylang.php +13 -59
  38. include/crud-posts.php +3 -0
  39. include/crud-terms.php +3 -0
  40. include/filters-links.php +3 -0
  41. include/filters.php +3 -0
  42. include/functions.php +3 -0
  43. include/language.php +27 -17
  44. include/license.php +3 -0
  45. include/links-abstract-domain.php +3 -0
  46. include/links-default.php +3 -0
  47. include/links-directory.php +3 -0
  48. include/links-domain.php +3 -0
  49. include/links-model.php +5 -2
  50. include/links-permalinks.php +3 -0
  51. include/links-subdomain.php +3 -0
  52. include/links.php +3 -0
  53. include/mo.php +3 -0
  54. include/model.php +37 -7
  55. include/nav-menu.php +3 -0
  56. include/olt-manager.php +3 -0
  57. include/pointer.php +3 -0
  58. include/query.php +3 -51
  59. include/rest-request.php +4 -29
  60. include/static-pages.php +3 -0
  61. include/switcher.php +15 -7
  62. include/translated-object.php +8 -0
  63. include/translated-post.php +3 -0
  64. include/translated-term.php +3 -0
  65. include/walker-dropdown.php +3 -0
  66. include/walker-list.php +3 -0
  67. include/widget-calendar.php +101 -95
  68. include/widget-languages.php +5 -2
  69. install/install-base.php +3 -0
  70. install/install.php +5 -2
  71. install/plugin-updater.php +3 -0
  72. install/t15s.php +74 -12
  73. install/upgrade.php +20 -15
  74. integrations/aqua-resizer/aqua-resizer.php +32 -0
  75. integrations/aqua-resizer/load.php +13 -0
  76. {modules/plugins → integrations/cache}/cache-compat.php +6 -2
  77. integrations/cache/load.php +21 -0
  78. integrations/custom-field-template/cft.php +35 -0
  79. integrations/custom-field-template/load.php +21 -0
  80. integrations/domain-mapping/domain-mapping.php +75 -0
  81. integrations/domain-mapping/load.php +12 -0
  82. integrations/duplicate-post/duplicate-post.php +38 -0
  83. integrations/duplicate-post/load.php +21 -0
  84. integrations/integrations.php +49 -0
  85. {modules/plugins → integrations/jetpack}/featured-content.php +3 -16
  86. {modules/plugins → integrations/jetpack}/jetpack.php +3 -0
  87. integrations/jetpack/load.php +14 -0
  88. integrations/no-category-base/load.php +13 -0
  89. integrations/no-category-base/no-category-base.php +36 -0
  90. integrations/twenty-seventeen/load.php +12 -0
  91. integrations/twenty-seventeen/twenty-seven-teen.php +33 -0
  92. integrations/wp-importer/load.php +12 -0
  93. integrations/wp-importer/wordpress-importer.php +70 -0
  94. {modules/plugins → integrations/wp-importer}/wp-import.php +3 -0
  95. {modules/plugins → integrations/wp-offload-media}/as3cf.php +3 -0
  96. integrations/wp-offload-media/load.php +21 -0
  97. integrations/wp-sweep/load.php +21 -0
  98. integrations/wp-sweep/wp-sweep.php +32 -0
  99. integrations/wpseo/load.php +21 -0
  100. {modules/plugins → integrations/wpseo}/wpseo-ogp.php +3 -0
  101. {modules/plugins → integrations/wpseo}/wpseo.php +3 -0
  102. integrations/yarpp/load.php +20 -0
  103. integrations/yarpp/yarpp.php +20 -0
  104. js/admin.js +4 -0
  105. js/block-editor.js +10 -43
  106. js/block-editor.min.js +1 -1
  107. js/classic-editor.js +5 -37
  108. js/classic-editor.min.js +1 -1
  109. js/nav-menu.js +8 -2
  110. js/nav-menu.min.js +1 -1
  111. js/post.js +4 -80
  112. js/post.min.js +1 -1
  113. js/term.js +4 -0
  114. js/term.min.js +1 -1
  115. js/user.js +6 -0
  116. js/user.min.js +1 -1
  117. js/widgets.js +7 -1
  118. js/widgets.min.js +1 -1
  119. {lingotek → modules/lingotek}/image01.gif +0 -0
  120. {lingotek → modules/lingotek}/image02.png +0 -0
  121. {lingotek → modules/lingotek}/image03.png +0 -0
  122. {lingotek → modules/lingotek}/image04.png +0 -0
  123. {lingotek → modules/lingotek}/lingotek.php +3 -0
  124. modules/lingotek/load.php +14 -0
  125. modules/plugins/plugins-compat.php +0 -345
  126. modules/share-slug/load.php +20 -0
  127. modules/share-slug/settings-share-slug.php +9 -0
  128. modules/site-health/admin-site-health.php +280 -0
  129. modules/site-health/load.php +14 -0
  130. modules/sitemaps/load.php +13 -0
  131. modules/sitemaps/multilingual-sitemaps-provider.php +210 -0
  132. modules/sitemaps/sitemaps.php +172 -0
  133. modules/sync/admin-sync.php +3 -0
  134. modules/sync/load.php +26 -0
  135. modules/sync/settings-sync.php +9 -0
  136. modules/sync/sync-metas.php +3 -0
  137. modules/sync/sync-post-metas.php +3 -0
  138. modules/sync/sync-tax.php +3 -0
  139. modules/sync/sync-term-metas.php +3 -0
  140. modules/sync/sync.php +3 -0
  141. modules/translate-slugs/load.php +20 -0
  142. modules/translate-slugs/settings-translate-slugs.php +10 -0
  143. modules/wizard/html-wizard-notice.php +2 -1
  144. modules/wizard/js/languages-step.js +4 -0
  145. modules/wizard/load.php +14 -0
  146. modules/wizard/view-wizard-page.php +2 -1
  147. modules/wizard/view-wizard-step-home-page.php +2 -1
  148. modules/wizard/view-wizard-step-languages.php +2 -1
  149. modules/wizard/view-wizard-step-last.php +2 -1
  150. modules/wizard/view-wizard-step-licenses.php +2 -1
  151. modules/wizard/view-wizard-step-media.php +2 -1
  152. modules/wizard/view-wizard-step-untranslated-contents.php +2 -1
  153. modules/wizard/wizard.php +13 -9
  154. modules/wpml/load.php +25 -0
  155. modules/wpml/settings-wpml.php +9 -0
  156. modules/wpml/wpml-api.php +3 -0
  157. modules/wpml/wpml-compat.php +4 -1
  158. modules/wpml/wpml-config.php +30 -4
  159. modules/wpml/wpml-legacy-api.php +3 -0
  160. polylang.php +37 -46
  161. readme.txt +27 -4
  162. settings/flags.php +3 -0
  163. settings/languages.php +22 -0
  164. settings/settings-browser.php +9 -0
  165. settings/settings-cpt.php +39 -3
  166. settings/settings-licenses.php +15 -0
  167. settings/settings-media.php +9 -0
  168. settings/settings-module.php +79 -3
  169. settings/settings-url.php +9 -0
  170. settings/settings.php +14 -30
  171. settings/table-languages.php +3 -0
  172. settings/table-settings.php +11 -0
  173. settings/table-string.php +3 -0
  174. settings/view-about.php +2 -1
  175. settings/view-languages.php +3 -2
  176. settings/view-tab-lang.php +3 -2
  177. settings/view-tab-settings.php +2 -1
  178. settings/view-tab-strings.php +2 -1
  179. uninstall.php +4 -12
  180. vendor/autoload.php +7 -0
  181. vendor/composer/ClassLoader.php +445 -0
  182. vendor/composer/LICENSE +21 -0
  183. vendor/composer/autoload_classmap.php +120 -0
  184. vendor/composer/autoload_namespaces.php +9 -0
  185. vendor/composer/autoload_psr4.php +9 -0
  186. vendor/composer/autoload_real.php +55 -0
  187. vendor/composer/autoload_static.php +130 -0
  188. vendor/composer/installed.json +1 -0
admin/admin-base.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Base class for both admin
@@ -20,7 +23,7 @@ class PLL_Admin_Base extends PLL_Base {
20
  parent::__construct( $links_model );
21
 
22
  // Plugin i18n, only needed for backend
23
- load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' );
24
 
25
  // Adds the link to the languages panel in the WordPress admin menu
26
  add_action( 'admin_menu', array( $this, 'add_menus' ) );
@@ -30,13 +33,6 @@ class PLL_Admin_Base extends PLL_Base {
30
  add_action( 'admin_print_footer_scripts', array( $this, 'admin_print_footer_scripts' ), 0 ); // High priority in case an ajax request is sent by an immediately invoked function
31
 
32
  add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_controls_enqueue_scripts' ) );
33
-
34
- if ( defined( 'POLYLANG_PRO' ) ) {
35
- new PLL_Pro();
36
- } elseif ( ! defined( 'PLL_LINGOTEK_AD' ) || PLL_LINGOTEK_AD ) {
37
- require_once POLYLANG_DIR . '/lingotek/lingotek.php'; // Lingotek
38
- add_action( 'wp_loaded', array( new PLL_Lingotek(), 'init' ) );
39
- }
40
  }
41
 
42
  /**
@@ -50,14 +46,6 @@ class PLL_Admin_Base extends PLL_Base {
50
 
51
  $this->notices = new PLL_Admin_Notices( $this );
52
 
53
- if ( Polylang::is_wizard() && class_exists( 'PLL_Wizard_Pro' ) ) {
54
- // Instantiate PLL_Wizard_Pro class after all PLL_Admin object is all initialized.
55
- // After PLL_Admin::maybe_load_sync_post which is hooked on admin_init with priority 20.
56
- add_action( 'admin_init', array( $this, 'instantiate_wizard_pro' ), 30 );
57
- }
58
-
59
- $this->wizard = new PLL_Wizard( $this );
60
-
61
  if ( ! $this->model->get_languages_list() ) {
62
  return;
63
  }
@@ -73,12 +61,6 @@ class PLL_Admin_Base extends PLL_Base {
73
 
74
  // Adds the languages in admin bar
75
  add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100 ); // 100 determines the position
76
-
77
- // Translate slugs, only for pretty permalinks
78
- if ( get_option( 'permalink_structure' ) && class_exists( 'PLL_Translate_Slugs' ) ) {
79
- $slugs_model = new PLL_Translate_Slugs_Model( $this );
80
- $this->translate_slugs = new PLL_Translate_Slugs( $slugs_model, $this->curlang );
81
- }
82
  }
83
 
84
  /**
@@ -195,22 +177,6 @@ class PLL_Admin_Base extends PLL_Base {
195
  * @since 2.4.0
196
  */
197
  public function localize_scripts() {
198
- if ( wp_script_is( 'pll_classic-editor', 'enqueued' ) ) {
199
- wp_localize_script(
200
- 'pll_classic-editor',
201
- 'confirm_text',
202
- __( 'You are about to overwrite an existing translation. Are you sure you want to proceed?', 'polylang' )
203
- );
204
- }
205
-
206
- if ( wp_script_is( 'pll_block-editor', 'enqueued' ) ) {
207
- wp_localize_script(
208
- 'pll_block-editor',
209
- 'confirm_text',
210
- __( 'You are about to overwrite an existing translation. Are you sure you want to proceed?', 'polylang' )
211
- );
212
- }
213
-
214
  if ( wp_script_is( 'pll_widgets', 'enqueued' ) ) {
215
  wp_localize_script(
216
  'pll_widgets',
@@ -440,12 +406,4 @@ class PLL_Admin_Base extends PLL_Base {
440
  );
441
  }
442
  }
443
- /**
444
- * Instantiate PLL_Wizard_Pro class.
445
- *
446
- * @since 2.7
447
- */
448
- public function instantiate_wizard_pro() {
449
- $this->wizard_pro = new PLL_Wizard_Pro( $this );
450
- }
451
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Base class for both admin
23
  parent::__construct( $links_model );
24
 
25
  // Plugin i18n, only needed for backend
26
+ load_plugin_textdomain( 'polylang' );
27
 
28
  // Adds the link to the languages panel in the WordPress admin menu
29
  add_action( 'admin_menu', array( $this, 'add_menus' ) );
33
  add_action( 'admin_print_footer_scripts', array( $this, 'admin_print_footer_scripts' ), 0 ); // High priority in case an ajax request is sent by an immediately invoked function
34
 
35
  add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_controls_enqueue_scripts' ) );
 
 
 
 
 
 
 
36
  }
37
 
38
  /**
46
 
47
  $this->notices = new PLL_Admin_Notices( $this );
48
 
 
 
 
 
 
 
 
 
49
  if ( ! $this->model->get_languages_list() ) {
50
  return;
51
  }
61
 
62
  // Adds the languages in admin bar
63
  add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100 ); // 100 determines the position
 
 
 
 
 
 
64
  }
65
 
66
  /**
177
  * @since 2.4.0
178
  */
179
  public function localize_scripts() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  if ( wp_script_is( 'pll_widgets', 'enqueued' ) ) {
181
  wp_localize_script(
182
  'pll_widgets',
406
  );
407
  }
408
  }
 
 
 
 
 
 
 
 
409
  }
admin/admin-block-editor.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages filters and actions related to the block editor
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages filters and actions related to the block editor
admin/admin-classic-editor.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages filters and actions related to the classic editor
@@ -112,7 +115,11 @@ class PLL_Admin_Classic_Editor {
112
 
113
  echo '<div id="post-translations" class="translations">';
114
  if ( $lang ) {
115
- include PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php';
 
 
 
 
116
  }
117
  echo '</div>' . "\n";
118
  }
@@ -152,7 +159,11 @@ class PLL_Admin_Classic_Editor {
152
 
153
  ob_start();
154
  if ( $lang ) {
155
- include PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php';
 
 
 
 
156
  }
157
  $x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
158
  ob_end_clean();
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages filters and actions related to the classic editor
115
 
116
  echo '<div id="post-translations" class="translations">';
117
  if ( $lang ) {
118
+ if ( 'attachment' === $post_type ) {
119
+ include __DIR__ . '/view-translations-media.php';
120
+ } else {
121
+ include __DIR__ . '/view-translations-post.php';
122
+ }
123
  }
124
  echo '</div>' . "\n";
125
  }
159
 
160
  ob_start();
161
  if ( $lang ) {
162
+ if ( 'attachment' === $post_type ) {
163
+ include __DIR__ . '/view-translations-media.php';
164
+ } else {
165
+ include __DIR__ . '/view-translations-post.php';
166
+ }
167
  }
168
  $x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
169
  ob_end_clean();
admin/admin-filters-columns.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Adds the language column in posts and terms list tables
@@ -63,7 +66,7 @@ class PLL_Admin_Filters_Columns {
63
  }
64
 
65
  foreach ( $this->model->get_languages_list() as $language ) {
66
- $columns[ 'language_' . $language->slug ] = $language->flag ? $language->flag . '<span class="screen-reader-text">' . esc_html( $language->name ) . '</span>' : esc_html( $language->slug );
67
  }
68
 
69
  return isset( $end ) ? array_merge( $columns, $end ) : $columns;
@@ -142,8 +145,10 @@ class PLL_Admin_Filters_Columns {
142
  // get_edit_post_link returns nothing if the user cannot edit the post
143
  // Thanks to Solinx. See http://wordpress.org/support/topic/feature-request-incl-code-check-for-capabilities-in-admin-screens
144
  if ( $link = get_edit_post_link( $id ) ) {
 
145
  if ( $id === $post_id ) {
146
- $class = 'pll_icon_tick';
 
147
  /* translators: accessibility text, %s is a native language name */
148
  $s = sprintf( __( 'Edit this item in %s', 'polylang' ), $language->name );
149
  } else {
@@ -152,17 +157,19 @@ class PLL_Admin_Filters_Columns {
152
  $s = sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name );
153
  }
154
  printf(
155
- '<a class="%1$s" title="%2$s" href="%3$s"><span class="screen-reader-text">%4$s</span></a>',
156
  esc_attr( $class ),
157
  esc_attr( get_post( $id )->post_title ),
158
  esc_url( $link ),
159
- esc_html( $s )
 
160
  );
161
  } elseif ( $id === $post_id ) {
162
  printf(
163
- '<span class="pll_icon_tick"><span class="screen-reader-text">%s</span></span>',
164
  /* translators: accessibility text, %s is a native language name */
165
- esc_html( sprintf( __( 'This item is in %s', 'polylang' ), $language->name ) )
 
166
  );
167
  }
168
  }
@@ -269,8 +276,10 @@ class PLL_Admin_Filters_Columns {
269
  // Link to edit term ( or a translation )
270
  if ( ( $id = $this->model->term->get( $term_id, $language ) ) && $term = get_term( $id, $taxonomy ) ) {
271
  if ( $link = get_edit_term_link( $id, $taxonomy, $post_type ) ) {
 
272
  if ( $id === $term_id ) {
273
- $class = 'pll_icon_tick';
 
274
  /* translators: accessibility text, %s is a native language name */
275
  $s = sprintf( __( 'Edit this item in %s', 'polylang' ), $language->name );
276
  } else {
@@ -279,17 +288,19 @@ class PLL_Admin_Filters_Columns {
279
  $s = sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name );
280
  }
281
  $out .= sprintf(
282
- '<a class="%1$s" title="%2$s" href="%3$s"><span class="screen-reader-text">%4$s</span></a>',
283
  $class,
284
  esc_attr( $term->name ),
285
  esc_url( $link ),
286
- esc_html( $s )
 
287
  );
288
  } elseif ( $id === $term_id ) {
289
  $out .= sprintf(
290
- '<span class="pll_icon_tick"><span class="screen-reader-text">%s</span></span>',
291
  /* translators: accessibility text, %s is a native language name */
292
- esc_html( sprintf( __( 'This item is in %s', 'polylang' ), $language->name ) )
 
293
  );
294
  }
295
  }
@@ -386,4 +397,16 @@ class PLL_Admin_Filters_Columns {
386
 
387
  $x->send();
388
  }
 
 
 
 
 
 
 
 
 
 
 
 
389
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Adds the language column in posts and terms list tables
66
  }
67
 
68
  foreach ( $this->model->get_languages_list() as $language ) {
69
+ $columns[ 'language_' . $language->slug ] = $this->get_flag_html( $language ) . '<span class="screen-reader-text">' . esc_html( $language->name ) . '</span>';
70
  }
71
 
72
  return isset( $end ) ? array_merge( $columns, $end ) : $columns;
145
  // get_edit_post_link returns nothing if the user cannot edit the post
146
  // Thanks to Solinx. See http://wordpress.org/support/topic/feature-request-incl-code-check-for-capabilities-in-admin-screens
147
  if ( $link = get_edit_post_link( $id ) ) {
148
+ $flag = '';
149
  if ( $id === $post_id ) {
150
+ $flag = $this->get_flag_html( $language );
151
+ $class = 'pll_column_flag';
152
  /* translators: accessibility text, %s is a native language name */
153
  $s = sprintf( __( 'Edit this item in %s', 'polylang' ), $language->name );
154
  } else {
157
  $s = sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name );
158
  }
159
  printf(
160
+ '<a class="%1$s" title="%2$s" href="%3$s"><span class="screen-reader-text">%4$s</span>%5$s</a>',
161
  esc_attr( $class ),
162
  esc_attr( get_post( $id )->post_title ),
163
  esc_url( $link ),
164
+ esc_html( $s ),
165
+ $flag // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
166
  );
167
  } elseif ( $id === $post_id ) {
168
  printf(
169
+ '<span class="pll_column_flag" style=""><span class="screen-reader-text">%1$s</span>%2$s</span>',
170
  /* translators: accessibility text, %s is a native language name */
171
+ esc_html( sprintf( __( 'This item is in %s', 'polylang' ), $language->name ) ),
172
+ $this->get_flag_html( $language ) // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
173
  );
174
  }
175
  }
276
  // Link to edit term ( or a translation )
277
  if ( ( $id = $this->model->term->get( $term_id, $language ) ) && $term = get_term( $id, $taxonomy ) ) {
278
  if ( $link = get_edit_term_link( $id, $taxonomy, $post_type ) ) {
279
+ $flag = '';
280
  if ( $id === $term_id ) {
281
+ $flag = $this->get_flag_html( $language );
282
+ $class = 'pll_column_flag';
283
  /* translators: accessibility text, %s is a native language name */
284
  $s = sprintf( __( 'Edit this item in %s', 'polylang' ), $language->name );
285
  } else {
288
  $s = sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name );
289
  }
290
  $out .= sprintf(
291
+ '<a class="%1$s" title="%2$s" href="%3$s"><span class="screen-reader-text">%4$s</span>%5$s</a>',
292
  $class,
293
  esc_attr( $term->name ),
294
  esc_url( $link ),
295
+ esc_html( $s ),
296
+ $flag // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
297
  );
298
  } elseif ( $id === $term_id ) {
299
  $out .= sprintf(
300
+ '<span class="pll_column_flag"><span class="screen-reader-text">%1$s</span>%2$s</span>',
301
  /* translators: accessibility text, %s is a native language name */
302
+ esc_html( sprintf( __( 'This item is in %s', 'polylang' ), $language->name ) ),
303
+ $this->get_flag_html( $language ) // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
304
  );
305
  }
306
  }
397
 
398
  $x->send();
399
  }
400
+
401
+ /**
402
+ * Returns the language flag or teh language slug if there is no flag.
403
+ *
404
+ * @since 2.8
405
+ *
406
+ * @param object $language PLL_Language object.
407
+ * @return string
408
+ */
409
+ protected function get_flag_html( $language ) {
410
+ return $language->flag ? $language->flag : sprintf( '<abbr>%s</abbr>', esc_html( $language->slug ) );
411
+ }
412
  }
admin/admin-filters-media.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages filters and actions related to media on admin side
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages filters and actions related to media on admin side
admin/admin-filters-post-base.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Some common code for PLL_Admin_Filters_Post and PLL_Admin_Filters_Media
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Some common code for PLL_Admin_Filters_Post and PLL_Admin_Filters_Media
admin/admin-filters-post.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages filters and actions related to posts on admin side
@@ -73,7 +76,9 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
73
 
74
  // Hierarchical post types
75
  if ( 'edit' == $screen->base && is_post_type_hierarchical( $screen->post_type ) ) {
76
- $pages = get_pages();
 
 
77
  $page_languages = array();
78
 
79
  foreach ( $pages as $page ) {
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages filters and actions related to posts on admin side
76
 
77
  // Hierarchical post types
78
  if ( 'edit' == $screen->base && is_post_type_hierarchical( $screen->post_type ) ) {
79
+ $pages = get_pages( array( 'sort_column' => 'menu_order, post_title' ) ); // Same arguments as the parent pages dropdown to avoid an extra query.
80
+ update_post_caches( $pages, $screen->post_type );
81
+
82
  $page_languages = array();
83
 
84
  foreach ( $pages as $page ) {
admin/admin-filters-term.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages filters and actions related to terms on admin side
@@ -108,7 +111,7 @@ class PLL_Admin_Filters_Term {
108
  // Adds translation fields
109
  echo '<div id="term-translations" class="form-field">';
110
  if ( $lang ) {
111
- include PLL_ADMIN_INC . '/view-translations-term.php';
112
  }
113
  echo '</div>' . "\n";
114
  }
@@ -175,7 +178,7 @@ class PLL_Admin_Filters_Term {
175
 
176
  echo '<tr id="term-translations" class="form-field">';
177
  if ( $lang ) {
178
- include PLL_ADMIN_INC . '/view-translations-term.php';
179
  }
180
  echo '</tr>' . "\n";
181
  }
@@ -402,22 +405,26 @@ class PLL_Admin_Filters_Term {
402
  // If the term already exists in another language
403
  if ( ! $slug && $this->model->is_translated_taxonomy( $taxonomy ) && term_exists( $name, $taxonomy ) ) {
404
  if ( isset( $_POST['term_lang_choice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
405
- $slug = $name . '-' . $this->model->get_language( sanitize_key( $_POST['term_lang_choice'] ) )->slug; // phpcs:ignore WordPress.Security.NonceVerification
406
  }
407
 
408
  elseif ( isset( $_POST['inline_lang_choice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
409
- $slug = $name . '-' . $this->model->get_language( sanitize_key( $_POST['inline_lang_choice'] ) )->slug; // phpcs:ignore WordPress.Security.NonceVerification
410
  }
411
 
412
  // *Post* bulk edit, in case a new term is created
413
  elseif ( isset( $_GET['bulk_edit'], $_GET['inline_lang_choice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
414
  // Bulk edit does not modify the language
415
  if ( -1 == $_GET['inline_lang_choice'] ) { // phpcs:ignore WordPress.Security.NonceVerification
416
- $slug = $name . '-' . $this->model->post->get_language( $this->post_id )->slug;
417
  } else {
418
- $slug = $name . '-' . $this->model->get_language( sanitize_key( $_GET['inline_lang_choice'] ) )->slug; // phpcs:ignore WordPress.Security.NonceVerification
419
  }
420
  }
 
 
 
 
421
  }
422
 
423
  return $slug;
@@ -446,7 +453,7 @@ class PLL_Admin_Filters_Term {
446
 
447
  ob_start();
448
  if ( $lang ) {
449
- include PLL_ADMIN_INC . '/view-translations-term.php';
450
  }
451
  $x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
452
  ob_end_clean();
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages filters and actions related to terms on admin side
111
  // Adds translation fields
112
  echo '<div id="term-translations" class="form-field">';
113
  if ( $lang ) {
114
+ include __DIR__ . '/view-translations-term.php';
115
  }
116
  echo '</div>' . "\n";
117
  }
178
 
179
  echo '<tr id="term-translations" class="form-field">';
180
  if ( $lang ) {
181
+ include __DIR__ . '/view-translations-term.php';
182
  }
183
  echo '</tr>' . "\n";
184
  }
405
  // If the term already exists in another language
406
  if ( ! $slug && $this->model->is_translated_taxonomy( $taxonomy ) && term_exists( $name, $taxonomy ) ) {
407
  if ( isset( $_POST['term_lang_choice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
408
+ $lang = $this->model->get_language( sanitize_key( $_POST['term_lang_choice'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
409
  }
410
 
411
  elseif ( isset( $_POST['inline_lang_choice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
412
+ $lang = $this->model->get_language( sanitize_key( $_POST['inline_lang_choice'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
413
  }
414
 
415
  // *Post* bulk edit, in case a new term is created
416
  elseif ( isset( $_GET['bulk_edit'], $_GET['inline_lang_choice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
417
  // Bulk edit does not modify the language
418
  if ( -1 == $_GET['inline_lang_choice'] ) { // phpcs:ignore WordPress.Security.NonceVerification
419
+ $lang = $this->model->post->get_language( $this->post_id );
420
  } else {
421
+ $lang = $this->model->get_language( sanitize_key( $_GET['inline_lang_choice'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
422
  }
423
  }
424
+
425
+ if ( ! empty( $lang ) && ! $this->model->term_exists_by_slug( $name, $lang, $taxonomy ) ) {
426
+ $slug = $name . '-' . $lang->slug;
427
+ }
428
  }
429
 
430
  return $slug;
453
 
454
  ob_start();
455
  if ( $lang ) {
456
+ include __DIR__ . '/view-translations-term.php';
457
  }
458
  $x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
459
  ob_end_clean();
admin/admin-filters.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Setup miscellaneous admin filters as well as filters common to admin and frontend
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Setup miscellaneous admin filters as well as filters common to admin and frontend
admin/admin-links.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages links related functions
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages links related functions
admin/admin-model.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Extends the PLL_Model class with methods needed only in Polylang settings pages
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Extends the PLL_Model class with methods needed only in Polylang settings pages
admin/admin-nav-menu.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages custom menus translations as well as the language switcher menu item on admin side
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages custom menus translations as well as the language switcher menu item on admin side
admin/admin-notices.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to manage admin notices
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to manage admin notices
admin/admin-static-pages.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages the static front page and the page for posts on admin side
@@ -200,7 +203,29 @@ class PLL_Admin_Static_Pages extends PLL_Static_Pages {
200
  public function notice_must_translate() {
201
  $screen = get_current_screen();
202
 
203
- if ( $this->page_on_front && ( 'toplevel_page_mlang' === $screen->id || 'edit-page' === $screen->id ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  $untranslated = array();
205
 
206
  foreach ( $this->model->get_languages_list() as $language ) {
@@ -214,15 +239,14 @@ class PLL_Admin_Static_Pages extends PLL_Static_Pages {
214
  }
215
 
216
  if ( ! empty( $untranslated ) ) {
217
- printf(
218
- '<div class="error"><p>%s</p></div>',
219
- sprintf(
220
- /* translators: %s is a comma separated list of native language names */
221
- esc_html__( 'You must translate your static front page in %s.', 'polylang' ),
222
- implode( ', ', $untranslated ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
223
- )
224
  );
225
  }
226
  }
 
 
227
  }
228
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages the static front page and the page for posts on admin side
203
  public function notice_must_translate() {
204
  $screen = get_current_screen();
205
 
206
+ if ( 'toplevel_page_mlang' === $screen->id || 'edit-page' === $screen->id ) {
207
+ $message = $this->get_must_translate_message();
208
+
209
+ if ( ! empty( $message ) ) {
210
+ printf(
211
+ '<div class="error"><p>%s</p></div>',
212
+ $message // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
213
+ );
214
+ }
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Returns the message asking to translate the static front page in all languages.
220
+ *
221
+ * @since 2.8
222
+ *
223
+ * @return string
224
+ */
225
+ public function get_must_translate_message() {
226
+ $message = '';
227
+
228
+ if ( $this->page_on_front ) {
229
  $untranslated = array();
230
 
231
  foreach ( $this->model->get_languages_list() as $language ) {
239
  }
240
 
241
  if ( ! empty( $untranslated ) ) {
242
+ $message = sprintf(
243
+ /* translators: %s is a comma separated list of native language names */
244
+ esc_html__( 'You must translate your static front page in %s.', 'polylang' ),
245
+ implode( ', ', $untranslated ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
 
 
 
246
  );
247
  }
248
  }
249
+
250
+ return $message;
251
  }
252
  }
admin/admin-strings.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A fully static class to manage strings translations on admin side
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A fully static class to manage strings translations on admin side
admin/admin.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Admin side controller
@@ -21,19 +24,14 @@
21
  * filters_post => reference to PLL_Admin_Filters_Post object
22
  * filters_term => reference to PLL_Admin_filters_Term object
23
  * nav_menu => reference to PLL_Admin_Nav_Menu object
24
- * sync => reference to PLL_Admin_Sync object
25
  * block_editor => reference to PLL_Admin_Block_Editor object
26
  * classic_editor => reference to PLL_Admin_Classic_Editor object
27
  * filters_media => optional, reference to PLL_Admin_Filters_Media object
28
- * bulk_translate => reference, a PLL_Bulk_Translate subclass instance
29
- * wizard => reference, a PLL_Wizard object
30
  *
31
  * @since 1.2
32
- * @since 2.7 Added a reference to a PLL_Bulk_Translate instance.
33
- * @since 2.7 Added a reference to a PLL_Wizard object.
34
  */
35
  class PLL_Admin extends PLL_Admin_Base {
36
- public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $sync, $filters_media;
37
 
38
  /**
39
  * Loads the polylang text domain
@@ -64,7 +62,6 @@ class PLL_Admin extends PLL_Admin_Base {
64
  // Priority 5 to make sure filters are there before customize_register is fired
65
  if ( $this->model->get_languages_list() ) {
66
  add_action( 'wp_loaded', array( $this, 'add_filters' ), 5 );
67
- add_action( 'admin_init', array( $this, 'maybe_load_sync_post' ), 20 ); // After fusion Builder.
68
  }
69
  }
70
 
@@ -103,7 +100,7 @@ class PLL_Admin extends PLL_Admin_Base {
103
  */
104
  public function add_filters() {
105
  // All these are separated just for convenience and maintainability
106
- $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Sync', 'Classic_Editor', 'Block_Editor' );
107
 
108
  // Don't load media filters if option is disabled or if user has no right
109
  if ( $this->options['media_support'] && ( $obj = get_post_type_object( 'attachment' ) ) && ( current_user_can( $obj->cap->edit_posts ) || current_user_can( $obj->cap->create_posts ) ) ) {
@@ -123,90 +120,5 @@ class PLL_Admin extends PLL_Admin_Base {
123
  $class = apply_filters( 'pll_' . $obj, 'PLL_Admin_' . $class );
124
  $this->$obj = new $class( $this );
125
  }
126
-
127
- $this->posts = new PLL_CRUD_Posts( $this );
128
- $this->terms = new PLL_CRUD_Terms( $this );
129
-
130
- // Bulk Translate
131
- // Needs to be loaded before other modules.
132
- if ( class_exists( 'PLL_Bulk_Translate' ) ) {
133
- $this->bulk_translate = new PLL_Bulk_Translate( $this->model );
134
- add_action( 'current_screen', array( $this->bulk_translate, 'init' ) );
135
- }
136
-
137
- // Advanced media
138
- if ( $this->options['media_support'] && class_exists( 'PLL_Admin_Advanced_Media' ) ) {
139
- $this->advanced_media = new PLL_Admin_Advanced_Media( $this );
140
- }
141
-
142
- // Share term slugs
143
- if ( get_option( 'permalink_structure' ) && $this->options['force_lang'] && class_exists( 'PLL_Admin_Share_Term_Slug' ) ) {
144
- $this->share_term_slug = new PLL_Admin_Share_Term_Slug( $this );
145
- }
146
-
147
- // Duplicate content
148
- if ( class_exists( 'PLL_Duplicate' ) ) {
149
- $this->duplicate = new PLL_Duplicate( $this );
150
- }
151
-
152
- if ( class_exists( 'PLL_Duplicate_REST' ) ) {
153
- $this->duplicate_rest = new PLL_Duplicate_REST();
154
- }
155
-
156
- if ( class_exists( 'PLL_Sync_Post_Model' ) ) {
157
- $this->sync_post_model = new PLL_Sync_Post_Model( $this );
158
- }
159
-
160
- // Block editor metabox
161
- if ( pll_use_block_editor_plugin() ) {
162
- $this->block_editor_plugin = new PLL_Block_Editor_Plugin( $this );
163
- }
164
-
165
- // FIXME: Specific for WP CRON and WP CLI as the action admin_init is not fired.
166
- // Waiting for a better way to handle the cases without loading the complete admin.
167
- if ( wp_doing_cron() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
168
- $this->maybe_load_sync_post();
169
- }
170
-
171
- }
172
-
173
- /**
174
- * Load the post synchronization object, depending on the editor in use.
175
- *
176
- * @since 2.6
177
- */
178
- public function maybe_load_sync_post() {
179
- // Post synchronization
180
- if ( 'post-new.php' === $GLOBALS['pagenow'] && function_exists( 'use_block_editor_for_post' ) ) {
181
- // We need to wait until we know which editor is in use
182
- add_filter( 'use_block_editor_for_post', array( $this, '_maybe_load_sync_post' ), 999 ); // After the plugin Classic Editor
183
- } elseif ( 'post.php' === $GLOBALS['pagenow'] && function_exists( 'use_block_editor_for_post' ) && isset( $_GET['post'] ) && empty( $_GET['meta-box-loader'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
184
- $this->_maybe_load_sync_post( use_block_editor_for_post( (int) $_GET['post'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
185
- } else {
186
- $this->_maybe_load_sync_post( false );
187
- }
188
- }
189
-
190
- /**
191
- * Load the post synchronization object, depending on the editor in use.
192
- *
193
- * We must make sure to instantiate the class only once, as the function may be called from a filter,
194
- * and that the synchronization model has been instantiated (due to InfiniteWP messing the actions wp_loaded and admin_init).
195
- *
196
- * @since 2.6
197
- *
198
- * @param bool $is_block_editor Whether to use the block editor or not.
199
- * @return bool
200
- */
201
- public function _maybe_load_sync_post( $is_block_editor ) {
202
- if ( ! isset( $this->sync_post ) && isset( $this->sync_post_model ) ) {
203
- if ( class_exists( 'PLL_Sync_Post_REST' ) && pll_use_block_editor_plugin() && $is_block_editor ) {
204
- $this->sync_post = new PLL_Sync_Post_REST( $this );
205
- } elseif ( class_exists( 'PLL_Sync_Post' ) ) {
206
- $this->sync_post = new PLL_Sync_Post( $this );
207
- }
208
- }
209
-
210
- return $is_block_editor;
211
  }
212
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Admin side controller
24
  * filters_post => reference to PLL_Admin_Filters_Post object
25
  * filters_term => reference to PLL_Admin_filters_Term object
26
  * nav_menu => reference to PLL_Admin_Nav_Menu object
 
27
  * block_editor => reference to PLL_Admin_Block_Editor object
28
  * classic_editor => reference to PLL_Admin_Classic_Editor object
29
  * filters_media => optional, reference to PLL_Admin_Filters_Media object
 
 
30
  *
31
  * @since 1.2
 
 
32
  */
33
  class PLL_Admin extends PLL_Admin_Base {
34
+ public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $filters_media;
35
 
36
  /**
37
  * Loads the polylang text domain
62
  // Priority 5 to make sure filters are there before customize_register is fired
63
  if ( $this->model->get_languages_list() ) {
64
  add_action( 'wp_loaded', array( $this, 'add_filters' ), 5 );
 
65
  }
66
  }
67
 
100
  */
101
  public function add_filters() {
102
  // All these are separated just for convenience and maintainability
103
+ $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Classic_Editor', 'Block_Editor' );
104
 
105
  // Don't load media filters if option is disabled or if user has no right
106
  if ( $this->options['media_support'] && ( $obj = get_post_type_object( 'attachment' ) ) && ( current_user_can( $obj->cap->edit_posts ) || current_user_can( $obj->cap->create_posts ) ) ) {
120
  $class = apply_filters( 'pll_' . $obj, 'PLL_Admin_' . $class );
121
  $this->$obj = new $class( $this );
122
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
  }
admin/view-translations-media.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
2
-
3
  /**
4
  * Displays the translations fields for media
5
  * Needs WP 3.5+
 
 
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
1
  <?php
 
2
  /**
3
  * Displays the translations fields for media
4
  * Needs WP 3.5+
5
+ *
6
+ * @package Polylang
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) {
admin/view-translations-post.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Displays the translations fields for posts
 
 
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) {
1
  <?php
 
2
  /**
3
  * Displays the translations fields for posts
4
+ *
5
+ * @package Polylang
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
admin/view-translations-term.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Displays the translations fields for terms
 
 
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) {
1
  <?php
 
2
  /**
3
  * Displays the translations fields for terms
4
+ *
5
+ * @package Polylang
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
css/admin.css CHANGED
@@ -228,25 +228,6 @@
228
  float: right;
229
  }
230
 
231
- /* Languages metabox buttons */
232
- .pll-button {
233
- padding: 0;
234
- height: 20px;
235
- background: none;
236
- border: none;
237
- font-size: 20px;
238
- cursor: pointer;
239
- }
240
-
241
- .pll-button:not(.wp-ui-text-highlight) {
242
- color: #DDDDDD;
243
- }
244
-
245
- #pll-duplicate {
246
- float: right;
247
- margin: 13px 7px;
248
- }
249
-
250
  /* language and translations in edit-tags.php */
251
  .pll-translation-flag { /* also for media */
252
  margin-right: 14px;
@@ -291,10 +272,6 @@
291
  }
292
 
293
  /* icon fonts */
294
- .pll_icon_tick:before {
295
- content: "\f147";
296
- }
297
-
298
  .pll_icon_add:before {
299
  content: "\f132";
300
  }
@@ -337,26 +314,6 @@
337
  margin-right: 10px;
338
  }
339
 
340
- /* Bulk translate */
341
- .bulk-translate-save .button {
342
- margin-right: 20px;
343
- }
344
-
345
- #wpbody-content #pll-translate fieldset {
346
- display: inline-block;
347
- width: 300px;
348
- }
349
-
350
- #pll-translate .pll-translation-flag {
351
- margin-right: 0.3em;
352
- }
353
-
354
- #pll-translate .title {
355
- display: block;
356
- margin: 0.2em 0;
357
- line-height: 2.5;
358
- }
359
-
360
  @media screen and ( max-width: 782px ) {
361
  /* settings */
362
  #wpbody-content .pll-settings .pll-configure > td {
228
  float: right;
229
  }
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  /* language and translations in edit-tags.php */
232
  .pll-translation-flag { /* also for media */
233
  margin-right: 14px;
272
  }
273
 
274
  /* icon fonts */
 
 
 
 
275
  .pll_icon_add:before {
276
  content: "\f132";
277
  }
314
  margin-right: 10px;
315
  }
316
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  @media screen and ( max-width: 782px ) {
318
  /* settings */
319
  #wpbody-content .pll-settings .pll-configure > td {
css/admin.min.css CHANGED
@@ -1 +1 @@
1
- #add-lang select{width:95%}.column-locale,.languages .column-slug{width:15%}.column-default_lang{width:5%}.column-count,.column-flag,.column-term_group{width:10%}.icon-default-lang:before{font-family:dashicons;content:"\f155"}.pll-icon:before{display:inline-block;text-align:left;width:15px}.pll-circle:before{content:"\25cf"}.form-field input[type=radio]{width:auto;margin-right:2px}#pll-about-box p,#pll-recommended p{text-align:justify}#pll-about-box input{margin:0;padding:0;float:right}.stringstranslations .column-context,.stringstranslations .column-name{width:10%}.stringstranslations .column-string{width:33%}.translation label{display:inline-block;width:23%;vertical-align:top}.translation input,.translation textarea{width:72%}.pll-settings{margin-top:20px}.pll-settings .plugin-title{width:25%}#wpbody-content .pll-settings .pll-configure tr{display:table-row}#wpbody-content .pll-settings .pll-configure td{display:table-cell}#wpbody-content .pll-settings .pll-configure>td{padding:20px 20px 20px 40px}.pll-configure legend{font-size:14px;font-weight:600;margin-bottom:.5em}.pll-configure td .description{margin-top:2px;margin-bottom:.5em}.pll-configure p.submit{margin-top:20px}.pll-configure .button{margin-right:20px}.pll-configure fieldset{margin-bottom:1.5em}.pll-inline-block-list{margin:0}.pll-inline-block-list li{display:inline-block;margin:0;width:250px}#pll-domains-table td{padding:2px 2px 2px 1.5em;-webkit-box-shadow:none;box-shadow:none;border:none}.pll-settings-url-col{display:inline-block;width:49%;vertical-align:top}#pll-licenses-table td{vertical-align:top}#pll-licenses-table label{font-size:1em;font-weight:600}.pll-configure .pll-deactivate-license{margin:0 0 0 20px}.wp-list-table td[class*=column-language_],.wp-list-table th[class*=column-language_]{width:1.5em;box-sizing:content-box}.pll-dir-rtl input[type=text],.pll-dir-rtl textarea{direction:rtl}.pll-dir-ltr input[type=text],.pll-dir-ltr textarea{direction:ltr}.pll-dir-ltr .tr_lang,.pll-dir-rtl .tr_lang{direction:inherit}#post-translations p{float:left}#post-translations table{table-layout:fixed;width:100%;clear:both}#post-translations a{text-decoration:none}#post-translations .pll-column-icon,#post-translations .pll-language-column{width:20px}#post-translations .tr_lang{width:100%}#post-translations td{padding:2px}#post-translations .spinner,#term-translations .spinner{float:none;margin:0;background-position:center;width:auto}.pll-column-icon{text-align:center}#select-post-language .pll-select-flag{padding:4px;margin-right:32px}#select-media-language .pll-select-flag{padding:4px;margin-right:10px}.pll-media-edit-column{float:right}.pll-button{padding:0;height:20px;background:0 0;border:none;font-size:20px;cursor:pointer}.pll-button:not(.wp-ui-text-highlight){color:#ddd}#pll-duplicate{float:right;margin:13px 7px}.pll-translation-flag{margin-right:14px}#select-add-term-language .pll-select-flag{padding:11px;margin-right:13px}#select-edit-term-language .pll-select-flag{padding:11px;margin-right:4px}#term-translations p{font-weight:400;font-style:normal;padding:2px;color:#23282d}#add-term-translations,#edit-term-translations{width:95%}#term-translations .pll-language-column{line-height:28px;width:20%}#add-term-translations .pll-language-column,#term-translations .pll-edit-column{width:20px}#edit-term-translations .pll-language-column{padding:15px 10px;font-weight:400}.pll_icon_tick:before{content:"\f147"}.pll_icon_add:before{content:"\f132"}.pll_icon_edit:before{content:"\f464"}[class^=pll_icon_]{font:20px/1 dashicons;vertical-align:middle}#wpadminbar #wp-admin-bar-languages .ab-item img{margin:0 8px 0 2px}#wpadminbar #wp-admin-bar-languages #wp-admin-bar-all .ab-item .ab-icon{float:none;top:4px}#wpadminbar #wp-admin-bar-languages .ab-icon:before{content:"\f326";top:1px}.pll-notice.notice{padding-right:38px;position:relative}.pll-notice a.notice-dismiss{text-decoration:none}.pll-notice .button{margin-right:10px}.bulk-translate-save .button{margin-right:20px}#wpbody-content #pll-translate fieldset{display:inline-block;width:300px}#pll-translate .pll-translation-flag{margin-right:.3em}#pll-translate .title{display:block;margin:.2em 0;line-height:2.5}@media screen and (max-width:782px){#wpbody-content .pll-settings .pll-configure>td{padding:20px}#wpbody-content .pll-settings #cb{padding:20px 9px}.pll-inline-block{width:auto}.pll-settings-url-col{display:block;width:100%}#wpbody-content .pll-settings #pll-licenses-table td{display:block}.pll-configure .pll-deactivate-license{margin:10px 0 5px}.stringstranslations .column-context,.stringstranslations .column-name{display:none}.translation label{display:block;width:95%;padding-left:0}.translation input{width:95%}#edit-term-translations .pll-language-name,#select-add-term-language .pll-select-flag,#select-edit-term-language .pll-select-flag{display:none}#edit-term-translations{width:100%}#add-term-translations .pll-language-column{line-height:38px}#edit-term-translations td{padding:8px 10px}#edit-term-translations .pll-edit-column,#edit-term-translations .pll-language-column{width:20px}.term-translations .pll-edit-column,.term-translations .pll-language-column,.term-translations .pll-translation-column{display:table-cell}.term-translations .hidden{display:none}#wpadminbar #wp-admin-bar-languages{display:block}#wpadminbar #wp-admin-bar-languages>.ab-item{width:50px;text-align:center}#wpadminbar #wp-admin-bar-languages>.ab-item .ab-icon:before{font:32px/1 dashicons;top:-1px}#wpadminbar #wp-admin-bar-languages>.ab-item img{margin:19px 0}#wpadminbar #wp-admin-bar-languages #wp-admin-bar-all .ab-item .ab-icon{margin-right:6px;font-size:20px!important;line-height:20px!important}}
1
+ #add-lang select{width:95%}.column-locale,.languages .column-slug{width:15%}.column-default_lang{width:5%}.column-count,.column-flag,.column-term_group{width:10%}.icon-default-lang:before{font-family:dashicons;content:"\f155"}.pll-icon:before{display:inline-block;text-align:left;width:15px}.pll-circle:before{content:"\25cf"}.form-field input[type=radio]{width:auto;margin-right:2px}#pll-about-box p,#pll-recommended p{text-align:justify}#pll-about-box input{margin:0;padding:0;float:right}.stringstranslations .column-context,.stringstranslations .column-name{width:10%}.stringstranslations .column-string{width:33%}.translation label{display:inline-block;width:23%;vertical-align:top}.translation input,.translation textarea{width:72%}.pll-settings{margin-top:20px}.pll-settings .plugin-title{width:25%}#wpbody-content .pll-settings .pll-configure tr{display:table-row}#wpbody-content .pll-settings .pll-configure td{display:table-cell}#wpbody-content .pll-settings .pll-configure>td{padding:20px 20px 20px 40px}.pll-configure legend{font-size:14px;font-weight:600;margin-bottom:.5em}.pll-configure td .description{margin-top:2px;margin-bottom:.5em}.pll-configure p.submit{margin-top:20px}.pll-configure .button{margin-right:20px}.pll-configure fieldset{margin-bottom:1.5em}.pll-inline-block-list{margin:0}.pll-inline-block-list li{display:inline-block;margin:0;width:250px}#pll-domains-table td{padding:2px 2px 2px 1.5em;-webkit-box-shadow:none;box-shadow:none;border:none}.pll-settings-url-col{display:inline-block;width:49%;vertical-align:top}#pll-licenses-table td{vertical-align:top}#pll-licenses-table label{font-size:1em;font-weight:600}.pll-configure .pll-deactivate-license{margin:0 0 0 20px}.wp-list-table td[class*=column-language_],.wp-list-table th[class*=column-language_]{width:1.5em;box-sizing:content-box}.pll-dir-rtl input[type=text],.pll-dir-rtl textarea{direction:rtl}.pll-dir-ltr input[type=text],.pll-dir-ltr textarea{direction:ltr}.pll-dir-ltr .tr_lang,.pll-dir-rtl .tr_lang{direction:inherit}#post-translations p{float:left}#post-translations table{table-layout:fixed;width:100%;clear:both}#post-translations a{text-decoration:none}#post-translations .pll-column-icon,#post-translations .pll-language-column{width:20px}#post-translations .tr_lang{width:100%}#post-translations td{padding:2px}#post-translations .spinner,#term-translations .spinner{float:none;margin:0;background-position:center;width:auto}.pll-column-icon{text-align:center}#select-post-language .pll-select-flag{padding:4px;margin-right:32px}#select-media-language .pll-select-flag{padding:4px;margin-right:10px}.pll-media-edit-column{float:right}.pll-translation-flag{margin-right:14px}#select-add-term-language .pll-select-flag{padding:11px;margin-right:13px}#select-edit-term-language .pll-select-flag{padding:11px;margin-right:4px}#term-translations p{font-weight:400;font-style:normal;padding:2px;color:#23282d}#add-term-translations,#edit-term-translations{width:95%}#term-translations .pll-language-column{line-height:28px;width:20%}#add-term-translations .pll-language-column,#term-translations .pll-edit-column{width:20px}#edit-term-translations .pll-language-column{padding:15px 10px;font-weight:400}.pll_icon_add:before{content:"\f132"}.pll_icon_edit:before{content:"\f464"}[class^=pll_icon_]{font:20px/1 dashicons;vertical-align:middle}#wpadminbar #wp-admin-bar-languages .ab-item img{margin:0 8px 0 2px}#wpadminbar #wp-admin-bar-languages #wp-admin-bar-all .ab-item .ab-icon{float:none;top:4px}#wpadminbar #wp-admin-bar-languages .ab-icon:before{content:"\f326";top:1px}.pll-notice.notice{padding-right:38px;position:relative}.pll-notice a.notice-dismiss{text-decoration:none}.pll-notice .button{margin-right:10px}@media screen and (max-width:782px){#wpbody-content .pll-settings .pll-configure>td{padding:20px}#wpbody-content .pll-settings #cb{padding:20px 9px}.pll-inline-block{width:auto}.pll-settings-url-col{display:block;width:100%}#wpbody-content .pll-settings #pll-licenses-table td{display:block}.pll-configure .pll-deactivate-license{margin:10px 0 5px}.stringstranslations .column-context,.stringstranslations .column-name{display:none}.translation label{display:block;width:95%;padding-left:0}.translation input{width:95%}#edit-term-translations .pll-language-name,#select-add-term-language .pll-select-flag,#select-edit-term-language .pll-select-flag{display:none}#edit-term-translations{width:100%}#add-term-translations .pll-language-column{line-height:38px}#edit-term-translations td{padding:8px 10px}#edit-term-translations .pll-edit-column,#edit-term-translations .pll-language-column{width:20px}.term-translations .pll-edit-column,.term-translations .pll-language-column,.term-translations .pll-translation-column{display:table-cell}.term-translations .hidden{display:none}#wpadminbar #wp-admin-bar-languages{display:block}#wpadminbar #wp-admin-bar-languages>.ab-item{width:50px;text-align:center}#wpadminbar #wp-admin-bar-languages>.ab-item .ab-icon:before{font:32px/1 dashicons;top:-1px}#wpadminbar #wp-admin-bar-languages>.ab-item img{margin:19px 0}#wpadminbar #wp-admin-bar-languages #wp-admin-bar-all .ab-item .ab-icon{margin-right:6px;font-size:20px!important;line-height:20px!important}}
frontend/choose-lang-content.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Choose the language when it is set from content
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Choose the language when it is set from content
frontend/choose-lang-domain.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Choose the language when the language is managed by different domains
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Choose the language when the language is managed by different domains
frontend/choose-lang-url.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Choose the language when the language code is added to all urls
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Choose the language when the language code is added to all urls
frontend/choose-lang.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Base class to choose the language
@@ -158,7 +161,7 @@ abstract class PLL_Choose_Lang {
158
  }
159
  }
160
 
161
- $accept_langs = wp_list_filter( $accept_langs, array( '0' ), 'NOT' ); // Remove languages markes as unacceptable (q=0).
162
 
163
  $languages = $this->model->get_languages_list( array( 'hide_empty' => true ) ); // Hides languages with no post
164
 
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Base class to choose the language
161
  }
162
  }
163
 
164
+ $accept_langs = array_filter( $accept_langs ); // Remove languages marked as unacceptable (q=0).
165
 
166
  $languages = $this->model->get_languages_list( array( 'hide_empty' => true ) ); // Hides languages with no post
167
 
frontend/frontend-auto-translate.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Auto translates the posts and terms ids
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Auto translates the posts and terms ids
frontend/frontend-filters-links.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages links filters on frontend
@@ -6,7 +9,26 @@
6
  * @since 1.8
7
  */
8
  class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
9
- public $cache; // Our internal non persistent cache object
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  /**
12
  * Constructor
@@ -237,10 +259,8 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
237
  return $url;
238
  }
239
 
240
- static $white_list, $black_list; // Avoid evaluating this at each function call
241
-
242
  // We *want* to filter the home url in these cases
243
- if ( empty( $white_list ) ) {
244
  // On Windows get_theme_root() mixes / and \
245
  // We want only \ for the comparison with debug_backtrace
246
  $theme_root = get_theme_root();
@@ -256,7 +276,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
256
  *
257
  * @param array $args
258
  */
259
- $white_list = apply_filters(
260
  'pll_home_url_white_list',
261
  array(
262
  array( 'file' => $theme_root ),
@@ -268,7 +288,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
268
  }
269
 
270
  // We don't want to filter the home url in these cases
271
- if ( empty( $black_list ) ) {
272
 
273
  /**
274
  * Filter the black list of the Polylang 'home_url' filter
@@ -280,7 +300,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
280
  *
281
  * @param array $args
282
  */
283
- $black_list = apply_filters(
284
  'pll_home_url_black_list',
285
  array(
286
  array( 'file' => 'searchform.php' ), // Since WP 3.6 searchform.php is passed through get_search_form
@@ -294,13 +314,13 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
294
 
295
  foreach ( $traces as $trace ) {
296
  // Black list first
297
- foreach ( $black_list as $v ) {
298
  if ( ( isset( $trace['file'], $v['file'] ) && false !== strpos( $trace['file'], $v['file'] ) ) || ( isset( $trace['function'], $v['function'] ) && $trace['function'] == $v['function'] ) ) {
299
  return $url;
300
  }
301
  }
302
 
303
- foreach ( $white_list as $v ) {
304
  if ( ( isset( $trace['function'], $v['function'] ) && $trace['function'] == $v['function'] ) ||
305
  ( isset( $trace['file'], $v['file'] ) && false !== strpos( $trace['file'], $v['file'] ) && in_array( $trace['function'], array( 'home_url', 'get_home_url', 'bloginfo', 'get_bloginfo' ) ) ) ) {
306
  $ok = true;
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages links filters on frontend
9
  * @since 1.8
10
  */
11
  class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
12
+ /**
13
+ * Our internal non persistent cache object
14
+ *
15
+ * @var PLL_Cache
16
+ */
17
+ public $cache;
18
+
19
+ /**
20
+ * Stores a list of files and functions that home_url() must not filter.
21
+ *
22
+ * @var array
23
+ */
24
+ private $black_list = array();
25
+
26
+ /**
27
+ * Stores a list of files and functions that home_url() must filter.
28
+ *
29
+ * @var array
30
+ */
31
+ private $white_list = array();
32
 
33
  /**
34
  * Constructor
259
  return $url;
260
  }
261
 
 
 
262
  // We *want* to filter the home url in these cases
263
+ if ( empty( $this->white_list ) ) {
264
  // On Windows get_theme_root() mixes / and \
265
  // We want only \ for the comparison with debug_backtrace
266
  $theme_root = get_theme_root();
276
  *
277
  * @param array $args
278
  */
279
+ $this->white_list = apply_filters(
280
  'pll_home_url_white_list',
281
  array(
282
  array( 'file' => $theme_root ),
288
  }
289
 
290
  // We don't want to filter the home url in these cases
291
+ if ( empty( $this->black_list ) ) {
292
 
293
  /**
294
  * Filter the black list of the Polylang 'home_url' filter
300
  *
301
  * @param array $args
302
  */
303
+ $this->black_list = apply_filters(
304
  'pll_home_url_black_list',
305
  array(
306
  array( 'file' => 'searchform.php' ), // Since WP 3.6 searchform.php is passed through get_search_form
314
 
315
  foreach ( $traces as $trace ) {
316
  // Black list first
317
+ foreach ( $this->black_list as $v ) {
318
  if ( ( isset( $trace['file'], $v['file'] ) && false !== strpos( $trace['file'], $v['file'] ) ) || ( isset( $trace['function'], $v['function'] ) && $trace['function'] == $v['function'] ) ) {
319
  return $url;
320
  }
321
  }
322
 
323
+ foreach ( $this->white_list as $v ) {
324
  if ( ( isset( $trace['function'], $v['function'] ) && $trace['function'] == $v['function'] ) ||
325
  ( isset( $trace['file'], $v['file'] ) && false !== strpos( $trace['file'], $v['file'] ) && in_array( $trace['function'], array( 'home_url', 'get_home_url', 'bloginfo', 'get_bloginfo' ) ) ) ) {
326
  $ok = true;
frontend/frontend-filters-search.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Filters search forms when using permalinks
@@ -70,8 +73,8 @@ class PLL_Frontend_Filters_Search {
70
  }
71
 
72
  /**
73
- * Rewrites the admin bar search form to pass our get_search form filter. See #21342
74
- * Code base last checked with WP 4.9.7
75
  *
76
  * @since 0.9
77
  *
@@ -84,11 +87,11 @@ class PLL_Frontend_Filters_Search {
84
  $form .= '<input type="submit" class="adminbar-button" value="' . esc_attr__( 'Search', 'polylang' ) . '"/>';
85
  $form .= '</form>';
86
 
87
- $wp_admin_bar->add_menu(
88
  array(
89
  'parent' => 'top-secondary',
90
  'id' => 'search',
91
- 'title' => $this->get_search_form( $form ), // Pass the get_search_form filter
92
  'meta' => array(
93
  'class' => 'admin-bar-search',
94
  'tabindex' => -1,
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Filters search forms when using permalinks
73
  }
74
 
75
  /**
76
+ * Rewrites the admin bar search form to pass our get_search_form filter. See #21342.
77
+ * Code last checked: WP 5.4.1.
78
  *
79
  * @since 0.9
80
  *
87
  $form .= '<input type="submit" class="adminbar-button" value="' . esc_attr__( 'Search', 'polylang' ) . '"/>';
88
  $form .= '</form>';
89
 
90
+ $wp_admin_bar->add_node(
91
  array(
92
  'parent' => 'top-secondary',
93
  'id' => 'search',
94
+ 'title' => $this->get_search_form( $form ), // Pass the get_search_form filter.
95
  'meta' => array(
96
  'class' => 'admin-bar-search',
97
  'tabindex' => -1,
frontend/frontend-filters.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Filters content by language on frontend
@@ -98,7 +101,7 @@ class PLL_Frontend_Filters extends PLL_Filters {
98
  $relations = $wpdb->get_results( "SELECT object_id, term_taxonomy_id FROM {$wpdb->term_relationships} WHERE object_id IN ({$posts}) AND term_taxonomy_id IN ({$languages})" );
99
 
100
  foreach ( $relations as $relation ) {
101
- $_posts[ $relation->term_taxonomy_id ][] = $relation->object_id;
102
  }
103
  wp_cache_add( 'sticky_posts', $_posts, 'options' );
104
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Filters content by language on frontend
101
  $relations = $wpdb->get_results( "SELECT object_id, term_taxonomy_id FROM {$wpdb->term_relationships} WHERE object_id IN ({$posts}) AND term_taxonomy_id IN ({$languages})" );
102
 
103
  foreach ( $relations as $relation ) {
104
+ $_posts[ $relation->term_taxonomy_id ][] = (int) $relation->object_id;
105
  }
106
  wp_cache_add( 'sticky_posts', $_posts, 'options' );
107
  }
frontend/frontend-links.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages links filters and url of translations on frontend
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages links filters and url of translations on frontend
frontend/frontend-nav-menu.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages custom menus translations as well as the language switcher menu item on frontend
@@ -106,7 +109,7 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
106
  // parent item for dropdown
107
  if ( ! empty( $options['dropdown'] ) ) {
108
  $name = isset( $options['display_names_as'] ) && 'slug' === $options['display_names_as'] ? $this->curlang->slug : $this->curlang->name;
109
- $item->title = $this->get_item_title( $this->curlang->flag, $name, $options );
110
  $item->attr_title = '';
111
  $item->classes = array( 'pll-parent-menu-item' );
112
  $new_items[] = $item;
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages custom menus translations as well as the language switcher menu item on frontend
109
  // parent item for dropdown
110
  if ( ! empty( $options['dropdown'] ) ) {
111
  $name = isset( $options['display_names_as'] ) && 'slug' === $options['display_names_as'] ? $this->curlang->slug : $this->curlang->name;
112
+ $item->title = $this->get_item_title( $this->curlang->get_display_flag(), $name, $options );
113
  $item->attr_title = '';
114
  $item->classes = array( 'pll-parent-menu-item' );
115
  $new_items[] = $item;
frontend/frontend-static-pages.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages the static front page and the page for posts on frontend
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages the static front page and the page for posts on frontend
frontend/frontend.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Frontend controller
@@ -18,7 +21,6 @@
18
  * posts => reference to PLL_CRUD_Posts object
19
  * terms => reference to PLL_CRUD_Terms object
20
  * nav_menu => reference to PLL_Frontend_Nav_Menu object
21
- * sync => reference to PLL_Sync object
22
  * auto_translate => optional, reference to PLL_Auto_Translate object
23
  *
24
  * @since 1.2
@@ -74,35 +76,6 @@ class PLL_Frontend extends PLL_Base {
74
 
75
  // Need to load nav menu class early to correctly define the locations in the customizer when the language is set from the content
76
  $this->nav_menu = new PLL_Frontend_Nav_Menu( $this );
77
-
78
- // Cross domain
79
- if ( PLL_COOKIE ) {
80
- $class = array( 2 => 'PLL_Xdata_Subdomain', 3 => 'PLL_Xdata_Domain' );
81
- if ( isset( $class[ $this->options['force_lang'] ] ) && class_exists( $class[ $this->options['force_lang'] ] ) ) {
82
- $this->xdata = new $class[ $this->options['force_lang'] ]( $this );
83
- }
84
- }
85
-
86
- if ( get_option( 'permalink_structure' ) ) {
87
- // Translate slugs
88
- if ( class_exists( 'PLL_Frontend_Translate_Slugs' ) ) {
89
- $slugs_model = new PLL_Translate_Slugs_Model( $this );
90
- $this->translate_slugs = new PLL_Frontend_Translate_Slugs( $slugs_model, $this->curlang );
91
- }
92
-
93
- // Share term slugs
94
- if ( $this->options['force_lang'] && class_exists( 'PLL_Share_Term_Slug' ) ) {
95
- $this->share_term_slug = new PLL_Share_Term_Slug( $this );
96
- }
97
- }
98
-
99
- if ( class_exists( 'PLL_Sync_Post_Model' ) ) {
100
- $this->sync_post_model = new PLL_Sync_Post_Model( $this );
101
- }
102
-
103
- if ( class_exists( 'PLL_Sync_Post' ) ) {
104
- $this->sync_post = new PLL_Sync_Post( $this );
105
- }
106
  }
107
 
108
  /**
@@ -115,10 +88,6 @@ class PLL_Frontend extends PLL_Base {
115
  $this->filters_links = new PLL_Frontend_Filters_Links( $this );
116
  $this->filters = new PLL_Frontend_Filters( $this );
117
  $this->filters_search = new PLL_Frontend_Filters_Search( $this );
118
- $this->posts = new PLL_CRUD_Posts( $this );
119
- $this->terms = new PLL_CRUD_Terms( $this );
120
-
121
- $this->sync = new PLL_Sync( $this );
122
 
123
  // Auto translate for Ajax
124
  if ( ( ! defined( 'PLL_AUTO_TRANSLATE' ) || PLL_AUTO_TRANSLATE ) && wp_doing_ajax() ) {
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Frontend controller
21
  * posts => reference to PLL_CRUD_Posts object
22
  * terms => reference to PLL_CRUD_Terms object
23
  * nav_menu => reference to PLL_Frontend_Nav_Menu object
 
24
  * auto_translate => optional, reference to PLL_Auto_Translate object
25
  *
26
  * @since 1.2
76
 
77
  // Need to load nav menu class early to correctly define the locations in the customizer when the language is set from the content
78
  $this->nav_menu = new PLL_Frontend_Nav_Menu( $this );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  /**
88
  $this->filters_links = new PLL_Frontend_Filters_Links( $this );
89
  $this->filters = new PLL_Frontend_Filters( $this );
90
  $this->filters_search = new PLL_Frontend_Filters_Search( $this );
 
 
 
 
91
 
92
  // Auto translate for Ajax
93
  if ( ( ! defined( 'PLL_AUTO_TRANSLATE' ) || PLL_AUTO_TRANSLATE ) && wp_doing_ajax() ) {
include/api.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Template tag: displays the language switcher
@@ -18,6 +21,7 @@
18
  * raw => set this to true to build your own custom language switcher, defaults to 0
19
  * item_spacing => whether to preserve or discard whitespace between list items, valid options are 'preserve' and 'discard', defaults to preserve
20
  *
 
21
  * @since 0.5
22
  *
23
  * @param array $args optional
@@ -35,6 +39,7 @@ function pll_the_languages( $args = '' ) {
35
  * Returns the current language on frontend
36
  * Returns the language set in admin language filter on backend ( false if set to all languages )
37
  *
 
38
  * @since 0.8.1
39
  *
40
  * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
@@ -50,6 +55,7 @@ function pll_current_language( $field = 'slug' ) {
50
  /**
51
  * Returns the default language
52
  *
 
53
  * @since 1.0
54
  *
55
  * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
@@ -71,6 +77,7 @@ function pll_default_language( $field = 'slug' ) {
71
  /**
72
  * Among the post and its translations, returns the id of the post which is in the language represented by $slug
73
  *
 
74
  * @since 0.5
75
  *
76
  * @param int $post_id post id
@@ -84,6 +91,7 @@ function pll_get_post( $post_id, $slug = '' ) {
84
  /**
85
  * Among the term and its translations, returns the id of the term which is in the language represented by $slug
86
  *
 
87
  * @since 0.5
88
  *
89
  * @param int $term_id term id
@@ -97,6 +105,7 @@ function pll_get_term( $term_id, $slug = '' ) {
97
  /**
98
  * Returns the home url in the current language
99
  *
 
100
  * @since 0.8
101
  *
102
  * @param string $lang language code ( optional on frontend )
@@ -113,6 +122,7 @@ function pll_home_url( $lang = '' ) {
113
  /**
114
  * Registers a string for translation in the "strings translation" panel
115
  *
 
116
  * @since 0.6
117
  *
118
  * @param string $name a unique name for the string
@@ -129,6 +139,7 @@ function pll_register_string( $name, $string, $context = 'polylang', $multiline
129
  /**
130
  * Translates a string ( previously registered with pll_register_string )
131
  *
 
132
  * @since 0.6
133
  *
134
  * @param string $string the string to translate
@@ -141,6 +152,7 @@ function pll__( $string ) {
141
  /**
142
  * Translates a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output.
143
  *
 
144
  * @since 2.1
145
  *
146
  * @param string $string the string to translate
@@ -153,6 +165,7 @@ function pll_esc_html__( $string ) {
153
  /**
154
  * Translates a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML attributes.
155
  *
 
156
  * @since 2.1
157
  *
158
  * @param string $string The string to translate
@@ -166,6 +179,7 @@ function pll_esc_attr__( $string ) {
166
  * Echoes a translated string ( previously registered with pll_register_string )
167
  * It is an equivalent of _e() and is not escaped.
168
  *
 
169
  * @since 0.6
170
  *
171
  * @param string $string The string to translate
@@ -177,6 +191,7 @@ function pll_e( $string ) {
177
  /**
178
  * Echoes a translated string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output.
179
  *
 
180
  * @since 2.1
181
  *
182
  * @param string $string The string to translate
@@ -188,6 +203,7 @@ function pll_esc_html_e( $string ) {
188
  /**
189
  * Echoes a translated a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML attributes.
190
  *
 
191
  * @since 2.1
192
  *
193
  * @param string $string The string to translate
@@ -199,6 +215,7 @@ function pll_esc_attr_e( $string ) {
199
  /**
200
  * Translates a string ( previously registered with pll_register_string )
201
  *
 
202
  * @since 1.5.4
203
  *
204
  * @param string $string the string to translate
@@ -232,6 +249,7 @@ function pll_translate_string( $string, $lang ) {
232
  /**
233
  * Returns true if Polylang manages languages and translations for this post type
234
  *
 
235
  * @since 1.0.1
236
  *
237
  * @param string $post_type Post type name
@@ -244,6 +262,7 @@ function pll_is_translated_post_type( $post_type ) {
244
  /**
245
  * Returns true if Polylang manages languages and translations for this taxonomy
246
  *
 
247
  * @since 1.0.1
248
  *
249
  * @param string $tax Taxonomy name
@@ -261,6 +280,7 @@ function pll_is_translated_taxonomy( $tax ) {
261
  * hide_empty => hides languages with no posts if set to true ( defaults to false )
262
  * fields => return only that field if set ( see PLL_Language for a list of fields )
263
  *
 
264
  * @since 1.5
265
  *
266
  * @param array $args list of parameters
@@ -274,6 +294,7 @@ function pll_languages_list( $args = array() ) {
274
  /**
275
  * Set the post language
276
  *
 
277
  * @since 1.5
278
  *
279
  * @param int $id post id
@@ -286,6 +307,7 @@ function pll_set_post_language( $id, $lang ) {
286
  /**
287
  * Set the term language
288
  *
 
289
  * @since 1.5
290
  *
291
  * @param int $id term id
@@ -298,6 +320,7 @@ function pll_set_term_language( $id, $lang ) {
298
  /**
299
  * Save posts translations
300
  *
 
301
  * @since 1.5
302
  *
303
  * @param array $arr an associative array of translations with language code as key and post id as value
@@ -309,6 +332,7 @@ function pll_save_post_translations( $arr ) {
309
  /**
310
  * Save terms translations
311
  *
 
312
  * @since 1.5
313
  *
314
  * @param array $arr an associative array of translations with language code as key and term id as value
@@ -320,6 +344,7 @@ function pll_save_term_translations( $arr ) {
320
  /**
321
  * Returns the post language
322
  *
 
323
  * @since 1.5.4
324
  *
325
  * @param int $post_id
@@ -333,6 +358,7 @@ function pll_get_post_language( $post_id, $field = 'slug' ) {
333
  /**
334
  * Returns the term language
335
  *
 
336
  * @since 1.5.4
337
  *
338
  * @param int $term_id
@@ -346,6 +372,7 @@ function pll_get_term_language( $term_id, $field = 'slug' ) {
346
  /**
347
  * Returns an array of translations of a post
348
  *
 
349
  * @since 1.8
350
  *
351
  * @param int $post_id
@@ -358,6 +385,7 @@ function pll_get_post_translations( $post_id ) {
358
  /**
359
  * Returns an array of translations of a term
360
  *
 
361
  * @since 1.8
362
  *
363
  * @param int $term_id
@@ -370,6 +398,7 @@ function pll_get_term_translations( $term_id ) {
370
  /**
371
  * Count posts in a language
372
  *
 
373
  * @since 1.5
374
  *
375
  * @param string $lang Language code.
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Template tag: displays the language switcher
21
  * raw => set this to true to build your own custom language switcher, defaults to 0
22
  * item_spacing => whether to preserve or discard whitespace between list items, valid options are 'preserve' and 'discard', defaults to preserve
23
  *
24
+ * @api
25
  * @since 0.5
26
  *
27
  * @param array $args optional
39
  * Returns the current language on frontend
40
  * Returns the language set in admin language filter on backend ( false if set to all languages )
41
  *
42
+ * @api
43
  * @since 0.8.1
44
  *
45
  * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
55
  /**
56
  * Returns the default language
57
  *
58
+ * @api
59
  * @since 1.0
60
  *
61
  * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
77
  /**
78
  * Among the post and its translations, returns the id of the post which is in the language represented by $slug
79
  *
80
+ * @api
81
  * @since 0.5
82
  *
83
  * @param int $post_id post id
91
  /**
92
  * Among the term and its translations, returns the id of the term which is in the language represented by $slug
93
  *
94
+ * @api
95
  * @since 0.5
96
  *
97
  * @param int $term_id term id
105
  /**
106
  * Returns the home url in the current language
107
  *
108
+ * @api
109
  * @since 0.8
110
  *
111
  * @param string $lang language code ( optional on frontend )
122
  /**
123
  * Registers a string for translation in the "strings translation" panel
124
  *
125
+ * @api
126
  * @since 0.6
127
  *
128
  * @param string $name a unique name for the string
139
  /**
140
  * Translates a string ( previously registered with pll_register_string )
141
  *
142
+ * @api
143
  * @since 0.6
144
  *
145
  * @param string $string the string to translate
152
  /**
153
  * Translates a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output.
154
  *
155
+ * @api
156
  * @since 2.1
157
  *
158
  * @param string $string the string to translate
165
  /**
166
  * Translates a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML attributes.
167
  *
168
+ * @api
169
  * @since 2.1
170
  *
171
  * @param string $string The string to translate
179
  * Echoes a translated string ( previously registered with pll_register_string )
180
  * It is an equivalent of _e() and is not escaped.
181
  *
182
+ * @api
183
  * @since 0.6
184
  *
185
  * @param string $string The string to translate
191
  /**
192
  * Echoes a translated string ( previously registered with pll_register_string ) and escapes it for safe use in HTML output.
193
  *
194
+ * @api
195
  * @since 2.1
196
  *
197
  * @param string $string The string to translate
203
  /**
204
  * Echoes a translated a string ( previously registered with pll_register_string ) and escapes it for safe use in HTML attributes.
205
  *
206
+ * @api
207
  * @since 2.1
208
  *
209
  * @param string $string The string to translate
215
  /**
216
  * Translates a string ( previously registered with pll_register_string )
217
  *
218
+ * @api
219
  * @since 1.5.4
220
  *
221
  * @param string $string the string to translate
249
  /**
250
  * Returns true if Polylang manages languages and translations for this post type
251
  *
252
+ * @api
253
  * @since 1.0.1
254
  *
255
  * @param string $post_type Post type name
262
  /**
263
  * Returns true if Polylang manages languages and translations for this taxonomy
264
  *
265
+ * @api
266
  * @since 1.0.1
267
  *
268
  * @param string $tax Taxonomy name
280
  * hide_empty => hides languages with no posts if set to true ( defaults to false )
281
  * fields => return only that field if set ( see PLL_Language for a list of fields )
282
  *
283
+ * @api
284
  * @since 1.5
285
  *
286
  * @param array $args list of parameters
294
  /**
295
  * Set the post language
296
  *
297
+ * @api
298
  * @since 1.5
299
  *
300
  * @param int $id post id
307
  /**
308
  * Set the term language
309
  *
310
+ * @api
311
  * @since 1.5
312
  *
313
  * @param int $id term id
320
  /**
321
  * Save posts translations
322
  *
323
+ * @api
324
  * @since 1.5
325
  *
326
  * @param array $arr an associative array of translations with language code as key and post id as value
332
  /**
333
  * Save terms translations
334
  *
335
+ * @api
336
  * @since 1.5
337
  *
338
  * @param array $arr an associative array of translations with language code as key and term id as value
344
  /**
345
  * Returns the post language
346
  *
347
+ * @api
348
  * @since 1.5.4
349
  *
350
  * @param int $post_id
358
  /**
359
  * Returns the term language
360
  *
361
+ * @api
362
  * @since 1.5.4
363
  *
364
  * @param int $term_id
372
  /**
373
  * Returns an array of translations of a post
374
  *
375
+ * @api
376
  * @since 1.8
377
  *
378
  * @param int $post_id
385
  /**
386
  * Returns an array of translations of a term
387
  *
388
+ * @api
389
  * @since 1.8
390
  *
391
  * @param int $term_id
398
  /**
399
  * Count posts in a language
400
  *
401
+ * @api
402
  * @since 1.5
403
  *
404
  * @param string $lang Language code.
include/base.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Base class for both admin and frontend
@@ -6,7 +9,40 @@
6
  * @since 1.2
7
  */
8
  abstract class PLL_Base {
9
- public $links_model, $model, $options;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  /**
12
  * Constructor
@@ -33,31 +69,15 @@ abstract class PLL_Base {
33
  }
34
 
35
  /**
36
- * Instantiate classes always needed
 
37
  *
38
  * @since 2.6
39
  */
40
  public function init() {
41
- // REST API
42
- if ( class_exists( 'PLL_REST_API' ) ) {
43
- $this->rest_api = new PLL_REST_API( $this );
44
- }
45
-
46
  if ( $this->model->get_languages_list() ) {
47
- // Used by content duplicate and post synchronization
48
- if ( class_exists( 'PLL_Sync_Content' ) ) {
49
- $this->sync_content = new PLL_Sync_Content( $this );
50
- }
51
-
52
- // Active languages
53
- if ( class_exists( 'PLL_Active_Languages' ) ) {
54
- $this->active_languages = new PLL_Active_Languages( $this );
55
- }
56
-
57
- // Share post slugs
58
- if ( get_option( 'permalink_structure' ) && $this->options['force_lang'] && class_exists( 'PLL_Share_Post_Slug' ) ) {
59
- $this->share_post_slug = new PLL_Share_Post_Slug( $this );
60
- }
61
  }
62
  }
63
 
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Base class for both admin and frontend
9
  * @since 1.2
10
  */
11
  abstract class PLL_Base {
12
+ /**
13
+ * Stores the plugin options.
14
+ *
15
+ * @var array
16
+ */
17
+ public $options;
18
+
19
+ /**
20
+ * Instance of PLL_Model.
21
+ *
22
+ * @var PLL_Model
23
+ */
24
+ public $model;
25
+
26
+ /**
27
+ * Instance of a child class of PLL_Links_Model.
28
+ *
29
+ * @var PLL_Links_Model
30
+ */
31
+ public $links_model;
32
+
33
+ /**
34
+ * Registers hooks on insert / update post related actions and filters.
35
+ *
36
+ * @var PLL_CRUD_Posts
37
+ */
38
+ public $posts;
39
+
40
+ /**
41
+ * Registers hooks on insert / update term related action and filters.
42
+ *
43
+ * @var PLL_CRUD_Terms
44
+ */
45
+ public $terms;
46
 
47
  /**
48
  * Constructor
69
  }
70
 
71
  /**
72
+ * Instantiates classes reacting to CRUD operations on posts and terms,
73
+ * only when at least one language is defined.
74
  *
75
  * @since 2.6
76
  */
77
  public function init() {
 
 
 
 
 
78
  if ( $this->model->get_languages_list() ) {
79
+ $this->posts = new PLL_CRUD_Posts( $this );
80
+ $this->terms = new PLL_CRUD_Terms( $this );
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
  }
83
 
include/cache.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * An extremely simple non persistent cache system
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * An extremely simple non persistent cache system
include/class-polylang.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  if ( ! defined( 'ABSPATH' ) ) {
4
  exit; // Don't access directly
@@ -27,8 +30,7 @@ class Polylang {
27
  * @since 0.1
28
  */
29
  public function __construct() {
30
- require_once PLL_INC . '/functions.php'; // VIP functions
31
- spl_autoload_register( array( $this, 'autoload' ) ); // Autoload classes
32
 
33
  // register an action when plugin is activating.
34
  register_activation_hook( POLYLANG_BASENAME, array( 'PLL_Wizard', 'start_wizard' ) );
@@ -50,60 +52,12 @@ class Polylang {
50
  PLL_OLT_Manager::instance();
51
  }
52
 
53
- // Extra code for compatibility with some plugins
54
- // Loaded as soon as possible as we may need to act before other plugins are loaded
 
 
55
  if ( ! defined( 'PLL_PLUGINS_COMPAT' ) || PLL_PLUGINS_COMPAT ) {
56
- PLL_Plugins_Compat::instance();
57
- }
58
- }
59
-
60
- /**
61
- * Autoload classes
62
- *
63
- * @since 1.2
64
- *
65
- * @param string $class
66
- */
67
- public function autoload( $class ) {
68
- // Not a Polylang class
69
- if ( 0 !== strncmp( 'PLL_', $class, 4 ) ) {
70
- return;
71
- }
72
-
73
- $class = str_replace( '_', '-', strtolower( substr( $class, 4 ) ) );
74
- $dirs = array();
75
- $parts = explode( '-', $class );
76
- $parts = array_values( array_diff( $parts, array( 'frontend', 'admin', 'settings', 'advanced' ) ) );
77
- if ( isset( $parts[0] ) ) {
78
- $dirs[] = PLL_MODULES_INC . "/{$parts[0]}";
79
- if ( isset( $parts[1] ) ) {
80
- $dirs[] = PLL_MODULES_INC . "/{$parts[0]}-{$parts[1]}";
81
- if ( isset( $parts[2] ) && in_array( $parts[1], array( 'post', 'term' ) ) ) {
82
- $dirs[] = PLL_MODULES_INC . "/{$parts[0]}-{$parts[2]}";
83
- }
84
- }
85
- }
86
-
87
- $dirs = array_merge(
88
- array(
89
- PLL_FRONT_INC,
90
- PLL_MODULES_INC,
91
- ),
92
- $dirs,
93
- array(
94
- PLL_MODULES_INC . '/plugins',
95
- PLL_INSTALL_INC,
96
- PLL_ADMIN_INC,
97
- PLL_SETTINGS_INC,
98
- PLL_INC,
99
- )
100
- );
101
-
102
- foreach ( $dirs as $dir ) {
103
- if ( file_exists( $file = "$dir/$class.php" ) ) {
104
- require_once $file; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
105
- return;
106
- }
107
  }
108
  }
109
 
@@ -280,11 +234,11 @@ class Polylang {
280
  */
281
  do_action_ref_array( 'pll_pre_init', array( &$polylang ) );
282
 
283
- require_once PLL_INC . '/api.php'; // Loads the API
284
 
285
- if ( ! defined( 'PLL_WPML_COMPAT' ) || PLL_WPML_COMPAT ) {
286
- PLL_WPML_Compat::instance(); // WPML API
287
- PLL_WPML_Config::instance(); // wpml-config.xml
288
  }
289
 
290
  $polylang->init();
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  if ( ! defined( 'ABSPATH' ) ) {
7
  exit; // Don't access directly
30
  * @since 0.1
31
  */
32
  public function __construct() {
33
+ require_once __DIR__ . '/functions.php'; // VIP functions
 
34
 
35
  // register an action when plugin is activating.
36
  register_activation_hook( POLYLANG_BASENAME, array( 'PLL_Wizard', 'start_wizard' ) );
52
  PLL_OLT_Manager::instance();
53
  }
54
 
55
+ /*
56
+ * Loads the compatibility with some plugins and themes.
57
+ * Loaded as soon as possible as we may need to act before other plugins are loaded.
58
+ */
59
  if ( ! defined( 'PLL_PLUGINS_COMPAT' ) || PLL_PLUGINS_COMPAT ) {
60
+ PLL_Integrations::instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
  }
63
 
234
  */
235
  do_action_ref_array( 'pll_pre_init', array( &$polylang ) );
236
 
237
+ require_once __DIR__ . '/api.php'; // Loads the API
238
 
239
+ // Loads the modules.
240
+ foreach ( glob( POLYLANG_DIR . '/modules/*/load.php', GLOB_NOSORT ) as $load_script ) { // phpcs:ignore WordPressVIPMinimum.Variables.VariableAnalysis.UnusedVariable
241
+ require_once $load_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
242
  }
243
 
244
  $polylang->init();
include/crud-posts.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Adds actions and filters related to languages when creating, updating or deleting posts
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Adds actions and filters related to languages when creating, updating or deleting posts
include/crud-terms.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Adds actions and filters related to languages when creating, reading, updating or deleting posts
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Adds actions and filters related to languages when creating, reading, updating or deleting posts
include/filters-links.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages links filters needed on both frontend and admin
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages links filters needed on both frontend and admin
include/filters.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Setup filters common to admin and frontend
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Setup filters common to admin and frontend
include/functions.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Define wordpress.com VIP equivalent of uncached functions
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Define wordpress.com VIP equivalent of uncached functions
include/language.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A language object is made of two terms in 'language' and 'term_language' taxonomies
@@ -81,7 +84,7 @@ class PLL_Language {
81
 
82
  $this->mo_id = PLL_MO::get_id( $this );
83
 
84
- $languages = include PLL_SETTINGS_INC . '/languages.php';
85
  $this->w3c = isset( $languages[ $this->locale ]['w3c'] ) ? $languages[ $this->locale ]['w3c'] : str_replace( '_', '-', $this->locale );
86
  if ( isset( $languages[ $this->locale ]['facebook'] ) ) {
87
  $this->facebook = $languages[ $this->locale ]['facebook'];
@@ -237,21 +240,21 @@ class PLL_Language {
237
  }
238
 
239
  /**
240
- * Replace flag by custom flag
241
- * Takes care of url scheme
242
  *
243
- * @since 1.7
244
  */
245
- public function set_custom_flag() {
246
- // Overwrite with custom flags on frontend only
247
- if ( ! empty( $this->custom_flag ) ) {
248
- $this->flag = $this->custom_flag;
249
- $this->flag_url = $this->custom_flag_url;
250
- unset( $this->custom_flag, $this->custom_flag_url ); // hide this
251
- }
252
 
253
- // Set url scheme, also for default flags
254
- $this->flag_url = set_url_scheme( $this->flag_url );
 
 
 
 
 
255
  }
256
 
257
  /**
@@ -278,14 +281,21 @@ class PLL_Language {
278
  }
279
 
280
  /**
281
- * Set home_url scheme
282
- * this can't be cached across pages
 
283
  *
284
- * @since 1.6.4
285
  */
286
- public function set_home_url_scheme() {
287
  $this->home_url = set_url_scheme( $this->home_url );
288
  $this->search_url = set_url_scheme( $this->search_url );
 
 
 
 
 
 
289
  }
290
 
291
  /**
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A language object is made of two terms in 'language' and 'term_language' taxonomies
84
 
85
  $this->mo_id = PLL_MO::get_id( $this );
86
 
87
+ $languages = include POLYLANG_DIR . '/settings/languages.php';
88
  $this->w3c = isset( $languages[ $this->locale ]['w3c'] ) ? $languages[ $this->locale ]['w3c'] : str_replace( '_', '-', $this->locale );
89
  if ( isset( $languages[ $this->locale ]['facebook'] ) ) {
90
  $this->facebook = $languages[ $this->locale ]['facebook'];
240
  }
241
 
242
  /**
243
+ * Returns the html of the custom flag if any, or the default flag otherwise.
 
244
  *
245
+ * @since 2.8
246
  */
247
+ public function get_display_flag() {
248
+ return empty( $this->custom_flag ) ? $this->flag : $this->custom_flag;
249
+ }
 
 
 
 
250
 
251
+ /**
252
+ * Returns the url of the custom flag if any, or the default flag otherwise.
253
+ *
254
+ * @since 2.8
255
+ */
256
+ public function get_display_flag_url() {
257
+ return empty( $this->custom_flag_url ) ? $this->flag : $this->custom_flag_url;
258
  }
259
 
260
  /**
281
  }
282
 
283
  /**
284
+ * Sets the scheme of the home url and the flag urls
285
+ *
286
+ * This can't be cached across pages.
287
  *
288
+ * @since 2.8
289
  */
290
+ public function set_url_scheme() {
291
  $this->home_url = set_url_scheme( $this->home_url );
292
  $this->search_url = set_url_scheme( $this->search_url );
293
+
294
+ // Set url scheme, also for the flags.
295
+ $this->flag_url = set_url_scheme( $this->flag_url );
296
+ if ( ! empty( $this->custom_flag_url ) ) {
297
+ $this->custom_flag_url = set_url_scheme( $this->custom_flag_url );
298
+ }
299
  }
300
 
301
  /**
include/license.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to easily manage licenses for Polylang Pro and addons
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to easily manage licenses for Polylang Pro and addons
include/links-abstract-domain.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Links model for use when using one domain or subdomain per language
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Links model for use when using one domain or subdomain per language
include/links-default.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Links model for default permalinks
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Links model for default permalinks
include/links-directory.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Links model for use when the language code is added in url as a directory
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Links model for use when the language code is added in url as a directory
include/links-domain.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Links model for use when using one domain per language
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Links model for use when using one domain per language
include/links-model.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Links model abstract class
@@ -116,8 +119,8 @@ abstract class PLL_Links_Model {
116
  $this->set_home_url( $language );
117
  }
118
 
119
- // Ensures that the ( possibly cached ) home url uses the right scheme http or https
120
- $language->set_home_url_scheme();
121
  }
122
  return $languages;
123
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Links model abstract class
119
  $this->set_home_url( $language );
120
  }
121
 
122
+ // Ensures that the ( possibly cached ) home and flag urls use the right scheme http or https.
123
+ $language->set_url_scheme();
124
  }
125
  return $languages;
126
  }
include/links-permalinks.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Links model base class when using pretty permalinks
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Links model base class when using pretty permalinks
include/links-subdomain.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Links model for use when the language code is added in url as a subdomain
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Links model for use when the language code is added in url as a subdomain
include/links.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages links related functions
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages links related functions
include/mo.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages strings translations storage
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages strings translations storage
include/model.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Setups the language and translations model based on WordPress taxonomies
@@ -102,13 +105,6 @@ class PLL_Model {
102
  }
103
  }
104
 
105
- // Custom flags
106
- if ( ! PLL_ADMIN ) {
107
- foreach ( $languages as $language ) {
108
- $language->set_custom_flag();
109
- }
110
- }
111
-
112
  /**
113
  * Filter the list of languages *after* it is stored in the persistent cache
114
  * /!\ this filter is fired *before* the $polylang object is available
@@ -444,6 +440,40 @@ class PLL_Model {
444
  return $wpdb->get_var( $select . $join . $where );
445
  }
446
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  /**
448
  * Gets the number of posts per language in a date, author or post type archive.
449
  *
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Setups the language and translations model based on WordPress taxonomies
105
  }
106
  }
107
 
 
 
 
 
 
 
 
108
  /**
109
  * Filter the list of languages *after* it is stored in the persistent cache
110
  * /!\ this filter is fired *before* the $polylang object is available
440
  return $wpdb->get_var( $select . $join . $where );
441
  }
442
 
443
+ /**
444
+ * Checks if a term slug exists in a given language, taxonomy, hierarchy
445
+ *
446
+ * @since 1.9
447
+ * @since 2.8 Moved from PLL_Share_Term_Slug::term_exists() to PLL_Model::term_exists_by_slug()
448
+ *
449
+ * @param string $slug The term slug to test.
450
+ * @param string|object $language The language slug or object.
451
+ * @param string $taxonomy Optional taxonomy name.
452
+ * @param int $parent Optional parent term id.
453
+ * @return null|int The term_id of the found term.
454
+ */
455
+ public function term_exists_by_slug( $slug, $language, $taxonomy = '', $parent = 0 ) {
456
+ global $wpdb;
457
+
458
+ $select = "SELECT t.term_id FROM {$wpdb->terms} AS t";
459
+ $join = " INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id";
460
+ $join .= $this->term->join_clause();
461
+ $where = $wpdb->prepare( ' WHERE t.slug = %s', $slug );
462
+ $where .= $this->term->where_clause( $this->get_language( $language ) );
463
+
464
+ if ( ! empty( $taxonomy ) ) {
465
+ $where .= $wpdb->prepare( ' AND tt.taxonomy = %s', $taxonomy );
466
+ }
467
+
468
+ if ( $parent > 0 ) {
469
+ $where .= $wpdb->prepare( ' AND tt.parent = %d', $parent );
470
+ }
471
+
472
+ // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
473
+ return $wpdb->get_var( $select . $join . $where );
474
+ }
475
+
476
+
477
  /**
478
  * Gets the number of posts per language in a date, author or post type archive.
479
  *
include/nav-menu.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages custom menus translations
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages custom menus translations
include/olt-manager.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * It is best practice that plugins do nothing before plugins_loaded is fired
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * It is best practice that plugins do nothing before plugins_loaded is fired
include/pointer.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to manage WP pointers
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to manage WP pointers
include/query.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to manipulate the language query var in WP_Query
@@ -6,30 +9,6 @@
6
  * @since 2.2
7
  */
8
  class PLL_Query {
9
-
10
- protected static $excludes = array(
11
- 'p',
12
- 'post_parent',
13
- 'attachment',
14
- 'attachment_id',
15
- 'name',
16
- 'pagename',
17
- 'page_id',
18
- 'category_name',
19
- 'tag',
20
- 'tag_id',
21
- 'cat',
22
- 'category__in',
23
- 'category__and',
24
- 'post__in',
25
- 'post_name__in',
26
- 'tag__in',
27
- 'tag__and',
28
- 'tag_slug__in',
29
- 'tag_slug__and',
30
- 'post_parent__in',
31
- );
32
-
33
  /**
34
  * Constructor
35
  *
@@ -129,33 +108,6 @@ class PLL_Query {
129
  $qvars = &$this->query->query_vars;
130
 
131
  if ( ! isset( $qvars['lang'] ) ) {
132
- /**
133
- * Filter the query vars which disable the language filter in a query
134
- *
135
- * @since 2.3.5
136
- *
137
- * @param array $excludes Query vars excluded from the language filter
138
- * @param object $query WP Query
139
- * @param object $lang Language
140
- */
141
- $excludes = apply_filters( 'pll_filter_query_excluded_query_vars', self::$excludes, $this->query, $lang );
142
-
143
- // Do not filter the query if the language is already specified in another way
144
- foreach ( $excludes as $k ) {
145
- if ( ! empty( $qvars[ $k ] ) ) {
146
- // Specific case for 'cat' as it can contain negative values
147
- if ( 'cat' === $k ) {
148
- foreach ( explode( ',', $qvars['cat'] ) as $cat ) {
149
- if ( $cat > 0 ) {
150
- return;
151
- }
152
- }
153
- } else {
154
- return;
155
- }
156
- }
157
- }
158
-
159
  $taxonomies = array_intersect( $this->model->get_translated_taxonomies(), get_taxonomies( array( '_builtin' => false ) ) );
160
 
161
  foreach ( $taxonomies as $tax ) {
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to manipulate the language query var in WP_Query
9
  * @since 2.2
10
  */
11
  class PLL_Query {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * Constructor
14
  *
108
  $qvars = &$this->query->query_vars;
109
 
110
  if ( ! isset( $qvars['lang'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  $taxonomies = array_intersect( $this->model->get_translated_taxonomies(), get_taxonomies( array( '_builtin' => false ) ) );
112
 
113
  foreach ( $taxonomies as $tax ) {
include/rest-request.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * REST API controller
@@ -14,12 +17,11 @@
14
  * filters_links => reference to PLL_Filters_Links object
15
  * posts => reference to PLL_CRUD_Posts object
16
  * terms => reference to PLL_CRUD_Terms object
17
- * sync => reference to PLL_Sync object
18
  *
19
  * @since 2.6
20
  */
21
  class PLL_REST_Request extends PLL_Base {
22
- public $links, $static_pages, $posts, $terms, $filters, $filters_links, $sync;
23
 
24
  /**
25
  * Setup filters
@@ -43,35 +45,8 @@ class PLL_REST_Request extends PLL_Base {
43
  }
44
 
45
  $this->links = new PLL_Admin_Links( $this );
46
- $this->posts = new PLL_CRUD_Posts( $this );
47
- $this->terms = new PLL_CRUD_Terms( $this );
48
- $this->sync = new PLL_Sync( $this );
49
 
50
  $this->nav_menu = new PLL_Nav_Menu( $this ); // For auto added pages to menu
51
-
52
- // Share term slugs
53
- if ( get_option( 'permalink_structure' ) && $this->options['force_lang'] && class_exists( 'PLL_Share_Term_Slug' ) ) {
54
- $this->share_term_slug = new PLL_Share_Term_Slug( $this );
55
- }
56
-
57
- // Translate slugs, only for pretty permalinks
58
- if ( get_option( 'permalink_structure' ) && class_exists( 'PLL_Translate_Slugs' ) ) {
59
- $curlang = null;
60
- $slugs_model = new PLL_Translate_Slugs_Model( $this );
61
- $this->translate_slugs = new PLL_Translate_Slugs( $slugs_model, $curlang );
62
- }
63
-
64
- if ( class_exists( 'PLL_Sync_Post_Model' ) ) {
65
- $this->sync_post_model = new PLL_Sync_Post_Model( $this );
66
- }
67
-
68
- if ( class_exists( 'PLL_Sync_Post_REST' ) ) {
69
- $this->sync_post = new PLL_Sync_Post_REST( $this );
70
- }
71
-
72
- if ( class_exists( 'PLL_Duplicate_REST' ) ) {
73
- $this->duplicate_rest = new PLL_Duplicate_REST();
74
- }
75
  }
76
  }
77
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * REST API controller
17
  * filters_links => reference to PLL_Filters_Links object
18
  * posts => reference to PLL_CRUD_Posts object
19
  * terms => reference to PLL_CRUD_Terms object
 
20
  *
21
  * @since 2.6
22
  */
23
  class PLL_REST_Request extends PLL_Base {
24
+ public $links, $static_pages, $posts, $terms, $filters, $filters_links;
25
 
26
  /**
27
  * Setup filters
45
  }
46
 
47
  $this->links = new PLL_Admin_Links( $this );
 
 
 
48
 
49
  $this->nav_menu = new PLL_Nav_Menu( $this ); // For auto added pages to menu
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
  }
52
  }
include/static-pages.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Base class to manage the static front page and the page for posts
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Base class to manage the static front page and the page for posts
include/switcher.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to display a language switcher on frontend
@@ -13,7 +16,7 @@ class PLL_Switcher {
13
  *
14
  * @since 0.7
15
  *
16
- * @param string $type optional either 'menu' or 'widget', defaults to 'widget'
17
  * @param string $key optional either 'string' or 'default', defaults to 'string'
18
  * @return array list of switcher options strings or default values
19
  */
@@ -26,7 +29,6 @@ class PLL_Switcher {
26
  'hide_current' => array( 'string' => __( 'Hides the current language', 'polylang' ), 'default' => 0 ),
27
  'hide_if_no_translation' => array( 'string' => __( 'Hides languages with no translation', 'polylang' ), 'default' => 0 ),
28
  );
29
-
30
  return wp_list_pluck( $options, $key );
31
  }
32
 
@@ -52,8 +54,10 @@ class PLL_Switcher {
52
  $locale = $language->get_locale( 'display' );
53
  $classes = array( 'lang-item', 'lang-item-' . $id, 'lang-item-' . esc_attr( $slug ) );
54
  $url = null; // Avoids potential notice
 
 
55
 
56
- if ( $current_lang = $links->curlang->slug == $slug ) {
57
  if ( $args['hide_current'] && ! ( $args['dropdown'] && ! $args['raw'] ) ) {
58
  continue; // Hide current language except for dropdown
59
  } else {
@@ -63,7 +67,7 @@ class PLL_Switcher {
63
 
64
  if ( null !== $args['post_id'] && ( $tr_id = $links->model->post->get( $args['post_id'], $language ) ) && $links->model->post->current_user_can_read( $tr_id ) ) {
65
  $url = get_permalink( $tr_id );
66
- } elseif ( null === $args['post_id'] ) {
67
  $url = $links->get_translation_url( $language );
68
  }
69
 
@@ -90,7 +94,7 @@ class PLL_Switcher {
90
  $url = empty( $url ) || $args['force_home'] ? $links->get_home_url( $language ) : $url; // If the page is not translated, link to the home page
91
 
92
  $name = $args['show_names'] || ! $args['show_flags'] || $args['raw'] ? ( 'slug' == $args['display_names_as'] ? $slug : $language->name ) : '';
93
- $flag = $args['raw'] && ! $args['show_flags'] ? $language->flag_url : ( $args['show_flags'] ? $language->flag : '' );
94
 
95
  if ( $first ) {
96
  $classes[] = 'lang-item-first';
@@ -121,6 +125,8 @@ class PLL_Switcher {
121
  * post_id => returns links to translations of post defined by post_id if set, defaults not set
122
  * raw => return a raw array instead of html markup if set to 1, defaults to 0
123
  * item_spacing => whether to preserve or discard whitespace between list items, valid options are 'preserve' and 'discard', defaults to preserve
 
 
124
  *
125
  * @since 0.1
126
  *
@@ -143,6 +149,8 @@ class PLL_Switcher {
143
  'post_id' => null, // if not null, link to translations of post defined by post_id
144
  'raw' => 0, // set this to true to build your own custom language switcher
145
  'item_spacing' => 'preserve', // 'preserve' or 'discard' whitespace between list items
 
 
146
  );
147
  $args = wp_parse_args( $args, $defaults );
148
 
@@ -169,7 +177,7 @@ class PLL_Switcher {
169
  if ( $args['dropdown'] ) {
170
  $args['name'] = 'lang_choice_' . $args['dropdown'];
171
  $walker = new PLL_Walker_Dropdown();
172
- $args['selected'] = $links->curlang->slug;
173
  }
174
  else {
175
  $walker = new PLL_Walker_List();
@@ -186,7 +194,7 @@ class PLL_Switcher {
186
  $out = apply_filters( 'pll_the_languages', $walker->walk( $elements, -1, $args ), $args );
187
 
188
  // Javascript to switch the language when using a dropdown list
189
- if ( $args['dropdown'] ) {
190
  // Accept only few valid characters for the urls_x variable name ( as the widget id includes '-' which is invalid )
191
  $out .= sprintf(
192
  '<script type="text/javascript">
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to display a language switcher on frontend
16
  *
17
  * @since 0.7
18
  *
19
+ * @param string $type optional either 'menu', 'widget' or 'block', defaults to 'widget'
20
  * @param string $key optional either 'string' or 'default', defaults to 'string'
21
  * @return array list of switcher options strings or default values
22
  */
29
  'hide_current' => array( 'string' => __( 'Hides the current language', 'polylang' ), 'default' => 0 ),
30
  'hide_if_no_translation' => array( 'string' => __( 'Hides languages with no translation', 'polylang' ), 'default' => 0 ),
31
  );
 
32
  return wp_list_pluck( $options, $key );
33
  }
34
 
54
  $locale = $language->get_locale( 'display' );
55
  $classes = array( 'lang-item', 'lang-item-' . $id, 'lang-item-' . esc_attr( $slug ) );
56
  $url = null; // Avoids potential notice
57
+ $curlang = 0 === $args['admin_render'] ? $links->curlang->slug : $args['admin_current_lang'];
58
+ $current_lang = $curlang == $slug;
59
 
60
+ if ( $current_lang ) {
61
  if ( $args['hide_current'] && ! ( $args['dropdown'] && ! $args['raw'] ) ) {
62
  continue; // Hide current language except for dropdown
63
  } else {
67
 
68
  if ( null !== $args['post_id'] && ( $tr_id = $links->model->post->get( $args['post_id'], $language ) ) && $links->model->post->current_user_can_read( $tr_id ) ) {
69
  $url = get_permalink( $tr_id );
70
+ } elseif ( null === $args['post_id'] && 0 === $args['admin_render'] ) {
71
  $url = $links->get_translation_url( $language );
72
  }
73
 
94
  $url = empty( $url ) || $args['force_home'] ? $links->get_home_url( $language ) : $url; // If the page is not translated, link to the home page
95
 
96
  $name = $args['show_names'] || ! $args['show_flags'] || $args['raw'] ? ( 'slug' == $args['display_names_as'] ? $slug : $language->name ) : '';
97
+ $flag = $args['raw'] && ! $args['show_flags'] ? $language->get_display_flag_url() : ( $args['show_flags'] ? $language->get_display_flag() : '' );
98
 
99
  if ( $first ) {
100
  $classes[] = 'lang-item-first';
125
  * post_id => returns links to translations of post defined by post_id if set, defaults not set
126
  * raw => return a raw array instead of html markup if set to 1, defaults to 0
127
  * item_spacing => whether to preserve or discard whitespace between list items, valid options are 'preserve' and 'discard', defaults to preserve
128
+ * admin_render => allows to force the current language code in an admin context if set, default to 0. Need to set the admin_current_lang argument below
129
+ * admin_current_lang => the current language code in an admin context. Need to set the admin_render to 1, defaults not set
130
  *
131
  * @since 0.1
132
  *
149
  'post_id' => null, // if not null, link to translations of post defined by post_id
150
  'raw' => 0, // set this to true to build your own custom language switcher
151
  'item_spacing' => 'preserve', // 'preserve' or 'discard' whitespace between list items
152
+ 'admin_render' => 0, // make the switcher in an frontend context
153
+ 'admin_current_lang' => null, // use when admin_render is set to 1, if not null use it instead of the current language
154
  );
155
  $args = wp_parse_args( $args, $defaults );
156
 
177
  if ( $args['dropdown'] ) {
178
  $args['name'] = 'lang_choice_' . $args['dropdown'];
179
  $walker = new PLL_Walker_Dropdown();
180
+ $args['selected'] = 0 === $args['admin_render'] ? $links->curlang->slug : $args['admin_current_lang'];
181
  }
182
  else {
183
  $walker = new PLL_Walker_List();
194
  $out = apply_filters( 'pll_the_languages', $walker->walk( $elements, -1, $args ), $args );
195
 
196
  // Javascript to switch the language when using a dropdown list
197
+ if ( $args['dropdown'] && 0 === $args['admin_render'] ) {
198
  // Accept only few valid characters for the urls_x variable name ( as the widget id includes '-' which is invalid )
199
  $out .= sprintf(
200
  '<script type="text/javascript">
include/translated-object.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Setups the objects languages and translations model
@@ -43,6 +46,11 @@ abstract class PLL_Translated_Object {
43
  }
44
 
45
  $object_id = (int) $object_id;
 
 
 
 
 
46
  $term = get_object_term_cache( $object_id, $taxonomy );
47
 
48
  if ( false === $term ) {
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Setups the objects languages and translations model
46
  }
47
 
48
  $object_id = (int) $object_id;
49
+
50
+ if ( $object_id < 0 ) {
51
+ return false;
52
+ }
53
+
54
  $term = get_object_term_cache( $object_id, $taxonomy );
55
 
56
  if ( false === $term ) {
include/translated-post.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Setups the posts languages and translations model
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Setups the posts languages and translations model
include/translated-term.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Setups the taxonomies languages and translations model
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Setups the taxonomies languages and translations model
include/walker-dropdown.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Displays languages in a dropdown list
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Displays languages in a dropdown list
include/walker-list.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Displays a language list
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Displays a language list
include/widget-calendar.php CHANGED
@@ -1,28 +1,33 @@
1
  <?php
 
 
 
2
 
3
  if ( ! class_exists( 'WP_Widget_Calendar' ) ) {
4
  require_once ABSPATH . '/wp-includes/default-widgets.php';
5
  }
6
 
7
  /**
8
- * Obliged to rewrite the whole functionality as there is no filter on sql queries and only a filter on final output
9
- * Code base last checked with WP 4.9.7
10
- * A request for making a filter on sql queries exists: http://core.trac.wordpress.org/ticket/15202
11
- * Method used in 0.4.x: use of the get_calendar filter and overwrite the output of get_calendar function -> not very efficient (add 4 to 5 sql queries)
12
- * Method used since 0.5: remove the WP widget and replace it by our own -> our language filter will not work if get_calendar is called directly by a theme
 
13
  *
14
  * @since 0.5
15
  */
16
  class PLL_Widget_Calendar extends WP_Widget_Calendar {
17
- protected static $pll_instance = 0; // Can't use $instance of WP_Widget_Calendar as it's private :/
18
 
19
  /**
20
  * Outputs the content for the current Calendar widget instance.
21
- * Modified version of the parent function to call our own get_calendar function.
22
  *
23
  * @since 0.5
24
  *
25
- * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
 
26
  * @param array $instance The settings for the particular instance of the widget.
27
  */
28
  public function widget( $args, $instance ) {
@@ -48,21 +53,21 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
48
  }
49
 
50
  /**
51
- * Modified version of WP get_calendar function to filter the query
52
  *
53
  * @since 0.5
54
  *
55
  * @param bool $initial Optional, default is true. Use initial calendar names.
56
- * @param bool $echo Optional, default is true. Set to false for return.
57
- * @return string|null String when retrieving, null when displaying.
58
  */
59
  static public function get_calendar( $initial = true, $echo = true ) {
60
  global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
61
 
62
- $join_clause = PLL()->model->post->join_clause(); #added#
63
  $where_clause = PLL()->model->post->where_clause( PLL()->curlang ); #added#
64
 
65
- $key = md5( PLL()->curlang->slug . $m . $monthnum . $year ); #modified#
66
  $cache = wp_cache_get( 'get_calendar', 'calendar' );
67
 
68
  if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) {
@@ -83,7 +88,7 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
83
 
84
  // Quick check. If we have no posts at all, abort!
85
  if ( ! $posts ) {
86
- $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
87
  if ( ! $gotsome ) {
88
  $cache[ $key ] = '';
89
  wp_cache_set( 'get_calendar', $cache, 'calendar' );
@@ -94,20 +99,19 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
94
  if ( isset( $_GET['w'] ) ) {
95
  $w = (int) $_GET['w'];
96
  }
97
- // week_begins = 0 stands for Sunday
98
  $week_begins = (int) get_option( 'start_of_week' );
99
- $ts = current_time( 'timestamp' );
100
 
101
- // Let's figure out when we are
102
  if ( ! empty( $monthnum ) && ! empty( $year ) ) {
103
  $thismonth = zeroise( intval( $monthnum ), 2 );
104
- $thisyear = (int) $year;
105
  } elseif ( ! empty( $w ) ) {
106
- // We need to get the month from MySQL
107
  $thisyear = (int) substr( $m, 0, 4 );
108
- //it seems MySQL's weeks disagree with PHP's
109
- $d = ( ( $w - 1 ) * 7 ) + 6;
110
- $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
111
  } elseif ( ! empty( $m ) ) {
112
  $thisyear = (int) substr( $m, 0, 4 );
113
  if ( strlen( $m ) < 6 ) {
@@ -116,34 +120,38 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
116
  $thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
117
  }
118
  } else {
119
- $thisyear = gmdate( 'Y', $ts );
120
- $thismonth = gmdate( 'm', $ts );
121
  }
122
 
123
- $unixmonth = mktime( 0, 0 , 0, $thismonth, 1, $thisyear );
124
- $last_day = date( 't', $unixmonth );
125
 
126
- // Get the next and previous month and year with at least one post
127
- $previous = $wpdb->get_row( "SELECT MONTH( post_date ) AS month, YEAR( post_date ) AS year
 
128
  FROM $wpdb->posts $join_clause
129
  WHERE post_date < '$thisyear-$thismonth-01'
130
  AND post_type = 'post' AND post_status = 'publish' $where_clause
131
  ORDER BY post_date DESC
132
- LIMIT 1" ); #modified#
133
- $next = $wpdb->get_row( "SELECT MONTH( post_date ) AS month, YEAR( post_date ) AS year
 
 
134
  FROM $wpdb->posts $join_clause
135
  WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
136
  AND post_type = 'post' AND post_status = 'publish' $where_clause
137
  ORDER BY post_date ASC
138
- LIMIT 1" ); #modified#
 
139
 
140
- /* translators: Calendar caption: 1: month name, 2: 4-digit year */
141
  $calendar_caption = _x( '%1$s %2$s', 'calendar caption' );
142
- $calendar_output = '<table id="wp-calendar">
143
  <caption>' . sprintf(
144
  $calendar_caption,
145
  $wp_locale->get_month( $thismonth ),
146
- date( 'Y', $unixmonth )
147
  ) . '</caption>
148
  <thead>
149
  <tr>';
@@ -155,85 +163,62 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
155
  }
156
 
157
  foreach ( $myweek as $wd ) {
158
- $day_name = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
159
- $wd = esc_attr( $wd );
160
  $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
161
  }
162
 
163
  $calendar_output .= '
164
  </tr>
165
  </thead>
166
-
167
- <tfoot>
168
- <tr>';
169
-
170
- if ( $previous ) {
171
- $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">&laquo; ' .
172
- $wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
173
- '</a></td>';
174
- } else {
175
- $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
176
- }
177
-
178
- $calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
179
-
180
- if ( $next ) {
181
- $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
182
- $wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
183
- ' &raquo;</a></td>';
184
- } else {
185
- $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
186
- }
187
-
188
- $calendar_output .= '
189
- </tr>
190
- </tfoot>
191
-
192
  <tbody>
193
  <tr>';
194
 
195
  $daywithpost = array();
196
 
197
- // Get days with posts
198
- $dayswithposts = $wpdb->get_results( "SELECT DISTINCT DAYOFMONTH( post_date )
199
- FROM $wpdb->posts $join_clause
200
- WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
201
- AND post_type = 'post' AND post_status = 'publish' $where_clause
202
- AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N ); #modified#
 
 
 
203
  if ( $dayswithposts ) {
204
  foreach ( (array) $dayswithposts as $daywith ) {
205
- $daywithpost[] = $daywith[0];
206
  }
207
  }
208
 
209
- // See how much we should pad in the beginning
210
- $pad = calendar_week_mod( date( 'w', $unixmonth ) - $week_begins );
211
  if ( 0 != $pad ) {
212
- $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr( $pad ) .'" class="pad">&nbsp;</td>';
213
  }
214
 
215
- $newrow = false;
216
- $daysinmonth = (int) date( 't', $unixmonth );
217
 
218
  for ( $day = 1; $day <= $daysinmonth; ++$day ) {
219
- if ( isset($newrow) && $newrow ) {
220
  $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
221
  }
222
  $newrow = false;
223
 
224
- if ( $day == gmdate( 'j', $ts ) &&
225
- $thismonth == gmdate( 'm', $ts ) &&
226
- $thisyear == gmdate( 'Y', $ts ) ) {
227
  $calendar_output .= '<td id="today">';
228
  } else {
229
  $calendar_output .= '<td>';
230
  }
231
 
232
- if ( in_array( $day, $daywithpost ) ) {
233
- // any posts today?
234
- $date_format = date( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
235
- /* translators: Post calendar label. 1: Date */
236
- $label = sprintf( __( 'Posts published on %s' ), $date_format );
237
  $calendar_output .= sprintf(
238
  '<a href="%s" aria-label="%s">%s</a>',
239
  get_day_link( $thisyear, $thismonth, $day ),
@@ -243,30 +228,51 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
243
  } else {
244
  $calendar_output .= $day;
245
  }
 
246
  $calendar_output .= '</td>';
247
 
248
- if ( 6 == calendar_week_mod( date( 'w', mktime(0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
249
  $newrow = true;
250
  }
251
  }
252
 
253
- $pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins );
254
- if ( $pad != 0 && $pad != 7 ) {
255
- $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr( $pad ) .'">&nbsp;</td>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  }
257
- $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
 
 
258
 
259
  $cache[ $key ] = $calendar_output;
260
  wp_cache_set( 'get_calendar', $cache, 'calendar' );
261
 
262
  if ( $echo ) {
263
- /**
264
- * Filters the HTML calendar output.
265
- *
266
- * @since 3.0.0
267
- *
268
- * @param string $calendar_output HTML output of the calendar.
269
- */
270
  echo apply_filters( 'get_calendar', $calendar_output );
271
  return;
272
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  if ( ! class_exists( 'WP_Widget_Calendar' ) ) {
7
  require_once ABSPATH . '/wp-includes/default-widgets.php';
8
  }
9
 
10
  /**
11
+ * This classes rewrite the whole Calendar widget functionality as there is no filter on sql queries and only a filter on final output.
12
+ * Code last checked: WP 5.5.
13
+ *
14
+ * A request to add filters on sql queries exists: http://core.trac.wordpress.org/ticket/15202.
15
+ * Method used in 0.4.x: use of the get_calendar filter and overwrite the output of get_calendar function -> not very efficient (add 4 to 5 sql queries).
16
+ * Method used since 0.5: remove the WP widget and replace it by our own -> our language filter will not work if get_calendar is called directly by a theme.
17
  *
18
  * @since 0.5
19
  */
20
  class PLL_Widget_Calendar extends WP_Widget_Calendar {
21
+ protected static $pll_instance = 0; // Can't use $instance of WP_Widget_Calendar as it's private :/.
22
 
23
  /**
24
  * Outputs the content for the current Calendar widget instance.
25
+ * Modified version of the parent function to call our own get_calendar() method.
26
  *
27
  * @since 0.5
28
  *
29
+ * @param array $args Display arguments including 'before_title', 'after_title',
30
+ * 'before_widget', and 'after_widget'.
31
  * @param array $instance The settings for the particular instance of the widget.
32
  */
33
  public function widget( $args, $instance ) {
53
  }
54
 
55
  /**
56
+ * Modified version of the WP get_calendar() function to filter the queries.
57
  *
58
  * @since 0.5
59
  *
60
  * @param bool $initial Optional, default is true. Use initial calendar names.
61
+ * @param bool $echo Optional, default is true. Set to false for return.
62
+ * @return void|string Void if `$echo` argument is true, calendar HTML if `$echo` is false.
63
  */
64
  static public function get_calendar( $initial = true, $echo = true ) {
65
  global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
66
 
67
+ $join_clause = PLL()->model->post->join_clause(); #added#
68
  $where_clause = PLL()->model->post->where_clause( PLL()->curlang ); #added#
69
 
70
+ $key = md5( PLL()->curlang->slug . $m . $monthnum . $year ); #modified#
71
  $cache = wp_cache_get( 'get_calendar', 'calendar' );
72
 
73
  if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) {
88
 
89
  // Quick check. If we have no posts at all, abort!
90
  if ( ! $posts ) {
91
+ $gotsome = $wpdb->get_var( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
92
  if ( ! $gotsome ) {
93
  $cache[ $key ] = '';
94
  wp_cache_set( 'get_calendar', $cache, 'calendar' );
99
  if ( isset( $_GET['w'] ) ) {
100
  $w = (int) $_GET['w'];
101
  }
102
+ // week_begins = 0 stands for Sunday.
103
  $week_begins = (int) get_option( 'start_of_week' );
 
104
 
105
+ // Let's figure out when we are.
106
  if ( ! empty( $monthnum ) && ! empty( $year ) ) {
107
  $thismonth = zeroise( intval( $monthnum ), 2 );
108
+ $thisyear = (int) $year;
109
  } elseif ( ! empty( $w ) ) {
110
+ // We need to get the month from MySQL.
111
  $thisyear = (int) substr( $m, 0, 4 );
112
+ // It seems MySQL's weeks disagree with PHP's.
113
+ $d = ( ( $w - 1 ) * 7 ) + 6;
114
+ $thismonth = $wpdb->get_var( "SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')" );
115
  } elseif ( ! empty( $m ) ) {
116
  $thisyear = (int) substr( $m, 0, 4 );
117
  if ( strlen( $m ) < 6 ) {
120
  $thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
121
  }
122
  } else {
123
+ $thisyear = current_time( 'Y' );
124
+ $thismonth = current_time( 'm' );
125
  }
126
 
127
+ $unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
128
+ $last_day = gmdate( 't', $unixmonth );
129
 
130
+ // Get the next and previous month and year with at least one post.
131
+ $previous = $wpdb->get_row(
132
+ "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
133
  FROM $wpdb->posts $join_clause
134
  WHERE post_date < '$thisyear-$thismonth-01'
135
  AND post_type = 'post' AND post_status = 'publish' $where_clause
136
  ORDER BY post_date DESC
137
+ LIMIT 1"
138
+ ); #modified#
139
+ $next = $wpdb->get_row(
140
+ "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
141
  FROM $wpdb->posts $join_clause
142
  WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
143
  AND post_type = 'post' AND post_status = 'publish' $where_clause
144
  ORDER BY post_date ASC
145
+ LIMIT 1"
146
+ ); #modified#
147
 
148
+ /* translators: Calendar caption: 1: Month name, 2: 4-digit year. */
149
  $calendar_caption = _x( '%1$s %2$s', 'calendar caption' );
150
+ $calendar_output = '<table id="wp-calendar" class="wp-calendar-table">
151
  <caption>' . sprintf(
152
  $calendar_caption,
153
  $wp_locale->get_month( $thismonth ),
154
+ gmdate( 'Y', $unixmonth )
155
  ) . '</caption>
156
  <thead>
157
  <tr>';
163
  }
164
 
165
  foreach ( $myweek as $wd ) {
166
+ $day_name = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
167
+ $wd = esc_attr( $wd );
168
  $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
169
  }
170
 
171
  $calendar_output .= '
172
  </tr>
173
  </thead>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  <tbody>
175
  <tr>';
176
 
177
  $daywithpost = array();
178
 
179
+ // Get days with posts.
180
+ $dayswithposts = $wpdb->get_results(
181
+ "SELECT DISTINCT DAYOFMONTH(post_date)
182
+ FROM $wpdb->posts $join_clause WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
183
+ AND post_type = 'post' AND post_status = 'publish'
184
+ AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' $where_clause",
185
+ ARRAY_N
186
+ ); #modified#
187
+
188
  if ( $dayswithposts ) {
189
  foreach ( (array) $dayswithposts as $daywith ) {
190
+ $daywithpost[] = (int) $daywith[0];
191
  }
192
  }
193
 
194
+ // See how much we should pad in the beginning.
195
+ $pad = calendar_week_mod( gmdate( 'w', $unixmonth ) - $week_begins );
196
  if ( 0 != $pad ) {
197
+ $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr( $pad ) . '" class="pad">&nbsp;</td>';
198
  }
199
 
200
+ $newrow = false;
201
+ $daysinmonth = (int) gmdate( 't', $unixmonth );
202
 
203
  for ( $day = 1; $day <= $daysinmonth; ++$day ) {
204
+ if ( isset( $newrow ) && $newrow ) {
205
  $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
206
  }
207
  $newrow = false;
208
 
209
+ if ( current_time( 'j' ) == $day &&
210
+ current_time( 'm' ) == $thismonth &&
211
+ current_time( 'Y' ) == $thisyear ) {
212
  $calendar_output .= '<td id="today">';
213
  } else {
214
  $calendar_output .= '<td>';
215
  }
216
 
217
+ if ( in_array( $day, $daywithpost, true ) ) {
218
+ // Any posts today?
219
+ $date_format = gmdate( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
220
+ /* translators: Post calendar label. %s: Date. */
221
+ $label = sprintf( __( 'Posts published on %s' ), $date_format );
222
  $calendar_output .= sprintf(
223
  '<a href="%s" aria-label="%s">%s</a>',
224
  get_day_link( $thisyear, $thismonth, $day ),
228
  } else {
229
  $calendar_output .= $day;
230
  }
231
+
232
  $calendar_output .= '</td>';
233
 
234
+ if ( 6 == calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
235
  $newrow = true;
236
  }
237
  }
238
 
239
+ $pad = 7 - calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins );
240
+ if ( 0 != $pad && 7 != $pad ) {
241
+ $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '">&nbsp;</td>';
242
+ }
243
+
244
+ $calendar_output .= "\n\t</tr>\n\t</tbody>";
245
+
246
+ $calendar_output .= "\n\t</table>";
247
+
248
+ $calendar_output .= '<nav aria-label="' . __( 'Previous and next months' ) . '" class="wp-calendar-nav">';
249
+
250
+ if ( $previous ) {
251
+ $calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">&laquo; ' .
252
+ $wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
253
+ '</a></span>';
254
+ } else {
255
+ $calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-prev">&nbsp;</span>';
256
+ }
257
+
258
+ $calendar_output .= "\n\t\t" . '<span class="pad">&nbsp;</span>';
259
+
260
+ if ( $next ) {
261
+ $calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
262
+ $wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
263
+ ' &raquo;</a></span>';
264
+ } else {
265
+ $calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-next">&nbsp;</span>';
266
  }
267
+
268
+ $calendar_output .= '
269
+ </nav>';
270
 
271
  $cache[ $key ] = $calendar_output;
272
  wp_cache_set( 'get_calendar', $cache, 'calendar' );
273
 
274
  if ( $echo ) {
275
+ /** This filter is documented in wp-includes/general-template.php */
 
 
 
 
 
 
276
  echo apply_filters( 'get_calendar', $calendar_output );
277
  return;
278
  }
include/widget-languages.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * The language switcher widget
@@ -135,7 +138,7 @@ class PLL_Widget_Languages extends WP_Widget {
135
  // Remove all options if dropdown is checked
136
  $( '.widgets-sortables,.control-section-sidebar' ).on( 'change', '.pll-dropdown', function() {
137
  var this_id = $( this ).parent().parent().parent().children( '.widget-id' ).attr( 'value' );
138
- pll_toggle( $( '.no-dropdown-' + this_id ), 'checked' != $( this ).attr( 'checked' ) );
139
  } );
140
 
141
  // Disallow unchecking both show names and show flags
@@ -143,7 +146,7 @@ class PLL_Widget_Languages extends WP_Widget {
143
  $.each( options, function( i, v ) {
144
  $( '.widgets-sortables,.control-section-sidebar' ).on( 'change', '.pll' + v, function() {
145
  var this_id = $( this ).parent().parent().parent().children( '.widget-id' ).attr( 'value' );
146
- if ( 'checked' != $( this ).attr( 'checked' ) ) {
147
  $( '#widget-' + this_id + options[ 1-i ] ).prop( 'checked', true );
148
  }
149
  } );
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * The language switcher widget
138
  // Remove all options if dropdown is checked
139
  $( '.widgets-sortables,.control-section-sidebar' ).on( 'change', '.pll-dropdown', function() {
140
  var this_id = $( this ).parent().parent().parent().children( '.widget-id' ).attr( 'value' );
141
+ pll_toggle( $( '.no-dropdown-' + this_id ), true != $( this ).prop( 'checked' ) );
142
  } );
143
 
144
  // Disallow unchecking both show names and show flags
146
  $.each( options, function( i, v ) {
147
  $( '.widgets-sortables,.control-section-sidebar' ).on( 'change', '.pll' + v, function() {
148
  var this_id = $( this ).parent().parent().parent().children( '.widget-id' ).attr( 'value' );
149
+ if ( true != $( this ).prop( 'checked' ) ) {
150
  $( '#widget-' + this_id + options[ 1-i ] ).prop( 'checked', true );
151
  }
152
  } );
install/install-base.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A generic activation / de-activation class compatble with multisite
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A generic activation / de-activation class compatble with multisite
install/install.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Polylang activation / de-activation class
@@ -34,7 +37,7 @@ class PLL_Install extends PLL_Install_Base {
34
  * @since 2.6.7
35
  */
36
  public function php_version_notice() {
37
- load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' ); // Plugin i18n.
38
 
39
  printf(
40
  '<div class="error"><p>%s</p></div>',
@@ -56,7 +59,7 @@ class PLL_Install extends PLL_Install_Base {
56
  public function wp_version_notice() {
57
  global $wp_version;
58
 
59
- load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' ); // Plugin i18n.
60
 
61
  printf(
62
  '<div class="error"><p>%s</p></div>',
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Polylang activation / de-activation class
37
  * @since 2.6.7
38
  */
39
  public function php_version_notice() {
40
+ load_plugin_textdomain( 'polylang' ); // Plugin i18n.
41
 
42
  printf(
43
  '<div class="error"><p>%s</p></div>',
59
  public function wp_version_notice() {
60
  global $wp_version;
61
 
62
+ load_plugin_textdomain( 'polylang' ); // Plugin i18n.
63
 
64
  printf(
65
  '<div class="error"><p>%s</p></div>',
install/plugin-updater.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  // Exit if accessed directly
4
  if ( ! defined( 'ABSPATH' ) ) {
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  // Exit if accessed directly
7
  if ( ! defined( 'ABSPATH' ) ) {
install/t15s.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Allows to download translations from TranslationsPress
@@ -8,13 +11,41 @@
8
  * @since 2.6
9
  */
10
  class PLL_T15S {
11
-
 
 
 
 
12
  const TRANSIENT_KEY_PLUGIN = 't15s-registry-plugins';
13
 
14
- private $type = 'plugin';
15
- private $slug = '';
 
 
 
 
 
 
 
 
 
 
16
  private $api_url = '';
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * Adds a new project to load translations for.
20
  *
@@ -29,7 +60,7 @@ class PLL_T15S {
29
 
30
  add_action( 'init', array( __CLASS__, 'register_clean_translations_cache' ), 9999 );
31
  add_filter( 'translations_api', array( $this, 'translations_api' ), 10, 3 );
32
- add_filter( 'site_transient_update_' . $this->type . 's', array( $this, 'site_transient_update_plugins' ) );
33
  }
34
 
35
  /**
@@ -43,8 +74,8 @@ class PLL_T15S {
43
  * @return bool|array
44
  */
45
  public function translations_api( $result, $requested_type, $args ) {
46
- if ( $this->type . 's' === $requested_type && $this->slug === $args['slug'] ) {
47
- return self::get_translations( $this->type, $args['slug'], $this->api_url );
48
  }
49
 
50
  return $result;
@@ -68,16 +99,16 @@ class PLL_T15S {
68
  $value->translations = array();
69
  }
70
 
71
- $translations = self::get_translations( $this->type, $this->slug, $this->api_url );
72
 
73
  if ( ! isset( $translations['translations'] ) ) {
74
  return $value;
75
  }
76
 
77
- $installed_translations = wp_get_installed_translations( $this->type . 's' );
78
 
79
  foreach ( (array) $translations['translations'] as $translation ) {
80
- if ( in_array( $translation['language'], get_available_languages() ) ) {
81
  if ( isset( $installed_translations[ $this->slug ][ $translation['language'] ] ) && $translation['updated'] ) {
82
  $local = new DateTime( $installed_translations[ $this->slug ][ $translation['language'] ]['PO-Revision-Date'] );
83
  $remote = new DateTime( $translation['updated'] );
@@ -87,7 +118,7 @@ class PLL_T15S {
87
  }
88
  }
89
 
90
- $translation['type'] = $this->type;
91
  $translation['slug'] = $this->slug;
92
 
93
  $value->translations[] = $translation;
@@ -138,12 +169,11 @@ class PLL_T15S {
138
  *
139
  * @since 2.6
140
  *
141
- * @param string $type Project type. Either plugin or theme.
142
  * @param string $slug Project directory slug.
143
  * @param string $url Full GlotPress API URL for the project.
144
  * @return array Translation data.
145
  */
146
- private static function get_translations( $type, $slug, $url ) {
147
  $translations = get_site_transient( self::TRANSIENT_KEY_PLUGIN );
148
 
149
  if ( ! is_object( $translations ) ) {
@@ -167,4 +197,36 @@ class PLL_T15S {
167
  set_site_transient( self::TRANSIENT_KEY_PLUGIN, $translations );
168
  return $result;
169
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Allows to download translations from TranslationsPress
11
  * @since 2.6
12
  */
13
  class PLL_T15S {
14
+ /**
15
+ * Transient key
16
+ *
17
+ * @var string
18
+ */
19
  const TRANSIENT_KEY_PLUGIN = 't15s-registry-plugins';
20
 
21
+ /**
22
+ * Project directory slug
23
+ *
24
+ * @var string
25
+ */
26
+ private $slug = '';
27
+
28
+ /**
29
+ * Full GlotPress API URL for the project.
30
+ *
31
+ * @var string
32
+ */
33
  private $api_url = '';
34
 
35
+ /**
36
+ * Installed translations.
37
+ *
38
+ * @var array
39
+ */
40
+ private static $installed_translations;
41
+
42
+ /**
43
+ * Available languages.
44
+ *
45
+ * @var array
46
+ */
47
+ private static $available_languages;
48
+
49
  /**
50
  * Adds a new project to load translations for.
51
  *
60
 
61
  add_action( 'init', array( __CLASS__, 'register_clean_translations_cache' ), 9999 );
62
  add_filter( 'translations_api', array( $this, 'translations_api' ), 10, 3 );
63
+ add_filter( 'site_transient_update_plugins', array( $this, 'site_transient_update_plugins' ) );
64
  }
65
 
66
  /**
74
  * @return bool|array
75
  */
76
  public function translations_api( $result, $requested_type, $args ) {
77
+ if ( 'plugins' === $requested_type && $this->slug === $args['slug'] ) {
78
+ return self::get_translations( $args['slug'], $this->api_url );
79
  }
80
 
81
  return $result;
99
  $value->translations = array();
100
  }
101
 
102
+ $translations = self::get_translations( $this->slug, $this->api_url );
103
 
104
  if ( ! isset( $translations['translations'] ) ) {
105
  return $value;
106
  }
107
 
108
+ $installed_translations = self::get_installed_translations();
109
 
110
  foreach ( (array) $translations['translations'] as $translation ) {
111
+ if ( in_array( $translation['language'], self::get_available_languages() ) ) {
112
  if ( isset( $installed_translations[ $this->slug ][ $translation['language'] ] ) && $translation['updated'] ) {
113
  $local = new DateTime( $installed_translations[ $this->slug ][ $translation['language'] ]['PO-Revision-Date'] );
114
  $remote = new DateTime( $translation['updated'] );
118
  }
119
  }
120
 
121
+ $translation['type'] = 'plugin';
122
  $translation['slug'] = $this->slug;
123
 
124
  $value->translations[] = $translation;
169
  *
170
  * @since 2.6
171
  *
 
172
  * @param string $slug Project directory slug.
173
  * @param string $url Full GlotPress API URL for the project.
174
  * @return array Translation data.
175
  */
176
+ private static function get_translations( $slug, $url ) {
177
  $translations = get_site_transient( self::TRANSIENT_KEY_PLUGIN );
178
 
179
  if ( ! is_object( $translations ) ) {
197
  set_site_transient( self::TRANSIENT_KEY_PLUGIN, $translations );
198
  return $result;
199
  }
200
+
201
+ /**
202
+ * Returns installed translations.
203
+ *
204
+ * Used to cache the result of wp_get_installed_translations() as it is very expensive.
205
+ *
206
+ * @since 2.8
207
+ *
208
+ * @return array
209
+ */
210
+ private static function get_installed_translations() {
211
+ if ( null === self::$installed_translations ) {
212
+ self::$installed_translations = wp_get_installed_translations( 'plugins' );
213
+ }
214
+ return self::$installed_translations;
215
+ }
216
+
217
+ /**
218
+ * Returns available languages.
219
+ *
220
+ * Used to cache the result of get_available_languages() as it is very expensive.
221
+ *
222
+ * @since 2.8
223
+ *
224
+ * @return array
225
+ */
226
+ private static function get_available_languages() {
227
+ if ( null === self::$available_languages ) {
228
+ self::$available_languages = get_available_languages();
229
+ }
230
+ return self::$available_languages;
231
+ }
232
  }
install/upgrade.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages Polylang upgrades
@@ -70,7 +73,7 @@ class PLL_Upgrade {
70
  * @since 1.0
71
  */
72
  public function admin_notices() {
73
- load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' );
74
  printf(
75
  '<div class="error"><p>%s</p><p>%s</p></div>',
76
  esc_html__( 'Polylang has been deactivated because you upgraded from a too old version.', 'polylang' ),
@@ -89,7 +92,7 @@ class PLL_Upgrade {
89
  * @since 1.2
90
  */
91
  public function _upgrade() {
92
- foreach ( array( '0.9', '1.0', '1.1', '1.2', '1.2.1', '1.2.3', '1.3', '1.4', '1.4.1', '1.4.4', '1.5', '1.6', '1.7.4', '1.8', '2.0.8', '2.1', '2.3', '2.7' ) as $version ) {
93
  if ( version_compare( $this->options['version'], $version, '<' ) ) {
94
  call_user_func( array( $this, 'upgrade_' . str_replace( '.', '_', $version ) ) );
95
  }
@@ -558,7 +561,7 @@ class PLL_Upgrade {
558
  */
559
  protected function upgrade_1_8() {
560
  // Adds the flag code in languages stored in DB
561
- $languages = include PLL_SETTINGS_INC . '/languages.php';
562
 
563
  $terms = get_terms( 'language', array( 'hide_empty' => 0 ) );
564
 
@@ -606,18 +609,6 @@ class PLL_Upgrade {
606
  }
607
  }
608
 
609
- /**
610
- * Upgrades if the previous version is < 2.3
611
- *
612
- * Deletes language cache due to 'redirect_lang' option removed for subdomains and multiple domains in 2.2
613
- * and W3C and Facebook locales added to PLL_Language objects in 2.3
614
- *
615
- * @since 2.3
616
- */
617
- protected function upgrade_2_3() {
618
- delete_transient( 'pll_languages_list' );
619
- }
620
-
621
  /**
622
  * Upgrades if the previous version is < 2.7
623
  * Replace numeric keys by hashes in WPML registered strings
@@ -642,4 +633,18 @@ class PLL_Upgrade {
642
 
643
  PLL_Admin_Notices::dismiss( 'wizard' );
644
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages Polylang upgrades
73
  * @since 1.0
74
  */
75
  public function admin_notices() {
76
+ load_plugin_textdomain( 'polylang' );
77
  printf(
78
  '<div class="error"><p>%s</p><p>%s</p></div>',
79
  esc_html__( 'Polylang has been deactivated because you upgraded from a too old version.', 'polylang' ),
92
  * @since 1.2
93
  */
94
  public function _upgrade() {
95
+ foreach ( array( '0.9', '1.0', '1.1', '1.2', '1.2.1', '1.2.3', '1.3', '1.4', '1.4.1', '1.4.4', '1.5', '1.6', '1.7.4', '1.8', '2.0.8', '2.1', '2.7', '2.8' ) as $version ) {
96
  if ( version_compare( $this->options['version'], $version, '<' ) ) {
97
  call_user_func( array( $this, 'upgrade_' . str_replace( '.', '_', $version ) ) );
98
  }
561
  */
562
  protected function upgrade_1_8() {
563
  // Adds the flag code in languages stored in DB
564
+ $languages = include POLYLANG_DIR . '/settings/languages.php';
565
 
566
  $terms = get_terms( 'language', array( 'hide_empty' => 0 ) );
567
 
609
  }
610
  }
611
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  /**
613
  * Upgrades if the previous version is < 2.7
614
  * Replace numeric keys by hashes in WPML registered strings
633
 
634
  PLL_Admin_Notices::dismiss( 'wizard' );
635
  }
636
+
637
+ /**
638
+ * Upgrades if the previous version is < 2.8
639
+ *
640
+ * Deletes language cache due to:
641
+ * - 'redirect_lang' option removed for subdomains and multiple domains in 2.2
642
+ * - W3C and Facebook locales added to PLL_Language objects in 2.3
643
+ * - flags moved to a different directory in Polylang Pro 2.8
644
+ *
645
+ * @since 2.8
646
+ */
647
+ protected function upgrade_2_8() {
648
+ delete_transient( 'pll_languages_list' );
649
+ }
650
  }
integrations/aqua-resizer/aqua-resizer.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Manages the compatibility with Aqua Resizer when used in themes.
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_Aqua_Resizer {
12
+ /**
13
+ * Setups filters.
14
+ *
15
+ * @since 2.8
16
+ */
17
+ public function init() {
18
+ add_filter( 'pll_home_url_black_list', array( $this, 'home_url_black_list' ) );
19
+ }
20
+
21
+ /**
22
+ * Avoids filtering the home url for the function aq_resize().
23
+ *
24
+ * @since 1.1.5
25
+ *
26
+ * @param array $arr Home url filter black list.
27
+ * @return array
28
+ */
29
+ public function home_url_black_list( $arr ) {
30
+ return array_merge( $arr, array( array( 'function' => 'aq_resize' ) ) );
31
+ }
32
+ }
integrations/aqua-resizer/load.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with Aqua Resizer.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ PLL_Integrations::instance()->aq_resizer = new PLL_Aqua_Resizer();
13
+ PLL_Integrations::instance()->aq_resizer->init();
{modules/plugins → integrations/cache}/cache-compat.php RENAMED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to manage specific compatibility issue with cache plugins
@@ -36,13 +39,14 @@ class PLL_Cache_Compat {
36
  '(function() {
37
  var expirationDate = new Date();
38
  expirationDate.setTime( expirationDate.getTime() + %d * 1000 );
39
- document.cookie = "%s=%s; expires=" + expirationDate.toUTCString() + "; path=%s%s";
40
  }());',
41
  esc_js( apply_filters( 'pll_cookie_expiration', YEAR_IN_SECONDS ) ),
42
  esc_js( PLL_COOKIE ),
43
  esc_js( pll_current_language() ),
44
  esc_js( COOKIEPATH ),
45
- $domain ? '; domain=' . esc_js( $domain ) : ''
 
46
  );
47
  echo '<script type="text/javascript">' . $js . '</script>'; // phpcs:ignore WordPress.Security.EscapeOutput
48
  }
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to manage specific compatibility issue with cache plugins
39
  '(function() {
40
  var expirationDate = new Date();
41
  expirationDate.setTime( expirationDate.getTime() + %d * 1000 );
42
+ document.cookie = "%s=%s; expires=" + expirationDate.toUTCString() + "; path=%s%s%s";
43
  }());',
44
  esc_js( apply_filters( 'pll_cookie_expiration', YEAR_IN_SECONDS ) ),
45
  esc_js( PLL_COOKIE ),
46
  esc_js( pll_current_language() ),
47
  esc_js( COOKIEPATH ),
48
+ $domain ? '; domain=' . esc_js( $domain ) : '',
49
+ is_ssl() ? '; secure' : ''
50
  );
51
  echo '<script type="text/javascript">' . $js . '</script>'; // phpcs:ignore WordPress.Security.EscapeOutput
52
  }
integrations/cache/load.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with cache plugins.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ add_action(
13
+ 'plugins_loaded',
14
+ function() {
15
+ if ( pll_is_cache_active() ) {
16
+ add_action( 'pll_init', array( PLL_Integrations::instance()->cache_compat = new PLL_Cache_Compat(), 'init' ) );
17
+ }
18
+ },
19
+ 0
20
+ );
21
+
integrations/custom-field-template/cft.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Manages the compatibility with Custom Field Template.
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_Cft {
12
+ /**
13
+ * Setups actions.
14
+ *
15
+ * @since 2.8
16
+ */
17
+ public function init() {
18
+ add_action( 'add_meta_boxes', array( $this, 'cft_copy' ), 10, 2 );
19
+ }
20
+
21
+ /**
22
+ * Custom field template does check $_REQUEST['post'] to populate the custom fields values.
23
+ *
24
+ * @since 1.0.2
25
+ *
26
+ * @param string $post_type Unused.
27
+ * @param object $post Current post object.
28
+ */
29
+ public function cft_copy( $post_type, $post ) {
30
+ global $custom_field_template;
31
+ if ( isset( $custom_field_template, $_REQUEST['from_post'], $_REQUEST['new_lang'] ) && ! empty( $post ) ) { // phpcs:ignore WordPress.Security.NonceVerification
32
+ $_REQUEST['post'] = $post->ID;
33
+ }
34
+ }
35
+ }
integrations/custom-field-template/load.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with Custom Field Template.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ add_action(
13
+ 'plugins_loaded',
14
+ function() {
15
+ if ( class_exists( 'custom_field_template' ) ) {
16
+ PLL_Integrations::instance()->cft = new PLL_Cft();
17
+ PLL_Integrations::instance()->cft->init();
18
+ }
19
+ },
20
+ 0
21
+ );
integrations/domain-mapping/domain-mapping.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Manages the compatibility with WordPress MU Domain Mapping.
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_Domain_Mapping {
12
+
13
+ /**
14
+ * Setups actions.
15
+ *
16
+ * @since 2.8
17
+ */
18
+ public function __construct() {
19
+ if ( function_exists( 'redirect_to_mapped_domain' ) ) {
20
+ if ( ! defined( 'PLL_CACHE_HOME_URL' ) && ( $options = get_option( 'polylang' ) ) && $options['force_lang'] < 2 ) {
21
+ define( 'PLL_CACHE_HOME_URL', false );
22
+ }
23
+
24
+ if ( ! get_site_option( 'dm_no_primary_domain' ) ) {
25
+ remove_action( 'template_redirect', 'redirect_to_mapped_domain' );
26
+ add_action( 'template_redirect', array( $this, 'dm_redirect_to_mapped_domain' ) );
27
+ }
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Fix primary domain check which forces only one domain per blog.
33
+ * Accept only known domains/subdomains for the current blog.
34
+ *
35
+ * @since 2.2
36
+ */
37
+ public function dm_redirect_to_mapped_domain() {
38
+ $options = get_option( 'polylang' );
39
+
40
+ // The language is set from the subdomain or domain name
41
+ if ( $options['force_lang'] > 1 ) {
42
+ // Don't redirect the main site
43
+ if ( is_main_site() ) {
44
+ return;
45
+ }
46
+
47
+ // Don't redirect post previews
48
+ if ( isset( $_GET['preview'] ) && 'true' === $_GET['preview'] ) { // phpcs:ignore WordPress.Security.NonceVerification
49
+ return;
50
+ }
51
+
52
+ // Don't redirect theme customizer
53
+ if ( isset( $_POST['customize'] ) && isset( $_POST['theme'] ) && 'on' === $_POST['customize'] ) { // phpcs:ignore WordPress.Security.NonceVerification
54
+ return;
55
+ }
56
+
57
+ // If we can't associate the requested domain to a language, redirect to the default domain
58
+ $requested_url = pll_get_requested_url();
59
+ $requested_host = wp_parse_url( $requested_url, PHP_URL_HOST );
60
+
61
+ $hosts = PLL()->links_model->get_hosts();
62
+ $lang = array_search( $requested_host, $hosts );
63
+
64
+ if ( empty( $lang ) ) {
65
+ $status = get_site_option( 'dm_301_redirect' ) ? '301' : '302'; // Honor status redirect option
66
+ $redirect = str_replace( '://' . $requested_host, '://' . $hosts[ $options['default_lang'] ], $requested_url );
67
+ wp_safe_redirect( $redirect, $status );
68
+ exit;
69
+ }
70
+ } else {
71
+ // Otherwise rely on MU Domain Mapping
72
+ redirect_to_mapped_domain();
73
+ }
74
+ }
75
+ }
integrations/domain-mapping/load.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with WordPress MU Domain Mapping.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ PLL_Integrations::instance()->dm = new PLL_Domain_Mapping();
integrations/duplicate-post/duplicate-post.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Manages the compatibility with Duplicate Post.
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_Duplicate_Post {
12
+ /**
13
+ * Setups actions.
14
+ *
15
+ * @since 2.8
16
+ */
17
+ public function init() {
18
+ add_filter( 'option_duplicate_post_taxonomies_blacklist', array( $this, 'taxonomies_blacklist' ) );
19
+ }
20
+
21
+ /**
22
+ * Duplicate Post
23
+ * Avoid duplicating the 'post_translations' taxonomy
24
+ *
25
+ * @since 1.8
26
+ *
27
+ * @param array|string $taxonomies
28
+ * @return array
29
+ */
30
+ public function duplicate_post_taxonomies_blacklist( $taxonomies ) {
31
+ if ( empty( $taxonomies ) ) {
32
+ $taxonomies = array(); // As we get an empty string when there is no taxonomy
33
+ }
34
+
35
+ $taxonomies[] = 'post_translations';
36
+ return $taxonomies;
37
+ }
38
+ }
integrations/duplicate-post/load.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with Duplicate Post.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ add_action(
13
+ 'plugins_loaded',
14
+ function() {
15
+ if ( defined( 'DUPLICATE_POST_CURRENT_VERSION' ) ) {
16
+ PLL_Integrations::instance()->duplicate_post = new PLL_Duplicate_Post();
17
+ PLL_Integrations::instance()->duplicate_post->init();
18
+ }
19
+ },
20
+ 0
21
+ );
integrations/integrations.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Container for 3rd party plugins ( and themes ) integrations.
8
+ * This class is available as soon as the plugin is loaded.
9
+ *
10
+ * @since 1.0
11
+ * @since 2.8 Renamed from PLL_Plugins_Compat to PLL_Integrations.
12
+ */
13
+ class PLL_Integrations {
14
+ /**
15
+ * Singleton instance.
16
+ *
17
+ * @var PLL_Integrations
18
+ */
19
+ protected static $instance;
20
+
21
+ /**
22
+ * Constructor.
23
+ *
24
+ * @since 1.0
25
+ */
26
+ protected function __construct() {
27
+ // Loads external integrations.
28
+ foreach ( glob( __DIR__ . '/*/load.php', GLOB_NOSORT ) as $load_script ) { // phpcs:ignore WordPressVIPMinimum.Variables.VariableAnalysis.UnusedVariable
29
+ require_once $load_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Access to the single instance of the class.
35
+ *
36
+ * @since 1.7
37
+ *
38
+ * @return object
39
+ */
40
+ public static function instance() {
41
+ if ( empty( self::$instance ) ) {
42
+ self::$instance = new self();
43
+ }
44
+
45
+ return self::$instance;
46
+ }
47
+ }
48
+
49
+ class_alias( 'PLL_Integrations', 'PLL_Plugins_Compat' ); // For Backward compatibility.
{modules/plugins → integrations/jetpack}/featured-content.php RENAMED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages the compatibility with the Jetpack Twenty Fourteenn Featured content
@@ -13,7 +16,6 @@ class PLL_Featured_Content {
13
  */
14
  public function init() {
15
  add_filter( 'transient_featured_content_ids', array( $this, 'featured_content_ids' ) );
16
- add_filter( 'pll_filter_query_excluded_query_vars', array( $this, 'fix_featured_posts' ) );
17
  add_filter( 'option_featured-content', array( $this, 'option_featured_content' ) );
18
  }
19
 
@@ -99,21 +101,6 @@ class PLL_Featured_Content {
99
  return $ids;
100
  }
101
 
102
- /**
103
- * Allow to filter the featured posts query per language
104
- *
105
- * @since 2.4
106
- *
107
- * @param array $excludes Query vars excluded from the language filter
108
- * @return array
109
- */
110
- public function fix_featured_posts( $excludes ) {
111
- if ( $this->is_active() && PLL() instanceof PLL_Frontend && doing_filter( $this->get_featured_posts_filter() ) ) {
112
- $excludes = array_diff( $excludes, array( 'post__in' ) );
113
- }
114
- return $excludes;
115
- }
116
-
117
  /**
118
  * Translates the featured tag id in featured content settings
119
  * Mainly to allow hiding it when requested in featured content options
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages the compatibility with the Jetpack Twenty Fourteenn Featured content
16
  */
17
  public function init() {
18
  add_filter( 'transient_featured_content_ids', array( $this, 'featured_content_ids' ) );
 
19
  add_filter( 'option_featured-content', array( $this, 'option_featured_content' ) );
20
  }
21
 
101
  return $ids;
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  /**
105
  * Translates the featured tag id in featured content settings
106
  * Mainly to allow hiding it when requested in featured content options
{modules/plugins → integrations/jetpack}/jetpack.php RENAMED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages the compatibility with Jetpack
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages the compatibility with Jetpack
integrations/jetpack/load.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with Jetpack.
4
+ * Works for Twenty Fourteen featured content too.
5
+ *
6
+ * @package Polylang
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit; // Don't access directly.
11
+ };
12
+
13
+ PLL_Integrations::instance()->jetpack = new PLL_Jetpack(); // Must be loaded before the plugin is active.
14
+ add_action( 'pll_init', array( PLL_Integrations::instance()->featured_content = new PLL_Featured_Content(), 'init' ) );
integrations/no-category-base/load.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with No Category Base.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ PLL_Integrations::instance()->no_category_base = new PLL_No_Category_Base();
13
+ PLL_Integrations::instance()->no_category_base->init();
integrations/no-category-base/no-category-base.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Manages the compatibility with No Category Base.
8
+ * Works for Yoast SEO too.
9
+ *
10
+ * @since 2.8
11
+ */
12
+ class PLL_No_Category_Base {
13
+ /**
14
+ * Setups actions.
15
+ *
16
+ * @since 2.8
17
+ */
18
+ public function init() {
19
+ add_filter( 'get_terms_args', array( $this, 'no_category_base_get_terms_args' ), 5 ); // Before adding our cache domain.
20
+ }
21
+
22
+ /**
23
+ * Make sure No category base plugins get all the categories when flushing rules.
24
+ *
25
+ * @since 2.1
26
+ *
27
+ * @param array $args WP_Term_Query arguments.
28
+ * @return array
29
+ */
30
+ public function no_category_base_get_terms_args( $args ) {
31
+ if ( doing_filter( 'category_rewrite_rules' ) ) {
32
+ $args['lang'] = '';
33
+ }
34
+ return $args;
35
+ }
36
+ }
integrations/twenty-seventeen/load.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with WordPress MU Domain Mapping.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ add_action( 'init', array( PLL_Integrations::instance()->twenty_seventeen = new PLL_Twenty_Seventeen(), 'init' ) );
integrations/twenty-seventeen/twenty-seven-teen.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Manages the compatibility with Twenty_Seventeen.
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_Twenty_Seventeen {
12
+ /**
13
+ * Translates the front page panels and the header video.
14
+ *
15
+ * @since 2.0.10
16
+ */
17
+ public function init() {
18
+ if ( 'twentyseventeen' === get_template() && did_action( 'pll_init' ) ) {
19
+ if ( function_exists( 'twentyseventeen_panel_count' ) && PLL() instanceof PLL_Frontend ) {
20
+ $num_sections = twentyseventeen_panel_count();
21
+ for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
22
+ add_filter( 'theme_mod_panel_' . $i, 'pll_get_post' );
23
+ }
24
+ }
25
+
26
+ if ( PLL() instanceof PLL_Frontend ) {
27
+ add_filter( 'theme_mod_external_header_video', 'pll__' );
28
+ } else {
29
+ pll_register_string( __( 'Header video', 'polylang' ), get_theme_mod( 'external_header_video' ), 'Twenty Seventeen', false );
30
+ }
31
+ }
32
+ }
33
+ }
integrations/wp-importer/load.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with WordPress Importer.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ PLL_Integrations::instance()->wp_importer = new PLL_WordPress_Importer();
integrations/wp-importer/wordpress-importer.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Manages the compatibility with WordPress Importer.
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_WordPress_Importer {
12
+
13
+ /**
14
+ * Setups filters.
15
+ *
16
+ * @since 2.8
17
+ */
18
+ public function __construct() {
19
+ add_action( 'init', array( $this, 'maybe_wordpress_importer' ) );
20
+ add_filter( 'wp_import_terms', array( $this, 'wp_import_terms' ) );
21
+ }
22
+
23
+ /**
24
+ * If WordPress Importer is active, replace the wordpress_importer_init function.
25
+ *
26
+ * @since 1.2
27
+ */
28
+ public function maybe_wordpress_importer() {
29
+ if ( defined( 'WP_LOAD_IMPORTERS' ) && class_exists( 'WP_Import' ) ) {
30
+ remove_action( 'admin_init', 'wordpress_importer_init' );
31
+ add_action( 'admin_init', array( $this, 'wordpress_importer_init' ) );
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Loads our child class PLL_WP_Import instead of WP_Import.
37
+ *
38
+ * @since 1.2
39
+ */
40
+ public function wordpress_importer_init() {
41
+ $class = new ReflectionClass( 'WP_Import' );
42
+ load_plugin_textdomain( 'wordpress-importer', false, basename( dirname( $class->getFileName() ) ) . '/languages' );
43
+
44
+ $GLOBALS['wp_import'] = new PLL_WP_Import();
45
+ register_importer( 'wordpress', 'WordPress', __( 'Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'polylang' ), array( $GLOBALS['wp_import'], 'dispatch' ) ); // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
46
+ }
47
+
48
+ /**
49
+ * Sets the flag when importing a language and the file has been exported with Polylang < 1.8.
50
+ *
51
+ * @since 1.8
52
+ *
53
+ * @param array $terms An array of arrays containing terms information form the WXR file.
54
+ * @return array
55
+ */
56
+ public function wp_import_terms( $terms ) {
57
+ $languages = include POLYLANG_DIR . '/settings/languages.php';
58
+
59
+ foreach ( $terms as $key => $term ) {
60
+ if ( 'language' === $term['term_taxonomy'] ) {
61
+ $description = maybe_unserialize( $term['term_description'] );
62
+ if ( empty( $description['flag_code'] ) && isset( $languages[ $description['locale'] ] ) ) {
63
+ $description['flag_code'] = $languages[ $description['locale'] ]['flag'];
64
+ $terms[ $key ]['term_description'] = maybe_serialize( $description );
65
+ }
66
+ }
67
+ }
68
+ return $terms;
69
+ }
70
+ }
{modules/plugins → integrations/wp-importer}/wp-import.php RENAMED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to import languages and translations information form a WXR file
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to import languages and translations information form a WXR file
{modules/plugins → integrations/wp-offload-media}/as3cf.php RENAMED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to manage the integration with WP Offload Media Lite.
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to manage the integration with WP Offload Media Lite.
integrations/wp-offload-media/load.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with WP Offload Media Lite.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ add_action(
13
+ 'plugins_loaded',
14
+ function() {
15
+ if ( function_exists( 'as3cf_init' ) && class_exists( 'PLL_AS3CF' ) ) {
16
+ add_action( 'pll_init', array( PLL_Integrations::instance()->as3cf = new PLL_AS3CF(), 'init' ) );
17
+ }
18
+ },
19
+ 0
20
+ );
21
+
integrations/wp-sweep/load.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with WP Sweep.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ add_action(
13
+ 'plugins_loaded',
14
+ function() {
15
+ if ( defined( 'WP_SWEEP_VERSION' ) ) {
16
+ PLL_Integrations::instance()->wp_sweep = new PLL_WP_Sweep();
17
+ PLL_Integrations::instance()->wp_sweep->init();
18
+ }
19
+ },
20
+ 0
21
+ );
integrations/wp-sweep/wp-sweep.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Manages the compatibility with WP Sweep.
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_WP_Sweep {
12
+ /**
13
+ * Setups actions.
14
+ *
15
+ * @since 2.8
16
+ */
17
+ public function init() {
18
+ add_filter( 'wp_sweep_excluded_taxonomies', array( $this, 'wp_sweep_excluded_taxonomies' ) );
19
+ }
20
+
21
+ /**
22
+ * Add 'term_language' and 'term_translations' to excluded taxonomies otherwise terms loose their language and translation group.
23
+ *
24
+ * @since 2.0
25
+ *
26
+ * @param array $excluded_taxonomies List of taxonomies excluded from sweeping.
27
+ * @return array
28
+ */
29
+ public function wp_sweep_excluded_taxonomies( $excluded_taxonomies ) {
30
+ return array_merge( $excluded_taxonomies, array( 'term_language', 'term_translations' ) );
31
+ }
32
+ }
integrations/wpseo/load.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with Yoast SEO.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ add_action(
13
+ 'plugins_loaded',
14
+ function() {
15
+ if ( defined( 'WPSEO_VERSION' ) ) {
16
+ add_action( 'pll_init', array( PLL_Integrations::instance()->wpseo = new PLL_WPSEO(), 'init' ) );
17
+ }
18
+ },
19
+ 0
20
+ );
21
+
{modules/plugins → integrations/wpseo}/wpseo-ogp.php RENAMED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  use Yoast\WP\SEO\Presenters\Abstract_Indexable_Presenter;
4
 
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  use Yoast\WP\SEO\Presenters\Abstract_Indexable_Presenter;
7
 
{modules/plugins → integrations/wpseo}/wpseo.php RENAMED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages the compatibility with Yoast SEO
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages the compatibility with Yoast SEO
integrations/yarpp/load.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the integration with Yet Another Related Posts Plugin.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ add_action(
13
+ 'plugins_loaded',
14
+ function() {
15
+ if ( defined( 'YARPP_VERSION' ) ) {
16
+ add_action( 'init', array( PLL_Integrations::instance()->yarpp = new PLL_Yarpp(), 'init' ) );
17
+ }
18
+ },
19
+ 0
20
+ );
integrations/yarpp/yarpp.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Manages the compatibility with Yet Another Related Posts Plugin.
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_Yarpp {
12
+ /**
13
+ * Just makes YARPP aware of the language taxonomy ( after Polylang registered it ).
14
+ *
15
+ * @since 1.0
16
+ */
17
+ public function init() {
18
+ $GLOBALS['wp_taxonomies']['language']->yarpp_support = 1;
19
+ }
20
+ }
js/admin.js CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  jQuery( document ).ready(
2
  function( $ ) {
3
  var transitionTimeout;
1
+ /**
2
+ * @package Polylang
3
+ */
4
+
5
  jQuery( document ).ready(
6
  function( $ ) {
7
  var transitionTimeout;
js/block-editor.js CHANGED
@@ -1,9 +1,12 @@
 
 
 
 
1
  /**
2
  * Filter REST API requests to add the language in the request
3
  *
4
  * @since 2.5
5
  */
6
-
7
  wp.apiFetch.use(
8
  function( options, next ) {
9
  // If options.url is defined, this is not a REST request but a direct call to post.php for legacy metaboxes.
@@ -92,25 +95,25 @@ jQuery( document ).ready(
92
  // If the post is well saved, we can reload the page
93
  unsubscribe();
94
  window.location.reload();
95
- },
96
  function() {
97
  // If the post save failed
98
  unsubscribe();
99
- }
100
  ).catch(
101
  function() {
102
  // If an exception is thrown
103
  unsubscribe();
104
  }
105
  );
106
- }
107
  );
108
- }
109
  );
110
 
111
  /**
112
  * Handles internals of the metabox:
113
- * Language select, autocomplete input field and buttons.
114
  *
115
  * @since 1.5
116
  */
@@ -128,7 +131,7 @@ jQuery( document ).ready(
128
  }
129
 
130
  $.post(
131
- ajaxurl,
132
  data,
133
  function( response ) {
134
  var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
@@ -193,41 +196,5 @@ jQuery( document ).ready(
193
  }
194
 
195
  init_translations();
196
-
197
- // Handle the response to a click on a Languages metabox button
198
- $( '#ml_box' ).on(
199
- 'click',
200
- '.pll-button',
201
- function(){
202
- var value = $( this ).hasClass( 'wp-ui-text-highlight' );
203
- var id = $( this ).attr( 'id' );
204
- var post_id = $( '#htr_lang_' + id.replace( 'pll_sync_post[', '' ).replace( ']', '' ) ).val();
205
-
206
- if ( 'undefined' == typeof( post_id ) || 0 == post_id || value || confirm( confirm_text ) ) {
207
- var data = {
208
- action: 'toggle_' + id,
209
- value: value,
210
- post_type: $( '#post_type' ).val(),
211
- _pll_nonce: $( '#_pll_nonce' ).val()
212
- }
213
-
214
- $.post(
215
- ajaxurl,
216
- data,
217
- function( response ){
218
- var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
219
- $.each(
220
- res.responses,
221
- function() {
222
- id = id.replace( '[', '\\[' ).replace( ']', '\\]' );
223
- $( '#' + id ).toggleClass( 'wp-ui-text-highlight' ).attr( 'title', this.data ).children( 'span' ).text( this.data );
224
- $( 'input[name="' + id + '"]' ).val( ! data['value'] );
225
- }
226
- );
227
- }
228
- );
229
- }
230
- }
231
- );
232
  }
233
  );
1
+ /**
2
+ * @package Polylang
3
+ */
4
+
5
  /**
6
  * Filter REST API requests to add the language in the request
7
  *
8
  * @since 2.5
9
  */
 
10
  wp.apiFetch.use(
11
  function( options, next ) {
12
  // If options.url is defined, this is not a REST request but a direct call to post.php for legacy metaboxes.
95
  // If the post is well saved, we can reload the page
96
  unsubscribe();
97
  window.location.reload();
98
+ },
99
  function() {
100
  // If the post save failed
101
  unsubscribe();
102
+ }
103
  ).catch(
104
  function() {
105
  // If an exception is thrown
106
  unsubscribe();
107
  }
108
  );
109
+ }
110
  );
111
+ }
112
  );
113
 
114
  /**
115
  * Handles internals of the metabox:
116
+ * Language select, autocomplete input field.
117
  *
118
  * @since 1.5
119
  */
131
  }
132
 
133
  $.post(
134
+ ajaxurl,
135
  data,
136
  function( response ) {
137
  var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
196
  }
197
 
198
  init_translations();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
200
  );
js/block-editor.min.js CHANGED
@@ -1 +1 @@
1
- function getCurrentLanguage(){return document.querySelector("[name=post_lang_choice]").value}wp.apiFetch.use(function(t,e){return void 0===t.url&&(void 0===t.data?t.path+=(t.path.indexOf("?")>=0?"&lang=":"?lang=")+getCurrentLanguage():t.data.lang=getCurrentLanguage()),e(t)}),jQuery(document).ready(function(t){t(".post_lang_choice").change(function(){const t=wp.data.select,e=wp.data.dispatch,n=wp.data.subscribe;let a=null;const o=new Promise(function(e,o){a=n(function(){const n=t("core/editor").didPostSaveRequestSucceed(),a=t("core/editor").didPostSaveRequestFail();(n||a)&&(a?o():e())})});if(location.pathname.match(/post-new.php/gi)){const e=t("core/editor").getEditedPostAttribute("title"),n=t("core/editor").getEditedPostAttribute("content"),a=t("core/editor").getEditedPostAttribute("excerpt");""===e&&""===n&&""===a&&(-1!=location.search.indexOf("new_lang")?window.location.search=window.location.search.replace(/(?:new_lang=[^&]*)(&)?(.*)/,"new_lang="+this.value+"$1$2"):window.location.search=window.location.search+(-1!=window.location.search.indexOf("?")?"&":"?")+"new_lang="+this.value)}e("core/editor").savePost(),o.then(function(){a(),window.location.reload()},function(){a()}).catch(function(){a()})})}),jQuery(document).ready(function(t){function e(){t(".tr_lang").each(function(){var e=t(this).attr("id").substring(8),n=t(this).parent().parent().siblings(".pll-edit-column");t(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_posts_not_translated&post_language="+t(".post_lang_choice").val()+"&translation_language="+e+"&post_type="+t("#post_type").val()+"&_pll_nonce="+t("#_pll_nonce").val(),select:function(a,o){t("#htr_lang_"+e).val(o.item.id),n.html(o.item.link)}}),t(this).blur(function(){t(this).val()||(t("#htr_lang_"+e).val(0),n.html(n.siblings(".hidden").children().clone()))})})}t(".post_lang_choice").change(function(){var n={action:"post_lang_choice",lang:t(this).val(),post_type:t("#post_type").val(),post_id:t("#post_ID").val(),_pll_nonce:t("#_pll_nonce").val()};t.post(ajaxurl,n,function(n){var a=wpAjax.parseAjaxResponse(n,"ajax-response");t.each(a.responses,function(){switch(this.what){case"translations":t(".translations").html(this.data),e();break;case"flag":t(".pll-select-flag").html(this.data)}})})}),e(),t("#ml_box").on("click",".pll-button",function(){var e=t(this).hasClass("wp-ui-text-highlight"),n=t(this).attr("id"),a=t("#htr_lang_"+n.replace("pll_sync_post[","").replace("]","")).val();if(void 0===a||0==a||e||confirm(confirm_text)){var o={action:"toggle_"+n,value:e,post_type:t("#post_type").val(),_pll_nonce:t("#_pll_nonce").val()};t.post(ajaxurl,o,function(e){var a=wpAjax.parseAjaxResponse(e,"ajax-response");t.each(a.responses,function(){n=n.replace("[","\\[").replace("]","\\]"),t("#"+n).toggleClass("wp-ui-text-highlight").attr("title",this.data).children("span").text(this.data),t('input[name="'+n+'"]').val(!o.value)})})}})});
1
+ function getCurrentLanguage(){return document.querySelector("[name=post_lang_choice]").value}wp.apiFetch.use(function(t,e){return void 0===t.url&&(void 0===t.data?t.path+=(t.path.indexOf("?")>=0?"&lang=":"?lang=")+getCurrentLanguage():t.data.lang=getCurrentLanguage()),e(t)}),jQuery(document).ready(function(t){t(".post_lang_choice").change(function(){const t=wp.data.select,e=wp.data.dispatch,n=wp.data.subscribe;let a=null;const o=new Promise(function(e,o){a=n(function(){const n=t("core/editor").didPostSaveRequestSucceed(),a=t("core/editor").didPostSaveRequestFail();(n||a)&&(a?o():e())})});if(location.pathname.match(/post-new.php/gi)){const e=t("core/editor").getEditedPostAttribute("title"),n=t("core/editor").getEditedPostAttribute("content"),a=t("core/editor").getEditedPostAttribute("excerpt");""===e&&""===n&&""===a&&(-1!=location.search.indexOf("new_lang")?window.location.search=window.location.search.replace(/(?:new_lang=[^&]*)(&)?(.*)/,"new_lang="+this.value+"$1$2"):window.location.search=window.location.search+(-1!=window.location.search.indexOf("?")?"&":"?")+"new_lang="+this.value)}e("core/editor").savePost(),o.then(function(){a(),window.location.reload()},function(){a()}).catch(function(){a()})})}),jQuery(document).ready(function(t){function e(){t(".tr_lang").each(function(){var e=t(this).attr("id").substring(8),n=t(this).parent().parent().siblings(".pll-edit-column");t(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_posts_not_translated&post_language="+t(".post_lang_choice").val()+"&translation_language="+e+"&post_type="+t("#post_type").val()+"&_pll_nonce="+t("#_pll_nonce").val(),select:function(a,o){t("#htr_lang_"+e).val(o.item.id),n.html(o.item.link)}}),t(this).blur(function(){t(this).val()||(t("#htr_lang_"+e).val(0),n.html(n.siblings(".hidden").children().clone()))})})}t(".post_lang_choice").change(function(){var n={action:"post_lang_choice",lang:t(this).val(),post_type:t("#post_type").val(),post_id:t("#post_ID").val(),_pll_nonce:t("#_pll_nonce").val()};t.post(ajaxurl,n,function(n){var a=wpAjax.parseAjaxResponse(n,"ajax-response");t.each(a.responses,function(){switch(this.what){case"translations":t(".translations").html(this.data),e();break;case"flag":t(".pll-select-flag").html(this.data)}})})}),e()});
js/classic-editor.js CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  // tag suggest in metabox
2
  (function( $ ){
3
  $.ajaxPrefilter(
@@ -98,7 +102,7 @@ jQuery( document ).ready(
98
  data,
99
  function( response ) {
100
  var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
101
- $.each(
102
  res.responses,
103
  function() {
104
  switch ( this.what ) {
@@ -192,41 +196,5 @@ jQuery( document ).ready(
192
  }
193
 
194
  init_translations();
195
-
196
- // Handle the response to a click on a Languages metabox button
197
- $( '#ml_box' ).on(
198
- 'click',
199
- '.pll-button',
200
- function(){
201
- var value = $( this ).hasClass( 'wp-ui-text-highlight' );
202
- var id = $( this ).attr( 'id' );
203
- var post_id = $( '#htr_lang_' + id.replace( 'pll_sync_post[', '' ).replace( ']', '' ) ).val();
204
-
205
- if ( 'undefined' == typeof( post_id ) || 0 == post_id || value || confirm( confirm_text ) ) {
206
- var data = {
207
- action: 'toggle_' + id,
208
- value: value,
209
- post_type: $( '#post_type' ).val(),
210
- _pll_nonce: $( '#_pll_nonce' ).val()
211
- }
212
-
213
- $.post(
214
- ajaxurl,
215
- data,
216
- function( response ){
217
- var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
218
- $.each(
219
- res.responses,
220
- function() {
221
- id = id.replace( '[', '\\[' ).replace( ']', '\\]' );
222
- $( '#' + id ).toggleClass( 'wp-ui-text-highlight' ).attr( 'title', this.data ).children( 'span' ).text( this.data );
223
- $( 'input[name="' + id + '"]' ).val( ! data['value'] );
224
- }
225
- );
226
- }
227
- );
228
- }
229
- }
230
- );
231
  }
232
  );
1
+ /**
2
+ * @package Polylang
3
+ */
4
+
5
  // tag suggest in metabox
6
  (function( $ ){
7
  $.ajaxPrefilter(
102
  data,
103
  function( response ) {
104
  var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
105
+ $.each(
106
  res.responses,
107
  function() {
108
  switch ( this.what ) {
196
  }
197
 
198
  init_translations();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
200
  );
js/classic-editor.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){t.ajaxPrefilter(function(a,l,n){"string"==typeof a.data&&-1!==a.url.indexOf("action=ajax-tag-search")&&(lang=t(".post_lang_choice").val())&&(a.data="lang="+lang+"&"+a.data)})}(jQuery),function(t){tagBox.get=function(a){var l=a.substr(a.indexOf("-")+1),n={action:"get-tagcloud",lang:t(".post_lang_choice").val(),tax:l};t.post(ajaxurl,n,function(n,e){0!=n&&"success"==e||(n=wpAjax.broken),n=t("<div />").addClass("the-tagcloud").attr("id","tagcloud-"+l).html(n),t("a",n).click(function(){return tagBox.flushTags(t(this).closest(".inside").children(".tagsdiv"),this),!1}),(v=t(".the-tagcloud").css("display"))?(t(".the-tagcloud").replaceWith(n),t(".the-tagcloud").css("display",v)):t("#"+a).after(n)})}}(jQuery),jQuery(document).ready(function(t){var a=new Array;function l(){t(".tr_lang").each(function(){var a=t(this).attr("id").substring(8),l=t(this).parent().parent().siblings(".pll-edit-column");t(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_posts_not_translated&post_language="+t(".post_lang_choice").val()+"&translation_language="+a+"&post_type="+t("#post_type").val()+"&_pll_nonce="+t("#_pll_nonce").val(),select:function(n,e){t("#htr_lang_"+a).val(e.item.id),l.html(e.item.link)}}),t(this).blur(function(){t(this).val()||(t("#htr_lang_"+a).val(0),l.html(l.siblings(".hidden").children().clone()))})})}t(".categorydiv").each(function(){var l,n;(l=t(this).attr("id").split("-")).shift(),n=l.join("-"),a.push(n),t("#"+n+"-add-submit").before(t("<input />").attr("type","hidden").attr("id",n+"-lang").attr("name","term_lang_choice").attr("value",t(".post_lang_choice").val()))}),t(".post_lang_choice").change(function(){var n=t(this).val(),e=t(this).children('option[value="'+n+'"]').attr("lang"),i=t('.pll-translation-column > span[lang="'+e+'"]').attr("dir"),s={action:"post_lang_choice",lang:n,post_type:t("#post_type").val(),taxonomies:a,post_id:t("#post_ID").val(),_pll_nonce:t("#_pll_nonce").val()};t.post(ajaxurl,s,function(a){var n=wpAjax.parseAjaxResponse(a,"ajax-response");t.each(n.responses,function(){switch(this.what){case"translations":t(".translations").html(this.data),l();break;case"taxonomy":var a=this.data;t("#"+a+"checklist").html(this.supplemental.all),t("#"+a+"checklist-pop").html(this.supplemental.populars),t("#new"+a+"_parent").replaceWith(this.supplemental.dropdown),t("#"+a+"-lang").val(t(".post_lang_choice").val());break;case"pages":t("#parent_id").html(this.data);break;case"flag":t(".pll-select-flag").html(this.data);break;case"permalink":var n=t("#edit-slug-box");"-1"!=this.data&&n.children().length&&n.html(this.data)}}),t(".tagcloud-link").each(function(){var a=t(this).attr("id");tagBox.get(a)}),t("body").removeClass("pll-dir-rtl").removeClass("pll-dir-ltr").addClass("pll-dir-"+i),t("#content_ifr").contents().find("html").attr("lang",e).attr("dir",i),t("#content_ifr").contents().find("body").attr("dir",i)})}),l(),t("#ml_box").on("click",".pll-button",function(){var a=t(this).hasClass("wp-ui-text-highlight"),l=t(this).attr("id"),n=t("#htr_lang_"+l.replace("pll_sync_post[","").replace("]","")).val();if(void 0===n||0==n||a||confirm(confirm_text)){var e={action:"toggle_"+l,value:a,post_type:t("#post_type").val(),_pll_nonce:t("#_pll_nonce").val()};t.post(ajaxurl,e,function(a){var n=wpAjax.parseAjaxResponse(a,"ajax-response");t.each(n.responses,function(){l=l.replace("[","\\[").replace("]","\\]"),t("#"+l).toggleClass("wp-ui-text-highlight").attr("title",this.data).children("span").text(this.data),t('input[name="'+l+'"]').val(!e.value)})})}})});
1
+ !function(t){t.ajaxPrefilter(function(a,l,n){"string"==typeof a.data&&-1!==a.url.indexOf("action=ajax-tag-search")&&(lang=t(".post_lang_choice").val())&&(a.data="lang="+lang+"&"+a.data)})}(jQuery),function(t){tagBox.get=function(a){var l=a.substr(a.indexOf("-")+1),n={action:"get-tagcloud",lang:t(".post_lang_choice").val(),tax:l};t.post(ajaxurl,n,function(n,e){0!=n&&"success"==e||(n=wpAjax.broken),n=t("<div />").addClass("the-tagcloud").attr("id","tagcloud-"+l).html(n),t("a",n).click(function(){return tagBox.flushTags(t(this).closest(".inside").children(".tagsdiv"),this),!1}),(v=t(".the-tagcloud").css("display"))?(t(".the-tagcloud").replaceWith(n),t(".the-tagcloud").css("display",v)):t("#"+a).after(n)})}}(jQuery),jQuery(document).ready(function(t){var a=new Array;function l(){t(".tr_lang").each(function(){var a=t(this).attr("id").substring(8),l=t(this).parent().parent().siblings(".pll-edit-column");t(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_posts_not_translated&post_language="+t(".post_lang_choice").val()+"&translation_language="+a+"&post_type="+t("#post_type").val()+"&_pll_nonce="+t("#_pll_nonce").val(),select:function(n,e){t("#htr_lang_"+a).val(e.item.id),l.html(e.item.link)}}),t(this).blur(function(){t(this).val()||(t("#htr_lang_"+a).val(0),l.html(l.siblings(".hidden").children().clone()))})})}t(".categorydiv").each(function(){var l,n;(l=t(this).attr("id").split("-")).shift(),n=l.join("-"),a.push(n),t("#"+n+"-add-submit").before(t("<input />").attr("type","hidden").attr("id",n+"-lang").attr("name","term_lang_choice").attr("value",t(".post_lang_choice").val()))}),t(".post_lang_choice").change(function(){var n=t(this).val(),e=t(this).children('option[value="'+n+'"]').attr("lang"),i=t('.pll-translation-column > span[lang="'+e+'"]').attr("dir"),s={action:"post_lang_choice",lang:n,post_type:t("#post_type").val(),taxonomies:a,post_id:t("#post_ID").val(),_pll_nonce:t("#_pll_nonce").val()};t.post(ajaxurl,s,function(a){var n=wpAjax.parseAjaxResponse(a,"ajax-response");t.each(n.responses,function(){switch(this.what){case"translations":t(".translations").html(this.data),l();break;case"taxonomy":var a=this.data;t("#"+a+"checklist").html(this.supplemental.all),t("#"+a+"checklist-pop").html(this.supplemental.populars),t("#new"+a+"_parent").replaceWith(this.supplemental.dropdown),t("#"+a+"-lang").val(t(".post_lang_choice").val());break;case"pages":t("#parent_id").html(this.data);break;case"flag":t(".pll-select-flag").html(this.data);break;case"permalink":var n=t("#edit-slug-box");"-1"!=this.data&&n.children().length&&n.html(this.data)}}),t(".tagcloud-link").each(function(){var a=t(this).attr("id");tagBox.get(a)}),t("body").removeClass("pll-dir-rtl").removeClass("pll-dir-ltr").addClass("pll-dir-"+i),t("#content_ifr").contents().find("html").attr("lang",e).attr("dir",i),t("#content_ifr").contents().find("body").attr("dir",i)})}),l()});
js/nav-menu.js CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  jQuery( document ).ready(
2
  function( $ ) {
3
  $( '#update-nav-menu' ).bind(
@@ -11,7 +17,7 @@ jQuery( document ).ready(
11
 
12
  // item is a number part of id of parent menu item built by WordPress
13
  // pll_data is built server side with i18n strings without HTML and data retrieved from post meta
14
- // the usage of attr method is safe before append call.
15
  h = $( '<input>' ).attr(
16
  {
17
  type: 'hidden',
@@ -79,7 +85,7 @@ jQuery( document ).ready(
79
  function( i, v ) {
80
  $( '#edit-menu-item-show_' + v + id ).change(
81
  function() {
82
- if ( 'checked' != $( this ).attr( 'checked' ) ) {
83
  $( '#edit-menu-item-show_' + options[ 1 - i ] + id ).prop( 'checked', true );
84
  }
85
  }
1
+ /**
2
+ * Handles the options in the language switcher nav menu metabox.
3
+ *
4
+ * @package Polylang
5
+ */
6
+
7
  jQuery( document ).ready(
8
  function( $ ) {
9
  $( '#update-nav-menu' ).bind(
17
 
18
  // item is a number part of id of parent menu item built by WordPress
19
  // pll_data is built server side with i18n strings without HTML and data retrieved from post meta
20
+ // the usage of attr method is safe before append call.
21
  h = $( '<input>' ).attr(
22
  {
23
  type: 'hidden',
85
  function( i, v ) {
86
  $( '#edit-menu-item-show_' + v + id ).change(
87
  function() {
88
+ if ( true != $( this ).prop( 'checked' ) ) {
89
  $( '#edit-menu-item-show_' + options[ 1 - i ] + id ).prop( 'checked', true );
90
  }
91
  }
js/nav-menu.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(e){e("#update-nav-menu").bind("click",function(t){t.target&&t.target.className&&-1!=t.target.className.indexOf("item-edit")&&(e("input[value='#pll_switcher'][type=text]").parent().parent().parent().each(function(){var t=e(this).attr("id").substring(19);e(this).children("p:not( .field-move )").remove(),h=e("<input>").attr({type:"hidden",id:"edit-menu-item-title-"+t,name:"menu-item-title["+t+"]",value:pll_data.title}),e(this).append(h),h=e("<input>").attr({type:"hidden",id:"edit-menu-item-url-"+t,name:"menu-item-url["+t+"]",value:"#pll_switcher"}),e(this).append(h),h=e("<input>").attr({type:"hidden",id:"edit-menu-item-pll-detect-"+t,name:"menu-item-pll-detect["+t+"]",value:1}),e(this).append(h),ids=Array("hide_if_no_translation","hide_current","force_home","show_flags","show_names","dropdown");for(var i=0,a=ids.length;i<a;i++)p=e("<p>").attr("class","description"),e(this).prepend(p),label=e("<label>").attr("for","edit-menu-item-"+ids[i]+"-"+t).text(" "+pll_data.strings[ids[i]]),p.append(label),cb=e("<input>").attr({type:"checkbox",id:"edit-menu-item-"+ids[i]+"-"+t,name:"menu-item-"+ids[i]+"["+t+"]",value:1}),(void 0!==pll_data.val[t]&&1==pll_data.val[t][ids[i]]||void 0===pll_data.val[t]&&"show_names"==ids[i])&&cb.prop("checked",!0),label.prepend(cb)}),e(".menu-item-data-object-id").each(function(){var t=e(this).val(),i=["names-","flags-"];e.each(i,function(a,n){e("#edit-menu-item-show_"+n+t).change(function(){"checked"!=e(this).attr("checked")&&e("#edit-menu-item-show_"+i[1-a]+t).prop("checked",!0)})})}))})});
1
+ jQuery(document).ready(function(e){e("#update-nav-menu").bind("click",function(t){t.target&&t.target.className&&-1!=t.target.className.indexOf("item-edit")&&(e("input[value='#pll_switcher'][type=text]").parent().parent().parent().each(function(){var t=e(this).attr("id").substring(19);e(this).children("p:not( .field-move )").remove(),h=e("<input>").attr({type:"hidden",id:"edit-menu-item-title-"+t,name:"menu-item-title["+t+"]",value:pll_data.title}),e(this).append(h),h=e("<input>").attr({type:"hidden",id:"edit-menu-item-url-"+t,name:"menu-item-url["+t+"]",value:"#pll_switcher"}),e(this).append(h),h=e("<input>").attr({type:"hidden",id:"edit-menu-item-pll-detect-"+t,name:"menu-item-pll-detect["+t+"]",value:1}),e(this).append(h),ids=Array("hide_if_no_translation","hide_current","force_home","show_flags","show_names","dropdown");for(var i=0,a=ids.length;i<a;i++)p=e("<p>").attr("class","description"),e(this).prepend(p),label=e("<label>").attr("for","edit-menu-item-"+ids[i]+"-"+t).text(" "+pll_data.strings[ids[i]]),p.append(label),cb=e("<input>").attr({type:"checkbox",id:"edit-menu-item-"+ids[i]+"-"+t,name:"menu-item-"+ids[i]+"["+t+"]",value:1}),(void 0!==pll_data.val[t]&&1==pll_data.val[t][ids[i]]||void 0===pll_data.val[t]&&"show_names"==ids[i])&&cb.prop("checked",!0),label.prepend(cb)}),e(".menu-item-data-object-id").each(function(){var t=e(this).val(),i=["names-","flags-"];e.each(i,function(a,n){e("#edit-menu-item-show_"+n+t).change(function(){1!=e(this).prop("checked")&&e("#edit-menu-item-show_"+i[1-a]+t).prop("checked",!0)})})}))})});
js/post.js CHANGED
@@ -1,7 +1,10 @@
1
  /**
2
- * Tag suggest in quick edit
3
  */
4
 
 
 
 
5
  (function( $ ){
6
  $.ajaxPrefilter(
7
  function( options, originalOptions, jqXHR ) {
@@ -156,82 +159,3 @@
156
  }
157
  );
158
  })( jQuery );
159
-
160
- /**
161
- * Bulk translate
162
- */
163
- jQuery( document ).ready(
164
- function( $ ) {
165
- var t = this;
166
-
167
- $( '.editinline' ).click(
168
- function(){
169
- $( '#pll-translate' ).find( '.cancel' ).click(); // Close the form on quick edit
170
- }
171
- );
172
-
173
- $( '#doaction, #doaction2' ).click(
174
- function( e ){
175
- t.whichBulkButtonId = $( this ).attr( 'id' );
176
- var n = t.whichBulkButtonId.substr( 2 );
177
-
178
- if ( 'pll_translate' === $( 'select[name="' + n + '"]' ).val() ) {
179
- e.preventDefault();
180
-
181
- if ( typeof inlineEditPost !== 'undefined' ) { // Not available for media.
182
- inlineEditPost.revert(); // Close Bulk edit and Quick edit if open.
183
- }
184
-
185
- $( '#pll-translate td' ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
186
- $( 'table.widefat tbody' ).prepend( $( '#pll-translate' ) ).prepend( '<tr class="hidden"></tr>' ); // The hidden tr allows to keep the background color
187
- } else {
188
- $( '#pll-translate' ).find( '.cancel' ).click();
189
- }
190
- }
191
- );
192
-
193
- // Cancel
194
- $( '#pll-translate' ).on(
195
- 'click',
196
- '.cancel',
197
- function(){
198
- // Close the form on any other bulk action
199
- $( '#pll-translate' ).siblings( '.hidden' ).remove();
200
- // #pll-translate is built and come from server side and is well escaped when necessary
201
- $( '#pll-bulk-translate' ).append( $( '#pll-translate' ) ); //phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.append
202
-
203
- // Move focus back to the Bulk Action button that was activated.
204
- $( '#' + t.whichBulkButtonId ).focus();
205
- }
206
- );
207
-
208
- // Act when pressing enter or esc
209
- $( '#pll-translate' ).keydown(
210
- function( event ){
211
- if ( 13 === event.keyCode && ! $( event.target ).hasClass( 'cancel' ) ) {
212
- event.preventDefault();
213
- $( this ).find( 'input[type=submit]' ).click();
214
- }
215
- if ( 27 === event.keyCode ) {
216
- event.preventDefault();
217
- $( this ).find( '.cancel' ).click();
218
- }
219
- }
220
- );
221
-
222
- // Clean DOM in case of file download
223
- $( '#posts-filter' ).on(
224
- 'submit',
225
- function() {
226
- $( '.settings-error' ).remove();
227
- setTimeout(
228
- function() {
229
- $( 'input[type=checkbox]:checked' ).attr( 'checked', false );
230
- $( '#pll-translate' ).find( '.cancel' ).trigger( 'click' );
231
- },
232
- 500
233
- );
234
- }
235
- );
236
- }
237
- );
1
  /**
2
+ * @package Polylang
3
  */
4
 
5
+ /**
6
+ * Tag suggest in quick edit
7
+ */
8
  (function( $ ){
9
  $.ajaxPrefilter(
10
  function( options, originalOptions, jqXHR ) {
159
  }
160
  );
161
  })( jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/post.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){t.ajaxPrefilter(function(n){"string"==typeof n.data&&-1!==n.data.indexOf("action=ajax-tag-search")&&(lang=t(':input[name="inline_lang_choice"]').val())&&(n.data="lang="+lang+"&"+n.data)})}(jQuery),function(t){t(document).bind("DOMNodeInserted",function(n){function e(n){"undefined"!=typeof pll_term_languages&&t.each(pll_term_languages,function(e,a){t.each(a,function(a,i){t.each(i,function(i){id="#"+a+"-"+pll_term_languages[e][a][i],n==e?t(id).show():t(id).hide()})})})}function a(n){"undefined"!=typeof pll_page_languages&&t.each(pll_page_languages,function(e,a){t.each(a,function(a){v=t('#post_parent option[value="'+pll_page_languages[e][a]+'"]'),n==e?v.show():v.hide()})})}var i=t(n.target);if("inline-edit"==i.attr("id")){var l=i.prev().attr("id").replace("post-","");if(l>0){var c=i.find(':input[name="inline_lang_choice"]'),o=t("#lang_"+l).html();c.val(o),e(o),a(o),c.change(function(){e(t(this).val()),a(t(this).val())})}}})}(jQuery),function(t){t(document).ajaxSuccess(function(n,e,a){function i(n){var e=new Array;t(".translation_"+n).each(function(){e.push(t(this).parent().parent().attr("id").substring(5))});var a={action:"pll_update_post_rows",post_id:n,translations:e.join(","),post_type:t("input[name='post_type']").val(),screen:t("input[name='screen']").val(),_pll_nonce:t("input[name='_inline_edit']").val()};t.post(ajaxurl,a,function(n){if(n){var e=wpAjax.parseAjaxResponse(n,"ajax-response");t.each(e.responses,function(){"row"==this.what&&t("#post-"+this.supplemental.post_id).replaceWith(this.data)})}})}if("string"==typeof a.data){var l=wpAjax.unserialize(a.data);"undefined"!=typeof l.action&&"inline-save"==l.action&&i(l.post_ID)}})}(jQuery),function(t){t.ajaxPrefilter(function(n){"string"==typeof n.data&&-1!==n.data.indexOf("action=find_posts")&&(n.data="pll_post_id="+t("#affected").val()+"&"+n.data)})}(jQuery),jQuery(document).ready(function(t){var n=this;t(".editinline").click(function(){t("#pll-translate").find(".cancel").click()}),t("#doaction, #doaction2").click(function(e){n.whichBulkButtonId=t(this).attr("id");var a=n.whichBulkButtonId.substr(2);"pll_translate"===t('select[name="'+a+'"]').val()?(e.preventDefault(),"undefined"!=typeof inlineEditPost&&inlineEditPost.revert(),t("#pll-translate td").attr("colspan",t("th:visible, td:visible",".widefat:first thead").length),t("table.widefat tbody").prepend(t("#pll-translate")).prepend('<tr class="hidden"></tr>')):t("#pll-translate").find(".cancel").click()}),t("#pll-translate").on("click",".cancel",function(){t("#pll-translate").siblings(".hidden").remove(),t("#pll-bulk-translate").append(t("#pll-translate")),t("#"+n.whichBulkButtonId).focus()}),t("#pll-translate").keydown(function(n){13!==n.keyCode||t(n.target).hasClass("cancel")||(n.preventDefault(),t(this).find("input[type=submit]").click()),27===n.keyCode&&(n.preventDefault(),t(this).find(".cancel").click())}),t("#posts-filter").on("submit",function(){t(".settings-error").remove(),setTimeout(function(){t("input[type=checkbox]:checked").attr("checked",!1),t("#pll-translate").find(".cancel").trigger("click")},500)})});
1
+ !function(a){a.ajaxPrefilter(function(n,t,e){"string"==typeof n.data&&-1!==n.data.indexOf("action=ajax-tag-search")&&(lang=a(':input[name="inline_lang_choice"]').val())&&(n.data="lang="+lang+"&"+n.data)})}(jQuery),function(a){a(document).bind("DOMNodeInserted",function(n){var t=a(n.target);if("inline-edit"==t.attr("id")){var e=t.prev().attr("id").replace("post-","");if(e>0){var i=t.find(':input[name="inline_lang_choice"]'),o=a("#lang_"+e).html();i.val(o),l(o),s(o),i.change(function(){l(a(this).val()),s(a(this).val())})}}function l(n){"undefined"!=typeof pll_term_languages&&a.each(pll_term_languages,function(t,e){a.each(e,function(e,i){a.each(i,function(i){id="#"+e+"-"+pll_term_languages[t][e][i],n==t?a(id).show():a(id).hide()})})})}function s(n){"undefined"!=typeof pll_page_languages&&a.each(pll_page_languages,function(t,e){a.each(e,function(e){v=a('#post_parent option[value="'+pll_page_languages[t][e]+'"]'),n==t?v.show():v.hide()})})}})}(jQuery),function(a){a(document).ajaxSuccess(function(n,t,e){if("string"==typeof e.data){var i=wpAjax.unserialize(e.data);void 0!==i.action&&"inline-save"==i.action&&function(n){var t=new Array;a(".translation_"+n).each(function(){t.push(a(this).parent().parent().attr("id").substring(5))});var e={action:"pll_update_post_rows",post_id:n,translations:t.join(","),post_type:a("input[name='post_type']").val(),screen:a("input[name='screen']").val(),_pll_nonce:a("input[name='_inline_edit']").val()};a.post(ajaxurl,e,function(n){if(n){var t=wpAjax.parseAjaxResponse(n,"ajax-response");a.each(t.responses,function(){"row"==this.what&&a("#post-"+this.supplemental.post_id).replaceWith(this.data)})}})}(i.post_ID)}})}(jQuery),function(a){a.ajaxPrefilter(function(n,t,e){"string"==typeof n.data&&-1!==n.data.indexOf("action=find_posts")&&(n.data="pll_post_id="+a("#affected").val()+"&"+n.data)})}(jQuery);
js/term.js CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  // quick edit
2
  (function( $ ) {
3
  $( document ).bind(
1
+ /**
2
+ * @package Polylang
3
+ */
4
+
5
  // quick edit
6
  (function( $ ) {
7
  $( document ).bind(
js/term.min.js CHANGED
@@ -1 +1 @@
1
- !function(a){a(document).bind("DOMNodeInserted",function(t){var n=a(t.target);if("inline-edit"==n.attr("id")){var e=n.prev().attr("id").replace("tag-","");if(e>0){var l=n.find(':input[name="inline_lang_choice"]'),i=a("#lang_"+e).html();l.val(i),e==a("#default_cat_"+e).html()&&l.prop("disabled",!0)}}})}(jQuery),function(a){a(document).ajaxSuccess(function(t,n,e){function l(t){var n=new Array;a(".translation_"+t).each(function(){n.push(a(this).parent().parent().attr("id").substring(4))});var e={action:"pll_update_term_rows",term_id:t,translations:n.join(","),taxonomy:a("input[name='taxonomy']").val(),post_type:a("input[name='post_type']").val(),screen:a("input[name='screen']").val(),_pll_nonce:a("#_pll_nonce").val()};a.post(ajaxurl,e,function(t){if(t){var n=wpAjax.parseAjaxResponse(t,"ajax-response");a.each(n.responses,function(){"row"==this.what&&a("#tag-"+this.supplemental.term_id).replaceWith(this.data)})}})}var i=wpAjax.unserialize(e.data);if(void 0!==i.action)switch(i.action){case"add-tag":res=wpAjax.parseAjaxResponse(n.responseXML,"ajax-response"),a.each(res.responses,function(){"term"==this.what&&l(this.supplemental.term_id)}),a(".htr_lang").val(0);break;case"delete-tag":l(i.tag_ID);break;case"inline-save-tax":l(i.tax_ID)}})}(jQuery),jQuery(document).ready(function(a){function t(){a(".tr_lang").each(function(){var t=a(this).attr("id").substring(8),n=a(this).parent().parent().siblings(".pll-edit-column");a(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_terms_not_translated&term_language="+a("#term_lang_choice").val()+"&term_id="+a("input[name='tag_ID']").val()+"&taxonomy="+a("input[name='taxonomy']").val()+"&translation_language="+t+"&post_type="+typenow+"&_pll_nonce="+a("#_pll_nonce").val(),select:function(e,l){a("#htr_lang_"+t).val(l.item.id),n.html(l.item.link)}}),a(this).blur(function(){a(this).val()||(a("#htr_lang_"+t).val(0),n.html(n.siblings(".hidden").children().clone()))})})}t(),a("#term_lang_choice").change(function(){var n=a(this).val(),e=a(this).children('option[value="'+n+'"]').attr("lang"),l=a('.pll-translation-column > span[lang="'+e+'"]').attr("dir"),i={action:"term_lang_choice",lang:n,from_tag:a("input[name='from_tag']").val(),term_id:a("input[name='tag_ID']").val(),taxonomy:a("input[name='taxonomy']").val(),post_type:typenow,_pll_nonce:a("#_pll_nonce").val()};a.post(ajaxurl,i,function(n){var e=wpAjax.parseAjaxResponse(n,"ajax-response");a.each(e.responses,function(){switch(this.what){case"translations":a("#term-translations").html(this.data),t();break;case"parent":a("#parent").replaceWith(this.data);break;case"tag_cloud":a(".tagcloud").replaceWith(this.data);break;case"flag":a(".pll-select-flag").html(this.data)}}),a("body").removeClass("pll-dir-rtl").removeClass("pll-dir-ltr").addClass("pll-dir-"+l)})})});
1
+ !function(a){a(document).bind("DOMNodeInserted",function(t){var n=a(t.target);if("inline-edit"==n.attr("id")){var e=n.prev().attr("id").replace("tag-","");if(e>0){var l=n.find(':input[name="inline_lang_choice"]'),i=a("#lang_"+e).html();l.val(i),e==a("#default_cat_"+e).html()&&l.prop("disabled",!0)}}})}(jQuery),function(a){a(document).ajaxSuccess(function(t,n,e){function l(t){var n=new Array;a(".translation_"+t).each(function(){n.push(a(this).parent().parent().attr("id").substring(4))});var e={action:"pll_update_term_rows",term_id:t,translations:n.join(","),taxonomy:a("input[name='taxonomy']").val(),post_type:a("input[name='post_type']").val(),screen:a("input[name='screen']").val(),_pll_nonce:a("#_pll_nonce").val()};a.post(ajaxurl,e,function(t){if(t){var n=wpAjax.parseAjaxResponse(t,"ajax-response");a.each(n.responses,function(){"row"==this.what&&a("#tag-"+this.supplemental.term_id).replaceWith(this.data)})}})}var i=wpAjax.unserialize(e.data);if(void 0!==i.action)switch(i.action){case"add-tag":res=wpAjax.parseAjaxResponse(n.responseXML,"ajax-response"),a.each(res.responses,function(){"term"==this.what&&l(this.supplemental.term_id)}),a(".htr_lang").val(0);break;case"delete-tag":l(i.tag_ID);break;case"inline-save-tax":l(i.tax_ID)}})}(jQuery),jQuery(document).ready(function(a){function t(){a(".tr_lang").each(function(){var t=a(this).attr("id").substring(8),n=a(this).parent().parent().siblings(".pll-edit-column");a(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_terms_not_translated&term_language="+a("#term_lang_choice").val()+"&term_id="+a("input[name='tag_ID']").val()+"&taxonomy="+a("input[name='taxonomy']").val()+"&translation_language="+t+"&post_type="+typenow+"&_pll_nonce="+a("#_pll_nonce").val(),select:function(e,l){a("#htr_lang_"+t).val(l.item.id),n.html(l.item.link)}}),a(this).blur(function(){a(this).val()||(a("#htr_lang_"+t).val(0),n.html(n.siblings(".hidden").children().clone()))})})}t(),a("#term_lang_choice").change(function(){var n=a(this).val(),e=a(this).children('option[value="'+n+'"]').attr("lang"),l=a('.pll-translation-column > span[lang="'+e+'"]').attr("dir"),i={action:"term_lang_choice",lang:n,from_tag:a("input[name='from_tag']").val(),term_id:a("input[name='tag_ID']").val(),taxonomy:a("input[name='taxonomy']").val(),post_type:typenow,_pll_nonce:a("#_pll_nonce").val()};a.post(ajaxurl,i,function(n){var e=wpAjax.parseAjaxResponse(n,"ajax-response");a.each(e.responses,function(){switch(this.what){case"translations":a("#term-translations").html(this.data),t();break;case"parent":a("#parent").replaceWith(this.data);break;case"tag_cloud":a(".tagcloud").replaceWith(this.data);break;case"flag":a(".pll-select-flag").html(this.data)}}),a("body").removeClass("pll-dir-rtl").removeClass("pll-dir-ltr").addClass("pll-dir-"+l)})})});
js/user.js CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  jQuery( document ).ready(
2
  function( $ ) {
3
  // biography
1
+ /**
2
+ * Adds one biography input field per language in the user profile.
3
+ *
4
+ * @package Polylang
5
+ */
6
+
7
  jQuery( document ).ready(
8
  function( $ ) {
9
  // biography
js/user.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(e){var n=e("#description").parent(),d=e("#description").clone(),i=n.children(".description").clone();n.children().remove(),e(".biography").each(function(){lang=e(this).attr("name").split("___"),desc=d.clone(),desc.attr("name","description_"+lang[0]),desc.attr("id","description_"+lang[0]),desc.html(e(this).val()),n.append(e("<div></div>").text(lang[1])),n.append(desc)}),n.append("<br />"),n.append(i)});
1
+ jQuery(document).ready(function(e){var n=e("#description").parent(),d=e("#description").clone(),i=n.children(".description").clone();n.children().remove(),e(".biography").each(function(){lang=e(this).attr("name").split("___"),desc=d.clone(),desc.attr("name","description_"+lang[0]),desc.attr("id","description_"+lang[0]),desc.html(e(this).val()),n.append(e("<div></div>").text(lang[1])),n.append(desc)}),n.append("<br />"),n.append(i)});
js/widgets.js CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  jQuery(
2
  function( $ ) {
3
  var widgets_container, widgets_selector, flags;
@@ -8,7 +14,7 @@ jQuery(
8
 
9
  /**
10
  * Prepend widget titles with a flag once a language is selected.
11
- *
12
  * @param {object} widget The widget element.
13
  * @return {void} Nothing.
14
  */
1
+ /**
2
+ * Adds a flag to the widgets filtered by a language.
3
+ *
4
+ * @package Polylang
5
+ */
6
+
7
  jQuery(
8
  function( $ ) {
9
  var widgets_container, widgets_selector, flags;
14
 
15
  /**
16
  * Prepend widget titles with a flag once a language is selected.
17
+ *
18
  * @param {object} widget The widget element.
19
  * @return {void} Nothing.
20
  */
js/widgets.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){var t,l,n;function i(t){if(n){t=e(t);var l=e(".widget-top .widget-title h3",t),i=e(".pll-lang-choice option:selected",t).val(),o=i&&n.hasOwnProperty(i)?n[i]:null;if(o){o+=" &nbsp; ";var d=e(".pll-lang",l);d.length?d.html(o):(flag=e("<span />").addClass("pll-lang").html(o),l.prepend(flag))}else e(".pll-lang",l).remove()}}if("undefined"!=typeof pll_widgets&&pll_widgets.hasOwnProperty("flags")&&(n=pll_widgets.flags),void 0!==wp.customize){function o(e){e.extended(wp.customize.Widgets.WidgetControl)&&(e.embedWidgetContent(),i(e.container.find(".widget")))}t=e("#customize-controls"),l=".customize-control .widget",wp.customize.control.each(o),wp.customize.control.bind("add",o)}else t=e("#widgets-right"),l=".widget";e(l,t).each(function(){i(this)}),t.on("change",".pll-lang-choice",function(){i(e(this).parents(".widget"))})});
1
+ jQuery(function(e){var t,l,n;function i(t){if(n){t=e(t);var l=e(".widget-top .widget-title h3",t),i=e(".pll-lang-choice option:selected",t).val(),o=i&&n.hasOwnProperty(i)?n[i]:null;if(o){o+=" &nbsp; ";var d=e(".pll-lang",l);d.length?d.html(o):(flag=e("<span />").addClass("pll-lang").html(o),l.prepend(flag))}else e(".pll-lang",l).remove()}}if("undefined"!=typeof pll_widgets&&pll_widgets.hasOwnProperty("flags")&&(n=pll_widgets.flags),void 0!==wp.customize){function o(e){e.extended(wp.customize.Widgets.WidgetControl)&&(e.embedWidgetContent(),i(e.container.find(".widget")))}t=e("#customize-controls"),l=".customize-control .widget",wp.customize.control.each(o),wp.customize.control.bind("add",o)}else t=e("#widgets-right"),l=".widget";e(l,t).each(function(){i(this)}),t.on("change",".pll-lang-choice",function(){i(e(this).parents(".widget"))})});
{lingotek → modules/lingotek}/image01.gif RENAMED
File without changes
{lingotek → modules/lingotek}/image02.png RENAMED
File without changes
{lingotek → modules/lingotek}/image03.png RENAMED
File without changes
{lingotek → modules/lingotek}/image04.png RENAMED
File without changes
{lingotek → modules/lingotek}/lingotek.php RENAMED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Class to manage Lingotek ads
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Class to manage Lingotek ads
modules/lingotek/load.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the Lingotek ad.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly
10
+ };
11
+
12
+ if ( ! defined( 'POLYLANG_PRO' ) && ( ! defined( 'PLL_LINGOTEK_AD' ) || PLL_LINGOTEK_AD ) && $polylang instanceof PLL_Admin_Base ) {
13
+ add_action( 'wp_loaded', array( new PLL_Lingotek(), 'init' ) );
14
+ }
modules/plugins/plugins-compat.php DELETED
@@ -1,345 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Manages compatibility with 3rd party plugins ( and themes )
5
- * This class is available as soon as the plugin is loaded
6
- *
7
- * @since 1.0
8
- */
9
- class PLL_Plugins_Compat {
10
- protected static $instance; // for singleton
11
-
12
- /**
13
- * Constructor
14
- *
15
- * @since 1.0
16
- */
17
- protected function __construct() {
18
- add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 0 );
19
- add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) );
20
-
21
- // WordPress Importer
22
- add_action( 'init', array( $this, 'maybe_wordpress_importer' ) );
23
- add_filter( 'wp_import_terms', array( $this, 'wp_import_terms' ) );
24
-
25
- // YARPP
26
- add_action( 'init', array( $this, 'yarpp_init' ) ); // after Polylang has registered its taxonomy in setup_theme
27
-
28
- // Custom field template
29
- add_action( 'add_meta_boxes', array( $this, 'cft_copy' ), 10, 2 );
30
-
31
- // Aqua Resizer
32
- add_filter( 'pll_home_url_black_list', array( $this, 'aq_home_url_black_list' ) );
33
-
34
- // Duplicate post
35
- add_filter( 'option_duplicate_post_taxonomies_blacklist', array( $this, 'duplicate_post_taxonomies_blacklist' ) );
36
-
37
- // Jetpack
38
- $this->jetpack = new PLL_Jetpack(); // Must be loaded before the plugin is active
39
- add_action( 'pll_init', array( $this->featured_content = new PLL_Featured_Content(), 'init' ) );
40
-
41
- // WP Sweep
42
- add_filter( 'wp_sweep_excluded_taxonomies', array( $this, 'wp_sweep_excluded_taxonomies' ) );
43
-
44
- // Twenty Seventeen
45
- add_action( 'init', array( $this, 'twenty_seventeen_init' ) );
46
-
47
- // No category base (works for Yoast SEO too)
48
- add_filter( 'get_terms_args', array( $this, 'no_category_base_get_terms_args' ), 5 ); // Before adding cache domain
49
-
50
- // WordPress MU Domain Mapping
51
- if ( function_exists( 'redirect_to_mapped_domain' ) ) {
52
- if ( ! defined( 'PLL_CACHE_HOME_URL' ) && ( $options = get_option( 'polylang' ) ) && $options['force_lang'] < 2 ) {
53
- define( 'PLL_CACHE_HOME_URL', false );
54
- }
55
-
56
- if ( ! get_site_option( 'dm_no_primary_domain' ) ) {
57
- remove_action( 'template_redirect', 'redirect_to_mapped_domain' );
58
- add_action( 'template_redirect', array( $this, 'dm_redirect_to_mapped_domain' ) );
59
- }
60
- }
61
- }
62
-
63
- /**
64
- * Access to the single instance of the class
65
- *
66
- * @since 1.7
67
- *
68
- * @return object
69
- */
70
- public static function instance() {
71
- if ( empty( self::$instance ) ) {
72
- self::$instance = new self();
73
- }
74
-
75
- return self::$instance;
76
- }
77
-
78
- /**
79
- * Look for active plugins and load compatibility layer if needed
80
- *
81
- * @since 2.3
82
- */
83
- public function plugins_loaded() {
84
- // Yoast SEO
85
- if ( defined( 'WPSEO_VERSION' ) ) {
86
- add_action( 'pll_init', array( $this->wpseo = new PLL_WPSEO(), 'init' ) );
87
- }
88
-
89
- if ( pll_is_cache_active() ) {
90
- add_action( 'pll_init', array( $this->cache_compat = new PLL_Cache_Compat(), 'init' ) );
91
- }
92
-
93
- // Custom Post Type UI
94
- if ( defined( 'CPTUI_VERSION' ) && class_exists( 'PLL_CPTUI' ) ) {
95
- add_action( 'pll_init', array( $this->cptui = new PLL_CPTUI(), 'init' ) );
96
- }
97
-
98
- // The Event Calendar
99
- if ( defined( 'TRIBE_EVENTS_FILE' ) && class_exists( 'PLL_TEC' ) ) {
100
- add_action( 'pll_init', array( $this->tec = new PLL_TEC(), 'init' ) );
101
- }
102
-
103
- // Beaver Builder
104
- if ( class_exists( 'FLBuilderLoader' ) && class_exists( 'PLL_FLBuilder' ) ) {
105
- $this->flbuilder = new PLL_FLBuilder();
106
- }
107
-
108
- // Divi Builder
109
- if ( ( 'Divi' === get_template() || defined( 'ET_BUILDER_PLUGIN_VERSION' ) ) && class_exists( 'PLL_Divi_Builder' ) ) {
110
- $this->divi_builder = new PLL_Divi_Builder();
111
- }
112
-
113
- // WP Offload Media Lite
114
- if ( function_exists( 'as3cf_init' ) && class_exists( 'PLL_AS3CF' ) ) {
115
- add_action( 'pll_init', array( $this->as3cf = new PLL_AS3CF(), 'init' ) );
116
- }
117
-
118
- // Content Blocks (Custom Post Widget)
119
- if ( function_exists( 'custom_post_widget_plugin_init' ) && class_exists( 'PLL_Content_Blocks' ) ) {
120
- add_action( 'pll_init', array( $this->content_blocks = new PLL_Content_Blocks(), 'init' ) );
121
- }
122
- }
123
-
124
- /**
125
- * Look for active plugins and load compatibility layer after the theme has been setup
126
- *
127
- * @since 2.3.8
128
- */
129
- public function after_setup_theme() {
130
- // Advanced Custom Fields Pro
131
- if ( defined( 'ACF_VERSION' ) && version_compare( ACF_VERSION, '5.7.11', '>=' ) && class_exists( 'PLL_ACF' ) ) {
132
- add_action( 'init', array( $this->acf = new PLL_ACF(), 'init' ) );
133
- }
134
-
135
- // Admin Columns & Admin Columns Pro
136
- if ( did_action( 'pll_init' ) && ( defined( 'AC_FILE' ) || defined( 'ACP_FILE' ) ) && class_exists( 'PLL_CPAC' ) ) {
137
- add_action( 'admin_init', array( $this->cpac = new PLL_CPAC(), 'init' ) );
138
- }
139
- }
140
-
141
- /**
142
- * WordPress Importer
143
- * If WordPress Importer is active, replace the wordpress_importer_init function
144
- *
145
- * @since 1.2
146
- */
147
- public function maybe_wordpress_importer() {
148
- if ( defined( 'WP_LOAD_IMPORTERS' ) && class_exists( 'WP_Import' ) ) {
149
- remove_action( 'admin_init', 'wordpress_importer_init' );
150
- add_action( 'admin_init', array( $this, 'wordpress_importer_init' ) );
151
- }
152
- }
153
-
154
- /**
155
- * WordPress Importer
156
- * Loads our child class PLL_WP_Import instead of WP_Import
157
- *
158
- * @since 1.2
159
- */
160
- public function wordpress_importer_init() {
161
- $class = new ReflectionClass( 'WP_Import' );
162
- load_plugin_textdomain( 'wordpress-importer', false, basename( dirname( $class->getFileName() ) ) . '/languages' );
163
-
164
- $GLOBALS['wp_import'] = new PLL_WP_Import();
165
- register_importer( 'wordpress', 'WordPress', __( 'Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'polylang' ), array( $GLOBALS['wp_import'], 'dispatch' ) ); // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
166
- }
167
-
168
- /**
169
- * WordPress Importer
170
- * Backward Compatibility Polylang < 1.8
171
- * Sets the flag when importing a language and the file has been exported with Polylang < 1.8
172
- *
173
- * @since 1.8
174
- *
175
- * @param array $terms an array of arrays containing terms information form the WXR file
176
- * @return array
177
- */
178
- public function wp_import_terms( $terms ) {
179
- $languages = include PLL_SETTINGS_INC . '/languages.php';
180
-
181
- foreach ( $terms as $key => $term ) {
182
- if ( 'language' === $term['term_taxonomy'] ) {
183
- $description = maybe_unserialize( $term['term_description'] );
184
- if ( empty( $description['flag_code'] ) && isset( $languages[ $description['locale'] ] ) ) {
185
- $description['flag_code'] = $languages[ $description['locale'] ]['flag'];
186
- $terms[ $key ]['term_description'] = maybe_serialize( $description );
187
- }
188
- }
189
- }
190
- return $terms;
191
- }
192
-
193
- /**
194
- * YARPP
195
- * Just makes YARPP aware of the language taxonomy ( after Polylang registered it )
196
- *
197
- * @since 1.0
198
- */
199
- public function yarpp_init() {
200
- $GLOBALS['wp_taxonomies']['language']->yarpp_support = 1;
201
- }
202
-
203
- /**
204
- * Aqua Resizer
205
- *
206
- * @since 1.1.5
207
- *
208
- * @param array $arr
209
- * @return array
210
- */
211
- public function aq_home_url_black_list( $arr ) {
212
- return array_merge( $arr, array( array( 'function' => 'aq_resize' ) ) );
213
- }
214
-
215
- /**
216
- * Custom field template
217
- * Custom field template does check $_REQUEST['post'] to populate the custom fields values
218
- *
219
- * @since 1.0.2
220
- *
221
- * @param string $post_type unused
222
- * @param object $post current post object
223
- */
224
- public function cft_copy( $post_type, $post ) {
225
- global $custom_field_template;
226
- if ( isset( $custom_field_template, $_REQUEST['from_post'], $_REQUEST['new_lang'] ) && ! empty( $post ) ) { // phpcs:ignore WordPress.Security.NonceVerification
227
- $_REQUEST['post'] = $post->ID;
228
- }
229
- }
230
-
231
- /**
232
- * Duplicate Post
233
- * Avoid duplicating the 'post_translations' taxonomy
234
- *
235
- * @since 1.8
236
- *
237
- * @param array|string $taxonomies
238
- * @return array
239
- */
240
- public function duplicate_post_taxonomies_blacklist( $taxonomies ) {
241
- if ( empty( $taxonomies ) ) {
242
- $taxonomies = array(); // As we get an empty string when there is no taxonomy
243
- }
244
-
245
- $taxonomies[] = 'post_translations';
246
- return $taxonomies;
247
- }
248
-
249
- /**
250
- * WP Sweep
251
- * Add 'term_language' and 'term_translations' to excluded taxonomies otherwise terms loose their language and translation group
252
- *
253
- * @since 2.0
254
- *
255
- * @param array $excluded_taxonomies list of taxonomies excluded from sweeping
256
- * @return array
257
- */
258
- public function wp_sweep_excluded_taxonomies( $excluded_taxonomies ) {
259
- return array_merge( $excluded_taxonomies, array( 'term_language', 'term_translations' ) );
260
- }
261
-
262
- /**
263
- * Twenty Seventeen
264
- * Translates the front page panels
265
- *
266
- * @since 2.0.10
267
- */
268
- public function twenty_seventeen_init() {
269
- if ( 'twentyseventeen' === get_template() && did_action( 'pll_init' ) ) {
270
- if ( function_exists( 'twentyseventeen_panel_count' ) && PLL() instanceof PLL_Frontend ) {
271
- $num_sections = twentyseventeen_panel_count();
272
- for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
273
- add_filter( 'theme_mod_panel_' . $i, 'pll_get_post' );
274
- }
275
- }
276
-
277
- if ( PLL() instanceof PLL_Frontend ) {
278
- add_filter( 'theme_mod_external_header_video', 'pll__' );
279
- } else {
280
- pll_register_string( __( 'Header video', 'polylang' ), get_theme_mod( 'external_header_video' ), 'Twenty Seventeen', false );
281
- }
282
- }
283
- }
284
-
285
- /**
286
- * Make sure No category base plugins (including Yoast SEO) get all categories when flushing rules
287
- *
288
- * @since 2.1
289
- *
290
- * @param array $args
291
- * @return array
292
- */
293
- public function no_category_base_get_terms_args( $args ) {
294
- if ( doing_filter( 'category_rewrite_rules' ) ) {
295
- $args['lang'] = '';
296
- }
297
- return $args;
298
- }
299
-
300
- /**
301
- * WordPress MU Domain Mapping
302
- * Fix primary domain check which forces only one domain per blog
303
- * Accept only known domains/subdomains for the current blog
304
- *
305
- * @since 2.2
306
- */
307
- public function dm_redirect_to_mapped_domain() {
308
- $options = get_option( 'polylang' );
309
-
310
- // The language is set from the subdomain or domain name
311
- if ( $options['force_lang'] > 1 ) {
312
- // Don't redirect the main site
313
- if ( is_main_site() ) {
314
- return;
315
- }
316
-
317
- // Don't redirect post previews
318
- if ( isset( $_GET['preview'] ) && 'true' === $_GET['preview'] ) { // phpcs:ignore WordPress.Security.NonceVerification
319
- return;
320
- }
321
-
322
- // Don't redirect theme customizer
323
- if ( isset( $_POST['customize'] ) && isset( $_POST['theme'] ) && 'on' === $_POST['customize'] ) { // phpcs:ignore WordPress.Security.NonceVerification
324
- return;
325
- }
326
-
327
- // If we can't associate the requested domain to a language, redirect to the default domain
328
- $requested_url = pll_get_requested_url();
329
- $requested_host = wp_parse_url( $requested_url, PHP_URL_HOST );
330
-
331
- $hosts = PLL()->links_model->get_hosts();
332
- $lang = array_search( $requested_host, $hosts );
333
-
334
- if ( empty( $lang ) ) {
335
- $status = get_site_option( 'dm_301_redirect' ) ? '301' : '302'; // Honor status redirect option
336
- $redirect = str_replace( '://' . $requested_host, '://' . $hosts[ $options['default_lang'] ], $requested_url );
337
- wp_safe_redirect( $redirect, $status );
338
- exit;
339
- }
340
- } else {
341
- // Otherwise rely on MU Domain Mapping
342
- redirect_to_mapped_domain();
343
- }
344
- }
345
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/share-slug/load.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the settings module for shared slugs.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly
10
+ };
11
+
12
+ if ( $polylang->model->get_languages_list() ) {
13
+ add_filter(
14
+ 'pll_settings_modules',
15
+ function( $modules ) {
16
+ $modules[] = 'PLL_Settings_Share_Slug';
17
+ return $modules;
18
+ }
19
+ );
20
+ }
modules/share-slug/settings-share-slug.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Settings class to advertize the Share slugs module
@@ -6,6 +9,12 @@
6
  * @since 1.9
7
  */
8
  class PLL_Settings_Share_Slug extends PLL_Settings_Module {
 
 
 
 
 
 
9
 
10
  /**
11
  * Constructor
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Settings class to advertize the Share slugs module
9
  * @since 1.9
10
  */
11
  class PLL_Settings_Share_Slug extends PLL_Settings_Module {
12
+ /**
13
+ * Stores the display order priority.
14
+ *
15
+ * @var int
16
+ */
17
+ public $priority = 70;
18
 
19
  /**
20
  * Constructor
modules/site-health/admin-site-health.php ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Class PLL_Admin_Site_Health to add debug info in WP Site Health.
8
+ *
9
+ * @link https://make.wordpress.org/core/2019/04/25/site-health-check-in-5-2/
10
+ *
11
+ * @since 2.8
12
+ */
13
+ class PLL_Admin_Site_Health {
14
+ /**
15
+ * A reference to the PLL_Model instance.
16
+ *
17
+ * @since 2.8
18
+ *
19
+ * @var PLL_Model
20
+ */
21
+ protected $model;
22
+
23
+ /**
24
+ * A reference to the PLL_Admin_Static_Pages instance.
25
+ *
26
+ * @since 2.8
27
+ *
28
+ * @var PLL_Admin_Static_Pages
29
+ */
30
+ protected $static_pages;
31
+
32
+ /**
33
+ * PLL_Admin_Site_Health constructor.
34
+ *
35
+ * @since 2.8
36
+ *
37
+ * @param object $polylang
38
+ */
39
+ public function __construct( &$polylang ) {
40
+ $this->model = &$polylang->model;
41
+ $this->static_pages = &$polylang->static_pages;
42
+
43
+ // Information tab.
44
+ add_filter( 'debug_information', array( $this, 'info_options' ), 15 );
45
+ add_filter( 'debug_information', array( $this, 'info_languages' ), 15 );
46
+
47
+ // Tests Tab.
48
+ add_filter( 'site_status_tests', array( $this, 'status_tests' ) );
49
+ }
50
+
51
+ /**
52
+ * Returns a list of keys to exclude from the site health information.
53
+ *
54
+ * @since 2.8
55
+ *
56
+ * @return array List of option keys to ignore.
57
+ */
58
+ protected function exclude_options_keys() {
59
+ return array(
60
+ 'uninstall',
61
+ 'first_activation',
62
+ );
63
+ }
64
+
65
+ /**
66
+ * Returns a list of keys to exclude from the site health information.
67
+ *
68
+ * @since 2.8
69
+ *
70
+ * @return array List of language keys to ignore.
71
+ */
72
+ protected function exclude_language_keys() {
73
+ return array(
74
+ 'flag',
75
+ 'host',
76
+ 'taxonomy',
77
+ 'description',
78
+ 'parent',
79
+ 'filter',
80
+ 'custom_flag',
81
+ );
82
+ }
83
+
84
+ /**
85
+ * Formats an array with language as keys to display in options information.
86
+ *
87
+ * @since 2.8
88
+ *
89
+ * @param array $array An array with language as keys.
90
+ * @return string
91
+ */
92
+ protected function format_array_with_languages( $array ) {
93
+ array_walk(
94
+ $array,
95
+ function ( &$value, $key ) {
96
+ $value = "$key => $value";
97
+ }
98
+ );
99
+
100
+ return implode( ' | ', $array );
101
+ }
102
+
103
+ /**
104
+ * Add Polylang Options to Site Health Informations tab.
105
+ *
106
+ * @since 2.8
107
+ *
108
+ * @param array $debug_info The debug information to be added to the core information page.
109
+ * @return array
110
+ */
111
+ public function info_options( $debug_info ) {
112
+ $fields = array();
113
+ foreach ( $this->model->options as $key => $value ) {
114
+ if ( in_array( $key, $this->exclude_options_keys() ) ) {
115
+ continue;
116
+ }
117
+
118
+ if ( ! is_array( $value ) ) {
119
+ if ( empty( $value ) ) {
120
+ $value = '0';
121
+ }
122
+
123
+ $fields[ $key ]['label'] = $key;
124
+ $fields[ $key ]['value'] = $value;
125
+ } elseif ( empty( $value ) ) {
126
+ $fields[ $key ]['label'] = $key;
127
+ $fields[ $key ]['value'] = '0';
128
+ } else {
129
+ switch ( $key ) {
130
+ case 'post_types':
131
+ $fields[ $key ]['label'] = $key;
132
+ $fields[ $key ]['value'] = implode( ', ', $this->model->get_translated_post_types() );
133
+ break;
134
+ case 'taxonomies':
135
+ $fields[ $key ]['label'] = $key;
136
+ $fields[ $key ]['value'] = implode( ', ', $this->model->get_translated_taxonomies() );
137
+ break;
138
+ case 'domains':
139
+ $fields[ $key ]['label'] = $key;
140
+ $fields[ $key ]['value'] = $this->format_array_with_languages( $value );
141
+ break;
142
+ case 'nav_menus':
143
+ $current_theme = get_stylesheet();
144
+ if ( isset( $value[ $current_theme ] ) ) {
145
+ foreach ( $value[ $current_theme ] as $location => $lang ) {
146
+ /* translators: placeholder is the menu location name */
147
+ $fields[ $location ]['label'] = sprintf( 'menu: %s', $location );
148
+ $fields[ $location ]['value'] = $this->format_array_with_languages( $lang );
149
+ }
150
+ }
151
+ break;
152
+ case 'media':
153
+ foreach ( $value as $sub_key => $sub_value ) {
154
+ $fields[ "$key-$sub_key" ]['label'] = "$key $sub_key";
155
+ $fields[ "$key-$sub_key" ]['value'] = $sub_value;
156
+ }
157
+ break;
158
+ default:
159
+ $fields[ $key ]['label'] = $key;
160
+ $fields[ $key ]['value'] = implode( ', ', $value );
161
+ break;
162
+ }
163
+ }
164
+ }
165
+
166
+ $debug_info['pll_options'] = array(
167
+ /* translators: placeholder is the plugin name */
168
+ 'label' => sprintf( esc_html__( '%s Options', 'polylang' ), POLYLANG ),
169
+ 'fields' => $fields,
170
+ );
171
+
172
+ return $debug_info;
173
+ }
174
+
175
+ /**
176
+ * Add Polylang Languages settings to Site Health Informations tab.
177
+ *
178
+ * @since 2.8
179
+ *
180
+ * @param array $debug_info The debug information to be added to the core information page.
181
+ * @return array
182
+ */
183
+ public function info_languages( $debug_info ) {
184
+ foreach ( $this->model->get_languages_list() as $language ) {
185
+ $fields = array();
186
+
187
+ foreach ( $language as $key => $value ) {
188
+ if ( in_array( $key, $this->exclude_language_keys(), true ) ) {
189
+ continue;
190
+ }
191
+
192
+ if ( empty( $value ) ) {
193
+ $value = '0';
194
+ }
195
+
196
+ $fields[ $key ]['label'] = $key;
197
+ $fields[ $key ]['value'] = $value;
198
+
199
+ if ( 'term_group' === $key ) {
200
+ $fields[ $key ]['label'] = 'order'; // Changed for readability but not translated as other keys are not.
201
+ }
202
+ }
203
+
204
+ $debug_info[ 'pll_language_' . $language->slug ] = array(
205
+ /* translators: placeholder is the language name */
206
+ 'label' => sprintf( esc_html__( 'Language: %s', 'polylang' ), esc_html( $language->name ) ),
207
+ /* translators: placeholder is the flag image */
208
+ 'description' => sprintf( esc_html__( 'Flag used in the language switcher: %s', 'polylang' ), $this->get_flag( $language ) ),
209
+ 'fields' => $fields,
210
+ );
211
+ }
212
+
213
+ return $debug_info;
214
+ }
215
+
216
+ /**
217
+ * Returns the flag used in the language switcher.
218
+ *
219
+ * @since 2.8
220
+ *
221
+ * @param object $language Language object.
222
+ * @return string
223
+ */
224
+ protected function get_flag( $language ) {
225
+ $flag = $language->get_display_flag();
226
+ return empty( $flag ) ? '<span>' . esc_html__( 'Undefined', 'polylang' ) . '</span>' : $flag;
227
+ }
228
+
229
+ /**
230
+ * Add a Site Health test on homepage translation.
231
+ *
232
+ * @since 2.8
233
+ *
234
+ * @param array $tests Array with tests declaration data.
235
+ * @return array
236
+ */
237
+ public function status_tests( $tests ) {
238
+ // Add the test only if the homepage displays static page.
239
+ if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) {
240
+ $tests['direct']['pll_homepage'] = array(
241
+ 'label' => esc_html__( 'Homepage translated', 'polylang' ),
242
+ 'test' => array( $this, 'homepage_test' ),
243
+ );
244
+ }
245
+ return $tests;
246
+ }
247
+
248
+ /**
249
+ * Test if the home page is translated or not.
250
+ *
251
+ * @since 2.8
252
+ *
253
+ * @return array $result Array with test results.
254
+ */
255
+ public function homepage_test() {
256
+ $result = array(
257
+ 'label' => esc_html__( 'All languages have a translated homepage', 'polylang' ),
258
+ 'status' => 'good',
259
+ 'badge' => array(
260
+ 'label' => POLYLANG,
261
+ 'color' => 'blue',
262
+ ),
263
+ 'description' => sprintf(
264
+ '<p>%s</p>',
265
+ esc_html__( 'It is mandatory to translate the static front page in all languages.', 'polylang' )
266
+ ),
267
+ 'actions' => '',
268
+ 'test' => 'pll_homepage',
269
+ );
270
+
271
+ $message = $this->static_pages->get_must_translate_message();
272
+
273
+ if ( ! empty( $message ) ) {
274
+ $result['status'] = 'critical';
275
+ $result['label'] = esc_html__( 'The homepage is not translated in all languages', 'polylang' );
276
+ $result['description'] = sprintf( '<p>%s</p>', $message );
277
+ }
278
+ return $result;
279
+ }
280
+ }
modules/site-health/load.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the site health.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly.
10
+ };
11
+
12
+ if ( $polylang instanceof PLL_Admin ) {
13
+ $polylang->site_health = new PLL_Admin_Site_Health( $polylang );
14
+ }
modules/sitemaps/load.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Don't access directly.
8
+ };
9
+
10
+ if ( $polylang->model->get_languages_list() ) {
11
+ $polylang->sitemaps = new PLL_Sitemaps( $polylang );
12
+ $polylang->sitemaps->init();
13
+ }
modules/sitemaps/multilingual-sitemaps-provider.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Decorator to add multilingual capability to sitemaps providers
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_Multilingual_Sitemaps_Provider extends WP_Sitemaps_Provider {
12
+ /**
13
+ * The decorated sitemaps provider.
14
+ *
15
+ * @since 2.8
16
+ *
17
+ * @var WP_Sitemaps_Provider
18
+ */
19
+ protected $provider;
20
+
21
+ /**
22
+ * The PLL_Links_Model instance.
23
+ *
24
+ * @since 2.8
25
+ *
26
+ * @var PLL_Links_Model
27
+ */
28
+ protected $links_model;
29
+
30
+ /**
31
+ * The PLL_Model instance.
32
+ *
33
+ * @since 2.8
34
+ *
35
+ * @var PLL_Model
36
+ */
37
+ protected $model;
38
+
39
+
40
+ /**
41
+ * Language used to filter queries for the sitemap index.
42
+ *
43
+ * @since 2.8
44
+ *
45
+ * @var string
46
+ */
47
+ private static $filter_lang = '';
48
+
49
+ /**
50
+ * Constructor.
51
+ *
52
+ * @since 2.8
53
+ *
54
+ * @param WP_Sitemaps_Provider $provider An instance of a WP_Sitemaps_Provider child class.
55
+ * @param PLL_Links_Model $links_model The PLL_Links_Model instance.
56
+ */
57
+ public function __construct( $provider, &$links_model ) {
58
+ $this->name = $provider->name;
59
+ $this->object_type = $provider->object_type;
60
+
61
+ $this->provider = $provider;
62
+ $this->links_model = &$links_model;
63
+ $this->model = &$links_model->model;
64
+ }
65
+
66
+ /**
67
+ * Gets a URL list for a sitemap.
68
+ *
69
+ * @since 2.8
70
+ *
71
+ * @param int $page_num Page of results.
72
+ * @param string $object_subtype Optional. Object subtype name. Default empty.
73
+ * @return array Array of URLs for a sitemap.
74
+ */
75
+ public function get_url_list( $page_num, $object_subtype = '' ) {
76
+ return $this->provider->get_url_list( $page_num, $object_subtype );
77
+ }
78
+
79
+ /**
80
+ * Gets the max number of pages available for the object type.
81
+ *
82
+ * @since 2.8
83
+ *
84
+ * @param string $object_subtype Optional. Object subtype. Default empty.
85
+ * @return int Total number of pages.
86
+ */
87
+ public function get_max_num_pages( $object_subtype = '' ) {
88
+ return $this->provider->get_max_num_pages( $object_subtype );
89
+ }
90
+
91
+ /**
92
+ * Filters the query arguments to add the language.
93
+ *
94
+ * @since 2.8
95
+ *
96
+ * @param array $args Sitemap provider WP_Query or WP_Term_Query arguments.
97
+ * @return array
98
+ */
99
+ public static function query_args( $args ) {
100
+ if ( ! empty( self::$filter_lang ) ) {
101
+ $args['lang'] = self::$filter_lang;
102
+ }
103
+ return $args;
104
+ }
105
+
106
+ /**
107
+ * Gets data for a given sitemap type.
108
+ *
109
+ * @since 2.8
110
+ *
111
+ * @param string $object_subtype_name Object subtype name if any.
112
+ * @param string $lang Optionnal language name.
113
+ * @return array
114
+ */
115
+ protected function get_sitemap_data( $object_subtype_name, $lang = '' ) {
116
+ $object_subtype_name = (string) $object_subtype_name;
117
+
118
+ if ( ! empty( $lang ) ) {
119
+ self::$filter_lang = $lang;
120
+ }
121
+
122
+ $return = array(
123
+ 'name' => implode( '-', array_filter( array( $object_subtype_name, $lang ) ) ),
124
+ 'pages' => $this->get_max_num_pages( $object_subtype_name ),
125
+ );
126
+
127
+ self::$filter_lang = '';
128
+ return $return;
129
+ }
130
+
131
+ /**
132
+ * Gets data about each sitemap type.
133
+ *
134
+ * @since 2.8
135
+ *
136
+ * @return array[] Array of sitemap types including object subtype name and number of pages.
137
+ */
138
+ public function get_sitemap_type_data() {
139
+ $sitemap_data = array();
140
+
141
+ add_filter( 'wp_sitemaps_posts_query_args', array( __CLASS__, 'query_args' ) );
142
+ add_filter( 'wp_sitemaps_taxonomies_query_args', array( __CLASS__, 'query_args' ) );
143
+
144
+ $object_subtypes = $this->get_object_subtypes();
145
+
146
+ if ( empty( $object_subtypes ) ) {
147
+ foreach ( $this->model->get_languages_list( array( 'fields' => 'slug' ) ) as $language ) {
148
+ $sitemap_data[] = $this->get_sitemap_data( '', $language );
149
+ }
150
+ }
151
+
152
+ switch ( $this->provider->name ) {
153
+ case 'posts':
154
+ $func = array( $this->model, 'is_translated_post_type' );
155
+ break;
156
+ case 'taxonomies':
157
+ $func = array( $this->model, 'is_translated_taxonomy' );
158
+ break;
159
+ default:
160
+ return $sitemap_data;
161
+ }
162
+
163
+ foreach ( array_keys( $object_subtypes ) as $object_subtype_name ) {
164
+ if ( call_user_func( $func, $object_subtype_name ) ) {
165
+ foreach ( $this->model->get_languages_list( array( 'fields' => 'slug' ) ) as $language ) {
166
+ $sitemap_data[] = $this->get_sitemap_data( $object_subtype_name, $language );
167
+ }
168
+ } else {
169
+ $sitemap_data[] = $this->get_sitemap_data( $object_subtype_name );
170
+ }
171
+ }
172
+
173
+ return $sitemap_data;
174
+ }
175
+
176
+ /**
177
+ * Gets the URL of a sitemap entry.
178
+ *
179
+ * @since 2.8
180
+ *
181
+ * @param string $name The name of the sitemap.
182
+ * @param int $page The page of the sitemap.
183
+ * @return string The composed URL for a sitemap entry.
184
+ */
185
+ public function get_sitemap_url( $name, $page ) {
186
+ $pattern = '#(' . implode( '|', $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) . ')$#';
187
+ if ( preg_match( $pattern, $name, $matches ) ) {
188
+ $lang = $this->model->get_language( $matches[1] );
189
+ $name = preg_replace( '#(-?' . $lang->slug . ')$#', '', $name );
190
+ $url = $this->provider->get_sitemap_url( $name, $page );
191
+ $url = $this->links_model->add_language_to_link( $url, $lang );
192
+ } else {
193
+ // Untranslated post types and taxonomies.
194
+ $url = $this->provider->get_sitemap_url( $name, $page );
195
+ }
196
+
197
+ return $url;
198
+ }
199
+
200
+ /**
201
+ * Returns the list of supported object subtypes exposed by the provider.
202
+ *
203
+ * @since 2.8
204
+ *
205
+ * @return array List of object subtypes objects keyed by their name.
206
+ */
207
+ public function get_object_subtypes() {
208
+ return $this->provider->get_object_subtypes();
209
+ }
210
+ }
modules/sitemaps/sitemaps.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
+ /**
7
+ * Handles the core sitemaps.
8
+ *
9
+ * @since 2.8
10
+ */
11
+ class PLL_Sitemaps {
12
+ /**
13
+ * A reference to the current language.
14
+ *
15
+ * @since 2.8
16
+ *
17
+ * @var PLL_Language
18
+ */
19
+ protected $curlang;
20
+
21
+ /**
22
+ * A reference to the PLL_Links_Model instance.
23
+ *
24
+ * @since 2.8
25
+ *
26
+ * @var PLL_Links_Model
27
+ */
28
+ protected $links_model;
29
+
30
+ /**
31
+ * A reference to the PLL_Model instance.
32
+ *
33
+ * @since 2.8
34
+ *
35
+ * @var PLL_Model
36
+ */
37
+ protected $model;
38
+
39
+ /**
40
+ * Stores the plugin options.
41
+ *
42
+ * @var array
43
+ */
44
+ protected $options;
45
+
46
+ /**
47
+ * Constructor.
48
+ *
49
+ * @since 2.8
50
+ *
51
+ * @param object $polylang Main Polylang object.
52
+ */
53
+ public function __construct( &$polylang ) {
54
+ $this->curlang = &$polylang->curlang;
55
+ $this->links_model = &$polylang->links_model;
56
+ $this->model = &$polylang->model;
57
+ $this->options = &$polylang->options;
58
+ }
59
+
60
+ /**
61
+ * Setups actions and filters.
62
+ *
63
+ * @since 2.8
64
+ */
65
+ public function init() {
66
+ add_filter( 'pll_home_url_white_list', array( $this, 'home_url_white_list' ) );
67
+
68
+ if ( $this->options['force_lang'] < 2 ) {
69
+ add_filter( 'pll_set_language_from_query', array( $this, 'set_language_from_query' ), 10, 2 );
70
+ add_filter( 'rewrite_rules_array', array( $this, 'rewrite_rules' ) );
71
+ add_filter( 'wp_sitemaps_add_provider', array( $this, 'replace_provider' ) );
72
+ } else {
73
+ add_filter( 'wp_sitemaps_index_entry', array( $this, 'index_entry' ) );
74
+ add_filter( 'wp_sitemaps_stylesheet_url', array( $this->links_model, 'site_url' ) );
75
+ add_filter( 'wp_sitemaps_stylesheet_index_url', array( $this->links_model, 'site_url' ) );
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Assigns the current language to the default language when the sitemap url
81
+ * doesn't include any language.
82
+ *
83
+ * @since 2.8
84
+ *
85
+ * @param string|bool $lang Current language code, false if not set yet.
86
+ * @param object $query Main WP query object.
87
+ * @return string|bool
88
+ */
89
+ public function set_language_from_query( $lang, $query ) {
90
+ if ( isset( $query->query['sitemap'] ) && empty( $query->query['lang'] ) ) {
91
+ $lang = $this->options['default_lang'];
92
+ }
93
+ return $lang;
94
+ }
95
+
96
+ /**
97
+ * Whitelists the home url filter for the sitemaps
98
+ *
99
+ * @since 2.8
100
+ *
101
+ * @param array $whitelist White list.
102
+ * @return array;
103
+ */
104
+ public function home_url_white_list( $whitelist ) {
105
+ $whitelist[] = array( 'file' => 'class-wp-sitemaps-posts' );
106
+ return $whitelist;
107
+ }
108
+
109
+ /**
110
+ * Filters the sitemaps rewrite rules to take the languages into account.
111
+ *
112
+ * @since 2.8
113
+ *
114
+ * @param array $rules Rewrite rules.
115
+ * @return array
116
+ */
117
+ public function rewrite_rules( $rules ) {
118
+ global $wp_rewrite;
119
+
120
+ $newrules = array();
121
+
122
+ $languages = $this->model->get_languages_list( array( 'fields' => 'slug' ) );
123
+ if ( $this->options['hide_default'] ) {
124
+ $languages = array_diff( $languages, array( $this->options['default_lang'] ) );
125
+ }
126
+
127
+ if ( ! empty( $languages ) ) {
128
+ $slug = $wp_rewrite->root . ( $this->options['rewrite'] ? '^' : '^language/' ) . '(' . implode( '|', $languages ) . ')/';
129
+ }
130
+
131
+ foreach ( $rules as $key => $rule ) {
132
+ if ( false !== strpos( $rule, 'sitemap=$matches[1]' ) ) {
133
+ $newrules[ str_replace( '^wp-sitemap', $slug . 'wp-sitemap', $key ) ] = str_replace(
134
+ array( '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?' ),
135
+ array( '[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&' ),
136
+ $rule
137
+ ); // Should be enough!
138
+ }
139
+
140
+ $newrules[ $key ] = $rule;
141
+ }
142
+ return $newrules;
143
+ }
144
+
145
+ /**
146
+ * Replaces a sitemap provider by our decorator.
147
+ *
148
+ * @since 2.8
149
+ *
150
+ * @param WP_Sitemaps_Provider $provider Instance of a WP_Sitemaps_Provider.
151
+ * @return WP_Sitemaps_Provider
152
+ */
153
+ public function replace_provider( $provider ) {
154
+ if ( $provider instanceof WP_Sitemaps_Provider ) {
155
+ $provider = new PLL_Multilingual_Sitemaps_Provider( $provider, $this->links_model );
156
+ }
157
+ return $provider;
158
+ }
159
+
160
+ /**
161
+ * Filters the sitemap index entries for subdomains and multiple domains.
162
+ *
163
+ * @since 2.8
164
+ *
165
+ * @param array $sitemap_entry Sitemap entry for the post.
166
+ * return array
167
+ */
168
+ public function index_entry( $sitemap_entry ) {
169
+ $sitemap_entry['loc'] = $this->links_model->site_url( $sitemap_entry['loc'] );
170
+ return $sitemap_entry;
171
+ }
172
+ }
modules/sync/admin-sync.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages copy and synchronization of terms and post metas
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages copy and synchronization of terms and post metas
modules/sync/load.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the module for general synchronization such as metas and taxonomies.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly
10
+ };
11
+
12
+ if ( $polylang->model->get_languages_list() ) {
13
+ if ( $polylang instanceof PLL_Admin_Base ) {
14
+ $polylang->sync = new PLL_Admin_Sync( $polylang );
15
+ } else {
16
+ $polylang->sync = new PLL_Sync( $polylang );
17
+ }
18
+
19
+ add_filter(
20
+ 'pll_settings_modules',
21
+ function( $modules ) {
22
+ $modules[] = 'PLL_Settings_Sync';
23
+ return $modules;
24
+ }
25
+ );
26
+ }
modules/sync/settings-sync.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Settings class for synchronization settings management
@@ -6,6 +9,12 @@
6
  * @since 1.8
7
  */
8
  class PLL_Settings_Sync extends PLL_Settings_Module {
 
 
 
 
 
 
9
 
10
  /**
11
  * Constructor
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Settings class for synchronization settings management
9
  * @since 1.8
10
  */
11
  class PLL_Settings_Sync extends PLL_Settings_Module {
12
+ /**
13
+ * Stores the display order priority.
14
+ *
15
+ * @var int
16
+ */
17
+ public $priority = 50;
18
 
19
  /**
20
  * Constructor
modules/sync/sync-metas.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Abstract class to manage the copy and synchronization of metas
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Abstract class to manage the copy and synchronization of metas
modules/sync/sync-post-metas.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to manage copy and synchronization of post metas
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to manage copy and synchronization of post metas
modules/sync/sync-tax.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to manage the sychronization of taxonomy terms across posts translations
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to manage the sychronization of taxonomy terms across posts translations
modules/sync/sync-term-metas.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to manage copy and synchronization of term metas
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to manage copy and synchronization of term metas
modules/sync/sync.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Manages copy and synchronization of terms and post metas on front
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Manages copy and synchronization of terms and post metas on front
modules/translate-slugs/load.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the settings module for translated slugs.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly
10
+ };
11
+
12
+ if ( $polylang->model->get_languages_list() ) {
13
+ add_filter(
14
+ 'pll_settings_modules',
15
+ function( $modules ) {
16
+ $modules[] = 'PLL_Settings_Translate_Slugs';
17
+ return $modules;
18
+ }
19
+ );
20
+ }
modules/translate-slugs/settings-translate-slugs.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Settings class to advertize the Translate slugs module
@@ -6,6 +9,13 @@
6
  * @since 1.9
7
  */
8
  class PLL_Settings_Translate_Slugs extends PLL_Settings_Module {
 
 
 
 
 
 
 
9
  /**
10
  * Constructor
11
  *
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Settings class to advertize the Translate slugs module
9
  * @since 1.9
10
  */
11
  class PLL_Settings_Translate_Slugs extends PLL_Settings_Module {
12
+ /**
13
+ * Stores the display order priority.
14
+ *
15
+ * @var int
16
+ */
17
+ public $priority = 80;
18
+
19
  /**
20
  * Constructor
21
  *
modules/wizard/html-wizard-notice.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
2
-
3
  /**
4
  * Displays the wizard notice content
5
  *
 
 
6
  * @since 2.7
7
  */
8
 
1
  <?php
 
2
  /**
3
  * Displays the wizard notice content
4
  *
5
+ * @package Polylang
6
+ *
7
  * @since 2.7
8
  */
9
 
modules/wizard/js/languages-step.js CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  jQuery( document ).ready(
2
  function( $ ) {
3
  var addLanguageForm = $( '.languages-step' ); // Form element.
1
+ /**
2
+ * @package Polylang
3
+ */
4
+
5
  jQuery( document ).ready(
6
  function( $ ) {
7
  var addLanguageForm = $( '.languages-step' ); // Form element.
modules/wizard/load.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the setup wizard.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly
10
+ };
11
+
12
+ if ( $polylang instanceof PLL_Admin_Base ) {
13
+ $polylang->wizard = new PLL_Wizard( $polylang );
14
+ }
modules/wizard/view-wizard-page.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
2
-
3
  /**
4
  * Displays the wizard
5
  *
 
 
6
  * @since 2.7
7
  */
8
 
1
  <?php
 
2
  /**
3
  * Displays the wizard
4
  *
5
+ * @package Polylang
6
+ *
7
  * @since 2.7
8
  */
9
 
modules/wizard/view-wizard-step-home-page.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
2
-
3
  /**
4
  * Displays the wizard home page step
5
  *
 
 
6
  * @since 2.7
7
  */
8
 
1
  <?php
 
2
  /**
3
  * Displays the wizard home page step
4
  *
5
+ * @package Polylang
6
+ *
7
  * @since 2.7
8
  */
9
 
modules/wizard/view-wizard-step-languages.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
2
-
3
  /**
4
  * Displays the wizard languages step
5
  *
 
 
6
  * @since 2.7
7
  */
8
 
1
  <?php
 
2
  /**
3
  * Displays the wizard languages step
4
  *
5
+ * @package Polylang
6
+ *
7
  * @since 2.7
8
  */
9
 
modules/wizard/view-wizard-step-last.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
2
-
3
  /**
4
  * Displays the wizard last step
5
  *
 
 
6
  * @since 2.7
7
  */
8
 
1
  <?php
 
2
  /**
3
  * Displays the wizard last step
4
  *
5
+ * @package Polylang
6
+ *
7
  * @since 2.7
8
  */
9
 
modules/wizard/view-wizard-step-licenses.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
2
-
3
  /**
4
  * Displays the wizard licenses step
5
  *
 
 
6
  * @since 2.7
7
  */
8
 
1
  <?php
 
2
  /**
3
  * Displays the wizard licenses step
4
  *
5
+ * @package Polylang
6
+ *
7
  * @since 2.7
8
  */
9
 
modules/wizard/view-wizard-step-media.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
2
-
3
  /**
4
  * Displays the wizard media step
5
  *
 
 
6
  * @since 2.7
7
  */
8
 
1
  <?php
 
2
  /**
3
  * Displays the wizard media step
4
  *
5
+ * @package Polylang
6
+ *
7
  * @since 2.7
8
  */
9
 
modules/wizard/view-wizard-step-untranslated-contents.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
2
-
3
  /**
4
  * Displays the wizard unstranslated content step
5
  *
 
 
6
  * @since 2.7
7
  */
8
 
1
  <?php
 
2
  /**
3
  * Displays the wizard unstranslated content step
4
  *
5
+ * @package Polylang
6
+ *
7
  * @since 2.7
8
  */
9
 
modules/wizard/wizard.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Main class for Polylang wizard.
4
  *
@@ -230,7 +234,7 @@ class PLL_Wizard {
230
  */
231
  public function wizard_notice() {
232
  ob_start();
233
- include PLL_MODULES_INC . '/wizard/html-wizard-notice.php';
234
  return ob_get_clean();
235
  }
236
 
@@ -241,7 +245,7 @@ class PLL_Wizard {
241
  */
242
  public function display_wizard_page() {
243
  set_current_screen();
244
- include PLL_MODULES_INC . '/wizard/view-wizard-page.php';
245
  }
246
 
247
  /**
@@ -347,7 +351,7 @@ class PLL_Wizard {
347
  * @since 2.7
348
  */
349
  public function display_step_licenses() {
350
- include PLL_MODULES_INC . '/wizard/view-wizard-step-licenses.php';
351
  }
352
 
353
  /**
@@ -458,7 +462,7 @@ class PLL_Wizard {
458
  * @since 2.7
459
  */
460
  public function display_step_languages() {
461
- include PLL_MODULES_INC . '/wizard/view-wizard-step-languages.php';
462
  }
463
 
464
  /**
@@ -471,7 +475,7 @@ class PLL_Wizard {
471
 
472
  $existing_languages = $this->model->get_languages_list();
473
 
474
- $all_languages = include PLL_SETTINGS_INC . '/languages.php';
475
  $languages = isset( $_POST['languages'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['languages'] ) ) : false;
476
  $saved_languages = array();
477
 
@@ -565,7 +569,7 @@ class PLL_Wizard {
565
  * @since 2.7
566
  */
567
  public function display_step_media() {
568
- include PLL_MODULES_INC . '/wizard/view-wizard-step-media.php';
569
  }
570
 
571
  /**
@@ -614,7 +618,7 @@ class PLL_Wizard {
614
  * @since 2.7
615
  */
616
  public function display_step_untranslated_contents() {
617
- include PLL_MODULES_INC . '/wizard/view-wizard-step-untranslated-contents.php';
618
  }
619
 
620
  /**
@@ -677,7 +681,7 @@ class PLL_Wizard {
677
  * @since 2.7
678
  */
679
  public function display_step_home_page() {
680
- include PLL_MODULES_INC . '/wizard/view-wizard-step-home-page.php';
681
  }
682
 
683
  /**
@@ -767,7 +771,7 @@ class PLL_Wizard {
767
  public function display_step_last() {
768
  // We ran the wizard once. So we can dismiss its notice.
769
  PLL_Admin_Notices::dismiss( 'wizard' );
770
- include PLL_MODULES_INC . '/wizard/view-wizard-step-last.php';
771
  }
772
 
773
  /**
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
+
6
  /**
7
  * Main class for Polylang wizard.
8
  *
234
  */
235
  public function wizard_notice() {
236
  ob_start();
237
+ include __DIR__ . '/html-wizard-notice.php';
238
  return ob_get_clean();
239
  }
240
 
245
  */
246
  public function display_wizard_page() {
247
  set_current_screen();
248
+ include __DIR__ . '/view-wizard-page.php';
249
  }
250
 
251
  /**
351
  * @since 2.7
352
  */
353
  public function display_step_licenses() {
354
+ include __DIR__ . '/view-wizard-step-licenses.php';
355
  }
356
 
357
  /**
462
  * @since 2.7
463
  */
464
  public function display_step_languages() {
465
+ include __DIR__ . '/view-wizard-step-languages.php';
466
  }
467
 
468
  /**
475
 
476
  $existing_languages = $this->model->get_languages_list();
477
 
478
+ $all_languages = include POLYLANG_DIR . '/settings/languages.php';
479
  $languages = isset( $_POST['languages'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['languages'] ) ) : false;
480
  $saved_languages = array();
481
 
569
  * @since 2.7
570
  */
571
  public function display_step_media() {
572
+ include __DIR__ . '/view-wizard-step-media.php';
573
  }
574
 
575
  /**
618
  * @since 2.7
619
  */
620
  public function display_step_untranslated_contents() {
621
+ include __DIR__ . '/view-wizard-step-untranslated-contents.php';
622
  }
623
 
624
  /**
681
  * @since 2.7
682
  */
683
  public function display_step_home_page() {
684
+ include __DIR__ . '/view-wizard-step-home-page.php';
685
  }
686
 
687
  /**
771
  public function display_step_last() {
772
  // We ran the wizard once. So we can dismiss its notice.
773
  PLL_Admin_Notices::dismiss( 'wizard' );
774
+ include __DIR__ . '/view-wizard-step-last.php';
775
  }
776
 
777
  /**
modules/wpml/load.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loads the WPML compatibility mode.
4
+ *
5
+ * @package Polylang
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Don't access directly
10
+ };
11
+
12
+ if ( $polylang->model->get_languages_list() ) {
13
+ if ( ! defined( 'PLL_WPML_COMPAT' ) || PLL_WPML_COMPAT ) {
14
+ PLL_WPML_Compat::instance(); // WPML API
15
+ PLL_WPML_Config::instance(); // wpml-config.xml
16
+ }
17
+
18
+ add_filter(
19
+ 'pll_settings_modules',
20
+ function( $modules ) {
21
+ $modules[] = 'PLL_Settings_WPML';
22
+ return $modules;
23
+ }
24
+ );
25
+ }
modules/wpml/settings-wpml.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to inform about the WPML compatibility module in Polylang settings
@@ -6,6 +9,12 @@
6
  * @since 1.8
7
  */
8
  class PLL_Settings_WPML extends PLL_Settings_Module {
 
 
 
 
 
 
9
 
10
  /**
11
  * Constructor
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to inform about the WPML compatibility module in Polylang settings
9
  * @since 1.8
10
  */
11
  class PLL_Settings_WPML extends PLL_Settings_Module {
12
+ /**
13
+ * Stores the display order priority.
14
+ *
15
+ * @var int
16
+ */
17
+ public $priority = 60;
18
 
19
  /**
20
  * Constructor
modules/wpml/wpml-api.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to handle the WPML API based on hooks, introduced since WPML 3.2
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to handle the WPML API based on hooks, introduced since WPML 3.2
modules/wpml/wpml-compat.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * WPML Compatibility class
@@ -19,7 +22,7 @@ class PLL_WPML_Compat {
19
  */
20
  protected function __construct() {
21
  // Load the WPML API
22
- require_once PLL_MODULES_INC . '/wpml/wpml-legacy-api.php';
23
  $this->api = new PLL_WPML_API();
24
 
25
  self::$strings = get_option( 'polylang_wpml_strings', array() );
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * WPML Compatibility class
22
  */
23
  protected function __construct() {
24
  // Load the WPML API
25
+ require_once __DIR__ . '/wpml-legacy-api.php';
26
  $this->api = new PLL_WPML_API();
27
 
28
  self::$strings = get_option( 'polylang_wpml_strings', array() );
modules/wpml/wpml-config.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Reads and interprets the file wpml-config.xml
@@ -80,11 +83,16 @@ class PLL_WPML_Config {
80
  foreach ( $xml->xpath( 'admin-texts/key' ) as $key ) {
81
  $attributes = $key->attributes();
82
  $name = (string) $attributes['name'];
83
- if ( PLL() instanceof PLL_Frontend ) {
84
- $this->options[ $name ] = $key;
85
- add_filter( 'option_' . $name, array( $this, 'translate_strings' ) );
 
 
 
 
 
86
  } else {
87
- $this->register_string_recursive( $context, $name, get_option( $name ), $key );
88
  }
89
  }
90
  }
@@ -183,6 +191,24 @@ class PLL_WPML_Config {
183
  return $taxonomies;
184
  }
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  /**
187
  * Translates the strings for an option
188
  *
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Reads and interprets the file wpml-config.xml
83
  foreach ( $xml->xpath( 'admin-texts/key' ) as $key ) {
84
  $attributes = $key->attributes();
85
  $name = (string) $attributes['name'];
86
+
87
+ if ( false !== strpos( $name, '*' ) ) {
88
+ $pattern = '#^' . str_replace( '*', '(?:.+)', $name ) . '$#';
89
+ $names = preg_grep( $pattern, array_keys( wp_load_alloptions() ) );
90
+
91
+ foreach ( $names as $_name ) {
92
+ $this->register_or_translate_option( $context, $_name, $key );
93
+ }
94
  } else {
95
+ $this->register_or_translate_option( $context, $name, $key );
96
  }
97
  }
98
  }
191
  return $taxonomies;
192
  }
193
 
194
+ /**
195
+ * Registers or translates the strings for an option
196
+ *
197
+ * @since 2.8
198
+ *
199
+ * @param string $context The group in which the strings will be registered.
200
+ * @param string $name Option name.
201
+ * @param object $key XML node.
202
+ */
203
+ protected function register_or_translate_option( $context, $name, $key ) {
204
+ if ( PLL() instanceof PLL_Frontend ) {
205
+ $this->options[ $name ] = $key;
206
+ add_filter( 'option_' . $name, array( $this, 'translate_strings' ) );
207
+ } else {
208
+ $this->register_string_recursive( $context, $name, get_option( $name ), $key );
209
+ }
210
+ }
211
+
212
  /**
213
  * Translates the strings for an option
214
  *
modules/wpml/wpml-legacy-api.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Compatibility with WPML legacy API
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Compatibility with WPML legacy API
polylang.php CHANGED
@@ -1,21 +1,25 @@
1
  <?php
2
-
3
  /**
4
- * Plugin Name: Polylang
5
- * Plugin URI: https://polylang.pro
6
- * Description: Adds multilingual capability to WordPress
7
- * Version: 2.7.4
 
 
 
 
 
 
 
8
  * Requires at least: 4.9
9
- * Requires PHP: 5.6
10
- * Author: WP SYNTEX
11
- * Author uri: https://polylang.pro
12
- * License: GPL v3 or later
13
- * License URI: https://www.gnu.org/licenses/gpl-3.0.html
14
- * Text Domain: polylang
15
- * Domain Path: /languages
16
- */
17
-
18
- /*
19
  * Copyright 2011-2019 Frédéric Demarle
20
  * Copyright 2019-2020 WP SYNTEX
21
  *
@@ -34,48 +38,35 @@
34
  */
35
 
36
  if ( ! defined( 'ABSPATH' ) ) {
37
- exit; // don't access directly
38
  };
39
 
40
- if ( defined( 'POLYLANG_BASENAME' ) ) {
41
- // The user is attempting to activate a second plugin instance, typically Polylang and Polylang Pro
42
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
43
- if ( defined( 'POLYLANG_PRO' ) ) {
44
- // Polylang Pro is already activated
45
- if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) {
46
- require_once ABSPATH . 'wp-includes/pluggable.php';
47
- deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate this plugin
48
- // WP does not allow us to send a custom meaningful message, so just tell the plugin has been deactivated
49
- wp_safe_redirect( add_query_arg( 'deactivate', 'true', remove_query_arg( 'activate' ) ) );
50
- exit;
51
- }
52
- } else {
53
- // Polylang was activated, deactivate it to keep only what we expect to be Polylang Pro
54
- deactivate_plugins( POLYLANG_BASENAME );
55
  }
56
  } else {
57
  // Go on loading the plugin
58
- define( 'POLYLANG_VERSION', '2.7.4' );
59
  define( 'PLL_MIN_WP_VERSION', '4.9' );
60
  define( 'PLL_MIN_PHP_VERSION', '5.6' );
61
 
62
- define( 'POLYLANG_FILE', __FILE__ ); // this file
63
- define( 'POLYLANG_BASENAME', plugin_basename( POLYLANG_FILE ) ); // plugin name as known by WP
64
- define( 'POLYLANG_DIR', dirname( POLYLANG_FILE ) ); // our directory
65
- define( 'POLYLANG', ucwords( str_replace( '-', ' ', dirname( POLYLANG_BASENAME ) ) ) );
66
-
67
- define( 'PLL_ADMIN_INC', POLYLANG_DIR . '/admin' );
68
- define( 'PLL_FRONT_INC', POLYLANG_DIR . '/frontend' );
69
- define( 'PLL_INC', POLYLANG_DIR . '/include' );
70
- define( 'PLL_INSTALL_INC', POLYLANG_DIR . '/install' );
71
- define( 'PLL_MODULES_INC', POLYLANG_DIR . '/modules' );
72
- define( 'PLL_SETTINGS_INC', POLYLANG_DIR . '/settings' );
73
- define( 'PLL_PREFIX', 'pll_' );
74
 
75
- if ( file_exists( PLL_MODULES_INC . '/pro.php' ) ) {
76
- define( 'POLYLANG_PRO', true );
 
77
  }
78
 
79
- require_once PLL_INC . '/class-polylang.php';
 
 
80
  new Polylang();
81
  }
1
  <?php
 
2
  /**
3
+ * Polylang
4
+ *
5
+ * @package Polylang
6
+ * @author WP SYNTEX
7
+ * @license GPL-3.0-or-later
8
+ *
9
+ * @wordpress-plugin
10
+ * Plugin Name: Polylang
11
+ * Plugin URI: https://polylang.pro
12
+ * Description: Adds multilingual capability to WordPress
13
+ * Version: 2.8
14
  * Requires at least: 4.9
15
+ * Requires PHP: 5.6
16
+ * Author: WP SYNTEX
17
+ * Author URI: https://polylang.pro
18
+ * Text Domain: polylang
19
+ * Domain Path: /languages
20
+ * License: GPL v3 or later
21
+ * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
22
+ *
 
 
23
  * Copyright 2011-2019 Frédéric Demarle
24
  * Copyright 2019-2020 WP SYNTEX
25
  *
38
  */
39
 
40
  if ( ! defined( 'ABSPATH' ) ) {
41
+ exit; // Don't access directly.
42
  };
43
 
44
+ if ( defined( 'POLYLANG_VERSION' ) ) {
45
+ // The user is attempting to activate a second plugin instance, typically Polylang and Polylang Pro.
46
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
47
+ require_once ABSPATH . 'wp-includes/pluggable.php';
48
+ if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) {
49
+ deactivate_plugins( plugin_basename( __FILE__ ) ); // Deactivate this plugin.
50
+ // WP does not allow us to send a custom meaningful message, so just tell the plugin has been deactivated.
51
+ wp_safe_redirect( add_query_arg( 'deactivate', 'true', remove_query_arg( 'activate' ) ) );
52
+ exit;
 
 
 
 
 
 
53
  }
54
  } else {
55
  // Go on loading the plugin
56
+ define( 'POLYLANG_VERSION', '2.8' );
57
  define( 'PLL_MIN_WP_VERSION', '4.9' );
58
  define( 'PLL_MIN_PHP_VERSION', '5.6' );
59
 
60
+ define( 'POLYLANG_FILE', __FILE__ );
61
+ define( 'POLYLANG_DIR', __DIR__ );
 
 
 
 
 
 
 
 
 
 
62
 
63
+ if ( ! defined( 'POLYLANG_BASENAME' ) ) {
64
+ define( 'POLYLANG_BASENAME', plugin_basename( __FILE__ ) ); // Plugin name as known by WP.
65
+ require __DIR__ . '/vendor/autoload.php';
66
  }
67
 
68
+ define( 'POLYLANG', ucwords( str_replace( '-', ' ', dirname( POLYLANG_BASENAME ) ) ) );
69
+
70
+ require __DIR__ . '/include/class-polylang.php';
71
  new Polylang();
72
  }
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === Polylang ===
2
- Contributors: Chouby, manooweb, raaaahman, marianne38
3
  Donate link: https://polylang.pro
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.9
6
- Tested up to: 5.4
7
  Requires PHP: 5.6
8
- Stable tag: 2.7.4
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -78,7 +78,30 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
78
 
79
  == Changelog ==
80
 
81
- = 2.7.4 ( 2020-06-29) =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  * Pro: Allow using our /untranslated-posts REST endpoint for non-public post types
84
  * Pro: Fix broken display in the block editor sidebar when a language has no flag
1
  === Polylang ===
2
+ Contributors: Chouby, manooweb, raaaahman, marianne38, sebastienserre
3
  Donate link: https://polylang.pro
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.9
6
+ Tested up to: 5.5
7
  Requires PHP: 5.6
8
+ Stable tag: 2.8
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
78
 
79
  == Changelog ==
80
 
81
+ = 2.8 (2020-08-17) =
82
+
83
+ * Pro: Add a language switcher block
84
+ * Pro: Add compatibility with block image edition introduced in WP 5.5
85
+ * Pro: Fix our private taxonomies being displayed in the ACF field group rules.
86
+ * Pro: Fix incorrect flags loaded from the block editor
87
+ * Pro: Fix SSO causing a wrong redirect when using subdomains (introduced in 2.7.4)
88
+ * Pro: Fix a performance issue on the plugins list
89
+ * Pro: Fix option to automatically duplicate media in all languages when uploading a new file not honored in block image
90
+ * Use composer for autoload and Polylang Pro dependency on Polylang
91
+ * Display a flag for each post in the posts list tables (same for terms). #515
92
+ * Add test for the homepage translations to Site Health
93
+ * Add debug information to Site Health
94
+ * Add compatibility with the sitemaps introduced in WP 5.5 #451
95
+ * Always filter WP_Query by the current language
96
+ * Support wildcards in "admin-texts" parent keys in wpml-config.xml
97
+ * Fix sticky posts showed for all languages when the admin language filter is active #469
98
+ * Fix a performance issue on the pages list
99
+ * Fix dependency to jQuery Migrate removed from WP 5.5 #539
100
+ * Fix: output secure cookie when using a cache plugin and ssl #542
101
+ * Fix the possibility to create 2 terms with the same name in the same language, without specifying the second slug.
102
+ * Fix sticky posts appearing 2 times in WP 5.5
103
+
104
+ = 2.7.4 (2020-06-29) =
105
 
106
  * Pro: Allow using our /untranslated-posts REST endpoint for non-public post types
107
  * Pro: Fix broken display in the block editor sidebar when a language has no flag
settings/flags.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  if ( ! defined( 'ABSPATH' ) ) {
4
  exit; // Don't access directly
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  if ( ! defined( 'ABSPATH' ) ) {
7
  exit; // Don't access directly
settings/languages.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  if ( ! defined( 'ABSPATH' ) ) {
4
  exit; // Don't access directly
@@ -22,17 +25,29 @@ if ( ! defined( 'ABSPATH' ) ) {
22
  *
23
  * Facebook locales without equivalent WordPress locale:
24
  * 'ay_BO' (Aymara)
 
25
  * 'ck_US' (Cherokee)
26
  * 'en_IN' (English India)
27
  * 'gx_GR' (Classical Greek)
28
  * 'ig_NG' (Igbo)
 
 
29
  * 'ja_KS' (Japanese Kansai)
 
30
  * 'lg_UG' (Ganda)
31
  * 'nd_ZW' (Ndebele)
 
 
32
  * 'ny_MW' (Chewa)
 
33
  * 'qu_PE' (Quechua)
34
  * 'se_NO' (Northern Sami)
 
 
35
  * 'tl_ST' (Klingon)
 
 
 
36
  * 'wo_SN' (Wolof)
37
  * 'yi_DE' (Yiddish)
38
  * 'zu_ZA' (Zulu)
@@ -485,6 +500,9 @@ return array(
485
  'ga' => array(
486
  'facebook' => 'ga_IE',
487
  ),
 
 
 
488
  'gd' => array(
489
  'code' => 'gd',
490
  'locale' => 'gd',
@@ -511,6 +529,9 @@ return array(
511
  'flag' => 'in',
512
  'facebook' => 'gu_IN',
513
  ),
 
 
 
514
  'hau' => array(
515
  'facebook' => 'ha_NG',
516
  ),
@@ -987,6 +1008,7 @@ return array(
987
  'name' => 'Basa Sunda',
988
  'dir' => 'ltr',
989
  'flag' => 'id',
 
990
  ),
991
  'sv_SE' => array(
992
  'code' => 'sv',
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  if ( ! defined( 'ABSPATH' ) ) {
7
  exit; // Don't access directly
25
  *
26
  * Facebook locales without equivalent WordPress locale:
27
  * 'ay_BO' (Aymara)
28
+ * 'bp_IN' (Bhojpuri)
29
  * 'ck_US' (Cherokee)
30
  * 'en_IN' (English India)
31
  * 'gx_GR' (Classical Greek)
32
  * 'ig_NG' (Igbo)
33
+ * 'ik_US' (Inupiak)
34
+ * 'iu_CA' (Inuktitut)
35
  * 'ja_KS' (Japanese Kansai)
36
+ * 'ks_IN' (Cachemiri)
37
  * 'lg_UG' (Ganda)
38
  * 'nd_ZW' (Ndebele)
39
+ * 'nr_ZA' (Southern Ndebele)
40
+ * 'ns_ZA' (Northern Sotho)
41
  * 'ny_MW' (Chewa)
42
+ * 'qc_GT' (Quiché)
43
  * 'qu_PE' (Quechua)
44
  * 'se_NO' (Northern Sami)
45
+ * 'ss_SZ' (Swazi)
46
+ * 'st_ZA' (Southern Sotho)
47
  * 'tl_ST' (Klingon)
48
+ * 'tn_BW' (Tswana)
49
+ * 'ts_ZA' (Tsonga)
50
+ * 've_ZA' (Venda)
51
  * 'wo_SN' (Wolof)
52
  * 'yi_DE' (Yiddish)
53
  * 'zu_ZA' (Zulu)
500
  'ga' => array(
501
  'facebook' => 'ga_IE',
502
  ),
503
+ 'gax' => array(
504
+ 'facebook' => 'om_ET',
505
+ ),
506
  'gd' => array(
507
  'code' => 'gd',
508
  'locale' => 'gd',
529
  'flag' => 'in',
530
  'facebook' => 'gu_IN',
531
  ),
532
+ 'hat' => array(
533
+ 'facebook' => 'ht_HT',
534
+ ),
535
  'hau' => array(
536
  'facebook' => 'ha_NG',
537
  ),
1008
  'name' => 'Basa Sunda',
1009
  'dir' => 'ltr',
1010
  'flag' => 'id',
1011
+ 'facebook' => 'su_ID',
1012
  ),
1013
  'sv_SE' => array(
1014
  'code' => 'sv',
settings/settings-browser.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Settings class for browser language preference detection
@@ -6,6 +9,12 @@
6
  * @since 1.8
7
  */
8
  class PLL_Settings_Browser extends PLL_Settings_Module {
 
 
 
 
 
 
9
 
10
  /**
11
  * Constructor
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Settings class for browser language preference detection
9
  * @since 1.8
10
  */
11
  class PLL_Settings_Browser extends PLL_Settings_Module {
12
+ /**
13
+ * Stores the display order priority.
14
+ *
15
+ * @var int
16
+ */
17
+ public $priority = 20;
18
 
19
  /**
20
  * Constructor
settings/settings-cpt.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Settings class for custom post types and taxonomies language and translation management
@@ -6,7 +9,40 @@
6
  * @since 1.8
7
  */
8
  class PLL_Settings_CPT extends PLL_Settings_Module {
9
- private $post_types, $disabled_post_types, $taxonomies, $disabled_taxonomies;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  /**
12
  * Constructor
@@ -29,8 +65,8 @@ class PLL_Settings_CPT extends PLL_Settings_Module {
29
  /** This filter is documented in include/model.php */
30
  $this->post_types = array_unique( apply_filters( 'pll_get_post_types', $public_post_types, true ) );
31
 
32
- $programmatically_active_post_types = array_unique( apply_filters( 'pll_get_post_types', array(), false ) );
33
  /** This filter is documented in include/model.php */
 
34
  $this->disabled_post_types = array_intersect( $programmatically_active_post_types, $this->post_types );
35
 
36
  $public_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) );
@@ -38,8 +74,8 @@ class PLL_Settings_CPT extends PLL_Settings_Module {
38
  /** This filter is documented in include/model.php */
39
  $this->taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', $public_taxonomies, true ) );
40
 
41
- $programmatically_active_taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', array(), false ) );
42
  /** This filter is documented in include/model.php */
 
43
  $this->disabled_taxonomies = array_intersect( $programmatically_active_taxonomies, $this->taxonomies );
44
  }
45
 
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Settings class for custom post types and taxonomies language and translation management
9
  * @since 1.8
10
  */
11
  class PLL_Settings_CPT extends PLL_Settings_Module {
12
+ /**
13
+ * Stores the display order priority.
14
+ *
15
+ * @var int
16
+ */
17
+ public $priority = 40;
18
+
19
+ /**
20
+ * The list of post types to show in the form.
21
+ *
22
+ * @var array
23
+ */
24
+ private $post_types;
25
+
26
+ /**
27
+ * The list of post types to disable in the form.
28
+ *
29
+ * @var array
30
+ */
31
+ private $disabled_post_types;
32
+
33
+ /**
34
+ * The list of taxonomies to show in the form.
35
+ *
36
+ * @var array
37
+ */
38
+ private $taxonomies;
39
+
40
+ /**
41
+ * The list of taxonomies to disable in the form.
42
+ *
43
+ * @var array
44
+ */
45
+ private $disabled_taxonomies;
46
 
47
  /**
48
  * Constructor
65
  /** This filter is documented in include/model.php */
66
  $this->post_types = array_unique( apply_filters( 'pll_get_post_types', $public_post_types, true ) );
67
 
 
68
  /** This filter is documented in include/model.php */
69
+ $programmatically_active_post_types = array_unique( apply_filters( 'pll_get_post_types', array(), false ) );
70
  $this->disabled_post_types = array_intersect( $programmatically_active_post_types, $this->post_types );
71
 
72
  $public_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) );
74
  /** This filter is documented in include/model.php */
75
  $this->taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', $public_taxonomies, true ) );
76
 
 
77
  /** This filter is documented in include/model.php */
78
+ $programmatically_active_taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', array(), false ) );
79
  $this->disabled_taxonomies = array_intersect( $programmatically_active_taxonomies, $this->taxonomies );
80
  }
81
 
settings/settings-licenses.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Settings class for licenses
@@ -6,6 +9,18 @@
6
  * @since 1.9
7
  */
8
  class PLL_Settings_Licenses extends PLL_Settings_Module {
 
 
 
 
 
 
 
 
 
 
 
 
9
  protected $items;
10
 
11
  /**
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Settings class for licenses
9
  * @since 1.9
10
  */
11
  class PLL_Settings_Licenses extends PLL_Settings_Module {
12
+ /**
13
+ * Stores the display order priority.
14
+ *
15
+ * @var int
16
+ */
17
+ public $priority = 100;
18
+
19
+ /**
20
+ * Stores an array of PLL_License instances.
21
+ *
22
+ * @var array
23
+ */
24
  protected $items;
25
 
26
  /**
settings/settings-media.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Settings class for media language and translation management
@@ -6,6 +9,12 @@
6
  * @since 1.8
7
  */
8
  class PLL_Settings_Media extends PLL_Settings_Module {
 
 
 
 
 
 
9
 
10
  /**
11
  * Constructor
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Settings class for media language and translation management
9
  * @since 1.8
10
  */
11
  class PLL_Settings_Media extends PLL_Settings_Module {
12
+ /**
13
+ * Stores the display order priority.
14
+ *
15
+ * @var int
16
+ */
17
+ public $priority = 30;
18
 
19
  /**
20
  * Constructor
settings/settings-module.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * Base class for all settings
@@ -6,10 +9,83 @@
6
  * @since 1.8
7
  */
8
  class PLL_Settings_Module {
9
- public $active_option, $configure;
10
- public $module, $title, $description;
 
 
 
11
  public $options;
12
- protected $action_links, $buttons, $form = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  /**
15
  * Constructor
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * Base class for all settings
9
  * @since 1.8
10
  */
11
  class PLL_Settings_Module {
12
+ /**
13
+ * Stores the plugin options.
14
+ *
15
+ * @var array
16
+ */
17
  public $options;
18
+
19
+ /**
20
+ * Instance of PLL_Model.
21
+ *
22
+ * @var PLL_Model
23
+ */
24
+ public $model;
25
+
26
+ /**
27
+ * Instance of a child class of PLL_Links_Model.
28
+ *
29
+ * @var PLL_Links_Model
30
+ */
31
+ public $links_model;
32
+
33
+ /**
34
+ * Stores if the module is active.
35
+ *
36
+ * @var bool
37
+ */
38
+ public $active_option;
39
+
40
+ /**
41
+ * Stores the display order priority.
42
+ *
43
+ * @var int
44
+ */
45
+ public $priority = 100;
46
+
47
+ /**
48
+ * Stores the module name.
49
+ * It must be unique.
50
+ *
51
+ * @var string
52
+ */
53
+ public $module;
54
+
55
+ /**
56
+ * Stores the module title.
57
+ *
58
+ * @var string
59
+ */
60
+ public $title;
61
+
62
+ /**
63
+ * Stores the module description.
64
+ *
65
+ * @var string
66
+ */
67
+ public $description;
68
+
69
+ /**
70
+ * Stores the settings actions.
71
+ *
72
+ * @var array
73
+ */
74
+ protected $action_links;
75
+
76
+ /**
77
+ * Stores html fragment for the buttons.
78
+ *
79
+ * @var array
80
+ */
81
+ protected $buttons;
82
+
83
+ /**
84
+ * Stores html form when provided by a child class.
85
+ *
86
+ * @var bool|string
87
+ */
88
+ protected $form = false;
89
 
90
  /**
91
  * Constructor
settings/settings-url.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class to manage URL modifications settings
@@ -6,6 +9,12 @@
6
  * @since 1.8
7
  */
8
  class PLL_Settings_Url extends PLL_Settings_Module {
 
 
 
 
 
 
9
 
10
  /**
11
  * Constructor
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class to manage URL modifications settings
9
  * @since 1.8
10
  */
11
  class PLL_Settings_Url extends PLL_Settings_Module {
12
+ /**
13
+ * Stores the display order priority.
14
+ *
15
+ * @var int
16
+ */
17
+ public $priority = 10;
18
 
19
  /**
20
  * Constructor
settings/settings.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  /**
4
  * A class for the Polylang settings pages
@@ -32,13 +35,6 @@ class PLL_Settings extends PLL_Admin_Base {
32
  */
33
  protected $modules;
34
 
35
- /**
36
- * Reference to PLL_Import_Export
37
- *
38
- * @var PLL_Import_Export $import_export
39
- */
40
- protected $import_export;
41
-
42
  /**
43
  * Constructor
44
  *
@@ -55,11 +51,6 @@ class PLL_Settings extends PLL_Admin_Base {
55
 
56
  PLL_Admin_Strings::init();
57
 
58
- if ( class_exists( 'PLL_Import_Export' ) ) {
59
- $this->import_export = new PLL_Import_Export( $this );
60
- }
61
-
62
- // FIXME put this as late as possible
63
  add_action( 'admin_init', array( $this, 'register_settings_modules' ) );
64
 
65
  // Adds screen options and the about box in the languages admin panel
@@ -76,26 +67,19 @@ class PLL_Settings extends PLL_Admin_Base {
76
  * @since 1.8
77
  */
78
  public function register_settings_modules() {
79
- $modules = array(
80
- 'PLL_Settings_Licenses',
81
- );
82
 
83
  if ( $this->model->get_languages_list() ) {
84
- $modules = array_merge(
85
- array(
86
- 'PLL_Settings_Url',
87
- 'PLL_Settings_Browser',
88
- 'PLL_Settings_Media',
89
- 'PLL_Settings_CPT',
90
- 'PLL_Settings_Sync',
91
- 'PLL_Settings_WPML',
92
- 'PLL_Settings_Share_Slug',
93
- 'PLL_Settings_Translate_Slugs',
94
- ),
95
- $modules
96
  );
97
  }
98
 
 
 
99
  /**
100
  * Filter the list of setting modules
101
  *
@@ -117,7 +101,7 @@ class PLL_Settings extends PLL_Admin_Base {
117
  * @since 0.8
118
  */
119
  public function metabox_about() {
120
- include PLL_SETTINGS_INC . '/view-about.php';
121
  }
122
 
123
  /**
@@ -328,7 +312,7 @@ class PLL_Settings extends PLL_Admin_Base {
328
  }
329
 
330
  // Displays the page
331
- include PLL_SETTINGS_INC . '/view-languages.php';
332
  }
333
 
334
  /**
@@ -387,7 +371,7 @@ class PLL_Settings extends PLL_Admin_Base {
387
  public static function get_predefined_languages() {
388
  require_once ABSPATH . 'wp-admin/includes/translation-install.php';
389
 
390
- $languages = include PLL_SETTINGS_INC . '/languages.php';
391
  $translations = wp_get_available_translations();
392
 
393
  // Keep only languages with existing WP language pack
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  /**
7
  * A class for the Polylang settings pages
35
  */
36
  protected $modules;
37
 
 
 
 
 
 
 
 
38
  /**
39
  * Constructor
40
  *
51
 
52
  PLL_Admin_Strings::init();
53
 
 
 
 
 
 
54
  add_action( 'admin_init', array( $this, 'register_settings_modules' ) );
55
 
56
  // Adds screen options and the about box in the languages admin panel
67
  * @since 1.8
68
  */
69
  public function register_settings_modules() {
70
+ $modules = array();
 
 
71
 
72
  if ( $this->model->get_languages_list() ) {
73
+ $modules = array(
74
+ 'PLL_Settings_Url',
75
+ 'PLL_Settings_Browser',
76
+ 'PLL_Settings_Media',
77
+ 'PLL_Settings_CPT',
 
 
 
 
 
 
 
78
  );
79
  }
80
 
81
+ $modules[] = 'PLL_Settings_Licenses';
82
+
83
  /**
84
  * Filter the list of setting modules
85
  *
101
  * @since 0.8
102
  */
103
  public function metabox_about() {
104
+ include __DIR__ . '/view-about.php';
105
  }
106
 
107
  /**
312
  }
313
 
314
  // Displays the page
315
+ include __DIR__ . '/view-languages.php';
316
  }
317
 
318
  /**
371
  public static function get_predefined_languages() {
372
  require_once ABSPATH . 'wp-admin/includes/translation-install.php';
373
 
374
+ $languages = include __DIR__ . '/languages.php';
375
  $translations = wp_get_available_translations();
376
 
377
  // Keep only languages with existing WP language pack
settings/table-languages.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  if ( ! class_exists( 'WP_List_Table' ) ) {
4
  require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  if ( ! class_exists( 'WP_List_Table' ) ) {
7
  require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
settings/table-settings.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  if ( ! class_exists( 'WP_List_Table' ) ) {
4
  require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
@@ -165,6 +168,14 @@ class PLL_Table_Settings extends WP_List_Table {
165
  */
166
  public function prepare_items( $items = array() ) {
167
  $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns(), $this->get_primary_column_name() );
 
 
 
 
 
 
 
 
168
  $this->items = $items;
169
  }
170
 
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  if ( ! class_exists( 'WP_List_Table' ) ) {
7
  require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
168
  */
169
  public function prepare_items( $items = array() ) {
170
  $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns(), $this->get_primary_column_name() );
171
+
172
+ // Sort rows, lowest priority on top.
173
+ usort(
174
+ $items,
175
+ function( $a, $b ) {
176
+ return $a->priority > $b->priority ? 1 : -1;
177
+ }
178
+ );
179
  $this->items = $items;
180
  }
181
 
settings/table-string.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  if ( ! class_exists( 'WP_List_Table' ) ) {
4
  require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  if ( ! class_exists( 'WP_List_Table' ) ) {
7
  require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
settings/view-about.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Displays the content of the About metabox
 
 
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) {
1
  <?php
 
2
  /**
3
  * Displays the content of the About metabox
4
+ *
5
+ * @package Polylang
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
settings/view-languages.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Displays the Languages admin panel
 
 
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) {
@@ -17,7 +18,7 @@ require ABSPATH . 'wp-admin/options-head.php'; // Displays the errors messages a
17
  case 'lang': // Languages tab
18
  case 'strings': // String translations tab
19
  case 'settings': // Settings tab
20
- include PLL_SETTINGS_INC . '/view-tab-' . $this->active_tab . '.php';
21
  // Intentional fall-through to upgrade to fire the action below.
22
 
23
  default:
1
  <?php
 
2
  /**
3
  * Displays the Languages admin panel
4
+ *
5
+ * @package Polylang
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
18
  case 'lang': // Languages tab
19
  case 'strings': // String translations tab
20
  case 'settings': // Settings tab
21
+ include __DIR__ . '/view-tab-' . $this->active_tab . '.php';
22
  // Intentional fall-through to upgrade to fire the action below.
23
 
24
  default:
settings/view-tab-lang.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Displays the languages tab in Polylang settings
 
 
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) {
@@ -127,7 +128,7 @@ if ( ! defined( 'ABSPATH' ) ) {
127
  <select name="flag" id="flag_list">
128
  <option value=""></option>
129
  <?php
130
- $flags = include PLL_SETTINGS_INC . '/flags.php';
131
  foreach ( $flags as $code => $label ) {
132
  printf(
133
  '<option value="%s" data-flag-html="%s"%s>%s</option>' . "\n",
1
  <?php
 
2
  /**
3
  * Displays the languages tab in Polylang settings
4
+ *
5
+ * @package Polylang
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
128
  <select name="flag" id="flag_list">
129
  <option value=""></option>
130
  <?php
131
+ $flags = include __DIR__ . '/flags.php';
132
  foreach ( $flags as $code => $label ) {
133
  printf(
134
  '<option value="%s" data-flag-html="%s"%s>%s</option>' . "\n",
settings/view-tab-settings.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Displays the settings tab in Polylang settings
 
 
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) {
1
  <?php
 
2
  /**
3
  * Displays the settings tab in Polylang settings
4
+ *
5
+ * @package Polylang
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
settings/view-tab-strings.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Displays the strings translations tab in Polylang settings
 
 
5
  */
6
 
7
  if ( ! defined( 'ABSPATH' ) ) {
1
  <?php
 
2
  /**
3
  * Displays the strings translations tab in Polylang settings
4
+ *
5
+ * @package Polylang
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
uninstall.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
 
3
  if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { // If uninstall not called from WordPress exit
4
  exit;
@@ -47,18 +50,7 @@ class PLL_Uninstall {
47
  public function uninstall() {
48
  global $wpdb;
49
 
50
- // Executes each module's uninstall script, if it exists
51
- $pll_modules_dir = dirname( __FILE__ ) . '/modules';
52
- opendir( $pll_modules_dir );
53
- while ( ( $module = readdir() ) != false ) {
54
- if ( substr( $module, 0, 1 ) !== '.' ) {
55
- $uninstall_script = $pll_modules_dir . '/' . $module . '/uninstall.php';
56
- if ( file_exists( $uninstall_script ) ) {
57
- require $uninstall_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
58
- }
59
- }
60
- }
61
- closedir();
62
 
63
  // Suppress data of the old model < 1.2
64
  // FIXME: to remove when support for v1.1.6 will be dropped
1
  <?php
2
+ /**
3
+ * @package Polylang
4
+ */
5
 
6
  if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { // If uninstall not called from WordPress exit
7
  exit;
50
  public function uninstall() {
51
  global $wpdb;
52
 
53
+ do_action( 'pll_uninstall' );
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  // Suppress data of the old model < 1.2
56
  // FIXME: to remove when support for v1.1.6 will be dropped
vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit11d7052b4ec8b12ab4b47a47ddfbd476::getLoader();
vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+ private $classMapAuthoritative = false;
57
+ private $missingClasses = array();
58
+ private $apcuPrefix;
59
+
60
+ public function getPrefixes()
61
+ {
62
+ if (!empty($this->prefixesPsr0)) {
63
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
64
+ }
65
+
66
+ return array();
67
+ }
68
+
69
+ public function getPrefixesPsr4()
70
+ {
71
+ return $this->prefixDirsPsr4;
72
+ }
73
+
74
+ public function getFallbackDirs()
75
+ {
76
+ return $this->fallbackDirsPsr0;
77
+ }
78
+
79
+ public function getFallbackDirsPsr4()
80
+ {
81
+ return $this->fallbackDirsPsr4;
82
+ }
83
+
84
+ public function getClassMap()
85
+ {
86
+ return $this->classMap;
87
+ }
88
+
89
+ /**
90
+ * @param array $classMap Class to filename map
91
+ */
92
+ public function addClassMap(array $classMap)
93
+ {
94
+ if ($this->classMap) {
95
+ $this->classMap = array_merge($this->classMap, $classMap);
96
+ } else {
97
+ $this->classMap = $classMap;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Registers a set of PSR-0 directories for a given prefix, either
103
+ * appending or prepending to the ones previously set for this prefix.
104
+ *
105
+ * @param string $prefix The prefix
106
+ * @param array|string $paths The PSR-0 root directories
107
+ * @param bool $prepend Whether to prepend the directories
108
+ */
109
+ public function add($prefix, $paths, $prepend = false)
110
+ {
111
+ if (!$prefix) {
112
+ if ($prepend) {
113
+ $this->fallbackDirsPsr0 = array_merge(
114
+ (array) $paths,
115
+ $this->fallbackDirsPsr0
116
+ );
117
+ } else {
118
+ $this->fallbackDirsPsr0 = array_merge(
119
+ $this->fallbackDirsPsr0,
120
+ (array) $paths
121
+ );
122
+ }
123
+
124
+ return;
125
+ }
126
+
127
+ $first = $prefix[0];
128
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130
+
131
+ return;
132
+ }
133
+ if ($prepend) {
134
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
135
+ (array) $paths,
136
+ $this->prefixesPsr0[$first][$prefix]
137
+ );
138
+ } else {
139
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
140
+ $this->prefixesPsr0[$first][$prefix],
141
+ (array) $paths
142
+ );
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Registers a set of PSR-4 directories for a given namespace, either
148
+ * appending or prepending to the ones previously set for this namespace.
149
+ *
150
+ * @param string $prefix The prefix/namespace, with trailing '\\'
151
+ * @param array|string $paths The PSR-4 base directories
152
+ * @param bool $prepend Whether to prepend the directories
153
+ *
154
+ * @throws \InvalidArgumentException
155
+ */
156
+ public function addPsr4($prefix, $paths, $prepend = false)
157
+ {
158
+ if (!$prefix) {
159
+ // Register directories for the root namespace.
160
+ if ($prepend) {
161
+ $this->fallbackDirsPsr4 = array_merge(
162
+ (array) $paths,
163
+ $this->fallbackDirsPsr4
164
+ );
165
+ } else {
166
+ $this->fallbackDirsPsr4 = array_merge(
167
+ $this->fallbackDirsPsr4,
168
+ (array) $paths
169
+ );
170
+ }
171
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172
+ // Register directories for a new namespace.
173
+ $length = strlen($prefix);
174
+ if ('\\' !== $prefix[$length - 1]) {
175
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176
+ }
177
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
179
+ } elseif ($prepend) {
180
+ // Prepend directories for an already registered namespace.
181
+ $this->prefixDirsPsr4[$prefix] = array_merge(
182
+ (array) $paths,
183
+ $this->prefixDirsPsr4[$prefix]
184
+ );
185
+ } else {
186
+ // Append directories for an already registered namespace.
187
+ $this->prefixDirsPsr4[$prefix] = array_merge(
188
+ $this->prefixDirsPsr4[$prefix],
189
+ (array) $paths
190
+ );
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Registers a set of PSR-0 directories for a given prefix,
196
+ * replacing any others previously set for this prefix.
197
+ *
198
+ * @param string $prefix The prefix
199
+ * @param array|string $paths The PSR-0 base directories
200
+ */
201
+ public function set($prefix, $paths)
202
+ {
203
+ if (!$prefix) {
204
+ $this->fallbackDirsPsr0 = (array) $paths;
205
+ } else {
206
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Registers a set of PSR-4 directories for a given namespace,
212
+ * replacing any others previously set for this namespace.
213
+ *
214
+ * @param string $prefix The prefix/namespace, with trailing '\\'
215
+ * @param array|string $paths The PSR-4 base directories
216
+ *
217
+ * @throws \InvalidArgumentException
218
+ */
219
+ public function setPsr4($prefix, $paths)
220
+ {
221
+ if (!$prefix) {
222
+ $this->fallbackDirsPsr4 = (array) $paths;
223
+ } else {
224
+ $length = strlen($prefix);
225
+ if ('\\' !== $prefix[$length - 1]) {
226
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227
+ }
228
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Turns on searching the include path for class files.
235
+ *
236
+ * @param bool $useIncludePath
237
+ */
238
+ public function setUseIncludePath($useIncludePath)
239
+ {
240
+ $this->useIncludePath = $useIncludePath;
241
+ }
242
+
243
+ /**
244
+ * Can be used to check if the autoloader uses the include path to check
245
+ * for classes.
246
+ *
247
+ * @return bool
248
+ */
249
+ public function getUseIncludePath()
250
+ {
251
+ return $this->useIncludePath;
252
+ }
253
+
254
+ /**
255
+ * Turns off searching the prefix and fallback directories for classes
256
+ * that have not been registered with the class map.
257
+ *
258
+ * @param bool $classMapAuthoritative
259
+ */
260
+ public function setClassMapAuthoritative($classMapAuthoritative)
261
+ {
262
+ $this->classMapAuthoritative = $classMapAuthoritative;
263
+ }
264
+
265
+ /**
266
+ * Should class lookup fail if not found in the current class map?
267
+ *
268
+ * @return bool
269
+ */
270
+ public function isClassMapAuthoritative()
271
+ {
272
+ return $this->classMapAuthoritative;
273
+ }
274
+
275
+ /**
276
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277
+ *
278
+ * @param string|null $apcuPrefix
279
+ */
280
+ public function setApcuPrefix($apcuPrefix)
281
+ {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283
+ }
284
+
285
+ /**
286
+ * The APCu prefix in use, or null if APCu caching is not enabled.
287
+ *
288
+ * @return string|null
289
+ */
290
+ public function getApcuPrefix()
291
+ {
292
+ return $this->apcuPrefix;
293
+ }
294
+
295
+ /**
296
+ * Registers this instance as an autoloader.
297
+ *
298
+ * @param bool $prepend Whether to prepend the autoloader or not
299
+ */
300
+ public function register($prepend = false)
301
+ {
302
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303
+ }
304
+
305
+ /**
306
+ * Unregisters this instance as an autoloader.
307
+ */
308
+ public function unregister()
309
+ {
310
+ spl_autoload_unregister(array($this, 'loadClass'));
311
+ }
312
+
313
+ /**
314
+ * Loads the given class or interface.
315
+ *
316
+ * @param string $class The name of the class
317
+ * @return bool|null True if loaded, null otherwise
318
+ */
319
+ public function loadClass($class)
320
+ {
321
+ if ($file = $this->findFile($class)) {
322
+ includeFile($file);
323
+
324
+ return true;
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Finds the path to the file where the class is defined.
330
+ *
331
+ * @param string $class The name of the class
332
+ *
333
+ * @return string|false The path if found, false otherwise
334
+ */
335
+ public function findFile($class)
336
+ {
337
+ // class map lookup
338
+ if (isset($this->classMap[$class])) {
339
+ return $this->classMap[$class];
340
+ }
341
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342
+ return false;
343
+ }
344
+ if (null !== $this->apcuPrefix) {
345
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346
+ if ($hit) {
347
+ return $file;
348
+ }
349
+ }
350
+
351
+ $file = $this->findFileWithExtension($class, '.php');
352
+
353
+ // Search for Hack files if we are running on HHVM
354
+ if (false === $file && defined('HHVM_VERSION')) {
355
+ $file = $this->findFileWithExtension($class, '.hh');
356
+ }
357
+
358
+ if (null !== $this->apcuPrefix) {
359
+ apcu_add($this->apcuPrefix.$class, $file);
360
+ }
361
+
362
+ if (false === $file) {
363
+ // Remember that this class does not exist.
364
+ $this->missingClasses[$class] = true;
365
+ }
366
+
367
+ return $file;
368
+ }
369
+
370
+ private function findFileWithExtension($class, $ext)
371
+ {
372
+ // PSR-4 lookup
373
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374
+
375
+ $first = $class[0];
376
+ if (isset($this->prefixLengthsPsr4[$first])) {
377
+ $subPath = $class;
378
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
379
+ $subPath = substr($subPath, 0, $lastPos);
380
+ $search = $subPath . '\\';
381
+ if (isset($this->prefixDirsPsr4[$search])) {
382
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
384
+ if (file_exists($file = $dir . $pathEnd)) {
385
+ return $file;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+
392
+ // PSR-4 fallback dirs
393
+ foreach ($this->fallbackDirsPsr4 as $dir) {
394
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395
+ return $file;
396
+ }
397
+ }
398
+
399
+ // PSR-0 lookup
400
+ if (false !== $pos = strrpos($class, '\\')) {
401
+ // namespaced class name
402
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404
+ } else {
405
+ // PEAR-like class name
406
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407
+ }
408
+
409
+ if (isset($this->prefixesPsr0[$first])) {
410
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411
+ if (0 === strpos($class, $prefix)) {
412
+ foreach ($dirs as $dir) {
413
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414
+ return $file;
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
420
+
421
+ // PSR-0 fallback dirs
422
+ foreach ($this->fallbackDirsPsr0 as $dir) {
423
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424
+ return $file;
425
+ }
426
+ }
427
+
428
+ // PSR-0 include paths.
429
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430
+ return $file;
431
+ }
432
+
433
+ return false;
434
+ }
435
+ }
436
+
437
+ /**
438
+ * Scope isolated include.
439
+ *
440
+ * Prevents access to $this/self from included files.
441
+ */
442
+ function includeFile($file)
443
+ {
444
+ include $file;
445
+ }
vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'PLL_AS3CF' => $baseDir . '/integrations/wp-offload-media/as3cf.php',
10
+ 'PLL_Admin' => $baseDir . '/admin/admin.php',
11
+ 'PLL_Admin_Base' => $baseDir . '/admin/admin-base.php',
12
+ 'PLL_Admin_Block_Editor' => $baseDir . '/admin/admin-block-editor.php',
13
+ 'PLL_Admin_Classic_Editor' => $baseDir . '/admin/admin-classic-editor.php',
14
+ 'PLL_Admin_Filters' => $baseDir . '/admin/admin-filters.php',
15
+ 'PLL_Admin_Filters_Columns' => $baseDir . '/admin/admin-filters-columns.php',
16
+ 'PLL_Admin_Filters_Media' => $baseDir . '/admin/admin-filters-media.php',
17
+ 'PLL_Admin_Filters_Post' => $baseDir . '/admin/admin-filters-post.php',
18
+ 'PLL_Admin_Filters_Post_Base' => $baseDir . '/admin/admin-filters-post-base.php',
19
+ 'PLL_Admin_Filters_Term' => $baseDir . '/admin/admin-filters-term.php',
20
+ 'PLL_Admin_Links' => $baseDir . '/admin/admin-links.php',
21
+ 'PLL_Admin_Model' => $baseDir . '/admin/admin-model.php',
22
+ 'PLL_Admin_Nav_Menu' => $baseDir . '/admin/admin-nav-menu.php',
23
+ 'PLL_Admin_Notices' => $baseDir . '/admin/admin-notices.php',
24
+ 'PLL_Admin_Site_Health' => $baseDir . '/modules/site-health/admin-site-health.php',
25
+ 'PLL_Admin_Static_Pages' => $baseDir . '/admin/admin-static-pages.php',
26
+ 'PLL_Admin_Strings' => $baseDir . '/admin/admin-strings.php',
27
+ 'PLL_Admin_Sync' => $baseDir . '/modules/sync/admin-sync.php',
28
+ 'PLL_Aqua_Resizer' => $baseDir . '/integrations/aqua-resizer/aqua-resizer.php',
29
+ 'PLL_Base' => $baseDir . '/include/base.php',
30
+ 'PLL_CRUD_Posts' => $baseDir . '/include/crud-posts.php',
31
+ 'PLL_CRUD_Terms' => $baseDir . '/include/crud-terms.php',
32
+ 'PLL_Cache' => $baseDir . '/include/cache.php',
33
+ 'PLL_Cache_Compat' => $baseDir . '/integrations/cache/cache-compat.php',
34
+ 'PLL_Cft' => $baseDir . '/integrations/custom-field-template/cft.php',
35
+ 'PLL_Choose_Lang' => $baseDir . '/frontend/choose-lang.php',
36
+ 'PLL_Choose_Lang_Content' => $baseDir . '/frontend/choose-lang-content.php',
37
+ 'PLL_Choose_Lang_Domain' => $baseDir . '/frontend/choose-lang-domain.php',
38
+ 'PLL_Choose_Lang_Url' => $baseDir . '/frontend/choose-lang-url.php',
39
+ 'PLL_Domain_Mapping' => $baseDir . '/integrations/domain-mapping/domain-mapping.php',
40
+ 'PLL_Duplicate_Post' => $baseDir . '/integrations/duplicate-post/duplicate-post.php',
41
+ 'PLL_Featured_Content' => $baseDir . '/integrations/jetpack/featured-content.php',
42
+ 'PLL_Filters' => $baseDir . '/include/filters.php',
43
+ 'PLL_Filters_Links' => $baseDir . '/include/filters-links.php',
44
+ 'PLL_Frontend' => $baseDir . '/frontend/frontend.php',
45
+ 'PLL_Frontend_Auto_Translate' => $baseDir . '/frontend/frontend-auto-translate.php',
46
+ 'PLL_Frontend_Filters' => $baseDir . '/frontend/frontend-filters.php',
47
+ 'PLL_Frontend_Filters_Links' => $baseDir . '/frontend/frontend-filters-links.php',
48
+ 'PLL_Frontend_Filters_Search' => $baseDir . '/frontend/frontend-filters-search.php',
49
+ 'PLL_Frontend_Links' => $baseDir . '/frontend/frontend-links.php',
50
+ 'PLL_Frontend_Nav_Menu' => $baseDir . '/frontend/frontend-nav-menu.php',
51
+ 'PLL_Frontend_Static_Pages' => $baseDir . '/frontend/frontend-static-pages.php',
52
+ 'PLL_Install' => $baseDir . '/install/install.php',
53
+ 'PLL_Install_Base' => $baseDir . '/install/install-base.php',
54
+ 'PLL_Integrations' => $baseDir . '/integrations/integrations.php',
55
+ 'PLL_Jetpack' => $baseDir . '/integrations/jetpack/jetpack.php',
56
+ 'PLL_Language' => $baseDir . '/include/language.php',
57
+ 'PLL_License' => $baseDir . '/include/license.php',
58
+ 'PLL_Lingotek' => $baseDir . '/modules/lingotek/lingotek.php',
59
+ 'PLL_Links' => $baseDir . '/include/links.php',
60
+ 'PLL_Links_Abstract_Domain' => $baseDir . '/include/links-abstract-domain.php',
61
+ 'PLL_Links_Default' => $baseDir . '/include/links-default.php',
62
+ 'PLL_Links_Directory' => $baseDir . '/include/links-directory.php',
63
+ 'PLL_Links_Domain' => $baseDir . '/include/links-domain.php',
64
+ 'PLL_Links_Model' => $baseDir . '/include/links-model.php',
65
+ 'PLL_Links_Permalinks' => $baseDir . '/include/links-permalinks.php',
66
+ 'PLL_Links_Subdomain' => $baseDir . '/include/links-subdomain.php',
67
+ 'PLL_MO' => $baseDir . '/include/mo.php',
68
+ 'PLL_Model' => $baseDir . '/include/model.php',
69
+ 'PLL_Multilingual_Sitemaps_Provider' => $baseDir . '/modules/sitemaps/multilingual-sitemaps-provider.php',
70
+ 'PLL_Nav_Menu' => $baseDir . '/include/nav-menu.php',
71
+ 'PLL_No_Category_Base' => $baseDir . '/integrations/no-category-base/no-category-base.php',
72
+ 'PLL_OLT_Manager' => $baseDir . '/include/olt-manager.php',
73
+ 'PLL_Plugin_Updater' => $baseDir . '/install/plugin-updater.php',
74
+ 'PLL_Pointer' => $baseDir . '/include/pointer.php',
75
+ 'PLL_Query' => $baseDir . '/include/query.php',
76
+ 'PLL_REST_Request' => $baseDir . '/include/rest-request.php',
77
+ 'PLL_Settings' => $baseDir . '/settings/settings.php',
78
+ 'PLL_Settings_Browser' => $baseDir . '/settings/settings-browser.php',
79
+ 'PLL_Settings_CPT' => $baseDir . '/settings/settings-cpt.php',
80
+ 'PLL_Settings_Licenses' => $baseDir . '/settings/settings-licenses.php',
81
+ 'PLL_Settings_Media' => $baseDir . '/settings/settings-media.php',
82
+ 'PLL_Settings_Module' => $baseDir . '/settings/settings-module.php',
83
+ 'PLL_Settings_Share_Slug' => $baseDir . '/modules/share-slug/settings-share-slug.php',
84
+ 'PLL_Settings_Sync' => $baseDir . '/modules/sync/settings-sync.php',
85
+ 'PLL_Settings_Translate_Slugs' => $baseDir . '/modules/translate-slugs/settings-translate-slugs.php',
86
+ 'PLL_Settings_Url' => $baseDir . '/settings/settings-url.php',
87
+ 'PLL_Settings_WPML' => $baseDir . '/modules/wpml/settings-wpml.php',
88
+ 'PLL_Sitemaps' => $baseDir . '/modules/sitemaps/sitemaps.php',
89
+ 'PLL_Static_Pages' => $baseDir . '/include/static-pages.php',
90
+ 'PLL_Switcher' => $baseDir . '/include/switcher.php',
91
+ 'PLL_Sync' => $baseDir . '/modules/sync/sync.php',
92
+ 'PLL_Sync_Metas' => $baseDir . '/modules/sync/sync-metas.php',
93
+ 'PLL_Sync_Post_Metas' => $baseDir . '/modules/sync/sync-post-metas.php',
94
+ 'PLL_Sync_Tax' => $baseDir . '/modules/sync/sync-tax.php',
95
+ 'PLL_Sync_Term_Metas' => $baseDir . '/modules/sync/sync-term-metas.php',
96
+ 'PLL_T15S' => $baseDir . '/install/t15s.php',
97
+ 'PLL_Table_Languages' => $baseDir . '/settings/table-languages.php',
98
+ 'PLL_Table_Settings' => $baseDir . '/settings/table-settings.php',
99
+ 'PLL_Table_String' => $baseDir . '/settings/table-string.php',
100
+ 'PLL_Translated_Object' => $baseDir . '/include/translated-object.php',
101
+ 'PLL_Translated_Post' => $baseDir . '/include/translated-post.php',
102
+ 'PLL_Translated_Term' => $baseDir . '/include/translated-term.php',
103
+ 'PLL_Twenty_Seventeen' => $baseDir . '/integrations/twenty-seventeen/twenty-seven-teen.php',
104
+ 'PLL_Upgrade' => $baseDir . '/install/upgrade.php',
105
+ 'PLL_WPML_API' => $baseDir . '/modules/wpml/wpml-api.php',
106
+ 'PLL_WPML_Compat' => $baseDir . '/modules/wpml/wpml-compat.php',
107
+ 'PLL_WPML_Config' => $baseDir . '/modules/wpml/wpml-config.php',
108
+ 'PLL_WPSEO' => $baseDir . '/integrations/wpseo/wpseo.php',
109
+ 'PLL_WPSEO_OGP' => $baseDir . '/integrations/wpseo/wpseo-ogp.php',
110
+ 'PLL_WP_Import' => $baseDir . '/integrations/wp-importer/wp-import.php',
111
+ 'PLL_WP_Sweep' => $baseDir . '/integrations/wp-sweep/wp-sweep.php',
112
+ 'PLL_Walker_Dropdown' => $baseDir . '/include/walker-dropdown.php',
113
+ 'PLL_Walker_List' => $baseDir . '/include/walker-list.php',
114
+ 'PLL_Widget_Calendar' => $baseDir . '/include/widget-calendar.php',
115
+ 'PLL_Widget_Languages' => $baseDir . '/include/widget-languages.php',
116
+ 'PLL_Wizard' => $baseDir . '/modules/wizard/wizard.php',
117
+ 'PLL_WordPress_Importer' => $baseDir . '/integrations/wp-importer/wordpress-importer.php',
118
+ 'PLL_Yarpp' => $baseDir . '/integrations/yarpp/yarpp.php',
119
+ 'Polylang' => $baseDir . '/include/class-polylang.php',
120
+ );
vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit11d7052b4ec8b12ab4b47a47ddfbd476
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ /**
17
+ * @return \Composer\Autoload\ClassLoader
18
+ */
19
+ public static function getLoader()
20
+ {
21
+ if (null !== self::$loader) {
22
+ return self::$loader;
23
+ }
24
+
25
+ spl_autoload_register(array('ComposerAutoloaderInit11d7052b4ec8b12ab4b47a47ddfbd476', 'loadClassLoader'), true, true);
26
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
27
+ spl_autoload_unregister(array('ComposerAutoloaderInit11d7052b4ec8b12ab4b47a47ddfbd476', 'loadClassLoader'));
28
+
29
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
+ if ($useStaticLoader) {
31
+ require_once __DIR__ . '/autoload_static.php';
32
+
33
+ call_user_func(\Composer\Autoload\ComposerStaticInit11d7052b4ec8b12ab4b47a47ddfbd476::getInitializer($loader));
34
+ } else {
35
+ $map = require __DIR__ . '/autoload_namespaces.php';
36
+ foreach ($map as $namespace => $path) {
37
+ $loader->set($namespace, $path);
38
+ }
39
+
40
+ $map = require __DIR__ . '/autoload_psr4.php';
41
+ foreach ($map as $namespace => $path) {
42
+ $loader->setPsr4($namespace, $path);
43
+ }
44
+
45
+ $classMap = require __DIR__ . '/autoload_classmap.php';
46
+ if ($classMap) {
47
+ $loader->addClassMap($classMap);
48
+ }
49
+ }
50
+
51
+ $loader->register(true);
52
+
53
+ return $loader;
54
+ }
55
+ }
vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInit11d7052b4ec8b12ab4b47a47ddfbd476
8
+ {
9
+ public static $classMap = array (
10
+ 'PLL_AS3CF' => __DIR__ . '/../..' . '/integrations/wp-offload-media/as3cf.php',
11
+ 'PLL_Admin' => __DIR__ . '/../..' . '/admin/admin.php',
12
+ 'PLL_Admin_Base' => __DIR__ . '/../..' . '/admin/admin-base.php',
13
+ 'PLL_Admin_Block_Editor' => __DIR__ . '/../..' . '/admin/admin-block-editor.php',
14
+ 'PLL_Admin_Classic_Editor' => __DIR__ . '/../..' . '/admin/admin-classic-editor.php',
15
+ 'PLL_Admin_Filters' => __DIR__ . '/../..' . '/admin/admin-filters.php',
16
+ 'PLL_Admin_Filters_Columns' => __DIR__ . '/../..' . '/admin/admin-filters-columns.php',
17
+ 'PLL_Admin_Filters_Media' => __DIR__ . '/../..' . '/admin/admin-filters-media.php',
18
+ 'PLL_Admin_Filters_Post' => __DIR__ . '/../..' . '/admin/admin-filters-post.php',
19
+ 'PLL_Admin_Filters_Post_Base' => __DIR__ . '/../..' . '/admin/admin-filters-post-base.php',
20
+ 'PLL_Admin_Filters_Term' => __DIR__ . '/../..' . '/admin/admin-filters-term.php',
21
+ 'PLL_Admin_Links' => __DIR__ . '/../..' . '/admin/admin-links.php',
22
+ 'PLL_Admin_Model' => __DIR__ . '/../..' . '/admin/admin-model.php',
23
+ 'PLL_Admin_Nav_Menu' => __DIR__ . '/../..' . '/admin/admin-nav-menu.php',
24
+ 'PLL_Admin_Notices' => __DIR__ . '/../..' . '/admin/admin-notices.php',
25
+ 'PLL_Admin_Site_Health' => __DIR__ . '/../..' . '/modules/site-health/admin-site-health.php',
26
+ 'PLL_Admin_Static_Pages' => __DIR__ . '/../..' . '/admin/admin-static-pages.php',
27
+ 'PLL_Admin_Strings' => __DIR__ . '/../..' . '/admin/admin-strings.php',
28
+ 'PLL_Admin_Sync' => __DIR__ . '/../..' . '/modules/sync/admin-sync.php',
29
+ 'PLL_Aqua_Resizer' => __DIR__ . '/../..' . '/integrations/aqua-resizer/aqua-resizer.php',
30
+ 'PLL_Base' => __DIR__ . '/../..' . '/include/base.php',
31
+ 'PLL_CRUD_Posts' => __DIR__ . '/../..' . '/include/crud-posts.php',
32
+ 'PLL_CRUD_Terms' => __DIR__ . '/../..' . '/include/crud-terms.php',
33
+ 'PLL_Cache' => __DIR__ . '/../..' . '/include/cache.php',
34
+ 'PLL_Cache_Compat' => __DIR__ . '/../..' . '/integrations/cache/cache-compat.php',
35
+ 'PLL_Cft' => __DIR__ . '/../..' . '/integrations/custom-field-template/cft.php',
36
+ 'PLL_Choose_Lang' => __DIR__ . '/../..' . '/frontend/choose-lang.php',
37
+ 'PLL_Choose_Lang_Content' => __DIR__ . '/../..' . '/frontend/choose-lang-content.php',
38
+ 'PLL_Choose_Lang_Domain' => __DIR__ . '/../..' . '/frontend/choose-lang-domain.php',
39
+ 'PLL_Choose_Lang_Url' => __DIR__ . '/../..' . '/frontend/choose-lang-url.php',
40
+ 'PLL_Domain_Mapping' => __DIR__ . '/../..' . '/integrations/domain-mapping/domain-mapping.php',
41
+ 'PLL_Duplicate_Post' => __DIR__ . '/../..' . '/integrations/duplicate-post/duplicate-post.php',
42
+ 'PLL_Featured_Content' => __DIR__ . '/../..' . '/integrations/jetpack/featured-content.php',
43
+ 'PLL_Filters' => __DIR__ . '/../..' . '/include/filters.php',
44
+ 'PLL_Filters_Links' => __DIR__ . '/../..' . '/include/filters-links.php',
45
+ 'PLL_Frontend' => __DIR__ . '/../..' . '/frontend/frontend.php',
46
+ 'PLL_Frontend_Auto_Translate' => __DIR__ . '/../..' . '/frontend/frontend-auto-translate.php',
47
+ 'PLL_Frontend_Filters' => __DIR__ . '/../..' . '/frontend/frontend-filters.php',
48
+ 'PLL_Frontend_Filters_Links' => __DIR__ . '/../..' . '/frontend/frontend-filters-links.php',
49
+ 'PLL_Frontend_Filters_Search' => __DIR__ . '/../..' . '/frontend/frontend-filters-search.php',
50
+ 'PLL_Frontend_Links' => __DIR__ . '/../..' . '/frontend/frontend-links.php',
51
+ 'PLL_Frontend_Nav_Menu' => __DIR__ . '/../..' . '/frontend/frontend-nav-menu.php',
52
+ 'PLL_Frontend_Static_Pages' => __DIR__ . '/../..' . '/frontend/frontend-static-pages.php',
53
+ 'PLL_Install' => __DIR__ . '/../..' . '/install/install.php',
54
+ 'PLL_Install_Base' => __DIR__ . '/../..' . '/install/install-base.php',
55
+ 'PLL_Integrations' => __DIR__ . '/../..' . '/integrations/integrations.php',
56
+ 'PLL_Jetpack' => __DIR__ . '/../..' . '/integrations/jetpack/jetpack.php',
57
+ 'PLL_Language' => __DIR__ . '/../..' . '/include/language.php',
58
+ 'PLL_License' => __DIR__ . '/../..' . '/include/license.php',
59
+ 'PLL_Lingotek' => __DIR__ . '/../..' . '/modules/lingotek/lingotek.php',
60
+ 'PLL_Links' => __DIR__ . '/../..' . '/include/links.php',
61
+ 'PLL_Links_Abstract_Domain' => __DIR__ . '/../..' . '/include/links-abstract-domain.php',
62
+ 'PLL_Links_Default' => __DIR__ . '/../..' . '/include/links-default.php',
63
+ 'PLL_Links_Directory' => __DIR__ . '/../..' . '/include/links-directory.php',
64
+ 'PLL_Links_Domain' => __DIR__ . '/../..' . '/include/links-domain.php',
65
+ 'PLL_Links_Model' => __DIR__ . '/../..' . '/include/links-model.php',
66
+ 'PLL_Links_Permalinks' => __DIR__ . '/../..' . '/include/links-permalinks.php',
67
+ 'PLL_Links_Subdomain' => __DIR__ . '/../..' . '/include/links-subdomain.php',
68
+ 'PLL_MO' => __DIR__ . '/../..' . '/include/mo.php',
69
+ 'PLL_Model' => __DIR__ . '/../..' . '/include/model.php',
70
+ 'PLL_Multilingual_Sitemaps_Provider' => __DIR__ . '/../..' . '/modules/sitemaps/multilingual-sitemaps-provider.php',
71
+ 'PLL_Nav_Menu' => __DIR__ . '/../..' . '/include/nav-menu.php',
72
+ 'PLL_No_Category_Base' => __DIR__ . '/../..' . '/integrations/no-category-base/no-category-base.php',
73
+ 'PLL_OLT_Manager' => __DIR__ . '/../..' . '/include/olt-manager.php',
74
+ 'PLL_Plugin_Updater' => __DIR__ . '/../..' . '/install/plugin-updater.php',
75
+ 'PLL_Pointer' => __DIR__ . '/../..' . '/include/pointer.php',
76
+ 'PLL_Query' => __DIR__ . '/../..' . '/include/query.php',
77
+ 'PLL_REST_Request' => __DIR__ . '/../..' . '/include/rest-request.php',
78
+ 'PLL_Settings' => __DIR__ . '/../..' . '/settings/settings.php',
79
+ 'PLL_Settings_Browser' => __DIR__ . '/../..' . '/settings/settings-browser.php',
80
+ 'PLL_Settings_CPT' => __DIR__ . '/../..' . '/settings/settings-cpt.php',
81
+ 'PLL_Settings_Licenses' => __DIR__ . '/../..' . '/settings/settings-licenses.php',
82
+ 'PLL_Settings_Media' => __DIR__ . '/../..' . '/settings/settings-media.php',
83
+ 'PLL_Settings_Module' => __DIR__ . '/../..' . '/settings/settings-module.php',
84
+ 'PLL_Settings_Share_Slug' => __DIR__ . '/../..' . '/modules/share-slug/settings-share-slug.php',
85
+ 'PLL_Settings_Sync' => __DIR__ . '/../..' . '/modules/sync/settings-sync.php',
86
+ 'PLL_Settings_Translate_Slugs' => __DIR__ . '/../..' . '/modules/translate-slugs/settings-translate-slugs.php',
87
+ 'PLL_Settings_Url' => __DIR__ . '/../..' . '/settings/settings-url.php',
88
+ 'PLL_Settings_WPML' => __DIR__ . '/../..' . '/modules/wpml/settings-wpml.php',
89
+ 'PLL_Sitemaps' => __DIR__ . '/../..' . '/modules/sitemaps/sitemaps.php',
90
+ 'PLL_Static_Pages' => __DIR__ . '/../..' . '/include/static-pages.php',
91
+ 'PLL_Switcher' => __DIR__ . '/../..' . '/include/switcher.php',
92
+ 'PLL_Sync' => __DIR__ . '/../..' . '/modules/sync/sync.php',
93
+ 'PLL_Sync_Metas' => __DIR__ . '/../..' . '/modules/sync/sync-metas.php',
94
+ 'PLL_Sync_Post_Metas' => __DIR__ . '/../..' . '/modules/sync/sync-post-metas.php',
95
+ 'PLL_Sync_Tax' => __DIR__ . '/../..' . '/modules/sync/sync-tax.php',
96
+ 'PLL_Sync_Term_Metas' => __DIR__ . '/../..' . '/modules/sync/sync-term-metas.php',
97
+ 'PLL_T15S' => __DIR__ . '/../..' . '/install/t15s.php',
98
+ 'PLL_Table_Languages' => __DIR__ . '/../..' . '/settings/table-languages.php',
99
+ 'PLL_Table_Settings' => __DIR__ . '/../..' . '/settings/table-settings.php',
100
+ 'PLL_Table_String' => __DIR__ . '/../..' . '/settings/table-string.php',
101
+ 'PLL_Translated_Object' => __DIR__ . '/../..' . '/include/translated-object.php',
102
+ 'PLL_Translated_Post' => __DIR__ . '/../..' . '/include/translated-post.php',
103
+ 'PLL_Translated_Term' => __DIR__ . '/../..' . '/include/translated-term.php',
104
+ 'PLL_Twenty_Seventeen' => __DIR__ . '/../..' . '/integrations/twenty-seventeen/twenty-seven-teen.php',
105
+ 'PLL_Upgrade' => __DIR__ . '/../..' . '/install/upgrade.php',
106
+ 'PLL_WPML_API' => __DIR__ . '/../..' . '/modules/wpml/wpml-api.php',
107
+ 'PLL_WPML_Compat' => __DIR__ . '/../..' . '/modules/wpml/wpml-compat.php',
108
+ 'PLL_WPML_Config' => __DIR__ . '/../..' . '/modules/wpml/wpml-config.php',
109
+ 'PLL_WPSEO' => __DIR__ . '/../..' . '/integrations/wpseo/wpseo.php',
110
+ 'PLL_WPSEO_OGP' => __DIR__ . '/../..' . '/integrations/wpseo/wpseo-ogp.php',
111
+ 'PLL_WP_Import' => __DIR__ . '/../..' . '/integrations/wp-importer/wp-import.php',
112
+ 'PLL_WP_Sweep' => __DIR__ . '/../..' . '/integrations/wp-sweep/wp-sweep.php',
113
+ 'PLL_Walker_Dropdown' => __DIR__ . '/../..' . '/include/walker-dropdown.php',
114
+ 'PLL_Walker_List' => __DIR__ . '/../..' . '/include/walker-list.php',
115
+ 'PLL_Widget_Calendar' => __DIR__ . '/../..' . '/include/widget-calendar.php',
116
+ 'PLL_Widget_Languages' => __DIR__ . '/../..' . '/include/widget-languages.php',
117
+ 'PLL_Wizard' => __DIR__ . '/../..' . '/modules/wizard/wizard.php',
118
+ 'PLL_WordPress_Importer' => __DIR__ . '/../..' . '/integrations/wp-importer/wordpress-importer.php',
119
+ 'PLL_Yarpp' => __DIR__ . '/../..' . '/integrations/yarpp/yarpp.php',
120
+ 'Polylang' => __DIR__ . '/../..' . '/include/class-polylang.php',
121
+ );
122
+
123
+ public static function getInitializer(ClassLoader $loader)
124
+ {
125
+ return \Closure::bind(function () use ($loader) {
126
+ $loader->classMap = ComposerStaticInit11d7052b4ec8b12ab4b47a47ddfbd476::$classMap;
127
+
128
+ }, null, ClassLoader::class);
129
+ }
130
+ }
vendor/composer/installed.json ADDED
@@ -0,0 +1 @@
 
1
+ []