Version Description
( 2016-04-27 ) =
- Pro: add the possibility to translate custom post types slugs, taxonomies slugs and more
- Pro: add the possibility to share the same post or term slug accross languages
- Pro: add the possibility to duplicate the content when creating a new translation
- Pro: add the possibility to create all translations at once when uploading a media
- Pro: add the possibility to disable a language
- Add license and update management
- Add inline docs for all filters and actions
- When possible, the rel alternate hreflang now display only the language code (without the country code)
- When combined with flags in the language switcher, wrap the language name inside tags
- Add customizer selective refresh support for the language switcher widget ( needs WP 4.5+ )
- Fix dynamic options of the language switcher widget not working in the customizer
- Fix possible error 404 on page shortlink when using subdomains or multiple domains
- Fix get_adjacent_post() and wp_get_archives() for untranslated post types ( needs WP 4.4+ )
- Fix language homepage urls not present in Yoast SEO sitemap (when the homepages display posts)
See changelog.txt for older changelog
Download this release
Release Info
Developer | Chouby |
Plugin | Polylang |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8.5 to 1.9
- admin/admin-base.php +21 -10
- admin/admin-filters-columns.php +12 -12
- admin/admin-filters-media.php +18 -9
- admin/admin-filters-post-base.php +4 -4
- admin/admin-filters-post.php +45 -18
- admin/admin-filters-term.php +39 -30
- admin/admin-filters.php +17 -11
- admin/admin-links.php +33 -12
- admin/admin-model.php +113 -88
- admin/admin-nav-menu.php +14 -14
- admin/admin-static-pages.php +5 -5
- admin/admin-strings.php +17 -10
- admin/admin.php +14 -6
- admin/view-translations-media.php +1 -1
- admin/view-translations-post.php +1 -2
- admin/view-translations-term.php +3 -3
- changelog.txt +84 -0
- css/admin.css +24 -1
- css/admin.min.css +1 -1
- css/selectmenu.min.css +1 -1
- frontend/choose-lang-content.php +14 -8
- frontend/choose-lang-domain.php +5 -4
- frontend/choose-lang-url.php +4 -4
- frontend/choose-lang.php +68 -17
- frontend/frontend-auto-translate.php +8 -7
- frontend/frontend-filters-links.php +68 -24
- frontend/frontend-filters-search.php +6 -6
- frontend/frontend-filters.php +116 -80
- frontend/frontend-links.php +32 -6
- frontend/frontend-nav-menu.php +40 -43
- frontend/frontend-static-pages.php +13 -13
- frontend/frontend.php +10 -10
- include/api.php +73 -72
- include/base.php +6 -6
- include/cache.php +6 -6
- include/class-polylang.php +30 -9
- include/filters-links.php +34 -14
- include/filters.php +6 -6
- include/language.php +29 -9
- include/license.php +171 -0
- include/links-default.php +17 -19
- include/links-directory.php +34 -34
- include/links-domain.php +17 -17
- include/links-model.php +22 -22
- include/links-permalinks.php +27 -19
- include/links-subdomain.php +18 -11
- include/links.php +4 -4
- include/mo.php +5 -5
- include/model.php +101 -52
- include/nav-menu.php +6 -6
- include/olt-manager.php +23 -16
- include/pointer.php +4 -4
- include/static-pages.php +4 -4
- include/switcher.php +32 -7
- include/translated-object.php +35 -28
- include/translated-post.php +25 -18
- include/translated-term.php +31 -24
- include/walker-dropdown.php +4 -4
- include/walker-list.php +13 -12
- include/widget-calendar.php +4 -3
- include/widget-languages.php +58 -54
- install/install-base.php +9 -9
- install/install.php +5 -5
- install/plugin-updater.php +383 -0
- install/upgrade.php +23 -23
- js/admin.js +54 -30
- js/admin.min.js +1 -1
- js/media.min.js +1 -1
- js/nav-menu.min.js +1 -1
- js/post.min.js +1 -1
- js/term.min.js +1 -1
- js/user.min.js +1 -1
- languages/polylang-es_ES.mo +0 -0
- languages/polylang-es_ES.po +0 -590
- languages/polylang-fi.mo +0 -0
- languages/polylang-fi.po +0 -585
- languages/polylang-hr.mo +0 -0
- languages/polylang-hr.po +0 -667
- languages/polylang-oci.mo +0 -0
- languages/polylang-oci.po +0 -675
- modules/plugins/plugins-compat.php +92 -64
- modules/plugins/wp-import.php +5 -5
- modules/share-slug/settings-share-slug.php +80 -0
- modules/sync/admin-sync.php +41 -22
- modules/sync/settings-sync.php +8 -7
- modules/translate-slugs/settings-translate-slugs.php +45 -0
- modules/wpml/settings-wpml.php +4 -3
- modules/wpml/wpml-compat.php +40 -39
- modules/wpml/wpml-config.php +13 -13
- polylang.php +4 -4
- readme.txt +32 -97
- settings/flags.php +8 -1
- settings/languages.php +8 -1
- settings/settings-browser.php +5 -4
- settings/settings-cpt.php +8 -5
- settings/settings-licenses.php +216 -0
- settings/settings-media.php +3 -2
- settings/settings-module.php +62 -20
- settings/settings-tools.php +6 -4
- settings/settings-url.php +8 -8
- settings/settings.php +89 -158
- settings/table-languages.php +39 -14
- settings/table-settings.php +24 -10
- settings/table-string.php +141 -43
- settings/view-about.php +15 -26
- settings/view-languages.php +8 -1
- settings/view-tab-lang.php +14 -1
- settings/view-tab-settings.php +2 -1
- settings/view-tab-strings.php +2 -1
- uninstall.php +5 -3
admin/admin-base.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* base class for both admin
|
5 |
*
|
6 |
* @since 1.8
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_Admin_Base extends PLL_Base {
|
9 |
public $curlang, $pref_lang;
|
10 |
|
11 |
-
|
12 |
* loads the polylang text domain
|
13 |
* setups actions needed on all admin pages
|
14 |
*
|
@@ -35,7 +35,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
35 |
}
|
36 |
}
|
37 |
|
38 |
-
|
39 |
* setups filters and action needed on all admin pages and on plugins page
|
40 |
* loads the settings pages or the filters base on the request
|
41 |
*
|
@@ -61,7 +61,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
61 |
add_action( 'admin_bar_menu', array( &$this, 'admin_bar_menu' ), 100 ); // 100 determines the position
|
62 |
}
|
63 |
|
64 |
-
|
65 |
* adds the link to the languages panel in the WordPress admin menu
|
66 |
*
|
67 |
* @since 0.1
|
@@ -70,7 +70,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
70 |
add_submenu_page( 'options-general.php', $title = __( 'Languages', 'polylang' ), $title, 'manage_options', 'mlang', '__return_null' );
|
71 |
}
|
72 |
|
73 |
-
|
74 |
* setup js scripts & css styles ( only on the relevant pages )
|
75 |
*
|
76 |
* @since 0.6
|
@@ -105,7 +105,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
105 |
wp_enqueue_style( 'polylang_admin', POLYLANG_URL .'/css/admin'.$suffix.'.css', array(), POLYLANG_VERSION );
|
106 |
}
|
107 |
|
108 |
-
|
109 |
* sets pll_ajax_backend on all backend ajax request
|
110 |
* the final goal is to detect if an ajax request is made on admin or frontend
|
111 |
*
|
@@ -169,7 +169,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
169 |
|
170 |
}
|
171 |
|
172 |
-
|
173 |
* defines the backend language and the admin language filter based on user preferences
|
174 |
*
|
175 |
* @since 1.2.3
|
@@ -188,20 +188,31 @@ class PLL_Admin_Base extends PLL_Base {
|
|
188 |
|
189 |
// set preferred language for use when saving posts and terms: must not be empty
|
190 |
$this->pref_lang = empty( $this->curlang ) ? $this->model->get_language( $this->options['default_lang'] ) : $this->curlang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
$this->pref_lang = apply_filters( 'pll_admin_preferred_language', $this->pref_lang );
|
192 |
|
193 |
// inform that the admin language has been set
|
194 |
// only if the admin language is one of the Polylang defined language
|
195 |
if ( $curlang = $this->model->get_language( get_locale() ) ) {
|
196 |
$GLOBALS['text_direction'] = $curlang->is_rtl ? 'rtl' : 'ltr'; // force text direction according to language setting
|
|
|
197 |
do_action( 'pll_language_defined', $curlang->slug, $curlang );
|
198 |
}
|
199 |
else {
|
|
|
200 |
do_action( 'pll_no_language_defined' ); // to load overriden textdomains
|
201 |
}
|
202 |
}
|
203 |
|
204 |
-
|
205 |
* avoids parsing a tax query when all languages are requested
|
206 |
* fixes https://wordpress.org/support/topic/notice-undefined-offset-0-in-wp-includesqueryphp-on-line-3877 introduced in WP 4.1
|
207 |
* @see the suggestion of @boonebgorges, https://core.trac.wordpress.org/ticket/31246
|
@@ -219,7 +230,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
219 |
return $qvars;
|
220 |
}
|
221 |
|
222 |
-
|
223 |
* get the locale based on user preference
|
224 |
*
|
225 |
* @since 0.4
|
@@ -231,7 +242,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
231 |
return ( $loc = get_user_meta( get_current_user_id(), 'user_lang', 'true' ) ) ? $loc : $locale;
|
232 |
}
|
233 |
|
234 |
-
|
235 |
* adds the languages list in admin bar for the admin languages filter
|
236 |
*
|
237 |
* @since 0.9
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* base class for both admin
|
5 |
*
|
6 |
* @since 1.8
|
8 |
class PLL_Admin_Base extends PLL_Base {
|
9 |
public $curlang, $pref_lang;
|
10 |
|
11 |
+
/**
|
12 |
* loads the polylang text domain
|
13 |
* setups actions needed on all admin pages
|
14 |
*
|
35 |
}
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
* setups filters and action needed on all admin pages and on plugins page
|
40 |
* loads the settings pages or the filters base on the request
|
41 |
*
|
61 |
add_action( 'admin_bar_menu', array( &$this, 'admin_bar_menu' ), 100 ); // 100 determines the position
|
62 |
}
|
63 |
|
64 |
+
/**
|
65 |
* adds the link to the languages panel in the WordPress admin menu
|
66 |
*
|
67 |
* @since 0.1
|
70 |
add_submenu_page( 'options-general.php', $title = __( 'Languages', 'polylang' ), $title, 'manage_options', 'mlang', '__return_null' );
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
* setup js scripts & css styles ( only on the relevant pages )
|
75 |
*
|
76 |
* @since 0.6
|
105 |
wp_enqueue_style( 'polylang_admin', POLYLANG_URL .'/css/admin'.$suffix.'.css', array(), POLYLANG_VERSION );
|
106 |
}
|
107 |
|
108 |
+
/**
|
109 |
* sets pll_ajax_backend on all backend ajax request
|
110 |
* the final goal is to detect if an ajax request is made on admin or frontend
|
111 |
*
|
169 |
|
170 |
}
|
171 |
|
172 |
+
/**
|
173 |
* defines the backend language and the admin language filter based on user preferences
|
174 |
*
|
175 |
* @since 1.2.3
|
188 |
|
189 |
// set preferred language for use when saving posts and terms: must not be empty
|
190 |
$this->pref_lang = empty( $this->curlang ) ? $this->model->get_language( $this->options['default_lang'] ) : $this->curlang;
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Filter the preferred language on amin side
|
194 |
+
* The preferred language is used for example to determine the language of a new post
|
195 |
+
*
|
196 |
+
* @since 1.2.3
|
197 |
+
*
|
198 |
+
* @param object $pref_lang preferred language
|
199 |
+
*/
|
200 |
$this->pref_lang = apply_filters( 'pll_admin_preferred_language', $this->pref_lang );
|
201 |
|
202 |
// inform that the admin language has been set
|
203 |
// only if the admin language is one of the Polylang defined language
|
204 |
if ( $curlang = $this->model->get_language( get_locale() ) ) {
|
205 |
$GLOBALS['text_direction'] = $curlang->is_rtl ? 'rtl' : 'ltr'; // force text direction according to language setting
|
206 |
+
/** This action is documented in frontend/choose-lang.php */
|
207 |
do_action( 'pll_language_defined', $curlang->slug, $curlang );
|
208 |
}
|
209 |
else {
|
210 |
+
/** This action is documented in include/class-polylang.php */
|
211 |
do_action( 'pll_no_language_defined' ); // to load overriden textdomains
|
212 |
}
|
213 |
}
|
214 |
|
215 |
+
/**
|
216 |
* avoids parsing a tax query when all languages are requested
|
217 |
* fixes https://wordpress.org/support/topic/notice-undefined-offset-0-in-wp-includesqueryphp-on-line-3877 introduced in WP 4.1
|
218 |
* @see the suggestion of @boonebgorges, https://core.trac.wordpress.org/ticket/31246
|
230 |
return $qvars;
|
231 |
}
|
232 |
|
233 |
+
/**
|
234 |
* get the locale based on user preference
|
235 |
*
|
236 |
* @since 0.4
|
242 |
return ( $loc = get_user_meta( get_current_user_id(), 'user_lang', 'true' ) ) ? $loc : $locale;
|
243 |
}
|
244 |
|
245 |
+
/**
|
246 |
* adds the languages list in admin bar for the admin languages filter
|
247 |
*
|
248 |
* @since 0.9
|
admin/admin-filters-columns.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* adds the language column in posts and terms list tables
|
5 |
* manages quick edit and bulk edit as well
|
6 |
*
|
@@ -9,7 +9,7 @@
|
|
9 |
class PLL_Admin_Filters_Columns {
|
10 |
public $links, $model, $curlang;
|
11 |
|
12 |
-
|
13 |
* constructor: setups filters and actions
|
14 |
*
|
15 |
* @since 1.2
|
@@ -44,7 +44,7 @@ class PLL_Admin_Filters_Columns {
|
|
44 |
add_action( 'wp_ajax_pll_update_term_rows', array( &$this, 'ajax_update_term_rows' ) );
|
45 |
}
|
46 |
|
47 |
-
|
48 |
* adds languages and translations columns in posts, pages, media, categories and tags tables
|
49 |
*
|
50 |
* @since 0.8.2
|
@@ -69,7 +69,7 @@ class PLL_Admin_Filters_Columns {
|
|
69 |
return isset( $end ) ? array_merge( $columns, $end ) : $columns;
|
70 |
}
|
71 |
|
72 |
-
|
73 |
* returns the first language column in the posts, pages and media library tables
|
74 |
*
|
75 |
* @since 0.9
|
@@ -86,7 +86,7 @@ class PLL_Admin_Filters_Columns {
|
|
86 |
return empty( $columns ) ? '' : reset( $columns );
|
87 |
}
|
88 |
|
89 |
-
|
90 |
* adds the language and translations columns ( before the comments column ) in the posts, pages and media library tables
|
91 |
*
|
92 |
* @since 0.1
|
@@ -98,7 +98,7 @@ class PLL_Admin_Filters_Columns {
|
|
98 |
return $this->add_column( $columns, 'comments' );
|
99 |
}
|
100 |
|
101 |
-
|
102 |
* fills the language and translations columns in the posts, pages and media library tables
|
103 |
* take care that when doing ajax inline edit, the post may not be updated in database yet
|
104 |
*
|
@@ -140,7 +140,7 @@ class PLL_Admin_Filters_Columns {
|
|
140 |
}
|
141 |
printf(
|
142 |
'<a class="%1$s" title="%2$s" href="%3$s"><span class="screen-reader-text">%4$s</span></a>',
|
143 |
-
$class, esc_attr( get_post( $id )->post_title ), esc_url( $link ), esc_html( $s )
|
144 |
);
|
145 |
} elseif ( $id === $post_id ) {
|
146 |
printf(
|
@@ -156,7 +156,7 @@ class PLL_Admin_Filters_Columns {
|
|
156 |
}
|
157 |
}
|
158 |
|
159 |
-
|
160 |
* quick edit & bulk edit
|
161 |
*
|
162 |
* @since 0.9
|
@@ -191,7 +191,7 @@ class PLL_Admin_Filters_Columns {
|
|
191 |
return $column;
|
192 |
}
|
193 |
|
194 |
-
|
195 |
* adds the language column ( before the posts column ) in the 'Categories' or 'Post Tags' table
|
196 |
*
|
197 |
* @since 0.1
|
@@ -203,7 +203,7 @@ class PLL_Admin_Filters_Columns {
|
|
203 |
return $this->add_column( $columns, 'posts' );
|
204 |
}
|
205 |
|
206 |
-
|
207 |
* fills the language column in the 'Categories' or 'Post Tags' table
|
208 |
*
|
209 |
* @since 0.1
|
@@ -270,7 +270,7 @@ class PLL_Admin_Filters_Columns {
|
|
270 |
return $out;
|
271 |
}
|
272 |
|
273 |
-
|
274 |
* update rows of translated posts when the language is modified in quick edit
|
275 |
*
|
276 |
* @since 1.7
|
@@ -304,7 +304,7 @@ class PLL_Admin_Filters_Columns {
|
|
304 |
$x->send();
|
305 |
}
|
306 |
|
307 |
-
|
308 |
* update rows of translated terms when adding / deleting a translation or when the language is modified in quick edit
|
309 |
*
|
310 |
* @since 1.7
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* adds the language column in posts and terms list tables
|
5 |
* manages quick edit and bulk edit as well
|
6 |
*
|
9 |
class PLL_Admin_Filters_Columns {
|
10 |
public $links, $model, $curlang;
|
11 |
|
12 |
+
/**
|
13 |
* constructor: setups filters and actions
|
14 |
*
|
15 |
* @since 1.2
|
44 |
add_action( 'wp_ajax_pll_update_term_rows', array( &$this, 'ajax_update_term_rows' ) );
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
* adds languages and translations columns in posts, pages, media, categories and tags tables
|
49 |
*
|
50 |
* @since 0.8.2
|
69 |
return isset( $end ) ? array_merge( $columns, $end ) : $columns;
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
* returns the first language column in the posts, pages and media library tables
|
74 |
*
|
75 |
* @since 0.9
|
86 |
return empty( $columns ) ? '' : reset( $columns );
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
* adds the language and translations columns ( before the comments column ) in the posts, pages and media library tables
|
91 |
*
|
92 |
* @since 0.1
|
98 |
return $this->add_column( $columns, 'comments' );
|
99 |
}
|
100 |
|
101 |
+
/**
|
102 |
* fills the language and translations columns in the posts, pages and media library tables
|
103 |
* take care that when doing ajax inline edit, the post may not be updated in database yet
|
104 |
*
|
140 |
}
|
141 |
printf(
|
142 |
'<a class="%1$s" title="%2$s" href="%3$s"><span class="screen-reader-text">%4$s</span></a>',
|
143 |
+
esc_attr( $class ), esc_attr( get_post( $id )->post_title ), esc_url( $link ), esc_html( $s )
|
144 |
);
|
145 |
} elseif ( $id === $post_id ) {
|
146 |
printf(
|
156 |
}
|
157 |
}
|
158 |
|
159 |
+
/**
|
160 |
* quick edit & bulk edit
|
161 |
*
|
162 |
* @since 0.9
|
191 |
return $column;
|
192 |
}
|
193 |
|
194 |
+
/**
|
195 |
* adds the language column ( before the posts column ) in the 'Categories' or 'Post Tags' table
|
196 |
*
|
197 |
* @since 0.1
|
203 |
return $this->add_column( $columns, 'posts' );
|
204 |
}
|
205 |
|
206 |
+
/**
|
207 |
* fills the language column in the 'Categories' or 'Post Tags' table
|
208 |
*
|
209 |
* @since 0.1
|
270 |
return $out;
|
271 |
}
|
272 |
|
273 |
+
/**
|
274 |
* update rows of translated posts when the language is modified in quick edit
|
275 |
*
|
276 |
* @since 1.7
|
304 |
$x->send();
|
305 |
}
|
306 |
|
307 |
+
/**
|
308 |
* update rows of translated terms when adding / deleting a translation or when the language is modified in quick edit
|
309 |
*
|
310 |
* @since 1.7
|
admin/admin-filters-media.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages filters and actions related to media on admin side
|
5 |
* capability to edit / create media is checked before loading this class
|
6 |
*
|
7 |
* @since 1.2
|
8 |
*/
|
9 |
class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
10 |
-
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.2
|
@@ -31,13 +31,13 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
31 |
}
|
32 |
}
|
33 |
|
34 |
-
|
35 |
* adds the language field and translations tables in the 'Edit Media' panel
|
36 |
* needs WP 3.5+
|
37 |
*
|
38 |
* @since 0.9
|
39 |
*
|
40 |
-
* @param array
|
41 |
* @param object $post
|
42 |
* @return array modified list of form fields
|
43 |
*/
|
@@ -63,12 +63,12 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
63 |
return $fields;
|
64 |
}
|
65 |
|
66 |
-
|
67 |
* creates a media translation
|
68 |
*
|
69 |
* @since 1.8
|
70 |
*
|
71 |
-
* @param int
|
72 |
* @param string|object $lang
|
73 |
* @return int id of the translated media
|
74 |
*/
|
@@ -99,11 +99,20 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
99 |
$translations[ $lang->slug ] = $tr_id;
|
100 |
$this->model->post->save_translations( $tr_id, $translations );
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
do_action( 'pll_translate_media', $post_id, $tr_id, $lang->slug );
|
103 |
return $tr_id;
|
104 |
}
|
105 |
|
106 |
-
|
107 |
* creates a media translation
|
108 |
*
|
109 |
* @since 0.9
|
@@ -125,7 +134,7 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
125 |
exit;
|
126 |
}
|
127 |
|
128 |
-
|
129 |
* called when a media is saved
|
130 |
* saves language and translations
|
131 |
*
|
@@ -149,7 +158,7 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
149 |
return $post;
|
150 |
}
|
151 |
|
152 |
-
|
153 |
* prevents WP deleting files when there are still media using them
|
154 |
* thanks to Bruno "Aesqe" Babic and its plugin file gallery in which I took all the ideas for this function
|
155 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages filters and actions related to media on admin side
|
5 |
* capability to edit / create media is checked before loading this class
|
6 |
*
|
7 |
* @since 1.2
|
8 |
*/
|
9 |
class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
10 |
+
/**
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.2
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
* adds the language field and translations tables in the 'Edit Media' panel
|
36 |
* needs WP 3.5+
|
37 |
*
|
38 |
* @since 0.9
|
39 |
*
|
40 |
+
* @param array $fields list of form fields
|
41 |
* @param object $post
|
42 |
* @return array modified list of form fields
|
43 |
*/
|
63 |
return $fields;
|
64 |
}
|
65 |
|
66 |
+
/**
|
67 |
* creates a media translation
|
68 |
*
|
69 |
* @since 1.8
|
70 |
*
|
71 |
+
* @param int $post_id
|
72 |
* @param string|object $lang
|
73 |
* @return int id of the translated media
|
74 |
*/
|
99 |
$translations[ $lang->slug ] = $tr_id;
|
100 |
$this->model->post->save_translations( $tr_id, $translations );
|
101 |
|
102 |
+
/**
|
103 |
+
* Fires after a media translation is created
|
104 |
+
*
|
105 |
+
* @since 1.6.4
|
106 |
+
*
|
107 |
+
* @param int $post_id post id of the source media
|
108 |
+
* @param int $tr_id post id of the new media translation
|
109 |
+
* @param string $slug language code of the new translation
|
110 |
+
*/
|
111 |
do_action( 'pll_translate_media', $post_id, $tr_id, $lang->slug );
|
112 |
return $tr_id;
|
113 |
}
|
114 |
|
115 |
+
/**
|
116 |
* creates a media translation
|
117 |
*
|
118 |
* @since 0.9
|
134 |
exit;
|
135 |
}
|
136 |
|
137 |
+
/**
|
138 |
* called when a media is saved
|
139 |
* saves language and translations
|
140 |
*
|
158 |
return $post;
|
159 |
}
|
160 |
|
161 |
+
/**
|
162 |
* prevents WP deleting files when there are still media using them
|
163 |
* thanks to Bruno "Aesqe" Babic and its plugin file gallery in which I took all the ideas for this function
|
164 |
*
|
admin/admin-filters-post-base.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* some common code for PLL_Admin_Filters_Post and PLL_Admin_Filters_Media
|
5 |
*
|
6 |
* @since 1.5
|
@@ -8,7 +8,7 @@
|
|
8 |
abstract class PLL_Admin_Filters_Post_Base {
|
9 |
public $links, $model, $pref_lang;
|
10 |
|
11 |
-
|
12 |
* constructor: setups filters and actions
|
13 |
*
|
14 |
* @since 1.2
|
@@ -21,7 +21,7 @@ abstract class PLL_Admin_Filters_Post_Base {
|
|
21 |
$this->pref_lang = &$polylang->pref_lang;
|
22 |
}
|
23 |
|
24 |
-
|
25 |
* allows to set a language by default for posts if it has no language yet
|
26 |
*
|
27 |
* @since 1.5
|
@@ -44,7 +44,7 @@ abstract class PLL_Admin_Filters_Post_Base {
|
|
44 |
}
|
45 |
}
|
46 |
|
47 |
-
|
48 |
* save translations from language metabox
|
49 |
*
|
50 |
* @since 1.5
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* some common code for PLL_Admin_Filters_Post and PLL_Admin_Filters_Media
|
5 |
*
|
6 |
* @since 1.5
|
8 |
abstract class PLL_Admin_Filters_Post_Base {
|
9 |
public $links, $model, $pref_lang;
|
10 |
|
11 |
+
/**
|
12 |
* constructor: setups filters and actions
|
13 |
*
|
14 |
* @since 1.2
|
21 |
$this->pref_lang = &$polylang->pref_lang;
|
22 |
}
|
23 |
|
24 |
+
/**
|
25 |
* allows to set a language by default for posts if it has no language yet
|
26 |
*
|
27 |
* @since 1.5
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
* save translations from language metabox
|
49 |
*
|
50 |
* @since 1.5
|
admin/admin-filters-post.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages filters and actions related to posts on admin side
|
5 |
*
|
6 |
* @since 1.2
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
9 |
public $options, $curlang;
|
10 |
|
11 |
-
|
12 |
* constructor: setups filters and actions
|
13 |
*
|
14 |
* @since 1.2
|
@@ -44,7 +44,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
44 |
add_filter( 'page_attributes_dropdown_pages_args', array( &$this, 'page_attributes_dropdown_pages_args' ), 10, 2 );
|
45 |
}
|
46 |
|
47 |
-
|
48 |
* outputs a javascript list of terms ordered by language and hierarchical taxonomies
|
49 |
* to filter the category checklist per post language in quick edit
|
50 |
* outputs a javascript list of pages ordered by language
|
@@ -97,7 +97,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
97 |
}
|
98 |
}
|
99 |
|
100 |
-
|
101 |
* filters posts, pages and media by language
|
102 |
*
|
103 |
* @since 0.1
|
@@ -127,7 +127,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
127 |
}
|
128 |
}
|
129 |
|
130 |
-
|
131 |
* adds the Language box in the 'Edit Post' and 'Edit Page' panels ( as well as in custom post types panels )
|
132 |
*
|
133 |
* @since 0.1
|
@@ -140,7 +140,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
140 |
}
|
141 |
}
|
142 |
|
143 |
-
|
144 |
* displays the Languages metabox in the 'Edit Post' and 'Edit Page' panels
|
145 |
*
|
146 |
* @since 0.1
|
@@ -162,8 +162,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
162 |
printf( '
|
163 |
<p><strong>%1$s</strong></p>
|
164 |
<label class="screen-reader-text" for="%2$s">%1$s</label>
|
165 |
-
<div id="select-%3$s-language">%4$s</div>
|
166 |
-
<div id="post-translations" class="translations">',
|
167 |
__( 'Language', 'polylang' ),
|
168 |
$id = ( 'attachment' === $post_type ) ? sprintf( 'attachments[%d][language]', $post_ID ) : 'post_lang_choice',
|
169 |
'attachment' === $post_type ? 'media' : 'post',
|
@@ -171,17 +170,25 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
171 |
'name' => $id,
|
172 |
'class' => 'post_lang_choice tags-input',
|
173 |
'selected' => $lang ? $lang->slug : '',
|
174 |
-
'flag' => true
|
175 |
) )
|
176 |
);
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
if ( $lang ) {
|
179 |
include( PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php' );
|
180 |
}
|
181 |
echo '</div>' . "\n";
|
182 |
}
|
183 |
|
184 |
-
|
185 |
* ajax response for changing the language in the post metabox
|
186 |
*
|
187 |
* @since 0.2
|
@@ -253,6 +260,8 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
253 |
'sort_column' => 'menu_order, post_title',
|
254 |
'echo' => 0,
|
255 |
);
|
|
|
|
|
256 |
$dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); // since WP 3.3
|
257 |
|
258 |
$x->Add( array( 'what' => 'pages', 'data' => wp_dropdown_pages( $dropdown_args ) ) );
|
@@ -264,7 +273,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
264 |
$x->send();
|
265 |
}
|
266 |
|
267 |
-
|
268 |
* ajax response for input in translation autocomplete input box
|
269 |
*
|
270 |
* @since 1.5
|
@@ -291,10 +300,19 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
291 |
'taxonomy' => 'language',
|
292 |
'field' => 'term_taxonomy_id', // WP 3.5+
|
293 |
'terms' => $translation_language->term_taxonomy_id,
|
294 |
-
) )
|
295 |
);
|
296 |
|
297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
$args = apply_filters( 'pll_ajax_posts_not_translated_args', $args );
|
299 |
$posts = get_posts( $args );
|
300 |
|
@@ -323,7 +341,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
323 |
wp_die( json_encode( $return ) );
|
324 |
}
|
325 |
|
326 |
-
|
327 |
* saves language
|
328 |
* checks the terms saved are in the right language
|
329 |
*
|
@@ -416,7 +434,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
416 |
}
|
417 |
}
|
418 |
|
419 |
-
|
420 |
* called when a post ( or page ) is saved, published or updated
|
421 |
* saves languages and translations
|
422 |
*
|
@@ -446,6 +464,15 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
446 |
$translations = $this->save_translations( $post_id, $_POST['post_tr_lang'] );
|
447 |
}
|
448 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
do_action( 'pll_save_post', $post_id, $post, empty( $translations ) ? $this->model->post->get_translations( $post_id ) : $translations );
|
450 |
}
|
451 |
|
@@ -455,7 +482,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
455 |
}
|
456 |
}
|
457 |
|
458 |
-
|
459 |
* make sure that the post parent is in the correct language when using bulk edit
|
460 |
*
|
461 |
* @since 1.8
|
@@ -477,7 +504,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
477 |
return $post_parent;
|
478 |
}
|
479 |
|
480 |
-
|
481 |
* called when a post, page or media is deleted
|
482 |
* don't delete translations if this is a post revision thanks to AndyDeGroo who catched this bug
|
483 |
* http://wordpress.org/support/topic/plugin-polylang-quick-edit-still-breaks-translation-linking-of-pages-in-072
|
@@ -492,7 +519,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
492 |
}
|
493 |
}
|
494 |
|
495 |
-
|
496 |
* filters the pages by language in the parent dropdown list in the page attributes metabox
|
497 |
*
|
498 |
* @since 0.6
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages filters and actions related to posts on admin side
|
5 |
*
|
6 |
* @since 1.2
|
8 |
class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
9 |
public $options, $curlang;
|
10 |
|
11 |
+
/**
|
12 |
* constructor: setups filters and actions
|
13 |
*
|
14 |
* @since 1.2
|
44 |
add_filter( 'page_attributes_dropdown_pages_args', array( &$this, 'page_attributes_dropdown_pages_args' ), 10, 2 );
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
* outputs a javascript list of terms ordered by language and hierarchical taxonomies
|
49 |
* to filter the category checklist per post language in quick edit
|
50 |
* outputs a javascript list of pages ordered by language
|
97 |
}
|
98 |
}
|
99 |
|
100 |
+
/**
|
101 |
* filters posts, pages and media by language
|
102 |
*
|
103 |
* @since 0.1
|
127 |
}
|
128 |
}
|
129 |
|
130 |
+
/**
|
131 |
* adds the Language box in the 'Edit Post' and 'Edit Page' panels ( as well as in custom post types panels )
|
132 |
*
|
133 |
* @since 0.1
|
140 |
}
|
141 |
}
|
142 |
|
143 |
+
/**
|
144 |
* displays the Languages metabox in the 'Edit Post' and 'Edit Page' panels
|
145 |
*
|
146 |
* @since 0.1
|
162 |
printf( '
|
163 |
<p><strong>%1$s</strong></p>
|
164 |
<label class="screen-reader-text" for="%2$s">%1$s</label>
|
165 |
+
<div id="select-%3$s-language">%4$s</div>',
|
|
|
166 |
__( 'Language', 'polylang' ),
|
167 |
$id = ( 'attachment' === $post_type ) ? sprintf( 'attachments[%d][language]', $post_ID ) : 'post_lang_choice',
|
168 |
'attachment' === $post_type ? 'media' : 'post',
|
170 |
'name' => $id,
|
171 |
'class' => 'post_lang_choice tags-input',
|
172 |
'selected' => $lang ? $lang->slug : '',
|
173 |
+
'flag' => true,
|
174 |
) )
|
175 |
);
|
176 |
|
177 |
+
/**
|
178 |
+
* Fires before displaying the list of translations in the Languages metabox for posts
|
179 |
+
*
|
180 |
+
* @since 1.8
|
181 |
+
*/
|
182 |
+
do_action( 'pll_before_post_translations', $post_type );
|
183 |
+
|
184 |
+
echo '<div id="post-translations" class="translations">';
|
185 |
if ( $lang ) {
|
186 |
include( PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php' );
|
187 |
}
|
188 |
echo '</div>' . "\n";
|
189 |
}
|
190 |
|
191 |
+
/**
|
192 |
* ajax response for changing the language in the post metabox
|
193 |
*
|
194 |
* @since 0.2
|
260 |
'sort_column' => 'menu_order, post_title',
|
261 |
'echo' => 0,
|
262 |
);
|
263 |
+
|
264 |
+
/** This filter is documented in wp-admin/includes/meta-boxes.php */
|
265 |
$dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); // since WP 3.3
|
266 |
|
267 |
$x->Add( array( 'what' => 'pages', 'data' => wp_dropdown_pages( $dropdown_args ) ) );
|
273 |
$x->send();
|
274 |
}
|
275 |
|
276 |
+
/**
|
277 |
* ajax response for input in translation autocomplete input box
|
278 |
*
|
279 |
* @since 1.5
|
300 |
'taxonomy' => 'language',
|
301 |
'field' => 'term_taxonomy_id', // WP 3.5+
|
302 |
'terms' => $translation_language->term_taxonomy_id,
|
303 |
+
) ),
|
304 |
);
|
305 |
|
306 |
+
/**
|
307 |
+
* Filter the query args when auto suggesting untranslated posts in the Languages metabox
|
308 |
+
* This should help plugins to fix some edge cases
|
309 |
+
*
|
310 |
+
* @see https://wordpress.org/support/topic/find-translated-post-when-10-is-not-enough
|
311 |
+
*
|
312 |
+
* @since 1.7
|
313 |
+
*
|
314 |
+
* @param array $args WP_Query arguments
|
315 |
+
*/
|
316 |
$args = apply_filters( 'pll_ajax_posts_not_translated_args', $args );
|
317 |
$posts = get_posts( $args );
|
318 |
|
341 |
wp_die( json_encode( $return ) );
|
342 |
}
|
343 |
|
344 |
+
/**
|
345 |
* saves language
|
346 |
* checks the terms saved are in the right language
|
347 |
*
|
434 |
}
|
435 |
}
|
436 |
|
437 |
+
/**
|
438 |
* called when a post ( or page ) is saved, published or updated
|
439 |
* saves languages and translations
|
440 |
*
|
464 |
$translations = $this->save_translations( $post_id, $_POST['post_tr_lang'] );
|
465 |
}
|
466 |
|
467 |
+
/**
|
468 |
+
* Fires after the post language and translations are saved
|
469 |
+
*
|
470 |
+
* @since 1.2
|
471 |
+
*
|
472 |
+
* @param int $post_id post id
|
473 |
+
* @param object $post post object
|
474 |
+
* @param array $translations the list of translations post ids
|
475 |
+
*/
|
476 |
do_action( 'pll_save_post', $post_id, $post, empty( $translations ) ? $this->model->post->get_translations( $post_id ) : $translations );
|
477 |
}
|
478 |
|
482 |
}
|
483 |
}
|
484 |
|
485 |
+
/**
|
486 |
* make sure that the post parent is in the correct language when using bulk edit
|
487 |
*
|
488 |
* @since 1.8
|
504 |
return $post_parent;
|
505 |
}
|
506 |
|
507 |
+
/**
|
508 |
* called when a post, page or media is deleted
|
509 |
* don't delete translations if this is a post revision thanks to AndyDeGroo who catched this bug
|
510 |
* http://wordpress.org/support/topic/plugin-polylang-quick-edit-still-breaks-translation-linking-of-pages-in-072
|
519 |
}
|
520 |
}
|
521 |
|
522 |
+
/**
|
523 |
* filters the pages by language in the parent dropdown list in the page attributes metabox
|
524 |
*
|
525 |
* @since 0.6
|
admin/admin-filters-term.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages filters and actions related to terms on admin side
|
5 |
*
|
6 |
* @since 1.2
|
@@ -10,7 +10,7 @@ class PLL_Admin_Filters_Term {
|
|
10 |
protected $pre_term_name; // used to store the term name before creating a slug if needed
|
11 |
protected $post_id; // used to store the current post_id when bulk editing posts
|
12 |
|
13 |
-
|
14 |
* constructor: setups filters and actions
|
15 |
*
|
16 |
* @param object $polylang
|
@@ -59,7 +59,7 @@ class PLL_Admin_Filters_Term {
|
|
59 |
add_action( 'split_shared_term', array( &$this, 'split_shared_term' ), 10, 4 ); // WP 4.2
|
60 |
}
|
61 |
|
62 |
-
|
63 |
* adds the language field in the 'Categories' and 'Post Tags' panels
|
64 |
*
|
65 |
* @since 0.1
|
@@ -88,7 +88,7 @@ class PLL_Admin_Filters_Term {
|
|
88 |
'name' => 'term_lang_choice',
|
89 |
'value' => 'term_id',
|
90 |
'selected' => $lang ? $lang->term_id : '',
|
91 |
-
'flag' => true
|
92 |
) ),
|
93 |
__( 'Sets the language', 'polylang' )
|
94 |
);
|
@@ -105,7 +105,7 @@ class PLL_Admin_Filters_Term {
|
|
105 |
echo '</div>'."\n";
|
106 |
}
|
107 |
|
108 |
-
|
109 |
* adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
|
110 |
*
|
111 |
* @since 0.1
|
@@ -143,7 +143,7 @@ class PLL_Admin_Filters_Term {
|
|
143 |
'value' => 'term_id',
|
144 |
'selected' => $lang ? $lang->term_id : '',
|
145 |
'disabled' => $disabled,
|
146 |
-
'flag' => true
|
147 |
) ),
|
148 |
__( 'Sets the language', 'polylang' )
|
149 |
);
|
@@ -155,7 +155,7 @@ class PLL_Admin_Filters_Term {
|
|
155 |
echo '</tr>'."\n";
|
156 |
}
|
157 |
|
158 |
-
|
159 |
* translates term parent if exists when using "Add new" ( translation )
|
160 |
*
|
161 |
* @since 0.7
|
@@ -173,7 +173,7 @@ class PLL_Admin_Filters_Term {
|
|
173 |
return $output;
|
174 |
}
|
175 |
|
176 |
-
|
177 |
* stores the current post_id when bulk editing posts for use in save_language and pre_term_slug
|
178 |
*
|
179 |
* @since 1.7
|
@@ -186,12 +186,12 @@ class PLL_Admin_Filters_Term {
|
|
186 |
}
|
187 |
}
|
188 |
|
189 |
-
|
190 |
* allows to set a language by default for terms if it has no language yet
|
191 |
*
|
192 |
* @since 1.5.4
|
193 |
*
|
194 |
-
* @param int
|
195 |
* @param string $taxonomy
|
196 |
*/
|
197 |
protected function set_default_language( $term_id, $taxonomy ) {
|
@@ -206,12 +206,12 @@ class PLL_Admin_Filters_Term {
|
|
206 |
}
|
207 |
}
|
208 |
|
209 |
-
|
210 |
* saves language
|
211 |
*
|
212 |
* @since 1.5
|
213 |
*
|
214 |
-
* @param int
|
215 |
* @param string $taxonomy
|
216 |
*/
|
217 |
protected function save_language( $term_id, $taxonomy ) {
|
@@ -306,7 +306,7 @@ class PLL_Admin_Filters_Term {
|
|
306 |
}
|
307 |
}
|
308 |
|
309 |
-
|
310 |
* save translations from our form
|
311 |
*
|
312 |
* @since 1.5
|
@@ -330,14 +330,14 @@ class PLL_Admin_Filters_Term {
|
|
330 |
return $translations;
|
331 |
}
|
332 |
|
333 |
-
|
334 |
* called when a category or post tag is created or edited
|
335 |
* saves language and translations
|
336 |
*
|
337 |
* @since 0.1
|
338 |
*
|
339 |
-
* @param int
|
340 |
-
* @param int
|
341 |
* @param string $taxonomy
|
342 |
*/
|
343 |
public function save_term( $term_id, $tt_id, $taxonomy ) {
|
@@ -357,6 +357,15 @@ class PLL_Admin_Filters_Term {
|
|
357 |
$translations = $this->save_translations( $term_id );
|
358 |
}
|
359 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
do_action( 'pll_save_term', $term_id, $taxonomy, empty( $translations ) ? $this->model->term->get_translations( $term_id ) : $translations );
|
361 |
}
|
362 |
|
@@ -366,7 +375,7 @@ class PLL_Admin_Filters_Term {
|
|
366 |
}
|
367 |
}
|
368 |
|
369 |
-
|
370 |
* stores the term name for use in pre_term_slug
|
371 |
*
|
372 |
* @since 0.9.5
|
@@ -378,7 +387,7 @@ class PLL_Admin_Filters_Term {
|
|
378 |
return $this->pre_term_name = $name;
|
379 |
}
|
380 |
|
381 |
-
|
382 |
* creates the term slug in case the term already exists in another language
|
383 |
*
|
384 |
* @since 0.9.5
|
@@ -422,7 +431,7 @@ class PLL_Admin_Filters_Term {
|
|
422 |
return $slug;
|
423 |
}
|
424 |
|
425 |
-
|
426 |
* called when a category or post tag is deleted
|
427 |
* deletes language and translations
|
428 |
*
|
@@ -435,7 +444,7 @@ class PLL_Admin_Filters_Term {
|
|
435 |
$this->model->term->delete_language( $term_id );
|
436 |
}
|
437 |
|
438 |
-
|
439 |
* ajax response for edit term form
|
440 |
*
|
441 |
* @since 0.2
|
@@ -497,7 +506,7 @@ class PLL_Admin_Filters_Term {
|
|
497 |
$x->send();
|
498 |
}
|
499 |
|
500 |
-
|
501 |
* ajax response for input in translation autocomplete input box
|
502 |
*
|
503 |
* @since 1.5
|
@@ -547,13 +556,13 @@ class PLL_Admin_Filters_Term {
|
|
547 |
}
|
548 |
|
549 |
|
550 |
-
|
551 |
* get the language(s) to filter get_terms
|
552 |
*
|
553 |
* @since 1.7.6
|
554 |
*
|
555 |
* @param array $taxonomies queried taxonomies
|
556 |
-
* @param array $args
|
557 |
* @return object|string|bool the language(s) to use in the filter, false otherwise
|
558 |
*/
|
559 |
protected function get_queried_language( $taxonomies, $args ) {
|
@@ -656,7 +665,7 @@ class PLL_Admin_Filters_Term {
|
|
656 |
return empty( $lang ) ? false : $lang;
|
657 |
}
|
658 |
|
659 |
-
|
660 |
* adds language dependent cache domain when querying terms
|
661 |
* useful as the 'lang' parameter is not included in cache key by WordPress
|
662 |
*
|
@@ -674,14 +683,14 @@ class PLL_Admin_Filters_Term {
|
|
674 |
return $args;
|
675 |
}
|
676 |
|
677 |
-
|
678 |
* filters categories and post tags by language(s) when needed on admin side
|
679 |
*
|
680 |
* @since 0.5
|
681 |
*
|
682 |
-
* @param array $clauses
|
683 |
* @param array $taxonomies list of taxonomies
|
684 |
-
* @param array $args
|
685 |
* @return array modified sql clauses
|
686 |
*/
|
687 |
public function terms_clauses( $clauses, $taxonomies, $args ) {
|
@@ -689,7 +698,7 @@ class PLL_Admin_Filters_Term {
|
|
689 |
return ! empty( $lang ) ? $this->model->terms_clauses( $clauses, $lang ) : $clauses; // adds our clauses to filter by current language
|
690 |
}
|
691 |
|
692 |
-
|
693 |
* hack to avoid displaying delete link for the default category in all languages
|
694 |
* also returns the default category in the right language when called from wp_delete_term
|
695 |
*
|
@@ -720,7 +729,7 @@ class PLL_Admin_Filters_Term {
|
|
720 |
return $value;
|
721 |
}
|
722 |
|
723 |
-
|
724 |
* checks if the new default category is translated in all languages
|
725 |
* if not, create the translations
|
726 |
*
|
@@ -745,7 +754,7 @@ class PLL_Admin_Filters_Term {
|
|
745 |
}
|
746 |
}
|
747 |
|
748 |
-
|
749 |
* updates the translations term ids when splitting a shared term
|
750 |
* splits translations if these are shared terms too
|
751 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages filters and actions related to terms on admin side
|
5 |
*
|
6 |
* @since 1.2
|
10 |
protected $pre_term_name; // used to store the term name before creating a slug if needed
|
11 |
protected $post_id; // used to store the current post_id when bulk editing posts
|
12 |
|
13 |
+
/**
|
14 |
* constructor: setups filters and actions
|
15 |
*
|
16 |
* @param object $polylang
|
59 |
add_action( 'split_shared_term', array( &$this, 'split_shared_term' ), 10, 4 ); // WP 4.2
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
* adds the language field in the 'Categories' and 'Post Tags' panels
|
64 |
*
|
65 |
* @since 0.1
|
88 |
'name' => 'term_lang_choice',
|
89 |
'value' => 'term_id',
|
90 |
'selected' => $lang ? $lang->term_id : '',
|
91 |
+
'flag' => true,
|
92 |
) ),
|
93 |
__( 'Sets the language', 'polylang' )
|
94 |
);
|
105 |
echo '</div>'."\n";
|
106 |
}
|
107 |
|
108 |
+
/**
|
109 |
* adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
|
110 |
*
|
111 |
* @since 0.1
|
143 |
'value' => 'term_id',
|
144 |
'selected' => $lang ? $lang->term_id : '',
|
145 |
'disabled' => $disabled,
|
146 |
+
'flag' => true,
|
147 |
) ),
|
148 |
__( 'Sets the language', 'polylang' )
|
149 |
);
|
155 |
echo '</tr>'."\n";
|
156 |
}
|
157 |
|
158 |
+
/**
|
159 |
* translates term parent if exists when using "Add new" ( translation )
|
160 |
*
|
161 |
* @since 0.7
|
173 |
return $output;
|
174 |
}
|
175 |
|
176 |
+
/**
|
177 |
* stores the current post_id when bulk editing posts for use in save_language and pre_term_slug
|
178 |
*
|
179 |
* @since 1.7
|
186 |
}
|
187 |
}
|
188 |
|
189 |
+
/**
|
190 |
* allows to set a language by default for terms if it has no language yet
|
191 |
*
|
192 |
* @since 1.5.4
|
193 |
*
|
194 |
+
* @param int $term_id
|
195 |
* @param string $taxonomy
|
196 |
*/
|
197 |
protected function set_default_language( $term_id, $taxonomy ) {
|
206 |
}
|
207 |
}
|
208 |
|
209 |
+
/**
|
210 |
* saves language
|
211 |
*
|
212 |
* @since 1.5
|
213 |
*
|
214 |
+
* @param int $term_id
|
215 |
* @param string $taxonomy
|
216 |
*/
|
217 |
protected function save_language( $term_id, $taxonomy ) {
|
306 |
}
|
307 |
}
|
308 |
|
309 |
+
/**
|
310 |
* save translations from our form
|
311 |
*
|
312 |
* @since 1.5
|
330 |
return $translations;
|
331 |
}
|
332 |
|
333 |
+
/**
|
334 |
* called when a category or post tag is created or edited
|
335 |
* saves language and translations
|
336 |
*
|
337 |
* @since 0.1
|
338 |
*
|
339 |
+
* @param int $term_id
|
340 |
+
* @param int $tt_id term taxononomy id
|
341 |
* @param string $taxonomy
|
342 |
*/
|
343 |
public function save_term( $term_id, $tt_id, $taxonomy ) {
|
357 |
$translations = $this->save_translations( $term_id );
|
358 |
}
|
359 |
|
360 |
+
/**
|
361 |
+
* Fires after the term language and translations are saved
|
362 |
+
*
|
363 |
+
* @since 1.2
|
364 |
+
*
|
365 |
+
* @param int $term_id term id
|
366 |
+
* @param string $taxonomy taxonomy name
|
367 |
+
* @param array $translations the list of translations term ids
|
368 |
+
*/
|
369 |
do_action( 'pll_save_term', $term_id, $taxonomy, empty( $translations ) ? $this->model->term->get_translations( $term_id ) : $translations );
|
370 |
}
|
371 |
|
375 |
}
|
376 |
}
|
377 |
|
378 |
+
/**
|
379 |
* stores the term name for use in pre_term_slug
|
380 |
*
|
381 |
* @since 0.9.5
|
387 |
return $this->pre_term_name = $name;
|
388 |
}
|
389 |
|
390 |
+
/**
|
391 |
* creates the term slug in case the term already exists in another language
|
392 |
*
|
393 |
* @since 0.9.5
|
431 |
return $slug;
|
432 |
}
|
433 |
|
434 |
+
/**
|
435 |
* called when a category or post tag is deleted
|
436 |
* deletes language and translations
|
437 |
*
|
444 |
$this->model->term->delete_language( $term_id );
|
445 |
}
|
446 |
|
447 |
+
/**
|
448 |
* ajax response for edit term form
|
449 |
*
|
450 |
* @since 0.2
|
506 |
$x->send();
|
507 |
}
|
508 |
|
509 |
+
/**
|
510 |
* ajax response for input in translation autocomplete input box
|
511 |
*
|
512 |
* @since 1.5
|
556 |
}
|
557 |
|
558 |
|
559 |
+
/**
|
560 |
* get the language(s) to filter get_terms
|
561 |
*
|
562 |
* @since 1.7.6
|
563 |
*
|
564 |
* @param array $taxonomies queried taxonomies
|
565 |
+
* @param array $args get_terms arguments
|
566 |
* @return object|string|bool the language(s) to use in the filter, false otherwise
|
567 |
*/
|
568 |
protected function get_queried_language( $taxonomies, $args ) {
|
665 |
return empty( $lang ) ? false : $lang;
|
666 |
}
|
667 |
|
668 |
+
/**
|
669 |
* adds language dependent cache domain when querying terms
|
670 |
* useful as the 'lang' parameter is not included in cache key by WordPress
|
671 |
*
|
683 |
return $args;
|
684 |
}
|
685 |
|
686 |
+
/**
|
687 |
* filters categories and post tags by language(s) when needed on admin side
|
688 |
*
|
689 |
* @since 0.5
|
690 |
*
|
691 |
+
* @param array $clauses list of sql clauses
|
692 |
* @param array $taxonomies list of taxonomies
|
693 |
+
* @param array $args get_terms arguments
|
694 |
* @return array modified sql clauses
|
695 |
*/
|
696 |
public function terms_clauses( $clauses, $taxonomies, $args ) {
|
698 |
return ! empty( $lang ) ? $this->model->terms_clauses( $clauses, $lang ) : $clauses; // adds our clauses to filter by current language
|
699 |
}
|
700 |
|
701 |
+
/**
|
702 |
* hack to avoid displaying delete link for the default category in all languages
|
703 |
* also returns the default category in the right language when called from wp_delete_term
|
704 |
*
|
729 |
return $value;
|
730 |
}
|
731 |
|
732 |
+
/**
|
733 |
* checks if the new default category is translated in all languages
|
734 |
* if not, create the translations
|
735 |
*
|
754 |
}
|
755 |
}
|
756 |
|
757 |
+
/**
|
758 |
* updates the translations term ids when splitting a shared term
|
759 |
* splits translations if these are shared terms too
|
760 |
*
|
admin/admin-filters.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* setup miscellaneous admin filters as well as filters common to admin and frontend
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Admin_Filters extends PLL_Filters {
|
9 |
|
10 |
-
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.2
|
@@ -35,7 +35,7 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
35 |
add_filter( 'plugins_update_check_locales', array( &$this, 'update_check_locales' ) );
|
36 |
}
|
37 |
|
38 |
-
|
39 |
* modifies the widgets forms to add our language dropdwown list
|
40 |
*
|
41 |
* @since 0.3
|
@@ -61,15 +61,15 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
61 |
);
|
62 |
}
|
63 |
|
64 |
-
|
65 |
* called when widget options are saved
|
66 |
* saves the language associated to the widget
|
67 |
*
|
68 |
* @since 0.3
|
69 |
*
|
70 |
-
* @param array
|
71 |
-
* @param array
|
72 |
-
* @param array
|
73 |
* @param object $widget WP_Widget object
|
74 |
* @return array widget options
|
75 |
*/
|
@@ -84,7 +84,7 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
84 |
return $instance;
|
85 |
}
|
86 |
|
87 |
-
|
88 |
* updates language user preference set in user profile
|
89 |
*
|
90 |
* @since 0.4
|
@@ -100,12 +100,14 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
100 |
foreach ( $this->model->get_languages_list() as $lang ) {
|
101 |
$meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_' . $lang->slug;
|
102 |
$description = empty( $_POST[ 'description_' . $lang->slug ] ) ? '' : trim( $_POST[ 'description_' . $lang->slug ] );
|
|
|
|
|
103 |
$description = apply_filters( 'pre_user_description', $description ); // applies WP default filter wp_filter_kses
|
104 |
update_user_meta( $user_id, $meta, $description );
|
105 |
}
|
106 |
}
|
107 |
|
108 |
-
|
109 |
* form for language user preference in user profile
|
110 |
*
|
111 |
* @since 0.4
|
@@ -136,6 +138,8 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
136 |
// hidden informations to modify the biography form with js
|
137 |
foreach ( $this->model->get_languages_list() as $lang ) {
|
138 |
$meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_' . $lang->slug;
|
|
|
|
|
139 |
$description = apply_filters( 'user_description', get_user_meta( $profileuser->ID, $meta, true ) ); // applies WP default filter wp_kses_data
|
140 |
|
141 |
printf( '<input type="hidden" class="biography" name="%s___%s" value="%s" />',
|
@@ -146,7 +150,7 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
146 |
}
|
147 |
}
|
148 |
|
149 |
-
|
150 |
* ugprades languages files after a core upgrade
|
151 |
* only for backward compatibility WP < 4.0 *AND* Polylang < 1.6
|
152 |
*
|
@@ -157,12 +161,14 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
157 |
public function upgrade_languages( $version ) {
|
158 |
// $GLOBALS['wp_version'] is the old WP version
|
159 |
if ( version_compare( $version, '4.0', '>=' ) && version_compare( $GLOBALS['wp_version'], '4.0', '<' ) ) {
|
|
|
|
|
160 |
apply_filters( 'update_feedback', __( 'Upgrading language files…', 'polylang' ) );
|
161 |
PLL_Upgrade::download_language_packs();
|
162 |
}
|
163 |
}
|
164 |
|
165 |
-
|
166 |
* allows to update translations files for plugins and themes
|
167 |
*
|
168 |
* @since 1.6
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* setup miscellaneous admin filters as well as filters common to admin and frontend
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Admin_Filters extends PLL_Filters {
|
9 |
|
10 |
+
/**
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.2
|
35 |
add_filter( 'plugins_update_check_locales', array( &$this, 'update_check_locales' ) );
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
* modifies the widgets forms to add our language dropdwown list
|
40 |
*
|
41 |
* @since 0.3
|
61 |
);
|
62 |
}
|
63 |
|
64 |
+
/**
|
65 |
* called when widget options are saved
|
66 |
* saves the language associated to the widget
|
67 |
*
|
68 |
* @since 0.3
|
69 |
*
|
70 |
+
* @param array $instance widget options
|
71 |
+
* @param array $new_instance not used
|
72 |
+
* @param array $old_instance not used
|
73 |
* @param object $widget WP_Widget object
|
74 |
* @return array widget options
|
75 |
*/
|
84 |
return $instance;
|
85 |
}
|
86 |
|
87 |
+
/**
|
88 |
* updates language user preference set in user profile
|
89 |
*
|
90 |
* @since 0.4
|
100 |
foreach ( $this->model->get_languages_list() as $lang ) {
|
101 |
$meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_' . $lang->slug;
|
102 |
$description = empty( $_POST[ 'description_' . $lang->slug ] ) ? '' : trim( $_POST[ 'description_' . $lang->slug ] );
|
103 |
+
|
104 |
+
/** This filter is documented in wp-includes/user.php */
|
105 |
$description = apply_filters( 'pre_user_description', $description ); // applies WP default filter wp_filter_kses
|
106 |
update_user_meta( $user_id, $meta, $description );
|
107 |
}
|
108 |
}
|
109 |
|
110 |
+
/**
|
111 |
* form for language user preference in user profile
|
112 |
*
|
113 |
* @since 0.4
|
138 |
// hidden informations to modify the biography form with js
|
139 |
foreach ( $this->model->get_languages_list() as $lang ) {
|
140 |
$meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_' . $lang->slug;
|
141 |
+
|
142 |
+
/** This filter is documented in wp-includes/user.php */
|
143 |
$description = apply_filters( 'user_description', get_user_meta( $profileuser->ID, $meta, true ) ); // applies WP default filter wp_kses_data
|
144 |
|
145 |
printf( '<input type="hidden" class="biography" name="%s___%s" value="%s" />',
|
150 |
}
|
151 |
}
|
152 |
|
153 |
+
/**
|
154 |
* ugprades languages files after a core upgrade
|
155 |
* only for backward compatibility WP < 4.0 *AND* Polylang < 1.6
|
156 |
*
|
161 |
public function upgrade_languages( $version ) {
|
162 |
// $GLOBALS['wp_version'] is the old WP version
|
163 |
if ( version_compare( $version, '4.0', '>=' ) && version_compare( $GLOBALS['wp_version'], '4.0', '<' ) ) {
|
164 |
+
|
165 |
+
/** This filter is documented in wp-admin/includes/update-core.php */
|
166 |
apply_filters( 'update_feedback', __( 'Upgrading language files…', 'polylang' ) );
|
167 |
PLL_Upgrade::download_language_packs();
|
168 |
}
|
169 |
}
|
170 |
|
171 |
+
/**
|
172 |
* allows to update translations files for plugins and themes
|
173 |
*
|
174 |
* @since 1.6
|
admin/admin-links.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages links related functions
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Admin_Links extends PLL_Links {
|
9 |
|
10 |
-
|
11 |
* get the link to create a new post translation
|
12 |
*
|
13 |
* @since 1.5
|
14 |
*
|
15 |
-
* @param int
|
16 |
-
* @param object $language
|
17 |
* @return string
|
18 |
*/
|
19 |
public function get_new_post_translation_link( $post_id, $language ) {
|
@@ -42,15 +42,24 @@ class PLL_Admin_Links extends PLL_Links {
|
|
42 |
$link = add_query_arg( $args, admin_url( 'post-new.php' ) );
|
43 |
}
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
return apply_filters( 'pll_get_new_post_translation_link', $link, $language, $post_id );
|
46 |
}
|
47 |
|
48 |
-
|
49 |
* returns html markup for a new post translation link
|
50 |
*
|
51 |
* @since 1.8
|
52 |
*
|
53 |
-
* @param int
|
54 |
* @param object $language
|
55 |
* @return string
|
56 |
*/
|
@@ -64,7 +73,7 @@ class PLL_Admin_Links extends PLL_Links {
|
|
64 |
) : '';
|
65 |
}
|
66 |
|
67 |
-
|
68 |
* returns html markup for a translation link
|
69 |
*
|
70 |
* @since 1.4
|
@@ -83,12 +92,12 @@ class PLL_Admin_Links extends PLL_Links {
|
|
83 |
) : '';
|
84 |
}
|
85 |
|
86 |
-
|
87 |
* get the link to create a new term translation
|
88 |
*
|
89 |
* @since 1.5
|
90 |
*
|
91 |
-
* @param int
|
92 |
* @param string $taxonomy
|
93 |
* @param string $post_type
|
94 |
* @param object $language
|
@@ -108,10 +117,22 @@ class PLL_Admin_Links extends PLL_Links {
|
|
108 |
);
|
109 |
|
110 |
$link = add_query_arg( $args, admin_url( 'edit-tags.php' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
return apply_filters( 'pll_get_new_term_translation_link', $link, $language, $term_id, $taxonomy, $post_type );
|
112 |
}
|
113 |
|
114 |
-
|
115 |
* returns html markup for a new term translation
|
116 |
*
|
117 |
* @since 1.8
|
@@ -132,12 +153,12 @@ class PLL_Admin_Links extends PLL_Links {
|
|
132 |
) : '';
|
133 |
}
|
134 |
|
135 |
-
|
136 |
* returns html markup for a term translation link
|
137 |
*
|
138 |
* @since 1.4
|
139 |
*
|
140 |
-
* @param object $term_id
|
141 |
* @param string $taxonomy
|
142 |
* @param string $post_type
|
143 |
* @return string
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages links related functions
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Admin_Links extends PLL_Links {
|
9 |
|
10 |
+
/**
|
11 |
* get the link to create a new post translation
|
12 |
*
|
13 |
* @since 1.5
|
14 |
*
|
15 |
+
* @param int $post_id the source post id
|
16 |
+
* @param object $language the language of the new translation
|
17 |
* @return string
|
18 |
*/
|
19 |
public function get_new_post_translation_link( $post_id, $language ) {
|
42 |
$link = add_query_arg( $args, admin_url( 'post-new.php' ) );
|
43 |
}
|
44 |
|
45 |
+
/**
|
46 |
+
* Filter the new post translation link
|
47 |
+
*
|
48 |
+
* @since 1.8
|
49 |
+
*
|
50 |
+
* @param string $link the new post translation link
|
51 |
+
* @param object $language the language of the new translation
|
52 |
+
* @param int $post_id the source post id
|
53 |
+
*/
|
54 |
return apply_filters( 'pll_get_new_post_translation_link', $link, $language, $post_id );
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
* returns html markup for a new post translation link
|
59 |
*
|
60 |
* @since 1.8
|
61 |
*
|
62 |
+
* @param int $post_id
|
63 |
* @param object $language
|
64 |
* @return string
|
65 |
*/
|
73 |
) : '';
|
74 |
}
|
75 |
|
76 |
+
/**
|
77 |
* returns html markup for a translation link
|
78 |
*
|
79 |
* @since 1.4
|
92 |
) : '';
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
* get the link to create a new term translation
|
97 |
*
|
98 |
* @since 1.5
|
99 |
*
|
100 |
+
* @param int $term_id
|
101 |
* @param string $taxonomy
|
102 |
* @param string $post_type
|
103 |
* @param object $language
|
117 |
);
|
118 |
|
119 |
$link = add_query_arg( $args, admin_url( 'edit-tags.php' ) );
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Filter the new term translation link
|
123 |
+
*
|
124 |
+
* @since 1.8
|
125 |
+
*
|
126 |
+
* @param string $link the new term translation link
|
127 |
+
* @param object $language the language of the new translation
|
128 |
+
* @param int $term_id the source term id
|
129 |
+
* @param string $taxonomy
|
130 |
+
* @param string $post_type
|
131 |
+
*/
|
132 |
return apply_filters( 'pll_get_new_term_translation_link', $link, $language, $term_id, $taxonomy, $post_type );
|
133 |
}
|
134 |
|
135 |
+
/**
|
136 |
* returns html markup for a new term translation
|
137 |
*
|
138 |
* @since 1.8
|
153 |
) : '';
|
154 |
}
|
155 |
|
156 |
+
/**
|
157 |
* returns html markup for a term translation link
|
158 |
*
|
159 |
* @since 1.4
|
160 |
*
|
161 |
+
* @param object $term_id translation term id
|
162 |
* @param string $taxonomy
|
163 |
* @param string $post_type
|
164 |
* @return string
|
admin/admin-model.php
CHANGED
@@ -1,25 +1,26 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Admin_Model extends PLL_Model {
|
9 |
|
10 |
-
|
11 |
-
*
|
12 |
-
*
|
13 |
*
|
14 |
-
*
|
15 |
* name -> language name ( used only for display )
|
16 |
-
* slug -> language code ( ideally 2-letters ISO 639-1 language code
|
17 |
* locale -> WordPress locale. If something wrong is used for the locale, the .mo files will not be loaded...
|
18 |
* rtl -> 1 if rtl language, 0 otherwise
|
19 |
* term_group -> language order when displayed
|
20 |
*
|
21 |
-
*
|
22 |
* no_default_cat -> if set, no default category will be created for this language
|
|
|
23 |
*
|
24 |
* @since 1.2
|
25 |
*
|
@@ -31,47 +32,55 @@ class PLL_Admin_Model extends PLL_Model {
|
|
31 |
return false;
|
32 |
}
|
33 |
|
34 |
-
//
|
35 |
$description = serialize( array( 'locale' => $args['locale'], 'rtl' => (int) $args['rtl'], 'flag_code' => empty( $args['flag'] ) ? '' : $args['flag'] ) );
|
36 |
$r = wp_insert_term( $args['name'], 'language', array( 'slug' => $args['slug'], 'description' => $description ) );
|
37 |
if ( is_wp_error( $r ) ) {
|
38 |
-
//
|
39 |
add_settings_error( 'general', 'pll_add_language', __( 'Impossible to add the language.', 'polylang' ) );
|
40 |
return false;
|
41 |
}
|
42 |
wp_update_term( (int) $r['term_id'], 'language', array( 'term_group' => (int) $args['term_group'] ) ); // can't set the term group directly in wp_insert_term
|
43 |
|
44 |
-
//
|
45 |
-
//
|
46 |
wp_insert_term( $args['name'], 'term_language', array( 'slug' => 'pll_' . $args['slug'] ) );
|
47 |
|
48 |
-
$this->clean_languages_cache(); //
|
49 |
|
50 |
if ( ! isset( $this->options['default_lang'] ) ) {
|
51 |
-
//
|
52 |
$this->options['default_lang'] = $args['slug'];
|
53 |
update_option( 'polylang', $this->options );
|
54 |
|
55 |
-
//
|
56 |
$this->term->set_language( (int) get_option( 'default_category' ), (int) $r['term_id'] );
|
57 |
-
}
|
58 |
-
elseif ( empty( $args['no_default_cat'] ) ) {
|
59 |
$this->create_default_category( $args['slug'] );
|
60 |
}
|
61 |
|
62 |
-
//
|
63 |
$mo = new PLL_MO();
|
64 |
$mo->export_to_db( $this->get_language( $args['slug'] ) );
|
65 |
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
add_settings_error( 'general', 'pll_languages_created', __( 'Language added.', 'polylang' ), 'updated' );
|
70 |
return true;
|
71 |
}
|
72 |
|
73 |
-
|
74 |
-
*
|
75 |
*
|
76 |
* @since 1.2
|
77 |
*
|
@@ -80,24 +89,23 @@ class PLL_Admin_Model extends PLL_Model {
|
|
80 |
public function delete_language( $lang_id ) {
|
81 |
$lang = $this->get_language( (int) $lang_id );
|
82 |
|
83 |
-
//
|
84 |
-
//
|
85 |
if ( $this->options['default_lang'] == $lang->slug ) {
|
86 |
$slugs = $this->get_languages_list( array( 'fields' => 'slug' ) );
|
87 |
$slugs = array_diff( $slugs, array( $lang->slug ) );
|
88 |
|
89 |
if ( ! empty( $slugs ) ) {
|
90 |
-
$this->update_default_lang( reset( $slugs ) ); //
|
91 |
-
}
|
92 |
-
else {
|
93 |
unset( $this->options['default_lang'] );
|
94 |
}
|
95 |
}
|
96 |
|
97 |
-
//
|
98 |
$this->update_translations( $lang->slug );
|
99 |
|
100 |
-
//
|
101 |
foreach ( $GLOBALS['wp_registered_widgets'] as $widget ) {
|
102 |
if ( ! empty( $widget['callback'][0] ) && ! empty( $widget['params'][0]['number'] ) ) {
|
103 |
$obj = $widget['callback'][0];
|
@@ -112,7 +120,7 @@ class PLL_Admin_Model extends PLL_Model {
|
|
112 |
}
|
113 |
}
|
114 |
|
115 |
-
//
|
116 |
if ( ! empty( $this->options['nav_menus'] ) ) {
|
117 |
foreach ( $this->options['nav_menus'] as $theme => $locations ) {
|
118 |
foreach ( $locations as $location => $languages ) {
|
@@ -121,27 +129,27 @@ class PLL_Admin_Model extends PLL_Model {
|
|
121 |
}
|
122 |
}
|
123 |
|
124 |
-
//
|
125 |
foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) {
|
126 |
delete_user_meta( $user_id, 'user_lang', $lang->locale );
|
127 |
delete_user_meta( $user_id, 'pll_filter_content', $lang->slug );
|
128 |
delete_user_meta( $user_id, 'description_'.$lang->slug );
|
129 |
}
|
130 |
|
131 |
-
//
|
132 |
$post = get_page_by_title( 'polylang_mo_' . $lang->term_id, OBJECT, 'polylang_mo' );
|
133 |
if ( ! empty( $post ) ) {
|
134 |
wp_delete_post( $post->ID );
|
135 |
}
|
136 |
|
137 |
-
//
|
138 |
unset( $this->options['domains'][ $lang->slug ] );
|
139 |
|
140 |
-
//
|
141 |
wp_delete_term( $lang->term_id, 'language' );
|
142 |
wp_delete_term( $lang->tl_term_id, 'term_language' );
|
143 |
|
144 |
-
//
|
145 |
$this->clean_languages_cache();
|
146 |
|
147 |
update_option( 'polylang', $this->options );
|
@@ -149,10 +157,10 @@ class PLL_Admin_Model extends PLL_Model {
|
|
149 |
add_settings_error( 'general', 'pll_languages_deleted', __( 'Language deleted.', 'polylang' ), 'updated' );
|
150 |
}
|
151 |
|
152 |
-
|
153 |
-
*
|
154 |
*
|
155 |
-
*
|
156 |
* lang_id -> term_id of the language to modify
|
157 |
* name -> language name ( used only for display )
|
158 |
* slug -> language code ( ideally 2-letters ISO 639-1 language code
|
@@ -160,6 +168,9 @@ class PLL_Admin_Model extends PLL_Model {
|
|
160 |
* rtl -> 1 if rtl language, 0 otherwise
|
161 |
* term_group -> language order when displayed
|
162 |
*
|
|
|
|
|
|
|
163 |
* @since 1.2
|
164 |
*
|
165 |
* @param array $args
|
@@ -176,10 +187,10 @@ class PLL_Admin_Model extends PLL_Model {
|
|
176 |
$old_slug = $lang->slug;
|
177 |
|
178 |
if ( $old_slug != $slug ) {
|
179 |
-
//
|
180 |
$this->update_translations( $old_slug, $slug );
|
181 |
|
182 |
-
//
|
183 |
foreach ( $GLOBALS['wp_registered_widgets'] as $widget ) {
|
184 |
if ( ! empty( $widget['callback'][0] ) && ! empty( $widget['params'][0]['number'] ) ) {
|
185 |
$obj = $widget['callback'][0];
|
@@ -194,7 +205,7 @@ class PLL_Admin_Model extends PLL_Model {
|
|
194 |
}
|
195 |
}
|
196 |
|
197 |
-
//
|
198 |
if ( ! empty( $this->options['nav_menus'] ) ) {
|
199 |
foreach ( $this->options['nav_menus'] as $theme => $locations ) {
|
200 |
foreach ( $locations as $location => $languages ) {
|
@@ -206,13 +217,13 @@ class PLL_Admin_Model extends PLL_Model {
|
|
206 |
}
|
207 |
}
|
208 |
|
209 |
-
//
|
210 |
if ( ! empty( $this->options['domains'][ $old_slug ] ) ) {
|
211 |
$this->options['domains'][ $slug ] = $this->options['domains'][ $old_slug ];
|
212 |
unset( $this->options['domains'][ $old_slug ] );
|
213 |
}
|
214 |
|
215 |
-
//
|
216 |
if ( $this->options['default_lang'] == $old_slug ) {
|
217 |
$this->options['default_lang'] = $slug;
|
218 |
}
|
@@ -220,50 +231,59 @@ class PLL_Admin_Model extends PLL_Model {
|
|
220 |
|
221 |
update_option( 'polylang', $this->options );
|
222 |
|
223 |
-
//
|
224 |
$description = serialize( array( 'locale' => $args['locale'], 'rtl' => (int) $args['rtl'], 'flag_code' => empty( $args['flag'] ) ? '' : $args['flag'] ) );
|
225 |
wp_update_term( (int) $lang->term_id, 'language', array( 'slug' => $slug, 'name' => $args['name'], 'description' => $description, 'term_group' => (int) $args['term_group'] ) );
|
226 |
wp_update_term( (int) $lang->tl_term_id, 'term_language', array( 'slug' => 'pll_' . $slug, 'name' => $args['name'] ) );
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
$this->clean_languages_cache();
|
229 |
-
flush_rewrite_rules(); //
|
230 |
add_settings_error( 'general', 'pll_languages_updated', __( 'Language updated.', 'polylang' ), 'updated' );
|
231 |
return true;
|
232 |
}
|
233 |
|
234 |
-
|
235 |
-
*
|
|
|
236 |
*
|
237 |
* @since 0.4
|
238 |
*
|
239 |
-
* @param array
|
240 |
* @param object $lang optional the language currently updated, the language is created if not set
|
241 |
* @return bool true if success / false if failed
|
242 |
-
* @see PLL_Admin_Model::add_language
|
243 |
*/
|
244 |
protected function validate_lang( $args, $lang = null ) {
|
245 |
-
//
|
246 |
if ( ! preg_match( '#^[a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?$#', $args['locale'], $matches ) ) {
|
247 |
add_settings_error( 'general', 'pll_invalid_locale', __( 'Enter a valid WordPress locale', 'polylang' ) );
|
248 |
}
|
249 |
|
250 |
-
//
|
251 |
if ( ! preg_match( '#^[a-z_-]+$#', $args['slug'] ) ) {
|
252 |
add_settings_error( 'general', 'pll_invalid_slug', __( 'The language code contains invalid characters', 'polylang' ) );
|
253 |
}
|
254 |
|
255 |
-
//
|
256 |
if ( $this->get_language( $args['slug'] ) && ( null === $lang || ( isset( $lang ) && $lang->slug != $args['slug'] ) ) ) {
|
257 |
add_settings_error( 'general', 'pll_non_unique_slug', __( 'The language code must be unique', 'polylang' ) );
|
258 |
}
|
259 |
|
260 |
-
//
|
261 |
-
//
|
262 |
if ( empty( $args['name'] ) ) {
|
263 |
add_settings_error( 'general', 'pll_invalid_name', __( 'The language must have a name', 'polylang' ) );
|
264 |
}
|
265 |
|
266 |
-
//
|
267 |
if ( ! empty( $args['flag'] ) && ! file_exists( POLYLANG_DIR . '/flags/' . $args['flag'] . '.png' ) ) {
|
268 |
add_settings_error( 'general', 'pll_invalid_flag', __( 'The flag does not exist', 'polylang' ) );
|
269 |
}
|
@@ -271,13 +291,13 @@ class PLL_Admin_Model extends PLL_Model {
|
|
271 |
return get_settings_errors() ? false : true;
|
272 |
}
|
273 |
|
274 |
-
|
275 |
-
*
|
276 |
*
|
277 |
* @since 1.2
|
278 |
*
|
279 |
-
* @param string
|
280 |
-
* @param array
|
281 |
* @param object|string $lang object or slug
|
282 |
*/
|
283 |
public function set_language_in_mass( $type, $ids, $lang ) {
|
@@ -294,7 +314,7 @@ class PLL_Admin_Model extends PLL_Model {
|
|
294 |
if ( ! empty( $values ) ) {
|
295 |
$values = array_unique( $values );
|
296 |
$wpdb->query( "INSERT INTO $wpdb->term_relationships ( object_id, term_taxonomy_id ) VALUES " . implode( ',', $values ) );
|
297 |
-
$lang->update_count(); //
|
298 |
}
|
299 |
|
300 |
if ( 'term' == $type ) {
|
@@ -308,13 +328,13 @@ class PLL_Admin_Model extends PLL_Model {
|
|
308 |
}
|
309 |
}
|
310 |
|
311 |
-
|
312 |
-
*
|
313 |
*
|
314 |
* @since 1.6.3
|
315 |
*
|
316 |
-
* @param string $type
|
317 |
-
* @param array
|
318 |
*/
|
319 |
public function set_translation_in_mass( $type, $translations ) {
|
320 |
global $wpdb;
|
@@ -327,30 +347,30 @@ class PLL_Admin_Model extends PLL_Model {
|
|
327 |
$count[ $term ] = count( $t );
|
328 |
}
|
329 |
|
330 |
-
//
|
331 |
if ( ! empty( $terms ) ) {
|
332 |
$terms = array_unique( $terms );
|
333 |
$wpdb->query( "INSERT INTO $wpdb->terms ( slug, name ) VALUES " . implode( ',', $terms ) );
|
334 |
}
|
335 |
|
336 |
-
//
|
337 |
$terms = $wpdb->get_results( "SELECT term_id, slug FROM $wpdb->terms WHERE slug IN ( " . implode( ',', $slugs ) . " )" );
|
338 |
|
339 |
-
//
|
340 |
foreach ( $terms as $term ) {
|
341 |
$tts[] = $wpdb->prepare( '( %d, "%s", "%s", %d )', $term->term_id, $type . '_translations', $description[ $term->slug ], $count[ $term->slug ] );
|
342 |
}
|
343 |
|
344 |
-
//
|
345 |
if ( ! empty( $tts ) ) {
|
346 |
$tts = array_unique( $tts );
|
347 |
$wpdb->query( "INSERT INTO $wpdb->term_taxonomy ( term_id, taxonomy, description, count ) VALUES " . implode( ',', $tts ) );
|
348 |
}
|
349 |
|
350 |
-
//
|
351 |
$terms = get_terms( $type . '_translations', array( 'hide_empty' => false ) );
|
352 |
|
353 |
-
//
|
354 |
foreach ( $terms as $term ) {
|
355 |
$t = unserialize( $term->description );
|
356 |
if ( in_array( $t, $translations ) ) {
|
@@ -362,15 +382,15 @@ class PLL_Admin_Model extends PLL_Model {
|
|
362 |
}
|
363 |
}
|
364 |
|
365 |
-
//
|
366 |
if ( ! empty( $trs ) ) {
|
367 |
$wpdb->query( "INSERT INTO $wpdb->term_relationships ( object_id, term_taxonomy_id ) VALUES " . implode( ',', $trs ) );
|
368 |
$trs = array_unique( $trs );
|
369 |
}
|
370 |
}
|
371 |
|
372 |
-
|
373 |
-
*
|
374 |
*
|
375 |
* @since 0.9
|
376 |
*
|
@@ -396,11 +416,18 @@ class PLL_Admin_Model extends PLL_Model {
|
|
396 |
$terms = array_unique( array_diff( $terms, $tr_terms ) ); // array_unique to avoid duplicates if a term is in more than one taxonomy
|
397 |
$terms = array_map( 'intval', $terms );
|
398 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
return apply_filters( 'pll_get_objects_with_no_lang', empty( $posts ) && empty( $terms ) ? false : array( 'posts' => $posts, 'terms' => $terms ) );
|
400 |
}
|
401 |
|
402 |
-
|
403 |
-
*
|
404 |
*
|
405 |
* @since 0.5
|
406 |
*
|
@@ -416,9 +443,8 @@ class PLL_Admin_Model extends PLL_Model {
|
|
416 |
$tr = unserialize( $term->description );
|
417 |
if ( ! empty( $tr[ $old_slug ] ) ) {
|
418 |
if ( $new_slug ) {
|
419 |
-
$tr[ $new_slug ] = $tr[ $old_slug ]; //
|
420 |
-
}
|
421 |
-
else {
|
422 |
$dr['id'][] = (int) $tr[ $old_slug ];
|
423 |
$dr['tt'][] = (int) $term->term_taxonomy_id;
|
424 |
}
|
@@ -427,15 +453,14 @@ class PLL_Admin_Model extends PLL_Model {
|
|
427 |
if ( empty( $tr ) || 1 == count( $tr ) ) {
|
428 |
$dt['t'][] = (int) $term->term_id;
|
429 |
$dt['tt'][] = (int) $term->term_taxonomy_id;
|
430 |
-
}
|
431 |
-
else {
|
432 |
$ut['case'][] = $wpdb->prepare( 'WHEN %d THEN %s', $term->term_id, serialize( $tr ) );
|
433 |
$ut['in'][] = (int) $term->term_id;
|
434 |
}
|
435 |
}
|
436 |
}
|
437 |
|
438 |
-
//
|
439 |
if ( ! empty( $dr ) ) {
|
440 |
$wpdb->query( "
|
441 |
DELETE FROM $wpdb->term_relationships
|
@@ -444,13 +469,13 @@ class PLL_Admin_Model extends PLL_Model {
|
|
444 |
" );
|
445 |
}
|
446 |
|
447 |
-
//
|
448 |
if ( ! empty( $dt ) ) {
|
449 |
$wpdb->query( "DELETE FROM $wpdb->terms WHERE term_id IN ( " . implode( ',', $dt['t'] ) . " ) " );
|
450 |
$wpdb->query( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ( " . implode( ',', $dt['tt'] ) . " ) " );
|
451 |
}
|
452 |
|
453 |
-
//
|
454 |
if ( ! empty( $ut ) ) {
|
455 |
$wpdb->query( "
|
456 |
UPDATE $wpdb->term_taxonomy
|
@@ -460,8 +485,8 @@ class PLL_Admin_Model extends PLL_Model {
|
|
460 |
}
|
461 |
}
|
462 |
|
463 |
-
|
464 |
-
*
|
465 |
* taking care to update the default category & the nav menu locations
|
466 |
*
|
467 |
* @since 1.8
|
@@ -469,7 +494,7 @@ class PLL_Admin_Model extends PLL_Model {
|
|
469 |
* @param string $slug new language slug
|
470 |
*/
|
471 |
public function update_default_lang( $slug ) {
|
472 |
-
//
|
473 |
$theme = get_stylesheet();
|
474 |
if ( ! empty( $this->options['nav_menus'][ $theme ] ) ) {
|
475 |
foreach ( $this->options['nav_menus'][ $theme ] as $key => $loc ) {
|
@@ -478,13 +503,13 @@ class PLL_Admin_Model extends PLL_Model {
|
|
478 |
set_theme_mod( 'nav_menu_locations', $menus );
|
479 |
}
|
480 |
|
481 |
-
//
|
482 |
$default_cats = $this->term->get_translations( get_option( 'default_category' ) );
|
483 |
if ( isset( $default_cats[ $slug ] ) ) {
|
484 |
update_option( 'default_category', $default_cats[ $slug ] );
|
485 |
}
|
486 |
|
487 |
-
//
|
488 |
$this->options['default_lang'] = $slug;
|
489 |
update_option( 'polylang', $this->options );
|
490 |
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Extends the PLL_Model class with methods needed only in Polylang settings pages
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Admin_Model extends PLL_Model {
|
9 |
|
10 |
+
/**
|
11 |
+
* Adds a new language
|
12 |
+
* Creates a default category for this language
|
13 |
*
|
14 |
+
* List of arguments that $args must contain:
|
15 |
* name -> language name ( used only for display )
|
16 |
+
* slug -> language code ( ideally 2-letters ISO 639-1 language code )
|
17 |
* locale -> WordPress locale. If something wrong is used for the locale, the .mo files will not be loaded...
|
18 |
* rtl -> 1 if rtl language, 0 otherwise
|
19 |
* term_group -> language order when displayed
|
20 |
*
|
21 |
+
* Optional arguments that $args can contain:
|
22 |
* no_default_cat -> if set, no default category will be created for this language
|
23 |
+
* flag -> country code, see flags.php
|
24 |
*
|
25 |
* @since 1.2
|
26 |
*
|
32 |
return false;
|
33 |
}
|
34 |
|
35 |
+
// First the language taxonomy
|
36 |
$description = serialize( array( 'locale' => $args['locale'], 'rtl' => (int) $args['rtl'], 'flag_code' => empty( $args['flag'] ) ? '' : $args['flag'] ) );
|
37 |
$r = wp_insert_term( $args['name'], 'language', array( 'slug' => $args['slug'], 'description' => $description ) );
|
38 |
if ( is_wp_error( $r ) ) {
|
39 |
+
// Avoid an ugly fatal error if something went wrong ( reported once in the forum )
|
40 |
add_settings_error( 'general', 'pll_add_language', __( 'Impossible to add the language.', 'polylang' ) );
|
41 |
return false;
|
42 |
}
|
43 |
wp_update_term( (int) $r['term_id'], 'language', array( 'term_group' => (int) $args['term_group'] ) ); // can't set the term group directly in wp_insert_term
|
44 |
|
45 |
+
// The term_language taxonomy
|
46 |
+
// Don't want shared terms so use a different slug
|
47 |
wp_insert_term( $args['name'], 'term_language', array( 'slug' => 'pll_' . $args['slug'] ) );
|
48 |
|
49 |
+
$this->clean_languages_cache(); // Udpate the languages list now !
|
50 |
|
51 |
if ( ! isset( $this->options['default_lang'] ) ) {
|
52 |
+
// If this is the first language created, set it as default language
|
53 |
$this->options['default_lang'] = $args['slug'];
|
54 |
update_option( 'polylang', $this->options );
|
55 |
|
56 |
+
// And assign default language to default category
|
57 |
$this->term->set_language( (int) get_option( 'default_category' ), (int) $r['term_id'] );
|
58 |
+
} elseif ( empty( $args['no_default_cat'] ) ) {
|
|
|
59 |
$this->create_default_category( $args['slug'] );
|
60 |
}
|
61 |
|
62 |
+
// Init a mo_id for this language
|
63 |
$mo = new PLL_MO();
|
64 |
$mo->export_to_db( $this->get_language( $args['slug'] ) );
|
65 |
|
66 |
+
/**
|
67 |
+
* Fires when a language is added
|
68 |
+
*
|
69 |
+
* @since 1.9
|
70 |
+
*
|
71 |
+
* @param array $args arguments used to create the language
|
72 |
+
*/
|
73 |
+
do_action( 'pll_add_language', $args );
|
74 |
+
|
75 |
+
$this->clean_languages_cache(); // Again to set add mo_id in the cached languages list
|
76 |
+
flush_rewrite_rules(); // Refresh rewrite rules
|
77 |
|
78 |
add_settings_error( 'general', 'pll_languages_created', __( 'Language added.', 'polylang' ), 'updated' );
|
79 |
return true;
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* Delete a language
|
84 |
*
|
85 |
* @since 1.2
|
86 |
*
|
89 |
public function delete_language( $lang_id ) {
|
90 |
$lang = $this->get_language( (int) $lang_id );
|
91 |
|
92 |
+
// Oops ! we are deleting the default language...
|
93 |
+
// Need to do this before loosing the information for default category translations
|
94 |
if ( $this->options['default_lang'] == $lang->slug ) {
|
95 |
$slugs = $this->get_languages_list( array( 'fields' => 'slug' ) );
|
96 |
$slugs = array_diff( $slugs, array( $lang->slug ) );
|
97 |
|
98 |
if ( ! empty( $slugs ) ) {
|
99 |
+
$this->update_default_lang( reset( $slugs ) ); // Arbitrary choice...
|
100 |
+
} else {
|
|
|
101 |
unset( $this->options['default_lang'] );
|
102 |
}
|
103 |
}
|
104 |
|
105 |
+
// Delete the translations
|
106 |
$this->update_translations( $lang->slug );
|
107 |
|
108 |
+
// Delete language option in widgets
|
109 |
foreach ( $GLOBALS['wp_registered_widgets'] as $widget ) {
|
110 |
if ( ! empty( $widget['callback'][0] ) && ! empty( $widget['params'][0]['number'] ) ) {
|
111 |
$obj = $widget['callback'][0];
|
120 |
}
|
121 |
}
|
122 |
|
123 |
+
// Delete menus locations
|
124 |
if ( ! empty( $this->options['nav_menus'] ) ) {
|
125 |
foreach ( $this->options['nav_menus'] as $theme => $locations ) {
|
126 |
foreach ( $locations as $location => $languages ) {
|
129 |
}
|
130 |
}
|
131 |
|
132 |
+
// Delete users options
|
133 |
foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) {
|
134 |
delete_user_meta( $user_id, 'user_lang', $lang->locale );
|
135 |
delete_user_meta( $user_id, 'pll_filter_content', $lang->slug );
|
136 |
delete_user_meta( $user_id, 'description_'.$lang->slug );
|
137 |
}
|
138 |
|
139 |
+
// Delete the string translations
|
140 |
$post = get_page_by_title( 'polylang_mo_' . $lang->term_id, OBJECT, 'polylang_mo' );
|
141 |
if ( ! empty( $post ) ) {
|
142 |
wp_delete_post( $post->ID );
|
143 |
}
|
144 |
|
145 |
+
// Delete domain
|
146 |
unset( $this->options['domains'][ $lang->slug ] );
|
147 |
|
148 |
+
// Delete the language itself
|
149 |
wp_delete_term( $lang->term_id, 'language' );
|
150 |
wp_delete_term( $lang->tl_term_id, 'term_language' );
|
151 |
|
152 |
+
// Update languages list
|
153 |
$this->clean_languages_cache();
|
154 |
|
155 |
update_option( 'polylang', $this->options );
|
157 |
add_settings_error( 'general', 'pll_languages_deleted', __( 'Language deleted.', 'polylang' ), 'updated' );
|
158 |
}
|
159 |
|
160 |
+
/**
|
161 |
+
* Update language properties
|
162 |
*
|
163 |
+
* List of arguments that $args must contain:
|
164 |
* lang_id -> term_id of the language to modify
|
165 |
* name -> language name ( used only for display )
|
166 |
* slug -> language code ( ideally 2-letters ISO 639-1 language code
|
168 |
* rtl -> 1 if rtl language, 0 otherwise
|
169 |
* term_group -> language order when displayed
|
170 |
*
|
171 |
+
* Optional arguments that $args can contain:
|
172 |
+
* flag -> country code, see flags.php
|
173 |
+
*
|
174 |
* @since 1.2
|
175 |
*
|
176 |
* @param array $args
|
187 |
$old_slug = $lang->slug;
|
188 |
|
189 |
if ( $old_slug != $slug ) {
|
190 |
+
// Update the language slug in translations
|
191 |
$this->update_translations( $old_slug, $slug );
|
192 |
|
193 |
+
// Update language option in widgets
|
194 |
foreach ( $GLOBALS['wp_registered_widgets'] as $widget ) {
|
195 |
if ( ! empty( $widget['callback'][0] ) && ! empty( $widget['params'][0]['number'] ) ) {
|
196 |
$obj = $widget['callback'][0];
|
205 |
}
|
206 |
}
|
207 |
|
208 |
+
// Update menus locations
|
209 |
if ( ! empty( $this->options['nav_menus'] ) ) {
|
210 |
foreach ( $this->options['nav_menus'] as $theme => $locations ) {
|
211 |
foreach ( $locations as $location => $languages ) {
|
217 |
}
|
218 |
}
|
219 |
|
220 |
+
// Update domains
|
221 |
if ( ! empty( $this->options['domains'][ $old_slug ] ) ) {
|
222 |
$this->options['domains'][ $slug ] = $this->options['domains'][ $old_slug ];
|
223 |
unset( $this->options['domains'][ $old_slug ] );
|
224 |
}
|
225 |
|
226 |
+
// Update the default language option if necessary
|
227 |
if ( $this->options['default_lang'] == $old_slug ) {
|
228 |
$this->options['default_lang'] = $slug;
|
229 |
}
|
231 |
|
232 |
update_option( 'polylang', $this->options );
|
233 |
|
234 |
+
// And finally update the language itself
|
235 |
$description = serialize( array( 'locale' => $args['locale'], 'rtl' => (int) $args['rtl'], 'flag_code' => empty( $args['flag'] ) ? '' : $args['flag'] ) );
|
236 |
wp_update_term( (int) $lang->term_id, 'language', array( 'slug' => $slug, 'name' => $args['name'], 'description' => $description, 'term_group' => (int) $args['term_group'] ) );
|
237 |
wp_update_term( (int) $lang->tl_term_id, 'term_language', array( 'slug' => 'pll_' . $slug, 'name' => $args['name'] ) );
|
238 |
|
239 |
+
/**
|
240 |
+
* Fires when a language is added
|
241 |
+
*
|
242 |
+
* @since 1.9
|
243 |
+
*
|
244 |
+
* @param array $args arguments used to modify the language
|
245 |
+
*/
|
246 |
+
do_action( 'pll_update_language', $args );
|
247 |
+
|
248 |
$this->clean_languages_cache();
|
249 |
+
flush_rewrite_rules(); // Refresh rewrite rules
|
250 |
add_settings_error( 'general', 'pll_languages_updated', __( 'Language updated.', 'polylang' ), 'updated' );
|
251 |
return true;
|
252 |
}
|
253 |
|
254 |
+
/**
|
255 |
+
* Validates data entered when creating or updating a language
|
256 |
+
* @see PLL_Admin_Model::add_language
|
257 |
*
|
258 |
* @since 0.4
|
259 |
*
|
260 |
+
* @param array $args
|
261 |
* @param object $lang optional the language currently updated, the language is created if not set
|
262 |
* @return bool true if success / false if failed
|
|
|
263 |
*/
|
264 |
protected function validate_lang( $args, $lang = null ) {
|
265 |
+
// Validate locale with the same pattern as WP 4.3. See #28303
|
266 |
if ( ! preg_match( '#^[a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?$#', $args['locale'], $matches ) ) {
|
267 |
add_settings_error( 'general', 'pll_invalid_locale', __( 'Enter a valid WordPress locale', 'polylang' ) );
|
268 |
}
|
269 |
|
270 |
+
// Validate slug characters
|
271 |
if ( ! preg_match( '#^[a-z_-]+$#', $args['slug'] ) ) {
|
272 |
add_settings_error( 'general', 'pll_invalid_slug', __( 'The language code contains invalid characters', 'polylang' ) );
|
273 |
}
|
274 |
|
275 |
+
// Validate slug is unique
|
276 |
if ( $this->get_language( $args['slug'] ) && ( null === $lang || ( isset( $lang ) && $lang->slug != $args['slug'] ) ) ) {
|
277 |
add_settings_error( 'general', 'pll_non_unique_slug', __( 'The language code must be unique', 'polylang' ) );
|
278 |
}
|
279 |
|
280 |
+
// Validate name
|
281 |
+
// No need to sanitize it as wp_insert_term will do it for us
|
282 |
if ( empty( $args['name'] ) ) {
|
283 |
add_settings_error( 'general', 'pll_invalid_name', __( 'The language must have a name', 'polylang' ) );
|
284 |
}
|
285 |
|
286 |
+
// Validate flag
|
287 |
if ( ! empty( $args['flag'] ) && ! file_exists( POLYLANG_DIR . '/flags/' . $args['flag'] . '.png' ) ) {
|
288 |
add_settings_error( 'general', 'pll_invalid_flag', __( 'The flag does not exist', 'polylang' ) );
|
289 |
}
|
291 |
return get_settings_errors() ? false : true;
|
292 |
}
|
293 |
|
294 |
+
/**
|
295 |
+
* Used to set the language of posts or terms in mass
|
296 |
*
|
297 |
* @since 1.2
|
298 |
*
|
299 |
+
* @param string $type either 'post' or 'term'
|
300 |
+
* @param array $ids array of post ids or term ids
|
301 |
* @param object|string $lang object or slug
|
302 |
*/
|
303 |
public function set_language_in_mass( $type, $ids, $lang ) {
|
314 |
if ( ! empty( $values ) ) {
|
315 |
$values = array_unique( $values );
|
316 |
$wpdb->query( "INSERT INTO $wpdb->term_relationships ( object_id, term_taxonomy_id ) VALUES " . implode( ',', $values ) );
|
317 |
+
$lang->update_count(); // Updating term count is mandatory ( thanks to AndyDeGroo )
|
318 |
}
|
319 |
|
320 |
if ( 'term' == $type ) {
|
328 |
}
|
329 |
}
|
330 |
|
331 |
+
/**
|
332 |
+
* Used to create a translations groups in mass
|
333 |
*
|
334 |
* @since 1.6.3
|
335 |
*
|
336 |
+
* @param string $type either 'post' or 'term'
|
337 |
+
* @param array $translations array of translations arrays
|
338 |
*/
|
339 |
public function set_translation_in_mass( $type, $translations ) {
|
340 |
global $wpdb;
|
347 |
$count[ $term ] = count( $t );
|
348 |
}
|
349 |
|
350 |
+
// Insert terms
|
351 |
if ( ! empty( $terms ) ) {
|
352 |
$terms = array_unique( $terms );
|
353 |
$wpdb->query( "INSERT INTO $wpdb->terms ( slug, name ) VALUES " . implode( ',', $terms ) );
|
354 |
}
|
355 |
|
356 |
+
// Get all terms with their term_id
|
357 |
$terms = $wpdb->get_results( "SELECT term_id, slug FROM $wpdb->terms WHERE slug IN ( " . implode( ',', $slugs ) . " )" );
|
358 |
|
359 |
+
// Prepare terms taxonomy relationship
|
360 |
foreach ( $terms as $term ) {
|
361 |
$tts[] = $wpdb->prepare( '( %d, "%s", "%s", %d )', $term->term_id, $type . '_translations', $description[ $term->slug ], $count[ $term->slug ] );
|
362 |
}
|
363 |
|
364 |
+
// Insert term_taxonomy
|
365 |
if ( ! empty( $tts ) ) {
|
366 |
$tts = array_unique( $tts );
|
367 |
$wpdb->query( "INSERT INTO $wpdb->term_taxonomy ( term_id, taxonomy, description, count ) VALUES " . implode( ',', $tts ) );
|
368 |
}
|
369 |
|
370 |
+
// Get all terms with term_taxonomy_id
|
371 |
$terms = get_terms( $type . '_translations', array( 'hide_empty' => false ) );
|
372 |
|
373 |
+
// Prepare objects relationships
|
374 |
foreach ( $terms as $term ) {
|
375 |
$t = unserialize( $term->description );
|
376 |
if ( in_array( $t, $translations ) ) {
|
382 |
}
|
383 |
}
|
384 |
|
385 |
+
// Insert term_relationships
|
386 |
if ( ! empty( $trs ) ) {
|
387 |
$wpdb->query( "INSERT INTO $wpdb->term_relationships ( object_id, term_taxonomy_id ) VALUES " . implode( ',', $trs ) );
|
388 |
$trs = array_unique( $trs );
|
389 |
}
|
390 |
}
|
391 |
|
392 |
+
/**
|
393 |
+
* Returns unstranslated posts and terms ids ( used in settings )
|
394 |
*
|
395 |
* @since 0.9
|
396 |
*
|
416 |
$terms = array_unique( array_diff( $terms, $tr_terms ) ); // array_unique to avoid duplicates if a term is in more than one taxonomy
|
417 |
$terms = array_map( 'intval', $terms );
|
418 |
|
419 |
+
/**
|
420 |
+
* Filter the list of untranslated posts ids and terms ids
|
421 |
+
*
|
422 |
+
* @since 0.9
|
423 |
+
*
|
424 |
+
* @param bool|array $objects false if no ids found, list of post and/or term ids otherwise
|
425 |
+
*/
|
426 |
return apply_filters( 'pll_get_objects_with_no_lang', empty( $posts ) && empty( $terms ) ? false : array( 'posts' => $posts, 'terms' => $terms ) );
|
427 |
}
|
428 |
|
429 |
+
/**
|
430 |
+
* Used to delete translations or update the translations when a language slug has been modified in settings
|
431 |
*
|
432 |
* @since 0.5
|
433 |
*
|
443 |
$tr = unserialize( $term->description );
|
444 |
if ( ! empty( $tr[ $old_slug ] ) ) {
|
445 |
if ( $new_slug ) {
|
446 |
+
$tr[ $new_slug ] = $tr[ $old_slug ]; // Suppress this for delete
|
447 |
+
} else {
|
|
|
448 |
$dr['id'][] = (int) $tr[ $old_slug ];
|
449 |
$dr['tt'][] = (int) $term->term_taxonomy_id;
|
450 |
}
|
453 |
if ( empty( $tr ) || 1 == count( $tr ) ) {
|
454 |
$dt['t'][] = (int) $term->term_id;
|
455 |
$dt['tt'][] = (int) $term->term_taxonomy_id;
|
456 |
+
} else {
|
|
|
457 |
$ut['case'][] = $wpdb->prepare( 'WHEN %d THEN %s', $term->term_id, serialize( $tr ) );
|
458 |
$ut['in'][] = (int) $term->term_id;
|
459 |
}
|
460 |
}
|
461 |
}
|
462 |
|
463 |
+
// Delete relationships
|
464 |
if ( ! empty( $dr ) ) {
|
465 |
$wpdb->query( "
|
466 |
DELETE FROM $wpdb->term_relationships
|
469 |
" );
|
470 |
}
|
471 |
|
472 |
+
// Delete terms
|
473 |
if ( ! empty( $dt ) ) {
|
474 |
$wpdb->query( "DELETE FROM $wpdb->terms WHERE term_id IN ( " . implode( ',', $dt['t'] ) . " ) " );
|
475 |
$wpdb->query( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ( " . implode( ',', $dt['tt'] ) . " ) " );
|
476 |
}
|
477 |
|
478 |
+
// Update terms
|
479 |
if ( ! empty( $ut ) ) {
|
480 |
$wpdb->query( "
|
481 |
UPDATE $wpdb->term_taxonomy
|
485 |
}
|
486 |
}
|
487 |
|
488 |
+
/**
|
489 |
+
* Updates the default language
|
490 |
* taking care to update the default category & the nav menu locations
|
491 |
*
|
492 |
* @since 1.8
|
494 |
* @param string $slug new language slug
|
495 |
*/
|
496 |
public function update_default_lang( $slug ) {
|
497 |
+
// The nav menus stored in theme locations should be in the default language
|
498 |
$theme = get_stylesheet();
|
499 |
if ( ! empty( $this->options['nav_menus'][ $theme ] ) ) {
|
500 |
foreach ( $this->options['nav_menus'][ $theme ] as $key => $loc ) {
|
503 |
set_theme_mod( 'nav_menu_locations', $menus );
|
504 |
}
|
505 |
|
506 |
+
// The default category should be in the default language
|
507 |
$default_cats = $this->term->get_translations( get_option( 'default_category' ) );
|
508 |
if ( isset( $default_cats[ $slug ] ) ) {
|
509 |
update_option( 'default_category', $default_cats[ $slug ] );
|
510 |
}
|
511 |
|
512 |
+
// Update options
|
513 |
$this->options['default_lang'] = $slug;
|
514 |
update_option( 'polylang', $this->options );
|
515 |
|
admin/admin-nav-menu.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages custom menus translations as well as the language switcher menu item on admin side
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
9 |
|
10 |
-
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.2
|
@@ -33,7 +33,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
33 |
}
|
34 |
}
|
35 |
|
36 |
-
|
37 |
* setups filters and terms
|
38 |
* adds the language switcher metabox and create new nav menu locations
|
39 |
*
|
@@ -58,7 +58,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
58 |
$this->create_nav_menu_locations();
|
59 |
}
|
60 |
|
61 |
-
|
62 |
* language switcher metabox
|
63 |
* The checkbox and all hidden fields are important
|
64 |
* thanks to John Morris for his very interesting post http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/
|
@@ -91,7 +91,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
91 |
</div><?php
|
92 |
}
|
93 |
|
94 |
-
|
95 |
* prepares javascript to modify the language switcher menu item
|
96 |
*
|
97 |
* @since 1.1
|
@@ -131,7 +131,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
131 |
wp_localize_script( 'pll_nav_menu', 'pll_data', $data );
|
132 |
}
|
133 |
|
134 |
-
|
135 |
* save our menu item options
|
136 |
*
|
137 |
* @since 1.1
|
@@ -165,7 +165,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
165 |
}
|
166 |
}
|
167 |
|
168 |
-
|
169 |
* translates the language switcher menu items title in case the user switches the admin language
|
170 |
*
|
171 |
* @since 1.1.1
|
@@ -182,7 +182,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
182 |
return $items;
|
183 |
}
|
184 |
|
185 |
-
|
186 |
* assign menu languages and translations based on ( temporary ) locations
|
187 |
*
|
188 |
* @since 1.8
|
@@ -206,7 +206,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
206 |
return $locations;
|
207 |
}
|
208 |
|
209 |
-
|
210 |
* assign menu languages and translations based on ( temporary ) locations
|
211 |
*
|
212 |
* @since 1.1
|
@@ -246,7 +246,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
246 |
return $mods;
|
247 |
}
|
248 |
|
249 |
-
|
250 |
* fills temporary menu locations based on menus translations
|
251 |
*
|
252 |
* @since 1.2
|
@@ -268,7 +268,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
268 |
return $menus;
|
269 |
}
|
270 |
|
271 |
-
|
272 |
* removes the nav menu term_id from the locations stored in Polylang options when a nav menu is deleted
|
273 |
*
|
274 |
* @since 1.7.3
|
@@ -291,7 +291,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
291 |
}
|
292 |
}
|
293 |
|
294 |
-
|
295 |
* filters the option nav_menu_options for auto added pages to menu
|
296 |
*
|
297 |
* @since 0.9.4
|
@@ -304,7 +304,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
304 |
return $options;
|
305 |
}
|
306 |
|
307 |
-
|
308 |
* filters _wp_auto_add_pages_to_menu by language
|
309 |
*
|
310 |
* @since 0.9.4
|
@@ -333,7 +333,7 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
333 |
}
|
334 |
}
|
335 |
|
336 |
-
|
337 |
* prevents sharing a menu term with a language term by renaming the nav menu before its creation
|
338 |
* to avoid http://core.trac.wordpress.org/ticket/24802
|
339 |
* and http://wordpress.org/support/topic/all-connection-between-elements-lost
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages custom menus translations as well as the language switcher menu item on admin side
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
9 |
|
10 |
+
/**
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.2
|
33 |
}
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
* setups filters and terms
|
38 |
* adds the language switcher metabox and create new nav menu locations
|
39 |
*
|
58 |
$this->create_nav_menu_locations();
|
59 |
}
|
60 |
|
61 |
+
/**
|
62 |
* language switcher metabox
|
63 |
* The checkbox and all hidden fields are important
|
64 |
* thanks to John Morris for his very interesting post http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/
|
91 |
</div><?php
|
92 |
}
|
93 |
|
94 |
+
/**
|
95 |
* prepares javascript to modify the language switcher menu item
|
96 |
*
|
97 |
* @since 1.1
|
131 |
wp_localize_script( 'pll_nav_menu', 'pll_data', $data );
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
* save our menu item options
|
136 |
*
|
137 |
* @since 1.1
|
165 |
}
|
166 |
}
|
167 |
|
168 |
+
/**
|
169 |
* translates the language switcher menu items title in case the user switches the admin language
|
170 |
*
|
171 |
* @since 1.1.1
|
182 |
return $items;
|
183 |
}
|
184 |
|
185 |
+
/**
|
186 |
* assign menu languages and translations based on ( temporary ) locations
|
187 |
*
|
188 |
* @since 1.8
|
206 |
return $locations;
|
207 |
}
|
208 |
|
209 |
+
/**
|
210 |
* assign menu languages and translations based on ( temporary ) locations
|
211 |
*
|
212 |
* @since 1.1
|
246 |
return $mods;
|
247 |
}
|
248 |
|
249 |
+
/**
|
250 |
* fills temporary menu locations based on menus translations
|
251 |
*
|
252 |
* @since 1.2
|
268 |
return $menus;
|
269 |
}
|
270 |
|
271 |
+
/**
|
272 |
* removes the nav menu term_id from the locations stored in Polylang options when a nav menu is deleted
|
273 |
*
|
274 |
* @since 1.7.3
|
291 |
}
|
292 |
}
|
293 |
|
294 |
+
/**
|
295 |
* filters the option nav_menu_options for auto added pages to menu
|
296 |
*
|
297 |
* @since 0.9.4
|
304 |
return $options;
|
305 |
}
|
306 |
|
307 |
+
/**
|
308 |
* filters _wp_auto_add_pages_to_menu by language
|
309 |
*
|
310 |
* @since 0.9.4
|
333 |
}
|
334 |
}
|
335 |
|
336 |
+
/**
|
337 |
* prevents sharing a menu term with a language term by renaming the nav menu before its creation
|
338 |
* to avoid http://core.trac.wordpress.org/ticket/24802
|
339 |
* and http://wordpress.org/support/topic/all-connection-between-elements-lost
|
admin/admin-static-pages.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages the static front page and the page for posts on admin side
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Admin_Static_Pages extends PLL_Static_Pages {
|
9 |
|
10 |
-
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.8
|
@@ -27,7 +27,7 @@ class PLL_Admin_Static_Pages extends PLL_Static_Pages {
|
|
27 |
add_filter( 'pre_update_option_page_on_front', array( &$this, 'update_page_on_front' ), 10, 2 );
|
28 |
}
|
29 |
|
30 |
-
|
31 |
* add post state for translations of the front page and posts page
|
32 |
*
|
33 |
* @since 1.8
|
@@ -48,7 +48,7 @@ class PLL_Admin_Static_Pages extends PLL_Static_Pages {
|
|
48 |
return $post_states;
|
49 |
}
|
50 |
|
51 |
-
|
52 |
* refresh language cache when a static front page has been translated
|
53 |
*
|
54 |
* @since 1.8
|
@@ -63,7 +63,7 @@ class PLL_Admin_Static_Pages extends PLL_Static_Pages {
|
|
63 |
}
|
64 |
}
|
65 |
|
66 |
-
|
67 |
* prevents choosing an untranslated static front page
|
68 |
* displays an error message
|
69 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages the static front page and the page for posts on admin side
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Admin_Static_Pages extends PLL_Static_Pages {
|
9 |
|
10 |
+
/**
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.8
|
27 |
add_filter( 'pre_update_option_page_on_front', array( &$this, 'update_page_on_front' ), 10, 2 );
|
28 |
}
|
29 |
|
30 |
+
/**
|
31 |
* add post state for translations of the front page and posts page
|
32 |
*
|
33 |
* @since 1.8
|
48 |
return $post_states;
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
* refresh language cache when a static front page has been translated
|
53 |
*
|
54 |
* @since 1.8
|
63 |
}
|
64 |
}
|
65 |
|
66 |
+
/**
|
67 |
* prevents choosing an untranslated static front page
|
68 |
* displays an error message
|
69 |
*
|
admin/admin-strings.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* a fully static class to manage strings translations on admin side
|
5 |
*
|
6 |
* @since 1.6
|
@@ -9,7 +9,7 @@ class PLL_Admin_Strings {
|
|
9 |
static protected $strings = array(); // strings to translate
|
10 |
static protected $default_strings; // default strings to register
|
11 |
|
12 |
-
|
13 |
* init: add filters
|
14 |
*
|
15 |
* @since 1.6
|
@@ -19,13 +19,13 @@ class PLL_Admin_Strings {
|
|
19 |
add_filter( 'pll_sanitize_string_translation', array( __CLASS__, 'sanitize_string_translation' ), 10, 2 );
|
20 |
}
|
21 |
|
22 |
-
|
23 |
* register strings for translation making sure it is not duplicate or empty
|
24 |
*
|
25 |
* @since 0.6
|
26 |
*
|
27 |
-
* @param string $name
|
28 |
-
* @param string $string
|
29 |
* @param string $context optional the group in which the string is registered, defaults to 'polylang'
|
30 |
* @param bool $multiline optional wether the string table should display a multiline textarea or a single line input, defaults to single line
|
31 |
*/
|
@@ -42,7 +42,7 @@ class PLL_Admin_Strings {
|
|
42 |
}
|
43 |
}
|
44 |
|
45 |
-
|
46 |
* get registered strings
|
47 |
*
|
48 |
* @since 0.6.1
|
@@ -97,18 +97,25 @@ class PLL_Admin_Strings {
|
|
97 |
}
|
98 |
}
|
99 |
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
self::$strings = apply_filters( 'pll_get_strings', self::$strings );
|
102 |
return self::$strings;
|
103 |
}
|
104 |
|
105 |
-
|
106 |
* performs the sanitization ( before saving in DB ) of default strings translations
|
107 |
*
|
108 |
* @since 1.6
|
109 |
*
|
110 |
-
* @param string $translation
|
111 |
-
* @param string $name
|
112 |
* @return string
|
113 |
*/
|
114 |
static public function sanitize_string_translation( $translation, $name ) {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* a fully static class to manage strings translations on admin side
|
5 |
*
|
6 |
* @since 1.6
|
9 |
static protected $strings = array(); // strings to translate
|
10 |
static protected $default_strings; // default strings to register
|
11 |
|
12 |
+
/**
|
13 |
* init: add filters
|
14 |
*
|
15 |
* @since 1.6
|
19 |
add_filter( 'pll_sanitize_string_translation', array( __CLASS__, 'sanitize_string_translation' ), 10, 2 );
|
20 |
}
|
21 |
|
22 |
+
/**
|
23 |
* register strings for translation making sure it is not duplicate or empty
|
24 |
*
|
25 |
* @since 0.6
|
26 |
*
|
27 |
+
* @param string $name a unique name for the string
|
28 |
+
* @param string $string the string to register
|
29 |
* @param string $context optional the group in which the string is registered, defaults to 'polylang'
|
30 |
* @param bool $multiline optional wether the string table should display a multiline textarea or a single line input, defaults to single line
|
31 |
*/
|
42 |
}
|
43 |
}
|
44 |
|
45 |
+
/**
|
46 |
* get registered strings
|
47 |
*
|
48 |
* @since 0.6.1
|
97 |
}
|
98 |
}
|
99 |
|
100 |
+
/**
|
101 |
+
* Filter the list of strings registered for translation
|
102 |
+
* Mainly for use by our PLL_WPML_Compat class
|
103 |
+
*
|
104 |
+
* @since 1.0.2
|
105 |
+
*
|
106 |
+
* @param array $strings list of strings
|
107 |
+
*/
|
108 |
self::$strings = apply_filters( 'pll_get_strings', self::$strings );
|
109 |
return self::$strings;
|
110 |
}
|
111 |
|
112 |
+
/**
|
113 |
* performs the sanitization ( before saving in DB ) of default strings translations
|
114 |
*
|
115 |
* @since 1.6
|
116 |
*
|
117 |
+
* @param string $translation translation to sanitize
|
118 |
+
* @param string $name unique name for the string
|
119 |
* @return string
|
120 |
*/
|
121 |
static public function sanitize_string_translation( $translation, $name ) {
|
admin/admin.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* admin side controller
|
5 |
* accessible in $polylang global object
|
6 |
*
|
@@ -25,7 +25,7 @@
|
|
25 |
class PLL_Admin extends PLL_Admin_Base {
|
26 |
public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $sync, $filters_media;
|
27 |
|
28 |
-
|
29 |
* loads the polylang text domain
|
30 |
* setups filters and action needed on all admin pages and on plugins page
|
31 |
*
|
@@ -41,7 +41,7 @@ class PLL_Admin extends PLL_Admin_Base {
|
|
41 |
add_action( 'in_plugin_update_message-' . POLYLANG_BASENAME, array( &$this, 'plugin_update_message' ), 10, 2 );
|
42 |
}
|
43 |
|
44 |
-
|
45 |
* setups filters and action needed on all admin pages and on plugins page
|
46 |
* loads the settings pages or the filters base on the request
|
47 |
*
|
@@ -59,7 +59,7 @@ class PLL_Admin extends PLL_Admin_Base {
|
|
59 |
}
|
60 |
}
|
61 |
|
62 |
-
|
63 |
* adds a 'settings' link in the plugins table
|
64 |
*
|
65 |
* @since 0.1
|
@@ -72,7 +72,7 @@ class PLL_Admin extends PLL_Admin_Base {
|
|
72 |
return $links;
|
73 |
}
|
74 |
|
75 |
-
|
76 |
* adds the upgrade notice in plugins table
|
77 |
*
|
78 |
* @since 1.1.6
|
@@ -86,7 +86,7 @@ class PLL_Admin extends PLL_Admin_Base {
|
|
86 |
}
|
87 |
}
|
88 |
|
89 |
-
|
90 |
* setup filters for admin pages
|
91 |
*
|
92 |
* @since 1.2
|
@@ -102,6 +102,14 @@ class PLL_Admin extends PLL_Admin_Base {
|
|
102 |
|
103 |
foreach ( $classes as $class ) {
|
104 |
$obj = strtolower( $class );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
$class = apply_filters( 'pll_' . $obj, 'PLL_Admin_' . $class );
|
106 |
$this->$obj = new $class( $this );
|
107 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* admin side controller
|
5 |
* accessible in $polylang global object
|
6 |
*
|
25 |
class PLL_Admin extends PLL_Admin_Base {
|
26 |
public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $sync, $filters_media;
|
27 |
|
28 |
+
/**
|
29 |
* loads the polylang text domain
|
30 |
* setups filters and action needed on all admin pages and on plugins page
|
31 |
*
|
41 |
add_action( 'in_plugin_update_message-' . POLYLANG_BASENAME, array( &$this, 'plugin_update_message' ), 10, 2 );
|
42 |
}
|
43 |
|
44 |
+
/**
|
45 |
* setups filters and action needed on all admin pages and on plugins page
|
46 |
* loads the settings pages or the filters base on the request
|
47 |
*
|
59 |
}
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
* adds a 'settings' link in the plugins table
|
64 |
*
|
65 |
* @since 0.1
|
72 |
return $links;
|
73 |
}
|
74 |
|
75 |
+
/**
|
76 |
* adds the upgrade notice in plugins table
|
77 |
*
|
78 |
* @since 1.1.6
|
86 |
}
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
* setup filters for admin pages
|
91 |
*
|
92 |
* @since 1.2
|
102 |
|
103 |
foreach ( $classes as $class ) {
|
104 |
$obj = strtolower( $class );
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Filter the class to instantiate when loding admin filters
|
108 |
+
*
|
109 |
+
* @since 1.5
|
110 |
+
*
|
111 |
+
* @param string $class class name
|
112 |
+
*/
|
113 |
$class = apply_filters( 'pll_' . $obj, 'PLL_Admin_' . $class );
|
114 |
$this->$obj = new $class( $this );
|
115 |
}
|
admin/view-translations-media.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* displays the translations fields for media
|
5 |
* needs WP 3.5+
|
6 |
*/
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* displays the translations fields for media
|
5 |
* needs WP 3.5+
|
6 |
*/
|
admin/view-translations-post.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* displays the translations fields for posts
|
5 |
*/
|
6 |
|
@@ -9,7 +9,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
9 |
};
|
10 |
?>
|
11 |
<p><strong><?php _e( 'Translations', 'polylang' ); ?></strong></p>
|
12 |
-
<?php do_action( 'pll_before_post_translations' ) ?>
|
13 |
<table><?php
|
14 |
foreach ( $this->model->get_languages_list() as $language ) {
|
15 |
if ( $language->term_id == $lang->term_id ) {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* displays the translations fields for posts
|
5 |
*/
|
6 |
|
9 |
};
|
10 |
?>
|
11 |
<p><strong><?php _e( 'Translations', 'polylang' ); ?></strong></p>
|
|
|
12 |
<table><?php
|
13 |
foreach ( $this->model->get_languages_list() as $language ) {
|
14 |
if ( $language->term_id == $lang->term_id ) {
|
admin/view-translations-term.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* displays the translations fields for terms
|
5 |
*/
|
6 |
|
@@ -9,12 +9,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
9 |
};
|
10 |
|
11 |
if ( isset( $term_id ) ) {
|
12 |
-
// edit term form?>
|
13 |
<th scope="row"><?php _e( 'Translations', 'polylang' ); ?></th>
|
14 |
<td><?php
|
15 |
}
|
16 |
else {
|
17 |
-
// add term form?>
|
18 |
<p><?php _e( 'Translations', 'polylang' ); ?></p><?php
|
19 |
}?>
|
20 |
<table class="widefat term-translations" id="<?php echo isset( $term_id ) ? 'edit' : 'add'; ?>-term-translations"><?php
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* displays the translations fields for terms
|
5 |
*/
|
6 |
|
9 |
};
|
10 |
|
11 |
if ( isset( $term_id ) ) {
|
12 |
+
// edit term form ?>
|
13 |
<th scope="row"><?php _e( 'Translations', 'polylang' ); ?></th>
|
14 |
<td><?php
|
15 |
}
|
16 |
else {
|
17 |
+
// add term form ?>
|
18 |
<p><?php _e( 'Translations', 'polylang' ); ?></p><?php
|
19 |
}?>
|
20 |
<table class="widefat term-translations" id="<?php echo isset( $term_id ) ? 'edit' : 'add'; ?>-term-translations"><?php
|
changelog.txt
CHANGED
@@ -2,6 +2,90 @@
|
|
2 |
|
3 |
This file contains only old changelog. See readme.txt for newer versions.
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
= 1.7.12 (2015-11-13) =
|
6 |
|
7 |
* The language taxonomy is now public for compatibility with WP 4.4
|
2 |
|
3 |
This file contains only old changelog. See readme.txt for newer versions.
|
4 |
|
5 |
+
= 1.8.5 (2016-04-03) =
|
6 |
+
|
7 |
+
* Revert from $_SERVER['PHP_SELF'] to $_SERVER['SCRIPT_FILENAME'] to detect if the user is on login/register/signup page
|
8 |
+
* Fix incompatibility introduced by WP 4.5 in Edit single taxonomy term screen
|
9 |
+
* Fix existing post overriden when creating a language and a conflicting plugin sets the global $post on languages pages
|
10 |
+
|
11 |
+
= 1.8.4 (2016-03-06) =
|
12 |
+
|
13 |
+
* Revert canonical redirection of static front page when combining plain permalinks + default language hidden in url (introduced in 1.8.2)
|
14 |
+
|
15 |
+
= 1.8.3 (2016-03-04) =
|
16 |
+
|
17 |
+
* fix: All pages are redirected to the home page on some installations (introduced in 1.8.2)
|
18 |
+
|
19 |
+
= 1.8.2 (2016-03-02) =
|
20 |
+
|
21 |
+
* Add support for the 'wpml_get_default_language()' function from the WPML API
|
22 |
+
* Stop blocking saving settings when errors are detected (invalid domains)
|
23 |
+
* Use publicly_queryable => true instead of public => true for the language taxonomy (WP 4.5+)
|
24 |
+
* fix: PHP notice when pll_default_language() is called before a language is created
|
25 |
+
* fix: PHP notice undefined property PLL_Language::$page_on_front
|
26 |
+
* fix: canonical redirection of static front page when combining plain permalinks + default language hidden in url
|
27 |
+
* fix: YARPP compatibility broken in v1.8
|
28 |
+
* fix: Remove the delete link for translations of the default category (introduced back by WP 4.3)
|
29 |
+
* fix: settings not displayed with WP 4.1 or older
|
30 |
+
|
31 |
+
= 1.8.1 (2016-01-31) =
|
32 |
+
|
33 |
+
* Update the list of Facebook locales used for Opengraph support with Yoast SEO and Jetpack
|
34 |
+
* fix: secondary query with translated post type and untranslated taxonomy mixes languages (introduced in 1.8)
|
35 |
+
* fix: issue with paged static front page when hiding the default language in url
|
36 |
+
* fix: potential issue with cache after synchronizations
|
37 |
+
* fix: trailing slash added to canonical home url outputed by Yoast SEO when using default permalinks
|
38 |
+
|
39 |
+
= 1.8 (2016-01-19) =
|
40 |
+
|
41 |
+
* Minimum WordPress version is now 4.0
|
42 |
+
* Add ary, bn_BD, en_ZA, es_AR, fr_CA and fr_BE to the predefined languages list
|
43 |
+
* Adopt WordPress coding standards
|
44 |
+
* New structure for translated posts and terms (=> several methods of PLL_Model are deprecated).
|
45 |
+
* Revamp the management of the static front page and page for posts
|
46 |
+
* Improve performance for navigation menus with a lot of pages
|
47 |
+
* The Polylang and WPML API are now loaded when 'plugins_loaded' is fired (on frontend only if at least one language has been defined)
|
48 |
+
* Add 'pll_get_post_translations()' and 'pll_get_term_translations()' to the API
|
49 |
+
* Add filter 'pll_cookie_expiration' to change the cookie expiration time
|
50 |
+
* Add support for 'wpml_get_language_information()' function from the WPML API
|
51 |
+
* The default language is now managed directly from the languages list table
|
52 |
+
* Various accessibility improvements
|
53 |
+
* It is now possible to choose the languages flags from the available list (custom flags on frontend still work as previously)
|
54 |
+
* Revamp the settings page (now a list table with inline configuration)
|
55 |
+
* Add an option to remove all data when uninstalling the plugin
|
56 |
+
* Add test of subdomains and domains accessibility
|
57 |
+
* Add post state for translations of the front page and posts page
|
58 |
+
* Add better support of the customizer menus introduced in WP 4.3
|
59 |
+
* Media taxonomies (created by 3rd party plugins) are now filtered by language when editing a media
|
60 |
+
* Synchronization of taxonomies (created by 3rd party plugins) and meta are now enabled for media
|
61 |
+
* The 'hreflang' tag now refers to the locale instead of the 2-letters language code
|
62 |
+
* Workaround for WordPress locales not being W3C valid (see #33511)
|
63 |
+
* Workaround a bug in Nextgen Gallery causing redirect on album
|
64 |
+
* Add compatibility with Duplicate Post plugin to avoid duplicated post keeping the link to translations
|
65 |
+
* Add compatibility with Jetpack Related Posts
|
66 |
+
* fix: incorrect rewrite rules after changing how the language is set (need to flush rewrite rules after this)
|
67 |
+
* fix: password protected pages don't work on multiple domains
|
68 |
+
* fix: ensure that the page parent is in the correct language when using bulk edit
|
69 |
+
* fix: is_tax set on category and post tags archives when it should not
|
70 |
+
* fix: automatically added new top-level pages to menus are not filtered by language
|
71 |
+
* fix: nav menus locations are messed when changing the default language
|
72 |
+
* fix: error 404 for untranslated taxonomies pages
|
73 |
+
* fix: single posts and pages links do not include the language code when using the default permalinks and forcing the language code in url
|
74 |
+
* fix: missing trailing slash on home url when using default permalinks or a static front page
|
75 |
+
* fix: sticky visibility is copied to new translation only if the synchronization is activated
|
76 |
+
* fix: remove "» Languages » [language name]" from the feed title
|
77 |
+
* fix: spaces are not honored when searching strings translations
|
78 |
+
* fix: default language not set and terms translations not correctly imported when using WordPress Importer
|
79 |
+
* fix: the browser language detection does not differentiate 'en_US' and 'en_GB'
|
80 |
+
* fix: non alphanumeric characters query vars values lead to an infinite redirection loop on static front pages
|
81 |
+
* fix: user profile not saved for a language when the language code contains a "-"
|
82 |
+
* fix: non translated posts page always link to the static front page even when they should not
|
83 |
+
* fix: remove hreflang="x-default" when using one domain per language
|
84 |
+
* fix: deprecated function notice in WP 4.5 alpha
|
85 |
+
* fix: wrong url for attachments when media are translated and using subdomains
|
86 |
+
* fix: wrong url for unattached attachments when using subdirectories (since WP 4.4)
|
87 |
+
* fix: wrong url scheme for custom flags
|
88 |
+
|
89 |
= 1.7.12 (2015-11-13) =
|
90 |
|
91 |
* The language taxonomy is now public for compatibility with WP 4.4
|
css/admin.css
CHANGED
@@ -92,7 +92,7 @@
|
|
92 |
margin-bottom: 0.5em;
|
93 |
}
|
94 |
|
95 |
-
.pll-configure .submit {
|
96 |
margin-top: 20px;
|
97 |
}
|
98 |
|
@@ -128,6 +128,20 @@
|
|
128 |
vertical-align: top;
|
129 |
}
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
/* language columns in edit.php and edit-tags.php */
|
132 |
th[class*='column-language_'],
|
133 |
td[class*='column-language_'] {
|
@@ -280,6 +294,15 @@ td[class*='column-language_'] {
|
|
280 |
width: 100%;
|
281 |
}
|
282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
/* strings translations table */
|
284 |
.stringstranslations .column-context,
|
285 |
.stringstranslations .column-name {
|
92 |
margin-bottom: 0.5em;
|
93 |
}
|
94 |
|
95 |
+
.pll-configure p.submit {
|
96 |
margin-top: 20px;
|
97 |
}
|
98 |
|
128 |
vertical-align: top;
|
129 |
}
|
130 |
|
131 |
+
/* settings Activation keys */
|
132 |
+
#pll-licenses-table td {
|
133 |
+
vertical-align: top;
|
134 |
+
}
|
135 |
+
|
136 |
+
#pll-licenses-table label {
|
137 |
+
font-size: 1em;
|
138 |
+
font-weight: 600;
|
139 |
+
}
|
140 |
+
|
141 |
+
.pll-configure .pll-deactivate-license {
|
142 |
+
margin: 0 0 0 20px;
|
143 |
+
}
|
144 |
+
|
145 |
/* language columns in edit.php and edit-tags.php */
|
146 |
th[class*='column-language_'],
|
147 |
td[class*='column-language_'] {
|
294 |
width: 100%;
|
295 |
}
|
296 |
|
297 |
+
/* settings licenses */
|
298 |
+
#wpbody-content .pll-settings #pll-licenses-table td {
|
299 |
+
display: block;
|
300 |
+
}
|
301 |
+
|
302 |
+
.pll-configure .pll-deactivate-license {
|
303 |
+
margin: 10px 0 5px;
|
304 |
+
}
|
305 |
+
|
306 |
/* strings translations table */
|
307 |
.stringstranslations .column-context,
|
308 |
.stringstranslations .column-name {
|
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-
|
1 |
+
#pll-licenses-table td,.translation label{vertical-align:top}#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"}.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}#string-translation .search-box{margin:16px 0 8px}.stringstranslations .column-context,.stringstranslations .column-name{width:10%}.stringstranslations .column-string{width:33%}.translation label{display:inline-block;width:23%}.translation input,.translation textarea{width:72%}.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 label{font-size:1em;font-weight:600}.pll-configure .pll-deactivate-license{margin:0 0 0 20px}td[class*=column-language_],th[class*=column-language_]{width:1.5em}#post-translations p{float:left}#post-translations table{table-layout:fixed;width:100%;clear:both}#post-translations a{text-decoration:none}#post-translations .pll-edit-column,#post-translations .pll-language-column{width:20px}#post-translations td{padding:2px}#post-translations .spinner,#term-translations .spinner{float:none;margin:0;background-position:center;width:auto}.pll-edit-column{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-size:12px;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}@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}}
|
css/selectmenu.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{position:relative;margin:0;padding:3px 1em 3px .4em;min-height:0;list-style-image:url(
|
1 |
+
.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{position:relative;margin:0;padding:3px 1em 3px .4em;min-height:0;list-style-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item{padding-left:2em}.ui-menu .ui-icon,.ui-selectmenu-text .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0}.ui-selectmenu-menu{padding:0;margin:0;position:absolute;top:0;left:0;display:none}.ui-selectmenu-menu .ui-menu{overflow:auto;overflow-x:hidden;padding-bottom:1px}.ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup{font-size:1em;font-weight:700;line-height:23px;padding:2px .4em;margin:.5em 0 0;height:auto;border:0}.ui-selectmenu-open{display:block}.ui-selectmenu-button{display:inline-block;overflow:hidden;position:relative;text-decoration:none}.ui-selectmenu-button span.ui-icon{right:.5em;left:auto;margin-top:-10px;position:absolute;top:50%}.ui-selectmenu-button span.ui-selectmenu-text{text-align:left;padding:.4em 2.1em .4em 2em;display:block;line-height:23px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ui-state-default,.ui-widget-content,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{background:#fff;border:1px solid #ddd;box-shadow:0 1px 2px rgba(0,0,0,.07) inset;color:#32373c}.ui-widget-content .ui-state-focus,.ui-widget-content .ui-state-hover{background:#f5f5f5}.ui-selectmenu-button.ui-state-focus{border:1px solid #5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}.ui-icon-triangle-1-s:before{content:"\f140";font:20px/1 dashicons}.ui-widget-content{max-height:231px;box-shadow:0 2px 6px rgba(100,100,100,.3)}
|
frontend/choose-lang-content.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* Choose the language when it is set from content
|
5 |
* The language is set either in parse_query with priority 2 or in wp with priority 5
|
6 |
*
|
@@ -8,7 +8,7 @@
|
|
8 |
*/
|
9 |
class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
10 |
|
11 |
-
|
12 |
* defers the language choice to the 'wp' action (when the content is known)
|
13 |
*
|
14 |
* @since 1.8
|
@@ -25,7 +25,7 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
25 |
}
|
26 |
}
|
27 |
|
28 |
-
|
29 |
* overwrites parent::set_language to remove the 'wp' action if the language is set before
|
30 |
*
|
31 |
* @since 1.2
|
@@ -37,7 +37,7 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
37 |
remove_action( 'wp', array( &$this, 'wp' ), 5 ); // won't attempt to set the language a 2nd time
|
38 |
}
|
39 |
|
40 |
-
|
41 |
* returns the language based on the queried content
|
42 |
*
|
43 |
* @since 1.2
|
@@ -67,11 +67,17 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
67 |
}
|
68 |
}
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
return apply_filters( 'pll_get_current_language', isset( $lang ) ? $lang : false );
|
72 |
}
|
73 |
|
74 |
-
|
75 |
* sets the language for home page
|
76 |
* add the lang query var when querying archives with no language code
|
77 |
*
|
@@ -109,7 +115,7 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
109 |
}
|
110 |
}
|
111 |
|
112 |
-
|
113 |
* sets the language from content
|
114 |
*
|
115 |
* @since 1.2
|
@@ -121,7 +127,7 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
121 |
}
|
122 |
}
|
123 |
|
124 |
-
|
125 |
* if no language found by get_language_from_content, return the preferred one
|
126 |
*
|
127 |
* @since 0.9
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* Choose the language when it is set from content
|
5 |
* The language is set either in parse_query with priority 2 or in wp with priority 5
|
6 |
*
|
8 |
*/
|
9 |
class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
10 |
|
11 |
+
/**
|
12 |
* defers the language choice to the 'wp' action (when the content is known)
|
13 |
*
|
14 |
* @since 1.8
|
25 |
}
|
26 |
}
|
27 |
|
28 |
+
/**
|
29 |
* overwrites parent::set_language to remove the 'wp' action if the language is set before
|
30 |
*
|
31 |
* @since 1.2
|
37 |
remove_action( 'wp', array( &$this, 'wp' ), 5 ); // won't attempt to set the language a 2nd time
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
* returns the language based on the queried content
|
42 |
*
|
43 |
* @since 1.2
|
67 |
}
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
+
* Filter the language before it is set from the content
|
72 |
+
*
|
73 |
+
* @since 0.9
|
74 |
+
*
|
75 |
+
* @param bool|object $lang language object or false if none was found
|
76 |
+
*/
|
77 |
return apply_filters( 'pll_get_current_language', isset( $lang ) ? $lang : false );
|
78 |
}
|
79 |
|
80 |
+
/**
|
81 |
* sets the language for home page
|
82 |
* add the lang query var when querying archives with no language code
|
83 |
*
|
115 |
}
|
116 |
}
|
117 |
|
118 |
+
/**
|
119 |
* sets the language from content
|
120 |
*
|
121 |
* @since 1.2
|
127 |
}
|
128 |
}
|
129 |
|
130 |
+
/**
|
131 |
* if no language found by get_language_from_content, return the preferred one
|
132 |
*
|
133 |
* @since 0.9
|
frontend/choose-lang-domain.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* Choose the language when the language is managed by different domains
|
5 |
*
|
6 |
* @since 1.5
|
7 |
*/
|
8 |
class PLL_Choose_Lang_Domain extends PLL_Choose_Lang_Url {
|
9 |
|
10 |
-
|
11 |
* don't set any language cookie
|
12 |
*
|
13 |
* @since 1.5
|
14 |
*/
|
15 |
protected function maybe_setcookie() {}
|
16 |
|
17 |
-
|
18 |
* don't redirect according to browser preferences
|
19 |
*
|
20 |
* @since 1.5
|
@@ -23,13 +23,14 @@ class PLL_Choose_Lang_Domain extends PLL_Choose_Lang_Url {
|
|
23 |
return $this->model->get_language( $this->links_model->get_language_from_url() );
|
24 |
}
|
25 |
|
26 |
-
|
27 |
* Adds query vars to query for home pages in all languages
|
28 |
*
|
29 |
* @since 1.5
|
30 |
*/
|
31 |
public function home_requested() {
|
32 |
$this->set_lang_query_var( $GLOBALS['wp_query'], $this->curlang );
|
|
|
33 |
do_action( 'pll_home_requested' );
|
34 |
}
|
35 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* Choose the language when the language is managed by different domains
|
5 |
*
|
6 |
* @since 1.5
|
7 |
*/
|
8 |
class PLL_Choose_Lang_Domain extends PLL_Choose_Lang_Url {
|
9 |
|
10 |
+
/**
|
11 |
* don't set any language cookie
|
12 |
*
|
13 |
* @since 1.5
|
14 |
*/
|
15 |
protected function maybe_setcookie() {}
|
16 |
|
17 |
+
/**
|
18 |
* don't redirect according to browser preferences
|
19 |
*
|
20 |
* @since 1.5
|
23 |
return $this->model->get_language( $this->links_model->get_language_from_url() );
|
24 |
}
|
25 |
|
26 |
+
/**
|
27 |
* Adds query vars to query for home pages in all languages
|
28 |
*
|
29 |
* @since 1.5
|
30 |
*/
|
31 |
public function home_requested() {
|
32 |
$this->set_lang_query_var( $GLOBALS['wp_query'], $this->curlang );
|
33 |
+
/** This action is documented in include/choose-lang.php */
|
34 |
do_action( 'pll_home_requested' );
|
35 |
}
|
36 |
}
|
frontend/choose-lang-url.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* Choose the language when the language code is added to all urls
|
5 |
* The language is set in plugins_loaded with priority 1 as done by WPML
|
6 |
* Some actions have to be delayed to wait for $wp_rewrite availibility
|
@@ -10,7 +10,7 @@
|
|
10 |
class PLL_Choose_Lang_Url extends PLL_Choose_lang {
|
11 |
protected $index = 'index.php'; // need this before $wp_rewrite is created, also harcoded in wp-includes/rewrite.php
|
12 |
|
13 |
-
|
14 |
* sets the language
|
15 |
*
|
16 |
* @since 1.8
|
@@ -25,7 +25,7 @@ class PLL_Choose_Lang_Url extends PLL_Choose_lang {
|
|
25 |
add_action( 'request', array( &$this, 'request' ) );
|
26 |
}
|
27 |
|
28 |
-
|
29 |
* finds the language according to information found in the url
|
30 |
*
|
31 |
* @since 1.2
|
@@ -67,7 +67,7 @@ class PLL_Choose_Lang_Url extends PLL_Choose_lang {
|
|
67 |
}
|
68 |
|
69 |
|
70 |
-
|
71 |
* adds the current language in query vars
|
72 |
* useful for subdomains and multiple domains
|
73 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* Choose the language when the language code is added to all urls
|
5 |
* The language is set in plugins_loaded with priority 1 as done by WPML
|
6 |
* Some actions have to be delayed to wait for $wp_rewrite availibility
|
10 |
class PLL_Choose_Lang_Url extends PLL_Choose_lang {
|
11 |
protected $index = 'index.php'; // need this before $wp_rewrite is created, also harcoded in wp-includes/rewrite.php
|
12 |
|
13 |
+
/**
|
14 |
* sets the language
|
15 |
*
|
16 |
* @since 1.8
|
25 |
add_action( 'request', array( &$this, 'request' ) );
|
26 |
}
|
27 |
|
28 |
+
/**
|
29 |
* finds the language according to information found in the url
|
30 |
*
|
31 |
* @since 1.2
|
67 |
}
|
68 |
|
69 |
|
70 |
+
/**
|
71 |
* adds the current language in query vars
|
72 |
* useful for subdomains and multiple domains
|
73 |
*
|
frontend/choose-lang.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* base class to choose the language
|
5 |
*
|
6 |
* @since 1.2
|
@@ -9,7 +9,7 @@ abstract class PLL_Choose_Lang {
|
|
9 |
public $links_model, $model, $options;
|
10 |
public $curlang;
|
11 |
|
12 |
-
|
13 |
* constructor
|
14 |
*
|
15 |
* @since 1.2
|
@@ -24,7 +24,7 @@ abstract class PLL_Choose_Lang {
|
|
24 |
$this->curlang = &$polylang->curlang;
|
25 |
}
|
26 |
|
27 |
-
|
28 |
* sets the language for ajax requests
|
29 |
* and setup actions
|
30 |
* any child class must call this method if it overrides it
|
@@ -40,7 +40,7 @@ abstract class PLL_Choose_Lang {
|
|
40 |
add_action( 'parse_query', array( &$this, 'parse_main_query' ), 2 ); // sets the language in special cases
|
41 |
}
|
42 |
|
43 |
-
|
44 |
* writes language cookie
|
45 |
* loads user defined translations
|
46 |
* fires the action 'pll_language_defined'
|
@@ -62,10 +62,19 @@ abstract class PLL_Choose_Lang {
|
|
62 |
$this->maybe_setcookie();
|
63 |
|
64 |
$GLOBALS['text_direction'] = $this->curlang->is_rtl ? 'rtl' : 'ltr';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
do_action( 'pll_language_defined', $this->curlang->slug, $this->curlang );
|
66 |
}
|
67 |
|
68 |
-
|
69 |
* set a cookie to remember the language.
|
70 |
* possibility to set PLL_COOKIE to false will disable cookie although it will break some functionalities
|
71 |
*
|
@@ -75,17 +84,27 @@ abstract class PLL_Choose_Lang {
|
|
75 |
// check headers have not been sent to avoid ugly error
|
76 |
// cookie domain must be set to false for localhost ( default value for COOKIE_DOMAIN ) thanks to Stephen Harris.
|
77 |
if ( ! headers_sent() && PLL_COOKIE !== false && ( ! isset( $_COOKIE[ PLL_COOKIE ] ) || $_COOKIE[ PLL_COOKIE ] != $this->curlang->slug ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
setcookie(
|
79 |
PLL_COOKIE,
|
80 |
$this->curlang->slug,
|
81 |
-
time() +
|
82 |
COOKIEPATH,
|
83 |
2 == $this->options['force_lang'] ? parse_url( $this->links_model->home, PHP_URL_HOST ) : COOKIE_DOMAIN
|
84 |
);
|
85 |
}
|
86 |
}
|
87 |
|
88 |
-
|
89 |
* get the preferred language according to the browser preferences
|
90 |
* code adapted from http://www.thefutureoftheweb.com/blog/use-accept-language-header
|
91 |
*
|
@@ -153,7 +172,7 @@ abstract class PLL_Choose_Lang {
|
|
153 |
return false;
|
154 |
}
|
155 |
|
156 |
-
|
157 |
* returns the language according to browser preference or the default language
|
158 |
*
|
159 |
* @since 0.1
|
@@ -166,15 +185,23 @@ abstract class PLL_Choose_Lang {
|
|
166 |
return $this->model->get_language( $_COOKIE[ PLL_COOKIE ] );
|
167 |
}
|
168 |
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
$slug = apply_filters( 'pll_preferred_language', $this->options['browser'] ? $this->get_preferred_browser_language() : false );
|
172 |
|
173 |
// return default if there is no preferences in the browser or preferences does not match our languages or it is requested not to use the browser preference
|
174 |
return ( $lang = $this->model->get_language( $slug ) ) ? $lang : $this->model->get_language( $this->options['default_lang'] );
|
175 |
}
|
176 |
|
177 |
-
|
178 |
* sets the language when home page is resquested
|
179 |
*
|
180 |
* @since 1.2
|
@@ -188,7 +215,7 @@ abstract class PLL_Choose_Lang {
|
|
188 |
$this->set_language( $language );
|
189 |
}
|
190 |
|
191 |
-
|
192 |
* to call when the home page has been requested
|
193 |
* make sure to call this after 'setup_theme' has been fired as we need $wp_query
|
194 |
* performs a redirection to the home page in the current language if needed
|
@@ -199,6 +226,12 @@ abstract class PLL_Choose_Lang {
|
|
199 |
// we are already on the right page
|
200 |
if ( $this->options['default_lang'] == $this->curlang->slug && $this->options['hide_default'] ) {
|
201 |
$this->set_lang_query_var( $GLOBALS['wp_query'], $this->curlang );
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
do_action( 'pll_home_requested' );
|
203 |
}
|
204 |
// redirect to the home page in the right language
|
@@ -208,6 +241,15 @@ abstract class PLL_Choose_Lang {
|
|
208 |
// don't forget the query string which may be added by plugins
|
209 |
elseif ( is_string( $redirect = $this->curlang->home_url ) && empty( $_POST ) ) {
|
210 |
$redirect = empty( $_SERVER['QUERY_STRING'] ) ? $redirect : $redirect . ( $this->links_model->using_permalinks ? '?' : '&' ) . $_SERVER['QUERY_STRING'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
if ( $redirect = apply_filters( 'pll_redirect_home', $redirect ) ) {
|
212 |
wp_redirect( $redirect );
|
213 |
exit;
|
@@ -215,7 +257,7 @@ abstract class PLL_Choose_Lang {
|
|
215 |
}
|
216 |
}
|
217 |
|
218 |
-
|
219 |
* set the language when posting a comment
|
220 |
*
|
221 |
* @since 0.8.4
|
@@ -226,7 +268,7 @@ abstract class PLL_Choose_Lang {
|
|
226 |
$this->set_language( $this->model->post->get_language( $post_id ) );
|
227 |
}
|
228 |
|
229 |
-
|
230 |
* modifies some main query vars for home page and page for posts
|
231 |
* to enable one home page ( and one page for posts ) per language
|
232 |
*
|
@@ -239,6 +281,14 @@ abstract class PLL_Choose_Lang {
|
|
239 |
return;
|
240 |
}
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
if ( $lang = apply_filters( 'pll_set_language_from_query', false, $query ) ) {
|
243 |
$this->set_language( $lang );
|
244 |
$this->set_lang_query_var( $query, $this->curlang );
|
@@ -247,14 +297,15 @@ abstract class PLL_Choose_Lang {
|
|
247 |
// sets is_home on translated home page when it displays posts
|
248 |
// is_home must be true on page 2, 3... too
|
249 |
// as well as when searching an empty string: http://wordpress.org/support/topic/plugin-polylang-polylang-breaks-search-in-spun-theme
|
250 |
-
if ( 'posts' == get_option( 'show_on_front' ) && ( count( $query->query ) == 1 || ( is_paged() && count( $query->query ) == 2 ) || ( isset( $query->query['s'] ) && ! $query->query['s'] ) ) &&
|
251 |
-
$
|
|
|
252 |
$query->is_home = true;
|
253 |
$query->is_archive = $query->is_tax = false;
|
254 |
}
|
255 |
}
|
256 |
|
257 |
-
|
258 |
* sets the language in query
|
259 |
* optimized for ( needs ) WP 3.5+
|
260 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* base class to choose the language
|
5 |
*
|
6 |
* @since 1.2
|
9 |
public $links_model, $model, $options;
|
10 |
public $curlang;
|
11 |
|
12 |
+
/**
|
13 |
* constructor
|
14 |
*
|
15 |
* @since 1.2
|
24 |
$this->curlang = &$polylang->curlang;
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
* sets the language for ajax requests
|
29 |
* and setup actions
|
30 |
* any child class must call this method if it overrides it
|
40 |
add_action( 'parse_query', array( &$this, 'parse_main_query' ), 2 ); // sets the language in special cases
|
41 |
}
|
42 |
|
43 |
+
/**
|
44 |
* writes language cookie
|
45 |
* loads user defined translations
|
46 |
* fires the action 'pll_language_defined'
|
62 |
$this->maybe_setcookie();
|
63 |
|
64 |
$GLOBALS['text_direction'] = $this->curlang->is_rtl ? 'rtl' : 'ltr';
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Fires when the current language is defined
|
68 |
+
*
|
69 |
+
* @since 0.9.5
|
70 |
+
*
|
71 |
+
* @param string $slug current language code
|
72 |
+
* @param object $curlang current language object
|
73 |
+
*/
|
74 |
do_action( 'pll_language_defined', $this->curlang->slug, $this->curlang );
|
75 |
}
|
76 |
|
77 |
+
/**
|
78 |
* set a cookie to remember the language.
|
79 |
* possibility to set PLL_COOKIE to false will disable cookie although it will break some functionalities
|
80 |
*
|
84 |
// check headers have not been sent to avoid ugly error
|
85 |
// cookie domain must be set to false for localhost ( default value for COOKIE_DOMAIN ) thanks to Stephen Harris.
|
86 |
if ( ! headers_sent() && PLL_COOKIE !== false && ( ! isset( $_COOKIE[ PLL_COOKIE ] ) || $_COOKIE[ PLL_COOKIE ] != $this->curlang->slug ) ) {
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Filter the Polylang cookie duration
|
90 |
+
*
|
91 |
+
* @since 1.8
|
92 |
+
*
|
93 |
+
* @param int $duration cookie duration in seconds
|
94 |
+
*/
|
95 |
+
$expiration = apply_filters( 'pll_cookie_expiration', YEAR_IN_SECONDS );
|
96 |
+
|
97 |
setcookie(
|
98 |
PLL_COOKIE,
|
99 |
$this->curlang->slug,
|
100 |
+
time() + $expiration,
|
101 |
COOKIEPATH,
|
102 |
2 == $this->options['force_lang'] ? parse_url( $this->links_model->home, PHP_URL_HOST ) : COOKIE_DOMAIN
|
103 |
);
|
104 |
}
|
105 |
}
|
106 |
|
107 |
+
/**
|
108 |
* get the preferred language according to the browser preferences
|
109 |
* code adapted from http://www.thefutureoftheweb.com/blog/use-accept-language-header
|
110 |
*
|
172 |
return false;
|
173 |
}
|
174 |
|
175 |
+
/**
|
176 |
* returns the language according to browser preference or the default language
|
177 |
*
|
178 |
* @since 0.1
|
185 |
return $this->model->get_language( $_COOKIE[ PLL_COOKIE ] );
|
186 |
}
|
187 |
|
188 |
+
/**
|
189 |
+
* Filter the visitor's preferred language (normally set first by cookie
|
190 |
+
* if this is not the first visit, then by the browser preferences).
|
191 |
+
* If no preferred language has been found or set by this filter,
|
192 |
+
* Polylang fallbacks to the default language
|
193 |
+
*
|
194 |
+
* @since 1.0
|
195 |
+
*
|
196 |
+
* @param string $language preferred language code
|
197 |
+
*/
|
198 |
$slug = apply_filters( 'pll_preferred_language', $this->options['browser'] ? $this->get_preferred_browser_language() : false );
|
199 |
|
200 |
// return default if there is no preferences in the browser or preferences does not match our languages or it is requested not to use the browser preference
|
201 |
return ( $lang = $this->model->get_language( $slug ) ) ? $lang : $this->model->get_language( $this->options['default_lang'] );
|
202 |
}
|
203 |
|
204 |
+
/**
|
205 |
* sets the language when home page is resquested
|
206 |
*
|
207 |
* @since 1.2
|
215 |
$this->set_language( $language );
|
216 |
}
|
217 |
|
218 |
+
/**
|
219 |
* to call when the home page has been requested
|
220 |
* make sure to call this after 'setup_theme' has been fired as we need $wp_query
|
221 |
* performs a redirection to the home page in the current language if needed
|
226 |
// we are already on the right page
|
227 |
if ( $this->options['default_lang'] == $this->curlang->slug && $this->options['hide_default'] ) {
|
228 |
$this->set_lang_query_var( $GLOBALS['wp_query'], $this->curlang );
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Fires when the site root page is requested
|
232 |
+
*
|
233 |
+
* @since 1.8
|
234 |
+
*/
|
235 |
do_action( 'pll_home_requested' );
|
236 |
}
|
237 |
// redirect to the home page in the right language
|
241 |
// don't forget the query string which may be added by plugins
|
242 |
elseif ( is_string( $redirect = $this->curlang->home_url ) && empty( $_POST ) ) {
|
243 |
$redirect = empty( $_SERVER['QUERY_STRING'] ) ? $redirect : $redirect . ( $this->links_model->using_permalinks ? '?' : '&' ) . $_SERVER['QUERY_STRING'];
|
244 |
+
|
245 |
+
/**
|
246 |
+
* When a visitor reaches the site home, Polylang redirects to the home page in the correct language.
|
247 |
+
* This filter allows plugins to modify the redirected url or prevent this redirection
|
248 |
+
*
|
249 |
+
* @since 1.1.1
|
250 |
+
*
|
251 |
+
* @param string $redirect the url the visitor will be redirected to
|
252 |
+
*/
|
253 |
if ( $redirect = apply_filters( 'pll_redirect_home', $redirect ) ) {
|
254 |
wp_redirect( $redirect );
|
255 |
exit;
|
257 |
}
|
258 |
}
|
259 |
|
260 |
+
/**
|
261 |
* set the language when posting a comment
|
262 |
*
|
263 |
* @since 0.8.4
|
268 |
$this->set_language( $this->model->post->get_language( $post_id ) );
|
269 |
}
|
270 |
|
271 |
+
/**
|
272 |
* modifies some main query vars for home page and page for posts
|
273 |
* to enable one home page ( and one page for posts ) per language
|
274 |
*
|
281 |
return;
|
282 |
}
|
283 |
|
284 |
+
/**
|
285 |
+
* This filter allows to set the language based on information contained in the main query
|
286 |
+
*
|
287 |
+
* @since 1.8
|
288 |
+
*
|
289 |
+
* @param bool|object $lang false or language object
|
290 |
+
* @param object $query WP_Query object
|
291 |
+
*/
|
292 |
if ( $lang = apply_filters( 'pll_set_language_from_query', false, $query ) ) {
|
293 |
$this->set_language( $lang );
|
294 |
$this->set_lang_query_var( $query, $this->curlang );
|
297 |
// sets is_home on translated home page when it displays posts
|
298 |
// is_home must be true on page 2, 3... too
|
299 |
// as well as when searching an empty string: http://wordpress.org/support/topic/plugin-polylang-polylang-breaks-search-in-spun-theme
|
300 |
+
if ( 'posts' == get_option( 'show_on_front' ) && ( count( $query->query ) == 1 || ( is_paged() && count( $query->query ) == 2 ) || ( isset( $query->query['s'] ) && ! $query->query['s'] ) ) && $lang = get_query_var( 'lang' ) ) {
|
301 |
+
$lang = $this->model->get_language( $lang );
|
302 |
+
$this->set_language( $lang ); // sets the language now otherwise it will be too late to filter sticky posts !
|
303 |
$query->is_home = true;
|
304 |
$query->is_archive = $query->is_tax = false;
|
305 |
}
|
306 |
}
|
307 |
|
308 |
+
/**
|
309 |
* sets the language in query
|
310 |
* optimized for ( needs ) WP 3.5+
|
311 |
*
|
frontend/frontend-auto-translate.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
* auto translates the posts and terms ids
|
4 |
* useful for example for themes querying a specific cat
|
5 |
*
|
@@ -8,7 +9,7 @@
|
|
8 |
class PLL_Frontend_Auto_Translate {
|
9 |
public $model, $curlang;
|
10 |
|
11 |
-
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.1
|
@@ -23,7 +24,7 @@ class PLL_Frontend_Auto_Translate {
|
|
23 |
add_filter( 'get_terms_args', array( &$this, 'get_terms_args' ), 10, 2 );
|
24 |
}
|
25 |
|
26 |
-
|
27 |
* helper function to get the translated post in the current language
|
28 |
*
|
29 |
* since 1.8
|
@@ -35,7 +36,7 @@ class PLL_Frontend_Auto_Translate {
|
|
35 |
return $this->model->post->get( $post_id, $this->curlang );
|
36 |
}
|
37 |
|
38 |
-
|
39 |
* helper function to get the translated term in the current language
|
40 |
*
|
41 |
* since 1.8
|
@@ -47,7 +48,7 @@ class PLL_Frontend_Auto_Translate {
|
|
47 |
return $this->model->term->get( $term_id, $this->curlang );
|
48 |
}
|
49 |
|
50 |
-
|
51 |
* filters posts query to automatically translate included ids
|
52 |
*
|
53 |
* @since 1.1
|
@@ -183,7 +184,7 @@ class PLL_Frontend_Auto_Translate {
|
|
183 |
}
|
184 |
}
|
185 |
|
186 |
-
|
187 |
* filters terms query to automatically translate included ids
|
188 |
*
|
189 |
* @since 1.1.1
|
@@ -203,7 +204,7 @@ class PLL_Frontend_Auto_Translate {
|
|
203 |
return $args;
|
204 |
}
|
205 |
|
206 |
-
|
207 |
* translates tax queries
|
208 |
* compatible with nested tax queries introduced in WP 4.1
|
209 |
*
|
1 |
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
* auto translates the posts and terms ids
|
5 |
* useful for example for themes querying a specific cat
|
6 |
*
|
9 |
class PLL_Frontend_Auto_Translate {
|
10 |
public $model, $curlang;
|
11 |
|
12 |
+
/**
|
13 |
* constructor
|
14 |
*
|
15 |
* @since 1.1
|
24 |
add_filter( 'get_terms_args', array( &$this, 'get_terms_args' ), 10, 2 );
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
* helper function to get the translated post in the current language
|
29 |
*
|
30 |
* since 1.8
|
36 |
return $this->model->post->get( $post_id, $this->curlang );
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
* helper function to get the translated term in the current language
|
41 |
*
|
42 |
* since 1.8
|
48 |
return $this->model->term->get( $term_id, $this->curlang );
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
* filters posts query to automatically translate included ids
|
53 |
*
|
54 |
* @since 1.1
|
184 |
}
|
185 |
}
|
186 |
|
187 |
+
/**
|
188 |
* filters terms query to automatically translate included ids
|
189 |
*
|
190 |
* @since 1.1.1
|
204 |
return $args;
|
205 |
}
|
206 |
|
207 |
+
/**
|
208 |
* translates tax queries
|
209 |
* compatible with nested tax queries introduced in WP 4.1
|
210 |
*
|
frontend/frontend-filters-links.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages links filters on frontend
|
5 |
*
|
6 |
* @since 1.8
|
@@ -9,7 +9,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
9 |
public $curlang;
|
10 |
public $cache; // our internal non persistent cache object
|
11 |
|
12 |
-
|
13 |
* constructor
|
14 |
* adds filters once the language is defined
|
15 |
* low priority on links filters to come after any other modification
|
@@ -53,7 +53,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
53 |
add_action( 'template_redirect', array( &$this, 'check_canonical_url' ), 4 );
|
54 |
}
|
55 |
|
56 |
-
|
57 |
* modifies the author and date links to add the language parameter ( as well as feed link )
|
58 |
*
|
59 |
* @since 0.4
|
@@ -65,7 +65,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
65 |
return $this->links_model->add_language_to_link( $link, $this->curlang );
|
66 |
}
|
67 |
|
68 |
-
|
69 |
* modifies the post type archive links to add the language parameter
|
70 |
* only if the post type is translated
|
71 |
*
|
@@ -79,7 +79,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
79 |
return $this->model->is_translated_post_type( $post_type ) ? $this->links_model->add_language_to_link( $link, $this->curlang ) : $link;
|
80 |
}
|
81 |
|
82 |
-
|
83 |
* modifies post & page links
|
84 |
* caches the result
|
85 |
*
|
@@ -98,14 +98,14 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
98 |
return $_link;
|
99 |
}
|
100 |
|
101 |
-
|
102 |
* modifies page links
|
103 |
* caches the result
|
104 |
*
|
105 |
* @since 1.7
|
106 |
*
|
107 |
-
* @param string $link
|
108 |
-
* @param int
|
109 |
* @return string modified post link
|
110 |
*/
|
111 |
public function _get_page_link( $link, $post_id ) {
|
@@ -117,14 +117,14 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
117 |
return $_link;
|
118 |
}
|
119 |
|
120 |
-
|
121 |
* modifies attachment links
|
122 |
* caches the result
|
123 |
*
|
124 |
* @since 1.6.2
|
125 |
*
|
126 |
-
* @param string $link
|
127 |
-
* @param int
|
128 |
* @return string modified attachment link
|
129 |
*/
|
130 |
public function attachment_link( $link, $post_id ) {
|
@@ -136,7 +136,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
136 |
return $_link;
|
137 |
}
|
138 |
|
139 |
-
|
140 |
* modifies custom posts links
|
141 |
* caches the result
|
142 |
*
|
@@ -155,7 +155,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
155 |
return $_link;
|
156 |
}
|
157 |
|
158 |
-
|
159 |
* modifies filtered taxonomies ( post format like ) and translated taxonomies links
|
160 |
* caches the result
|
161 |
*
|
@@ -163,7 +163,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
163 |
*
|
164 |
* @param string $link
|
165 |
* @param object $term term object
|
166 |
-
* @param string $tax
|
167 |
* @return string modified link
|
168 |
*/
|
169 |
public function term_link( $link, $term, $tax ) {
|
@@ -171,6 +171,8 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
171 |
if ( false === $_link = $this->cache->get( $cache_key ) ) {
|
172 |
if ( in_array( $tax, $this->model->get_filtered_taxonomies() ) ) {
|
173 |
$_link = $this->links_model->add_language_to_link( $link, $this->curlang );
|
|
|
|
|
174 |
$_link = apply_filters( 'pll_term_link', $_link, $this->curlang, $term );
|
175 |
}
|
176 |
|
@@ -182,7 +184,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
182 |
return $_link;
|
183 |
}
|
184 |
|
185 |
-
|
186 |
* outputs references to translated pages ( if exists ) in the html head section
|
187 |
*
|
188 |
* @since 0.1
|
@@ -198,7 +200,16 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
198 |
// ouptputs the section only if there are translations ( $urls always contains self link )
|
199 |
// don't output anything on paged archives: see https://wordpress.org/support/topic/hreflang-on-page2
|
200 |
if ( ! empty( $urls ) && count( $urls ) > 1 && ! is_paged() ) {
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
printf( '<link rel="alternate" href="%s" hreflang="%s" />'."\n", esc_url( $url ), esc_attr( $lang ) );
|
203 |
}
|
204 |
|
@@ -210,7 +221,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
210 |
}
|
211 |
}
|
212 |
|
213 |
-
|
214 |
* filters the home url to get the right language
|
215 |
*
|
216 |
* @since 0.4
|
@@ -233,6 +244,16 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
233 |
$theme_root = get_theme_root();
|
234 |
$theme_root = ( false === strpos( $theme_root, '\\' ) ) ? $theme_root : str_replace( '/', '\\', $theme_root );
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
$white_list = apply_filters( 'pll_home_url_white_list', array(
|
237 |
array( 'file' => $theme_root ),
|
238 |
array( 'function' => 'wp_nav_menu' ),
|
@@ -242,6 +263,17 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
242 |
|
243 |
// we don't want to filter the home url in these cases
|
244 |
if ( empty( $black_list ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
$black_list = apply_filters( 'pll_home_url_black_list', array(
|
246 |
array( 'file' => 'searchform.php' ), // since WP 3.6 searchform.php is passed through get_search_form
|
247 |
array( 'function' => 'get_search_form' ),
|
@@ -270,12 +302,12 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
270 |
return empty( $ok ) ? $url : ( empty( $path ) ? rtrim( $this->links->get_home_url( $this->curlang ), '/' ) : $this->links->get_home_url( $this->curlang ) );
|
271 |
}
|
272 |
|
273 |
-
|
274 |
* rewrites ajax url when using domains or subdomains
|
275 |
*
|
276 |
* @since 1.5
|
277 |
*
|
278 |
-
* @param string $url
|
279 |
* @param string $path admin path
|
280 |
* @return string
|
281 |
*/
|
@@ -283,14 +315,14 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
283 |
return 'admin-ajax.php' === $path ? $this->links_model->switch_language_in_link( $url, $this->curlang ) : $url;
|
284 |
}
|
285 |
|
286 |
-
|
287 |
* if the language code is not in agreement with the language of the content
|
288 |
* redirects incoming links to the proper URL to avoid duplicate content
|
289 |
*
|
290 |
* @since 0.9.6
|
291 |
*
|
292 |
* @param string $requested_url optional
|
293 |
-
* @param bool
|
294 |
* @return string if redirect is not performed
|
295 |
*/
|
296 |
public function check_canonical_url( $requested_url = '', $do_redirect = true ) {
|
@@ -334,11 +366,16 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
334 |
$language = $this->model->post->get_language( (int) $obj->ID );
|
335 |
}
|
336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
if ( empty( $language ) ) {
|
338 |
$language = $this->curlang;
|
339 |
$redirect_url = $requested_url;
|
340 |
-
}
|
341 |
-
else {
|
342 |
// first get the canonical url evaluated by WP
|
343 |
$redirect_url = ( ! $redirect_url = redirect_canonical( $requested_url, false ) ) ? $requested_url : $redirect_url;
|
344 |
|
@@ -348,7 +385,14 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
348 |
$this->links_model->remove_language_from_link( $redirect_url ); // works only for default permalinks
|
349 |
}
|
350 |
|
351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
$redirect_url = apply_filters( 'pll_check_canonical_url', $redirect_url, $language );
|
353 |
|
354 |
// the language is not correctly set so let's redirect to the correct url for this object
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages links filters on frontend
|
5 |
*
|
6 |
* @since 1.8
|
9 |
public $curlang;
|
10 |
public $cache; // our internal non persistent cache object
|
11 |
|
12 |
+
/**
|
13 |
* constructor
|
14 |
* adds filters once the language is defined
|
15 |
* low priority on links filters to come after any other modification
|
53 |
add_action( 'template_redirect', array( &$this, 'check_canonical_url' ), 4 );
|
54 |
}
|
55 |
|
56 |
+
/**
|
57 |
* modifies the author and date links to add the language parameter ( as well as feed link )
|
58 |
*
|
59 |
* @since 0.4
|
65 |
return $this->links_model->add_language_to_link( $link, $this->curlang );
|
66 |
}
|
67 |
|
68 |
+
/**
|
69 |
* modifies the post type archive links to add the language parameter
|
70 |
* only if the post type is translated
|
71 |
*
|
79 |
return $this->model->is_translated_post_type( $post_type ) ? $this->links_model->add_language_to_link( $link, $this->curlang ) : $link;
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
* modifies post & page links
|
84 |
* caches the result
|
85 |
*
|
98 |
return $_link;
|
99 |
}
|
100 |
|
101 |
+
/**
|
102 |
* modifies page links
|
103 |
* caches the result
|
104 |
*
|
105 |
* @since 1.7
|
106 |
*
|
107 |
+
* @param string $link post link
|
108 |
+
* @param int $post_id post ID
|
109 |
* @return string modified post link
|
110 |
*/
|
111 |
public function _get_page_link( $link, $post_id ) {
|
117 |
return $_link;
|
118 |
}
|
119 |
|
120 |
+
/**
|
121 |
* modifies attachment links
|
122 |
* caches the result
|
123 |
*
|
124 |
* @since 1.6.2
|
125 |
*
|
126 |
+
* @param string $link attachment link
|
127 |
+
* @param int $post_id attachment link
|
128 |
* @return string modified attachment link
|
129 |
*/
|
130 |
public function attachment_link( $link, $post_id ) {
|
136 |
return $_link;
|
137 |
}
|
138 |
|
139 |
+
/**
|
140 |
* modifies custom posts links
|
141 |
* caches the result
|
142 |
*
|
155 |
return $_link;
|
156 |
}
|
157 |
|
158 |
+
/**
|
159 |
* modifies filtered taxonomies ( post format like ) and translated taxonomies links
|
160 |
* caches the result
|
161 |
*
|
163 |
*
|
164 |
* @param string $link
|
165 |
* @param object $term term object
|
166 |
+
* @param string $tax taxonomy name
|
167 |
* @return string modified link
|
168 |
*/
|
169 |
public function term_link( $link, $term, $tax ) {
|
171 |
if ( false === $_link = $this->cache->get( $cache_key ) ) {
|
172 |
if ( in_array( $tax, $this->model->get_filtered_taxonomies() ) ) {
|
173 |
$_link = $this->links_model->add_language_to_link( $link, $this->curlang );
|
174 |
+
|
175 |
+
/** This filter is documented in include/filters-links.php */
|
176 |
$_link = apply_filters( 'pll_term_link', $_link, $this->curlang, $term );
|
177 |
}
|
178 |
|
184 |
return $_link;
|
185 |
}
|
186 |
|
187 |
+
/**
|
188 |
* outputs references to translated pages ( if exists ) in the html head section
|
189 |
*
|
190 |
* @since 0.1
|
200 |
// ouptputs the section only if there are translations ( $urls always contains self link )
|
201 |
// don't output anything on paged archives: see https://wordpress.org/support/topic/hreflang-on-page2
|
202 |
if ( ! empty( $urls ) && count( $urls ) > 1 && ! is_paged() ) {
|
203 |
+
// prepare the list of languages to remove the country code
|
204 |
+
foreach ( array_keys( $urls ) as $locale ) {
|
205 |
+
$split = explode( '-', $locale );
|
206 |
+
$languages[ $locale ] = reset( $split );
|
207 |
+
}
|
208 |
+
|
209 |
+
$count = array_count_values( $languages );
|
210 |
+
|
211 |
+
foreach ( $urls as $locale => $url ) {
|
212 |
+
$lang = $count[ $languages[ $locale ] ] > 1 ? $locale : $languages[ $locale ]; // output the country code only when necessary
|
213 |
printf( '<link rel="alternate" href="%s" hreflang="%s" />'."\n", esc_url( $url ), esc_attr( $lang ) );
|
214 |
}
|
215 |
|
221 |
}
|
222 |
}
|
223 |
|
224 |
+
/**
|
225 |
* filters the home url to get the right language
|
226 |
*
|
227 |
* @since 0.4
|
244 |
$theme_root = get_theme_root();
|
245 |
$theme_root = ( false === strpos( $theme_root, '\\' ) ) ? $theme_root : str_replace( '/', '\\', $theme_root );
|
246 |
|
247 |
+
/**
|
248 |
+
* Filter the white list of the Polylang 'home_url' filter
|
249 |
+
* The $args contains an array of arrays each of them having
|
250 |
+
* a 'file' key and/or a 'function' key to decide which functions in
|
251 |
+
* which files using home_url() calls must be filtered
|
252 |
+
*
|
253 |
+
* @since 1.1.2
|
254 |
+
*
|
255 |
+
* @param array $args
|
256 |
+
*/
|
257 |
$white_list = apply_filters( 'pll_home_url_white_list', array(
|
258 |
array( 'file' => $theme_root ),
|
259 |
array( 'function' => 'wp_nav_menu' ),
|
263 |
|
264 |
// we don't want to filter the home url in these cases
|
265 |
if ( empty( $black_list ) ) {
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Filter the black list of the Polylang 'home_url' filter
|
269 |
+
* The $args contains an array of arrays each of them having
|
270 |
+
* a 'file' key and/or a 'function' key to decide which functions in
|
271 |
+
* which files using home_url() calls must be filtered
|
272 |
+
*
|
273 |
+
* @since 1.1.2
|
274 |
+
*
|
275 |
+
* @param array $args
|
276 |
+
*/
|
277 |
$black_list = apply_filters( 'pll_home_url_black_list', array(
|
278 |
array( 'file' => 'searchform.php' ), // since WP 3.6 searchform.php is passed through get_search_form
|
279 |
array( 'function' => 'get_search_form' ),
|
302 |
return empty( $ok ) ? $url : ( empty( $path ) ? rtrim( $this->links->get_home_url( $this->curlang ), '/' ) : $this->links->get_home_url( $this->curlang ) );
|
303 |
}
|
304 |
|
305 |
+
/**
|
306 |
* rewrites ajax url when using domains or subdomains
|
307 |
*
|
308 |
* @since 1.5
|
309 |
*
|
310 |
+
* @param string $url admin url with path evaluated by WordPress
|
311 |
* @param string $path admin path
|
312 |
* @return string
|
313 |
*/
|
315 |
return 'admin-ajax.php' === $path ? $this->links_model->switch_language_in_link( $url, $this->curlang ) : $url;
|
316 |
}
|
317 |
|
318 |
+
/**
|
319 |
* if the language code is not in agreement with the language of the content
|
320 |
* redirects incoming links to the proper URL to avoid duplicate content
|
321 |
*
|
322 |
* @since 0.9.6
|
323 |
*
|
324 |
* @param string $requested_url optional
|
325 |
+
* @param bool $do_redirect optional, whether to perform the redirection or not
|
326 |
* @return string if redirect is not performed
|
327 |
*/
|
328 |
public function check_canonical_url( $requested_url = '', $do_redirect = true ) {
|
366 |
$language = $this->model->post->get_language( (int) $obj->ID );
|
367 |
}
|
368 |
|
369 |
+
elseif ( is_404() && $id = get_query_var('p') ) {
|
370 |
+
// special case for page shortlinks when using subdomains or multiple domains
|
371 |
+
// needed because redirect_canonical doesn't accept to change the domain name
|
372 |
+
$language = $this->model->post->get_language( (int) $id );
|
373 |
+
}
|
374 |
+
|
375 |
if ( empty( $language ) ) {
|
376 |
$language = $this->curlang;
|
377 |
$redirect_url = $requested_url;
|
378 |
+
} else {
|
|
|
379 |
// first get the canonical url evaluated by WP
|
380 |
$redirect_url = ( ! $redirect_url = redirect_canonical( $requested_url, false ) ) ? $requested_url : $redirect_url;
|
381 |
|
385 |
$this->links_model->remove_language_from_link( $redirect_url ); // works only for default permalinks
|
386 |
}
|
387 |
|
388 |
+
/**
|
389 |
+
* Filters the canonical url detected by Polylang
|
390 |
+
*
|
391 |
+
* @since 1.6
|
392 |
+
*
|
393 |
+
* @param bool|string $redirect_url false or the url to redirect to
|
394 |
+
* @param object $language the language detected
|
395 |
+
*/
|
396 |
$redirect_url = apply_filters( 'pll_check_canonical_url', $redirect_url, $language );
|
397 |
|
398 |
// the language is not correctly set so let's redirect to the correct url for this object
|
frontend/frontend-filters-search.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* filters search forms when using permalinks
|
5 |
*
|
6 |
* @since 1.2
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_Frontend_Filters_Search {
|
9 |
public $links_model, $curlang;
|
10 |
|
11 |
-
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.2
|
@@ -33,7 +33,7 @@ class PLL_Frontend_Filters_Search {
|
|
33 |
}
|
34 |
}
|
35 |
|
36 |
-
|
37 |
* adds the language information in the search form
|
38 |
* does not work if searchform.php ( prior to WP 3.6 ) is used or if the search form is hardcoded in another template file
|
39 |
*
|
@@ -59,7 +59,7 @@ class PLL_Frontend_Filters_Search {
|
|
59 |
return $form;
|
60 |
}
|
61 |
|
62 |
-
|
63 |
* adds the language information in admin bar search form
|
64 |
*
|
65 |
* @since 1.2
|
@@ -69,7 +69,7 @@ class PLL_Frontend_Filters_Search {
|
|
69 |
add_action( 'admin_bar_menu', array( &$this, 'admin_bar_search_menu' ), 4 );
|
70 |
}
|
71 |
|
72 |
-
|
73 |
* rewrites the admin bar search form to pass our get_search form filter. See #21342
|
74 |
* code base is WP 4.3.1
|
75 |
*
|
@@ -92,7 +92,7 @@ class PLL_Frontend_Filters_Search {
|
|
92 |
) );
|
93 |
}
|
94 |
|
95 |
-
|
96 |
* allows modifying the search form if it does not pass get_search_form
|
97 |
*
|
98 |
* @since 0.1
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* filters search forms when using permalinks
|
5 |
*
|
6 |
* @since 1.2
|
8 |
class PLL_Frontend_Filters_Search {
|
9 |
public $links_model, $curlang;
|
10 |
|
11 |
+
/**
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.2
|
33 |
}
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
* adds the language information in the search form
|
38 |
* does not work if searchform.php ( prior to WP 3.6 ) is used or if the search form is hardcoded in another template file
|
39 |
*
|
59 |
return $form;
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
* adds the language information in admin bar search form
|
64 |
*
|
65 |
* @since 1.2
|
69 |
add_action( 'admin_bar_menu', array( &$this, 'admin_bar_search_menu' ), 4 );
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
* rewrites the admin bar search form to pass our get_search form filter. See #21342
|
74 |
* code base is WP 4.3.1
|
75 |
*
|
92 |
) );
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
* allows modifying the search form if it does not pass get_search_form
|
97 |
*
|
98 |
* @since 0.1
|
frontend/frontend-filters.php
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Frontend_Filters extends PLL_Filters{
|
9 |
-
|
10 |
-
|
|
|
11 |
*
|
12 |
* @since 1.2
|
13 |
*
|
@@ -16,37 +17,38 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
16 |
public function __construct( &$polylang ) {
|
17 |
parent::__construct( $polylang );
|
18 |
|
19 |
-
//
|
20 |
add_filter( 'locale', array( &$this, 'get_locale' ) );
|
21 |
|
22 |
-
//
|
23 |
add_filter( 'option_sticky_posts', array( &$this, 'option_sticky_posts' ) );
|
24 |
|
25 |
-
//
|
26 |
add_filter( 'get_terms_args', array( &$this, 'get_terms_args' ) );
|
27 |
|
28 |
-
//
|
29 |
add_filter( 'terms_clauses', array( &$this, 'terms_clauses' ), 10, 3 );
|
30 |
|
31 |
-
//
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
-
//
|
39 |
add_filter( 'widget_display_callback', array( &$this, 'widget_display_callback' ), 10, 2 );
|
40 |
|
41 |
-
//
|
42 |
foreach ( array( 'widget_text', 'widget_title', 'option_blogname', 'option_blogdescription', 'option_date_format', 'option_time_format' ) as $filter ) {
|
43 |
add_filter( $filter, 'pll__', 1 );
|
44 |
}
|
45 |
|
46 |
-
//
|
47 |
add_filter( 'get_user_metadata', array( &$this, 'get_user_metadata' ), 10, 4 );
|
48 |
|
49 |
-
//
|
50 |
add_action( 'save_post', array( &$this, 'save_post' ), 200, 2 );
|
51 |
add_action( 'create_term', array( &$this, 'save_term' ), 10, 3 );
|
52 |
add_action( 'edit_term', array( &$this, 'save_term' ), 10, 3 );
|
@@ -55,7 +57,7 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
55 |
add_action( 'add_attachment', array( &$this, 'set_default_language' ) );
|
56 |
}
|
57 |
|
58 |
-
//
|
59 |
// FIXME of course does not work if 'transport' is set to 'postMessage'
|
60 |
if ( isset( $_POST['wp_customize'], $_POST['customized'] ) ) {
|
61 |
add_filter( 'pre_option_blogname', 'pll__', 20 );
|
@@ -63,8 +65,8 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
63 |
}
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
*
|
68 |
*
|
69 |
* @since 0.1
|
70 |
*
|
@@ -75,8 +77,8 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
75 |
return $this->curlang->locale;
|
76 |
}
|
77 |
|
78 |
-
|
79 |
-
*
|
80 |
*
|
81 |
* @since 0.8
|
82 |
*
|
@@ -96,8 +98,8 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
96 |
return $posts;
|
97 |
}
|
98 |
|
99 |
-
|
100 |
-
*
|
101 |
* useful as the 'lang' parameter is not included in cache key by WordPress
|
102 |
*
|
103 |
* @since 1.3
|
@@ -112,82 +114,124 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
112 |
return $args;
|
113 |
}
|
114 |
|
115 |
-
|
116 |
-
*
|
117 |
*
|
118 |
* @since 0.2
|
119 |
*
|
120 |
-
* @param array $clauses
|
121 |
* @param array $taxonomies
|
122 |
-
* @param array $args
|
123 |
* @return array modified sql clauses
|
124 |
*/
|
125 |
public function terms_clauses( $clauses, $taxonomies, $args ) {
|
126 |
-
//
|
127 |
if ( ! $this->model->is_translated_taxonomy( $taxonomies ) ) {
|
128 |
return $clauses;
|
129 |
}
|
130 |
|
131 |
-
//
|
132 |
return $this->model->terms_clauses( $clauses, isset( $args['lang'] ) ? $args['lang'] : $this->curlang );
|
133 |
}
|
134 |
|
135 |
-
|
136 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
*
|
138 |
* @since 0.1
|
139 |
*
|
140 |
-
* @param string
|
141 |
-
* @
|
|
|
|
|
|
|
|
|
142 |
*/
|
143 |
-
public function posts_join( $sql ) {
|
144 |
-
|
|
|
145 |
}
|
146 |
|
147 |
-
|
148 |
-
*
|
149 |
*
|
150 |
* @since 0.1
|
151 |
*
|
152 |
-
* @param string
|
153 |
-
* @
|
|
|
|
|
|
|
|
|
154 |
*/
|
155 |
-
public function posts_where( $sql ) {
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
}
|
159 |
|
160 |
-
|
161 |
-
*
|
162 |
-
*
|
163 |
*
|
164 |
* @since 0.3
|
165 |
*
|
166 |
-
* @param array
|
167 |
-
* @param object $widget
|
168 |
* @return bool|array false if we hide the widget, unmodified $instance otherwise
|
169 |
*/
|
170 |
public function widget_display_callback( $instance, $widget ) {
|
171 |
return ! empty( $instance['pll_lang'] ) && $instance['pll_lang'] != $this->curlang->slug ? false : $instance;
|
172 |
}
|
173 |
|
174 |
-
|
175 |
-
*
|
176 |
*
|
177 |
* @since 0.9
|
178 |
*
|
179 |
-
* @param null
|
180 |
-
* @param int
|
181 |
* @param string $meta_key
|
182 |
-
* @param bool
|
183 |
* @return null|string
|
184 |
*/
|
185 |
public function get_user_metadata( $null, $id, $meta_key, $single ) {
|
186 |
return 'description' === $meta_key && $this->curlang->slug !== $this->options['default_lang'] ? get_user_meta( $id, 'description_'.$this->curlang->slug, $single ) : $null;
|
187 |
}
|
188 |
|
189 |
-
|
190 |
-
*
|
191 |
*
|
192 |
* @since 1.5.4
|
193 |
*
|
@@ -197,28 +241,24 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
197 |
if ( ! $this->model->post->get_language( $post_id ) ) {
|
198 |
if ( isset( $_REQUEST['lang'] ) ) {
|
199 |
$this->model->post->set_language( $post_id, $_REQUEST['lang'] );
|
200 |
-
}
|
201 |
-
|
202 |
-
elseif ( ( $parent_id = wp_get_post_parent_id( $post_id ) ) && $parent_lang = $this->model->post->get_language( $parent_id ) ) {
|
203 |
$this->model->post->set_language( $post_id, $parent_lang );
|
204 |
-
}
|
205 |
-
|
206 |
-
else {
|
207 |
$this->model->post->set_language( $post_id, $this->curlang );
|
208 |
}
|
209 |
}
|
210 |
}
|
211 |
|
212 |
-
|
213 |
-
*
|
214 |
-
*
|
215 |
-
*
|
216 |
*
|
217 |
* @since 1.1
|
218 |
*
|
219 |
-
* @param int
|
220 |
* @param object $post
|
221 |
-
* @param bool
|
222 |
*/
|
223 |
public function save_post( $post_id, $post ) {
|
224 |
if ( $this->model->is_translated_post_type( $post->post_type ) ) {
|
@@ -226,28 +266,24 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
226 |
}
|
227 |
}
|
228 |
|
229 |
-
|
230 |
-
*
|
231 |
-
*
|
232 |
-
*
|
233 |
*
|
234 |
* @since 1.1
|
235 |
*
|
236 |
-
* @param int
|
237 |
-
* @param int
|
238 |
* @param string $taxonomy
|
239 |
*/
|
240 |
public function save_term( $term_id, $tt_id, $taxonomy ) {
|
241 |
if ( $this->model->is_translated_taxonomy( $taxonomy ) && ! $this->model->term->get_language( $term_id ) ) {
|
242 |
if ( isset( $_REQUEST['lang'] ) ) {
|
243 |
$this->model->term->set_language( $term_id, $_REQUEST['lang'] );
|
244 |
-
}
|
245 |
-
|
246 |
-
elseif ( ( $term = get_term( $term_id, $taxonomy ) ) && ! empty( $term->parent ) && $parent_lang = $this->model->term->get_language( $term->parent ) ) {
|
247 |
$this->model->term->set_language( $term_id, $parent_lang );
|
248 |
-
}
|
249 |
-
|
250 |
-
else {
|
251 |
$this->model->term->set_language( $term_id, $this->curlang );
|
252 |
}
|
253 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Filters content by language on frontend
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Frontend_Filters extends PLL_Filters{
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.2
|
14 |
*
|
17 |
public function __construct( &$polylang ) {
|
18 |
parent::__construct( $polylang );
|
19 |
|
20 |
+
// Filters the WordPress locale
|
21 |
add_filter( 'locale', array( &$this, 'get_locale' ) );
|
22 |
|
23 |
+
// Filter sticky posts by current language
|
24 |
add_filter( 'option_sticky_posts', array( &$this, 'option_sticky_posts' ) );
|
25 |
|
26 |
+
// Adds cache domain when querying terms
|
27 |
add_filter( 'get_terms_args', array( &$this, 'get_terms_args' ) );
|
28 |
|
29 |
+
// Filters categories and post tags by language
|
30 |
add_filter( 'terms_clauses', array( &$this, 'terms_clauses' ), 10, 3 );
|
31 |
|
32 |
+
// Rewrites archives, next and previous post links to filter them by language
|
33 |
+
add_filter( 'getarchives_join', array( &$this, 'getarchives_join' ), 10, 2 );
|
34 |
+
add_filter( 'getarchives_where', array( &$this, 'getarchives_where' ), 10, 2 );
|
35 |
+
add_filter( 'get_previous_post_join', array( &$this, 'posts_join' ), 10, 5 );
|
36 |
+
add_filter( 'get_next_post_join', array( &$this, 'posts_join' ), 10, 5 );
|
37 |
+
add_filter( 'get_previous_post_where', array( &$this, 'posts_where' ), 10, 5 );
|
38 |
+
add_filter( 'get_next_post_where', array( &$this, 'posts_where' ), 10, 5 );
|
39 |
|
40 |
+
// Filters the widgets according to the current language
|
41 |
add_filter( 'widget_display_callback', array( &$this, 'widget_display_callback' ), 10, 2 );
|
42 |
|
43 |
+
// Strings translation ( must be applied before WordPress applies its default formatting filters )
|
44 |
foreach ( array( 'widget_text', 'widget_title', 'option_blogname', 'option_blogdescription', 'option_date_format', 'option_time_format' ) as $filter ) {
|
45 |
add_filter( $filter, 'pll__', 1 );
|
46 |
}
|
47 |
|
48 |
+
// Translates biography
|
49 |
add_filter( 'get_user_metadata', array( &$this, 'get_user_metadata' ), 10, 4 );
|
50 |
|
51 |
+
// Set posts and terms language when created from frontend ( ex with P2 theme )
|
52 |
add_action( 'save_post', array( &$this, 'save_post' ), 200, 2 );
|
53 |
add_action( 'create_term', array( &$this, 'save_term' ), 10, 3 );
|
54 |
add_action( 'edit_term', array( &$this, 'save_term' ), 10, 3 );
|
57 |
add_action( 'add_attachment', array( &$this, 'set_default_language' ) );
|
58 |
}
|
59 |
|
60 |
+
// Support theme customizer
|
61 |
// FIXME of course does not work if 'transport' is set to 'postMessage'
|
62 |
if ( isset( $_POST['wp_customize'], $_POST['customized'] ) ) {
|
63 |
add_filter( 'pre_option_blogname', 'pll__', 20 );
|
65 |
}
|
66 |
}
|
67 |
|
68 |
+
/**
|
69 |
+
* Returns the locale based on current language
|
70 |
*
|
71 |
* @since 0.1
|
72 |
*
|
77 |
return $this->curlang->locale;
|
78 |
}
|
79 |
|
80 |
+
/**
|
81 |
+
* Filters sticky posts by current language
|
82 |
*
|
83 |
* @since 0.8
|
84 |
*
|
98 |
return $posts;
|
99 |
}
|
100 |
|
101 |
+
/**
|
102 |
+
* Adds language dependent cache domain when querying terms
|
103 |
* useful as the 'lang' parameter is not included in cache key by WordPress
|
104 |
*
|
105 |
* @since 1.3
|
114 |
return $args;
|
115 |
}
|
116 |
|
117 |
+
/**
|
118 |
+
* Filters categories and post tags by language when needed
|
119 |
*
|
120 |
* @since 0.2
|
121 |
*
|
122 |
+
* @param array $clauses sql clauses
|
123 |
* @param array $taxonomies
|
124 |
+
* @param array $args get_terms arguments
|
125 |
* @return array modified sql clauses
|
126 |
*/
|
127 |
public function terms_clauses( $clauses, $taxonomies, $args ) {
|
128 |
+
// Does nothing except on taxonomies which are filterable
|
129 |
if ( ! $this->model->is_translated_taxonomy( $taxonomies ) ) {
|
130 |
return $clauses;
|
131 |
}
|
132 |
|
133 |
+
// Adds our clauses to filter by language
|
134 |
return $this->model->terms_clauses( $clauses, isset( $args['lang'] ) ? $args['lang'] : $this->curlang );
|
135 |
}
|
136 |
|
137 |
+
/**
|
138 |
+
* Modifies the sql request for wp_get_archives to filter by the current language
|
139 |
+
*
|
140 |
+
* @since 1.9
|
141 |
+
*
|
142 |
+
* @param string $sql JOIN clause
|
143 |
+
* @param array $r wp_get_archives arguments
|
144 |
+
* @return string modified JOIN clause
|
145 |
+
*/
|
146 |
+
public function getarchives_join( $sql, $r ) {
|
147 |
+
return ! empty( $r['post_type'] ) && $this->model->is_translated_post_type( $r['post_type'] ) ? $sql . $this->model->post->join_clause() : $sql;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Modifies the sql request for wp_get_archives to filter by the current language
|
152 |
+
*
|
153 |
+
* @since 1.9
|
154 |
+
*
|
155 |
+
* @param string $sql WHERE clause
|
156 |
+
* @param array $r wp_get_archives arguments
|
157 |
+
* @return string modified WHERE clause
|
158 |
+
*/
|
159 |
+
public function getarchives_where( $sql, $r ) {
|
160 |
+
return ! empty( $r['post_type'] ) && $this->model->is_translated_post_type( $r['post_type'] ) ? $sql . $this->model->post->where_clause( $this->curlang ) : $sql;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Modifies the sql request for get_adjacent_post to filter by the current language
|
165 |
*
|
166 |
* @since 0.1
|
167 |
*
|
168 |
+
* @param string $sql The JOIN clause in the SQL.
|
169 |
+
* @param bool $in_same_term Whether post should be in a same taxonomy term.
|
170 |
+
* @param array $excluded_terms Array of excluded term IDs.
|
171 |
+
* @param string $taxonomy Taxonomy. Used to identify the term used when `$in_same_term` is true.
|
172 |
+
* @param WP_Post $post WP_Post object.
|
173 |
+
* @return string modified JOIN clause
|
174 |
*/
|
175 |
+
public function posts_join( $sql, $in_same_term, $excluded_terms, $taxonomy = '', $post = null ) {
|
176 |
+
// FIXME empty( $post ) for backward compatibility with WP < 4.4
|
177 |
+
return empty( $post ) || $this->model->is_translated_post_type( $post->post_type ) ? $sql . $this->model->post->join_clause() : $sql;
|
178 |
}
|
179 |
|
180 |
+
/**
|
181 |
+
* Modifies the sql request for wp_get_archives and get_adjacent_post to filter by the current language
|
182 |
*
|
183 |
* @since 0.1
|
184 |
*
|
185 |
+
* @param string $sql The WHERE clause in the SQL.
|
186 |
+
* @param bool $in_same_term Whether post should be in a same taxonomy term.
|
187 |
+
* @param array $excluded_terms Array of excluded term IDs.
|
188 |
+
* @param string $taxonomy Taxonomy. Used to identify the term used when `$in_same_term` is true.
|
189 |
+
* @param WP_Post $post WP_Post object.
|
190 |
+
* @return string modified WHERE clause
|
191 |
*/
|
192 |
+
public function posts_where( $sql, $in_same_term, $excluded_terms, $taxonomy = '', $post = null ) {
|
193 |
+
// backward compatibility with WP < 4.4
|
194 |
+
if ( version_compare( $GLOBALS['wp_version'], '4.4', '<' ) ) {
|
195 |
+
preg_match( "#post_type = '([^']+)'#", $sql, $matches ); // find the queried post type
|
196 |
+
$post_type = $matches[1];
|
197 |
+
} else {
|
198 |
+
$post_type = $post->post_type;
|
199 |
+
}
|
200 |
+
|
201 |
+
return ! empty( $post_type ) && $this->model->is_translated_post_type( $post_type ) ? $sql . $this->model->post->where_clause( $this->curlang ) : $sql;
|
202 |
}
|
203 |
|
204 |
+
/**
|
205 |
+
* Filters the widgets according to the current language
|
206 |
+
* Don't display if a language filter is set and this is not the current one
|
207 |
*
|
208 |
* @since 0.3
|
209 |
*
|
210 |
+
* @param array $instance widget settings
|
211 |
+
* @param object $widget WP_Widget object
|
212 |
* @return bool|array false if we hide the widget, unmodified $instance otherwise
|
213 |
*/
|
214 |
public function widget_display_callback( $instance, $widget ) {
|
215 |
return ! empty( $instance['pll_lang'] ) && $instance['pll_lang'] != $this->curlang->slug ? false : $instance;
|
216 |
}
|
217 |
|
218 |
+
/**
|
219 |
+
* Translates biography
|
220 |
*
|
221 |
* @since 0.9
|
222 |
*
|
223 |
+
* @param null $null
|
224 |
+
* @param int $id User id
|
225 |
* @param string $meta_key
|
226 |
+
* @param bool $single Whether to return only the first value of the specified $meta_key
|
227 |
* @return null|string
|
228 |
*/
|
229 |
public function get_user_metadata( $null, $id, $meta_key, $single ) {
|
230 |
return 'description' === $meta_key && $this->curlang->slug !== $this->options['default_lang'] ? get_user_meta( $id, 'description_'.$this->curlang->slug, $single ) : $null;
|
231 |
}
|
232 |
|
233 |
+
/**
|
234 |
+
* Allows to set a language by default for posts if it has no language yet
|
235 |
*
|
236 |
* @since 1.5.4
|
237 |
*
|
241 |
if ( ! $this->model->post->get_language( $post_id ) ) {
|
242 |
if ( isset( $_REQUEST['lang'] ) ) {
|
243 |
$this->model->post->set_language( $post_id, $_REQUEST['lang'] );
|
244 |
+
} elseif ( ( $parent_id = wp_get_post_parent_id( $post_id ) ) && $parent_lang = $this->model->post->get_language( $parent_id ) ) {
|
|
|
|
|
245 |
$this->model->post->set_language( $post_id, $parent_lang );
|
246 |
+
} else {
|
|
|
|
|
247 |
$this->model->post->set_language( $post_id, $this->curlang );
|
248 |
}
|
249 |
}
|
250 |
}
|
251 |
|
252 |
+
/**
|
253 |
+
* Called when a post ( or page ) is saved, published or updated
|
254 |
+
* Does nothing except on post types which are filterable
|
255 |
+
* Sets the language but does not allow to modify it
|
256 |
*
|
257 |
* @since 1.1
|
258 |
*
|
259 |
+
* @param int $post_id
|
260 |
* @param object $post
|
261 |
+
* @param bool $update Whether it is an update or not
|
262 |
*/
|
263 |
public function save_post( $post_id, $post ) {
|
264 |
if ( $this->model->is_translated_post_type( $post->post_type ) ) {
|
266 |
}
|
267 |
}
|
268 |
|
269 |
+
/**
|
270 |
+
* Called when a category or post tag is created or edited
|
271 |
+
* Does nothing except on taxonomies which are filterable
|
272 |
+
* Sets the language but does not allow to modify it
|
273 |
*
|
274 |
* @since 1.1
|
275 |
*
|
276 |
+
* @param int $term_id
|
277 |
+
* @param int $tt_id Term taxonomy id
|
278 |
* @param string $taxonomy
|
279 |
*/
|
280 |
public function save_term( $term_id, $tt_id, $taxonomy ) {
|
281 |
if ( $this->model->is_translated_taxonomy( $taxonomy ) && ! $this->model->term->get_language( $term_id ) ) {
|
282 |
if ( isset( $_REQUEST['lang'] ) ) {
|
283 |
$this->model->term->set_language( $term_id, $_REQUEST['lang'] );
|
284 |
+
} elseif ( ( $term = get_term( $term_id, $taxonomy ) ) && ! empty( $term->parent ) && $parent_lang = $this->model->term->get_language( $term->parent ) ) {
|
|
|
|
|
285 |
$this->model->term->set_language( $term_id, $parent_lang );
|
286 |
+
} else {
|
|
|
|
|
287 |
$this->model->term->set_language( $term_id, $this->curlang );
|
288 |
}
|
289 |
}
|
frontend/frontend-links.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages links filters and url of translations on frontend
|
5 |
*
|
6 |
* @since 1.2
|
@@ -9,7 +9,7 @@ class PLL_Frontend_Links extends PLL_Links {
|
|
9 |
public $curlang;
|
10 |
public $cache; // our internal non persistent cache object
|
11 |
|
12 |
-
|
13 |
* constructor
|
14 |
*
|
15 |
* @since 1.2
|
@@ -24,7 +24,7 @@ class PLL_Frontend_Links extends PLL_Links {
|
|
24 |
|
25 |
}
|
26 |
|
27 |
-
|
28 |
* returns the url of the translation ( if exists ) of the current page
|
29 |
*
|
30 |
* @since 0.1
|
@@ -43,7 +43,16 @@ class PLL_Frontend_Links extends PLL_Links {
|
|
43 |
// see https://wordpress.org/support/topic/patch-for-fixing-a-notice
|
44 |
$queried_object_id = $wp_query->get_queried_object_id();
|
45 |
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
if ( ! $url = apply_filters( 'pll_pre_translation_url', '', $language, $queried_object_id ) ) {
|
48 |
$qv = $wp_query->query_vars;
|
49 |
$hide = $this->options['default_lang'] == $language->slug && $this->options['hide_default'];
|
@@ -122,12 +131,20 @@ class PLL_Frontend_Links extends PLL_Links {
|
|
122 |
}
|
123 |
}
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
$translation_url = apply_filters( 'pll_translation_url', ( isset( $url ) && ! is_wp_error( $url ) ? $url : null ), $language->slug );
|
126 |
$this->cache->set( 'translation_url:' . $language->slug, $translation_url );
|
127 |
return $translation_url;
|
128 |
}
|
129 |
|
130 |
-
|
131 |
* get the translation of the current archive url
|
132 |
* used also for search
|
133 |
*
|
@@ -140,10 +157,19 @@ class PLL_Frontend_Links extends PLL_Links {
|
|
140 |
$url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
141 |
$url = $this->links_model->switch_language_in_link( $url, $language );
|
142 |
$url = $this->links_model->remove_paged_from_link( $url );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
return apply_filters( 'pll_get_archive_url', $url, $language );
|
144 |
}
|
145 |
|
146 |
-
|
147 |
* returns the home url in the right language
|
148 |
*
|
149 |
* @since 0.1
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages links filters and url of translations on frontend
|
5 |
*
|
6 |
* @since 1.2
|
9 |
public $curlang;
|
10 |
public $cache; // our internal non persistent cache object
|
11 |
|
12 |
+
/**
|
13 |
* constructor
|
14 |
*
|
15 |
* @since 1.2
|
24 |
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
* returns the url of the translation ( if exists ) of the current page
|
29 |
*
|
30 |
* @since 0.1
|
43 |
// see https://wordpress.org/support/topic/patch-for-fixing-a-notice
|
44 |
$queried_object_id = $wp_query->get_queried_object_id();
|
45 |
|
46 |
+
/**
|
47 |
+
* Filter the translation url before Polylang attempts to find one
|
48 |
+
* Internally used by Polylang for the static front page and posts page
|
49 |
+
*
|
50 |
+
* @since 1.8
|
51 |
+
*
|
52 |
+
* @param string $url empty or the url of the translation of teh current page
|
53 |
+
* @param object $language language of the translation
|
54 |
+
* @param int $queried_object_id queried object id
|
55 |
+
*/
|
56 |
if ( ! $url = apply_filters( 'pll_pre_translation_url', '', $language, $queried_object_id ) ) {
|
57 |
$qv = $wp_query->query_vars;
|
58 |
$hide = $this->options['default_lang'] == $language->slug && $this->options['hide_default'];
|
131 |
}
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
+
* Filter the translation url of the current page before Polylang caches it
|
136 |
+
*
|
137 |
+
* @since 1.1.2
|
138 |
+
*
|
139 |
+
* @param null|string $url the translation url, null if none was found
|
140 |
+
* @param string $language the language code of the translation
|
141 |
+
*/
|
142 |
$translation_url = apply_filters( 'pll_translation_url', ( isset( $url ) && ! is_wp_error( $url ) ? $url : null ), $language->slug );
|
143 |
$this->cache->set( 'translation_url:' . $language->slug, $translation_url );
|
144 |
return $translation_url;
|
145 |
}
|
146 |
|
147 |
+
/**
|
148 |
* get the translation of the current archive url
|
149 |
* used also for search
|
150 |
*
|
157 |
$url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
158 |
$url = $this->links_model->switch_language_in_link( $url, $language );
|
159 |
$url = $this->links_model->remove_paged_from_link( $url );
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Filter the archive url
|
163 |
+
*
|
164 |
+
* @since 1.6
|
165 |
+
*
|
166 |
+
* @param string $url url of the archive
|
167 |
+
* @param object $language language of the archive
|
168 |
+
*/
|
169 |
return apply_filters( 'pll_get_archive_url', $url, $language );
|
170 |
}
|
171 |
|
172 |
+
/**
|
173 |
* returns the home url in the right language
|
174 |
*
|
175 |
* @since 0.1
|
frontend/frontend-nav-menu.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
9 |
public $curlang;
|
10 |
|
11 |
-
|
12 |
-
*
|
13 |
*
|
14 |
* @since 1.2
|
15 |
*/
|
@@ -18,23 +18,23 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
18 |
|
19 |
$this->curlang = &$polylang->curlang;
|
20 |
|
21 |
-
//
|
22 |
add_filter( 'wp_get_nav_menu_items', array( &$this, 'wp_get_nav_menu_items' ), 20 ); // after the customizer menus
|
23 |
add_filter( 'wp_nav_menu_objects', array( &$this, 'wp_nav_menu_objects' ) );
|
24 |
add_filter( 'nav_menu_link_attributes', array( &$this, 'nav_menu_link_attributes' ), 10, 3 );
|
25 |
|
26 |
-
//
|
27 |
add_filter( 'theme_mod_nav_menu_locations', array( $this, 'nav_menu_locations' ), 20 );
|
28 |
add_filter( 'wp_nav_menu_args', array( &$this, 'wp_nav_menu_args' ) );
|
29 |
|
30 |
-
//
|
31 |
if ( isset( $_POST['wp_customize'], $_POST['customized'] ) ) {
|
32 |
add_filter( 'wp_nav_menu_args', array( &$this, 'filter_args_before_customizer' ) );
|
33 |
add_filter( 'wp_nav_menu_args', array( &$this, 'filter_args_after_customizer' ), 2000 );
|
34 |
}
|
35 |
}
|
36 |
|
37 |
-
|
38 |
* Sort menu items by menu order
|
39 |
*
|
40 |
* @since 1.7.9
|
@@ -47,8 +47,8 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
47 |
return ( $a->menu_order < $b->menu_order ) ? -1 : 1;
|
48 |
}
|
49 |
|
50 |
-
|
51 |
-
*
|
52 |
* take care to menu_order as it is used later in wp_nav_menu
|
53 |
*
|
54 |
* @since 1.1.1
|
@@ -61,7 +61,7 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
61 |
return $items;
|
62 |
}
|
63 |
|
64 |
-
//
|
65 |
usort( $items, array( $this, 'usort_menu_items' ) );
|
66 |
|
67 |
$new_items = array();
|
@@ -77,17 +77,16 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
77 |
|
78 |
foreach ( $the_languages as $lang ) {
|
79 |
$lang_item = clone $item;
|
80 |
-
$lang_item->ID = $lang_item->ID . '-' . $lang['slug']; //
|
81 |
-
$lang_item->title = $options['show_flags'] && $options['show_names'] ? $lang['flag'].'
|
82 |
$lang_item->url = $lang['url'];
|
83 |
-
$lang_item->lang = $lang['locale']; //
|
84 |
$lang_item->classes = $lang['classes'];
|
85 |
$lang_item->menu_order += $offset + $i++;
|
86 |
$new_items[] = $lang_item;
|
87 |
}
|
88 |
$offset += $i - 1;
|
89 |
-
}
|
90 |
-
else {
|
91 |
$item->menu_order += $offset;
|
92 |
$new_items[] = $item;
|
93 |
}
|
@@ -96,8 +95,8 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
96 |
return $new_items;
|
97 |
}
|
98 |
|
99 |
-
|
100 |
-
*
|
101 |
*
|
102 |
* @since 1.1.1
|
103 |
*
|
@@ -113,8 +112,8 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
113 |
return $ids;
|
114 |
}
|
115 |
|
116 |
-
|
117 |
-
*
|
118 |
*
|
119 |
* @since 1.1.1
|
120 |
*
|
@@ -128,10 +127,9 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
128 |
if ( ! empty( $item->classes ) && is_array( $item->classes ) ) {
|
129 |
if ( in_array( 'current-lang', $item->classes ) ) {
|
130 |
$item->classes = array_diff( $item->classes, array( 'current-menu-item' ) );
|
131 |
-
$r_ids = array_merge( $r_ids, $this->get_ancestors( $item ) ); //
|
132 |
-
}
|
133 |
-
|
134 |
-
$k_ids = array_merge( $k_ids, $this->get_ancestors( $item ) ); // keep the classes for these ancestors
|
135 |
}
|
136 |
}
|
137 |
}
|
@@ -147,8 +145,8 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
147 |
return $items;
|
148 |
}
|
149 |
|
150 |
-
|
151 |
-
*
|
152 |
* available since WP3.6
|
153 |
*
|
154 |
* @since 1.1
|
@@ -163,9 +161,9 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
163 |
return $atts;
|
164 |
}
|
165 |
|
166 |
-
|
167 |
-
*
|
168 |
-
*
|
169 |
*
|
170 |
* @since 1.2
|
171 |
*
|
@@ -174,15 +172,15 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
174 |
*/
|
175 |
public function nav_menu_locations( $menus ) {
|
176 |
if ( is_array( $menus ) && ! empty( $this->curlang ) ) {
|
177 |
-
//
|
178 |
$theme = get_option( 'stylesheet' );
|
179 |
|
180 |
foreach ( $menus as $loc => $menu ) {
|
181 |
$menus[ $loc ] = empty( $this->options['nav_menus'][ $theme ][ $loc ][ $this->curlang->slug ] ) ? 0 : $this->options['nav_menus'][ $theme ][ $loc ][ $this->curlang->slug ];
|
182 |
}
|
183 |
|
184 |
-
//
|
185 |
-
//
|
186 |
if ( isset( $_POST['wp_customize'], $_POST['customized'] ) ) {
|
187 |
$customized = json_decode( wp_unslash( $_POST['customized'] ) );
|
188 |
|
@@ -193,8 +191,7 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
193 |
$infos = $this->explode_location( $loc );
|
194 |
if ( $infos['lang'] == $this->curlang->slug ) {
|
195 |
$menus[ $infos['location'] ] = $c;
|
196 |
-
}
|
197 |
-
elseif ( $this->curlang->slug == $this->options['default_lang'] ) {
|
198 |
$menus[ $loc ] = $c;
|
199 |
}
|
200 |
}
|
@@ -205,8 +202,8 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
205 |
return $menus;
|
206 |
}
|
207 |
|
208 |
-
|
209 |
-
*
|
210 |
*
|
211 |
* @since 1.7.10
|
212 |
*
|
@@ -223,8 +220,8 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
223 |
// Get the nav menu based on the requested menu
|
224 |
$menu = wp_get_nav_menu_object( $args['menu'] );
|
225 |
|
226 |
-
//
|
227 |
-
//
|
228 |
if ( $menu ) {
|
229 |
foreach ( $this->options['nav_menus'][ $theme ] as $menus ) {
|
230 |
if ( in_array( $menu->term_id, $menus ) && ! empty( $menus[ $this->curlang->slug ] ) ) {
|
@@ -234,7 +231,7 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
234 |
}
|
235 |
}
|
236 |
|
237 |
-
//
|
238 |
if ( ! $menu && ! $args['theme_location'] ) {
|
239 |
$menus = wp_get_nav_menus();
|
240 |
foreach ( $menus as $menu_maybe ) {
|
@@ -252,8 +249,8 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
252 |
return $args;
|
253 |
}
|
254 |
|
255 |
-
|
256 |
-
*
|
257 |
*
|
258 |
* @since 1.8
|
259 |
*
|
@@ -267,8 +264,8 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
267 |
return $args;
|
268 |
}
|
269 |
|
270 |
-
|
271 |
-
*
|
272 |
*
|
273 |
* @since 1.8
|
274 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Manages custom menus translations as well as the language switcher menu item on frontend
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
9 |
public $curlang;
|
10 |
|
11 |
+
/**
|
12 |
+
* Constructor
|
13 |
*
|
14 |
* @since 1.2
|
15 |
*/
|
18 |
|
19 |
$this->curlang = &$polylang->curlang;
|
20 |
|
21 |
+
// Split the language switcher menu item in several language menu items
|
22 |
add_filter( 'wp_get_nav_menu_items', array( &$this, 'wp_get_nav_menu_items' ), 20 ); // after the customizer menus
|
23 |
add_filter( 'wp_nav_menu_objects', array( &$this, 'wp_nav_menu_objects' ) );
|
24 |
add_filter( 'nav_menu_link_attributes', array( &$this, 'nav_menu_link_attributes' ), 10, 3 );
|
25 |
|
26 |
+
// Filters menus by language
|
27 |
add_filter( 'theme_mod_nav_menu_locations', array( $this, 'nav_menu_locations' ), 20 );
|
28 |
add_filter( 'wp_nav_menu_args', array( &$this, 'wp_nav_menu_args' ) );
|
29 |
|
30 |
+
// The customizer
|
31 |
if ( isset( $_POST['wp_customize'], $_POST['customized'] ) ) {
|
32 |
add_filter( 'wp_nav_menu_args', array( &$this, 'filter_args_before_customizer' ) );
|
33 |
add_filter( 'wp_nav_menu_args', array( &$this, 'filter_args_after_customizer' ), 2000 );
|
34 |
}
|
35 |
}
|
36 |
|
37 |
+
/**
|
38 |
* Sort menu items by menu order
|
39 |
*
|
40 |
* @since 1.7.9
|
47 |
return ( $a->menu_order < $b->menu_order ) ? -1 : 1;
|
48 |
}
|
49 |
|
50 |
+
/**
|
51 |
+
* Splits the one item of backend in several items on frontend
|
52 |
* take care to menu_order as it is used later in wp_nav_menu
|
53 |
*
|
54 |
* @since 1.1.1
|
61 |
return $items;
|
62 |
}
|
63 |
|
64 |
+
// The customizer menus does not sort the items and we need them to be sorted before splitting the language switcher
|
65 |
usort( $items, array( $this, 'usort_menu_items' ) );
|
66 |
|
67 |
$new_items = array();
|
77 |
|
78 |
foreach ( $the_languages as $lang ) {
|
79 |
$lang_item = clone $item;
|
80 |
+
$lang_item->ID = $lang_item->ID . '-' . $lang['slug']; // A unique ID
|
81 |
+
$lang_item->title = $options['show_flags'] && $options['show_names'] ? $lang['flag'] . '<span style="margin-left:0.3em;">' . esc_html( $lang['name'] ) . '</span>' : ( $options['show_flags'] ? $lang['flag'] : esc_html( $lang['name'] ) );
|
82 |
$lang_item->url = $lang['url'];
|
83 |
+
$lang_item->lang = $lang['locale']; // Save this for use in nav_menu_link_attributes
|
84 |
$lang_item->classes = $lang['classes'];
|
85 |
$lang_item->menu_order += $offset + $i++;
|
86 |
$new_items[] = $lang_item;
|
87 |
}
|
88 |
$offset += $i - 1;
|
89 |
+
} else {
|
|
|
90 |
$item->menu_order += $offset;
|
91 |
$new_items[] = $item;
|
92 |
}
|
95 |
return $new_items;
|
96 |
}
|
97 |
|
98 |
+
/**
|
99 |
+
* Returns the ancestors of a menu item
|
100 |
*
|
101 |
* @since 1.1.1
|
102 |
*
|
112 |
return $ids;
|
113 |
}
|
114 |
|
115 |
+
/**
|
116 |
+
* Removes current-menu and current-menu-ancestor classes to lang switcher when not on the home page
|
117 |
*
|
118 |
* @since 1.1.1
|
119 |
*
|
127 |
if ( ! empty( $item->classes ) && is_array( $item->classes ) ) {
|
128 |
if ( in_array( 'current-lang', $item->classes ) ) {
|
129 |
$item->classes = array_diff( $item->classes, array( 'current-menu-item' ) );
|
130 |
+
$r_ids = array_merge( $r_ids, $this->get_ancestors( $item ) ); // Remove the classes for these ancestors
|
131 |
+
} elseif ( in_array( 'current-menu-item', $item->classes ) ) {
|
132 |
+
$k_ids = array_merge( $k_ids, $this->get_ancestors( $item ) ); // Keep the classes for these ancestors
|
|
|
133 |
}
|
134 |
}
|
135 |
}
|
145 |
return $items;
|
146 |
}
|
147 |
|
148 |
+
/**
|
149 |
+
* Adds hreflang attribute for the language switcher menu items
|
150 |
* available since WP3.6
|
151 |
*
|
152 |
* @since 1.1
|
161 |
return $atts;
|
162 |
}
|
163 |
|
164 |
+
/**
|
165 |
+
* Fills the theme nav menus locations with the right menu in the right language
|
166 |
+
* Needs to wait for the language to be defined
|
167 |
*
|
168 |
* @since 1.2
|
169 |
*
|
172 |
*/
|
173 |
public function nav_menu_locations( $menus ) {
|
174 |
if ( is_array( $menus ) && ! empty( $this->curlang ) ) {
|
175 |
+
// First get multilingual menu locations from DB
|
176 |
$theme = get_option( 'stylesheet' );
|
177 |
|
178 |
foreach ( $menus as $loc => $menu ) {
|
179 |
$menus[ $loc ] = empty( $this->options['nav_menus'][ $theme ][ $loc ][ $this->curlang->slug ] ) ? 0 : $this->options['nav_menus'][ $theme ][ $loc ][ $this->curlang->slug ];
|
180 |
}
|
181 |
|
182 |
+
// Support for theme customizer
|
183 |
+
// Let's look for multilingual menu locations directly in $_POST as there are not in customizer object
|
184 |
if ( isset( $_POST['wp_customize'], $_POST['customized'] ) ) {
|
185 |
$customized = json_decode( wp_unslash( $_POST['customized'] ) );
|
186 |
|
191 |
$infos = $this->explode_location( $loc );
|
192 |
if ( $infos['lang'] == $this->curlang->slug ) {
|
193 |
$menus[ $infos['location'] ] = $c;
|
194 |
+
} elseif ( $this->curlang->slug == $this->options['default_lang'] ) {
|
|
|
195 |
$menus[ $loc ] = $c;
|
196 |
}
|
197 |
}
|
202 |
return $menus;
|
203 |
}
|
204 |
|
205 |
+
/**
|
206 |
+
* Attempt to translate the nav menu when it is hardcoded or when no location is defined in wp_nav_menu
|
207 |
*
|
208 |
* @since 1.7.10
|
209 |
*
|
220 |
// Get the nav menu based on the requested menu
|
221 |
$menu = wp_get_nav_menu_object( $args['menu'] );
|
222 |
|
223 |
+
// Attempt to find a translation of this menu
|
224 |
+
// This obviously does not work if the nav menu has no associated theme location
|
225 |
if ( $menu ) {
|
226 |
foreach ( $this->options['nav_menus'][ $theme ] as $menus ) {
|
227 |
if ( in_array( $menu->term_id, $menus ) && ! empty( $menus[ $this->curlang->slug ] ) ) {
|
231 |
}
|
232 |
}
|
233 |
|
234 |
+
// Get the first menu that has items and and is in the current language if we still can't find a menu
|
235 |
if ( ! $menu && ! $args['theme_location'] ) {
|
236 |
$menus = wp_get_nav_menus();
|
237 |
foreach ( $menus as $menu_maybe ) {
|
249 |
return $args;
|
250 |
}
|
251 |
|
252 |
+
/**
|
253 |
+
* Filters the nav menu location before the customizer so that it matches the temporary location in the customizer
|
254 |
*
|
255 |
* @since 1.8
|
256 |
*
|
264 |
return $args;
|
265 |
}
|
266 |
|
267 |
+
/**
|
268 |
+
* Filters the nav menu location after the customizer to get back the true nav menu location for the theme
|
269 |
*
|
270 |
* @since 1.8
|
271 |
*
|
frontend/frontend-static-pages.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages the static front page and the page for posts on frontend
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
9 |
|
10 |
-
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.8
|
@@ -37,7 +37,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
37 |
add_filter( 'pll_set_language_from_query', array( &$this, 'page_for_posts_query' ), 10, 2 );
|
38 |
}
|
39 |
|
40 |
-
|
41 |
* init the filters
|
42 |
*
|
43 |
* @since 1.8
|
@@ -57,7 +57,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
57 |
}
|
58 |
}
|
59 |
|
60 |
-
|
61 |
* translates the page_id query var when the site root page is requested
|
62 |
*
|
63 |
* @since 1.8
|
@@ -66,7 +66,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
66 |
set_query_var( 'page_id', $this->curlang->page_on_front );
|
67 |
}
|
68 |
|
69 |
-
|
70 |
* translates page on front
|
71 |
*
|
72 |
* @since 1.8
|
@@ -79,7 +79,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
79 |
return isset( $this->curlang->page_on_front ) ? $this->curlang->page_on_front : $v;
|
80 |
}
|
81 |
|
82 |
-
|
83 |
* translates page for posts
|
84 |
*
|
85 |
* @since 1.8
|
@@ -92,7 +92,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
92 |
return isset( $this->curlang->page_for_posts ) ? $this->curlang->page_for_posts : $v;
|
93 |
}
|
94 |
|
95 |
-
|
96 |
* modifies the page link in case the front page is not in the default language
|
97 |
*
|
98 |
* @since 0.7.2
|
@@ -108,7 +108,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
108 |
return $link;
|
109 |
}
|
110 |
|
111 |
-
|
112 |
* manages canonical redirection of the homepage when using page on front
|
113 |
*
|
114 |
* @since 0.1
|
@@ -136,7 +136,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
136 |
return $redirect_url;
|
137 |
}
|
138 |
|
139 |
-
|
140 |
* translates the url of the page on front and page for posts
|
141 |
*
|
142 |
* @since 1.8
|
@@ -162,7 +162,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
162 |
return $url;
|
163 |
}
|
164 |
|
165 |
-
|
166 |
* prevents canonical redirection if we are on a static front page
|
167 |
*
|
168 |
* @since 1.8
|
@@ -174,7 +174,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
174 |
return $this->options['redirect_lang'] && isset( $this->curlang->page_on_front ) && is_page( $this->curlang->page_on_front ) ? false : $redirect_url;
|
175 |
}
|
176 |
|
177 |
-
|
178 |
* setups query vars when requesting a static front page
|
179 |
*
|
180 |
* @since 1.8
|
@@ -222,7 +222,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
222 |
return $lang;
|
223 |
}
|
224 |
|
225 |
-
|
226 |
* setups query vars when requesting a posts page
|
227 |
*
|
228 |
* @since 1.8
|
@@ -248,7 +248,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
|
248 |
return $lang;
|
249 |
}
|
250 |
|
251 |
-
|
252 |
* get queried page_id ( if exists )
|
253 |
* If permalinks are used, WordPress does set and use $query->queried_object_id and sets $query->query_vars['page_id'] to 0
|
254 |
* and does set and use $query->query_vars['page_id'] if permalinks are not used :(
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages the static front page and the page for posts on frontend
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
|
9 |
|
10 |
+
/**
|
11 |
* constructor: setups filters and actions
|
12 |
*
|
13 |
* @since 1.8
|
37 |
add_filter( 'pll_set_language_from_query', array( &$this, 'page_for_posts_query' ), 10, 2 );
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
* init the filters
|
42 |
*
|
43 |
* @since 1.8
|
57 |
}
|
58 |
}
|
59 |
|
60 |
+
/**
|
61 |
* translates the page_id query var when the site root page is requested
|
62 |
*
|
63 |
* @since 1.8
|
66 |
set_query_var( 'page_id', $this->curlang->page_on_front );
|
67 |
}
|
68 |
|
69 |
+
/**
|
70 |
* translates page on front
|
71 |
*
|
72 |
* @since 1.8
|
79 |
return isset( $this->curlang->page_on_front ) ? $this->curlang->page_on_front : $v;
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
* translates page for posts
|
84 |
*
|
85 |
* @since 1.8
|
92 |
return isset( $this->curlang->page_for_posts ) ? $this->curlang->page_for_posts : $v;
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
* modifies the page link in case the front page is not in the default language
|
97 |
*
|
98 |
* @since 0.7.2
|
108 |
return $link;
|
109 |
}
|
110 |
|
111 |
+
/**
|
112 |
* manages canonical redirection of the homepage when using page on front
|
113 |
*
|
114 |
* @since 0.1
|
136 |
return $redirect_url;
|
137 |
}
|
138 |
|
139 |
+
/**
|
140 |
* translates the url of the page on front and page for posts
|
141 |
*
|
142 |
* @since 1.8
|
162 |
return $url;
|
163 |
}
|
164 |
|
165 |
+
/**
|
166 |
* prevents canonical redirection if we are on a static front page
|
167 |
*
|
168 |
* @since 1.8
|
174 |
return $this->options['redirect_lang'] && isset( $this->curlang->page_on_front ) && is_page( $this->curlang->page_on_front ) ? false : $redirect_url;
|
175 |
}
|
176 |
|
177 |
+
/**
|
178 |
* setups query vars when requesting a static front page
|
179 |
*
|
180 |
* @since 1.8
|
222 |
return $lang;
|
223 |
}
|
224 |
|
225 |
+
/**
|
226 |
* setups query vars when requesting a posts page
|
227 |
*
|
228 |
* @since 1.8
|
248 |
return $lang;
|
249 |
}
|
250 |
|
251 |
+
/**
|
252 |
* get queried page_id ( if exists )
|
253 |
* If permalinks are used, WordPress does set and use $query->queried_object_id and sets $query->query_vars['page_id'] to 0
|
254 |
* and does set and use $query->query_vars['page_id'] if permalinks are not used :(
|
frontend/frontend.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* frontend controller
|
5 |
* accessible as $polylang global object
|
6 |
*
|
@@ -24,7 +24,7 @@ class PLL_Frontend extends PLL_Base {
|
|
24 |
public $curlang;
|
25 |
public $links, $choose_lang, $filters, $filters_search, $nav_menu, $auto_translate;
|
26 |
|
27 |
-
|
28 |
* constructor
|
29 |
*
|
30 |
* @since 1.2
|
@@ -48,7 +48,7 @@ class PLL_Frontend extends PLL_Base {
|
|
48 |
}
|
49 |
}
|
50 |
|
51 |
-
|
52 |
* setups the language chooser based on options
|
53 |
*
|
54 |
* @since 1.2
|
@@ -67,7 +67,7 @@ class PLL_Frontend extends PLL_Base {
|
|
67 |
$this->nav_menu = new PLL_Frontend_Nav_Menu( $this );
|
68 |
}
|
69 |
|
70 |
-
|
71 |
* setups filters and nav menus once the language has been defined
|
72 |
*
|
73 |
* @since 1.2
|
@@ -80,7 +80,7 @@ class PLL_Frontend extends PLL_Base {
|
|
80 |
}
|
81 |
|
82 |
|
83 |
-
|
84 |
* when querying multiple taxonomies, makes sure that the language is not the queried object
|
85 |
*
|
86 |
* @since 1.8
|
@@ -95,7 +95,7 @@ class PLL_Frontend extends PLL_Base {
|
|
95 |
}
|
96 |
}
|
97 |
|
98 |
-
|
99 |
* modifies some query vars to "hide" that the language is a taxonomy and avoid conflicts
|
100 |
*
|
101 |
* @since 1.2
|
@@ -153,7 +153,7 @@ class PLL_Frontend extends PLL_Base {
|
|
153 |
}
|
154 |
}
|
155 |
|
156 |
-
|
157 |
* auto translate posts and terms ids
|
158 |
*
|
159 |
* @since 1.2
|
@@ -162,7 +162,7 @@ class PLL_Frontend extends PLL_Base {
|
|
162 |
$this->auto_translate = new PLL_Frontend_Auto_Translate( $this );
|
163 |
}
|
164 |
|
165 |
-
|
166 |
* resets some variables when switching blog
|
167 |
* overrides parent method
|
168 |
*
|
@@ -183,7 +183,7 @@ class PLL_Frontend extends PLL_Base {
|
|
183 |
}
|
184 |
}
|
185 |
|
186 |
-
|
187 |
* check if translated taxonomy is queried
|
188 |
* compatible with nested queries introduced in WP 4.1
|
189 |
* @see https://wordpress.org/support/topic/tax_query-bug
|
@@ -208,7 +208,7 @@ class PLL_Frontend extends PLL_Base {
|
|
208 |
return false;
|
209 |
}
|
210 |
|
211 |
-
|
212 |
* get queried taxonomies
|
213 |
*
|
214 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* frontend controller
|
5 |
* accessible as $polylang global object
|
6 |
*
|
24 |
public $curlang;
|
25 |
public $links, $choose_lang, $filters, $filters_search, $nav_menu, $auto_translate;
|
26 |
|
27 |
+
/**
|
28 |
* constructor
|
29 |
*
|
30 |
* @since 1.2
|
48 |
}
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
* setups the language chooser based on options
|
53 |
*
|
54 |
* @since 1.2
|
67 |
$this->nav_menu = new PLL_Frontend_Nav_Menu( $this );
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
* setups filters and nav menus once the language has been defined
|
72 |
*
|
73 |
* @since 1.2
|
80 |
}
|
81 |
|
82 |
|
83 |
+
/**
|
84 |
* when querying multiple taxonomies, makes sure that the language is not the queried object
|
85 |
*
|
86 |
* @since 1.8
|
95 |
}
|
96 |
}
|
97 |
|
98 |
+
/**
|
99 |
* modifies some query vars to "hide" that the language is a taxonomy and avoid conflicts
|
100 |
*
|
101 |
* @since 1.2
|
153 |
}
|
154 |
}
|
155 |
|
156 |
+
/**
|
157 |
* auto translate posts and terms ids
|
158 |
*
|
159 |
* @since 1.2
|
162 |
$this->auto_translate = new PLL_Frontend_Auto_Translate( $this );
|
163 |
}
|
164 |
|
165 |
+
/**
|
166 |
* resets some variables when switching blog
|
167 |
* overrides parent method
|
168 |
*
|
183 |
}
|
184 |
}
|
185 |
|
186 |
+
/**
|
187 |
* check if translated taxonomy is queried
|
188 |
* compatible with nested queries introduced in WP 4.1
|
189 |
* @see https://wordpress.org/support/topic/tax_query-bug
|
208 |
return false;
|
209 |
}
|
210 |
|
211 |
+
/**
|
212 |
* get queried taxonomies
|
213 |
*
|
214 |
* @since 1.8
|
include/api.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
-
*
|
7 |
*
|
8 |
* dropdown => displays a dropdown if set to 1, defaults to 0
|
9 |
* echo => echoes the the switcher if set to 1 ( default )
|
@@ -31,20 +31,21 @@ function pll_the_languages( $args = '' ) {
|
|
31 |
return $switcher->the_languages( PLL()->links, $args );
|
32 |
}
|
33 |
|
34 |
-
|
35 |
-
*
|
|
|
36 |
*
|
37 |
* @since 0.8.1
|
38 |
*
|
39 |
* @param string $field optional the language field to return 'name', 'locale', defaults to 'slug'
|
40 |
-
* @return string the requested field for the current language
|
41 |
*/
|
42 |
function pll_current_language( $field = 'slug' ) {
|
43 |
return isset( PLL()->curlang->$field ) ? PLL()->curlang->$field : false;
|
44 |
}
|
45 |
|
46 |
-
|
47 |
-
*
|
48 |
*
|
49 |
* @since 1.0
|
50 |
*
|
@@ -55,34 +56,34 @@ function pll_default_language( $field = 'slug' ) {
|
|
55 |
return isset( PLL()->options['default_lang'] ) && ( $lang = PLL()->model->get_language( PLL()->options['default_lang'] ) ) && isset( $lang->$field ) ? $lang->$field : false;
|
56 |
}
|
57 |
|
58 |
-
|
59 |
-
*
|
60 |
*
|
61 |
* @since 0.5
|
62 |
*
|
63 |
-
* @param int
|
64 |
-
* @param string $slug
|
65 |
-
* @return int post id of the translation if exists
|
66 |
*/
|
67 |
function pll_get_post( $post_id, $slug = '' ) {
|
68 |
return ( $slug = $slug ? $slug : pll_current_language() ) ? PLL()->model->post->get( $post_id, $slug ) : null;
|
69 |
}
|
70 |
|
71 |
-
|
72 |
-
*
|
73 |
*
|
74 |
* @since 0.5
|
75 |
*
|
76 |
-
* @param int
|
77 |
-
* @param string $slug
|
78 |
-
* @return int term id of the translation if exists
|
79 |
*/
|
80 |
function pll_get_term( $term_id, $slug = '' ) {
|
81 |
return ( $slug = $slug ? $slug : pll_current_language() ) ? PLL()->model->term->get( $term_id, $slug ) : null;
|
82 |
}
|
83 |
|
84 |
-
|
85 |
-
*
|
86 |
*
|
87 |
* @since 0.8
|
88 |
*
|
@@ -97,15 +98,15 @@ function pll_home_url( $lang = '' ) {
|
|
97 |
return empty( $lang ) ? home_url( '/' ) : PLL()->links->get_home_url( $lang );
|
98 |
}
|
99 |
|
100 |
-
|
101 |
-
*
|
102 |
*
|
103 |
* @since 0.6
|
104 |
*
|
105 |
-
* @param string $name
|
106 |
-
* @param string $string
|
107 |
-
* @param string $context
|
108 |
-
* @param bool
|
109 |
*/
|
110 |
function pll_register_string( $name, $string, $context = 'polylang', $multiline = false ) {
|
111 |
if ( PLL_ADMIN ) {
|
@@ -113,8 +114,8 @@ function pll_register_string( $name, $string, $context = 'polylang', $multiline
|
|
113 |
}
|
114 |
}
|
115 |
|
116 |
-
|
117 |
-
*
|
118 |
*
|
119 |
* @since 0.6
|
120 |
*
|
@@ -122,9 +123,9 @@ function pll_register_string( $name, $string, $context = 'polylang', $multiline
|
|
122 |
* @return string the string translation in the current language
|
123 |
*/
|
124 |
function pll__( $string ) {
|
125 |
-
static $cache; //
|
126 |
|
127 |
-
if ( ! did_action( 'pll_language_defined' ) ) { //
|
128 |
return $string;
|
129 |
}
|
130 |
|
@@ -140,8 +141,8 @@ function pll__( $string ) {
|
|
140 |
return $str;
|
141 |
}
|
142 |
|
143 |
-
|
144 |
-
*
|
145 |
*
|
146 |
* @since 0.6
|
147 |
*
|
@@ -151,13 +152,13 @@ function pll_e( $string ) {
|
|
151 |
echo pll__( $string );
|
152 |
}
|
153 |
|
154 |
-
|
155 |
-
*
|
156 |
*
|
157 |
* @since 1.5.4
|
158 |
*
|
159 |
* @param string $string the string to translate
|
160 |
-
* @param string $lang
|
161 |
* @return string the string translation in the requested language
|
162 |
*/
|
163 |
function pll_translate_string( $string, $lang ) {
|
@@ -165,7 +166,7 @@ function pll_translate_string( $string, $lang ) {
|
|
165 |
return pll__( $string );
|
166 |
}
|
167 |
|
168 |
-
static $cache; //
|
169 |
|
170 |
if ( empty( $cache ) ) {
|
171 |
$cache = new PLL_Cache();
|
@@ -180,8 +181,8 @@ function pll_translate_string( $string, $lang ) {
|
|
180 |
return $mo->translate( $string );
|
181 |
}
|
182 |
|
183 |
-
|
184 |
-
*
|
185 |
*
|
186 |
* @since 1.0.1
|
187 |
*
|
@@ -192,8 +193,8 @@ function pll_is_translated_post_type( $post_type ) {
|
|
192 |
return PLL()->model->is_translated_post_type( $post_type );
|
193 |
}
|
194 |
|
195 |
-
|
196 |
-
*
|
197 |
*
|
198 |
* @since 1.0.1
|
199 |
*
|
@@ -204,10 +205,10 @@ function pll_is_translated_taxonomy( $tax ) {
|
|
204 |
return PLL()->model->is_translated_taxonomy( $tax );
|
205 |
}
|
206 |
|
207 |
-
|
208 |
-
*
|
209 |
*
|
210 |
-
*
|
211 |
*
|
212 |
* hide_empty => hides languages with no posts if set to true ( defaults to false )
|
213 |
* fields => return only that field if set ( see PLL_Language for a list of fields )
|
@@ -222,32 +223,32 @@ function pll_languages_list( $args = array() ) {
|
|
222 |
return PLL()->model->get_languages_list( $args );
|
223 |
}
|
224 |
|
225 |
-
|
226 |
-
*
|
227 |
*
|
228 |
* @since 1.5
|
229 |
*
|
230 |
-
* @param int
|
231 |
* @param string $lang language code
|
232 |
*/
|
233 |
function pll_set_post_language( $id, $lang ) {
|
234 |
PLL()->model->post->set_language( $id, $lang );
|
235 |
}
|
236 |
|
237 |
-
|
238 |
-
*
|
239 |
*
|
240 |
* @since 1.5
|
241 |
*
|
242 |
-
* @param int
|
243 |
* @param string $lang language code
|
244 |
*/
|
245 |
function pll_set_term_language( $id, $lang ) {
|
246 |
PLL()->model->term->set_language( $id, $lang );
|
247 |
}
|
248 |
|
249 |
-
|
250 |
-
*
|
251 |
*
|
252 |
* @since 1.5
|
253 |
*
|
@@ -257,8 +258,8 @@ function pll_save_post_translations( $arr ) {
|
|
257 |
PLL()->model->post->save_translations( reset( $arr ), $arr );
|
258 |
}
|
259 |
|
260 |
-
|
261 |
-
*
|
262 |
*
|
263 |
* @since 1.5
|
264 |
*
|
@@ -268,34 +269,34 @@ function pll_save_term_translations( $arr ) {
|
|
268 |
PLL()->model->term->save_translations( reset( $arr ), $arr );
|
269 |
}
|
270 |
|
271 |
-
|
272 |
-
*
|
273 |
*
|
274 |
* @since 1.5.4
|
275 |
*
|
276 |
-
* @param int
|
277 |
-
* @param string $field
|
278 |
* @return bool|string the requested field for the post language, false if no language is associated to that post
|
279 |
*/
|
280 |
function pll_get_post_language( $post_id, $field = 'slug' ) {
|
281 |
return ( $lang = PLL()->model->post->get_language( $post_id ) ) ? $lang->$field : false;
|
282 |
}
|
283 |
|
284 |
-
|
285 |
-
*
|
286 |
*
|
287 |
* @since 1.5.4
|
288 |
*
|
289 |
-
* @param int
|
290 |
-
* @param string $field
|
291 |
* @return bool|string the requested field for the term language, false if no language is associated to that term
|
292 |
*/
|
293 |
function pll_get_term_language( $term_id, $field = 'slug' ) {
|
294 |
return ( $lang = PLL()->model->term->get_language( $term_id ) ) ? $lang->$field : false;
|
295 |
}
|
296 |
|
297 |
-
|
298 |
-
*
|
299 |
*
|
300 |
* @since 1.8
|
301 |
*
|
@@ -306,8 +307,8 @@ function pll_get_post_translations( $post_id ) {
|
|
306 |
return PLL()->model->post->get_translations( $post_id );
|
307 |
}
|
308 |
|
309 |
-
|
310 |
-
*
|
311 |
*
|
312 |
* @since 1.8
|
313 |
*
|
@@ -318,23 +319,23 @@ function pll_get_term_translations( $term_id ) {
|
|
318 |
return PLL()->model->term->get_translations( $term_id );
|
319 |
}
|
320 |
|
321 |
-
|
322 |
-
*
|
323 |
*
|
324 |
* @since 1.5
|
325 |
*
|
326 |
* @param string $lang language code
|
327 |
-
* @param array
|
328 |
* @return int posts count
|
329 |
*/
|
330 |
function pll_count_posts( $lang, $args = array() ) {
|
331 |
return PLL()->model->count_posts( PLL()->model->get_language( $lang ), $args );
|
332 |
}
|
333 |
|
334 |
-
|
335 |
-
*
|
336 |
-
*
|
337 |
-
*
|
338 |
*
|
339 |
* @since 1.8
|
340 |
*/
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Template tag: displays the language switcher
|
5 |
*
|
6 |
+
* List of parameters accepted in $args:
|
7 |
*
|
8 |
* dropdown => displays a dropdown if set to 1, defaults to 0
|
9 |
* echo => echoes the the switcher if set to 1 ( default )
|
31 |
return $switcher->the_languages( PLL()->links, $args );
|
32 |
}
|
33 |
|
34 |
+
/**
|
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 'name', 'locale', defaults to 'slug'
|
41 |
+
* @return string|bool the requested field for the current language
|
42 |
*/
|
43 |
function pll_current_language( $field = 'slug' ) {
|
44 |
return isset( PLL()->curlang->$field ) ? PLL()->curlang->$field : false;
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
+
* Returns the default language
|
49 |
*
|
50 |
* @since 1.0
|
51 |
*
|
56 |
return isset( PLL()->options['default_lang'] ) && ( $lang = PLL()->model->get_language( PLL()->options['default_lang'] ) ) && isset( $lang->$field ) ? $lang->$field : false;
|
57 |
}
|
58 |
|
59 |
+
/**
|
60 |
+
* Among the post and its translations, returns the id of the post which is in the language represented by $slug
|
61 |
*
|
62 |
* @since 0.5
|
63 |
*
|
64 |
+
* @param int $post_id post id
|
65 |
+
* @param string $slug optional language code, defaults to current language
|
66 |
+
* @return int|null post id of the translation if exists, null otherwise
|
67 |
*/
|
68 |
function pll_get_post( $post_id, $slug = '' ) {
|
69 |
return ( $slug = $slug ? $slug : pll_current_language() ) ? PLL()->model->post->get( $post_id, $slug ) : null;
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
+
* Among the term and its translations, returns the id of the term which is in the language represented by $slug
|
74 |
*
|
75 |
* @since 0.5
|
76 |
*
|
77 |
+
* @param int $term_id term id
|
78 |
+
* @param string $slug optional language code, defaults to current language
|
79 |
+
* @return int|null term id of the translation if exists, null otherwise
|
80 |
*/
|
81 |
function pll_get_term( $term_id, $slug = '' ) {
|
82 |
return ( $slug = $slug ? $slug : pll_current_language() ) ? PLL()->model->term->get( $term_id, $slug ) : null;
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
+
* Returns the home url in the current language
|
87 |
*
|
88 |
* @since 0.8
|
89 |
*
|
98 |
return empty( $lang ) ? home_url( '/' ) : PLL()->links->get_home_url( $lang );
|
99 |
}
|
100 |
|
101 |
+
/**
|
102 |
+
* Registers a string for translation in the "strings translation" panel
|
103 |
*
|
104 |
* @since 0.6
|
105 |
*
|
106 |
+
* @param string $name a unique name for the string
|
107 |
+
* @param string $string the string to register
|
108 |
+
* @param string $context optional the group in which the string is registered, defaults to 'polylang'
|
109 |
+
* @param bool $multiline optional wether the string table should display a multiline textarea or a single line input, defaults to single line
|
110 |
*/
|
111 |
function pll_register_string( $name, $string, $context = 'polylang', $multiline = false ) {
|
112 |
if ( PLL_ADMIN ) {
|
114 |
}
|
115 |
}
|
116 |
|
117 |
+
/**
|
118 |
+
* Translates a string ( previously registered with pll_register_string )
|
119 |
*
|
120 |
* @since 0.6
|
121 |
*
|
123 |
* @return string the string translation in the current language
|
124 |
*/
|
125 |
function pll__( $string ) {
|
126 |
+
static $cache; // Cache object to avoid translating the same string several times
|
127 |
|
128 |
+
if ( ! did_action( 'pll_language_defined' ) ) { // No need for translation
|
129 |
return $string;
|
130 |
}
|
131 |
|
141 |
return $str;
|
142 |
}
|
143 |
|
144 |
+
/**
|
145 |
+
* Echoes a translated string ( previously registered with pll_register_string )
|
146 |
*
|
147 |
* @since 0.6
|
148 |
*
|
152 |
echo pll__( $string );
|
153 |
}
|
154 |
|
155 |
+
/**
|
156 |
+
* Translates a string ( previously registered with pll_register_string )
|
157 |
*
|
158 |
* @since 1.5.4
|
159 |
*
|
160 |
* @param string $string the string to translate
|
161 |
+
* @param string $lang language code
|
162 |
* @return string the string translation in the requested language
|
163 |
*/
|
164 |
function pll_translate_string( $string, $lang ) {
|
166 |
return pll__( $string );
|
167 |
}
|
168 |
|
169 |
+
static $cache; // Cache object to avoid loading the same translations object several times
|
170 |
|
171 |
if ( empty( $cache ) ) {
|
172 |
$cache = new PLL_Cache();
|
181 |
return $mo->translate( $string );
|
182 |
}
|
183 |
|
184 |
+
/**
|
185 |
+
* Returns true if Polylang manages languages and translations for this post type
|
186 |
*
|
187 |
* @since 1.0.1
|
188 |
*
|
193 |
return PLL()->model->is_translated_post_type( $post_type );
|
194 |
}
|
195 |
|
196 |
+
/**
|
197 |
+
* Returns true if Polylang manages languages and translations for this taxonomy
|
198 |
*
|
199 |
* @since 1.0.1
|
200 |
*
|
205 |
return PLL()->model->is_translated_taxonomy( $tax );
|
206 |
}
|
207 |
|
208 |
+
/**
|
209 |
+
* Returns the list of available languages
|
210 |
*
|
211 |
+
* List of parameters accepted in $args:
|
212 |
*
|
213 |
* hide_empty => hides languages with no posts if set to true ( defaults to false )
|
214 |
* fields => return only that field if set ( see PLL_Language for a list of fields )
|
223 |
return PLL()->model->get_languages_list( $args );
|
224 |
}
|
225 |
|
226 |
+
/**
|
227 |
+
* Set the post language
|
228 |
*
|
229 |
* @since 1.5
|
230 |
*
|
231 |
+
* @param int $id post id
|
232 |
* @param string $lang language code
|
233 |
*/
|
234 |
function pll_set_post_language( $id, $lang ) {
|
235 |
PLL()->model->post->set_language( $id, $lang );
|
236 |
}
|
237 |
|
238 |
+
/**
|
239 |
+
* Set the term language
|
240 |
*
|
241 |
* @since 1.5
|
242 |
*
|
243 |
+
* @param int $id term id
|
244 |
* @param string $lang language code
|
245 |
*/
|
246 |
function pll_set_term_language( $id, $lang ) {
|
247 |
PLL()->model->term->set_language( $id, $lang );
|
248 |
}
|
249 |
|
250 |
+
/**
|
251 |
+
* Save posts translations
|
252 |
*
|
253 |
* @since 1.5
|
254 |
*
|
258 |
PLL()->model->post->save_translations( reset( $arr ), $arr );
|
259 |
}
|
260 |
|
261 |
+
/**
|
262 |
+
* Save terms translations
|
263 |
*
|
264 |
* @since 1.5
|
265 |
*
|
269 |
PLL()->model->term->save_translations( reset( $arr ), $arr );
|
270 |
}
|
271 |
|
272 |
+
/**
|
273 |
+
* Returns the post language
|
274 |
*
|
275 |
* @since 1.5.4
|
276 |
*
|
277 |
+
* @param int $post_id
|
278 |
+
* @param string $field optional the language field to return 'name', 'locale', defaults to 'slug'
|
279 |
* @return bool|string the requested field for the post language, false if no language is associated to that post
|
280 |
*/
|
281 |
function pll_get_post_language( $post_id, $field = 'slug' ) {
|
282 |
return ( $lang = PLL()->model->post->get_language( $post_id ) ) ? $lang->$field : false;
|
283 |
}
|
284 |
|
285 |
+
/**
|
286 |
+
* Returns the term language
|
287 |
*
|
288 |
* @since 1.5.4
|
289 |
*
|
290 |
+
* @param int $term_id
|
291 |
+
* @param string $field optional the language field to return 'name', 'locale', defaults to 'slug'
|
292 |
* @return bool|string the requested field for the term language, false if no language is associated to that term
|
293 |
*/
|
294 |
function pll_get_term_language( $term_id, $field = 'slug' ) {
|
295 |
return ( $lang = PLL()->model->term->get_language( $term_id ) ) ? $lang->$field : false;
|
296 |
}
|
297 |
|
298 |
+
/**
|
299 |
+
* Returns an array of translations of a post
|
300 |
*
|
301 |
* @since 1.8
|
302 |
*
|
307 |
return PLL()->model->post->get_translations( $post_id );
|
308 |
}
|
309 |
|
310 |
+
/**
|
311 |
+
* Returns an array of translations of a term
|
312 |
*
|
313 |
* @since 1.8
|
314 |
*
|
319 |
return PLL()->model->term->get_translations( $term_id );
|
320 |
}
|
321 |
|
322 |
+
/**
|
323 |
+
* Count posts in a language
|
324 |
*
|
325 |
* @since 1.5
|
326 |
*
|
327 |
* @param string $lang language code
|
328 |
+
* @param array $args ( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format )
|
329 |
* @return int posts count
|
330 |
*/
|
331 |
function pll_count_posts( $lang, $args = array() ) {
|
332 |
return PLL()->model->count_posts( PLL()->model->get_language( $lang ), $args );
|
333 |
}
|
334 |
|
335 |
+
/**
|
336 |
+
* Allows to access the Polylang instance
|
337 |
+
* It is always preferable to use API functions
|
338 |
+
* Internal methods may be changed without prior notice
|
339 |
*
|
340 |
* @since 1.8
|
341 |
*/
|
include/base.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* base class for both admin and frontend
|
5 |
*
|
6 |
* @since 1.2
|
@@ -8,7 +8,7 @@
|
|
8 |
abstract class PLL_Base {
|
9 |
public $links_model, $model, $options;
|
10 |
|
11 |
-
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.2
|
@@ -29,7 +29,7 @@ abstract class PLL_Base {
|
|
29 |
add_action( 'switch_blog', array( &$this, 'switch_blog' ), 10, 2 );
|
30 |
}
|
31 |
|
32 |
-
|
33 |
* registers our widgets
|
34 |
*
|
35 |
* @since 0.1
|
@@ -59,7 +59,7 @@ abstract class PLL_Base {
|
|
59 |
}
|
60 |
}
|
61 |
|
62 |
-
|
63 |
* loads user defined strings translations
|
64 |
*
|
65 |
* @since 1.2
|
@@ -70,7 +70,7 @@ abstract class PLL_Base {
|
|
70 |
$GLOBALS['l10n']['pll_string'] = &$mo;
|
71 |
}
|
72 |
|
73 |
-
|
74 |
* resets some variables when switching blog
|
75 |
* applies only if Polylang is active on the new blog
|
76 |
*
|
@@ -92,7 +92,7 @@ abstract class PLL_Base {
|
|
92 |
return false;
|
93 |
}
|
94 |
|
95 |
-
|
96 |
* some backward compatibility with Polylang < 1.2
|
97 |
* allows for example to call $polylang->get_languages_list() instead of $polylang->model->get_languages_list()
|
98 |
* this works but should be slower than the direct call, thus an error is triggered in debug mode
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* base class for both admin and frontend
|
5 |
*
|
6 |
* @since 1.2
|
8 |
abstract class PLL_Base {
|
9 |
public $links_model, $model, $options;
|
10 |
|
11 |
+
/**
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.2
|
29 |
add_action( 'switch_blog', array( &$this, 'switch_blog' ), 10, 2 );
|
30 |
}
|
31 |
|
32 |
+
/**
|
33 |
* registers our widgets
|
34 |
*
|
35 |
* @since 0.1
|
59 |
}
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
* loads user defined strings translations
|
64 |
*
|
65 |
* @since 1.2
|
70 |
$GLOBALS['l10n']['pll_string'] = &$mo;
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
* resets some variables when switching blog
|
75 |
* applies only if Polylang is active on the new blog
|
76 |
*
|
92 |
return false;
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
* some backward compatibility with Polylang < 1.2
|
97 |
* allows for example to call $polylang->get_languages_list() instead of $polylang->model->get_languages_list()
|
98 |
* this works but should be slower than the direct call, thus an error is triggered in debug mode
|
include/cache.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* an extremely simple non persistent cache system
|
5 |
* not as fast as using directly an array but more readable
|
6 |
*
|
@@ -9,7 +9,7 @@
|
|
9 |
class PLL_Cache {
|
10 |
protected $blog_id, $cache;
|
11 |
|
12 |
-
|
13 |
* constructor
|
14 |
*
|
15 |
* @since 1.7
|
@@ -19,7 +19,7 @@ class PLL_Cache {
|
|
19 |
add_action( 'switch_blog', array( &$this, 'switch_blog' ) );
|
20 |
}
|
21 |
|
22 |
-
|
23 |
* called when switching blog
|
24 |
*
|
25 |
* @since 1.7
|
@@ -30,7 +30,7 @@ class PLL_Cache {
|
|
30 |
$this->blog_id = $new_blog;
|
31 |
}
|
32 |
|
33 |
-
|
34 |
* add a value in cache
|
35 |
*
|
36 |
* @since 1.7
|
@@ -42,7 +42,7 @@ class PLL_Cache {
|
|
42 |
$this->cache[ $this->blog_id ][ $key ] = $data;
|
43 |
}
|
44 |
|
45 |
-
|
46 |
* get value from cache
|
47 |
*
|
48 |
* @since 1.7
|
@@ -54,7 +54,7 @@ class PLL_Cache {
|
|
54 |
return isset( $this->cache[ $this->blog_id ][ $key ] ) ? $this->cache[ $this->blog_id ][ $key ] : false;
|
55 |
}
|
56 |
|
57 |
-
|
58 |
* clean the cache (for this blog only)
|
59 |
*
|
60 |
* @since 1.7
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* an extremely simple non persistent cache system
|
5 |
* not as fast as using directly an array but more readable
|
6 |
*
|
9 |
class PLL_Cache {
|
10 |
protected $blog_id, $cache;
|
11 |
|
12 |
+
/**
|
13 |
* constructor
|
14 |
*
|
15 |
* @since 1.7
|
19 |
add_action( 'switch_blog', array( &$this, 'switch_blog' ) );
|
20 |
}
|
21 |
|
22 |
+
/**
|
23 |
* called when switching blog
|
24 |
*
|
25 |
* @since 1.7
|
30 |
$this->blog_id = $new_blog;
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
* add a value in cache
|
35 |
*
|
36 |
* @since 1.7
|
42 |
$this->cache[ $this->blog_id ][ $key ] = $data;
|
43 |
}
|
44 |
|
45 |
+
/**
|
46 |
* get value from cache
|
47 |
*
|
48 |
* @since 1.7
|
54 |
return isset( $this->cache[ $this->blog_id ][ $key ] ) ? $this->cache[ $this->blog_id ][ $key ] : false;
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
* clean the cache (for this blog only)
|
59 |
*
|
60 |
* @since 1.7
|
include/class-polylang.php
CHANGED
@@ -14,14 +14,14 @@ if ( file_exists( PLL_LOCAL_DIR . '/pll-config.php' ) ) {
|
|
14 |
include_once( PLL_LOCAL_DIR . '/pll-config.php' );
|
15 |
}
|
16 |
|
17 |
-
|
18 |
* controls the plugin, as well as activation, and deactivation
|
19 |
*
|
20 |
* @since 0.1
|
21 |
*/
|
22 |
class Polylang {
|
23 |
|
24 |
-
|
25 |
* constructor
|
26 |
*
|
27 |
* @since 0.1
|
@@ -54,7 +54,7 @@ class Polylang {
|
|
54 |
}
|
55 |
}
|
56 |
|
57 |
-
|
58 |
* autoload classes
|
59 |
*
|
60 |
* @since 1.2
|
@@ -90,7 +90,7 @@ class Polylang {
|
|
90 |
}
|
91 |
}
|
92 |
|
93 |
-
|
94 |
* defines constants
|
95 |
* may be overriden by a plugin if set before plugins_loaded, 1
|
96 |
*
|
@@ -127,11 +127,11 @@ class Polylang {
|
|
127 |
|
128 |
// settings page whatever the tab
|
129 |
if ( ! defined( 'PLL_SETTINGS' ) ) {
|
130 |
-
define( 'PLL_SETTINGS', is_admin() && ( ( isset( $_GET['page'] ) && 'mlang' == $_GET['page'] ) ||
|
131 |
}
|
132 |
}
|
133 |
|
134 |
-
|
135 |
* Polylang initialization
|
136 |
* setups models and separate admin and frontend
|
137 |
*
|
@@ -151,7 +151,14 @@ class Polylang {
|
|
151 |
}
|
152 |
}
|
153 |
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
$class = apply_filters( 'pll_model', PLL_SETTINGS ? 'PLL_Admin_Model' : 'PLL_Model' );
|
156 |
$model = new $class( $options );
|
157 |
$links_model = $model->get_links_model();
|
@@ -170,7 +177,13 @@ class Polylang {
|
|
170 |
}
|
171 |
|
172 |
if ( ! $model->get_languages_list() ) {
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
|
176 |
if ( ! empty( $polylang ) ) {
|
@@ -182,7 +195,15 @@ class Polylang {
|
|
182 |
}
|
183 |
|
184 |
$polylang->init();
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
}
|
187 |
}
|
188 |
}
|
14 |
include_once( PLL_LOCAL_DIR . '/pll-config.php' );
|
15 |
}
|
16 |
|
17 |
+
/**
|
18 |
* controls the plugin, as well as activation, and deactivation
|
19 |
*
|
20 |
* @since 0.1
|
21 |
*/
|
22 |
class Polylang {
|
23 |
|
24 |
+
/**
|
25 |
* constructor
|
26 |
*
|
27 |
* @since 0.1
|
54 |
}
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
* autoload classes
|
59 |
*
|
60 |
* @since 1.2
|
90 |
}
|
91 |
}
|
92 |
|
93 |
+
/**
|
94 |
* defines constants
|
95 |
* may be overriden by a plugin if set before plugins_loaded, 1
|
96 |
*
|
127 |
|
128 |
// settings page whatever the tab
|
129 |
if ( ! defined( 'PLL_SETTINGS' ) ) {
|
130 |
+
define( 'PLL_SETTINGS', is_admin() && ( ( isset( $_GET['page'] ) && 'mlang' == $_GET['page'] ) || ! empty( $_REQUEST['pll_ajax_settings'] ) ) );
|
131 |
}
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
* Polylang initialization
|
136 |
* setups models and separate admin and frontend
|
137 |
*
|
151 |
}
|
152 |
}
|
153 |
|
154 |
+
/**
|
155 |
+
* Filter the model class to use
|
156 |
+
* /!\ this filter is fired *before* the $polylang object is available
|
157 |
+
*
|
158 |
+
* @since 1.5
|
159 |
+
*
|
160 |
+
* @param string $class either PLL_Model or PLL_Admin_Model
|
161 |
+
*/
|
162 |
$class = apply_filters( 'pll_model', PLL_SETTINGS ? 'PLL_Admin_Model' : 'PLL_Model' );
|
163 |
$model = new $class( $options );
|
164 |
$links_model = $model->get_links_model();
|
177 |
}
|
178 |
|
179 |
if ( ! $model->get_languages_list() ) {
|
180 |
+
/**
|
181 |
+
* Fires when no language has been defined yet
|
182 |
+
* Used to load overriden textdomains
|
183 |
+
*
|
184 |
+
* @since 1.2
|
185 |
+
*/
|
186 |
+
do_action( 'pll_no_language_defined' );
|
187 |
}
|
188 |
|
189 |
if ( ! empty( $polylang ) ) {
|
195 |
}
|
196 |
|
197 |
$polylang->init();
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Fires after the $polylang object and the API is loaded
|
201 |
+
*
|
202 |
+
* @since 1.7
|
203 |
+
*
|
204 |
+
* @param object $polylang
|
205 |
+
*/
|
206 |
+
do_action_ref_array( 'pll_init', array( &$polylang ) );
|
207 |
}
|
208 |
}
|
209 |
}
|
include/filters-links.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages links filters needed on both frontend and admin
|
5 |
*
|
6 |
* @since 1.8
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_Filters_Links {
|
9 |
public $links, $links_model, $model, $options;
|
10 |
|
11 |
-
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.8
|
@@ -39,7 +39,7 @@ class PLL_Filters_Links {
|
|
39 |
}
|
40 |
}
|
41 |
|
42 |
-
|
43 |
* modifies post & page links
|
44 |
*
|
45 |
* @since 0.7
|
@@ -54,13 +54,13 @@ class PLL_Filters_Links {
|
|
54 |
}
|
55 |
|
56 |
|
57 |
-
|
58 |
* modifies page links
|
59 |
*
|
60 |
* @since 1.7
|
61 |
*
|
62 |
-
* @param string $link
|
63 |
-
* @param int
|
64 |
* @return string modified post link
|
65 |
*/
|
66 |
public function _get_page_link( $link, $post_id ) {
|
@@ -68,20 +68,20 @@ class PLL_Filters_Links {
|
|
68 |
return false !== strpos( $link, 'preview=true' ) && false !== strpos( $link, 'page_id=' ) ? $link : $this->links_model->add_language_to_link( $link, $this->model->post->get_language( $post_id ) );
|
69 |
}
|
70 |
|
71 |
-
|
72 |
* modifies attachment links
|
73 |
*
|
74 |
* @since 1.6.2
|
75 |
*
|
76 |
-
* @param string $link
|
77 |
-
* @param int
|
78 |
* @return string modified attachment link
|
79 |
*/
|
80 |
public function attachment_link( $link, $post_id ) {
|
81 |
return wp_get_post_parent_id( $post_id ) ? $link : $this->links_model->add_language_to_link( $link, $this->model->post->get_language( $post_id ) );
|
82 |
}
|
83 |
|
84 |
-
|
85 |
* modifies custom posts links
|
86 |
*
|
87 |
* @since 1.6
|
@@ -95,26 +95,46 @@ class PLL_Filters_Links {
|
|
95 |
if ( ( false === strpos( $link, 'preview=true' ) || false === strpos( $link, 'p=' ) ) && $this->model->is_translated_post_type( $post->post_type ) ) {
|
96 |
$lang = $this->model->post->get_language( $post->ID );
|
97 |
$link = $this->options['force_lang'] ? $this->links_model->add_language_to_link( $link, $lang ) : $link;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
$link = apply_filters( 'pll_post_type_link', $link, $lang, $post );
|
99 |
}
|
100 |
|
101 |
return $link;
|
102 |
}
|
103 |
|
104 |
-
|
105 |
* modifies term link
|
106 |
*
|
107 |
* @since 0.7
|
108 |
*
|
109 |
* @param string $link term link
|
110 |
-
* @param object $
|
111 |
-
* @param string $tax
|
112 |
* @return string modified term link
|
113 |
*/
|
114 |
public function term_link( $link, $term, $tax ) {
|
115 |
if ( $this->model->is_translated_taxonomy( $tax ) ) {
|
116 |
$lang = $this->model->term->get_language( $term->term_id );
|
117 |
$link = $this->options['force_lang'] ? $this->links_model->add_language_to_link( $link, $lang ) : $link;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
return apply_filters( 'pll_term_link', $link, $lang, $term );
|
119 |
}
|
120 |
|
@@ -126,7 +146,7 @@ class PLL_Filters_Links {
|
|
126 |
return $link;
|
127 |
}
|
128 |
|
129 |
-
|
130 |
* FIXME: keeps the preview post link on default domain when using multiple domains
|
131 |
*
|
132 |
* @since 1.6.1
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages links filters needed on both frontend and admin
|
5 |
*
|
6 |
* @since 1.8
|
8 |
class PLL_Filters_Links {
|
9 |
public $links, $links_model, $model, $options;
|
10 |
|
11 |
+
/**
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.8
|
39 |
}
|
40 |
}
|
41 |
|
42 |
+
/**
|
43 |
* modifies post & page links
|
44 |
*
|
45 |
* @since 0.7
|
54 |
}
|
55 |
|
56 |
|
57 |
+
/**
|
58 |
* modifies page links
|
59 |
*
|
60 |
* @since 1.7
|
61 |
*
|
62 |
+
* @param string $link post link
|
63 |
+
* @param int $post_id post ID
|
64 |
* @return string modified post link
|
65 |
*/
|
66 |
public function _get_page_link( $link, $post_id ) {
|
68 |
return false !== strpos( $link, 'preview=true' ) && false !== strpos( $link, 'page_id=' ) ? $link : $this->links_model->add_language_to_link( $link, $this->model->post->get_language( $post_id ) );
|
69 |
}
|
70 |
|
71 |
+
/**
|
72 |
* modifies attachment links
|
73 |
*
|
74 |
* @since 1.6.2
|
75 |
*
|
76 |
+
* @param string $link attachment link
|
77 |
+
* @param int $post_id attachment link
|
78 |
* @return string modified attachment link
|
79 |
*/
|
80 |
public function attachment_link( $link, $post_id ) {
|
81 |
return wp_get_post_parent_id( $post_id ) ? $link : $this->links_model->add_language_to_link( $link, $this->model->post->get_language( $post_id ) );
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
* modifies custom posts links
|
86 |
*
|
87 |
* @since 1.6
|
95 |
if ( ( false === strpos( $link, 'preview=true' ) || false === strpos( $link, 'p=' ) ) && $this->model->is_translated_post_type( $post->post_type ) ) {
|
96 |
$lang = $this->model->post->get_language( $post->ID );
|
97 |
$link = $this->options['force_lang'] ? $this->links_model->add_language_to_link( $link, $lang ) : $link;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Filter a custom post type link
|
101 |
+
*
|
102 |
+
* @since 1.6
|
103 |
+
*
|
104 |
+
* @param string $link the term link
|
105 |
+
* @param object $lang the current language
|
106 |
+
* @param object $post the post object
|
107 |
+
*/
|
108 |
$link = apply_filters( 'pll_post_type_link', $link, $lang, $post );
|
109 |
}
|
110 |
|
111 |
return $link;
|
112 |
}
|
113 |
|
114 |
+
/**
|
115 |
* modifies term link
|
116 |
*
|
117 |
* @since 0.7
|
118 |
*
|
119 |
* @param string $link term link
|
120 |
+
* @param object $term term object
|
121 |
+
* @param string $tax taxonomy name
|
122 |
* @return string modified term link
|
123 |
*/
|
124 |
public function term_link( $link, $term, $tax ) {
|
125 |
if ( $this->model->is_translated_taxonomy( $tax ) ) {
|
126 |
$lang = $this->model->term->get_language( $term->term_id );
|
127 |
$link = $this->options['force_lang'] ? $this->links_model->add_language_to_link( $link, $lang ) : $link;
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Filter a term link
|
131 |
+
*
|
132 |
+
* @since 1.6
|
133 |
+
*
|
134 |
+
* @param string $link the term link
|
135 |
+
* @param object $lang the current language
|
136 |
+
* @param object $term the term object
|
137 |
+
*/
|
138 |
return apply_filters( 'pll_term_link', $link, $lang, $term );
|
139 |
}
|
140 |
|
146 |
return $link;
|
147 |
}
|
148 |
|
149 |
+
/**
|
150 |
* FIXME: keeps the preview post link on default domain when using multiple domains
|
151 |
*
|
152 |
* @since 1.6.1
|
include/filters.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* setup filters common to admin and frontend
|
5 |
*
|
6 |
* @since 1.4
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_Filters {
|
9 |
public $links_model, $model, $options, $curlang;
|
10 |
|
11 |
-
|
12 |
* constructor: setups filters
|
13 |
*
|
14 |
* @since 1.4
|
@@ -31,7 +31,7 @@ class PLL_Filters {
|
|
31 |
add_filter( 'language_attributes', array( &$this, 'language_attributes' ) );
|
32 |
}
|
33 |
|
34 |
-
|
35 |
* filters the comments according to the current language
|
36 |
* used by the recent comments widget and admin language filter
|
37 |
*
|
@@ -70,7 +70,7 @@ class PLL_Filters {
|
|
70 |
return $clauses;
|
71 |
}
|
72 |
|
73 |
-
|
74 |
* filters get_pages per language
|
75 |
*
|
76 |
* @since 1.4
|
@@ -103,7 +103,7 @@ class PLL_Filters {
|
|
103 |
'field' => 'term_taxonomy_id', // since WP 3.5
|
104 |
'terms' => $language->term_taxonomy_id,
|
105 |
'operator' => 'NOT IN',
|
106 |
-
) )
|
107 |
);
|
108 |
|
109 |
$args['exclude'] = array_merge( $args['exclude'], get_posts( $r ) );
|
@@ -130,7 +130,7 @@ class PLL_Filters {
|
|
130 |
return $pages;
|
131 |
}
|
132 |
|
133 |
-
|
134 |
* converts WordPress locale to valid W3 locale in html language attributes
|
135 |
*
|
136 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* setup filters common to admin and frontend
|
5 |
*
|
6 |
* @since 1.4
|
8 |
class PLL_Filters {
|
9 |
public $links_model, $model, $options, $curlang;
|
10 |
|
11 |
+
/**
|
12 |
* constructor: setups filters
|
13 |
*
|
14 |
* @since 1.4
|
31 |
add_filter( 'language_attributes', array( &$this, 'language_attributes' ) );
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
* filters the comments according to the current language
|
36 |
* used by the recent comments widget and admin language filter
|
37 |
*
|
70 |
return $clauses;
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
* filters get_pages per language
|
75 |
*
|
76 |
* @since 1.4
|
103 |
'field' => 'term_taxonomy_id', // since WP 3.5
|
104 |
'terms' => $language->term_taxonomy_id,
|
105 |
'operator' => 'NOT IN',
|
106 |
+
) ),
|
107 |
);
|
108 |
|
109 |
$args['exclude'] = array_merge( $args['exclude'], get_posts( $r ) );
|
130 |
return $pages;
|
131 |
}
|
132 |
|
133 |
+
/**
|
134 |
* converts WordPress locale to valid W3 locale in html language attributes
|
135 |
*
|
136 |
* @since 1.8
|
include/language.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* a language object is made of two terms in 'language' and 'term_language' taxonomies
|
5 |
* manipulating only one object per language instead of two terms should make things easier
|
6 |
*
|
@@ -42,7 +42,7 @@ class PLL_Language {
|
|
42 |
public $host, $mo_id;
|
43 |
public $page_on_front, $page_for_posts;
|
44 |
|
45 |
-
|
46 |
* constructor: builds a language object given its two corresponding terms in language and term_language taxonomies
|
47 |
*
|
48 |
* @since 1.2
|
@@ -84,7 +84,7 @@ class PLL_Language {
|
|
84 |
}
|
85 |
}
|
86 |
|
87 |
-
|
88 |
* sets flag_url and flag properties
|
89 |
*
|
90 |
* @since 1.2
|
@@ -110,14 +110,34 @@ class PLL_Language {
|
|
110 |
$flags['custom_flag']['src'] = esc_url( PLL_LOCAL_URL . $file );
|
111 |
}
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
foreach ( $flags as $key => $flag ) {
|
114 |
$this->{$key . '_url'} = empty( $flag['url'] ) ? '' : $flag['url'];
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
$this->{$key} = apply_filters( 'pll_get_flag', empty( $flag['src'] ) ? '' :
|
117 |
sprintf(
|
118 |
'<img src="%s" title="%s" alt="%s" />',
|
119 |
$flag['src'],
|
120 |
-
esc_attr(
|
121 |
esc_attr( $this->name )
|
122 |
),
|
123 |
$this->slug
|
@@ -125,7 +145,7 @@ class PLL_Language {
|
|
125 |
}
|
126 |
}
|
127 |
|
128 |
-
|
129 |
* replace flag by custom flag
|
130 |
* takes care of url scheme
|
131 |
*
|
@@ -149,7 +169,7 @@ class PLL_Language {
|
|
149 |
}
|
150 |
}
|
151 |
|
152 |
-
|
153 |
* updates post and term count
|
154 |
*
|
155 |
* @since 1.2
|
@@ -159,7 +179,7 @@ class PLL_Language {
|
|
159 |
wp_update_term_count( $this->tl_term_taxonomy_id, 'term_language' ); // terms count
|
160 |
}
|
161 |
|
162 |
-
|
163 |
* set home_url and search_url properties
|
164 |
*
|
165 |
* @since 1.3
|
@@ -172,7 +192,7 @@ class PLL_Language {
|
|
172 |
$this->home_url = $home_url;
|
173 |
}
|
174 |
|
175 |
-
|
176 |
* set home_url scheme
|
177 |
* this can't be cached accross pages
|
178 |
*
|
@@ -190,7 +210,7 @@ class PLL_Language {
|
|
190 |
}
|
191 |
}
|
192 |
|
193 |
-
|
194 |
* returns the language locale
|
195 |
* converts WP locales to W3C valid locales for display
|
196 |
* @see #33511
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* a language object is made of two terms in 'language' and 'term_language' taxonomies
|
5 |
* manipulating only one object per language instead of two terms should make things easier
|
6 |
*
|
42 |
public $host, $mo_id;
|
43 |
public $page_on_front, $page_for_posts;
|
44 |
|
45 |
+
/**
|
46 |
* constructor: builds a language object given its two corresponding terms in language and term_language taxonomies
|
47 |
*
|
48 |
* @since 1.2
|
84 |
}
|
85 |
}
|
86 |
|
87 |
+
/**
|
88 |
* sets flag_url and flag properties
|
89 |
*
|
90 |
* @since 1.2
|
110 |
$flags['custom_flag']['src'] = esc_url( PLL_LOCAL_URL . $file );
|
111 |
}
|
112 |
|
113 |
+
/**
|
114 |
+
* Filter the flag title attribute
|
115 |
+
* Defaults to the language name
|
116 |
+
*
|
117 |
+
* @since 0.7
|
118 |
+
*
|
119 |
+
* @param string $title the flag title attribute
|
120 |
+
* @param string $slug the language code
|
121 |
+
* @param string $locale the language locale
|
122 |
+
*/
|
123 |
+
$title = apply_filters( 'pll_flag_title', $this->name, $this->slug, $this->locale );
|
124 |
+
|
125 |
foreach ( $flags as $key => $flag ) {
|
126 |
$this->{$key . '_url'} = empty( $flag['url'] ) ? '' : $flag['url'];
|
127 |
|
128 |
+
/**
|
129 |
+
* Filter the html markup of a flag
|
130 |
+
*
|
131 |
+
* @since 1.0.2
|
132 |
+
*
|
133 |
+
* @param string $flag html markup of the flag or empty string
|
134 |
+
* @param string $slug language code
|
135 |
+
*/
|
136 |
$this->{$key} = apply_filters( 'pll_get_flag', empty( $flag['src'] ) ? '' :
|
137 |
sprintf(
|
138 |
'<img src="%s" title="%s" alt="%s" />',
|
139 |
$flag['src'],
|
140 |
+
esc_attr( $title ),
|
141 |
esc_attr( $this->name )
|
142 |
),
|
143 |
$this->slug
|
145 |
}
|
146 |
}
|
147 |
|
148 |
+
/**
|
149 |
* replace flag by custom flag
|
150 |
* takes care of url scheme
|
151 |
*
|
169 |
}
|
170 |
}
|
171 |
|
172 |
+
/**
|
173 |
* updates post and term count
|
174 |
*
|
175 |
* @since 1.2
|
179 |
wp_update_term_count( $this->tl_term_taxonomy_id, 'term_language' ); // terms count
|
180 |
}
|
181 |
|
182 |
+
/**
|
183 |
* set home_url and search_url properties
|
184 |
*
|
185 |
* @since 1.3
|
192 |
$this->home_url = $home_url;
|
193 |
}
|
194 |
|
195 |
+
/**
|
196 |
* set home_url scheme
|
197 |
* this can't be cached accross pages
|
198 |
*
|
210 |
}
|
211 |
}
|
212 |
|
213 |
+
/**
|
214 |
* returns the language locale
|
215 |
* converts WP locales to W3C valid locales for display
|
216 |
* @see #33511
|
include/license.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* A class to easily manage licenses for Polylang Pro and addons
|
5 |
+
*
|
6 |
+
* @since 1.9
|
7 |
+
*/
|
8 |
+
class PLL_License {
|
9 |
+
public $id, $name, $license_key, $license_data;
|
10 |
+
private $file, $version, $author;
|
11 |
+
private $api_url = 'https://polylang.pro';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
*
|
16 |
+
* @since 1.9
|
17 |
+
*
|
18 |
+
* @param string $file
|
19 |
+
* @param string $item_name
|
20 |
+
* @param string $version
|
21 |
+
* @param string $author
|
22 |
+
* @param string $api_url optional
|
23 |
+
*/
|
24 |
+
function __construct( $file, $item_name, $version, $author, $api_url = null ) {
|
25 |
+
$this->id = sanitize_title( $item_name );
|
26 |
+
$this->file = $file;
|
27 |
+
$this->name = $item_name;
|
28 |
+
$this->version = $version;
|
29 |
+
$this->author = $author;
|
30 |
+
$this->api_url = empty( $api_url ) ? $this->api_url : $api_url;
|
31 |
+
|
32 |
+
$licenses = get_option( 'polylang_licenses' );
|
33 |
+
$this->license_key = empty( $licenses[ $this->id ]['key'] ) ? '' : $licenses[ $this->id ]['key'];
|
34 |
+
if ( ! empty( $licenses[ $this->id ]['data'] ) ) {
|
35 |
+
$this->license_data = $licenses[ $this->id ]['data'];
|
36 |
+
}
|
37 |
+
|
38 |
+
// Updater
|
39 |
+
add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
|
40 |
+
|
41 |
+
// Register settings
|
42 |
+
add_filter( 'pll_settings_licenses', array( $this, 'settings' ) );
|
43 |
+
|
44 |
+
// Weekly schedule
|
45 |
+
if ( ! wp_next_scheduled( 'polylang_check_licenses' ) ) {
|
46 |
+
wp_schedule_event( time(), 'weekly', 'polylang_check_licenses' );
|
47 |
+
}
|
48 |
+
|
49 |
+
add_action( 'polylang_check_licenses', array( &$this, 'check_license' ) );
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Auto updater
|
54 |
+
*
|
55 |
+
* @since 1.9
|
56 |
+
*/
|
57 |
+
public function auto_updater() {
|
58 |
+
$args = array(
|
59 |
+
'version' => $this->version,
|
60 |
+
'license' => $this->license_key,
|
61 |
+
'author' => $this->author,
|
62 |
+
'item_name' => $this->name,
|
63 |
+
);
|
64 |
+
|
65 |
+
// Setup the updater
|
66 |
+
new PLL_Plugin_Updater( $this->api_url, $this->file, $args );
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Registers the licence in the Settings
|
71 |
+
*
|
72 |
+
* @since 1.9
|
73 |
+
*
|
74 |
+
* @param array $items
|
75 |
+
* @return array
|
76 |
+
*/
|
77 |
+
public function settings( $items ) {
|
78 |
+
$items[ $this->id ] = $this;
|
79 |
+
return $items;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Activate the license key
|
84 |
+
*
|
85 |
+
* @since 1.9
|
86 |
+
*
|
87 |
+
* @param string $license_key activation key
|
88 |
+
* @return object updated $this
|
89 |
+
*/
|
90 |
+
public function activate_license( $license_key ) {
|
91 |
+
$this->license_key = $license_key;
|
92 |
+
$this->api_request( 'activate_license' );
|
93 |
+
|
94 |
+
// Tell WordPress to look for updates
|
95 |
+
set_site_transient( 'update_plugins', null );
|
96 |
+
return $this;
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Deactivate the license key
|
102 |
+
*
|
103 |
+
* @since 1.9
|
104 |
+
*
|
105 |
+
* @return object updated $this
|
106 |
+
*/
|
107 |
+
public function deactivate_license() {
|
108 |
+
$this->api_request( 'deactivate_license' );
|
109 |
+
return $this;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Check if license key is valid
|
114 |
+
*
|
115 |
+
* @since 1.9
|
116 |
+
*
|
117 |
+
* @return object updated $this
|
118 |
+
*/
|
119 |
+
public function check_license() {
|
120 |
+
$this->api_request( 'check_license' );
|
121 |
+
return $this;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Sends an api request to check, activate or deactivate the license
|
126 |
+
* Updates the licenses option according to the status
|
127 |
+
*
|
128 |
+
* @since 1.9
|
129 |
+
*
|
130 |
+
* @param string $request check_license | activate_license | deactivate_license
|
131 |
+
*/
|
132 |
+
private function api_request( $request ) {
|
133 |
+
$licenses = get_option( 'polylang_licenses' );
|
134 |
+
unset( $licenses[ $this->id ], $this->license_data );
|
135 |
+
|
136 |
+
if ( ! empty( $this->license_key ) ) {
|
137 |
+
// Data to send in our API request
|
138 |
+
$api_params = array(
|
139 |
+
'edd_action' => $request,
|
140 |
+
'license' => $this->license_key,
|
141 |
+
'item_name' => urlencode( $this->name ),
|
142 |
+
'url' => home_url(),
|
143 |
+
);
|
144 |
+
|
145 |
+
// Call the API
|
146 |
+
$response = wp_remote_post(
|
147 |
+
$this->api_url,
|
148 |
+
array(
|
149 |
+
'timeout' => 15,
|
150 |
+
'sslverify' => false,
|
151 |
+
'body' => $api_params,
|
152 |
+
)
|
153 |
+
);
|
154 |
+
|
155 |
+
// Update the option only if we got a response
|
156 |
+
if ( is_wp_error( $response ) ) {
|
157 |
+
return;
|
158 |
+
}
|
159 |
+
|
160 |
+
// Save new license info
|
161 |
+
$licenses[ $this->id ] = array( 'key' => $this->license_key );
|
162 |
+
$data = json_decode( wp_remote_retrieve_body( $response ) );
|
163 |
+
|
164 |
+
if ( 'deactivated' !== $data->license ) {
|
165 |
+
$licenses[ $this->id ]['data'] = $this->license_data = $data;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
update_option( 'polylang_licenses', $licenses ); // FIXME called multiple times when saving all licenses
|
170 |
+
}
|
171 |
+
}
|
include/links-default.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
* for example mysite.com/?somevar=something&lang=en
|
6 |
* implements the "links_model interface"
|
7 |
*
|
@@ -10,13 +10,13 @@
|
|
10 |
class PLL_Links_Default extends PLL_Links_Model {
|
11 |
public $using_permalinks = false;
|
12 |
|
13 |
-
|
14 |
-
*
|
15 |
* links_model interface
|
16 |
*
|
17 |
* @since 1.2
|
18 |
*
|
19 |
-
* @param string $url
|
20 |
* @param object $lang language
|
21 |
* @return string modified url
|
22 |
*/
|
@@ -24,8 +24,8 @@ class PLL_Links_Default extends PLL_Links_Model {
|
|
24 |
return empty( $lang ) || ( $this->options['hide_default'] && $this->options['default_lang'] == $lang->slug ) ? $url : add_query_arg( 'lang', $lang->slug, $url );
|
25 |
}
|
26 |
|
27 |
-
|
28 |
-
*
|
29 |
* links_model interface
|
30 |
*
|
31 |
* @since 1.2
|
@@ -37,8 +37,8 @@ class PLL_Links_Default extends PLL_Links_Model {
|
|
37 |
return remove_query_arg( 'lang', $url );
|
38 |
}
|
39 |
|
40 |
-
|
41 |
-
*
|
42 |
* links_model interface
|
43 |
*
|
44 |
* @since 1.2
|
@@ -50,23 +50,21 @@ class PLL_Links_Default extends PLL_Links_Model {
|
|
50 |
return remove_query_arg( 'paged', $url );
|
51 |
}
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
* returns the link to the paged page when using pretty permalinks
|
56 |
*
|
57 |
* @since 1.5
|
58 |
*
|
59 |
-
* @param string $url
|
60 |
-
* @param int
|
61 |
* @return string modified url
|
62 |
*/
|
63 |
public function add_paged_to_link( $url, $page ) {
|
64 |
return add_query_arg( array( 'paged' => $page ), $url );
|
65 |
}
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
* gets the language slug from the url if present
|
70 |
* links_model interface
|
71 |
*
|
72 |
* @since 1.2
|
@@ -78,8 +76,8 @@ class PLL_Links_Default extends PLL_Links_Model {
|
|
78 |
return preg_match( $pattern, trailingslashit( $_SERVER['REQUEST_URI'] ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
79 |
}
|
80 |
|
81 |
-
|
82 |
-
*
|
83 |
*
|
84 |
* @since 1.8
|
85 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Links model for default permalinks
|
5 |
* for example mysite.com/?somevar=something&lang=en
|
6 |
* implements the "links_model interface"
|
7 |
*
|
10 |
class PLL_Links_Default extends PLL_Links_Model {
|
11 |
public $using_permalinks = false;
|
12 |
|
13 |
+
/**
|
14 |
+
* Adds language information to an url
|
15 |
* links_model interface
|
16 |
*
|
17 |
* @since 1.2
|
18 |
*
|
19 |
+
* @param string $url url to modify
|
20 |
* @param object $lang language
|
21 |
* @return string modified url
|
22 |
*/
|
24 |
return empty( $lang ) || ( $this->options['hide_default'] && $this->options['default_lang'] == $lang->slug ) ? $url : add_query_arg( 'lang', $lang->slug, $url );
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
+
* Removes the language information from an url
|
29 |
* links_model interface
|
30 |
*
|
31 |
* @since 1.2
|
37 |
return remove_query_arg( 'lang', $url );
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
+
* Returns the link to the first page
|
42 |
* links_model interface
|
43 |
*
|
44 |
* @since 1.2
|
50 |
return remove_query_arg( 'paged', $url );
|
51 |
}
|
52 |
|
53 |
+
/**
|
54 |
+
* Returns the link to the paged page when using pretty permalinks
|
|
|
55 |
*
|
56 |
* @since 1.5
|
57 |
*
|
58 |
+
* @param string $url url to modify
|
59 |
+
* @param int $page
|
60 |
* @return string modified url
|
61 |
*/
|
62 |
public function add_paged_to_link( $url, $page ) {
|
63 |
return add_query_arg( array( 'paged' => $page ), $url );
|
64 |
}
|
65 |
|
66 |
+
/**
|
67 |
+
* Gets the language slug from the url if present
|
|
|
68 |
* links_model interface
|
69 |
*
|
70 |
* @since 1.2
|
76 |
return preg_match( $pattern, trailingslashit( $_SERVER['REQUEST_URI'] ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
77 |
}
|
78 |
|
79 |
+
/**
|
80 |
+
* Returns the static front page url
|
81 |
*
|
82 |
* @since 1.8
|
83 |
*
|
include/links-directory.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
* for example mysite.com/en/something
|
6 |
* implements the "links_model interface"
|
7 |
*
|
@@ -9,8 +9,8 @@
|
|
9 |
*/
|
10 |
class PLL_Links_Directory extends PLL_Links_Permalinks {
|
11 |
|
12 |
-
|
13 |
-
*
|
14 |
*
|
15 |
* @since 1.2
|
16 |
*
|
@@ -28,8 +28,8 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
28 |
|
29 |
}
|
30 |
|
31 |
-
|
32 |
-
*
|
33 |
*
|
34 |
* @since 1.6
|
35 |
*/
|
@@ -41,17 +41,17 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
41 |
add_action( 'setup_theme', array( &$this, 'add_permastruct' ), 2 );
|
42 |
}
|
43 |
|
44 |
-
//
|
45 |
add_action( 'pre_option_rewrite_rules', array( &$this, 'prepare_rewrite_rules' ) );
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
*
|
50 |
* links_model interface
|
51 |
*
|
52 |
* @since 1.2
|
53 |
*
|
54 |
-
* @param string $url
|
55 |
* @param object $lang language
|
56 |
* @return string modified url
|
57 |
*/
|
@@ -64,8 +64,8 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
64 |
return $url;
|
65 |
}
|
66 |
|
67 |
-
|
68 |
-
*
|
69 |
* links_model interface
|
70 |
*
|
71 |
* @since 1.2
|
@@ -88,8 +88,8 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
88 |
return $url;
|
89 |
}
|
90 |
|
91 |
-
|
92 |
-
*
|
93 |
* links_model interface
|
94 |
*
|
95 |
* @since 1.2
|
@@ -103,8 +103,8 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
103 |
return preg_match( $pattern, trailingslashit( $requested_url ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
104 |
}
|
105 |
|
106 |
-
|
107 |
-
*
|
108 |
* links_model interface
|
109 |
*
|
110 |
* @since 1.3.1
|
@@ -118,19 +118,19 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
118 |
return trailingslashit( $this->home . $slug );
|
119 |
}
|
120 |
|
121 |
-
|
122 |
-
*
|
123 |
*
|
124 |
* @since 1.2
|
125 |
*/
|
126 |
function add_permastruct() {
|
127 |
-
//
|
128 |
-
//
|
129 |
add_permastruct( 'language', $this->options['rewrite'] ? '%language%' : 'language/%language%', array( 'with_front' => false ) );
|
130 |
}
|
131 |
|
132 |
-
|
133 |
-
*
|
134 |
*
|
135 |
* @since 0.8.1
|
136 |
*
|
@@ -138,9 +138,9 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
138 |
* @return unmodified $pre
|
139 |
*/
|
140 |
public function prepare_rewrite_rules( $pre ) {
|
141 |
-
//
|
142 |
if ( $this->model->get_languages_list() && ! has_filter( 'language_rewrite_rules', '__return_empty_array' ) ) {
|
143 |
-
//
|
144 |
add_filter( 'language_rewrite_rules', '__return_empty_array' );
|
145 |
|
146 |
foreach ( $this->get_rewrite_rules_filters() as $type ) {
|
@@ -152,8 +152,8 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
152 |
return $pre;
|
153 |
}
|
154 |
|
155 |
-
|
156 |
-
*
|
157 |
* always make sure the default language is at the end in case the language information is hidden for default language
|
158 |
* thanks to brbrbr http://wordpress.org/support/topic/plugin-polylang-rewrite-rules-not-correct
|
159 |
*
|
@@ -177,47 +177,47 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
177 |
$slug = $wp_rewrite->root . ( $this->options['rewrite'] ? '' : 'language/' ) . '(' . implode( '|', $languages ) . ')/';
|
178 |
}
|
179 |
|
180 |
-
//
|
181 |
$cpts = array_intersect( $this->model->get_translated_post_types(), get_post_types( array( '_builtin' => false ) ) );
|
182 |
$cpts = $cpts ? '#post_type=(' . implode( '|', $cpts ) . ')#' : '';
|
183 |
|
184 |
foreach ( $rules as $key => $rule ) {
|
185 |
-
//
|
186 |
if ( $this->options['force_lang'] && in_array( $filter, array_merge( $this->model->get_translated_post_types(), $this->model->get_translated_taxonomies() ) ) ) {
|
187 |
if ( isset( $slug ) ) {
|
188 |
$newrules[ $slug . str_replace( $wp_rewrite->root, '', $key ) ] = str_replace(
|
189 |
array( '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?' ),
|
190 |
array( '[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&' ),
|
191 |
$rule
|
192 |
-
); //
|
193 |
}
|
194 |
|
195 |
if ( $this->options['hide_default'] ) {
|
196 |
$newrules[ $key ] = $rules[ $key ];
|
197 |
-
//
|
198 |
unset( $rules[ $key ] );
|
199 |
}
|
200 |
}
|
201 |
|
202 |
-
//
|
203 |
elseif ( in_array( $filter, $this->always_rewrite ) || in_array( $filter, $this->model->get_filtered_taxonomies() ) || ( $cpts && preg_match( $cpts, $rule ) && ! strpos( $rule, 'name=' ) ) || ( 'rewrite_rules_array' != $filter && $this->options['force_lang'] ) ) {
|
204 |
if ( isset( $slug ) ) {
|
205 |
$newrules[ $slug . str_replace( $wp_rewrite->root, '', $key ) ] = str_replace(
|
206 |
array( '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?' ),
|
207 |
array( '[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&' ),
|
208 |
$rule
|
209 |
-
); //
|
210 |
}
|
211 |
|
212 |
if ( $this->options['hide_default'] ) {
|
213 |
$newrules[ $key ] = str_replace( '?', '?lang=' . $this->options['default_lang'] . '&', $rule );
|
214 |
}
|
215 |
|
216 |
-
unset( $rules[ $key ] ); //
|
217 |
}
|
218 |
}
|
219 |
|
220 |
-
//
|
221 |
if ( 'root' == $filter && isset( $slug ) ) {
|
222 |
$newrules[ $slug . '?$' ] = $wp_rewrite->index.'?lang=$matches[1]';
|
223 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Links model for use when the language code is added in url as a directory
|
5 |
* for example mysite.com/en/something
|
6 |
* implements the "links_model interface"
|
7 |
*
|
9 |
*/
|
10 |
class PLL_Links_Directory extends PLL_Links_Permalinks {
|
11 |
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
*
|
15 |
* @since 1.2
|
16 |
*
|
28 |
|
29 |
}
|
30 |
|
31 |
+
/**
|
32 |
+
* Called only at first object creation to avoid duplicating filters when switching blog
|
33 |
*
|
34 |
* @since 1.6
|
35 |
*/
|
41 |
add_action( 'setup_theme', array( &$this, 'add_permastruct' ), 2 );
|
42 |
}
|
43 |
|
44 |
+
// Make sure to prepare rewrite rules when flushing
|
45 |
add_action( 'pre_option_rewrite_rules', array( &$this, 'prepare_rewrite_rules' ) );
|
46 |
}
|
47 |
|
48 |
+
/**
|
49 |
+
* Adds the language code in url
|
50 |
* links_model interface
|
51 |
*
|
52 |
* @since 1.2
|
53 |
*
|
54 |
+
* @param string $url url to modify
|
55 |
* @param object $lang language
|
56 |
* @return string modified url
|
57 |
*/
|
64 |
return $url;
|
65 |
}
|
66 |
|
67 |
+
/**
|
68 |
+
* Returns the url without language code
|
69 |
* links_model interface
|
70 |
*
|
71 |
* @since 1.2
|
88 |
return $url;
|
89 |
}
|
90 |
|
91 |
+
/**
|
92 |
+
* Returns the language based on language code in url
|
93 |
* links_model interface
|
94 |
*
|
95 |
* @since 1.2
|
103 |
return preg_match( $pattern, trailingslashit( $requested_url ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
104 |
}
|
105 |
|
106 |
+
/**
|
107 |
+
* Returns the home url
|
108 |
* links_model interface
|
109 |
*
|
110 |
* @since 1.3.1
|
118 |
return trailingslashit( $this->home . $slug );
|
119 |
}
|
120 |
|
121 |
+
/**
|
122 |
+
* Optionaly removes 'language' in permalinks so that we get http://www.myblog/en/ instead of http://www.myblog/language/en/
|
123 |
*
|
124 |
* @since 1.2
|
125 |
*/
|
126 |
function add_permastruct() {
|
127 |
+
// Language information always in front of the uri ( 'with_front' => false )
|
128 |
+
// The 3rd parameter structure has been modified in WP 3.4
|
129 |
add_permastruct( 'language', $this->options['rewrite'] ? '%language%' : 'language/%language%', array( 'with_front' => false ) );
|
130 |
}
|
131 |
|
132 |
+
/**
|
133 |
+
* Prepares rewrite rules filters
|
134 |
*
|
135 |
* @since 0.8.1
|
136 |
*
|
138 |
* @return unmodified $pre
|
139 |
*/
|
140 |
public function prepare_rewrite_rules( $pre ) {
|
141 |
+
// Don't modify the rules if there is no languages created yet
|
142 |
if ( $this->model->get_languages_list() && ! has_filter( 'language_rewrite_rules', '__return_empty_array' ) ) {
|
143 |
+
// Suppress the rules created by WordPress for our taxonomy
|
144 |
add_filter( 'language_rewrite_rules', '__return_empty_array' );
|
145 |
|
146 |
foreach ( $this->get_rewrite_rules_filters() as $type ) {
|
152 |
return $pre;
|
153 |
}
|
154 |
|
155 |
+
/**
|
156 |
+
* The rewrite rules !
|
157 |
* always make sure the default language is at the end in case the language information is hidden for default language
|
158 |
* thanks to brbrbr http://wordpress.org/support/topic/plugin-polylang-rewrite-rules-not-correct
|
159 |
*
|
177 |
$slug = $wp_rewrite->root . ( $this->options['rewrite'] ? '' : 'language/' ) . '(' . implode( '|', $languages ) . ')/';
|
178 |
}
|
179 |
|
180 |
+
// For custom post type archives
|
181 |
$cpts = array_intersect( $this->model->get_translated_post_types(), get_post_types( array( '_builtin' => false ) ) );
|
182 |
$cpts = $cpts ? '#post_type=(' . implode( '|', $cpts ) . ')#' : '';
|
183 |
|
184 |
foreach ( $rules as $key => $rule ) {
|
185 |
+
// Special case for translated post types and taxonomies to allow canonical redirection
|
186 |
if ( $this->options['force_lang'] && in_array( $filter, array_merge( $this->model->get_translated_post_types(), $this->model->get_translated_taxonomies() ) ) ) {
|
187 |
if ( isset( $slug ) ) {
|
188 |
$newrules[ $slug . str_replace( $wp_rewrite->root, '', $key ) ] = str_replace(
|
189 |
array( '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?' ),
|
190 |
array( '[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&' ),
|
191 |
$rule
|
192 |
+
); // Should be enough!
|
193 |
}
|
194 |
|
195 |
if ( $this->options['hide_default'] ) {
|
196 |
$newrules[ $key ] = $rules[ $key ];
|
197 |
+
// Unset only if we hide the code for the default language as check_language_code_in_url will do its job in other cases
|
198 |
unset( $rules[ $key ] );
|
199 |
}
|
200 |
}
|
201 |
|
202 |
+
// Rewrite rules filtered by language
|
203 |
elseif ( in_array( $filter, $this->always_rewrite ) || in_array( $filter, $this->model->get_filtered_taxonomies() ) || ( $cpts && preg_match( $cpts, $rule ) && ! strpos( $rule, 'name=' ) ) || ( 'rewrite_rules_array' != $filter && $this->options['force_lang'] ) ) {
|
204 |
if ( isset( $slug ) ) {
|
205 |
$newrules[ $slug . str_replace( $wp_rewrite->root, '', $key ) ] = str_replace(
|
206 |
array( '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?' ),
|
207 |
array( '[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&' ),
|
208 |
$rule
|
209 |
+
); // Should be enough!
|
210 |
}
|
211 |
|
212 |
if ( $this->options['hide_default'] ) {
|
213 |
$newrules[ $key ] = str_replace( '?', '?lang=' . $this->options['default_lang'] . '&', $rule );
|
214 |
}
|
215 |
|
216 |
+
unset( $rules[ $key ] ); // Now useless
|
217 |
}
|
218 |
}
|
219 |
|
220 |
+
// The home rewrite rule
|
221 |
if ( 'root' == $filter && isset( $slug ) ) {
|
222 |
$newrules[ $slug . '?$' ] = $wp_rewrite->index.'?lang=$matches[1]';
|
223 |
}
|
include/links-domain.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
* for example mysite.com/sth and mysite.fr/qqch
|
6 |
* implements the "links_model interface"
|
7 |
*
|
@@ -9,8 +9,8 @@
|
|
9 |
*/
|
10 |
class PLL_Links_Domain extends PLL_Links_Permalinks {
|
11 |
|
12 |
-
|
13 |
-
*
|
14 |
*
|
15 |
* @since 1.8
|
16 |
*
|
@@ -23,13 +23,13 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
23 |
}
|
24 |
|
25 |
|
26 |
-
|
27 |
-
*
|
28 |
* links_model interface
|
29 |
*
|
30 |
* @since 1.2
|
31 |
*
|
32 |
-
* @param string $url
|
33 |
* @param object $lang language
|
34 |
* @return string modified url
|
35 |
*/
|
@@ -40,8 +40,8 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
40 |
return $url;
|
41 |
}
|
42 |
|
43 |
-
|
44 |
-
*
|
45 |
* links_model interface
|
46 |
*
|
47 |
* @since 1.2
|
@@ -56,8 +56,8 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
56 |
return $url;
|
57 |
}
|
58 |
|
59 |
-
|
60 |
-
*
|
61 |
* links_model interface
|
62 |
*
|
63 |
* @since 1.2
|
@@ -68,8 +68,8 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
68 |
return ( $lang = array_search( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . parse_url( $this->home, PHP_URL_PATH ), $this->options['domains'] ) ) ? $lang : '';
|
69 |
}
|
70 |
|
71 |
-
|
72 |
-
*
|
73 |
* links_model interface
|
74 |
*
|
75 |
* @since 1.3.1
|
@@ -81,8 +81,8 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
81 |
return trailingslashit( empty( $this->options['domains'][ $lang->slug ] ) ? $this->home : $this->options['domains'][ $lang->slug ] );
|
82 |
}
|
83 |
|
84 |
-
|
85 |
-
*
|
86 |
*
|
87 |
* @since 1.5
|
88 |
*
|
@@ -96,8 +96,8 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
96 |
return $hosts;
|
97 |
}
|
98 |
|
99 |
-
|
100 |
-
*
|
101 |
*
|
102 |
* @since 1.8
|
103 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Links model for use when using one domain per language
|
5 |
* for example mysite.com/sth and mysite.fr/qqch
|
6 |
* implements the "links_model interface"
|
7 |
*
|
9 |
*/
|
10 |
class PLL_Links_Domain extends PLL_Links_Permalinks {
|
11 |
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
*
|
15 |
* @since 1.8
|
16 |
*
|
23 |
}
|
24 |
|
25 |
|
26 |
+
/**
|
27 |
+
* Adds the language code in url
|
28 |
* links_model interface
|
29 |
*
|
30 |
* @since 1.2
|
31 |
*
|
32 |
+
* @param string $url url to modify
|
33 |
* @param object $lang language
|
34 |
* @return string modified url
|
35 |
*/
|
40 |
return $url;
|
41 |
}
|
42 |
|
43 |
+
/**
|
44 |
+
* Returns the url without language code
|
45 |
* links_model interface
|
46 |
*
|
47 |
* @since 1.2
|
56 |
return $url;
|
57 |
}
|
58 |
|
59 |
+
/**
|
60 |
+
* Returns the language based on language code in url
|
61 |
* links_model interface
|
62 |
*
|
63 |
* @since 1.2
|
68 |
return ( $lang = array_search( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . parse_url( $this->home, PHP_URL_PATH ), $this->options['domains'] ) ) ? $lang : '';
|
69 |
}
|
70 |
|
71 |
+
/**
|
72 |
+
* Returns the home url
|
73 |
* links_model interface
|
74 |
*
|
75 |
* @since 1.3.1
|
81 |
return trailingslashit( empty( $this->options['domains'][ $lang->slug ] ) ? $this->home : $this->options['domains'][ $lang->slug ] );
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* Get hosts managed on the website
|
86 |
*
|
87 |
* @since 1.5
|
88 |
*
|
96 |
return $hosts;
|
97 |
}
|
98 |
|
99 |
+
/**
|
100 |
+
* Returns the correct site url ( mainly to get the correct login form )
|
101 |
*
|
102 |
* @since 1.8
|
103 |
*
|
include/links-model.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.5
|
7 |
*/
|
@@ -10,8 +10,8 @@ abstract class PLL_Links_Model {
|
|
10 |
public $home; // used to store the home url before it is filtered
|
11 |
public $using_permalinks;
|
12 |
|
13 |
-
|
14 |
-
*
|
15 |
*
|
16 |
* @since 1.5
|
17 |
*
|
@@ -30,12 +30,12 @@ abstract class PLL_Links_Model {
|
|
30 |
add_filter( 'allowed_redirect_hosts', array( &$this, 'allowed_redirect_hosts' ) );
|
31 |
}
|
32 |
|
33 |
-
|
34 |
-
*
|
35 |
*
|
36 |
* @since 1.5
|
37 |
*
|
38 |
-
* @param string $url
|
39 |
* @param object $lang language
|
40 |
* @return string modified url
|
41 |
*/
|
@@ -44,8 +44,8 @@ abstract class PLL_Links_Model {
|
|
44 |
return $this->add_language_to_link( $url, $lang );
|
45 |
}
|
46 |
|
47 |
-
|
48 |
-
*
|
49 |
*
|
50 |
* @since 1.5
|
51 |
*
|
@@ -55,8 +55,8 @@ abstract class PLL_Links_Model {
|
|
55 |
return array( parse_url( $this->home, PHP_URL_HOST ) );
|
56 |
}
|
57 |
|
58 |
-
|
59 |
-
*
|
60 |
*
|
61 |
* @since 1.3.1
|
62 |
*
|
@@ -68,8 +68,8 @@ abstract class PLL_Links_Model {
|
|
68 |
return $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ? $url: $this->add_language_to_link( $url, $lang );
|
69 |
}
|
70 |
|
71 |
-
|
72 |
-
*
|
73 |
*
|
74 |
* @since 1.8
|
75 |
*
|
@@ -81,8 +81,8 @@ abstract class PLL_Links_Model {
|
|
81 |
$language->set_home_url( $search_url, $home_url );
|
82 |
}
|
83 |
|
84 |
-
|
85 |
-
*
|
86 |
*
|
87 |
* @since 1.8
|
88 |
*
|
@@ -96,9 +96,9 @@ abstract class PLL_Links_Model {
|
|
96 |
return $languages;
|
97 |
}
|
98 |
|
99 |
-
|
100 |
-
*
|
101 |
-
*
|
102 |
*
|
103 |
* @since 1.8
|
104 |
*
|
@@ -107,19 +107,19 @@ abstract class PLL_Links_Model {
|
|
107 |
*/
|
108 |
public function pll_after_languages_cache( $languages ) {
|
109 |
foreach ( $languages as $language ) {
|
110 |
-
//
|
111 |
if ( ( defined( 'PLL_CACHE_LANGUAGES' ) && ! PLL_CACHE_LANGUAGES ) || ( defined( 'PLL_CACHE_HOME_URL' ) && ! PLL_CACHE_HOME_URL ) ) {
|
112 |
$this->set_home_url( $language );
|
113 |
}
|
114 |
|
115 |
-
//
|
116 |
$language->set_home_url_scheme();
|
117 |
}
|
118 |
return $languages;
|
119 |
}
|
120 |
|
121 |
-
|
122 |
-
*
|
123 |
*
|
124 |
* @since 1.4.3
|
125 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Links model abstract class
|
5 |
*
|
6 |
* @since 1.5
|
7 |
*/
|
10 |
public $home; // used to store the home url before it is filtered
|
11 |
public $using_permalinks;
|
12 |
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
*
|
16 |
* @since 1.5
|
17 |
*
|
30 |
add_filter( 'allowed_redirect_hosts', array( &$this, 'allowed_redirect_hosts' ) );
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
* Changes the language code in url
|
35 |
*
|
36 |
* @since 1.5
|
37 |
*
|
38 |
+
* @param string $url url to modify
|
39 |
* @param object $lang language
|
40 |
* @return string modified url
|
41 |
*/
|
44 |
return $this->add_language_to_link( $url, $lang );
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
+
* Get hosts managed on the website
|
49 |
*
|
50 |
* @since 1.5
|
51 |
*
|
55 |
return array( parse_url( $this->home, PHP_URL_HOST ) );
|
56 |
}
|
57 |
|
58 |
+
/**
|
59 |
+
* Returns the home url
|
60 |
*
|
61 |
* @since 1.3.1
|
62 |
*
|
68 |
return $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ? $url: $this->add_language_to_link( $url, $lang );
|
69 |
}
|
70 |
|
71 |
+
/**
|
72 |
+
* Sets the home urls
|
73 |
*
|
74 |
* @since 1.8
|
75 |
*
|
81 |
$language->set_home_url( $search_url, $home_url );
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* Sets the home urls before it is persistently cached
|
86 |
*
|
87 |
* @since 1.8
|
88 |
*
|
96 |
return $languages;
|
97 |
}
|
98 |
|
99 |
+
/**
|
100 |
+
* Sets the home urls when not cached
|
101 |
+
* Sets the home urls scheme
|
102 |
*
|
103 |
* @since 1.8
|
104 |
*
|
107 |
*/
|
108 |
public function pll_after_languages_cache( $languages ) {
|
109 |
foreach ( $languages as $language ) {
|
110 |
+
// Get the home urls when not cached
|
111 |
if ( ( defined( 'PLL_CACHE_LANGUAGES' ) && ! PLL_CACHE_LANGUAGES ) || ( defined( 'PLL_CACHE_HOME_URL' ) && ! PLL_CACHE_HOME_URL ) ) {
|
112 |
$this->set_home_url( $language );
|
113 |
}
|
114 |
|
115 |
+
// Ensures that the ( possibly cached ) home url uses the right scheme http or https
|
116 |
$language->set_home_url_scheme();
|
117 |
}
|
118 |
return $languages;
|
119 |
}
|
120 |
|
121 |
+
/**
|
122 |
+
* Adds our domains or subdomains to allowed hosts for safe redirection
|
123 |
*
|
124 |
* @since 1.4.3
|
125 |
*
|
include/links-permalinks.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.6
|
7 |
*/
|
@@ -11,8 +11,8 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
11 |
protected $root, $use_trailing_slashes;
|
12 |
protected $always_rewrite = array( 'date', 'root', 'comments', 'search', 'author' );
|
13 |
|
14 |
-
|
15 |
-
*
|
16 |
*
|
17 |
* @since 1.8
|
18 |
*
|
@@ -21,14 +21,14 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
21 |
public function __construct( &$model ) {
|
22 |
parent::__construct( $model );
|
23 |
|
24 |
-
//
|
25 |
$permalink_structure = get_option( 'permalink_structure' );
|
26 |
$this->root = preg_match( '#^/*' . $this->index . '#', $permalink_structure ) ? $this->index . '/' : '';
|
27 |
$this->use_trailing_slashes = ( '/' == substr( $permalink_structure, -1, 1 ) );
|
28 |
}
|
29 |
|
30 |
-
|
31 |
-
*
|
32 |
*
|
33 |
* @since 1.2
|
34 |
*
|
@@ -39,21 +39,21 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
39 |
return preg_replace( '#\/page\/[0-9]+\/?#', $this->use_trailing_slashes ? '/' : '', $url );
|
40 |
}
|
41 |
|
42 |
-
|
43 |
-
*
|
44 |
*
|
45 |
* @since 1.5
|
46 |
*
|
47 |
-
* @param string $url
|
48 |
-
* @param int
|
49 |
* @return string modified url
|
50 |
*/
|
51 |
public function add_paged_to_link( $url, $page ) {
|
52 |
return user_trailingslashit( trailingslashit( $url ) . 'page/' . $page, 'paged' );
|
53 |
}
|
54 |
|
55 |
-
|
56 |
-
*
|
57 |
*
|
58 |
* @since 1.3.1
|
59 |
*
|
@@ -64,8 +64,8 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
64 |
return trailingslashit( parent::home_url( $lang ) );
|
65 |
}
|
66 |
|
67 |
-
|
68 |
-
*
|
69 |
*
|
70 |
* @since 1.8
|
71 |
*
|
@@ -81,15 +81,23 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
81 |
return $this->options['force_lang'] ? $this->add_language_to_link( $url, $lang ) : $url;
|
82 |
}
|
83 |
|
84 |
-
|
85 |
-
*
|
86 |
*
|
87 |
* @since 1.6
|
88 |
*/
|
89 |
public function get_rewrite_rules_filters() {
|
90 |
-
//
|
91 |
$types = array_values( array_merge( $this->model->get_translated_post_types(), $this->model->get_translated_taxonomies(), $this->model->get_filtered_taxonomies() ) );
|
92 |
$types = array_merge( $this->always_rewrite, $types );
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Links model base class when using pretty permalinks
|
5 |
*
|
6 |
* @since 1.6
|
7 |
*/
|
11 |
protected $root, $use_trailing_slashes;
|
12 |
protected $always_rewrite = array( 'date', 'root', 'comments', 'search', 'author' );
|
13 |
|
14 |
+
/**
|
15 |
+
* Constructor
|
16 |
*
|
17 |
* @since 1.8
|
18 |
*
|
21 |
public function __construct( &$model ) {
|
22 |
parent::__construct( $model );
|
23 |
|
24 |
+
// Inspired by wp-includes/rewrite.php
|
25 |
$permalink_structure = get_option( 'permalink_structure' );
|
26 |
$this->root = preg_match( '#^/*' . $this->index . '#', $permalink_structure ) ? $this->index . '/' : '';
|
27 |
$this->use_trailing_slashes = ( '/' == substr( $permalink_structure, -1, 1 ) );
|
28 |
}
|
29 |
|
30 |
+
/**
|
31 |
+
* Returns the link to the first page when using pretty permalinks
|
32 |
*
|
33 |
* @since 1.2
|
34 |
*
|
39 |
return preg_replace( '#\/page\/[0-9]+\/?#', $this->use_trailing_slashes ? '/' : '', $url );
|
40 |
}
|
41 |
|
42 |
+
/**
|
43 |
+
* Returns the link to the paged page when using pretty permalinks
|
44 |
*
|
45 |
* @since 1.5
|
46 |
*
|
47 |
+
* @param string $url url to modify
|
48 |
+
* @param int $page
|
49 |
* @return string modified url
|
50 |
*/
|
51 |
public function add_paged_to_link( $url, $page ) {
|
52 |
return user_trailingslashit( trailingslashit( $url ) . 'page/' . $page, 'paged' );
|
53 |
}
|
54 |
|
55 |
+
/**
|
56 |
+
* Returns the home url
|
57 |
*
|
58 |
* @since 1.3.1
|
59 |
*
|
64 |
return trailingslashit( parent::home_url( $lang ) );
|
65 |
}
|
66 |
|
67 |
+
/**
|
68 |
+
* Returns the static front page url
|
69 |
*
|
70 |
* @since 1.8
|
71 |
*
|
81 |
return $this->options['force_lang'] ? $this->add_language_to_link( $url, $lang ) : $url;
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* Prepares rewrite rules filters
|
86 |
*
|
87 |
* @since 1.6
|
88 |
*/
|
89 |
public function get_rewrite_rules_filters() {
|
90 |
+
// Make sure we have the right post types and taxonomies
|
91 |
$types = array_values( array_merge( $this->model->get_translated_post_types(), $this->model->get_translated_taxonomies(), $this->model->get_filtered_taxonomies() ) );
|
92 |
$types = array_merge( $this->always_rewrite, $types );
|
93 |
+
|
94 |
+
/*
|
95 |
+
* Filter the list of rewrite rules filters to be used by Polylang
|
96 |
+
*
|
97 |
+
* @since 0.8.1
|
98 |
+
*
|
99 |
+
* @param array $types the list of filters (without '_rewrite_rules' at the end)
|
100 |
+
*/
|
101 |
+
return apply_filters( 'pll_rewrite_rules', $types );
|
102 |
}
|
103 |
}
|
include/links-subdomain.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
* for example en.mysite.com/something
|
6 |
* implements the "links_model interface"
|
7 |
*
|
@@ -10,18 +10,25 @@
|
|
10 |
class PLL_Links_Subdomain extends PLL_Links_Permalinks {
|
11 |
protected $www;
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
public function __construct( &$model ) {
|
14 |
parent::__construct( $model );
|
15 |
$this->www = false === strpos( $this->home, '://www.' ) ? '://' : '://www.';
|
16 |
}
|
17 |
|
18 |
-
|
19 |
-
*
|
20 |
* links_model interface
|
21 |
*
|
22 |
* @since 1.2
|
23 |
*
|
24 |
-
* @param string $url
|
25 |
* @param object $lang language
|
26 |
* @return string modified url
|
27 |
*/
|
@@ -32,8 +39,8 @@ class PLL_Links_Subdomain extends PLL_Links_Permalinks {
|
|
32 |
return $url;
|
33 |
}
|
34 |
|
35 |
-
|
36 |
-
*
|
37 |
* links_model interface
|
38 |
*
|
39 |
* @since 1.2
|
@@ -55,8 +62,8 @@ class PLL_Links_Subdomain extends PLL_Links_Permalinks {
|
|
55 |
return $url;
|
56 |
}
|
57 |
|
58 |
-
|
59 |
-
*
|
60 |
* links_model interface
|
61 |
*
|
62 |
* @since 1.2
|
@@ -68,8 +75,8 @@ class PLL_Links_Subdomain extends PLL_Links_Permalinks {
|
|
68 |
return preg_match( $pattern, trailingslashit( $_SERVER['HTTP_HOST'] ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
69 |
}
|
70 |
|
71 |
-
|
72 |
-
*
|
73 |
*
|
74 |
* @since 1.5
|
75 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Links model for use when the language code is added in url as a subdomain
|
5 |
* for example en.mysite.com/something
|
6 |
* implements the "links_model interface"
|
7 |
*
|
10 |
class PLL_Links_Subdomain extends PLL_Links_Permalinks {
|
11 |
protected $www;
|
12 |
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
*
|
16 |
+
* @since 1.7.4
|
17 |
+
*
|
18 |
+
* @param object $model PLL_Model instance
|
19 |
+
*/
|
20 |
public function __construct( &$model ) {
|
21 |
parent::__construct( $model );
|
22 |
$this->www = false === strpos( $this->home, '://www.' ) ? '://' : '://www.';
|
23 |
}
|
24 |
|
25 |
+
/**
|
26 |
+
* Adds the language code in url
|
27 |
* links_model interface
|
28 |
*
|
29 |
* @since 1.2
|
30 |
*
|
31 |
+
* @param string $url url to modify
|
32 |
* @param object $lang language
|
33 |
* @return string modified url
|
34 |
*/
|
39 |
return $url;
|
40 |
}
|
41 |
|
42 |
+
/**
|
43 |
+
* Returns the url without language code
|
44 |
* links_model interface
|
45 |
*
|
46 |
* @since 1.2
|
62 |
return $url;
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
+
* Returns the language based on language code in url
|
67 |
* links_model interface
|
68 |
*
|
69 |
* @since 1.2
|
75 |
return preg_match( $pattern, trailingslashit( $_SERVER['HTTP_HOST'] ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
76 |
}
|
77 |
|
78 |
+
/**
|
79 |
+
* Get hosts managed on the website
|
80 |
*
|
81 |
* @since 1.5
|
82 |
*
|
include/links.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages links related functions
|
5 |
*
|
6 |
* @since 1.2
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_Links {
|
9 |
public $links_model, $model, $options;
|
10 |
|
11 |
-
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.2
|
@@ -21,7 +21,7 @@ class PLL_Links {
|
|
21 |
$this->options = &$polylang->options;
|
22 |
}
|
23 |
|
24 |
-
|
25 |
* returns the home url in the requested language
|
26 |
*
|
27 |
* @since 1.3
|
@@ -34,7 +34,7 @@ class PLL_Links {
|
|
34 |
return $is_search ? $language->search_url : $language->home_url;
|
35 |
}
|
36 |
|
37 |
-
|
38 |
* checks if the current user can read the post
|
39 |
*
|
40 |
* @since 1.5
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages links related functions
|
5 |
*
|
6 |
* @since 1.2
|
8 |
class PLL_Links {
|
9 |
public $links_model, $model, $options;
|
10 |
|
11 |
+
/**
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.2
|
21 |
$this->options = &$polylang->options;
|
22 |
}
|
23 |
|
24 |
+
/**
|
25 |
* returns the home url in the requested language
|
26 |
*
|
27 |
* @since 1.3
|
34 |
return $is_search ? $language->search_url : $language->home_url;
|
35 |
}
|
36 |
|
37 |
+
/**
|
38 |
* checks if the current user can read the post
|
39 |
*
|
40 |
* @since 1.5
|
include/mo.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages strings translations storage
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_MO extends MO {
|
9 |
|
10 |
-
|
11 |
* registers the polylang_mo custom post type, only at first object creation
|
12 |
*
|
13 |
* @since 1.2
|
@@ -19,7 +19,7 @@ class PLL_MO extends MO {
|
|
19 |
}
|
20 |
}
|
21 |
|
22 |
-
|
23 |
* writes a PLL_MO object into a custom post
|
24 |
*
|
25 |
* @since 1.2
|
@@ -48,7 +48,7 @@ class PLL_MO extends MO {
|
|
48 |
wp_insert_post( $post );
|
49 |
}
|
50 |
|
51 |
-
|
52 |
* reads a PLL_MO object from a custom post
|
53 |
*
|
54 |
* @since 1.2
|
@@ -67,7 +67,7 @@ class PLL_MO extends MO {
|
|
67 |
}
|
68 |
}
|
69 |
|
70 |
-
|
71 |
* returns the post id of the post storing the strings translations
|
72 |
*
|
73 |
* @since 1.4
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages strings translations storage
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_MO extends MO {
|
9 |
|
10 |
+
/**
|
11 |
* registers the polylang_mo custom post type, only at first object creation
|
12 |
*
|
13 |
* @since 1.2
|
19 |
}
|
20 |
}
|
21 |
|
22 |
+
/**
|
23 |
* writes a PLL_MO object into a custom post
|
24 |
*
|
25 |
* @since 1.2
|
48 |
wp_insert_post( $post );
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
* reads a PLL_MO object from a custom post
|
53 |
*
|
54 |
* @since 1.2
|
67 |
}
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
* returns the post id of the post storing the strings translations
|
72 |
*
|
73 |
* @since 1.4
|
include/model.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
@@ -10,8 +10,10 @@ class PLL_Model {
|
|
10 |
public $options;
|
11 |
public $post, $term; // translated objects models
|
12 |
|
13 |
-
|
14 |
-
*
|
|
|
|
|
15 |
*
|
16 |
* @since 1.2
|
17 |
*
|
@@ -34,8 +36,8 @@ class PLL_Model {
|
|
34 |
add_filter( 'language_description', '__return_empty_string' );
|
35 |
}
|
36 |
|
37 |
-
|
38 |
-
*
|
39 |
* caches the list in a db transient ( except flags ), unless PLL_CACHE_LANGUAGES is set to false
|
40 |
* caches the list ( with flags ) in the private property $languages
|
41 |
*
|
@@ -70,8 +72,15 @@ class PLL_Model {
|
|
70 |
// we will need the languages list to allow its access in the filter below
|
71 |
$this->cache->set( 'languages', $languages );
|
72 |
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
$languages = apply_filters( 'pll_languages_list', $languages, $this );
|
76 |
|
77 |
// don't store directly objects as it badly break with some hosts ( GoDaddy ) due to race conditions when using object cache
|
@@ -98,8 +107,14 @@ class PLL_Model {
|
|
98 |
}
|
99 |
}
|
100 |
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
$languages = apply_filters( 'pll_after_languages_cache', $languages );
|
104 |
$this->cache->set( 'languages', $languages );
|
105 |
}
|
@@ -114,14 +129,14 @@ class PLL_Model {
|
|
114 |
return empty( $args['fields'] ) ? $languages : wp_list_pluck( $languages, $args['fields'] );
|
115 |
}
|
116 |
|
117 |
-
|
118 |
-
*
|
119 |
* can be called directly with no parameter
|
120 |
* called by the 'edited_term_taxonomy' filter with 2 parameters when count needs to be updated
|
121 |
*
|
122 |
* @since 1.2
|
123 |
*
|
124 |
-
* @param int
|
125 |
* @param string $taxonomy taxonomy name
|
126 |
*/
|
127 |
public function clean_languages_cache( $term = 0, $taxonomy = null ) {
|
@@ -137,8 +152,8 @@ class PLL_Model {
|
|
137 |
}
|
138 |
}
|
139 |
|
140 |
-
|
141 |
-
*
|
142 |
*
|
143 |
* @since 0.1
|
144 |
*
|
@@ -163,13 +178,13 @@ class PLL_Model {
|
|
163 |
return $return;
|
164 |
}
|
165 |
|
166 |
-
|
167 |
-
*
|
168 |
*
|
169 |
* @since 1.2
|
170 |
*
|
171 |
-
* @param array
|
172 |
-
* @param object $lang
|
173 |
* @return array modifed list of clauses
|
174 |
*/
|
175 |
public function terms_clauses( $clauses, $lang ) {
|
@@ -180,8 +195,8 @@ class PLL_Model {
|
|
180 |
return $clauses;
|
181 |
}
|
182 |
|
183 |
-
|
184 |
-
*
|
185 |
* the post types list is cached for better better performance
|
186 |
* wait for 'after_setup_theme' to apply the cache to allow themes adding the filter in functions.php
|
187 |
*
|
@@ -202,7 +217,18 @@ class PLL_Model {
|
|
202 |
$post_types = array_merge( $post_types, array_combine( $this->options['post_types'], $this->options['post_types'] ) );
|
203 |
}
|
204 |
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
if ( did_action( 'after_setup_theme' ) ) {
|
208 |
$this->cache->set( 'post_types', $post_types );
|
@@ -212,8 +238,8 @@ class PLL_Model {
|
|
212 |
return $filter ? array_intersect( $post_types, get_post_types() ) : $post_types;
|
213 |
}
|
214 |
|
215 |
-
|
216 |
-
*
|
217 |
*
|
218 |
* @since 1.2
|
219 |
*
|
@@ -225,8 +251,8 @@ class PLL_Model {
|
|
225 |
return ( is_array( $post_type ) && array_intersect( $post_type, $post_types ) || in_array( $post_type, $post_types ) );
|
226 |
}
|
227 |
|
228 |
-
|
229 |
-
*
|
230 |
*
|
231 |
* @since 1.2
|
232 |
*
|
@@ -241,6 +267,17 @@ class PLL_Model {
|
|
241 |
$taxonomies = array_merge( $taxonomies, array_combine( $this->options['taxonomies'], $this->options['taxonomies'] ) );
|
242 |
}
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
$taxonomies = apply_filters( 'pll_get_taxonomies', $taxonomies, false );
|
245 |
if ( did_action( 'after_setup_theme' ) ) {
|
246 |
$this->cache->set( 'taxonomies', $taxonomies );
|
@@ -250,8 +287,8 @@ class PLL_Model {
|
|
250 |
return $filter ? array_intersect( $taxonomies, get_taxonomies() ) : $taxonomies;
|
251 |
}
|
252 |
|
253 |
-
|
254 |
-
*
|
255 |
*
|
256 |
* @since 1.2
|
257 |
*
|
@@ -263,8 +300,8 @@ class PLL_Model {
|
|
263 |
return ( is_array( $tax ) && array_intersect( $tax, $taxonomies ) || in_array( $tax, $taxonomies ) );
|
264 |
}
|
265 |
|
266 |
-
|
267 |
-
*
|
268 |
*
|
269 |
* @since 1.7
|
270 |
*
|
@@ -278,14 +315,26 @@ class PLL_Model {
|
|
278 |
|
279 |
if ( empty( $taxonomies ) ) {
|
280 |
$taxonomies = array( 'post_format' => 'post_format' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
$taxonomies = apply_filters( 'pll_filtered_taxonomies', $taxonomies, false );
|
282 |
}
|
283 |
|
284 |
return $filter ? array_intersect( $taxonomies, get_taxonomies() ) : $taxonomies;
|
285 |
}
|
286 |
|
287 |
-
|
288 |
-
*
|
289 |
*
|
290 |
* @since 1.7
|
291 |
*
|
@@ -297,8 +346,8 @@ class PLL_Model {
|
|
297 |
return ( is_array( $tax ) && array_intersect( $tax, $taxonomies ) || in_array( $tax, $taxonomies ) );
|
298 |
}
|
299 |
|
300 |
-
|
301 |
-
*
|
302 |
*
|
303 |
* @since 1.7
|
304 |
*
|
@@ -313,8 +362,8 @@ class PLL_Model {
|
|
313 |
return $query_vars;
|
314 |
}
|
315 |
|
316 |
-
|
317 |
-
*
|
318 |
*
|
319 |
* @since 1.2
|
320 |
*
|
@@ -350,17 +399,17 @@ class PLL_Model {
|
|
350 |
$this->term->save_translations( (int) $cat, $translations );
|
351 |
}
|
352 |
|
353 |
-
|
354 |
-
*
|
355 |
* but the native term_exists will return true even if only one exists
|
356 |
* so here the function adds the language parameter
|
357 |
*
|
358 |
* @since 1.4
|
359 |
*
|
360 |
-
* @param string
|
361 |
-
* @param string
|
362 |
-
* @param int
|
363 |
-
* @param string|object $language
|
364 |
* @return null|int the term_id of the found term
|
365 |
*/
|
366 |
public function term_exists( $term_name, $taxonomy, $parent, $language ) {
|
@@ -371,23 +420,23 @@ class PLL_Model {
|
|
371 |
$select = "SELECT t.term_id FROM $wpdb->terms AS t";
|
372 |
$join = " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
|
373 |
$join .= $this->term->join_clause();
|
374 |
-
$where = $wpdb->prepare(
|
375 |
$where .= $this->term->where_clause( $this->get_language( $language ) );
|
376 |
|
377 |
if ( $parent > 0 ) {
|
378 |
-
$where .= $wpdb->prepare(
|
379 |
}
|
380 |
|
381 |
return $wpdb->get_var( $select . $join . $where );
|
382 |
}
|
383 |
|
384 |
-
|
385 |
-
*
|
386 |
*
|
387 |
* @since 1.2
|
388 |
*
|
389 |
-
* @param object lang
|
390 |
-
* @param array
|
391 |
* @return int
|
392 |
*/
|
393 |
public function count_posts( $lang, $q = array() ) {
|
@@ -476,8 +525,8 @@ class PLL_Model {
|
|
476 |
return empty( $counts[ $lang->term_taxonomy_id ] ) ? 0 : $counts[ $lang->term_taxonomy_id ];
|
477 |
}
|
478 |
|
479 |
-
|
480 |
-
*
|
481 |
*
|
482 |
* @since 1.2
|
483 |
*
|
@@ -489,8 +538,8 @@ class PLL_Model {
|
|
489 |
return new $class( $this );
|
490 |
}
|
491 |
|
492 |
-
|
493 |
-
*
|
494 |
* allows for example to call $polylang->model->get_post_languages( $post_id ) instead of $polylang->model->post->get_language( $post_id )
|
495 |
* this works but should be slower than the direct call, thus an error is triggered in debug mode
|
496 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Setups the language and translations model based on WordPress taxonomies
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
10 |
public $options;
|
11 |
public $post, $term; // translated objects models
|
12 |
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
* setups translated objects sub models
|
16 |
+
* setups filters and actions
|
17 |
*
|
18 |
* @since 1.2
|
19 |
*
|
36 |
add_filter( 'language_description', '__return_empty_string' );
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* Returns the list of available languages
|
41 |
* caches the list in a db transient ( except flags ), unless PLL_CACHE_LANGUAGES is set to false
|
42 |
* caches the list ( with flags ) in the private property $languages
|
43 |
*
|
72 |
// we will need the languages list to allow its access in the filter below
|
73 |
$this->cache->set( 'languages', $languages );
|
74 |
|
75 |
+
/**
|
76 |
+
* Filter the list of languages *before* it is stored in the persistent cache
|
77 |
+
* /!\ this filter is fired *before* the $polylang object is available
|
78 |
+
*
|
79 |
+
* @since 1.7.5
|
80 |
+
*
|
81 |
+
* @param array $languages the list of language objects
|
82 |
+
* @param object $model PLL_Model object
|
83 |
+
*/
|
84 |
$languages = apply_filters( 'pll_languages_list', $languages, $this );
|
85 |
|
86 |
// don't store directly objects as it badly break with some hosts ( GoDaddy ) due to race conditions when using object cache
|
107 |
}
|
108 |
}
|
109 |
|
110 |
+
/**
|
111 |
+
* Filter the list of languages *after* it is stored in the persistent cache
|
112 |
+
* /!\ this filter is fired *before* the $polylang object is available
|
113 |
+
*
|
114 |
+
* @since 1.8
|
115 |
+
*
|
116 |
+
* @param array $languages the list of language objects
|
117 |
+
*/
|
118 |
$languages = apply_filters( 'pll_after_languages_cache', $languages );
|
119 |
$this->cache->set( 'languages', $languages );
|
120 |
}
|
129 |
return empty( $args['fields'] ) ? $languages : wp_list_pluck( $languages, $args['fields'] );
|
130 |
}
|
131 |
|
132 |
+
/**
|
133 |
+
* Cleans language cache
|
134 |
* can be called directly with no parameter
|
135 |
* called by the 'edited_term_taxonomy' filter with 2 parameters when count needs to be updated
|
136 |
*
|
137 |
* @since 1.2
|
138 |
*
|
139 |
+
* @param int $term not used
|
140 |
* @param string $taxonomy taxonomy name
|
141 |
*/
|
142 |
public function clean_languages_cache( $term = 0, $taxonomy = null ) {
|
152 |
}
|
153 |
}
|
154 |
|
155 |
+
/**
|
156 |
+
* Returns the language by its term_id, tl_term_id, slug or locale
|
157 |
*
|
158 |
* @since 0.1
|
159 |
*
|
178 |
return $return;
|
179 |
}
|
180 |
|
181 |
+
/**
|
182 |
+
* Adds terms clauses to get_terms to filter them by languages - used in both frontend and admin
|
183 |
*
|
184 |
* @since 1.2
|
185 |
*
|
186 |
+
* @param array $clauses the list of sql clauses in terms query
|
187 |
+
* @param object $lang PLL_Language object
|
188 |
* @return array modifed list of clauses
|
189 |
*/
|
190 |
public function terms_clauses( $clauses, $lang ) {
|
195 |
return $clauses;
|
196 |
}
|
197 |
|
198 |
+
/**
|
199 |
+
* Returns post types that need to be translated
|
200 |
* the post types list is cached for better better performance
|
201 |
* wait for 'after_setup_theme' to apply the cache to allow themes adding the filter in functions.php
|
202 |
*
|
217 |
$post_types = array_merge( $post_types, array_combine( $this->options['post_types'], $this->options['post_types'] ) );
|
218 |
}
|
219 |
|
220 |
+
/**
|
221 |
+
* Filter the list of post types available for translation.
|
222 |
+
* The default are post types which have the parameter ‘public’ set to true.
|
223 |
+
* The filter must be added soon in the WordPress loading process:
|
224 |
+
* in a function hooked to ‘plugins_loaded’ or directly in functions.php for themes.
|
225 |
+
*
|
226 |
+
* @since 0.8
|
227 |
+
*
|
228 |
+
* @param array $post_types list of post type names
|
229 |
+
* @param bool $is_settings true when displaying the list of custom post types in Polylang settings
|
230 |
+
*/
|
231 |
+
$post_types = apply_filters( 'pll_get_post_types', $post_types, false );
|
232 |
|
233 |
if ( did_action( 'after_setup_theme' ) ) {
|
234 |
$this->cache->set( 'post_types', $post_types );
|
238 |
return $filter ? array_intersect( $post_types, get_post_types() ) : $post_types;
|
239 |
}
|
240 |
|
241 |
+
/**
|
242 |
+
* Returns true if Polylang manages languages and translations for this post type
|
243 |
*
|
244 |
* @since 1.2
|
245 |
*
|
251 |
return ( is_array( $post_type ) && array_intersect( $post_type, $post_types ) || in_array( $post_type, $post_types ) );
|
252 |
}
|
253 |
|
254 |
+
/**
|
255 |
+
* Return taxonomies that need to be translated
|
256 |
*
|
257 |
* @since 1.2
|
258 |
*
|
267 |
$taxonomies = array_merge( $taxonomies, array_combine( $this->options['taxonomies'], $this->options['taxonomies'] ) );
|
268 |
}
|
269 |
|
270 |
+
/**
|
271 |
+
* Filter the list of taxonomies available for translation.
|
272 |
+
* The default are taxonomies which have the parameter ‘public’ set to true.
|
273 |
+
* The filter must be added soon in the WordPress loading process:
|
274 |
+
* in a function hooked to ‘plugins_loaded’ or directly in functions.php for themes.
|
275 |
+
*
|
276 |
+
* @since 0.8
|
277 |
+
*
|
278 |
+
* @param array $taxonomies list of taxonomy names
|
279 |
+
* @param bool $is_settings true when displaying the list of custom taxonomies in Polylang settings
|
280 |
+
*/
|
281 |
$taxonomies = apply_filters( 'pll_get_taxonomies', $taxonomies, false );
|
282 |
if ( did_action( 'after_setup_theme' ) ) {
|
283 |
$this->cache->set( 'taxonomies', $taxonomies );
|
287 |
return $filter ? array_intersect( $taxonomies, get_taxonomies() ) : $taxonomies;
|
288 |
}
|
289 |
|
290 |
+
/**
|
291 |
+
* Returns true if Polylang manages languages and translations for this taxonomy
|
292 |
*
|
293 |
* @since 1.2
|
294 |
*
|
300 |
return ( is_array( $tax ) && array_intersect( $tax, $taxonomies ) || in_array( $tax, $taxonomies ) );
|
301 |
}
|
302 |
|
303 |
+
/**
|
304 |
+
* Return taxonomies that need to be filtered ( post_format like )
|
305 |
*
|
306 |
* @since 1.7
|
307 |
*
|
315 |
|
316 |
if ( empty( $taxonomies ) ) {
|
317 |
$taxonomies = array( 'post_format' => 'post_format' );
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Filter the list of taxonomies not translatable but filtered by language.
|
321 |
+
* Includes only the post format by default
|
322 |
+
* The filter must be added soon in the WordPress loading process:
|
323 |
+
* in a function hooked to ‘plugins_loaded’ or directly in functions.php for themes.
|
324 |
+
*
|
325 |
+
* @since 1.7
|
326 |
+
*
|
327 |
+
* @param array $taxonomies list of taxonomy names
|
328 |
+
* @param bool $is_settings true when displaying the list of custom taxonomies in Polylang settings
|
329 |
+
*/
|
330 |
$taxonomies = apply_filters( 'pll_filtered_taxonomies', $taxonomies, false );
|
331 |
}
|
332 |
|
333 |
return $filter ? array_intersect( $taxonomies, get_taxonomies() ) : $taxonomies;
|
334 |
}
|
335 |
|
336 |
+
/**
|
337 |
+
* Returns true if Polylang filters this taxonomy per language
|
338 |
*
|
339 |
* @since 1.7
|
340 |
*
|
346 |
return ( is_array( $tax ) && array_intersect( $tax, $taxonomies ) || in_array( $tax, $taxonomies ) );
|
347 |
}
|
348 |
|
349 |
+
/**
|
350 |
+
* Returns the query vars of all filtered taxonomies
|
351 |
*
|
352 |
* @since 1.7
|
353 |
*
|
362 |
return $query_vars;
|
363 |
}
|
364 |
|
365 |
+
/**
|
366 |
+
* Create a default category for a language
|
367 |
*
|
368 |
* @since 1.2
|
369 |
*
|
399 |
$this->term->save_translations( (int) $cat, $translations );
|
400 |
}
|
401 |
|
402 |
+
/**
|
403 |
+
* It is possible to have several terms with the same name in the same taxonomy ( one per language )
|
404 |
* but the native term_exists will return true even if only one exists
|
405 |
* so here the function adds the language parameter
|
406 |
*
|
407 |
* @since 1.4
|
408 |
*
|
409 |
+
* @param string $term_name the term name
|
410 |
+
* @param string $taxonomy taxonomy name
|
411 |
+
* @param int $parent parent term id
|
412 |
+
* @param string|object $language the language slug or object
|
413 |
* @return null|int the term_id of the found term
|
414 |
*/
|
415 |
public function term_exists( $term_name, $taxonomy, $parent, $language ) {
|
420 |
$select = "SELECT t.term_id FROM $wpdb->terms AS t";
|
421 |
$join = " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
|
422 |
$join .= $this->term->join_clause();
|
423 |
+
$where = $wpdb->prepare( ' WHERE tt.taxonomy = %s AND t.name = %s', $taxonomy, $term_name );
|
424 |
$where .= $this->term->where_clause( $this->get_language( $language ) );
|
425 |
|
426 |
if ( $parent > 0 ) {
|
427 |
+
$where .= $wpdb->prepare( ' AND tt.parent = %d', $parent );
|
428 |
}
|
429 |
|
430 |
return $wpdb->get_var( $select . $join . $where );
|
431 |
}
|
432 |
|
433 |
+
/**
|
434 |
+
* Gets the number of posts per language in a date, author or post type archive
|
435 |
*
|
436 |
* @since 1.2
|
437 |
*
|
438 |
+
* @param object $lang
|
439 |
+
* @param array $q WP_Query arguments ( accepted: post_type, m, year, monthnum, day, author, author_name, post_format )
|
440 |
* @return int
|
441 |
*/
|
442 |
public function count_posts( $lang, $q = array() ) {
|
525 |
return empty( $counts[ $lang->term_taxonomy_id ] ) ? 0 : $counts[ $lang->term_taxonomy_id ];
|
526 |
}
|
527 |
|
528 |
+
/**
|
529 |
+
* Setup the links model based on options
|
530 |
*
|
531 |
* @since 1.2
|
532 |
*
|
538 |
return new $class( $this );
|
539 |
}
|
540 |
|
541 |
+
/**
|
542 |
+
* Some backward compatibility with Polylang < 1.8
|
543 |
* allows for example to call $polylang->model->get_post_languages( $post_id ) instead of $polylang->model->post->get_language( $post_id )
|
544 |
* this works but should be slower than the direct call, thus an error is triggered in debug mode
|
545 |
*
|
include/nav-menu.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages custom menus translations
|
5 |
* common to admin and frontend for the customizer
|
6 |
*
|
@@ -9,7 +9,7 @@
|
|
9 |
class PLL_Nav_Menu {
|
10 |
public $model, $options;
|
11 |
|
12 |
-
|
13 |
* constructor: setups filters and actions
|
14 |
*
|
15 |
* @since 1.7.7
|
@@ -24,7 +24,7 @@ class PLL_Nav_Menu {
|
|
24 |
add_action( 'customize_register', array( &$this, 'create_nav_menu_locations' ), 5 );
|
25 |
}
|
26 |
|
27 |
-
|
28 |
* create temporary nav menu locations ( one per location and per language ) for all non-default language
|
29 |
* to do only one time
|
30 |
*
|
@@ -46,7 +46,7 @@ class PLL_Nav_Menu {
|
|
46 |
}
|
47 |
}
|
48 |
|
49 |
-
|
50 |
* creates a temporary nav menu location from a location and a language
|
51 |
*
|
52 |
* @since 1.8
|
@@ -56,10 +56,10 @@ class PLL_Nav_Menu {
|
|
56 |
* @return string
|
57 |
*/
|
58 |
public function combine_location( $loc, $lang ) {
|
59 |
-
return $loc . ( strpos( $loc, '___') || $this->options['default_lang']
|
60 |
}
|
61 |
|
62 |
-
|
63 |
* get nav menu locations and language from a temporary locaction
|
64 |
*
|
65 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages custom menus translations
|
5 |
* common to admin and frontend for the customizer
|
6 |
*
|
9 |
class PLL_Nav_Menu {
|
10 |
public $model, $options;
|
11 |
|
12 |
+
/**
|
13 |
* constructor: setups filters and actions
|
14 |
*
|
15 |
* @since 1.7.7
|
24 |
add_action( 'customize_register', array( &$this, 'create_nav_menu_locations' ), 5 );
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
* create temporary nav menu locations ( one per location and per language ) for all non-default language
|
29 |
* to do only one time
|
30 |
*
|
46 |
}
|
47 |
}
|
48 |
|
49 |
+
/**
|
50 |
* creates a temporary nav menu location from a location and a language
|
51 |
*
|
52 |
* @since 1.8
|
56 |
* @return string
|
57 |
*/
|
58 |
public function combine_location( $loc, $lang ) {
|
59 |
+
return $loc . ( strpos( $loc, '___' ) || $this->options['default_lang'] === $lang->slug ? '' : '___' . $lang->slug );
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
* get nav menu locations and language from a temporary locaction
|
64 |
*
|
65 |
* @since 1.8
|
include/olt-manager.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* it is best practice that plugins do nothing before plugins_loaded is fired
|
5 |
* so it is what Polylang intends to do
|
6 |
* but some plugins load their text domain as soon as loaded, thus before plugins_loaded is fired
|
@@ -15,7 +15,7 @@ class PLL_OLT_Manager {
|
|
15 |
protected $list_textdomains = array(); // all text domains
|
16 |
public $labels = array(); // post types and taxonomies labels to translate
|
17 |
|
18 |
-
|
19 |
* constructor: setups relevant filters
|
20 |
*
|
21 |
* @since 1.2
|
@@ -38,7 +38,7 @@ class PLL_OLT_Manager {
|
|
38 |
add_filter( 'pre_update_option_active_sitewide_plugins', array( &$this, 'make_polylang_first' ) );
|
39 |
}
|
40 |
|
41 |
-
|
42 |
* access to the single instance of the class
|
43 |
*
|
44 |
* @since 1.7
|
@@ -53,7 +53,7 @@ class PLL_OLT_Manager {
|
|
53 |
return self::$instance;
|
54 |
}
|
55 |
|
56 |
-
|
57 |
* loads text domains
|
58 |
*
|
59 |
* @since 0.1
|
@@ -105,19 +105,26 @@ class PLL_OLT_Manager {
|
|
105 |
$GLOBALS['wp_locale'] = new WP_Locale();
|
106 |
}
|
107 |
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
do_action_ref_array( 'pll_translate_labels', array( &$this->labels ) );
|
110 |
|
111 |
// free memory
|
112 |
unset( $this->default_locale, $this->list_textdomains, $this->labels );
|
113 |
}
|
114 |
|
115 |
-
|
116 |
* saves all text domains in a table for later usage
|
117 |
*
|
118 |
* @since 0.1
|
119 |
*
|
120 |
-
* @param bool
|
121 |
* @param string $domain text domain name
|
122 |
* @param string $mofile translation file name
|
123 |
* @return bool always true
|
@@ -127,14 +134,14 @@ class PLL_OLT_Manager {
|
|
127 |
return true; // prevents WP loading text domains as we will load them all later
|
128 |
}
|
129 |
|
130 |
-
|
131 |
* saves post types and taxonomies labels for a later usage
|
132 |
*
|
133 |
* @since 0.9
|
134 |
*
|
135 |
* @param string $translation not used
|
136 |
-
* @param string $text
|
137 |
-
* @param string $domain
|
138 |
* @return string unmodified $translation
|
139 |
*/
|
140 |
public function gettext( $translation, $text, $domain ) {
|
@@ -144,15 +151,15 @@ class PLL_OLT_Manager {
|
|
144 |
return $translation;
|
145 |
}
|
146 |
|
147 |
-
|
148 |
* saves post types and taxonomies labels for a later usage
|
149 |
*
|
150 |
* @since 0.9
|
151 |
*
|
152 |
* @param string $translation not used
|
153 |
-
* @param string $text
|
154 |
-
* @param string $context
|
155 |
-
* @param string $domain
|
156 |
* @return string unmodified $translation
|
157 |
*/
|
158 |
public function gettext_with_context( $translation, $text, $context, $domain ) {
|
@@ -160,7 +167,7 @@ class PLL_OLT_Manager {
|
|
160 |
return $translation;
|
161 |
}
|
162 |
|
163 |
-
|
164 |
* translates post types and taxonomies labels once the language is known
|
165 |
*
|
166 |
* @since 0.9
|
@@ -185,7 +192,7 @@ class PLL_OLT_Manager {
|
|
185 |
}
|
186 |
}
|
187 |
|
188 |
-
|
189 |
* allows Polylang to be the first plugin loaded ;- )
|
190 |
*
|
191 |
* @since 1.2
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* it is best practice that plugins do nothing before plugins_loaded is fired
|
5 |
* so it is what Polylang intends to do
|
6 |
* but some plugins load their text domain as soon as loaded, thus before plugins_loaded is fired
|
15 |
protected $list_textdomains = array(); // all text domains
|
16 |
public $labels = array(); // post types and taxonomies labels to translate
|
17 |
|
18 |
+
/**
|
19 |
* constructor: setups relevant filters
|
20 |
*
|
21 |
* @since 1.2
|
38 |
add_filter( 'pre_update_option_active_sitewide_plugins', array( &$this, 'make_polylang_first' ) );
|
39 |
}
|
40 |
|
41 |
+
/**
|
42 |
* access to the single instance of the class
|
43 |
*
|
44 |
* @since 1.7
|
53 |
return self::$instance;
|
54 |
}
|
55 |
|
56 |
+
/**
|
57 |
* loads text domains
|
58 |
*
|
59 |
* @since 0.1
|
105 |
$GLOBALS['wp_locale'] = new WP_Locale();
|
106 |
}
|
107 |
|
108 |
+
/**
|
109 |
+
* Fires after the post types and taxonomies labels have been translated
|
110 |
+
* This allows plugins to translate text the same way we do for post types and taxonomies labels
|
111 |
+
*
|
112 |
+
* @since 1.2
|
113 |
+
*
|
114 |
+
* @param array $labels list of strings to trnaslate
|
115 |
+
*/
|
116 |
do_action_ref_array( 'pll_translate_labels', array( &$this->labels ) );
|
117 |
|
118 |
// free memory
|
119 |
unset( $this->default_locale, $this->list_textdomains, $this->labels );
|
120 |
}
|
121 |
|
122 |
+
/**
|
123 |
* saves all text domains in a table for later usage
|
124 |
*
|
125 |
* @since 0.1
|
126 |
*
|
127 |
+
* @param bool $bool not used
|
128 |
* @param string $domain text domain name
|
129 |
* @param string $mofile translation file name
|
130 |
* @return bool always true
|
134 |
return true; // prevents WP loading text domains as we will load them all later
|
135 |
}
|
136 |
|
137 |
+
/**
|
138 |
* saves post types and taxonomies labels for a later usage
|
139 |
*
|
140 |
* @since 0.9
|
141 |
*
|
142 |
* @param string $translation not used
|
143 |
+
* @param string $text string to translate
|
144 |
+
* @param string $domain text domain
|
145 |
* @return string unmodified $translation
|
146 |
*/
|
147 |
public function gettext( $translation, $text, $domain ) {
|
151 |
return $translation;
|
152 |
}
|
153 |
|
154 |
+
/**
|
155 |
* saves post types and taxonomies labels for a later usage
|
156 |
*
|
157 |
* @since 0.9
|
158 |
*
|
159 |
* @param string $translation not used
|
160 |
+
* @param string $text string to translate
|
161 |
+
* @param string $context some comment to describe the context of string to translate
|
162 |
+
* @param string $domain text domain
|
163 |
* @return string unmodified $translation
|
164 |
*/
|
165 |
public function gettext_with_context( $translation, $text, $context, $domain ) {
|
167 |
return $translation;
|
168 |
}
|
169 |
|
170 |
+
/**
|
171 |
* translates post types and taxonomies labels once the language is known
|
172 |
*
|
173 |
* @since 0.9
|
192 |
}
|
193 |
}
|
194 |
|
195 |
+
/**
|
196 |
* allows Polylang to be the first plugin loaded ;- )
|
197 |
*
|
198 |
* @since 1.2
|
include/pointer.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* a class to manage WP pointers
|
5 |
* offers the possibility to have customized buttons
|
6 |
*
|
@@ -9,7 +9,7 @@
|
|
9 |
class PLL_Pointer {
|
10 |
protected $args;
|
11 |
|
12 |
-
|
13 |
* constructor
|
14 |
* enqueues the pointer script
|
15 |
*
|
@@ -36,7 +36,7 @@ class PLL_Pointer {
|
|
36 |
add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
|
37 |
}
|
38 |
|
39 |
-
|
40 |
* enqueue javascripts and styles if the pointer has not been dismissed
|
41 |
*
|
42 |
* @since 1.7.7
|
@@ -54,7 +54,7 @@ class PLL_Pointer {
|
|
54 |
wp_enqueue_script( 'wp-pointer' );
|
55 |
}
|
56 |
|
57 |
-
|
58 |
* adds the javascript of our pointer to the page
|
59 |
*
|
60 |
* @since 1.7.7
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* a class to manage WP pointers
|
5 |
* offers the possibility to have customized buttons
|
6 |
*
|
9 |
class PLL_Pointer {
|
10 |
protected $args;
|
11 |
|
12 |
+
/**
|
13 |
* constructor
|
14 |
* enqueues the pointer script
|
15 |
*
|
36 |
add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
* enqueue javascripts and styles if the pointer has not been dismissed
|
41 |
*
|
42 |
* @since 1.7.7
|
54 |
wp_enqueue_script( 'wp-pointer' );
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
* adds the javascript of our pointer to the page
|
59 |
*
|
60 |
* @since 1.7.7
|
include/static-pages.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* base class to manage the static front page and the page for posts
|
5 |
*
|
6 |
* @since 1.8
|
@@ -9,7 +9,7 @@ abstract class PLL_Static_Pages {
|
|
9 |
public $model, $options;
|
10 |
public $page_on_front, $page_for_posts;
|
11 |
|
12 |
-
|
13 |
* constructor: setups filters and actions
|
14 |
*
|
15 |
* @since 1.8
|
@@ -30,7 +30,7 @@ abstract class PLL_Static_Pages {
|
|
30 |
add_action( 'update_option_page_on_front', 'flush_rewrite_rules' );
|
31 |
}
|
32 |
|
33 |
-
|
34 |
* stores the page on front and page for posts ids
|
35 |
*
|
36 |
* @since 1.8
|
@@ -47,7 +47,7 @@ abstract class PLL_Static_Pages {
|
|
47 |
}
|
48 |
}
|
49 |
|
50 |
-
|
51 |
* adds page_on_front and page_for_posts properties to the language objects
|
52 |
*
|
53 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* base class to manage the static front page and the page for posts
|
5 |
*
|
6 |
* @since 1.8
|
9 |
public $model, $options;
|
10 |
public $page_on_front, $page_for_posts;
|
11 |
|
12 |
+
/**
|
13 |
* constructor: setups filters and actions
|
14 |
*
|
15 |
* @since 1.8
|
30 |
add_action( 'update_option_page_on_front', 'flush_rewrite_rules' );
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
* stores the page on front and page for posts ids
|
35 |
*
|
36 |
* @since 1.8
|
47 |
}
|
48 |
}
|
49 |
|
50 |
+
/**
|
51 |
* adds page_on_front and page_for_posts properties to the language objects
|
52 |
*
|
53 |
* @since 1.8
|
include/switcher.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* a class to display a language switcher on frontend
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Switcher {
|
9 |
|
10 |
-
|
11 |
* returns options available for the language switcher - menu or widget
|
12 |
* either strings to display the options or default values
|
13 |
*
|
14 |
* @since 0.7
|
15 |
*
|
16 |
* @param string $type optional either 'menu' or 'widget', defaults to 'widget'
|
17 |
-
* @param string $key
|
18 |
* @return array list of switcher options srings or default values
|
19 |
*/
|
20 |
static public function get_switcher_options( $type = 'widget', $key = 'string' ) {
|
@@ -33,7 +33,7 @@ class PLL_Switcher {
|
|
33 |
return wp_list_pluck( $options, $key );
|
34 |
}
|
35 |
|
36 |
-
|
37 |
* get the language elements for use in a walker
|
38 |
*
|
39 |
* list of parameters accepted in $args:
|
@@ -42,7 +42,7 @@ class PLL_Switcher {
|
|
42 |
* @since 1.2
|
43 |
*
|
44 |
* @param object $links instance of PLL_Frontend_Links
|
45 |
-
* @param array
|
46 |
* @return array
|
47 |
*/
|
48 |
protected function get_elements( $links, $args ) {
|
@@ -72,6 +72,15 @@ class PLL_Switcher {
|
|
72 |
$classes[] = 'no-translation';
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
$url = apply_filters( 'pll_the_language_link', $url, $slug, $language->locale );
|
76 |
|
77 |
// hide if no translation exists
|
@@ -90,7 +99,7 @@ class PLL_Switcher {
|
|
90 |
return empty( $out ) ? array() : $out;
|
91 |
}
|
92 |
|
93 |
-
|
94 |
* displays a language switcher
|
95 |
* or returns the raw elements to build a custom language switcher
|
96 |
*
|
@@ -111,7 +120,7 @@ class PLL_Switcher {
|
|
111 |
* @since 0.1
|
112 |
*
|
113 |
* @param object $links instance of PLL_Frontend_Links
|
114 |
-
* @param array
|
115 |
* @return string|array either the html markup of the switcher or the raw elements to build a custom language switcher
|
116 |
*/
|
117 |
public function the_languages( $links, $args = '' ) {
|
@@ -130,6 +139,14 @@ class PLL_Switcher {
|
|
130 |
'raw' => 0, // set this to true to build your own custom language switcher
|
131 |
);
|
132 |
$args = wp_parse_args( $args, $defaults );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
$args = apply_filters( 'pll_the_languages_args', $args );
|
134 |
|
135 |
// prevents showing empty options in dropdown
|
@@ -152,6 +169,14 @@ class PLL_Switcher {
|
|
152 |
$walker = new PLL_Walker_List();
|
153 |
}
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
$out = apply_filters( 'pll_the_languages', $walker->walk( $elements, $args ), $args );
|
156 |
|
157 |
// javascript to switch the language when using a dropdown list
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* a class to display a language switcher on frontend
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Switcher {
|
9 |
|
10 |
+
/**
|
11 |
* returns options available for the language switcher - menu or widget
|
12 |
* either strings to display the options or default values
|
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 srings or default values
|
19 |
*/
|
20 |
static public function get_switcher_options( $type = 'widget', $key = 'string' ) {
|
33 |
return wp_list_pluck( $options, $key );
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
* get the language elements for use in a walker
|
38 |
*
|
39 |
* list of parameters accepted in $args:
|
42 |
* @since 1.2
|
43 |
*
|
44 |
* @param object $links instance of PLL_Frontend_Links
|
45 |
+
* @param array $args
|
46 |
* @return array
|
47 |
*/
|
48 |
protected function get_elements( $links, $args ) {
|
72 |
$classes[] = 'no-translation';
|
73 |
}
|
74 |
|
75 |
+
/*
|
76 |
+
* Filter the link in the language switcher
|
77 |
+
*
|
78 |
+
* @since 0.7
|
79 |
+
*
|
80 |
+
* @param string $url the link
|
81 |
+
* @param string $slug language code
|
82 |
+
* @param string $locale language locale
|
83 |
+
*/
|
84 |
$url = apply_filters( 'pll_the_language_link', $url, $slug, $language->locale );
|
85 |
|
86 |
// hide if no translation exists
|
99 |
return empty( $out ) ? array() : $out;
|
100 |
}
|
101 |
|
102 |
+
/**
|
103 |
* displays a language switcher
|
104 |
* or returns the raw elements to build a custom language switcher
|
105 |
*
|
120 |
* @since 0.1
|
121 |
*
|
122 |
* @param object $links instance of PLL_Frontend_Links
|
123 |
+
* @param array $args
|
124 |
* @return string|array either the html markup of the switcher or the raw elements to build a custom language switcher
|
125 |
*/
|
126 |
public function the_languages( $links, $args = '' ) {
|
139 |
'raw' => 0, // set this to true to build your own custom language switcher
|
140 |
);
|
141 |
$args = wp_parse_args( $args, $defaults );
|
142 |
+
|
143 |
+
/*
|
144 |
+
* Filter the arguments of the 'pll_the_languages' template tag
|
145 |
+
*
|
146 |
+
* @since 1.5
|
147 |
+
*
|
148 |
+
* @param array $args
|
149 |
+
*/
|
150 |
$args = apply_filters( 'pll_the_languages_args', $args );
|
151 |
|
152 |
// prevents showing empty options in dropdown
|
169 |
$walker = new PLL_Walker_List();
|
170 |
}
|
171 |
|
172 |
+
/*
|
173 |
+
* Filter the whole html markup returned by the 'pll_the_languages' template tag
|
174 |
+
*
|
175 |
+
* @since 0.8
|
176 |
+
*
|
177 |
+
* @param string $html html returned/outputed by the template tag
|
178 |
+
* @param array $args arguments passed to the template tag
|
179 |
+
*/
|
180 |
$out = apply_filters( 'pll_the_languages', $walker->walk( $elements, $args ), $args );
|
181 |
|
182 |
// javascript to switch the language when using a dropdown list
|
include/translated-object.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
@@ -9,6 +9,13 @@ abstract class PLL_Translated_Object {
|
|
9 |
public $model;
|
10 |
protected $object_type, $tax_language, $tax_translations, $tax_tt;
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
public function __construct( &$model ) {
|
13 |
$this->model = &$model;
|
14 |
|
@@ -20,14 +27,14 @@ abstract class PLL_Translated_Object {
|
|
20 |
register_taxonomy( $this->tax_translations, $this->object_type, $args );
|
21 |
}
|
22 |
|
23 |
-
|
24 |
-
*
|
25 |
* inspired by the function get_the_terms
|
26 |
*
|
27 |
* @since 1.2
|
28 |
*
|
29 |
-
* @param int
|
30 |
-
* @param string $taxonomy
|
31 |
* @return bool|object the term associated to the object in the requested taxonomy if exists, false otherwise
|
32 |
*/
|
33 |
public function get_object_term( $object_id, $taxonomy ) {
|
@@ -63,24 +70,24 @@ abstract class PLL_Translated_Object {
|
|
63 |
return empty( $term ) ? false : $term;
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
*
|
68 |
*
|
69 |
* @since 1.8
|
70 |
*
|
71 |
-
* @param array $translations
|
72 |
*/
|
73 |
protected function keep_translation_group( $translations ) {
|
74 |
return count( $translations ) > 1;
|
75 |
}
|
76 |
|
77 |
-
|
78 |
-
*
|
79 |
*
|
80 |
* @since 0.5
|
81 |
*
|
82 |
-
* @param int
|
83 |
-
* @param array $translations
|
84 |
*/
|
85 |
public function save_translations( $id, $translations ) {
|
86 |
$id = (int) $id;
|
@@ -132,8 +139,8 @@ abstract class PLL_Translated_Object {
|
|
132 |
}
|
133 |
}
|
134 |
|
135 |
-
|
136 |
-
*
|
137 |
*
|
138 |
* @since 0.5
|
139 |
*
|
@@ -157,8 +164,8 @@ abstract class PLL_Translated_Object {
|
|
157 |
}
|
158 |
}
|
159 |
|
160 |
-
|
161 |
-
*
|
162 |
*
|
163 |
* @since 0.5
|
164 |
*
|
@@ -180,12 +187,12 @@ abstract class PLL_Translated_Object {
|
|
180 |
return $translations;
|
181 |
}
|
182 |
|
183 |
-
|
184 |
-
*
|
185 |
*
|
186 |
* @since 0.5
|
187 |
*
|
188 |
-
* @param int
|
189 |
* @param object|string $lang object or slug
|
190 |
* @return bool|int post id or term id of the translation, false if there is none
|
191 |
*/
|
@@ -199,13 +206,13 @@ abstract class PLL_Translated_Object {
|
|
199 |
return isset( $translations[ $lang->slug ] ) ? $translations[ $lang->slug ] : false;
|
200 |
}
|
201 |
|
202 |
-
|
203 |
-
*
|
204 |
*
|
205 |
* @since 0.1
|
206 |
*
|
207 |
-
* @param int
|
208 |
-
* @param int|string|object language ( term_id or slug or object )
|
209 |
* @return bool|int the translation post id or term id if exists, otherwise the post id or term id, false if the post has no language
|
210 |
*/
|
211 |
public function get( $id, $lang ) {
|
@@ -218,8 +225,8 @@ abstract class PLL_Translated_Object {
|
|
218 |
return $obj_lang->term_id == $lang->term_id ? $id : $this->get_translation( $id, $lang );
|
219 |
}
|
220 |
|
221 |
-
|
222 |
-
*
|
223 |
*
|
224 |
* @since 1.2
|
225 |
*
|
@@ -246,8 +253,8 @@ abstract class PLL_Translated_Object {
|
|
246 |
return ' AND pll_tr.term_taxonomy_id IN ( ' . implode( ',', $languages ) . ' )';
|
247 |
}
|
248 |
|
249 |
-
|
250 |
-
*
|
251 |
* faster than get_objects_in_term as it avoids a JOIN
|
252 |
*
|
253 |
* @since 1.4
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Setups the objects languages and translations model
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
9 |
public $model;
|
10 |
protected $object_type, $tax_language, $tax_translations, $tax_tt;
|
11 |
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
+
*
|
15 |
+
* @since 1.8
|
16 |
+
*
|
17 |
+
* @param object $model
|
18 |
+
*/
|
19 |
public function __construct( &$model ) {
|
20 |
$this->model = &$model;
|
21 |
|
27 |
register_taxonomy( $this->tax_translations, $this->object_type, $args );
|
28 |
}
|
29 |
|
30 |
+
/**
|
31 |
+
* Wrap wp_get_object_terms to cache it and return only one object
|
32 |
* inspired by the function get_the_terms
|
33 |
*
|
34 |
* @since 1.2
|
35 |
*
|
36 |
+
* @param int $object_id post_id or term_id
|
37 |
+
* @param string $taxonomy Polylang taxonomy depending if we are looking for a post ( or term ) language ( or translation )
|
38 |
* @return bool|object the term associated to the object in the requested taxonomy if exists, false otherwise
|
39 |
*/
|
40 |
public function get_object_term( $object_id, $taxonomy ) {
|
70 |
return empty( $term ) ? false : $term;
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
+
* Tells wether to store a translation term
|
75 |
*
|
76 |
* @since 1.8
|
77 |
*
|
78 |
+
* @param array $translations an associative array of translations with language code as key and translation id as value
|
79 |
*/
|
80 |
protected function keep_translation_group( $translations ) {
|
81 |
return count( $translations ) > 1;
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* Saves translations for posts or terms
|
86 |
*
|
87 |
* @since 0.5
|
88 |
*
|
89 |
+
* @param int $id post id or term id
|
90 |
+
* @param array $translations an associative array of translations with language code as key and translation id as value
|
91 |
*/
|
92 |
public function save_translations( $id, $translations ) {
|
93 |
$id = (int) $id;
|
139 |
}
|
140 |
}
|
141 |
|
142 |
+
/**
|
143 |
+
* Deletes a translation of a post or term
|
144 |
*
|
145 |
* @since 0.5
|
146 |
*
|
164 |
}
|
165 |
}
|
166 |
|
167 |
+
/**
|
168 |
+
* Returns an array of translations of a post or term
|
169 |
*
|
170 |
* @since 0.5
|
171 |
*
|
187 |
return $translations;
|
188 |
}
|
189 |
|
190 |
+
/**
|
191 |
+
* Returns the id of the translation of a post or term
|
192 |
*
|
193 |
* @since 0.5
|
194 |
*
|
195 |
+
* @param int $id post id or term id
|
196 |
* @param object|string $lang object or slug
|
197 |
* @return bool|int post id or term id of the translation, false if there is none
|
198 |
*/
|
206 |
return isset( $translations[ $lang->slug ] ) ? $translations[ $lang->slug ] : false;
|
207 |
}
|
208 |
|
209 |
+
/**
|
210 |
+
* Among the object and its translations, returns the id of the object which is in $lang
|
211 |
*
|
212 |
* @since 0.1
|
213 |
*
|
214 |
+
* @param int $id post id or term id
|
215 |
+
* @param int|string|object $lang language ( term_id or slug or object )
|
216 |
* @return bool|int the translation post id or term id if exists, otherwise the post id or term id, false if the post has no language
|
217 |
*/
|
218 |
public function get( $id, $lang ) {
|
225 |
return $obj_lang->term_id == $lang->term_id ? $id : $this->get_translation( $id, $lang );
|
226 |
}
|
227 |
|
228 |
+
/**
|
229 |
+
* A where clause to add to sql queries when filtering by language is needed directly in query
|
230 |
*
|
231 |
* @since 1.2
|
232 |
*
|
253 |
return ' AND pll_tr.term_taxonomy_id IN ( ' . implode( ',', $languages ) . ' )';
|
254 |
}
|
255 |
|
256 |
+
/**
|
257 |
+
* Returns ids of objects in a language similarly to get_objects_in_term for a taxonomy
|
258 |
* faster than get_objects_in_term as it avoids a JOIN
|
259 |
*
|
260 |
* @since 1.4
|
include/translated-post.php
CHANGED
@@ -1,12 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Translated_Post extends PLL_Translated_Object {
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
public function __construct( &$model ) {
|
11 |
// init properties
|
12 |
$this->object_type = null;
|
@@ -26,20 +33,20 @@ class PLL_Translated_Post extends PLL_Translated_Object {
|
|
26 |
add_action( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
|
27 |
}
|
28 |
|
29 |
-
|
30 |
-
*
|
31 |
*
|
32 |
* @since 0.6
|
33 |
*
|
34 |
-
* @param int
|
35 |
-
* @param int|string|object language ( term_id or slug or object )
|
36 |
*/
|
37 |
public function set_language( $post_id, $lang ) {
|
38 |
wp_set_post_terms( (int) $post_id, $lang ? $this->model->get_language( $lang )->slug : '', 'language' );
|
39 |
}
|
40 |
|
41 |
-
|
42 |
-
*
|
43 |
*
|
44 |
* @since 0.1
|
45 |
*
|
@@ -51,8 +58,8 @@ class PLL_Translated_Post extends PLL_Translated_Object {
|
|
51 |
return ( $lang ) ? $this->model->get_language( $lang ) : false;
|
52 |
}
|
53 |
|
54 |
-
|
55 |
-
*
|
56 |
*
|
57 |
* @since 0.5
|
58 |
*
|
@@ -63,8 +70,8 @@ class PLL_Translated_Post extends PLL_Translated_Object {
|
|
63 |
wp_set_object_terms( $id, null, $this->tax_translations );
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
*
|
68 |
*
|
69 |
* @since 1.2
|
70 |
*
|
@@ -75,8 +82,8 @@ class PLL_Translated_Post extends PLL_Translated_Object {
|
|
75 |
return " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = ID";
|
76 |
}
|
77 |
|
78 |
-
|
79 |
-
*
|
80 |
*
|
81 |
* @since 1.2
|
82 |
*/
|
@@ -98,8 +105,8 @@ class PLL_Translated_Post extends PLL_Translated_Object {
|
|
98 |
) );
|
99 |
}
|
100 |
|
101 |
-
|
102 |
-
*
|
103 |
*
|
104 |
* @since 1.2
|
105 |
*
|
@@ -112,8 +119,8 @@ class PLL_Translated_Post extends PLL_Translated_Object {
|
|
112 |
}
|
113 |
}
|
114 |
|
115 |
-
|
116 |
-
*
|
117 |
* this is especially useful for nav menus with a lot of pages
|
118 |
* without doing this, we would have one query per page in the menu to get the page language for the permalink
|
119 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Setups the posts languages and translations model
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Translated_Post extends PLL_Translated_Object {
|
9 |
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
*
|
13 |
+
* @since 1.8
|
14 |
+
*
|
15 |
+
* @param object $model
|
16 |
+
*/
|
17 |
public function __construct( &$model ) {
|
18 |
// init properties
|
19 |
$this->object_type = null;
|
33 |
add_action( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
+
* Store the post language in the database
|
38 |
*
|
39 |
* @since 0.6
|
40 |
*
|
41 |
+
* @param int $post_id post id
|
42 |
+
* @param int|string|object $lang language ( term_id or slug or object )
|
43 |
*/
|
44 |
public function set_language( $post_id, $lang ) {
|
45 |
wp_set_post_terms( (int) $post_id, $lang ? $this->model->get_language( $lang )->slug : '', 'language' );
|
46 |
}
|
47 |
|
48 |
+
/**
|
49 |
+
* Returns the language of a post
|
50 |
*
|
51 |
* @since 0.1
|
52 |
*
|
58 |
return ( $lang ) ? $this->model->get_language( $lang ) : false;
|
59 |
}
|
60 |
|
61 |
+
/**
|
62 |
+
* Deletes a translation
|
63 |
*
|
64 |
* @since 0.5
|
65 |
*
|
70 |
wp_set_object_terms( $id, null, $this->tax_translations );
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
+
* A join clause to add to sql queries when filtering by language is needed directly in query
|
75 |
*
|
76 |
* @since 1.2
|
77 |
*
|
82 |
return " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = ID";
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
+
* Register the language taxonomy
|
87 |
*
|
88 |
* @since 1.2
|
89 |
*/
|
105 |
) );
|
106 |
}
|
107 |
|
108 |
+
/**
|
109 |
+
* Check if registered post type must be translated
|
110 |
*
|
111 |
* @since 1.2
|
112 |
*
|
119 |
}
|
120 |
}
|
121 |
|
122 |
+
/**
|
123 |
+
* Forces calling 'update_object_term_cache' when querying posts or pages
|
124 |
* this is especially useful for nav menus with a lot of pages
|
125 |
* without doing this, we would have one query per page in the menu to get the page language for the permalink
|
126 |
*
|
include/translated-term.php
CHANGED
@@ -1,12 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Translated_Term extends PLL_Translated_Object {
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
public function __construct( &$model ) {
|
11 |
$this->object_type = 'term';
|
12 |
$this->tax_language = 'term_language';
|
@@ -20,13 +27,13 @@ class PLL_Translated_Term extends PLL_Translated_Object {
|
|
20 |
add_filter( 'wp_get_object_terms', array( &$this, 'wp_get_object_terms' ), 10, 3 );
|
21 |
}
|
22 |
|
23 |
-
|
24 |
-
*
|
25 |
*
|
26 |
* @since 0.6
|
27 |
*
|
28 |
-
* @param int
|
29 |
-
* @param int|string|object language ( term_id or slug or object )
|
30 |
*/
|
31 |
public function set_language( $term_id, $lang ) {
|
32 |
$term_id = (int) $term_id;
|
@@ -41,8 +48,8 @@ class PLL_Translated_Term extends PLL_Translated_Object {
|
|
41 |
$this->save_translations( $term_id, $translations );
|
42 |
}
|
43 |
|
44 |
-
|
45 |
-
*
|
46 |
*
|
47 |
* @since 0.5
|
48 |
*
|
@@ -52,13 +59,13 @@ class PLL_Translated_Term extends PLL_Translated_Object {
|
|
52 |
wp_delete_object_term_relationships( $term_id, 'term_language' );
|
53 |
}
|
54 |
|
55 |
-
|
56 |
-
*
|
57 |
*
|
58 |
* @since 0.1
|
59 |
*
|
60 |
-
* @param int|string $value
|
61 |
-
* @param string
|
62 |
* @return bool|object PLL_Language object, false if no language is associated to that term
|
63 |
*/
|
64 |
public function get_language( $value, $taxonomy = '' ) {
|
@@ -75,8 +82,8 @@ class PLL_Translated_Term extends PLL_Translated_Object {
|
|
75 |
return isset( $term_id ) && ( $lang = $this->get_object_term( $term_id, 'term_language' ) ) ? $this->model->get_language( $lang->term_id ) : false;
|
76 |
}
|
77 |
|
78 |
-
|
79 |
-
*
|
80 |
*
|
81 |
* @since 1.8
|
82 |
*
|
@@ -86,8 +93,8 @@ class PLL_Translated_Term extends PLL_Translated_Object {
|
|
86 |
return true;
|
87 |
}
|
88 |
|
89 |
-
|
90 |
-
*
|
91 |
*
|
92 |
* @since 0.5
|
93 |
*
|
@@ -107,8 +114,8 @@ class PLL_Translated_Term extends PLL_Translated_Object {
|
|
107 |
}
|
108 |
}
|
109 |
|
110 |
-
|
111 |
-
*
|
112 |
*
|
113 |
* @since 1.2
|
114 |
*
|
@@ -119,12 +126,12 @@ class PLL_Translated_Term extends PLL_Translated_Object {
|
|
119 |
return " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = t.term_id";
|
120 |
}
|
121 |
|
122 |
-
|
123 |
-
*
|
124 |
*
|
125 |
* @since 1.2
|
126 |
*
|
127 |
-
* @param array $terms
|
128 |
* @param array $taxonomies queried taxonomies
|
129 |
* @return array unmodified $terms
|
130 |
*/
|
@@ -141,12 +148,12 @@ class PLL_Translated_Term extends PLL_Translated_Object {
|
|
141 |
return $terms;
|
142 |
}
|
143 |
|
144 |
-
|
145 |
-
*
|
146 |
*
|
147 |
* @since 1.2
|
148 |
*
|
149 |
-
* @param array $terms
|
150 |
* @param array $object_ids not used
|
151 |
* @param array $taxonomies terms taxonomies
|
152 |
* @return array unmodified $terms
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Setups the taxonomies languages and translations model
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Translated_Term extends PLL_Translated_Object {
|
9 |
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
*
|
13 |
+
* @since 1.8
|
14 |
+
*
|
15 |
+
* @param object $model
|
16 |
+
*/
|
17 |
public function __construct( &$model ) {
|
18 |
$this->object_type = 'term';
|
19 |
$this->tax_language = 'term_language';
|
27 |
add_filter( 'wp_get_object_terms', array( &$this, 'wp_get_object_terms' ), 10, 3 );
|
28 |
}
|
29 |
|
30 |
+
/**
|
31 |
+
* Stores the term language in the database
|
32 |
*
|
33 |
* @since 0.6
|
34 |
*
|
35 |
+
* @param int $term_id term id
|
36 |
+
* @param int|string|object $lang language ( term_id or slug or object )
|
37 |
*/
|
38 |
public function set_language( $term_id, $lang ) {
|
39 |
$term_id = (int) $term_id;
|
48 |
$this->save_translations( $term_id, $translations );
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
+
* Removes the term language in database
|
53 |
*
|
54 |
* @since 0.5
|
55 |
*
|
59 |
wp_delete_object_term_relationships( $term_id, 'term_language' );
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
+
* Returns the language of a term
|
64 |
*
|
65 |
* @since 0.1
|
66 |
*
|
67 |
+
* @param int|string $value term id or term slug
|
68 |
+
* @param string $taxonomy optional taxonomy needed when the term slug is passed as first parameter
|
69 |
* @return bool|object PLL_Language object, false if no language is associated to that term
|
70 |
*/
|
71 |
public function get_language( $value, $taxonomy = '' ) {
|
82 |
return isset( $term_id ) && ( $lang = $this->get_object_term( $term_id, 'term_language' ) ) ? $this->model->get_language( $lang->term_id ) : false;
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
+
* Tells the parent class to always store a translation term
|
87 |
*
|
88 |
* @since 1.8
|
89 |
*
|
93 |
return true;
|
94 |
}
|
95 |
|
96 |
+
/**
|
97 |
+
* Deletes a translation
|
98 |
*
|
99 |
* @since 0.5
|
100 |
*
|
114 |
}
|
115 |
}
|
116 |
|
117 |
+
/**
|
118 |
+
* A join clause to add to sql queries when filtering by language is needed directly in query
|
119 |
*
|
120 |
* @since 1.2
|
121 |
*
|
126 |
return " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = t.term_id";
|
127 |
}
|
128 |
|
129 |
+
/**
|
130 |
+
* Cache language and translations when terms are queried by get_terms
|
131 |
*
|
132 |
* @since 1.2
|
133 |
*
|
134 |
+
* @param array $terms queried terms
|
135 |
* @param array $taxonomies queried taxonomies
|
136 |
* @return array unmodified $terms
|
137 |
*/
|
148 |
return $terms;
|
149 |
}
|
150 |
|
151 |
+
/**
|
152 |
+
* When terms are found for posts, add their language and translations to cache
|
153 |
*
|
154 |
* @since 1.2
|
155 |
*
|
156 |
+
* @param array $terms terms found
|
157 |
* @param array $object_ids not used
|
158 |
* @param array $taxonomies terms taxonomies
|
159 |
* @return array unmodified $terms
|
include/walker-dropdown.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* displays languages in a dropdown list
|
5 |
*
|
6 |
* @since 1.2
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_Walker_Dropdown extends Walker {
|
9 |
var $db_fields = array( 'parent' => 'parent', 'id' => 'id' );
|
10 |
|
11 |
-
|
12 |
* outputs one element
|
13 |
*
|
14 |
* @since 1.2
|
@@ -25,7 +25,7 @@ class PLL_Walker_Dropdown extends Walker {
|
|
25 |
);
|
26 |
}
|
27 |
|
28 |
-
|
29 |
* overrides Walker::display_element as expects an object with a parent property
|
30 |
*
|
31 |
* @since 1.2
|
@@ -38,7 +38,7 @@ class PLL_Walker_Dropdown extends Walker {
|
|
38 |
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
39 |
}
|
40 |
|
41 |
-
|
42 |
* starts the output of the dropdown list
|
43 |
*
|
44 |
* @since 1.2
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* displays languages in a dropdown list
|
5 |
*
|
6 |
* @since 1.2
|
8 |
class PLL_Walker_Dropdown extends Walker {
|
9 |
var $db_fields = array( 'parent' => 'parent', 'id' => 'id' );
|
10 |
|
11 |
+
/**
|
12 |
* outputs one element
|
13 |
*
|
14 |
* @since 1.2
|
25 |
);
|
26 |
}
|
27 |
|
28 |
+
/**
|
29 |
* overrides Walker::display_element as expects an object with a parent property
|
30 |
*
|
31 |
* @since 1.2
|
38 |
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
39 |
}
|
40 |
|
41 |
+
/**
|
42 |
* starts the output of the dropdown list
|
43 |
*
|
44 |
* @since 1.2
|
include/walker-list.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Walker_List extends Walker {
|
9 |
var $db_fields = array( 'parent' => 'parent', 'id' => 'id' );
|
10 |
|
11 |
-
|
12 |
-
*
|
13 |
*
|
14 |
* @since 1.2
|
15 |
*
|
@@ -17,29 +17,30 @@ class PLL_Walker_List extends Walker {
|
|
17 |
*/
|
18 |
function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) {
|
19 |
$output .= sprintf(
|
20 |
-
"\t".'<li class="%s"><a hreflang="%s" href="%s">%s</a></li>'."\n",
|
21 |
esc_attr( implode( ' ', $element->classes ) ),
|
22 |
esc_attr( $element->locale ),
|
23 |
esc_url( $element->url ),
|
24 |
-
$
|
|
|
25 |
);
|
26 |
}
|
27 |
|
28 |
-
|
29 |
-
*
|
30 |
*
|
31 |
* @since 1.2
|
32 |
*
|
33 |
* @see Walker::display_element
|
34 |
*/
|
35 |
function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
|
36 |
-
$element = (object) $element; //
|
37 |
-
$element->parent = $element->id = 0; //
|
38 |
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
39 |
}
|
40 |
|
41 |
-
|
42 |
-
*
|
43 |
*
|
44 |
* @since 1.2
|
45 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Displays a language list
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Walker_List extends Walker {
|
9 |
var $db_fields = array( 'parent' => 'parent', 'id' => 'id' );
|
10 |
|
11 |
+
/**
|
12 |
+
* Outputs one element
|
13 |
*
|
14 |
* @since 1.2
|
15 |
*
|
17 |
*/
|
18 |
function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) {
|
19 |
$output .= sprintf(
|
20 |
+
"\t".'<li class="%s"><a hreflang="%s" href="%s">%s%s</a></li>'."\n",
|
21 |
esc_attr( implode( ' ', $element->classes ) ),
|
22 |
esc_attr( $element->locale ),
|
23 |
esc_url( $element->url ),
|
24 |
+
$element->flag,
|
25 |
+
$args['show_flags'] && $args['show_names'] ? '<span style="margin-left:0.3em;">' . esc_html( $element->name ) . '</span>' : esc_html( $element->name )
|
26 |
);
|
27 |
}
|
28 |
|
29 |
+
/**
|
30 |
+
* Overrides Walker::display_element as it expects an object with a parent property
|
31 |
*
|
32 |
* @since 1.2
|
33 |
*
|
34 |
* @see Walker::display_element
|
35 |
*/
|
36 |
function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
|
37 |
+
$element = (object) $element; // Make sure we have an object
|
38 |
+
$element->parent = $element->id = 0; // Don't care about this
|
39 |
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
40 |
}
|
41 |
|
42 |
+
/**
|
43 |
+
* Overrides Walker:walk to set depth argument
|
44 |
*
|
45 |
* @since 1.2
|
46 |
*
|
include/widget-calendar.php
CHANGED
@@ -4,7 +4,7 @@ if ( ! class_exists( 'WP_Widget_Calendar' ) ) {
|
|
4 |
require_once( ABSPATH . '/wp-includes/default-widgets.php' );
|
5 |
}
|
6 |
|
7 |
-
|
8 |
* obliged to rewrite the whole functionnality as there is no filter on sql queries and only a filter on final output
|
9 |
* code base last checked with WP 4.4.2
|
10 |
* a request for making a filter on sql queries exists: http://core.trac.wordpress.org/ticket/15202
|
@@ -15,7 +15,7 @@ if ( ! class_exists( 'WP_Widget_Calendar' ) ) {
|
|
15 |
*/
|
16 |
class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
17 |
|
18 |
-
|
19 |
* displays the widget
|
20 |
* modified version of the parent function to call our own get_calendar function
|
21 |
*
|
@@ -25,6 +25,7 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
25 |
* @param array $instance The settings for the particular instance of the widget
|
26 |
*/
|
27 |
function widget( $args, $instance ) {
|
|
|
28 |
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? ' ' : $instance['title'], $instance, $this->id_base );
|
29 |
echo $args['before_widget'];
|
30 |
if ( $title ) {
|
@@ -36,7 +37,7 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
36 |
echo $args['after_widget'];
|
37 |
}
|
38 |
|
39 |
-
|
40 |
* modified version of WP get_calendar function to filter the query
|
41 |
*
|
42 |
* @since 0.5
|
4 |
require_once( ABSPATH . '/wp-includes/default-widgets.php' );
|
5 |
}
|
6 |
|
7 |
+
/**
|
8 |
* obliged to rewrite the whole functionnality as there is no filter on sql queries and only a filter on final output
|
9 |
* code base last checked with WP 4.4.2
|
10 |
* a request for making a filter on sql queries exists: http://core.trac.wordpress.org/ticket/15202
|
15 |
*/
|
16 |
class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
17 |
|
18 |
+
/**
|
19 |
* displays the widget
|
20 |
* modified version of the parent function to call our own get_calendar function
|
21 |
*
|
25 |
* @param array $instance The settings for the particular instance of the widget
|
26 |
*/
|
27 |
function widget( $args, $instance ) {
|
28 |
+
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
29 |
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? ' ' : $instance['title'], $instance, $this->id_base );
|
30 |
echo $args['before_widget'];
|
31 |
if ( $title ) {
|
37 |
echo $args['after_widget'];
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
* modified version of WP get_calendar function to filter the query
|
42 |
*
|
43 |
* @since 0.5
|
include/widget-languages.php
CHANGED
@@ -1,35 +1,43 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*
|
6 |
* @since 0.1
|
7 |
*/
|
8 |
class PLL_Widget_Languages extends WP_Widget {
|
9 |
|
10 |
-
|
11 |
-
*
|
12 |
*
|
13 |
* @since 0.1
|
14 |
*/
|
15 |
function __construct() {
|
16 |
-
parent::__construct(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
}
|
18 |
|
19 |
-
|
20 |
-
*
|
21 |
*
|
22 |
* @since 0.1
|
23 |
*
|
24 |
-
* @param array $args
|
25 |
* @param array $instance The settings for the particular instance of the widget
|
26 |
*/
|
27 |
function widget( $args, $instance ) {
|
28 |
-
//
|
29 |
$instance['dropdown'] = empty( $instance['dropdown'] ) ? 0 : $args['widget_id'];
|
30 |
|
31 |
if ( $list = pll_the_languages( array_merge( $instance, array( 'echo' => 0 ) ) ) ) {
|
32 |
$title = empty( $instance['title'] ) ? '' : $instance['title'];
|
|
|
33 |
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
34 |
|
35 |
echo $args['before_widget'];
|
@@ -41,8 +49,8 @@ class PLL_Widget_Languages extends WP_Widget {
|
|
41 |
}
|
42 |
}
|
43 |
|
44 |
-
|
45 |
-
*
|
46 |
*
|
47 |
* @since 0.4
|
48 |
*
|
@@ -59,19 +67,19 @@ class PLL_Widget_Languages extends WP_Widget {
|
|
59 |
return $instance;
|
60 |
}
|
61 |
|
62 |
-
|
63 |
-
*
|
64 |
*
|
65 |
* @since 0.4
|
66 |
*
|
67 |
* @param array $instance Current settings
|
68 |
*/
|
69 |
function form( $instance ) {
|
70 |
-
//
|
71 |
$instance = wp_parse_args( (array) $instance, array_merge( array( 'title' => '' ), PLL_Switcher::get_switcher_options( 'widget', 'default' ) ) );
|
72 |
|
73 |
-
//
|
74 |
-
|
75 |
'<p><label for="%1$s">%2$s</label><input class="widefat" id="%1$s" name="%3$s" type="text" value="%4$s" /></p>',
|
76 |
$this->get_field_id( 'title' ),
|
77 |
__( 'Title:', 'polylang' ),
|
@@ -82,17 +90,18 @@ class PLL_Widget_Languages extends WP_Widget {
|
|
82 |
$fields = '';
|
83 |
foreach ( PLL_Switcher::get_switcher_options( 'widget' ) as $key => $str ) {
|
84 |
$fields .= sprintf(
|
85 |
-
'<div
|
86 |
$this->get_field_id( $key ),
|
87 |
$this->get_field_name( $key ),
|
88 |
-
$instance[ $key ] ? 'checked="checked"' : '',
|
89 |
esc_html( $str ),
|
90 |
-
in_array( $key, array( 'show_names', 'show_flags', 'hide_current' ) ) ? 'no-dropdown-' . $this->id : '',
|
91 |
-
! empty( $instance['dropdown'] ) && in_array( $key, array( 'show_names', 'show_flags', 'hide_current' ) ) ? 'style="display:none;"' : ''
|
|
|
92 |
);
|
93 |
}
|
94 |
|
95 |
-
echo $
|
96 |
|
97 |
// FIXME echoing script in form is not very clean
|
98 |
// but it does not work if enqueued properly :
|
@@ -100,49 +109,44 @@ class PLL_Widget_Languages extends WP_Widget {
|
|
100 |
$this->admin_print_script();
|
101 |
}
|
102 |
|
103 |
-
|
104 |
-
*
|
105 |
*
|
106 |
* @since 1.3
|
107 |
*/
|
108 |
public function admin_print_script() {
|
109 |
-
static $
|
110 |
|
111 |
-
if ( $
|
112 |
return;
|
113 |
}
|
114 |
|
115 |
-
$
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
$( '#widget-'+this_id+'-dropdown' ).change( function() {
|
129 |
-
pll_toggle( $( '.no-dropdown-'+this_id ), 'checked' != $( this ).attr( 'checked' ) );
|
130 |
-
} );
|
131 |
-
|
132 |
-
// disallow unchecking both show names and show flags
|
133 |
-
var options = ['-show_flags', '-show_names'];
|
134 |
-
$.each( options, function( i, v ) {
|
135 |
-
$( '#widget-'+this_id+v ).change( function() {
|
136 |
-
if ( 'checked' != $( this ).attr( 'checked' ) )
|
137 |
-
$( '#widget-'+this_id+options[1-i] ).prop( 'checked', true );
|
138 |
-
} );
|
139 |
-
} );
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
} );
|
142 |
} );
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
echo $js;
|
147 |
}
|
148 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* The language switcher widget
|
5 |
*
|
6 |
* @since 0.1
|
7 |
*/
|
8 |
class PLL_Widget_Languages extends WP_Widget {
|
9 |
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
*
|
13 |
* @since 0.1
|
14 |
*/
|
15 |
function __construct() {
|
16 |
+
parent::__construct(
|
17 |
+
'polylang',
|
18 |
+
__( 'Language Switcher', 'polylang' ),
|
19 |
+
array(
|
20 |
+
'description' => __( 'Displays a language switcher', 'polylang' ),
|
21 |
+
'customize_selective_refresh' => true,
|
22 |
+
)
|
23 |
+
);
|
24 |
}
|
25 |
|
26 |
+
/**
|
27 |
+
* Displays the widget
|
28 |
*
|
29 |
* @since 0.1
|
30 |
*
|
31 |
+
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
32 |
* @param array $instance The settings for the particular instance of the widget
|
33 |
*/
|
34 |
function widget( $args, $instance ) {
|
35 |
+
// Sets a unique id for dropdown
|
36 |
$instance['dropdown'] = empty( $instance['dropdown'] ) ? 0 : $args['widget_id'];
|
37 |
|
38 |
if ( $list = pll_the_languages( array_merge( $instance, array( 'echo' => 0 ) ) ) ) {
|
39 |
$title = empty( $instance['title'] ) ? '' : $instance['title'];
|
40 |
+
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
41 |
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
42 |
|
43 |
echo $args['before_widget'];
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
/**
|
53 |
+
* Updates the widget options
|
54 |
*
|
55 |
* @since 0.4
|
56 |
*
|
67 |
return $instance;
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
+
* Displays the widget form
|
72 |
*
|
73 |
* @since 0.4
|
74 |
*
|
75 |
* @param array $instance Current settings
|
76 |
*/
|
77 |
function form( $instance ) {
|
78 |
+
// Default values
|
79 |
$instance = wp_parse_args( (array) $instance, array_merge( array( 'title' => '' ), PLL_Switcher::get_switcher_options( 'widget', 'default' ) ) );
|
80 |
|
81 |
+
// Title
|
82 |
+
printf(
|
83 |
'<p><label for="%1$s">%2$s</label><input class="widefat" id="%1$s" name="%3$s" type="text" value="%4$s" /></p>',
|
84 |
$this->get_field_id( 'title' ),
|
85 |
__( 'Title:', 'polylang' ),
|
90 |
$fields = '';
|
91 |
foreach ( PLL_Switcher::get_switcher_options( 'widget' ) as $key => $str ) {
|
92 |
$fields .= sprintf(
|
93 |
+
'<div%5$s%6$s><input type="checkbox" class="checkbox %7$s" id="%1$s" name="%2$s"%3$s /><label for="%1$s">%4$s</label></div>',
|
94 |
$this->get_field_id( $key ),
|
95 |
$this->get_field_name( $key ),
|
96 |
+
$instance[ $key ] ? ' checked="checked"' : '',
|
97 |
esc_html( $str ),
|
98 |
+
in_array( $key, array( 'show_names', 'show_flags', 'hide_current' ) ) ? ' class="no-dropdown-' . $this->id . '"' : '',
|
99 |
+
! empty( $instance['dropdown'] ) && in_array( $key, array( 'show_names', 'show_flags', 'hide_current' ) ) ? ' style="display:none;"' : '',
|
100 |
+
'pll-' . $key
|
101 |
);
|
102 |
}
|
103 |
|
104 |
+
echo $fields;
|
105 |
|
106 |
// FIXME echoing script in form is not very clean
|
107 |
// but it does not work if enqueued properly :
|
109 |
$this->admin_print_script();
|
110 |
}
|
111 |
|
112 |
+
/**
|
113 |
+
* Add javascript to control the language switcher options
|
114 |
*
|
115 |
* @since 1.3
|
116 |
*/
|
117 |
public function admin_print_script() {
|
118 |
+
static $done = false;
|
119 |
|
120 |
+
if ( $done ) {
|
121 |
return;
|
122 |
}
|
123 |
|
124 |
+
$done = true; ?>
|
125 |
+
<script type='text/javascript'>
|
126 |
+
//<![CDATA[
|
127 |
+
jQuery( document ).ready( function( $ ) {
|
128 |
+
function pll_toggle( a, test ) {
|
129 |
+
test ? a.show() : a.hide();
|
130 |
+
}
|
131 |
+
|
132 |
+
// Remove all options if dropdown is checked
|
133 |
+
$( '.widgets-sortables,.control-section-sidebar' ).on( 'change', '.pll-dropdown', function() {
|
134 |
+
var this_id = $( this ).parent().parent().parent().children( '.widget-id' ).attr( 'value' );
|
135 |
+
pll_toggle( $( '.no-dropdown-' + this_id ), 'checked' != $( this ).attr( 'checked' ) );
|
136 |
+
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
+
// Disallow unchecking both show names and show flags
|
139 |
+
var options = ['-show_flags', '-show_names'];
|
140 |
+
$.each( options, function( i, v ) {
|
141 |
+
$( '.widgets-sortables,.control-section-sidebar' ).on( 'change', '.pll' + v, function() {
|
142 |
+
var this_id = $( this ).parent().parent().parent().children( '.widget-id' ).attr( 'value' );
|
143 |
+
if ( 'checked' != $( this ).attr( 'checked' ) ) {
|
144 |
+
$( '#widget-' + this_id + options[ 1-i ] ).prop( 'checked', true );
|
145 |
+
}
|
146 |
} );
|
147 |
} );
|
148 |
+
} );
|
149 |
+
//]]>
|
150 |
+
</script><?php
|
|
|
151 |
}
|
152 |
}
|
install/install-base.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* a generic activation / de-activation class compatble with multisite
|
5 |
*
|
6 |
* @since 1.7
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_Install_Base {
|
9 |
protected $plugin_basename;
|
10 |
|
11 |
-
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.7
|
@@ -24,7 +24,7 @@ class PLL_Install_Base {
|
|
24 |
add_action( 'wpmu_new_blog', array( &$this, 'wpmu_new_blog' ), 5 ); // before WP attempts to send mails which can break on some PHP versions
|
25 |
}
|
26 |
|
27 |
-
|
28 |
* allows to detect plugin deactivation
|
29 |
*
|
30 |
* @since 1.7
|
@@ -35,7 +35,7 @@ class PLL_Install_Base {
|
|
35 |
return isset( $_GET['action'], $_GET['plugin'] ) && 'deactivate' == $_GET['action'] && $this->plugin_basename == $_GET['plugin'];
|
36 |
}
|
37 |
|
38 |
-
|
39 |
* activation or deactivation for all blogs
|
40 |
*
|
41 |
* @since 1.2
|
@@ -60,7 +60,7 @@ class PLL_Install_Base {
|
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
|
64 |
* plugin activation for multisite
|
65 |
*
|
66 |
* @since 1.7
|
@@ -69,7 +69,7 @@ class PLL_Install_Base {
|
|
69 |
$this->do_for_all_blogs( 'activate', $networkwide );
|
70 |
}
|
71 |
|
72 |
-
|
73 |
* plugin activation
|
74 |
*
|
75 |
* @since 0.5
|
@@ -78,7 +78,7 @@ class PLL_Install_Base {
|
|
78 |
// can be overriden in child class
|
79 |
}
|
80 |
|
81 |
-
|
82 |
* plugin deactivation for multisite
|
83 |
*
|
84 |
* @since 0.1
|
@@ -87,7 +87,7 @@ class PLL_Install_Base {
|
|
87 |
$this->do_for_all_blogs( 'deactivate', $networkwide );
|
88 |
}
|
89 |
|
90 |
-
|
91 |
* plugin deactivation
|
92 |
*
|
93 |
* @since 0.5
|
@@ -96,7 +96,7 @@ class PLL_Install_Base {
|
|
96 |
// can be overriden in child class
|
97 |
}
|
98 |
|
99 |
-
|
100 |
* blog creation on multisite ( to set default options )
|
101 |
*
|
102 |
* @since 0.9.4
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* a generic activation / de-activation class compatble with multisite
|
5 |
*
|
6 |
* @since 1.7
|
8 |
class PLL_Install_Base {
|
9 |
protected $plugin_basename;
|
10 |
|
11 |
+
/**
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.7
|
24 |
add_action( 'wpmu_new_blog', array( &$this, 'wpmu_new_blog' ), 5 ); // before WP attempts to send mails which can break on some PHP versions
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
* allows to detect plugin deactivation
|
29 |
*
|
30 |
* @since 1.7
|
35 |
return isset( $_GET['action'], $_GET['plugin'] ) && 'deactivate' == $_GET['action'] && $this->plugin_basename == $_GET['plugin'];
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
* activation or deactivation for all blogs
|
40 |
*
|
41 |
* @since 1.2
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
/**
|
64 |
* plugin activation for multisite
|
65 |
*
|
66 |
* @since 1.7
|
69 |
$this->do_for_all_blogs( 'activate', $networkwide );
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
* plugin activation
|
74 |
*
|
75 |
* @since 0.5
|
78 |
// can be overriden in child class
|
79 |
}
|
80 |
|
81 |
+
/**
|
82 |
* plugin deactivation for multisite
|
83 |
*
|
84 |
* @since 0.1
|
87 |
$this->do_for_all_blogs( 'deactivate', $networkwide );
|
88 |
}
|
89 |
|
90 |
+
/**
|
91 |
* plugin deactivation
|
92 |
*
|
93 |
* @since 0.5
|
96 |
// can be overriden in child class
|
97 |
}
|
98 |
|
99 |
+
/**
|
100 |
* blog creation on multisite ( to set default options )
|
101 |
*
|
102 |
* @since 0.9.4
|
install/install.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* Polylang activation / de-activation class
|
5 |
*
|
6 |
* @since 1.7
|
7 |
*/
|
8 |
class PLL_Install extends PLL_Install_Base {
|
9 |
|
10 |
-
|
11 |
* plugin activation for multisite
|
12 |
*
|
13 |
* @since 0.1
|
@@ -31,7 +31,7 @@ class PLL_Install extends PLL_Install_Base {
|
|
31 |
$this->do_for_all_blogs( 'activate', $networkwide );
|
32 |
}
|
33 |
|
34 |
-
|
35 |
* get default Polylang options
|
36 |
*
|
37 |
* @since 1.8
|
@@ -55,7 +55,7 @@ class PLL_Install extends PLL_Install_Base {
|
|
55 |
);
|
56 |
}
|
57 |
|
58 |
-
|
59 |
* plugin activation
|
60 |
*
|
61 |
* @since 0.5
|
@@ -84,7 +84,7 @@ class PLL_Install extends PLL_Install_Base {
|
|
84 |
delete_option( 'rewrite_rules' );
|
85 |
}
|
86 |
|
87 |
-
|
88 |
* plugin deactivation
|
89 |
*
|
90 |
* @since 0.5
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* Polylang activation / de-activation class
|
5 |
*
|
6 |
* @since 1.7
|
7 |
*/
|
8 |
class PLL_Install extends PLL_Install_Base {
|
9 |
|
10 |
+
/**
|
11 |
* plugin activation for multisite
|
12 |
*
|
13 |
* @since 0.1
|
31 |
$this->do_for_all_blogs( 'activate', $networkwide );
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
* get default Polylang options
|
36 |
*
|
37 |
* @since 1.8
|
55 |
);
|
56 |
}
|
57 |
|
58 |
+
/**
|
59 |
* plugin activation
|
60 |
*
|
61 |
* @since 0.5
|
84 |
delete_option( 'rewrite_rules' );
|
85 |
}
|
86 |
|
87 |
+
/**
|
88 |
* plugin deactivation
|
89 |
*
|
90 |
* @since 0.5
|
install/plugin-updater.php
ADDED
@@ -0,0 +1,383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// uncomment this line for testing
|
4 |
+
//set_site_transient( 'update_plugins', null );
|
5 |
+
|
6 |
+
// Exit if accessed directly
|
7 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
+
exit;
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Allows plugins to use their own update API.
|
13 |
+
* Modified version with 'polylang' text domain and comments for translators
|
14 |
+
*
|
15 |
+
* @author Pippin Williamson
|
16 |
+
* @version 1.6.3
|
17 |
+
*/
|
18 |
+
class PLL_Plugin_Updater {
|
19 |
+
private $api_url = '';
|
20 |
+
private $api_data = array();
|
21 |
+
private $name = '';
|
22 |
+
private $slug = '';
|
23 |
+
private $version = '';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Class constructor.
|
27 |
+
*
|
28 |
+
* @uses plugin_basename()
|
29 |
+
* @uses hook()
|
30 |
+
*
|
31 |
+
* @param string $_api_url The URL pointing to the custom API endpoint.
|
32 |
+
* @param string $_plugin_file Path to the plugin file.
|
33 |
+
* @param array $_api_data Optional data to send with API calls.
|
34 |
+
*/
|
35 |
+
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
|
36 |
+
|
37 |
+
global $edd_plugin_data;
|
38 |
+
|
39 |
+
$this->api_url = trailingslashit( $_api_url );
|
40 |
+
$this->api_data = $_api_data;
|
41 |
+
$this->name = plugin_basename( $_plugin_file );
|
42 |
+
$this->slug = basename( $_plugin_file, '.php' );
|
43 |
+
$this->version = $_api_data['version'];
|
44 |
+
|
45 |
+
$edd_plugin_data[ $this->slug ] = $this->api_data;
|
46 |
+
|
47 |
+
// Set up hooks.
|
48 |
+
$this->init();
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Set up WordPress filters to hook into WP's update process.
|
54 |
+
*
|
55 |
+
* @uses add_filter()
|
56 |
+
*
|
57 |
+
* @return void
|
58 |
+
*/
|
59 |
+
public function init() {
|
60 |
+
|
61 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
62 |
+
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
|
63 |
+
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10, 2 );
|
64 |
+
add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
|
65 |
+
add_action( 'admin_init', array( $this, 'show_changelog' ) );
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Check for Updates at the defined API endpoint and modify the update array.
|
71 |
+
*
|
72 |
+
* This function dives into the update API just when WordPress creates its update array,
|
73 |
+
* then adds a custom API call and injects the custom plugin data retrieved from the API.
|
74 |
+
* It is reassembled from parts of the native WordPress plugin update code.
|
75 |
+
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
|
76 |
+
*
|
77 |
+
* @uses api_request()
|
78 |
+
*
|
79 |
+
* @param array $_transient_data Update array build by WordPress.
|
80 |
+
* @return array Modified update array with custom plugin data.
|
81 |
+
*/
|
82 |
+
public function check_update( $_transient_data ) {
|
83 |
+
|
84 |
+
global $pagenow;
|
85 |
+
|
86 |
+
if ( ! is_object( $_transient_data ) ) {
|
87 |
+
$_transient_data = new stdClass;
|
88 |
+
}
|
89 |
+
|
90 |
+
if ( 'plugins.php' == $pagenow && is_multisite() ) {
|
91 |
+
return $_transient_data;
|
92 |
+
}
|
93 |
+
|
94 |
+
if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
|
95 |
+
|
96 |
+
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
|
97 |
+
|
98 |
+
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
|
99 |
+
|
100 |
+
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
101 |
+
|
102 |
+
$_transient_data->response[ $this->name ] = $version_info;
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
$_transient_data->last_checked = time();
|
107 |
+
$_transient_data->checked[ $this->name ] = $this->version;
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
return $_transient_data;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
118 |
+
*
|
119 |
+
* @param string $file
|
120 |
+
* @param array $plugin
|
121 |
+
*/
|
122 |
+
public function show_update_notification( $file, $plugin ) {
|
123 |
+
|
124 |
+
if ( ! current_user_can( 'update_plugins' ) ) {
|
125 |
+
return;
|
126 |
+
}
|
127 |
+
|
128 |
+
if ( ! is_multisite() ) {
|
129 |
+
return;
|
130 |
+
}
|
131 |
+
|
132 |
+
if ( $this->name != $file ) {
|
133 |
+
return;
|
134 |
+
}
|
135 |
+
|
136 |
+
// Remove our filter on the site transient
|
137 |
+
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
|
138 |
+
|
139 |
+
$update_cache = get_site_transient( 'update_plugins' );
|
140 |
+
|
141 |
+
$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
|
142 |
+
|
143 |
+
if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
|
144 |
+
|
145 |
+
$cache_key = md5( 'edd_plugin_' . sanitize_key( $this->name ) . '_version_info' );
|
146 |
+
$version_info = get_transient( $cache_key );
|
147 |
+
|
148 |
+
if ( false === $version_info ) {
|
149 |
+
|
150 |
+
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
|
151 |
+
|
152 |
+
set_transient( $cache_key, $version_info, 3600 );
|
153 |
+
}
|
154 |
+
|
155 |
+
if ( ! is_object( $version_info ) ) {
|
156 |
+
return;
|
157 |
+
}
|
158 |
+
|
159 |
+
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
160 |
+
|
161 |
+
$update_cache->response[ $this->name ] = $version_info;
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
$update_cache->last_checked = time();
|
166 |
+
$update_cache->checked[ $this->name ] = $this->version;
|
167 |
+
|
168 |
+
set_site_transient( 'update_plugins', $update_cache );
|
169 |
+
|
170 |
+
} else {
|
171 |
+
|
172 |
+
$version_info = $update_cache->response[ $this->name ];
|
173 |
+
|
174 |
+
}
|
175 |
+
|
176 |
+
// Restore our filter
|
177 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
178 |
+
|
179 |
+
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
180 |
+
|
181 |
+
// build a plugin list row, with update notification
|
182 |
+
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
|
183 |
+
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
|
184 |
+
|
185 |
+
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
|
186 |
+
|
187 |
+
if ( empty( $version_info->download_link ) ) {
|
188 |
+
printf(
|
189 |
+
/* translators: %1$s plugin name, %3$s plugin version, %2$s and %4$s are html tags */
|
190 |
+
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'polylang' ),
|
191 |
+
esc_html( $version_info->name ),
|
192 |
+
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
193 |
+
esc_html( $version_info->new_version ),
|
194 |
+
'</a>'
|
195 |
+
);
|
196 |
+
} else {
|
197 |
+
printf(
|
198 |
+
/* translators: %1$s plugin name, %3$s plugin version, %2$s, %4$s, %5$s and %6$s are html tags */
|
199 |
+
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'polylang' ),
|
200 |
+
esc_html( $version_info->name ),
|
201 |
+
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
202 |
+
esc_html( $version_info->new_version ),
|
203 |
+
'</a>',
|
204 |
+
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
|
205 |
+
'</a>'
|
206 |
+
);
|
207 |
+
}
|
208 |
+
|
209 |
+
do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
|
210 |
+
|
211 |
+
echo '</div></td></tr>';
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Updates information on the "View version x.x details" page with custom data.
|
218 |
+
*
|
219 |
+
* @uses api_request()
|
220 |
+
*
|
221 |
+
* @param mixed $_data
|
222 |
+
* @param string $_action
|
223 |
+
* @param object $_args
|
224 |
+
* @return object $_data
|
225 |
+
*/
|
226 |
+
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
|
227 |
+
|
228 |
+
|
229 |
+
if ( $_action != 'plugin_information' ) {
|
230 |
+
|
231 |
+
return $_data;
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
|
236 |
+
|
237 |
+
return $_data;
|
238 |
+
|
239 |
+
}
|
240 |
+
|
241 |
+
$to_send = array(
|
242 |
+
'slug' => $this->slug,
|
243 |
+
'is_ssl' => is_ssl(),
|
244 |
+
'fields' => array(
|
245 |
+
'banners' => false, // These will be supported soon hopefully
|
246 |
+
'reviews' => false
|
247 |
+
)
|
248 |
+
);
|
249 |
+
|
250 |
+
$api_response = $this->api_request( 'plugin_information', $to_send );
|
251 |
+
|
252 |
+
if ( false !== $api_response ) {
|
253 |
+
$_data = $api_response;
|
254 |
+
}
|
255 |
+
|
256 |
+
return $_data;
|
257 |
+
}
|
258 |
+
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Disable SSL verification in order to prevent download update failures
|
262 |
+
*
|
263 |
+
* @param array $args
|
264 |
+
* @param string $url
|
265 |
+
* @return object $array
|
266 |
+
*/
|
267 |
+
public function http_request_args( $args, $url ) {
|
268 |
+
// If it is an https request and we are performing a package download, disable ssl verification
|
269 |
+
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
|
270 |
+
$args['sslverify'] = false;
|
271 |
+
}
|
272 |
+
return $args;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Calls the API and, if successfull, returns the object delivered by the API.
|
277 |
+
*
|
278 |
+
* @uses get_bloginfo()
|
279 |
+
* @uses wp_remote_post()
|
280 |
+
* @uses is_wp_error()
|
281 |
+
*
|
282 |
+
* @param string $_action The requested action.
|
283 |
+
* @param array $_data Parameters for the API action.
|
284 |
+
* @return false|object
|
285 |
+
*/
|
286 |
+
private function api_request( $_action, $_data ) {
|
287 |
+
|
288 |
+
global $wp_version;
|
289 |
+
|
290 |
+
$data = array_merge( $this->api_data, $_data );
|
291 |
+
|
292 |
+
if ( $data['slug'] != $this->slug ) {
|
293 |
+
return;
|
294 |
+
}
|
295 |
+
|
296 |
+
if ( $this->api_url == home_url() ) {
|
297 |
+
return false; // Don't allow a plugin to ping itself
|
298 |
+
}
|
299 |
+
|
300 |
+
$api_params = array(
|
301 |
+
'edd_action' => 'get_version',
|
302 |
+
'license' => ! empty( $data['license'] ) ? $data['license'] : '',
|
303 |
+
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
304 |
+
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
305 |
+
'slug' => $data['slug'],
|
306 |
+
'author' => $data['author'],
|
307 |
+
'url' => home_url()
|
308 |
+
);
|
309 |
+
|
310 |
+
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
|
311 |
+
|
312 |
+
if ( ! is_wp_error( $request ) ) {
|
313 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( $request && isset( $request->sections ) ) {
|
317 |
+
$request->sections = maybe_unserialize( $request->sections );
|
318 |
+
} else {
|
319 |
+
$request = false;
|
320 |
+
}
|
321 |
+
|
322 |
+
return $request;
|
323 |
+
}
|
324 |
+
|
325 |
+
public function show_changelog() {
|
326 |
+
|
327 |
+
global $edd_plugin_data;
|
328 |
+
|
329 |
+
if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
|
330 |
+
return;
|
331 |
+
}
|
332 |
+
|
333 |
+
if ( empty( $_REQUEST['plugin'] ) ) {
|
334 |
+
return;
|
335 |
+
}
|
336 |
+
|
337 |
+
if ( empty( $_REQUEST['slug'] ) ) {
|
338 |
+
return;
|
339 |
+
}
|
340 |
+
|
341 |
+
if ( ! current_user_can( 'update_plugins' ) ) {
|
342 |
+
wp_die( __( 'You do not have permission to install plugin updates', 'polylang' ), __( 'Error', 'polylang' ), array( 'response' => 403 ) );
|
343 |
+
}
|
344 |
+
|
345 |
+
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
|
346 |
+
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' );
|
347 |
+
$version_info = get_transient( $cache_key );
|
348 |
+
|
349 |
+
if ( false === $version_info ) {
|
350 |
+
|
351 |
+
$api_params = array(
|
352 |
+
'edd_action' => 'get_version',
|
353 |
+
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
354 |
+
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
355 |
+
'slug' => $_REQUEST['slug'],
|
356 |
+
'author' => $data['author'],
|
357 |
+
'url' => home_url()
|
358 |
+
);
|
359 |
+
|
360 |
+
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
|
361 |
+
|
362 |
+
if ( ! is_wp_error( $request ) ) {
|
363 |
+
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
|
364 |
+
}
|
365 |
+
|
366 |
+
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
|
367 |
+
$version_info->sections = maybe_unserialize( $version_info->sections );
|
368 |
+
} else {
|
369 |
+
$version_info = false;
|
370 |
+
}
|
371 |
+
|
372 |
+
set_transient( $cache_key, $version_info, 3600 );
|
373 |
+
|
374 |
+
}
|
375 |
+
|
376 |
+
if ( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
|
377 |
+
echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
|
378 |
+
}
|
379 |
+
|
380 |
+
exit;
|
381 |
+
}
|
382 |
+
|
383 |
+
}
|
install/upgrade.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages Polylang upgrades
|
5 |
*
|
6 |
* @since 1.2
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_Upgrade {
|
9 |
public $options;
|
10 |
|
11 |
-
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.2
|
@@ -17,7 +17,7 @@ class PLL_Upgrade {
|
|
17 |
$this->options = &$options;
|
18 |
}
|
19 |
|
20 |
-
|
21 |
* check if upgrade is possible otherwise die to avoid activation
|
22 |
*
|
23 |
* @since 1.2
|
@@ -30,7 +30,7 @@ class PLL_Upgrade {
|
|
30 |
}
|
31 |
}
|
32 |
|
33 |
-
|
34 |
* upgrades if possible otherwise returns false to stop Polylang loading
|
35 |
*
|
36 |
* @since 1.2
|
@@ -48,7 +48,7 @@ class PLL_Upgrade {
|
|
48 |
}
|
49 |
|
50 |
|
51 |
-
|
52 |
* check if we the previous version is not too old
|
53 |
* upgrades if OK
|
54 |
* /!\ never start any upgrade before admin_init as it is likely to conflict with some other plugins
|
@@ -62,7 +62,7 @@ class PLL_Upgrade {
|
|
62 |
return version_compare( $this->options['version'], '0.8', '>=' );
|
63 |
}
|
64 |
|
65 |
-
|
66 |
* displays a notice when ugrading from a too old version
|
67 |
*
|
68 |
* @since 1.0
|
@@ -81,7 +81,7 @@ class PLL_Upgrade {
|
|
81 |
);
|
82 |
}
|
83 |
|
84 |
-
|
85 |
* upgrades the plugin depending on the previous version
|
86 |
*
|
87 |
* @since 1.2
|
@@ -103,7 +103,7 @@ class PLL_Upgrade {
|
|
103 |
update_option( 'polylang', $this->options );
|
104 |
}
|
105 |
|
106 |
-
|
107 |
* upgrades if the previous version is < 0.9
|
108 |
*
|
109 |
* @since 1.2
|
@@ -112,7 +112,7 @@ class PLL_Upgrade {
|
|
112 |
$this->options['sync'] = defined( 'PLL_SYNC' ) && ! PLL_SYNC ? 0 : 1; // the option replaces PLL_SYNC in 0.9
|
113 |
}
|
114 |
|
115 |
-
|
116 |
* upgrades if the previous version is < 1.0
|
117 |
*
|
118 |
* @since 1.2
|
@@ -132,7 +132,7 @@ class PLL_Upgrade {
|
|
132 |
flush_rewrite_rules(); // rewrite rules have been modified in 1.0
|
133 |
}
|
134 |
|
135 |
-
|
136 |
* upgrades if the previous version is < 1.1
|
137 |
*
|
138 |
* @since 1.2
|
@@ -154,7 +154,7 @@ class PLL_Upgrade {
|
|
154 |
}
|
155 |
}
|
156 |
|
157 |
-
|
158 |
* upgrades if the previous version is < 1.2
|
159 |
*
|
160 |
* @since 1.2
|
@@ -270,7 +270,7 @@ class PLL_Upgrade {
|
|
270 |
// upgrade of nav menus is now in upgrade_1_2_3
|
271 |
}
|
272 |
|
273 |
-
|
274 |
* upgrades if the previous version is < 1.2.1
|
275 |
*
|
276 |
* @since 1.2.1
|
@@ -288,7 +288,7 @@ class PLL_Upgrade {
|
|
288 |
}
|
289 |
}
|
290 |
|
291 |
-
|
292 |
* upgrades if the previous version is < 1.2.3
|
293 |
* uprades multilingual menus depending on the old version due to multiple changes in menus management
|
294 |
*
|
@@ -365,7 +365,7 @@ class PLL_Upgrade {
|
|
365 |
}
|
366 |
}
|
367 |
|
368 |
-
|
369 |
* upgrades if the previous version is < 1.3
|
370 |
* moves the user biographies in default language to the 'description' user meta
|
371 |
*
|
@@ -384,7 +384,7 @@ class PLL_Upgrade {
|
|
384 |
}
|
385 |
}
|
386 |
|
387 |
-
|
388 |
* upgrades if the previous version is < 1.4
|
389 |
* sets a transient to delete old model data
|
390 |
* deletes language cache (due to bug correction in home urls in 1.3.1 and added mo_id in 1.4)
|
@@ -396,7 +396,7 @@ class PLL_Upgrade {
|
|
396 |
delete_transient( 'pll_languages_list' );
|
397 |
}
|
398 |
|
399 |
-
|
400 |
* old data were not deleted in 1.2, just in case...
|
401 |
* delete them at first upgrade at least 60 days after upgrade to 1.4
|
402 |
*
|
@@ -424,7 +424,7 @@ class PLL_Upgrade {
|
|
424 |
delete_transient( 'pll_upgrade_1_4' );
|
425 |
}
|
426 |
|
427 |
-
|
428 |
* upgrades if the previous version is < 1.4.1
|
429 |
* disables the browser detection when using multiple domains
|
430 |
*
|
@@ -436,7 +436,7 @@ class PLL_Upgrade {
|
|
436 |
}
|
437 |
}
|
438 |
|
439 |
-
|
440 |
* upgrades if the previous version is < 1.4.4
|
441 |
* uprades widgets options for language filter
|
442 |
*
|
@@ -456,7 +456,7 @@ class PLL_Upgrade {
|
|
456 |
unset( $this->options['widgets'] );
|
457 |
}
|
458 |
|
459 |
-
|
460 |
* upgrades if the previous version is < 1.5
|
461 |
* deletes language cache (due to host property added and bug on search url)
|
462 |
*
|
@@ -466,7 +466,7 @@ class PLL_Upgrade {
|
|
466 |
delete_transient( 'pll_languages_list' );
|
467 |
}
|
468 |
|
469 |
-
|
470 |
* upgrades if the previous version is < 1.6
|
471 |
* upgrades core language files to get the .po file (only for WP 4.0+)
|
472 |
*
|
@@ -478,7 +478,7 @@ class PLL_Upgrade {
|
|
478 |
}
|
479 |
}
|
480 |
|
481 |
-
|
482 |
* downloads language packs
|
483 |
* intended to be used only one time (at upgrade to Polylang 1.6 or first upgrade of WP 4.0 or later)
|
484 |
* adapted from wp_download_language_pack
|
@@ -520,7 +520,7 @@ class PLL_Upgrade {
|
|
520 |
}
|
521 |
}
|
522 |
|
523 |
-
|
524 |
* upgrades if the previous version is < 1.7.4
|
525 |
*
|
526 |
* @since 1.7.4
|
@@ -530,7 +530,7 @@ class PLL_Upgrade {
|
|
530 |
flush_rewrite_rules(); // flush rewrite rules due to custom taxonomy rewrite rule bug fix
|
531 |
}
|
532 |
|
533 |
-
|
534 |
* upgrades if the previous version is < 1.8
|
535 |
*
|
536 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages Polylang upgrades
|
5 |
*
|
6 |
* @since 1.2
|
8 |
class PLL_Upgrade {
|
9 |
public $options;
|
10 |
|
11 |
+
/**
|
12 |
* constructor
|
13 |
*
|
14 |
* @since 1.2
|
17 |
$this->options = &$options;
|
18 |
}
|
19 |
|
20 |
+
/**
|
21 |
* check if upgrade is possible otherwise die to avoid activation
|
22 |
*
|
23 |
* @since 1.2
|
30 |
}
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
* upgrades if possible otherwise returns false to stop Polylang loading
|
35 |
*
|
36 |
* @since 1.2
|
48 |
}
|
49 |
|
50 |
|
51 |
+
/**
|
52 |
* check if we the previous version is not too old
|
53 |
* upgrades if OK
|
54 |
* /!\ never start any upgrade before admin_init as it is likely to conflict with some other plugins
|
62 |
return version_compare( $this->options['version'], '0.8', '>=' );
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
* displays a notice when ugrading from a too old version
|
67 |
*
|
68 |
* @since 1.0
|
81 |
);
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
* upgrades the plugin depending on the previous version
|
86 |
*
|
87 |
* @since 1.2
|
103 |
update_option( 'polylang', $this->options );
|
104 |
}
|
105 |
|
106 |
+
/**
|
107 |
* upgrades if the previous version is < 0.9
|
108 |
*
|
109 |
* @since 1.2
|
112 |
$this->options['sync'] = defined( 'PLL_SYNC' ) && ! PLL_SYNC ? 0 : 1; // the option replaces PLL_SYNC in 0.9
|
113 |
}
|
114 |
|
115 |
+
/**
|
116 |
* upgrades if the previous version is < 1.0
|
117 |
*
|
118 |
* @since 1.2
|
132 |
flush_rewrite_rules(); // rewrite rules have been modified in 1.0
|
133 |
}
|
134 |
|
135 |
+
/**
|
136 |
* upgrades if the previous version is < 1.1
|
137 |
*
|
138 |
* @since 1.2
|
154 |
}
|
155 |
}
|
156 |
|
157 |
+
/**
|
158 |
* upgrades if the previous version is < 1.2
|
159 |
*
|
160 |
* @since 1.2
|
270 |
// upgrade of nav menus is now in upgrade_1_2_3
|
271 |
}
|
272 |
|
273 |
+
/**
|
274 |
* upgrades if the previous version is < 1.2.1
|
275 |
*
|
276 |
* @since 1.2.1
|
288 |
}
|
289 |
}
|
290 |
|
291 |
+
/**
|
292 |
* upgrades if the previous version is < 1.2.3
|
293 |
* uprades multilingual menus depending on the old version due to multiple changes in menus management
|
294 |
*
|
365 |
}
|
366 |
}
|
367 |
|
368 |
+
/**
|
369 |
* upgrades if the previous version is < 1.3
|
370 |
* moves the user biographies in default language to the 'description' user meta
|
371 |
*
|
384 |
}
|
385 |
}
|
386 |
|
387 |
+
/**
|
388 |
* upgrades if the previous version is < 1.4
|
389 |
* sets a transient to delete old model data
|
390 |
* deletes language cache (due to bug correction in home urls in 1.3.1 and added mo_id in 1.4)
|
396 |
delete_transient( 'pll_languages_list' );
|
397 |
}
|
398 |
|
399 |
+
/**
|
400 |
* old data were not deleted in 1.2, just in case...
|
401 |
* delete them at first upgrade at least 60 days after upgrade to 1.4
|
402 |
*
|
424 |
delete_transient( 'pll_upgrade_1_4' );
|
425 |
}
|
426 |
|
427 |
+
/**
|
428 |
* upgrades if the previous version is < 1.4.1
|
429 |
* disables the browser detection when using multiple domains
|
430 |
*
|
436 |
}
|
437 |
}
|
438 |
|
439 |
+
/**
|
440 |
* upgrades if the previous version is < 1.4.4
|
441 |
* uprades widgets options for language filter
|
442 |
*
|
456 |
unset( $this->options['widgets'] );
|
457 |
}
|
458 |
|
459 |
+
/**
|
460 |
* upgrades if the previous version is < 1.5
|
461 |
* deletes language cache (due to host property added and bug on search url)
|
462 |
*
|
466 |
delete_transient( 'pll_languages_list' );
|
467 |
}
|
468 |
|
469 |
+
/**
|
470 |
* upgrades if the previous version is < 1.6
|
471 |
* upgrades core language files to get the .po file (only for WP 4.0+)
|
472 |
*
|
478 |
}
|
479 |
}
|
480 |
|
481 |
+
/**
|
482 |
* downloads language packs
|
483 |
* intended to be used only one time (at upgrade to Polylang 1.6 or first upgrade of WP 4.0 or later)
|
484 |
* adapted from wp_download_language_pack
|
520 |
}
|
521 |
}
|
522 |
|
523 |
+
/**
|
524 |
* upgrades if the previous version is < 1.7.4
|
525 |
*
|
526 |
* @since 1.7.4
|
530 |
flush_rewrite_rules(); // flush rewrite rules due to custom taxonomy rewrite rule bug fix
|
531 |
}
|
532 |
|
533 |
+
/**
|
534 |
* upgrades if the previous version is < 1.8
|
535 |
*
|
536 |
* @since 1.8
|
js/admin.js
CHANGED
@@ -99,41 +99,50 @@ jQuery( document ).ready(function( $ ) {
|
|
99 |
var parts = tr.attr( 'id' ).split( '-' );
|
100 |
|
101 |
var data = {
|
102 |
-
action:
|
103 |
-
|
104 |
-
|
|
|
105 |
}
|
106 |
|
107 |
data = tr.find( ':input' ).serialize() + '&' + $.param( data );
|
108 |
|
109 |
-
$.post( ajaxurl, data
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
});
|
135 |
-
|
136 |
-
}
|
137 |
});
|
138 |
});
|
139 |
});
|
@@ -163,4 +172,19 @@ jQuery( document ).ready(function( $ ) {
|
|
163 |
pll_toggle( $( "#pll-hide-default" ), 3 > value );
|
164 |
pll_toggle( $( "#pll-rewrite" ), 2 > value );
|
165 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
});
|
99 |
var parts = tr.attr( 'id' ).split( '-' );
|
100 |
|
101 |
var data = {
|
102 |
+
action: 'pll_save_options',
|
103 |
+
pll_ajax_settings: true,
|
104 |
+
module: parts[parts.length - 1],
|
105 |
+
_pll_nonce: $( '#_pll_nonce' ).val()
|
106 |
}
|
107 |
|
108 |
data = tr.find( ':input' ).serialize() + '&' + $.param( data );
|
109 |
|
110 |
+
$.post( ajaxurl, data, function( response ) {
|
111 |
+
var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
|
112 |
+
$.each( res.responses, function() {
|
113 |
+
switch ( this.what ) {
|
114 |
+
case 'license-update':
|
115 |
+
$( '#pll-license-' + this.data ).replaceWith( this.supplemental.html );
|
116 |
+
break;
|
117 |
+
case 'success':
|
118 |
+
tr.hide().prev().show(); // close only if there is no error
|
119 |
+
case 'error':
|
120 |
+
$( '.settings-error' ).remove(); // remove previous messages if any
|
121 |
+
$( '.nav-tab-wrapper' ).after( this.data );
|
122 |
+
|
123 |
+
// Make notices dismissible
|
124 |
+
// copy paste of common.js from WP 4.2.2
|
125 |
+
$( '.notice.is-dismissible' ).each(function() {
|
126 |
+
var $this = $( this ),
|
127 |
+
$button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ),
|
128 |
+
btnText = commonL10n.dismiss || '';
|
129 |
+
|
130 |
+
// Ensure plain text
|
131 |
+
$button.find( '.screen-reader-text' ).text( btnText );
|
132 |
+
|
133 |
+
$this.append( $button );
|
134 |
+
|
135 |
+
$button.on( 'click.wp-dismiss-notice', function( event ) {
|
136 |
+
event.preventDefault();
|
137 |
+
$this.fadeTo( 100 , 0, function() {
|
138 |
+
$( this ).slideUp( 100, function() {
|
139 |
+
$( this ).remove();
|
140 |
+
});
|
141 |
+
});
|
142 |
+
});
|
143 |
});
|
144 |
+
break;
|
145 |
+
}
|
146 |
});
|
147 |
});
|
148 |
});
|
172 |
pll_toggle( $( "#pll-hide-default" ), 3 > value );
|
173 |
pll_toggle( $( "#pll-rewrite" ), 2 > value );
|
174 |
});
|
175 |
+
|
176 |
+
// settings license
|
177 |
+
// deactivate button
|
178 |
+
$( '.pll-deactivate-license' ).on( 'click', function() {
|
179 |
+
var data = {
|
180 |
+
action: 'pll_deactivate_license',
|
181 |
+
pll_ajax_settings: true,
|
182 |
+
id: $( this ).attr( 'id' ),
|
183 |
+
_pll_nonce: $( '#_pll_nonce' ).val()
|
184 |
+
}
|
185 |
+
$.post( ajaxurl, data , function( response ){
|
186 |
+
$( '#pll-license-' + response.id ).replaceWith( response.html );
|
187 |
+
});
|
188 |
+
});
|
189 |
+
|
190 |
});
|
js/admin.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(
|
1 |
+
jQuery(document).ready(function(e){function t(){var t=e(this).val();if(t){var n=e(this).iconselectmenu("widget").children(":last"),i=e('<img class="ui-icon" >').appendTo(n);i.attr("src",pll_flag_base_url+t+".png")}}var n;e("table.languages").on({focusin:function(){clearTimeout(n),focusedRowActions=e(this).find(".row-actions"),e(".row-actions").not(this).removeClass("visible"),focusedRowActions.addClass("visible")},focusout:function(){n=setTimeout(function(){focusedRowActions.removeClass("visible")},30)}},"tr"),e.widget("custom.iconselectmenu",e.ui.selectmenu,{_renderItem:function(t,n){var i=e("<li>",{text:n.label});return n.value&&e("<img>",{src:pll_flag_base_url+n.value+".png","class":"ui-icon"}).appendTo(i),i.appendTo(t)}}),e("#flag_list").iconselectmenu({create:t,select:t}),e("#lang_list").change(function(){value=e(this).val().split("-"),selected=e("select option:selected").text().split(" - "),e("#lang_slug").val(value[0]),e("#lang_locale").val(value[1]),e('input[name="rtl"]').val([value[2]]),e("#lang_name").val(selected[0]),e('#flag_list option[value="'+value[3]+'"]').attr("selected","selected"),e("#flag_list").iconselectmenu("destroy").iconselectmenu({create:t,select:t})}),e(".translation input").keypress(function(t){13===t.keyCode&&(t.preventDefault(),e("#submit").click())}),e("#the-list").on("click",".configure>a",function(){return e(".pll-configure").hide().prev().show(),e(this).closest("tr").hide().next().show(),!1}),e("#the-list").on("click",".cancel",function(){e(this).closest("tr").hide().prev().show()}),e("#the-list").on("click",".save",function(){var t=e(this).closest("tr"),n=t.attr("id").split("-"),i={action:"pll_save_options",pll_ajax_settings:!0,module:n[n.length-1],_pll_nonce:e("#_pll_nonce").val()};i=t.find(":input").serialize()+"&"+e.param(i),e.post(ajaxurl,i,function(n){var i=wpAjax.parseAjaxResponse(n,"ajax-response");e.each(i.responses,function(){switch(this.what){case"license-update":e("#pll-license-"+this.data).replaceWith(this.supplemental.html);break;case"success":t.hide().prev().show();case"error":e(".settings-error").remove(),e(".nav-tab-wrapper").after(this.data),e(".notice.is-dismissible").each(function(){var t=e(this),n=e('<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>'),i=commonL10n.dismiss||"";n.find(".screen-reader-text").text(i),t.append(n),n.on("click.wp-dismiss-notice",function(n){n.preventDefault(),t.fadeTo(100,0,function(){e(this).slideUp(100,function(){e(this).remove()})})})})}})})}),e(".pll-configure").keypress(function(t){13===t.keyCode&&(t.preventDefault(),e(this).find(".save").click()),27===t.keyCode&&(t.preventDefault(),e(this).find(".cancel").click())}),e("input[name='force_lang']").change(function(){function t(e,t){t?e.show():e.hide()}var n=e(this).val();t(e("#pll-domains-table"),3==n),t(e("#pll-hide-default"),3>n),t(e("#pll-rewrite"),2>n)}),e(".pll-deactivate-license").on("click",function(){var t={action:"pll_deactivate_license",pll_ajax_settings:!0,id:e(this).attr("id"),_pll_nonce:e("#_pll_nonce").val()};e.post(ajaxurl,t,function(t){e("#pll-license-"+t.id).replaceWith(t.html)})})});
|
js/media.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
1 |
+
!function(a){a.ajaxPrefilter(function(t){t.data="pll_post_id="+a("#affected").val()+"&"+t.data})}(jQuery);
|
js/nav-menu.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(
|
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");for(var i=0;i<ids.length;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[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}),("undefined"!=typeof pll_data.val[t]&&1==pll_data.val[t][ids[i]]||"undefined"==typeof 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)})})}))})});
|
js/post.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
1 |
+
!function(t){t.ajaxPrefilter(function(a){-1!==a.url.indexOf("action=ajax-tag-search")&&((lang=t(".post_lang_choice").val())||(lang=t(':input[name="inline_lang_choice"]').val()))&&(a.data="lang="+lang+"&"+a.data)})}(jQuery),function(t){tagBox.get=function(a){var n=a.substr(a.indexOf("-")+1),e={action:"get-tagcloud",lang:t(".post_lang_choice").val(),tax:n};t.post(ajaxurl,e,function(e,i){0!=e&&"success"==i||(e=wpAjax.broken),e=t('<p id="tagcloud-'+n+'" class="the-tagcloud">'+e+"</p>"),t("a",e).click(function(){return tagBox.flushTags(t(this).closest(".inside").children(".tagsdiv"),this),!1}),(v=t(".the-tagcloud").css("display"))?(t(".the-tagcloud").replaceWith(e),t(".the-tagcloud").css("display",v)):t("#"+a).after(e)})}}(jQuery),function(t){t(document).bind("DOMNodeInserted",function(a){function n(a){"undefined"!=typeof pll_term_languages&&t.each(pll_term_languages,function(n,e){t.each(e,function(e,i){t.each(i,function(i){id="#"+e+"-"+pll_term_languages[n][e][i],a==n?t(id).show():t(id).hide()})})})}function e(a){"undefined"!=typeof pll_page_languages&&t.each(pll_page_languages,function(n,e){t.each(e,function(e){v=t('#post_parent option[value="'+pll_page_languages[n][e]+'"]'),a==n?v.show():v.hide()})})}var i=t(a.target);if("inline-edit"==i.attr("id")){var l=i.prev().attr("id").replace("post-","");if(l>0){var s=i.find(':input[name="inline_lang_choice"]'),o=t("#lang_"+l).html();s.val(o),n(o),e(o),s.change(function(){n(t(this).val()),e(t(this).val())})}}})}(jQuery),function(t){t(document).ajaxSuccess(function(a,n,e){function i(a){var n=new Array;t(".translation_"+a).each(function(){n.push(t(this).parent().parent().attr("id").substring(5))});var e={action:"pll_update_post_rows",post_id:a,translations:n.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,e,function(a){if(a){var n=wpAjax.parseAjaxResponse(a,"ajax-response");t.each(n.responses,function(){"row"==this.what&&t("#post-"+this.supplemental.post_id).replaceWith(this.data)})}})}var l=wpAjax.unserialize(e.data);"undefined"!=typeof l.action&&"inline-save"==l.action&&i(l.post_ID)})}(jQuery),jQuery(document).ready(function(t){function a(){t(".tr_lang").each(function(){var a=t(this).attr("id").substring(8),n=t(this).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(e,i){t("#htr_lang_"+a).val(i.item.id),n.html(i.item.link)}}),t(this).blur(function(){t(this).val()||(t("#htr_lang_"+a).val(0),n.html(n.siblings(".hidden").children().clone()))})})}var n=new Array;t(".categorydiv").each(function(){var a,e,i=t(this).attr("id");a=i.split("-"),a.shift(),e=a.join("-"),n.push(e),t("#"+e+"-add-submit").before(t("<input />").attr("type","hidden").attr("id",e+"-lang").attr("name","term_lang_choice").attr("value",t(".post_lang_choice").val()))}),t(".post_lang_choice").change(function(){var e={action:"post_lang_choice",lang:t(this).val(),post_type:t("#post_type").val(),taxonomies:n,post_id:t("#post_ID").val(),_pll_nonce:t("#_pll_nonce").val()};t.post(ajaxurl,e,function(n){var e=wpAjax.parseAjaxResponse(n,"ajax-response");t.each(e.responses,function(){switch(this.what){case"translations":t(".translations").html(this.data),a();break;case"taxonomy":var n=this.data;t("#"+n+"checklist").html(this.supplemental.all),t("#"+n+"checklist-pop").html(this.supplemental.populars),t("#new"+n+"_parent").replaceWith(this.supplemental.dropdown),t("#"+n+"-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)}}),t(".tagcloud-link").each(function(){var a=t(this).attr("id");tagBox.get(a)})})}),a()});
|
js/term.min.js
CHANGED
@@ -1 +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 i=n.find(':input[name="inline_lang_choice"]'),l=a("#lang_"+e).html();i.val(l);var s=a("#default_cat_"+e).html();e==s&&i.prop("disabled",!0)}}})}(jQuery),function(a){a(document).ajaxSuccess(function(t,n,e){function i(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(),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 l=wpAjax.unserialize(e.data);if("undefined"!=typeof l.action)switch(l.action){case"add-tag":res=wpAjax.parseAjaxResponse(n.responseXML,"ajax-response"),a.each(res.responses,function(){"term"==this.what&&i(this.supplemental.term_id)}),a(".htr_lang").val(0);break;case"delete-tag":i(l.tag_ID);break;case"inline-save-tax":i(l.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().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,i){a("#htr_lang_"+t).val(i.item.id),n.html(i.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={action:"term_lang_choice",lang:a(this).val(),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,n,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)}})})})});
|
js/user.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(
|
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.html(e(this).val()),n.append("<div>"+lang[1]+"</div"),n.append(desc)}),n.append("<br />"),n.append(i)});
|
languages/polylang-es_ES.mo
DELETED
Binary file
|
languages/polylang-es_ES.po
DELETED
@@ -1,590 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: polylang\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: \n"
|
6 |
-
"PO-Revision-Date: \n"
|
7 |
-
"Last-Translator: Curro C. <curro.cejudo@me.com>\n"
|
8 |
-
"Language-Team: \n"
|
9 |
-
"Language: es_ES\n"
|
10 |
-
"MIME-Version: 1.0\n"
|
11 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
-
"Content-Transfer-Encoding: 8bit\n"
|
13 |
-
"Plural-Forms: nplurals=2: nplural=n>1;\n"
|
14 |
-
"X-Poedit-SourceCharset: utf-8\n"
|
15 |
-
"X-Poedit-KeywordsList: _e;__;_x\n"
|
16 |
-
"X-Poedit-Basepath: .\n"
|
17 |
-
"X-Generator: Poedit 1.5.4\n"
|
18 |
-
"X-Poedit-SearchPath-0: ..\n"
|
19 |
-
"X-Poedit-SearchPath-1: ../include\n"
|
20 |
-
|
21 |
-
#: admin/view-about.php:3
|
22 |
-
#, php-format
|
23 |
-
msgid ""
|
24 |
-
"Polylang is provided with an extensive %sdocumentation%s (in English only). "
|
25 |
-
"It includes information on how to set up your multilingual site and use it "
|
26 |
-
"on a daily basis, a FAQ, as well as a documentation for programmers to adapt "
|
27 |
-
"their plugins and themes."
|
28 |
-
msgstr ""
|
29 |
-
"Polylang se distribuye con una extensa %sdocumentación%s (sólo en inglés). "
|
30 |
-
"Se incluye información de cómo crear tu sitio multi-idiomático y cómo usarlo "
|
31 |
-
"en el día a día, una página de preguntas frecuentes, así como información "
|
32 |
-
"para que los programadores puedan adaptar sus plugins y temas."
|
33 |
-
|
34 |
-
#: admin/view-about.php:9
|
35 |
-
#, php-format
|
36 |
-
msgid ""
|
37 |
-
"You will also find useful information in the %ssupport forum%s. However "
|
38 |
-
"don't forget to make a search before posting a new topic."
|
39 |
-
msgstr ""
|
40 |
-
"También encontrarás información útil en los %sforos de soporte%s. Pero no "
|
41 |
-
"olvides hacer una búsqueda antes de crear un nuevo tema."
|
42 |
-
|
43 |
-
#: admin/view-about.php:16
|
44 |
-
#, php-format
|
45 |
-
msgid ""
|
46 |
-
"Polylang is free of charge and is released under the same license as "
|
47 |
-
"WordPress, the %sGPL%s."
|
48 |
-
msgstr ""
|
49 |
-
"Polylang es gratuito y se distribuye bajo la misma licencia que WordPress, "
|
50 |
-
"%sGPL%s."
|
51 |
-
|
52 |
-
#: admin/view-about.php:22
|
53 |
-
#, php-format
|
54 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
55 |
-
msgstr "Si quieres saber cómo puedes ayudar al proyecto, lee %sesto%s."
|
56 |
-
|
57 |
-
#: admin/view-about.php:27
|
58 |
-
msgid ""
|
59 |
-
"Finally if you like this plugin or if it helps your business, donations to "
|
60 |
-
"the author are greatly appreciated."
|
61 |
-
msgstr ""
|
62 |
-
"Finalmente, si te gusta este plugin y te ayuda a ganar dinero, el autor "
|
63 |
-
"agradece enormemente un donativo."
|
64 |
-
|
65 |
-
#: admin/admin-filters-post.php:115 admin/admin.php:90 admin/settings.php:70
|
66 |
-
#: admin/settings.php:97 include/model.php:561
|
67 |
-
msgid "Languages"
|
68 |
-
msgstr "Idiomas"
|
69 |
-
|
70 |
-
#: include/switcher.php:22
|
71 |
-
msgid "Displays language names"
|
72 |
-
msgstr "Muestra los nombres de los idiomas"
|
73 |
-
|
74 |
-
#: include/switcher.php:23
|
75 |
-
msgid "Displays flags"
|
76 |
-
msgstr "Muestra las banderas"
|
77 |
-
|
78 |
-
#: include/switcher.php:24
|
79 |
-
msgid "Forces link to front page"
|
80 |
-
msgstr "Fuerza un enlace a la página principal"
|
81 |
-
|
82 |
-
#: include/switcher.php:25
|
83 |
-
msgid "Hides the current language"
|
84 |
-
msgstr "Oculta el idioma actual"
|
85 |
-
|
86 |
-
#: include/switcher.php:30
|
87 |
-
msgid "Displays as dropdown"
|
88 |
-
msgstr "Mostrar como menú desplegable"
|
89 |
-
|
90 |
-
#: admin/admin.php:267
|
91 |
-
msgid "Filters content by language"
|
92 |
-
msgstr "Filtrar el contenido por idioma"
|
93 |
-
|
94 |
-
#: admin/admin.php:258
|
95 |
-
msgid "Show all languages"
|
96 |
-
msgstr "Mostrar todos los idiomas"
|
97 |
-
|
98 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
99 |
-
msgid "Add new translation"
|
100 |
-
msgstr "Añadir nueva traducción"
|
101 |
-
|
102 |
-
#: admin/admin-filters-columns.php:173 admin/admin-filters-media.php:55
|
103 |
-
#: admin/admin-filters-post.php:141 admin/admin-filters-term.php:75
|
104 |
-
#: admin/admin-filters-term.php:122 include/model.php:562
|
105 |
-
msgid "Language"
|
106 |
-
msgstr "Idioma"
|
107 |
-
|
108 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
109 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
110 |
-
#: admin/view-translations-term.php:11
|
111 |
-
msgid "Translations"
|
112 |
-
msgstr "Traducciones"
|
113 |
-
|
114 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
115 |
-
msgid "Sets the language"
|
116 |
-
msgstr "Establece el idioma"
|
117 |
-
|
118 |
-
#: admin/admin-filters.php:52
|
119 |
-
msgid "The widget is displayed for:"
|
120 |
-
msgstr "El widget se muestra para:"
|
121 |
-
|
122 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
123 |
-
msgid "All languages"
|
124 |
-
msgstr "Todos los idiomas"
|
125 |
-
|
126 |
-
#: admin/admin-filters.php:123
|
127 |
-
msgid "Admin language"
|
128 |
-
msgstr "Idioma del administrador"
|
129 |
-
|
130 |
-
#: admin/admin-filters.php:126
|
131 |
-
msgid "WordPress default"
|
132 |
-
msgstr "Opción por defecto de WordPress"
|
133 |
-
|
134 |
-
#: admin/admin.php:167 admin/settings.php:102
|
135 |
-
msgid "Settings"
|
136 |
-
msgstr "Ajustes"
|
137 |
-
|
138 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
139 |
-
msgid "Upgrading language files…"
|
140 |
-
msgstr "Actualizando los archivos de idioma…"
|
141 |
-
|
142 |
-
#: admin/settings.php:62
|
143 |
-
msgid "About Polylang"
|
144 |
-
msgstr "Acerca de Polylang"
|
145 |
-
|
146 |
-
#: admin/settings.php:78
|
147 |
-
msgid "Strings translations"
|
148 |
-
msgstr "Traducciones de cadenas"
|
149 |
-
|
150 |
-
#: admin/settings.php:101
|
151 |
-
msgid "Strings translation"
|
152 |
-
msgstr "Traducción de cadenas"
|
153 |
-
|
154 |
-
#: admin/admin-model.php:244
|
155 |
-
msgid "Enter a valid WordPress locale"
|
156 |
-
msgstr "Introduce una zona idiomática válida de WordPress"
|
157 |
-
|
158 |
-
#: admin/admin-model.php:252
|
159 |
-
msgid "The language code must be unique"
|
160 |
-
msgstr "El código idiomático debe ser único"
|
161 |
-
|
162 |
-
#: admin/admin-model.php:256
|
163 |
-
msgid "The language must have a name"
|
164 |
-
msgstr "El dioma debe tener un nombre"
|
165 |
-
|
166 |
-
#: admin/admin.php:367 admin/settings.php:180
|
167 |
-
msgid ""
|
168 |
-
"The language was created, but the WordPress language file was not "
|
169 |
-
"downloaded. Please install it manually."
|
170 |
-
msgstr ""
|
171 |
-
"Se ha creado el idioma pero el archivo de este idioma de WordPress no se ha "
|
172 |
-
"descargado. Por favor, instálalo manualmente."
|
173 |
-
|
174 |
-
#: admin/admin-strings.php:59
|
175 |
-
msgid "Widget title"
|
176 |
-
msgstr "Título del widget"
|
177 |
-
|
178 |
-
# @ polylang
|
179 |
-
#: admin/settings.php:319
|
180 |
-
msgid "Taxonomies"
|
181 |
-
msgstr "Taxonomías"
|
182 |
-
|
183 |
-
# @ polylang
|
184 |
-
#: admin/settings.php:320
|
185 |
-
msgid "Custom fields"
|
186 |
-
msgstr "Campos personalizados"
|
187 |
-
|
188 |
-
# @ polylang
|
189 |
-
#: admin/settings.php:321
|
190 |
-
msgid "Comment status"
|
191 |
-
msgstr "Estado de los comentarios"
|
192 |
-
|
193 |
-
# @ polylang
|
194 |
-
#: admin/settings.php:322
|
195 |
-
msgid "Ping status"
|
196 |
-
msgstr "Estados de los pings"
|
197 |
-
|
198 |
-
# @ polylang
|
199 |
-
#: admin/settings.php:323
|
200 |
-
msgid "Sticky posts"
|
201 |
-
msgstr "Entradas fijas"
|
202 |
-
|
203 |
-
# @ polylang
|
204 |
-
#: admin/settings.php:324
|
205 |
-
msgid "Published date"
|
206 |
-
msgstr "Fecha de publicación"
|
207 |
-
|
208 |
-
# @ polylang
|
209 |
-
#: admin/settings.php:325
|
210 |
-
msgid "Post format"
|
211 |
-
msgstr "Formato de entrada"
|
212 |
-
|
213 |
-
#: admin/settings.php:326
|
214 |
-
msgid "Page parent"
|
215 |
-
msgstr "Página superior"
|
216 |
-
|
217 |
-
# @ polylang
|
218 |
-
#: admin/settings.php:327
|
219 |
-
msgid "Page template"
|
220 |
-
msgstr "Plantilla de página"
|
221 |
-
|
222 |
-
#: admin/settings.php:328
|
223 |
-
msgid "Page order"
|
224 |
-
msgstr "Orden de página"
|
225 |
-
|
226 |
-
# @ polylang
|
227 |
-
#: admin/settings.php:329
|
228 |
-
msgid "Featured image"
|
229 |
-
msgstr "Imagen destacada"
|
230 |
-
|
231 |
-
#: admin/view-tab-lang.php:21
|
232 |
-
msgid "Edit language"
|
233 |
-
msgstr "Editar idioma"
|
234 |
-
|
235 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
236 |
-
msgid "Add new language"
|
237 |
-
msgstr "Añadir nuevo idioma"
|
238 |
-
|
239 |
-
#: admin/view-tab-lang.php:37
|
240 |
-
msgid "Choose a language"
|
241 |
-
msgstr "Elegir un idioma"
|
242 |
-
|
243 |
-
#: admin/view-tab-lang.php:51
|
244 |
-
msgid "You can choose a language in the list or directly edit it below."
|
245 |
-
msgstr "Puedes elegir un idioma de la lista o editarlo directamente abajo."
|
246 |
-
|
247 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
248 |
-
msgid "Full name"
|
249 |
-
msgstr "Nombre completo"
|
250 |
-
|
251 |
-
#: admin/view-tab-lang.php:57
|
252 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
253 |
-
msgstr "El nombre es como se muestra en tu sitio (por ejemplo: Español)."
|
254 |
-
|
255 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
256 |
-
msgid "Locale"
|
257 |
-
msgstr "Región"
|
258 |
-
|
259 |
-
#: admin/view-tab-lang.php:66
|
260 |
-
msgid ""
|
261 |
-
"WordPress Locale for the language (for example: en_US). You will need to "
|
262 |
-
"install the .mo file for this language."
|
263 |
-
msgstr ""
|
264 |
-
"Región idiomática de WordPress (por ejemplo: es_ES). Deberás instalar el "
|
265 |
-
"archivo .mo para este idioma."
|
266 |
-
|
267 |
-
#: admin/view-tab-lang.php:70
|
268 |
-
msgid "Language code"
|
269 |
-
msgstr "Código idiomático"
|
270 |
-
|
271 |
-
#: admin/view-tab-lang.php:76
|
272 |
-
msgid "Text direction"
|
273 |
-
msgstr "Dirección de escritura"
|
274 |
-
|
275 |
-
#: admin/view-tab-lang.php:80
|
276 |
-
msgid "left to right"
|
277 |
-
msgstr "izquierda a derecha"
|
278 |
-
|
279 |
-
#: admin/view-tab-lang.php:85
|
280 |
-
msgid "right to left"
|
281 |
-
msgstr "derecha a izquierda"
|
282 |
-
|
283 |
-
#: admin/view-tab-lang.php:87
|
284 |
-
msgid "Choose the text direction for the language"
|
285 |
-
msgstr "Elige la dirección de escritura del idioma"
|
286 |
-
|
287 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
288 |
-
msgid "Order"
|
289 |
-
msgstr "Orden"
|
290 |
-
|
291 |
-
#: admin/view-tab-lang.php:93
|
292 |
-
msgid "Position of the language in the language switcher"
|
293 |
-
msgstr "Posición en el conmutador de idioma"
|
294 |
-
|
295 |
-
#: admin/admin-nav-menu.php:54 admin/admin-nav-menu.php:92
|
296 |
-
#: admin/admin-nav-menu.php:95 admin/admin-nav-menu.php:126
|
297 |
-
#: admin/admin-nav-menu.php:188 install/upgrade.php:301
|
298 |
-
msgid "Language switcher"
|
299 |
-
msgstr "Conmutador de idioma"
|
300 |
-
|
301 |
-
#: admin/view-tab-strings.php:8
|
302 |
-
msgid "Search translations"
|
303 |
-
msgstr "Buscar traducciones"
|
304 |
-
|
305 |
-
#: admin/view-tab-strings.php:11
|
306 |
-
msgid "Clean strings translation database"
|
307 |
-
msgstr "Limpiar la base de datos de traducciones de cadenas"
|
308 |
-
|
309 |
-
#: admin/view-tab-settings.php:14
|
310 |
-
msgid "Default language"
|
311 |
-
msgstr "Idioma predeterminado"
|
312 |
-
|
313 |
-
#: admin/view-tab-settings.php:29
|
314 |
-
msgid ""
|
315 |
-
"There are posts, pages, categories or tags without language set. Do you want "
|
316 |
-
"to set them all to default language ?"
|
317 |
-
msgstr ""
|
318 |
-
"Hay entradas, páginas, categorías o etiquetas sin idioma establecido. "
|
319 |
-
"¿Quieres establecerlas al idioma predeterminado?"
|
320 |
-
|
321 |
-
#: admin/view-tab-settings.php:149
|
322 |
-
msgid "Detect browser language"
|
323 |
-
msgstr "Detectar el idioma del navegador"
|
324 |
-
|
325 |
-
#: admin/view-tab-settings.php:155
|
326 |
-
msgid ""
|
327 |
-
"When the front page is visited, set the language according to the browser "
|
328 |
-
"preference"
|
329 |
-
msgstr ""
|
330 |
-
"Al visitar la página principal, se establece el idioma de acuerdo con las "
|
331 |
-
"preferencias del navegador"
|
332 |
-
|
333 |
-
#: admin/view-tab-settings.php:37
|
334 |
-
msgid "URL modifications"
|
335 |
-
msgstr "Modificaciones de URL"
|
336 |
-
|
337 |
-
#: admin/view-tab-settings.php:93
|
338 |
-
msgid "Hide URL language information for default language"
|
339 |
-
msgstr "Ocultar el URL del idioma en el idioma predeterminado"
|
340 |
-
|
341 |
-
# @ polylang
|
342 |
-
#: admin/view-tab-settings.php:162
|
343 |
-
msgid "Media"
|
344 |
-
msgstr "Medios"
|
345 |
-
|
346 |
-
# @ polylang
|
347 |
-
#: admin/view-tab-settings.php:168
|
348 |
-
msgid "Activate languages and translations for media"
|
349 |
-
msgstr "Activar idiomas y traducciones para los medios"
|
350 |
-
|
351 |
-
#: admin/view-tab-settings.php:215
|
352 |
-
msgid "Synchronization"
|
353 |
-
msgstr "Sincronización"
|
354 |
-
|
355 |
-
# @ polylang
|
356 |
-
#: admin/view-tab-settings.php:176
|
357 |
-
msgid "Custom post types"
|
358 |
-
msgstr "Tipos de entrada personalizados"
|
359 |
-
|
360 |
-
# @ polylang
|
361 |
-
#: admin/view-tab-settings.php:189
|
362 |
-
msgid "Activate languages and translations for custom post types."
|
363 |
-
msgstr "Activar idiomas y traducciones para tipos de entrada personalizados."
|
364 |
-
|
365 |
-
# @ polylang
|
366 |
-
#: admin/view-tab-settings.php:196
|
367 |
-
msgid "Custom taxonomies"
|
368 |
-
msgstr "Taxonomías personalizadas"
|
369 |
-
|
370 |
-
# @ polylang
|
371 |
-
#: admin/view-tab-settings.php:209
|
372 |
-
msgid "Activate languages and translations for custom taxonomies."
|
373 |
-
msgstr "Activar idiomas y traducciones para taxonomías personalizadas."
|
374 |
-
|
375 |
-
#: admin/admin-filters-post.php:433 admin/admin-filters-term.php:642
|
376 |
-
#: admin/table-languages.php:54 admin/view-translations-media.php:21
|
377 |
-
msgid "Edit"
|
378 |
-
msgstr "Editar"
|
379 |
-
|
380 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
381 |
-
msgid "Delete"
|
382 |
-
msgstr "Eliminar"
|
383 |
-
|
384 |
-
#: admin/table-languages.php:76
|
385 |
-
msgid "Code"
|
386 |
-
msgstr "Código"
|
387 |
-
|
388 |
-
#: admin/table-languages.php:78
|
389 |
-
msgid "Flag"
|
390 |
-
msgstr "Bandera"
|
391 |
-
|
392 |
-
#: admin/table-languages.php:79
|
393 |
-
msgid "Posts"
|
394 |
-
msgstr "Entradas"
|
395 |
-
|
396 |
-
#: admin/table-string.php:110
|
397 |
-
msgid "Name"
|
398 |
-
msgstr "Nombre"
|
399 |
-
|
400 |
-
#: admin/table-string.php:111
|
401 |
-
msgid "String"
|
402 |
-
msgstr "Cadena"
|
403 |
-
|
404 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
405 |
-
#: admin/view-translations-term.php:30
|
406 |
-
msgid "Add new"
|
407 |
-
msgstr "Añadir nuevo"
|
408 |
-
|
409 |
-
#: include/widget-languages.php:16
|
410 |
-
msgid "Language Switcher"
|
411 |
-
msgstr "Conmutador de idioma"
|
412 |
-
|
413 |
-
#: include/widget-languages.php:16
|
414 |
-
msgid "Displays a language switcher"
|
415 |
-
msgstr "Muestra un conmutador de idioma"
|
416 |
-
|
417 |
-
#: include/widget-languages.php:75
|
418 |
-
msgid "Title:"
|
419 |
-
msgstr "Título:"
|
420 |
-
|
421 |
-
# @ polylang
|
422 |
-
#. translators: plugin header field 'Description'
|
423 |
-
#: polylang.php:0
|
424 |
-
msgid "Adds multilingual capability to WordPress"
|
425 |
-
msgstr "Añade capacidad multilingüística a WordPress"
|
426 |
-
|
427 |
-
#: install/install.php:24
|
428 |
-
#, php-format
|
429 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
430 |
-
msgstr "Estás usando WordPress %s. Polylang necesita como mínimo WordPress %s."
|
431 |
-
|
432 |
-
# @ polylang
|
433 |
-
#: install/upgrade.php:76
|
434 |
-
msgid ""
|
435 |
-
"Polylang has been deactivated because you upgraded from a too old version."
|
436 |
-
msgstr ""
|
437 |
-
"Polylang se ha desactivado porque lo has actualizado desde una versión "
|
438 |
-
"demasiado antigua."
|
439 |
-
|
440 |
-
# @ polylang
|
441 |
-
#: install/upgrade.php:78
|
442 |
-
#, php-format
|
443 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
444 |
-
msgstr "Por favor, actualiza primero a %s antes de actualizar a %s."
|
445 |
-
|
446 |
-
# @ polylang
|
447 |
-
#: admin/table-string.php:109
|
448 |
-
msgid "Group"
|
449 |
-
msgstr "Grupo"
|
450 |
-
|
451 |
-
# @ polylang
|
452 |
-
#: admin/table-string.php:187
|
453 |
-
msgid "View all groups"
|
454 |
-
msgstr "Ver todos los grupos"
|
455 |
-
|
456 |
-
# @ polylang
|
457 |
-
#: admin/table-languages.php:59
|
458 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
459 |
-
msgstr "Estás a punto de eliminar este idioma permanentemente, ¿estás seguro?"
|
460 |
-
|
461 |
-
# @ polylang
|
462 |
-
#: admin/view-tab-strings.php:12
|
463 |
-
msgid ""
|
464 |
-
"Use this to remove unused strings from database, for example after a plugin "
|
465 |
-
"has been uninstalled."
|
466 |
-
msgstr ""
|
467 |
-
"Usa esto para borrar de la base de datos las cadenas que no se usen. Por "
|
468 |
-
"ejemplo, tras desinstalar un plugin."
|
469 |
-
|
470 |
-
# @ polylang
|
471 |
-
#: admin/view-tab-settings.php:226
|
472 |
-
msgid ""
|
473 |
-
"The synchronization options allow to maintain exact same values (or "
|
474 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
475 |
-
"between the translations of a post or page."
|
476 |
-
msgstr ""
|
477 |
-
"Las opciones de sincronización permiten mantener exactamente los mismos "
|
478 |
-
"valores (o traducciones, en caso de taxonomías o páginas superiores) de "
|
479 |
-
"metacontenido entre las traducciones de una entrada o página."
|
480 |
-
|
481 |
-
#: admin/admin-model.php:248
|
482 |
-
msgid "The language code contains invalid characters"
|
483 |
-
msgstr "El código idiomático contiene caracteres no válidos"
|
484 |
-
|
485 |
-
# @ polylang
|
486 |
-
#: admin/view-tab-settings.php:43
|
487 |
-
msgid "The language is set from content"
|
488 |
-
msgstr "El idioma se establece por el contenido"
|
489 |
-
|
490 |
-
#: admin/view-tab-settings.php:46
|
491 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
492 |
-
msgstr "Las URL de las entradas, páginas y categorías no se modifican."
|
493 |
-
|
494 |
-
#: admin/view-tab-settings.php:51
|
495 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
496 |
-
msgstr ""
|
497 |
-
"El idioma se establece por el nombre del directorio en los enlaces "
|
498 |
-
"permanentes personalizados."
|
499 |
-
|
500 |
-
# @ polylang
|
501 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
502 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
503 |
-
msgid "Example:"
|
504 |
-
msgstr "Ejemplo:"
|
505 |
-
|
506 |
-
#: admin/view-tab-settings.php:60
|
507 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
508 |
-
msgstr ""
|
509 |
-
"El idioma se establece por el nombre del subdominio en los enlaces "
|
510 |
-
"permanentes personalizados."
|
511 |
-
|
512 |
-
# @ polylang
|
513 |
-
#: admin/view-tab-settings.php:69
|
514 |
-
msgid "The language is set from different domains"
|
515 |
-
msgstr "El idioma se establece por diferentes dominios"
|
516 |
-
|
517 |
-
#: admin/view-tab-settings.php:107
|
518 |
-
msgid "Remove /language/ in pretty permalinks"
|
519 |
-
msgstr "Eliminar /idioma/ en los enlaces permanentes personalizados"
|
520 |
-
|
521 |
-
#: admin/view-tab-settings.php:116
|
522 |
-
msgid "Keep /language/ in pretty permalinks"
|
523 |
-
msgstr "Mantener /idioma/ con enlaces permanentes personalizados"
|
524 |
-
|
525 |
-
# @ polylang
|
526 |
-
#: admin/view-tab-settings.php:131
|
527 |
-
msgid ""
|
528 |
-
"The front page url contains the language code instead of the page name or "
|
529 |
-
"page id"
|
530 |
-
msgstr ""
|
531 |
-
"La URL de la página de inicio muestra el código del idioma en vez del nombre "
|
532 |
-
"de la página o su ID."
|
533 |
-
|
534 |
-
# @ polylang
|
535 |
-
#: admin/view-tab-settings.php:139
|
536 |
-
#, php-format
|
537 |
-
msgid "Example: %s instead of %s"
|
538 |
-
msgstr "por ejemplo: %s en vez de %s"
|
539 |
-
|
540 |
-
#: admin/admin-model.php:38
|
541 |
-
msgid "Impossible to add the language."
|
542 |
-
msgstr "Imposible añadir ese idioma."
|
543 |
-
|
544 |
-
# @ polylang
|
545 |
-
#: admin/admin-model.php:66
|
546 |
-
msgid "Language added."
|
547 |
-
msgstr "Idioma añadido."
|
548 |
-
|
549 |
-
# @ polylang
|
550 |
-
#: admin/admin-model.php:146
|
551 |
-
msgid "Language deleted."
|
552 |
-
msgstr "Idioma eliminado."
|
553 |
-
|
554 |
-
# @ polylang
|
555 |
-
#: admin/admin-model.php:227
|
556 |
-
msgid "Language updated."
|
557 |
-
msgstr "Idioma actualizado."
|
558 |
-
|
559 |
-
# @ polylang
|
560 |
-
#: admin/settings.php:239
|
561 |
-
msgid "Translations updated."
|
562 |
-
msgstr "Traducciones actualizadas."
|
563 |
-
|
564 |
-
#: admin/view-tab-lang.php:72
|
565 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
566 |
-
msgstr ""
|
567 |
-
|
568 |
-
# @ polylang
|
569 |
-
#: admin/admin-filters.php:203
|
570 |
-
msgid "The chosen static front page must be translated in all languages."
|
571 |
-
msgstr ""
|
572 |
-
|
573 |
-
#: admin/admin-strings.php:60
|
574 |
-
msgid "Widget text"
|
575 |
-
msgstr ""
|
576 |
-
|
577 |
-
# @ polylang
|
578 |
-
#: admin/settings.php:52
|
579 |
-
msgid "Recommended plugins"
|
580 |
-
msgstr ""
|
581 |
-
|
582 |
-
# @ polylang
|
583 |
-
#: admin/view-tab-settings.php:51
|
584 |
-
msgid "The language is set from the code in the URL"
|
585 |
-
msgstr ""
|
586 |
-
|
587 |
-
# @ polylang
|
588 |
-
#: include/switcher.php:26
|
589 |
-
msgid "Hides languages with no translation"
|
590 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-fi.mo
DELETED
Binary file
|
languages/polylang-fi.po
DELETED
@@ -1,585 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: polylang\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: \n"
|
6 |
-
"PO-Revision-Date: \n"
|
7 |
-
"Last-Translator: Jani Alha <tuki@wysiwyg.fi>\n"
|
8 |
-
"Language-Team: \n"
|
9 |
-
"Language: fi\n"
|
10 |
-
"MIME-Version: 1.0\n"
|
11 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
-
"Content-Transfer-Encoding: 8bit\n"
|
13 |
-
"Plural-Forms: nplurals=2: nplural=n>1;\n"
|
14 |
-
"X-Poedit-SourceCharset: utf-8\n"
|
15 |
-
"X-Poedit-KeywordsList: _e;__;_x\n"
|
16 |
-
"X-Poedit-Basepath: .\n"
|
17 |
-
"X-Generator: Poedit 1.5.4\n"
|
18 |
-
"X-Poedit-SearchPath-0: ..\n"
|
19 |
-
"X-Poedit-SearchPath-1: ../include\n"
|
20 |
-
|
21 |
-
#: admin/view-about.php:3
|
22 |
-
#, php-format
|
23 |
-
msgid ""
|
24 |
-
"Polylang is provided with an extensive %sdocumentation%s (in English only). "
|
25 |
-
"It includes information on how to set up your multilingual site and use it "
|
26 |
-
"on a daily basis, a FAQ, as well as a documentation for programmers to adapt "
|
27 |
-
"their plugins and themes."
|
28 |
-
msgstr ""
|
29 |
-
"Polylang toimitetaan kattavan %sdokumentaation%s kanssa (vain englanniksi). "
|
30 |
-
"Se sisältää tietoa kuinka perustat monikielisen sivuston ja käytät sitä "
|
31 |
-
"päivittäisessä käytössä, UKK:t sekä dokumentaation ohjelmoijille lisäosien "
|
32 |
-
"ja teemojen sovittamiseksi."
|
33 |
-
|
34 |
-
#: admin/view-about.php:9
|
35 |
-
#, php-format
|
36 |
-
msgid ""
|
37 |
-
"You will also find useful information in the %ssupport forum%s. However "
|
38 |
-
"don't forget to make a search before posting a new topic."
|
39 |
-
msgstr ""
|
40 |
-
"Tarpeellista tietoa löydät myös %stukifoorumilta%s. Älä kuitenkaan unohda "
|
41 |
-
"tehdä hakua ennen uuden viestin lähettämistä."
|
42 |
-
|
43 |
-
#: admin/view-about.php:16
|
44 |
-
#, php-format
|
45 |
-
msgid ""
|
46 |
-
"Polylang is free of charge and is released under the same license as "
|
47 |
-
"WordPress, the %sGPL%s."
|
48 |
-
msgstr ""
|
49 |
-
"Polylang on ilmainen ja se on julkaistu saman lisenssin alla kuin WordPress, "
|
50 |
-
"%sGPL%s."
|
51 |
-
|
52 |
-
#: admin/view-about.php:22
|
53 |
-
#, php-format
|
54 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
55 |
-
msgstr "Mikäli mietit kuinka voit auttaa projektia, %slue tämä%s."
|
56 |
-
|
57 |
-
#: admin/view-about.php:27
|
58 |
-
msgid ""
|
59 |
-
"Finally if you like this plugin or if it helps your business, donations to "
|
60 |
-
"the author are greatly appreciated."
|
61 |
-
msgstr ""
|
62 |
-
"Mikäli pidit tästä lisäosasta tai se auttaa yritystäsi, lahjoituksia "
|
63 |
-
"tekijälle arvostetaan suuresti."
|
64 |
-
|
65 |
-
#: admin/admin-filters-post.php:115 admin/admin.php:90 admin/settings.php:70
|
66 |
-
#: admin/settings.php:97 include/model.php:561
|
67 |
-
msgid "Languages"
|
68 |
-
msgstr "Kielet"
|
69 |
-
|
70 |
-
#: include/switcher.php:22
|
71 |
-
msgid "Displays language names"
|
72 |
-
msgstr "Näytä kielien nimet"
|
73 |
-
|
74 |
-
#: include/switcher.php:23
|
75 |
-
msgid "Displays flags"
|
76 |
-
msgstr "Näytä liput"
|
77 |
-
|
78 |
-
#: include/switcher.php:24
|
79 |
-
msgid "Forces link to front page"
|
80 |
-
msgstr "Pakottaa linkin etusivulle"
|
81 |
-
|
82 |
-
#: include/switcher.php:25
|
83 |
-
msgid "Hides the current language"
|
84 |
-
msgstr "Piilottaa nykyisen kielen"
|
85 |
-
|
86 |
-
#: include/switcher.php:30
|
87 |
-
msgid "Displays as dropdown"
|
88 |
-
msgstr "Näytä pudotusvalikkona"
|
89 |
-
|
90 |
-
#: admin/admin.php:267
|
91 |
-
msgid "Filters content by language"
|
92 |
-
msgstr "Suodata sisältöä kielen mukaan"
|
93 |
-
|
94 |
-
#: admin/admin.php:258
|
95 |
-
msgid "Show all languages"
|
96 |
-
msgstr "Näytä kaikki kielet"
|
97 |
-
|
98 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
99 |
-
msgid "Add new translation"
|
100 |
-
msgstr "Lisää uusi käännös"
|
101 |
-
|
102 |
-
#: admin/admin-filters-columns.php:173 admin/admin-filters-media.php:55
|
103 |
-
#: admin/admin-filters-post.php:141 admin/admin-filters-term.php:75
|
104 |
-
#: admin/admin-filters-term.php:122 include/model.php:562
|
105 |
-
msgid "Language"
|
106 |
-
msgstr "Kieli"
|
107 |
-
|
108 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
109 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
110 |
-
#: admin/view-translations-term.php:11
|
111 |
-
msgid "Translations"
|
112 |
-
msgstr "Käännökset"
|
113 |
-
|
114 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
115 |
-
msgid "Sets the language"
|
116 |
-
msgstr "Aseta kieli"
|
117 |
-
|
118 |
-
#: admin/admin-filters.php:52
|
119 |
-
msgid "The widget is displayed for:"
|
120 |
-
msgstr "Vimpain näytetään:"
|
121 |
-
|
122 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
123 |
-
msgid "All languages"
|
124 |
-
msgstr "Kaikki kielet"
|
125 |
-
|
126 |
-
#: admin/admin-filters.php:123
|
127 |
-
msgid "Admin language"
|
128 |
-
msgstr "Ylläpidon kieli"
|
129 |
-
|
130 |
-
#: admin/admin-filters.php:126
|
131 |
-
msgid "WordPress default"
|
132 |
-
msgstr "WordPress oletus"
|
133 |
-
|
134 |
-
#: admin/admin.php:167 admin/settings.php:102
|
135 |
-
msgid "Settings"
|
136 |
-
msgstr "Asetukset"
|
137 |
-
|
138 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
139 |
-
msgid "Upgrading language files…"
|
140 |
-
msgstr "Päivitetään kielitiedostoja…"
|
141 |
-
|
142 |
-
#: admin/settings.php:62
|
143 |
-
msgid "About Polylang"
|
144 |
-
msgstr "Tietoja Polylang:sta"
|
145 |
-
|
146 |
-
#: admin/settings.php:78
|
147 |
-
msgid "Strings translations"
|
148 |
-
msgstr "Merkkijonojen käännökset"
|
149 |
-
|
150 |
-
#: admin/settings.php:101
|
151 |
-
msgid "Strings translation"
|
152 |
-
msgstr "Merkkijonojen käännös"
|
153 |
-
|
154 |
-
#: admin/admin-model.php:244
|
155 |
-
msgid "Enter a valid WordPress locale"
|
156 |
-
msgstr "Syötä oikeanmuotoinen WordPress lokaali"
|
157 |
-
|
158 |
-
#: admin/admin-model.php:252
|
159 |
-
msgid "The language code must be unique"
|
160 |
-
msgstr "Kielikoodin täytyy olla uniikki"
|
161 |
-
|
162 |
-
#: admin/admin-model.php:256
|
163 |
-
msgid "The language must have a name"
|
164 |
-
msgstr "Kielellä täytyy olla nimi"
|
165 |
-
|
166 |
-
#: admin/admin.php:367 admin/settings.php:180
|
167 |
-
msgid ""
|
168 |
-
"The language was created, but the WordPress language file was not "
|
169 |
-
"downloaded. Please install it manually."
|
170 |
-
msgstr ""
|
171 |
-
"Kieli luotiin, mutta WordPress-kielitiedostoa ei ladattu. Asenna se käsin."
|
172 |
-
|
173 |
-
#: admin/admin-strings.php:59
|
174 |
-
msgid "Widget title"
|
175 |
-
msgstr "Vimpaimen otsikko"
|
176 |
-
|
177 |
-
# @ polylang
|
178 |
-
#: admin/settings.php:319
|
179 |
-
msgid "Taxonomies"
|
180 |
-
msgstr "Luokittelut"
|
181 |
-
|
182 |
-
# @ polylang
|
183 |
-
#: admin/settings.php:320
|
184 |
-
msgid "Custom fields"
|
185 |
-
msgstr "Mukautetut kentät"
|
186 |
-
|
187 |
-
# @ polylang
|
188 |
-
#: admin/settings.php:321
|
189 |
-
msgid "Comment status"
|
190 |
-
msgstr "Kommentin tila"
|
191 |
-
|
192 |
-
# @ polylang
|
193 |
-
#: admin/settings.php:322
|
194 |
-
msgid "Ping status"
|
195 |
-
msgstr "Ping-tila"
|
196 |
-
|
197 |
-
# @ polylang
|
198 |
-
#: admin/settings.php:323
|
199 |
-
msgid "Sticky posts"
|
200 |
-
msgstr "Kiinnitetyt artikkelit"
|
201 |
-
|
202 |
-
# @ polylang
|
203 |
-
#: admin/settings.php:324
|
204 |
-
msgid "Published date"
|
205 |
-
msgstr "Julkaisupäivämäärä"
|
206 |
-
|
207 |
-
# @ polylang
|
208 |
-
#: admin/settings.php:325
|
209 |
-
msgid "Post format"
|
210 |
-
msgstr "Artikkelin muoto"
|
211 |
-
|
212 |
-
#: admin/settings.php:326
|
213 |
-
msgid "Page parent"
|
214 |
-
msgstr "Sivun yläsivu"
|
215 |
-
|
216 |
-
# @ polylang
|
217 |
-
#: admin/settings.php:327
|
218 |
-
msgid "Page template"
|
219 |
-
msgstr "Sivun sivupohja"
|
220 |
-
|
221 |
-
#: admin/settings.php:328
|
222 |
-
msgid "Page order"
|
223 |
-
msgstr "Sivun järjestys"
|
224 |
-
|
225 |
-
# @ polylang
|
226 |
-
#: admin/settings.php:329
|
227 |
-
msgid "Featured image"
|
228 |
-
msgstr "Artikkelikuva"
|
229 |
-
|
230 |
-
#: admin/view-tab-lang.php:21
|
231 |
-
msgid "Edit language"
|
232 |
-
msgstr "Muokkaa kieltä"
|
233 |
-
|
234 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
235 |
-
msgid "Add new language"
|
236 |
-
msgstr "Lisää uusi kieli"
|
237 |
-
|
238 |
-
#: admin/view-tab-lang.php:37
|
239 |
-
msgid "Choose a language"
|
240 |
-
msgstr "Valitse kieli"
|
241 |
-
|
242 |
-
#: admin/view-tab-lang.php:51
|
243 |
-
msgid "You can choose a language in the list or directly edit it below."
|
244 |
-
msgstr "Voit valita kielen listalta tai muokata sitä suoraan alla."
|
245 |
-
|
246 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
247 |
-
msgid "Full name"
|
248 |
-
msgstr "Täydellinen nimi"
|
249 |
-
|
250 |
-
#: admin/view-tab-lang.php:57
|
251 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
252 |
-
msgstr "Nimi kuinka se esiintyy sivustollasi (esimerkiksi: Englanti)."
|
253 |
-
|
254 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
255 |
-
msgid "Locale"
|
256 |
-
msgstr "Lokaali"
|
257 |
-
|
258 |
-
#: admin/view-tab-lang.php:66
|
259 |
-
msgid ""
|
260 |
-
"WordPress Locale for the language (for example: en_US). You will need to "
|
261 |
-
"install the .mo file for this language."
|
262 |
-
msgstr ""
|
263 |
-
"WordPress lokaali tälle kielelle (esimerkiksi: en_US). Sinun pitää asentaa ."
|
264 |
-
"mo-tiedosto tälle kielelle."
|
265 |
-
|
266 |
-
#: admin/view-tab-lang.php:70
|
267 |
-
msgid "Language code"
|
268 |
-
msgstr "Kielikoodi"
|
269 |
-
|
270 |
-
#: admin/view-tab-lang.php:76
|
271 |
-
msgid "Text direction"
|
272 |
-
msgstr "Tekstin suunta"
|
273 |
-
|
274 |
-
#: admin/view-tab-lang.php:80
|
275 |
-
msgid "left to right"
|
276 |
-
msgstr "vasemmalta oikealle"
|
277 |
-
|
278 |
-
#: admin/view-tab-lang.php:85
|
279 |
-
msgid "right to left"
|
280 |
-
msgstr "oikealta vasemmalle"
|
281 |
-
|
282 |
-
#: admin/view-tab-lang.php:87
|
283 |
-
msgid "Choose the text direction for the language"
|
284 |
-
msgstr "Valitse kielen tekstin suunta"
|
285 |
-
|
286 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
287 |
-
msgid "Order"
|
288 |
-
msgstr "Järjestys"
|
289 |
-
|
290 |
-
#: admin/view-tab-lang.php:93
|
291 |
-
msgid "Position of the language in the language switcher"
|
292 |
-
msgstr "Kielen sijainti kielivalinnassa"
|
293 |
-
|
294 |
-
#: admin/admin-nav-menu.php:54 admin/admin-nav-menu.php:92
|
295 |
-
#: admin/admin-nav-menu.php:95 admin/admin-nav-menu.php:126
|
296 |
-
#: admin/admin-nav-menu.php:188 install/upgrade.php:301
|
297 |
-
msgid "Language switcher"
|
298 |
-
msgstr "Kielivalinta"
|
299 |
-
|
300 |
-
#: admin/view-tab-strings.php:8
|
301 |
-
msgid "Search translations"
|
302 |
-
msgstr "Haun käännökset"
|
303 |
-
|
304 |
-
#: admin/view-tab-strings.php:11
|
305 |
-
msgid "Clean strings translation database"
|
306 |
-
msgstr "Tyhjennä merkkijonot käännöstietokannasta"
|
307 |
-
|
308 |
-
#: admin/view-tab-settings.php:14
|
309 |
-
msgid "Default language"
|
310 |
-
msgstr "Oletuskieli"
|
311 |
-
|
312 |
-
#: admin/view-tab-settings.php:29
|
313 |
-
msgid ""
|
314 |
-
"There are posts, pages, categories or tags without language set. Do you want "
|
315 |
-
"to set them all to default language ?"
|
316 |
-
msgstr ""
|
317 |
-
"Siellä on artikkeleita, sivuja, kategorioita tai tageja ilman asetettua "
|
318 |
-
"kieltä. Haluatko asettaa ne oletuskielelle?"
|
319 |
-
|
320 |
-
#: admin/view-tab-settings.php:149
|
321 |
-
msgid "Detect browser language"
|
322 |
-
msgstr "Tunnista selaimen kieli"
|
323 |
-
|
324 |
-
#: admin/view-tab-settings.php:155
|
325 |
-
msgid ""
|
326 |
-
"When the front page is visited, set the language according to the browser "
|
327 |
-
"preference"
|
328 |
-
msgstr "Kun etusivulla vieraillaan, aseta kieli selaimen asetuksen mukaan"
|
329 |
-
|
330 |
-
#: admin/view-tab-settings.php:37
|
331 |
-
msgid "URL modifications"
|
332 |
-
msgstr "URL muunnokset"
|
333 |
-
|
334 |
-
#: admin/view-tab-settings.php:93
|
335 |
-
msgid "Hide URL language information for default language"
|
336 |
-
msgstr "Piilota URL-osoitteen kielitieto oletuskieleltä"
|
337 |
-
|
338 |
-
# @ polylang
|
339 |
-
#: admin/view-tab-settings.php:162
|
340 |
-
msgid "Media"
|
341 |
-
msgstr "Media"
|
342 |
-
|
343 |
-
# @ polylang
|
344 |
-
#: admin/view-tab-settings.php:168
|
345 |
-
msgid "Activate languages and translations for media"
|
346 |
-
msgstr "Aktivoi kielet ja käännökset mediassa."
|
347 |
-
|
348 |
-
#: admin/view-tab-settings.php:215
|
349 |
-
msgid "Synchronization"
|
350 |
-
msgstr "Synkronointi"
|
351 |
-
|
352 |
-
# @ polylang
|
353 |
-
#: admin/view-tab-settings.php:176
|
354 |
-
msgid "Custom post types"
|
355 |
-
msgstr "Mukautetut artikkelien mallit"
|
356 |
-
|
357 |
-
# @ polylang
|
358 |
-
#: admin/view-tab-settings.php:189
|
359 |
-
msgid "Activate languages and translations for custom post types."
|
360 |
-
msgstr "Aktivoi kielet ja käännökset mukautettujen artikkelien malleissa."
|
361 |
-
|
362 |
-
# @ polylang
|
363 |
-
#: admin/view-tab-settings.php:196
|
364 |
-
msgid "Custom taxonomies"
|
365 |
-
msgstr "Mukautetut luokittelut"
|
366 |
-
|
367 |
-
# @ polylang
|
368 |
-
#: admin/view-tab-settings.php:209
|
369 |
-
msgid "Activate languages and translations for custom taxonomies."
|
370 |
-
msgstr "Aktivoi kielet ja käännökset mukautettuissa luokitteluissa."
|
371 |
-
|
372 |
-
#: admin/admin-filters-post.php:433 admin/admin-filters-term.php:642
|
373 |
-
#: admin/table-languages.php:54 admin/view-translations-media.php:21
|
374 |
-
msgid "Edit"
|
375 |
-
msgstr "Muokkaa"
|
376 |
-
|
377 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
378 |
-
msgid "Delete"
|
379 |
-
msgstr "Poista"
|
380 |
-
|
381 |
-
#: admin/table-languages.php:76
|
382 |
-
msgid "Code"
|
383 |
-
msgstr "Koodi"
|
384 |
-
|
385 |
-
#: admin/table-languages.php:78
|
386 |
-
msgid "Flag"
|
387 |
-
msgstr "Lippu"
|
388 |
-
|
389 |
-
#: admin/table-languages.php:79
|
390 |
-
msgid "Posts"
|
391 |
-
msgstr "Artikkelit"
|
392 |
-
|
393 |
-
#: admin/table-string.php:110
|
394 |
-
msgid "Name"
|
395 |
-
msgstr "Nimi"
|
396 |
-
|
397 |
-
#: admin/table-string.php:111
|
398 |
-
msgid "String"
|
399 |
-
msgstr "Merkkijono"
|
400 |
-
|
401 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
402 |
-
#: admin/view-translations-term.php:30
|
403 |
-
msgid "Add new"
|
404 |
-
msgstr "Lisää uusi"
|
405 |
-
|
406 |
-
#: include/widget-languages.php:16
|
407 |
-
msgid "Language Switcher"
|
408 |
-
msgstr "Kielivalinta"
|
409 |
-
|
410 |
-
#: include/widget-languages.php:16
|
411 |
-
msgid "Displays a language switcher"
|
412 |
-
msgstr "Näytä kielivalinta"
|
413 |
-
|
414 |
-
#: include/widget-languages.php:75
|
415 |
-
msgid "Title:"
|
416 |
-
msgstr "Otsikko:"
|
417 |
-
|
418 |
-
# @ polylang
|
419 |
-
#. translators: plugin header field 'Description'
|
420 |
-
#: polylang.php:0
|
421 |
-
msgid "Adds multilingual capability to WordPress"
|
422 |
-
msgstr "Lisää monikielisyyden tuen WordPressiin"
|
423 |
-
|
424 |
-
#: install/install.php:24
|
425 |
-
#, php-format
|
426 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
427 |
-
msgstr ""
|
428 |
-
"Käytät WordPress versiota %s. Polylang vaatii vähintään WordPress version %s."
|
429 |
-
|
430 |
-
# @ polylang
|
431 |
-
#: install/upgrade.php:76
|
432 |
-
msgid ""
|
433 |
-
"Polylang has been deactivated because you upgraded from a too old version."
|
434 |
-
msgstr ""
|
435 |
-
"Polylang on poistettu käytöstä, koska päivitit liian vanhasta versiosta."
|
436 |
-
|
437 |
-
# @ polylang
|
438 |
-
#: install/upgrade.php:78
|
439 |
-
#, php-format
|
440 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
441 |
-
msgstr "Päivitä ensin versioon %s ennen kuin päivität %s."
|
442 |
-
|
443 |
-
# @ polylang
|
444 |
-
#: admin/table-string.php:109
|
445 |
-
msgid "Group"
|
446 |
-
msgstr "Ryhmä"
|
447 |
-
|
448 |
-
# @ polylang
|
449 |
-
#: admin/table-string.php:187
|
450 |
-
msgid "View all groups"
|
451 |
-
msgstr "Näytä kaikki ryhmät"
|
452 |
-
|
453 |
-
# @ polylang
|
454 |
-
#: admin/table-languages.php:59
|
455 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
456 |
-
msgstr "Olet aikaissa pysyvästi poistaa tämän kielen. Oletko varma?"
|
457 |
-
|
458 |
-
# @ polylang
|
459 |
-
#: admin/view-tab-strings.php:12
|
460 |
-
msgid ""
|
461 |
-
"Use this to remove unused strings from database, for example after a plugin "
|
462 |
-
"has been uninstalled."
|
463 |
-
msgstr ""
|
464 |
-
"Käytä tätä poistaaksesi käyttämättömät merkkijonot tietokannasta, "
|
465 |
-
"esimerkiksi lisäosan poiston jälkeen."
|
466 |
-
|
467 |
-
# @ polylang
|
468 |
-
#: admin/view-tab-settings.php:226
|
469 |
-
msgid ""
|
470 |
-
"The synchronization options allow to maintain exact same values (or "
|
471 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
472 |
-
"between the translations of a post or page."
|
473 |
-
msgstr ""
|
474 |
-
"Synkrorointiasetukset sallivat samojen arvojen säilyttämisen (tai "
|
475 |
-
"taksonomioiden käännösten olleessa kyseessä) metatietojen artikkelien tai "
|
476 |
-
"sivujen välillä."
|
477 |
-
|
478 |
-
#: admin/admin-model.php:248
|
479 |
-
msgid "The language code contains invalid characters"
|
480 |
-
msgstr "Kielikoodi sisältää virhellisiä merkkejä"
|
481 |
-
|
482 |
-
#: admin/view-tab-settings.php:43
|
483 |
-
msgid "The language is set from content"
|
484 |
-
msgstr "Kieli on asetettu sisällöstä"
|
485 |
-
|
486 |
-
#: admin/view-tab-settings.php:46
|
487 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
488 |
-
msgstr ""
|
489 |
-
"Artikkelien, sivujen, kategorioiden ja avainsanojen url-osoitteet eivät ole "
|
490 |
-
"muokattuja."
|
491 |
-
|
492 |
-
#: admin/view-tab-settings.php:51
|
493 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
494 |
-
msgstr ""
|
495 |
-
"Kieli on asetettu hakemiston nimestä käyttäjäystävällisissä kestolinkeissä"
|
496 |
-
|
497 |
-
# @ polylang
|
498 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
499 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
500 |
-
msgid "Example:"
|
501 |
-
msgstr "Esimerkki:"
|
502 |
-
|
503 |
-
#: admin/view-tab-settings.php:60
|
504 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
505 |
-
msgstr ""
|
506 |
-
"Kieli on asetettu aliverkkotunnuksesta käyttäjäystävällisissä kestolinkeissä"
|
507 |
-
|
508 |
-
# @ polylang
|
509 |
-
#: admin/view-tab-settings.php:69
|
510 |
-
msgid "The language is set from different domains"
|
511 |
-
msgstr "Kieli on asetettu eri verkkotunnukselle"
|
512 |
-
|
513 |
-
#: admin/view-tab-settings.php:107
|
514 |
-
msgid "Remove /language/ in pretty permalinks"
|
515 |
-
msgstr "Poista /kieli/ käyttäjäystävällisistä kestolinkeistä"
|
516 |
-
|
517 |
-
#: admin/view-tab-settings.php:116
|
518 |
-
msgid "Keep /language/ in pretty permalinks"
|
519 |
-
msgstr "Säilytä /kieli/ käyttäjäystävällisissä kestolinkeissä"
|
520 |
-
|
521 |
-
# @ polylang
|
522 |
-
#: admin/view-tab-settings.php:131
|
523 |
-
msgid ""
|
524 |
-
"The front page url contains the language code instead of the page name or "
|
525 |
-
"page id"
|
526 |
-
msgstr ""
|
527 |
-
"Etusivun url-osoite sisältää kielikoodin sivun nimen tai sivun tunnisteen "
|
528 |
-
"sijasta"
|
529 |
-
|
530 |
-
# @ polylang
|
531 |
-
#: admin/view-tab-settings.php:139
|
532 |
-
#, php-format
|
533 |
-
msgid "Example: %s instead of %s"
|
534 |
-
msgstr "Esimerkki: %s %s sijasta"
|
535 |
-
|
536 |
-
#: admin/admin-model.php:38
|
537 |
-
msgid "Impossible to add the language."
|
538 |
-
msgstr "Kielen lisääminen on mahdotonta."
|
539 |
-
|
540 |
-
# @ polylang
|
541 |
-
#: admin/admin-model.php:66
|
542 |
-
msgid "Language added."
|
543 |
-
msgstr "Kieli lisätty."
|
544 |
-
|
545 |
-
# @ polylang
|
546 |
-
#: admin/admin-model.php:146
|
547 |
-
msgid "Language deleted."
|
548 |
-
msgstr "Kieli poistettu."
|
549 |
-
|
550 |
-
# @ polylang
|
551 |
-
#: admin/admin-model.php:227
|
552 |
-
msgid "Language updated."
|
553 |
-
msgstr "Kieli päivitetty."
|
554 |
-
|
555 |
-
# @ polylang
|
556 |
-
#: admin/settings.php:239
|
557 |
-
msgid "Translations updated."
|
558 |
-
msgstr "Käännökset päivitetty."
|
559 |
-
|
560 |
-
#: admin/view-tab-lang.php:72
|
561 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
562 |
-
msgstr "Kielikoodi - mieluiten 2-kirjainta ISO 639-1 (esimerkiksi: en)"
|
563 |
-
|
564 |
-
# @ polylang
|
565 |
-
#: admin/admin-filters.php:203
|
566 |
-
msgid "The chosen static front page must be translated in all languages."
|
567 |
-
msgstr "Valittu staattinen etusivu täytyy täytyy kääntää kaikille kielille."
|
568 |
-
|
569 |
-
#: admin/admin-strings.php:60
|
570 |
-
msgid "Widget text"
|
571 |
-
msgstr "Vimpaimen teksti"
|
572 |
-
|
573 |
-
# @ polylang
|
574 |
-
#: admin/settings.php:52
|
575 |
-
msgid "Recommended plugins"
|
576 |
-
msgstr ""
|
577 |
-
|
578 |
-
#: admin/view-tab-settings.php:51
|
579 |
-
msgid "The language is set from the code in the URL"
|
580 |
-
msgstr ""
|
581 |
-
|
582 |
-
# @ polylang
|
583 |
-
#: include/switcher.php:26
|
584 |
-
msgid "Hides languages with no translation"
|
585 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-hr.mo
DELETED
Binary file
|
languages/polylang-hr.po
DELETED
@@ -1,667 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: Polylang v1.5\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: \n"
|
6 |
-
"PO-Revision-Date: 2015-02-14 09:18+0100\n"
|
7 |
-
"Last-Translator: \n"
|
8 |
-
"Language-Team: capa-pub Team <gbajro@gmail.com>\n"
|
9 |
-
"MIME-Version: 1.0\n"
|
10 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
-
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
13 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
14 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
15 |
-
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
|
16 |
-
"X-Poedit-Basepath: ../\n"
|
17 |
-
"X-Textdomain-Support: yes\n"
|
18 |
-
"X-Generator: Poedit 1.5.4\n"
|
19 |
-
"Language: hr\n"
|
20 |
-
"X-Poedit-SearchPath-0: .\n"
|
21 |
-
|
22 |
-
# @ polylang
|
23 |
-
#: admin/view-about.php:3
|
24 |
-
#, php-format
|
25 |
-
msgid ""
|
26 |
-
"Polylang is provided with an extensive %sdocumentation%s (in English only). "
|
27 |
-
"It includes information on how to set up your multilingual site and use it "
|
28 |
-
"on a daily basis, a FAQ, as well as a documentation for programmers to adapt "
|
29 |
-
"their plugins and themes."
|
30 |
-
msgstr ""
|
31 |
-
"Polylang sadrži detaljnu %sdokumentaciju%s (samo na engleskom). Ona sadrži "
|
32 |
-
"podatke kako podesiti vaš višejezični web i kako ga koristiti na dnevnoj "
|
33 |
-
"bazi; često postavljana pitanja kao i dokumentaciju za programere da "
|
34 |
-
"prilagode njihove dodatke i teme."
|
35 |
-
|
36 |
-
# @ polylang
|
37 |
-
#: admin/view-about.php:9
|
38 |
-
#, php-format
|
39 |
-
msgid ""
|
40 |
-
"You will also find useful information in the %ssupport forum%s. However "
|
41 |
-
"don't forget to make a search before posting a new topic."
|
42 |
-
msgstr ""
|
43 |
-
"Korisne informacije ćete pronaći i na %sforumima podrške%s. Probajte prvo "
|
44 |
-
"potražiti odgovor na neko pitanje prije nego pošaljete novi upit."
|
45 |
-
|
46 |
-
# @ polylang
|
47 |
-
#: admin/view-about.php:16
|
48 |
-
#, php-format
|
49 |
-
msgid ""
|
50 |
-
"Polylang is free of charge and is released under the same license as "
|
51 |
-
"WordPress, the %sGPL%s."
|
52 |
-
msgstr ""
|
53 |
-
"Polylang je besplatan i objavljen pod istom licencom kao i "
|
54 |
-
"WordPress, %sGPL%s."
|
55 |
-
|
56 |
-
# @ polylang
|
57 |
-
#: admin/view-about.php:22
|
58 |
-
#, php-format
|
59 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
60 |
-
msgstr "Ako se pitate kako pomoći projektu, samo %spročitajte ovo%s."
|
61 |
-
|
62 |
-
# @ polylang
|
63 |
-
#: admin/view-about.php:27
|
64 |
-
msgid ""
|
65 |
-
"Finally if you like this plugin or if it helps your business, donations to "
|
66 |
-
"the author are greatly appreciated."
|
67 |
-
msgstr ""
|
68 |
-
"Na kraju, ako vam ovaj dodatak pomaže u poslu ili vam se jednostavno sviđa, "
|
69 |
-
"donacije autoru su vrlo cijenjene."
|
70 |
-
|
71 |
-
# @ polylang
|
72 |
-
#: admin/admin-filters-post.php:115 admin/admin.php:90 admin/settings.php:70
|
73 |
-
#: admin/settings.php:97 include/model.php:561
|
74 |
-
msgid "Languages"
|
75 |
-
msgstr "Jezici"
|
76 |
-
|
77 |
-
# @ polylang
|
78 |
-
#: include/switcher.php:22
|
79 |
-
msgid "Displays language names"
|
80 |
-
msgstr "Prikazuje imena jezika"
|
81 |
-
|
82 |
-
# @ polylang
|
83 |
-
#: include/switcher.php:23
|
84 |
-
msgid "Displays flags"
|
85 |
-
msgstr "Prikazuje zastave"
|
86 |
-
|
87 |
-
# @ polylang
|
88 |
-
#: include/switcher.php:24
|
89 |
-
msgid "Forces link to front page"
|
90 |
-
msgstr "Forsira linkove do početne stranice"
|
91 |
-
|
92 |
-
# @ polylang
|
93 |
-
#: include/switcher.php:25
|
94 |
-
msgid "Hides the current language"
|
95 |
-
msgstr "Sakriva trenutni jezik"
|
96 |
-
|
97 |
-
# @ polylang
|
98 |
-
#: include/switcher.php:30
|
99 |
-
msgid "Displays as dropdown"
|
100 |
-
msgstr "Prikazuje kao spuštajući izbornik"
|
101 |
-
|
102 |
-
# @ polylang
|
103 |
-
#: admin/admin.php:267
|
104 |
-
msgid "Filters content by language"
|
105 |
-
msgstr "Filtrira sadržaj po jeziku"
|
106 |
-
|
107 |
-
# @ polylang
|
108 |
-
#: admin/admin.php:258
|
109 |
-
msgid "Show all languages"
|
110 |
-
msgstr "Prikazuje sve jezike"
|
111 |
-
|
112 |
-
# @ polylang
|
113 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
114 |
-
msgid "Add new translation"
|
115 |
-
msgstr "Dodaje novi prijevod"
|
116 |
-
|
117 |
-
# @ polylang
|
118 |
-
#: admin/admin-filters-columns.php:173 admin/admin-filters-media.php:55
|
119 |
-
#: admin/admin-filters-post.php:141 admin/admin-filters-term.php:75
|
120 |
-
#: admin/admin-filters-term.php:122 include/model.php:562
|
121 |
-
msgid "Language"
|
122 |
-
msgstr "Jezik"
|
123 |
-
|
124 |
-
# @ polylang
|
125 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
126 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
127 |
-
#: admin/view-translations-term.php:11
|
128 |
-
msgid "Translations"
|
129 |
-
msgstr "Prijevodi"
|
130 |
-
|
131 |
-
# @ polylang
|
132 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
133 |
-
msgid "Sets the language"
|
134 |
-
msgstr "Postavlja jezik"
|
135 |
-
|
136 |
-
# @ polylang
|
137 |
-
#: admin/admin-filters.php:52
|
138 |
-
msgid "The widget is displayed for:"
|
139 |
-
msgstr "Widget je prikazan za:"
|
140 |
-
|
141 |
-
# @ polylang
|
142 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
143 |
-
msgid "All languages"
|
144 |
-
msgstr "Svi jezici"
|
145 |
-
|
146 |
-
# @ polylang
|
147 |
-
#: admin/admin-filters.php:123
|
148 |
-
msgid "Admin language"
|
149 |
-
msgstr "Jezik administratora"
|
150 |
-
|
151 |
-
# @ polylang
|
152 |
-
#: admin/admin-filters.php:126
|
153 |
-
msgid "WordPress default"
|
154 |
-
msgstr "Standardna vrijednost WordPressa"
|
155 |
-
|
156 |
-
# @ polylang
|
157 |
-
#: admin/admin.php:167 admin/settings.php:102
|
158 |
-
msgid "Settings"
|
159 |
-
msgstr "Postavke"
|
160 |
-
|
161 |
-
# @ polylang
|
162 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
163 |
-
msgid "Upgrading language files…"
|
164 |
-
msgstr "Osvježavanje datoteka s jezikom …"
|
165 |
-
|
166 |
-
# @ polylang
|
167 |
-
#: admin/settings.php:62
|
168 |
-
msgid "About Polylang"
|
169 |
-
msgstr "O Polylangu"
|
170 |
-
|
171 |
-
# @ polylang
|
172 |
-
#: admin/settings.php:78
|
173 |
-
msgid "Strings translations"
|
174 |
-
msgstr "Prevođenje linija teksta"
|
175 |
-
|
176 |
-
# @ polylang
|
177 |
-
#: admin/settings.php:101
|
178 |
-
msgid "Strings translation"
|
179 |
-
msgstr "Prijevod linije teksta"
|
180 |
-
|
181 |
-
# @ polylang
|
182 |
-
#: admin/admin-model.php:244
|
183 |
-
msgid "Enter a valid WordPress locale"
|
184 |
-
msgstr "Unesite ispravan locale (jezik i set znakova) od WordPressa"
|
185 |
-
|
186 |
-
# @ polylang
|
187 |
-
#: admin/admin-model.php:252
|
188 |
-
msgid "The language code must be unique"
|
189 |
-
msgstr "Šifra jezika mora biti jedinstvena"
|
190 |
-
|
191 |
-
# @ polylang
|
192 |
-
#: admin/admin-model.php:256
|
193 |
-
msgid "The language must have a name"
|
194 |
-
msgstr "Jezik mora imati ime"
|
195 |
-
|
196 |
-
# @ polylang
|
197 |
-
#: admin/admin.php:367 admin/settings.php:180
|
198 |
-
msgid ""
|
199 |
-
"The language was created, but the WordPress language file was not "
|
200 |
-
"downloaded. Please install it manually."
|
201 |
-
msgstr ""
|
202 |
-
"Jezik je kreiran, ali datoteka jezika WordPressa nije skinuta. Molim da istu "
|
203 |
-
"instalirate ručno."
|
204 |
-
|
205 |
-
# @ polylang
|
206 |
-
#: admin/admin-strings.php:59
|
207 |
-
msgid "Widget title"
|
208 |
-
msgstr "Naslov widgeta"
|
209 |
-
|
210 |
-
# @ polylang
|
211 |
-
#: admin/settings.php:319
|
212 |
-
msgid "Taxonomies"
|
213 |
-
msgstr "Taksonomija"
|
214 |
-
|
215 |
-
# @ polylang
|
216 |
-
#: admin/settings.php:320
|
217 |
-
msgid "Custom fields"
|
218 |
-
msgstr "Vlastita polja"
|
219 |
-
|
220 |
-
# @ polylang
|
221 |
-
#: admin/settings.php:321
|
222 |
-
msgid "Comment status"
|
223 |
-
msgstr "Status komentara"
|
224 |
-
|
225 |
-
# @ polylang
|
226 |
-
#: admin/settings.php:322
|
227 |
-
msgid "Ping status"
|
228 |
-
msgstr "Status pinga"
|
229 |
-
|
230 |
-
# @ polylang
|
231 |
-
#: admin/settings.php:323
|
232 |
-
msgid "Sticky posts"
|
233 |
-
msgstr "Zalijepljeni postovi"
|
234 |
-
|
235 |
-
# @ polylang
|
236 |
-
#: admin/settings.php:324
|
237 |
-
msgid "Published date"
|
238 |
-
msgstr "Datum objave"
|
239 |
-
|
240 |
-
# @ polylang
|
241 |
-
#: admin/settings.php:325
|
242 |
-
msgid "Post format"
|
243 |
-
msgstr "Format posta"
|
244 |
-
|
245 |
-
# @ polylang
|
246 |
-
#: admin/settings.php:326
|
247 |
-
msgid "Page parent"
|
248 |
-
msgstr "Nadređena stranica"
|
249 |
-
|
250 |
-
# @ polylang
|
251 |
-
#: admin/settings.php:327
|
252 |
-
msgid "Page template"
|
253 |
-
msgstr "Predložak stranice"
|
254 |
-
|
255 |
-
# @ polylang
|
256 |
-
#: admin/settings.php:328
|
257 |
-
msgid "Page order"
|
258 |
-
msgstr "Redoslijed stranica"
|
259 |
-
|
260 |
-
# @ polylang
|
261 |
-
#: admin/settings.php:329
|
262 |
-
msgid "Featured image"
|
263 |
-
msgstr "Istaknuta slika"
|
264 |
-
|
265 |
-
# @ polylang
|
266 |
-
#: admin/view-tab-lang.php:21
|
267 |
-
msgid "Edit language"
|
268 |
-
msgstr "Mijenjaj jezik"
|
269 |
-
|
270 |
-
# @ polylang
|
271 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
272 |
-
msgid "Add new language"
|
273 |
-
msgstr "Dodavanje novog jezika"
|
274 |
-
|
275 |
-
# @ polylang
|
276 |
-
#: admin/view-tab-lang.php:37
|
277 |
-
msgid "Choose a language"
|
278 |
-
msgstr "Odaberite jezik"
|
279 |
-
|
280 |
-
# @ polylang
|
281 |
-
#: admin/view-tab-lang.php:51
|
282 |
-
msgid "You can choose a language in the list or directly edit it below."
|
283 |
-
msgstr "Možete odabrati jezik na popisu ili ga direktno upisati ispod."
|
284 |
-
|
285 |
-
# @ polylang
|
286 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
287 |
-
msgid "Full name"
|
288 |
-
msgstr "Puno ime"
|
289 |
-
|
290 |
-
# @ polylang
|
291 |
-
#: admin/view-tab-lang.php:57
|
292 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
293 |
-
msgstr "Ime kako je prikazano na vašim stranicama (primjerice: hrvatski)"
|
294 |
-
|
295 |
-
# @ polylang
|
296 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
297 |
-
msgid "Locale"
|
298 |
-
msgstr "Locale (kombinacija jezika i seta znakova)"
|
299 |
-
|
300 |
-
# @ polylang
|
301 |
-
#: admin/view-tab-lang.php:66
|
302 |
-
msgid ""
|
303 |
-
"WordPress Locale for the language (for example: en_US). You will need to "
|
304 |
-
"install the .mo file for this language."
|
305 |
-
msgstr ""
|
306 |
-
"WordPress locale za vaš jezik (primjerice hr). Morat ćete instalirati .mo "
|
307 |
-
"datoteku za vaš jezik."
|
308 |
-
|
309 |
-
# @ polylang
|
310 |
-
#: admin/view-tab-lang.php:70
|
311 |
-
msgid "Language code"
|
312 |
-
msgstr "Šifra jezika"
|
313 |
-
|
314 |
-
# @ polylang
|
315 |
-
#: admin/view-tab-lang.php:76
|
316 |
-
msgid "Text direction"
|
317 |
-
msgstr "Smjer teksta"
|
318 |
-
|
319 |
-
# @ polylang
|
320 |
-
#: admin/view-tab-lang.php:80
|
321 |
-
msgid "left to right"
|
322 |
-
msgstr "s lijeva na desno"
|
323 |
-
|
324 |
-
# @ polylang
|
325 |
-
#: admin/view-tab-lang.php:85
|
326 |
-
msgid "right to left"
|
327 |
-
msgstr "s desna na lijevo"
|
328 |
-
|
329 |
-
# @ polylang
|
330 |
-
#: admin/view-tab-lang.php:87
|
331 |
-
msgid "Choose the text direction for the language"
|
332 |
-
msgstr "Odaberite smjer teksta za jezik"
|
333 |
-
|
334 |
-
# @ polylang
|
335 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
336 |
-
msgid "Order"
|
337 |
-
msgstr "Redoslijed"
|
338 |
-
|
339 |
-
# @ polylang
|
340 |
-
#: admin/view-tab-lang.php:93
|
341 |
-
msgid "Position of the language in the language switcher"
|
342 |
-
msgstr "Pozicija jezika na popisu jezika"
|
343 |
-
|
344 |
-
# @ polylang
|
345 |
-
#: admin/admin-nav-menu.php:54 admin/admin-nav-menu.php:92
|
346 |
-
#: admin/admin-nav-menu.php:95 admin/admin-nav-menu.php:126
|
347 |
-
#: admin/admin-nav-menu.php:188 install/upgrade.php:301
|
348 |
-
msgid "Language switcher"
|
349 |
-
msgstr "Mijenjanje jezika"
|
350 |
-
|
351 |
-
# @ polylang
|
352 |
-
#: admin/view-tab-strings.php:8
|
353 |
-
msgid "Search translations"
|
354 |
-
msgstr "Pretraga za prijevodima"
|
355 |
-
|
356 |
-
# @ polylang
|
357 |
-
#: admin/view-tab-strings.php:11
|
358 |
-
msgid "Clean strings translation database"
|
359 |
-
msgstr "Počisti bazu prevedenih linija"
|
360 |
-
|
361 |
-
# @ polylang
|
362 |
-
#: admin/view-tab-settings.php:14
|
363 |
-
msgid "Default language"
|
364 |
-
msgstr "Originalni jezik"
|
365 |
-
|
366 |
-
# @ polylang
|
367 |
-
#: admin/view-tab-settings.php:29
|
368 |
-
msgid ""
|
369 |
-
"There are posts, pages, categories or tags without language set. Do you want "
|
370 |
-
"to set them all to default language ?"
|
371 |
-
msgstr ""
|
372 |
-
"Postoje članci, stranice, kategorije i tagovi bez postavljenog jezika. "
|
373 |
-
"Želite li da se svi postave na osnovni jezik?"
|
374 |
-
|
375 |
-
# @ polylang
|
376 |
-
#: admin/view-tab-settings.php:149
|
377 |
-
msgid "Detect browser language"
|
378 |
-
msgstr "Otkrij jezik u browseru"
|
379 |
-
|
380 |
-
# @ polylang
|
381 |
-
#: admin/view-tab-settings.php:155
|
382 |
-
msgid ""
|
383 |
-
"When the front page is visited, set the language according to the browser "
|
384 |
-
"preference"
|
385 |
-
msgstr ""
|
386 |
-
"Kada se otvori naslovna stranica, postavi jezik ovisno o postavkama browsera"
|
387 |
-
|
388 |
-
# @ polylang
|
389 |
-
#: admin/view-tab-settings.php:37
|
390 |
-
msgid "URL modifications"
|
391 |
-
msgstr "Prilagodbe URL-a"
|
392 |
-
|
393 |
-
# @ polylang
|
394 |
-
#: admin/view-tab-settings.php:93
|
395 |
-
msgid "Hide URL language information for default language"
|
396 |
-
msgstr "Sakrij informacije o jeziku u URL-u za osnovni jezik"
|
397 |
-
|
398 |
-
# @ polylang
|
399 |
-
#: admin/view-tab-settings.php:162
|
400 |
-
msgid "Media"
|
401 |
-
msgstr "Medij"
|
402 |
-
|
403 |
-
# @ polylang
|
404 |
-
#: admin/view-tab-settings.php:168
|
405 |
-
msgid "Activate languages and translations for media"
|
406 |
-
msgstr "Aktivirajte jezike i prijevode za medije"
|
407 |
-
|
408 |
-
# @ polylang
|
409 |
-
#: admin/view-tab-settings.php:215
|
410 |
-
msgid "Synchronization"
|
411 |
-
msgstr "Sinkronizacija"
|
412 |
-
|
413 |
-
# @ polylang
|
414 |
-
#: admin/view-tab-settings.php:176
|
415 |
-
msgid "Custom post types"
|
416 |
-
msgstr "Prilagođeni tipovi postova"
|
417 |
-
|
418 |
-
# @ polylang
|
419 |
-
#: admin/view-tab-settings.php:189
|
420 |
-
msgid "Activate languages and translations for custom post types."
|
421 |
-
msgstr "Aktivirajte jezike i prijevode za vlastite tipove postova."
|
422 |
-
|
423 |
-
# @ polylang
|
424 |
-
#: admin/view-tab-settings.php:196
|
425 |
-
msgid "Custom taxonomies"
|
426 |
-
msgstr "Prilagođene taksonomije"
|
427 |
-
|
428 |
-
# @ polylang
|
429 |
-
#: admin/view-tab-settings.php:209
|
430 |
-
msgid "Activate languages and translations for custom taxonomies."
|
431 |
-
msgstr "Aktivirajte jezike i prijevode za prilagođene taksonomije"
|
432 |
-
|
433 |
-
# @ polylang
|
434 |
-
#: admin/admin-filters-post.php:433 admin/admin-filters-term.php:642
|
435 |
-
#: admin/table-languages.php:54 admin/view-translations-media.php:21
|
436 |
-
msgid "Edit"
|
437 |
-
msgstr "Uredi"
|
438 |
-
|
439 |
-
# @ polylang
|
440 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
441 |
-
msgid "Delete"
|
442 |
-
msgstr "Obriši"
|
443 |
-
|
444 |
-
# @ polylang
|
445 |
-
#: admin/table-languages.php:76
|
446 |
-
msgid "Code"
|
447 |
-
msgstr "Kod"
|
448 |
-
|
449 |
-
# @ polylang
|
450 |
-
#: admin/table-languages.php:78
|
451 |
-
msgid "Flag"
|
452 |
-
msgstr "Zastavica"
|
453 |
-
|
454 |
-
# @ polylang
|
455 |
-
#: admin/table-languages.php:79
|
456 |
-
msgid "Posts"
|
457 |
-
msgstr "Postovi"
|
458 |
-
|
459 |
-
# @ polylang
|
460 |
-
#: admin/table-string.php:110
|
461 |
-
msgid "Name"
|
462 |
-
msgstr "Ime"
|
463 |
-
|
464 |
-
# @ polylang
|
465 |
-
#: admin/table-string.php:111
|
466 |
-
msgid "String"
|
467 |
-
msgstr "Linija"
|
468 |
-
|
469 |
-
# @ polylang
|
470 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
471 |
-
#: admin/view-translations-term.php:30
|
472 |
-
msgid "Add new"
|
473 |
-
msgstr "Dodaj novi"
|
474 |
-
|
475 |
-
# @ polylang
|
476 |
-
#: include/widget-languages.php:16
|
477 |
-
msgid "Language Switcher"
|
478 |
-
msgstr "Prebacivanje jezika"
|
479 |
-
|
480 |
-
# @ polylang
|
481 |
-
#: include/widget-languages.php:16
|
482 |
-
msgid "Displays a language switcher"
|
483 |
-
msgstr "Prikazuje prebacivanje jezika"
|
484 |
-
|
485 |
-
# @ polylang
|
486 |
-
#: include/widget-languages.php:75
|
487 |
-
msgid "Title:"
|
488 |
-
msgstr "Naslov:"
|
489 |
-
|
490 |
-
# @ polylang
|
491 |
-
#. translators: plugin header field 'Description'
|
492 |
-
#: polylang.php:0
|
493 |
-
msgid "Adds multilingual capability to WordPress"
|
494 |
-
msgstr "Dodaje višejezičnu podršku u WordPress"
|
495 |
-
|
496 |
-
# @ polylang
|
497 |
-
#: install/install.php:24
|
498 |
-
#, php-format
|
499 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
500 |
-
msgstr "Koristite WordPress verzije %s. Polylang zahtijeva barem verziju %s."
|
501 |
-
|
502 |
-
# @ polylang
|
503 |
-
#: install/upgrade.php:76
|
504 |
-
msgid ""
|
505 |
-
"Polylang has been deactivated because you upgraded from a too old version."
|
506 |
-
msgstr "Polylang je isključen jer ste imali zastarjelu verziju dodatka."
|
507 |
-
|
508 |
-
# @ polylang
|
509 |
-
#: install/upgrade.php:78
|
510 |
-
#, php-format
|
511 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
512 |
-
msgstr "Molimo nadogradite prvo na %s prije nadogradnje na %s."
|
513 |
-
|
514 |
-
# @ polylang
|
515 |
-
#: admin/table-string.php:109
|
516 |
-
msgid "Group"
|
517 |
-
msgstr "Grupa"
|
518 |
-
|
519 |
-
# @ polylang
|
520 |
-
#: admin/table-string.php:187
|
521 |
-
msgid "View all groups"
|
522 |
-
msgstr "Vidi sve grupe"
|
523 |
-
|
524 |
-
# @ polylang
|
525 |
-
#: admin/table-languages.php:59
|
526 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
527 |
-
msgstr "Planirate trajno obrisati ovaj jezik. Jeste li sigurni?"
|
528 |
-
|
529 |
-
# @ polylang
|
530 |
-
#: admin/view-tab-strings.php:12
|
531 |
-
msgid ""
|
532 |
-
"Use this to remove unused strings from database, for example after a plugin "
|
533 |
-
"has been uninstalled."
|
534 |
-
msgstr ""
|
535 |
-
"Koristite ovo da maknete neiskorištene linije iz baze, primjerice nakon što "
|
536 |
-
"je neki dodatak maknut."
|
537 |
-
|
538 |
-
# @ polylang
|
539 |
-
#: admin/view-tab-settings.php:226
|
540 |
-
msgid ""
|
541 |
-
"The synchronization options allow to maintain exact same values (or "
|
542 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
543 |
-
"between the translations of a post or page."
|
544 |
-
msgstr ""
|
545 |
-
"Opcija sinkronizacije dozvoljava da zadržimo identične vrijednosti (odnosno "
|
546 |
-
"prijevode u primjeru taksonomije i nadređenih stranica) od meta podataka "
|
547 |
-
"nakon prijevoda postova ili stranica."
|
548 |
-
|
549 |
-
# @ polylang
|
550 |
-
#: admin/admin-model.php:248
|
551 |
-
msgid "The language code contains invalid characters"
|
552 |
-
msgstr "Oznaka jezika sadrži pogrešne znakove"
|
553 |
-
|
554 |
-
# @ polylang
|
555 |
-
#: admin/view-tab-settings.php:43
|
556 |
-
msgid "The language is set from content"
|
557 |
-
msgstr "Jezik je postavljen iz sadržaja"
|
558 |
-
|
559 |
-
# @ polylang
|
560 |
-
#: admin/view-tab-settings.php:46
|
561 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
562 |
-
msgstr "Postovi, stranice, kategorije i oznake (tagovi) nisu promijenjeni."
|
563 |
-
|
564 |
-
# @ polylang
|
565 |
-
#: admin/view-tab-settings.php:51
|
566 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
567 |
-
msgstr ""
|
568 |
-
"Jezik je postavljen po imenu direktorija u uljepšanim trajnim linkovima"
|
569 |
-
|
570 |
-
# @ polylang
|
571 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
572 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
573 |
-
msgid "Example:"
|
574 |
-
msgstr "Primjer:"
|
575 |
-
|
576 |
-
# @ polylang
|
577 |
-
#: admin/view-tab-settings.php:60
|
578 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
579 |
-
msgstr ""
|
580 |
-
"Jezik je postavljen po imenu poddomene u uljepšanim trajnim linkovima "
|
581 |
-
"(permalinks)"
|
582 |
-
|
583 |
-
# @ polylang
|
584 |
-
#: admin/view-tab-settings.php:69
|
585 |
-
msgid "The language is set from different domains"
|
586 |
-
msgstr "Jezik je postavljen od različitih domena"
|
587 |
-
|
588 |
-
# @ polylang
|
589 |
-
#: admin/view-tab-settings.php:107
|
590 |
-
msgid "Remove /language/ in pretty permalinks"
|
591 |
-
msgstr "Ukloni /jezik/ u uljepšanim trajnim linkovima"
|
592 |
-
|
593 |
-
# @ polylang
|
594 |
-
#: admin/view-tab-settings.php:116
|
595 |
-
msgid "Keep /language/ in pretty permalinks"
|
596 |
-
msgstr "Zadrži /jezik/ u uljepšanim trajnim linkovima"
|
597 |
-
|
598 |
-
# @ polylang
|
599 |
-
#: admin/view-tab-settings.php:131
|
600 |
-
msgid ""
|
601 |
-
"The front page url contains the language code instead of the page name or "
|
602 |
-
"page id"
|
603 |
-
msgstr ""
|
604 |
-
"URL naslovne stranice sadrži oznaku jezika umjesto imena ili oznake stranice"
|
605 |
-
|
606 |
-
# @ polylang
|
607 |
-
#: admin/view-tab-settings.php:139
|
608 |
-
#, php-format
|
609 |
-
msgid "Example: %s instead of %s"
|
610 |
-
msgstr "Primjer: %s umjesto %s"
|
611 |
-
|
612 |
-
# @ polylang
|
613 |
-
#: admin/admin-model.php:38
|
614 |
-
msgid "Impossible to add the language."
|
615 |
-
msgstr "Nije moguće dodati jezik"
|
616 |
-
|
617 |
-
# @ polylang
|
618 |
-
#: admin/admin-model.php:66
|
619 |
-
msgid "Language added."
|
620 |
-
msgstr "Jezik dodan"
|
621 |
-
|
622 |
-
# @ polylang
|
623 |
-
#: admin/admin-model.php:146
|
624 |
-
msgid "Language deleted."
|
625 |
-
msgstr "Jezik obrisan"
|
626 |
-
|
627 |
-
# @ polylang
|
628 |
-
#: admin/admin-model.php:227
|
629 |
-
msgid "Language updated."
|
630 |
-
msgstr "Jezik osvježen"
|
631 |
-
|
632 |
-
# @ polylang
|
633 |
-
#: admin/settings.php:239
|
634 |
-
msgid "Translations updated."
|
635 |
-
msgstr "Prijevodi osvježeni"
|
636 |
-
|
637 |
-
# @ polylang
|
638 |
-
#: admin/view-tab-lang.php:72
|
639 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
640 |
-
msgstr ""
|
641 |
-
"Oznaka jezika - preferirano dvoznačna oznaka u ISO 639-1 formatu "
|
642 |
-
"(primjerice: hr)"
|
643 |
-
|
644 |
-
# @ polylang
|
645 |
-
#: admin/admin-filters.php:203
|
646 |
-
msgid "The chosen static front page must be translated in all languages."
|
647 |
-
msgstr "Naslovna (statična) stranica mora biti prevedena na svim jezicima."
|
648 |
-
|
649 |
-
# @ polylang
|
650 |
-
#: admin/admin-strings.php:60
|
651 |
-
msgid "Widget text"
|
652 |
-
msgstr "Tekst Widgeta"
|
653 |
-
|
654 |
-
# @ polylang
|
655 |
-
#: admin/settings.php:52
|
656 |
-
msgid "Recommended plugins"
|
657 |
-
msgstr "Preporučeni dodaci"
|
658 |
-
|
659 |
-
# @ polylang
|
660 |
-
#: admin/view-tab-settings.php:51
|
661 |
-
msgid "The language is set from the code in the URL"
|
662 |
-
msgstr "Jezik je postavljen preko oznake jezika u URL-u"
|
663 |
-
|
664 |
-
# @ polylang
|
665 |
-
#: include/switcher.php:26
|
666 |
-
msgid "Hides languages with no translation"
|
667 |
-
msgstr "Sakrij jezike koji nisu prevedeni"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-oci.mo
DELETED
Binary file
|
languages/polylang-oci.po
DELETED
@@ -1,675 +0,0 @@
|
|
1 |
-
# Cedric Valmary <cvalmary@yahoo.fr>, 2015.
|
2 |
-
msgid ""
|
3 |
-
msgstr ""
|
4 |
-
"Project-Id-Version: Polylang v1.6beta1\n"
|
5 |
-
"Report-Msgid-Bugs-To: \n"
|
6 |
-
"POT-Creation-Date: \n"
|
7 |
-
"PO-Revision-Date: 2015-08-27 11:23+0200\n"
|
8 |
-
"Last-Translator: director <cvalmary@yahoo.fr>\n"
|
9 |
-
"Language-Team: Tot en òc (totenoc.eu)\n"
|
10 |
-
"Language: oci\n"
|
11 |
-
"MIME-Version: 1.0\n"
|
12 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
-
"Content-Transfer-Encoding: 8bit\n"
|
14 |
-
"Plural-Forms: nplurals=2; plural=n>1;\n"
|
15 |
-
"X-Generator: Virtaal 0.7.1\n"
|
16 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noo"
|
18 |
-
"p:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
|
19 |
-
"X-Poedit-Basepath: .\n"
|
20 |
-
"X-Textdomain-Support: yes\n"
|
21 |
-
"X-Poedit-SearchPath-0: ..\n"
|
22 |
-
|
23 |
-
# @ polylang
|
24 |
-
#: admin/view-about.php:3
|
25 |
-
#, php-format
|
26 |
-
msgid ""
|
27 |
-
"Polylang is provided with an extensive %sdocumentation%s (in English only). "
|
28 |
-
"It includes information on how to set up your multilingual site and use it "
|
29 |
-
"on a daily basis, a FAQ, as well as a documentation for programmers to adapt "
|
30 |
-
"their plugins and themes."
|
31 |
-
msgstr ""
|
32 |
-
"Polylang es provesit amb una %sdocumentation%s (en anglés). Explica cossí "
|
33 |
-
"installar vòstre site multilingüe e l’utilizar al jorn lo jorn. Conten "
|
34 |
-
"tanben una FAQ e una documentacion per los desvelopaires lor permet d’"
|
35 |
-
"adaptar lors extensions e lors tèmas."
|
36 |
-
|
37 |
-
# @ polylang
|
38 |
-
#: admin/view-about.php:9
|
39 |
-
#, php-format
|
40 |
-
msgid ""
|
41 |
-
"You will also find useful information in the %ssupport forum%s. However "
|
42 |
-
"don't forget to make a search before posting a new topic."
|
43 |
-
msgstr ""
|
44 |
-
"Podètz tanben trobar d’informacions dins lo %sforum de supòrt%s (en "
|
45 |
-
"anglés). Pasmens, doblidetz pas de far una recèrca abans de publicar."
|
46 |
-
|
47 |
-
# @ polylang
|
48 |
-
#: admin/view-about.php:16
|
49 |
-
#, php-format
|
50 |
-
msgid ""
|
51 |
-
"Polylang is free of charge and is released under the same license as "
|
52 |
-
"WordPress, the %sGPL%s."
|
53 |
-
msgstr ""
|
54 |
-
"Polylang es gratuit e publicat jos la meteissa licéncia que WordPress, la "
|
55 |
-
"%sGPL%s."
|
56 |
-
|
57 |
-
# @ polylang
|
58 |
-
#: admin/view-about.php:22
|
59 |
-
#, php-format
|
60 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
61 |
-
msgstr "Se volètz ajudar lo projècte, %slegissètz aquò%s."
|
62 |
-
|
63 |
-
# @ polylang
|
64 |
-
#: admin/view-about.php:27
|
65 |
-
msgid ""
|
66 |
-
"Finally if you like this plugin or if it helps your business, donations to "
|
67 |
-
"the author are greatly appreciated."
|
68 |
-
msgstr ""
|
69 |
-
"Enfin, se vos agrada aquesta extension o se vos ajuda dins vòstre business, "
|
70 |
-
"podètz far un don a l’autor."
|
71 |
-
|
72 |
-
# @ polylang
|
73 |
-
#: admin/admin-filters-post.php:115 admin/admin.php:90 admin/settings.php:70
|
74 |
-
#: admin/settings.php:97 include/model.php:561
|
75 |
-
msgid "Languages"
|
76 |
-
msgstr "Lengas"
|
77 |
-
|
78 |
-
# @ polylang
|
79 |
-
#: include/switcher.php:22
|
80 |
-
msgid "Displays language names"
|
81 |
-
msgstr "Afichar lo nom de las lengas"
|
82 |
-
|
83 |
-
# @ polylang
|
84 |
-
#: include/switcher.php:23
|
85 |
-
msgid "Displays flags"
|
86 |
-
msgstr "Afichar las bandièras"
|
87 |
-
|
88 |
-
# @ polylang
|
89 |
-
#: include/switcher.php:24
|
90 |
-
msgid "Forces link to front page"
|
91 |
-
msgstr "Fòrça lo ligam cap a la pagina d’acuèlh"
|
92 |
-
|
93 |
-
# @ polylang
|
94 |
-
#: include/switcher.php:25
|
95 |
-
msgid "Hides the current language"
|
96 |
-
msgstr "Amagar la lenga correnta"
|
97 |
-
|
98 |
-
# @ polylang
|
99 |
-
#: include/switcher.php:30
|
100 |
-
msgid "Displays as dropdown"
|
101 |
-
msgstr "Afichar en lista desenrotlanta"
|
102 |
-
|
103 |
-
# @ polylang
|
104 |
-
#: admin/admin.php:267
|
105 |
-
msgid "Filters content by language"
|
106 |
-
msgstr "Filtrar lo contengut per lenga"
|
107 |
-
|
108 |
-
# @ polylang
|
109 |
-
#: admin/admin.php:258
|
110 |
-
msgid "Show all languages"
|
111 |
-
msgstr "Afichar totas las lengas"
|
112 |
-
|
113 |
-
# @ polylang
|
114 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
115 |
-
msgid "Add new translation"
|
116 |
-
msgstr "Apondre una novèla traduccion"
|
117 |
-
|
118 |
-
# @ polylang
|
119 |
-
#: admin/admin-filters-columns.php:173 admin/admin-filters-media.php:55
|
120 |
-
#: admin/admin-filters-post.php:141 admin/admin-filters-term.php:75
|
121 |
-
#: admin/admin-filters-term.php:122 include/model.php:562
|
122 |
-
msgid "Language"
|
123 |
-
msgstr "Lenga"
|
124 |
-
|
125 |
-
# @ polylang
|
126 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
127 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
128 |
-
#: admin/view-translations-term.php:11
|
129 |
-
msgid "Translations"
|
130 |
-
msgstr "Traduccions"
|
131 |
-
|
132 |
-
# @ polylang
|
133 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
134 |
-
msgid "Sets the language"
|
135 |
-
msgstr "Definís la lenga"
|
136 |
-
|
137 |
-
# @ polylang
|
138 |
-
#: admin/admin-filters.php:52
|
139 |
-
msgid "The widget is displayed for:"
|
140 |
-
msgstr "Afichar lo widget per :"
|
141 |
-
|
142 |
-
# @ polylang
|
143 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
144 |
-
msgid "All languages"
|
145 |
-
msgstr "Totas las lengas"
|
146 |
-
|
147 |
-
# @ polylang
|
148 |
-
#: admin/admin-filters.php:123
|
149 |
-
msgid "Admin language"
|
150 |
-
msgstr "Lenga per l’interfàcia d’administracion"
|
151 |
-
|
152 |
-
# @ polylang
|
153 |
-
#: admin/admin-filters.php:126
|
154 |
-
msgid "WordPress default"
|
155 |
-
msgstr "Lenga per defaut de WordPress"
|
156 |
-
|
157 |
-
# @ polylang
|
158 |
-
#: admin/admin.php:167 admin/settings.php:102
|
159 |
-
msgid "Settings"
|
160 |
-
msgstr "Reglatges"
|
161 |
-
|
162 |
-
# @ polylang
|
163 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
164 |
-
msgid "Upgrading language files…"
|
165 |
-
msgstr "Mesa a jorn dels fichièrs de lengas…"
|
166 |
-
|
167 |
-
# @ polylang
|
168 |
-
#: admin/settings.php:62
|
169 |
-
msgid "About Polylang"
|
170 |
-
msgstr "A prepaus de Polylang"
|
171 |
-
|
172 |
-
# @ polylang
|
173 |
-
#: admin/settings.php:78
|
174 |
-
msgid "Strings translations"
|
175 |
-
msgstr "Traduccions de las cadenas"
|
176 |
-
|
177 |
-
# @ polylang
|
178 |
-
#: admin/settings.php:101
|
179 |
-
msgid "Strings translation"
|
180 |
-
msgstr "Traduccion de las cadenas"
|
181 |
-
|
182 |
-
# @ polylang
|
183 |
-
#: admin/admin-model.php:244
|
184 |
-
msgid "Enter a valid WordPress locale"
|
185 |
-
msgstr "Entratz un còde local WordPress valid"
|
186 |
-
|
187 |
-
# @ polylang
|
188 |
-
#: admin/admin-model.php:252
|
189 |
-
msgid "The language code must be unique"
|
190 |
-
msgstr "Lo còde de la lenga deu èsser unic"
|
191 |
-
|
192 |
-
# @ polylang
|
193 |
-
#: admin/admin-model.php:256
|
194 |
-
msgid "The language must have a name"
|
195 |
-
msgstr "La lenga deu aver un nom"
|
196 |
-
|
197 |
-
# @ polylang
|
198 |
-
#: admin/admin.php:367 admin/settings.php:180
|
199 |
-
msgid ""
|
200 |
-
"The language was created, but the WordPress language file was not "
|
201 |
-
"downloaded. Please install it manually."
|
202 |
-
msgstr ""
|
203 |
-
"La lenga es estada creada, mas lo fichièr de lenga WordPress a pas pogut "
|
204 |
-
"èsser telecargat. Mercé de l’installar manualament."
|
205 |
-
|
206 |
-
# @ polylang
|
207 |
-
#: admin/admin-strings.php:59
|
208 |
-
msgid "Widget title"
|
209 |
-
msgstr "Títol del widget"
|
210 |
-
|
211 |
-
# @ polylang
|
212 |
-
#: admin/settings.php:319
|
213 |
-
msgid "Taxonomies"
|
214 |
-
msgstr "Taxinomias"
|
215 |
-
|
216 |
-
# @ polylang
|
217 |
-
#: admin/settings.php:320
|
218 |
-
msgid "Custom fields"
|
219 |
-
msgstr "Camps personalizats"
|
220 |
-
|
221 |
-
# @ polylang
|
222 |
-
#: admin/settings.php:321
|
223 |
-
msgid "Comment status"
|
224 |
-
msgstr "Autorizacion dels comentaris"
|
225 |
-
|
226 |
-
# @ polylang
|
227 |
-
#: admin/settings.php:322
|
228 |
-
msgid "Ping status"
|
229 |
-
msgstr "Autorizacion dels pings"
|
230 |
-
|
231 |
-
# @ polylang
|
232 |
-
#: admin/settings.php:323
|
233 |
-
msgid "Sticky posts"
|
234 |
-
msgstr "Articles meses en avant"
|
235 |
-
|
236 |
-
# @ polylang
|
237 |
-
#: admin/settings.php:324
|
238 |
-
msgid "Published date"
|
239 |
-
msgstr "Data de publicacion"
|
240 |
-
|
241 |
-
# @ polylang
|
242 |
-
#: admin/settings.php:325
|
243 |
-
msgid "Post format"
|
244 |
-
msgstr "Format"
|
245 |
-
|
246 |
-
# @ polylang
|
247 |
-
#: admin/settings.php:326
|
248 |
-
msgid "Page parent"
|
249 |
-
msgstr "Pagina parent"
|
250 |
-
|
251 |
-
# @ polylang
|
252 |
-
#: admin/settings.php:327
|
253 |
-
msgid "Page template"
|
254 |
-
msgstr "Modèl de pagina"
|
255 |
-
|
256 |
-
# @ polylang
|
257 |
-
#: admin/settings.php:328
|
258 |
-
msgid "Page order"
|
259 |
-
msgstr "Òrdre de las paginas"
|
260 |
-
|
261 |
-
# @ polylang
|
262 |
-
#: admin/settings.php:329
|
263 |
-
msgid "Featured image"
|
264 |
-
msgstr "Imatge a la Una"
|
265 |
-
|
266 |
-
# @ polylang
|
267 |
-
#: admin/view-tab-lang.php:21
|
268 |
-
msgid "Edit language"
|
269 |
-
msgstr "Modificar la lenga"
|
270 |
-
|
271 |
-
# @ polylang
|
272 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
273 |
-
msgid "Add new language"
|
274 |
-
msgstr "Apondre una novèla lenga"
|
275 |
-
|
276 |
-
# @ polylang
|
277 |
-
#: admin/view-tab-lang.php:37
|
278 |
-
msgid "Choose a language"
|
279 |
-
msgstr "Causir una lenga"
|
280 |
-
|
281 |
-
# @ polylang
|
282 |
-
#: admin/view-tab-lang.php:51
|
283 |
-
msgid "You can choose a language in the list or directly edit it below."
|
284 |
-
msgstr "Causissètz una lenga dins la lista o modificatz-la dirèctament çaijós."
|
285 |
-
|
286 |
-
# @ polylang
|
287 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
288 |
-
msgid "Full name"
|
289 |
-
msgstr "Nom"
|
290 |
-
|
291 |
-
# @ polylang
|
292 |
-
#: admin/view-tab-lang.php:57
|
293 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
294 |
-
msgstr "Lo nom es utilizat un pauc pertot sul site (per exemple : Occitan)"
|
295 |
-
|
296 |
-
# @ polylang
|
297 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
298 |
-
msgid "Locale"
|
299 |
-
msgstr "Còde local"
|
300 |
-
|
301 |
-
# @ polylang
|
302 |
-
#: admin/view-tab-lang.php:66
|
303 |
-
msgid ""
|
304 |
-
"WordPress Locale for the language (for example: en_US). You will need to "
|
305 |
-
"install the .mo file for this language."
|
306 |
-
msgstr ""
|
307 |
-
"Còde local utilizat per WordPress per la lenga (per exemple : oci). "
|
308 |
-
"Auretz besonh d’installar los fichièrs .mo correspondent."
|
309 |
-
|
310 |
-
# @ polylang
|
311 |
-
#: admin/view-tab-lang.php:70
|
312 |
-
msgid "Language code"
|
313 |
-
msgstr "Còde de la lenga"
|
314 |
-
|
315 |
-
# @ polylang
|
316 |
-
#: admin/view-tab-lang.php:76
|
317 |
-
msgid "Text direction"
|
318 |
-
msgstr "Sistèma d’escritura"
|
319 |
-
|
320 |
-
# @ polylang
|
321 |
-
#: admin/view-tab-lang.php:80
|
322 |
-
msgid "left to right"
|
323 |
-
msgstr "d’esquèrra a drecha"
|
324 |
-
|
325 |
-
# @ polylang
|
326 |
-
#: admin/view-tab-lang.php:85
|
327 |
-
msgid "right to left"
|
328 |
-
msgstr "de drecha a esquèrra"
|
329 |
-
|
330 |
-
# @ polylang
|
331 |
-
#: admin/view-tab-lang.php:87
|
332 |
-
msgid "Choose the text direction for the language"
|
333 |
-
msgstr "Causir lo sistèma d’escritura per la lenga"
|
334 |
-
|
335 |
-
# @ polylang
|
336 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
337 |
-
msgid "Order"
|
338 |
-
msgstr "Òrdre"
|
339 |
-
|
340 |
-
# @ polylang
|
341 |
-
#: admin/view-tab-lang.php:93
|
342 |
-
msgid "Position of the language in the language switcher"
|
343 |
-
msgstr "Posicion de la lenga dins la lista de lengas"
|
344 |
-
|
345 |
-
# @ polylang
|
346 |
-
#: admin/admin-nav-menu.php:54 admin/admin-nav-menu.php:92
|
347 |
-
#: admin/admin-nav-menu.php:95 admin/admin-nav-menu.php:126
|
348 |
-
#: admin/admin-nav-menu.php:188 install/upgrade.php:301
|
349 |
-
msgid "Language switcher"
|
350 |
-
msgstr "Lista de las lengas"
|
351 |
-
|
352 |
-
# @ polylang
|
353 |
-
#: admin/view-tab-strings.php:8
|
354 |
-
msgid "Search translations"
|
355 |
-
msgstr "Cercar dins las traduccions"
|
356 |
-
|
357 |
-
# @ polylang
|
358 |
-
#: admin/view-tab-strings.php:11
|
359 |
-
msgid "Clean strings translation database"
|
360 |
-
msgstr "Netejar las cadenas de traduccion de la banca de donadas"
|
361 |
-
|
362 |
-
# @ polylang
|
363 |
-
#: admin/view-tab-settings.php:14
|
364 |
-
msgid "Default language"
|
365 |
-
msgstr "Lenga per defaut"
|
366 |
-
|
367 |
-
# @ polylang
|
368 |
-
#: admin/view-tab-settings.php:29
|
369 |
-
msgid ""
|
370 |
-
"There are posts, pages, categories or tags without language set. Do you want "
|
371 |
-
"to set them all to default language ?"
|
372 |
-
msgstr ""
|
373 |
-
"I a d’articles, paginas, categorias o etiquetas sens jòc de lenga. Lor "
|
374 |
-
"volètz atribuir la lenga per defaut ?"
|
375 |
-
|
376 |
-
# @ polylang
|
377 |
-
#: admin/view-tab-settings.php:149
|
378 |
-
msgid "Detect browser language"
|
379 |
-
msgstr "Detectar la lenga del navigador"
|
380 |
-
|
381 |
-
# @ polylang
|
382 |
-
#: admin/view-tab-settings.php:155
|
383 |
-
msgid ""
|
384 |
-
"When the front page is visited, set the language according to the browser "
|
385 |
-
"preference"
|
386 |
-
msgstr ""
|
387 |
-
"Quand la pagina d’acuèlh es visitada, lo visitor es redirigit en "
|
388 |
-
"foncion de las preferéncias de lenga de son navigador"
|
389 |
-
|
390 |
-
# @ polylang
|
391 |
-
#: admin/view-tab-settings.php:37
|
392 |
-
msgid "URL modifications"
|
393 |
-
msgstr "Modificacions de las URL"
|
394 |
-
|
395 |
-
# @ polylang
|
396 |
-
#: admin/view-tab-settings.php:93
|
397 |
-
msgid "Hide URL language information for default language"
|
398 |
-
msgstr ""
|
399 |
-
"Amagar l’informacion de lenga dins l’URL per la lenga per defaut"
|
400 |
-
|
401 |
-
# @ polylang
|
402 |
-
#: admin/view-tab-settings.php:162
|
403 |
-
msgid "Media"
|
404 |
-
msgstr "Mèdias"
|
405 |
-
|
406 |
-
# @ polylang
|
407 |
-
#: admin/view-tab-settings.php:168
|
408 |
-
msgid "Activate languages and translations for media"
|
409 |
-
msgstr "Activar la gestion de las lengas e de las traduccions per los mèdias."
|
410 |
-
|
411 |
-
# @ polylang
|
412 |
-
#: admin/view-tab-settings.php:215
|
413 |
-
msgid "Synchronization"
|
414 |
-
msgstr "Sincronizacion"
|
415 |
-
|
416 |
-
# @ polylang
|
417 |
-
#: admin/view-tab-settings.php:176
|
418 |
-
msgid "Custom post types"
|
419 |
-
msgstr "Tipes de contengut personalizat"
|
420 |
-
|
421 |
-
# @ polylang
|
422 |
-
#: admin/view-tab-settings.php:189
|
423 |
-
msgid "Activate languages and translations for custom post types."
|
424 |
-
msgstr ""
|
425 |
-
"Activar la gestion de las lengas e de las traduccions per los tipes de "
|
426 |
-
"contengut."
|
427 |
-
|
428 |
-
# @ polylang
|
429 |
-
#: admin/view-tab-settings.php:196
|
430 |
-
msgid "Custom taxonomies"
|
431 |
-
msgstr "Taxinomias"
|
432 |
-
|
433 |
-
# @ polylang
|
434 |
-
#: admin/view-tab-settings.php:209
|
435 |
-
msgid "Activate languages and translations for custom taxonomies."
|
436 |
-
msgstr ""
|
437 |
-
"Activar la gestion de las lengas e de las traduccions per las taxinomias."
|
438 |
-
|
439 |
-
# @ polylang
|
440 |
-
#: admin/admin-filters-post.php:433 admin/admin-filters-term.php:642
|
441 |
-
#: admin/table-languages.php:54 admin/view-translations-media.php:21
|
442 |
-
msgid "Edit"
|
443 |
-
msgstr "Modificar"
|
444 |
-
|
445 |
-
# @ polylang
|
446 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
447 |
-
msgid "Delete"
|
448 |
-
msgstr "Suprimir"
|
449 |
-
|
450 |
-
# @ polylang
|
451 |
-
#: admin/table-languages.php:76
|
452 |
-
msgid "Code"
|
453 |
-
msgstr "Còde"
|
454 |
-
|
455 |
-
# @ polylang
|
456 |
-
#: admin/table-languages.php:78
|
457 |
-
msgid "Flag"
|
458 |
-
msgstr "Bandièra"
|
459 |
-
|
460 |
-
# @ polylang
|
461 |
-
#: admin/table-languages.php:79
|
462 |
-
msgid "Posts"
|
463 |
-
msgstr "Articles"
|
464 |
-
|
465 |
-
# @ polylang
|
466 |
-
#: admin/table-string.php:110
|
467 |
-
msgid "Name"
|
468 |
-
msgstr "Nom"
|
469 |
-
|
470 |
-
# @ polylang
|
471 |
-
#: admin/table-string.php:111
|
472 |
-
msgid "String"
|
473 |
-
msgstr "Cadena"
|
474 |
-
|
475 |
-
# @ polylang
|
476 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
477 |
-
#: admin/view-translations-term.php:30
|
478 |
-
msgid "Add new"
|
479 |
-
msgstr "Apondre"
|
480 |
-
|
481 |
-
# @ polylang
|
482 |
-
#: include/widget-languages.php:16
|
483 |
-
msgid "Language Switcher"
|
484 |
-
msgstr "Lista de las lengas"
|
485 |
-
|
486 |
-
# @ polylang
|
487 |
-
#: include/widget-languages.php:16
|
488 |
-
msgid "Displays a language switcher"
|
489 |
-
msgstr "Afichar la lista de las lengas"
|
490 |
-
|
491 |
-
# @ polylang
|
492 |
-
#: include/widget-languages.php:75
|
493 |
-
msgid "Title:"
|
494 |
-
msgstr "Títol :"
|
495 |
-
|
496 |
-
# @ polylang
|
497 |
-
#. translators: plugin header field 'Description'
|
498 |
-
#: polylang.php:0
|
499 |
-
msgid "Adds multilingual capability to WordPress"
|
500 |
-
msgstr "Permet una utilizacion multilingüa de WordPress"
|
501 |
-
|
502 |
-
# @ polylang
|
503 |
-
#: install/install.php:24
|
504 |
-
#, php-format
|
505 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
506 |
-
msgstr "Utilizatz WordPress %s. Polylang necessita al mens WordPress %s."
|
507 |
-
|
508 |
-
# @ polylang
|
509 |
-
#: install/upgrade.php:76
|
510 |
-
msgid ""
|
511 |
-
"Polylang has been deactivated because you upgraded from a too old version."
|
512 |
-
msgstr ""
|
513 |
-
"Polylang es estat desactivat perque avètz fach una mesa a jorn dempuèi una "
|
514 |
-
"version tròp anciana."
|
515 |
-
|
516 |
-
# @ polylang
|
517 |
-
#: install/upgrade.php:78
|
518 |
-
#, php-format
|
519 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
520 |
-
msgstr "D’en primièr, metètz a jorn en %s abans de metre a jorn en %s."
|
521 |
-
|
522 |
-
# @ polylang
|
523 |
-
#: admin/table-string.php:109
|
524 |
-
msgid "Group"
|
525 |
-
msgstr "Grop"
|
526 |
-
|
527 |
-
# @ polylang
|
528 |
-
#: admin/table-string.php:187
|
529 |
-
msgid "View all groups"
|
530 |
-
msgstr "Veire totes los gropes"
|
531 |
-
|
532 |
-
# @ polylang
|
533 |
-
#: admin/table-languages.php:59
|
534 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
535 |
-
msgstr "Sètz segur que volètz suprimir aquesta lenga definitivament ?"
|
536 |
-
|
537 |
-
# @ polylang
|
538 |
-
#: admin/view-tab-strings.php:12
|
539 |
-
msgid ""
|
540 |
-
"Use this to remove unused strings from database, for example after a plugin "
|
541 |
-
"has been uninstalled."
|
542 |
-
msgstr ""
|
543 |
-
"Utilizatz aquesta opcion per suprimir las frasas inutilas dins la banca de "
|
544 |
-
"donadas, per exemple aprèp aver desinstallat una extension."
|
545 |
-
|
546 |
-
# @ polylang
|
547 |
-
#: admin/view-tab-settings.php:226
|
548 |
-
msgid ""
|
549 |
-
"The synchronization options allow to maintain exact same values (or "
|
550 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
551 |
-
"between the translations of a post or page."
|
552 |
-
msgstr ""
|
553 |
-
"Las opcions de sincronizacion permeton de manténer las meteissas valors de "
|
554 |
-
"metacontenguts entre las traduccions d’un article o d’une pagina "
|
555 |
-
"(o de las tradusir dins lo cas de las taxinomias e de la pagina parent)"
|
556 |
-
|
557 |
-
# @ polylang
|
558 |
-
#: admin/admin-model.php:248
|
559 |
-
msgid "The language code contains invalid characters"
|
560 |
-
msgstr "Lo còde de la lenga conten de caractèrs invalids"
|
561 |
-
|
562 |
-
# @ polylang
|
563 |
-
#: admin/view-tab-settings.php:43
|
564 |
-
msgid "The language is set from content"
|
565 |
-
msgstr "La lenga es determinada pel contengut"
|
566 |
-
|
567 |
-
# @ polylang
|
568 |
-
#: admin/view-tab-settings.php:46
|
569 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
570 |
-
msgstr ""
|
571 |
-
"Las adreças dels articles, paginas, categorias e mots claus son pas "
|
572 |
-
"modificadas."
|
573 |
-
|
574 |
-
# @ polylang
|
575 |
-
#: admin/view-tab-settings.php:51
|
576 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
577 |
-
msgstr "La lenga es determinada pel nom del repertòri dins los permaligams"
|
578 |
-
|
579 |
-
# @ polylang
|
580 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
581 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
582 |
-
msgid "Example:"
|
583 |
-
msgstr "Exemple :"
|
584 |
-
|
585 |
-
# @ polylang
|
586 |
-
#: admin/view-tab-settings.php:60
|
587 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
588 |
-
msgstr "La lenga es determinada pel sosdomeni dins los permaligams"
|
589 |
-
|
590 |
-
# @ polylang
|
591 |
-
#: admin/view-tab-settings.php:69
|
592 |
-
msgid "The language is set from different domains"
|
593 |
-
msgstr "La lenga es determinada per de noms de domeni diferents"
|
594 |
-
|
595 |
-
# @ polylang
|
596 |
-
#: admin/view-tab-settings.php:107
|
597 |
-
msgid "Remove /language/ in pretty permalinks"
|
598 |
-
msgstr "Suprimir /language/ dins los permaligams"
|
599 |
-
|
600 |
-
# @ polylang
|
601 |
-
#: admin/view-tab-settings.php:116
|
602 |
-
msgid "Keep /language/ in pretty permalinks"
|
603 |
-
msgstr "Conservar /language/ dins los permaligams"
|
604 |
-
|
605 |
-
# @ polylang
|
606 |
-
#: admin/view-tab-settings.php:131
|
607 |
-
msgid ""
|
608 |
-
"The front page url contains the language code instead of the page name or "
|
609 |
-
"page id"
|
610 |
-
msgstr ""
|
611 |
-
"L'adreça de la pagina d'acuèlh conten lo còde de la lenga al luòc del nom de "
|
612 |
-
"la pagina"
|
613 |
-
|
614 |
-
# @ polylang
|
615 |
-
#: admin/view-tab-settings.php:139
|
616 |
-
#, php-format
|
617 |
-
msgid "Example: %s instead of %s"
|
618 |
-
msgstr "Exemple : %s al luòc de %s"
|
619 |
-
|
620 |
-
# @ polylang
|
621 |
-
#: admin/admin-model.php:38
|
622 |
-
msgid "Impossible to add the language."
|
623 |
-
msgstr "Impossible d'apondre la lenga."
|
624 |
-
|
625 |
-
# @ polylang
|
626 |
-
#: admin/admin-model.php:66
|
627 |
-
msgid "Language added."
|
628 |
-
msgstr "Lenga aponduda."
|
629 |
-
|
630 |
-
# @ polylang
|
631 |
-
#: admin/admin-model.php:146
|
632 |
-
msgid "Language deleted."
|
633 |
-
msgstr "Lenga suprimida."
|
634 |
-
|
635 |
-
# @ polylang
|
636 |
-
#: admin/admin-model.php:227
|
637 |
-
msgid "Language updated."
|
638 |
-
msgstr "Lenga mesa a jorn."
|
639 |
-
|
640 |
-
# @ polylang
|
641 |
-
#: admin/settings.php:239
|
642 |
-
msgid "Translations updated."
|
643 |
-
msgstr "Traduccions mesas a jorn."
|
644 |
-
|
645 |
-
# @ polylang
|
646 |
-
#: admin/view-tab-lang.php:72
|
647 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
648 |
-
msgstr ""
|
649 |
-
"Còde de lenga, de preferéncia còde ISO 639-1 a 2 letras (per exemple : "
|
650 |
-
"fr)"
|
651 |
-
|
652 |
-
# @ polylang
|
653 |
-
#: admin/admin-filters.php:203
|
654 |
-
msgid "The chosen static front page must be translated in all languages."
|
655 |
-
msgstr "La pagina d'acuèlh estatica deu èsser tradusida dins totas las lengas."
|
656 |
-
|
657 |
-
# @ polylang
|
658 |
-
#: admin/admin-strings.php:60
|
659 |
-
msgid "Widget text"
|
660 |
-
msgstr "Widget tèxte"
|
661 |
-
|
662 |
-
# @ polylang
|
663 |
-
#: admin/settings.php:52
|
664 |
-
msgid "Recommended plugins"
|
665 |
-
msgstr "Extensions recomandadas"
|
666 |
-
|
667 |
-
# @ polylang
|
668 |
-
#: admin/view-tab-settings.php:51
|
669 |
-
msgid "The language is set from the code in the URL"
|
670 |
-
msgstr "La lenga es determinada pel còde dins l'URL"
|
671 |
-
|
672 |
-
# @ polylang
|
673 |
-
#: include/switcher.php:26
|
674 |
-
msgid "Hides languages with no translation"
|
675 |
-
msgstr "Amagar las lengas sens traduccion"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modules/plugins/plugins-compat.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
*
|
7 |
* @since 1.0
|
8 |
*/
|
9 |
class PLL_Plugins_Compat {
|
10 |
static protected $instance; // for singleton
|
11 |
|
12 |
-
|
13 |
-
*
|
14 |
*
|
15 |
* @since 1.0
|
16 |
*/
|
@@ -52,8 +52,8 @@ class PLL_Plugins_Compat {
|
|
52 |
}
|
53 |
}
|
54 |
|
55 |
-
|
56 |
-
*
|
57 |
*
|
58 |
* @since 1.7
|
59 |
*
|
@@ -67,9 +67,9 @@ class PLL_Plugins_Compat {
|
|
67 |
return self::$instance;
|
68 |
}
|
69 |
|
70 |
-
|
71 |
* WordPress Importer
|
72 |
-
*
|
73 |
*
|
74 |
* @since 1.2
|
75 |
*/
|
@@ -80,9 +80,9 @@ class PLL_Plugins_Compat {
|
|
80 |
}
|
81 |
}
|
82 |
|
83 |
-
|
84 |
* WordPress Importer
|
85 |
-
*
|
86 |
*
|
87 |
* @since 1.2
|
88 |
*/
|
@@ -94,10 +94,10 @@ class PLL_Plugins_Compat {
|
|
94 |
register_importer( 'wordpress', 'WordPress', __( 'Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'wordpress-importer' ), array( $GLOBALS['wp_import'], 'dispatch' ) );
|
95 |
}
|
96 |
|
97 |
-
|
98 |
* WordPress Importer
|
99 |
* Backward Compatibility Polylang < 1.8
|
100 |
-
*
|
101 |
*
|
102 |
* @since 1.8
|
103 |
*
|
@@ -119,9 +119,9 @@ class PLL_Plugins_Compat {
|
|
119 |
return $terms;
|
120 |
}
|
121 |
|
122 |
-
|
123 |
* YARPP
|
124 |
-
*
|
125 |
*
|
126 |
* @since 1.0
|
127 |
*/
|
@@ -129,10 +129,9 @@ class PLL_Plugins_Compat {
|
|
129 |
$GLOBALS['wp_taxonomies']['language']->yarpp_support = 1;
|
130 |
}
|
131 |
|
132 |
-
|
133 |
* Yoast SEO
|
134 |
-
*
|
135 |
-
* add specific filters and actions
|
136 |
*
|
137 |
* @since 1.6.4
|
138 |
*/
|
@@ -141,8 +140,8 @@ class PLL_Plugins_Compat {
|
|
141 |
return;
|
142 |
}
|
143 |
|
144 |
-
//
|
145 |
-
//
|
146 |
if ( did_action( 'wp_loaded' ) ) {
|
147 |
if ( version_compare( WPSEO_VERSION, '1.7.2', '<' ) ) {
|
148 |
global $wpseo_front;
|
@@ -156,7 +155,7 @@ class PLL_Plugins_Compat {
|
|
156 |
}
|
157 |
}
|
158 |
|
159 |
-
//
|
160 |
// because WPSEO does not accept several domains or subdomains in one sitemap
|
161 |
if ( PLL()->options['force_lang'] > 1 ) {
|
162 |
add_filter( 'wpseo_enable_xml_sitemap_transient_caching', '__return_false' ); // disable cache! otherwise WPSEO keeps only one domain (thanks to Junaid Bhura)
|
@@ -167,9 +166,14 @@ class PLL_Plugins_Compat {
|
|
167 |
add_filter( 'wpseo_typecount_where', array( &$this, 'wpseo_posts_where' ), 10, 2 );
|
168 |
}
|
169 |
|
170 |
-
//
|
171 |
else {
|
172 |
add_filter( 'get_terms_args', array( &$this, 'wpseo_remove_terms_filter' ) );
|
|
|
|
|
|
|
|
|
|
|
173 |
}
|
174 |
|
175 |
add_filter( 'pll_home_url_white_list', array( &$this, 'wpseo_home_url_white_list' ) );
|
@@ -177,10 +181,10 @@ class PLL_Plugins_Compat {
|
|
177 |
add_filter( 'wpseo_canonical', array( &$this, 'wpseo_canonical' ) );
|
178 |
}
|
179 |
|
180 |
-
|
181 |
* Yoast SEO
|
182 |
-
*
|
183 |
-
*
|
184 |
*
|
185 |
* @since 1.6.4
|
186 |
*
|
@@ -197,14 +201,14 @@ class PLL_Plugins_Compat {
|
|
197 |
return $url;
|
198 |
}
|
199 |
|
200 |
-
|
201 |
* Yoast SEO
|
202 |
-
*
|
203 |
-
*
|
204 |
*
|
205 |
* @since 1.6.4
|
206 |
*
|
207 |
-
* @param string $sql
|
208 |
* @param string $post_type
|
209 |
* @return string
|
210 |
*/
|
@@ -212,14 +216,14 @@ class PLL_Plugins_Compat {
|
|
212 |
return pll_is_translated_post_type( $post_type ) ? $sql. PLL()->model->post->join_clause() : $sql;
|
213 |
}
|
214 |
|
215 |
-
|
216 |
* Yoast SEO
|
217 |
-
*
|
218 |
-
*
|
219 |
*
|
220 |
* @since 1.6.4
|
221 |
*
|
222 |
-
* @param string $sql
|
223 |
* @param string $post_type
|
224 |
* @return string
|
225 |
*/
|
@@ -227,10 +231,10 @@ class PLL_Plugins_Compat {
|
|
227 |
return pll_is_translated_post_type( $post_type ) ? $sql . PLL()->model->post->where_clause( PLL()->curlang ) : $sql;
|
228 |
}
|
229 |
|
230 |
-
|
231 |
* Yoast SEO
|
232 |
-
*
|
233 |
-
*
|
234 |
*
|
235 |
* @since 1.0.3
|
236 |
*
|
@@ -244,7 +248,31 @@ class PLL_Plugins_Compat {
|
|
244 |
return $args;
|
245 |
}
|
246 |
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
* Yoast SEO
|
249 |
*
|
250 |
* @since 1.1.2
|
@@ -256,9 +284,9 @@ class PLL_Plugins_Compat {
|
|
256 |
return array_merge( $arr, array( array( 'file' => 'wordpress-seo' ) ) );
|
257 |
}
|
258 |
|
259 |
-
|
260 |
* Yoast SEO
|
261 |
-
*
|
262 |
*
|
263 |
* @since 1.6
|
264 |
*/
|
@@ -275,9 +303,9 @@ class PLL_Plugins_Compat {
|
|
275 |
}
|
276 |
}
|
277 |
|
278 |
-
|
279 |
* Yoast SEO
|
280 |
-
*
|
281 |
*
|
282 |
* @since 1.7.10
|
283 |
*
|
@@ -288,7 +316,7 @@ class PLL_Plugins_Compat {
|
|
288 |
return is_front_page( $url ) && get_option( 'permalink_structure' ) ? trailingslashit( $url ) : $url;
|
289 |
}
|
290 |
|
291 |
-
|
292 |
* Aqua Resizer
|
293 |
*
|
294 |
* @since 1.1.5
|
@@ -300,14 +328,14 @@ class PLL_Plugins_Compat {
|
|
300 |
return array_merge( $arr, array( array( 'function' => 'aq_resize' ) ) );
|
301 |
}
|
302 |
|
303 |
-
|
304 |
* Custom field template
|
305 |
* Custom field template does check $_REQUEST['post'] to populate the custom fields values
|
306 |
*
|
307 |
* @since 1.0.2
|
308 |
*
|
309 |
* @param string $post_type unused
|
310 |
-
* @param object $post
|
311 |
*/
|
312 |
public function cft_copy( $post_type, $post ) {
|
313 |
global $custom_field_template;
|
@@ -316,9 +344,9 @@ class PLL_Plugins_Compat {
|
|
316 |
}
|
317 |
}
|
318 |
|
319 |
-
|
320 |
* Twenty Fourteen
|
321 |
-
*
|
322 |
*
|
323 |
* @since 1.4
|
324 |
*
|
@@ -336,12 +364,12 @@ class PLL_Plugins_Compat {
|
|
336 |
return $featured_ids;
|
337 |
}
|
338 |
|
339 |
-
//
|
340 |
$tags = PLL()->model->term->get_translations( $term->term_id );
|
341 |
$ids = array();
|
342 |
|
343 |
// Query for featured posts in all languages
|
344 |
-
//
|
345 |
foreach ( $tags as $tag ) {
|
346 |
$_ids = get_posts( array(
|
347 |
'lang' => 0, // avoid language filters
|
@@ -362,11 +390,11 @@ class PLL_Plugins_Compat {
|
|
362 |
return $ids;
|
363 |
}
|
364 |
|
365 |
-
|
366 |
* Twenty Fourteen
|
367 |
-
*
|
368 |
-
*
|
369 |
-
*
|
370 |
*
|
371 |
* @since 1.4
|
372 |
*
|
@@ -381,7 +409,7 @@ class PLL_Plugins_Compat {
|
|
381 |
return $settings;
|
382 |
}
|
383 |
|
384 |
-
|
385 |
* Duplicate Post
|
386 |
* Avoid duplicating the 'post_translations' taxonomy
|
387 |
*
|
@@ -395,9 +423,9 @@ class PLL_Plugins_Compat {
|
|
395 |
return $taxonomies;
|
396 |
}
|
397 |
|
398 |
-
|
399 |
* Jetpack
|
400 |
-
*
|
401 |
*
|
402 |
* @since 1.5.4
|
403 |
*/
|
@@ -411,10 +439,10 @@ class PLL_Plugins_Compat {
|
|
411 |
return $posts;
|
412 |
}
|
413 |
|
414 |
-
|
415 |
* Jetpack
|
416 |
-
*
|
417 |
-
*
|
418 |
*
|
419 |
* @since 1.5.4
|
420 |
*/
|
@@ -429,9 +457,9 @@ class PLL_Plugins_Compat {
|
|
429 |
return $r;
|
430 |
}
|
431 |
|
432 |
-
|
433 |
* Jetpack
|
434 |
-
*
|
435 |
*
|
436 |
* @since 1.6
|
437 |
*
|
@@ -452,23 +480,23 @@ class PLL_Plugins_Compat {
|
|
452 |
return $tags;
|
453 |
}
|
454 |
|
455 |
-
|
456 |
* Jetpack
|
457 |
* Allows to make sure that related posts are in the correct language
|
458 |
*
|
459 |
* @since 1.8
|
460 |
*
|
461 |
-
* @param array
|
462 |
* @param string $post_id Post ID of the post for which we are retrieving Related Posts.
|
463 |
* @return array
|
464 |
*/
|
465 |
function jetpack_relatedposts_filter_filters( $filters, $post_id ) {
|
466 |
$slug = sanitize_title( pll_get_post_language( $post_id, 'name' ) );
|
467 |
-
$filters[] = array( 'term' => array( 'taxonomy.language.slug' =>
|
468 |
return $filters;
|
469 |
}
|
470 |
|
471 |
-
|
472 |
* Correspondance between WordPress locales and Facebook locales
|
473 |
* @see https://translate.wordpress.org/
|
474 |
* @see https://www.facebook.com/translations/FacebookLocales.xml
|
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 |
static protected $instance; // for singleton
|
11 |
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
*
|
15 |
* @since 1.0
|
16 |
*/
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
/**
|
56 |
+
* Access to the single instance of the class
|
57 |
*
|
58 |
* @since 1.7
|
59 |
*
|
67 |
return self::$instance;
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
* WordPress Importer
|
72 |
+
* If WordPress Importer is active, replace the wordpress_importer_init function
|
73 |
*
|
74 |
* @since 1.2
|
75 |
*/
|
80 |
}
|
81 |
}
|
82 |
|
83 |
+
/**
|
84 |
* WordPress Importer
|
85 |
+
* Loads our child class PLL_WP_Import instead of WP_Import
|
86 |
*
|
87 |
* @since 1.2
|
88 |
*/
|
94 |
register_importer( 'wordpress', 'WordPress', __( 'Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'wordpress-importer' ), array( $GLOBALS['wp_import'], 'dispatch' ) );
|
95 |
}
|
96 |
|
97 |
+
/**
|
98 |
* WordPress Importer
|
99 |
* Backward Compatibility Polylang < 1.8
|
100 |
+
* Sets the flag when importing a language and the file has been exported with Polylang < 1.8
|
101 |
*
|
102 |
* @since 1.8
|
103 |
*
|
119 |
return $terms;
|
120 |
}
|
121 |
|
122 |
+
/**
|
123 |
* YARPP
|
124 |
+
* Just makes YARPP aware of the language taxonomy ( after Polylang registered it )
|
125 |
*
|
126 |
* @since 1.0
|
127 |
*/
|
129 |
$GLOBALS['wp_taxonomies']['language']->yarpp_support = 1;
|
130 |
}
|
131 |
|
132 |
+
/**
|
133 |
* Yoast SEO
|
134 |
+
* Translate options and add specific filters and actions
|
|
|
135 |
*
|
136 |
* @since 1.6.4
|
137 |
*/
|
140 |
return;
|
141 |
}
|
142 |
|
143 |
+
// Reloads options once the language has been defined to enable translations
|
144 |
+
// Useful only when the language is set from content
|
145 |
if ( did_action( 'wp_loaded' ) ) {
|
146 |
if ( version_compare( WPSEO_VERSION, '1.7.2', '<' ) ) {
|
147 |
global $wpseo_front;
|
155 |
}
|
156 |
}
|
157 |
|
158 |
+
// One sitemap per language when using multiple domains or subdomains
|
159 |
// because WPSEO does not accept several domains or subdomains in one sitemap
|
160 |
if ( PLL()->options['force_lang'] > 1 ) {
|
161 |
add_filter( 'wpseo_enable_xml_sitemap_transient_caching', '__return_false' ); // disable cache! otherwise WPSEO keeps only one domain (thanks to Junaid Bhura)
|
166 |
add_filter( 'wpseo_typecount_where', array( &$this, 'wpseo_posts_where' ), 10, 2 );
|
167 |
}
|
168 |
|
169 |
+
// One sitemap for all languages when the language is set from the content or directory name
|
170 |
else {
|
171 |
add_filter( 'get_terms_args', array( &$this, 'wpseo_remove_terms_filter' ) );
|
172 |
+
|
173 |
+
// Add the homepages for all languages to the sitemap when the front page displays posts
|
174 |
+
if ( ! get_option( 'page_on_front' ) ) {
|
175 |
+
add_filter( 'wpseo_sitemap_post_content', array( &$this, 'add_language_home_urls' ) );
|
176 |
+
}
|
177 |
}
|
178 |
|
179 |
add_filter( 'pll_home_url_white_list', array( &$this, 'wpseo_home_url_white_list' ) );
|
181 |
add_filter( 'wpseo_canonical', array( &$this, 'wpseo_canonical' ) );
|
182 |
}
|
183 |
|
184 |
+
/**
|
185 |
* Yoast SEO
|
186 |
+
* Fixes the home url as well as the stylesheet url
|
187 |
+
* Only when using multiple domains or subdomains
|
188 |
*
|
189 |
* @since 1.6.4
|
190 |
*
|
201 |
return $url;
|
202 |
}
|
203 |
|
204 |
+
/**
|
205 |
* Yoast SEO
|
206 |
+
* Modifies the sql request for posts sitemaps
|
207 |
+
* Only when using multiple domains or subdomains
|
208 |
*
|
209 |
* @since 1.6.4
|
210 |
*
|
211 |
+
* @param string $sql JOIN clause
|
212 |
* @param string $post_type
|
213 |
* @return string
|
214 |
*/
|
216 |
return pll_is_translated_post_type( $post_type ) ? $sql. PLL()->model->post->join_clause() : $sql;
|
217 |
}
|
218 |
|
219 |
+
/**
|
220 |
* Yoast SEO
|
221 |
+
* Modifies the sql request for posts sitemaps
|
222 |
+
* Only when using multiple domains or subdomains
|
223 |
*
|
224 |
* @since 1.6.4
|
225 |
*
|
226 |
+
* @param string $sql WHERE clause
|
227 |
* @param string $post_type
|
228 |
* @return string
|
229 |
*/
|
231 |
return pll_is_translated_post_type( $post_type ) ? $sql . PLL()->model->post->where_clause( PLL()->curlang ) : $sql;
|
232 |
}
|
233 |
|
234 |
+
/**
|
235 |
* Yoast SEO
|
236 |
+
* Removes the language filter for the taxonomy sitemaps
|
237 |
+
* Only when the language is set from the content or directory name
|
238 |
*
|
239 |
* @since 1.0.3
|
240 |
*
|
248 |
return $args;
|
249 |
}
|
250 |
|
251 |
+
/**
|
252 |
+
* Yoast SEO
|
253 |
+
* Adds the home urls for all languages to the sitemap
|
254 |
+
*
|
255 |
+
* @since 1.9
|
256 |
+
*
|
257 |
+
* @param string $str additional urls to sitemap post
|
258 |
+
* @return string
|
259 |
+
*/
|
260 |
+
public function add_language_home_urls( $str ) {
|
261 |
+
global $wpseo_sitemaps;
|
262 |
+
|
263 |
+
foreach ( pll_languages_list() as $lang ) {
|
264 |
+
if ( empty( PLL()->options['hide_default'] ) || pll_default_language() !== $lang ) {
|
265 |
+
$str .= $wpseo_sitemaps->sitemap_url( array(
|
266 |
+
'loc' => pll_home_url( $lang ),
|
267 |
+
'pri' => 1,
|
268 |
+
'chf' => apply_filters( 'wpseo_sitemap_homepage_change_freq', 'daily', pll_home_url( $lang ) ),
|
269 |
+
) );
|
270 |
+
}
|
271 |
+
}
|
272 |
+
return $str;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
* Yoast SEO
|
277 |
*
|
278 |
* @since 1.1.2
|
284 |
return array_merge( $arr, array( array( 'file' => 'wordpress-seo' ) ) );
|
285 |
}
|
286 |
|
287 |
+
/**
|
288 |
* Yoast SEO
|
289 |
+
* Adds opengraph support for translations
|
290 |
*
|
291 |
* @since 1.6
|
292 |
*/
|
303 |
}
|
304 |
}
|
305 |
|
306 |
+
/**
|
307 |
* Yoast SEO
|
308 |
+
* Fixes the canonical front page url as unlike WP, WPSEO does not add a trailing slash to the canonical front page url
|
309 |
*
|
310 |
* @since 1.7.10
|
311 |
*
|
316 |
return is_front_page( $url ) && get_option( 'permalink_structure' ) ? trailingslashit( $url ) : $url;
|
317 |
}
|
318 |
|
319 |
+
/**
|
320 |
* Aqua Resizer
|
321 |
*
|
322 |
* @since 1.1.5
|
328 |
return array_merge( $arr, array( array( 'function' => 'aq_resize' ) ) );
|
329 |
}
|
330 |
|
331 |
+
/**
|
332 |
* Custom field template
|
333 |
* Custom field template does check $_REQUEST['post'] to populate the custom fields values
|
334 |
*
|
335 |
* @since 1.0.2
|
336 |
*
|
337 |
* @param string $post_type unused
|
338 |
+
* @param object $post current post object
|
339 |
*/
|
340 |
public function cft_copy( $post_type, $post ) {
|
341 |
global $custom_field_template;
|
344 |
}
|
345 |
}
|
346 |
|
347 |
+
/**
|
348 |
* Twenty Fourteen
|
349 |
+
* Rewrites the function Featured_Content::get_featured_post_ids()
|
350 |
*
|
351 |
* @since 1.4
|
352 |
*
|
364 |
return $featured_ids;
|
365 |
}
|
366 |
|
367 |
+
// Get featured tag translations
|
368 |
$tags = PLL()->model->term->get_translations( $term->term_id );
|
369 |
$ids = array();
|
370 |
|
371 |
// Query for featured posts in all languages
|
372 |
+
// One query per language to get the correct number of posts per language
|
373 |
foreach ( $tags as $tag ) {
|
374 |
$_ids = get_posts( array(
|
375 |
'lang' => 0, // avoid language filters
|
390 |
return $ids;
|
391 |
}
|
392 |
|
393 |
+
/**
|
394 |
* Twenty Fourteen
|
395 |
+
* Translates the featured tag id in featured content settings
|
396 |
+
* Mainly to allow hiding it when requested in featured content options
|
397 |
+
* Acts only on frontend
|
398 |
*
|
399 |
* @since 1.4
|
400 |
*
|
409 |
return $settings;
|
410 |
}
|
411 |
|
412 |
+
/**
|
413 |
* Duplicate Post
|
414 |
* Avoid duplicating the 'post_translations' taxonomy
|
415 |
*
|
423 |
return $taxonomies;
|
424 |
}
|
425 |
|
426 |
+
/**
|
427 |
* Jetpack
|
428 |
+
* Adapted from the same function in jetpack-3.0.2/3rd-party/wpml.php
|
429 |
*
|
430 |
* @since 1.5.4
|
431 |
*/
|
439 |
return $posts;
|
440 |
}
|
441 |
|
442 |
+
/**
|
443 |
* Jetpack
|
444 |
+
* Adapted from the same function in jetpack-3.0.2/3rd-party/wpml.php
|
445 |
+
* Keeps using 'icl_translate' as the function registers the string
|
446 |
*
|
447 |
* @since 1.5.4
|
448 |
*/
|
457 |
return $r;
|
458 |
}
|
459 |
|
460 |
+
/**
|
461 |
* Jetpack
|
462 |
+
* Adds opengraph support for locale and translations
|
463 |
*
|
464 |
* @since 1.6
|
465 |
*
|
480 |
return $tags;
|
481 |
}
|
482 |
|
483 |
+
/**
|
484 |
* Jetpack
|
485 |
* Allows to make sure that related posts are in the correct language
|
486 |
*
|
487 |
* @since 1.8
|
488 |
*
|
489 |
+
* @param array $filters Array of ElasticSearch filters based on the post_id and args.
|
490 |
* @param string $post_id Post ID of the post for which we are retrieving Related Posts.
|
491 |
* @return array
|
492 |
*/
|
493 |
function jetpack_relatedposts_filter_filters( $filters, $post_id ) {
|
494 |
$slug = sanitize_title( pll_get_post_language( $post_id, 'name' ) );
|
495 |
+
$filters[] = array( 'term' => array( 'taxonomy.language.slug' => $slug ) );
|
496 |
return $filters;
|
497 |
}
|
498 |
|
499 |
+
/**
|
500 |
* Correspondance between WordPress locales and Facebook locales
|
501 |
* @see https://translate.wordpress.org/
|
502 |
* @see https://www.facebook.com/translations/FacebookLocales.xml
|
modules/plugins/wp-import.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* a class to import languages and translations information form a WXR file
|
5 |
*
|
6 |
* @since 1.2
|
@@ -8,7 +8,7 @@
|
|
8 |
class PLL_WP_Import extends WP_Import {
|
9 |
public $post_translations = array();
|
10 |
|
11 |
-
|
12 |
* overrides WP_Import::process_terms to remap terms translations
|
13 |
*
|
14 |
* @since 1.2
|
@@ -44,7 +44,7 @@ class PLL_WP_Import extends WP_Import {
|
|
44 |
$this->remap_translations( $term_translations, $this->processed_terms );
|
45 |
}
|
46 |
|
47 |
-
|
48 |
* overrides WP_Import::process_post to remap posts translations
|
49 |
* also merges strings translations from the WXR file to the existing ones
|
50 |
*
|
@@ -103,7 +103,7 @@ class PLL_WP_Import extends WP_Import {
|
|
103 |
}
|
104 |
}
|
105 |
|
106 |
-
|
107 |
* remaps terms languages
|
108 |
*
|
109 |
* @since 1.2
|
@@ -149,7 +149,7 @@ class PLL_WP_Import extends WP_Import {
|
|
149 |
}
|
150 |
}
|
151 |
|
152 |
-
|
153 |
* remaps translations for both posts and terms
|
154 |
*
|
155 |
* @since 1.2
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* a class to import languages and translations information form a WXR file
|
5 |
*
|
6 |
* @since 1.2
|
8 |
class PLL_WP_Import extends WP_Import {
|
9 |
public $post_translations = array();
|
10 |
|
11 |
+
/**
|
12 |
* overrides WP_Import::process_terms to remap terms translations
|
13 |
*
|
14 |
* @since 1.2
|
44 |
$this->remap_translations( $term_translations, $this->processed_terms );
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
* overrides WP_Import::process_post to remap posts translations
|
49 |
* also merges strings translations from the WXR file to the existing ones
|
50 |
*
|
103 |
}
|
104 |
}
|
105 |
|
106 |
+
/**
|
107 |
* remaps terms languages
|
108 |
*
|
109 |
* @since 1.2
|
149 |
}
|
150 |
}
|
151 |
|
152 |
+
/**
|
153 |
* remaps translations for both posts and terms
|
154 |
*
|
155 |
* @since 1.2
|
modules/share-slug/settings-share-slug.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Settings class to advertize the Share slugs module
|
5 |
+
*
|
6 |
+
* @since 1.9
|
7 |
+
*/
|
8 |
+
class PLL_Settings_Share_Slug extends PLL_Settings_Module {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* constructor
|
12 |
+
*
|
13 |
+
* @since 1.9
|
14 |
+
*
|
15 |
+
* @param object $polylang polylang object
|
16 |
+
*/
|
17 |
+
public function __construct( &$polylang ) {
|
18 |
+
parent::__construct( $polylang, array(
|
19 |
+
'module' => 'share-slugs',
|
20 |
+
'title' => __( 'Share slugs', 'polylang' ),
|
21 |
+
'description' => __( 'Allows to share the same url slug accross languages for posts and terms.', 'polylang' ),
|
22 |
+
) );
|
23 |
+
|
24 |
+
if ( class_exists( 'PLL_Share_Post_Slug', true ) && get_option( 'permalink_structure' ) ) {
|
25 |
+
add_action( 'admin_print_footer_scripts', array( &$this, 'print_js' ) );
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* tells if the module is active
|
31 |
+
*
|
32 |
+
* @since 1.9
|
33 |
+
*
|
34 |
+
* @return bool
|
35 |
+
*/
|
36 |
+
public function is_active() {
|
37 |
+
return class_exists( 'PLL_Share_Post_Slug', true ) && $this->options['force_lang'] && get_option( 'permalink_structure' );
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* displays upgrade message
|
42 |
+
*
|
43 |
+
* @since 1.9
|
44 |
+
*
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
public function get_upgrade_message() {
|
48 |
+
return class_exists( 'PLL_Share_Post_Slug', true ) ? '' : $this->default_upgrade_message();
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* displays the javascript to handle dynamically the change in url modifications
|
53 |
+
* as sharing slugs is not possible when the language is set from the content
|
54 |
+
*
|
55 |
+
* @since 1.9
|
56 |
+
*/
|
57 |
+
public function print_js() {
|
58 |
+
wp_enqueue_script( 'jquery' );
|
59 |
+
|
60 |
+
$activated = sprintf( '<span class="activated">%s</span>', $this->action_links['activated'] );
|
61 |
+
$deactivated = sprintf( '<span class="deactivated">%s</span>', $this->action_links['deactivated'] );
|
62 |
+
|
63 |
+
?>
|
64 |
+
<script type='text/javascript'>
|
65 |
+
//<![CDATA[
|
66 |
+
( function( $ ){
|
67 |
+
$( "input[name='force_lang']" ).change( function() {
|
68 |
+
var value = $( this ).val();
|
69 |
+
if ( value > 0 ) {
|
70 |
+
$( "#pll-module-share-slugs" ).removeClass( "inactive" ).addClass( "active" ).children( "td" ).children( ".row-actions" ).html( '<?php echo $activated; ?>' );
|
71 |
+
}
|
72 |
+
else {
|
73 |
+
$( "#pll-module-share-slugs" ).removeClass( "active" ).addClass( "inactive" ).children( "td" ).children( ".row-actions" ).html( '<?php echo $deactivated; ?>' );
|
74 |
+
}
|
75 |
+
} );
|
76 |
+
} )( jQuery );
|
77 |
+
// ]]>
|
78 |
+
</script><?php
|
79 |
+
}
|
80 |
+
}
|
modules/sync/admin-sync.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* manages copy and synchronization of terms and post metas
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Admin_Sync {
|
9 |
|
10 |
-
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.2
|
@@ -31,23 +31,26 @@ class PLL_Admin_Sync {
|
|
31 |
}
|
32 |
}
|
33 |
|
34 |
-
|
35 |
* translate post parent if exists when using "Add new" ( translation )
|
36 |
*
|
37 |
* @since 0.6
|
|
|
|
|
|
|
38 |
*/
|
39 |
public function wp_insert_post_parent( $post_parent ) {
|
40 |
return isset( $_GET['from_post'], $_GET['new_lang'] ) && ( $id = wp_get_post_parent_id( (int) $_GET['from_post'] ) ) && ( $parent = $this->model->post->get_translation( $id, $_GET['new_lang'] ) ) ? $parent : $post_parent;
|
41 |
}
|
42 |
|
43 |
-
|
44 |
* copy post metas, menu order, comment and ping status when using "Add new" ( translation )
|
45 |
* formerly used dbx_post_advanced deprecated in WP 3.7
|
46 |
*
|
47 |
* @since 1.2
|
48 |
*
|
49 |
* @param string $post_type unused
|
50 |
-
* @param object $post
|
51 |
*/
|
52 |
public function add_meta_boxes( $post_type, $post ) {
|
53 |
if ( 'post-new.php' == $GLOBALS['pagenow'] && isset( $_GET['from_post'], $_GET['new_lang'] ) && $this->model->is_translated_post_type( $post->post_type ) ) {
|
@@ -69,7 +72,7 @@ class PLL_Admin_Sync {
|
|
69 |
}
|
70 |
}
|
71 |
|
72 |
-
|
73 |
* get the list of taxonomies to copy or to synchronize
|
74 |
*
|
75 |
* @since 1.7
|
@@ -83,16 +86,24 @@ class PLL_Admin_Sync {
|
|
83 |
$taxonomies[] = 'post_format';
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
return array_unique( apply_filters( 'pll_copy_taxonomies', $taxonomies, $sync ) );
|
87 |
}
|
88 |
|
89 |
-
|
90 |
* copy or synchronize terms
|
91 |
*
|
92 |
* @since 1.8
|
93 |
*
|
94 |
-
* @param int
|
95 |
-
* @param int
|
96 |
* @param string $lang language slug
|
97 |
* @param bool $sync true if it is synchronization, false if it is a copy, defaults to false
|
98 |
*/
|
@@ -141,13 +152,13 @@ class PLL_Admin_Sync {
|
|
141 |
}
|
142 |
}
|
143 |
|
144 |
-
|
145 |
* copy or synchronize metas (custom fields)
|
146 |
*
|
147 |
* @since 0.9
|
148 |
*
|
149 |
-
* @param int
|
150 |
-
* @param int
|
151 |
* @param string $lang language slug
|
152 |
* @param bool $sync true if it is synchronization, false if it is a copy, defaults to false
|
153 |
*/
|
@@ -171,6 +182,14 @@ class PLL_Admin_Sync {
|
|
171 |
}
|
172 |
}
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
$keys = array_unique( apply_filters( 'pll_copy_post_metas', empty( $keys ) ? array() : $keys, $sync ) );
|
175 |
|
176 |
// and now copy / synchronize
|
@@ -188,14 +207,14 @@ class PLL_Admin_Sync {
|
|
188 |
}
|
189 |
}
|
190 |
|
191 |
-
|
192 |
* synchronizes terms and metas in translations
|
193 |
*
|
194 |
* @since 1.2
|
195 |
*
|
196 |
-
* @param int
|
197 |
-
* @param object $post
|
198 |
-
* @param array
|
199 |
*/
|
200 |
public function pll_save_post( $post_id, $post, $translations ) {
|
201 |
global $wpdb;
|
@@ -247,14 +266,14 @@ class PLL_Admin_Sync {
|
|
247 |
}
|
248 |
}
|
249 |
|
250 |
-
|
251 |
* synchronize translations of a term in all posts
|
252 |
*
|
253 |
* @since 1.2
|
254 |
*
|
255 |
-
* @param int
|
256 |
-
* @param string $taxonomy
|
257 |
-
* @param array
|
258 |
*/
|
259 |
public function pll_save_term( $term_id, $taxonomy, $translations ) {
|
260 |
// check if the taxonomy is synchronized
|
@@ -273,7 +292,7 @@ class PLL_Admin_Sync {
|
|
273 |
'taxonomy' => $taxonomy,
|
274 |
'field' => 'id',
|
275 |
'terms' => array_merge( array( $term_id ), array_values( $translations ) ),
|
276 |
-
) )
|
277 |
) );
|
278 |
|
279 |
// associate translated term to translated post
|
@@ -313,7 +332,7 @@ class PLL_Admin_Sync {
|
|
313 |
}
|
314 |
}
|
315 |
|
316 |
-
|
317 |
* synchronizes terms and metas in translations for media
|
318 |
*
|
319 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* manages copy and synchronization of terms and post metas
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Admin_Sync {
|
9 |
|
10 |
+
/**
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.2
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
* translate post parent if exists when using "Add new" ( translation )
|
36 |
*
|
37 |
* @since 0.6
|
38 |
+
*
|
39 |
+
* @param int $post_parent
|
40 |
+
* @return int
|
41 |
*/
|
42 |
public function wp_insert_post_parent( $post_parent ) {
|
43 |
return isset( $_GET['from_post'], $_GET['new_lang'] ) && ( $id = wp_get_post_parent_id( (int) $_GET['from_post'] ) ) && ( $parent = $this->model->post->get_translation( $id, $_GET['new_lang'] ) ) ? $parent : $post_parent;
|
44 |
}
|
45 |
|
46 |
+
/**
|
47 |
* copy post metas, menu order, comment and ping status when using "Add new" ( translation )
|
48 |
* formerly used dbx_post_advanced deprecated in WP 3.7
|
49 |
*
|
50 |
* @since 1.2
|
51 |
*
|
52 |
* @param string $post_type unused
|
53 |
+
* @param object $post current post object
|
54 |
*/
|
55 |
public function add_meta_boxes( $post_type, $post ) {
|
56 |
if ( 'post-new.php' == $GLOBALS['pagenow'] && isset( $_GET['from_post'], $_GET['new_lang'] ) && $this->model->is_translated_post_type( $post->post_type ) ) {
|
72 |
}
|
73 |
}
|
74 |
|
75 |
+
/**
|
76 |
* get the list of taxonomies to copy or to synchronize
|
77 |
*
|
78 |
* @since 1.7
|
86 |
$taxonomies[] = 'post_format';
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
+
* Filter the taxonomies to copy or synchronize
|
91 |
+
*
|
92 |
+
* @since 1.7
|
93 |
+
*
|
94 |
+
* @param array $taxonomies list of taxonomy names
|
95 |
+
* @param bool $sync true if it is synchronization, false if it is a copy
|
96 |
+
*/
|
97 |
return array_unique( apply_filters( 'pll_copy_taxonomies', $taxonomies, $sync ) );
|
98 |
}
|
99 |
|
100 |
+
/**
|
101 |
* copy or synchronize terms
|
102 |
*
|
103 |
* @since 1.8
|
104 |
*
|
105 |
+
* @param int $from id of the post from which we copy informations
|
106 |
+
* @param int $to id of the post to which we paste informations
|
107 |
* @param string $lang language slug
|
108 |
* @param bool $sync true if it is synchronization, false if it is a copy, defaults to false
|
109 |
*/
|
152 |
}
|
153 |
}
|
154 |
|
155 |
+
/**
|
156 |
* copy or synchronize metas (custom fields)
|
157 |
*
|
158 |
* @since 0.9
|
159 |
*
|
160 |
+
* @param int $from id of the post from which we copy informations
|
161 |
+
* @param int $to id of the post to which we paste informations
|
162 |
* @param string $lang language slug
|
163 |
* @param bool $sync true if it is synchronization, false if it is a copy, defaults to false
|
164 |
*/
|
182 |
}
|
183 |
}
|
184 |
|
185 |
+
/**
|
186 |
+
* Filter the custom fields to copy or synchronize
|
187 |
+
*
|
188 |
+
* @since 0.6
|
189 |
+
*
|
190 |
+
* @param array $keys list of custom fields names
|
191 |
+
* @param bool $sync true if it is synchronization, false if it is a copy
|
192 |
+
*/
|
193 |
$keys = array_unique( apply_filters( 'pll_copy_post_metas', empty( $keys ) ? array() : $keys, $sync ) );
|
194 |
|
195 |
// and now copy / synchronize
|
207 |
}
|
208 |
}
|
209 |
|
210 |
+
/**
|
211 |
* synchronizes terms and metas in translations
|
212 |
*
|
213 |
* @since 1.2
|
214 |
*
|
215 |
+
* @param int $post_id post id
|
216 |
+
* @param object $post post object
|
217 |
+
* @param array $translations post translations
|
218 |
*/
|
219 |
public function pll_save_post( $post_id, $post, $translations ) {
|
220 |
global $wpdb;
|
266 |
}
|
267 |
}
|
268 |
|
269 |
+
/**
|
270 |
* synchronize translations of a term in all posts
|
271 |
*
|
272 |
* @since 1.2
|
273 |
*
|
274 |
+
* @param int $term_id term id
|
275 |
+
* @param string $taxonomy taxonomy name of the term
|
276 |
+
* @param array $translations translations of the term
|
277 |
*/
|
278 |
public function pll_save_term( $term_id, $taxonomy, $translations ) {
|
279 |
// check if the taxonomy is synchronized
|
292 |
'taxonomy' => $taxonomy,
|
293 |
'field' => 'id',
|
294 |
'terms' => array_merge( array( $term_id ), array_values( $translations ) ),
|
295 |
+
) ),
|
296 |
) );
|
297 |
|
298 |
// associate translated term to translated post
|
332 |
}
|
333 |
}
|
334 |
|
335 |
+
/**
|
336 |
* synchronizes terms and metas in translations for media
|
337 |
*
|
338 |
* @since 1.8
|
modules/sync/settings-sync.php
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* Settings class for synchronization settings management
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_Sync extends PLL_Settings_Module {
|
9 |
-
|
|
|
10 |
* constructor
|
11 |
*
|
12 |
* @since 1.8
|
@@ -21,7 +22,7 @@ class PLL_Settings_Sync extends PLL_Settings_Module {
|
|
21 |
) );
|
22 |
}
|
23 |
|
24 |
-
|
25 |
* deactivates the module
|
26 |
*
|
27 |
* @since 1.8
|
@@ -31,7 +32,7 @@ class PLL_Settings_Sync extends PLL_Settings_Module {
|
|
31 |
update_option( 'polylang', $this->options );
|
32 |
}
|
33 |
|
34 |
-
|
35 |
* displays the settings form
|
36 |
*
|
37 |
* @since 1.8
|
@@ -49,7 +50,7 @@ class PLL_Settings_Sync extends PLL_Settings_Module {
|
|
49 |
</ul><?php
|
50 |
}
|
51 |
|
52 |
-
|
53 |
* sanitizes the settings before saving
|
54 |
*
|
55 |
* @since 1.8
|
@@ -61,7 +62,7 @@ class PLL_Settings_Sync extends PLL_Settings_Module {
|
|
61 |
return $newoptions; // take care to return only validated options
|
62 |
}
|
63 |
|
64 |
-
|
65 |
* get the row actions
|
66 |
*
|
67 |
* @since 1.8
|
@@ -72,7 +73,7 @@ class PLL_Settings_Sync extends PLL_Settings_Module {
|
|
72 |
return empty( $this->options['sync'] ) ? array( 'configure' ) : array( 'configure', 'deactivate' );
|
73 |
}
|
74 |
|
75 |
-
|
76 |
* list the post metas to synchronize
|
77 |
*
|
78 |
* @since 1.0
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* Settings class for synchronization settings management
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_Sync extends PLL_Settings_Module {
|
9 |
+
|
10 |
+
/**
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.8
|
22 |
) );
|
23 |
}
|
24 |
|
25 |
+
/**
|
26 |
* deactivates the module
|
27 |
*
|
28 |
* @since 1.8
|
32 |
update_option( 'polylang', $this->options );
|
33 |
}
|
34 |
|
35 |
+
/**
|
36 |
* displays the settings form
|
37 |
*
|
38 |
* @since 1.8
|
50 |
</ul><?php
|
51 |
}
|
52 |
|
53 |
+
/**
|
54 |
* sanitizes the settings before saving
|
55 |
*
|
56 |
* @since 1.8
|
62 |
return $newoptions; // take care to return only validated options
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
* get the row actions
|
67 |
*
|
68 |
* @since 1.8
|
73 |
return empty( $this->options['sync'] ) ? array( 'configure' ) : array( 'configure', 'deactivate' );
|
74 |
}
|
75 |
|
76 |
+
/**
|
77 |
* list the post metas to synchronize
|
78 |
*
|
79 |
* @since 1.0
|
modules/translate-slugs/settings-translate-slugs.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Settings class to advertize the Translate slugs module
|
5 |
+
*
|
6 |
+
* @since 1.9
|
7 |
+
*/
|
8 |
+
class PLL_Settings_Translate_Slugs extends PLL_Settings_Module {
|
9 |
+
/**
|
10 |
+
* constructor
|
11 |
+
*
|
12 |
+
* @since 1.9
|
13 |
+
*
|
14 |
+
* @param object $polylang polylang object
|
15 |
+
*/
|
16 |
+
public function __construct( &$polylang ) {
|
17 |
+
parent::__construct( $polylang, array(
|
18 |
+
'module' => 'translate-slugs',
|
19 |
+
'title' => __( 'Translate slugs', 'polylang' ),
|
20 |
+
'description' => __( 'Allows to translate custom post types and taxonomies slugs in urls.', 'polylang' ),
|
21 |
+
) );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* tells if the module is active
|
26 |
+
*
|
27 |
+
* @since 1.9
|
28 |
+
*
|
29 |
+
* @return bool
|
30 |
+
*/
|
31 |
+
public function is_active() {
|
32 |
+
return class_exists( 'PLL_Translate_Slugs_Model', true ) && get_option( 'permalink_structure' );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* displays upgrade message
|
37 |
+
*
|
38 |
+
* @since 1.9
|
39 |
+
*
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function get_upgrade_message() {
|
43 |
+
return class_exists( 'PLL_Translate_Slugs_Model', true ) ? '' : $this->default_upgrade_message();
|
44 |
+
}
|
45 |
+
}
|
modules/wpml/settings-wpml.php
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* A class to inform about the WPML compatibility module in Polylang settings
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_WPML extends PLL_Settings_Module {
|
9 |
-
|
|
|
10 |
* constructor
|
11 |
*
|
12 |
* @since 1.8
|
@@ -21,7 +22,7 @@ class PLL_Settings_WPML extends PLL_Settings_Module {
|
|
21 |
) );
|
22 |
}
|
23 |
|
24 |
-
|
25 |
* tells if the module is active
|
26 |
*
|
27 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* A class to inform about the WPML compatibility module in Polylang settings
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_WPML extends PLL_Settings_Module {
|
9 |
+
|
10 |
+
/**
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.8
|
22 |
) );
|
23 |
}
|
24 |
|
25 |
+
/**
|
26 |
* tells if the module is active
|
27 |
*
|
28 |
* @since 1.8
|
modules/wpml/wpml-compat.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
*/
|
6 |
|
7 |
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
exit; // don't access directly
|
9 |
};
|
10 |
|
11 |
-
|
12 |
* defines two WPML constants once the language has been defined
|
13 |
* the compatibility with WPML is not perfect on admin side as the constants are defined
|
14 |
* in 'setup_theme' by Polylang ( based on user info ) and 'plugins_loaded' by WPML ( based on cookie )
|
@@ -39,7 +39,7 @@ function pll_define_wpml_constants() {
|
|
39 |
|
40 |
add_action( 'pll_language_defined', 'pll_define_wpml_constants' );
|
41 |
|
42 |
-
|
43 |
* link to the home page in the active language
|
44 |
*
|
45 |
* @since 0.9.4
|
@@ -52,7 +52,7 @@ if ( ! function_exists( 'icl_get_home_url' ) ) {
|
|
52 |
}
|
53 |
}
|
54 |
|
55 |
-
|
56 |
* used for building custom language selectors
|
57 |
* available only on frontend
|
58 |
*
|
@@ -115,15 +115,15 @@ if ( ! function_exists( 'icl_get_languages' ) ) {
|
|
115 |
}
|
116 |
}
|
117 |
|
118 |
-
|
119 |
* used for creating language dependent links in themes
|
120 |
*
|
121 |
* @since 1.0
|
122 |
*
|
123 |
-
* @param int
|
124 |
-
* @param string $type
|
125 |
-
* @param string $text
|
126 |
-
* @param array
|
127 |
* @param string $anchor optional the anchor to add to teh link, defaults to empty
|
128 |
* @return string a language dependent link
|
129 |
*/
|
@@ -167,14 +167,14 @@ if ( ! function_exists( 'icl_link_to_element' ) ) {
|
|
167 |
}
|
168 |
}
|
169 |
|
170 |
-
|
171 |
* used for calculating the IDs of objects ( usually categories ) in the current language
|
172 |
*
|
173 |
* @since 0.9.5
|
174 |
*
|
175 |
* @param int $id object id
|
176 |
* @param string $type, post type or taxonomy name of the object, defaults to 'post'
|
177 |
-
* @param bool
|
178 |
* @param string $lang optional language code, defaults to current language
|
179 |
* @return int|null the object id of the translation, null if the translation is missing and $return_original_if_missing set to false
|
180 |
*/
|
@@ -186,7 +186,7 @@ if ( ! function_exists( 'icl_object_id' ) ) {
|
|
186 |
}
|
187 |
}
|
188 |
|
189 |
-
|
190 |
* undocumented function used by the theme Maya
|
191 |
* returns the post language
|
192 |
* @see original WPML code at https://wpml.org/forums/topic/canonical-urls-for-wpml-duplicated-posts/#post-52198
|
@@ -213,14 +213,14 @@ if ( ! function_exists( 'wpml_get_language_information' ) ) {
|
|
213 |
}
|
214 |
}
|
215 |
|
216 |
-
|
217 |
* registers a string for translation in the "strings translation" panel
|
218 |
*
|
219 |
* @since 0.9.3
|
220 |
*
|
221 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
222 |
-
* @param string $name
|
223 |
-
* @param string $string
|
224 |
*/
|
225 |
if ( ! function_exists( 'icl_register_string' ) ) {
|
226 |
function icl_register_string( $context, $name, $string ) {
|
@@ -228,13 +228,13 @@ if ( ! function_exists( 'icl_register_string' ) ) {
|
|
228 |
}
|
229 |
}
|
230 |
|
231 |
-
|
232 |
* removes a string from the "strings translation" panel
|
233 |
*
|
234 |
* @since 1.0.2
|
235 |
*
|
236 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
237 |
-
* @param string $name
|
238 |
*/
|
239 |
if ( ! function_exists( 'icl_unregister_string' ) ) {
|
240 |
function icl_unregister_string( $context, $name ) {
|
@@ -242,14 +242,14 @@ if ( ! function_exists( 'icl_unregister_string' ) ) {
|
|
242 |
}
|
243 |
}
|
244 |
|
245 |
-
|
246 |
* gets the translated value of a string ( previously registered with icl_register_string or pll_register_string )
|
247 |
*
|
248 |
* @since 0.9.3
|
249 |
*
|
250 |
* @param string $context not used by Polylang
|
251 |
-
* @param string $name
|
252 |
-
* @param string $string
|
253 |
* @return string the translated string in the current language
|
254 |
*/
|
255 |
if ( ! function_exists( 'icl_t' ) ) {
|
@@ -258,7 +258,7 @@ if ( ! function_exists( 'icl_t' ) ) {
|
|
258 |
}
|
259 |
}
|
260 |
|
261 |
-
|
262 |
* undocumented function used by NextGen Gallery
|
263 |
* seems to be used to both register and translate a string
|
264 |
* used in PLL_Plugins_Compat for Jetpack with only 3 arguments
|
@@ -266,9 +266,9 @@ if ( ! function_exists( 'icl_t' ) ) {
|
|
266 |
* @since 1.0.2
|
267 |
*
|
268 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
269 |
-
* @param string $name
|
270 |
-
* @param string $string
|
271 |
-
* @param bool
|
272 |
* @return string the translated string in the current language
|
273 |
*/
|
274 |
if ( ! function_exists( 'icl_translate' ) ) {
|
@@ -278,11 +278,11 @@ if ( ! function_exists( 'icl_translate' ) ) {
|
|
278 |
}
|
279 |
}
|
280 |
|
281 |
-
|
282 |
* undocumented function used by Types
|
283 |
* FIXME: tested only with Types
|
284 |
* probably incomplete as Types locks the custom fields for a new post, but not when edited
|
285 |
-
* this is probably linked to the fact that WPML has always an original post in the default language and not Polylang :
|
286 |
*
|
287 |
* @since 1.1.2
|
288 |
*
|
@@ -302,13 +302,14 @@ if ( ! function_exists( 'wpml_get_copied_fields_for_post_edit' ) ) {
|
|
302 |
}
|
303 |
|
304 |
// apply our filter and fill the expected output ( see /types/embedded/includes/fields-post.php )
|
|
|
305 |
$arr['fields'] = array_unique( apply_filters( 'pll_copy_post_metas', empty( $keys ) ? array() : $keys, false ) );
|
306 |
$arr['original_post_id'] = (int) $_GET['from_post'];
|
307 |
return $arr;
|
308 |
}
|
309 |
}
|
310 |
|
311 |
-
|
312 |
* undocumented function used by Warp 6 by Yootheme
|
313 |
*
|
314 |
* @since 1.0.5
|
@@ -321,7 +322,7 @@ if ( ! function_exists( 'icl_get_default_language' ) ) {
|
|
321 |
}
|
322 |
}
|
323 |
|
324 |
-
|
325 |
* undocumented function reported to be used by Table Rate Shipping for WooCommerce
|
326 |
* @see https://wordpress.org/support/topic/add-wpml-compatibility-function
|
327 |
*
|
@@ -335,7 +336,7 @@ if ( ! function_exists( 'wpml_get_default_language' ) ) {
|
|
335 |
}
|
336 |
}
|
337 |
|
338 |
-
|
339 |
* registers strings in a persistent way as done by WPML
|
340 |
*
|
341 |
* @since 1.0.2
|
@@ -344,7 +345,7 @@ class PLL_WPML_Compat {
|
|
344 |
static protected $instance; // for singleton
|
345 |
static protected $strings; // used for cache
|
346 |
|
347 |
-
|
348 |
* constructor
|
349 |
*
|
350 |
* @since 1.0.2
|
@@ -355,7 +356,7 @@ class PLL_WPML_Compat {
|
|
355 |
add_action( 'pll_get_strings', array( &$this, 'get_strings' ) );
|
356 |
}
|
357 |
|
358 |
-
|
359 |
* access to the single instance of the class
|
360 |
*
|
361 |
* @since 1.7
|
@@ -369,7 +370,7 @@ class PLL_WPML_Compat {
|
|
369 |
return self::$instance;
|
370 |
}
|
371 |
|
372 |
-
|
373 |
* unlike pll_register_string, icl_register_string stores the string in database
|
374 |
* so we need to do the same as some plugins or themes may expect this
|
375 |
* we use a serialized option to do this
|
@@ -377,9 +378,9 @@ class PLL_WPML_Compat {
|
|
377 |
* @since 1.0.2
|
378 |
*
|
379 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
380 |
-
* @param string $name
|
381 |
-
* @param string $string
|
382 |
-
|
383 |
public function register_string( $context, $name, $string ) {
|
384 |
// registers the string if it does not exist yet
|
385 |
$to_register = array( 'context' => $context, 'name' => $name, 'string' => $string, 'multiline' => false, 'icl' => true );
|
@@ -389,13 +390,13 @@ class PLL_WPML_Compat {
|
|
389 |
}
|
390 |
}
|
391 |
|
392 |
-
|
393 |
* removes a string from the registered strings list
|
394 |
*
|
395 |
* @since 1.0.2
|
396 |
*
|
397 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
398 |
-
* @param string $name
|
399 |
*/
|
400 |
public function unregister_string( $context, $name ) {
|
401 |
foreach ( self::$strings as $key => $string ) {
|
@@ -406,7 +407,7 @@ class PLL_WPML_Compat {
|
|
406 |
}
|
407 |
}
|
408 |
|
409 |
-
|
410 |
* adds strings registered by icl_register_string to those registered by pll_register_string
|
411 |
*
|
412 |
* @since 1.0.2
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Compatibility with WPML API. See http://wpml.org/documentation/support/wpml-coding-api/
|
5 |
*/
|
6 |
|
7 |
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
exit; // don't access directly
|
9 |
};
|
10 |
|
11 |
+
/**
|
12 |
* defines two WPML constants once the language has been defined
|
13 |
* the compatibility with WPML is not perfect on admin side as the constants are defined
|
14 |
* in 'setup_theme' by Polylang ( based on user info ) and 'plugins_loaded' by WPML ( based on cookie )
|
39 |
|
40 |
add_action( 'pll_language_defined', 'pll_define_wpml_constants' );
|
41 |
|
42 |
+
/**
|
43 |
* link to the home page in the active language
|
44 |
*
|
45 |
* @since 0.9.4
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
/**
|
56 |
* used for building custom language selectors
|
57 |
* available only on frontend
|
58 |
*
|
115 |
}
|
116 |
}
|
117 |
|
118 |
+
/**
|
119 |
* used for creating language dependent links in themes
|
120 |
*
|
121 |
* @since 1.0
|
122 |
*
|
123 |
+
* @param int $id object id
|
124 |
+
* @param string $type optional, post type or taxonomy name of the object, defaults to 'post'
|
125 |
+
* @param string $text optional the link text. If not specified will produce the name of the element in the current language
|
126 |
+
* @param array $args optional an array of arguments to add to the link, defaults to empty
|
127 |
* @param string $anchor optional the anchor to add to teh link, defaults to empty
|
128 |
* @return string a language dependent link
|
129 |
*/
|
167 |
}
|
168 |
}
|
169 |
|
170 |
+
/**
|
171 |
* used for calculating the IDs of objects ( usually categories ) in the current language
|
172 |
*
|
173 |
* @since 0.9.5
|
174 |
*
|
175 |
* @param int $id object id
|
176 |
* @param string $type, post type or taxonomy name of the object, defaults to 'post'
|
177 |
+
* @param bool $return_original_if_missing optional, true if Polylang should return the original id if the translation is missing, defaults to false
|
178 |
* @param string $lang optional language code, defaults to current language
|
179 |
* @return int|null the object id of the translation, null if the translation is missing and $return_original_if_missing set to false
|
180 |
*/
|
186 |
}
|
187 |
}
|
188 |
|
189 |
+
/**
|
190 |
* undocumented function used by the theme Maya
|
191 |
* returns the post language
|
192 |
* @see original WPML code at https://wpml.org/forums/topic/canonical-urls-for-wpml-duplicated-posts/#post-52198
|
213 |
}
|
214 |
}
|
215 |
|
216 |
+
/**
|
217 |
* registers a string for translation in the "strings translation" panel
|
218 |
*
|
219 |
* @since 0.9.3
|
220 |
*
|
221 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
222 |
+
* @param string $name a unique name for the string
|
223 |
+
* @param string $string the string to register
|
224 |
*/
|
225 |
if ( ! function_exists( 'icl_register_string' ) ) {
|
226 |
function icl_register_string( $context, $name, $string ) {
|
228 |
}
|
229 |
}
|
230 |
|
231 |
+
/**
|
232 |
* removes a string from the "strings translation" panel
|
233 |
*
|
234 |
* @since 1.0.2
|
235 |
*
|
236 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
237 |
+
* @param string $name a unique name for the string
|
238 |
*/
|
239 |
if ( ! function_exists( 'icl_unregister_string' ) ) {
|
240 |
function icl_unregister_string( $context, $name ) {
|
242 |
}
|
243 |
}
|
244 |
|
245 |
+
/**
|
246 |
* gets the translated value of a string ( previously registered with icl_register_string or pll_register_string )
|
247 |
*
|
248 |
* @since 0.9.3
|
249 |
*
|
250 |
* @param string $context not used by Polylang
|
251 |
+
* @param string $name not used by Polylang
|
252 |
+
* @param string $string the string to translated
|
253 |
* @return string the translated string in the current language
|
254 |
*/
|
255 |
if ( ! function_exists( 'icl_t' ) ) {
|
258 |
}
|
259 |
}
|
260 |
|
261 |
+
/**
|
262 |
* undocumented function used by NextGen Gallery
|
263 |
* seems to be used to both register and translate a string
|
264 |
* used in PLL_Plugins_Compat for Jetpack with only 3 arguments
|
266 |
* @since 1.0.2
|
267 |
*
|
268 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
269 |
+
* @param string $name a unique name for the string
|
270 |
+
* @param string $string the string to register
|
271 |
+
* @param bool $bool optional, not used by Polylang
|
272 |
* @return string the translated string in the current language
|
273 |
*/
|
274 |
if ( ! function_exists( 'icl_translate' ) ) {
|
278 |
}
|
279 |
}
|
280 |
|
281 |
+
/**
|
282 |
* undocumented function used by Types
|
283 |
* FIXME: tested only with Types
|
284 |
* probably incomplete as Types locks the custom fields for a new post, but not when edited
|
285 |
+
* this is probably linked to the fact that WPML has always an original post in the default language and not Polylang :)
|
286 |
*
|
287 |
* @since 1.1.2
|
288 |
*
|
302 |
}
|
303 |
|
304 |
// apply our filter and fill the expected output ( see /types/embedded/includes/fields-post.php )
|
305 |
+
/** This filter is documented in modules/sync/admin-sync.php */
|
306 |
$arr['fields'] = array_unique( apply_filters( 'pll_copy_post_metas', empty( $keys ) ? array() : $keys, false ) );
|
307 |
$arr['original_post_id'] = (int) $_GET['from_post'];
|
308 |
return $arr;
|
309 |
}
|
310 |
}
|
311 |
|
312 |
+
/**
|
313 |
* undocumented function used by Warp 6 by Yootheme
|
314 |
*
|
315 |
* @since 1.0.5
|
322 |
}
|
323 |
}
|
324 |
|
325 |
+
/**
|
326 |
* undocumented function reported to be used by Table Rate Shipping for WooCommerce
|
327 |
* @see https://wordpress.org/support/topic/add-wpml-compatibility-function
|
328 |
*
|
336 |
}
|
337 |
}
|
338 |
|
339 |
+
/**
|
340 |
* registers strings in a persistent way as done by WPML
|
341 |
*
|
342 |
* @since 1.0.2
|
345 |
static protected $instance; // for singleton
|
346 |
static protected $strings; // used for cache
|
347 |
|
348 |
+
/**
|
349 |
* constructor
|
350 |
*
|
351 |
* @since 1.0.2
|
356 |
add_action( 'pll_get_strings', array( &$this, 'get_strings' ) );
|
357 |
}
|
358 |
|
359 |
+
/**
|
360 |
* access to the single instance of the class
|
361 |
*
|
362 |
* @since 1.7
|
370 |
return self::$instance;
|
371 |
}
|
372 |
|
373 |
+
/**
|
374 |
* unlike pll_register_string, icl_register_string stores the string in database
|
375 |
* so we need to do the same as some plugins or themes may expect this
|
376 |
* we use a serialized option to do this
|
378 |
* @since 1.0.2
|
379 |
*
|
380 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
381 |
+
* @param string $name a unique name for the string
|
382 |
+
* @param string $string the string to register
|
383 |
+
*/
|
384 |
public function register_string( $context, $name, $string ) {
|
385 |
// registers the string if it does not exist yet
|
386 |
$to_register = array( 'context' => $context, 'name' => $name, 'string' => $string, 'multiline' => false, 'icl' => true );
|
390 |
}
|
391 |
}
|
392 |
|
393 |
+
/**
|
394 |
* removes a string from the registered strings list
|
395 |
*
|
396 |
* @since 1.0.2
|
397 |
*
|
398 |
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
399 |
+
* @param string $name a unique name for the string
|
400 |
*/
|
401 |
public function unregister_string( $context, $name ) {
|
402 |
foreach ( self::$strings as $key => $string ) {
|
407 |
}
|
408 |
}
|
409 |
|
410 |
+
/**
|
411 |
* adds strings registered by icl_register_string to those registered by pll_register_string
|
412 |
*
|
413 |
* @since 1.0.2
|
modules/wpml/wpml-config.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* reads and interprets the file wpml-config.xml
|
5 |
* see http://wpml.org/documentation/support/language-configuration-files/
|
6 |
* the language switcher configuration is not interpreted
|
@@ -14,7 +14,7 @@ class PLL_WPML_Config {
|
|
14 |
protected $values, $index, $strings;
|
15 |
public $tags;
|
16 |
|
17 |
-
|
18 |
* constructor
|
19 |
*
|
20 |
* @since 1.0
|
@@ -23,7 +23,7 @@ class PLL_WPML_Config {
|
|
23 |
$this->init();
|
24 |
}
|
25 |
|
26 |
-
|
27 |
* access to the single instance of the class
|
28 |
*
|
29 |
* @since 1.7
|
@@ -37,7 +37,7 @@ class PLL_WPML_Config {
|
|
37 |
return self::$instance;
|
38 |
}
|
39 |
|
40 |
-
|
41 |
* parses the wpml-config.xml file
|
42 |
*
|
43 |
* @since 1.0
|
@@ -76,7 +76,7 @@ class PLL_WPML_Config {
|
|
76 |
}
|
77 |
}
|
78 |
|
79 |
-
|
80 |
* recursively parses the wpml-config.xml file
|
81 |
*
|
82 |
* @since 1.0
|
@@ -137,7 +137,7 @@ class PLL_WPML_Config {
|
|
137 |
return $found;
|
138 |
}
|
139 |
|
140 |
-
|
141 |
* finds the wpml-config.xml files to parse and setup filters
|
142 |
*
|
143 |
* @since 1.0
|
@@ -212,7 +212,7 @@ class PLL_WPML_Config {
|
|
212 |
}
|
213 |
}
|
214 |
|
215 |
-
|
216 |
* arranges strings in a cleaner way
|
217 |
*
|
218 |
* @since 1.0
|
@@ -233,7 +233,7 @@ class PLL_WPML_Config {
|
|
233 |
return $strings;
|
234 |
}
|
235 |
|
236 |
-
|
237 |
* recursively registers strings for a serialized option
|
238 |
*
|
239 |
* @since 1.0
|
@@ -257,7 +257,7 @@ class PLL_WPML_Config {
|
|
257 |
}
|
258 |
}
|
259 |
|
260 |
-
|
261 |
* adds custom fields to the list of metas to copy when creating a new translation
|
262 |
*
|
263 |
* @since 1.0
|
@@ -284,7 +284,7 @@ class PLL_WPML_Config {
|
|
284 |
return $metas;
|
285 |
}
|
286 |
|
287 |
-
|
288 |
* language and translation management for custom post types
|
289 |
*
|
290 |
* @since 1.0
|
@@ -307,7 +307,7 @@ class PLL_WPML_Config {
|
|
307 |
return $types;
|
308 |
}
|
309 |
|
310 |
-
|
311 |
* language and translation management for custom taxonomies
|
312 |
*
|
313 |
* @since 1.0
|
@@ -331,7 +331,7 @@ class PLL_WPML_Config {
|
|
331 |
return $taxonomies;
|
332 |
}
|
333 |
|
334 |
-
|
335 |
* translates the strings for an option
|
336 |
*
|
337 |
* @since 1.0
|
@@ -351,7 +351,7 @@ class PLL_WPML_Config {
|
|
351 |
return pll__( $value );
|
352 |
}
|
353 |
|
354 |
-
|
355 |
* recursively translates strings for a serialized option
|
356 |
*
|
357 |
* @since 1.0
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* reads and interprets the file wpml-config.xml
|
5 |
* see http://wpml.org/documentation/support/language-configuration-files/
|
6 |
* the language switcher configuration is not interpreted
|
14 |
protected $values, $index, $strings;
|
15 |
public $tags;
|
16 |
|
17 |
+
/**
|
18 |
* constructor
|
19 |
*
|
20 |
* @since 1.0
|
23 |
$this->init();
|
24 |
}
|
25 |
|
26 |
+
/**
|
27 |
* access to the single instance of the class
|
28 |
*
|
29 |
* @since 1.7
|
37 |
return self::$instance;
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
* parses the wpml-config.xml file
|
42 |
*
|
43 |
* @since 1.0
|
76 |
}
|
77 |
}
|
78 |
|
79 |
+
/**
|
80 |
* recursively parses the wpml-config.xml file
|
81 |
*
|
82 |
* @since 1.0
|
137 |
return $found;
|
138 |
}
|
139 |
|
140 |
+
/**
|
141 |
* finds the wpml-config.xml files to parse and setup filters
|
142 |
*
|
143 |
* @since 1.0
|
212 |
}
|
213 |
}
|
214 |
|
215 |
+
/**
|
216 |
* arranges strings in a cleaner way
|
217 |
*
|
218 |
* @since 1.0
|
233 |
return $strings;
|
234 |
}
|
235 |
|
236 |
+
/**
|
237 |
* recursively registers strings for a serialized option
|
238 |
*
|
239 |
* @since 1.0
|
257 |
}
|
258 |
}
|
259 |
|
260 |
+
/**
|
261 |
* adds custom fields to the list of metas to copy when creating a new translation
|
262 |
*
|
263 |
* @since 1.0
|
284 |
return $metas;
|
285 |
}
|
286 |
|
287 |
+
/**
|
288 |
* language and translation management for custom post types
|
289 |
*
|
290 |
* @since 1.0
|
307 |
return $types;
|
308 |
}
|
309 |
|
310 |
+
/**
|
311 |
* language and translation management for custom taxonomies
|
312 |
*
|
313 |
* @since 1.0
|
331 |
return $taxonomies;
|
332 |
}
|
333 |
|
334 |
+
/**
|
335 |
* translates the strings for an option
|
336 |
*
|
337 |
* @since 1.0
|
351 |
return pll__( $value );
|
352 |
}
|
353 |
|
354 |
+
/**
|
355 |
* recursively translates strings for a serialized option
|
356 |
*
|
357 |
* @since 1.0
|
polylang.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
/*
|
4 |
Plugin Name: Polylang
|
5 |
-
Plugin URI:
|
6 |
-
Version: 1.
|
7 |
Author: Frédéric Demarle
|
8 |
-
Author uri:
|
9 |
Description: Adds multilingual capability to WordPress
|
10 |
Text Domain: polylang
|
11 |
Domain Path: /languages
|
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
35 |
exit; // don't access directly
|
36 |
};
|
37 |
|
38 |
-
define( 'POLYLANG_VERSION', '1.
|
39 |
define( 'PLL_MIN_WP_VERSION', '4.0' );
|
40 |
|
41 |
define( 'POLYLANG_FILE', __FILE__ ); // this file
|
2 |
|
3 |
/*
|
4 |
Plugin Name: Polylang
|
5 |
+
Plugin URI: https://polylang.pro
|
6 |
+
Version: 1.9
|
7 |
Author: Frédéric Demarle
|
8 |
+
Author uri: https://polylang.pro
|
9 |
Description: Adds multilingual capability to WordPress
|
10 |
Text Domain: polylang
|
11 |
Domain Path: /languages
|
35 |
exit; // don't access directly
|
36 |
};
|
37 |
|
38 |
+
define( 'POLYLANG_VERSION', '1.9' );
|
39 |
define( 'PLL_MIN_WP_VERSION', '4.0' );
|
40 |
|
41 |
define( 'POLYLANG_FILE', __FILE__ ); // this file
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Polylang ===
|
2 |
Contributors: Chouby
|
3 |
-
Donate link: https://
|
4 |
Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.5
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Making WordPress multilingual
|
@@ -23,10 +23,12 @@ Polylang allows you to create a bilingual or multilingual WordPress site. You wr
|
|
23 |
* A customizable language switcher is provided as a widget or in the nav menu
|
24 |
* The admin interface is of course multilingual too and each user can set the WordPress admin language in its profile
|
25 |
|
26 |
-
|
27 |
|
28 |
If you wish to migrate from WPML, you can use the plugin [WPML to Polylang](https://wordpress.org/plugins/wpml-to-polylang/)
|
29 |
|
|
|
|
|
30 |
= Credits =
|
31 |
|
32 |
Thanks a lot to all translators who [help translating Polylang](https://translate.wordpress.org/projects/wp-plugins/polylang).
|
@@ -36,31 +38,31 @@ Wherever third party code has been used, credit has been given in the code’s c
|
|
36 |
|
37 |
= Do you like Polylang? =
|
38 |
|
39 |
-
Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-reviews/polylang#postform).
|
40 |
|
41 |
== Installation ==
|
42 |
|
43 |
1. Make sure you are using WordPress 4.0 or later and that your server is running PHP 5.2.4 or later (same requirement as WordPress itself)
|
44 |
-
1. If you tried other multilingual plugins, deactivate them before activating Polylang, otherwise, you may get unexpected results
|
45 |
1. Install and activate the plugin as usual from the 'Plugins' menu in WordPress.
|
46 |
1. Go to the languages settings page and create the languages you need
|
47 |
1. Add the 'language switcher' widget to let your visitors switch the language.
|
48 |
-
1. Take care that your theme must come with the corresponding .mo files (Polylang automatically downloads them when they are available for themes and plugins in this repository). If your theme is not internationalized yet, please refer to the [
|
49 |
|
50 |
== Frequently Asked Questions ==
|
51 |
|
52 |
= Where to find help ? =
|
53 |
|
54 |
-
* First time users should read [Polylang - Getting started](
|
55 |
-
* Read the [documentation](
|
56 |
-
* Search the [support forum](https://wordpress.org/search/). You will
|
57 |
-
* Read the sticky posts in the [support forum](http://wordpress.org/support/plugin/polylang).
|
58 |
-
* If you still have a problem, open a new thread in the [support forum](http://wordpress.org/support/plugin/polylang).
|
59 |
-
*
|
60 |
|
61 |
-
=
|
62 |
|
63 |
-
|
64 |
|
65 |
== Screenshots ==
|
66 |
|
@@ -71,88 +73,21 @@ See http://polylang.wordpress.com/documentation/contribute/
|
|
71 |
|
72 |
== Changelog ==
|
73 |
|
74 |
-
= 1.
|
75 |
-
|
76 |
-
*
|
77 |
-
*
|
78 |
-
*
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
*
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
*
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
* Add support for the 'wpml_get_default_language()' function from the WPML API
|
91 |
-
* Stop blocking saving settings when errors are detected (invalid domains)
|
92 |
-
* Use publicly_queryable => true instead of public => true for the language taxonomy (WP 4.5+)
|
93 |
-
* fix: PHP notice when pll_default_language() is called before a language is created
|
94 |
-
* fix: PHP notice undefined property PLL_Language::$page_on_front
|
95 |
-
* fix: canonical redirection of static front page when combining plain permalinks + default language hidden in url
|
96 |
-
* fix: YARPP compatibility broken in v1.8
|
97 |
-
* fix: Remove the delete link for translations of the default category (introduced back by WP 4.3)
|
98 |
-
* fix: settings not displayed with WP 4.1 or older
|
99 |
-
|
100 |
-
= 1.8.1 (2016-01-31) =
|
101 |
-
|
102 |
-
* Update the list of Facebook locales used for Opengraph support with Yoast SEO and Jetpack
|
103 |
-
* fix: secondary query with translated post type and untranslated taxonomy mixes languages (introduced in 1.8)
|
104 |
-
* fix: issue with paged static front page when hiding the default language in url
|
105 |
-
* fix: potential issue with cache after synchronizations
|
106 |
-
* fix: trailing slash added to canonical home url outputed by Yoast SEO when using default permalinks
|
107 |
-
|
108 |
-
= 1.8 (2016-01-19) =
|
109 |
-
|
110 |
-
* Minimum WordPress version is now 4.0
|
111 |
-
* Add ary, bn_BD, en_ZA, es_AR, fr_CA and fr_BE to the predefined languages list
|
112 |
-
* Adopt WordPress coding standards
|
113 |
-
* New structure for translated posts and terms (=> several methods of PLL_Model are deprecated).
|
114 |
-
* Revamp the management of the static front page and page for posts
|
115 |
-
* Improve performance for navigation menus with a lot of pages
|
116 |
-
* The Polylang and WPML API are now loaded when 'plugins_loaded' is fired (on frontend only if at least one language has been defined)
|
117 |
-
* Add 'pll_get_post_translations()' and 'pll_get_term_translations()' to the API
|
118 |
-
* Add filter 'pll_cookie_expiration' to change the cookie expiration time
|
119 |
-
* Add support for 'wpml_get_language_information()' function from the WPML API
|
120 |
-
* The default language is now managed directly from the languages list table
|
121 |
-
* Various accessibility improvements
|
122 |
-
* It is now possible to choose the languages flags from the available list (custom flags on frontend still work as previously)
|
123 |
-
* Revamp the settings page (now a list table with inline configuration)
|
124 |
-
* Add an option to remove all data when uninstalling the plugin
|
125 |
-
* Add test of subdomains and domains accessibility
|
126 |
-
* Add post state for translations of the front page and posts page
|
127 |
-
* Add better support of the customizer menus introduced in WP 4.3
|
128 |
-
* Media taxonomies (created by 3rd party plugins) are now filtered by language when editing a media
|
129 |
-
* Synchronization of taxonomies (created by 3rd party plugins) and meta are now enabled for media
|
130 |
-
* The 'hreflang' tag now refers to the locale instead of the 2-letters language code
|
131 |
-
* Workaround for WordPress locales not being W3C valid (see #33511)
|
132 |
-
* Workaround a bug in Nextgen Gallery causing redirect on album
|
133 |
-
* Add compatibility with Duplicate Post plugin to avoid duplicated post keeping the link to translations
|
134 |
-
* Add compatibility with Jetpack Related Posts
|
135 |
-
* fix: incorrect rewrite rules after changing how the language is set (need to flush rewrite rules after this)
|
136 |
-
* fix: password protected pages don't work on multiple domains
|
137 |
-
* fix: ensure that the page parent is in the correct language when using bulk edit
|
138 |
-
* fix: is_tax set on category and post tags archives when it should not
|
139 |
-
* fix: automatically added new top-level pages to menus are not filtered by language
|
140 |
-
* fix: nav menus locations are messed when changing the default language
|
141 |
-
* fix: error 404 for untranslated taxonomies pages
|
142 |
-
* fix: single posts and pages links do not include the language code when using the default permalinks and forcing the language code in url
|
143 |
-
* fix: missing trailing slash on home url when using default permalinks or a static front page
|
144 |
-
* fix: sticky visibility is copied to new translation only if the synchronization is activated
|
145 |
-
* fix: remove "» Languages » [language name]" from the feed title
|
146 |
-
* fix: spaces are not honored when searching strings translations
|
147 |
-
* fix: default language not set and terms translations not correctly imported when using WordPress Importer
|
148 |
-
* fix: the browser language detection does not differentiate 'en_US' and 'en_GB'
|
149 |
-
* fix: non alphanumeric characters query vars values lead to an infinite redirection loop on static front pages
|
150 |
-
* fix: user profile not saved for a language when the language code contains a "-"
|
151 |
-
* fix: non translated posts page always link to the static front page even when they should not
|
152 |
-
* fix: remove hreflang="x-default" when using one domain per language
|
153 |
-
* fix: deprecated function notice in WP 4.5 alpha
|
154 |
-
* fix: wrong url for attachments when media are translated and using subdomains
|
155 |
-
* fix: wrong url for unattached attachments when using subdirectories (since WP 4.4)
|
156 |
-
* fix: wrong url scheme for custom flags
|
157 |
|
158 |
See changelog.txt for older changelog
|
1 |
=== Polylang ===
|
2 |
Contributors: Chouby
|
3 |
+
Donate link: https://polylang.pro
|
4 |
Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.5
|
7 |
+
Stable tag: 1.9
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Making WordPress multilingual
|
23 |
* A customizable language switcher is provided as a widget or in the nav menu
|
24 |
* The admin interface is of course multilingual too and each user can set the WordPress admin language in its profile
|
25 |
|
26 |
+
> The author does not provide support on the wordpress.org forum. Support and extra features are available to [Polylang Pro](https://polylang.pro) users.
|
27 |
|
28 |
If you wish to migrate from WPML, you can use the plugin [WPML to Polylang](https://wordpress.org/plugins/wpml-to-polylang/)
|
29 |
|
30 |
+
If you wish to use a professional or automatic translation service, you can install [Lingotek Translation](https://wordpress.org/plugins/lingotek-translation/), as an addon of Polylang. Lingotek offers a complete translation management system which provides services such as translation memory or semi-automated translation processes (e.g. machine translation > human translation > legal review).
|
31 |
+
|
32 |
= Credits =
|
33 |
|
34 |
Thanks a lot to all translators who [help translating Polylang](https://translate.wordpress.org/projects/wp-plugins/polylang).
|
38 |
|
39 |
= Do you like Polylang? =
|
40 |
|
41 |
+
Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-reviews/polylang#postform).
|
42 |
|
43 |
== Installation ==
|
44 |
|
45 |
1. Make sure you are using WordPress 4.0 or later and that your server is running PHP 5.2.4 or later (same requirement as WordPress itself)
|
46 |
+
1. If you tried other multilingual plugins, deactivate them before activating Polylang, otherwise, you may get unexpected results!
|
47 |
1. Install and activate the plugin as usual from the 'Plugins' menu in WordPress.
|
48 |
1. Go to the languages settings page and create the languages you need
|
49 |
1. Add the 'language switcher' widget to let your visitors switch the language.
|
50 |
+
1. Take care that your theme must come with the corresponding .mo files (Polylang automatically downloads them when they are available for themes and plugins in this repository). If your theme is not internationalized yet, please refer to the [Theme Handbook](https://developer.wordpress.org/themes/functionality/internationalization/) or ask the theme author to internationalize it.
|
51 |
|
52 |
== Frequently Asked Questions ==
|
53 |
|
54 |
= Where to find help ? =
|
55 |
|
56 |
+
* First time users should read [Polylang - Getting started](https://polylang.pro/doc-category/getting-started/), which explains the basics with a lot of screenshots.
|
57 |
+
* Read the [documentation](https://polylang.pro/doc/). It includes a [FAQ](https://polylang.pro/doc-category/faq/) and the [documentation for developers](https://polylang.pro/doc-category/developers/).
|
58 |
+
* Search the [community support forum](https://wordpress.org/search/). You will probably find your answer here.
|
59 |
+
* Read the sticky posts in the [community support forum](http://wordpress.org/support/plugin/polylang).
|
60 |
+
* If you still have a problem, open a new thread in the [community support forum](http://wordpress.org/support/plugin/polylang).
|
61 |
+
* [Polylang Pro](https://polylang.pro) users have access to our helpdesk.
|
62 |
|
63 |
+
= Do you need translation services? =
|
64 |
|
65 |
+
* If you want to use professional or automatic translation services, install and activate the [Lingotek Translation](https://wordpress.org/plugins/lingotek-translation/) plugin.
|
66 |
|
67 |
== Screenshots ==
|
68 |
|
73 |
|
74 |
== Changelog ==
|
75 |
|
76 |
+
= 1.9 ( 2016-04-27 ) =
|
77 |
+
|
78 |
+
* Pro: add the possibility to translate custom post types slugs, taxonomies slugs and more
|
79 |
+
* Pro: add the possibility to share the same post or term slug accross languages
|
80 |
+
* Pro: add the possibility to duplicate the content when creating a new translation
|
81 |
+
* Pro: add the possibility to create all translations at once when uploading a media
|
82 |
+
* Pro: add the possibility to disable a language
|
83 |
+
* Add license and update management
|
84 |
+
* Add inline docs for all filters and actions
|
85 |
+
* When possible, the rel alternate hreflang now display only the language code (without the country code)
|
86 |
+
* When combined with flags in the language switcher, wrap the language name inside <span> tags
|
87 |
+
* Add customizer selective refresh support for the language switcher widget ( needs WP 4.5+ )
|
88 |
+
* Fix dynamic options of the language switcher widget not working in the customizer
|
89 |
+
* Fix possible error 404 on page shortlink when using subdomains or multiple domains
|
90 |
+
* Fix get_adjacent_post() and wp_get_archives() for untranslated post types ( needs WP 4.4+ )
|
91 |
+
* Fix language homepage urls not present in Yoast SEO sitemap (when the homepages display posts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
See changelog.txt for older changelog
|
settings/flags.php
CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
4 |
exit; // don't access directly
|
5 |
};
|
6 |
|
7 |
-
|
8 |
* The list of flags
|
9 |
*
|
10 |
* for each flag:
|
@@ -262,4 +262,11 @@ $flags = array(
|
|
262 |
'zw' => __( 'Zimbabwe', 'polylang' ),
|
263 |
);
|
264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
$flags = apply_filters( 'pll_predefined_flags', $flags );
|
4 |
exit; // don't access directly
|
5 |
};
|
6 |
|
7 |
+
/**
|
8 |
* The list of flags
|
9 |
*
|
10 |
* for each flag:
|
262 |
'zw' => __( 'Zimbabwe', 'polylang' ),
|
263 |
);
|
264 |
|
265 |
+
/*
|
266 |
+
* Filter the list of predefined flags
|
267 |
+
*
|
268 |
+
* @since 1.8
|
269 |
+
*
|
270 |
+
* @param array $flags
|
271 |
+
*/
|
272 |
$flags = apply_filters( 'pll_predefined_flags', $flags );
|
settings/languages.php
CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
4 |
exit; // don't access directly
|
5 |
};
|
6 |
|
7 |
-
|
8 |
* The list of predefined languages
|
9 |
*
|
10 |
* for each language:
|
@@ -113,4 +113,11 @@ $languages = array(
|
|
113 |
'zh_TW' => array( 'zh', 'zh_TW', '中文 (台灣)', 'ltr', 'tw' ),
|
114 |
);
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
$languages = apply_filters( 'pll_predefined_languages', $languages );
|
4 |
exit; // don't access directly
|
5 |
};
|
6 |
|
7 |
+
/**
|
8 |
* The list of predefined languages
|
9 |
*
|
10 |
* for each language:
|
113 |
'zh_TW' => array( 'zh', 'zh_TW', '中文 (台灣)', 'ltr', 'tw' ),
|
114 |
);
|
115 |
|
116 |
+
/*
|
117 |
+
* Filter the list of predefined languages
|
118 |
+
*
|
119 |
+
* @since 1.7.10
|
120 |
+
*
|
121 |
+
* @param array $languages
|
122 |
+
*/
|
123 |
$languages = apply_filters( 'pll_predefined_languages', $languages );
|
settings/settings-browser.php
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* Settings class for browser language preference detection
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_Browser extends PLL_Settings_Module {
|
9 |
-
|
|
|
10 |
* constructor
|
11 |
*
|
12 |
* @since 1.8
|
@@ -24,7 +25,7 @@ class PLL_Settings_Browser extends PLL_Settings_Module {
|
|
24 |
add_action( 'admin_print_footer_scripts', array( &$this, 'print_js' ) );
|
25 |
}
|
26 |
|
27 |
-
|
28 |
* tells if the module is active
|
29 |
*
|
30 |
* @since 1.8
|
@@ -35,7 +36,7 @@ class PLL_Settings_Browser extends PLL_Settings_Module {
|
|
35 |
return 3 > $this->options['force_lang'] ? parent::is_active() : false;
|
36 |
}
|
37 |
|
38 |
-
|
39 |
* displays the javascript to handle dynamically the change in url modifications
|
40 |
* as the preferred browser language is not used when the language is set from different domains
|
41 |
*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* Settings class for browser language preference detection
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_Browser extends PLL_Settings_Module {
|
9 |
+
|
10 |
+
/**
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.8
|
25 |
add_action( 'admin_print_footer_scripts', array( &$this, 'print_js' ) );
|
26 |
}
|
27 |
|
28 |
+
/**
|
29 |
* tells if the module is active
|
30 |
*
|
31 |
* @since 1.8
|
36 |
return 3 > $this->options['force_lang'] ? parent::is_active() : false;
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
* displays the javascript to handle dynamically the change in url modifications
|
41 |
* as the preferred browser language is not used when the language is set from different domains
|
42 |
*
|
settings/settings-cpt.php
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* Settings class for custom post types and taxonomies language and translation management
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_CPT extends PLL_Settings_Module {
|
9 |
-
|
|
|
10 |
* constructor
|
11 |
*
|
12 |
* @since 1.8
|
@@ -23,14 +24,16 @@ class PLL_Settings_CPT extends PLL_Settings_Module {
|
|
23 |
// FIXME should be OK when the modules will be loaded from the settings page
|
24 |
$post_types = get_post_types( array( 'public' => true, '_builtin' => false ) );
|
25 |
$post_types = array_diff( $post_types, get_post_types( array( '_pll' => true ) ) );
|
|
|
26 |
$this->post_types = array_unique( apply_filters( 'pll_get_post_types', $post_types, true ) );
|
27 |
|
28 |
$taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) );
|
29 |
$taxonomies = array_diff( $taxonomies, get_taxonomies( array( '_pll' => true ) ) );
|
|
|
30 |
$this->taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', $taxonomies , true ) );
|
31 |
}
|
32 |
|
33 |
-
|
34 |
* tells if the module is active
|
35 |
*
|
36 |
* @since 1.8
|
@@ -41,7 +44,7 @@ class PLL_Settings_CPT extends PLL_Settings_Module {
|
|
41 |
return ! empty( $this->post_types ) || ! empty( $this->taxonomies );
|
42 |
}
|
43 |
|
44 |
-
|
45 |
* displays the settings form
|
46 |
*
|
47 |
* @since 1.8
|
@@ -80,7 +83,7 @@ class PLL_Settings_CPT extends PLL_Settings_Module {
|
|
80 |
}
|
81 |
}
|
82 |
|
83 |
-
|
84 |
* sanitizes the settings before saving
|
85 |
*
|
86 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* Settings class for custom post types and taxonomies language and translation management
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_CPT extends PLL_Settings_Module {
|
9 |
+
|
10 |
+
/**
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.8
|
24 |
// FIXME should be OK when the modules will be loaded from the settings page
|
25 |
$post_types = get_post_types( array( 'public' => true, '_builtin' => false ) );
|
26 |
$post_types = array_diff( $post_types, get_post_types( array( '_pll' => true ) ) );
|
27 |
+
/** This filter is documented in include/model.php */
|
28 |
$this->post_types = array_unique( apply_filters( 'pll_get_post_types', $post_types, true ) );
|
29 |
|
30 |
$taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) );
|
31 |
$taxonomies = array_diff( $taxonomies, get_taxonomies( array( '_pll' => true ) ) );
|
32 |
+
/** This filter is documented in include/model.php */
|
33 |
$this->taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', $taxonomies , true ) );
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
* tells if the module is active
|
38 |
*
|
39 |
* @since 1.8
|
44 |
return ! empty( $this->post_types ) || ! empty( $this->taxonomies );
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
* displays the settings form
|
49 |
*
|
50 |
* @since 1.8
|
83 |
}
|
84 |
}
|
85 |
|
86 |
+
/**
|
87 |
* sanitizes the settings before saving
|
88 |
*
|
89 |
* @since 1.8
|
settings/settings-licenses.php
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Settings class for licenses
|
5 |
+
*
|
6 |
+
* @since 1.9
|
7 |
+
*/
|
8 |
+
class PLL_Settings_Licenses extends PLL_Settings_Module {
|
9 |
+
protected $items;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* constructor
|
13 |
+
*
|
14 |
+
* @since 1.9
|
15 |
+
*
|
16 |
+
* @param object $polylang polylang object
|
17 |
+
*/
|
18 |
+
public function __construct( &$polylang ) {
|
19 |
+
parent::__construct( $polylang, array(
|
20 |
+
'module' => 'licenses',
|
21 |
+
'title' => __( 'License keys', 'polylang' ),
|
22 |
+
'description' => __( 'Manage licenses for Polylang Pro or addons.', 'polylang' ),
|
23 |
+
) );
|
24 |
+
|
25 |
+
$this->buttons['cancel'] = sprintf( '<button type="button" class="button button-secondary cancel">%s</button>', __( 'Close' ) );
|
26 |
+
|
27 |
+
$this->items = apply_filters( 'pll_settings_licenses', array() );
|
28 |
+
|
29 |
+
add_action( 'wp_ajax_pll_deactivate_license', array( &$this, 'deactivate_license' ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* tells if the module is active
|
34 |
+
*
|
35 |
+
* @since 1.9
|
36 |
+
*
|
37 |
+
* @return bool
|
38 |
+
*/
|
39 |
+
public function is_active() {
|
40 |
+
return ! empty( $this->items );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* displays the settings form
|
45 |
+
*
|
46 |
+
* @since 1.9
|
47 |
+
*/
|
48 |
+
protected function form() {
|
49 |
+
if ( ! empty( $this->items ) ) { ?>
|
50 |
+
<table id="pll-licenses-table" class="form-table"><?php
|
51 |
+
foreach ( $this->items as $item ) {
|
52 |
+
echo $this->get_row( $item );
|
53 |
+
} ?>
|
54 |
+
</table><?php
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* get the html for a row (one per license key) for display
|
60 |
+
*
|
61 |
+
* @since 1.9
|
62 |
+
*
|
63 |
+
* @param array $item licence id, name and key
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
protected function get_row( $item ) {
|
67 |
+
if ( ! empty( $item->license_data ) ) {
|
68 |
+
$license = $item->license_data;
|
69 |
+
}
|
70 |
+
|
71 |
+
$class = 'license-null';
|
72 |
+
|
73 |
+
$out = sprintf(
|
74 |
+
'<td><label for="pll-licenses[%1$s]">%2$s</label></td>' .
|
75 |
+
'<td><input name="licenses[%1$s]" id="pll-licenses[%1$s]" type="text" value="%3$s" class="regular-text code" />',
|
76 |
+
esc_attr( $item->id ), esc_attr( $item->name ), esc_html( $item->license_key )
|
77 |
+
);
|
78 |
+
|
79 |
+
if ( ! empty( $license ) && is_object( $license ) ) {
|
80 |
+
$now = current_time( 'timestamp' );
|
81 |
+
$expiration = strtotime( $license->expires, $now );
|
82 |
+
|
83 |
+
// special case: the license expired after the last check
|
84 |
+
if ( $license->success && $expiration < $now ) {
|
85 |
+
$license->success = false;
|
86 |
+
$license->error = 'expired';
|
87 |
+
}
|
88 |
+
|
89 |
+
if ( false === $license->success ) {
|
90 |
+
$class = 'notice-error notice-alt';
|
91 |
+
|
92 |
+
switch ( $license->error ) {
|
93 |
+
case 'expired' :
|
94 |
+
$message = sprintf(
|
95 |
+
/* translators: %1$s is a date, %2$s and %3$s are html tags */
|
96 |
+
__( 'Your license key expired on %1$s. Please %2$srenew your license key%3$s.', 'polylang' ),
|
97 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
|
98 |
+
sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/checkout/?edd_license_key=' . $item->license_key ),
|
99 |
+
'</a>'
|
100 |
+
);
|
101 |
+
break;
|
102 |
+
|
103 |
+
case 'missing' :
|
104 |
+
$message = sprintf(
|
105 |
+
/* translators: %s are html tags */
|
106 |
+
__( 'Invalid license. Please %svisit your account page%s and verify it.', 'polylang' ),
|
107 |
+
sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ),
|
108 |
+
'</a>'
|
109 |
+
);
|
110 |
+
break;
|
111 |
+
|
112 |
+
case 'invalid' :
|
113 |
+
case 'site_inactive' :
|
114 |
+
$message = sprintf(
|
115 |
+
/* translators: %1$s is a product name, %2$s and %3$s are html tags */
|
116 |
+
__( 'Your %1$s license key is not active for this URL. Please %2$svisit your account page%3$s to manage your license key URLs.', 'polylang' ),
|
117 |
+
$item->name,
|
118 |
+
sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ),
|
119 |
+
'</a>'
|
120 |
+
);
|
121 |
+
break;
|
122 |
+
|
123 |
+
case 'item_name_mismatch' :
|
124 |
+
/* translators: %s is a product name */
|
125 |
+
$message = sprintf( __( 'This is not a %s license key.', 'polylang' ), $item->name );
|
126 |
+
break;
|
127 |
+
|
128 |
+
case 'no_activations_left':
|
129 |
+
/* translators: %s are html tags */
|
130 |
+
$message = sprintf(
|
131 |
+
__( 'Your license key has reached its activation limit. %sView possible upgrades%s now.', 'polylang' ),
|
132 |
+
sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ),
|
133 |
+
'</a>'
|
134 |
+
);
|
135 |
+
break;
|
136 |
+
}
|
137 |
+
} else {
|
138 |
+
$class = 'license-valid';
|
139 |
+
|
140 |
+
$out .= sprintf( '<button id="deactivate_%s" type="button" class="button button-secondary pll-deactivate-license">%s</button>', $item->id, __( 'Deactivate', 'polylang' ) );
|
141 |
+
|
142 |
+
if ( 'lifetime' === $license->expires ) {
|
143 |
+
$message = __( 'The license key never expires.', 'polylang' );
|
144 |
+
} elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
145 |
+
$class = 'notice-warning notice-alt';
|
146 |
+
$message = sprintf(
|
147 |
+
/* translators: %1$s is a date, %2$s and %3$s are html tags */
|
148 |
+
__( 'Your license key expires soon! It expires on %1$s. %2$sRenew your license key%3$s.', 'polylang' ),
|
149 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, $now ) ),
|
150 |
+
sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/checkout/?edd_license_key=' . $item->license_key ),
|
151 |
+
'</a>'
|
152 |
+
);
|
153 |
+
} else {
|
154 |
+
$message = sprintf(
|
155 |
+
/* translators: %s is a date */
|
156 |
+
__( 'Your license key expires on %s.', 'polylang' ),
|
157 |
+
date_i18n( get_option( 'date_format' ), strtotime( $license->expires, $now ) )
|
158 |
+
);
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
if ( ! empty( $message ) ) {
|
164 |
+
$out .= '<p>' . $message . '</p>';
|
165 |
+
}
|
166 |
+
|
167 |
+
return sprintf( '<tr id="pll-license-%s" class="%s">%s</tr>', $item->id, $class, $out );
|
168 |
+
}
|
169 |
+
|
170 |
+
/*
|
171 |
+
* ajax method to save the license keys and activate the licenses at the same time
|
172 |
+
* overrides parent's method
|
173 |
+
*
|
174 |
+
* @since 1.9
|
175 |
+
*/
|
176 |
+
public function save_options() {
|
177 |
+
check_ajax_referer( 'pll_options', '_pll_nonce' );
|
178 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
179 |
+
wp_die( -1 );
|
180 |
+
}
|
181 |
+
|
182 |
+
if ( $this->module === $_POST['module'] && ! empty( $_POST['licenses'] ) ) {
|
183 |
+
$x = new WP_Ajax_Response();
|
184 |
+
foreach ( $this->items as $item ) {
|
185 |
+
$updated_item = $item->activate_license( sanitize_text_field( $_POST['licenses'][ $item->id ] ) );
|
186 |
+
$x->Add( array( 'what' => 'license-update', 'data' => $item->id, 'supplemental' => array( 'html' => $this->get_row( $updated_item ) ) ) );
|
187 |
+
}
|
188 |
+
|
189 |
+
// updated message
|
190 |
+
add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' );
|
191 |
+
ob_start();
|
192 |
+
settings_errors();
|
193 |
+
$x->Add( array( 'what' => 'success', 'data' => ob_get_clean() ) );
|
194 |
+
$x->send();
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* ajax method to deactivate a license
|
200 |
+
*
|
201 |
+
* @since 1.9
|
202 |
+
*/
|
203 |
+
public function deactivate_license() {
|
204 |
+
check_ajax_referer( 'pll_options', '_pll_nonce' );
|
205 |
+
|
206 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
207 |
+
wp_die( -1 );
|
208 |
+
}
|
209 |
+
|
210 |
+
$id = sanitize_text_field( substr( $_POST['id'], 11 ) );
|
211 |
+
wp_send_json( array(
|
212 |
+
'id' => $id,
|
213 |
+
'html' => $this->get_row( $this->items[ $id ]->deactivate_license() ),
|
214 |
+
) );
|
215 |
+
}
|
216 |
+
}
|
settings/settings-media.php
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* Settings class for media language and translation management
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_Media extends PLL_Settings_Module {
|
9 |
-
|
|
|
10 |
* constructor
|
11 |
*
|
12 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* Settings class for media language and translation management
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_Media extends PLL_Settings_Module {
|
9 |
+
|
10 |
+
/**
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.8
|
settings/settings-module.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* base class for all settings
|
5 |
*
|
6 |
* @since 1.8
|
@@ -9,9 +9,9 @@ class PLL_Settings_Module {
|
|
9 |
public $active_option, $configure;
|
10 |
public $module, $title, $description;
|
11 |
public $options;
|
12 |
-
protected $action_links;
|
13 |
|
14 |
-
|
15 |
* constructor
|
16 |
*
|
17 |
* @since 1.8
|
@@ -62,11 +62,16 @@ class PLL_Settings_Module {
|
|
62 |
'deactivated' => __( 'Deactivated', 'polylang' ),
|
63 |
);
|
64 |
|
|
|
|
|
|
|
|
|
|
|
65 |
// ajax action to save options
|
66 |
add_action( 'wp_ajax_pll_save_options', array( &$this, 'save_options' ) );
|
67 |
}
|
68 |
|
69 |
-
|
70 |
* tells if the module is active
|
71 |
*
|
72 |
* @since 1.8
|
@@ -77,7 +82,7 @@ class PLL_Settings_Module {
|
|
77 |
return empty( $this->active_option ) || ! empty( $this->options[ $this->active_option ] );
|
78 |
}
|
79 |
|
80 |
-
|
81 |
* activates the module
|
82 |
*
|
83 |
* @since 1.8
|
@@ -89,7 +94,7 @@ class PLL_Settings_Module {
|
|
89 |
}
|
90 |
}
|
91 |
|
92 |
-
|
93 |
* deactivates the module
|
94 |
*
|
95 |
* @since 1.8
|
@@ -101,7 +106,7 @@ class PLL_Settings_Module {
|
|
101 |
}
|
102 |
}
|
103 |
|
104 |
-
|
105 |
* protected method to display a configuration form
|
106 |
*
|
107 |
* @since 1.8
|
@@ -111,7 +116,7 @@ class PLL_Settings_Module {
|
|
111 |
// child classes can provide a form
|
112 |
}
|
113 |
|
114 |
-
|
115 |
* public method returning the form if any
|
116 |
*
|
117 |
* @since 1.8
|
@@ -131,7 +136,7 @@ class PLL_Settings_Module {
|
|
131 |
return $form;
|
132 |
}
|
133 |
|
134 |
-
|
135 |
* allows child classes to validate their options before saving
|
136 |
*
|
137 |
* @since 1.8
|
@@ -143,7 +148,7 @@ class PLL_Settings_Module {
|
|
143 |
return array(); // it's responsibility of the child class to decide what is saved
|
144 |
}
|
145 |
|
146 |
-
|
147 |
* ajax method to save the options
|
148 |
*
|
149 |
* @since 1.8
|
@@ -155,10 +160,9 @@ class PLL_Settings_Module {
|
|
155 |
}
|
156 |
|
157 |
if ( $this->module == $_POST['module'] ) {
|
158 |
-
unset( $_POST['action'], $_POST['module'], $_POST['pll_ajax_backend'], $_POST['_pll_nonce'] );
|
159 |
-
|
160 |
// it's up to the child class to decide which options are saved, whether there are errors or not
|
161 |
-
$
|
|
|
162 |
$this->options = array_merge( $this->options, $options );
|
163 |
update_option( 'polylang', $this->options );
|
164 |
|
@@ -175,18 +179,18 @@ class PLL_Settings_Module {
|
|
175 |
// send update message
|
176 |
add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' );
|
177 |
settings_errors();
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
else {
|
182 |
// send error messages
|
183 |
settings_errors();
|
184 |
-
|
|
|
185 |
}
|
186 |
}
|
187 |
}
|
188 |
|
189 |
-
|
190 |
* get the row actions
|
191 |
*
|
192 |
* @since 1.8
|
@@ -209,7 +213,7 @@ class PLL_Settings_Module {
|
|
209 |
return $actions;
|
210 |
}
|
211 |
|
212 |
-
|
213 |
* get the actions links
|
214 |
*
|
215 |
* @since 1.8
|
@@ -219,4 +223,42 @@ class PLL_Settings_Module {
|
|
219 |
public function get_action_links() {
|
220 |
return array_intersect_key( $this->action_links, array_flip( $this->get_actions() ) );
|
221 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* base class for all settings
|
5 |
*
|
6 |
* @since 1.8
|
9 |
public $active_option, $configure;
|
10 |
public $module, $title, $description;
|
11 |
public $options;
|
12 |
+
protected $action_links, $buttons;
|
13 |
|
14 |
+
/**
|
15 |
* constructor
|
16 |
*
|
17 |
* @since 1.8
|
62 |
'deactivated' => __( 'Deactivated', 'polylang' ),
|
63 |
);
|
64 |
|
65 |
+
$this->buttons = array(
|
66 |
+
'cancel' => sprintf( '<button type="button" class="button button-secondary cancel">%s</button>', __( 'Cancel' ) ),
|
67 |
+
'save' => sprintf( '<button type="button" class="button button-primary save">%s</button>', __( 'Save Changes' ) ),
|
68 |
+
);
|
69 |
+
|
70 |
// ajax action to save options
|
71 |
add_action( 'wp_ajax_pll_save_options', array( &$this, 'save_options' ) );
|
72 |
}
|
73 |
|
74 |
+
/**
|
75 |
* tells if the module is active
|
76 |
*
|
77 |
* @since 1.8
|
82 |
return empty( $this->active_option ) || ! empty( $this->options[ $this->active_option ] );
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
* activates the module
|
87 |
*
|
88 |
* @since 1.8
|
94 |
}
|
95 |
}
|
96 |
|
97 |
+
/**
|
98 |
* deactivates the module
|
99 |
*
|
100 |
* @since 1.8
|
106 |
}
|
107 |
}
|
108 |
|
109 |
+
/**
|
110 |
* protected method to display a configuration form
|
111 |
*
|
112 |
* @since 1.8
|
116 |
// child classes can provide a form
|
117 |
}
|
118 |
|
119 |
+
/**
|
120 |
* public method returning the form if any
|
121 |
*
|
122 |
* @since 1.8
|
136 |
return $form;
|
137 |
}
|
138 |
|
139 |
+
/**
|
140 |
* allows child classes to validate their options before saving
|
141 |
*
|
142 |
* @since 1.8
|
148 |
return array(); // it's responsibility of the child class to decide what is saved
|
149 |
}
|
150 |
|
151 |
+
/**
|
152 |
* ajax method to save the options
|
153 |
*
|
154 |
* @since 1.8
|
160 |
}
|
161 |
|
162 |
if ( $this->module == $_POST['module'] ) {
|
|
|
|
|
163 |
// it's up to the child class to decide which options are saved, whether there are errors or not
|
164 |
+
$post = array_diff_key( $_POST, array_flip( array( 'action', 'module', 'pll_ajax_backend', '_pll_nonce' ) ) );
|
165 |
+
$options = $this->update( $post );
|
166 |
$this->options = array_merge( $this->options, $options );
|
167 |
update_option( 'polylang', $this->options );
|
168 |
|
179 |
// send update message
|
180 |
add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' );
|
181 |
settings_errors();
|
182 |
+
$x = new WP_Ajax_Response( array( 'what' => 'success', 'data' => ob_get_clean() ) );
|
183 |
+
$x->send();
|
184 |
+
} else {
|
|
|
185 |
// send error messages
|
186 |
settings_errors();
|
187 |
+
$x = new WP_Ajax_Response( array( 'what' => 'error', 'data' => ob_get_clean() ) );
|
188 |
+
$x->send();
|
189 |
}
|
190 |
}
|
191 |
}
|
192 |
|
193 |
+
/**
|
194 |
* get the row actions
|
195 |
*
|
196 |
* @since 1.8
|
213 |
return $actions;
|
214 |
}
|
215 |
|
216 |
+
/**
|
217 |
* get the actions links
|
218 |
*
|
219 |
* @since 1.8
|
223 |
public function get_action_links() {
|
224 |
return array_intersect_key( $this->action_links, array_flip( $this->get_actions() ) );
|
225 |
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* default upgrade message ( to pro version )
|
229 |
+
*
|
230 |
+
* @since 1.9
|
231 |
+
*
|
232 |
+
* @return string
|
233 |
+
*/
|
234 |
+
protected function default_upgrade_message() {
|
235 |
+
return sprintf(
|
236 |
+
'%s <a href="%s">%s</a>',
|
237 |
+
__( 'You need Polylang Pro to enable this feature.', 'polylang' ),
|
238 |
+
'https://polylang.pro',
|
239 |
+
__( 'Upgrade now.', 'polylang' )
|
240 |
+
);
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* allows child classes to display an upgrade message
|
245 |
+
*
|
246 |
+
* @since 1.9
|
247 |
+
*
|
248 |
+
* @return string
|
249 |
+
*/
|
250 |
+
public function get_upgrade_message() {
|
251 |
+
return '';
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* get the buttons
|
256 |
+
*
|
257 |
+
* @since 1.9
|
258 |
+
*
|
259 |
+
* @return array
|
260 |
+
*/
|
261 |
+
public function get_buttons() {
|
262 |
+
return $this->buttons;
|
263 |
+
}
|
264 |
}
|
settings/settings-tools.php
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
* Settings class for tools
|
4 |
*
|
5 |
* @since 1.8
|
6 |
*/
|
7 |
class PLL_Settings_Tools extends PLL_Settings_Module {
|
8 |
-
|
|
|
9 |
* constructor
|
10 |
*
|
11 |
* @since 1.8
|
@@ -20,7 +22,7 @@ class PLL_Settings_Tools extends PLL_Settings_Module {
|
|
20 |
) );
|
21 |
}
|
22 |
|
23 |
-
|
24 |
* displays the settings form
|
25 |
*
|
26 |
* @since 1.8
|
@@ -33,7 +35,7 @@ class PLL_Settings_Tools extends PLL_Settings_Module {
|
|
33 |
);
|
34 |
}
|
35 |
|
36 |
-
|
37 |
* sanitizes the settings before saving
|
38 |
*
|
39 |
* @since 1.8
|
1 |
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
* Settings class for tools
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_Tools extends PLL_Settings_Module {
|
9 |
+
|
10 |
+
/**
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.8
|
22 |
) );
|
23 |
}
|
24 |
|
25 |
+
/**
|
26 |
* displays the settings form
|
27 |
*
|
28 |
* @since 1.8
|
35 |
);
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
* sanitizes the settings before saving
|
40 |
*
|
41 |
* @since 1.8
|
settings/settings-url.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
* A class to manage URL modifications settings
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_Url extends PLL_Settings_Module {
|
9 |
|
10 |
-
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.8
|
@@ -26,7 +26,7 @@ class PLL_Settings_Url extends PLL_Settings_Module {
|
|
26 |
$this->page_on_front = &$polylang->static_pages->page_on_front;
|
27 |
}
|
28 |
|
29 |
-
|
30 |
* displays the fieldset to choose how the language is set
|
31 |
*
|
32 |
* @since 1.8
|
@@ -93,7 +93,7 @@ class PLL_Settings_Url extends PLL_Settings_Module {
|
|
93 |
</label><?php
|
94 |
}
|
95 |
|
96 |
-
|
97 |
* displays the fieldset to choose to hide /language/ in url
|
98 |
*
|
99 |
* @since 1.8
|
@@ -119,7 +119,7 @@ class PLL_Settings_Url extends PLL_Settings_Module {
|
|
119 |
<p class="description"><?php echo __( 'Example:', 'polylang' ) . ' <code>' . esc_html( home_url( 'language/en/' ) ) . '</code>';?></p><?php
|
120 |
}
|
121 |
|
122 |
-
|
123 |
* displays the fieldset to choose to redirect the home page to language page
|
124 |
*
|
125 |
* @since 1.8
|
@@ -145,7 +145,7 @@ class PLL_Settings_Url extends PLL_Settings_Module {
|
|
145 |
</p><?php
|
146 |
}
|
147 |
|
148 |
-
|
149 |
* displays the settings
|
150 |
*
|
151 |
* @since 1.8
|
@@ -176,7 +176,7 @@ class PLL_Settings_Url extends PLL_Settings_Module {
|
|
176 |
</div><?php
|
177 |
}
|
178 |
|
179 |
-
|
180 |
* sanitizes the settings before saving
|
181 |
*
|
182 |
* @since 1.8
|
@@ -219,7 +219,7 @@ class PLL_Settings_Url extends PLL_Settings_Module {
|
|
219 |
return $newoptions; // take care to return only validated options
|
220 |
}
|
221 |
|
222 |
-
|
223 |
* check if subdomains or domains are accessible
|
224 |
*
|
225 |
* @since 1.8
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
* A class to manage URL modifications settings
|
5 |
*
|
6 |
* @since 1.8
|
7 |
*/
|
8 |
class PLL_Settings_Url extends PLL_Settings_Module {
|
9 |
|
10 |
+
/**
|
11 |
* constructor
|
12 |
*
|
13 |
* @since 1.8
|
26 |
$this->page_on_front = &$polylang->static_pages->page_on_front;
|
27 |
}
|
28 |
|
29 |
+
/**
|
30 |
* displays the fieldset to choose how the language is set
|
31 |
*
|
32 |
* @since 1.8
|
93 |
</label><?php
|
94 |
}
|
95 |
|
96 |
+
/**
|
97 |
* displays the fieldset to choose to hide /language/ in url
|
98 |
*
|
99 |
* @since 1.8
|
119 |
<p class="description"><?php echo __( 'Example:', 'polylang' ) . ' <code>' . esc_html( home_url( 'language/en/' ) ) . '</code>';?></p><?php
|
120 |
}
|
121 |
|
122 |
+
/**
|
123 |
* displays the fieldset to choose to redirect the home page to language page
|
124 |
*
|
125 |
* @since 1.8
|
145 |
</p><?php
|
146 |
}
|
147 |
|
148 |
+
/**
|
149 |
* displays the settings
|
150 |
*
|
151 |
* @since 1.8
|
176 |
</div><?php
|
177 |
}
|
178 |
|
179 |
+
/**
|
180 |
* sanitizes the settings before saving
|
181 |
*
|
182 |
* @since 1.8
|
219 |
return $newoptions; // take care to return only validated options
|
220 |
}
|
221 |
|
222 |
+
/**
|
223 |
* check if subdomains or domains are accessible
|
224 |
*
|
225 |
* @since 1.8
|
settings/settings.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
*
|
5 |
* accessible in $polylang global object
|
6 |
*
|
7 |
* properties:
|
@@ -19,8 +19,8 @@
|
|
19 |
class PLL_Settings extends PLL_Admin_Base {
|
20 |
protected $active_tab, $modules;
|
21 |
|
22 |
-
|
23 |
-
*
|
24 |
*
|
25 |
* @since 1.2
|
26 |
*
|
@@ -43,12 +43,19 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
43 |
add_filter( 'set-screen-option', array( &$this, 'set_screen_option' ), 10, 3 );
|
44 |
}
|
45 |
|
46 |
-
|
47 |
-
*
|
48 |
*
|
49 |
* @since 1.8
|
50 |
*/
|
51 |
public function register_settings_modules() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
$modules = apply_filters( 'pll_settings_modules', array(
|
53 |
'PLL_Settings_Url',
|
54 |
'PLL_Settings_Browser',
|
@@ -56,7 +63,10 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
56 |
'PLL_Settings_CPT',
|
57 |
'PLL_Settings_Sync',
|
58 |
'PLL_Settings_WPML',
|
|
|
|
|
59 |
'PLL_Settings_Tools',
|
|
|
60 |
) );
|
61 |
|
62 |
foreach ( $modules as $key => $class ) {
|
@@ -65,8 +75,8 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
65 |
}
|
66 |
}
|
67 |
|
68 |
-
|
69 |
-
*
|
70 |
*
|
71 |
* @since 0.1
|
72 |
*/
|
@@ -74,7 +84,7 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
74 |
add_submenu_page( 'options-general.php', $title = __( 'Languages', 'polylang' ), $title, 'manage_options', 'mlang', array( $this, 'languages_page' ) );
|
75 |
}
|
76 |
|
77 |
-
|
78 |
* Loads the about metabox
|
79 |
*
|
80 |
* @since 0.8
|
@@ -83,8 +93,8 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
83 |
include( PLL_SETTINGS_INC.'/view-about.php' );
|
84 |
}
|
85 |
|
86 |
-
|
87 |
-
*
|
88 |
*
|
89 |
* @since 0.9.5
|
90 |
*/
|
@@ -121,14 +131,14 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
121 |
}
|
122 |
}
|
123 |
|
124 |
-
|
125 |
* Save the "Views/Uploads per page" option set by this user
|
126 |
*
|
127 |
* @since 0.9.5
|
128 |
*
|
129 |
-
* @param mixed
|
130 |
* @param string $option Name of the option being changed
|
131 |
-
* @param string $value
|
132 |
*
|
133 |
* @return string New value if this is our option, otherwise nothing
|
134 |
*/
|
@@ -136,92 +146,19 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
136 |
return 'pll_strings_per_page' === $option ? $value : $status;
|
137 |
}
|
138 |
|
139 |
-
|
140 |
-
*
|
141 |
-
* also manages user input for these pages
|
142 |
*
|
143 |
-
* @since
|
|
|
|
|
144 |
*/
|
145 |
-
public function
|
146 |
-
// prepare the list of tabs
|
147 |
-
$tabs = array( 'lang' => __( 'Languages','polylang' ) );
|
148 |
-
|
149 |
-
// only if at least one language has been created
|
150 |
-
if ( $listlanguages = $this->model->get_languages_list() ) {
|
151 |
-
$tabs['strings'] = __( 'Strings translations', 'polylang' );
|
152 |
-
$tabs['settings'] = __( 'Settings', 'polylang' );
|
153 |
-
}
|
154 |
-
|
155 |
-
// allows plugins to add tabs
|
156 |
-
$tabs = apply_filters( 'pll_settings_tabs', $tabs );
|
157 |
-
|
158 |
-
switch ( $this->active_tab ) {
|
159 |
-
case 'lang':
|
160 |
-
// prepare the list table of languages
|
161 |
-
$list_table = new PLL_Table_Languages();
|
162 |
-
$list_table->prepare_items( $listlanguages );
|
163 |
-
break;
|
164 |
-
|
165 |
-
case 'strings':
|
166 |
-
// get the strings to translate
|
167 |
-
$data = PLL_Admin_Strings::get_strings();
|
168 |
-
|
169 |
-
// get the groups
|
170 |
-
foreach ( $data as $key => $row ) {
|
171 |
-
$groups[] = $row['context'];
|
172 |
-
}
|
173 |
-
|
174 |
-
$groups = array_unique( $groups );
|
175 |
-
$selected = empty( $_GET['group'] ) || ! in_array( $_GET['group'], $groups ) ? -1 : $_GET['group'];
|
176 |
-
$s = empty( $_GET['s'] ) ? '' : wp_unslash( $_GET['s'] );
|
177 |
-
|
178 |
-
// filter for search string
|
179 |
-
foreach ( $data as $key => $row ) {
|
180 |
-
if ( ( -1 != $selected && $row['context'] != $selected ) || ( ! empty( $s ) && stripos( $row['name'], $s ) === false && stripos( $row['string'], $s ) === false ) ) {
|
181 |
-
unset( $data[ $key ] );
|
182 |
-
}
|
183 |
-
}
|
184 |
-
|
185 |
-
// load translations
|
186 |
-
foreach ( $listlanguages as $language ) {
|
187 |
-
// filters by language if requested
|
188 |
-
if ( ( $lg = get_user_meta( get_current_user_id(), 'pll_filter_content', true ) ) && $language->slug != $lg ) {
|
189 |
-
continue;
|
190 |
-
}
|
191 |
-
|
192 |
-
$mo = new PLL_MO();
|
193 |
-
$mo->import_from_db( $language );
|
194 |
-
foreach ( $data as $key => $row ) {
|
195 |
-
$data[ $key ]['translations'][ $language->slug ] = $mo->translate( $row['string'] );
|
196 |
-
$data[ $key ]['row'] = $key; // store the row number for convenience
|
197 |
-
}
|
198 |
-
}
|
199 |
-
|
200 |
-
// get an array with language slugs as keys, names as values
|
201 |
-
$languages = array_combine( wp_list_pluck( $listlanguages, 'slug' ), wp_list_pluck( $listlanguages, 'name' ) );
|
202 |
-
|
203 |
-
$string_table = new PLL_Table_String( compact( 'languages', 'groups', 'selected' ) );
|
204 |
-
$string_table->prepare_items( $data );
|
205 |
-
break;
|
206 |
-
|
207 |
-
case 'settings':
|
208 |
-
$post_types = get_post_types( array( 'public' => true, '_builtin' => false ) );
|
209 |
-
$post_types = array_diff( $post_types, get_post_types( array( '_pll' => true ) ) );
|
210 |
-
$post_types = array_unique( apply_filters( 'pll_get_post_types', $post_types, true ) );
|
211 |
-
|
212 |
-
$taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) );
|
213 |
-
$taxonomies = array_diff( $taxonomies, get_taxonomies( array( '_pll' => true ) ) );
|
214 |
-
$taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', $taxonomies , true ) );
|
215 |
-
break;
|
216 |
-
}
|
217 |
-
|
218 |
-
$action = isset( $_REQUEST['pll_action'] ) ? $_REQUEST['pll_action'] : '';
|
219 |
-
|
220 |
switch ( $action ) {
|
221 |
case 'add':
|
222 |
check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
|
223 |
|
224 |
-
if ( $this->model->add_language( $_POST ) && 'en_US'
|
225 |
// attempts to install the language pack
|
226 |
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
|
227 |
if ( ! wp_download_language_pack( $_POST['locale'] ) ) {
|
@@ -245,12 +182,6 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
245 |
self::redirect(); // to refresh the page ( possible thanks to the $_GET['noheader']=true )
|
246 |
break;
|
247 |
|
248 |
-
case 'edit':
|
249 |
-
if ( ! empty( $_GET['lang'] ) ) {
|
250 |
-
$edit_lang = $this->model->get_language( (int) $_GET['lang'] );
|
251 |
-
}
|
252 |
-
break;
|
253 |
-
|
254 |
case 'update':
|
255 |
check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
|
256 |
$error = $this->model->update_language( $_POST );
|
@@ -282,58 +213,6 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
282 |
self::redirect(); // to refresh the page ( possible thanks to the $_GET['noheader']=true )
|
283 |
break;
|
284 |
|
285 |
-
case 'string-translation':
|
286 |
-
if ( ! empty( $_POST['submit'] ) ) {
|
287 |
-
check_admin_referer( 'string-translation', '_wpnonce_string-translation' );
|
288 |
-
$strings = PLL_Admin_Strings::get_strings();
|
289 |
-
|
290 |
-
foreach ( $this->model->get_languages_list() as $language ) {
|
291 |
-
if ( empty( $_POST['translation'][ $language->slug ] ) ) { // in case the language filter is active ( thanks to John P. Bloch )
|
292 |
-
continue;
|
293 |
-
}
|
294 |
-
|
295 |
-
$mo = new PLL_MO();
|
296 |
-
$mo->import_from_db( $language );
|
297 |
-
|
298 |
-
foreach ( $_POST['translation'][ $language->slug ] as $key => $translation ) {
|
299 |
-
$translation = apply_filters( 'pll_sanitize_string_translation', $translation, $strings[ $key ]['name'], $strings[ $key ]['context'] );
|
300 |
-
$mo->add_entry( $mo->make_entry( $strings[ $key ]['string'], $translation ) );
|
301 |
-
}
|
302 |
-
|
303 |
-
// clean database ( removes all strings which were registered some day but are no more )
|
304 |
-
if ( ! empty( $_POST['clean'] ) ) {
|
305 |
-
$new_mo = new PLL_MO();
|
306 |
-
|
307 |
-
foreach ( $strings as $string ) {
|
308 |
-
$new_mo->add_entry( $mo->make_entry( $string['string'], $mo->translate( $string['string'] ) ) );
|
309 |
-
}
|
310 |
-
}
|
311 |
-
|
312 |
-
isset( $new_mo ) ? $new_mo->export_to_db( $language ) : $mo->export_to_db( $language );
|
313 |
-
}
|
314 |
-
|
315 |
-
add_settings_error( 'general', 'pll_strings_translations_updated', __( 'Translations updated.', 'polylang' ), 'updated' );
|
316 |
-
do_action( 'pll_save_strings_translations' );
|
317 |
-
}
|
318 |
-
|
319 |
-
// unregisters strings registered through WPML API
|
320 |
-
if ( $string_table->current_action() == 'delete' && ! empty( $_POST['strings'] ) && function_exists( 'icl_unregister_string' ) ) {
|
321 |
-
check_admin_referer( 'string-translation', '_wpnonce_string-translation' );
|
322 |
-
$strings = PLL_Admin_Strings::get_strings();
|
323 |
-
|
324 |
-
foreach ( $_POST['strings'] as $key ) {
|
325 |
-
icl_unregister_string( $strings[ $key ]['context'], $strings[ $key ]['name'] );
|
326 |
-
}
|
327 |
-
}
|
328 |
-
|
329 |
-
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
|
330 |
-
$args = array_intersect_key( $_REQUEST, array_flip( array( 's', 'paged', 'group' ) ) );
|
331 |
-
if ( ! empty( $args['s'] ) ) {
|
332 |
-
$args['s'] = urlencode( $args['s'] ); // searched string needs to be encoded as it comes from $_POST
|
333 |
-
}
|
334 |
-
self::redirect( $args );
|
335 |
-
break;
|
336 |
-
|
337 |
case 'activate':
|
338 |
check_admin_referer( 'pll_activate' );
|
339 |
$this->modules[ $_GET['module'] ]->activate();
|
@@ -347,16 +226,68 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
347 |
break;
|
348 |
|
349 |
default:
|
|
|
|
|
|
|
|
|
|
|
350 |
do_action( "mlang_action_$action" );
|
351 |
break;
|
352 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
|
354 |
// displays the page
|
355 |
include( PLL_SETTINGS_INC.'/view-languages.php' );
|
356 |
}
|
357 |
|
358 |
-
|
359 |
-
*
|
360 |
*/
|
361 |
public function admin_enqueue_scripts() {
|
362 |
parent::admin_enqueue_scripts();
|
@@ -369,8 +300,8 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
369 |
wp_enqueue_style( 'pll_selectmenu', POLYLANG_URL .'/css/selectmenu'.$suffix.'.css', array(), POLYLANG_VERSION );
|
370 |
}
|
371 |
|
372 |
-
|
373 |
-
*
|
374 |
*
|
375 |
* @since 1.8
|
376 |
*/
|
@@ -385,8 +316,8 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
385 |
}
|
386 |
}
|
387 |
|
388 |
-
|
389 |
-
*
|
390 |
* saves error messages in a transient for reuse in redirected page
|
391 |
*
|
392 |
* @since 1.5
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* A class for the Polylang settings pages
|
5 |
* accessible in $polylang global object
|
6 |
*
|
7 |
* properties:
|
19 |
class PLL_Settings extends PLL_Admin_Base {
|
20 |
protected $active_tab, $modules;
|
21 |
|
22 |
+
/**
|
23 |
+
* Constructor
|
24 |
*
|
25 |
* @since 1.2
|
26 |
*
|
43 |
add_filter( 'set-screen-option', array( &$this, 'set_screen_option' ), 10, 3 );
|
44 |
}
|
45 |
|
46 |
+
/**
|
47 |
+
* Initializes the modules
|
48 |
*
|
49 |
* @since 1.8
|
50 |
*/
|
51 |
public function register_settings_modules() {
|
52 |
+
/**
|
53 |
+
* Filter the list of setting modules
|
54 |
+
*
|
55 |
+
* @since 1.8
|
56 |
+
*
|
57 |
+
* @param array $modules the list of module classes
|
58 |
+
*/
|
59 |
$modules = apply_filters( 'pll_settings_modules', array(
|
60 |
'PLL_Settings_Url',
|
61 |
'PLL_Settings_Browser',
|
63 |
'PLL_Settings_CPT',
|
64 |
'PLL_Settings_Sync',
|
65 |
'PLL_Settings_WPML',
|
66 |
+
'PLL_Settings_Share_Slug',
|
67 |
+
'PLL_Settings_Translate_Slugs',
|
68 |
'PLL_Settings_Tools',
|
69 |
+
'PLL_Settings_Licenses',
|
70 |
) );
|
71 |
|
72 |
foreach ( $modules as $key => $class ) {
|
75 |
}
|
76 |
}
|
77 |
|
78 |
+
/**
|
79 |
+
* Adds the link to the languages panel in the WordPress admin menu
|
80 |
*
|
81 |
* @since 0.1
|
82 |
*/
|
84 |
add_submenu_page( 'options-general.php', $title = __( 'Languages', 'polylang' ), $title, 'manage_options', 'mlang', array( $this, 'languages_page' ) );
|
85 |
}
|
86 |
|
87 |
+
/**
|
88 |
* Loads the about metabox
|
89 |
*
|
90 |
* @since 0.8
|
93 |
include( PLL_SETTINGS_INC.'/view-about.php' );
|
94 |
}
|
95 |
|
96 |
+
/**
|
97 |
+
* Adds screen options and the about box in the languages admin panel
|
98 |
*
|
99 |
* @since 0.9.5
|
100 |
*/
|
131 |
}
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
* Save the "Views/Uploads per page" option set by this user
|
136 |
*
|
137 |
* @since 0.9.5
|
138 |
*
|
139 |
+
* @param mixed $status false or value returned by previous filter
|
140 |
* @param string $option Name of the option being changed
|
141 |
+
* @param string $value Value of the option
|
142 |
*
|
143 |
* @return string New value if this is our option, otherwise nothing
|
144 |
*/
|
146 |
return 'pll_strings_per_page' === $option ? $value : $status;
|
147 |
}
|
148 |
|
149 |
+
/**
|
150 |
+
* Manages the user input for the languages pages
|
|
|
151 |
*
|
152 |
+
* @since 1.9
|
153 |
+
*
|
154 |
+
* @param string $action
|
155 |
*/
|
156 |
+
public function handle_actions( $action ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
switch ( $action ) {
|
158 |
case 'add':
|
159 |
check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
|
160 |
|
161 |
+
if ( $this->model->add_language( $_POST ) && 'en_US' !== $_POST['locale'] ) {
|
162 |
// attempts to install the language pack
|
163 |
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
|
164 |
if ( ! wp_download_language_pack( $_POST['locale'] ) ) {
|
182 |
self::redirect(); // to refresh the page ( possible thanks to the $_GET['noheader']=true )
|
183 |
break;
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
case 'update':
|
186 |
check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
|
187 |
$error = $this->model->update_language( $_POST );
|
213 |
self::redirect(); // to refresh the page ( possible thanks to the $_GET['noheader']=true )
|
214 |
break;
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
case 'activate':
|
217 |
check_admin_referer( 'pll_activate' );
|
218 |
$this->modules[ $_GET['module'] ]->activate();
|
226 |
break;
|
227 |
|
228 |
default:
|
229 |
+
/**
|
230 |
+
* Fires when a non default action has been sent to Polylang settings
|
231 |
+
*
|
232 |
+
* @since 1.8
|
233 |
+
*/
|
234 |
do_action( "mlang_action_$action" );
|
235 |
break;
|
236 |
}
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Displays the 3 tabs pages: languages, strings translations, settings
|
241 |
+
* also manages user input for these pages
|
242 |
+
*
|
243 |
+
* @since 0.1
|
244 |
+
*/
|
245 |
+
public function languages_page() {
|
246 |
+
// prepare the list of tabs
|
247 |
+
$tabs = array( 'lang' => __( 'Languages','polylang' ) );
|
248 |
+
|
249 |
+
// only if at least one language has been created
|
250 |
+
if ( $listlanguages = $this->model->get_languages_list() ) {
|
251 |
+
$tabs['strings'] = __( 'Strings translations', 'polylang' );
|
252 |
+
$tabs['settings'] = __( 'Settings', 'polylang' );
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Filter the list of tabs in Polylang settings
|
257 |
+
*
|
258 |
+
* @since 1.5.1
|
259 |
+
*
|
260 |
+
* @param array $tabs list of tab names
|
261 |
+
*/
|
262 |
+
$tabs = apply_filters( 'pll_settings_tabs', $tabs );
|
263 |
+
|
264 |
+
switch ( $this->active_tab ) {
|
265 |
+
case 'lang':
|
266 |
+
// prepare the list table of languages
|
267 |
+
$list_table = new PLL_Table_Languages();
|
268 |
+
$list_table->prepare_items( $listlanguages );
|
269 |
+
break;
|
270 |
+
|
271 |
+
case 'strings':
|
272 |
+
$string_table = new PLL_Table_String( $listlanguages );
|
273 |
+
$string_table->prepare_items();
|
274 |
+
break;
|
275 |
+
}
|
276 |
+
|
277 |
+
// handle user input
|
278 |
+
$action = isset( $_REQUEST['pll_action'] ) ? $_REQUEST['pll_action'] : '';
|
279 |
+
if ( 'edit' === $action && ! empty( $_GET['lang'] ) ) {
|
280 |
+
$edit_lang = $this->model->get_language( (int) $_GET['lang'] );
|
281 |
+
} else {
|
282 |
+
$this->handle_actions( $action );
|
283 |
+
}
|
284 |
|
285 |
// displays the page
|
286 |
include( PLL_SETTINGS_INC.'/view-languages.php' );
|
287 |
}
|
288 |
|
289 |
+
/**
|
290 |
+
* Enqueues scripts and styles
|
291 |
*/
|
292 |
public function admin_enqueue_scripts() {
|
293 |
parent::admin_enqueue_scripts();
|
300 |
wp_enqueue_style( 'pll_selectmenu', POLYLANG_URL .'/css/selectmenu'.$suffix.'.css', array(), POLYLANG_VERSION );
|
301 |
}
|
302 |
|
303 |
+
/**
|
304 |
+
* Displays a notice when there are objects with no language assigned
|
305 |
*
|
306 |
* @since 1.8
|
307 |
*/
|
316 |
}
|
317 |
}
|
318 |
|
319 |
+
/**
|
320 |
+
* Redirects to language page ( current active tab )
|
321 |
* saves error messages in a transient for reuse in redirected page
|
322 |
*
|
323 |
* @since 1.5
|
settings/table-languages.php
CHANGED
@@ -4,7 +4,7 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
|
|
4 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
|
5 |
}
|
6 |
|
7 |
-
|
8 |
* a class to create the languages table in Polylang settings
|
9 |
* Thanks to Matt Van Andel ( http://www.mattvanandel.com ) for its plugin "Custom List Table Example" !
|
10 |
*
|
@@ -12,7 +12,7 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
|
|
12 |
*/
|
13 |
class PLL_Table_Languages extends WP_List_Table {
|
14 |
|
15 |
-
|
16 |
* constructor
|
17 |
*
|
18 |
* @since 0.1
|
@@ -24,7 +24,7 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
24 |
) );
|
25 |
}
|
26 |
|
27 |
-
|
28 |
* Generates content for a single row of the table
|
29 |
*
|
30 |
* @since 1.8
|
@@ -32,13 +32,21 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
32 |
* @param object $item The current item
|
33 |
*/
|
34 |
public function single_row( $item ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
$classes = apply_filters( 'pll_languages_row_classes', array(), $item );
|
36 |
echo '<tr' . ( empty( $classes ) ? '>' : ' class="' . esc_attr( implode( ' ', $classes ) ) . '">' );
|
37 |
$this->single_row_columns( $item );
|
38 |
echo '</tr>';
|
39 |
}
|
40 |
|
41 |
-
|
42 |
* displays the item information in a column ( default case )
|
43 |
*
|
44 |
* @since 0.1
|
@@ -62,7 +70,7 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
62 |
}
|
63 |
}
|
64 |
|
65 |
-
|
66 |
* displays the item information in the column 'name'
|
67 |
* displays the edit and delete action links
|
68 |
*
|
@@ -80,7 +88,7 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
80 |
);
|
81 |
}
|
82 |
|
83 |
-
|
84 |
* displays the item information in the default language
|
85 |
* displays the 'make default' action link
|
86 |
*
|
@@ -102,7 +110,16 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
102 |
/* translators: %s is a native language name */
|
103 |
esc_html( sprintf( __( 'Choose %s as default language', 'polylang' ), $item->name ) )
|
104 |
);
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
} else {
|
107 |
$s = sprintf(
|
108 |
'<span class="icon-default-lang"><span class="screen-reader-text">%1$s</span></span>',
|
@@ -114,7 +131,7 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
114 |
return $s;
|
115 |
}
|
116 |
|
117 |
-
|
118 |
* gets the list of columns
|
119 |
*
|
120 |
* @since 0.1
|
@@ -133,7 +150,7 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
133 |
);
|
134 |
}
|
135 |
|
136 |
-
|
137 |
* gets the list of sortable columns
|
138 |
*
|
139 |
* @since 0.1
|
@@ -155,9 +172,9 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
155 |
*
|
156 |
* @since 1.8
|
157 |
*
|
158 |
-
* @param object $item
|
159 |
* @param string $column_name Current column name.
|
160 |
-
* @param string $primary
|
161 |
* @return string The row actions output.
|
162 |
*/
|
163 |
protected function handle_row_actions( $item, $column_name, $primary ) {
|
@@ -181,12 +198,20 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
181 |
),
|
182 |
);
|
183 |
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
|
186 |
return $this->row_actions( $actions );
|
187 |
}
|
188 |
|
189 |
-
|
190 |
* Sort items
|
191 |
*
|
192 |
* @since 0.1
|
@@ -207,7 +232,7 @@ class PLL_Table_Languages extends WP_List_Table {
|
|
207 |
return ( empty( $_GET['order'] ) || 'asc' == $_GET['order'] ) ? $result : -$result;
|
208 |
}
|
209 |
|
210 |
-
|
211 |
* prepares the list of items for displaying
|
212 |
*
|
213 |
* @since 0.1
|
4 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
|
5 |
}
|
6 |
|
7 |
+
/**
|
8 |
* a class to create the languages table in Polylang settings
|
9 |
* Thanks to Matt Van Andel ( http://www.mattvanandel.com ) for its plugin "Custom List Table Example" !
|
10 |
*
|
12 |
*/
|
13 |
class PLL_Table_Languages extends WP_List_Table {
|
14 |
|
15 |
+
/**
|
16 |
* constructor
|
17 |
*
|
18 |
* @since 0.1
|
24 |
) );
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
* Generates content for a single row of the table
|
29 |
*
|
30 |
* @since 1.8
|
32 |
* @param object $item The current item
|
33 |
*/
|
34 |
public function single_row( $item ) {
|
35 |
+
/*
|
36 |
+
* Filter the list of classes assigned a row in the languages list table
|
37 |
+
*
|
38 |
+
* @since 1.8
|
39 |
+
*
|
40 |
+
* @param array $classes list of class names
|
41 |
+
* @param object $item the current item
|
42 |
+
*/
|
43 |
$classes = apply_filters( 'pll_languages_row_classes', array(), $item );
|
44 |
echo '<tr' . ( empty( $classes ) ? '>' : ' class="' . esc_attr( implode( ' ', $classes ) ) . '">' );
|
45 |
$this->single_row_columns( $item );
|
46 |
echo '</tr>';
|
47 |
}
|
48 |
|
49 |
+
/**
|
50 |
* displays the item information in a column ( default case )
|
51 |
*
|
52 |
* @since 0.1
|
70 |
}
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
* displays the item information in the column 'name'
|
75 |
* displays the edit and delete action links
|
76 |
*
|
88 |
);
|
89 |
}
|
90 |
|
91 |
+
/**
|
92 |
* displays the item information in the default language
|
93 |
* displays the 'make default' action link
|
94 |
*
|
110 |
/* translators: %s is a native language name */
|
111 |
esc_html( sprintf( __( 'Choose %s as default language', 'polylang' ), $item->name ) )
|
112 |
);
|
113 |
+
|
114 |
+
/*
|
115 |
+
* Filter the default language row action in the languages list table
|
116 |
+
*
|
117 |
+
* @since 1.8
|
118 |
+
*
|
119 |
+
* @param string $s html markup of the action
|
120 |
+
* @param object $item
|
121 |
+
*/
|
122 |
+
$s = apply_filters( 'pll_default_lang_row_action', $s, $item );
|
123 |
} else {
|
124 |
$s = sprintf(
|
125 |
'<span class="icon-default-lang"><span class="screen-reader-text">%1$s</span></span>',
|
131 |
return $s;
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
* gets the list of columns
|
136 |
*
|
137 |
* @since 0.1
|
150 |
);
|
151 |
}
|
152 |
|
153 |
+
/**
|
154 |
* gets the list of sortable columns
|
155 |
*
|
156 |
* @since 0.1
|
172 |
*
|
173 |
* @since 1.8
|
174 |
*
|
175 |
+
* @param object $item The item being acted upon.
|
176 |
* @param string $column_name Current column name.
|
177 |
+
* @param string $primary Primary column name.
|
178 |
* @return string The row actions output.
|
179 |
*/
|
180 |
protected function handle_row_actions( $item, $column_name, $primary ) {
|
198 |
),
|
199 |
);
|
200 |
|
201 |
+
/*
|
202 |
+
* Filter the list of row actions in the languages list table
|
203 |
+
*
|
204 |
+
* @since 1.8
|
205 |
+
*
|
206 |
+
* @param array $actions list of html markup actions
|
207 |
+
* @param object $item
|
208 |
+
*/
|
209 |
+
$actions = apply_filters( 'pll_languages_row_actions', $actions, $item );
|
210 |
|
211 |
return $this->row_actions( $actions );
|
212 |
}
|
213 |
|
214 |
+
/**
|
215 |
* Sort items
|
216 |
*
|
217 |
* @since 0.1
|
232 |
return ( empty( $_GET['order'] ) || 'asc' == $_GET['order'] ) ? $result : -$result;
|
233 |
}
|
234 |
|
235 |
+
/**
|
236 |
* prepares the list of items for displaying
|
237 |
*
|
238 |
* @since 0.1
|
settings/table-settings.php
CHANGED
@@ -4,14 +4,14 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
|
|
4 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
|
5 |
}
|
6 |
|
7 |
-
|
8 |
* a class to create a table to list all settings modules
|
9 |
*
|
10 |
* @since 1.8
|
11 |
*/
|
12 |
class PLL_Table_Settings extends WP_List_Table {
|
13 |
|
14 |
-
|
15 |
* constructor
|
16 |
*
|
17 |
* @since 1.8
|
@@ -23,7 +23,7 @@ class PLL_Table_Settings extends WP_List_Table {
|
|
23 |
) );
|
24 |
}
|
25 |
|
26 |
-
|
27 |
* get the table classes for styling
|
28 |
*
|
29 |
* @øince 1.8
|
@@ -32,7 +32,7 @@ class PLL_Table_Settings extends WP_List_Table {
|
|
32 |
return array( 'wp-list-table', 'widefat', 'plugins', 'pll-settings' ); // get the style of the plugins list table + one specific class
|
33 |
}
|
34 |
|
35 |
-
|
36 |
* displays a single row
|
37 |
*
|
38 |
* @øince 1.8
|
@@ -42,12 +42,27 @@ class PLL_Table_Settings extends WP_List_Table {
|
|
42 |
public function single_row( $item ) {
|
43 |
// classes to reuse css from the plugins list table
|
44 |
$classes = $item->is_active() ? 'active' : 'inactive';
|
|
|
|
|
|
|
45 |
|
46 |
// display the columns
|
47 |
printf( '<tr id="pll-module-%s" class="%s">', esc_attr( $item->module ), esc_attr( $classes ) );
|
48 |
$this->single_row_columns( $item );
|
49 |
echo '</tr>';
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
// the settings if there are
|
52 |
// "inactive" class to reuse css from the plugins list table
|
53 |
if ( $form = $item->get_form() ) {
|
@@ -57,12 +72,11 @@ class PLL_Table_Settings extends WP_List_Table {
|
|
57 |
<legend>%s</legend>
|
58 |
%s
|
59 |
<p class="submit inline-edit-save">
|
60 |
-
|
61 |
-
<button type="button" class="button button-primary save">%s</button>
|
62 |
</p>
|
63 |
</td>
|
64 |
</tr>',
|
65 |
-
esc_attr( $item->module ), esc_html( $item->title ), $form,
|
66 |
);
|
67 |
}
|
68 |
}
|
@@ -109,7 +123,7 @@ class PLL_Table_Settings extends WP_List_Table {
|
|
109 |
*/
|
110 |
protected function column_cb( $item ) {}
|
111 |
|
112 |
-
|
113 |
* displays the item information in a column ( default case )
|
114 |
*
|
115 |
* @since 1.8
|
@@ -125,7 +139,7 @@ class PLL_Table_Settings extends WP_List_Table {
|
|
125 |
return $item->$column_name;
|
126 |
}
|
127 |
|
128 |
-
|
129 |
* gets the list of columns
|
130 |
*
|
131 |
* @since 1.8
|
@@ -151,7 +165,7 @@ class PLL_Table_Settings extends WP_List_Table {
|
|
151 |
return 'plugin-title';
|
152 |
}
|
153 |
|
154 |
-
|
155 |
* prepares the list of items for displaying
|
156 |
*
|
157 |
* @since 1.8
|
4 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
|
5 |
}
|
6 |
|
7 |
+
/**
|
8 |
* a class to create a table to list all settings modules
|
9 |
*
|
10 |
* @since 1.8
|
11 |
*/
|
12 |
class PLL_Table_Settings extends WP_List_Table {
|
13 |
|
14 |
+
/**
|
15 |
* constructor
|
16 |
*
|
17 |
* @since 1.8
|
23 |
) );
|
24 |
}
|
25 |
|
26 |
+
/**
|
27 |
* get the table classes for styling
|
28 |
*
|
29 |
* @øince 1.8
|
32 |
return array( 'wp-list-table', 'widefat', 'plugins', 'pll-settings' ); // get the style of the plugins list table + one specific class
|
33 |
}
|
34 |
|
35 |
+
/**
|
36 |
* displays a single row
|
37 |
*
|
38 |
* @øince 1.8
|
42 |
public function single_row( $item ) {
|
43 |
// classes to reuse css from the plugins list table
|
44 |
$classes = $item->is_active() ? 'active' : 'inactive';
|
45 |
+
if ( $message = $item->get_upgrade_message() ) {
|
46 |
+
$classes .= ' update';
|
47 |
+
}
|
48 |
|
49 |
// display the columns
|
50 |
printf( '<tr id="pll-module-%s" class="%s">', esc_attr( $item->module ), esc_attr( $classes ) );
|
51 |
$this->single_row_columns( $item );
|
52 |
echo '</tr>';
|
53 |
|
54 |
+
// display an upgrade message if there is any
|
55 |
+
if ( $message = $item->get_upgrade_message() ) {
|
56 |
+
printf( '
|
57 |
+
<tr class="plugin-update-tr">
|
58 |
+
<td colspan="3" class="plugin-update colspanchange">
|
59 |
+
<div class="update-message">%s</div>
|
60 |
+
</td>
|
61 |
+
</tr>',
|
62 |
+
$message
|
63 |
+
);
|
64 |
+
}
|
65 |
+
|
66 |
// the settings if there are
|
67 |
// "inactive" class to reuse css from the plugins list table
|
68 |
if ( $form = $item->get_form() ) {
|
72 |
<legend>%s</legend>
|
73 |
%s
|
74 |
<p class="submit inline-edit-save">
|
75 |
+
%s
|
|
|
76 |
</p>
|
77 |
</td>
|
78 |
</tr>',
|
79 |
+
esc_attr( $item->module ), esc_html( $item->title ), $form, implode( $item->get_buttons() )
|
80 |
);
|
81 |
}
|
82 |
}
|
123 |
*/
|
124 |
protected function column_cb( $item ) {}
|
125 |
|
126 |
+
/**
|
127 |
* displays the item information in a column ( default case )
|
128 |
*
|
129 |
* @since 1.8
|
139 |
return $item->$column_name;
|
140 |
}
|
141 |
|
142 |
+
/**
|
143 |
* gets the list of columns
|
144 |
*
|
145 |
* @since 1.8
|
165 |
return 'plugin-title';
|
166 |
}
|
167 |
|
168 |
+
/**
|
169 |
* prepares the list of items for displaying
|
170 |
*
|
171 |
* @since 1.8
|
settings/table-string.php
CHANGED
@@ -4,40 +4,42 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
|
|
4 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
|
5 |
}
|
6 |
|
7 |
-
|
8 |
-
*
|
9 |
* Thanks to Matt Van Andel ( http://www.mattvanandel.com ) for its plugin "Custom List Table Example" !
|
10 |
*
|
11 |
* @since 0.6
|
12 |
*/
|
13 |
class PLL_Table_String extends WP_List_Table {
|
14 |
-
protected $languages, $groups, $
|
15 |
|
16 |
-
|
17 |
-
*
|
18 |
*
|
19 |
* @since 0.6
|
20 |
*
|
21 |
-
* @param array $
|
22 |
-
* @param string $group_selected
|
23 |
*/
|
24 |
-
function __construct( $
|
25 |
parent::__construct( array(
|
26 |
'plural' => 'Strings translations', // do not translate ( used for css class )
|
27 |
'ajax' => false,
|
28 |
) );
|
29 |
|
30 |
-
$this->languages = $
|
31 |
-
$this->
|
32 |
-
$this->
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
-
|
36 |
-
*
|
37 |
*
|
38 |
* @since 0.6
|
39 |
*
|
40 |
-
* @param array
|
41 |
* @param string $column_name
|
42 |
* @return string
|
43 |
*/
|
@@ -45,8 +47,8 @@ class PLL_Table_String extends WP_List_Table {
|
|
45 |
return $item[ $column_name ];
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
*
|
50 |
*
|
51 |
* @since 1.1
|
52 |
*
|
@@ -63,8 +65,8 @@ class PLL_Table_String extends WP_List_Table {
|
|
63 |
);
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
*
|
68 |
*
|
69 |
* @since 1.0
|
70 |
*
|
@@ -75,8 +77,8 @@ class PLL_Table_String extends WP_List_Table {
|
|
75 |
return format_to_edit( $item['string'] ); // don't interpret special chars for the string column
|
76 |
}
|
77 |
|
78 |
-
|
79 |
-
*
|
80 |
*
|
81 |
* @since 0.6
|
82 |
*
|
@@ -84,7 +86,9 @@ class PLL_Table_String extends WP_List_Table {
|
|
84 |
* @return string
|
85 |
*/
|
86 |
function column_translations( $item ) {
|
|
|
87 |
$out = '';
|
|
|
88 |
foreach ( $item['translations'] as $key => $translation ) {
|
89 |
$input_type = $item['multiline'] ?
|
90 |
'<textarea name="translation[%1$s][%2$s]" id="%1$s-%2$s">%4$s</textarea>' :
|
@@ -92,14 +96,15 @@ class PLL_Table_String extends WP_List_Table {
|
|
92 |
$out .= sprintf( '<div class="translation"><label for="%1$s-%2$s">%3$s</label>'.$input_type.'</div>'."\n",
|
93 |
esc_attr( $key ),
|
94 |
esc_attr( $item['row'] ),
|
95 |
-
esc_html( $
|
96 |
format_to_edit( $translation ) ); // don't interpret special chars
|
97 |
}
|
|
|
98 |
return $out;
|
99 |
}
|
100 |
|
101 |
-
|
102 |
-
*
|
103 |
*
|
104 |
* @since 0.6
|
105 |
*
|
@@ -107,7 +112,7 @@ class PLL_Table_String extends WP_List_Table {
|
|
107 |
*/
|
108 |
function get_columns() {
|
109 |
return array(
|
110 |
-
'cb' => '<input type="checkbox" />', //checkbox
|
111 |
'string' => __( 'String', 'polylang' ),
|
112 |
'name' => __( 'Name', 'polylang' ),
|
113 |
'context' => __( 'Group', 'polylang' ),
|
@@ -115,8 +120,8 @@ class PLL_Table_String extends WP_List_Table {
|
|
115 |
);
|
116 |
}
|
117 |
|
118 |
-
|
119 |
-
*
|
120 |
*
|
121 |
* @since 0.6
|
122 |
*
|
@@ -130,7 +135,7 @@ class PLL_Table_String extends WP_List_Table {
|
|
130 |
);
|
131 |
}
|
132 |
|
133 |
-
|
134 |
* Sort items
|
135 |
*
|
136 |
* @since 0.6
|
@@ -141,21 +146,44 @@ class PLL_Table_String extends WP_List_Table {
|
|
141 |
*/
|
142 |
protected function usort_reorder( $a, $b ) {
|
143 |
$result = strcmp( $a[ $_GET['orderby'] ], $b[ $_GET['orderby'] ] ); // determine sort order
|
144 |
-
return ( empty( $_GET['order'] ) || 'asc'
|
145 |
}
|
146 |
|
147 |
-
|
148 |
-
*
|
149 |
*
|
150 |
* @since 0.6
|
151 |
-
*
|
152 |
-
* @param array $data
|
153 |
*/
|
154 |
-
function prepare_items(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
$per_page = $this->get_items_per_page( 'pll_strings_per_page' );
|
156 |
$this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
|
157 |
|
158 |
-
if ( ! empty( $_GET['orderby'] ) ) {// no sort by default
|
159 |
usort( $data, array( &$this, 'usort_reorder' ) );
|
160 |
}
|
161 |
|
@@ -169,8 +197,8 @@ class PLL_Table_String extends WP_List_Table {
|
|
169 |
) );
|
170 |
}
|
171 |
|
172 |
-
|
173 |
-
*
|
174 |
*
|
175 |
* @since 1.1
|
176 |
*
|
@@ -180,8 +208,8 @@ class PLL_Table_String extends WP_List_Table {
|
|
180 |
return array( 'delete' => __( 'Delete','polylang' ) );
|
181 |
}
|
182 |
|
183 |
-
|
184 |
-
*
|
185 |
* overrides parent function to avoid submit button to trigger bulk actions
|
186 |
*
|
187 |
* @since 1.8
|
@@ -192,15 +220,15 @@ class PLL_Table_String extends WP_List_Table {
|
|
192 |
return empty( $_POST['submit'] ) ? parent::current_action() : false;
|
193 |
}
|
194 |
|
195 |
-
|
196 |
-
*
|
197 |
*
|
198 |
* @since 1.1
|
199 |
*
|
200 |
* @param string $which only 'top' is supported
|
201 |
*/
|
202 |
function extra_tablenav( $which ) {
|
203 |
-
if ( 'top'
|
204 |
return;
|
205 |
}
|
206 |
|
@@ -209,7 +237,7 @@ class PLL_Table_String extends WP_List_Table {
|
|
209 |
echo '<select id="select-group" name="group">' . "\n";
|
210 |
printf(
|
211 |
'<option value="-1"%s>%s</option>' . "\n",
|
212 |
-
-1
|
213 |
__( 'View all groups', 'polylang' )
|
214 |
);
|
215 |
|
@@ -217,7 +245,7 @@ class PLL_Table_String extends WP_List_Table {
|
|
217 |
printf(
|
218 |
'<option value="%s"%s>%s</option>' . "\n",
|
219 |
esc_attr( urlencode( $group ) ),
|
220 |
-
$this->
|
221 |
esc_html( $group )
|
222 |
);
|
223 |
}
|
@@ -226,4 +254,74 @@ class PLL_Table_String extends WP_List_Table {
|
|
226 |
submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
|
227 |
echo '</div>';
|
228 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
}
|
4 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
|
5 |
}
|
6 |
|
7 |
+
/**
|
8 |
+
* A class to create the strings translations table
|
9 |
* Thanks to Matt Van Andel ( http://www.mattvanandel.com ) for its plugin "Custom List Table Example" !
|
10 |
*
|
11 |
* @since 0.6
|
12 |
*/
|
13 |
class PLL_Table_String extends WP_List_Table {
|
14 |
+
protected $languages, $strings, $groups, $selected_group;
|
15 |
|
16 |
+
/**
|
17 |
+
* Constructor
|
18 |
*
|
19 |
* @since 0.6
|
20 |
*
|
21 |
+
* @param array $languages list of languages
|
|
|
22 |
*/
|
23 |
+
function __construct( $languages ) {
|
24 |
parent::__construct( array(
|
25 |
'plural' => 'Strings translations', // do not translate ( used for css class )
|
26 |
'ajax' => false,
|
27 |
) );
|
28 |
|
29 |
+
$this->languages = $languages;
|
30 |
+
$this->strings = PLL_Admin_Strings::get_strings();
|
31 |
+
$this->groups = array_unique( wp_list_pluck( $this->strings, 'context' ) );
|
32 |
+
$this->selected_group = empty( $_GET['group'] ) || ! in_array( $_GET['group'], $this->groups ) ? -1 : $_GET['group'];
|
33 |
+
|
34 |
+
add_action( 'mlang_action_string-translation', array( &$this, 'save_translations' ) );
|
35 |
}
|
36 |
|
37 |
+
/**
|
38 |
+
* Displays the item information in a column ( default case )
|
39 |
*
|
40 |
* @since 0.6
|
41 |
*
|
42 |
+
* @param array $item
|
43 |
* @param string $column_name
|
44 |
* @return string
|
45 |
*/
|
47 |
return $item[ $column_name ];
|
48 |
}
|
49 |
|
50 |
+
/**
|
51 |
+
* Displays the checkbox in first column
|
52 |
*
|
53 |
* @since 1.1
|
54 |
*
|
65 |
);
|
66 |
}
|
67 |
|
68 |
+
/**
|
69 |
+
* Displays the string to translate
|
70 |
*
|
71 |
* @since 1.0
|
72 |
*
|
77 |
return format_to_edit( $item['string'] ); // don't interpret special chars for the string column
|
78 |
}
|
79 |
|
80 |
+
/**
|
81 |
+
* Displays the translations to edit
|
82 |
*
|
83 |
* @since 0.6
|
84 |
*
|
86 |
* @return string
|
87 |
*/
|
88 |
function column_translations( $item ) {
|
89 |
+
$languages = array_combine( wp_list_pluck( $this->languages, 'slug' ), wp_list_pluck( $this->languages, 'name' ) );
|
90 |
$out = '';
|
91 |
+
|
92 |
foreach ( $item['translations'] as $key => $translation ) {
|
93 |
$input_type = $item['multiline'] ?
|
94 |
'<textarea name="translation[%1$s][%2$s]" id="%1$s-%2$s">%4$s</textarea>' :
|
96 |
$out .= sprintf( '<div class="translation"><label for="%1$s-%2$s">%3$s</label>'.$input_type.'</div>'."\n",
|
97 |
esc_attr( $key ),
|
98 |
esc_attr( $item['row'] ),
|
99 |
+
esc_html( $languages[ $key ] ),
|
100 |
format_to_edit( $translation ) ); // don't interpret special chars
|
101 |
}
|
102 |
+
|
103 |
return $out;
|
104 |
}
|
105 |
|
106 |
+
/**
|
107 |
+
* Gets the list of columns
|
108 |
*
|
109 |
* @since 0.6
|
110 |
*
|
112 |
*/
|
113 |
function get_columns() {
|
114 |
return array(
|
115 |
+
'cb' => '<input type="checkbox" />', // checkbox
|
116 |
'string' => __( 'String', 'polylang' ),
|
117 |
'name' => __( 'Name', 'polylang' ),
|
118 |
'context' => __( 'Group', 'polylang' ),
|
120 |
);
|
121 |
}
|
122 |
|
123 |
+
/**
|
124 |
+
* Gets the list of sortable columns
|
125 |
*
|
126 |
* @since 0.6
|
127 |
*
|
135 |
);
|
136 |
}
|
137 |
|
138 |
+
/**
|
139 |
* Sort items
|
140 |
*
|
141 |
* @since 0.6
|
146 |
*/
|
147 |
protected function usort_reorder( $a, $b ) {
|
148 |
$result = strcmp( $a[ $_GET['orderby'] ], $b[ $_GET['orderby'] ] ); // determine sort order
|
149 |
+
return ( empty( $_GET['order'] ) || 'asc' === $_GET['order'] ) ? $result : -$result; // send final sort direction to usort
|
150 |
}
|
151 |
|
152 |
+
/**
|
153 |
+
* Prepares the list of items for displaying
|
154 |
*
|
155 |
* @since 0.6
|
|
|
|
|
156 |
*/
|
157 |
+
function prepare_items() {
|
158 |
+
$data = $this->strings;
|
159 |
+
|
160 |
+
// filter for search string
|
161 |
+
$s = empty( $_GET['s'] ) ? '' : wp_unslash( $_GET['s'] );
|
162 |
+
foreach ( $data as $key => $row ) {
|
163 |
+
if ( ( -1 !== $this->selected_group && $row['context'] !== $this->selected_group ) || ( ! empty( $s ) && stripos( $row['name'], $s ) === false && stripos( $row['string'], $s ) === false ) ) {
|
164 |
+
unset( $data[ $key ] );
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
// load translations
|
169 |
+
foreach ( $this->languages as $language ) {
|
170 |
+
// filters by language if requested
|
171 |
+
if ( ( $lg = get_user_meta( get_current_user_id(), 'pll_filter_content', true ) ) && $language->slug !== $lg ) {
|
172 |
+
continue;
|
173 |
+
}
|
174 |
+
|
175 |
+
$mo = new PLL_MO();
|
176 |
+
$mo->import_from_db( $language );
|
177 |
+
foreach ( $data as $key => $row ) {
|
178 |
+
$data[ $key ]['translations'][ $language->slug ] = $mo->translate( $row['string'] );
|
179 |
+
$data[ $key ]['row'] = $key; // store the row number for convenience
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
$per_page = $this->get_items_per_page( 'pll_strings_per_page' );
|
184 |
$this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
|
185 |
|
186 |
+
if ( ! empty( $_GET['orderby'] ) ) { // no sort by default
|
187 |
usort( $data, array( &$this, 'usort_reorder' ) );
|
188 |
}
|
189 |
|
197 |
) );
|
198 |
}
|
199 |
|
200 |
+
/**
|
201 |
+
* Get the list of possible bulk actions
|
202 |
*
|
203 |
* @since 1.1
|
204 |
*
|
208 |
return array( 'delete' => __( 'Delete','polylang' ) );
|
209 |
}
|
210 |
|
211 |
+
/**
|
212 |
+
* Get the current action selected from the bulk actions dropdown.
|
213 |
* overrides parent function to avoid submit button to trigger bulk actions
|
214 |
*
|
215 |
* @since 1.8
|
220 |
return empty( $_POST['submit'] ) ? parent::current_action() : false;
|
221 |
}
|
222 |
|
223 |
+
/**
|
224 |
+
* Displays the dropdown list to filter strings per group
|
225 |
*
|
226 |
* @since 1.1
|
227 |
*
|
228 |
* @param string $which only 'top' is supported
|
229 |
*/
|
230 |
function extra_tablenav( $which ) {
|
231 |
+
if ( 'top' !== $which ) {
|
232 |
return;
|
233 |
}
|
234 |
|
237 |
echo '<select id="select-group" name="group">' . "\n";
|
238 |
printf(
|
239 |
'<option value="-1"%s>%s</option>' . "\n",
|
240 |
+
-1 === $this->group_selected ? ' selected="selected"' : '',
|
241 |
__( 'View all groups', 'polylang' )
|
242 |
);
|
243 |
|
245 |
printf(
|
246 |
'<option value="%s"%s>%s</option>' . "\n",
|
247 |
esc_attr( urlencode( $group ) ),
|
248 |
+
$this->selected_group === $group ? ' selected="selected"' : '',
|
249 |
esc_html( $group )
|
250 |
);
|
251 |
}
|
254 |
submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
|
255 |
echo '</div>';
|
256 |
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Saves the strings translations in DB
|
260 |
+
* Optionaly clean the DB
|
261 |
+
*
|
262 |
+
* @since 1.9
|
263 |
+
*/
|
264 |
+
public function save_translations() {
|
265 |
+
check_admin_referer( 'string-translation', '_wpnonce_string-translation' );
|
266 |
+
|
267 |
+
if ( ! empty( $_POST['submit'] ) ) {
|
268 |
+
foreach ( $this->languages as $language ) {
|
269 |
+
if ( empty( $_POST['translation'][ $language->slug ] ) ) { // in case the language filter is active ( thanks to John P. Bloch )
|
270 |
+
continue;
|
271 |
+
}
|
272 |
+
|
273 |
+
$mo = new PLL_MO();
|
274 |
+
$mo->import_from_db( $language );
|
275 |
+
|
276 |
+
foreach ( $_POST['translation'][ $language->slug ] as $key => $translation ) {
|
277 |
+
/*
|
278 |
+
* Filter the string translation before it is saved in DB
|
279 |
+
* Allows to sanitize strings registered with pll_register_string
|
280 |
+
*
|
281 |
+
* @since 1.6
|
282 |
+
*
|
283 |
+
* @param string $translation the string translation
|
284 |
+
* @param string $name the name as defined in pll_register_string
|
285 |
+
* @param string $context the context as defined in pll_register_string
|
286 |
+
*/
|
287 |
+
$translation = apply_filters( 'pll_sanitize_string_translation', $translation, $this->strings[ $key ]['name'], $this->strings[ $key ]['context'] );
|
288 |
+
$mo->add_entry( $mo->make_entry( $this->strings[ $key ]['string'], $translation ) );
|
289 |
+
}
|
290 |
+
|
291 |
+
// clean database ( removes all strings which were registered some day but are no more )
|
292 |
+
if ( ! empty( $_POST['clean'] ) ) {
|
293 |
+
$new_mo = new PLL_MO();
|
294 |
+
|
295 |
+
foreach ( $this->strings as $string ) {
|
296 |
+
$new_mo->add_entry( $mo->make_entry( $string['string'], $mo->translate( $string['string'] ) ) );
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
isset( $new_mo ) ? $new_mo->export_to_db( $language ) : $mo->export_to_db( $language );
|
301 |
+
}
|
302 |
+
|
303 |
+
add_settings_error( 'general', 'pll_strings_translations_updated', __( 'Translations updated.', 'polylang' ), 'updated' );
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Fires after the strings translations are saved in DB
|
307 |
+
*
|
308 |
+
* @since 1.2
|
309 |
+
*/
|
310 |
+
do_action( 'pll_save_strings_translations' );
|
311 |
+
}
|
312 |
+
|
313 |
+
// unregisters strings registered through WPML API
|
314 |
+
if ( $this->current_action() === 'delete' && ! empty( $_POST['strings'] ) && function_exists( 'icl_unregister_string' ) ) {
|
315 |
+
foreach ( $_POST['strings'] as $key ) {
|
316 |
+
icl_unregister_string( $this->strings[ $key ]['context'], $this->strings[ $key ]['name'] );
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
+
// to refresh the page ( possible thanks to the $_GET['noheader']=true )
|
321 |
+
$args = array_intersect_key( $_REQUEST, array_flip( array( 's', 'paged', 'group' ) ) );
|
322 |
+
if ( ! empty( $args['s'] ) ) {
|
323 |
+
$args['s'] = urlencode( $args['s'] ); // searched string needs to be encoded as it comes from $_POST
|
324 |
+
}
|
325 |
+
PLL_Settings::redirect( $args );
|
326 |
+
}
|
327 |
}
|
settings/view-about.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
* displays the content of the About metabox
|
4 |
*/
|
5 |
|
@@ -10,37 +11,25 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
10 |
<p><?php
|
11 |
printf(
|
12 |
/* translators: %s are html tags */
|
13 |
-
__( 'Polylang is provided with an extensive %sdocumentation%s (in English only). It includes information on how to set up your multilingual site and use it on a daily basis, a FAQ, as well as a documentation for
|
14 |
-
'<a href="
|
15 |
'</a>'
|
16 |
);
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
23 |
</p>
|
24 |
<p><?php
|
25 |
printf(
|
26 |
/* translators: %s are html tags */
|
27 |
-
__( 'Polylang is
|
28 |
'<a href="http://wordpress.org/about/gpl/">',
|
29 |
'</a>'
|
30 |
);
|
31 |
-
|
32 |
-
printf(
|
33 |
-
/* translators: %s are html tags */
|
34 |
-
__( 'If you wonder how you can help the project, just %sread this%s.', 'polylang' ),
|
35 |
-
'<a href="http://polylang.wordpress.com/documentation/contribute/">',
|
36 |
-
'</a>'
|
37 |
-
);
|
38 |
-
echo ' ';
|
39 |
-
_e( 'Finally if you like this plugin or if it helps your business, donations to the author are greatly appreciated.', 'polylang' )?>
|
40 |
-
</p>
|
41 |
-
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
42 |
-
<input type="hidden" name="cmd" value="_s-xclick">
|
43 |
-
<input type="hidden" name="hosted_button_id" value="CCWWYUUQV8F4E">
|
44 |
-
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
45 |
-
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
46 |
-
</form>
|
1 |
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
* displays the content of the About metabox
|
5 |
*/
|
6 |
|
11 |
<p><?php
|
12 |
printf(
|
13 |
/* translators: %s are html tags */
|
14 |
+
__( 'Polylang is provided with an extensive %sdocumentation%s (in English only). It includes information on how to set up your multilingual site and use it on a daily basis, a FAQ, as well as a documentation for developers to adapt their plugins and themes.', 'polylang' ),
|
15 |
+
'<a href="https://polylang.pro/doc/">',
|
16 |
'</a>'
|
17 |
);
|
18 |
+
if ( ! defined( 'POLYLANG_PRO' ) ) {
|
19 |
+
echo ' ';
|
20 |
+
printf(
|
21 |
+
/* translators: %s are html tags */
|
22 |
+
__( 'Support and extra features are available to %sPolylang Pro%s users.' ),
|
23 |
+
'<a href="https://polylang.pro">',
|
24 |
+
'</a>'
|
25 |
+
);
|
26 |
+
}?>
|
27 |
</p>
|
28 |
<p><?php
|
29 |
printf(
|
30 |
/* translators: %s are html tags */
|
31 |
+
__( 'Polylang is released under the same license as WordPress, the %sGPL%s.', 'polylang' ),
|
32 |
'<a href="http://wordpress.org/about/gpl/">',
|
33 |
'</a>'
|
34 |
);
|
35 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings/view-languages.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
* displays the Languages admin panel
|
4 |
*/
|
5 |
|
@@ -29,6 +30,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
29 |
break;
|
30 |
|
31 |
default:
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
do_action( 'pll_settings_active_tab_' . $this->active_tab );
|
33 |
break;
|
34 |
}?>
|
1 |
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
* displays the Languages admin panel
|
5 |
*/
|
6 |
|
30 |
break;
|
31 |
|
32 |
default:
|
33 |
+
/**
|
34 |
+
* Fires when loading the active Polylang settings tab
|
35 |
+
* Allows plugins to add their own tab
|
36 |
+
*
|
37 |
+
* @since 1.5.1
|
38 |
+
*/
|
39 |
do_action( 'pll_settings_active_tab_' . $this->active_tab );
|
40 |
break;
|
41 |
}?>
|
settings/view-tab-lang.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
* displays the languages tab in Polylang settings
|
4 |
*/
|
5 |
|
@@ -125,8 +126,20 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
125 |
</div><?php
|
126 |
|
127 |
if ( ! empty( $edit_lang ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
do_action( 'pll_language_edit_form_fields', $edit_lang );
|
129 |
} else {
|
|
|
|
|
|
|
|
|
|
|
130 |
do_action( 'pll_language_add_form_fields' );
|
131 |
}
|
132 |
|
1 |
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
* displays the languages tab in Polylang settings
|
5 |
*/
|
6 |
|
126 |
</div><?php
|
127 |
|
128 |
if ( ! empty( $edit_lang ) ) {
|
129 |
+
/**
|
130 |
+
* Fires after the Edit Language form fields are displayed.
|
131 |
+
*
|
132 |
+
* @since 1.7.10
|
133 |
+
*
|
134 |
+
* @param object $lang language being edited.
|
135 |
+
*/
|
136 |
do_action( 'pll_language_edit_form_fields', $edit_lang );
|
137 |
} else {
|
138 |
+
/**
|
139 |
+
* Fires after the Add Language form fields are displayed.
|
140 |
+
*
|
141 |
+
* @since 1.7.10
|
142 |
+
*/
|
143 |
do_action( 'pll_language_add_form_fields' );
|
144 |
}
|
145 |
|
settings/view-tab-settings.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
* displays the settings tab in Polylang settings
|
4 |
*/
|
5 |
|
1 |
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
* displays the settings tab in Polylang settings
|
5 |
*/
|
6 |
|
settings/view-tab-strings.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
3 |
* displays the strings translations tab in Polylang settings
|
4 |
*/
|
5 |
|
1 |
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
* displays the strings translations tab in Polylang settings
|
5 |
*/
|
6 |
|
uninstall.php
CHANGED
@@ -5,7 +5,7 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
5 |
exit();
|
6 |
}
|
7 |
|
8 |
-
|
9 |
* manages Polylang uninstallation
|
10 |
* the goal is to remove ALL Polylang related data in db
|
11 |
*
|
@@ -13,7 +13,7 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
13 |
*/
|
14 |
class PLL_Uninstall {
|
15 |
|
16 |
-
|
17 |
* constructor: manages uninstall for multisite
|
18 |
*
|
19 |
* @since 0.5
|
@@ -34,7 +34,7 @@ class PLL_Uninstall {
|
|
34 |
}
|
35 |
}
|
36 |
|
37 |
-
|
38 |
* removes ALL plugin data
|
39 |
* only when the relevant option is active
|
40 |
*
|
@@ -129,10 +129,12 @@ class PLL_Uninstall {
|
|
129 |
delete_option( 'polylang' );
|
130 |
delete_option( 'widget_polylang' ); // automatically created by WP
|
131 |
delete_option( 'polylang_wpml_strings' ); // strings registered with icl_register_string
|
|
|
132 |
|
133 |
//delete transients
|
134 |
delete_transient( 'pll_languages_list' );
|
135 |
delete_transient( 'pll_upgrade_1_4' );
|
|
|
136 |
}
|
137 |
}
|
138 |
|
5 |
exit();
|
6 |
}
|
7 |
|
8 |
+
/**
|
9 |
* manages Polylang uninstallation
|
10 |
* the goal is to remove ALL Polylang related data in db
|
11 |
*
|
13 |
*/
|
14 |
class PLL_Uninstall {
|
15 |
|
16 |
+
/**
|
17 |
* constructor: manages uninstall for multisite
|
18 |
*
|
19 |
* @since 0.5
|
34 |
}
|
35 |
}
|
36 |
|
37 |
+
/**
|
38 |
* removes ALL plugin data
|
39 |
* only when the relevant option is active
|
40 |
*
|
129 |
delete_option( 'polylang' );
|
130 |
delete_option( 'widget_polylang' ); // automatically created by WP
|
131 |
delete_option( 'polylang_wpml_strings' ); // strings registered with icl_register_string
|
132 |
+
delete_option( 'polylang_licenses' );
|
133 |
|
134 |
//delete transients
|
135 |
delete_transient( 'pll_languages_list' );
|
136 |
delete_transient( 'pll_upgrade_1_4' );
|
137 |
+
delete_transient( 'pll_translated_slugs' );
|
138 |
}
|
139 |
}
|
140 |
|