Version Description
(2016-01-19) =
- Minimum WordPress version is now 4.0
- Add ary, bn_BD, en_ZA, es_AR, fr_CA and fr_BE to the predefined languages list
- Adopt WordPress coding standards
- New structure for translated posts and terms (=> several methods of PLL_Model are deprecated).
- Revamp the management of the static front page and page for posts
- Improve performance for navigation menus with a lot of pages
- The Polylang and WPML API are now loaded when 'plugins_loaded' is fired (on frontend only if at least one language has been defined)
- Add 'pll_get_post_translations()' and 'pll_get_term_translations()' to the API
- Add filter 'pll_cookie_expiration' to change the cookie expiration time
- Add support for 'wpml_get_language_information' function from the WPML API
- The default language is now managed directly from the languages list table
- Various accessibility improvements
- It is now possible to choose the languages flags from the available list (custom flags on frontend still work as previously)
- Revamp the settings page (now a list table with inline configuration)
- Add an option to remove all data when uninstalling the plugin
- Add test of subdomains and domains accessibility
- Add post state for translations of the front page and posts page
- Add better support of the customizer menus introduced in WP 4.3
- Media taxonomies (created by 3rd party plugins) are now filtered by language when editing a media
- Synchronization of taxonomies (created by 3rd party plugins) and meta are now enabled for media
- The 'hreflang' tag now refers to the locale instead of the 2-letters language code
- Workaround for WordPress locales not being W3C valid (see #33511)
- Workaround a bug in Nextgen Gallery causing redirect on album
- Add compatibility with Duplicate Post plugin to avoid duplicated post keeping the link to translations
- Add compatibility with Jetpack Related Posts
- fix: incorrect rewrite rules after changing how the language is set (need to flush rewrite rules after this)
- fix: password protected pages don't work on multiple domains
- fix: ensure that the page parent is in the correct language when using bulk edit
- fix: is_tax set on category and post tags archives when it should not
- fix: automatically added new top-level pages to menus are not filtered by language
- fix: nav menus locations are messed when changing the default language
- fix: error 404 for untranslated taxonomies pages
- fix: single posts and pages links do not include the language code when using the default permalinks and forcing the language code in url
- fix: missing trailing slash on home url when using default permalinks or a static front page
- fix: sticky visibility is copied to new translation only if the synchronization is activated
- fix: remove " Languages [language name]" from the feed title
- fix: spaces are not honored when searching strings translations
- fix: default language not set and terms translations not correctly imported when using WordPress Importer
- fix: the browser language detection does not differentiate 'en_US' and 'en_GB'
- fix: non alphanumeric characters query vars values lead to an infinite redirection loop on static front pages
- fix: user profile not saved for a language when the language code contains a "-"
- fix: non translated posts page always link to the static front page even when they should not
- fix: remove hreflang="x-default" when using one domain per language
- fix: deprecated function notice in WP 4.5 alpha
- fix: wrong url for attachments when media are translated and using subdomains
- fix: wrong url for unattached attachments when using subdirectories (since WP 4.4)
- fix: wrong url scheme for custom flags
See changelog.txt for older changelog
Download this release
Release Info
Developer | Chouby |
Plugin | Polylang |
Version | 1.8 |
Comparing to | |
See all releases |
Code changes from version 1.7.12 to 1.8
- admin/admin-base.php +271 -0
- admin/admin-filters-columns.php +130 -101
- admin/admin-filters-media.php +67 -75
- admin/admin-filters-post-base.php +18 -19
- admin/admin-filters-post.php +218 -183
- admin/admin-filters-term.php +280 -255
- admin/admin-filters.php +51 -84
- admin/admin-links.php +156 -0
- admin/admin-model.php +234 -173
- admin/admin-nav-menu.php +130 -97
- admin/admin-static-pages.php +89 -0
- admin/admin-strings.php +45 -36
- admin/admin-sync.php +0 -270
- admin/admin.php +26 -339
- admin/languages.php +0 -102
- admin/settings.php +0 -352
- admin/table-languages.php +0 -139
- admin/table-string.php +0 -203
- admin/view-about.php +0 -34
- admin/view-languages.php +0 -31
- admin/view-tab-lang.php +0 -120
- admin/view-tab-settings.php +0 -233
- admin/view-tab-strings.php +0 -15
- admin/view-translations-media.php +21 -18
- admin/view-translations-post.php +34 -25
- admin/view-translations-term.php +43 -33
- admin/wp-import.php +0 -172
- changelog.txt +156 -0
- css/admin.css +139 -21
- css/admin.min.css +1 -1
- css/selectmenu.css +140 -0
- css/selectmenu.min.css +1 -0
- flags/ad.png +0 -0
- flags/ae.png +0 -0
- flags/af.png +0 -0
- flags/ag.png +0 -0
- flags/ai.png +0 -0
- flags/{sq.png → al.png} +0 -0
- flags/{hy.png → am.png} +0 -0
- flags/an.png +0 -0
- flags/ao.png +0 -0
- flags/ar.png +0 -0
- flags/arab.png +0 -0
- flags/as.png +0 -0
- flags/at.png +0 -0
- flags/{en_AU.png → au.png} +0 -0
- flags/aw.png +0 -0
- flags/ax.png +0 -0
- flags/{bs_BA.png → ba.png} +0 -0
- flags/{eu.png → basque.png} +0 -0
- flags/bb.png +0 -0
- flags/bd.png +0 -0
- flags/be.png +0 -0
- flags/bf.png +0 -0
- flags/{bg_BG.png → bg.png} +0 -0
- flags/bh.png +0 -0
- flags/bi.png +0 -0
- flags/bj.png +0 -0
- flags/bm.png +0 -0
- flags/bn.png +0 -0
- flags/bo.png +0 -0
- flags/{pt_BR.png → br.png} +0 -0
- flags/bs.png +0 -0
- flags/bt.png +0 -0
- flags/bw.png +0 -0
- flags/{bel.png → by.png} +0 -0
- flags/bz.png +0 -0
- flags/ca.png +0 -0
- flags/catalonia.png +0 -0
- flags/cc.png +0 -0
- flags/cd.png +0 -0
- flags/cf.png +0 -0
- flags/cg.png +0 -0
- flags/{de_CH.png → ch.png} +0 -0
- flags/ci.png +0 -0
- flags/ck.png +0 -0
- flags/{es_CL.png → cl.png} +0 -0
- flags/cm.png +0 -0
- flags/{ug_CN.png → cn.png} +0 -0
- flags/{es_CO.png → co.png} +0 -0
- flags/cr.png +0 -0
- flags/cu.png +0 -0
- flags/cv.png +0 -0
- flags/cx.png +0 -0
- flags/cy.png +0 -0
- flags/{cs_CZ.png → cz.png} +0 -0
- flags/{de_DE.png → de.png} +0 -0
- flags/de_DE_formal.png +0 -0
- flags/dj.png +0 -0
- flags/{da_DK.png → dk.png} +0 -0
- flags/dm.png +0 -0
- flags/do.png +0 -0
- flags/dz.png +0 -0
- flags/ec.png +0 -0
- flags/ee.png +0 -0
- flags/eg.png +0 -0
- flags/eh.png +0 -0
- flags/en_CA.png +0 -0
- flags/england.png +0 -0
- flags/er.png +0 -0
- flags/{es_ES.png → es.png} +0 -0
- flags/es_AR.png +0 -0
- flags/{eo.png → esperanto.png} +0 -0
- flags/et.png +0 -0
- flags/fa_AF.png +0 -0
- flags/fi.png +0 -0
- flags/fj.png +0 -0
- flags/fk.png +0 -0
- flags/fm.png +0 -0
- flags/fo.png +0 -0
- flags/{fr_FR.png → fr.png} +0 -0
- flags/ga.png +0 -0
- flags/{gl_ES.png → galicia.png} +0 -0
- flags/{en_GB.png → gb.png} +0 -0
- flags/gd.png +0 -0
- flags/{ka_GE.png → ge.png} +0 -0
- flags/gh.png +0 -0
- flags/gi.png +0 -0
- flags/gl.png +0 -0
- flags/gm.png +0 -0
- flags/gn.png +0 -0
- flags/gp.png +0 -0
- flags/gq.png +0 -0
- flags/{el.png → gr.png} +0 -0
- flags/gs.png +0 -0
- flags/gt.png +0 -0
- flags/gu.png +0 -0
- flags/gw.png +0 -0
- flags/gy.png +0 -0
- flags/haz.png +0 -0
- flags/{zh_HK.png → hk.png} +0 -0
- flags/hm.png +0 -0
- flags/hn.png +0 -0
- flags/hr.png +0 -0
- flags/ht.png +0 -0
- flags/{hu_HU.png → hu.png} +0 -0
- flags/{id_ID.png → id.png} +0 -0
- flags/ie.png +0 -0
- flags/{he_IL.png → il.png} +0 -0
- flags/{hi_IN.png → in.png} +0 -0
- flags/io.png +0 -0
- flags/iq.png +0 -0
- flags/{fa_IR.png → ir.png} +0 -0
- flags/{is_IS.png → is.png} +0 -0
- flags/{it_IT.png → it.png} +0 -0
- flags/jm.png +0 -0
- flags/jo.png +0 -0
- flags/{ja.png → jp.png} +0 -0
- flags/jv_ID.png +0 -0
- flags/ke.png +0 -0
- flags/kg.png +0 -0
- flags/kh.png +0 -0
- flags/ki.png +0 -0
- flags/km.png +0 -0
- flags/kn.png +0 -0
- flags/kp.png +0 -0
- flags/{ko_KR.png → kr.png} +0 -0
- flags/{ckb.png → kurdistan.png} +0 -0
- flags/kw.png +0 -0
- flags/ky.png +0 -0
- flags/{kk.png → kz.png} +0 -0
- flags/{lo.png → la.png} +0 -0
- flags/lb.png +0 -0
- flags/lc.png +0 -0
- flags/li.png +0 -0
- flags/{si_LK.png → lk.png} +0 -0
- flags/lr.png +0 -0
- flags/ls.png +0 -0
- flags/{lt_LT.png → lt.png} +0 -0
- flags/lu.png +0 -0
- flags/lv.png +0 -0
- flags/ly.png +0 -0
- flags/ma.png +0 -0
- flags/mc.png +0 -0
- flags/md.png +0 -0
- flags/me.png +0 -0
- flags/mg.png +0 -0
- flags/mh.png +0 -0
- flags/{mk_MK.png → mk.png} +0 -0
- flags/ml.png +0 -0
- flags/mm.png +0 -0
- flags/mo.png +0 -0
- flags/mp.png +0 -0
- flags/mq.png +0 -0
- flags/mr.png +0 -0
- flags/ms.png +0 -0
- flags/mt.png +0 -0
- flags/mu.png +0 -0
- flags/mv.png +0 -0
- flags/mw.png +0 -0
- flags/{es_MX.png → mx.png} +0 -0
- flags/{ms_MY.png → my.png} +0 -0
- flags/my_MM.png +0 -0
- flags/mz.png +0 -0
- flags/na.png +0 -0
- flags/nc.png +0 -0
- flags/ne.png +0 -0
- flags/nf.png +0 -0
- flags/ng.png +0 -0
- flags/ni.png +0 -0
- flags/{fy.png → nl.png} +0 -0
- flags/nl_NL.png +0 -0
- flags/nn_NO.png +0 -0
- flags/{nb_NO.png → no.png} +0 -0
- flags/{ne_NP.png → np.png} +0 -0
- flags/nr.png +0 -0
- flags/nu.png +0 -0
- flags/{en_NZ.png → nz.png} +0 -0
- flags/{oci.png → occitania.png} +0 -0
- flags/om.png +0 -0
- flags/pa.png +0 -0
- flags/{es_PE.png → pe.png} +0 -0
- flags/pf.png +0 -0
- flags/pg.png +0 -0
- flags/ph.png +0 -0
- flags/{ur.png → pk.png} +0 -0
- flags/{pl_PL.png → pl.png} +0 -0
- flags/pm.png +0 -0
- flags/pn.png +0 -0
- flags/pr.png +0 -0
- flags/ps.png +0 -0
- flags/{pt_PT.png → pt.png} +0 -0
- flags/pw.png +0 -0
- flags/py.png +0 -0
- flags/qa.png +0 -0
- flags/quebec.png +0 -0
- flags/{ro_RO.png → ro.png} +0 -0
- flags/{sr_RS.png → rs.png} +0 -0
- flags/{ru_RU.png → ru.png} +0 -0
- flags/rw.png +0 -0
- flags/sa.png +0 -0
- flags/sb.png +0 -0
- flags/sc.png +0 -0
- flags/scotland.png +0 -0
- flags/sd.png +0 -0
- flags/{sv_SE.png → se.png} +0 -0
- flags/sg.png +0 -0
- flags/sh.png +0 -0
- flags/{sl_SI.png → si.png} +0 -0
- flags/{sk_SK.png → sk.png} +0 -0
- flags/sl.png +0 -0
- flags/sm.png +0 -0
- flags/sn.png +0 -0
- flags/{so_SO.png → so.png} +0 -0
- flags/sr.png +0 -0
- flags/ss.png +0 -0
- flags/st.png +0 -0
- flags/su_ID.png +0 -0
- flags/sv.png +0 -0
- flags/sy.png +0 -0
- flags/sz.png +0 -0
- flags/ta_LK.png +0 -0
- flags/tc.png +0 -0
- flags/td.png +0 -0
- flags/tf.png +0 -0
- flags/tg.png +0 -0
- flags/th.png +0 -0
- flags/tj.png +0 -0
- flags/tk.png +0 -0
- flags/tl.png +0 -0
- flags/tm.png +0 -0
- flags/tn.png +0 -0
- flags/to.png +0 -0
- flags/{tr_TR.png → tr.png} +0 -0
- flags/tt.png +0 -0
- flags/tv.png +0 -0
- flags/{zh_TW.png → tw.png} +0 -0
- flags/tz.png +0 -0
- flags/{uk.png → ua.png} +0 -0
- flags/ug.png +0 -0
- flags/{en_US.png → us.png} +0 -0
- flags/uy.png +0 -0
- flags/{uz_UZ.png → uz.png} +0 -0
- flags/va.png +0 -0
- flags/vc.png +0 -0
- flags/{es_VE.png → ve.png} +0 -0
- flags/vec.png +0 -0
- flags/veneto.png +0 -0
- flags/vg.png +0 -0
- flags/vi.png +0 -0
- flags/vn.png +0 -0
- flags/vu.png +0 -0
- flags/wales.png +0 -0
- flags/wf.png +0 -0
- flags/ws.png +0 -0
- flags/ye.png +0 -0
- flags/yt.png +0 -0
- flags/za.png +0 -0
- flags/zh_CN.png +0 -0
- flags/zm.png +0 -0
- flags/zw.png +0 -0
- frontend/choose-lang-content.php +39 -36
- frontend/choose-lang-domain.php +3 -2
- frontend/choose-lang-url.php +62 -23
- frontend/choose-lang.php +122 -148
- frontend/frontend-auto-translate.php +109 -77
- frontend/frontend-filters-links.php +362 -0
- frontend/frontend-filters-search.php +38 -34
- frontend/frontend-filters.php +80 -73
- frontend/frontend-links.php +79 -483
- frontend/frontend-nav-menu.php +94 -51
- frontend/frontend-static-pages.php +272 -0
- frontend/frontend.php +79 -51
- include/api.php +110 -90
- include/base.php +34 -31
- include/cache.php +14 -9
- include/class-polylang.php +190 -0
- include/filters-links.php +141 -0
- include/filters.php +50 -27
- include/language.php +92 -52
- include/links-default.php +19 -16
- include/links-directory.php +80 -71
- include/links-domain.php +43 -10
- include/links-model.php +86 -5
- include/links-permalinks.php +55 -8
- include/links-subdomain.php +21 -29
- include/links.php +10 -190
- include/mo.php +21 -21
- include/model.php +264 -638
- include/nav-menu.php +40 -7
- include/olt-manager.php +60 -54
- include/plugins-compat.php +0 -402
- include/pointer.php +31 -30
- include/static-pages.php +66 -0
- include/switcher.php +56 -99
- include/translated-object.php +263 -0
- include/translated-post.php +127 -0
- include/translated-term.php +161 -0
- include/walker-dropdown.php +15 -15
- include/walker-list.php +53 -0
- include/widget-calendar.php +57 -56
- include/widget-languages.php +52 -49
- include/widget-recent-comments.php +7 -17
- include/widget-recent-posts.php +7 -17
- include/wpml-compat.php +0 -365
- include/wpml-config.php +0 -341
- index.php +0 -3
- install/install-base.php +20 -19
- install/install.php +46 -38
- install/upgrade.php +202 -156
- js/admin.js +166 -37
- js/admin.min.js +1 -1
- js/media.js +4 -4
- js/nav-menu.js +45 -45
- js/nav-menu.min.js +1 -1
- js/post.js +237 -263
- js/post.min.js +1 -1
- js/term.js +159 -157
- js/term.min.js +1 -1
- js/user.js +12 -12
- js/user.min.js +1 -1
- languages/polylang-da_DK.mo +0 -0
- languages/polylang-da_DK.po +0 -585
- languages/polylang-el.mo +0 -0
- languages/polylang-el.po +0 -675
- languages/polylang-fr_FR.mo +0 -0
- languages/polylang-fr_FR.po +0 -701
- languages/polylang-gl_ES.mo +0 -0
- languages/polylang-gl_ES.po +0 -667
- languages/polylang-it_IT.mo +0 -0
- languages/polylang-it_IT.po +0 -600
- languages/polylang-ja.mo +0 -0
- languages/polylang-ja.po +0 -612
- languages/polylang-nl_NL.mo +0 -0
- languages/polylang-nl_NL.po +0 -656
- languages/polylang-pt_PT.mo +0 -0
- languages/polylang-pt_PT.po +0 -701
- languages/polylang-ro_RO.mo +0 -0
- languages/polylang-ro_RO.po +0 -676
- languages/polylang-sk_SK.mo +0 -0
- languages/polylang-sk_SK.po +0 -668
- languages/polylang-sv_SE.mo +0 -0
- languages/polylang-sv_SE.po +0 -661
- languages/polylang.pot +0 -640
- lingotek/lingotek.php +58 -52
admin/admin-base.php
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* base class for both admin
|
5 |
+
*
|
6 |
+
* @since 1.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 |
+
*
|
15 |
+
* @since 1.8
|
16 |
+
*
|
17 |
+
* @param object $links_model
|
18 |
+
*/
|
19 |
+
public function __construct( &$links_model ) {
|
20 |
+
parent::__construct( $links_model );
|
21 |
+
|
22 |
+
// plugin i18n, only needed for backend
|
23 |
+
load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ).'/languages' );
|
24 |
+
|
25 |
+
// adds the link to the languages panel in the WordPress admin menu
|
26 |
+
add_action( 'admin_menu', array( &$this, 'add_menus' ) );
|
27 |
+
|
28 |
+
// setup js scripts and css styles
|
29 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
|
30 |
+
add_action( 'admin_print_footer_scripts', array( &$this, 'admin_print_footer_scripts' ) );
|
31 |
+
|
32 |
+
// Lingotek
|
33 |
+
if ( ! defined( 'PLL_LINGOTEK_AD' ) || PLL_LINGOTEK_AD ) {
|
34 |
+
require_once( POLYLANG_DIR . '/lingotek/lingotek.php' );
|
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 |
+
*
|
42 |
+
* @since 1.2
|
43 |
+
*
|
44 |
+
* @param object $links_model
|
45 |
+
*/
|
46 |
+
public function init() {
|
47 |
+
if ( ! $this->model->get_languages_list() ) {
|
48 |
+
return;
|
49 |
+
}
|
50 |
+
|
51 |
+
$this->links = new PLL_Admin_Links( $this ); // FIXME needed here ?
|
52 |
+
$this->static_pages = new PLL_Admin_Static_Pages( $this ); // FIXME needed here ?
|
53 |
+
$this->filters_links = new PLL_Filters_Links( $this ); // FIXME needed here ?
|
54 |
+
|
55 |
+
// filter admin language for users
|
56 |
+
// we must not call user info before WordPress defines user roles in wp-settings.php
|
57 |
+
add_filter( 'setup_theme', array( &$this, 'init_user' ) );
|
58 |
+
add_filter( 'request', array( &$this, 'request' ) );
|
59 |
+
|
60 |
+
// adds the languages in admin bar
|
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
|
68 |
+
*/
|
69 |
+
public function add_menus() {
|
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
|
77 |
+
*/
|
78 |
+
public function admin_enqueue_scripts() {
|
79 |
+
$screen = get_current_screen();
|
80 |
+
if ( empty( $screen ) ) {
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
85 |
+
|
86 |
+
// for each script:
|
87 |
+
// 0 => the pages on which to load the script
|
88 |
+
// 1 => the scripts it needs to work
|
89 |
+
// 2 => 1 if loaded even if languages have not been defined yet, 0 otherwise
|
90 |
+
// 3 => 1 if loaded in footer
|
91 |
+
// FIXME: check if I can load more scripts in footer
|
92 |
+
$scripts = array(
|
93 |
+
'post' => array( array( 'post', 'media', 'async-upload', 'edit' ), array( 'jquery', 'wp-ajax-response', 'post', 'jquery-ui-autocomplete' ), 0 , 1 ),
|
94 |
+
'media' => array( array( 'upload' ), array( 'jquery' ), 0 , 1 ),
|
95 |
+
'term' => array( array( 'edit-tags' ), array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), 0, 1 ),
|
96 |
+
'user' => array( array( 'profile', 'user-edit' ), array( 'jquery' ), 0 , 0 ),
|
97 |
+
);
|
98 |
+
|
99 |
+
foreach ( $scripts as $script => $v ) {
|
100 |
+
if ( in_array( $screen->base, $v[0] ) && ( $v[2] || $this->model->get_languages_list() ) ) {
|
101 |
+
wp_enqueue_script( 'pll_'.$script, POLYLANG_URL .'/js/'.$script.$suffix.'.js', $v[1], POLYLANG_VERSION, $v[3] );
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
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 |
+
*
|
112 |
+
* takes care to various situations:
|
113 |
+
* when the ajax request has no options.data thanks to ScreenfeedFr
|
114 |
+
* see: https://wordpress.org/support/topic/ajaxprefilter-may-not-work-as-expected
|
115 |
+
* when options.data is a json string
|
116 |
+
* see: https://wordpress.org/support/topic/polylang-breaking-third-party-ajax-requests-on-admin-panels
|
117 |
+
* when options.data is an empty string (GET request with the method 'load')
|
118 |
+
* see: https://wordpress.org/support/topic/invalid-url-during-wordpress-new-dashboard-widget-operation
|
119 |
+
*
|
120 |
+
* @since 1.4
|
121 |
+
*/
|
122 |
+
public function admin_print_footer_scripts() {
|
123 |
+
global $post_ID;
|
124 |
+
|
125 |
+
$params = array( 'pll_ajax_backend' => 1 );
|
126 |
+
if ( ! empty( $post_ID ) ) {
|
127 |
+
$params = array_merge( $params, array( 'pll_post_id' => (int) $post_ID ) );
|
128 |
+
}
|
129 |
+
|
130 |
+
$str = $arr = '';
|
131 |
+
foreach ( $params as $k => $v ) {
|
132 |
+
$str .= ( empty( $str ) ? '' : '&' ) . $k . '=' . $v;
|
133 |
+
$arr .= ( empty( $arr ) ? '' : ', ') . $k . ': ' . $v;
|
134 |
+
}
|
135 |
+
?>
|
136 |
+
<script type="text/javascript">
|
137 |
+
if (typeof jQuery != 'undefined') {
|
138 |
+
(function($){
|
139 |
+
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
|
140 |
+
if (options.url.indexOf(ajaxurl) != -1) {
|
141 |
+
if ( typeof options.data === 'undefined' ) {
|
142 |
+
options.data = options.type.toLowerCase() === "get" ? '<?php echo $str;?>' : {<?php echo $arr;?>};
|
143 |
+
}
|
144 |
+
else {
|
145 |
+
if (typeof options.data === "string") {
|
146 |
+
if ( '' === options.data && "get" === options.type.toLowerCase() ) {
|
147 |
+
options.url = options.url+'<?php echo '&' . $str;?>';
|
148 |
+
}
|
149 |
+
else {
|
150 |
+
try {
|
151 |
+
o = $.parseJSON(options.data);
|
152 |
+
o = $.extend(o, {<?php echo $arr;?>});
|
153 |
+
options.data = JSON.stringify(o);
|
154 |
+
}
|
155 |
+
catch(e) {
|
156 |
+
options.data = '<?php echo $str . '&';?>'+options.data;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
else {
|
161 |
+
options.data = $.extend(options.data, {<?php echo $arr;?>});
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
});
|
166 |
+
})(jQuery)
|
167 |
+
}
|
168 |
+
</script><?php
|
169 |
+
|
170 |
+
}
|
171 |
+
|
172 |
+
/*
|
173 |
+
* defines the backend language and the admin language filter based on user preferences
|
174 |
+
*
|
175 |
+
* @since 1.2.3
|
176 |
+
*/
|
177 |
+
public function init_user() {
|
178 |
+
// backend locale
|
179 |
+
add_filter( 'locale', array( &$this, 'get_locale' ) );
|
180 |
+
|
181 |
+
// language for admin language filter: may be empty
|
182 |
+
// $_GET['lang'] is numeric when editing a language, not when selecting a new language in the filter
|
183 |
+
if ( ! defined( 'DOING_AJAX' ) && ! empty( $_GET['lang'] ) && ! is_numeric( $_GET['lang'] ) && current_user_can( 'edit_user', $user_id = get_current_user_id() ) ) {
|
184 |
+
update_user_meta( $user_id, 'pll_filter_content', ( $lang = $this->model->get_language( $_GET['lang'] ) ) ? $lang->slug : '' );
|
185 |
+
}
|
186 |
+
|
187 |
+
$this->curlang = $this->model->get_language( get_user_meta( get_current_user_id(), 'pll_filter_content', true ) );
|
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
|
208 |
+
*
|
209 |
+
* @since 1.6.5
|
210 |
+
*
|
211 |
+
* @param array $qvars
|
212 |
+
* @return array
|
213 |
+
*/
|
214 |
+
public function request( $qvars ) {
|
215 |
+
if ( isset( $qvars['lang'] ) && 'all' === $qvars['lang'] ) {
|
216 |
+
unset( $qvars['lang'] );
|
217 |
+
}
|
218 |
+
|
219 |
+
return $qvars;
|
220 |
+
}
|
221 |
+
|
222 |
+
/*
|
223 |
+
* get the locale based on user preference
|
224 |
+
*
|
225 |
+
* @since 0.4
|
226 |
+
*
|
227 |
+
* @param string $locale
|
228 |
+
* @return string modified locale
|
229 |
+
*/
|
230 |
+
public function get_locale( $locale ) {
|
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
|
238 |
+
*
|
239 |
+
* @param object $wp_admin_bar
|
240 |
+
*/
|
241 |
+
public function admin_bar_menu( $wp_admin_bar ) {
|
242 |
+
$url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
243 |
+
|
244 |
+
$all_item = (object) array(
|
245 |
+
'slug' => 'all',
|
246 |
+
'name' => __( 'Show all languages', 'polylang' ),
|
247 |
+
'flag' => '<span class="ab-icon"></span>',
|
248 |
+
);
|
249 |
+
|
250 |
+
$selected = empty( $this->curlang ) ? $all_item : $this->curlang;
|
251 |
+
|
252 |
+
$wp_admin_bar->add_menu( array(
|
253 |
+
'id' => 'languages',
|
254 |
+
'title' => $selected->flag . '<span class="ab-label">'. esc_html( $selected->name ) . '</span>',
|
255 |
+
'meta' => array( 'title' => __( 'Filters content by language', 'polylang' ) ),
|
256 |
+
) );
|
257 |
+
|
258 |
+
foreach ( array_merge( array( $all_item ), $this->model->get_languages_list() ) as $lang ) {
|
259 |
+
if ( $selected->slug == $lang->slug ) {
|
260 |
+
continue;
|
261 |
+
}
|
262 |
+
|
263 |
+
$wp_admin_bar->add_menu( array(
|
264 |
+
'parent' => 'languages',
|
265 |
+
'id' => $lang->slug,
|
266 |
+
'title' => $lang->flag . esc_html( $lang->name ),
|
267 |
+
'href' => esc_url( add_query_arg( 'lang', $lang->slug, remove_query_arg( 'paged', $url ) ) ),
|
268 |
+
) );
|
269 |
+
}
|
270 |
+
}
|
271 |
+
}
|
admin/admin-filters-columns.php
CHANGED
@@ -16,32 +16,32 @@ class PLL_Admin_Filters_Columns {
|
|
16 |
*
|
17 |
* @param object $polylang
|
18 |
*/
|
19 |
-
public function __construct(&$polylang) {
|
20 |
$this->links = &$polylang->links;
|
21 |
$this->model = &$polylang->model;
|
22 |
$this->curlang = &$polylang->curlang;
|
23 |
|
24 |
// add the language and translations columns in 'All Posts', 'All Pages' and 'Media library' panels
|
25 |
-
foreach ($this->model->get_translated_post_types() as $type) {
|
26 |
// use the latest filter late as some plugins purely overwrite what's done by others :(
|
27 |
// specific case for media
|
28 |
-
add_filter('manage_'. (
|
29 |
-
add_action('manage_'. (
|
30 |
}
|
31 |
|
32 |
// quick edit and bulk edit
|
33 |
-
add_filter('quick_edit_custom_box', array(&$this, 'quick_edit_custom_box'), 10, 2);
|
34 |
-
add_filter('bulk_edit_custom_box', array(&$this, 'quick_edit_custom_box'), 10, 2);
|
35 |
|
36 |
// adds the language column in the 'Categories' and 'Post Tags' tables
|
37 |
-
foreach ($this->model->get_translated_taxonomies() as $tax) {
|
38 |
-
add_filter('manage_edit-'.$tax.'_columns', array(&$this, 'add_term_column'));
|
39 |
-
add_filter('manage_'.$tax.'_custom_column', array(&$this, 'term_column'), 10, 3);
|
40 |
}
|
41 |
|
42 |
// ajax responses to update list table rows
|
43 |
-
add_action('wp_ajax_pll_update_post_rows', array(&$this, 'ajax_update_post_rows'));
|
44 |
-
add_action('wp_ajax_pll_update_term_rows', array(&$this, 'ajax_update_term_rows'));
|
45 |
}
|
46 |
|
47 |
/*
|
@@ -53,20 +53,20 @@ class PLL_Admin_Filters_Columns {
|
|
53 |
* @param string $before the column before which we want to add our languages
|
54 |
* @return array modified list of columns
|
55 |
*/
|
56 |
-
protected function add_column($columns, $before) {
|
57 |
-
if ($n = array_search($before, array_keys($columns))) {
|
58 |
-
$end = array_slice($columns, $n);
|
59 |
-
$columns = array_slice($columns, 0, $n);
|
60 |
}
|
61 |
|
62 |
-
foreach ($this->model->get_languages_list() as $language) {
|
63 |
// don't add the column for the filtered language
|
64 |
-
if (empty($this->curlang) || $language->slug != $this->curlang->slug) {
|
65 |
-
$columns['language_'.$language->slug] = $language->flag ? $language->flag . '<span class="screen-reader-text">' . $language->name . '</span>' : esc_html($language->slug);
|
66 |
}
|
67 |
}
|
68 |
|
69 |
-
return isset($end) ? array_merge($columns, $end) : $columns;
|
70 |
}
|
71 |
|
72 |
/*
|
@@ -77,24 +77,25 @@ class PLL_Admin_Filters_Columns {
|
|
77 |
* @return string first language column name
|
78 |
*/
|
79 |
protected function get_first_language_column() {
|
80 |
-
foreach ($this->model->get_languages_list() as $language) {
|
81 |
-
if (empty($this->curlang) || $language->slug != $this->curlang->slug)
|
82 |
-
$columns[] = 'language_'
|
|
|
83 |
}
|
84 |
|
85 |
-
return empty($columns) ? '' : reset($columns);
|
86 |
}
|
87 |
|
88 |
/*
|
89 |
-
* adds the language and translations columns (before the comments column) in the posts, pages and media library tables
|
90 |
*
|
91 |
* @since 0.1
|
92 |
*
|
93 |
* @param array $columns list of posts table columns
|
94 |
* @return array modified list of columns
|
95 |
*/
|
96 |
-
function add_post_column($columns) {
|
97 |
-
return $this->add_column($columns, 'comments');
|
98 |
}
|
99 |
|
100 |
/*
|
@@ -106,41 +107,52 @@ class PLL_Admin_Filters_Columns {
|
|
106 |
* @param string $column column name
|
107 |
* @param int $post_id
|
108 |
*/
|
109 |
-
public function post_column($column, $post_id) {
|
110 |
-
$inline = defined('DOING_AJAX') && $_REQUEST['action']
|
111 |
-
$lang = $inline ? $this->model->get_language($_POST['inline_lang_choice']) : $this->model->
|
112 |
|
113 |
-
if (false === strpos($column, 'language_') ||
|
114 |
return;
|
|
|
115 |
|
116 |
-
$language = $this->model->get_language(substr($column, 9));
|
117 |
|
118 |
// hidden field containing the post language for quick edit
|
119 |
-
if ($column == $this->get_first_language_column())
|
120 |
-
printf('<div class="hidden" id="lang_%d">%s</div>', esc_attr($post_id), esc_html($lang->slug));
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
//
|
126 |
-
if ($id = $this->model->
|
127 |
-
if
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
);
|
133 |
-
}
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
136 |
}
|
137 |
}
|
138 |
// link to add a new translation
|
139 |
-
|
140 |
-
|
141 |
-
__('Add new translation', 'polylang'),
|
142 |
-
esc_url($this->links->get_new_post_translation_link($post_id, $language))
|
143 |
-
);
|
144 |
}
|
145 |
}
|
146 |
|
@@ -153,12 +165,13 @@ class PLL_Admin_Filters_Columns {
|
|
153 |
* @param string $type either 'edit-tags' for terms list table or post type for posts list table
|
154 |
* @return string unmodified $column
|
155 |
*/
|
156 |
-
public function quick_edit_custom_box($column, $type) {
|
157 |
-
if ($column == $this->get_first_language_column()) {
|
158 |
|
159 |
$elements = $this->model->get_languages_list();
|
160 |
-
if (current_filter() == 'bulk_edit_custom_box')
|
161 |
-
array_unshift($elements, (object) array('slug' => -1, 'name' => __('— No Change —')));
|
|
|
162 |
|
163 |
$dropdown = new PLL_Walker_Dropdown();
|
164 |
// the hidden field 'old_lang' allows to pass the old language to ajax request
|
@@ -171,23 +184,23 @@ class PLL_Admin_Filters_Columns {
|
|
171 |
</label>
|
172 |
</div>
|
173 |
</fieldset>',
|
174 |
-
__('Language', 'polylang'),
|
175 |
-
$dropdown->walk($elements, array('name' => 'inline_lang_choice', 'id' => ''))
|
176 |
);
|
177 |
}
|
178 |
return $column;
|
179 |
}
|
180 |
|
181 |
/*
|
182 |
-
* adds the language column (before the posts column) in the 'Categories' or 'Post Tags' table
|
183 |
*
|
184 |
* @since 0.1
|
185 |
*
|
186 |
* @param array $columns list of terms table columns
|
187 |
* @return array modified list of columns
|
188 |
*/
|
189 |
-
public function add_term_column($columns) {
|
190 |
-
return $this->add_column($columns, 'posts');
|
191 |
}
|
192 |
|
193 |
/*
|
@@ -199,43 +212,59 @@ class PLL_Admin_Filters_Columns {
|
|
199 |
* @param string $column column name
|
200 |
* @param int term_id
|
201 |
*/
|
202 |
-
public function term_column($out, $column, $term_id) {
|
203 |
-
$inline = defined('DOING_AJAX') && $_REQUEST['action']
|
204 |
-
if (false === strpos($column, 'language_') || !($lang = $inline ? $this->model->get_language($_POST['inline_lang_choice']) : $this->model->
|
205 |
return $out;
|
|
|
206 |
|
207 |
-
$post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type']; // 2nd case for quick edit
|
208 |
-
$taxonomy = isset($GLOBALS['taxonomy']) ? $GLOBALS['taxonomy'] : $_REQUEST['taxonomy'];
|
209 |
|
210 |
-
if (!post_type_exists($post_type) || !taxonomy_exists($taxonomy))
|
211 |
return $out;
|
|
|
212 |
|
213 |
$term_id = (int) $term_id;
|
214 |
-
$language = $this->model->get_language(substr($column, 9));
|
215 |
|
216 |
-
if ($column == $this->get_first_language_column()) {
|
217 |
-
$out = sprintf('<div class="hidden" id="lang_%d">%s</div>', $term_id, esc_html($lang->slug));
|
218 |
|
219 |
// identify the default categories to disable the language dropdown in js
|
220 |
-
if (in_array(get_option('default_category'), $this->model->get_translations(
|
221 |
-
$out .= sprintf('<div class="hidden" id="default_cat_%1$d">%1$d</div>', $term_id);
|
|
|
222 |
}
|
223 |
|
224 |
-
// link to edit term (or a translation)
|
225 |
-
if (($id = $this->model->
|
226 |
-
$
|
227 |
-
$id
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
}
|
232 |
|
233 |
// link to add a new translation
|
234 |
else {
|
235 |
-
$out .=
|
236 |
-
__('Add new translation', 'polylang'),
|
237 |
-
esc_url($this->links->get_new_term_translation_link($term_id, $taxonomy, $post_type, $language))
|
238 |
-
);
|
239 |
}
|
240 |
|
241 |
return $out;
|
@@ -250,25 +279,25 @@ class PLL_Admin_Filters_Columns {
|
|
250 |
global $wp_list_table;
|
251 |
|
252 |
if ( ! post_type_exists( $post_type = $_POST['post_type'] ) || ! $this->model->is_translated_post_type( $post_type ) ) {
|
253 |
-
die(0);
|
254 |
}
|
255 |
|
256 |
-
check_ajax_referer('inlineeditnonce', '_pll_nonce');
|
257 |
|
258 |
$x = new WP_Ajax_Response();
|
259 |
$wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
|
260 |
|
261 |
-
$translations = empty($_POST['translations']) ? array() : explode(',', $_POST['translations']); // collect old translations
|
262 |
-
$translations = array_merge($translations, array($_POST['post_id'])); // add current post
|
263 |
-
$translations = array_map('intval', $translations);
|
264 |
|
265 |
-
foreach ($translations as $post_id) {
|
266 |
$level = is_post_type_hierarchical( $post_type ) ? count( get_ancestors( $post_id, $post_type ) ) : 0;
|
267 |
-
if ($post = get_post($post_id)) {
|
268 |
ob_start();
|
269 |
$wp_list_table->single_row( $post, $level );
|
270 |
$data = ob_get_clean();
|
271 |
-
$x->add(array('what' => 'row', 'data' => $data, 'supplemental' => array('post_id' => $post_id)));
|
272 |
}
|
273 |
}
|
274 |
|
@@ -284,26 +313,26 @@ class PLL_Admin_Filters_Columns {
|
|
284 |
global $wp_list_table;
|
285 |
|
286 |
if ( ! taxonomy_exists( $taxonomy = $_POST['taxonomy'] ) || ! $this->model->is_translated_taxonomy( $taxonomy ) ) {
|
287 |
-
die(0);
|
288 |
}
|
289 |
|
290 |
-
check_ajax_referer('pll_language', '_pll_nonce');
|
291 |
|
292 |
$x = new WP_Ajax_Response();
|
293 |
$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) );
|
294 |
|
295 |
-
$translations = empty($_POST['translations']) ? array() : explode(',', $_POST['translations']); // collect old translations
|
296 |
-
$translations = array_merge($translations, $this->model->get_translations(
|
297 |
-
$translations = array_unique($translations); // remove doublons
|
298 |
-
$translations = array_map('intval', $translations);
|
299 |
|
300 |
-
foreach ($translations as $term_id) {
|
301 |
-
$level = is_taxonomy_hierarchical($taxonomy) ? count( get_ancestors( $term_id, $taxonomy ) ) : 0;
|
302 |
-
if ($tag = get_term($term_id, $taxonomy)) {
|
303 |
ob_start();
|
304 |
$wp_list_table->single_row( $tag, $level );
|
305 |
$data = ob_get_clean();
|
306 |
-
$x->add(array('what' => 'row', 'data' => $data, 'supplemental' => array('term_id' => $term_id)));
|
307 |
}
|
308 |
}
|
309 |
|
16 |
*
|
17 |
* @param object $polylang
|
18 |
*/
|
19 |
+
public function __construct( &$polylang ) {
|
20 |
$this->links = &$polylang->links;
|
21 |
$this->model = &$polylang->model;
|
22 |
$this->curlang = &$polylang->curlang;
|
23 |
|
24 |
// add the language and translations columns in 'All Posts', 'All Pages' and 'Media library' panels
|
25 |
+
foreach ( $this->model->get_translated_post_types() as $type ) {
|
26 |
// use the latest filter late as some plugins purely overwrite what's done by others :(
|
27 |
// specific case for media
|
28 |
+
add_filter( 'manage_'. ( 'attachment' == $type ? 'upload' : 'edit-'. $type ) .'_columns', array( &$this, 'add_post_column' ), 100 );
|
29 |
+
add_action( 'manage_'. ( 'attachment' == $type ? 'media' : $type .'_posts' ) .'_custom_column', array( &$this, 'post_column' ), 10, 2 );
|
30 |
}
|
31 |
|
32 |
// quick edit and bulk edit
|
33 |
+
add_filter( 'quick_edit_custom_box', array( &$this, 'quick_edit_custom_box' ), 10, 2 );
|
34 |
+
add_filter( 'bulk_edit_custom_box', array( &$this, 'quick_edit_custom_box' ), 10, 2 );
|
35 |
|
36 |
// adds the language column in the 'Categories' and 'Post Tags' tables
|
37 |
+
foreach ( $this->model->get_translated_taxonomies() as $tax ) {
|
38 |
+
add_filter( 'manage_edit-'.$tax.'_columns', array( &$this, 'add_term_column' ) );
|
39 |
+
add_filter( 'manage_'.$tax.'_custom_column', array( &$this, 'term_column' ), 10, 3 );
|
40 |
}
|
41 |
|
42 |
// ajax responses to update list table rows
|
43 |
+
add_action( 'wp_ajax_pll_update_post_rows', array( &$this, 'ajax_update_post_rows' ) );
|
44 |
+
add_action( 'wp_ajax_pll_update_term_rows', array( &$this, 'ajax_update_term_rows' ) );
|
45 |
}
|
46 |
|
47 |
/*
|
53 |
* @param string $before the column before which we want to add our languages
|
54 |
* @return array modified list of columns
|
55 |
*/
|
56 |
+
protected function add_column( $columns, $before ) {
|
57 |
+
if ( $n = array_search( $before, array_keys( $columns ) ) ) {
|
58 |
+
$end = array_slice( $columns, $n );
|
59 |
+
$columns = array_slice( $columns, 0, $n );
|
60 |
}
|
61 |
|
62 |
+
foreach ( $this->model->get_languages_list() as $language ) {
|
63 |
// don't add the column for the filtered language
|
64 |
+
if ( empty( $this->curlang ) || $language->slug != $this->curlang->slug ) {
|
65 |
+
$columns[ 'language_'.$language->slug ] = $language->flag ? $language->flag . '<span class="screen-reader-text">' . esc_html( $language->name ) . '</span>' : esc_html( $language->slug );
|
66 |
}
|
67 |
}
|
68 |
|
69 |
+
return isset( $end ) ? array_merge( $columns, $end ) : $columns;
|
70 |
}
|
71 |
|
72 |
/*
|
77 |
* @return string first language column name
|
78 |
*/
|
79 |
protected function get_first_language_column() {
|
80 |
+
foreach ( $this->model->get_languages_list() as $language ) {
|
81 |
+
if ( empty( $this->curlang ) || $language->slug != $this->curlang->slug ) {
|
82 |
+
$columns[] = 'language_' . $language->slug;
|
83 |
+
}
|
84 |
}
|
85 |
|
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
|
93 |
*
|
94 |
* @param array $columns list of posts table columns
|
95 |
* @return array modified list of columns
|
96 |
*/
|
97 |
+
function add_post_column( $columns ) {
|
98 |
+
return $this->add_column( $columns, 'comments' );
|
99 |
}
|
100 |
|
101 |
/*
|
107 |
* @param string $column column name
|
108 |
* @param int $post_id
|
109 |
*/
|
110 |
+
public function post_column( $column, $post_id ) {
|
111 |
+
$inline = defined( 'DOING_AJAX' ) && 'inline-save' == $_REQUEST['action'] && isset( $_POST['inline_lang_choice'] );
|
112 |
+
$lang = $inline ? $this->model->get_language( $_POST['inline_lang_choice'] ) : $this->model->post->get_language( $post_id );
|
113 |
|
114 |
+
if ( false === strpos( $column, 'language_' ) || ! $lang ) {
|
115 |
return;
|
116 |
+
}
|
117 |
|
118 |
+
$language = $this->model->get_language( substr( $column, 9 ) );
|
119 |
|
120 |
// hidden field containing the post language for quick edit
|
121 |
+
if ( $column == $this->get_first_language_column() ) {
|
122 |
+
printf( '<div class="hidden" id="lang_%d">%s</div>', esc_attr( $post_id ), esc_html( $lang->slug ) );
|
123 |
+
}
|
124 |
+
|
125 |
+
$post_type_object = get_post_type_object( get_post_type( $post_id ) );
|
126 |
+
|
127 |
+
// link to edit post ( or a translation )
|
128 |
+
if ( $id = $this->model->post->get( $post_id, $language ) ) {
|
129 |
+
// get_edit_post_link returns nothing if the user cannot edit the post
|
130 |
+
// thanks to Solinx. See http://wordpress.org/support/topic/feature-request-incl-code-check-for-capabilities-in-admin-screens
|
131 |
+
if ( $link = get_edit_post_link( $id ) ) {
|
132 |
+
if ( $id === $post_id ) {
|
133 |
+
$class = 'pll_icon_tick';
|
134 |
+
/* translators: %s is a native language name */
|
135 |
+
$s = sprintf( __( 'Edit this item in %s', 'polylang' ), $language->name );
|
136 |
+
} else {
|
137 |
+
$class = esc_attr( 'pll_icon_edit translation_' . $id );
|
138 |
+
/* translators: %s is a native language name */
|
139 |
+
$s = sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name );
|
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(
|
147 |
+
'<span class="pll_icon_tick"><span class="screen-reader-text">%s</span></span>',
|
148 |
+
/* translators: %s is a native language name */
|
149 |
+
esc_html( sprintf( __( 'This item is in %s', 'polylang' ), $language->name ) )
|
150 |
+
);
|
151 |
}
|
152 |
}
|
153 |
// link to add a new translation
|
154 |
+
else {
|
155 |
+
echo $this->links->new_post_translation_link( $post_id, $language );
|
|
|
|
|
|
|
156 |
}
|
157 |
}
|
158 |
|
165 |
* @param string $type either 'edit-tags' for terms list table or post type for posts list table
|
166 |
* @return string unmodified $column
|
167 |
*/
|
168 |
+
public function quick_edit_custom_box( $column, $type ) {
|
169 |
+
if ( $column == $this->get_first_language_column() ) {
|
170 |
|
171 |
$elements = $this->model->get_languages_list();
|
172 |
+
if ( current_filter() == 'bulk_edit_custom_box' ) {
|
173 |
+
array_unshift( $elements, (object) array( 'slug' => -1, 'name' => __( '— No Change —' ) ) );
|
174 |
+
}
|
175 |
|
176 |
$dropdown = new PLL_Walker_Dropdown();
|
177 |
// the hidden field 'old_lang' allows to pass the old language to ajax request
|
184 |
</label>
|
185 |
</div>
|
186 |
</fieldset>',
|
187 |
+
__( 'Language', 'polylang' ),
|
188 |
+
$dropdown->walk( $elements, array( 'name' => 'inline_lang_choice', 'id' => '' ) )
|
189 |
);
|
190 |
}
|
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
|
198 |
*
|
199 |
* @param array $columns list of terms table columns
|
200 |
* @return array modified list of columns
|
201 |
*/
|
202 |
+
public function add_term_column( $columns ) {
|
203 |
+
return $this->add_column( $columns, 'posts' );
|
204 |
}
|
205 |
|
206 |
/*
|
212 |
* @param string $column column name
|
213 |
* @param int term_id
|
214 |
*/
|
215 |
+
public function term_column( $out, $column, $term_id ) {
|
216 |
+
$inline = defined( 'DOING_AJAX' ) && 'inline-save-tax' == $_REQUEST['action'] && isset( $_POST['inline_lang_choice'] );
|
217 |
+
if ( false === strpos( $column, 'language_' ) || ! ( $lang = $inline ? $this->model->get_language( $_POST['inline_lang_choice'] ) : $this->model->term->get_language( $term_id ) ) ) {
|
218 |
return $out;
|
219 |
+
}
|
220 |
|
221 |
+
$post_type = isset( $GLOBALS['post_type'] ) ? $GLOBALS['post_type'] : $_REQUEST['post_type']; // 2nd case for quick edit
|
222 |
+
$taxonomy = isset( $GLOBALS['taxonomy'] ) ? $GLOBALS['taxonomy'] : $_REQUEST['taxonomy'];
|
223 |
|
224 |
+
if ( ! post_type_exists( $post_type ) || ! taxonomy_exists( $taxonomy ) ) {
|
225 |
return $out;
|
226 |
+
}
|
227 |
|
228 |
$term_id = (int) $term_id;
|
229 |
+
$language = $this->model->get_language( substr( $column, 9 ) );
|
230 |
|
231 |
+
if ( $column == $this->get_first_language_column() ) {
|
232 |
+
$out = sprintf( '<div class="hidden" id="lang_%d">%s</div>', $term_id, esc_html( $lang->slug ) );
|
233 |
|
234 |
// identify the default categories to disable the language dropdown in js
|
235 |
+
if ( in_array( get_option( 'default_category' ), $this->model->term->get_translations( $term_id ) ) ) {
|
236 |
+
$out .= sprintf( '<div class="hidden" id="default_cat_%1$d">%1$d</div>', $term_id );
|
237 |
+
}
|
238 |
}
|
239 |
|
240 |
+
// link to edit term ( or a translation )
|
241 |
+
if ( ( $id = $this->model->term->get( $term_id, $language ) ) && $term = get_term( $id, $taxonomy ) ) {
|
242 |
+
if ( $link = get_edit_term_link( $id, $taxonomy, $post_type ) ) {
|
243 |
+
if ( $id === $term_id ) {
|
244 |
+
$class = 'pll_icon_tick';
|
245 |
+
/* translators: %s is a native language name */
|
246 |
+
$s = sprintf( __( 'Edit this item in %s', 'polylang' ), $language->name );
|
247 |
+
} else {
|
248 |
+
$class = esc_attr( 'pll_icon_edit translation_' . $id );
|
249 |
+
/* translators: %s is a native language name */
|
250 |
+
$s = sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name );
|
251 |
+
}
|
252 |
+
$out .= sprintf(
|
253 |
+
'<a class="%1$s" title="%2$s" href="%3$s"><span class="screen-reader-text">%4$s</span></a>',
|
254 |
+
$class, esc_attr( $term->name ), esc_url( $link ), esc_html( $s )
|
255 |
+
);
|
256 |
+
} elseif ( $id === $term_id ) {
|
257 |
+
$out .= printf(
|
258 |
+
'<span class="pll_icon_tick"><span class="screen-reader-text">%s</span></span>',
|
259 |
+
/* translators: %s is a native language name */
|
260 |
+
esc_html( sprintf( __( 'This item is in %s', 'polylang' ), $language->name ) )
|
261 |
+
);
|
262 |
+
}
|
263 |
}
|
264 |
|
265 |
// link to add a new translation
|
266 |
else {
|
267 |
+
$out .= $this->links->new_term_translation_link( $term_id, $taxonomy, $post_type, $language );
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
return $out;
|
279 |
global $wp_list_table;
|
280 |
|
281 |
if ( ! post_type_exists( $post_type = $_POST['post_type'] ) || ! $this->model->is_translated_post_type( $post_type ) ) {
|
282 |
+
die( 0 );
|
283 |
}
|
284 |
|
285 |
+
check_ajax_referer( 'inlineeditnonce', '_pll_nonce' );
|
286 |
|
287 |
$x = new WP_Ajax_Response();
|
288 |
$wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
|
289 |
|
290 |
+
$translations = empty( $_POST['translations'] ) ? array() : explode( ',', $_POST['translations'] ); // collect old translations
|
291 |
+
$translations = array_merge( $translations, array( $_POST['post_id'] ) ); // add current post
|
292 |
+
$translations = array_map( 'intval', $translations );
|
293 |
|
294 |
+
foreach ( $translations as $post_id ) {
|
295 |
$level = is_post_type_hierarchical( $post_type ) ? count( get_ancestors( $post_id, $post_type ) ) : 0;
|
296 |
+
if ( $post = get_post( $post_id ) ) {
|
297 |
ob_start();
|
298 |
$wp_list_table->single_row( $post, $level );
|
299 |
$data = ob_get_clean();
|
300 |
+
$x->add( array( 'what' => 'row', 'data' => $data, 'supplemental' => array( 'post_id' => $post_id ) ) );
|
301 |
}
|
302 |
}
|
303 |
|
313 |
global $wp_list_table;
|
314 |
|
315 |
if ( ! taxonomy_exists( $taxonomy = $_POST['taxonomy'] ) || ! $this->model->is_translated_taxonomy( $taxonomy ) ) {
|
316 |
+
die( 0 );
|
317 |
}
|
318 |
|
319 |
+
check_ajax_referer( 'pll_language', '_pll_nonce' );
|
320 |
|
321 |
$x = new WP_Ajax_Response();
|
322 |
$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) );
|
323 |
|
324 |
+
$translations = empty( $_POST['translations'] ) ? array() : explode( ',', $_POST['translations'] ); // collect old translations
|
325 |
+
$translations = array_merge( $translations, $this->model->term->get_translations( (int) $_POST['term_id'] ) ); // add current translations
|
326 |
+
$translations = array_unique( $translations ); // remove doublons
|
327 |
+
$translations = array_map( 'intval', $translations );
|
328 |
|
329 |
+
foreach ( $translations as $term_id ) {
|
330 |
+
$level = is_taxonomy_hierarchical( $taxonomy ) ? count( get_ancestors( $term_id, $taxonomy ) ) : 0;
|
331 |
+
if ( $tag = get_term( $term_id, $taxonomy ) ) {
|
332 |
ob_start();
|
333 |
$wp_list_table->single_row( $tag, $level );
|
334 |
$data = ob_get_clean();
|
335 |
+
$x->add( array( 'what' => 'row', 'data' => $data, 'supplemental' => array( 'term_id' => $term_id ) ) );
|
336 |
}
|
337 |
}
|
338 |
|
admin/admin-filters-media.php
CHANGED
@@ -14,23 +14,21 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
14 |
*
|
15 |
* @param object $polylang
|
16 |
*/
|
17 |
-
public function __construct(&$polylang) {
|
18 |
-
parent::__construct($polylang);
|
19 |
|
20 |
// adds the language field and translations tables in the 'Edit Media' panel
|
21 |
-
add_filter('attachment_fields_to_edit', array(&$this, 'attachment_fields_to_edit'), 10, 2);
|
22 |
-
|
23 |
-
// ajax response for changing the language in media form
|
24 |
-
add_action('wp_ajax_media_lang_choice', array(&$this,'media_lang_choice'));
|
25 |
|
26 |
// adds actions related to languages when creating, saving or deleting media
|
27 |
-
add_action('add_attachment', array(&$this, 'set_default_language'));
|
28 |
-
add_filter('attachment_fields_to_save', array(&$this, 'save_media'), 10, 2);
|
29 |
-
add_filter('wp_delete_file', array(&$this, 'wp_delete_file'));
|
30 |
|
31 |
// creates a media translation
|
32 |
-
if (isset($_GET['action'], $_GET['new_lang'], $_GET['from_media']) && $_GET['action']
|
33 |
-
add_action('admin_init', array(&$this, 'translate_media'));
|
|
|
34 |
}
|
35 |
|
36 |
/*
|
@@ -43,52 +41,66 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
43 |
* @param object $post
|
44 |
* @return array modified list of form fields
|
45 |
*/
|
46 |
-
public function attachment_fields_to_edit($fields, $post) {
|
47 |
-
if ($GLOBALS['pagenow']
|
48 |
return $fields; // don't add anything on edit media panel for WP 3.5+ since we have the metabox
|
|
|
49 |
|
50 |
$post_id = $post->ID;
|
51 |
-
$lang = $this->model->
|
52 |
|
53 |
$dropdown = new PLL_Walker_Dropdown();
|
54 |
$fields['language'] = array(
|
55 |
-
'label' => __('Language', 'polylang'),
|
56 |
'input' => 'html',
|
57 |
-
'html' => $dropdown->walk($this->model->get_languages_list(), array(
|
58 |
-
'name' => sprintf('attachments[%d][language]', $post_id),
|
59 |
'class' => 'media_lang_choice',
|
60 |
-
'selected' => $lang ? $lang->slug : ''
|
61 |
-
))
|
62 |
);
|
63 |
|
64 |
return $fields;
|
65 |
}
|
66 |
|
67 |
/*
|
68 |
-
*
|
69 |
-
* needs WP 3.5+
|
70 |
*
|
71 |
-
* @since
|
|
|
|
|
|
|
|
|
72 |
*/
|
73 |
-
public function
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
|
77 |
-
$post_id = $matches[1];
|
78 |
-
$lang = $this->model->get_language($_POST['lang']);
|
79 |
|
80 |
-
|
81 |
-
if ($
|
82 |
-
|
83 |
-
$data = ob_get_contents();
|
84 |
}
|
85 |
-
$x = new WP_Ajax_Response(array('what' => 'translations', 'data' => $data));
|
86 |
-
ob_end_clean();
|
87 |
|
88 |
-
|
89 |
-
$
|
90 |
|
91 |
-
$
|
|
|
92 |
}
|
93 |
|
94 |
/*
|
@@ -98,40 +110,18 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
98 |
*/
|
99 |
public function translate_media() {
|
100 |
//security check
|
101 |
-
check_admin_referer('translate_media');
|
102 |
-
|
103 |
-
$post = get_post((int) $_GET['from_media']);
|
104 |
-
$post_id = $post->ID;
|
105 |
-
$new_lang = $this->model->get_language($_GET['new_lang']); // make sure we get a valid language slug
|
106 |
|
107 |
// bails if the translations already exists
|
108 |
// see https://wordpress.org/support/topic/edit-translation-in-media-attachments?#post-7322303
|
109 |
-
if ( $this->model->get_translation(
|
110 |
wp_safe_redirect( wp_get_referer() );
|
111 |
exit;
|
112 |
}
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
$post->post_parent = ($post->post_parent && $tr_parent = $this->model->get_translation('post', $post->post_parent, $new_lang->slug)) ? $tr_parent : 0;
|
117 |
-
$tr_id = wp_insert_attachment($post);
|
118 |
-
add_post_meta($tr_id, '_wp_attachment_metadata', get_post_meta($post_id, '_wp_attachment_metadata', true));
|
119 |
-
add_post_meta($tr_id, '_wp_attached_file', get_post_meta($post_id, '_wp_attached_file', true));
|
120 |
-
|
121 |
-
// copy alternative text to be consistent with title, caption and description copied when cloning the post
|
122 |
-
if ($meta = get_post_meta($post_id, '_wp_attachment_image_alt', true))
|
123 |
-
add_post_meta($tr_id, '_wp_attachment_image_alt', $meta);
|
124 |
-
|
125 |
-
$translations = $this->model->get_translations('post', $post_id);
|
126 |
-
if (!$translations && $lang = $this->model->get_post_language($post_id))
|
127 |
-
$translations[$lang->slug] = $post_id;
|
128 |
-
|
129 |
-
$translations[$new_lang->slug] = $tr_id;
|
130 |
-
$this->model->save_translations('post', $tr_id, $translations);
|
131 |
-
|
132 |
-
do_action('pll_translate_media', $tr_id, $post, $translations);
|
133 |
-
|
134 |
-
wp_safe_redirect(admin_url(sprintf('post.php?post=%d&action=edit', $tr_id))); // WP 3.5+
|
135 |
exit;
|
136 |
}
|
137 |
|
@@ -145,14 +135,16 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
145 |
* @param array $attachment
|
146 |
* @return array unmodified $post
|
147 |
*/
|
148 |
-
public function save_media($post, $attachment) {
|
149 |
// language is filled in attachment by the function applying the filter 'attachment_fields_to_save'
|
150 |
// all security checks have been done by functions applying this filter
|
151 |
-
if (!empty($attachment['language']))
|
152 |
-
$this->model->
|
|
|
153 |
|
154 |
-
if (isset($_POST['media_tr_lang']))
|
155 |
-
$this->save_translations($post['ID'], $_POST['media_tr_lang']);
|
|
|
156 |
|
157 |
return $post;
|
158 |
}
|
@@ -166,20 +158,20 @@ class PLL_Admin_Filters_Media extends PLL_Admin_Filters_Post_Base {
|
|
166 |
* @param string $file
|
167 |
* @return string unmodified $file
|
168 |
*/
|
169 |
-
public function wp_delete_file($file) {
|
170 |
global $wpdb;
|
171 |
|
172 |
$uploadpath = wp_upload_dir();
|
173 |
|
174 |
-
$ids = $wpdb->get_col($wpdb->prepare("
|
175 |
SELECT post_id FROM $wpdb->postmeta
|
176 |
WHERE meta_key = '_wp_attached_file' AND meta_value = '%s'",
|
177 |
-
substr_replace($file, '', 0, strlen(trailingslashit($uploadpath['basedir'])))
|
178 |
-
));
|
179 |
|
180 |
-
if (!empty($ids)) {
|
181 |
-
// regenerate intermediate sizes if it's an image (since we could not prevent WP deleting them before)
|
182 |
-
wp_update_attachment_metadata($ids[0], wp_generate_attachment_metadata($ids[0], $file));
|
183 |
return ''; // prevent deleting the main file
|
184 |
}
|
185 |
|
14 |
*
|
15 |
* @param object $polylang
|
16 |
*/
|
17 |
+
public function __construct( &$polylang ) {
|
18 |
+
parent::__construct( $polylang );
|
19 |
|
20 |
// adds the language field and translations tables in the 'Edit Media' panel
|
21 |
+
add_filter( 'attachment_fields_to_edit', array( &$this, 'attachment_fields_to_edit' ), 10, 2 );
|
|
|
|
|
|
|
22 |
|
23 |
// adds actions related to languages when creating, saving or deleting media
|
24 |
+
add_action( 'add_attachment', array( &$this, 'set_default_language' ) );
|
25 |
+
add_filter( 'attachment_fields_to_save', array( &$this, 'save_media' ), 10, 2 );
|
26 |
+
add_filter( 'wp_delete_file', array( &$this, 'wp_delete_file' ) );
|
27 |
|
28 |
// creates a media translation
|
29 |
+
if ( isset( $_GET['action'], $_GET['new_lang'], $_GET['from_media'] ) && 'translate_media' == $_GET['action']) {
|
30 |
+
add_action( 'admin_init', array( &$this, 'translate_media' ) );
|
31 |
+
}
|
32 |
}
|
33 |
|
34 |
/*
|
41 |
* @param object $post
|
42 |
* @return array modified list of form fields
|
43 |
*/
|
44 |
+
public function attachment_fields_to_edit( $fields, $post ) {
|
45 |
+
if ( 'post.php' == $GLOBALS['pagenow'] ) {
|
46 |
return $fields; // don't add anything on edit media panel for WP 3.5+ since we have the metabox
|
47 |
+
}
|
48 |
|
49 |
$post_id = $post->ID;
|
50 |
+
$lang = $this->model->post->get_language( $post_id );
|
51 |
|
52 |
$dropdown = new PLL_Walker_Dropdown();
|
53 |
$fields['language'] = array(
|
54 |
+
'label' => __( 'Language', 'polylang' ),
|
55 |
'input' => 'html',
|
56 |
+
'html' => $dropdown->walk( $this->model->get_languages_list(), array(
|
57 |
+
'name' => sprintf( 'attachments[%d][language]', $post_id ),
|
58 |
'class' => 'media_lang_choice',
|
59 |
+
'selected' => $lang ? $lang->slug : '',
|
60 |
+
) ),
|
61 |
);
|
62 |
|
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 |
*/
|
75 |
+
public function create_media_translation( $post_id, $lang ) {
|
76 |
+
$post = get_post( $post_id );
|
77 |
+
$lang = $this->model->get_language( $lang ); // make sure we get a valid language slug
|
78 |
+
|
79 |
+
// create a new attachment ( translate attachment parent if exists )
|
80 |
+
$post->ID = null; // will force the creation
|
81 |
+
$post->post_parent = ( $post->post_parent && $tr_parent = $this->model->post->get_translation( $post->post_parent, $lang->slug ) ) ? $tr_parent : 0;
|
82 |
+
$post->tax_input = array( 'language' => array( $lang->slug ) ); // assigns the language
|
83 |
+
$tr_id = wp_insert_attachment( $post );
|
84 |
+
|
85 |
+
// copy metadata, attached file and alternative text
|
86 |
+
foreach ( array( '_wp_attachment_metadata', '_wp_attached_file', '_wp_attachment_image_alt' ) as $key ) {
|
87 |
+
if ( $meta = get_post_meta( $post_id, $key , true ) ) {
|
88 |
+
add_post_meta( $tr_id, $key, $meta );
|
89 |
+
}
|
90 |
+
}
|
91 |
|
92 |
+
$this->model->post->set_language( $tr_id, $lang );
|
|
|
|
|
93 |
|
94 |
+
$translations = $this->model->post->get_translations( $post_id );
|
95 |
+
if ( ! $translations && $src_lang = $this->model->post->get_language( $post_id ) ) {
|
96 |
+
$translations[ $src_lang->slug ] = $post_id;
|
|
|
97 |
}
|
|
|
|
|
98 |
|
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 |
/*
|
110 |
*/
|
111 |
public function translate_media() {
|
112 |
//security check
|
113 |
+
check_admin_referer( 'translate_media' );
|
114 |
+
$post_id = (int) $_GET['from_media'];
|
|
|
|
|
|
|
115 |
|
116 |
// bails if the translations already exists
|
117 |
// see https://wordpress.org/support/topic/edit-translation-in-media-attachments?#post-7322303
|
118 |
+
if ( $this->model->post->get_translation( $post_id, $_GET['new_lang'] ) ) {
|
119 |
wp_safe_redirect( wp_get_referer() );
|
120 |
exit;
|
121 |
}
|
122 |
|
123 |
+
$tr_id = $this->create_media_translation( $post_id, $_GET['new_lang'] );
|
124 |
+
wp_safe_redirect( admin_url( sprintf( 'post.php?post=%d&action=edit', $tr_id ) ) ); // WP 3.5+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
exit;
|
126 |
}
|
127 |
|
135 |
* @param array $attachment
|
136 |
* @return array unmodified $post
|
137 |
*/
|
138 |
+
public function save_media( $post, $attachment ) {
|
139 |
// language is filled in attachment by the function applying the filter 'attachment_fields_to_save'
|
140 |
// all security checks have been done by functions applying this filter
|
141 |
+
if ( ! empty( $attachment['language'] ) ) {
|
142 |
+
$this->model->post->set_language( $post['ID'], $attachment['language'] );
|
143 |
+
}
|
144 |
|
145 |
+
if ( isset( $_POST['media_tr_lang'] ) ) {
|
146 |
+
$this->save_translations( $post['ID'], $_POST['media_tr_lang'] );
|
147 |
+
}
|
148 |
|
149 |
return $post;
|
150 |
}
|
158 |
* @param string $file
|
159 |
* @return string unmodified $file
|
160 |
*/
|
161 |
+
public function wp_delete_file( $file ) {
|
162 |
global $wpdb;
|
163 |
|
164 |
$uploadpath = wp_upload_dir();
|
165 |
|
166 |
+
$ids = $wpdb->get_col( $wpdb->prepare( "
|
167 |
SELECT post_id FROM $wpdb->postmeta
|
168 |
WHERE meta_key = '_wp_attached_file' AND meta_value = '%s'",
|
169 |
+
substr_replace( $file, '', 0, strlen( trailingslashit( $uploadpath['basedir'] ) ) )
|
170 |
+
) );
|
171 |
|
172 |
+
if ( ! empty( $ids ) ) {
|
173 |
+
// regenerate intermediate sizes if it's an image ( since we could not prevent WP deleting them before )
|
174 |
+
wp_update_attachment_metadata( $ids[0], wp_generate_attachment_metadata( $ids[0], $file ) );
|
175 |
return ''; // prevent deleting the main file
|
176 |
}
|
177 |
|
admin/admin-filters-post-base.php
CHANGED
@@ -15,7 +15,7 @@ abstract class PLL_Admin_Filters_Post_Base {
|
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
-
public function __construct(&$polylang) {
|
19 |
$this->links = &$polylang->links;
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->pref_lang = &$polylang->pref_lang;
|
@@ -28,16 +28,19 @@ abstract class PLL_Admin_Filters_Post_Base {
|
|
28 |
*
|
29 |
* @param int $post_id
|
30 |
*/
|
31 |
-
public function set_default_language($post_id) {
|
32 |
-
if (
|
33 |
-
if (isset($_GET['new_lang']) && $lang = $this->model->get_language($_GET['new_lang']))
|
34 |
-
$this->model->
|
|
|
35 |
|
36 |
-
elseif (($parent_id = wp_get_post_parent_id($post_id)) && $parent_lang = $this->model->
|
37 |
-
$this->model->
|
|
|
38 |
|
39 |
-
else
|
40 |
-
$this->model->
|
|
|
41 |
}
|
42 |
}
|
43 |
|
@@ -50,21 +53,17 @@ abstract class PLL_Admin_Filters_Post_Base {
|
|
50 |
* @param array $arr
|
51 |
* @return array
|
52 |
*/
|
53 |
-
protected function save_translations($post_id, $arr) {
|
54 |
// security check
|
55 |
// as 'wp_insert_post' can be called from outside WP admin
|
56 |
-
check_admin_referer('pll_language', '_pll_nonce');
|
57 |
|
58 |
// save translations after checking the translated post is in the right language
|
59 |
-
foreach ($arr as $lang => $tr_id)
|
60 |
-
$translations[$lang] = ($tr_id && $this->model->
|
61 |
-
|
62 |
-
$this->model->save_translations('post', $post_id, $translations);
|
63 |
-
|
64 |
-
// refresh language cache when a static front page has been translated
|
65 |
-
if (($pof = get_option('page_on_front')) && in_array($pof, $translations))
|
66 |
-
$this->model->clean_languages_cache();
|
67 |
|
|
|
68 |
return $translations;
|
69 |
}
|
70 |
}
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
+
public function __construct( &$polylang ) {
|
19 |
$this->links = &$polylang->links;
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->pref_lang = &$polylang->pref_lang;
|
28 |
*
|
29 |
* @param int $post_id
|
30 |
*/
|
31 |
+
public function set_default_language( $post_id ) {
|
32 |
+
if ( ! $this->model->post->get_language( $post_id ) ) {
|
33 |
+
if ( isset( $_GET['new_lang'] ) && $lang = $this->model->get_language( $_GET['new_lang'] ) ) {
|
34 |
+
$this->model->post->set_language( $post_id, $lang );
|
35 |
+
}
|
36 |
|
37 |
+
elseif ( ( $parent_id = wp_get_post_parent_id( $post_id ) ) && $parent_lang = $this->model->post->get_language( $parent_id ) ) {
|
38 |
+
$this->model->post->set_language( $post_id, $parent_lang );
|
39 |
+
}
|
40 |
|
41 |
+
else {
|
42 |
+
$this->model->post->set_language( $post_id, $this->pref_lang );
|
43 |
+
}
|
44 |
}
|
45 |
}
|
46 |
|
53 |
* @param array $arr
|
54 |
* @return array
|
55 |
*/
|
56 |
+
protected function save_translations( $post_id, $arr ) {
|
57 |
// security check
|
58 |
// as 'wp_insert_post' can be called from outside WP admin
|
59 |
+
check_admin_referer( 'pll_language', '_pll_nonce' );
|
60 |
|
61 |
// save translations after checking the translated post is in the right language
|
62 |
+
foreach ( $arr as $lang => $tr_id ) {
|
63 |
+
$translations[ $lang ] = ( $tr_id && $this->model->post->get_language( (int) $tr_id )->slug == $lang ) ? (int) $tr_id : 0;
|
64 |
+
}
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
+
$this->model->post->save_translations( $post_id, $translations );
|
67 |
return $translations;
|
68 |
}
|
69 |
}
|
admin/admin-filters-post.php
CHANGED
@@ -15,31 +15,33 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
-
public function __construct(&$polylang) {
|
19 |
-
parent::__construct($polylang);
|
20 |
$this->options = &$polylang->options;
|
21 |
$this->curlang = &$polylang->curlang;
|
22 |
|
23 |
-
add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
|
24 |
|
25 |
// filters posts, pages and media by language
|
26 |
-
add_action('parse_query',array(&$this,'parse_query'));
|
27 |
|
28 |
// adds the Languages box in the 'Edit Post' and 'Edit Page' panels
|
29 |
-
add_action('add_meta_boxes', array(&$this, 'add_meta_boxes'));
|
30 |
|
31 |
// ajax response for changing the language in the post metabox
|
32 |
-
add_action('wp_ajax_post_lang_choice', array(&$this,'post_lang_choice'));
|
33 |
-
add_action('wp_ajax_pll_posts_not_translated', array(&$this,'ajax_posts_not_translated'));
|
34 |
|
35 |
// adds actions and filters related to languages when creating, saving or deleting posts and pages
|
36 |
-
add_action('save_post', array(&$this, 'save_post'), 21, 3); // priority 21 to come after advanced custom fields (20) and before the event calendar which breaks everything after 25
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
40 |
|
41 |
// filters the pages by language in the parent dropdown list in the page attributes metabox
|
42 |
-
add_filter('page_attributes_dropdown_pages_args', array(&$this, 'page_attributes_dropdown_pages_args'), 10, 2);
|
43 |
}
|
44 |
|
45 |
/*
|
@@ -54,40 +56,43 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
54 |
$screen = get_current_screen();
|
55 |
|
56 |
//hierarchical taxonomies
|
57 |
-
if ('edit' == $screen->base && $taxonomies = get_object_taxonomies($screen->post_type, 'object')) {
|
58 |
// get translated hierarchical taxonomies
|
59 |
-
foreach ($taxonomies as $taxonomy) {
|
60 |
-
if ( $taxonomy->hierarchical && $this->model->is_translated_taxonomy($taxonomy->name))
|
61 |
$hierarchical_taxonomies[] = $taxonomy->name;
|
|
|
62 |
}
|
63 |
|
64 |
-
if (!empty($hierarchical_taxonomies)) {
|
65 |
-
$terms = get_terms($hierarchical_taxonomies, array( 'get' => 'all' ));
|
66 |
|
67 |
-
foreach($terms as $term) {
|
68 |
-
if ($lang = $this->model->
|
69 |
-
$term_languages[$lang->slug][$term->taxonomy][] = $term->term_id;
|
|
|
70 |
}
|
71 |
|
72 |
// send all these data to javascript
|
73 |
-
if (!empty($term_languages)) {
|
74 |
-
wp_localize_script('pll_post', 'pll_term_languages', $term_languages);
|
75 |
}
|
76 |
}
|
77 |
}
|
78 |
-
|
79 |
// hierarchical post types
|
80 |
-
if ('edit' == $screen->base && is_post_type_hierarchical($screen->post_type)) {
|
81 |
$pages = get_pages();
|
82 |
|
83 |
-
foreach($pages as $page) {
|
84 |
-
if ($lang = $this->model->
|
85 |
-
$page_languages[$lang->slug][] = $page->ID;
|
|
|
86 |
}
|
87 |
|
88 |
// send all these data to javascript
|
89 |
-
if (!empty($page_languages)) {
|
90 |
-
wp_localize_script('pll_post', 'pll_page_languages', $page_languages);
|
91 |
}
|
92 |
}
|
93 |
}
|
@@ -99,38 +104,40 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
99 |
*
|
100 |
* @param object $query a WP_Query object
|
101 |
*/
|
102 |
-
public function parse_query($query) {
|
103 |
$qvars = &$query->query_vars;
|
104 |
|
105 |
// do not filter post types such as nav_menu_item
|
106 |
-
if (isset($qvars['post_type']) &&
|
107 |
-
unset
|
108 |
return;
|
109 |
}
|
110 |
|
111 |
-
if (isset($qvars['post_type']) && !isset($qvars['lang'])) {
|
112 |
-
// filters the list of media (or wp-links) by language when uploading from post
|
113 |
-
if (isset($_REQUEST['pll_post_id']) && $lang = $this->model->
|
114 |
-
$query->set('lang', $lang->slug);
|
115 |
-
|
116 |
-
elseif (!empty($this->curlang))
|
117 |
$qvars['lang'] = $this->curlang->slug;
|
|
|
118 |
}
|
119 |
|
120 |
-
if (isset($qvars['lang']) && 'all' === $qvars['lang'])
|
121 |
-
unset
|
|
|
122 |
}
|
123 |
|
124 |
/*
|
125 |
-
* adds the Language box in the 'Edit Post' and 'Edit Page' panels (as well as in custom post types panels)
|
126 |
*
|
127 |
* @since 0.1
|
128 |
*
|
129 |
* @param string $post_type
|
130 |
*/
|
131 |
-
public function add_meta_boxes($post_type) {
|
132 |
-
if ($this->model->is_translated_post_type($post_type))
|
133 |
-
add_meta_box('ml_box', __('Languages','polylang'), array(&$this, 'post_language'), $post_type, 'side', 'high');
|
|
|
134 |
}
|
135 |
|
136 |
/*
|
@@ -141,33 +148,37 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
141 |
public function post_language() {
|
142 |
global $post_ID;
|
143 |
$post_id = $post_ID;
|
144 |
-
$post_type = get_post_type($post_ID);
|
145 |
|
146 |
-
$lang = ($lg = $this->model->
|
147 |
-
(isset($_GET['new_lang']) ? $this->model->get_language($_GET['new_lang']) :
|
148 |
-
$this->pref_lang);
|
149 |
|
150 |
$dropdown = new PLL_Walker_Dropdown();
|
151 |
|
152 |
-
wp_nonce_field('pll_language', '_pll_nonce');
|
153 |
|
154 |
-
// NOTE: the class "tags-input" allows to include the field in the autosave $_POST (see autosave.js)
|
155 |
-
printf('
|
156 |
-
<p><strong>%s</strong></p>
|
157 |
-
<
|
|
|
158 |
<div id="post-translations" class="translations">',
|
159 |
-
__('Language', 'polylang'),
|
160 |
-
$
|
161 |
-
$
|
162 |
-
|
163 |
-
'
|
|
|
164 |
'selected' => $lang ? $lang->slug : '',
|
165 |
'flag' => true
|
166 |
-
))
|
167 |
);
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
171 |
}
|
172 |
|
173 |
/*
|
@@ -176,59 +187,61 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
176 |
* @since 0.2
|
177 |
*/
|
178 |
public function post_lang_choice() {
|
179 |
-
check_ajax_referer('pll_language', '_pll_nonce');
|
180 |
|
181 |
global $post_ID; // obliged to use the global variable for wp_popular_terms_checklist
|
182 |
-
$post_ID = (int) $_POST['post_id'];
|
183 |
-
$
|
184 |
-
$lang = $this->model->get_language($_POST['lang']);
|
185 |
|
186 |
-
$
|
187 |
-
|
188 |
-
|
|
|
|
|
189 |
|
190 |
-
$this->model->
|
191 |
|
192 |
ob_start();
|
193 |
-
if ($lang)
|
194 |
-
include(PLL_ADMIN_INC.'/view-translations-post.php');
|
195 |
-
|
|
|
196 |
ob_end_clean();
|
197 |
|
198 |
// categories
|
199 |
-
if (isset($_POST['taxonomies'])) {
|
200 |
// not set for pages
|
201 |
-
foreach ($_POST['taxonomies'] as $taxname) {
|
202 |
-
$taxonomy = get_taxonomy($taxname);
|
203 |
|
204 |
ob_start();
|
205 |
-
$popular_ids = wp_popular_terms_checklist($taxonomy->name);
|
206 |
$supplemental['populars'] = ob_get_contents();
|
207 |
ob_end_clean();
|
208 |
|
209 |
ob_start();
|
210 |
// use $post_ID to remember ckecked terms in case we come back to the original language
|
211 |
-
wp_terms_checklist( $post_ID, array( 'taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids ));
|
212 |
$supplemental['all'] = ob_get_contents();
|
213 |
ob_end_clean();
|
214 |
|
215 |
-
$supplemental['dropdown'] = wp_dropdown_categories(array(
|
216 |
'taxonomy' => $taxonomy->name,
|
217 |
'hide_empty' => 0,
|
218 |
'name' => 'new'.$taxonomy->name.'_parent',
|
219 |
'orderby' => 'name',
|
220 |
'hierarchical' => 1,
|
221 |
'show_option_none' => '— '.$taxonomy->labels->parent_item.' —',
|
222 |
-
'echo' => 0
|
223 |
-
));
|
224 |
|
225 |
-
$x->Add(array('what' => 'taxonomy', 'data' => $taxonomy->name, 'supplemental' => $supplemental));
|
226 |
}
|
227 |
}
|
228 |
|
229 |
-
// parent dropdown list (only for hierarchical post types)
|
230 |
-
if (in_array($post_type, get_post_types(array('hierarchical' => true)))) {
|
231 |
-
$post = get_post($post_ID);
|
232 |
|
233 |
// args and filter from 'page_attributes_meta_box' in wp-admin/includes/meta-boxes.php of WP 4.2.1
|
234 |
$dropdown_args = array(
|
@@ -236,17 +249,17 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
236 |
'exclude_tree' => $post->ID,
|
237 |
'selected' => $post->post_parent,
|
238 |
'name' => 'parent_id',
|
239 |
-
'show_option_none' => __('(no parent)'),
|
240 |
'sort_column' => 'menu_order, post_title',
|
241 |
'echo' => 0,
|
242 |
);
|
243 |
$dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); // since WP 3.3
|
244 |
-
|
245 |
-
$x->Add(array('what' => 'pages', 'data' => wp_dropdown_pages( $dropdown_args )));
|
246 |
}
|
247 |
|
248 |
// flag
|
249 |
-
$x->Add(array('what' => 'flag', 'data' => empty($lang->flag) ? esc_html($lang->slug) : $lang->flag));
|
250 |
|
251 |
$x->send();
|
252 |
}
|
@@ -257,51 +270,57 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
257 |
* @since 1.5
|
258 |
*/
|
259 |
public function ajax_posts_not_translated() {
|
260 |
-
check_ajax_referer('pll_language', '_pll_nonce');
|
261 |
-
|
262 |
-
if (!post_type_exists($
|
263 |
-
die(0);
|
264 |
-
|
265 |
-
|
266 |
-
$
|
267 |
-
|
|
|
268 |
// don't order by title: see https://wordpress.org/support/topic/find-translated-post-when-10-is-not-enough
|
269 |
$args = array(
|
270 |
-
's' => wp_unslash($
|
271 |
'suppress_filters' => 0, // to make the post_fields filter work
|
272 |
'lang' => 0, // avoid admin language filter
|
273 |
'numberposts' => 20, // limit to 20 posts
|
274 |
'post_status' => 'any',
|
275 |
-
'post_type' => $
|
276 |
-
'tax_query' => array(array(
|
277 |
'taxonomy' => 'language',
|
278 |
'field' => 'term_taxonomy_id', // WP 3.5+
|
279 |
-
'terms' => $translation_language->term_taxonomy_id
|
280 |
-
))
|
281 |
);
|
282 |
-
|
283 |
// allow plugins to change args help fixing edge cases: see same topic as above
|
284 |
-
$args = apply_filters('pll_ajax_posts_not_translated_args', $args);
|
285 |
-
$posts = get_posts($args);
|
286 |
|
287 |
$return = array();
|
288 |
|
289 |
-
foreach ($posts as $key => $post) {
|
290 |
-
if (
|
291 |
-
$return[] = array(
|
|
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
|
294 |
// add current translation in list
|
295 |
-
if ($post_id = $this->model->get_translation(
|
296 |
-
$post = get_post($post_id);
|
297 |
-
array_unshift($return, array(
|
298 |
'id' => $post_id,
|
299 |
'value' => $post->post_title,
|
300 |
-
'link' => $this->
|
301 |
-
));
|
302 |
}
|
303 |
|
304 |
-
wp_die(json_encode($return));
|
305 |
}
|
306 |
|
307 |
/*
|
@@ -313,42 +332,43 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
313 |
* @param int $post_id
|
314 |
* @param array $post
|
315 |
*/
|
316 |
-
protected function save_language($post_id, $post) {
|
317 |
// security checks are necessary to accept language modifications
|
318 |
// as 'wp_insert_post' can be called from outside WP admin
|
319 |
|
320 |
// edit post
|
321 |
-
if (isset($
|
322 |
-
check_admin_referer('pll_language', '_pll_nonce');
|
323 |
-
$this->model->
|
324 |
}
|
325 |
|
326 |
// quick edit and bulk edit
|
327 |
-
|
|
|
328 |
// bulk edit does not modify the language
|
329 |
-
if (isset($
|
330 |
-
check_admin_referer('bulk-posts');
|
331 |
-
$lang = $this->model->
|
332 |
}
|
333 |
// a language is set in the language dropdown
|
334 |
else {
|
335 |
-
isset($
|
336 |
|
337 |
-
$old_lang = $this->model->
|
338 |
-
$this->model->
|
339 |
|
340 |
// checks if the new language already exists in the translation group
|
341 |
-
if ($old_lang && $old_lang->slug != $lang->slug) {
|
342 |
-
$translations = $this->model->get_translations(
|
343 |
|
344 |
// if yes, separate this post from the translation group
|
345 |
-
if (array_key_exists($lang->slug, $translations)) {
|
346 |
-
$this->model->delete_translation(
|
347 |
}
|
348 |
|
349 |
-
elseif (array_key_exists($old_lang->slug, $translations)) {
|
350 |
-
unset($translations[$old_lang->slug]);
|
351 |
-
$this->model->save_translations(
|
352 |
}
|
353 |
}
|
354 |
}
|
@@ -356,45 +376,48 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
356 |
|
357 |
// quick press
|
358 |
// 'post-quickpress-save', 'post-quickpress-publish' = backward compatibility WP < 3.8
|
359 |
-
elseif (isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('post-quickpress-save', 'post-quickpress-publish', 'post-quickdraft-save'))) {
|
360 |
-
check_admin_referer('add-' . $post->post_type);
|
361 |
-
$this->model->
|
362 |
}
|
363 |
|
364 |
-
else
|
365 |
-
$this->set_default_language($post_id);
|
|
|
366 |
|
367 |
// make sure we get save terms in the right language (especially tags with same name in different languages)
|
368 |
-
if (!empty($lang)) {
|
369 |
-
|
370 |
// FIXME quite a lot of queries in foreach
|
371 |
-
foreach ($this->model->get_translated_taxonomies() as $tax) {
|
372 |
-
$terms = get_the_terms($post_id, $tax);
|
373 |
|
374 |
-
if (is_array($terms)) {
|
375 |
$newterms = array();
|
376 |
-
foreach ($terms as $term) {
|
377 |
-
// check if the term is in the correct language or if a translation exist (mainly for default category)
|
378 |
-
if ($newterm = $this->model->
|
379 |
$newterms[] = (int) $newterm;
|
|
|
380 |
|
381 |
-
// or choose the correct language for tags (initially defined by name)
|
382 |
-
elseif ($newterm = $this->model->term_exists($term->name, $tax, $term->parent, $lang))
|
383 |
$newterms[] = (int) $newterm; // cast is important otherwise we get 'numeric' tags
|
|
|
384 |
|
385 |
// or create the term in the correct language
|
386 |
-
elseif (!is_wp_error($term_info = wp_insert_term($term->name, $tax)))
|
387 |
$newterms[] = (int) $term_info['term_id'];
|
|
|
388 |
}
|
389 |
|
390 |
-
wp_set_object_terms($post_id, $newterms, $tax);
|
391 |
}
|
392 |
}
|
393 |
}
|
394 |
}
|
395 |
|
396 |
/*
|
397 |
-
* called when a post (or page) is saved, published or updated
|
398 |
* saves languages and translations
|
399 |
*
|
400 |
* @since 0.1
|
@@ -403,29 +426,55 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
403 |
* @param object $post
|
404 |
* @param bool $update whether it is an update or not
|
405 |
*/
|
406 |
-
public function save_post($post_id, $post, $update) {
|
407 |
// does nothing except on post types which are filterable
|
408 |
-
if (
|
409 |
return;
|
|
|
410 |
|
411 |
-
if ($id = wp_is_post_revision($post_id))
|
412 |
$post_id = $id;
|
|
|
413 |
|
414 |
// capability check
|
415 |
// as 'wp_insert_post' can be called from outside WP admin
|
416 |
-
$post_type_object = get_post_type_object($post->post_type);
|
417 |
-
if (($update && current_user_can($post_type_object->cap->edit_post, $post_id)) || (
|
418 |
-
$this->save_language($post_id, $post);
|
419 |
|
420 |
-
if (isset($_POST['post_tr_lang']))
|
421 |
-
$translations = $this->save_translations($post_id, $_POST['post_tr_lang']);
|
|
|
422 |
|
423 |
-
do_action('pll_save_post', $post_id, $post, empty($translations) ? $this->model->get_translations(
|
424 |
}
|
425 |
|
426 |
// attempts to set a default language even if no capability
|
427 |
-
else
|
428 |
-
$this->set_default_language($post_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
}
|
430 |
|
431 |
/*
|
@@ -437,9 +486,10 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
437 |
*
|
438 |
* @param int $post_id
|
439 |
*/
|
440 |
-
public function delete_post($post_id) {
|
441 |
-
if (!wp_is_post_revision($post_id))
|
442 |
-
$this->model->delete_translation(
|
|
|
443 |
}
|
444 |
|
445 |
/*
|
@@ -451,27 +501,12 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
451 |
* @param object $post
|
452 |
* @return array modified arguments
|
453 |
*/
|
454 |
-
public function page_attributes_dropdown_pages_args($dropdown_args, $post) {
|
455 |
-
$dropdown_args['lang'] = isset($_POST['lang']) ? $this->model->get_language($_POST['lang']) : $this->model->
|
456 |
-
if (
|
457 |
$dropdown_args['lang'] = $this->pref_lang;
|
|
|
458 |
|
459 |
return $dropdown_args;
|
460 |
}
|
461 |
-
|
462 |
-
/*
|
463 |
-
* returns html markup for a translation link
|
464 |
-
*
|
465 |
-
* @since 1.4
|
466 |
-
*
|
467 |
-
* @param int $post_id translation post id
|
468 |
-
* @return string
|
469 |
-
*/
|
470 |
-
public function edit_translation_link($post_id) {
|
471 |
-
return sprintf(
|
472 |
-
'<a href="%1$s" class="pll_icon_edit" title="%2$s"></a>',
|
473 |
-
esc_url(get_edit_post_link($post_id)),
|
474 |
-
__('Edit', 'polylang')
|
475 |
-
);
|
476 |
-
}
|
477 |
}
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
+
public function __construct( &$polylang ) {
|
19 |
+
parent::__construct( $polylang );
|
20 |
$this->options = &$polylang->options;
|
21 |
$this->curlang = &$polylang->curlang;
|
22 |
|
23 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
|
24 |
|
25 |
// filters posts, pages and media by language
|
26 |
+
add_action( 'parse_query', array( &$this, 'parse_query' ) );
|
27 |
|
28 |
// adds the Languages box in the 'Edit Post' and 'Edit Page' panels
|
29 |
+
add_action( 'add_meta_boxes', array( &$this, 'add_meta_boxes' ) );
|
30 |
|
31 |
// ajax response for changing the language in the post metabox
|
32 |
+
add_action( 'wp_ajax_post_lang_choice', array( &$this, 'post_lang_choice' ) );
|
33 |
+
add_action( 'wp_ajax_pll_posts_not_translated', array( &$this, 'ajax_posts_not_translated' ) );
|
34 |
|
35 |
// adds actions and filters related to languages when creating, saving or deleting posts and pages
|
36 |
+
add_action( 'save_post', array( &$this, 'save_post' ), 21, 3 ); // priority 21 to come after advanced custom fields ( 20 ) and before the event calendar which breaks everything after 25
|
37 |
+
add_filter( 'wp_insert_post_parent', array( &$this, 'wp_insert_post_parent' ), 10, 4 );
|
38 |
+
add_action( 'before_delete_post', array( &$this, 'delete_post' ) );
|
39 |
+
if ( $this->options['media_support'] ) {
|
40 |
+
add_action( 'delete_attachment', array( &$this, 'delete_post' ) ); // action shared with media
|
41 |
+
}
|
42 |
|
43 |
// filters the pages by language in the parent dropdown list in the page attributes metabox
|
44 |
+
add_filter( 'page_attributes_dropdown_pages_args', array( &$this, 'page_attributes_dropdown_pages_args' ), 10, 2 );
|
45 |
}
|
46 |
|
47 |
/*
|
56 |
$screen = get_current_screen();
|
57 |
|
58 |
//hierarchical taxonomies
|
59 |
+
if ( 'edit' == $screen->base && $taxonomies = get_object_taxonomies( $screen->post_type, 'object' ) ) {
|
60 |
// get translated hierarchical taxonomies
|
61 |
+
foreach ( $taxonomies as $taxonomy ) {
|
62 |
+
if ( $taxonomy->hierarchical && $this->model->is_translated_taxonomy( $taxonomy->name ) ) {
|
63 |
$hierarchical_taxonomies[] = $taxonomy->name;
|
64 |
+
}
|
65 |
}
|
66 |
|
67 |
+
if ( ! empty( $hierarchical_taxonomies ) ) {
|
68 |
+
$terms = get_terms( $hierarchical_taxonomies, array( 'get' => 'all' ) );
|
69 |
|
70 |
+
foreach ( $terms as $term ) {
|
71 |
+
if ( $lang = $this->model->term->get_language( $term->term_id ) ) {
|
72 |
+
$term_languages[ $lang->slug ][ $term->taxonomy ][] = $term->term_id;
|
73 |
+
}
|
74 |
}
|
75 |
|
76 |
// send all these data to javascript
|
77 |
+
if ( ! empty( $term_languages ) ) {
|
78 |
+
wp_localize_script( 'pll_post', 'pll_term_languages', $term_languages );
|
79 |
}
|
80 |
}
|
81 |
}
|
82 |
+
|
83 |
// hierarchical post types
|
84 |
+
if ( 'edit' == $screen->base && is_post_type_hierarchical( $screen->post_type ) ) {
|
85 |
$pages = get_pages();
|
86 |
|
87 |
+
foreach ( $pages as $page ) {
|
88 |
+
if ( $lang = $this->model->post->get_language( $page->ID ) ) {
|
89 |
+
$page_languages[ $lang->slug ][] = $page->ID;
|
90 |
+
}
|
91 |
}
|
92 |
|
93 |
// send all these data to javascript
|
94 |
+
if ( ! empty( $page_languages ) ) {
|
95 |
+
wp_localize_script( 'pll_post', 'pll_page_languages', $page_languages );
|
96 |
}
|
97 |
}
|
98 |
}
|
104 |
*
|
105 |
* @param object $query a WP_Query object
|
106 |
*/
|
107 |
+
public function parse_query( $query ) {
|
108 |
$qvars = &$query->query_vars;
|
109 |
|
110 |
// do not filter post types such as nav_menu_item
|
111 |
+
if ( isset( $qvars['post_type'] ) && ! $this->model->is_translated_post_type( $qvars['post_type'] ) ) {
|
112 |
+
unset( $qvars['lang'] );
|
113 |
return;
|
114 |
}
|
115 |
|
116 |
+
if ( isset( $qvars['post_type'] ) && ! isset( $qvars['lang'] ) ) {
|
117 |
+
// filters the list of media ( or wp-links ) by language when uploading from post
|
118 |
+
if ( isset( $_REQUEST['pll_post_id'] ) && $lang = $this->model->post->get_language( (int) $_REQUEST['pll_post_id'] ) ) {
|
119 |
+
$query->set( 'lang', $lang->slug );
|
120 |
+
} elseif ( ! empty( $this->curlang ) ) {
|
|
|
121 |
$qvars['lang'] = $this->curlang->slug;
|
122 |
+
}
|
123 |
}
|
124 |
|
125 |
+
if ( isset( $qvars['lang'] ) && 'all' === $qvars['lang'] ) {
|
126 |
+
unset( $qvars['lang'] );
|
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
|
134 |
*
|
135 |
* @param string $post_type
|
136 |
*/
|
137 |
+
public function add_meta_boxes( $post_type ) {
|
138 |
+
if ( $this->model->is_translated_post_type( $post_type ) ) {
|
139 |
+
add_meta_box( 'ml_box', __( 'Languages','polylang' ), array( &$this, 'post_language' ), $post_type, 'side', 'high' );
|
140 |
+
}
|
141 |
}
|
142 |
|
143 |
/*
|
148 |
public function post_language() {
|
149 |
global $post_ID;
|
150 |
$post_id = $post_ID;
|
151 |
+
$post_type = get_post_type( $post_ID );
|
152 |
|
153 |
+
$lang = ( $lg = $this->model->post->get_language( $post_ID ) ) ? $lg :
|
154 |
+
( isset( $_GET['new_lang'] ) ? $this->model->get_language( $_GET['new_lang'] ) :
|
155 |
+
$this->pref_lang );
|
156 |
|
157 |
$dropdown = new PLL_Walker_Dropdown();
|
158 |
|
159 |
+
wp_nonce_field( 'pll_language', '_pll_nonce' );
|
160 |
|
161 |
+
// NOTE: the class "tags-input" allows to include the field in the autosave $_POST ( see autosave.js )
|
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',
|
170 |
+
$dropdown->walk( $this->model->get_languages_list(), array(
|
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 |
/*
|
187 |
* @since 0.2
|
188 |
*/
|
189 |
public function post_lang_choice() {
|
190 |
+
check_ajax_referer( 'pll_language', '_pll_nonce' );
|
191 |
|
192 |
global $post_ID; // obliged to use the global variable for wp_popular_terms_checklist
|
193 |
+
$post_id = $post_ID = (int) $_POST['post_id'];
|
194 |
+
$lang = $this->model->get_language( $_POST['lang'] );
|
|
|
195 |
|
196 |
+
$post_type = $_POST['post_type'];
|
197 |
+
$post_type_object = get_post_type_object( $post_type );
|
198 |
+
if ( ! current_user_can( $post_type_object->cap->edit_post, $post_ID ) ) {
|
199 |
+
wp_die( -1 );
|
200 |
+
}
|
201 |
|
202 |
+
$this->model->post->set_language( $post_ID, $lang ); // save language, useful to set the language when uploading media from post
|
203 |
|
204 |
ob_start();
|
205 |
+
if ( $lang ) {
|
206 |
+
include( PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php' );
|
207 |
+
}
|
208 |
+
$x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
|
209 |
ob_end_clean();
|
210 |
|
211 |
// categories
|
212 |
+
if ( isset( $_POST['taxonomies'] ) ) {
|
213 |
// not set for pages
|
214 |
+
foreach ( $_POST['taxonomies'] as $taxname ) {
|
215 |
+
$taxonomy = get_taxonomy( $taxname );
|
216 |
|
217 |
ob_start();
|
218 |
+
$popular_ids = wp_popular_terms_checklist( $taxonomy->name );
|
219 |
$supplemental['populars'] = ob_get_contents();
|
220 |
ob_end_clean();
|
221 |
|
222 |
ob_start();
|
223 |
// use $post_ID to remember ckecked terms in case we come back to the original language
|
224 |
+
wp_terms_checklist( $post_ID, array( 'taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids ) );
|
225 |
$supplemental['all'] = ob_get_contents();
|
226 |
ob_end_clean();
|
227 |
|
228 |
+
$supplemental['dropdown'] = wp_dropdown_categories( array(
|
229 |
'taxonomy' => $taxonomy->name,
|
230 |
'hide_empty' => 0,
|
231 |
'name' => 'new'.$taxonomy->name.'_parent',
|
232 |
'orderby' => 'name',
|
233 |
'hierarchical' => 1,
|
234 |
'show_option_none' => '— '.$taxonomy->labels->parent_item.' —',
|
235 |
+
'echo' => 0,
|
236 |
+
) );
|
237 |
|
238 |
+
$x->Add( array( 'what' => 'taxonomy', 'data' => $taxonomy->name, 'supplemental' => $supplemental ) );
|
239 |
}
|
240 |
}
|
241 |
|
242 |
+
// parent dropdown list ( only for hierarchical post types )
|
243 |
+
if ( in_array( $post_type, get_post_types( array( 'hierarchical' => true ) ) ) ) {
|
244 |
+
$post = get_post( $post_ID );
|
245 |
|
246 |
// args and filter from 'page_attributes_meta_box' in wp-admin/includes/meta-boxes.php of WP 4.2.1
|
247 |
$dropdown_args = array(
|
249 |
'exclude_tree' => $post->ID,
|
250 |
'selected' => $post->post_parent,
|
251 |
'name' => 'parent_id',
|
252 |
+
'show_option_none' => __( '(no parent)' ),
|
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 ) ) );
|
259 |
}
|
260 |
|
261 |
// flag
|
262 |
+
$x->Add( array( 'what' => 'flag', 'data' => empty( $lang->flag ) ? esc_html( $lang->slug ) : $lang->flag ) );
|
263 |
|
264 |
$x->send();
|
265 |
}
|
270 |
* @since 1.5
|
271 |
*/
|
272 |
public function ajax_posts_not_translated() {
|
273 |
+
check_ajax_referer( 'pll_language', '_pll_nonce' );
|
274 |
+
|
275 |
+
if ( ! post_type_exists( $_GET['post_type'] ) ) {
|
276 |
+
die( 0 );
|
277 |
+
}
|
278 |
+
|
279 |
+
$post_language = $this->model->get_language( $_GET['post_language'] );
|
280 |
+
$translation_language = $this->model->get_language( $_GET['translation_language'] );
|
281 |
+
|
282 |
// don't order by title: see https://wordpress.org/support/topic/find-translated-post-when-10-is-not-enough
|
283 |
$args = array(
|
284 |
+
's' => wp_unslash( $_GET['term'] ),
|
285 |
'suppress_filters' => 0, // to make the post_fields filter work
|
286 |
'lang' => 0, // avoid admin language filter
|
287 |
'numberposts' => 20, // limit to 20 posts
|
288 |
'post_status' => 'any',
|
289 |
+
'post_type' => $_GET['post_type'],
|
290 |
+
'tax_query' => array( array(
|
291 |
'taxonomy' => 'language',
|
292 |
'field' => 'term_taxonomy_id', // WP 3.5+
|
293 |
+
'terms' => $translation_language->term_taxonomy_id,
|
294 |
+
) )
|
295 |
);
|
296 |
+
|
297 |
// allow plugins to change args help fixing edge cases: see same topic as above
|
298 |
+
$args = apply_filters( 'pll_ajax_posts_not_translated_args', $args );
|
299 |
+
$posts = get_posts( $args );
|
300 |
|
301 |
$return = array();
|
302 |
|
303 |
+
foreach ( $posts as $key => $post ) {
|
304 |
+
if ( ! $this->model->post->get_translation( $post->ID, $post_language ) ) {
|
305 |
+
$return[] = array(
|
306 |
+
'id' => $post->ID,
|
307 |
+
'value' => $post->post_title,
|
308 |
+
'link' => $this->links->edit_post_translation_link( $post->ID ),
|
309 |
+
);
|
310 |
+
}
|
311 |
}
|
312 |
|
313 |
// add current translation in list
|
314 |
+
if ( $post_id = $this->model->post->get_translation( (int) $_GET['pll_post_id'], $translation_language ) ) {
|
315 |
+
$post = get_post( $post_id );
|
316 |
+
array_unshift( $return, array(
|
317 |
'id' => $post_id,
|
318 |
'value' => $post->post_title,
|
319 |
+
'link' => $this->links->edit_post_translation_link( $post_id ),
|
320 |
+
) );
|
321 |
}
|
322 |
|
323 |
+
wp_die( json_encode( $return ) );
|
324 |
}
|
325 |
|
326 |
/*
|
332 |
* @param int $post_id
|
333 |
* @param array $post
|
334 |
*/
|
335 |
+
protected function save_language( $post_id, $post ) {
|
336 |
// security checks are necessary to accept language modifications
|
337 |
// as 'wp_insert_post' can be called from outside WP admin
|
338 |
|
339 |
// edit post
|
340 |
+
if ( isset( $_POST['post_lang_choice'] ) ) {
|
341 |
+
check_admin_referer( 'pll_language', '_pll_nonce' );
|
342 |
+
$this->model->post->set_language( $post_id, $lang = $this->model->get_language( $_POST['post_lang_choice'] ) );
|
343 |
}
|
344 |
|
345 |
// quick edit and bulk edit
|
346 |
+
// POST for quick edit, GET for bulk edit
|
347 |
+
elseif ( isset( $_REQUEST['inline_lang_choice'] ) ) {
|
348 |
// bulk edit does not modify the language
|
349 |
+
if ( isset( $_GET['bulk_edit'] ) && -1 == $_REQUEST['inline_lang_choice'] ) {
|
350 |
+
check_admin_referer( 'bulk-posts' );
|
351 |
+
$lang = $this->model->post->get_language( $post_id ); // get the post language for later use when saving terms
|
352 |
}
|
353 |
// a language is set in the language dropdown
|
354 |
else {
|
355 |
+
isset( $_GET['bulk_edit'] ) ? check_admin_referer( 'bulk-posts' ) : check_admin_referer( 'inlineeditnonce', '_inline_edit' );
|
356 |
|
357 |
+
$old_lang = $this->model->post->get_language( $post_id ); // stores the old language
|
358 |
+
$this->model->post->set_language( $post_id, $lang = $this->model->get_language( $_REQUEST['inline_lang_choice'] ) ); // set new language
|
359 |
|
360 |
// checks if the new language already exists in the translation group
|
361 |
+
if ( $old_lang && $old_lang->slug != $lang->slug ) {
|
362 |
+
$translations = $this->model->post->get_translations( $post_id );
|
363 |
|
364 |
// if yes, separate this post from the translation group
|
365 |
+
if ( array_key_exists( $lang->slug, $translations ) ) {
|
366 |
+
$this->model->post->delete_translation( $post_id );
|
367 |
}
|
368 |
|
369 |
+
elseif ( array_key_exists( $old_lang->slug, $translations ) ) {
|
370 |
+
unset( $translations[ $old_lang->slug ] );
|
371 |
+
$this->model->post->save_translations( $post_id, $translations );
|
372 |
}
|
373 |
}
|
374 |
}
|
376 |
|
377 |
// quick press
|
378 |
// 'post-quickpress-save', 'post-quickpress-publish' = backward compatibility WP < 3.8
|
379 |
+
elseif ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], array( 'post-quickpress-save', 'post-quickpress-publish', 'post-quickdraft-save' ) ) ) {
|
380 |
+
check_admin_referer( 'add-' . $post->post_type );
|
381 |
+
$this->model->post->set_language( $post_id, $lang = $this->pref_lang ); // default language for Quick draft
|
382 |
}
|
383 |
|
384 |
+
else {
|
385 |
+
$this->set_default_language( $post_id );
|
386 |
+
}
|
387 |
|
388 |
// make sure we get save terms in the right language (especially tags with same name in different languages)
|
389 |
+
if ( ! empty( $lang ) ) {
|
|
|
390 |
// FIXME quite a lot of queries in foreach
|
391 |
+
foreach ( $this->model->get_translated_taxonomies() as $tax ) {
|
392 |
+
$terms = get_the_terms( $post_id, $tax );
|
393 |
|
394 |
+
if ( is_array( $terms ) ) {
|
395 |
$newterms = array();
|
396 |
+
foreach ( $terms as $term ) {
|
397 |
+
// check if the term is in the correct language or if a translation exist ( mainly for default category )
|
398 |
+
if ( $newterm = $this->model->term->get( $term->term_id, $lang ) ) {
|
399 |
$newterms[] = (int) $newterm;
|
400 |
+
}
|
401 |
|
402 |
+
// or choose the correct language for tags ( initially defined by name )
|
403 |
+
elseif ( $newterm = $this->model->term_exists( $term->name, $tax, $term->parent, $lang ) ) {
|
404 |
$newterms[] = (int) $newterm; // cast is important otherwise we get 'numeric' tags
|
405 |
+
}
|
406 |
|
407 |
// or create the term in the correct language
|
408 |
+
elseif ( ! is_wp_error( $term_info = wp_insert_term( $term->name, $tax ) ) ) {
|
409 |
$newterms[] = (int) $term_info['term_id'];
|
410 |
+
}
|
411 |
}
|
412 |
|
413 |
+
wp_set_object_terms( $post_id, $newterms, $tax );
|
414 |
}
|
415 |
}
|
416 |
}
|
417 |
}
|
418 |
|
419 |
/*
|
420 |
+
* called when a post ( or page ) is saved, published or updated
|
421 |
* saves languages and translations
|
422 |
*
|
423 |
* @since 0.1
|
426 |
* @param object $post
|
427 |
* @param bool $update whether it is an update or not
|
428 |
*/
|
429 |
+
public function save_post( $post_id, $post, $update ) {
|
430 |
// does nothing except on post types which are filterable
|
431 |
+
if ( ! $this->model->is_translated_post_type( $post->post_type ) ) {
|
432 |
return;
|
433 |
+
}
|
434 |
|
435 |
+
if ( $id = wp_is_post_revision( $post_id ) ) {
|
436 |
$post_id = $id;
|
437 |
+
}
|
438 |
|
439 |
// capability check
|
440 |
// as 'wp_insert_post' can be called from outside WP admin
|
441 |
+
$post_type_object = get_post_type_object( $post->post_type );
|
442 |
+
if ( ( $update && current_user_can( $post_type_object->cap->edit_post, $post_id ) ) || ( ! $update && current_user_can( $post_type_object->cap->create_posts ) ) ) {
|
443 |
+
$this->save_language( $post_id, $post );
|
444 |
|
445 |
+
if ( isset( $_POST['post_tr_lang'] ) ) {
|
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 |
|
452 |
// attempts to set a default language even if no capability
|
453 |
+
else {
|
454 |
+
$this->set_default_language( $post_id );
|
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
|
462 |
+
*
|
463 |
+
* @param int $post_parent Post parent ID.
|
464 |
+
* @param int $post_id Post ID.
|
465 |
+
* @param array $new_postarr Array of parsed post data.
|
466 |
+
* @param array $postarr Array of sanitized, but otherwise unmodified post data.
|
467 |
+
* @return int
|
468 |
+
*/
|
469 |
+
public function wp_insert_post_parent( $post_parent, $post_id, $new_postarr, $postarr ) {
|
470 |
+
if ( isset( $postarr['bulk_edit'] ) ) {
|
471 |
+
check_admin_referer( 'bulk-posts' );
|
472 |
+
$lang = -1 == $postarr['inline_lang_choice'] ?
|
473 |
+
$this->model->post->get_language( $post_id ) :
|
474 |
+
$this->model->get_language( $postarr['inline_lang_choice'] );
|
475 |
+
$post_parent = $this->model->post->get_translation( $post_parent, $lang );
|
476 |
+
}
|
477 |
+
return $post_parent;
|
478 |
}
|
479 |
|
480 |
/*
|
486 |
*
|
487 |
* @param int $post_id
|
488 |
*/
|
489 |
+
public function delete_post( $post_id ) {
|
490 |
+
if ( ! wp_is_post_revision( $post_id ) ) {
|
491 |
+
$this->model->post->delete_translation( $post_id );
|
492 |
+
}
|
493 |
}
|
494 |
|
495 |
/*
|
501 |
* @param object $post
|
502 |
* @return array modified arguments
|
503 |
*/
|
504 |
+
public function page_attributes_dropdown_pages_args( $dropdown_args, $post ) {
|
505 |
+
$dropdown_args['lang'] = isset( $_POST['lang'] ) ? $this->model->get_language( $_POST['lang'] ) : $this->model->post->get_language( $post->ID ); // ajax or not ?
|
506 |
+
if ( ! $dropdown_args['lang'] ) {
|
507 |
$dropdown_args['lang'] = $this->pref_lang;
|
508 |
+
}
|
509 |
|
510 |
return $dropdown_args;
|
511 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
}
|
admin/admin-filters-term.php
CHANGED
@@ -15,48 +15,48 @@ class PLL_Admin_Filters_Term {
|
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
-
public function __construct(&$polylang) {
|
19 |
$this->links = &$polylang->links;
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->options = &$polylang->options;
|
22 |
$this->curlang = &$polylang->curlang;
|
23 |
$this->pref_lang = &$polylang->pref_lang;
|
24 |
|
25 |
-
foreach ($this->model->get_translated_taxonomies() as $tax) {
|
26 |
// adds the language field in the 'Categories' and 'Post Tags' panels
|
27 |
-
add_action($tax.'_add_form_fields', array(&$this, 'add_term_form'));
|
28 |
|
29 |
// adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
|
30 |
-
add_action($tax.'_edit_form_fields', array(&$this, 'edit_term_form'));
|
31 |
|
32 |
// adds action related to languages when deleting categories and post tags
|
33 |
-
add_action('delete_'.$tax, array(&$this, 'delete_term'));
|
34 |
}
|
35 |
|
36 |
// adds actions related to languages when creating or saving categories and post tags
|
37 |
-
add_filter('wp_dropdown_cats', array(&$this, 'wp_dropdown_cats'));
|
38 |
-
add_action('create_term', array(&$this, 'save_term'), 999, 3);
|
39 |
-
add_action('edit_term', array(&$this, 'save_term'), 999, 3); // late as it may conflict with other plugins, see http://wordpress.org/support/topic/polylang-and-wordpress-seo-by-yoast
|
40 |
-
add_action('pre_post_update', array(&$this, 'pre_post_update'));
|
41 |
-
add_filter('pre_term_name', array(&$this, 'pre_term_name'));
|
42 |
-
add_filter('pre_term_slug', array(&$this, 'pre_term_slug'), 10, 2);
|
43 |
|
44 |
// ajax response for edit term form
|
45 |
-
add_action('wp_ajax_term_lang_choice', array(&$this,'term_lang_choice'));
|
46 |
-
add_action('wp_ajax_pll_terms_not_translated', array(&$this,'ajax_terms_not_translated'));
|
47 |
|
48 |
// adds cache domain when querying terms
|
49 |
-
add_filter('get_terms_args', array(&$this, 'get_terms_args'), 10, 2);
|
50 |
|
51 |
// filters categories and post tags by language
|
52 |
-
add_filter('terms_clauses', array(&$this, 'terms_clauses'), 10, 3);
|
53 |
|
54 |
// allows to get the default categories in all languages
|
55 |
-
add_filter('option_default_category', array(&$this, 'option_default_category'));
|
56 |
-
add_action('update_option_default_category', array(&$this, 'update_option_default_category'), 10, 2);
|
57 |
|
58 |
// updates the translations term ids when splitting a shared term
|
59 |
-
add_action('split_shared_term', array(&$this, 'split_shared_term'), 10, 4); // WP 4.2
|
60 |
}
|
61 |
|
62 |
/*
|
@@ -66,39 +66,42 @@ class PLL_Admin_Filters_Term {
|
|
66 |
*/
|
67 |
public function add_term_form() {
|
68 |
$taxonomy = $_GET['taxonomy'];
|
69 |
-
$post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type'];
|
70 |
|
71 |
-
if (!taxonomy_exists($taxonomy) || !post_type_exists($post_type))
|
72 |
return;
|
|
|
73 |
|
74 |
-
$lang = isset($_GET['new_lang']) ? $this->model->get_language($_GET['new_lang']) : $this->pref_lang;
|
75 |
$dropdown = new PLL_Walker_Dropdown();
|
76 |
|
77 |
-
wp_nonce_field('pll_language', '_pll_nonce');
|
78 |
|
79 |
-
printf('
|
80 |
<div class="form-field">
|
81 |
<label for="term_lang_choice">%s</label>
|
82 |
<div id="select-add-term-language">%s</div>
|
83 |
<p>%s</p>
|
84 |
</div>',
|
85 |
-
__('Language', 'polylang'),
|
86 |
-
$dropdown->walk($this->model->get_languages_list(), array(
|
87 |
'name' => 'term_lang_choice',
|
88 |
'value' => 'term_id',
|
89 |
'selected' => $lang ? $lang->term_id : '',
|
90 |
'flag' => true
|
91 |
-
)),
|
92 |
-
__('Sets the language', 'polylang')
|
93 |
);
|
94 |
|
95 |
-
if (!empty($_GET['from_tag']))
|
96 |
-
printf('<input type="hidden" name="from_tag" value="%d" />', $_GET['from_tag']);
|
|
|
97 |
|
98 |
// adds translation fields
|
99 |
echo '<div id="term-translations" class="form-field">';
|
100 |
-
if ($lang)
|
101 |
-
include(PLL_ADMIN_INC.'/view-translations-term.php');
|
|
|
102 |
echo '</div>'."\n";
|
103 |
}
|
104 |
|
@@ -107,62 +110,65 @@ class PLL_Admin_Filters_Term {
|
|
107 |
*
|
108 |
* @since 0.1
|
109 |
*/
|
110 |
-
public function edit_term_form($tag) {
|
111 |
$term_id = $tag->term_id;
|
112 |
-
$lang = $this->model->
|
113 |
$taxonomy = $tag->taxonomy;
|
114 |
-
$post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type'];
|
115 |
|
116 |
-
if (!post_type_exists($post_type))
|
117 |
return;
|
|
|
118 |
|
119 |
$dropdown = new PLL_Walker_Dropdown();
|
120 |
|
121 |
// disable the language dropdown and the translations input fields for default categories to prevent removal
|
122 |
-
$disabled = in_array(get_option('default_category'), $this->model->get_translations(
|
123 |
|
124 |
-
wp_nonce_field('pll_language', '_pll_nonce');
|
125 |
|
126 |
-
printf('
|
127 |
<tr class="form-field">
|
128 |
<th scope="row">
|
129 |
<label for="term_lang_choice">%s</label>
|
130 |
</th>
|
131 |
<td id="select-edit-term-language">
|
132 |
%s<br />
|
133 |
-
<
|
134 |
</td>
|
135 |
</tr>',
|
136 |
-
__('Language', 'polylang'),
|
137 |
-
$dropdown->walk($this->model->get_languages_list(), array(
|
138 |
'name' => 'term_lang_choice',
|
139 |
'value' => 'term_id',
|
140 |
'selected' => $lang ? $lang->term_id : '',
|
141 |
'disabled' => $disabled,
|
142 |
'flag' => true
|
143 |
-
)),
|
144 |
-
__('Sets the language', 'polylang')
|
145 |
);
|
146 |
|
147 |
echo '<tr id="term-translations" class="form-field">';
|
148 |
-
if ($lang)
|
149 |
-
include(PLL_ADMIN_INC.'/view-translations-term.php');
|
|
|
150 |
echo '</tr>'."\n";
|
151 |
}
|
152 |
|
153 |
/*
|
154 |
-
* translates term parent if exists when using "Add new" (translation)
|
155 |
*
|
156 |
* @since 0.7
|
157 |
*
|
158 |
* @param string html markup for dropdown list of categories
|
159 |
* @return string modified html
|
160 |
*/
|
161 |
-
public function wp_dropdown_cats($output) {
|
162 |
-
if (isset($_GET['taxonomy'], $_GET['from_tag'], $_GET['new_lang']) && taxonomy_exists($_GET['taxonomy']) && $id = get_term((int) $_GET['from_tag'], $_GET['taxonomy'])->parent) {
|
163 |
-
$lang = $this->model->get_language($_GET['new_lang']);
|
164 |
-
if ($parent = $this->model->get_translation(
|
165 |
-
return str_replace('"'.$parent.'"', '"'.$parent.'" selected="selected"', $output);
|
|
|
166 |
}
|
167 |
return $output;
|
168 |
}
|
@@ -174,9 +180,10 @@ class PLL_Admin_Filters_Term {
|
|
174 |
*
|
175 |
* @param int $post_id
|
176 |
*/
|
177 |
-
public function pre_post_update($post_id) {
|
178 |
-
if (isset($_GET['bulk_edit']))
|
179 |
$this->post_id = $post_id;
|
|
|
180 |
}
|
181 |
|
182 |
/*
|
@@ -187,14 +194,15 @@ class PLL_Admin_Filters_Term {
|
|
187 |
* @param int $term_id
|
188 |
* @param string $taxonomy
|
189 |
*/
|
190 |
-
protected function set_default_language($term_id, $taxonomy) {
|
191 |
-
if (
|
192 |
// sets language from term parent if exists thanks to Scott Kingsley Clark
|
193 |
-
if (($term = get_term($term_id, $taxonomy)) && !empty($term->parent) && $parent_lang = $this->model->
|
194 |
-
$this->model->
|
195 |
-
|
196 |
-
else
|
197 |
-
$this->model->
|
|
|
198 |
}
|
199 |
}
|
200 |
|
@@ -206,94 +214,96 @@ class PLL_Admin_Filters_Term {
|
|
206 |
* @param int $term_id
|
207 |
* @param string $taxonomy
|
208 |
*/
|
209 |
-
protected function save_language($term_id, $taxonomy) {
|
210 |
global $wpdb;
|
211 |
// security checks are necessary to accept language modifications
|
212 |
// as 'wp_update_term' can be called from outside WP admin
|
213 |
|
214 |
// edit tags
|
215 |
-
if (isset($_POST['term_lang_choice'])) {
|
216 |
-
if ('add-' . $taxonomy == $_POST['action'])
|
217 |
-
check_ajax_referer($_POST['action'], '_ajax_nonce-add-' . $taxonomy); // category metabox
|
218 |
-
|
219 |
-
else
|
220 |
-
check_admin_referer('pll_language', '_pll_nonce'); // edit tags or tags metabox
|
|
|
221 |
|
222 |
-
$this->model->
|
223 |
}
|
224 |
|
225 |
// *post* bulk edit, in case a new term is created
|
226 |
-
elseif (isset($_GET['bulk_edit'], $_GET['inline_lang_choice'])) {
|
227 |
-
check_admin_referer('bulk-posts');
|
228 |
|
229 |
// bulk edit does not modify the language
|
230 |
// so we possibly create a tag in several languages
|
231 |
-
if ($_GET['inline_lang_choice']
|
232 |
// the language of the current term is set a according to the language of the current post
|
233 |
-
$this->model->
|
234 |
-
$term = get_term($term_id, $taxonomy);
|
235 |
|
236 |
// get all terms with the same name
|
237 |
// FIXME backward compatibility WP < 4.2
|
238 |
// no WP function to get all terms with the exact same name so let's use a custom query
|
239 |
-
// $terms = get_terms($taxonomy, array('name' => $term->name, 'hide_empty' => false, 'fields' => 'ids')); should be OK in 4.2
|
240 |
// I may need to rework the loop below
|
241 |
-
$terms = $wpdb->get_results($wpdb->prepare("
|
242 |
SELECT t.term_id FROM $wpdb->terms AS t
|
243 |
INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id
|
244 |
WHERE tt.taxonomy = %s AND t.name = %s",
|
245 |
$taxonomy, $term->name
|
246 |
-
));
|
247 |
|
248 |
// if we have several terms with the same name, they are translations of each other
|
249 |
-
if (count($terms) > 1) {
|
250 |
-
foreach ($terms as $term) {
|
251 |
-
$translations[$this->model->
|
252 |
}
|
253 |
|
254 |
-
$this->model->save_translations(
|
255 |
}
|
256 |
}
|
257 |
|
258 |
else {
|
259 |
-
$this->model->
|
260 |
}
|
261 |
}
|
262 |
|
263 |
// quick edit
|
264 |
-
elseif (isset($_POST['inline_lang_choice'])) {
|
265 |
check_ajax_referer(
|
266 |
-
isset($_POST['action']) && 'inline-save' == $_POST['action'] ? 'inlineeditnonce' : 'taxinlineeditnonce', // post quick edit or tag quick edit ?
|
267 |
'_inline_edit'
|
268 |
);
|
269 |
|
270 |
-
$old_lang = $this->model->
|
271 |
-
$lang = $this->model->get_language($_POST['inline_lang_choice']); // new language
|
272 |
-
$translations = $this->model->get_translations(
|
273 |
|
274 |
// checks if the new language already exists in the translation group
|
275 |
-
if ($old_lang && $old_lang->slug != $lang->slug) {
|
276 |
-
if (array_key_exists($lang->slug, $translations)) {
|
277 |
-
$this->model->delete_translation(
|
278 |
}
|
279 |
|
280 |
-
elseif (array_key_exists($old_lang->slug, $translations)) {
|
281 |
-
unset($translations[$old_lang->slug]);
|
282 |
-
$this->model->save_translations(
|
283 |
}
|
284 |
}
|
285 |
|
286 |
-
$this->model->
|
287 |
}
|
288 |
|
289 |
// edit post
|
290 |
-
elseif (isset($_POST['post_lang_choice'])) {// FIXME should be useless now
|
291 |
-
check_admin_referer('pll_language', '_pll_nonce');
|
292 |
-
$this->model->
|
293 |
}
|
294 |
|
295 |
-
else
|
296 |
-
$this->set_default_language($term_id, $taxonomy);
|
|
|
297 |
}
|
298 |
|
299 |
/*
|
@@ -304,18 +314,18 @@ class PLL_Admin_Filters_Term {
|
|
304 |
* @param int $term_id
|
305 |
* @return array
|
306 |
*/
|
307 |
-
protected function save_translations($term_id) {
|
308 |
// security check
|
309 |
// as 'wp_update_term' can be called from outside WP admin
|
310 |
-
check_admin_referer('pll_language', '_pll_nonce');
|
311 |
|
312 |
-
// save translations after checking the translated term is in the right language (as well as cast id to int)
|
313 |
-
foreach ($_POST['term_tr_lang'] as $lang => $tr_id) {
|
314 |
-
$tr_lang = $this->model->
|
315 |
-
$translations[$lang] = $tr_lang && $tr_lang->slug == $lang ? (int) $tr_id : 0;
|
316 |
}
|
317 |
|
318 |
-
$this->model->save_translations(
|
319 |
|
320 |
return $translations;
|
321 |
}
|
@@ -330,27 +340,30 @@ class PLL_Admin_Filters_Term {
|
|
330 |
* @param int $tt_id term taxononomy id
|
331 |
* @param string $taxonomy
|
332 |
*/
|
333 |
-
public function save_term($term_id, $tt_id, $taxonomy) {
|
334 |
// does nothing except on taxonomies which are filterable
|
335 |
-
if (
|
336 |
return;
|
|
|
337 |
|
338 |
// capability check
|
339 |
// as 'wp_update_term' can be called from outside WP admin
|
340 |
// 2nd test for creating tags when creating / editing a post
|
341 |
-
$tax = get_taxonomy($taxonomy);
|
342 |
-
if (current_user_can($tax->cap->edit_terms) || (isset($_POST['tax_input'][$taxonomy]) && current_user_can($tax->cap->assign_terms))) {
|
343 |
-
$this->save_language($term_id, $taxonomy);
|
344 |
|
345 |
-
if (isset($_POST['term_tr_lang']))
|
346 |
-
$translations = $this->save_translations($term_id);
|
|
|
347 |
|
348 |
-
do_action('pll_save_term', $term_id, $taxonomy, empty($translations) ? $this->model->get_translations(
|
349 |
}
|
350 |
|
351 |
// attempts to set a default language even if no capability
|
352 |
-
else
|
353 |
-
$this->set_default_language($term_id, $taxonomy);
|
|
|
354 |
}
|
355 |
|
356 |
/*
|
@@ -361,7 +374,7 @@ class PLL_Admin_Filters_Term {
|
|
361 |
* @param string $name term name
|
362 |
* @return string unmodified term name
|
363 |
*/
|
364 |
-
public function pre_term_name($name) {
|
365 |
return $this->pre_term_name = $name;
|
366 |
}
|
367 |
|
@@ -374,31 +387,34 @@ class PLL_Admin_Filters_Term {
|
|
374 |
* @param string $taxonomy
|
375 |
* @return string
|
376 |
*/
|
377 |
-
public function pre_term_slug($slug, $taxonomy) {
|
378 |
-
$name = sanitize_title($this->pre_term_name);
|
379 |
|
380 |
// if the new term has the same name as a language, we *need* to differentiate the term
|
381 |
// see http://core.trac.wordpress.org/ticket/23199
|
382 |
// backward compatibility with WP < 4.1
|
383 |
-
if (version_compare($GLOBALS['wp_version'], '4.1', '<') && term_exists($name, 'language') && !term_exists($name, $taxonomy) && (
|
384 |
$slug = $name . '-' . $taxonomy; // a convenient slug which may be modified later by the user
|
|
|
385 |
|
386 |
// if the term already exists in another language
|
387 |
-
if (
|
388 |
-
if (isset($_POST['term_lang_choice']))
|
389 |
-
$slug = $name . '-' . $this->model->get_language($_POST['term_lang_choice'])->slug;
|
|
|
390 |
|
391 |
-
elseif (isset($_POST['inline_lang_choice']))
|
392 |
-
$slug = $name . '-' . $this->model->get_language($_POST['inline_lang_choice'])->slug;
|
|
|
393 |
|
394 |
// *post* bulk edit, in case a new term is created
|
395 |
-
elseif (isset($_GET['bulk_edit'], $_GET['inline_lang_choice'])) {
|
396 |
// bulk edit does not modify the language
|
397 |
-
if ($_GET['inline_lang_choice']
|
398 |
-
$slug = $name . '-' . $this->model->
|
399 |
}
|
400 |
else {
|
401 |
-
$slug = $name . '-' . $this->model->get_language($_GET['inline_lang_choice'])->slug;
|
402 |
}
|
403 |
}
|
404 |
}
|
@@ -414,9 +430,9 @@ class PLL_Admin_Filters_Term {
|
|
414 |
*
|
415 |
* @param int $term_id
|
416 |
*/
|
417 |
-
public function delete_term($term_id) {
|
418 |
-
$this->model->delete_translation(
|
419 |
-
$this->model->
|
420 |
}
|
421 |
|
422 |
/*
|
@@ -425,25 +441,27 @@ class PLL_Admin_Filters_Term {
|
|
425 |
* @since 0.2
|
426 |
*/
|
427 |
public function term_lang_choice() {
|
428 |
-
check_ajax_referer('pll_language', '_pll_nonce');
|
429 |
|
430 |
-
$lang = $this->model->get_language($_POST['lang']);
|
431 |
-
$term_id = isset($_POST['term_id']) ? (int) $_POST['term_id'] : null;
|
432 |
$taxonomy = $_POST['taxonomy'];
|
433 |
$post_type = $_POST['post_type'];
|
434 |
|
435 |
-
if (!post_type_exists($post_type) || ! taxonomy_exists($taxonomy))
|
436 |
-
die(0);
|
|
|
437 |
|
438 |
ob_start();
|
439 |
-
if ($lang)
|
440 |
-
include(PLL_ADMIN_INC.'/view-translations-term.php');
|
441 |
-
|
|
|
442 |
ob_end_clean();
|
443 |
|
444 |
-
// parent dropdown list (only for hierarchical taxonomies)
|
445 |
// $args copied from edit_tags.php except echo
|
446 |
-
if (is_taxonomy_hierarchical($taxonomy)) {
|
447 |
$args = array(
|
448 |
'hide_empty' => 0,
|
449 |
'hide_if_empty' => false,
|
@@ -451,28 +469,30 @@ class PLL_Admin_Filters_Term {
|
|
451 |
'name' => 'parent',
|
452 |
'orderby' => 'name',
|
453 |
'hierarchical' => true,
|
454 |
-
'show_option_none' => __('None'),
|
455 |
'echo' => 0,
|
456 |
);
|
457 |
-
$x->Add(array('what' => 'parent', 'data' => wp_dropdown_categories($args)));
|
458 |
}
|
459 |
|
460 |
// tag cloud
|
461 |
// tests copied from edit_tags.php
|
462 |
else {
|
463 |
-
$tax = get_taxonomy($taxonomy);
|
464 |
-
if (!is_null($tax->labels->popular_items)) {
|
465 |
-
$args = array('taxonomy' => $taxonomy, 'echo' => false);
|
466 |
-
if (current_user_can($tax->cap->edit_terms))
|
467 |
-
$args = array_merge($args, array('link' => 'edit'));
|
468 |
-
|
469 |
-
|
470 |
-
|
|
|
|
|
471 |
}
|
472 |
}
|
473 |
|
474 |
// flag
|
475 |
-
$x->Add(array('what' => 'flag', 'data' => empty($lang->flag) ? esc_html($lang->slug) : $lang->flag));
|
476 |
|
477 |
$x->send();
|
478 |
}
|
@@ -483,45 +503,47 @@ class PLL_Admin_Filters_Term {
|
|
483 |
* @since 1.5
|
484 |
*/
|
485 |
public function ajax_terms_not_translated() {
|
486 |
-
check_ajax_referer('pll_language', '_pll_nonce');
|
487 |
|
488 |
-
$s = wp_unslash($
|
489 |
-
$post_type = $
|
490 |
-
$taxonomy = $
|
491 |
|
492 |
-
if (!post_type_exists($post_type) || ! taxonomy_exists($taxonomy))
|
493 |
-
die(0);
|
|
|
494 |
|
495 |
-
$term_language = $this->model->get_language($
|
496 |
-
$translation_language = $this->model->get_language($
|
497 |
|
498 |
$return = array();
|
499 |
|
500 |
// it is more efficient to use one common query for all languages as soon as there are more than 2
|
501 |
// pll_get_terms_not_translated arg to identify this query in terms_clauses filter
|
502 |
-
foreach (get_terms($taxonomy, 'hide_empty=0&pll_get_terms_not_translated=1&name__like=' . $s) as $term) {
|
503 |
-
$lang = $this->model->
|
504 |
|
505 |
-
if ($lang && $lang->slug == $translation_language->slug &&
|
506 |
$return[] = array(
|
507 |
'id' => $term->term_id,
|
508 |
'value' => $term->name,
|
509 |
-
'link' => $this->
|
510 |
);
|
|
|
511 |
}
|
512 |
|
513 |
// add current translation in list
|
514 |
// not in add term for as term_id is not set
|
515 |
-
if ('undefined' !== $
|
516 |
-
$term = get_term($term_id, $taxonomy);
|
517 |
-
array_unshift($return, array(
|
518 |
'id' => $term_id,
|
519 |
'value' => $term->name,
|
520 |
-
'link' => $this->
|
521 |
-
));
|
522 |
}
|
523 |
|
524 |
-
wp_die(json_encode($return));
|
525 |
}
|
526 |
|
527 |
|
@@ -534,89 +556,104 @@ class PLL_Admin_Filters_Term {
|
|
534 |
* @param array $args get_terms arguments
|
535 |
* @return object|string|bool the language(s) to use in the filter, false otherwise
|
536 |
*/
|
537 |
-
protected function get_queried_language($taxonomies, $args) {
|
538 |
// does nothing except on taxonomies which are filterable
|
539 |
-
if (
|
540 |
return false;
|
|
|
541 |
|
542 |
// if get_terms is queried with a 'lang' parameter
|
543 |
-
if (!empty($args['lang']))
|
544 |
return $args['lang'];
|
|
|
545 |
|
546 |
// do not filter 'get_terms_not_translated'
|
547 |
-
if (!empty($args['pll_get_terms_not_translated']))
|
548 |
return false;
|
|
|
549 |
|
550 |
-
if (function_exists('get_current_screen'))
|
551 |
$screen = get_current_screen(); // since WP 3.1, may not be available the first time(s) get_terms is called
|
|
|
552 |
|
553 |
// don't filter nav menus on nav menus screen
|
554 |
-
if (isset($screen) && 'nav-menus' == $screen->base && in_array('nav_menu', $taxonomies))
|
555 |
return false;
|
|
|
556 |
|
557 |
// does nothing in Languages and dasboard admin panels
|
558 |
-
if (isset($screen) && in_array($screen->base, array('toplevel_page_mlang', 'dashboard')))
|
559 |
return false;
|
|
|
560 |
|
561 |
// ajax actions
|
562 |
-
if (isset($_POST['action'])) {
|
563 |
// admin language filter for:
|
564 |
// ajax paginate_links in taxonomies metabox in nav menus panel
|
565 |
-
// and taxonomies menus items in customizer menus (since WP 4.3)
|
566 |
-
if (!empty($this->curlang) && in_array($_POST['action'], array('menu-get-metabox', 'load-available-menu-items-customizer'))) {
|
567 |
return $this->curlang;
|
568 |
}
|
569 |
|
570 |
// The only ajax response I want to deal with is when changing the language in post metabox
|
571 |
-
if (!in_array($_POST['action'], array('post_lang_choice', 'term_lang_choice', 'get-tagcloud'))) {
|
572 |
return false;
|
573 |
}
|
574 |
|
575 |
// I only want to filter the parent dropdown list when editing a term in a hierarchical taxonomy
|
576 |
-
if ('term_lang_choice' == $_POST['action'] && !(isset($args['class']) || isset($args['unit']))) {
|
577 |
return false;
|
578 |
}
|
579 |
}
|
580 |
|
581 |
-
// ajax response for changing the language in the post metabox (or in the edit-tags panels)
|
582 |
-
if (isset($_POST['lang']))
|
583 |
-
$lang = $this->model->get_language($_POST['lang']);
|
|
|
584 |
|
585 |
-
// the post (or term) is created with the 'add new' (translation) link
|
586 |
// test of $args['page'] to avoid filtering the terms list table in edit-tags panel
|
587 |
-
elseif (!empty($_GET['new_lang']) && empty($args['page']))
|
588 |
-
$lang = $this->model->get_language($_GET['new_lang']);
|
|
|
589 |
|
590 |
// FIXME can we simplify how we deal with the admin language filter?
|
591 |
// the language filter selection has just changed
|
592 |
// test $screen->base to avoid interference between the language filter and the post language selection and the category parent dropdown list
|
593 |
-
elseif (!empty($_GET['lang']) && !(isset($screen) && in_array($screen->base, array('post', 'edit-tags')))) {
|
594 |
-
if ($_GET['lang']
|
595 |
-
$lang = $this->model->get_language($_GET['lang']);
|
596 |
-
|
|
|
597 |
$lang = $this->pref_lang; // parent dropdown
|
|
|
598 |
}
|
599 |
|
600 |
// again the language filter
|
601 |
-
elseif (!empty($this->curlang) && (isset($screen) &&
|
602 |
$lang = $this->curlang;
|
|
|
603 |
|
604 |
-
elseif (isset($_GET['post']) && is_numeric($_GET['post'])) // is numeric avoids array of posts in *post* bulk edit
|
605 |
-
$lang = $this->model->
|
|
|
606 |
|
607 |
// for the parent dropdown list in edit term
|
608 |
-
elseif (isset($_GET['tag_ID']))
|
609 |
-
$lang = $this->model->
|
|
|
610 |
|
611 |
// when a new category is created in the edit post panel
|
612 |
-
elseif (isset($_POST['term_lang_choice']))
|
613 |
-
$lang = $this->model->get_language($_POST['term_lang_choice']);
|
|
|
614 |
|
615 |
-
// for a new post (or the parent dropdown list of a new term)
|
616 |
-
elseif (isset($screen) && (
|
617 |
$lang = $this->pref_lang;
|
|
|
618 |
|
619 |
-
return empty($lang) ? false : $lang;
|
620 |
}
|
621 |
|
622 |
/*
|
@@ -629,10 +666,10 @@ class PLL_Admin_Filters_Term {
|
|
629 |
* @param array $taxonomies
|
630 |
* @return array modified arguments
|
631 |
*/
|
632 |
-
public function get_terms_args($args, $taxonomies) {
|
633 |
-
if ($lang = $this->get_queried_language($taxonomies, $args)) {
|
634 |
-
$key = '_' . (is_array($lang) ? implode(',', $lang) : $this->model->get_language($lang)->slug);
|
635 |
-
$args['cache_domain'] = empty($args['cache_domain']) ? 'pll' . $key : $args['cache_domain'] . $key;
|
636 |
}
|
637 |
return $args;
|
638 |
}
|
@@ -647,9 +684,9 @@ class PLL_Admin_Filters_Term {
|
|
647 |
* @param array $args get_terms arguments
|
648 |
* @return array modified sql clauses
|
649 |
*/
|
650 |
-
public function terms_clauses($clauses, $taxonomies, $args) {
|
651 |
-
$lang = $this->get_queried_language($taxonomies, $args);
|
652 |
-
return !empty($lang) ? $this->model->terms_clauses($clauses, $lang) : $clauses; // adds our clauses to filter by current language
|
653 |
}
|
654 |
|
655 |
/*
|
@@ -661,20 +698,22 @@ class PLL_Admin_Filters_Term {
|
|
661 |
* @param int $value
|
662 |
* @return int
|
663 |
*/
|
664 |
-
public function option_default_category($value) {
|
665 |
$traces = debug_backtrace();
|
666 |
|
667 |
-
if (isset($traces[4])) {
|
668 |
-
if (in_array($traces[4]['function'], array('column_cb', 'column_name')) && in_array($traces[4]['args'][0]->term_id, $this->model->get_translations(
|
669 |
return $traces[4]['args'][0]->term_id;
|
|
|
670 |
|
671 |
-
if ('wp_delete_term' == $traces[4]['function'])
|
672 |
-
return $this->model->
|
|
|
673 |
}
|
674 |
|
675 |
// filters the default category in note below the category list table and in settings->writing dropdown
|
676 |
-
elseif (false
|
677 |
-
return $this->model->
|
678 |
}
|
679 |
|
680 |
return $value;
|
@@ -689,18 +728,19 @@ class PLL_Admin_Filters_Term {
|
|
689 |
* @param int $old_value
|
690 |
* @param int $value
|
691 |
*/
|
692 |
-
public function update_option_default_category($old_value, $value) {
|
693 |
-
$default_cat_lang = $this->model->
|
694 |
|
695 |
// assign a default language to default category
|
696 |
-
if (
|
697 |
-
$default_cat_lang = $this->model->get_language($this->options['default_lang']);
|
698 |
-
$this->
|
699 |
}
|
700 |
|
701 |
-
foreach ($this->model->get_languages_list() as $language) {
|
702 |
-
if ($language->slug != $default_cat_lang->slug &&
|
703 |
-
$this->model->create_default_category($language);
|
|
|
704 |
}
|
705 |
}
|
706 |
|
@@ -715,52 +755,37 @@ class PLL_Admin_Filters_Term {
|
|
715 |
* @param int $term_taxonomy_id
|
716 |
* @param string $taxonomy
|
717 |
*/
|
718 |
-
public function split_shared_term($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) {
|
719 |
-
if (
|
720 |
return;
|
|
|
721 |
|
722 |
// avoid recursion
|
723 |
static $avoid_recursion = false;
|
724 |
-
if ($avoid_recursion)
|
725 |
return;
|
|
|
726 |
|
727 |
$avoid_recursion = true;
|
728 |
-
$lang = $this->model->
|
729 |
|
730 |
-
foreach ($this->model->get_translations(
|
731 |
-
if ($lang->slug == $key) {
|
732 |
-
$translations[$key] = $new_term_id;
|
733 |
}
|
734 |
else {
|
735 |
-
$tr_term = get_term($tr_id, $taxonomy);
|
736 |
-
$translations[$key] = _split_shared_term($tr_id, $tr_term->term_taxonomy_id);
|
737 |
|
738 |
// hack translation ids sent by the form to avoid overwrite in PLL_Admin_Filters_Term::save_translations
|
739 |
-
if (isset($_POST['term_tr_lang'][$key]) && $_POST['term_tr_lang'][$key] == $tr_id)
|
740 |
-
$_POST['term_tr_lang'][$key] = $translations[$key];
|
|
|
741 |
}
|
742 |
-
$this->model->
|
743 |
}
|
744 |
|
745 |
-
$this->model->save_translations(
|
746 |
$avoid_recursion = false;
|
747 |
}
|
748 |
-
|
749 |
-
/*
|
750 |
-
* returns html markup for a translation link
|
751 |
-
*
|
752 |
-
* @since 1.4
|
753 |
-
*
|
754 |
-
* @param object $term_id translation term id
|
755 |
-
* @param string $taxonomy
|
756 |
-
* @param string $post_type
|
757 |
-
* @return string
|
758 |
-
*/
|
759 |
-
public function edit_translation_link($term_id, $taxonomy, $post_type) {
|
760 |
-
return sprintf(
|
761 |
-
'<a href="%1$s" class="pll_icon_edit title="%2$s"></a></td>',
|
762 |
-
esc_url(get_edit_term_link($term_id, $taxonomy, $post_type)),
|
763 |
-
__('Edit','polylang')
|
764 |
-
);
|
765 |
-
}
|
766 |
}
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
+
public function __construct( &$polylang ) {
|
19 |
$this->links = &$polylang->links;
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->options = &$polylang->options;
|
22 |
$this->curlang = &$polylang->curlang;
|
23 |
$this->pref_lang = &$polylang->pref_lang;
|
24 |
|
25 |
+
foreach ( $this->model->get_translated_taxonomies() as $tax ) {
|
26 |
// adds the language field in the 'Categories' and 'Post Tags' panels
|
27 |
+
add_action( $tax.'_add_form_fields', array( &$this, 'add_term_form' ) );
|
28 |
|
29 |
// adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
|
30 |
+
add_action( $tax.'_edit_form_fields', array( &$this, 'edit_term_form' ) );
|
31 |
|
32 |
// adds action related to languages when deleting categories and post tags
|
33 |
+
add_action( 'delete_'.$tax, array( &$this, 'delete_term' ) );
|
34 |
}
|
35 |
|
36 |
// adds actions related to languages when creating or saving categories and post tags
|
37 |
+
add_filter( 'wp_dropdown_cats', array( &$this, 'wp_dropdown_cats' ) );
|
38 |
+
add_action( 'create_term', array( &$this, 'save_term' ), 999, 3 );
|
39 |
+
add_action( 'edit_term', array( &$this, 'save_term' ), 999, 3 ); // late as it may conflict with other plugins, see http://wordpress.org/support/topic/polylang-and-wordpress-seo-by-yoast
|
40 |
+
add_action( 'pre_post_update', array( &$this, 'pre_post_update' ) );
|
41 |
+
add_filter( 'pre_term_name', array( &$this, 'pre_term_name' ) );
|
42 |
+
add_filter( 'pre_term_slug', array( &$this, 'pre_term_slug' ), 10, 2 );
|
43 |
|
44 |
// ajax response for edit term form
|
45 |
+
add_action( 'wp_ajax_term_lang_choice', array( &$this, 'term_lang_choice' ) );
|
46 |
+
add_action( 'wp_ajax_pll_terms_not_translated', array( &$this, 'ajax_terms_not_translated' ) );
|
47 |
|
48 |
// adds cache domain when querying terms
|
49 |
+
add_filter( 'get_terms_args', array( &$this, 'get_terms_args' ), 10, 2 );
|
50 |
|
51 |
// filters categories and post tags by language
|
52 |
+
add_filter( 'terms_clauses', array( &$this, 'terms_clauses' ), 10, 3 );
|
53 |
|
54 |
// allows to get the default categories in all languages
|
55 |
+
add_filter( 'option_default_category', array( &$this, 'option_default_category' ) );
|
56 |
+
add_action( 'update_option_default_category', array( &$this, 'update_option_default_category' ), 10, 2 );
|
57 |
|
58 |
// updates the translations term ids when splitting a shared term
|
59 |
+
add_action( 'split_shared_term', array( &$this, 'split_shared_term' ), 10, 4 ); // WP 4.2
|
60 |
}
|
61 |
|
62 |
/*
|
66 |
*/
|
67 |
public function add_term_form() {
|
68 |
$taxonomy = $_GET['taxonomy'];
|
69 |
+
$post_type = isset( $GLOBALS['post_type'] ) ? $GLOBALS['post_type'] : $_REQUEST['post_type'];
|
70 |
|
71 |
+
if ( ! taxonomy_exists( $taxonomy ) || ! post_type_exists( $post_type ) ) {
|
72 |
return;
|
73 |
+
}
|
74 |
|
75 |
+
$lang = isset( $_GET['new_lang'] ) ? $this->model->get_language( $_GET['new_lang'] ) : $this->pref_lang;
|
76 |
$dropdown = new PLL_Walker_Dropdown();
|
77 |
|
78 |
+
wp_nonce_field( 'pll_language', '_pll_nonce' );
|
79 |
|
80 |
+
printf( '
|
81 |
<div class="form-field">
|
82 |
<label for="term_lang_choice">%s</label>
|
83 |
<div id="select-add-term-language">%s</div>
|
84 |
<p>%s</p>
|
85 |
</div>',
|
86 |
+
__( 'Language', 'polylang' ),
|
87 |
+
$dropdown->walk( $this->model->get_languages_list(), array(
|
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 |
);
|
95 |
|
96 |
+
if ( ! empty( $_GET['from_tag'] ) ) {
|
97 |
+
printf( '<input type="hidden" name="from_tag" value="%d" />', $_GET['from_tag'] );
|
98 |
+
}
|
99 |
|
100 |
// adds translation fields
|
101 |
echo '<div id="term-translations" class="form-field">';
|
102 |
+
if ( $lang ) {
|
103 |
+
include( PLL_ADMIN_INC.'/view-translations-term.php' );
|
104 |
+
}
|
105 |
echo '</div>'."\n";
|
106 |
}
|
107 |
|
110 |
*
|
111 |
* @since 0.1
|
112 |
*/
|
113 |
+
public function edit_term_form( $tag ) {
|
114 |
$term_id = $tag->term_id;
|
115 |
+
$lang = $this->model->term->get_language( $term_id );
|
116 |
$taxonomy = $tag->taxonomy;
|
117 |
+
$post_type = isset( $GLOBALS['post_type'] ) ? $GLOBALS['post_type'] : $_REQUEST['post_type'];
|
118 |
|
119 |
+
if ( ! post_type_exists( $post_type ) ) {
|
120 |
return;
|
121 |
+
}
|
122 |
|
123 |
$dropdown = new PLL_Walker_Dropdown();
|
124 |
|
125 |
// disable the language dropdown and the translations input fields for default categories to prevent removal
|
126 |
+
$disabled = in_array( get_option( 'default_category' ), $this->model->term->get_translations( $term_id ) );
|
127 |
|
128 |
+
wp_nonce_field( 'pll_language', '_pll_nonce' );
|
129 |
|
130 |
+
printf( '
|
131 |
<tr class="form-field">
|
132 |
<th scope="row">
|
133 |
<label for="term_lang_choice">%s</label>
|
134 |
</th>
|
135 |
<td id="select-edit-term-language">
|
136 |
%s<br />
|
137 |
+
<p class="description">%s</p>
|
138 |
</td>
|
139 |
</tr>',
|
140 |
+
__( 'Language', 'polylang' ),
|
141 |
+
$dropdown->walk( $this->model->get_languages_list(), array(
|
142 |
'name' => 'term_lang_choice',
|
143 |
'value' => 'term_id',
|
144 |
'selected' => $lang ? $lang->term_id : '',
|
145 |
'disabled' => $disabled,
|
146 |
'flag' => true
|
147 |
+
) ),
|
148 |
+
__( 'Sets the language', 'polylang' )
|
149 |
);
|
150 |
|
151 |
echo '<tr id="term-translations" class="form-field">';
|
152 |
+
if ( $lang ) {
|
153 |
+
include( PLL_ADMIN_INC.'/view-translations-term.php' );
|
154 |
+
}
|
155 |
echo '</tr>'."\n";
|
156 |
}
|
157 |
|
158 |
/*
|
159 |
+
* translates term parent if exists when using "Add new" ( translation )
|
160 |
*
|
161 |
* @since 0.7
|
162 |
*
|
163 |
* @param string html markup for dropdown list of categories
|
164 |
* @return string modified html
|
165 |
*/
|
166 |
+
public function wp_dropdown_cats( $output ) {
|
167 |
+
if ( isset( $_GET['taxonomy'], $_GET['from_tag'], $_GET['new_lang'] ) && taxonomy_exists( $_GET['taxonomy'] ) && $id = get_term( (int) $_GET['from_tag'], $_GET['taxonomy'] )->parent ) {
|
168 |
+
$lang = $this->model->get_language( $_GET['new_lang'] );
|
169 |
+
if ( $parent = $this->model->term->get_translation( $id, $lang ) ) {
|
170 |
+
return str_replace( '"'.$parent.'"', '"'.$parent.'" selected="selected"', $output );
|
171 |
+
}
|
172 |
}
|
173 |
return $output;
|
174 |
}
|
180 |
*
|
181 |
* @param int $post_id
|
182 |
*/
|
183 |
+
public function pre_post_update( $post_id ) {
|
184 |
+
if ( isset( $_GET['bulk_edit'] ) ) {
|
185 |
$this->post_id = $post_id;
|
186 |
+
}
|
187 |
}
|
188 |
|
189 |
/*
|
194 |
* @param int $term_id
|
195 |
* @param string $taxonomy
|
196 |
*/
|
197 |
+
protected function set_default_language( $term_id, $taxonomy ) {
|
198 |
+
if ( ! $this->model->term->get_language( $term_id ) ) {
|
199 |
// sets language from term parent if exists thanks to Scott Kingsley Clark
|
200 |
+
if ( ( $term = get_term( $term_id, $taxonomy ) ) && ! empty( $term->parent ) && $parent_lang = $this->model->term->get_language( $term->parent ) ) {
|
201 |
+
$this->model->term->set_language( $term_id, $parent_lang );
|
202 |
+
}
|
203 |
+
else {
|
204 |
+
$this->model->term->set_language( $term_id, $this->pref_lang );
|
205 |
+
}
|
206 |
}
|
207 |
}
|
208 |
|
214 |
* @param int $term_id
|
215 |
* @param string $taxonomy
|
216 |
*/
|
217 |
+
protected function save_language( $term_id, $taxonomy ) {
|
218 |
global $wpdb;
|
219 |
// security checks are necessary to accept language modifications
|
220 |
// as 'wp_update_term' can be called from outside WP admin
|
221 |
|
222 |
// edit tags
|
223 |
+
if ( isset( $_POST['term_lang_choice'] ) ) {
|
224 |
+
if ( 'add-' . $taxonomy == $_POST['action'] ) {
|
225 |
+
check_ajax_referer( $_POST['action'], '_ajax_nonce-add-' . $taxonomy ); // category metabox
|
226 |
+
}
|
227 |
+
else {
|
228 |
+
check_admin_referer( 'pll_language', '_pll_nonce' ); // edit tags or tags metabox
|
229 |
+
}
|
230 |
|
231 |
+
$this->model->term->set_language( $term_id, $this->model->get_language( $_POST['term_lang_choice'] ) );
|
232 |
}
|
233 |
|
234 |
// *post* bulk edit, in case a new term is created
|
235 |
+
elseif ( isset( $_GET['bulk_edit'], $_GET['inline_lang_choice'] ) ) {
|
236 |
+
check_admin_referer( 'bulk-posts' );
|
237 |
|
238 |
// bulk edit does not modify the language
|
239 |
// so we possibly create a tag in several languages
|
240 |
+
if ( -1 == $_GET['inline_lang_choice'] ) {
|
241 |
// the language of the current term is set a according to the language of the current post
|
242 |
+
$this->model->term->set_language( $term_id, $this->model->post->get_language( $this->post_id ) );
|
243 |
+
$term = get_term( $term_id, $taxonomy );
|
244 |
|
245 |
// get all terms with the same name
|
246 |
// FIXME backward compatibility WP < 4.2
|
247 |
// no WP function to get all terms with the exact same name so let's use a custom query
|
248 |
+
// $terms = get_terms( $taxonomy, array( 'name' => $term->name, 'hide_empty' => false, 'fields' => 'ids' ) ); should be OK in 4.2
|
249 |
// I may need to rework the loop below
|
250 |
+
$terms = $wpdb->get_results( $wpdb->prepare( "
|
251 |
SELECT t.term_id FROM $wpdb->terms AS t
|
252 |
INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id
|
253 |
WHERE tt.taxonomy = %s AND t.name = %s",
|
254 |
$taxonomy, $term->name
|
255 |
+
) );
|
256 |
|
257 |
// if we have several terms with the same name, they are translations of each other
|
258 |
+
if ( count( $terms ) > 1 ) {
|
259 |
+
foreach ( $terms as $term ) {
|
260 |
+
$translations[ $this->model->term->get_language( $term->term_id )->slug ] = $term->term_id;
|
261 |
}
|
262 |
|
263 |
+
$this->model->term->save_translations( $term_id, $translations );
|
264 |
}
|
265 |
}
|
266 |
|
267 |
else {
|
268 |
+
$this->model->term->set_language( $term_id, $this->model->get_language( $_GET['inline_lang_choice'] ) );
|
269 |
}
|
270 |
}
|
271 |
|
272 |
// quick edit
|
273 |
+
elseif ( isset( $_POST['inline_lang_choice'] ) ) {
|
274 |
check_ajax_referer(
|
275 |
+
isset( $_POST['action'] ) && 'inline-save' == $_POST['action'] ? 'inlineeditnonce' : 'taxinlineeditnonce', // post quick edit or tag quick edit ?
|
276 |
'_inline_edit'
|
277 |
);
|
278 |
|
279 |
+
$old_lang = $this->model->term->get_language( $term_id ); // stores the old language
|
280 |
+
$lang = $this->model->get_language( $_POST['inline_lang_choice'] ); // new language
|
281 |
+
$translations = $this->model->term->get_translations( $term_id );
|
282 |
|
283 |
// checks if the new language already exists in the translation group
|
284 |
+
if ( $old_lang && $old_lang->slug != $lang->slug ) {
|
285 |
+
if ( array_key_exists( $lang->slug, $translations ) ) {
|
286 |
+
$this->model->term->delete_translation( $term_id );
|
287 |
}
|
288 |
|
289 |
+
elseif ( array_key_exists( $old_lang->slug, $translations ) ) {
|
290 |
+
unset( $translations[ $old_lang->slug ] );
|
291 |
+
$this->model->term->save_translations( $term_id, $translations );
|
292 |
}
|
293 |
}
|
294 |
|
295 |
+
$this->model->term->set_language( $term_id, $lang ); // set new language
|
296 |
}
|
297 |
|
298 |
// edit post
|
299 |
+
elseif ( isset( $_POST['post_lang_choice'] ) ) {// FIXME should be useless now
|
300 |
+
check_admin_referer( 'pll_language', '_pll_nonce' );
|
301 |
+
$this->model->term->set_language( $term_id, $this->model->get_language( $_POST['post_lang_choice'] ) );
|
302 |
}
|
303 |
|
304 |
+
else {
|
305 |
+
$this->set_default_language( $term_id, $taxonomy );
|
306 |
+
}
|
307 |
}
|
308 |
|
309 |
/*
|
314 |
* @param int $term_id
|
315 |
* @return array
|
316 |
*/
|
317 |
+
protected function save_translations( $term_id ) {
|
318 |
// security check
|
319 |
// as 'wp_update_term' can be called from outside WP admin
|
320 |
+
check_admin_referer( 'pll_language', '_pll_nonce' );
|
321 |
|
322 |
+
// save translations after checking the translated term is in the right language ( as well as cast id to int )
|
323 |
+
foreach ( $_POST['term_tr_lang'] as $lang => $tr_id ) {
|
324 |
+
$tr_lang = $this->model->term->get_language( (int) $tr_id );
|
325 |
+
$translations[ $lang ] = $tr_lang && $tr_lang->slug == $lang ? (int) $tr_id : 0;
|
326 |
}
|
327 |
|
328 |
+
$this->model->term->save_translations( $term_id, $translations );
|
329 |
|
330 |
return $translations;
|
331 |
}
|
340 |
* @param int $tt_id term taxononomy id
|
341 |
* @param string $taxonomy
|
342 |
*/
|
343 |
+
public function save_term( $term_id, $tt_id, $taxonomy ) {
|
344 |
// does nothing except on taxonomies which are filterable
|
345 |
+
if ( ! $this->model->is_translated_taxonomy( $taxonomy ) ) {
|
346 |
return;
|
347 |
+
}
|
348 |
|
349 |
// capability check
|
350 |
// as 'wp_update_term' can be called from outside WP admin
|
351 |
// 2nd test for creating tags when creating / editing a post
|
352 |
+
$tax = get_taxonomy( $taxonomy );
|
353 |
+
if ( current_user_can( $tax->cap->edit_terms ) || ( isset( $_POST['tax_input'][ $taxonomy ] ) && current_user_can( $tax->cap->assign_terms ) ) ) {
|
354 |
+
$this->save_language( $term_id, $taxonomy );
|
355 |
|
356 |
+
if ( isset( $_POST['term_tr_lang'] ) ) {
|
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 |
|
363 |
// attempts to set a default language even if no capability
|
364 |
+
else {
|
365 |
+
$this->set_default_language( $term_id, $taxonomy );
|
366 |
+
}
|
367 |
}
|
368 |
|
369 |
/*
|
374 |
* @param string $name term name
|
375 |
* @return string unmodified term name
|
376 |
*/
|
377 |
+
public function pre_term_name( $name ) {
|
378 |
return $this->pre_term_name = $name;
|
379 |
}
|
380 |
|
387 |
* @param string $taxonomy
|
388 |
* @return string
|
389 |
*/
|
390 |
+
public function pre_term_slug( $slug, $taxonomy ) {
|
391 |
+
$name = sanitize_title( $this->pre_term_name );
|
392 |
|
393 |
// if the new term has the same name as a language, we *need* to differentiate the term
|
394 |
// see http://core.trac.wordpress.org/ticket/23199
|
395 |
// backward compatibility with WP < 4.1
|
396 |
+
if ( version_compare( $GLOBALS['wp_version'], '4.1', '<' ) && term_exists( $name, 'language' ) && ! term_exists( $name, $taxonomy ) && ( ! $slug || $slug == $name ) ) {
|
397 |
$slug = $name . '-' . $taxonomy; // a convenient slug which may be modified later by the user
|
398 |
+
}
|
399 |
|
400 |
// if the term already exists in another language
|
401 |
+
if ( ! $slug && $this->model->is_translated_taxonomy( $taxonomy ) && term_exists( $name, $taxonomy ) ) {
|
402 |
+
if ( isset( $_POST['term_lang_choice'] ) ) {
|
403 |
+
$slug = $name . '-' . $this->model->get_language( $_POST['term_lang_choice'] )->slug;
|
404 |
+
}
|
405 |
|
406 |
+
elseif ( isset( $_POST['inline_lang_choice'] ) ) {
|
407 |
+
$slug = $name . '-' . $this->model->get_language( $_POST['inline_lang_choice'] )->slug;
|
408 |
+
}
|
409 |
|
410 |
// *post* bulk edit, in case a new term is created
|
411 |
+
elseif ( isset( $_GET['bulk_edit'], $_GET['inline_lang_choice'] ) ) {
|
412 |
// bulk edit does not modify the language
|
413 |
+
if ( -1 == $_GET['inline_lang_choice'] ) {
|
414 |
+
$slug = $name . '-' . $this->model->post->get_language( $this->post_id )->slug;
|
415 |
}
|
416 |
else {
|
417 |
+
$slug = $name . '-' . $this->model->get_language( $_GET['inline_lang_choice'] )->slug;
|
418 |
}
|
419 |
}
|
420 |
}
|
430 |
*
|
431 |
* @param int $term_id
|
432 |
*/
|
433 |
+
public function delete_term( $term_id ) {
|
434 |
+
$this->model->term->delete_translation( $term_id );
|
435 |
+
$this->model->term->delete_language( $term_id );
|
436 |
}
|
437 |
|
438 |
/*
|
441 |
* @since 0.2
|
442 |
*/
|
443 |
public function term_lang_choice() {
|
444 |
+
check_ajax_referer( 'pll_language', '_pll_nonce' );
|
445 |
|
446 |
+
$lang = $this->model->get_language( $_POST['lang'] );
|
447 |
+
$term_id = isset( $_POST['term_id'] ) ? (int) $_POST['term_id'] : null;
|
448 |
$taxonomy = $_POST['taxonomy'];
|
449 |
$post_type = $_POST['post_type'];
|
450 |
|
451 |
+
if ( ! post_type_exists( $post_type ) || ! taxonomy_exists( $taxonomy ) ) {
|
452 |
+
die( 0 );
|
453 |
+
}
|
454 |
|
455 |
ob_start();
|
456 |
+
if ( $lang ) {
|
457 |
+
include( PLL_ADMIN_INC.'/view-translations-term.php' );
|
458 |
+
}
|
459 |
+
$x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
|
460 |
ob_end_clean();
|
461 |
|
462 |
+
// parent dropdown list ( only for hierarchical taxonomies )
|
463 |
// $args copied from edit_tags.php except echo
|
464 |
+
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
|
465 |
$args = array(
|
466 |
'hide_empty' => 0,
|
467 |
'hide_if_empty' => false,
|
469 |
'name' => 'parent',
|
470 |
'orderby' => 'name',
|
471 |
'hierarchical' => true,
|
472 |
+
'show_option_none' => __( 'None' ),
|
473 |
'echo' => 0,
|
474 |
);
|
475 |
+
$x->Add( array( 'what' => 'parent', 'data' => wp_dropdown_categories( $args ) ) );
|
476 |
}
|
477 |
|
478 |
// tag cloud
|
479 |
// tests copied from edit_tags.php
|
480 |
else {
|
481 |
+
$tax = get_taxonomy( $taxonomy );
|
482 |
+
if ( ! is_null( $tax->labels->popular_items ) ) {
|
483 |
+
$args = array( 'taxonomy' => $taxonomy, 'echo' => false );
|
484 |
+
if ( current_user_can( $tax->cap->edit_terms ) ) {
|
485 |
+
$args = array_merge( $args, array( 'link' => 'edit' ) );
|
486 |
+
}
|
487 |
+
|
488 |
+
if ( $tag_cloud = wp_tag_cloud( $args ) ) {
|
489 |
+
$x->Add( array( 'what' => 'tag_cloud', 'data' => '<h3>'.$tax->labels->popular_items.'</h3>'.$tag_cloud ) );
|
490 |
+
}
|
491 |
}
|
492 |
}
|
493 |
|
494 |
// flag
|
495 |
+
$x->Add( array( 'what' => 'flag', 'data' => empty( $lang->flag ) ? esc_html( $lang->slug ) : $lang->flag ) );
|
496 |
|
497 |
$x->send();
|
498 |
}
|
503 |
* @since 1.5
|
504 |
*/
|
505 |
public function ajax_terms_not_translated() {
|
506 |
+
check_ajax_referer( 'pll_language', '_pll_nonce' );
|
507 |
|
508 |
+
$s = wp_unslash( $_GET['term'] );
|
509 |
+
$post_type = $_GET['post_type'];
|
510 |
+
$taxonomy = $_GET['taxonomy'];
|
511 |
|
512 |
+
if ( ! post_type_exists( $post_type ) || ! taxonomy_exists( $taxonomy ) ) {
|
513 |
+
die( 0 );
|
514 |
+
}
|
515 |
|
516 |
+
$term_language = $this->model->get_language( $_GET['term_language'] );
|
517 |
+
$translation_language = $this->model->get_language( $_GET['translation_language'] );
|
518 |
|
519 |
$return = array();
|
520 |
|
521 |
// it is more efficient to use one common query for all languages as soon as there are more than 2
|
522 |
// pll_get_terms_not_translated arg to identify this query in terms_clauses filter
|
523 |
+
foreach ( get_terms( $taxonomy, 'hide_empty=0&pll_get_terms_not_translated=1&name__like=' . $s ) as $term ) {
|
524 |
+
$lang = $this->model->term->get_language( $term->term_id );
|
525 |
|
526 |
+
if ( $lang && $lang->slug == $translation_language->slug && ! $this->model->term->get_translation( $term->term_id, $term_language ) ) {
|
527 |
$return[] = array(
|
528 |
'id' => $term->term_id,
|
529 |
'value' => $term->name,
|
530 |
+
'link' => $this->links->edit_term_translation_link( $term->term_id, $taxonomy, $post_type ),
|
531 |
);
|
532 |
+
}
|
533 |
}
|
534 |
|
535 |
// add current translation in list
|
536 |
// not in add term for as term_id is not set
|
537 |
+
if ( 'undefined' !== $_GET['term_id'] && $term_id = $this->model->term->get_translation( (int) $_GET['term_id'], $translation_language ) ) {
|
538 |
+
$term = get_term( $term_id, $taxonomy );
|
539 |
+
array_unshift( $return, array(
|
540 |
'id' => $term_id,
|
541 |
'value' => $term->name,
|
542 |
+
'link' => $this->links->edit_term_translation_link( $term->term_id, $taxonomy, $post_type ),
|
543 |
+
) );
|
544 |
}
|
545 |
|
546 |
+
wp_die( json_encode( $return ) );
|
547 |
}
|
548 |
|
549 |
|
556 |
* @param array $args get_terms arguments
|
557 |
* @return object|string|bool the language(s) to use in the filter, false otherwise
|
558 |
*/
|
559 |
+
protected function get_queried_language( $taxonomies, $args ) {
|
560 |
// does nothing except on taxonomies which are filterable
|
561 |
+
if ( ! $this->model->is_translated_taxonomy( $taxonomies ) ) {
|
562 |
return false;
|
563 |
+
}
|
564 |
|
565 |
// if get_terms is queried with a 'lang' parameter
|
566 |
+
if ( ! empty( $args['lang'] ) ) {
|
567 |
return $args['lang'];
|
568 |
+
}
|
569 |
|
570 |
// do not filter 'get_terms_not_translated'
|
571 |
+
if ( ! empty( $args['pll_get_terms_not_translated'] ) ) {
|
572 |
return false;
|
573 |
+
}
|
574 |
|
575 |
+
if ( function_exists( 'get_current_screen' ) ) {
|
576 |
$screen = get_current_screen(); // since WP 3.1, may not be available the first time(s) get_terms is called
|
577 |
+
}
|
578 |
|
579 |
// don't filter nav menus on nav menus screen
|
580 |
+
if ( isset( $screen ) && 'nav-menus' == $screen->base && in_array( 'nav_menu', $taxonomies ) ) {
|
581 |
return false;
|
582 |
+
}
|
583 |
|
584 |
// does nothing in Languages and dasboard admin panels
|
585 |
+
if ( isset( $screen ) && in_array( $screen->base, array( 'toplevel_page_mlang', 'dashboard' ) ) ) {
|
586 |
return false;
|
587 |
+
}
|
588 |
|
589 |
// ajax actions
|
590 |
+
if ( isset( $_POST['action'] ) ) {
|
591 |
// admin language filter for:
|
592 |
// ajax paginate_links in taxonomies metabox in nav menus panel
|
593 |
+
// and taxonomies menus items in customizer menus ( since WP 4.3 )
|
594 |
+
if ( ! empty( $this->curlang ) && in_array( $_POST['action'], array( 'menu-get-metabox', 'load-available-menu-items-customizer' ) ) ) {
|
595 |
return $this->curlang;
|
596 |
}
|
597 |
|
598 |
// The only ajax response I want to deal with is when changing the language in post metabox
|
599 |
+
if ( ! in_array( $_POST['action'], array( 'post_lang_choice', 'term_lang_choice', 'get-tagcloud' ) ) ) {
|
600 |
return false;
|
601 |
}
|
602 |
|
603 |
// I only want to filter the parent dropdown list when editing a term in a hierarchical taxonomy
|
604 |
+
if ( 'term_lang_choice' == $_POST['action'] && ! ( isset( $args['class'] ) || isset( $args['unit'] ) ) ) {
|
605 |
return false;
|
606 |
}
|
607 |
}
|
608 |
|
609 |
+
// ajax response for changing the language in the post metabox ( or in the edit-tags panels )
|
610 |
+
if ( isset( $_POST['lang'] ) ) {
|
611 |
+
$lang = $this->model->get_language( $_POST['lang'] );
|
612 |
+
}
|
613 |
|
614 |
+
// the post ( or term ) is created with the 'add new' ( translation ) link
|
615 |
// test of $args['page'] to avoid filtering the terms list table in edit-tags panel
|
616 |
+
elseif ( ! empty( $_GET['new_lang'] ) && empty( $args['page'] ) ) {
|
617 |
+
$lang = $this->model->get_language( $_GET['new_lang'] );
|
618 |
+
}
|
619 |
|
620 |
// FIXME can we simplify how we deal with the admin language filter?
|
621 |
// the language filter selection has just changed
|
622 |
// test $screen->base to avoid interference between the language filter and the post language selection and the category parent dropdown list
|
623 |
+
elseif ( ! empty( $_GET['lang'] ) && ! ( isset( $screen ) && in_array( $screen->base, array( 'post', 'edit-tags' ) ) ) ) {
|
624 |
+
if ( 'all' != $_GET['lang'] ) {
|
625 |
+
$lang = $this->model->get_language( $_GET['lang'] );
|
626 |
+
}
|
627 |
+
elseif ( 'edit-tags' == $screen->base && isset( $args['class'] ) ) {
|
628 |
$lang = $this->pref_lang; // parent dropdown
|
629 |
+
}
|
630 |
}
|
631 |
|
632 |
// again the language filter
|
633 |
+
elseif ( ! empty( $this->curlang ) && ( isset( $screen ) && 'post' != $screen->base && ! ( 'edit-tags' == $screen->base && isset( $args['class'] ) ) ) ) { // don't apply to post edit and the category parent dropdown list
|
634 |
$lang = $this->curlang;
|
635 |
+
}
|
636 |
|
637 |
+
elseif ( isset( $_GET['post'] ) && is_numeric( $_GET['post'] ) ) { // is numeric avoids array of posts in *post* bulk edit
|
638 |
+
$lang = $this->model->post->get_language( $_GET['post'] );
|
639 |
+
}
|
640 |
|
641 |
// for the parent dropdown list in edit term
|
642 |
+
elseif ( isset( $_GET['tag_ID'] ) ) {
|
643 |
+
$lang = $this->model->term->get_language( (int) $_GET['tag_ID'] );
|
644 |
+
}
|
645 |
|
646 |
// when a new category is created in the edit post panel
|
647 |
+
elseif ( isset( $_POST['term_lang_choice'] ) ) {
|
648 |
+
$lang = $this->model->get_language( $_POST['term_lang_choice'] );
|
649 |
+
}
|
650 |
|
651 |
+
// for a new post ( or the parent dropdown list of a new term )
|
652 |
+
elseif ( isset( $screen ) && ( 'post' == $screen->base || ( 'edit-tags' == $screen->base && isset( $args['class'] ) ) ) ) {
|
653 |
$lang = $this->pref_lang;
|
654 |
+
}
|
655 |
|
656 |
+
return empty( $lang ) ? false : $lang;
|
657 |
}
|
658 |
|
659 |
/*
|
666 |
* @param array $taxonomies
|
667 |
* @return array modified arguments
|
668 |
*/
|
669 |
+
public function get_terms_args( $args, $taxonomies ) {
|
670 |
+
if ( $lang = $this->get_queried_language( $taxonomies, $args ) ) {
|
671 |
+
$key = '_' . ( is_array( $lang ) ? implode( ',', $lang ) : $this->model->get_language( $lang )->slug );
|
672 |
+
$args['cache_domain'] = empty( $args['cache_domain'] ) ? 'pll' . $key : $args['cache_domain'] . $key;
|
673 |
}
|
674 |
return $args;
|
675 |
}
|
684 |
* @param array $args get_terms arguments
|
685 |
* @return array modified sql clauses
|
686 |
*/
|
687 |
+
public function terms_clauses( $clauses, $taxonomies, $args ) {
|
688 |
+
$lang = $this->get_queried_language( $taxonomies, $args );
|
689 |
+
return ! empty( $lang ) ? $this->model->terms_clauses( $clauses, $lang ) : $clauses; // adds our clauses to filter by current language
|
690 |
}
|
691 |
|
692 |
/*
|
698 |
* @param int $value
|
699 |
* @return int
|
700 |
*/
|
701 |
+
public function option_default_category( $value ) {
|
702 |
$traces = debug_backtrace();
|
703 |
|
704 |
+
if ( isset( $traces[4] ) ) {
|
705 |
+
if ( in_array( $traces[4]['function'], array( 'column_cb', 'column_name' ) ) && in_array( $traces[4]['args'][0]->term_id, $this->model->term->get_translations( $value ) ) ) {
|
706 |
return $traces[4]['args'][0]->term_id;
|
707 |
+
}
|
708 |
|
709 |
+
if ( 'wp_delete_term' == $traces[4]['function'] ) {
|
710 |
+
return $this->model->term->get( $value, $this->model->term->get_language( $traces[4]['args'][0] ) );
|
711 |
+
}
|
712 |
}
|
713 |
|
714 |
// filters the default category in note below the category list table and in settings->writing dropdown
|
715 |
+
elseif ( false !== stripos( $traces[3]['file'], 'edit-tags.php' ) || false !== stripos( $traces[3]['file'], 'options-writing.php' ) ) {
|
716 |
+
return $this->model->term->get( $value, $this->pref_lang );
|
717 |
}
|
718 |
|
719 |
return $value;
|
728 |
* @param int $old_value
|
729 |
* @param int $value
|
730 |
*/
|
731 |
+
public function update_option_default_category( $old_value, $value ) {
|
732 |
+
$default_cat_lang = $this->model->term->get_language( $value );
|
733 |
|
734 |
// assign a default language to default category
|
735 |
+
if ( ! $default_cat_lang ) {
|
736 |
+
$default_cat_lang = $this->model->get_language( $this->options['default_lang'] );
|
737 |
+
$this->model->term->set_language( (int) $value, $default_cat_lang );
|
738 |
}
|
739 |
|
740 |
+
foreach ( $this->model->get_languages_list() as $language ) {
|
741 |
+
if ( $language->slug != $default_cat_lang->slug && ! $this->model->term->get_translation( $value, $language ) ) {
|
742 |
+
$this->model->create_default_category( $language );
|
743 |
+
}
|
744 |
}
|
745 |
}
|
746 |
|
755 |
* @param int $term_taxonomy_id
|
756 |
* @param string $taxonomy
|
757 |
*/
|
758 |
+
public function split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
|
759 |
+
if ( ! $this->model->is_translated_taxonomy( $taxonomy ) ) {
|
760 |
return;
|
761 |
+
}
|
762 |
|
763 |
// avoid recursion
|
764 |
static $avoid_recursion = false;
|
765 |
+
if ( $avoid_recursion ) {
|
766 |
return;
|
767 |
+
}
|
768 |
|
769 |
$avoid_recursion = true;
|
770 |
+
$lang = $this->model->term->get_language( $term_id );
|
771 |
|
772 |
+
foreach ( $this->model->term->get_translations( $term_id ) as $key => $tr_id ) {
|
773 |
+
if ( $lang->slug == $key ) {
|
774 |
+
$translations[ $key ] = $new_term_id;
|
775 |
}
|
776 |
else {
|
777 |
+
$tr_term = get_term( $tr_id, $taxonomy );
|
778 |
+
$translations[ $key ] = _split_shared_term( $tr_id, $tr_term->term_taxonomy_id );
|
779 |
|
780 |
// hack translation ids sent by the form to avoid overwrite in PLL_Admin_Filters_Term::save_translations
|
781 |
+
if ( isset( $_POST['term_tr_lang'][ $key ] ) && $_POST['term_tr_lang'][ $key ] == $tr_id ) {
|
782 |
+
$_POST['term_tr_lang'][ $key ] = $translations[ $key ];
|
783 |
+
}
|
784 |
}
|
785 |
+
$this->model->term->set_language( $translations[ $key ], $key );
|
786 |
}
|
787 |
|
788 |
+
$this->model->term->save_translations( $new_term_id, $translations );
|
789 |
$avoid_recursion = false;
|
790 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
791 |
}
|
admin/admin-filters.php
CHANGED
@@ -14,28 +14,25 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
14 |
*
|
15 |
* @param object $polylang
|
16 |
*/
|
17 |
-
public function __construct(&$polylang) {
|
18 |
-
parent::__construct($polylang);
|
19 |
|
20 |
// widgets languages filter
|
21 |
-
add_action('in_widget_form', array(&$this, 'in_widget_form'), 10, 3);
|
22 |
-
add_filter('widget_update_callback', array(&$this, 'widget_update_callback'), 10, 4);
|
23 |
|
24 |
// language management for users
|
25 |
-
add_action('personal_options_update', array(&$this, 'personal_options_update'));
|
26 |
-
add_action('edit_user_profile_update', array(&$this, 'personal_options_update'));
|
27 |
-
add_action('personal_options', array(&$this, 'personal_options'));
|
28 |
|
29 |
-
// ugrades languages files after a core upgrade (timing is important)
|
30 |
// backward compatibility WP < 4.0 *AND* Polylang < 1.6
|
31 |
-
add_action( '_core_updated_successfully', array(&$this, 'upgrade_languages'), 1); // since WP 3.3
|
32 |
|
33 |
// upgrades plugins and themes translations files
|
34 |
-
add_filter('themes_update_check_locales', array(&$this, 'update_check_locales'));
|
35 |
-
add_filter('plugins_update_check_locales', array(&$this, 'update_check_locales'));
|
36 |
-
|
37 |
-
// checks if chosen page on front is translated
|
38 |
-
add_filter('pre_update_option_page_on_front', array(&$this, 'update_page_on_front'), 10, 2);
|
39 |
}
|
40 |
|
41 |
/*
|
@@ -45,20 +42,20 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
45 |
*
|
46 |
* @param object $widget
|
47 |
*/
|
48 |
-
public function in_widget_form($widget, $return, $instance) {
|
49 |
$dropdown = new PLL_Walker_Dropdown();
|
50 |
-
printf('<p><label for="%1$s">%2$s %3$s</label></p>',
|
51 |
-
esc_attr( $widget->id.'_lang_choice'),
|
52 |
-
__('The widget is displayed for:', 'polylang'),
|
53 |
$dropdown->walk(
|
54 |
array_merge(
|
55 |
-
array((object) array('slug' => 0, 'name' => __('All languages', 'polylang'))),
|
56 |
$this->model->get_languages_list()
|
57 |
),
|
58 |
array(
|
59 |
'name' => $widget->id.'_lang_choice',
|
60 |
'class' => 'tags-input',
|
61 |
-
'selected' => empty($instance['pll_lang']) ? '' : $instance['pll_lang']
|
62 |
)
|
63 |
)
|
64 |
);
|
@@ -76,11 +73,13 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
76 |
* @param object $widget WP_Widget object
|
77 |
* @return array widget options
|
78 |
*/
|
79 |
-
public function widget_update_callback($instance, $new_instance, $old_instance, $widget) {
|
80 |
-
if (!empty($_POST[$key = $widget->id.'_lang_choice']) && in_array($_POST[$key], $this->model->get_languages_list(array('fields' => 'slug'))))
|
81 |
-
$instance['pll_lang'] = $_POST[$key];
|
82 |
-
|
83 |
-
|
|
|
|
|
84 |
|
85 |
return $instance;
|
86 |
}
|
@@ -92,17 +91,17 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
92 |
*
|
93 |
* @param int $user_id
|
94 |
*/
|
95 |
-
public function personal_options_update($user_id) {
|
96 |
// admin language
|
97 |
-
$user_lang = in_array($_POST['user_lang'], $this->model->get_languages_list(array('fields' => 'locale'))) ? $_POST['user_lang'] : 0;
|
98 |
-
update_user_meta($user_id, 'user_lang', $user_lang);
|
99 |
|
100 |
// biography translations
|
101 |
-
foreach ($this->model->get_languages_list() as $lang) {
|
102 |
-
$meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_'
|
103 |
-
$description = empty($_POST['description_'
|
104 |
-
$description = apply_filters('pre_user_description', $description); // applies WP default filter wp_filter_kses
|
105 |
-
update_user_meta($user_id, $meta, $description);
|
106 |
}
|
107 |
}
|
108 |
|
@@ -113,60 +112,52 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
113 |
*
|
114 |
* @param object $profileuser
|
115 |
*/
|
116 |
-
public function personal_options($profileuser) {
|
117 |
$dropdown = new PLL_Walker_Dropdown();
|
118 |
-
printf('
|
119 |
<tr>
|
120 |
<th><label for="user_lang">%s</label></th>
|
121 |
<td>%s</td>
|
122 |
</tr>',
|
123 |
-
__('Admin language', 'polylang'),
|
124 |
$dropdown->walk(
|
125 |
array_merge(
|
126 |
-
array((object) array('locale' => 0, 'name' => __('WordPress default', 'polylang'))),
|
127 |
$this->model->get_languages_list()
|
128 |
),
|
129 |
array(
|
130 |
'name' => 'user_lang',
|
131 |
'value' => 'locale',
|
132 |
-
'selected' => get_user_meta($profileuser->ID, 'user_lang', true),
|
133 |
)
|
134 |
)
|
135 |
);
|
136 |
|
137 |
// hidden informations to modify the biography form with js
|
138 |
-
foreach ($this->model->get_languages_list() as $lang) {
|
139 |
-
$meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_'
|
140 |
-
$description = apply_filters('user_description', get_user_meta($profileuser->ID, $meta, true)); // applies WP default filter wp_kses_data
|
141 |
-
|
142 |
-
printf('<input type="hidden" class="biography" name="%s
|
143 |
-
esc_attr($lang->slug),
|
144 |
-
esc_attr($lang->name),
|
145 |
-
esc_attr($description)
|
146 |
);
|
147 |
}
|
148 |
}
|
149 |
|
150 |
/*
|
151 |
* ugprades languages files after a core upgrade
|
|
|
152 |
*
|
153 |
* @since 0.6
|
154 |
*
|
155 |
* @param string $version new WP version
|
156 |
*/
|
157 |
-
public function upgrade_languages($version) {
|
158 |
-
// backward compatibility WP < 4.0
|
159 |
-
if (version_compare($version, '4.0', '<')) {
|
160 |
-
apply_filters('update_feedback', __('Upgrading language files…', 'polylang'));
|
161 |
-
foreach ($this->model->get_languages_list() as $language)
|
162 |
-
if (!empty($_POST['locale']) && $language->locale != $_POST['locale']) // do not (re)update the language files of a localized WordPress
|
163 |
-
PLL_Admin::download_mo($language->locale, $version);
|
164 |
-
}
|
165 |
-
|
166 |
-
// backward compatibility WP < 4.0 *AND* Polylang < 1.6
|
167 |
// $GLOBALS['wp_version'] is the old WP version
|
168 |
-
|
169 |
-
apply_filters('update_feedback', __('Upgrading language files…', 'polylang'));
|
170 |
PLL_Upgrade::download_language_packs();
|
171 |
}
|
172 |
}
|
@@ -179,31 +170,7 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
179 |
* @param array $locale not used
|
180 |
* @return array list of locales to update
|
181 |
*/
|
182 |
-
function update_check_locales($locales) {
|
183 |
-
return $this->model->get_languages_list(array('fields' => 'locale'));
|
184 |
-
}
|
185 |
-
|
186 |
-
/*
|
187 |
-
* prevents choosing an untranslated static front page
|
188 |
-
* displays an error message
|
189 |
-
*
|
190 |
-
* @since 1.6
|
191 |
-
*
|
192 |
-
* @param int $page_id new page on front page id
|
193 |
-
* @param int $old_id old page on front page_id
|
194 |
-
* @return int
|
195 |
-
*/
|
196 |
-
public function update_page_on_front($page_id, $old_id) {
|
197 |
-
if ($page_id) {
|
198 |
-
$translations = count($this->model->get_translations('post', $page_id));
|
199 |
-
$languages = count($this->model->get_languages_list());
|
200 |
-
|
201 |
-
if ($languages > 1 && $translations != $languages) {
|
202 |
-
$page_id = $old_id;
|
203 |
-
add_settings_error('reading', 'pll_page_on_front_error', __('The chosen static front page must be translated in all languages.', 'polylang'));
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
return $page_id;
|
208 |
}
|
209 |
}
|
14 |
*
|
15 |
* @param object $polylang
|
16 |
*/
|
17 |
+
public function __construct( &$polylang ) {
|
18 |
+
parent::__construct( $polylang );
|
19 |
|
20 |
// widgets languages filter
|
21 |
+
add_action( 'in_widget_form', array( &$this, 'in_widget_form' ), 10, 3 );
|
22 |
+
add_filter( 'widget_update_callback', array( &$this, 'widget_update_callback' ), 10, 4 );
|
23 |
|
24 |
// language management for users
|
25 |
+
add_action( 'personal_options_update', array( &$this, 'personal_options_update' ) );
|
26 |
+
add_action( 'edit_user_profile_update', array( &$this, 'personal_options_update' ) );
|
27 |
+
add_action( 'personal_options', array( &$this, 'personal_options' ) );
|
28 |
|
29 |
+
// ugrades languages files after a core upgrade ( timing is important )
|
30 |
// backward compatibility WP < 4.0 *AND* Polylang < 1.6
|
31 |
+
add_action( '_core_updated_successfully', array( &$this, 'upgrade_languages' ), 1 ); // since WP 3.3
|
32 |
|
33 |
// upgrades plugins and themes translations files
|
34 |
+
add_filter( 'themes_update_check_locales', array( &$this, 'update_check_locales' ) );
|
35 |
+
add_filter( 'plugins_update_check_locales', array( &$this, 'update_check_locales' ) );
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
/*
|
42 |
*
|
43 |
* @param object $widget
|
44 |
*/
|
45 |
+
public function in_widget_form( $widget, $return, $instance ) {
|
46 |
$dropdown = new PLL_Walker_Dropdown();
|
47 |
+
printf( '<p><label for="%1$s">%2$s %3$s</label></p>',
|
48 |
+
esc_attr( $widget->id.'_lang_choice' ),
|
49 |
+
__( 'The widget is displayed for:', 'polylang' ),
|
50 |
$dropdown->walk(
|
51 |
array_merge(
|
52 |
+
array( (object) array( 'slug' => 0, 'name' => __( 'All languages', 'polylang' ) ) ),
|
53 |
$this->model->get_languages_list()
|
54 |
),
|
55 |
array(
|
56 |
'name' => $widget->id.'_lang_choice',
|
57 |
'class' => 'tags-input',
|
58 |
+
'selected' => empty( $instance['pll_lang'] ) ? '' : $instance['pll_lang'],
|
59 |
)
|
60 |
)
|
61 |
);
|
73 |
* @param object $widget WP_Widget object
|
74 |
* @return array widget options
|
75 |
*/
|
76 |
+
public function widget_update_callback( $instance, $new_instance, $old_instance, $widget ) {
|
77 |
+
if ( ! empty( $_POST[ $key = $widget->id.'_lang_choice' ] ) && in_array( $_POST[ $key ], $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) ) {
|
78 |
+
$instance['pll_lang'] = $_POST[ $key ];
|
79 |
+
}
|
80 |
+
else {
|
81 |
+
unset( $instance['pll_lang'] );
|
82 |
+
}
|
83 |
|
84 |
return $instance;
|
85 |
}
|
91 |
*
|
92 |
* @param int $user_id
|
93 |
*/
|
94 |
+
public function personal_options_update( $user_id ) {
|
95 |
// admin language
|
96 |
+
$user_lang = in_array( $_POST['user_lang'], $this->model->get_languages_list( array( 'fields' => 'locale' ) ) ) ? $_POST['user_lang'] : 0;
|
97 |
+
update_user_meta( $user_id, 'user_lang', $user_lang );
|
98 |
|
99 |
// biography translations
|
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 |
|
112 |
*
|
113 |
* @param object $profileuser
|
114 |
*/
|
115 |
+
public function personal_options( $profileuser ) {
|
116 |
$dropdown = new PLL_Walker_Dropdown();
|
117 |
+
printf( '
|
118 |
<tr>
|
119 |
<th><label for="user_lang">%s</label></th>
|
120 |
<td>%s</td>
|
121 |
</tr>',
|
122 |
+
__( 'Admin language', 'polylang' ),
|
123 |
$dropdown->walk(
|
124 |
array_merge(
|
125 |
+
array( (object) array( 'locale' => 0, 'name' => __( 'WordPress default', 'polylang' ) ) ),
|
126 |
$this->model->get_languages_list()
|
127 |
),
|
128 |
array(
|
129 |
'name' => 'user_lang',
|
130 |
'value' => 'locale',
|
131 |
+
'selected' => get_user_meta( $profileuser->ID, 'user_lang', true ),
|
132 |
)
|
133 |
)
|
134 |
);
|
135 |
|
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" />',
|
142 |
+
esc_attr( $lang->slug ),
|
143 |
+
esc_attr( $lang->name ),
|
144 |
+
esc_attr( $description )
|
145 |
);
|
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 |
*
|
153 |
* @since 0.6
|
154 |
*
|
155 |
* @param string $version new WP version
|
156 |
*/
|
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 |
}
|
170 |
* @param array $locale not used
|
171 |
* @return array list of locales to update
|
172 |
*/
|
173 |
+
function update_check_locales( $locales ) {
|
174 |
+
return $this->model->get_languages_list( array( 'fields' => 'locale' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
}
|
admin/admin-links.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
16 |
+
* @param object $language
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
public function get_new_post_translation_link( $post_id, $language ) {
|
20 |
+
$post_type = get_post_type( $post_id );
|
21 |
+
$post_type_object = get_post_type_object( get_post_type( $post_id ) );
|
22 |
+
if ( ! current_user_can( $post_type_object->cap->create_posts ) ) {
|
23 |
+
return '';
|
24 |
+
}
|
25 |
+
|
26 |
+
if ( 'attachment' == $post_type ) {
|
27 |
+
$args = array(
|
28 |
+
'action' => 'translate_media',
|
29 |
+
'from_media' => $post_id,
|
30 |
+
'new_lang' => $language->slug,
|
31 |
+
);
|
32 |
+
|
33 |
+
// add nonce for media as we will directly publish a new attachment from a clic on this link
|
34 |
+
$link = wp_nonce_url( add_query_arg( $args, admin_url( 'admin.php' ) ), 'translate_media' );
|
35 |
+
} else {
|
36 |
+
$args = array(
|
37 |
+
'post_type' => $post_type,
|
38 |
+
'from_post' => $post_id,
|
39 |
+
'new_lang' => $language->slug,
|
40 |
+
);
|
41 |
+
|
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 $post_id
|
54 |
+
* @param object $language
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function new_post_translation_link( $post_id, $language ) {
|
58 |
+
$link = $this->get_new_post_translation_link( $post_id, $language );
|
59 |
+
return $link ? sprintf(
|
60 |
+
'<a href="%1$s" class="pll_icon_add"><span class="screen-reader-text">%2$s</span></a>',
|
61 |
+
esc_url( $link ),
|
62 |
+
/* translators: %s is a native language name */
|
63 |
+
esc_html( sprintf( __( 'Add a translation in %s', 'polylang' ), $language->name ) )
|
64 |
+
) : '';
|
65 |
+
}
|
66 |
+
|
67 |
+
/*
|
68 |
+
* returns html markup for a translation link
|
69 |
+
*
|
70 |
+
* @since 1.4
|
71 |
+
*
|
72 |
+
* @param int $post_id translation post id
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function edit_post_translation_link( $post_id ) {
|
76 |
+
$link = get_edit_post_link( $post_id );
|
77 |
+
$language = $this->model->post->get_language( $post_id );
|
78 |
+
return $link ? sprintf(
|
79 |
+
'<a href="%1$s" class="pll_icon_edit"><span class="screen-reader-text">%2$s</span></a>',
|
80 |
+
esc_url( $link ),
|
81 |
+
/* translators: %s is a native language name */
|
82 |
+
esc_html( sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name ) )
|
83 |
+
) : '';
|
84 |
+
}
|
85 |
+
|
86 |
+
/*
|
87 |
+
* get the link to create a new term translation
|
88 |
+
*
|
89 |
+
* @since 1.5
|
90 |
+
*
|
91 |
+
* @param int $term_id
|
92 |
+
* @param string $taxonomy
|
93 |
+
* @param string $post_type
|
94 |
+
* @param object $language
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
public function get_new_term_translation_link( $term_id, $taxonomy, $post_type, $language ) {
|
98 |
+
$tax = get_taxonomy( $taxonomy );
|
99 |
+
if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) {
|
100 |
+
return '';
|
101 |
+
}
|
102 |
+
|
103 |
+
$args = array(
|
104 |
+
'taxonomy' => $taxonomy,
|
105 |
+
'post_type' => $post_type,
|
106 |
+
'from_tag' => $term_id,
|
107 |
+
'new_lang' => $language->slug,
|
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
|
118 |
+
*
|
119 |
+
* @param int $term_id
|
120 |
+
* @param string $taxonomy
|
121 |
+
* @param string $post_type
|
122 |
+
* @param object $language
|
123 |
+
* @return string
|
124 |
+
*/
|
125 |
+
public function new_term_translation_link( $term_id, $taxonomy, $post_type, $language ) {
|
126 |
+
$link = $this->get_new_term_translation_link( $term_id, $taxonomy, $post_type, $language );
|
127 |
+
return $link ? sprintf(
|
128 |
+
'<a href="%1$s" class="pll_icon_add"><span class="screen-reader-text">%2$s</span></a>',
|
129 |
+
esc_url( $link ),
|
130 |
+
/* translators: %s is a native language name */
|
131 |
+
esc_html( sprintf( __( 'Add a translation in %s', 'polylang' ), $language->name ) )
|
132 |
+
) : '';
|
133 |
+
}
|
134 |
+
|
135 |
+
/*
|
136 |
+
* returns html markup for a term translation link
|
137 |
+
*
|
138 |
+
* @since 1.4
|
139 |
+
*
|
140 |
+
* @param object $term_id translation term id
|
141 |
+
* @param string $taxonomy
|
142 |
+
* @param string $post_type
|
143 |
+
* @return string
|
144 |
+
*/
|
145 |
+
public function edit_term_translation_link( $term_id, $taxonomy, $post_type ) {
|
146 |
+
$link = get_edit_term_link( $term_id, $taxonomy, $post_type );
|
147 |
+
$language = $this->model->term->get_language( $term_id );
|
148 |
+
return $link ? sprintf(
|
149 |
+
'<a href="%1$s" class="pll_icon_edit"><span class="screen-reader-text">%2$s</span></a>',
|
150 |
+
esc_url( $link ),
|
151 |
+
/* translators: %s is a native language name */
|
152 |
+
esc_html( sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name ) )
|
153 |
+
) : '';
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
admin/admin-model.php
CHANGED
@@ -12,8 +12,8 @@ class PLL_Admin_Model extends PLL_Model {
|
|
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
|
@@ -26,44 +26,47 @@ class PLL_Admin_Model extends PLL_Model {
|
|
26 |
* @param array $args
|
27 |
* @return bool true if success / false if failed
|
28 |
*/
|
29 |
-
public function add_language($args) {
|
30 |
-
if (
|
31 |
return false;
|
|
|
32 |
|
33 |
// first the language taxonomy
|
34 |
-
$description = serialize(array('locale' => $args['locale'], 'rtl' => (int) $args['rtl']));
|
35 |
-
$r = wp_insert_term($args['name'], 'language', array('slug' => $args['slug'], 'description' => $description));
|
36 |
-
if (is_wp_error($r)) {
|
37 |
-
// avoid an ugly fatal error if something went wrong (reported once in the forum)
|
38 |
-
add_settings_error('general', 'pll_add_language', __('Impossible to add the language.', 'polylang'));
|
39 |
return false;
|
40 |
}
|
41 |
-
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
|
42 |
|
43 |
// the term_language taxonomy
|
44 |
// don't want shared terms so use a different slug
|
45 |
-
wp_insert_term($args['name'], 'term_language', array('slug' => 'pll_' . $args['slug']));
|
46 |
|
47 |
$this->clean_languages_cache(); // udpate the languages list now !
|
48 |
|
49 |
-
|
50 |
-
$mo = new PLL_MO();
|
51 |
-
$mo->export_to_db($this->get_language($args['slug']));
|
52 |
-
|
53 |
-
if (!isset($this->options['default_lang'])) {
|
54 |
// if this is the first language created, set it as default language
|
55 |
$this->options['default_lang'] = $args['slug'];
|
56 |
-
update_option('polylang', $this->options);
|
57 |
|
58 |
// and assign default language to default category
|
59 |
-
$this->
|
|
|
|
|
|
|
60 |
}
|
61 |
-
elseif (empty($args['no_default_cat']))
|
62 |
-
$this->create_default_category($args['slug']);
|
63 |
|
|
|
|
|
|
|
|
|
|
|
64 |
flush_rewrite_rules(); // refresh rewrite rules
|
65 |
|
66 |
-
add_settings_error('general', 'pll_languages_created', __('Language added.', 'polylang'), 'updated');
|
67 |
return true;
|
68 |
}
|
69 |
|
@@ -74,75 +77,76 @@ class PLL_Admin_Model extends PLL_Model {
|
|
74 |
*
|
75 |
* @param int $lang_id language term_id
|
76 |
*/
|
77 |
-
public function delete_language($lang_id) {
|
78 |
-
$lang = $this->get_language((int) $lang_id);
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
// delete the translations
|
82 |
-
$this->update_translations($lang->slug);
|
83 |
|
84 |
// delete language option in widgets
|
85 |
-
foreach ($GLOBALS['wp_registered_widgets'] as $widget) {
|
86 |
-
if (!empty($widget['callback'][0]) && !empty($widget['params'][0]['number'])) {
|
87 |
$obj = $widget['callback'][0];
|
88 |
$number = $widget['params'][0]['number'];
|
89 |
-
if (is_object($obj) && method_exists($obj, 'get_settings') && method_exists($obj, 'save_settings')) {
|
90 |
$settings = $obj->get_settings();
|
91 |
-
if (isset($settings[$number]['pll_lang']) && $settings[$number]['pll_lang'] == $lang->slug) {
|
92 |
-
unset($settings[$number]['pll_lang']);
|
93 |
-
$obj->save_settings($settings);
|
94 |
}
|
95 |
}
|
96 |
}
|
97 |
}
|
98 |
|
99 |
// delete menus locations
|
100 |
-
if (!empty($this->options['nav_menus'])) {
|
101 |
-
foreach ($this->options['nav_menus'] as $theme => $locations) {
|
102 |
-
foreach ($locations as $location => $languages) {
|
103 |
-
unset($this->options['nav_menus'][$theme][$location][$lang->slug]);
|
104 |
}
|
105 |
}
|
106 |
}
|
107 |
|
108 |
// delete users options
|
109 |
-
foreach (get_users(array('fields' => 'ID')) as $user_id) {
|
110 |
-
delete_user_meta($user_id, 'user_lang', $lang->locale);
|
111 |
-
delete_user_meta($user_id, 'pll_filter_content', $lang->slug);
|
112 |
-
delete_user_meta($user_id, 'description_'.$lang->slug);
|
113 |
}
|
114 |
|
115 |
// delete the string translations
|
116 |
-
$post = get_page_by_title('polylang_mo_' . $lang->term_id, OBJECT, 'polylang_mo');
|
117 |
-
if (!empty($post))
|
118 |
-
wp_delete_post($post->ID);
|
|
|
119 |
|
120 |
// delete domain
|
121 |
-
unset($this->options['domains'][$lang->slug]);
|
122 |
|
123 |
// delete the language itself
|
124 |
-
wp_delete_term($lang->term_id, 'language');
|
125 |
-
wp_delete_term($lang->tl_term_id, 'term_language');
|
126 |
|
127 |
// update languages list
|
128 |
$this->clean_languages_cache();
|
129 |
|
130 |
-
|
131 |
-
if ($this->options['default_lang'] == $lang->slug) {
|
132 |
-
if ($slugs = $this->get_languages_list(array('fields' => 'slug'))) {
|
133 |
-
$this->options['default_lang'] = $slug = reset($slugs); // arbitrary choice...
|
134 |
-
|
135 |
-
// the default category should be in the default language
|
136 |
-
if (isset($default_cats[$slug]))
|
137 |
-
update_option('default_category', $default_cats[$slug]);
|
138 |
-
}
|
139 |
-
else
|
140 |
-
unset($this->options['default_lang']);
|
141 |
-
}
|
142 |
-
|
143 |
-
update_option('polylang', $this->options);
|
144 |
flush_rewrite_rules(); // refresh rewrite rules
|
145 |
-
add_settings_error('general', 'pll_languages_deleted', __('Language deleted.', 'polylang'), 'updated');
|
146 |
}
|
147 |
|
148 |
/*
|
@@ -150,8 +154,8 @@ class PLL_Admin_Model extends PLL_Model {
|
|
150 |
*
|
151 |
* list of arguments that $args must contain:
|
152 |
* lang_id -> term_id of the language to modify
|
153 |
-
* name -> language name (used only for display)
|
154 |
-
* slug -> language code (ideally 2-letters ISO 639-1 language code
|
155 |
* locale -> WordPress locale. If something wrong is used for the locale, the .mo files will not be loaded...
|
156 |
* rtl -> 1 if rtl language, 0 otherwise
|
157 |
* term_group -> language order when displayed
|
@@ -161,67 +165,69 @@ class PLL_Admin_Model extends PLL_Model {
|
|
161 |
* @param array $args
|
162 |
* @return bool true if success / false if failed
|
163 |
*/
|
164 |
-
public function update_language($args) {
|
165 |
-
$lang = $this->get_language((int) $args['lang_id']);
|
166 |
-
if (
|
167 |
return false;
|
|
|
168 |
|
169 |
// Update links to this language in posts and terms in case the slug has been modified
|
170 |
$slug = $args['slug'];
|
171 |
$old_slug = $lang->slug;
|
172 |
|
173 |
-
if ($old_slug != $slug) {
|
174 |
// update the language slug in translations
|
175 |
-
$this->update_translations($old_slug, $slug);
|
176 |
|
177 |
// update language option in widgets
|
178 |
-
foreach ($GLOBALS['wp_registered_widgets'] as $widget) {
|
179 |
-
if (!empty($widget['callback'][0]) && !empty($widget['params'][0]['number'])) {
|
180 |
$obj = $widget['callback'][0];
|
181 |
$number = $widget['params'][0]['number'];
|
182 |
-
if (is_object($obj) && method_exists($obj, 'get_settings') && method_exists($obj, 'save_settings')) {
|
183 |
$settings = $obj->get_settings();
|
184 |
-
if (isset($settings[$number]['pll_lang']) && $settings[$number]['pll_lang'] == $old_slug) {
|
185 |
-
$settings[$number]['pll_lang'] = $slug;
|
186 |
-
$obj->save_settings($settings);
|
187 |
}
|
188 |
}
|
189 |
}
|
190 |
}
|
191 |
|
192 |
// update menus locations
|
193 |
-
if (!empty($this->options['nav_menus'])) {
|
194 |
-
foreach ($this->options['nav_menus'] as $theme => $locations) {
|
195 |
-
foreach ($locations as $location => $languages) {
|
196 |
-
if (!empty($this->options['nav_menus'][$theme][$location][$old_slug])) {
|
197 |
-
$this->options['nav_menus'][$theme][$location][$slug] = $this->options['nav_menus'][$theme][$location][$old_slug];
|
198 |
-
unset($this->options['nav_menus'][$theme][$location][$old_slug]);
|
199 |
}
|
200 |
}
|
201 |
}
|
202 |
}
|
203 |
|
204 |
// update domains
|
205 |
-
if (!empty($this->options['domains'][$old_slug])) {
|
206 |
-
$this->options['domains'][$slug] = $this->options['domains'][$old_slug];
|
207 |
-
unset($this->options['domains'][$old_slug]);
|
208 |
}
|
209 |
|
210 |
// update the default language option if necessary
|
211 |
-
if ($this->options['default_lang'] == $old_slug)
|
212 |
$this->options['default_lang'] = $slug;
|
|
|
213 |
}
|
214 |
|
215 |
-
update_option('polylang', $this->options);
|
216 |
|
217 |
// and finally update the language itself
|
218 |
-
$description = serialize(array('locale' => $args['locale'], 'rtl' => (int) $args['rtl']));
|
219 |
-
wp_update_term((int) $lang->term_id, 'language', array('slug' => $slug, 'name' => $args['name'], 'description' => $description, 'term_group' => (int) $args['term_group']));
|
220 |
-
wp_update_term((int) $lang->tl_term_id, 'term_language', array('slug' => 'pll_' . $slug, 'name' =>
|
221 |
|
222 |
$this->clean_languages_cache();
|
223 |
flush_rewrite_rules(); // refresh rewrite rules
|
224 |
-
add_settings_error('general', 'pll_languages_updated', __('Language updated.', 'polylang'), 'updated');
|
225 |
return true;
|
226 |
}
|
227 |
|
@@ -235,23 +241,32 @@ class PLL_Admin_Model extends PLL_Model {
|
|
235 |
* @return bool true if success / false if failed
|
236 |
* @see PLL_Admin_Model::add_language
|
237 |
*/
|
238 |
-
protected function validate_lang($args, $lang = null) {
|
239 |
// validate locale with the same pattern as WP 4.3. See #28303
|
240 |
-
if ( !preg_match('#^[a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?$#', $args['locale'], $matches))
|
241 |
-
add_settings_error('general', 'pll_invalid_locale', __('Enter a valid WordPress locale', 'polylang'));
|
|
|
242 |
|
243 |
// validate slug characters
|
244 |
-
if (!preg_match('#^[a-z_-]+$#', $args['slug']))
|
245 |
-
add_settings_error('general', 'pll_invalid_slug', __('The language code contains invalid characters', 'polylang'));
|
|
|
246 |
|
247 |
// validate slug is unique
|
248 |
-
if ($this->get_language($args['slug']) && (
|
249 |
-
add_settings_error('general', 'pll_non_unique_slug', __('The language code must be unique', 'polylang'));
|
|
|
250 |
|
251 |
// validate name
|
252 |
// no need to sanitize it as wp_insert_term will do it for us
|
253 |
-
if (empty($args['name']))
|
254 |
-
add_settings_error('general', 'pll_invalid_name', __('The language must have a name', 'polylang'));
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
return get_settings_errors() ? false : true;
|
257 |
}
|
@@ -265,28 +280,31 @@ class PLL_Admin_Model extends PLL_Model {
|
|
265 |
* @param array $ids array of post ids or term ids
|
266 |
* @param object|string $lang object or slug
|
267 |
*/
|
268 |
-
public function set_language_in_mass($type, $ids, $lang) {
|
269 |
global $wpdb;
|
270 |
|
271 |
-
$ids = array_map('intval', $ids);
|
272 |
-
$lang = $this->get_language($lang);
|
273 |
$tt_id = 'term' == $type ? $lang->tl_term_taxonomy_id : $lang->term_taxonomy_id;
|
274 |
|
275 |
-
foreach ($ids as $id)
|
276 |
-
$values[] = $wpdb->prepare(
|
|
|
277 |
|
278 |
-
if (!empty($values)) {
|
279 |
-
$values = array_unique($values);
|
280 |
-
$wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES " . implode(',', $values));
|
281 |
-
$lang->update_count(); // updating term count is mandatory (thanks to AndyDeGroo)
|
282 |
}
|
283 |
|
284 |
-
if ('term' == $type) {
|
285 |
-
foreach ($ids as $id)
|
286 |
-
$translations[] = array($lang->slug => $id);
|
|
|
287 |
|
288 |
-
if (!empty($translations))
|
289 |
-
$this->set_translation_in_mass('term', $translations);
|
|
|
290 |
}
|
291 |
}
|
292 |
|
@@ -298,83 +316,87 @@ class PLL_Admin_Model extends PLL_Model {
|
|
298 |
* @param string $type either 'post' or 'term'
|
299 |
* @param array $translations array of translations arrays
|
300 |
*/
|
301 |
-
public function set_translation_in_mass($type, $translations) {
|
302 |
global $wpdb;
|
303 |
|
304 |
-
foreach ($translations as $t) {
|
305 |
-
$term = uniqid('pll_'); // the term name
|
306 |
-
$terms[] = $wpdb->prepare('("%1$s", "%1$s")', $term);
|
307 |
-
$slugs[] = $wpdb->prepare('"%s"', $term);
|
308 |
-
$description[$term] = serialize($t);
|
309 |
-
$count[$term] = count($t);
|
310 |
}
|
311 |
|
312 |
// insert terms
|
313 |
-
if (!empty($terms)) {
|
314 |
-
$terms = array_unique($terms);
|
315 |
-
$wpdb->query("INSERT INTO $wpdb->terms (slug, name) VALUES " . implode(',', $terms));
|
316 |
}
|
317 |
|
318 |
// get all terms with their term_id
|
319 |
-
$terms = $wpdb->get_results("SELECT term_id, slug FROM $wpdb->terms WHERE slug IN (" . implode(',', $slugs) . ")");
|
320 |
|
321 |
// prepare terms taxonomy relationship
|
322 |
-
foreach ($terms as $term)
|
323 |
-
$tts[] = $wpdb->prepare('(%d, "%s", "%s", %d)', $term->term_id, $type . '_translations', $description[$term->slug], $count[$term->slug]);
|
|
|
324 |
|
325 |
// insert term_taxonomy
|
326 |
-
if (!empty($tts)) {
|
327 |
-
$tts = array_unique($tts);
|
328 |
-
$wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, count) VALUES " . implode(',', $tts));
|
329 |
}
|
330 |
|
331 |
// get all terms with term_taxonomy_id
|
332 |
-
$terms = get_terms($type . '_translations', array('hide_empty' => false));
|
333 |
|
334 |
// prepare objects relationships
|
335 |
-
foreach ($terms as $term) {
|
336 |
-
$t = unserialize($term->description);
|
337 |
-
if (in_array($t, $translations)) {
|
338 |
-
foreach ($t as $object_id)
|
339 |
-
if (!empty($object_id))
|
340 |
-
$trs[] = $wpdb->prepare('(%d, %d)', $object_id, $term->term_taxonomy_id);
|
|
|
|
|
341 |
}
|
342 |
}
|
343 |
|
344 |
// insert term_relationships
|
345 |
-
if (!empty($trs)) {
|
346 |
-
$wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES " . implode(',', $trs));
|
347 |
-
$trs = array_unique($trs);
|
348 |
}
|
349 |
}
|
350 |
|
351 |
/*
|
352 |
-
* returns unstranslated posts and terms ids (used in settings)
|
353 |
*
|
354 |
* @since 0.9
|
355 |
*
|
356 |
* @return array array made of an array of post ids and an array of term ids
|
357 |
*/
|
358 |
public function get_objects_with_no_lang() {
|
359 |
-
$posts = get_posts(array(
|
360 |
'numberposts' => -1,
|
361 |
'nopaging' => true,
|
362 |
'post_type' => $this->get_translated_post_types(),
|
363 |
'post_status' => 'any',
|
364 |
'fields' => 'ids',
|
365 |
-
'tax_query' => array(array(
|
366 |
'taxonomy' => 'language',
|
367 |
-
'terms' => $this->get_languages_list(array('fields' => 'term_id')),
|
368 |
-
'operator' => 'NOT IN'
|
369 |
-
))
|
370 |
-
));
|
371 |
-
|
372 |
-
$terms = get_terms($this->get_translated_taxonomies(), array('get'=>'all', 'fields'=>'ids'));
|
373 |
-
$groups = $this->get_languages_list(array('fields' => 'tl_term_id'));
|
374 |
-
$tr_terms = get_objects_in_term($groups, 'term_language');
|
375 |
-
$terms = array_unique(array_diff($terms, $tr_terms)); // array_unique to avoid duplicates if a term is in more than one taxonomy
|
376 |
-
|
377 |
-
|
|
|
378 |
}
|
379 |
|
380 |
/*
|
@@ -385,49 +407,88 @@ class PLL_Admin_Model extends PLL_Model {
|
|
385 |
* @param string $old_slug the old language slug
|
386 |
* @param string $new_slug optional, the new language slug, if not set it means the correspondant has been deleted
|
387 |
*/
|
388 |
-
public function update_translations($old_slug, $new_slug = '') {
|
389 |
global $wpdb;
|
390 |
|
391 |
-
$terms = get_terms(array('post_translations', 'term_translations'));
|
392 |
|
393 |
-
foreach ($terms as $term) {
|
394 |
-
$tr = unserialize($term->description);
|
395 |
-
if (!empty($tr[$old_slug])) {
|
396 |
-
if ($new_slug)
|
397 |
-
$tr[$new_slug] = $tr[$old_slug]; // suppress this for delete
|
|
|
398 |
else {
|
399 |
-
$dr['id'][] = (int) $tr[$old_slug];
|
400 |
$dr['tt'][] = (int) $term->term_taxonomy_id;
|
401 |
}
|
402 |
-
unset($tr[$old_slug]);
|
403 |
|
404 |
-
if (empty($tr) || 1 == count($tr)) {
|
405 |
$dt['t'][] = (int) $term->term_id;
|
406 |
$dt['tt'][] = (int) $term->term_taxonomy_id;
|
407 |
}
|
408 |
else {
|
409 |
-
$ut['case'][] = $wpdb->prepare('WHEN %d THEN %s', $term->term_id, serialize($tr));
|
410 |
$ut['in'][] = (int) $term->term_id;
|
411 |
}
|
412 |
}
|
413 |
}
|
414 |
|
415 |
// delete relationships
|
416 |
-
if (!empty($dr))
|
417 |
-
$wpdb->query("
|
418 |
-
|
419 |
-
|
|
|
|
|
|
|
420 |
|
421 |
// delete terms
|
422 |
-
if (!empty($dt)) {
|
423 |
-
$wpdb->query("DELETE FROM $wpdb->terms WHERE term_id IN ( " . implode(',', $dt['t']) . " ) ");
|
424 |
-
$wpdb->query("DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ( " . implode(',', $dt['tt']) . " ) ");
|
425 |
}
|
426 |
|
427 |
// update terms
|
428 |
-
if (!empty($ut))
|
429 |
-
$wpdb->query("
|
430 |
-
|
431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
}
|
433 |
}
|
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
|
26 |
* @param array $args
|
27 |
* @return bool true if success / false if failed
|
28 |
*/
|
29 |
+
public function add_language( $args ) {
|
30 |
+
if ( ! $this->validate_lang( $args ) ) {
|
31 |
return false;
|
32 |
+
}
|
33 |
|
34 |
// first the language taxonomy
|
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 |
+
// avoid an ugly fatal error if something went wrong ( reported once in the forum )
|
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 |
// the term_language taxonomy
|
45 |
// don't want shared terms so use a different slug
|
46 |
+
wp_insert_term( $args['name'], 'term_language', array( 'slug' => 'pll_' . $args['slug'] ) );
|
47 |
|
48 |
$this->clean_languages_cache(); // udpate the languages list now !
|
49 |
|
50 |
+
if ( ! isset( $this->options['default_lang'] ) ) {
|
|
|
|
|
|
|
|
|
51 |
// if this is the first language created, set it as default language
|
52 |
$this->options['default_lang'] = $args['slug'];
|
53 |
+
update_option( 'polylang', $this->options );
|
54 |
|
55 |
// and assign default language to default category
|
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 |
+
// init a mo_id for this language
|
63 |
+
$mo = new PLL_MO();
|
64 |
+
$mo->export_to_db( $this->get_language( $args['slug'] ) );
|
65 |
+
|
66 |
+
$this->clean_languages_cache(); // again to set add mo_id in the cached languages list
|
67 |
flush_rewrite_rules(); // refresh rewrite rules
|
68 |
|
69 |
+
add_settings_error( 'general', 'pll_languages_created', __( 'Language added.', 'polylang' ), 'updated' );
|
70 |
return true;
|
71 |
}
|
72 |
|
77 |
*
|
78 |
* @param int $lang_id language term_id
|
79 |
*/
|
80 |
+
public function delete_language( $lang_id ) {
|
81 |
+
$lang = $this->get_language( (int) $lang_id );
|
82 |
+
|
83 |
+
// oops ! we are deleting the default language...
|
84 |
+
// need to do this before loosing the information for default category translations
|
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 ) ); // arbitrary choice...
|
91 |
+
}
|
92 |
+
else {
|
93 |
+
unset( $this->options['default_lang'] );
|
94 |
+
}
|
95 |
+
}
|
96 |
|
97 |
// delete the translations
|
98 |
+
$this->update_translations( $lang->slug );
|
99 |
|
100 |
// delete language option in widgets
|
101 |
+
foreach ( $GLOBALS['wp_registered_widgets'] as $widget ) {
|
102 |
+
if ( ! empty( $widget['callback'][0] ) && ! empty( $widget['params'][0]['number'] ) ) {
|
103 |
$obj = $widget['callback'][0];
|
104 |
$number = $widget['params'][0]['number'];
|
105 |
+
if ( is_object( $obj ) && method_exists( $obj, 'get_settings' ) && method_exists( $obj, 'save_settings' ) ) {
|
106 |
$settings = $obj->get_settings();
|
107 |
+
if ( isset( $settings[ $number ]['pll_lang'] ) && $settings[ $number ]['pll_lang'] == $lang->slug ) {
|
108 |
+
unset( $settings[ $number ]['pll_lang'] );
|
109 |
+
$obj->save_settings( $settings );
|
110 |
}
|
111 |
}
|
112 |
}
|
113 |
}
|
114 |
|
115 |
// delete menus locations
|
116 |
+
if ( ! empty( $this->options['nav_menus'] ) ) {
|
117 |
+
foreach ( $this->options['nav_menus'] as $theme => $locations ) {
|
118 |
+
foreach ( $locations as $location => $languages ) {
|
119 |
+
unset( $this->options['nav_menus'][ $theme ][ $location ][ $lang->slug ] );
|
120 |
}
|
121 |
}
|
122 |
}
|
123 |
|
124 |
// delete users options
|
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 |
// delete the string translations
|
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 |
// delete domain
|
138 |
+
unset( $this->options['domains'][ $lang->slug ] );
|
139 |
|
140 |
// delete the language itself
|
141 |
+
wp_delete_term( $lang->term_id, 'language' );
|
142 |
+
wp_delete_term( $lang->tl_term_id, 'term_language' );
|
143 |
|
144 |
// update languages list
|
145 |
$this->clean_languages_cache();
|
146 |
|
147 |
+
update_option( 'polylang', $this->options );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
flush_rewrite_rules(); // refresh rewrite rules
|
149 |
+
add_settings_error( 'general', 'pll_languages_deleted', __( 'Language deleted.', 'polylang' ), 'updated' );
|
150 |
}
|
151 |
|
152 |
/*
|
154 |
*
|
155 |
* list of arguments that $args must contain:
|
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
|
159 |
* locale -> WordPress locale. If something wrong is used for the locale, the .mo files will not be loaded...
|
160 |
* rtl -> 1 if rtl language, 0 otherwise
|
161 |
* term_group -> language order when displayed
|
165 |
* @param array $args
|
166 |
* @return bool true if success / false if failed
|
167 |
*/
|
168 |
+
public function update_language( $args ) {
|
169 |
+
$lang = $this->get_language( (int) $args['lang_id'] );
|
170 |
+
if ( ! $this->validate_lang( $args, $lang ) ) {
|
171 |
return false;
|
172 |
+
}
|
173 |
|
174 |
// Update links to this language in posts and terms in case the slug has been modified
|
175 |
$slug = $args['slug'];
|
176 |
$old_slug = $lang->slug;
|
177 |
|
178 |
+
if ( $old_slug != $slug ) {
|
179 |
// update the language slug in translations
|
180 |
+
$this->update_translations( $old_slug, $slug );
|
181 |
|
182 |
// update language option in widgets
|
183 |
+
foreach ( $GLOBALS['wp_registered_widgets'] as $widget ) {
|
184 |
+
if ( ! empty( $widget['callback'][0] ) && ! empty( $widget['params'][0]['number'] ) ) {
|
185 |
$obj = $widget['callback'][0];
|
186 |
$number = $widget['params'][0]['number'];
|
187 |
+
if ( is_object( $obj ) && method_exists( $obj, 'get_settings' ) && method_exists( $obj, 'save_settings' ) ) {
|
188 |
$settings = $obj->get_settings();
|
189 |
+
if ( isset( $settings[ $number ]['pll_lang'] ) && $settings[ $number ]['pll_lang'] == $old_slug ) {
|
190 |
+
$settings[ $number ]['pll_lang'] = $slug;
|
191 |
+
$obj->save_settings( $settings );
|
192 |
}
|
193 |
}
|
194 |
}
|
195 |
}
|
196 |
|
197 |
// update menus locations
|
198 |
+
if ( ! empty( $this->options['nav_menus'] ) ) {
|
199 |
+
foreach ( $this->options['nav_menus'] as $theme => $locations ) {
|
200 |
+
foreach ( $locations as $location => $languages ) {
|
201 |
+
if ( ! empty( $this->options['nav_menus'][ $theme ][ $location ][ $old_slug ] ) ) {
|
202 |
+
$this->options['nav_menus'][ $theme ][ $location ][ $slug ] = $this->options['nav_menus'][ $theme ][ $location ][ $old_slug ];
|
203 |
+
unset( $this->options['nav_menus'][ $theme ][ $location ][ $old_slug ] );
|
204 |
}
|
205 |
}
|
206 |
}
|
207 |
}
|
208 |
|
209 |
// update domains
|
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 |
// update the default language option if necessary
|
216 |
+
if ( $this->options['default_lang'] == $old_slug ) {
|
217 |
$this->options['default_lang'] = $slug;
|
218 |
+
}
|
219 |
}
|
220 |
|
221 |
+
update_option( 'polylang', $this->options );
|
222 |
|
223 |
// and finally update the language itself
|
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(); // refresh rewrite rules
|
230 |
+
add_settings_error( 'general', 'pll_languages_updated', __( 'Language updated.', 'polylang' ), 'updated' );
|
231 |
return true;
|
232 |
}
|
233 |
|
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 |
// validate locale with the same pattern as WP 4.3. See #28303
|
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 |
// validate slug characters
|
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 |
// validate slug is unique
|
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 |
// validate name
|
261 |
// no need to sanitize it as wp_insert_term will do it for us
|
262 |
+
if ( empty( $args['name'] ) ) {
|
263 |
+
add_settings_error( 'general', 'pll_invalid_name', __( 'The language must have a name', 'polylang' ) );
|
264 |
+
}
|
265 |
+
|
266 |
+
// validate flag
|
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 |
+
}
|
270 |
|
271 |
return get_settings_errors() ? false : true;
|
272 |
}
|
280 |
* @param array $ids array of post ids or term ids
|
281 |
* @param object|string $lang object or slug
|
282 |
*/
|
283 |
+
public function set_language_in_mass( $type, $ids, $lang ) {
|
284 |
global $wpdb;
|
285 |
|
286 |
+
$ids = array_map( 'intval', $ids );
|
287 |
+
$lang = $this->get_language( $lang );
|
288 |
$tt_id = 'term' == $type ? $lang->tl_term_taxonomy_id : $lang->term_taxonomy_id;
|
289 |
|
290 |
+
foreach ( $ids as $id ) {
|
291 |
+
$values[] = $wpdb->prepare( '( %d, %d )', $id, $tt_id );
|
292 |
+
}
|
293 |
|
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(); // updating term count is mandatory ( thanks to AndyDeGroo )
|
298 |
}
|
299 |
|
300 |
+
if ( 'term' == $type ) {
|
301 |
+
foreach ( $ids as $id ) {
|
302 |
+
$translations[] = array( $lang->slug => $id );
|
303 |
+
}
|
304 |
|
305 |
+
if ( ! empty( $translations ) ) {
|
306 |
+
$this->set_translation_in_mass( 'term', $translations );
|
307 |
+
}
|
308 |
}
|
309 |
}
|
310 |
|
316 |
* @param string $type either 'post' or 'term'
|
317 |
* @param array $translations array of translations arrays
|
318 |
*/
|
319 |
+
public function set_translation_in_mass( $type, $translations ) {
|
320 |
global $wpdb;
|
321 |
|
322 |
+
foreach ( $translations as $t ) {
|
323 |
+
$term = uniqid( 'pll_' ); // the term name
|
324 |
+
$terms[] = $wpdb->prepare( '( "%1$s", "%1$s" )', $term );
|
325 |
+
$slugs[] = $wpdb->prepare( '"%s"', $term );
|
326 |
+
$description[ $term ] = serialize( $t );
|
327 |
+
$count[ $term ] = count( $t );
|
328 |
}
|
329 |
|
330 |
// insert terms
|
331 |
+
if ( ! empty( $terms ) ) {
|
332 |
+
$terms = array_unique( $terms );
|
333 |
+
$wpdb->query( "INSERT INTO $wpdb->terms ( slug, name ) VALUES " . implode( ',', $terms ) );
|
334 |
}
|
335 |
|
336 |
// get all terms with their term_id
|
337 |
+
$terms = $wpdb->get_results( "SELECT term_id, slug FROM $wpdb->terms WHERE slug IN ( " . implode( ',', $slugs ) . " )" );
|
338 |
|
339 |
// prepare terms taxonomy relationship
|
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 |
// insert term_taxonomy
|
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 |
// get all terms with term_taxonomy_id
|
351 |
+
$terms = get_terms( $type . '_translations', array( 'hide_empty' => false ) );
|
352 |
|
353 |
// prepare objects relationships
|
354 |
+
foreach ( $terms as $term ) {
|
355 |
+
$t = unserialize( $term->description );
|
356 |
+
if ( in_array( $t, $translations ) ) {
|
357 |
+
foreach ( $t as $object_id ) {
|
358 |
+
if ( ! empty( $object_id ) ) {
|
359 |
+
$trs[] = $wpdb->prepare( '( %d, %d )', $object_id, $term->term_taxonomy_id );
|
360 |
+
}
|
361 |
+
}
|
362 |
}
|
363 |
}
|
364 |
|
365 |
// insert term_relationships
|
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 |
+
* returns unstranslated posts and terms ids ( used in settings )
|
374 |
*
|
375 |
* @since 0.9
|
376 |
*
|
377 |
* @return array array made of an array of post ids and an array of term ids
|
378 |
*/
|
379 |
public function get_objects_with_no_lang() {
|
380 |
+
$posts = get_posts( array(
|
381 |
'numberposts' => -1,
|
382 |
'nopaging' => true,
|
383 |
'post_type' => $this->get_translated_post_types(),
|
384 |
'post_status' => 'any',
|
385 |
'fields' => 'ids',
|
386 |
+
'tax_query' => array( array(
|
387 |
'taxonomy' => 'language',
|
388 |
+
'terms' => $this->get_languages_list( array( 'fields' => 'term_id' ) ),
|
389 |
+
'operator' => 'NOT IN',
|
390 |
+
) )
|
391 |
+
) );
|
392 |
+
|
393 |
+
$terms = get_terms( $this->get_translated_taxonomies(), array( 'get' => 'all', 'fields' => 'ids' ) );
|
394 |
+
$groups = $this->get_languages_list( array( 'fields' => 'tl_term_id' ) );
|
395 |
+
$tr_terms = get_objects_in_term( $groups, 'term_language' );
|
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 |
/*
|
407 |
* @param string $old_slug the old language slug
|
408 |
* @param string $new_slug optional, the new language slug, if not set it means the correspondant has been deleted
|
409 |
*/
|
410 |
+
public function update_translations( $old_slug, $new_slug = '' ) {
|
411 |
global $wpdb;
|
412 |
|
413 |
+
$terms = get_terms( array( 'post_translations', 'term_translations' ) );
|
414 |
|
415 |
+
foreach ( $terms as $term ) {
|
416 |
+
$tr = unserialize( $term->description );
|
417 |
+
if ( ! empty( $tr[ $old_slug ] ) ) {
|
418 |
+
if ( $new_slug ) {
|
419 |
+
$tr[ $new_slug ] = $tr[ $old_slug ]; // suppress this for delete
|
420 |
+
}
|
421 |
else {
|
422 |
+
$dr['id'][] = (int) $tr[ $old_slug ];
|
423 |
$dr['tt'][] = (int) $term->term_taxonomy_id;
|
424 |
}
|
425 |
+
unset( $tr[ $old_slug ] );
|
426 |
|
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 |
// delete relationships
|
439 |
+
if ( ! empty( $dr ) ) {
|
440 |
+
$wpdb->query( "
|
441 |
+
DELETE FROM $wpdb->term_relationships
|
442 |
+
WHERE object_id IN ( " . implode( ',', $dr['id'] ) . " )
|
443 |
+
AND term_taxonomy_id IN ( " . implode( ',', $dr['tt'] ) . " )
|
444 |
+
" );
|
445 |
+
}
|
446 |
|
447 |
// delete terms
|
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 |
// update terms
|
454 |
+
if ( ! empty( $ut ) ) {
|
455 |
+
$wpdb->query( "
|
456 |
+
UPDATE $wpdb->term_taxonomy
|
457 |
+
SET description = ( CASE term_id " . implode( ' ', $ut['case'] ) . " END )
|
458 |
+
WHERE term_id IN ( " . implode( ',', $ut['in'] ) . " )
|
459 |
+
" );
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
/*
|
464 |
+
* updates the default language
|
465 |
+
* taking care to update the default category & the nav menu locations
|
466 |
+
*
|
467 |
+
* @since 1.8
|
468 |
+
*
|
469 |
+
* @param string $slug new language slug
|
470 |
+
*/
|
471 |
+
public function update_default_lang( $slug ) {
|
472 |
+
// the nav menus stored in theme locations should be in the default language
|
473 |
+
$theme = get_stylesheet();
|
474 |
+
if ( ! empty( $this->options['nav_menus'][ $theme ] ) ) {
|
475 |
+
foreach ( $this->options['nav_menus'][ $theme ] as $key => $loc ) {
|
476 |
+
$menus[ $key ] = empty( $loc[ $slug ] ) ? 0 : $loc[ $slug ];
|
477 |
+
}
|
478 |
+
set_theme_mod( 'nav_menu_locations', $menus );
|
479 |
+
}
|
480 |
+
|
481 |
+
// the default category should be in the default language
|
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 |
+
// update options
|
488 |
+
$this->options['default_lang'] = $slug;
|
489 |
+
update_option( 'polylang', $this->options );
|
490 |
+
|
491 |
+
$this->clean_languages_cache();
|
492 |
+
flush_rewrite_rules();
|
493 |
}
|
494 |
}
|
admin/admin-nav-menu.php
CHANGED
@@ -14,22 +14,23 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
14 |
*
|
15 |
* @param object $polylang
|
16 |
*/
|
17 |
-
public function __construct(&$polylang) {
|
18 |
-
parent::__construct($polylang);
|
19 |
|
20 |
$this->theme = get_option( 'stylesheet' );
|
21 |
|
22 |
// populates nav menus locations
|
23 |
// since WP 4.4, must be done before customize_register is fired
|
24 |
-
add_filter('theme_mod_nav_menu_locations', array($this, '
|
25 |
|
26 |
// integration in the WP menu interface
|
27 |
-
add_action('admin_init', array(&$this, 'admin_init')); // after Polylang upgrade
|
28 |
|
29 |
// protection against #24802
|
30 |
// backward compatibility with WP < 4.1
|
31 |
-
if (version_compare($GLOBALS['wp_version'], '4.1', '<'))
|
32 |
-
add_filter('pre_insert_term', array(&$this, 'pre_insert_term'), 10, 2);
|
|
|
33 |
}
|
34 |
|
35 |
/*
|
@@ -38,21 +39,21 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
38 |
*
|
39 |
* @since 1.1
|
40 |
*/
|
41 |
-
public function admin_init(){
|
42 |
-
add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
|
43 |
-
add_action('wp_update_nav_menu_item', array(&$this, 'wp_update_nav_menu_item'), 10, 2);
|
44 |
-
add_filter('wp_get_nav_menu_items', array(&$this, 'translate_switcher_title'));
|
45 |
|
46 |
// translation of menus based on chosen locations
|
47 |
-
add_filter('pre_update_option_theme_mods_' . $this->theme, array($this, '
|
48 |
-
add_action('delete_nav_menu', array(&$this, 'delete_nav_menu'));
|
49 |
|
50 |
// filter _wp_auto_add_pages_to_menu by language
|
51 |
-
add_action('transition_post_status', array(&$this, 'auto_add_pages_to_menu'), 5, 3); // before _wp_auto_add_pages_to_menu
|
52 |
|
53 |
-
// FIXME is it possible to choose the order (after theme locations in WP3.5 and older) ?
|
54 |
// FIXME not displayed if Polylang is activated before the first time the user goes to nav menus http://core.trac.wordpress.org/ticket/16828
|
55 |
-
add_meta_box('pll_lang_switch_box', __('Language switcher', 'polylang'), array( &$this, 'lang_switch' ), 'nav-menus', 'side', 'high');
|
56 |
|
57 |
$this->create_nav_menu_locations();
|
58 |
}
|
@@ -66,28 +67,28 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
66 |
*/
|
67 |
public function lang_switch() {
|
68 |
global $_nav_menu_placeholder, $nav_menu_selected_id;
|
69 |
-
$_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1
|
70 |
|
71 |
<div id="posttype-lang-switch" class="posttypediv">
|
72 |
<div id="tabs-panel-lang-switch" class="tabs-panel tabs-panel-active">
|
73 |
<ul id ="lang-switch-checklist" class="categorychecklist form-no-clear">
|
74 |
<li>
|
75 |
<label class="menu-item-title">
|
76 |
-
<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-object-id]" value="-1"> <?php _e('Language switcher', 'polylang'); ?>
|
77 |
</label>
|
78 |
<input type="hidden" class="menu-item-type" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" value="custom">
|
79 |
-
<input type="hidden" class="menu-item-title" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" value="<?php _e('Language switcher', 'polylang'); ?>">
|
80 |
<input type="hidden" class="menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" value="#pll_switcher">
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
}
|
92 |
|
93 |
/*
|
@@ -97,34 +98,37 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
97 |
*/
|
98 |
public function admin_enqueue_scripts() {
|
99 |
$screen = get_current_screen();
|
100 |
-
if ('nav-menus' != $screen->base)
|
101 |
return;
|
|
|
102 |
|
103 |
-
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
|
104 |
-
wp_enqueue_script('pll_nav_menu', POLYLANG_URL .'/js/nav-menu'
|
105 |
|
106 |
// the strings for the options
|
107 |
-
foreach (array_reverse(PLL_Switcher::get_switcher_options('menu', 'string')) as $str)
|
108 |
$data['strings'][] = $str;
|
|
|
109 |
|
110 |
-
$data['title'] = __('Language switcher', 'polylang'); // the title
|
111 |
|
112 |
// get all language switcher menu items
|
113 |
-
$items = get_posts(array(
|
114 |
'numberposts' => -1,
|
115 |
'nopaging' => true,
|
116 |
'post_type' => 'nav_menu_item',
|
117 |
'fields' => 'ids',
|
118 |
-
'meta_key' => '_pll_menu_item'
|
119 |
-
));
|
120 |
|
121 |
// the options values for the language switcher
|
122 |
$data['val'] = array();
|
123 |
-
foreach ($items as $item)
|
124 |
-
$data['val'][$item] = get_post_meta($item, '_pll_menu_item', true);
|
|
|
125 |
|
126 |
// send all these data to javascript
|
127 |
-
wp_localize_script('pll_nav_menu', 'pll_data', $data);
|
128 |
}
|
129 |
|
130 |
/*
|
@@ -136,24 +140,27 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
136 |
* @param int $menu_item_db_id
|
137 |
*/
|
138 |
public function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0 ) {
|
139 |
-
if (empty($_POST['menu-item-url'][$menu_item_db_id]) || $_POST['menu-item-url'][$menu_item_db_id]
|
140 |
return;
|
|
|
141 |
|
142 |
// security check
|
143 |
// as 'wp_update_nav_menu_item' can be called from outside WP admin
|
144 |
-
if (current_user_can('edit_theme_options')) {
|
145 |
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
|
146 |
|
147 |
-
$options = array('hide_if_no_translation' => 0, 'hide_current' => 0,'force_home' => 0 ,'show_flags' => 0 ,'show_names' => 1); // default values
|
148 |
// our jQuery form has not been displayed
|
149 |
-
if (empty($_POST['menu-item-pll-detect'][$menu_item_db_id])) {
|
150 |
-
if (!get_post_meta($menu_item_db_id, '_pll_menu_item', true)) // our options were never saved
|
151 |
-
update_post_meta($menu_item_db_id, '_pll_menu_item', $options);
|
|
|
152 |
}
|
153 |
else {
|
154 |
-
foreach ($options as $opt => $v)
|
155 |
-
$options[$opt] = empty($_POST['menu-item-'
|
156 |
-
|
|
|
157 |
}
|
158 |
}
|
159 |
}
|
@@ -166,60 +173,75 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
166 |
* @param array $items
|
167 |
* @return array modified $items
|
168 |
*/
|
169 |
-
public function translate_switcher_title($items) {
|
170 |
-
foreach ($items as $item)
|
171 |
-
if ('#pll_switcher' == $item->url)
|
172 |
-
$item->post_title = __('Language switcher', 'polylang');
|
|
|
|
|
173 |
return $items;
|
174 |
}
|
175 |
|
176 |
/*
|
177 |
-
* assign menu languages and translations based on (temporary) locations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
*
|
179 |
* @since 1.1
|
180 |
*
|
181 |
* @param array $mods theme mods
|
182 |
* @return unmodified $mods
|
183 |
*/
|
184 |
-
public function
|
185 |
-
if (current_user_can('edit_theme_options') && isset($mods['nav_menu_locations'])) {
|
186 |
|
187 |
// Manage Locations tab in Appearance -> Menus
|
188 |
-
if (isset($
|
189 |
-
check_admin_referer('save-menu-locations');
|
190 |
-
$this->options['nav_menus'][$this->theme] = array();
|
191 |
}
|
192 |
|
193 |
// Edit Menus tab in Appearance -> Menus
|
194 |
-
// add the test of $
|
195 |
-
elseif (isset($
|
196 |
-
check_admin_referer('update-nav_menu', 'update-nav-menu-nonce');
|
197 |
-
$this->options['nav_menus'][$this->theme] = array();
|
198 |
}
|
199 |
|
200 |
// customizer
|
201 |
// don't reset locations in this case.
|
202 |
// see http://wordpress.org/support/topic/menus-doesnt-show-and-not-saved-in-theme-settings-multilingual-site
|
203 |
-
elseif (isset($
|
204 |
check_ajax_referer( 'save-customize_' . $GLOBALS['wp_customize']->get_stylesheet(), 'nonce' );
|
205 |
}
|
206 |
|
207 |
-
else
|
208 |
return $mods; // no modification for nav menu locations
|
209 |
-
|
210 |
-
$default = pll_default_language();
|
211 |
-
|
212 |
-
// extract language and menu from locations
|
213 |
-
foreach ($mods['nav_menu_locations'] as $loc => $menu) {
|
214 |
-
if ($pos = strpos($loc, '___')) {
|
215 |
-
$this->options['nav_menus'][$this->theme][substr($loc, 0, $pos)][substr($loc, $pos+3)] = $menu;
|
216 |
-
unset($mods['nav_menu_locations'][$loc]); // remove temporary locations before database update
|
217 |
-
}
|
218 |
-
else
|
219 |
-
$this->options['nav_menus'][$this->theme][$loc][$default] = $menu;
|
220 |
}
|
221 |
|
222 |
-
|
223 |
}
|
224 |
return $mods;
|
225 |
}
|
@@ -232,12 +254,13 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
232 |
* @param bool|array $menus
|
233 |
* @return bool|array modified list of menu locations
|
234 |
*/
|
235 |
-
public function
|
236 |
-
if (is_array($menus)) {
|
237 |
-
foreach ($menus as $loc => $menu) {
|
238 |
-
foreach ($this->model->get_languages_list() as $lang) {
|
239 |
-
if (
|
240 |
-
$menus[$loc
|
|
|
241 |
}
|
242 |
}
|
243 |
}
|
@@ -252,17 +275,18 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
252 |
*
|
253 |
* @param int nav menu id
|
254 |
*/
|
255 |
-
function delete_nav_menu($term_id) {
|
256 |
-
foreach ($this->options['nav_menus'] as $theme => $locations) {
|
257 |
-
foreach ($locations as $loc => $languages)
|
258 |
-
foreach ($languages as $lang => $menu_id) {
|
259 |
-
if ($menu_id === $term_id)
|
260 |
-
unset($this->options['nav_menus'][$theme][$loc][$lang]);
|
|
|
261 |
}
|
262 |
}
|
263 |
}
|
264 |
|
265 |
-
update_option('polylang', $this->options);
|
266 |
}
|
267 |
|
268 |
/*
|
@@ -275,14 +299,23 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
275 |
* @param object $post Post data.
|
276 |
*/
|
277 |
public function auto_add_pages_to_menu( $new_status, $old_status, $post ) {
|
278 |
-
if ('publish' != $new_status || 'publish' == $old_status || 'page' != $post->post_type || ! empty($post->post_parent) || !($lang = $this->model->
|
279 |
return;
|
|
|
280 |
|
281 |
-
|
282 |
-
|
283 |
-
|
|
|
|
|
|
|
|
|
284 |
|
285 |
-
|
|
|
|
|
|
|
|
|
286 |
}
|
287 |
|
288 |
/*
|
@@ -295,9 +328,9 @@ class PLL_Admin_Nav_Menu extends PLL_Nav_Menu {
|
|
295 |
*
|
296 |
* @param string $name term name
|
297 |
* @param string $taxonomy
|
298 |
-
* @return string modified (nav menu) term name if necessary
|
299 |
*/
|
300 |
-
function pre_insert_term($name, $taxonomy) {
|
301 |
-
return ('nav_menu' == $taxonomy && in_array($name, $this->model->get_languages_list(array('fields' => 'name')))) ? $name .= '-menu' : $name;
|
302 |
}
|
303 |
}
|
14 |
*
|
15 |
* @param object $polylang
|
16 |
*/
|
17 |
+
public function __construct( &$polylang ) {
|
18 |
+
parent::__construct( $polylang );
|
19 |
|
20 |
$this->theme = get_option( 'stylesheet' );
|
21 |
|
22 |
// populates nav menus locations
|
23 |
// since WP 4.4, must be done before customize_register is fired
|
24 |
+
add_filter( 'theme_mod_nav_menu_locations', array( $this, 'theme_mod_nav_menu_locations' ), 20 );
|
25 |
|
26 |
// integration in the WP menu interface
|
27 |
+
add_action( 'admin_init', array( &$this, 'admin_init' ) ); // after Polylang upgrade
|
28 |
|
29 |
// protection against #24802
|
30 |
// backward compatibility with WP < 4.1
|
31 |
+
if ( version_compare( $GLOBALS['wp_version'], '4.1', '<' ) ) {
|
32 |
+
add_filter( 'pre_insert_term', array( &$this, 'pre_insert_term' ), 10, 2 );
|
33 |
+
}
|
34 |
}
|
35 |
|
36 |
/*
|
39 |
*
|
40 |
* @since 1.1
|
41 |
*/
|
42 |
+
public function admin_init() {
|
43 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
|
44 |
+
add_action( 'wp_update_nav_menu_item', array( &$this, 'wp_update_nav_menu_item' ), 10, 2 );
|
45 |
+
add_filter( 'wp_get_nav_menu_items', array( &$this, 'translate_switcher_title' ) );
|
46 |
|
47 |
// translation of menus based on chosen locations
|
48 |
+
add_filter( 'pre_update_option_theme_mods_' . $this->theme, array( $this, 'pre_update_option_theme_mods' ) );
|
49 |
+
add_action( 'delete_nav_menu', array( &$this, 'delete_nav_menu' ) );
|
50 |
|
51 |
// filter _wp_auto_add_pages_to_menu by language
|
52 |
+
add_action( 'transition_post_status', array( &$this, 'auto_add_pages_to_menu' ), 5, 3 ); // before _wp_auto_add_pages_to_menu
|
53 |
|
54 |
+
// FIXME is it possible to choose the order ( after theme locations in WP3.5 and older ) ?
|
55 |
// FIXME not displayed if Polylang is activated before the first time the user goes to nav menus http://core.trac.wordpress.org/ticket/16828
|
56 |
+
add_meta_box( 'pll_lang_switch_box', __( 'Language switcher', 'polylang' ), array( &$this, 'lang_switch' ), 'nav-menus', 'side', 'high' );
|
57 |
|
58 |
$this->create_nav_menu_locations();
|
59 |
}
|
67 |
*/
|
68 |
public function lang_switch() {
|
69 |
global $_nav_menu_placeholder, $nav_menu_selected_id;
|
70 |
+
$_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1; ?>
|
71 |
|
72 |
<div id="posttype-lang-switch" class="posttypediv">
|
73 |
<div id="tabs-panel-lang-switch" class="tabs-panel tabs-panel-active">
|
74 |
<ul id ="lang-switch-checklist" class="categorychecklist form-no-clear">
|
75 |
<li>
|
76 |
<label class="menu-item-title">
|
77 |
+
<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-object-id]" value="-1"> <?php _e( 'Language switcher', 'polylang' ); ?>
|
78 |
</label>
|
79 |
<input type="hidden" class="menu-item-type" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" value="custom">
|
80 |
+
<input type="hidden" class="menu-item-title" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" value="<?php _e( 'Language switcher', 'polylang' ); ?>">
|
81 |
<input type="hidden" class="menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" value="#pll_switcher">
|
82 |
+
</li>
|
83 |
+
</ul>
|
84 |
+
</div>
|
85 |
+
<p class="button-controls">
|
86 |
+
<span class="add-to-menu">
|
87 |
+
<input type="submit" <?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-post-type-menu-item" id="submit-posttype-lang-switch">
|
88 |
+
<span class="spinner"></span>
|
89 |
+
</span>
|
90 |
+
</p>
|
91 |
+
</div><?php
|
92 |
}
|
93 |
|
94 |
/*
|
98 |
*/
|
99 |
public function admin_enqueue_scripts() {
|
100 |
$screen = get_current_screen();
|
101 |
+
if ( 'nav-menus' != $screen->base ) {
|
102 |
return;
|
103 |
+
}
|
104 |
|
105 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
106 |
+
wp_enqueue_script( 'pll_nav_menu', POLYLANG_URL .'/js/nav-menu' . $suffix . '.js', array( 'jquery' ), POLYLANG_VERSION );
|
107 |
|
108 |
// the strings for the options
|
109 |
+
foreach ( array_reverse( PLL_Switcher::get_switcher_options( 'menu', 'string' ) ) as $str ) {
|
110 |
$data['strings'][] = $str;
|
111 |
+
}
|
112 |
|
113 |
+
$data['title'] = __( 'Language switcher', 'polylang' ); // the title
|
114 |
|
115 |
// get all language switcher menu items
|
116 |
+
$items = get_posts( array(
|
117 |
'numberposts' => -1,
|
118 |
'nopaging' => true,
|
119 |
'post_type' => 'nav_menu_item',
|
120 |
'fields' => 'ids',
|
121 |
+
'meta_key' => '_pll_menu_item',
|
122 |
+
) );
|
123 |
|
124 |
// the options values for the language switcher
|
125 |
$data['val'] = array();
|
126 |
+
foreach ( $items as $item ) {
|
127 |
+
$data['val'][ $item ] = get_post_meta( $item, '_pll_menu_item', true );
|
128 |
+
}
|
129 |
|
130 |
// send all these data to javascript
|
131 |
+
wp_localize_script( 'pll_nav_menu', 'pll_data', $data );
|
132 |
}
|
133 |
|
134 |
/*
|
140 |
* @param int $menu_item_db_id
|
141 |
*/
|
142 |
public function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0 ) {
|
143 |
+
if ( empty( $_POST['menu-item-url'][ $menu_item_db_id ] ) || '#pll_switcher' != $_POST['menu-item-url'][ $menu_item_db_id ] ) {
|
144 |
return;
|
145 |
+
}
|
146 |
|
147 |
// security check
|
148 |
// as 'wp_update_nav_menu_item' can be called from outside WP admin
|
149 |
+
if ( current_user_can( 'edit_theme_options' ) ) {
|
150 |
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
|
151 |
|
152 |
+
$options = array( 'hide_if_no_translation' => 0, 'hide_current' => 0,'force_home' => 0 ,'show_flags' => 0 ,'show_names' => 1 ); // default values
|
153 |
// our jQuery form has not been displayed
|
154 |
+
if ( empty( $_POST['menu-item-pll-detect'][ $menu_item_db_id ] ) ) {
|
155 |
+
if ( ! get_post_meta( $menu_item_db_id, '_pll_menu_item', true ) ) { // our options were never saved
|
156 |
+
update_post_meta( $menu_item_db_id, '_pll_menu_item', $options );
|
157 |
+
}
|
158 |
}
|
159 |
else {
|
160 |
+
foreach ( $options as $opt => $v ) {
|
161 |
+
$options[ $opt ] = empty( $_POST[ 'menu-item-' . $opt ][ $menu_item_db_id ] ) ? 0 : 1;
|
162 |
+
}
|
163 |
+
update_post_meta( $menu_item_db_id, '_pll_menu_item', $options ); // allow us to easily identify our nav menu item
|
164 |
}
|
165 |
}
|
166 |
}
|
173 |
* @param array $items
|
174 |
* @return array modified $items
|
175 |
*/
|
176 |
+
public function translate_switcher_title( $items ) {
|
177 |
+
foreach ( $items as $item ) {
|
178 |
+
if ( '#pll_switcher' == $item->url ) {
|
179 |
+
$item->post_title = __( 'Language switcher', 'polylang' );
|
180 |
+
}
|
181 |
+
}
|
182 |
return $items;
|
183 |
}
|
184 |
|
185 |
/*
|
186 |
+
* assign menu languages and translations based on ( temporary ) locations
|
187 |
+
*
|
188 |
+
* @since 1.8
|
189 |
+
*
|
190 |
+
* @param array $locations nav menu locations
|
191 |
+
* @return array
|
192 |
+
*/
|
193 |
+
public function update_nav_menu_locations( $locations ) {
|
194 |
+
$default = $this->options['default_lang'];
|
195 |
+
|
196 |
+
// extract language and menu from locations
|
197 |
+
foreach ( $locations as $loc => $menu ) {
|
198 |
+
$infos = $this->explode_location( $loc );
|
199 |
+
$this->options['nav_menus'][ $this->theme ][ $infos['location'] ][ $infos['lang'] ] = $menu;
|
200 |
+
if ( $this->options['default_lang'] != $infos['lang'] ) {
|
201 |
+
unset( $locations[ $loc ] ); // remove temporary locations before database update
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
update_option( 'polylang', $this->options );
|
206 |
+
return $locations;
|
207 |
+
}
|
208 |
+
|
209 |
+
/*
|
210 |
+
* assign menu languages and translations based on ( temporary ) locations
|
211 |
*
|
212 |
* @since 1.1
|
213 |
*
|
214 |
* @param array $mods theme mods
|
215 |
* @return unmodified $mods
|
216 |
*/
|
217 |
+
public function pre_update_option_theme_mods( $mods ) {
|
218 |
+
if ( current_user_can( 'edit_theme_options' ) && isset( $mods['nav_menu_locations'] ) ) {
|
219 |
|
220 |
// Manage Locations tab in Appearance -> Menus
|
221 |
+
if ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) {
|
222 |
+
check_admin_referer( 'save-menu-locations' );
|
223 |
+
$this->options['nav_menus'][ $this->theme ] = array();
|
224 |
}
|
225 |
|
226 |
// Edit Menus tab in Appearance -> Menus
|
227 |
+
// add the test of $_POST['update-nav-menu-nonce'] to avoid conflict with Vantage theme
|
228 |
+
elseif ( isset( $_POST['action'], $_POST['update-nav-menu-nonce'] ) && 'update' == $_POST['action'] ) {
|
229 |
+
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
|
230 |
+
$this->options['nav_menus'][ $this->theme ] = array();
|
231 |
}
|
232 |
|
233 |
// customizer
|
234 |
// don't reset locations in this case.
|
235 |
// see http://wordpress.org/support/topic/menus-doesnt-show-and-not-saved-in-theme-settings-multilingual-site
|
236 |
+
elseif ( isset( $_POST['action'] ) && 'customize_save' == $_POST['action'] ) {
|
237 |
check_ajax_referer( 'save-customize_' . $GLOBALS['wp_customize']->get_stylesheet(), 'nonce' );
|
238 |
}
|
239 |
|
240 |
+
else {
|
241 |
return $mods; // no modification for nav menu locations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
|
244 |
+
$mods['nav_menu_locations'] = $this->update_nav_menu_locations( $mods['nav_menu_locations'] );
|
245 |
}
|
246 |
return $mods;
|
247 |
}
|
254 |
* @param bool|array $menus
|
255 |
* @return bool|array modified list of menu locations
|
256 |
*/
|
257 |
+
public function theme_mod_nav_menu_locations( $menus ) {
|
258 |
+
if ( is_array( $menus ) ) {
|
259 |
+
foreach ( $menus as $loc => $menu ) {
|
260 |
+
foreach ( $this->model->get_languages_list() as $lang ) {
|
261 |
+
if ( ! empty( $this->options['nav_menus'][ $this->theme ][ $loc ][ $lang->slug ] ) && term_exists( $this->options['nav_menus'][ $this->theme ][ $loc ][ $lang->slug ], 'nav_menu' ) ) {
|
262 |
+
$menus[ $this->combine_location( $loc, $lang ) ] = $this->options['nav_menus'][ $this->theme ][ $loc ][ $lang->slug ];
|
263 |
+
}
|
264 |
}
|
265 |
}
|
266 |
}
|
275 |
*
|
276 |
* @param int nav menu id
|
277 |
*/
|
278 |
+
function delete_nav_menu( $term_id ) {
|
279 |
+
foreach ( $this->options['nav_menus'] as $theme => $locations ) {
|
280 |
+
foreach ( $locations as $loc => $languages ) {
|
281 |
+
foreach ( $languages as $lang => $menu_id ) {
|
282 |
+
if ( $menu_id === $term_id ) {
|
283 |
+
unset( $this->options['nav_menus'][ $theme ][ $loc ][ $lang ] );
|
284 |
+
}
|
285 |
}
|
286 |
}
|
287 |
}
|
288 |
|
289 |
+
update_option( 'polylang', $this->options );
|
290 |
}
|
291 |
|
292 |
/*
|
299 |
* @param object $post Post data.
|
300 |
*/
|
301 |
public function auto_add_pages_to_menu( $new_status, $old_status, $post ) {
|
302 |
+
if ( 'publish' != $new_status || 'publish' == $old_status || 'page' != $post->post_type || ! empty( $post->post_parent ) || ! ( $lang = $this->model->post->get_language( $post->ID ) ) ) {
|
303 |
return;
|
304 |
+
}
|
305 |
|
306 |
+
if ( ! empty( $this->options['nav_menus'][ $this->theme ] ) ) {
|
307 |
+
// get all the menus in the page language
|
308 |
+
foreach ( $this->options['nav_menus'][ $this->theme ] as $loc ) {
|
309 |
+
if ( ! empty( $loc[ $lang->slug ] ) ) {
|
310 |
+
$menus[] = $loc[ $lang->slug ];
|
311 |
+
}
|
312 |
+
}
|
313 |
|
314 |
+
if ( ! empty( $menus ) ) {
|
315 |
+
$menus = implode( ',', $menus );
|
316 |
+
add_filter( 'option_nav_menu_options', create_function( '$a', "\$a['auto_add'] = array_intersect( \$a['auto_add'], array( $menus ) ); return \$a;" ) );
|
317 |
+
}
|
318 |
+
}
|
319 |
}
|
320 |
|
321 |
/*
|
328 |
*
|
329 |
* @param string $name term name
|
330 |
* @param string $taxonomy
|
331 |
+
* @return string modified ( nav menu ) term name if necessary
|
332 |
*/
|
333 |
+
function pre_insert_term( $name, $taxonomy ) {
|
334 |
+
return ( 'nav_menu' == $taxonomy && in_array( $name, $this->model->get_languages_list( array( 'fields' => 'name' ) ) ) ) ? $name .= '-menu' : $name;
|
335 |
}
|
336 |
}
|
admin/admin-static-pages.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
14 |
+
*
|
15 |
+
* @param object $polylang
|
16 |
+
*/
|
17 |
+
public function __construct( &$polylang ) {
|
18 |
+
parent::__construct( $polylang );
|
19 |
+
|
20 |
+
// add post state for translations of the front page and posts page
|
21 |
+
add_filter( 'display_post_states', array( &$this, 'display_post_states' ), 10, 2 );
|
22 |
+
|
23 |
+
// refresh language cache when a static front page has been translated
|
24 |
+
add_action( 'pll_save_post', array( &$this, 'pll_save_post' ), 10, 3 );
|
25 |
+
|
26 |
+
// checks if chosen page on front is translated
|
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
|
34 |
+
*
|
35 |
+
* @param array $post_states
|
36 |
+
* @param object $post
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
public function display_post_states( $post_states, $post ) {
|
40 |
+
if ( in_array( $post->ID, $this->model->get_languages_list( array( 'fields' => 'page_on_front' ) ) ) ) {
|
41 |
+
$post_states['page_on_front'] = __( 'Front Page' );
|
42 |
+
}
|
43 |
+
|
44 |
+
if ( in_array( $post->ID, $this->model->get_languages_list( array( 'fields' => 'page_for_posts' ) ) ) ) {
|
45 |
+
$post_states['page_for_posts'] = __( 'Posts Page' );
|
46 |
+
}
|
47 |
+
|
48 |
+
return $post_states;
|
49 |
+
}
|
50 |
+
|
51 |
+
/*
|
52 |
+
* refresh language cache when a static front page has been translated
|
53 |
+
*
|
54 |
+
* @since 1.8
|
55 |
+
*
|
56 |
+
* @param int $post_id not used
|
57 |
+
* @param object $post not used
|
58 |
+
* @param array $translations
|
59 |
+
*/
|
60 |
+
public function pll_save_post( $post_id, $post, $translations ) {
|
61 |
+
if ( in_array( $this->page_on_front, $translations ) ) {
|
62 |
+
$this->model->clean_languages_cache();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/*
|
67 |
+
* prevents choosing an untranslated static front page
|
68 |
+
* displays an error message
|
69 |
+
*
|
70 |
+
* @since 1.6
|
71 |
+
*
|
72 |
+
* @param int $page_id new page on front page id
|
73 |
+
* @param int $old_id old page on front page_id
|
74 |
+
* @return int
|
75 |
+
*/
|
76 |
+
public function update_page_on_front( $page_id, $old_id ) {
|
77 |
+
if ( $page_id ) {
|
78 |
+
$translations = count( $this->model->post->get_translations( $page_id ) );
|
79 |
+
$languages = count( $this->model->get_languages_list() );
|
80 |
+
|
81 |
+
if ( $languages > 1 && $translations != $languages ) {
|
82 |
+
$page_id = $old_id;
|
83 |
+
add_settings_error( 'reading', 'pll_page_on_front_error', __( 'The chosen static front page must be translated in all languages.', 'polylang' ) );
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
return $page_id;
|
88 |
+
}
|
89 |
+
}
|
admin/admin-strings.php
CHANGED
@@ -16,7 +16,7 @@ class PLL_Admin_Strings {
|
|
16 |
*/
|
17 |
static public function init() {
|
18 |
// default strings translations sanitization
|
19 |
-
add_filter('pll_sanitize_string_translation', array(__CLASS__, 'sanitize_string_translation'), 10, 2);
|
20 |
}
|
21 |
|
22 |
/*
|
@@ -29,16 +29,17 @@ class PLL_Admin_Strings {
|
|
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 |
*/
|
32 |
-
static public function register_string($name, $string, $context = '
|
33 |
// backward compatibility with Polylang older than 1.1
|
34 |
-
if (is_bool($context)) {
|
35 |
$multiline = $context;
|
36 |
-
$context = '
|
37 |
}
|
38 |
|
39 |
-
$to_register = compact('name', 'string', 'context', 'multiline');
|
40 |
-
if (!in_array($to_register, self::$strings) && $to_register['string'])
|
41 |
self::$strings[] = $to_register;
|
|
|
42 |
}
|
43 |
|
44 |
/*
|
@@ -51,53 +52,58 @@ class PLL_Admin_Strings {
|
|
51 |
static public function &get_strings() {
|
52 |
self::$default_strings = array(
|
53 |
'options' => array(
|
54 |
-
'blogname' => __('Site Title'),
|
55 |
-
'blogdescription' => __('Tagline'),
|
56 |
-
'date_format' => __('Date Format'),
|
57 |
-
'time_format' => __('Time Format'),
|
58 |
),
|
59 |
-
'widget_title' => __('Widget title', 'polylang'),
|
60 |
-
'widget_text' => __('Widget text', 'polylang'),
|
61 |
);
|
62 |
|
63 |
// WP strings
|
64 |
-
foreach (self::$default_strings['options'] as $option => $string)
|
65 |
-
self::register_string($string, get_option($option), 'WordPress');
|
|
|
66 |
|
67 |
// widgets titles
|
68 |
global $wp_registered_widgets;
|
69 |
$sidebars = wp_get_sidebars_widgets();
|
70 |
-
foreach ($sidebars as $sidebar => $widgets) {
|
71 |
-
if (
|
72 |
continue;
|
|
|
73 |
|
74 |
-
foreach ($widgets as $widget) {
|
75 |
// nothing can be done if the widget is created using pre WP2.8 API :(
|
76 |
// there is no object, so we can't access it to get the widget options
|
77 |
-
if (!isset($wp_registered_widgets[$widget]['callback'][0]) || !is_object($wp_registered_widgets[$widget]['callback'][0]) || !method_exists($wp_registered_widgets[$widget]['callback'][0], 'get_settings'))
|
78 |
continue;
|
|
|
79 |
|
80 |
-
$widget_settings = $wp_registered_widgets[$widget]['callback'][0]->get_settings();
|
81 |
-
$number = $wp_registered_widgets[$widget]['params'][0]['number'];
|
82 |
|
83 |
// don't enable widget translation if the widget is visible in only one language or if there is no title
|
84 |
-
if (empty($widget_settings[$number]['pll_lang'])) {
|
85 |
-
if (isset($widget_settings[$number]['title']) && $title = $widget_settings[$number]['title'])
|
86 |
-
self::register_string(self::$default_strings['widget_title'], $title, 'Widget');
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
90 |
}
|
91 |
}
|
92 |
}
|
93 |
|
94 |
// allow plugins to modify our list of strings, mainly for use by our PLL_WPML_Compat class
|
95 |
-
self::$strings = apply_filters('pll_get_strings', self::$strings);
|
96 |
return self::$strings;
|
97 |
}
|
98 |
|
99 |
/*
|
100 |
-
* performs the sanitization (before saving in DB) of default strings translations
|
101 |
*
|
102 |
* @since 1.6
|
103 |
*
|
@@ -105,17 +111,20 @@ class PLL_Admin_Strings {
|
|
105 |
* @param string $name unique name for the string
|
106 |
* @return string
|
107 |
*/
|
108 |
-
static public function sanitize_string_translation($translation, $name) {
|
109 |
-
$translation = wp_unslash(trim($translation));
|
110 |
|
111 |
-
if (false !== ($option = array_search($name, self::$default_strings['options'], true)))
|
112 |
-
$translation = sanitize_option($option, $translation);
|
|
|
113 |
|
114 |
-
if ($name == self::$default_strings['widget_title'])
|
115 |
-
$translation = strip_tags($translation);
|
|
|
116 |
|
117 |
-
if ($name == self::$default_strings['widget_text'] && !current_user_can('unfiltered_html'))
|
118 |
-
$translation = wp_unslash( wp_filter_post_kses( addslashes($translation) ) ); // wp_filter_post_kses() expects slashed
|
|
|
119 |
|
120 |
return $translation;
|
121 |
}
|
16 |
*/
|
17 |
static public function init() {
|
18 |
// default strings translations sanitization
|
19 |
+
add_filter( 'pll_sanitize_string_translation', array( __CLASS__, 'sanitize_string_translation' ), 10, 2 );
|
20 |
}
|
21 |
|
22 |
/*
|
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 |
*/
|
32 |
+
static public function register_string( $name, $string, $context = 'Polylang', $multiline = false ) {
|
33 |
// backward compatibility with Polylang older than 1.1
|
34 |
+
if ( is_bool( $context ) ) {
|
35 |
$multiline = $context;
|
36 |
+
$context = 'Polylang';
|
37 |
}
|
38 |
|
39 |
+
$to_register = compact( 'name', 'string', 'context', 'multiline' );
|
40 |
+
if ( ! in_array( $to_register, self::$strings ) && $to_register['string'] ) {
|
41 |
self::$strings[] = $to_register;
|
42 |
+
}
|
43 |
}
|
44 |
|
45 |
/*
|
52 |
static public function &get_strings() {
|
53 |
self::$default_strings = array(
|
54 |
'options' => array(
|
55 |
+
'blogname' => __( 'Site Title' ),
|
56 |
+
'blogdescription' => __( 'Tagline' ),
|
57 |
+
'date_format' => __( 'Date Format' ),
|
58 |
+
'time_format' => __( 'Time Format' ),
|
59 |
),
|
60 |
+
'widget_title' => __( 'Widget title', 'polylang' ),
|
61 |
+
'widget_text' => __( 'Widget text', 'polylang' ),
|
62 |
);
|
63 |
|
64 |
// WP strings
|
65 |
+
foreach ( self::$default_strings['options'] as $option => $string ) {
|
66 |
+
self::register_string( $string, get_option( $option ), 'WordPress' );
|
67 |
+
}
|
68 |
|
69 |
// widgets titles
|
70 |
global $wp_registered_widgets;
|
71 |
$sidebars = wp_get_sidebars_widgets();
|
72 |
+
foreach ( $sidebars as $sidebar => $widgets ) {
|
73 |
+
if ( 'wp_inactive_widgets' == $sidebar || empty( $widgets ) ) {
|
74 |
continue;
|
75 |
+
}
|
76 |
|
77 |
+
foreach ( $widgets as $widget ) {
|
78 |
// nothing can be done if the widget is created using pre WP2.8 API :(
|
79 |
// there is no object, so we can't access it to get the widget options
|
80 |
+
if ( ! isset( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! is_object( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! method_exists( $wp_registered_widgets[ $widget ]['callback'][0], 'get_settings' ) ) {
|
81 |
continue;
|
82 |
+
}
|
83 |
|
84 |
+
$widget_settings = $wp_registered_widgets[ $widget ]['callback'][0]->get_settings();
|
85 |
+
$number = $wp_registered_widgets[ $widget ]['params'][0]['number'];
|
86 |
|
87 |
// don't enable widget translation if the widget is visible in only one language or if there is no title
|
88 |
+
if ( empty( $widget_settings[ $number ]['pll_lang'] ) ) {
|
89 |
+
if ( isset( $widget_settings[ $number ]['title'] ) && $title = $widget_settings[ $number ]['title'] ) {
|
90 |
+
self::register_string( self::$default_strings['widget_title'], $title, 'Widget' );
|
91 |
+
}
|
92 |
+
|
93 |
+
if ( isset( $widget_settings[ $number ]['text'] ) && $text = $widget_settings[ $number ]['text'] ) {
|
94 |
+
self::register_string( self::$default_strings['widget_text'], $text, 'Widget', true );
|
95 |
+
}
|
96 |
}
|
97 |
}
|
98 |
}
|
99 |
|
100 |
// allow plugins to modify our list of strings, mainly for use by our PLL_WPML_Compat class
|
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 |
*
|
111 |
* @param string $name unique name for the string
|
112 |
* @return string
|
113 |
*/
|
114 |
+
static public function sanitize_string_translation( $translation, $name ) {
|
115 |
+
$translation = wp_unslash( trim( $translation ) );
|
116 |
|
117 |
+
if ( false !== ( $option = array_search( $name, self::$default_strings['options'], true ) ) ) {
|
118 |
+
$translation = sanitize_option( $option, $translation );
|
119 |
+
}
|
120 |
|
121 |
+
if ( $name == self::$default_strings['widget_title'] ) {
|
122 |
+
$translation = strip_tags( $translation );
|
123 |
+
}
|
124 |
|
125 |
+
if ( $name == self::$default_strings['widget_text'] && !current_user_can( 'unfiltered_html' ) ) {
|
126 |
+
$translation = wp_unslash( wp_filter_post_kses( addslashes( $translation ) ) ); // wp_filter_post_kses() expects slashed
|
127 |
+
}
|
128 |
|
129 |
return $translation;
|
130 |
}
|
admin/admin-sync.php
DELETED
@@ -1,270 +0,0 @@
|
|
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
|
14 |
-
*
|
15 |
-
* @param object $polylang
|
16 |
-
*/
|
17 |
-
public function __construct(&$polylang) {
|
18 |
-
$this->model = &$polylang->model;
|
19 |
-
$this->options = &$polylang->options;
|
20 |
-
|
21 |
-
add_filter('wp_insert_post_parent', array(&$this, 'wp_insert_post_parent'));
|
22 |
-
add_action('add_meta_boxes', array(&$this, 'add_meta_boxes'), 5, 2); // before Types which populates custom fields in same hook with priority 10
|
23 |
-
|
24 |
-
add_action('pll_save_post', array(&$this, 'pll_save_post'), 10, 3);
|
25 |
-
add_action('pll_save_term', array(&$this, 'pll_save_term'), 10, 3);
|
26 |
-
}
|
27 |
-
|
28 |
-
/*
|
29 |
-
* translate post parent if exists when using "Add new" (translation)
|
30 |
-
*
|
31 |
-
* @since 0.6
|
32 |
-
*/
|
33 |
-
function wp_insert_post_parent($post_parent) {
|
34 |
-
return isset($_GET['from_post'], $_GET['new_lang']) && ($id = wp_get_post_parent_id((int) $_GET['from_post'])) && ($parent = $this->model->get_translation('post', $id, $_GET['new_lang'])) ? $parent : $post_parent;
|
35 |
-
}
|
36 |
-
|
37 |
-
/*
|
38 |
-
* copy post metas, menu order, comment and ping status when using "Add new" (translation)
|
39 |
-
* formerly used dbx_post_advanced deprecated in WP 3.7
|
40 |
-
*
|
41 |
-
* @since 1.2
|
42 |
-
*
|
43 |
-
* @param string $post_type unused
|
44 |
-
* @param object $post current post object
|
45 |
-
*/
|
46 |
-
function add_meta_boxes($post_type, $post) {
|
47 |
-
if ('post-new.php' == $GLOBALS['pagenow'] && isset($_GET['from_post'], $_GET['new_lang'])) {
|
48 |
-
if (!$this->model->is_translated_post_type($post->post_type))
|
49 |
-
return;
|
50 |
-
|
51 |
-
// capability check already done in post-new.php
|
52 |
-
$from_post_id = (int) $_GET['from_post'];
|
53 |
-
$lang = $this->model->get_language($_GET['new_lang']);
|
54 |
-
|
55 |
-
$this->copy_post_metas($from_post_id, $post->ID, $lang->slug);
|
56 |
-
|
57 |
-
$from_post = get_post($from_post_id);
|
58 |
-
foreach (array('menu_order', 'comment_status', 'ping_status') as $property)
|
59 |
-
$post->$property = $from_post->$property;
|
60 |
-
|
61 |
-
if (in_array('sticky_posts', $this->options['sync']) && is_sticky($from_post_id))
|
62 |
-
stick_post($post->ID);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
/*
|
67 |
-
* get the list of taxonomies to copy or to synchronize
|
68 |
-
*
|
69 |
-
* @since 1.7
|
70 |
-
*
|
71 |
-
* @param bool $sync true if it is synchronization, false if it is a copy
|
72 |
-
* @return array list of taxonomy names
|
73 |
-
*/
|
74 |
-
public function get_taxonomies_to_copy($sync) {
|
75 |
-
$taxonomies = !$sync || in_array('taxonomies', $this->options['sync']) ? $this->model->get_translated_taxonomies() : array();
|
76 |
-
if (!$sync || in_array('post_format', $this->options['sync']))
|
77 |
-
$taxonomies[] = 'post_format';
|
78 |
-
|
79 |
-
return array_unique(apply_filters('pll_copy_taxonomies', $taxonomies, $sync));
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
/*
|
84 |
-
* copy or synchronize terms and metas
|
85 |
-
*
|
86 |
-
* @since 0.9
|
87 |
-
*
|
88 |
-
* @param int $from id of the post from which we copy informations
|
89 |
-
* @param int $to id of the post to which we paste informations
|
90 |
-
* @param string $lang language slug
|
91 |
-
* @param bool $sync true if it is synchronization, false if it is a copy, defaults to false
|
92 |
-
*/
|
93 |
-
public function copy_post_metas($from, $to, $lang, $sync = false) {
|
94 |
-
// copy or synchronize terms
|
95 |
-
// FIXME quite a lot of query in foreach
|
96 |
-
foreach ($this->get_taxonomies_to_copy($sync) as $tax) {
|
97 |
-
$terms = get_the_terms($from, $tax);
|
98 |
-
|
99 |
-
// translated taxonomy
|
100 |
-
if ($this->model->is_translated_taxonomy($tax)) {
|
101 |
-
$newterms = array();
|
102 |
-
if (is_array($terms)) {
|
103 |
-
foreach ($terms as $term) {
|
104 |
-
if ($term_id = $this->model->get_translation('term', $term->term_id, $lang))
|
105 |
-
$newterms[] = (int) $term_id; // cast is important otherwise we get 'numeric' tags
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
// for some reasons, the user may have untranslated terms in the translation. don't forget them.
|
110 |
-
if ($sync) {
|
111 |
-
$tr_terms = get_the_terms($to, $tax);
|
112 |
-
if (is_array($tr_terms)) {
|
113 |
-
foreach ($tr_terms as $term) {
|
114 |
-
if (!$this->model->get_translation('term', $term->term_id, $this->model->get_post_language($from)))
|
115 |
-
$newterms[] = (int) $term->term_id;
|
116 |
-
}
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
if (!empty($newterms) || $sync)
|
121 |
-
wp_set_object_terms($to, $newterms, $tax); // replace terms in translation
|
122 |
-
}
|
123 |
-
|
124 |
-
// untranslated taxonomy (post format)
|
125 |
-
// don't use simple get_post_format / set_post_format to generalize the case to other taxonomies
|
126 |
-
else {
|
127 |
-
wp_set_object_terms($to, is_array($terms) ? array_map('intval', wp_list_pluck($terms, 'term_id')) : null, $tax);
|
128 |
-
}
|
129 |
-
}
|
130 |
-
|
131 |
-
// copy or synchronize post metas and allow plugins to do the same
|
132 |
-
$metas = get_post_custom($from);
|
133 |
-
|
134 |
-
// get public meta keys (including from translated post in case we just deleted a custom field)
|
135 |
-
if (!$sync || in_array('post_meta', $this->options['sync'])) {
|
136 |
-
foreach ($keys = array_unique(array_merge(array_keys($metas), array_keys(get_post_custom($to)))) as $k => $meta_key)
|
137 |
-
if (is_protected_meta($meta_key))
|
138 |
-
unset ($keys[$k]);
|
139 |
-
}
|
140 |
-
|
141 |
-
// add page template and featured image
|
142 |
-
foreach (array('_wp_page_template', '_thumbnail_id') as $meta)
|
143 |
-
if (!$sync || in_array($meta, $this->options['sync']))
|
144 |
-
$keys[] = $meta;
|
145 |
-
|
146 |
-
$keys = array_unique(apply_filters('pll_copy_post_metas', empty($keys) ? array() : $keys, $sync));
|
147 |
-
|
148 |
-
// and now copy / synchronize
|
149 |
-
foreach ($keys as $key) {
|
150 |
-
delete_post_meta($to, $key); // the synchronization process of multiple values custom fields is easier if we delete all metas first
|
151 |
-
if (isset($metas[$key])) {
|
152 |
-
foreach ($metas[$key] as $value) {
|
153 |
-
// important: always maybe_unserialize value coming from get_post_custom. See codex.
|
154 |
-
// thanks to goncalveshugo http://wordpress.org/support/topic/plugin-polylang-pll_copy_post_meta
|
155 |
-
$value = maybe_unserialize($value);
|
156 |
-
// special case for featured images which can be translated
|
157 |
-
add_post_meta($to, $key, ($key == '_thumbnail_id' && $tr_value = $this->model->get_translation('post', $value, $lang)) ? $tr_value : $value);
|
158 |
-
}
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
/*
|
164 |
-
* synchronizes terms and metas in translations
|
165 |
-
*
|
166 |
-
* @since 1.2
|
167 |
-
*
|
168 |
-
* @param int $post_id post id
|
169 |
-
* @param object $post post object
|
170 |
-
* @param array translations post translations
|
171 |
-
*/
|
172 |
-
public function pll_save_post($post_id, $post, $translations) {
|
173 |
-
global $wpdb;
|
174 |
-
|
175 |
-
// prepare properties to synchronize
|
176 |
-
foreach (array('comment_status', 'ping_status', 'menu_order', 'post_date') as $property)
|
177 |
-
if (in_array($property, $this->options['sync']))
|
178 |
-
$postarr[$property] = $post->$property;
|
179 |
-
|
180 |
-
if (in_array('post_date', $this->options['sync']))
|
181 |
-
$post_arr['post_date_gmt'] = $post->post_date_gmt;
|
182 |
-
|
183 |
-
// synchronise terms and metas in translations
|
184 |
-
foreach ($translations as $lang => $tr_id) {
|
185 |
-
if (!$tr_id)
|
186 |
-
continue;
|
187 |
-
|
188 |
-
// synchronize terms and metas
|
189 |
-
$this->copy_post_metas($post_id, $tr_id, $lang, true);
|
190 |
-
|
191 |
-
// sticky posts
|
192 |
-
if (in_array('sticky_posts', $this->options['sync']))
|
193 |
-
isset($_REQUEST['sticky']) ? stick_post($tr_id) : unstick_post($tr_id);
|
194 |
-
|
195 |
-
// synchronize comment status, ping status, menu order...
|
196 |
-
if (!empty($postarr))
|
197 |
-
$wpdb->update($wpdb->posts, $postarr, array('ID' => $tr_id));
|
198 |
-
|
199 |
-
// FIXME: optimize the 2 db update in 1
|
200 |
-
// post parent
|
201 |
-
// do not udpate the translation parent if the user set a parent with no translation
|
202 |
-
if (in_array('post_parent', $this->options['sync'])) {
|
203 |
-
$post_parent = ($parent_id = wp_get_post_parent_id($post_id)) ? $this->model->get_translation('post', $parent_id, $lang) : 0;
|
204 |
-
if (!($parent_id && !$post_parent))
|
205 |
-
$wpdb->update($wpdb->posts, array('post_parent'=> $post_parent), array( 'ID' => $tr_id ));
|
206 |
-
}
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
/*
|
211 |
-
* synchronize translations of a term in all posts
|
212 |
-
*
|
213 |
-
* @since 1.2
|
214 |
-
*
|
215 |
-
* @param int $term_id term id
|
216 |
-
* @param string $taxonomy taxonomy name of the term
|
217 |
-
* @param array $translations translations of the term
|
218 |
-
*/
|
219 |
-
public function pll_save_term($term_id, $taxonomy, $translations) {
|
220 |
-
// check if the taxonomy is synchronized
|
221 |
-
if (!$this->model->is_translated_taxonomy($taxonomy) || !in_array($taxonomy, $this->get_taxonomies_to_copy(true)))
|
222 |
-
return;
|
223 |
-
|
224 |
-
// get all posts associated to this term
|
225 |
-
$posts = get_posts(array(
|
226 |
-
'numberposts' => -1,
|
227 |
-
'nopaging' => true,
|
228 |
-
'post_type' => 'any',
|
229 |
-
'post_status' => 'any',
|
230 |
-
'fields' => 'ids',
|
231 |
-
'tax_query' => array(array(
|
232 |
-
'taxonomy' => $taxonomy,
|
233 |
-
'field' => 'id',
|
234 |
-
'terms' => array_merge(array($term_id), array_values($translations)),
|
235 |
-
))
|
236 |
-
));
|
237 |
-
|
238 |
-
// associate translated term to translated post
|
239 |
-
// FIXME quite a lot of query in foreach
|
240 |
-
foreach ($this->model->get_languages_list() as $language) {
|
241 |
-
if ($translated_term = $this->model->get_term($term_id, $language)) {
|
242 |
-
foreach ($posts as $post_id) {
|
243 |
-
if ($translated_post = $this->model->get_post($post_id, $language))
|
244 |
-
wp_set_object_terms($translated_post, $translated_term, $taxonomy, true);
|
245 |
-
}
|
246 |
-
}
|
247 |
-
}
|
248 |
-
|
249 |
-
// synchronize parent in translations
|
250 |
-
// calling clean_term_cache *after* this is mandatory otherwise the $taxonomy_children option is not correctly updated
|
251 |
-
// but clean_term_cache can be called (efficiently) only one time due to static array which prevents to update the option more than once
|
252 |
-
// this is the reason to use the edit_term filter and not edited_term
|
253 |
-
// take care that $_POST contains the only valid values for the current term
|
254 |
-
// FIXME can I synchronize parent without using $_POST instead?
|
255 |
-
if (isset($_POST['term_tr_lang'])) {
|
256 |
-
foreach ($_POST['term_tr_lang'] as $lang => $tr_id) {
|
257 |
-
if (!$tr_id)
|
258 |
-
continue;
|
259 |
-
|
260 |
-
if (isset($_POST['parent']) && $_POST['parent'] != -1) // since WP 3.1
|
261 |
-
$term_parent = $this->model->get_translation('term', (int) $_POST['parent'], $lang);
|
262 |
-
|
263 |
-
global $wpdb;
|
264 |
-
$wpdb->update($wpdb->term_taxonomy,
|
265 |
-
array('parent'=> isset($term_parent) ? $term_parent : 0),
|
266 |
-
array('term_taxonomy_id' => get_term((int) $tr_id, $taxonomy)->term_taxonomy_id));
|
267 |
-
}
|
268 |
-
}
|
269 |
-
}
|
270 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/admin.php
CHANGED
@@ -8,23 +8,22 @@
|
|
8 |
* options => inherited, reference to Polylang options array
|
9 |
* model => inherited, reference to PLL_Model object
|
10 |
* links_model => inherited, reference to PLL_Links_Model object
|
11 |
-
*
|
12 |
-
*
|
13 |
-
*
|
14 |
-
*
|
|
|
15 |
* filters => reference to PLL_Filters object
|
16 |
* filters_columns => reference to PLL_Admin_Filters_Columns object
|
17 |
* filters_post => reference to PLL_Admin_Filters_Post object
|
18 |
* filters_term => reference to PLL_Admin_filters_Term object
|
19 |
* nav_menu => reference to PLL_Admin_Nav_Menu object
|
20 |
-
* sync => reference to PLL_Admin_Sync object
|
21 |
* filters_media => optional, reference to PLL_Admin_Filters_Media object
|
22 |
*
|
23 |
* @since 1.2
|
24 |
*/
|
25 |
-
class PLL_Admin extends
|
26 |
-
public $
|
27 |
-
public $settings_page, $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $sync, $filters_media;
|
28 |
|
29 |
/*
|
30 |
* loads the polylang text domain
|
@@ -34,26 +33,12 @@ class PLL_Admin extends PLL_Base {
|
|
34 |
*
|
35 |
* @param object $links_model
|
36 |
*/
|
37 |
-
public function __construct(&$links_model) {
|
38 |
-
parent::__construct($links_model);
|
39 |
-
|
40 |
-
// plugin i18n, only needed for backend
|
41 |
-
load_plugin_textdomain('polylang', false, basename(POLYLANG_DIR).'/languages');
|
42 |
-
|
43 |
-
// adds the link to the languages panel in the WordPress admin menu
|
44 |
-
add_action('admin_menu', array(&$this, 'add_menus'));
|
45 |
-
|
46 |
-
// setup js scripts and css styles
|
47 |
-
add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
|
48 |
-
add_action('admin_print_footer_scripts', array(&$this, 'admin_print_footer_scripts'));
|
49 |
|
50 |
// adds a 'settings' link in the plugins table
|
51 |
-
add_filter('plugin_action_links_' . POLYLANG_BASENAME, array(&$this, 'plugin_action_links'));
|
52 |
-
add_action('in_plugin_update_message-' . POLYLANG_BASENAME, array(&$this, 'plugin_update_message'), 10, 2);
|
53 |
-
|
54 |
-
// Lingotek
|
55 |
-
if (!defined('PLL_LINGOTEK_AD') || PLL_LINGOTEK_AD)
|
56 |
-
require(POLYLANG_DIR . '/lingotek/lingotek.php');
|
57 |
}
|
58 |
|
59 |
/*
|
@@ -65,131 +50,13 @@ class PLL_Admin extends PLL_Base {
|
|
65 |
* @param object $links_model
|
66 |
*/
|
67 |
public function init() {
|
68 |
-
|
69 |
-
$this->settings_page = new PLL_Settings($this);
|
70 |
-
|
71 |
-
if (!$this->model->get_languages_list())
|
72 |
-
return;
|
73 |
-
|
74 |
-
$this->links = new PLL_Links($this);
|
75 |
-
|
76 |
-
// filter admin language for users
|
77 |
-
// we must not call user info before WordPress defines user roles in wp-settings.php
|
78 |
-
add_filter('setup_theme', array(&$this, 'init_user'));
|
79 |
-
add_filter('request', array(&$this, 'request'));
|
80 |
-
|
81 |
-
|
82 |
-
// adds the languages in admin bar
|
83 |
-
add_action('admin_bar_menu', array(&$this, 'admin_bar_menu'), 100); // 100 determines the position
|
84 |
|
85 |
// setup filters for admin pages
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
/*
|
91 |
-
* adds the link to the languages panel in the WordPress admin menu
|
92 |
-
*
|
93 |
-
* @since 0.1
|
94 |
-
*/
|
95 |
-
public function add_menus() {
|
96 |
-
add_submenu_page('options-general.php', $title = __('Languages', 'polylang'), $title, 'manage_options', 'mlang',
|
97 |
-
PLL_SETTINGS ? array($this->settings_page, 'languages_page') : create_function('', ''));
|
98 |
-
}
|
99 |
-
|
100 |
-
/*
|
101 |
-
* setup js scripts & css styles (only on the relevant pages)
|
102 |
-
*
|
103 |
-
* @since 0.6
|
104 |
-
*/
|
105 |
-
public function admin_enqueue_scripts() {
|
106 |
-
$screen = get_current_screen();
|
107 |
-
if (empty($screen))
|
108 |
-
return;
|
109 |
-
|
110 |
-
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
|
111 |
-
|
112 |
-
// for each script:
|
113 |
-
// 0 => the pages on which to load the script
|
114 |
-
// 1 => the scripts it needs to work
|
115 |
-
// 2 => 1 if loaded even if languages have not been defined yet, 0 otherwise
|
116 |
-
// 3 => 1 if loaded in footer
|
117 |
-
// FIXME: check if I can load more scripts in footer
|
118 |
-
$scripts = array(
|
119 |
-
'admin' => array( array('settings_page_mlang'), array('jquery', 'wp-ajax-response', 'postbox'), 1 , 0),
|
120 |
-
'post' => array( array('post', 'media', 'async-upload', 'edit'), array('jquery', 'wp-ajax-response', 'post', 'jquery-ui-autocomplete'), 0 , 1),
|
121 |
-
'media' => array( array('upload'), array('jquery'), 0 , 1),
|
122 |
-
'term' => array( array('edit-tags'), array('jquery', 'wp-ajax-response', 'jquery-ui-autocomplete'), 0, 1),
|
123 |
-
'user' => array( array('profile', 'user-edit'), array('jquery'), 0 , 0),
|
124 |
-
);
|
125 |
-
|
126 |
-
foreach ($scripts as $script => $v)
|
127 |
-
if (in_array($screen->base, $v[0]) && ($v[2] || $this->model->get_languages_list()))
|
128 |
-
wp_enqueue_script('pll_'.$script, POLYLANG_URL .'/js/'.$script.$suffix.'.js', $v[1], POLYLANG_VERSION, $v[3]);
|
129 |
-
|
130 |
-
wp_enqueue_style('polylang_admin', POLYLANG_URL .'/css/admin'.$suffix.'.css', array(), POLYLANG_VERSION);
|
131 |
-
}
|
132 |
-
|
133 |
-
/*
|
134 |
-
* sets pll_ajax_backend on all backend ajax request
|
135 |
-
* the final goal is to detect if an ajax request is made on admin or frontend
|
136 |
-
*
|
137 |
-
* takes care to various situations:
|
138 |
-
* when the ajax request has no options.data thanks to ScreenfeedFr
|
139 |
-
* see: https://wordpress.org/support/topic/ajaxprefilter-may-not-work-as-expected
|
140 |
-
* when options.data is a json string
|
141 |
-
* see: https://wordpress.org/support/topic/polylang-breaking-third-party-ajax-requests-on-admin-panels
|
142 |
-
* when options.data is an empty string (GET request with the method 'load')
|
143 |
-
* see: https://wordpress.org/support/topic/invalid-url-during-wordpress-new-dashboard-widget-operation
|
144 |
-
*
|
145 |
-
* @since 1.4
|
146 |
-
*/
|
147 |
-
public function admin_print_footer_scripts() {
|
148 |
-
global $post_ID;
|
149 |
-
$params = array('pll_ajax_backend' => 1);
|
150 |
-
if (!empty($post_ID))
|
151 |
-
$params = array_merge($params, array('pll_post_id' => $post_ID));
|
152 |
-
|
153 |
-
$str = $arr = '';
|
154 |
-
foreach ($params as $k => $v) {
|
155 |
-
$str .= ( empty( $str ) ? '' : '&' ) . $k . '=' . $v;
|
156 |
-
$arr .= (empty($arr) ? '' : ', ') . $k . ': ' . $v;
|
157 |
}
|
158 |
-
?>
|
159 |
-
<script type="text/javascript">
|
160 |
-
if (typeof jQuery != 'undefined') {
|
161 |
-
(function($){
|
162 |
-
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
|
163 |
-
if (options.url.indexOf(ajaxurl) != -1) {
|
164 |
-
if ( typeof options.data === 'undefined' ) {
|
165 |
-
options.data = options.type.toLowerCase() === "get" ? '<?php echo $str;?>' : {<?php echo $arr;?>};
|
166 |
-
}
|
167 |
-
else {
|
168 |
-
if (typeof options.data === "string") {
|
169 |
-
if ( '' === options.data && "get" === options.type.toLowerCase() ) {
|
170 |
-
options.url = options.url+'<?php echo '&' . $str;?>';
|
171 |
-
}
|
172 |
-
else {
|
173 |
-
try {
|
174 |
-
o = $.parseJSON(options.data);
|
175 |
-
o = $.extend(o, {<?php echo $arr;?>});
|
176 |
-
options.data = JSON.stringify(o);
|
177 |
-
}
|
178 |
-
catch(e) {
|
179 |
-
options.data = '<?php echo $str . '&';?>'+options.data;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
}
|
183 |
-
else {
|
184 |
-
options.data = $.extend(options.data, {<?php echo $arr;?>});
|
185 |
-
}
|
186 |
-
}
|
187 |
-
}
|
188 |
-
});
|
189 |
-
})(jQuery)
|
190 |
-
}
|
191 |
-
</script><?php
|
192 |
-
|
193 |
}
|
194 |
|
195 |
/*
|
@@ -200,8 +67,8 @@ class PLL_Admin extends PLL_Base {
|
|
200 |
* @param array $links list of links associated to the plugin
|
201 |
* @return array modified list of links
|
202 |
*/
|
203 |
-
public function plugin_action_links($links) {
|
204 |
-
array_unshift($links, '<a href="admin.php?page=mlang">' . __('Settings', 'polylang') . '</a>');
|
205 |
return $links;
|
206 |
}
|
207 |
|
@@ -213,68 +80,10 @@ class PLL_Admin extends PLL_Base {
|
|
213 |
* @param array $plugin_data not used
|
214 |
* @param object $r plugin update data
|
215 |
*/
|
216 |
-
function plugin_update_message($plugin_data, $r) {
|
217 |
-
if (isset($r->upgrade_notice))
|
218 |
-
printf('<p style="margin: 3px 0 0 0; border-top: 1px solid #ddd; padding-top: 3px">%s</p>', $r->upgrade_notice);
|
219 |
-
}
|
220 |
-
|
221 |
-
/*
|
222 |
-
* defines the backend language and the admin language filter based on user preferences
|
223 |
-
*
|
224 |
-
* @since 1.2.3
|
225 |
-
*/
|
226 |
-
public function init_user() {
|
227 |
-
// backend locale
|
228 |
-
add_filter('locale', array(&$this, 'get_locale'));
|
229 |
-
|
230 |
-
// language for admin language filter: may be empty
|
231 |
-
// $_GET['lang'] is numeric when editing a language, not when selecting a new language in the filter
|
232 |
-
if (!defined('DOING_AJAX') && !empty($_GET['lang']) && !is_numeric($_GET['lang']) && current_user_can('edit_user', $user_id = get_current_user_id()))
|
233 |
-
update_user_meta($user_id, 'pll_filter_content', ($lang = $this->model->get_language($_GET['lang'])) ? $lang->slug : '');
|
234 |
-
|
235 |
-
$this->curlang = $this->model->get_language(get_user_meta(get_current_user_id(), 'pll_filter_content', true));
|
236 |
-
|
237 |
-
// set preferred language for use when saving posts and terms: must not be empty
|
238 |
-
$this->pref_lang = empty($this->curlang) ? $this->model->get_language($this->options['default_lang']) : $this->curlang;
|
239 |
-
$this->pref_lang = apply_filters('pll_admin_preferred_language', $this->pref_lang);
|
240 |
-
|
241 |
-
// inform that the admin language has been set
|
242 |
-
// only if the admin language is one of the Polylang defined language
|
243 |
-
if ($curlang = $this->model->get_language(get_locale())) {
|
244 |
-
$GLOBALS['text_direction'] = $curlang->is_rtl ? 'rtl' : 'ltr'; // force text direction according to language setting
|
245 |
-
do_action('pll_language_defined', $curlang->slug, $curlang);
|
246 |
}
|
247 |
-
else
|
248 |
-
do_action('pll_no_language_defined'); // to load overriden textdomains
|
249 |
-
}
|
250 |
-
|
251 |
-
/*
|
252 |
-
* avoids parsing a tax query when all languages are requested
|
253 |
-
* fixes https://wordpress.org/support/topic/notice-undefined-offset-0-in-wp-includesqueryphp-on-line-3877 introduced in WP 4.1
|
254 |
-
* @see the suggestion of @boonebgorges, https://core.trac.wordpress.org/ticket/31246
|
255 |
-
*
|
256 |
-
* @since 1.6.5
|
257 |
-
*
|
258 |
-
* @param array $qvars
|
259 |
-
* @return array
|
260 |
-
*/
|
261 |
-
public function request($qvars) {
|
262 |
-
if (isset($qvars['lang']) && 'all' === $qvars['lang'])
|
263 |
-
unset($qvars['lang']);
|
264 |
-
|
265 |
-
return $qvars;
|
266 |
-
}
|
267 |
-
|
268 |
-
/*
|
269 |
-
* get the locale based on user preference
|
270 |
-
*
|
271 |
-
* @since 0.4
|
272 |
-
*
|
273 |
-
* @param string $locale
|
274 |
-
* @return string modified locale
|
275 |
-
*/
|
276 |
-
public function get_locale($locale) {
|
277 |
-
return ($loc = get_user_meta(get_current_user_id(), 'user_lang', 'true')) ? $loc : $locale;
|
278 |
}
|
279 |
|
280 |
/*
|
@@ -284,139 +93,17 @@ class PLL_Admin extends PLL_Base {
|
|
284 |
*/
|
285 |
public function add_filters() {
|
286 |
// all these are separated just for convenience and maintainability
|
287 |
-
$classes = array('Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Sync');
|
288 |
|
289 |
// don't load media filters if option is disabled or if user has no right
|
290 |
-
if ($this->options['media_support'] && ($obj = get_post_type_object('attachment')) && (current_user_can($obj->cap->edit_posts) || current_user_can($obj->cap->create_posts)))
|
291 |
$classes[] = 'Filters_Media';
|
292 |
-
|
293 |
-
foreach ($classes as $class) {
|
294 |
-
$obj = strtolower($class);
|
295 |
-
$class = apply_filters('pll_' . $obj, 'PLL_Admin_' . $class);
|
296 |
-
$this->$obj = new $class($this);
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
/*
|
301 |
-
* adds the languages list in admin bar for the admin languages filter
|
302 |
-
*
|
303 |
-
* @since 0.9
|
304 |
-
*
|
305 |
-
* @param object $wp_admin_bar
|
306 |
-
*/
|
307 |
-
public function admin_bar_menu($wp_admin_bar) {
|
308 |
-
$url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
309 |
-
|
310 |
-
$all_item = (object) array(
|
311 |
-
'slug' => 'all',
|
312 |
-
'name' => __('Show all languages', 'polylang'),
|
313 |
-
'flag' => '<span class="ab-icon"></span>'
|
314 |
-
);
|
315 |
-
|
316 |
-
$selected = empty($this->curlang) ? $all_item : $this->curlang;
|
317 |
-
|
318 |
-
$wp_admin_bar->add_menu(array(
|
319 |
-
'id' => 'languages',
|
320 |
-
'title' => $selected->flag . '<span class="ab-label">'. esc_html($selected->name) . '</span>',
|
321 |
-
'meta' => array('title' => __('Filters content by language', 'polylang')),
|
322 |
-
));
|
323 |
-
|
324 |
-
foreach (array_merge(array($all_item), $this->model->get_languages_list()) as $lang) {
|
325 |
-
if ($selected->slug == $lang->slug)
|
326 |
-
continue;
|
327 |
-
|
328 |
-
$wp_admin_bar->add_menu(array(
|
329 |
-
'parent' => 'languages',
|
330 |
-
'id' => $lang->slug,
|
331 |
-
'title' => $lang->flag . esc_html($lang->name),
|
332 |
-
'href' => esc_url(add_query_arg('lang', $lang->slug, remove_query_arg('paged',$url))),
|
333 |
-
));
|
334 |
}
|
335 |
-
}
|
336 |
-
/*
|
337 |
-
* downloads mofiles from http://svn.automattic.com/wordpress-i18n/
|
338 |
-
* FIXME backward compatibility WP < 4.0
|
339 |
-
*
|
340 |
-
* @since 0.6
|
341 |
-
*
|
342 |
-
* @param string $locale locale to download
|
343 |
-
* @param bool $upgrade optional true if this is an upgrade, false if this is the first download, defaults to false
|
344 |
-
* @return bool true on success, false otherwise
|
345 |
-
*/
|
346 |
-
static public function download_mo($locale, $upgrade = false) {
|
347 |
-
global $wp_version;
|
348 |
-
$mofile = WP_LANG_DIR."/$locale.mo";
|
349 |
-
|
350 |
-
// does file exists ?
|
351 |
-
if ((file_exists($mofile) && !$upgrade) || $locale == 'en_US')
|
352 |
-
return true;
|
353 |
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
}
|
359 |
-
|
360 |
-
// will first look in tags/ (most languages) then in branches/ (only Greek ?)
|
361 |
-
$base = 'http://svn.automattic.com/wordpress-i18n/'.$locale;
|
362 |
-
$bases = array($base.'/tags/', $base.'/branches/');
|
363 |
-
|
364 |
-
foreach ($bases as $base) {
|
365 |
-
// get all the versions available in the subdirectory
|
366 |
-
$resp = wp_remote_get($base);
|
367 |
-
if (is_wp_error($resp) || 200 != $resp['response']['code'])
|
368 |
-
continue;
|
369 |
-
|
370 |
-
preg_match_all('#>([0-9\.]+)\/#', $resp['body'], $matches);
|
371 |
-
if (empty($matches[1]))
|
372 |
-
continue;
|
373 |
-
|
374 |
-
rsort($matches[1]); // sort from newest to oldest
|
375 |
-
$versions = $matches[1];
|
376 |
-
|
377 |
-
$newest = $upgrade ? $upgrade : $wp_version;
|
378 |
-
foreach ($versions as $key=>$version) {
|
379 |
-
// will not try to download a too recent mofile
|
380 |
-
if (version_compare($version, $newest, '>'))
|
381 |
-
unset($versions[$key]);
|
382 |
-
// will not download an older version if we are upgrading
|
383 |
-
if ($upgrade && version_compare($version, $wp_version, '<='))
|
384 |
-
unset($versions[$key]);
|
385 |
-
}
|
386 |
-
|
387 |
-
$versions = array_splice($versions, 0, 5); // reduce the number of versions to test to 5
|
388 |
-
$args = array('timeout' => 30, 'stream' => true);
|
389 |
-
|
390 |
-
// try to download the file
|
391 |
-
foreach ($versions as $version) {
|
392 |
-
$resp = wp_remote_get($base."$version/messages/$locale.mo", $args + array('filename' => $mofile));
|
393 |
-
if (is_wp_error($resp) || 200 != $resp['response']['code']) {
|
394 |
-
unlink($mofile); // otherwise we download a gzipped 404 page
|
395 |
-
continue;
|
396 |
-
}
|
397 |
-
// try to download ms and continents-cities files if exist (will not return false if failed)
|
398 |
-
// with new files introduced in WP 3.4
|
399 |
-
foreach (array('ms', 'continents-cities', 'admin', 'admin-network') as $file) {
|
400 |
-
$resp = wp_remote_get($base."$version/messages/$file-$locale.mo", $args + array('filename' => WP_LANG_DIR."/$file-$locale.mo"));
|
401 |
-
if (is_wp_error($resp) || 200 != $resp['response']['code'])
|
402 |
-
unlink(WP_LANG_DIR."/$file-$locale.mo");
|
403 |
-
}
|
404 |
-
// try to download theme files if exist (will not return false if failed)
|
405 |
-
// FIXME not updated when the theme is updated outside a core update
|
406 |
-
foreach (array('twentyten', 'twentyeleven', 'twentytwelve', 'twentythirteen', 'twentyfourteen') as $theme) {
|
407 |
-
if (!is_dir($theme_dir = get_theme_root()."/$theme/languages"))
|
408 |
-
continue; // the theme is not present
|
409 |
-
|
410 |
-
$resp = wp_remote_get($base."$version/messages/$theme/$locale.mo", $args + array('filename' => "$theme_dir/$locale.mo"));
|
411 |
-
if (is_wp_error($resp) || 200 != $resp['response']['code'])
|
412 |
-
unlink("$theme_dir/$locale.mo");
|
413 |
-
}
|
414 |
-
return true;
|
415 |
-
}
|
416 |
-
}
|
417 |
-
|
418 |
-
// we did not succeeded to download a file :(
|
419 |
-
add_settings_error('general', 'pll_download_mo', __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang'));
|
420 |
-
return false;
|
421 |
}
|
422 |
}
|
8 |
* options => inherited, reference to Polylang options array
|
9 |
* model => inherited, reference to PLL_Model object
|
10 |
* links_model => inherited, reference to PLL_Links_Model object
|
11 |
+
* links => inherited, reference to PLL_Admin_Links object
|
12 |
+
* static_pages => inherited, reference to PLL_Admin_Static_Pages object
|
13 |
+
* filters_links => inherited, reference to PLL_Filters_Links object
|
14 |
+
* curlang => inherited, optional, current language used to filter admin content
|
15 |
+
* pref_lang => inherited, preferred language used as default when saving posts or terms
|
16 |
* filters => reference to PLL_Filters object
|
17 |
* filters_columns => reference to PLL_Admin_Filters_Columns object
|
18 |
* filters_post => reference to PLL_Admin_Filters_Post object
|
19 |
* filters_term => reference to PLL_Admin_filters_Term object
|
20 |
* nav_menu => reference to PLL_Admin_Nav_Menu object
|
|
|
21 |
* filters_media => optional, reference to PLL_Admin_Filters_Media object
|
22 |
*
|
23 |
* @since 1.2
|
24 |
*/
|
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
|
33 |
*
|
34 |
* @param object $links_model
|
35 |
*/
|
36 |
+
public function __construct( &$links_model ) {
|
37 |
+
parent::__construct( $links_model );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
// adds a 'settings' link in the plugins table
|
40 |
+
add_filter( 'plugin_action_links_' . POLYLANG_BASENAME, array( &$this, 'plugin_action_links' ) );
|
41 |
+
add_action( 'in_plugin_update_message-' . POLYLANG_BASENAME, array( &$this, 'plugin_update_message' ), 10, 2 );
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
|
44 |
/*
|
50 |
* @param object $links_model
|
51 |
*/
|
52 |
public function init() {
|
53 |
+
parent::init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
// setup filters for admin pages
|
56 |
+
// priority 5 to make sure filters are there before customize_register is fired
|
57 |
+
if ( $this->model->get_languages_list() ) {
|
58 |
+
add_action( 'wp_loaded', array( &$this, 'add_filters' ), 5 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
/*
|
67 |
* @param array $links list of links associated to the plugin
|
68 |
* @return array modified list of links
|
69 |
*/
|
70 |
+
public function plugin_action_links( $links ) {
|
71 |
+
array_unshift( $links, '<a href="admin.php?page=mlang">' . __( 'Settings', 'polylang' ) . '</a>' );
|
72 |
return $links;
|
73 |
}
|
74 |
|
80 |
* @param array $plugin_data not used
|
81 |
* @param object $r plugin update data
|
82 |
*/
|
83 |
+
function plugin_update_message( $plugin_data, $r ) {
|
84 |
+
if ( isset( $r->upgrade_notice ) ) {
|
85 |
+
printf( '<p style="margin: 3px 0 0 0; border-top: 1px solid #ddd; padding-top: 3px">%s</p>', esc_html( $r->upgrade_notice ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
/*
|
93 |
*/
|
94 |
public function add_filters() {
|
95 |
// all these are separated just for convenience and maintainability
|
96 |
+
$classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Sync' );
|
97 |
|
98 |
// don't load media filters if option is disabled or if user has no right
|
99 |
+
if ( $this->options['media_support'] && ( $obj = get_post_type_object( 'attachment' ) ) && ( current_user_can( $obj->cap->edit_posts ) || current_user_can( $obj->cap->create_posts ) ) ) {
|
100 |
$classes[] = 'Filters_Media';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
}
|
109 |
}
|
admin/languages.php
DELETED
@@ -1,102 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* for each language:
|
4 |
-
* [0] => ISO 639-1 language code
|
5 |
-
* [1] => WordPress locale
|
6 |
-
* [2] => name
|
7 |
-
* [3] => not set for ltr scripts, 'rtl' otherwise
|
8 |
-
*/
|
9 |
-
$languages = array(
|
10 |
-
array('af', 'af', 'Afrikaans'),
|
11 |
-
array('ar', 'ar', 'العربية', 'rtl'),
|
12 |
-
array('az', 'az', 'Azərbaycan'),
|
13 |
-
array('be', 'bel', 'Беларуская мова'),
|
14 |
-
array('bg', 'bg_BG', 'български'),
|
15 |
-
array('bs', 'bs_BA', 'Bosanski'),
|
16 |
-
array('ca', 'ca', 'Català'),
|
17 |
-
array('cs', 'cs_CZ', 'Čeština'),
|
18 |
-
array('cy', 'cy', 'Cymraeg'),
|
19 |
-
array('da', 'da_DK', 'Dansk'),
|
20 |
-
array('de', 'de_CH', 'Deutsch'),
|
21 |
-
array('de', 'de_DE', 'Deutsch'),
|
22 |
-
array( 'de', 'de_DE_formal', 'Deutsch'),
|
23 |
-
array('el', 'el', 'Ελληνικά'),
|
24 |
-
array('en', 'en_AU', 'English'),
|
25 |
-
array('en', 'en_CA', 'English'),
|
26 |
-
array('en', 'en_GB', 'English'),
|
27 |
-
array( 'en', 'en_NZ', 'English'),
|
28 |
-
array('en', 'en_US', 'English'),
|
29 |
-
array('eo', 'eo', 'Esperanto'),
|
30 |
-
array('es', 'es_CL', 'Español'),
|
31 |
-
array( 'es', 'es_CO', 'Español'),
|
32 |
-
array('es', 'es_ES', 'Español'),
|
33 |
-
array('es', 'es_MX', 'Español'),
|
34 |
-
array('es', 'es_PE', 'Español'),
|
35 |
-
array('es', 'es_VE', 'Español'),
|
36 |
-
array('et', 'et', 'Eesti'),
|
37 |
-
array('eu', 'eu', 'Euskara'),
|
38 |
-
array('fa', 'fa_AF', 'فارسی', 'rtl'),
|
39 |
-
array('fa', 'fa_IR', 'فارسی', 'rtl'),
|
40 |
-
array('fi', 'fi', 'Suomi'),
|
41 |
-
array('fo', 'fo', 'Føroyskt'),
|
42 |
-
array('fr', 'fr_FR', 'Français'),
|
43 |
-
array('fy', 'fy', 'Frysk'),
|
44 |
-
array('gd', 'gd', 'Gàidhlig'),
|
45 |
-
array('gl', 'gl_ES', 'Galego'),
|
46 |
-
array('haz', 'haz', 'هزاره گی', 'rtl'),
|
47 |
-
array('he', 'he_IL', 'עברית', 'rtl'),
|
48 |
-
array('hi', 'hi_IN', 'हिन्दी'),
|
49 |
-
array('hr', 'hr', 'Hrvatski'),
|
50 |
-
array('hu', 'hu_HU', 'Magyar'),
|
51 |
-
array( 'hy', 'hy', 'Հայերեն'),
|
52 |
-
array('id', 'id_ID', 'Bahasa Indonesia'),
|
53 |
-
array('is', 'is_IS', 'Íslenska'),
|
54 |
-
array('it', 'it_IT', 'Italiano'),
|
55 |
-
array('ja', 'ja', '日本語'),
|
56 |
-
array('jv', 'jv_ID', 'Basa Jawa'),
|
57 |
-
array('ka', 'ka_GE', 'ქართული'),
|
58 |
-
array('kk', 'kk', 'Қазақ тілі'),
|
59 |
-
array('ko', 'ko_KR', '한국어'),
|
60 |
-
array('ku', 'ckb', 'کوردی', 'rtl'),
|
61 |
-
array('lo', 'lo', 'ພາສາລາວ'),
|
62 |
-
array('lt', 'lt_LT', 'Lietuviškai'),
|
63 |
-
array('lv', 'lv', 'Latviešu valoda'),
|
64 |
-
array('mk', 'mk_MK', 'македонски јазик'),
|
65 |
-
array('mn', 'mn', 'Монгол хэл'),
|
66 |
-
array('ms', 'ms_MY', 'Bahasa Melayu'),
|
67 |
-
array('my', 'my_MM', 'ဗမာစာ'),
|
68 |
-
array('nb', 'nb_NO', 'Norsk Bokmål'),
|
69 |
-
array('ne', 'ne_NP', 'नेपाली'),
|
70 |
-
array('nl', 'nl_NL', 'Nederlands'),
|
71 |
-
array('nn', 'nn_NO', 'Norsk Nynorsk'),
|
72 |
-
array( 'oc', 'oci', 'Occitan'),
|
73 |
-
array('pl', 'pl_PL', 'Polski'),
|
74 |
-
array( 'ps', 'ps', 'پښتو', 'rtl'),
|
75 |
-
array('pt', 'pt_BR', 'Português'),
|
76 |
-
array('pt', 'pt_PT', 'Português'),
|
77 |
-
array('ro', 'ro_RO', 'Română'),
|
78 |
-
array('ru', 'ru_RU', 'Русский'),
|
79 |
-
array('si', 'si_LK', 'සිංහල'),
|
80 |
-
array('sk', 'sk_SK', 'Slovenčina'),
|
81 |
-
array('sl', 'sl_SI', 'Slovenščina'),
|
82 |
-
array('so', 'so_SO', 'Af-Soomaali'),
|
83 |
-
array('sq', 'sq', 'Shqip'),
|
84 |
-
array('sr', 'sr_RS', 'Српски језик'),
|
85 |
-
array('su', 'su_ID', 'Basa Sunda'),
|
86 |
-
array('sv', 'sv_SE', 'Svenska'),
|
87 |
-
array('ta', 'ta_LK', 'தமிழ்'),
|
88 |
-
array('th', 'th', 'ไทย'),
|
89 |
-
array( 'tl', 'tl', 'Tagalog'),
|
90 |
-
array('tr', 'tr_TR', 'Türkçe'),
|
91 |
-
array('ug', 'ug_CN', 'Uyƣurqə'),
|
92 |
-
array('uk', 'uk', 'Українська'),
|
93 |
-
array('ur', 'ur', 'اردو', 'rtl'),
|
94 |
-
array('uz', 'uz_UZ', 'Oʻzbek'),
|
95 |
-
array('vec', 'vec', 'Vèneto'),
|
96 |
-
array('vi', 'vi', 'Tiếng Việt'),
|
97 |
-
array('zh', 'zh_CN', '中文 (中国)'),
|
98 |
-
array('zh', 'zh_HK', '中文 (香港)'),
|
99 |
-
array('zh', 'zh_TW', '中文 (台灣)'),
|
100 |
-
);
|
101 |
-
|
102 |
-
$languages = apply_filters( 'pll_predefined_languages', $languages );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/settings.php
DELETED
@@ -1,352 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* a class for the Polylang settings pages
|
5 |
-
*
|
6 |
-
* @since 1.2
|
7 |
-
*/
|
8 |
-
class PLL_Settings {
|
9 |
-
public $links_model, $model, $options;
|
10 |
-
protected $active_tab;
|
11 |
-
|
12 |
-
/*
|
13 |
-
* constructor
|
14 |
-
*
|
15 |
-
* @since 1.2
|
16 |
-
*
|
17 |
-
* @param object $polylang
|
18 |
-
*/
|
19 |
-
public function __construct(&$polylang) {
|
20 |
-
$this->links_model = &$polylang->links_model;
|
21 |
-
$this->model = &$polylang->model;
|
22 |
-
$this->options = &$polylang->options;
|
23 |
-
|
24 |
-
$this->active_tab = !empty($_GET['tab']) ? $_GET['tab'] : 'lang';
|
25 |
-
|
26 |
-
PLL_Admin_Strings::init();
|
27 |
-
|
28 |
-
// adds screen options and the about box in the languages admin panel
|
29 |
-
add_action('load-settings_page_mlang', array(&$this, 'load_page'));
|
30 |
-
|
31 |
-
// saves per-page value in screen option
|
32 |
-
add_filter('set-screen-option', create_function('$s, $o, $v', 'return $v;'), 10, 3);
|
33 |
-
}
|
34 |
-
|
35 |
-
/*
|
36 |
-
* adds screen options and the about box in the languages admin panel
|
37 |
-
*
|
38 |
-
* @since 0.9.5
|
39 |
-
*/
|
40 |
-
public function load_page() {
|
41 |
-
// test of $this->active_tab avoids displaying the automatically generated screen options on other tabs
|
42 |
-
switch ($this->active_tab) {
|
43 |
-
case 'lang':
|
44 |
-
ob_start();
|
45 |
-
include(PLL_ADMIN_INC.'/view-recommended.php');
|
46 |
-
$content = trim(ob_get_contents());
|
47 |
-
ob_end_clean();
|
48 |
-
|
49 |
-
if (strlen($content) > 0) {
|
50 |
-
add_meta_box(
|
51 |
-
'pll_recommended',
|
52 |
-
__('Recommended plugins', 'polylang'),
|
53 |
-
create_function('', "echo '$content';"),
|
54 |
-
'settings_page_mlang',
|
55 |
-
'normal'
|
56 |
-
);
|
57 |
-
}
|
58 |
-
|
59 |
-
if (!defined('PLL_DISPLAY_ABOUT') || PLL_DISPLAY_ABOUT) {
|
60 |
-
add_meta_box(
|
61 |
-
'pll_about_box',
|
62 |
-
__('About Polylang', 'polylang'),
|
63 |
-
create_function('', "include(PLL_ADMIN_INC.'/view-about.php');"),
|
64 |
-
'settings_page_mlang',
|
65 |
-
'normal'
|
66 |
-
);
|
67 |
-
}
|
68 |
-
|
69 |
-
add_screen_option('per_page', array(
|
70 |
-
'label' => __('Languages', 'polylang'),
|
71 |
-
'default' => 10,
|
72 |
-
'option' => 'pll_lang_per_page'
|
73 |
-
));
|
74 |
-
break;
|
75 |
-
|
76 |
-
case 'strings':
|
77 |
-
add_screen_option('per_page', array(
|
78 |
-
'label' => __('Strings translations', 'polylang'),
|
79 |
-
'default' => 10,
|
80 |
-
'option' => 'pll_strings_per_page'
|
81 |
-
));
|
82 |
-
break;
|
83 |
-
|
84 |
-
default:
|
85 |
-
break;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
/*
|
90 |
-
* diplays the 3 tabs pages: languages, strings translations, settings
|
91 |
-
* also manages user input for these pages
|
92 |
-
*
|
93 |
-
* @since 0.1
|
94 |
-
*/
|
95 |
-
public function languages_page() {
|
96 |
-
// prepare the list of tabs
|
97 |
-
$tabs = array('lang' => __('Languages','polylang'));
|
98 |
-
|
99 |
-
// only if at least one language has been created
|
100 |
-
if ($listlanguages = $this->model->get_languages_list()) {
|
101 |
-
$tabs['strings'] = __('Strings translation','polylang');
|
102 |
-
$tabs['settings'] = __('Settings', 'polylang');
|
103 |
-
}
|
104 |
-
|
105 |
-
$tabs = apply_filters('pll_settings_tabs', $tabs);
|
106 |
-
|
107 |
-
switch($this->active_tab) {
|
108 |
-
case 'lang':
|
109 |
-
// prepare the list table of languages
|
110 |
-
$list_table = new PLL_Table_Languages();
|
111 |
-
$list_table->prepare_items($listlanguages);
|
112 |
-
break;
|
113 |
-
|
114 |
-
case 'strings':
|
115 |
-
// get the strings to translate
|
116 |
-
$data = PLL_Admin_Strings::get_strings();
|
117 |
-
|
118 |
-
// get the groups
|
119 |
-
foreach ($data as $key => $row)
|
120 |
-
$groups[] = $row['context'];
|
121 |
-
|
122 |
-
$groups = array_unique($groups);
|
123 |
-
$selected = empty($_REQUEST['group']) || !in_array($_REQUEST['group'], $groups) ? -1 : $_REQUEST['group'];
|
124 |
-
$s = empty($_REQUEST['s']) ? '' : wp_unslash($_REQUEST['s']);
|
125 |
-
|
126 |
-
// filter for search string
|
127 |
-
foreach ($data as $key => $row) {
|
128 |
-
if (($selected !=-1 && $row['context'] != $selected) || (!empty($s) && stripos($row['name'], $s) === false && stripos($row['string'], $s) === false))
|
129 |
-
unset ($data[$key]);
|
130 |
-
}
|
131 |
-
|
132 |
-
// load translations
|
133 |
-
foreach ($listlanguages as $language) {
|
134 |
-
// filters by language if requested
|
135 |
-
if (($lg = get_user_meta(get_current_user_id(), 'pll_filter_content', true)) && $language->slug != $lg)
|
136 |
-
continue;
|
137 |
-
|
138 |
-
$mo = new PLL_MO();
|
139 |
-
$mo->import_from_db($language);
|
140 |
-
foreach ($data as $key=>$row) {
|
141 |
-
$data[$key]['translations'][$language->slug] = $mo->translate($row['string']);
|
142 |
-
$data[$key]['row'] = $key; // store the row number for convenience
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
// get an array with language slugs as keys, names as values
|
147 |
-
$languages = array_combine(wp_list_pluck($listlanguages, 'slug'), wp_list_pluck($listlanguages, 'name'));
|
148 |
-
|
149 |
-
$string_table = new PLL_Table_String(compact('languages', 'groups', 'selected'));
|
150 |
-
$string_table->prepare_items($data);
|
151 |
-
break;
|
152 |
-
|
153 |
-
case 'settings':
|
154 |
-
$post_types = get_post_types(array('public' => true, '_builtin' => false));
|
155 |
-
$post_types = array_diff($post_types, get_post_types(array('_pll' => true)));
|
156 |
-
$post_types = array_unique(apply_filters('pll_get_post_types', $post_types, true));
|
157 |
-
|
158 |
-
$taxonomies = get_taxonomies(array('public' => true, '_builtin' => false));
|
159 |
-
$taxonomies = array_diff($taxonomies, get_taxonomies(array('_pll' => true)));
|
160 |
-
$taxonomies = array_unique(apply_filters('pll_get_taxonomies', $taxonomies , true));
|
161 |
-
break;
|
162 |
-
|
163 |
-
default:
|
164 |
-
break;
|
165 |
-
}
|
166 |
-
|
167 |
-
$action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : '';
|
168 |
-
|
169 |
-
switch ($action) {
|
170 |
-
case 'add':
|
171 |
-
check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
|
172 |
-
|
173 |
-
if ($this->model->add_language($_POST)) {
|
174 |
-
// backward compatibility WP < 4.0
|
175 |
-
if (version_compare($GLOBALS['wp_version'], '4.0', '<')) {
|
176 |
-
PLL_Admin::download_mo($_POST['locale']);
|
177 |
-
}
|
178 |
-
|
179 |
-
elseif ('en_US' != $_POST['locale']) {
|
180 |
-
// attempts to install the language pack
|
181 |
-
require_once(ABSPATH . 'wp-admin/includes/translation-install.php');
|
182 |
-
if (!wp_download_language_pack($_POST['locale']))
|
183 |
-
add_settings_error('general', 'pll_download_mo', __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang'));
|
184 |
-
|
185 |
-
// force checking for themes and plugins translations updates
|
186 |
-
wp_update_themes();
|
187 |
-
wp_update_plugins();
|
188 |
-
}
|
189 |
-
}
|
190 |
-
$this->redirect(); // to refresh the page (possible thanks to the $_GET['noheader']=true)
|
191 |
-
break;
|
192 |
-
|
193 |
-
case 'delete':
|
194 |
-
check_admin_referer('delete-lang');
|
195 |
-
|
196 |
-
if (!empty($_GET['lang']))
|
197 |
-
$this->model->delete_language((int) $_GET['lang']);
|
198 |
-
|
199 |
-
$this->redirect(); // to refresh the page (possible thanks to the $_GET['noheader']=true)
|
200 |
-
break;
|
201 |
-
|
202 |
-
case 'edit':
|
203 |
-
if (!empty($_GET['lang']))
|
204 |
-
$edit_lang = $this->model->get_language((int) $_GET['lang']);
|
205 |
-
break;
|
206 |
-
|
207 |
-
case 'update':
|
208 |
-
check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
|
209 |
-
|
210 |
-
$error = $this->model->update_language($_POST);
|
211 |
-
|
212 |
-
$this->redirect(); // to refresh the page (possible thanks to the $_GET['noheader']=true)
|
213 |
-
break;
|
214 |
-
|
215 |
-
case 'string-translation':
|
216 |
-
if (!empty($_REQUEST['submit'])) {
|
217 |
-
check_admin_referer( 'string-translation', '_wpnonce_string-translation' );
|
218 |
-
$strings = PLL_Admin_Strings::get_strings();
|
219 |
-
|
220 |
-
foreach ($this->model->get_languages_list() as $language) {
|
221 |
-
if (empty($_POST['translation'][$language->slug])) // in case the language filter is active (thanks to John P. Bloch)
|
222 |
-
continue;
|
223 |
-
|
224 |
-
$mo = new PLL_MO();
|
225 |
-
$mo->import_from_db($language);
|
226 |
-
|
227 |
-
foreach ($_POST['translation'][$language->slug] as $key => $translation) {
|
228 |
-
$translation = apply_filters('pll_sanitize_string_translation', $translation, $strings[$key]['name'], $strings[$key]['context']);
|
229 |
-
$mo->add_entry($mo->make_entry($strings[$key]['string'], $translation));
|
230 |
-
}
|
231 |
-
|
232 |
-
// clean database (removes all strings which were registered some day but are no more)
|
233 |
-
if (!empty($_POST['clean'])) {
|
234 |
-
$new_mo = new PLL_MO();
|
235 |
-
|
236 |
-
foreach ($strings as $string)
|
237 |
-
$new_mo->add_entry($mo->make_entry($string['string'], $mo->translate($string['string'])));
|
238 |
-
}
|
239 |
-
|
240 |
-
isset($new_mo) ? $new_mo->export_to_db($language) : $mo->export_to_db($language);
|
241 |
-
}
|
242 |
-
add_settings_error('general', 'pll_strings_translations_updated', __('Translations updated.', 'polylang'), 'updated');
|
243 |
-
}
|
244 |
-
|
245 |
-
do_action('pll_save_strings_translations');
|
246 |
-
|
247 |
-
// unregisters strings registered through WPML API
|
248 |
-
if ($string_table->current_action() == 'delete' && !empty($_REQUEST['strings']) && function_exists('icl_unregister_string')) {
|
249 |
-
check_admin_referer( 'string-translation', '_wpnonce_string-translation' );
|
250 |
-
$strings = PLL_Admin_Strings::get_strings();
|
251 |
-
|
252 |
-
foreach ($_REQUEST['strings'] as $key)
|
253 |
-
icl_unregister_string($strings[$key]['context'], $strings[$key]['name']);
|
254 |
-
}
|
255 |
-
|
256 |
-
// to refresh the page (possible thanks to the $_GET['noheader']=true)
|
257 |
-
$this->redirect(array_intersect_key($_REQUEST, array_flip(array('s', 'paged', 'group'))));
|
258 |
-
break;
|
259 |
-
|
260 |
-
case 'options':
|
261 |
-
check_admin_referer( 'options-lang', '_wpnonce_options-lang' );
|
262 |
-
|
263 |
-
$this->options['default_lang'] = sanitize_title($_POST['default_lang']); // we have slug as value
|
264 |
-
|
265 |
-
foreach(array('force_lang', 'rewrite') as $key)
|
266 |
-
$this->options[$key] = isset($_POST[$key]) ? (int) $_POST[$key] : 0;
|
267 |
-
|
268 |
-
if (3 == $this->options['force_lang'] && isset($_POST['domains']) && is_array($_POST['domains'])) {
|
269 |
-
foreach ($_POST['domains'] as $key => $domain) {
|
270 |
-
$this->options['domains'][$key] = esc_url_raw(trim($domain));
|
271 |
-
}
|
272 |
-
}
|
273 |
-
|
274 |
-
foreach (array('browser', 'hide_default', 'redirect_lang', 'media_support') as $key)
|
275 |
-
$this->options[$key] = isset($_POST[$key]) ? 1 : 0;
|
276 |
-
|
277 |
-
if (3 == $this->options['force_lang'])
|
278 |
-
$this->options['browser'] = $this->options['hide_default'] = 0;
|
279 |
-
|
280 |
-
foreach (array('sync', 'post_types', 'taxonomies') as $key)
|
281 |
-
$this->options[$key] = empty($_POST[$key]) ? array() : array_keys($_POST[$key], 1);
|
282 |
-
|
283 |
-
update_option('polylang', $this->options);
|
284 |
-
|
285 |
-
// refresh rewrite rules in case rewrite, hide_default, post types or taxonomies options have been modified
|
286 |
-
// it seems useless to refresh permastruct here
|
287 |
-
flush_rewrite_rules();
|
288 |
-
|
289 |
-
// refresh language cache in case home urls have been modified
|
290 |
-
$this->model->clean_languages_cache();
|
291 |
-
|
292 |
-
// fills existing posts & terms with default language
|
293 |
-
if (isset($_POST['fill_languages']) && $nolang = $this->model->get_objects_with_no_lang()) {
|
294 |
-
if (!empty($nolang['posts']))
|
295 |
-
$this->model->set_language_in_mass('post', $nolang['posts'], $this->options['default_lang']);
|
296 |
-
if (!empty($nolang['terms']))
|
297 |
-
$this->model->set_language_in_mass('term', $nolang['terms'], $this->options['default_lang']);
|
298 |
-
}
|
299 |
-
|
300 |
-
add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
|
301 |
-
$this->redirect();
|
302 |
-
break;
|
303 |
-
|
304 |
-
default:
|
305 |
-
break;
|
306 |
-
}
|
307 |
-
|
308 |
-
// displays the page
|
309 |
-
include(PLL_ADMIN_INC.'/view-languages.php');
|
310 |
-
}
|
311 |
-
|
312 |
-
/*
|
313 |
-
* list the post metas to synchronize
|
314 |
-
*
|
315 |
-
* @since 1.0
|
316 |
-
*
|
317 |
-
* @return array
|
318 |
-
*/
|
319 |
-
static public function list_metas_to_sync() {
|
320 |
-
return array(
|
321 |
-
'taxonomies' => __('Taxonomies', 'polylang'),
|
322 |
-
'post_meta' => __('Custom fields', 'polylang'),
|
323 |
-
'comment_status' => __('Comment status', 'polylang'),
|
324 |
-
'ping_status' => __('Ping status', 'polylang'),
|
325 |
-
'sticky_posts' => __('Sticky posts', 'polylang'),
|
326 |
-
'post_date' => __('Published date', 'polylang'),
|
327 |
-
'post_format' => __('Post format', 'polylang'),
|
328 |
-
'post_parent' => __('Page parent', 'polylang'),
|
329 |
-
'_wp_page_template' => __('Page template', 'polylang'),
|
330 |
-
'menu_order' => __('Page order', 'polylang'),
|
331 |
-
'_thumbnail_id' => __('Featured image', 'polylang'),
|
332 |
-
);
|
333 |
-
}
|
334 |
-
|
335 |
-
/*
|
336 |
-
* redirects to language page (current active tab)
|
337 |
-
* saves error messages in a transient for reuse in redirected page
|
338 |
-
*
|
339 |
-
* @since 1.5
|
340 |
-
*
|
341 |
-
* @param array $args query arguments to add to the url
|
342 |
-
*/
|
343 |
-
protected function redirect($args = array()) {
|
344 |
-
if ($errors = get_settings_errors()) {
|
345 |
-
set_transient('settings_errors', $errors, 30);
|
346 |
-
$args['settings-updated'] = 1;
|
347 |
-
}
|
348 |
-
// remove possible 'pll_action' and 'lang' query args from the referer before redirecting
|
349 |
-
wp_redirect(add_query_arg($args, remove_query_arg( array('pll_action', 'lang'), wp_get_referer() )));
|
350 |
-
exit;
|
351 |
-
}
|
352 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/table-languages.php
DELETED
@@ -1,139 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!class_exists('WP_List_Table')){
|
4 |
-
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
|
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 |
-
*
|
11 |
-
* @since 0.1
|
12 |
-
*/
|
13 |
-
class PLL_Table_Languages extends WP_List_Table {
|
14 |
-
|
15 |
-
/*
|
16 |
-
* constructor
|
17 |
-
*
|
18 |
-
* @since 0.1
|
19 |
-
*/
|
20 |
-
function __construct() {
|
21 |
-
parent::__construct(array(
|
22 |
-
'plural' => 'Languages', // do not translate (used for css class)
|
23 |
-
'ajax' => false
|
24 |
-
));
|
25 |
-
}
|
26 |
-
|
27 |
-
/*
|
28 |
-
* displays the item information in a column (default case)
|
29 |
-
*
|
30 |
-
* @since 0.1
|
31 |
-
*
|
32 |
-
* @param object $item
|
33 |
-
* @param string $column_name
|
34 |
-
* @return string
|
35 |
-
*/
|
36 |
-
function column_default($item, $column_name) {
|
37 |
-
switch($column_name) {
|
38 |
-
case 'locale':
|
39 |
-
case 'slug':
|
40 |
-
return esc_html($item->$column_name);
|
41 |
-
|
42 |
-
case 'term_group':
|
43 |
-
case 'count':
|
44 |
-
return (int) $item->$column_name;
|
45 |
-
|
46 |
-
default:
|
47 |
-
return $item->$column_name; // flag
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
/*
|
52 |
-
* displays the item information in the column 'name'
|
53 |
-
* displays the edit and delete links
|
54 |
-
*
|
55 |
-
* @since 0.1
|
56 |
-
*
|
57 |
-
* @param object $item
|
58 |
-
* @return string
|
59 |
-
*/
|
60 |
-
function column_name($item) {
|
61 |
-
return esc_html($item->name) . $this->row_actions(array(
|
62 |
-
'edit' => sprintf(
|
63 |
-
'<a href="%s">%s</a>',
|
64 |
-
esc_url(admin_url('admin.php?page=mlang&pll_action=edit&lang=' . $item->term_id)),
|
65 |
-
__('Edit','polylang')
|
66 |
-
),
|
67 |
-
'delete' => sprintf(
|
68 |
-
'<a href="%s" onclick = "return confirm(\'%s\');">%s</a>',
|
69 |
-
wp_nonce_url('?page=mlang&pll_action=delete&noheader=true&lang=' . $item->term_id, 'delete-lang'),
|
70 |
-
__('You are about to permanently delete this language. Are you sure?', 'polylang'),
|
71 |
-
__('Delete','polylang')
|
72 |
-
)
|
73 |
-
));
|
74 |
-
}
|
75 |
-
|
76 |
-
/*
|
77 |
-
* gets the list of columns
|
78 |
-
*
|
79 |
-
* @since 0.1
|
80 |
-
*
|
81 |
-
* @return array the list of column titles
|
82 |
-
*/
|
83 |
-
function get_columns() {
|
84 |
-
return array(
|
85 |
-
'name' => __('Full name', 'polylang'),
|
86 |
-
'locale' => __('Locale', 'polylang'),
|
87 |
-
'slug' => __('Code', 'polylang'),
|
88 |
-
'term_group' => __('Order', 'polylang'),
|
89 |
-
'flag' => __('Flag', 'polylang'),
|
90 |
-
'count' => __('Posts', 'polylang')
|
91 |
-
);
|
92 |
-
}
|
93 |
-
|
94 |
-
/*
|
95 |
-
* gets the list of sortable columns
|
96 |
-
*
|
97 |
-
* @since 0.1
|
98 |
-
*
|
99 |
-
* @return array
|
100 |
-
*/
|
101 |
-
function get_sortable_columns() {
|
102 |
-
return array(
|
103 |
-
'name' => array('name', true), // sorted by name by default
|
104 |
-
'locale' => array('locale', false),
|
105 |
-
'slug' => array('slug', false),
|
106 |
-
'term_group' => array('term_group', false),
|
107 |
-
'count' => array('count', false)
|
108 |
-
);
|
109 |
-
}
|
110 |
-
|
111 |
-
/*
|
112 |
-
* prepares the list of items for displaying
|
113 |
-
*
|
114 |
-
* @since 0.1
|
115 |
-
*
|
116 |
-
* @param array $data
|
117 |
-
*/
|
118 |
-
function prepare_items($data = array()) {
|
119 |
-
$per_page = $this->get_items_per_page('pll_lang_per_page');
|
120 |
-
$this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
|
121 |
-
|
122 |
-
function usort_reorder($a, $b){
|
123 |
-
$orderby = !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'name';
|
124 |
-
$result = strcmp($a->$orderby, $b->$orderby); // determine sort order
|
125 |
-
return (empty($_REQUEST['order']) || $_REQUEST['order'] == 'asc') ? $result : -$result; // send final sort direction to usort
|
126 |
-
};
|
127 |
-
|
128 |
-
usort($data, 'usort_reorder');
|
129 |
-
|
130 |
-
$total_items = count($data);
|
131 |
-
$this->items = array_slice($data, ($this->get_pagenum() - 1) * $per_page, $per_page);
|
132 |
-
|
133 |
-
$this->set_pagination_args(array(
|
134 |
-
'total_items' => $total_items,
|
135 |
-
'per_page' => $per_page,
|
136 |
-
'total_pages' => ceil($total_items/$per_page)
|
137 |
-
));
|
138 |
-
}
|
139 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/table-string.php
DELETED
@@ -1,203 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!class_exists('WP_List_Table')){
|
4 |
-
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
|
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, $groups, $group_selected;
|
15 |
-
|
16 |
-
/*
|
17 |
-
* constructor
|
18 |
-
*
|
19 |
-
* @since 0.6
|
20 |
-
*
|
21 |
-
* @param array $groups
|
22 |
-
* @param string $group_selected
|
23 |
-
*/
|
24 |
-
function __construct($args) {
|
25 |
-
parent::__construct(array(
|
26 |
-
'plural' => 'Strings translations', // do not translate (used for css class)
|
27 |
-
'ajax' => false
|
28 |
-
));
|
29 |
-
|
30 |
-
$this->languages = $args['languages'];
|
31 |
-
$this->groups = $args['groups'];
|
32 |
-
$this->group_selected = $args['selected'];
|
33 |
-
}
|
34 |
-
|
35 |
-
/*
|
36 |
-
* displays the item information in a column (default case)
|
37 |
-
*
|
38 |
-
* @since 0.6
|
39 |
-
*
|
40 |
-
* @param array $item
|
41 |
-
* @param string $column_name
|
42 |
-
* @return string
|
43 |
-
*/
|
44 |
-
function column_default($item, $column_name) {
|
45 |
-
return $item[$column_name];
|
46 |
-
}
|
47 |
-
|
48 |
-
/*
|
49 |
-
* displays the checkbox in first column
|
50 |
-
*
|
51 |
-
* @since 1.1
|
52 |
-
*
|
53 |
-
* @param array $item
|
54 |
-
* @return string
|
55 |
-
*/
|
56 |
-
function column_cb($item){
|
57 |
-
return sprintf(
|
58 |
-
'<input type="checkbox" name="strings[]" value="%s" %s />',
|
59 |
-
esc_attr($item['row']),
|
60 |
-
empty($item['icl']) ? 'disabled' : '' // only strings registered with WPML API can be removed
|
61 |
-
);
|
62 |
-
}
|
63 |
-
|
64 |
-
/*
|
65 |
-
* displays the string to translate
|
66 |
-
*
|
67 |
-
* @since 1.0
|
68 |
-
*
|
69 |
-
* @param array $item
|
70 |
-
* @return string
|
71 |
-
*/
|
72 |
-
function column_string($item) {
|
73 |
-
return format_to_edit($item['string']); // don't interpret special chars for the string column
|
74 |
-
}
|
75 |
-
|
76 |
-
/*
|
77 |
-
* displays the translations to edit
|
78 |
-
*
|
79 |
-
* @since 0.6
|
80 |
-
*
|
81 |
-
* @param array $item
|
82 |
-
* @return string
|
83 |
-
*/
|
84 |
-
function column_translations($item) {
|
85 |
-
$out = '';
|
86 |
-
foreach($item['translations'] as $key => $translation) {
|
87 |
-
$input_type = $item['multiline'] ?
|
88 |
-
'<textarea name="translation[%1$s][%2$s]" id="%1$s-%2$s">%4$s</textarea>' :
|
89 |
-
'<input type="text" name="translation[%1$s][%2$s]" id="%1$s-%2$s" value="%4$s" />';
|
90 |
-
$out .= sprintf('<div class="translation"><label for="%1$s-%2$s">%3$s</label>'.$input_type.'</div>'."\n",
|
91 |
-
esc_attr($key),
|
92 |
-
esc_attr($item['row']),
|
93 |
-
esc_html($this->languages[$key]),
|
94 |
-
format_to_edit($translation)); // don't interpret special chars
|
95 |
-
}
|
96 |
-
return $out;
|
97 |
-
}
|
98 |
-
|
99 |
-
/*
|
100 |
-
* gets the list of columns
|
101 |
-
*
|
102 |
-
* @since 0.6
|
103 |
-
*
|
104 |
-
* @return array the list of column titles
|
105 |
-
*/
|
106 |
-
function get_columns() {
|
107 |
-
return array(
|
108 |
-
'cb' => '<input type="checkbox" />', //checkbox
|
109 |
-
'string' => __('String', 'polylang'),
|
110 |
-
'name' => __('Name', 'polylang'),
|
111 |
-
'context' => __('Group', 'polylang'),
|
112 |
-
'translations' => __('Translations', 'polylang'),
|
113 |
-
);
|
114 |
-
}
|
115 |
-
|
116 |
-
/*
|
117 |
-
* gets the list of sortable columns
|
118 |
-
*
|
119 |
-
* @since 0.6
|
120 |
-
*
|
121 |
-
* @return array
|
122 |
-
*/
|
123 |
-
function get_sortable_columns() {
|
124 |
-
return array(
|
125 |
-
'string' => array('string', false),
|
126 |
-
'name' => array('name', false),
|
127 |
-
'context' => array('context', false),
|
128 |
-
);
|
129 |
-
}
|
130 |
-
|
131 |
-
/*
|
132 |
-
* prepares the list of items ofr displaying
|
133 |
-
*
|
134 |
-
* @since 0.6
|
135 |
-
*
|
136 |
-
* @param array $data
|
137 |
-
*/
|
138 |
-
function prepare_items($data = array()) {
|
139 |
-
$per_page = $this->get_items_per_page('pll_strings_per_page');
|
140 |
-
$this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
|
141 |
-
|
142 |
-
function usort_reorder($a, $b){
|
143 |
-
$result = strcmp($a[$_REQUEST['orderby']], $b[$_REQUEST['orderby']]); // determine sort order
|
144 |
-
return (empty($_REQUEST['order']) || $_REQUEST['order'] == 'asc') ? $result : -$result; // send final sort direction to usort
|
145 |
-
};
|
146 |
-
|
147 |
-
if (!empty($_REQUEST['orderby'])) // no sort by default
|
148 |
-
usort($data, 'usort_reorder');
|
149 |
-
|
150 |
-
$total_items = count($data);
|
151 |
-
$this->items = array_slice($data, ($this->get_pagenum() - 1) * $per_page, $per_page);
|
152 |
-
|
153 |
-
$this->set_pagination_args(array(
|
154 |
-
'total_items' => $total_items,
|
155 |
-
'per_page' => $per_page,
|
156 |
-
'total_pages' => ceil($total_items/$per_page)
|
157 |
-
));
|
158 |
-
}
|
159 |
-
|
160 |
-
/*
|
161 |
-
* get the list of possible bulk actions
|
162 |
-
*
|
163 |
-
* @since 1.1
|
164 |
-
*
|
165 |
-
* @return array
|
166 |
-
*/
|
167 |
-
function get_bulk_actions() {
|
168 |
-
return array('delete' => __('Delete','polylang'));
|
169 |
-
}
|
170 |
-
|
171 |
-
/*
|
172 |
-
* displays the dropdown list to filter strings per group
|
173 |
-
*
|
174 |
-
* @since 1.1
|
175 |
-
*
|
176 |
-
* @param string $which only 'top' is supported
|
177 |
-
*/
|
178 |
-
function extra_tablenav($which) {
|
179 |
-
if ('top' != $which)
|
180 |
-
return;
|
181 |
-
|
182 |
-
echo '<div class="alignleft actions">';
|
183 |
-
echo '<select name="group">' . "\n";
|
184 |
-
printf(
|
185 |
-
'<option value="-1"%s>%s</option>' . "\n",
|
186 |
-
$this->group_selected == -1 ? ' selected="selected"' : '',
|
187 |
-
__('View all groups', 'polylang')
|
188 |
-
);
|
189 |
-
|
190 |
-
foreach ($this->groups as $group) {
|
191 |
-
printf(
|
192 |
-
'<option value="%s"%s>%s</option>' . "\n",
|
193 |
-
esc_attr(urlencode($group)),
|
194 |
-
$this->group_selected == $group ? ' selected="selected"' : '',
|
195 |
-
esc_html($group)
|
196 |
-
);
|
197 |
-
}
|
198 |
-
echo '</select>'."\n";
|
199 |
-
|
200 |
-
submit_button( __( 'Filter' ), 'button', false, false, array( 'id' => 'post-query-submit' ) );
|
201 |
-
echo '</div>';
|
202 |
-
}
|
203 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/view-about.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<p><?php
|
2 |
-
printf(
|
3 |
-
__('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 programmers to adapt their plugins and themes.', 'polylang'),
|
4 |
-
'<a href="http://polylang.wordpress.com/documentation/">',
|
5 |
-
'</a>'
|
6 |
-
);
|
7 |
-
echo ' ';
|
8 |
-
printf(
|
9 |
-
__("You will also find useful information in the %ssupport forum%s. However don't forget to make a search before posting a new topic.", 'polylang'),
|
10 |
-
'<a href="http://wordpress.org/support/plugin/polylang">',
|
11 |
-
'</a>'
|
12 |
-
);?>
|
13 |
-
</p>
|
14 |
-
<p><?php
|
15 |
-
printf(
|
16 |
-
__('Polylang is free of charge and is released under the same license as WordPress, the %sGPL%s.', 'polylang'),
|
17 |
-
'<a href="http://wordpress.org/about/gpl/">',
|
18 |
-
'</a>'
|
19 |
-
);
|
20 |
-
echo ' ';
|
21 |
-
printf(
|
22 |
-
__('If you wonder how you can help the project, just %sread this%s.', 'polylang'),
|
23 |
-
'<a href="http://polylang.wordpress.com/documentation/contribute/">',
|
24 |
-
'</a>'
|
25 |
-
);
|
26 |
-
echo ' ';
|
27 |
-
_e('Finally if you like this plugin or if it helps your business, donations to the author are greatly appreciated.', 'polylang')?>
|
28 |
-
</p>
|
29 |
-
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
30 |
-
<input type="hidden" name="cmd" value="_s-xclick">
|
31 |
-
<input type="hidden" name="hosted_button_id" value="CCWWYUUQV8F4E">
|
32 |
-
<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!">
|
33 |
-
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
34 |
-
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/view-languages.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// displays the Languages admin panel
|
3 |
-
?>
|
4 |
-
<div class="wrap"><?php
|
5 |
-
screen_icon('options-general'); ?>
|
6 |
-
|
7 |
-
<h2 class="nav-tab-wrapper"><?php
|
8 |
-
// display tabs
|
9 |
-
foreach ($tabs as $key => $name)
|
10 |
-
printf(
|
11 |
-
'<a href="options-general.php?page=mlang&tab=%1$s" id="nav-tab-%1$s" class="nav-tab %2$s">%3$s</a>',
|
12 |
-
$key,
|
13 |
-
$key == $this->active_tab ? 'nav-tab-active' : '',
|
14 |
-
$name
|
15 |
-
);?>
|
16 |
-
</h2><?php
|
17 |
-
|
18 |
-
switch($this->active_tab) {
|
19 |
-
|
20 |
-
case 'lang': // Languages tab
|
21 |
-
case 'strings': // string translations tab
|
22 |
-
case 'settings': // settings tab
|
23 |
-
include(PLL_ADMIN_INC.'/view-tab-' . $this->active_tab . '.php');
|
24 |
-
break;
|
25 |
-
|
26 |
-
default:
|
27 |
-
do_action('pll_settings_active_tab_' . $this->active_tab);
|
28 |
-
break;
|
29 |
-
}?>
|
30 |
-
|
31 |
-
</div><!-- wrap -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/view-tab-lang.php
DELETED
@@ -1,120 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// displays the languages tab in Polylang settings
|
3 |
-
?>
|
4 |
-
|
5 |
-
<div id="col-container">
|
6 |
-
<div id="col-right">
|
7 |
-
<div class="col-wrap"><?php
|
8 |
-
// displays the language list in a table
|
9 |
-
$list_table->display();?>
|
10 |
-
<div class="metabox-holder"><?php
|
11 |
-
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
12 |
-
do_meta_boxes('settings_page_mlang', 'normal', array());?>
|
13 |
-
</div>
|
14 |
-
</div><!-- col-wrap -->
|
15 |
-
</div><!-- col-right -->
|
16 |
-
|
17 |
-
<div id="col-left">
|
18 |
-
<div class="col-wrap">
|
19 |
-
|
20 |
-
<div class="form-wrap">
|
21 |
-
<h3><?php echo $action=='edit' ? __('Edit language', 'polylang') : __('Add new language', 'polylang'); ?></h3><?php
|
22 |
-
|
23 |
-
// displays the add (or edit) language form
|
24 |
-
// adds noheader=true in the action url to allow using wp_redirect when processing the form ?>
|
25 |
-
<form id="add-lang" method="post" action="admin.php?page=mlang&noheader=true" class="validate">
|
26 |
-
<?php wp_nonce_field('add-lang', '_wpnonce_add-lang');
|
27 |
-
|
28 |
-
if ($action=='edit') {?>
|
29 |
-
<input type="hidden" name="pll_action" value="update" />
|
30 |
-
<input type="hidden" name="lang_id" value="<?php echo esc_attr($edit_lang->term_id);?>" /><?php
|
31 |
-
}
|
32 |
-
else { ?>
|
33 |
-
<input type="hidden" name="pll_action" value="add" /><?php
|
34 |
-
}?>
|
35 |
-
|
36 |
-
<div class="form-field">
|
37 |
-
<label for="lang_list"><?php _e('Choose a language', 'polylang');?></label>
|
38 |
-
<select name="lang_list" id="lang_list">
|
39 |
-
<option value=""></option><?php
|
40 |
-
include(PLL_ADMIN_INC.'/languages.php');
|
41 |
-
foreach ($languages as $lg) {
|
42 |
-
printf(
|
43 |
-
'<option value="%1$s-%2$s-%3$s">%4$s - %2$s</option>'."\n",
|
44 |
-
esc_attr($lg[0]),
|
45 |
-
esc_attr($lg[1]),
|
46 |
-
isset( $lg[3] ) && 'rtl' == $lg[3] ? '1' : '0',
|
47 |
-
esc_html($lg[2])
|
48 |
-
);
|
49 |
-
} ?>
|
50 |
-
</select>
|
51 |
-
<p><?php _e('You can choose a language in the list or directly edit it below.', 'polylang');?></p>
|
52 |
-
</div>
|
53 |
-
|
54 |
-
<div class="form-field form-required">
|
55 |
-
<label for="lang_name"><?php _e('Full name', 'polylang');?></label>
|
56 |
-
<input name="name" id="lang_name" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->name);?>" size="40" aria-required="true" />
|
57 |
-
<p><?php _e('The name is how it is displayed on your site (for example: English).', 'polylang');?></p>
|
58 |
-
</div>
|
59 |
-
|
60 |
-
<div class="form-field form-required">
|
61 |
-
<label for="lang_locale"><?php _e('Locale', 'polylang');?></label><?php
|
62 |
-
printf(
|
63 |
-
'<input name="locale" id="lang_locale" type="text" value="%s" size="40" aria-required="true" />',
|
64 |
-
$action=='edit' ? esc_attr($edit_lang->locale) : ''
|
65 |
-
);?>
|
66 |
-
<p><?php _e('WordPress Locale for the language (for example: en_US). You will need to install the .mo file for this language.', 'polylang');?></p>
|
67 |
-
</div>
|
68 |
-
|
69 |
-
<div class="form-field">
|
70 |
-
<label for="lang_slug"><?php _e('Language code', 'polylang');?></label>
|
71 |
-
<input name="slug" id="lang_slug" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->slug);?>" size="40"/>
|
72 |
-
<p><?php _e('Language code - preferably 2-letters ISO 639-1 (for example: en)', 'polylang');?></p>
|
73 |
-
</div>
|
74 |
-
|
75 |
-
<div class="form-field"><fieldset>
|
76 |
-
<legend><?php _e('Text direction', 'polylang');?></legend><?php
|
77 |
-
printf(
|
78 |
-
'<label><input name="rtl" type="radio" value="0" %s /> %s</label>',
|
79 |
-
$action == 'edit' && $edit_lang->is_rtl ? '' : 'checked="checked"',
|
80 |
-
__('left to right', 'polylang')
|
81 |
-
);
|
82 |
-
printf(
|
83 |
-
'<label><input name="rtl" type="radio" value="1" %s /> %s</label>',
|
84 |
-
$action == 'edit' && $edit_lang->is_rtl ? 'checked="checked"' : '',
|
85 |
-
__('right to left', 'polylang')
|
86 |
-
);?>
|
87 |
-
<p><?php _e('Choose the text direction for the language', 'polylang');?></p>
|
88 |
-
</fieldset></div>
|
89 |
-
|
90 |
-
<div class="form-field">
|
91 |
-
<label for="lang_order"><?php _e('Order', 'polylang');?></label>
|
92 |
-
<input name="term_group" id="lang_order" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->term_group);?>" />
|
93 |
-
<p><?php _e('Position of the language in the language switcher', 'polylang');?></p>
|
94 |
-
</div><?php
|
95 |
-
|
96 |
-
if ( 'edit' == $action ) {
|
97 |
-
do_action( 'pll_language_edit_form_fields', $edit_lang );
|
98 |
-
}
|
99 |
-
else {
|
100 |
-
do_action( 'pll_language_add_form_fields' );
|
101 |
-
}
|
102 |
-
|
103 |
-
submit_button( $action == 'edit' ? __('Update') : __('Add new language', 'polylang')); // since WP 3.1 ?>
|
104 |
-
|
105 |
-
</form>
|
106 |
-
</div><!-- form-wrap -->
|
107 |
-
</div><!-- col-wrap -->
|
108 |
-
</div><!-- col-left -->
|
109 |
-
</div><!-- col-container -->
|
110 |
-
|
111 |
-
<script type="text/javascript">
|
112 |
-
//<![CDATA[
|
113 |
-
jQuery(document).ready( function($) {
|
114 |
-
// close postboxes that should be closed
|
115 |
-
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
116 |
-
// postboxes setup
|
117 |
-
postboxes.add_postbox_toggles('settings_page_mlang');
|
118 |
-
});
|
119 |
-
//]]>
|
120 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/view-tab-settings.php
DELETED
@@ -1,233 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// displays the settings tab in Polylang settings
|
3 |
-
|
4 |
-
$content_with_no_languages = $this->model->get_objects_with_no_lang() && $this->options['default_lang'];
|
5 |
-
$page_on_front = 'page' == get_option('show_on_front') ? get_option('page_on_front') : 0; ?>
|
6 |
-
|
7 |
-
<form id="options-lang" method="post" action="admin.php?page=mlang&tab=settings&noheader=true" class="validate">
|
8 |
-
<?php wp_nonce_field('options-lang', '_wpnonce_options-lang');?>
|
9 |
-
<input type="hidden" name="pll_action" value="options" />
|
10 |
-
|
11 |
-
<table class="form-table">
|
12 |
-
<tr>
|
13 |
-
<th <?php echo $content_with_no_languages ? 'rowspan=2' : ''; ?>>
|
14 |
-
<label for='default_lang'><?php _e('Default language', 'polylang');?></label>
|
15 |
-
</th>
|
16 |
-
<td><?php
|
17 |
-
$dropdown = new PLL_Walker_Dropdown;
|
18 |
-
echo $dropdown->walk($listlanguages, array('name' => 'default_lang', 'selected' => $this->options['default_lang']));?>
|
19 |
-
</td>
|
20 |
-
</tr><?php
|
21 |
-
|
22 |
-
// posts or terms without language set
|
23 |
-
if ($content_with_no_languages) {?>
|
24 |
-
<tr>
|
25 |
-
<td>
|
26 |
-
<label style="color: red"><?php
|
27 |
-
printf(
|
28 |
-
'<input name="fill_languages" type="checkbox" value="1" /> %s',
|
29 |
-
__('There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?', 'polylang')
|
30 |
-
);?>
|
31 |
-
</label>
|
32 |
-
</td>
|
33 |
-
</tr><?php
|
34 |
-
}?>
|
35 |
-
|
36 |
-
<tr>
|
37 |
-
<th rowspan = <?php echo ($page_on_front ? 3 : 2) + $this->links_model->using_permalinks; ?>><?php _e('URL modifications', 'polylang') ?></th>
|
38 |
-
<td><fieldset id='pll-force-lang'>
|
39 |
-
<label><?php
|
40 |
-
printf(
|
41 |
-
'<input name="force_lang" type="radio" value="0" %s /> %s',
|
42 |
-
$this->options['force_lang'] ? '' : 'checked="checked"',
|
43 |
-
__('The language is set from content', 'polylang')
|
44 |
-
);?>
|
45 |
-
</label>
|
46 |
-
<p class="description"><?php _e('Posts, pages, categories and tags urls are not modified.', 'polylang');?></p>
|
47 |
-
<label><?php
|
48 |
-
printf(
|
49 |
-
'<input name="force_lang" type="radio" value="1" %s/> %s',
|
50 |
-
1 == $this->options['force_lang'] ? 'checked="checked"' : '',
|
51 |
-
$this->links_model->using_permalinks ? __('The language is set from the directory name in pretty permalinks', 'polylang') : __('The language is set from the code in the URL', 'polylang')
|
52 |
-
);?>
|
53 |
-
</label>
|
54 |
-
<p class="description"><?php echo __('Example:', 'polylang') . ' <code>'.esc_html(home_url($this->links_model->using_permalinks ? 'en/my-post/' : '?lang=en&p=1')).'</code>';?></p>
|
55 |
-
<label><?php
|
56 |
-
printf(
|
57 |
-
'<input name="force_lang" type="radio" value="2" %s %s/> %s',
|
58 |
-
$this->links_model->using_permalinks ? '' : 'disabled="disabled"',
|
59 |
-
2 == $this->options['force_lang'] ? 'checked="checked"' : '',
|
60 |
-
__('The language is set from the subdomain name in pretty permalinks', 'polylang')
|
61 |
-
);?>
|
62 |
-
</label>
|
63 |
-
<p class="description"><?php echo __('Example:', 'polylang') . ' <code>'.esc_html(str_replace(array('://', 'www.'), array('://en.', ''), home_url('my-post/'))).'</code>';?></p>
|
64 |
-
<label><?php
|
65 |
-
printf(
|
66 |
-
'<input name="force_lang" type="radio" value="3" %s %s/> %s',
|
67 |
-
$this->links_model->using_permalinks ? '' : 'disabled="disabled"',
|
68 |
-
3 == $this->options['force_lang'] ? 'checked="checked"' : '',
|
69 |
-
__('The language is set from different domains', 'polylang')
|
70 |
-
);?>
|
71 |
-
</label>
|
72 |
-
<table id="pll-domains-table" <?php echo 3 == $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>><?php
|
73 |
-
foreach ($listlanguages as $lg) {
|
74 |
-
printf(
|
75 |
-
'<tr><td><label for="pll-domain[%1$s]">%2$s</label></td>' .
|
76 |
-
'<td><input name="domains[%1$s]" id="pll-domain[%1$s]" type="text" value="%3$s" size="40" aria-required="true" /></td></tr>',
|
77 |
-
esc_attr($lg->slug),
|
78 |
-
esc_attr($lg->name),
|
79 |
-
esc_url(isset($this->options['domains'][$lg->slug]) ? $this->options['domains'][$lg->slug] : ($lg->slug == $this->options['default_lang'] ? $this->links_model->home : ''))
|
80 |
-
);
|
81 |
-
}?>
|
82 |
-
</table>
|
83 |
-
</fieldset></td>
|
84 |
-
</tr>
|
85 |
-
|
86 |
-
<tr>
|
87 |
-
<td id="pll-hide-default" <?php echo 3 > $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>><fieldset>
|
88 |
-
<label><?php
|
89 |
-
printf(
|
90 |
-
'<input name="hide_default" type="checkbox" value="1" %s /> %s',
|
91 |
-
$this->options['hide_default'] ? 'checked="checked"' :'',
|
92 |
-
__('Hide URL language information for default language', 'polylang')
|
93 |
-
);?>
|
94 |
-
</label>
|
95 |
-
</fieldset></td>
|
96 |
-
</tr><?php
|
97 |
-
|
98 |
-
if ($this->links_model->using_permalinks) { ?>
|
99 |
-
<tr>
|
100 |
-
<td id="pll-rewrite" <?php echo 2 > $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>><fieldset>
|
101 |
-
<label><?php
|
102 |
-
printf(
|
103 |
-
'<input name="rewrite" type="radio" value="1" %s %s/> %s',
|
104 |
-
$this->links_model->using_permalinks ? '' : 'disabled="disabled"',
|
105 |
-
$this->options['rewrite'] ? 'checked="checked"' : '',
|
106 |
-
__('Remove /language/ in pretty permalinks', 'polylang')
|
107 |
-
);?>
|
108 |
-
</label>
|
109 |
-
<p class="description"><?php echo __('Example:', 'polylang') . ' <code>'.esc_html(home_url('en/')).'</code>';?></p>
|
110 |
-
<label><?php
|
111 |
-
printf(
|
112 |
-
'<input name="rewrite" type="radio" value="0" %s %s/> %s',
|
113 |
-
$this->links_model->using_permalinks ? '' : 'disabled="disabled"',
|
114 |
-
$this->options['rewrite'] ? '' : 'checked="checked"',
|
115 |
-
__('Keep /language/ in pretty permalinks', 'polylang')
|
116 |
-
);?>
|
117 |
-
</label>
|
118 |
-
<p class="description"><?php echo __('Example:', 'polylang') . ' <code>'.esc_html(home_url('language/en/')).'</code>';?></p>
|
119 |
-
</fieldset></td>
|
120 |
-
</tr><?php
|
121 |
-
}
|
122 |
-
|
123 |
-
if ($page_on_front) { ?>
|
124 |
-
<tr>
|
125 |
-
<td><fieldset>
|
126 |
-
<label><?php
|
127 |
-
printf(
|
128 |
-
'<input name="redirect_lang" type="checkbox" value="1" %s/> %s',
|
129 |
-
$this->options['redirect_lang'] ? 'checked="checked"' :'',
|
130 |
-
__('The front page url contains the language code instead of the page name or page id', 'polylang')
|
131 |
-
);?>
|
132 |
-
</label>
|
133 |
-
<p class="description"><?php
|
134 |
-
// that's nice to display the right home urls but don't forget that the page on front may have no language yet
|
135 |
-
$lang = $this->model->get_post_language($page_on_front);
|
136 |
-
$lang = $lang ? $lang : $this->model->get_language($this->options['default_lang']);
|
137 |
-
printf(
|
138 |
-
__('Example: %s instead of %s', 'polylang'),
|
139 |
-
'<code>' . esc_html($this->links_model->home_url($lang)) . '</code>',
|
140 |
-
'<code>' . esc_html(_get_page_link($page_on_front)) . '</code>'
|
141 |
-
); ?>
|
142 |
-
</p>
|
143 |
-
</fieldset></td>
|
144 |
-
</tr><?php
|
145 |
-
} ?>
|
146 |
-
|
147 |
-
<tr id="pll-detect-browser" <?php echo 3 > $this->options['force_lang'] ? '' : 'style="display: none;"'; ?>>
|
148 |
-
<th><?php _e('Detect browser language', 'polylang');?></th>
|
149 |
-
<td>
|
150 |
-
<label><?php
|
151 |
-
printf(
|
152 |
-
'<input name="browser" type="checkbox" value="1" %s /> %s',
|
153 |
-
$this->options['browser'] ? 'checked="checked"' :'',
|
154 |
-
__('When the front page is visited, set the language according to the browser preference', 'polylang')
|
155 |
-
);?>
|
156 |
-
</label>
|
157 |
-
</td>
|
158 |
-
</tr>
|
159 |
-
|
160 |
-
<tr>
|
161 |
-
<th scope="row"><?php _e('Media', 'polylang') ?></th>
|
162 |
-
<td>
|
163 |
-
<label><?php
|
164 |
-
printf(
|
165 |
-
'<input name="media_support" type="checkbox" value="1" %s /> %s',
|
166 |
-
$this->options['media_support'] ? 'checked="checked"' :'',
|
167 |
-
__('Activate languages and translations for media', 'polylang')
|
168 |
-
);?>
|
169 |
-
</label>
|
170 |
-
</td>
|
171 |
-
</tr><?php
|
172 |
-
|
173 |
-
if (!empty($post_types)) {?>
|
174 |
-
<tr>
|
175 |
-
<th scope="row"><?php _e('Custom post types', 'polylang') ?></th>
|
176 |
-
<td>
|
177 |
-
<ul class="pll_inline_block"><?php
|
178 |
-
foreach ($post_types as $post_type) {
|
179 |
-
$pt = get_post_type_object($post_type);
|
180 |
-
printf(
|
181 |
-
'<li><label><input name="post_types[%s]" type="checkbox" value="1" %s /> %s</label></li>',
|
182 |
-
esc_attr($post_type),
|
183 |
-
in_array($post_type, $this->options['post_types']) ? 'checked="checked"' :'',
|
184 |
-
esc_html($pt->labels->name)
|
185 |
-
);
|
186 |
-
}?>
|
187 |
-
</ul>
|
188 |
-
<p class="description"><?php _e('Activate languages and translations for custom post types.', 'polylang');?></p>
|
189 |
-
</td>
|
190 |
-
</tr><?php
|
191 |
-
}
|
192 |
-
|
193 |
-
if (!empty($taxonomies)) {?>
|
194 |
-
<tr>
|
195 |
-
<th scope="row"><?php _e('Custom taxonomies', 'polylang') ?></th>
|
196 |
-
<td>
|
197 |
-
<ul class="pll_inline_block"><?php
|
198 |
-
foreach ($taxonomies as $taxonomy) {
|
199 |
-
$tax = get_taxonomy($taxonomy);
|
200 |
-
printf(
|
201 |
-
'<li><label><input name="taxonomies[%s]" type="checkbox" value="1" %s /> %s</label></li>',
|
202 |
-
esc_attr($taxonomy),
|
203 |
-
in_array($taxonomy, $this->options['taxonomies']) ? 'checked="checked"' :'',
|
204 |
-
esc_html($tax->labels->name)
|
205 |
-
);
|
206 |
-
}?>
|
207 |
-
</ul>
|
208 |
-
<p class="description"><?php _e('Activate languages and translations for custom taxonomies.', 'polylang');?></p>
|
209 |
-
</td>
|
210 |
-
</tr><?php
|
211 |
-
}?>
|
212 |
-
|
213 |
-
<tr>
|
214 |
-
<th scope="row"><?php _e('Synchronization', 'polylang') ?></th>
|
215 |
-
<td>
|
216 |
-
<ul class="pll_inline_block"><?php
|
217 |
-
foreach (self::list_metas_to_sync() as $key => $str)
|
218 |
-
printf(
|
219 |
-
'<li><label><input name="sync[%s]" type="checkbox" value="1" %s /> %s</label></li>',
|
220 |
-
esc_attr($key),
|
221 |
-
in_array($key, $this->options['sync']) ? 'checked="checked"' :'',
|
222 |
-
esc_html($str)
|
223 |
-
);?>
|
224 |
-
</ul>
|
225 |
-
<p class="description"><?php _e('The synchronization options allow to maintain exact same values (or translations in the case of taxonomies and page parent) of meta content between the translations of a post or page.', 'polylang');?></p>
|
226 |
-
</td>
|
227 |
-
</tr>
|
228 |
-
|
229 |
-
</table>
|
230 |
-
|
231 |
-
<?php submit_button(); // since WP 3.1 ?>
|
232 |
-
|
233 |
-
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/view-tab-strings.php
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// displays the strings translations tab in Polylang settings
|
3 |
-
?>
|
4 |
-
|
5 |
-
<div class="form-wrap">
|
6 |
-
<form id="string-translation" method="post" action="admin.php?page=mlang&tab=strings&noheader=true">
|
7 |
-
<input type="hidden" name="pll_action" value="string-translation" /><?php
|
8 |
-
$string_table->search_box(__('Search translations', 'polylang'), 'translations' );
|
9 |
-
wp_nonce_field('string-translation', '_wpnonce_string-translation');
|
10 |
-
$string_table->display();
|
11 |
-
printf('<br /><label><input name="clean" type="checkbox" value="1" /> %s</label>', __('Clean strings translation database', 'polylang')); ?>
|
12 |
-
<p><?php _e('Use this to remove unused strings from database, for example after a plugin has been uninstalled.', 'polylang');?></p><?php
|
13 |
-
submit_button(); // since WP 3.1 ?>
|
14 |
-
</form>
|
15 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/view-translations-media.php
CHANGED
@@ -1,34 +1,37 @@
|
|
1 |
<?php
|
2 |
-
// needs WP 3.5+
|
3 |
-
?>
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
<table><?php
|
7 |
-
foreach ($this->model->get_languages_list() as $language) {
|
8 |
-
if ($language->term_id == $lang->term_id)
|
9 |
-
continue
|
|
|
10 |
|
11 |
<tr>
|
12 |
-
<td class = "pll-media-language-column"><span class = "pll-translation-flag"><?php echo $language->flag?></span><?php echo esc_html($language->name); ?></td>
|
13 |
<td class = "pll-media-edit-column"><?php
|
14 |
// the translation exists
|
15 |
-
if (($translation_id = $this->model->get_translation(
|
16 |
printf(
|
17 |
-
'<input type="hidden" name="media_tr_lang[%s]" value="%d"
|
18 |
-
esc_attr($language->slug),
|
19 |
-
esc_attr($translation_id),
|
20 |
-
|
21 |
-
__('Edit','polylang')
|
22 |
);
|
23 |
}
|
24 |
|
25 |
// no translation
|
26 |
else {
|
27 |
-
|
28 |
-
'<a href="%s" title="%s" class="pll_icon_add"></a>',
|
29 |
-
esc_url($this->links->get_new_post_translation_link($post_id, $language)),
|
30 |
-
__('Add new','polylang')
|
31 |
-
);
|
32 |
}?>
|
33 |
</td>
|
34 |
</tr><?php
|
1 |
<?php
|
|
|
|
|
2 |
|
3 |
+
/*
|
4 |
+
* displays the translations fields for media
|
5 |
+
* needs WP 3.5+
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // don't access directly
|
10 |
+
};
|
11 |
+
?>
|
12 |
+
<p><strong><?php _e( 'Translations', 'polylang' );?></strong></p>
|
13 |
<table><?php
|
14 |
+
foreach ( $this->model->get_languages_list() as $language ) {
|
15 |
+
if ( $language->term_id == $lang->term_id ) {
|
16 |
+
continue;
|
17 |
+
}?>
|
18 |
|
19 |
<tr>
|
20 |
+
<td class = "pll-media-language-column"><span class = "pll-translation-flag"><?php echo $language->flag; ?></span><?php echo esc_html( $language->name ); ?></td>
|
21 |
<td class = "pll-media-edit-column"><?php
|
22 |
// the translation exists
|
23 |
+
if ( ( $translation_id = $this->model->post->get_translation( $post_id, $language ) ) && $translation_id !== $post_id ) {
|
24 |
printf(
|
25 |
+
'<input type="hidden" name="media_tr_lang[%s]" value="%d" />%s',
|
26 |
+
esc_attr( $language->slug ),
|
27 |
+
esc_attr( $translation_id ),
|
28 |
+
$this->links->edit_post_translation_link( $translation_id )
|
|
|
29 |
);
|
30 |
}
|
31 |
|
32 |
// no translation
|
33 |
else {
|
34 |
+
echo $this->links->new_post_translation_link( $post_id, $language );
|
|
|
|
|
|
|
|
|
35 |
}?>
|
36 |
</td>
|
37 |
</tr><?php
|
admin/view-translations-post.php
CHANGED
@@ -1,42 +1,51 @@
|
|
1 |
<?php
|
2 |
-
// displays the translations fields
|
3 |
-
?>
|
4 |
|
5 |
-
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
continue;
|
|
|
11 |
|
12 |
-
$value = $this->model->get_translation(
|
13 |
-
if (
|
14 |
$value = '';
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
17 |
|
18 |
-
$link = $add_link =
|
19 |
-
'<a href="%1$s" class="pll_icon_add" title="%2$s"></a>',
|
20 |
-
esc_url($this->links->get_new_post_translation_link($post_ID, $language)),
|
21 |
-
__('Add new', 'polylang')
|
22 |
-
);
|
23 |
|
24 |
-
if ($value) {
|
25 |
-
$selected = get_post($value);
|
26 |
-
$link = $this->
|
27 |
} ?>
|
28 |
|
29 |
<tr>
|
30 |
-
<
|
31 |
<td class = "hidden"><?php echo $add_link;?></td>
|
32 |
<td class = "pll-edit-column"><?php echo $link;?></td>
|
33 |
<td class = "pll-translation-column"><?php
|
34 |
-
printf('
|
35 |
-
<
|
36 |
-
<input type="
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
40 |
); ?>
|
41 |
</td>
|
42 |
</tr><?php
|
1 |
<?php
|
|
|
|
|
2 |
|
3 |
+
/*
|
4 |
+
* displays the translations fields for posts
|
5 |
+
*/
|
6 |
|
7 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
+
exit; // don't access directly
|
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 ) {
|
16 |
continue;
|
17 |
+
}
|
18 |
|
19 |
+
$value = $this->model->post->get_translation( $post_ID, $language );
|
20 |
+
if ( ! $value || $value == $post_ID ) { // $value == $post_ID happens if the post has been ( auto )saved before changing the language
|
21 |
$value = '';
|
22 |
+
}
|
23 |
+
|
24 |
+
if ( isset( $_GET['from_post'] ) ) {
|
25 |
+
$value = $this->model->post->get( (int) $_GET['from_post'], $language );
|
26 |
+
}
|
27 |
|
28 |
+
$link = $add_link = $this->links->new_post_translation_link( $post_ID, $language );
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
if ( $value ) {
|
31 |
+
$selected = get_post( $value );
|
32 |
+
$link = $this->links->edit_post_translation_link( $value );
|
33 |
} ?>
|
34 |
|
35 |
<tr>
|
36 |
+
<th class = "pll-language-column"><?php echo $language->flag ? $language->flag : esc_html( $language->slug ); ?></th>
|
37 |
<td class = "hidden"><?php echo $add_link;?></td>
|
38 |
<td class = "pll-edit-column"><?php echo $link;?></td>
|
39 |
<td class = "pll-translation-column"><?php
|
40 |
+
printf( '
|
41 |
+
<label class="screen-reader-text" for="tr_lang_%1$s">%2$s</label>
|
42 |
+
<input type="hidden" name="post_tr_lang[%1$s]" id="htr_lang_%1$s" value="%3$s"/>
|
43 |
+
<input type="text" class="tr_lang" id="tr_lang_%1$s" value="%4$s"%5$s>',
|
44 |
+
esc_attr( $language->slug ),
|
45 |
+
__( 'Translation', 'polylang' ),
|
46 |
+
empty( $value ) ? 0 : esc_attr( $selected->ID ),
|
47 |
+
empty( $value ) ? '' : esc_attr( $selected->post_title ),
|
48 |
+
empty( $link ) ? ' disabled="disabled"' : ''
|
49 |
); ?>
|
50 |
</td>
|
51 |
</tr><?php
|
admin/view-translations-term.php
CHANGED
@@ -1,66 +1,76 @@
|
|
1 |
<?php
|
2 |
-
// displays the translations fields
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
// edit term form?>
|
6 |
-
<th scope="row"><?php _e('Translations', 'polylang')
|
7 |
<td><?php
|
8 |
}
|
9 |
else {
|
10 |
// add term form?>
|
11 |
-
<
|
12 |
}?>
|
13 |
-
<table class="widefat term-translations" id="<?php echo isset($term_id) ? 'edit' : 'add'; ?>-term-translations"><?php
|
14 |
-
foreach ($this->model->get_languages_list() as $language) {
|
15 |
-
if ($language->term_id == $lang->term_id)
|
16 |
continue;
|
|
|
17 |
|
18 |
// look for any existing translation in this language
|
19 |
// take care not ot propose a self link
|
20 |
$translation = 0;
|
21 |
-
if (isset($term_id) && ($translation_id = $this->model->get_translation(
|
22 |
-
$translation = get_term($translation_id, $taxonomy);
|
23 |
-
|
24 |
-
|
|
|
|
|
25 |
|
26 |
-
if (isset($term_id)) { // do not display the add new link in add term form ($term_id not set !!!)
|
27 |
-
$link = $add_link =
|
28 |
-
'<a href="%1$s" class="pll_icon_add" title="%2$s"></a>',
|
29 |
-
esc_url($this->links->get_new_term_translation_link($term_id, $taxonomy, $post_type, $language)),
|
30 |
-
__('Add new','polylang')
|
31 |
-
);
|
32 |
}
|
33 |
|
34 |
-
if ($translation) {
|
35 |
-
$link = $this->
|
36 |
} ?>
|
37 |
|
38 |
<tr>
|
39 |
-
<
|
40 |
<span class = "pll-translation-flag"><?php echo $language->flag; ?></span><?php
|
41 |
-
|
42 |
-
<span class
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
46 |
<td class = "hidden"><?php echo $add_link;?></td>
|
47 |
<td class = "pll-edit-column"><?php echo $link;?></td><?php
|
48 |
} ?>
|
49 |
<td class = "pll-translation-column"><?php
|
50 |
-
printf('
|
51 |
-
<
|
52 |
-
<input type="
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
empty($
|
|
|
|
|
57 |
); ?>
|
58 |
</td>
|
59 |
</tr><?php
|
60 |
} // foreach ?>
|
61 |
</table><?php
|
62 |
|
63 |
-
if (isset($term_id)) {
|
64 |
// edit term form?>
|
65 |
</td><?php
|
66 |
}
|
1 |
<?php
|
|
|
2 |
|
3 |
+
/*
|
4 |
+
* displays the translations fields for terms
|
5 |
+
*/
|
6 |
+
|
7 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
+
exit; // don't access directly
|
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
|
21 |
+
foreach ( $this->model->get_languages_list() as $language ) {
|
22 |
+
if ( $language->term_id == $lang->term_id ) {
|
23 |
continue;
|
24 |
+
}
|
25 |
|
26 |
// look for any existing translation in this language
|
27 |
// take care not ot propose a self link
|
28 |
$translation = 0;
|
29 |
+
if ( isset( $term_id ) && ( $translation_id = $this->model->term->get_translation( $term_id, $language ) ) && $translation_id != $term_id ) {
|
30 |
+
$translation = get_term( $translation_id, $taxonomy );
|
31 |
+
}
|
32 |
+
if ( isset( $_GET['from_tag'] ) && ( $translation_id = $this->model->term->get( (int) $_GET['from_tag'], $language ) ) && ! $this->model->term->get_translation( $translation_id, $lang ) ) {
|
33 |
+
$translation = get_term( $translation_id, $taxonomy );
|
34 |
+
}
|
35 |
|
36 |
+
if ( isset( $term_id ) ) { // do not display the add new link in add term form ( $term_id not set !!! )
|
37 |
+
$link = $add_link = $this->links->new_term_translation_link( $term_id, $taxonomy, $post_type, $language );
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
+
if ( $translation ) {
|
41 |
+
$link = $this->links->edit_term_translation_link( $translation->term_id, $taxonomy, $post_type );
|
42 |
} ?>
|
43 |
|
44 |
<tr>
|
45 |
+
<th class = "pll-language-column">
|
46 |
<span class = "pll-translation-flag"><?php echo $language->flag; ?></span><?php
|
47 |
+
printf(
|
48 |
+
'<span class="pll-language-name%1$s">%2$s</span>',
|
49 |
+
isset( $term_id ) ? '' : ' screen-reader-text',
|
50 |
+
esc_html( $language->name )
|
51 |
+
); ?>
|
52 |
+
</th> <?php
|
53 |
+
if ( isset( $term_id ) ) { ?>
|
54 |
<td class = "hidden"><?php echo $add_link;?></td>
|
55 |
<td class = "pll-edit-column"><?php echo $link;?></td><?php
|
56 |
} ?>
|
57 |
<td class = "pll-translation-column"><?php
|
58 |
+
printf( '
|
59 |
+
<label class="screen-reader-text" for="tr_lang_%1$s">%2$s</label>
|
60 |
+
<input type="hidden" class="htr_lang" name="term_tr_lang[%1$s]" id="htr_lang_%1$s" value="%3$s"/>
|
61 |
+
<input type="text" class="tr_lang" id="tr_lang_%1$s" value="%4$s"%5$s>',
|
62 |
+
esc_attr( $language->slug ),
|
63 |
+
__( 'Translation', 'polylang' ),
|
64 |
+
empty( $translation ) ? 0 : esc_attr( $translation->term_id ),
|
65 |
+
empty( $translation ) ? '' : esc_attr( $translation->name ),
|
66 |
+
empty( $disabled ) ? '' : ' disabled="disabled"'
|
67 |
); ?>
|
68 |
</td>
|
69 |
</tr><?php
|
70 |
} // foreach ?>
|
71 |
</table><?php
|
72 |
|
73 |
+
if ( isset( $term_id ) ) {
|
74 |
// edit term form?>
|
75 |
</td><?php
|
76 |
}
|
admin/wp-import.php
DELETED
@@ -1,172 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* a class to import languages and translations information form a WXR file
|
5 |
-
*
|
6 |
-
* @since 1.2
|
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
|
15 |
-
*/
|
16 |
-
function process_terms() {
|
17 |
-
$term_translations = array();
|
18 |
-
|
19 |
-
// store this for future usage as parent function unsets $this->terms
|
20 |
-
foreach ($this->terms as $term) {
|
21 |
-
if ('post_translations' == $term['term_taxonomy'])
|
22 |
-
$this->post_translations[] = $term;
|
23 |
-
if ('term_translations' == $term['term_taxonomy'])
|
24 |
-
$term_translations[] = $term;
|
25 |
-
}
|
26 |
-
|
27 |
-
parent::process_terms();
|
28 |
-
|
29 |
-
global $polylang;
|
30 |
-
$polylang->model->clean_languages_cache(); // to update the languages list if needed
|
31 |
-
|
32 |
-
if (($options = get_option('polylang')) && empty($options['default_lang']) && ($languages = $polylang->model->get_languages_list())) {
|
33 |
-
// assign the default language if importer created the first language
|
34 |
-
$default_lang = reset($languages);
|
35 |
-
$options['default_lang'] = $default_lang->slug;
|
36 |
-
update_option('polylang', $options);
|
37 |
-
}
|
38 |
-
|
39 |
-
$this->remap_terms_relations($term_translations);
|
40 |
-
$this->remap_translations($term_translations, $this->processed_terms);
|
41 |
-
}
|
42 |
-
|
43 |
-
/*
|
44 |
-
* overrides WP_Import::process_post to remap posts translations
|
45 |
-
* also merges strings translations from the WXR file to the existing ones
|
46 |
-
*
|
47 |
-
* @since 1.2
|
48 |
-
*/
|
49 |
-
function process_posts() {
|
50 |
-
$menu_items = $mo_posts = array();
|
51 |
-
|
52 |
-
// store this for future usage as parent function unset $this->posts
|
53 |
-
foreach ($this->posts as $post) {
|
54 |
-
if ('nav_menu_item' == $post['post_type'])
|
55 |
-
$menu_items[] = $post;
|
56 |
-
|
57 |
-
if (0 === strpos($post['post_title'], 'polylang_mo_'))
|
58 |
-
$mo_posts[] = $post;
|
59 |
-
}
|
60 |
-
|
61 |
-
if (!empty($mo_posts))
|
62 |
-
new PLL_MO(); // just to register the polylang_mo post type before processing posts
|
63 |
-
|
64 |
-
parent::process_posts();
|
65 |
-
|
66 |
-
global $polylang;
|
67 |
-
$polylang->model->clean_languages_cache(); // to update the posts count in (cached) languages list
|
68 |
-
|
69 |
-
$this->remap_translations($this->post_translations, $this->processed_posts);
|
70 |
-
unset($this->post_translations);
|
71 |
-
|
72 |
-
// language switcher menu items
|
73 |
-
foreach ($menu_items as $item) {
|
74 |
-
foreach ($item['postmeta'] as $meta) {
|
75 |
-
if ('_pll_menu_item' == $meta['key'])
|
76 |
-
update_post_meta($this->processed_menu_items[$item['post_id']], '_pll_menu_item', maybe_unserialize($meta['value']));
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
// merge strings translations
|
81 |
-
foreach ($mo_posts as $post) {
|
82 |
-
$lang_id = (int) substr($post['post_title'], 12);
|
83 |
-
|
84 |
-
if (!empty($this->processed_terms[$lang_id])) {
|
85 |
-
if ($strings = unserialize($post['post_content'])) {
|
86 |
-
$mo = new PLL_MO();
|
87 |
-
$mo->import_from_db($this->processed_terms[$lang_id]);
|
88 |
-
foreach ($strings as $msg)
|
89 |
-
$mo->add_entry_or_merge($mo->make_entry($msg[0], $msg[1]));
|
90 |
-
$mo->export_to_db($this->processed_terms[$lang_id]);
|
91 |
-
}
|
92 |
-
}
|
93 |
-
// delete the now useless imported post
|
94 |
-
wp_delete_post($this->processed_posts[$post['post_id']], true);
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
/*
|
99 |
-
* remaps terms languages
|
100 |
-
*
|
101 |
-
* @since 1.2
|
102 |
-
*
|
103 |
-
* @param array $terms array of terms in 'term_translations' taxonomy
|
104 |
-
*/
|
105 |
-
function remap_terms_relations(&$terms){
|
106 |
-
global $polylang, $wpdb;
|
107 |
-
|
108 |
-
foreach ($terms as $term) {
|
109 |
-
$translations = unserialize($term['term_description']);
|
110 |
-
foreach($translations as $slug => $old_id)
|
111 |
-
if ($old_id && !empty($this->processed_terms[$old_id]) && $lang = $polylang->model->get_language($slug)) {
|
112 |
-
// language relationship
|
113 |
-
$trs[] = $wpdb->prepare('(%d, %d)', $this->processed_terms[$old_id], $lang->tl_term_taxonomy_id);
|
114 |
-
|
115 |
-
// translation relationship
|
116 |
-
$trs[] = $wpdb->prepare('(%d, %d)', $this->processed_terms[$old_id], get_term($this->processed_terms[$term['term_id']], 'term_translations')->term_taxonomy_id );
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
// insert term_relationships
|
121 |
-
if (!empty($trs)) {
|
122 |
-
$trs = array_unique($trs);
|
123 |
-
|
124 |
-
// make sure we don't attempt to insert already existing term relationships
|
125 |
-
$existing_trs = $wpdb->get_results("
|
126 |
-
SELECT tr.object_id, tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr
|
127 |
-
INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
|
128 |
-
WHERE tt.taxonomy IN ('term_language', 'term_translations')
|
129 |
-
");
|
130 |
-
|
131 |
-
foreach ($existing_trs as $key => $tr)
|
132 |
-
$existing_trs[$key] = $wpdb->prepare('(%d, %d)', $tr->object_id, $tr->term_taxonomy_id);
|
133 |
-
|
134 |
-
$trs = array_diff($trs, $existing_trs);
|
135 |
-
|
136 |
-
if (!empty($trs))
|
137 |
-
$wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES " . implode(',', $trs));
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
/*
|
142 |
-
* remaps translations for both posts and terms
|
143 |
-
*
|
144 |
-
* @since 1.2
|
145 |
-
*
|
146 |
-
* @param array $terms array of terms in 'post_translations' or 'term_translations' taxonomies
|
147 |
-
* @param array $processed_objects array of posts or terms processed by WordPress Importer
|
148 |
-
*/
|
149 |
-
function remap_translations(&$terms, &$processed_objects) {
|
150 |
-
global $wpdb;
|
151 |
-
|
152 |
-
foreach ($terms as $term) {
|
153 |
-
$translations = unserialize($term['term_description']);
|
154 |
-
$new_translations = array();
|
155 |
-
|
156 |
-
foreach($translations as $slug => $old_id)
|
157 |
-
if ($old_id && !empty($processed_objects[$old_id]))
|
158 |
-
$new_translations[$slug] = $processed_objects[$old_id];
|
159 |
-
|
160 |
-
if (!empty($new_translations)) {
|
161 |
-
$u['case'][] = $wpdb->prepare('WHEN %d THEN %s', $this->processed_terms[$term['term_id']], serialize($new_translations));
|
162 |
-
$u['in'][] = (int) $this->processed_terms[$term['term_id']];
|
163 |
-
}
|
164 |
-
}
|
165 |
-
|
166 |
-
if (!empty($u)) {
|
167 |
-
$wpdb->query("UPDATE $wpdb->term_taxonomy
|
168 |
-
SET description = ( CASE term_id " . implode(' ', $u['case']) . " END )
|
169 |
-
WHERE term_id IN ( " . implode(',', $u['in']) . " )");
|
170 |
-
}
|
171 |
-
}
|
172 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
changelog.txt
CHANGED
@@ -2,6 +2,162 @@
|
|
2 |
|
3 |
This file contains only old changelog. See readme.txt for newer versions.
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
= 1.6.5 (2015-02-18) =
|
6 |
|
7 |
* Add new correspondances between WordPress locales and Facebook locales (for WPSEO and Jetpack users)
|
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
|
8 |
+
* fix: nav menus locations are not correctly populated in customizer in WP 4.4
|
9 |
+
* fix: the termmeta table was still deleted at upgrade
|
10 |
+
* fix: fatal error when using the argument 'post_id' in 'pll_the_languages()' (introduced in 1.7.11) [props EKesty](https://wordpress.org/support/topic/bug-on)
|
11 |
+
* fix: potential notice in 'pll_the_languages()' [props mattkeys](https://wordpress.org/support/topic/bug-on)
|
12 |
+
|
13 |
+
= 1.7.11 (2015-10-15) =
|
14 |
+
|
15 |
+
* fix: conflict with GET ajax requests sent by the jquery method load
|
16 |
+
* fix: notice in frontend-nav-menu.php at line 211 (introduced in 1.7.10) [props Jesse Graupmann](https://wordpress.org/support/topic/warning-and-notice-on-upgrade)
|
17 |
+
* fix: the parent list in page attributes metabox is not in the correct language (introduced in 1.7.10)
|
18 |
+
* fix: error 404 for attachments
|
19 |
+
* fix: the language switcher is not displayed when combining "Forces link to front page" and "Hides languages with no translation"
|
20 |
+
|
21 |
+
= 1.7.10 (2015-09-28) =
|
22 |
+
|
23 |
+
* Add Occitan translation contributed by [Cédric Valmary](http://www.totenoc.eu/)
|
24 |
+
* Add de_DE_formal, en_NZ, es_CO, hy, oci, ps and tl to the predefined languages list
|
25 |
+
* Add the filter 'pll_predefined_languages' and the actions 'pll_language_edit_form_fields' and 'pll_language_add_form_fields'
|
26 |
+
* the termmeta table (used in Polylang < 1.2) is no more deleted when uninstalling the plugin (as it will soon be included in WP)
|
27 |
+
* fix: prevent creating a media translation if one already exists
|
28 |
+
* fix: Attempt to translate the nav menus for themes registering a theme location but not using it in wp_nav_menu()
|
29 |
+
* fix: Jetpack infinite scroll
|
30 |
+
* fix: issue with terms languages when two languages have the same name
|
31 |
+
* fix: notices when deleting a tag and Lingotek is active
|
32 |
+
* fix: the languages cache is not cleaned when updating the site home url
|
33 |
+
* fix: conflict with the theme Ambition
|
34 |
+
* fix: front page canonical url displayed by Yoast SEO
|
35 |
+
* fix: typo in options definition at install [props null.bit](https://wordpress.org/support/topic/suggestions-for-two-new-filters?replies=5#post-7466159)
|
36 |
+
* fix: error when adding a term in a non-translated taxonomy
|
37 |
+
|
38 |
+
= 1.7.9 (2015-08-17) =
|
39 |
+
|
40 |
+
* Minimum WordPress version is now v3.9
|
41 |
+
* Add: hreflang="x-default" on front page when the default language code is not hidden in urls
|
42 |
+
* fix: remove hreflang links in html head section of paged archives to please Google
|
43 |
+
* fix: conflict with WPSEO sitemap caching when using multiple domains. [props Junaid Bhura](https://wordpress.org/support/topic/wp-seo-sitemap-and-translation-subdomain-issue?replies=8#post-7113817)
|
44 |
+
* fix: change the order of strings translations columns for better display on mobile devices in WP 4.3
|
45 |
+
* fix: various issues with nav menus and customizer in WP 4.3
|
46 |
+
* fix: correctly disallow unchecking both show names and show flags in the language switcher form
|
47 |
+
|
48 |
+
= 1.7.8 (2015-07-21) =
|
49 |
+
|
50 |
+
* fix: conflict with PHP < 5.4 introduced in 1.7.7
|
51 |
+
|
52 |
+
= 1.7.7 (2015-07-20) =
|
53 |
+
|
54 |
+
* Add Romanian translation contributed by uskro
|
55 |
+
* Add Japanese translation contributed by [Eiko Toda](http://www.eikotoda.com)
|
56 |
+
* Update French translation contributed by [fxbenard](http://fxbenard.com/)
|
57 |
+
* The language locale is now validated with the same pattern as in WP 4.3. See #28303
|
58 |
+
* fix: make sure that the language switcher never finds translations for untranslated post types (could occur when the post type was previously translated)
|
59 |
+
* fix: display the default category according to the admin language filter in settings->writing
|
60 |
+
* fix: flushing rewrite rules at network activation and de-activation is back. [props RavanH](https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/comment-page-1/#comment-1138)
|
61 |
+
* fix: avoid a conflict with WP Super Cache preloading (loading 'polylang_mo' posts which are 404). [props ecdltf](https://wordpress.org/support/topic/polylang_mo-and-404s-take-2)
|
62 |
+
* fix: customizer menus issues introduced by changes in WP 4.1
|
63 |
+
* fix: strings translations are not saved when pressing enter
|
64 |
+
* fix: it is not possible to de-activate the translation for custom post types and taxonomies from wpml-config.xml
|
65 |
+
* fix: conflict whith plugins using stringified json in ajax requests
|
66 |
+
|
67 |
+
= 1.7.6 (2015-06-10) =
|
68 |
+
|
69 |
+
* Add Galician translation contributed by [Toño Calo](http://fedellar.wordpress.com/)
|
70 |
+
* fix: incorrect post type archive link for untranslated post types
|
71 |
+
* fix: notices in wp-import.php
|
72 |
+
* fix: avoid flushing rewrite rules at network activation and de-activation
|
73 |
+
* fix: the note below the category list table displays the default category according to the admin language filter
|
74 |
+
* fix: wrong future posts permalinks
|
75 |
+
* fix: deleting a media translation deletes the file too
|
76 |
+
* fix: when using persistent object cache, get_terms is not always filtered by the correct language on admin side
|
77 |
+
* fix: it is possible to create two categories having the same translation
|
78 |
+
* fix: fatal error when using the dropdown language switcher in WP < 4.1
|
79 |
+
|
80 |
+
= 1.7.5 (2015-05-11) =
|
81 |
+
|
82 |
+
* Add 'pll_languages_list' filter
|
83 |
+
* fix: warning when a plugin calls 'icl_object_id' with an untranslated post type (seen in ACF 4.4.1)
|
84 |
+
* fix: the language is not correctly set from the url when using PATHINFO permalinks (introduced in 1.6!)
|
85 |
+
* fix: notice when a search is filtered by a taxonomy term in a different language
|
86 |
+
|
87 |
+
= 1.7.4 (2015-05-03) =
|
88 |
+
|
89 |
+
* fix: translated taxonomies and post types from wpml-config.xml are not filtered on frontend (introduced in 1.7.2)
|
90 |
+
* fix: WPML strings translations not always loaded (introduced in 1.7)
|
91 |
+
* fix: $.ajaxPrefilter() may not work as expected [props ScreenfeedFr](https://wordpress.org/support/topic/ajaxprefilter-may-not-work-as-expected)
|
92 |
+
* fix: can't hide the language code for the default language when using subdomains
|
93 |
+
* fix: incorrect static front page url when hiding the default language information
|
94 |
+
* fix: an untranslated posts page may display posts in all languages
|
95 |
+
* fix: javascript error when changing the language of a hierarchical post type from the languages metabox in WP 4.2
|
96 |
+
* fix: subdomains urls are malformed when the main site uses www.
|
97 |
+
* fix: suggest tags are not filtered in quick edit
|
98 |
+
* fix: parent page dropdown list not filtered in quick edit
|
99 |
+
|
100 |
+
= 1.7.3 (2015-04-11) =
|
101 |
+
|
102 |
+
* the transient 'pll_languages_list' now stores an array of arrays instead of an array of PLL_Language objects
|
103 |
+
* fix: fatal error for users hosted at GoDaddy (due to PLL_Language objects stored in a transient)
|
104 |
+
* fix: additional query vars are removed from home page
|
105 |
+
* fix: categories are not filtered by the admin language switcher in posts list table (introduced in 1.7)
|
106 |
+
* fix: when using multiple domains, the domain url is lost when modifying the language slug
|
107 |
+
* fix: the queried object is incorrectly set for author archives (introduced in 1.6.5)
|
108 |
+
* fix: notice when a nav menu assigned to a translated nav menu location has been deleted
|
109 |
+
* fix: no canonical redirection when using pretty permalinks and querying default permalinks
|
110 |
+
|
111 |
+
= 1.7.2 (2015-03-23) =
|
112 |
+
|
113 |
+
* fix: comments are filtered for posts in a post type not managed by Polylang
|
114 |
+
* fix: translated static front page don't work when setting PLL_CACHE_HOME_URL to false (introduced in 1.7)
|
115 |
+
* fix: the query for taxonomies on custom post types is broken (when adding the language code to the url)
|
116 |
+
|
117 |
+
= 1.7.1 (2015-03-20) =
|
118 |
+
|
119 |
+
* fix: wrong redirection when using a static front page and replacing the page name by the language code (introduced in 1.7)
|
120 |
+
|
121 |
+
= 1.7 (2015-03-19) =
|
122 |
+
|
123 |
+
* Minimum WordPress version is now v3.8
|
124 |
+
* Add new languages to the predefined languages list: Swiss German, Hazaragi
|
125 |
+
* Add compatibility with nested tax queries introduced in WP 4.1
|
126 |
+
* Add compatibility with splitting shared terms to be introduced in WP 4.2
|
127 |
+
* Add the possibility to change the domain in the default language when using multiple domains (avoids a conflict with the domain mapping plugin)
|
128 |
+
* Add the possibility to set the language from the code in url when using default permalinks
|
129 |
+
* Adding the language code in url is now default at first activation (should improve the out of the box compatibility with other plugins and themes)
|
130 |
+
* Add new language switcher option to hide a language with no translation
|
131 |
+
* pll_the_languages() now outputs the js code to handle language change in dropdown list (as done by the widget)
|
132 |
+
* Improve performance by using base64 encoded flags + various slight optimizations
|
133 |
+
* Improve protection against chained redirects
|
134 |
+
* The find posts list is now filtered per media language when clicking on attach link in Media library
|
135 |
+
* Copy alternative text when creating a media translation
|
136 |
+
* The category checklist in quick edit is now filtered per post language instead of admin language filter
|
137 |
+
* Quick and bulk language edit don't break translations anymore if the new language is free
|
138 |
+
* Make it impossible to change the language of the default categories
|
139 |
+
* Make sure that a default category defined in settings->writing is translated in all languages
|
140 |
+
* Tweak css for mobiles in add and edit term form
|
141 |
+
* Tweak the query getting the list of available posts in the autocomplete input field in the post languages metabox
|
142 |
+
* fix: after adding a term translation, need to refresh the page before adding a new term
|
143 |
+
* fix: term translations rows are not modified in list table when a term is added / deleted or inline edited
|
144 |
+
* fix: post translations rows are not modified in list table when a post is inline edited
|
145 |
+
* fix: using brackets in language name breaks strings translations
|
146 |
+
* fix: quick edit may conflict with other plugins
|
147 |
+
* fix: impossible to use several dropdown languages widgets
|
148 |
+
* fix: pll_the_languages() may display a dropdown with empty options
|
149 |
+
* fix: the categories widget does not work correctly with dropdown
|
150 |
+
* fix: autosave post always created after manual save
|
151 |
+
* fix: tax query not filtered by language when using 'NOT IN' operator on a translated taxonomy
|
152 |
+
* fix: incorrect translation url for searches filtered by taxonomy
|
153 |
+
* fix: backward incompatibility for edited_term_taxonomy action introduced in WP 4.2
|
154 |
+
* fix: the home link may be incorrect on MS Windows
|
155 |
+
* fix: tags in wrong language may be assigned when bulk editing posts in several languages
|
156 |
+
* fix: tags created when bulk editing posts are not assigned any language
|
157 |
+
* fix: Illegal string offset 'taxonomy' introduced in v1.6.5
|
158 |
+
* fix: Undefined property: WP_Query::$queried_object_id when calling pll_the_languages(array('raw' => 1)) in a function hooked to 'wp'. props [KLicheR](https://wordpress.org/support/profile/klicher)
|
159 |
+
* fix: Notice in admin.php when used with MailPoet plugin
|
160 |
+
|
161 |
= 1.6.5 (2015-02-18) =
|
162 |
|
163 |
* Add new correspondances between WordPress locales and Facebook locales (for WPSEO and Jetpack users)
|
css/admin.css
CHANGED
@@ -1,19 +1,39 @@
|
|
1 |
/* languages admin panel */
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
width : 10%;
|
4 |
}
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
.form-field input[type="radio"] {
|
7 |
width: auto;
|
8 |
margin-right: 2px;
|
9 |
}
|
10 |
|
11 |
/* about Polylang metabox */
|
12 |
-
#
|
|
|
13 |
text-align: justify;
|
14 |
}
|
15 |
|
16 |
-
#
|
17 |
margin: 0;
|
18 |
padding: 0;
|
19 |
float: right;
|
@@ -24,7 +44,8 @@
|
|
24 |
margin: 16px 0 8px 0;
|
25 |
}
|
26 |
|
27 |
-
.stringstranslations .column-name,
|
|
|
28 |
width: 10%;
|
29 |
}
|
30 |
|
@@ -38,47 +59,99 @@
|
|
38 |
vertical-align: top;
|
39 |
}
|
40 |
|
41 |
-
.translation input,
|
|
|
42 |
width: 72%;
|
43 |
}
|
44 |
|
45 |
/* settings */
|
46 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
margin: 0;
|
48 |
}
|
49 |
|
50 |
-
.
|
51 |
display: inline-block;
|
52 |
margin: 0;
|
53 |
width: 250px;
|
54 |
}
|
55 |
|
|
|
56 |
#pll-domains-table td {
|
57 |
padding: 2px 2px 2px 1.5em;
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
63 |
}
|
64 |
|
65 |
/* language columns in edit.php and edit-tags.php */
|
66 |
-
th[class*='column-language_'],
|
67 |
-
|
|
|
68 |
}
|
69 |
|
70 |
|
71 |
/* languages metabox in post.php */
|
|
|
|
|
|
|
|
|
72 |
#post-translations table {
|
73 |
table-layout: fixed;
|
74 |
width: 100%;
|
|
|
75 |
}
|
76 |
|
77 |
#post-translations a {
|
78 |
text-decoration: none;
|
79 |
}
|
80 |
|
81 |
-
#post-translations .pll-language-column,
|
|
|
82 |
width: 20px;
|
83 |
}
|
84 |
|
@@ -86,7 +159,8 @@ th[class*='column-language_'], td[class*='column-language_'] {
|
|
86 |
padding: 2px;
|
87 |
}
|
88 |
|
89 |
-
#post-translations .spinner,
|
|
|
90 |
float: none;
|
91 |
margin: 0;
|
92 |
background-position: center;
|
@@ -127,17 +201,32 @@ th[class*='column-language_'], td[class*='column-language_'] {
|
|
127 |
margin-right: 4px;
|
128 |
}
|
129 |
|
130 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
width: 95%;
|
132 |
}
|
133 |
|
134 |
#term-translations .pll-language-column {
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
137 |
}
|
138 |
|
139 |
-
#
|
140 |
-
|
|
|
141 |
}
|
142 |
|
143 |
/* icon fonts */
|
@@ -172,10 +261,39 @@ th[class*='column-language_'], td[class*='column-language_'] {
|
|
172 |
}
|
173 |
|
174 |
@media screen and ( max-width: 782px ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
/* strings translations table */
|
176 |
.stringstranslations .column-context,
|
177 |
.stringstranslations .column-name {
|
178 |
-
display: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
}
|
180 |
|
181 |
/* hide selected language flag and translations language name */
|
@@ -214,7 +332,7 @@ th[class*='column-language_'], td[class*='column-language_'] {
|
|
214 |
}
|
215 |
|
216 |
/* admin bar */
|
217 |
-
#wpadminbar
|
218 |
display: block; /*shows our menu on mobile devices */
|
219 |
}
|
220 |
|
1 |
/* languages admin panel */
|
2 |
+
#add-lang select {
|
3 |
+
width: 95%;
|
4 |
+
}
|
5 |
+
|
6 |
+
.column-locale,
|
7 |
+
.languages .column-slug {
|
8 |
+
width : 15%
|
9 |
+
}
|
10 |
+
|
11 |
+
.column-default_lang {
|
12 |
+
width : 5%;
|
13 |
+
}
|
14 |
+
|
15 |
+
.column-term_group,
|
16 |
+
.column-flag, .column-count {
|
17 |
width : 10%;
|
18 |
}
|
19 |
|
20 |
+
.icon-default-lang:before {
|
21 |
+
font-family: 'dashicons';
|
22 |
+
content: "\f155";
|
23 |
+
}
|
24 |
+
|
25 |
.form-field input[type="radio"] {
|
26 |
width: auto;
|
27 |
margin-right: 2px;
|
28 |
}
|
29 |
|
30 |
/* about Polylang metabox */
|
31 |
+
#pll-about-box p,
|
32 |
+
#pll-recommended p {
|
33 |
text-align: justify;
|
34 |
}
|
35 |
|
36 |
+
#pll-about-box input {
|
37 |
margin: 0;
|
38 |
padding: 0;
|
39 |
float: right;
|
44 |
margin: 16px 0 8px 0;
|
45 |
}
|
46 |
|
47 |
+
.stringstranslations .column-name,
|
48 |
+
.stringstranslations .column-context {
|
49 |
width: 10%;
|
50 |
}
|
51 |
|
59 |
vertical-align: top;
|
60 |
}
|
61 |
|
62 |
+
.translation input,
|
63 |
+
.translation textarea {
|
64 |
width: 72%;
|
65 |
}
|
66 |
|
67 |
/* settings */
|
68 |
+
.pll-settings .plugin-title {
|
69 |
+
width: 25%;
|
70 |
+
}
|
71 |
+
|
72 |
+
#wpbody-content .pll-settings .pll-configure tr {
|
73 |
+
display: table-row;
|
74 |
+
}
|
75 |
+
|
76 |
+
#wpbody-content .pll-settings .pll-configure td {
|
77 |
+
display: table-cell;
|
78 |
+
}
|
79 |
+
|
80 |
+
#wpbody-content .pll-settings .pll-configure > td {
|
81 |
+
padding: 20px 20px 20px 40px;
|
82 |
+
}
|
83 |
+
|
84 |
+
.pll-configure legend {
|
85 |
+
font-size: 14px;
|
86 |
+
font-weight: 600;
|
87 |
+
margin-bottom: 0.5em;
|
88 |
+
}
|
89 |
+
|
90 |
+
.pll-configure td .description {
|
91 |
+
margin-top: 2px;
|
92 |
+
margin-bottom: 0.5em;
|
93 |
+
}
|
94 |
+
|
95 |
+
.pll-configure .submit {
|
96 |
+
margin-top: 20px;
|
97 |
+
}
|
98 |
+
|
99 |
+
.pll-configure .button {
|
100 |
+
margin-right: 20px;
|
101 |
+
}
|
102 |
+
|
103 |
+
.pll-configure fieldset {
|
104 |
+
margin-bottom: 1.5em;
|
105 |
+
}
|
106 |
+
|
107 |
+
.pll-inline-block-list {
|
108 |
margin: 0;
|
109 |
}
|
110 |
|
111 |
+
.pll-inline-block-list li {
|
112 |
display: inline-block;
|
113 |
margin: 0;
|
114 |
width: 250px;
|
115 |
}
|
116 |
|
117 |
+
/* settings URL modifications */
|
118 |
#pll-domains-table td {
|
119 |
padding: 2px 2px 2px 1.5em;
|
120 |
+
-webkit-box-shadow: none;
|
121 |
+
box-shadow: none;
|
122 |
+
border: none;
|
123 |
}
|
124 |
|
125 |
+
.pll-settings-url-col {
|
126 |
+
display: inline-block;
|
127 |
+
width: 49%;
|
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_'] {
|
134 |
+
width: 1.5em;
|
135 |
}
|
136 |
|
137 |
|
138 |
/* languages metabox in post.php */
|
139 |
+
#post-translations p {
|
140 |
+
float: left;
|
141 |
+
}
|
142 |
+
|
143 |
#post-translations table {
|
144 |
table-layout: fixed;
|
145 |
width: 100%;
|
146 |
+
clear: both;
|
147 |
}
|
148 |
|
149 |
#post-translations a {
|
150 |
text-decoration: none;
|
151 |
}
|
152 |
|
153 |
+
#post-translations .pll-language-column,
|
154 |
+
#post-translations .pll-edit-column {
|
155 |
width: 20px;
|
156 |
}
|
157 |
|
159 |
padding: 2px;
|
160 |
}
|
161 |
|
162 |
+
#post-translations .spinner,
|
163 |
+
#term-translations .spinner {
|
164 |
float: none;
|
165 |
margin: 0;
|
166 |
background-position: center;
|
201 |
margin-right: 4px;
|
202 |
}
|
203 |
|
204 |
+
#term-translations p {
|
205 |
+
/* same style as label */
|
206 |
+
font-size: 12px;
|
207 |
+
font-style: normal;
|
208 |
+
padding: 2px;
|
209 |
+
color: #23282d;
|
210 |
+
}
|
211 |
+
|
212 |
+
#add-term-translations,
|
213 |
+
#edit-term-translations {
|
214 |
width: 95%;
|
215 |
}
|
216 |
|
217 |
#term-translations .pll-language-column {
|
218 |
+
line-height: 28px;
|
219 |
+
width: 20%;
|
220 |
+
}
|
221 |
+
|
222 |
+
#term-translations .pll-edit-column,
|
223 |
+
#add-term-translations .pll-language-column {
|
224 |
+
width: 20px;
|
225 |
}
|
226 |
|
227 |
+
#edit-term-translations .pll-language-column {
|
228 |
+
padding: 15px 10px;
|
229 |
+
font-weight: normal;
|
230 |
}
|
231 |
|
232 |
/* icon fonts */
|
261 |
}
|
262 |
|
263 |
@media screen and ( max-width: 782px ) {
|
264 |
+
/* settings */
|
265 |
+
#wpbody-content .pll-settings .pll-configure > td {
|
266 |
+
padding: 20px;
|
267 |
+
}
|
268 |
+
|
269 |
+
#wpbody-content .pll-settings #cb {
|
270 |
+
padding: 20px 9px;
|
271 |
+
}
|
272 |
+
|
273 |
+
/* settings URL modifications */
|
274 |
+
.pll-inline-block {
|
275 |
+
width: auto;
|
276 |
+
}
|
277 |
+
|
278 |
+
.pll-settings-url-col {
|
279 |
+
display: block;
|
280 |
+
width: 100%;
|
281 |
+
}
|
282 |
+
|
283 |
/* strings translations table */
|
284 |
.stringstranslations .column-context,
|
285 |
.stringstranslations .column-name {
|
286 |
+
display: none; /* backward compatibility WP < 4.3 */
|
287 |
+
}
|
288 |
+
|
289 |
+
.translation label {
|
290 |
+
display: block;
|
291 |
+
width: 95%;
|
292 |
+
padding-left: 0;
|
293 |
+
}
|
294 |
+
|
295 |
+
.translation input {
|
296 |
+
width: 95%;
|
297 |
}
|
298 |
|
299 |
/* hide selected language flag and translations language name */
|
332 |
}
|
333 |
|
334 |
/* admin bar */
|
335 |
+
#wpadminbar #wp-admin-bar-languages {
|
336 |
display: block; /*shows our menu on mobile devices */
|
337 |
}
|
338 |
|
css/admin.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.column-term_group,.column-flag,.column-count{width:10%}.form-field input[type="radio"]{width:auto;margin-right:2px}#
|
1 |
+
#add-lang select{width:95%}.column-locale,.languages .column-slug{width:15%}.column-default_lang{width:5%}.column-term_group,.column-flag,.column-count{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 0}.stringstranslations .column-name,.stringstranslations .column-context{width:10%}.stringstranslations .column-string{width:33%}.translation label{display:inline-block;width:23%;vertical-align:top}.translation input,.translation textarea{width:72%}.pll-settings .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 .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:0}.pll-settings-url-col{display:inline-block;width:49%;vertical-align:top}th[class*='column-language_'],td[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-language-column,#post-translations .pll-edit-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%}#term-translations .pll-edit-column,#add-term-translations .pll-language-column{width:20px}#edit-term-translations .pll-language-column{padding:15px 10px;font-weight:normal}.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%}.stringstranslations .column-context,.stringstranslations .column-name{display:none}.translation label{display:block;width:95%;padding-left:0}.translation input{width:95%}#select-add-term-language .pll-select-flag,#select-edit-term-language .pll-select-flag,#edit-term-translations .pll-language-name{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-language-column,#edit-term-translations .pll-edit-column{width:20px}.term-translations .pll-language-column,.term-translations .pll-edit-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.css
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Greatly modified version of the jquery-ui.css */
|
2 |
+
|
3 |
+
.ui-widget-overlay {
|
4 |
+
position: fixed;
|
5 |
+
top: 0;
|
6 |
+
left: 0;
|
7 |
+
width: 100%;
|
8 |
+
height: 100%;
|
9 |
+
}
|
10 |
+
|
11 |
+
.ui-menu {
|
12 |
+
list-style: none;
|
13 |
+
padding: 0;
|
14 |
+
margin: 0;
|
15 |
+
display: block;
|
16 |
+
outline: none;
|
17 |
+
}
|
18 |
+
|
19 |
+
.ui-menu .ui-menu {
|
20 |
+
position: absolute;
|
21 |
+
}
|
22 |
+
|
23 |
+
.ui-menu .ui-menu-item {
|
24 |
+
position: relative;
|
25 |
+
margin: 0;
|
26 |
+
padding: 3px 1em 3px .4em;
|
27 |
+
min-height: 0; /* support: IE7 */
|
28 |
+
/* support: IE10, see #8844 */
|
29 |
+
list-style-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
|
30 |
+
}
|
31 |
+
|
32 |
+
/* icon support */
|
33 |
+
.ui-menu-icons {
|
34 |
+
position: relative;
|
35 |
+
}
|
36 |
+
|
37 |
+
.ui-menu-icons .ui-menu-item {
|
38 |
+
padding-left: 2em;
|
39 |
+
}
|
40 |
+
|
41 |
+
/* left-aligned */
|
42 |
+
.ui-selectmenu-text .ui-icon,
|
43 |
+
.ui-menu .ui-icon {
|
44 |
+
position: absolute;
|
45 |
+
top: 0;
|
46 |
+
bottom: 0;
|
47 |
+
left: .2em;
|
48 |
+
margin: auto 0;
|
49 |
+
}
|
50 |
+
|
51 |
+
/* right-aligned */
|
52 |
+
.ui-menu .ui-menu-icon {
|
53 |
+
left: auto;
|
54 |
+
right: 0;
|
55 |
+
}
|
56 |
+
|
57 |
+
.ui-selectmenu-menu {
|
58 |
+
padding: 0;
|
59 |
+
margin: 0;
|
60 |
+
position: absolute;
|
61 |
+
top: 0;
|
62 |
+
left: 0;
|
63 |
+
display: none;
|
64 |
+
}
|
65 |
+
|
66 |
+
.ui-selectmenu-menu .ui-menu {
|
67 |
+
overflow: auto;
|
68 |
+
/* Support: IE7 */
|
69 |
+
overflow-x: hidden;
|
70 |
+
padding-bottom: 1px;
|
71 |
+
}
|
72 |
+
|
73 |
+
.ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup {
|
74 |
+
font-size: 1em;
|
75 |
+
font-weight: bold;
|
76 |
+
line-height: 23px;
|
77 |
+
padding: 2px 0.4em;
|
78 |
+
margin: 0.5em 0 0 0;
|
79 |
+
height: auto;
|
80 |
+
border: 0;
|
81 |
+
}
|
82 |
+
|
83 |
+
.ui-selectmenu-open {
|
84 |
+
display: block;
|
85 |
+
}
|
86 |
+
|
87 |
+
.ui-selectmenu-button {
|
88 |
+
display: inline-block;
|
89 |
+
overflow: hidden;
|
90 |
+
position: relative;
|
91 |
+
text-decoration: none;
|
92 |
+
}
|
93 |
+
|
94 |
+
.ui-selectmenu-button span.ui-icon {
|
95 |
+
right: 0.5em;
|
96 |
+
left: auto;
|
97 |
+
margin-top: -10px;
|
98 |
+
position: absolute;
|
99 |
+
top: 50%;
|
100 |
+
}
|
101 |
+
|
102 |
+
.ui-selectmenu-button span.ui-selectmenu-text {
|
103 |
+
text-align: left;
|
104 |
+
padding: 0.4em 2.1em 0.4em 2em;
|
105 |
+
display: block;
|
106 |
+
line-height: 23px;
|
107 |
+
overflow: hidden;
|
108 |
+
text-overflow: ellipsis;
|
109 |
+
white-space: nowrap;
|
110 |
+
}
|
111 |
+
|
112 |
+
.ui-widget-content,
|
113 |
+
.ui-state-default,
|
114 |
+
.ui-widget-content .ui-state-default,
|
115 |
+
.ui-widget-header .ui-state-default {
|
116 |
+
background: #fff;
|
117 |
+
border: 1px solid #ddd;
|
118 |
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07) inset;
|
119 |
+
color: #32373c;
|
120 |
+
}
|
121 |
+
|
122 |
+
.ui-widget-content .ui-state-hover,
|
123 |
+
.ui-widget-content .ui-state-focus {
|
124 |
+
background: #f5f5f5;
|
125 |
+
}
|
126 |
+
|
127 |
+
.ui-selectmenu-button.ui-state-focus {
|
128 |
+
border: 1px solid #5b9dd9;
|
129 |
+
box-shadow: 0 0 2px rgba(30, 140, 190, 0.8);
|
130 |
+
}
|
131 |
+
|
132 |
+
.ui-icon-triangle-1-s:before {
|
133 |
+
content: "\f140";
|
134 |
+
font: 20px/1 'dashicons';
|
135 |
+
}
|
136 |
+
|
137 |
+
.ui-widget-content {
|
138 |
+
max-height: 231px;
|
139 |
+
box-shadow: 0 2px 6px rgba(100, 100, 100, 0.3);
|
140 |
+
}
|
css/selectmenu.min.css
ADDED
@@ -0,0 +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("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item{padding-left:2em}.ui-selectmenu-text .ui-icon,.ui-menu .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:bold;line-height:23px;padding:2px .4em;margin:.5em 0 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-widget-content,.ui-state-default,.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,0.07) inset;color:#32373c}.ui-widget-content .ui-state-hover,.ui-widget-content .ui-state-focus{background:#f5f5f5}.ui-selectmenu-button.ui-state-focus{border:1px solid #5b9dd9;box-shadow:0 0 2px rgba(30,140,190,0.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,0.3)}
|
flags/ad.png
ADDED
Binary file
|
flags/ae.png
ADDED
Binary file
|
flags/af.png
CHANGED
Binary file
|
flags/ag.png
ADDED
Binary file
|
flags/ai.png
ADDED
Binary file
|
flags/{sq.png → al.png}
RENAMED
File without changes
|
flags/{hy.png → am.png}
RENAMED
File without changes
|
flags/an.png
ADDED
Binary file
|
flags/ao.png
ADDED
Binary file
|
flags/ar.png
CHANGED
Binary file
|
flags/arab.png
ADDED
Binary file
|
flags/as.png
ADDED
Binary file
|
flags/at.png
ADDED
Binary file
|
flags/{en_AU.png → au.png}
RENAMED
File without changes
|
flags/aw.png
ADDED
Binary file
|
flags/ax.png
ADDED
Binary file
|
flags/{bs_BA.png → ba.png}
RENAMED
File without changes
|
flags/{eu.png → basque.png}
RENAMED
File without changes
|
flags/bb.png
ADDED
Binary file
|
flags/bd.png
ADDED
Binary file
|
flags/be.png
ADDED
Binary file
|
flags/bf.png
ADDED
Binary file
|
flags/{bg_BG.png → bg.png}
RENAMED
File without changes
|
flags/bh.png
ADDED
Binary file
|
flags/bi.png
ADDED
Binary file
|
flags/bj.png
ADDED
Binary file
|
flags/bm.png
ADDED
Binary file
|
flags/bn.png
ADDED
Binary file
|
flags/bo.png
ADDED
Binary file
|
flags/{pt_BR.png → br.png}
RENAMED
File without changes
|
flags/bs.png
ADDED
Binary file
|
flags/bt.png
ADDED
Binary file
|
flags/bw.png
ADDED
Binary file
|
flags/{bel.png → by.png}
RENAMED
File without changes
|
flags/bz.png
ADDED
Binary file
|
flags/ca.png
CHANGED
Binary file
|
flags/catalonia.png
ADDED
Binary file
|
flags/cc.png
ADDED
Binary file
|
flags/cd.png
ADDED
Binary file
|
flags/cf.png
ADDED
Binary file
|
flags/cg.png
ADDED
Binary file
|
flags/{de_CH.png → ch.png}
RENAMED
File without changes
|
flags/ci.png
ADDED
Binary file
|
flags/ck.png
ADDED
Binary file
|
flags/{es_CL.png → cl.png}
RENAMED
File without changes
|
flags/cm.png
ADDED
Binary file
|
flags/{ug_CN.png → cn.png}
RENAMED
File without changes
|
flags/{es_CO.png → co.png}
RENAMED
File without changes
|
flags/cr.png
ADDED
Binary file
|
flags/cu.png
ADDED
Binary file
|
flags/cv.png
ADDED
Binary file
|
flags/cx.png
ADDED
Binary file
|
flags/cy.png
CHANGED
Binary file
|
flags/{cs_CZ.png → cz.png}
RENAMED
File without changes
|
flags/{de_DE.png → de.png}
RENAMED
File without changes
|
flags/de_DE_formal.png
DELETED
Binary file
|
flags/dj.png
ADDED
Binary file
|
flags/{da_DK.png → dk.png}
RENAMED
File without changes
|
flags/dm.png
ADDED
Binary file
|
flags/do.png
ADDED
Binary file
|
flags/dz.png
ADDED
Binary file
|
flags/ec.png
ADDED
Binary file
|
flags/ee.png
ADDED
Binary file
|
flags/eg.png
ADDED
Binary file
|
flags/eh.png
ADDED
Binary file
|
flags/en_CA.png
DELETED
Binary file
|
flags/england.png
ADDED
Binary file
|
flags/er.png
ADDED
Binary file
|
flags/{es_ES.png → es.png}
RENAMED
File without changes
|
flags/es_AR.png
DELETED
Binary file
|
flags/{eo.png → esperanto.png}
RENAMED
File without changes
|
flags/et.png
CHANGED
Binary file
|
flags/fa_AF.png
DELETED
Binary file
|
flags/fi.png
CHANGED
File without changes
|
flags/fj.png
ADDED
Binary file
|
flags/fk.png
ADDED
Binary file
|
flags/fm.png
ADDED
Binary file
|
flags/fo.png
CHANGED
File without changes
|
flags/{fr_FR.png → fr.png}
RENAMED
File without changes
|
flags/ga.png
ADDED
Binary file
|
flags/{gl_ES.png → galicia.png}
RENAMED
File without changes
|
flags/{en_GB.png → gb.png}
RENAMED
File without changes
|
flags/gd.png
CHANGED
Binary file
|
flags/{ka_GE.png → ge.png}
RENAMED
File without changes
|
flags/gh.png
ADDED
Binary file
|
flags/gi.png
ADDED
Binary file
|
flags/gl.png
ADDED
Binary file
|
flags/gm.png
ADDED
Binary file
|
flags/gn.png
ADDED
Binary file
|
flags/gp.png
ADDED
Binary file
|
flags/gq.png
ADDED
Binary file
|
flags/{el.png → gr.png}
RENAMED
File without changes
|
flags/gs.png
ADDED
Binary file
|
flags/gt.png
ADDED
Binary file
|
flags/gu.png
ADDED
Binary file
|
flags/gw.png
ADDED
Binary file
|
flags/gy.png
ADDED
Binary file
|
flags/haz.png
DELETED
Binary file
|
flags/{zh_HK.png → hk.png}
RENAMED
File without changes
|
flags/hm.png
ADDED
Binary file
|
flags/hn.png
ADDED
Binary file
|
flags/hr.png
CHANGED
File without changes
|
flags/ht.png
ADDED
Binary file
|
flags/{hu_HU.png → hu.png}
RENAMED
File without changes
|
flags/{id_ID.png → id.png}
RENAMED
File without changes
|
flags/ie.png
ADDED
Binary file
|
flags/{he_IL.png → il.png}
RENAMED
File without changes
|
flags/{hi_IN.png → in.png}
RENAMED
File without changes
|
flags/io.png
ADDED
Binary file
|
flags/iq.png
ADDED
Binary file
|
flags/{fa_IR.png → ir.png}
RENAMED
File without changes
|
flags/{is_IS.png → is.png}
RENAMED
File without changes
|
flags/{it_IT.png → it.png}
RENAMED
File without changes
|
flags/jm.png
ADDED
Binary file
|
flags/jo.png
ADDED
Binary file
|
flags/{ja.png → jp.png}
RENAMED
File without changes
|
flags/jv_ID.png
DELETED
Binary file
|
flags/ke.png
ADDED
Binary file
|
flags/kg.png
ADDED
Binary file
|
flags/kh.png
ADDED
Binary file
|
flags/ki.png
ADDED
Binary file
|
flags/km.png
ADDED
Binary file
|
flags/kn.png
ADDED
Binary file
|
flags/kp.png
ADDED
Binary file
|
flags/{ko_KR.png → kr.png}
RENAMED
File without changes
|
flags/{ckb.png → kurdistan.png}
RENAMED
File without changes
|
flags/kw.png
ADDED
Binary file
|
flags/ky.png
ADDED
Binary file
|
flags/{kk.png → kz.png}
RENAMED
File without changes
|
flags/{lo.png → la.png}
RENAMED
File without changes
|
flags/lb.png
ADDED
Binary file
|
flags/lc.png
ADDED
Binary file
|
flags/li.png
ADDED
Binary file
|
flags/{si_LK.png → lk.png}
RENAMED
File without changes
|
flags/lr.png
ADDED
Binary file
|
flags/ls.png
ADDED
Binary file
|
flags/{lt_LT.png → lt.png}
RENAMED
File without changes
|
flags/lu.png
ADDED
Binary file
|
flags/lv.png
CHANGED
File without changes
|
flags/ly.png
ADDED
Binary file
|
flags/ma.png
ADDED
Binary file
|
flags/mc.png
ADDED
Binary file
|
flags/md.png
ADDED
Binary file
|
flags/me.png
ADDED
Binary file
|
flags/mg.png
ADDED
Binary file
|
flags/mh.png
ADDED
Binary file
|
flags/{mk_MK.png → mk.png}
RENAMED
File without changes
|
flags/ml.png
ADDED
Binary file
|
flags/mm.png
ADDED
Binary file
|
flags/mo.png
ADDED
Binary file
|
flags/mp.png
ADDED
Binary file
|
flags/mq.png
ADDED
Binary file
|
flags/mr.png
ADDED
Binary file
|
flags/ms.png
ADDED
Binary file
|
flags/mt.png
ADDED
Binary file
|
flags/mu.png
ADDED
Binary file
|
flags/mv.png
ADDED
Binary file
|
flags/mw.png
ADDED
Binary file
|
flags/{es_MX.png → mx.png}
RENAMED
File without changes
|
flags/{ms_MY.png → my.png}
RENAMED
File without changes
|
flags/my_MM.png
DELETED
Binary file
|
flags/mz.png
ADDED
Binary file
|
flags/na.png
ADDED
Binary file
|
flags/nc.png
ADDED
Binary file
|
flags/ne.png
ADDED
Binary file
|
flags/nf.png
ADDED
Binary file
|
flags/ng.png
ADDED
Binary file
|
flags/ni.png
ADDED
Binary file
|
flags/{fy.png → nl.png}
RENAMED
File without changes
|
flags/nl_NL.png
DELETED
Binary file
|
flags/nn_NO.png
DELETED
Binary file
|
flags/{nb_NO.png → no.png}
RENAMED
File without changes
|
flags/{ne_NP.png → np.png}
RENAMED
File without changes
|
flags/nr.png
ADDED
Binary file
|
flags/nu.png
ADDED
Binary file
|
flags/{en_NZ.png → nz.png}
RENAMED
File without changes
|
flags/{oci.png → occitania.png}
RENAMED
File without changes
|
flags/om.png
ADDED
Binary file
|
flags/pa.png
ADDED
Binary file
|
flags/{es_PE.png → pe.png}
RENAMED
File without changes
|
flags/pf.png
ADDED
Binary file
|
flags/pg.png
ADDED
Binary file
|
flags/ph.png
ADDED
Binary file
|
flags/{ur.png → pk.png}
RENAMED
File without changes
|
flags/{pl_PL.png → pl.png}
RENAMED
File without changes
|
flags/pm.png
ADDED
Binary file
|
flags/pn.png
ADDED
Binary file
|
flags/pr.png
ADDED
Binary file
|
flags/ps.png
CHANGED
Binary file
|
flags/{pt_PT.png → pt.png}
RENAMED
File without changes
|
flags/pw.png
ADDED
Binary file
|
flags/py.png
ADDED
Binary file
|
flags/qa.png
ADDED
Binary file
|
flags/quebec.png
ADDED
Binary file
|
flags/{ro_RO.png → ro.png}
RENAMED
File without changes
|
flags/{sr_RS.png → rs.png}
RENAMED
File without changes
|
flags/{ru_RU.png → ru.png}
RENAMED
File without changes
|
flags/rw.png
ADDED
Binary file
|
flags/sa.png
ADDED
Binary file
|
flags/sb.png
ADDED
Binary file
|
flags/sc.png
ADDED
Binary file
|
flags/scotland.png
ADDED
Binary file
|
flags/sd.png
ADDED
Binary file
|
flags/{sv_SE.png → se.png}
RENAMED
File without changes
|
flags/sg.png
ADDED
Binary file
|
flags/sh.png
ADDED
Binary file
|
flags/{sl_SI.png → si.png}
RENAMED
File without changes
|
flags/{sk_SK.png → sk.png}
RENAMED
File without changes
|
flags/sl.png
ADDED
Binary file
|
flags/sm.png
ADDED
Binary file
|
flags/sn.png
ADDED
Binary file
|
flags/{so_SO.png → so.png}
RENAMED
File without changes
|
flags/sr.png
ADDED
Binary file
|
flags/ss.png
ADDED
Binary file
|
flags/st.png
ADDED
Binary file
|
flags/su_ID.png
DELETED
Binary file
|
flags/sv.png
ADDED
Binary file
|
flags/sy.png
ADDED
Binary file
|
flags/sz.png
ADDED
Binary file
|
flags/ta_LK.png
DELETED
Binary file
|
flags/tc.png
ADDED
Binary file
|
flags/td.png
ADDED
Binary file
|
flags/tf.png
ADDED
Binary file
|
flags/tg.png
ADDED
Binary file
|
flags/th.png
CHANGED
File without changes
|
flags/tj.png
ADDED
Binary file
|
flags/tk.png
ADDED
Binary file
|
flags/tl.png
CHANGED
Binary file
|
flags/tm.png
ADDED
Binary file
|
flags/tn.png
ADDED
Binary file
|
flags/to.png
ADDED
Binary file
|
flags/{tr_TR.png → tr.png}
RENAMED
File without changes
|
flags/tt.png
ADDED
Binary file
|
flags/tv.png
ADDED
Binary file
|
flags/{zh_TW.png → tw.png}
RENAMED
File without changes
|
flags/tz.png
ADDED
Binary file
|
flags/{uk.png → ua.png}
RENAMED
File without changes
|
flags/ug.png
ADDED
Binary file
|
flags/{en_US.png → us.png}
RENAMED
File without changes
|
flags/uy.png
ADDED
Binary file
|
flags/{uz_UZ.png → uz.png}
RENAMED
File without changes
|
flags/va.png
ADDED
Binary file
|
flags/vc.png
ADDED
Binary file
|
flags/{es_VE.png → ve.png}
RENAMED
File without changes
|
flags/vec.png
DELETED
Binary file
|
flags/veneto.png
ADDED
Binary file
|
flags/vg.png
ADDED
Binary file
|
flags/vi.png
CHANGED
Binary file
|
flags/vn.png
ADDED
Binary file
|
flags/vu.png
ADDED
Binary file
|
flags/wales.png
ADDED
Binary file
|
flags/wf.png
ADDED
Binary file
|
flags/ws.png
ADDED
Binary file
|
flags/ye.png
ADDED
Binary file
|
flags/yt.png
ADDED
Binary file
|
flags/za.png
ADDED
Binary file
|
flags/zh_CN.png
DELETED
Binary file
|
flags/zm.png
ADDED
Binary file
|
flags/zw.png
ADDED
Binary file
|
frontend/choose-lang-content.php
CHANGED
@@ -9,21 +9,19 @@
|
|
9 |
class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
10 |
|
11 |
/*
|
12 |
-
*
|
13 |
*
|
14 |
-
* @since 1.
|
15 |
-
*
|
16 |
-
* @param object $polylang
|
17 |
*/
|
18 |
-
public function
|
19 |
-
parent::
|
20 |
|
21 |
-
if (!did_action('pll_language_defined')) {
|
22 |
// set the languages from content
|
23 |
-
add_action('wp', array(&$this, 'wp'), 5); // priority 5 for post types and taxonomies registered in wp hook with default priority
|
24 |
|
25 |
// if no language found, choose the preferred one
|
26 |
-
add_filter('pll_get_current_language', array(&$this, 'pll_get_current_language'));
|
27 |
}
|
28 |
}
|
29 |
|
@@ -34,9 +32,9 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
34 |
*
|
35 |
* @param object $curlang current language
|
36 |
*/
|
37 |
-
protected function set_language($curlang) {
|
38 |
-
parent::set_language($curlang);
|
39 |
-
remove_action('wp', array(&$this, 'wp'), 5); // won't attempt to set the language a 2nd time
|
40 |
}
|
41 |
|
42 |
/*
|
@@ -48,26 +46,29 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
48 |
*/
|
49 |
protected function get_language_from_content() {
|
50 |
// no language set for 404
|
51 |
-
if (is_404() || (is_attachment() &&
|
52 |
return $this->get_preferred_language();
|
|
|
53 |
|
54 |
-
if ($var = get_query_var('lang')) {
|
55 |
-
$lang = explode(',',$var);
|
56 |
-
$lang = $this->model->get_language(reset($lang)); // choose the first queried language
|
57 |
}
|
58 |
|
59 |
-
elseif ((is_single() || is_page() || (is_attachment() && $this->options['media_support'])) && ( ($var = get_queried_object_id()) || ($var = get_query_var('p')) || ($var = get_query_var('page_id')) || ($var = get_query_var('attachment_id')) ))
|
60 |
-
$lang = $this->model->
|
|
|
61 |
|
62 |
else {
|
63 |
-
foreach ($this->model->get_translated_taxonomies() as $taxonomy) {
|
64 |
-
if ($var = get_query_var(get_taxonomy($taxonomy)->query_var))
|
65 |
-
$lang = $this->model->
|
|
|
66 |
}
|
67 |
}
|
68 |
|
69 |
// allows plugins to set the language
|
70 |
-
return apply_filters('pll_get_current_language', isset($lang) ? $lang : false);
|
71 |
}
|
72 |
|
73 |
/*
|
@@ -78,32 +79,33 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
78 |
*
|
79 |
* @param object $query instance of WP_Query
|
80 |
*/
|
81 |
-
public function parse_main_query($query) {
|
82 |
-
if ($query !== $GLOBALS['wp_the_query'])
|
83 |
return;
|
|
|
84 |
|
85 |
$qv = $query->query_vars;
|
86 |
|
87 |
// homepage is requested, let's set the language
|
88 |
// take care to avoid posts page for which is_home = 1
|
89 |
-
if (empty($query->query) && (is_home() ||
|
90 |
$this->home_language();
|
91 |
$this->home_requested();
|
92 |
}
|
93 |
|
94 |
-
parent::parse_main_query($query);
|
95 |
|
96 |
-
$is_archive = (count($query->query) == 1 && !empty($qv['paged'])) ||
|
97 |
$query->is_date ||
|
98 |
$query->is_author ||
|
99 |
-
(!empty($qv['post_type']) && $query->is_post_type_archive &&
|
100 |
|
101 |
// sets the language in case we hide the default language
|
102 |
// use $query->query['s'] as is_search is not set when search is empty
|
103 |
// http://wordpress.org/support/topic/search-for-empty-string-in-default-language
|
104 |
-
if ($this->options['hide_default'] && !isset($qv['lang']) && ($is_archive || isset($query->query['s']) || (count($query->query) == 1 && !empty($qv['feed'])) )) {
|
105 |
-
$this->set_language($this->model->get_language($this->options['default_lang']));
|
106 |
-
$this->set_lang_query_var($query, $this->curlang);
|
107 |
}
|
108 |
}
|
109 |
|
@@ -113,9 +115,10 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
113 |
* @since 1.2
|
114 |
*/
|
115 |
public function wp() {
|
116 |
-
// nothing to do if the language has already been set (although normally the filter has been removed)
|
117 |
-
if (
|
118 |
-
parent::set_language($curlang);
|
|
|
119 |
}
|
120 |
|
121 |
/*
|
@@ -126,7 +129,7 @@ class PLL_Choose_Lang_Content extends PLL_Choose_lang {
|
|
126 |
* @param object|bool language found in get_language_from_content
|
127 |
* @return object language
|
128 |
*/
|
129 |
-
public function pll_get_current_language($lang) {
|
130 |
-
return
|
131 |
}
|
132 |
}
|
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
|
|
|
|
|
15 |
*/
|
16 |
+
public function init() {
|
17 |
+
parent::init();
|
18 |
|
19 |
+
if ( ! did_action( 'pll_language_defined' ) ) {
|
20 |
// set the languages from content
|
21 |
+
add_action( 'wp', array( &$this, 'wp' ), 5 ); // priority 5 for post types and taxonomies registered in wp hook with default priority
|
22 |
|
23 |
// if no language found, choose the preferred one
|
24 |
+
add_filter( 'pll_get_current_language', array( &$this, 'pll_get_current_language' ) );
|
25 |
}
|
26 |
}
|
27 |
|
32 |
*
|
33 |
* @param object $curlang current language
|
34 |
*/
|
35 |
+
protected function set_language( $curlang ) {
|
36 |
+
parent::set_language( $curlang );
|
37 |
+
remove_action( 'wp', array( &$this, 'wp' ), 5 ); // won't attempt to set the language a 2nd time
|
38 |
}
|
39 |
|
40 |
/*
|
46 |
*/
|
47 |
protected function get_language_from_content() {
|
48 |
// no language set for 404
|
49 |
+
if ( is_404() || ( is_attachment() && ! $this->options['media_support'] ) ) {
|
50 |
return $this->get_preferred_language();
|
51 |
+
}
|
52 |
|
53 |
+
if ( $var = get_query_var( 'lang' ) ) {
|
54 |
+
$lang = explode( ',',$var );
|
55 |
+
$lang = $this->model->get_language( reset( $lang ) ); // choose the first queried language
|
56 |
}
|
57 |
|
58 |
+
elseif ( ( is_single() || is_page() || ( is_attachment() && $this->options['media_support'] ) ) && ( ( $var = get_queried_object_id() ) || ( $var = get_query_var( 'p' ) ) || ( $var = get_query_var( 'page_id' ) ) || ( $var = get_query_var( 'attachment_id' ) ) ) ) {
|
59 |
+
$lang = $this->model->post->get_language( $var );
|
60 |
+
}
|
61 |
|
62 |
else {
|
63 |
+
foreach ( $this->model->get_translated_taxonomies() as $taxonomy ) {
|
64 |
+
if ( $var = get_query_var( get_taxonomy( $taxonomy )->query_var ) ) {
|
65 |
+
$lang = $this->model->term->get_language( $var, $taxonomy );
|
66 |
+
}
|
67 |
}
|
68 |
}
|
69 |
|
70 |
// allows plugins to set the language
|
71 |
+
return apply_filters( 'pll_get_current_language', isset( $lang ) ? $lang : false );
|
72 |
}
|
73 |
|
74 |
/*
|
79 |
*
|
80 |
* @param object $query instance of WP_Query
|
81 |
*/
|
82 |
+
public function parse_main_query( $query ) {
|
83 |
+
if ( $query !== $GLOBALS['wp_the_query'] ) {
|
84 |
return;
|
85 |
+
}
|
86 |
|
87 |
$qv = $query->query_vars;
|
88 |
|
89 |
// homepage is requested, let's set the language
|
90 |
// take care to avoid posts page for which is_home = 1
|
91 |
+
if ( empty( $query->query ) && ( is_home() || is_page() ) ) {
|
92 |
$this->home_language();
|
93 |
$this->home_requested();
|
94 |
}
|
95 |
|
96 |
+
parent::parse_main_query( $query );
|
97 |
|
98 |
+
$is_archive = ( count( $query->query ) == 1 && ! empty( $qv['paged'] ) ) ||
|
99 |
$query->is_date ||
|
100 |
$query->is_author ||
|
101 |
+
( ! empty( $qv['post_type'] ) && $query->is_post_type_archive && $this->model->is_translated_post_type( $qv['post_type'] ) );
|
102 |
|
103 |
// sets the language in case we hide the default language
|
104 |
// use $query->query['s'] as is_search is not set when search is empty
|
105 |
// http://wordpress.org/support/topic/search-for-empty-string-in-default-language
|
106 |
+
if ( $this->options['hide_default'] && ! isset( $qv['lang'] ) && ( $is_archive || isset( $query->query['s'] ) || ( count( $query->query ) == 1 && ! empty( $qv['feed'] ) ) ) ) {
|
107 |
+
$this->set_language( $this->model->get_language( $this->options['default_lang'] ) );
|
108 |
+
$this->set_lang_query_var( $query, $this->curlang );
|
109 |
}
|
110 |
}
|
111 |
|
115 |
* @since 1.2
|
116 |
*/
|
117 |
public function wp() {
|
118 |
+
// nothing to do if the language has already been set ( although normally the filter has been removed )
|
119 |
+
if ( ! $this->curlang && $curlang = $this->get_language_from_content() ) {
|
120 |
+
parent::set_language( $curlang );
|
121 |
+
}
|
122 |
}
|
123 |
|
124 |
/*
|
129 |
* @param object|bool language found in get_language_from_content
|
130 |
* @return object language
|
131 |
*/
|
132 |
+
public function pll_get_current_language( $lang ) {
|
133 |
+
return ! $lang ? $this->get_preferred_language() : $lang;
|
134 |
}
|
135 |
}
|
frontend/choose-lang-domain.php
CHANGED
@@ -20,7 +20,7 @@ class PLL_Choose_Lang_Domain extends PLL_Choose_Lang_Url {
|
|
20 |
* @since 1.5
|
21 |
*/
|
22 |
public function get_preferred_language() {
|
23 |
-
return $this->model->get_language($this->links_model->get_language_from_url());
|
24 |
}
|
25 |
|
26 |
/*
|
@@ -29,6 +29,7 @@ class PLL_Choose_Lang_Domain extends PLL_Choose_Lang_Url {
|
|
29 |
* @since 1.5
|
30 |
*/
|
31 |
public function home_requested() {
|
32 |
-
$this->
|
|
|
33 |
}
|
34 |
}
|
20 |
* @since 1.5
|
21 |
*/
|
22 |
public function get_preferred_language() {
|
23 |
+
return $this->model->get_language( $this->links_model->get_language_from_url() );
|
24 |
}
|
25 |
|
26 |
/*
|
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 |
}
|
frontend/choose-lang-url.php
CHANGED
@@ -11,17 +11,18 @@ 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 |
-
*
|
15 |
*
|
16 |
-
* @since 1.
|
17 |
-
*
|
18 |
-
* @param object $polylang
|
19 |
*/
|
20 |
-
public function
|
21 |
-
parent::
|
22 |
|
23 |
-
if (!did_action('pll_language_defined'))
|
24 |
$this->set_language_from_url();
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
/*
|
@@ -30,34 +31,72 @@ class PLL_Choose_Lang_Url extends PLL_Choose_lang {
|
|
30 |
* @since 1.2
|
31 |
*/
|
32 |
public function set_language_from_url() {
|
33 |
-
$host = str_replace('www.', '', parse_url($this->links_model->home, PHP_URL_HOST));
|
34 |
-
$home_path = parse_url($this->links_model->home, PHP_URL_PATH);
|
35 |
|
36 |
-
$requested_host = str_replace('www.', '', $_SERVER['HTTP_HOST']);
|
37 |
-
$requested_uri = rtrim(str_replace($this->index, '', $_SERVER['REQUEST_URI']), '/'); // some PHP setups turn requests for / into /index.php in REQUEST_URI
|
38 |
|
39 |
// home is resquested
|
40 |
-
if ($requested_host == $host && $requested_uri == $home_path && empty($_SERVER['QUERY_STRING'])) {
|
41 |
$this->home_language();
|
42 |
-
add_action('setup_theme', array(&$this, 'home_requested'));
|
43 |
}
|
44 |
|
45 |
// take care to post & page preview http://wordpress.org/support/topic/static-frontpage-url-parameter-url-language-information
|
46 |
-
elseif (isset($_GET['preview']) && ( (isset($_GET['p']) && $id = $_GET['p']) || (isset($_GET['page_id']) && $id = $_GET['page_id']) ))
|
47 |
-
$curlang = ($lg = $this->model->
|
|
|
48 |
|
49 |
-
// take care to (unattached) attachments
|
50 |
-
elseif (isset($_GET['attachment_id']) && $id = $_GET['attachment_id'])
|
51 |
-
|
|
|
52 |
|
53 |
-
elseif ($slug = $this->links_model->get_language_from_url())
|
54 |
-
$curlang = $this->model->get_language($slug);
|
|
|
55 |
|
56 |
-
elseif ($this->options['hide_default'])
|
57 |
-
$curlang = $this->model->get_language($this->options['default_lang']);
|
|
|
58 |
|
59 |
// if no language found, check_language_code_in_url will attempt to find one and redirect to the correct url
|
60 |
// otherwise 404 will be fired in the preferred language
|
61 |
-
$this->set_language(empty($curlang) ? $this->get_preferred_language() : $curlang);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
63 |
}
|
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
|
|
|
|
|
17 |
*/
|
18 |
+
public function init() {
|
19 |
+
parent::init();
|
20 |
|
21 |
+
if ( ! did_action( 'pll_language_defined' ) ) {
|
22 |
$this->set_language_from_url();
|
23 |
+
}
|
24 |
+
|
25 |
+
add_action( 'request', array( &$this, 'request' ) );
|
26 |
}
|
27 |
|
28 |
/*
|
31 |
* @since 1.2
|
32 |
*/
|
33 |
public function set_language_from_url() {
|
34 |
+
$host = str_replace( 'www.', '', parse_url( $this->links_model->home, PHP_URL_HOST ) );
|
35 |
+
$home_path = parse_url( $this->links_model->home, PHP_URL_PATH );
|
36 |
|
37 |
+
$requested_host = str_replace( 'www.', '', $_SERVER['HTTP_HOST'] );
|
38 |
+
$requested_uri = rtrim( str_replace( $this->index, '', $_SERVER['REQUEST_URI'] ), '/' ); // some PHP setups turn requests for / into /index.php in REQUEST_URI
|
39 |
|
40 |
// home is resquested
|
41 |
+
if ( $requested_host == $host && $requested_uri == $home_path && empty( $_SERVER['QUERY_STRING'] ) ) {
|
42 |
$this->home_language();
|
43 |
+
add_action( 'setup_theme', array( &$this, 'home_requested' ) );
|
44 |
}
|
45 |
|
46 |
// take care to post & page preview http://wordpress.org/support/topic/static-frontpage-url-parameter-url-language-information
|
47 |
+
elseif ( isset( $_GET['preview'] ) && ( ( isset( $_GET['p'] ) && $id = (int) $_GET['p'] ) || ( isset( $_GET['page_id'] ) && $id = (int) $_GET['page_id'] ) ) ) {
|
48 |
+
$curlang = ( $lg = $this->model->post->get_language( $id ) ) ? $lg : $this->model->get_language( $this->options['default_lang'] );
|
49 |
+
}
|
50 |
|
51 |
+
// take care to ( unattached ) attachments
|
52 |
+
elseif ( isset( $_GET['attachment_id'] ) && $id = (int) $_GET['attachment_id'] ) {
|
53 |
+
$curlang = ( $lg = $this->model->post->get_language( $id ) ) ? $lg : $this->get_preferred_language();
|
54 |
+
}
|
55 |
|
56 |
+
elseif ( $slug = $this->links_model->get_language_from_url() ) {
|
57 |
+
$curlang = $this->model->get_language( $slug );
|
58 |
+
}
|
59 |
|
60 |
+
elseif ( $this->options['hide_default'] ) {
|
61 |
+
$curlang = $this->model->get_language( $this->options['default_lang'] );
|
62 |
+
}
|
63 |
|
64 |
// if no language found, check_language_code_in_url will attempt to find one and redirect to the correct url
|
65 |
// otherwise 404 will be fired in the preferred language
|
66 |
+
$this->set_language( empty( $curlang ) ? $this->get_preferred_language() : $curlang );
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/*
|
71 |
+
* adds the current language in query vars
|
72 |
+
* useful for subdomains and multiple domains
|
73 |
+
*
|
74 |
+
* @since 1.8
|
75 |
+
*
|
76 |
+
* @param array $qv main request query vars
|
77 |
+
* @return array modified query vars
|
78 |
+
*/
|
79 |
+
public function request( $qv ) {
|
80 |
+
// FIXME take care not to break untranslated content
|
81 |
+
// FIXME media ?
|
82 |
+
|
83 |
+
// untranslated post types
|
84 |
+
if ( isset( $qv['post_type'] ) && ! $this->model->is_translated_post_type( $qv['post_type'] ) ) {
|
85 |
+
return $qv;
|
86 |
+
}
|
87 |
+
|
88 |
+
// untranslated taxonomies
|
89 |
+
$tax_qv = array_filter( wp_list_pluck( get_taxonomies( array(), 'objects' ), 'query_var' ) ); // get all taxonomies query vars
|
90 |
+
$tax_qv = array_intersect( $tax_qv, array_keys( $qv ) ); // get all queried taxonomies query vars
|
91 |
+
|
92 |
+
if ( ! $this->model->is_translated_taxonomy( array_keys( $tax_qv ) ) ) {
|
93 |
+
return $qv;
|
94 |
+
}
|
95 |
+
|
96 |
+
if ( isset( $this->curlang ) && empty( $qv['lang'] ) ) {
|
97 |
+
$qv['lang'] = $this->curlang->slug;
|
98 |
+
}
|
99 |
+
|
100 |
+
return $qv;
|
101 |
}
|
102 |
}
|
frontend/choose-lang.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*/
|
8 |
abstract class PLL_Choose_Lang {
|
9 |
public $links_model, $model, $options;
|
10 |
-
public $
|
11 |
|
12 |
/*
|
13 |
* constructor
|
@@ -16,20 +16,28 @@ abstract class PLL_Choose_Lang {
|
|
16 |
*
|
17 |
* @param object $polylang
|
18 |
*/
|
19 |
-
public function __construct(&$polylang) {
|
20 |
$this->links_model = &$polylang->links_model;
|
21 |
$this->model = &$polylang->model;
|
22 |
$this->options = &$polylang->options;
|
23 |
|
24 |
-
$this->page_on_front = &$polylang->links->page_on_front;
|
25 |
-
$this->page_for_posts = &$polylang->links->page_for_posts;
|
26 |
$this->curlang = &$polylang->curlang;
|
|
|
27 |
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
add_action('pre_comment_on_post', array(&$this, 'pre_comment_on_post')); // sets the language of comment
|
32 |
-
add_action('parse_query', array(&$this, 'parse_main_query'), 2); // sets the language in special cases
|
33 |
}
|
34 |
|
35 |
/*
|
@@ -41,19 +49,20 @@ abstract class PLL_Choose_Lang {
|
|
41 |
*
|
42 |
* @param object $curlang current language
|
43 |
*/
|
44 |
-
protected function set_language($curlang) {
|
45 |
// don't set the language a second time
|
46 |
-
if (isset($this->curlang))
|
47 |
return;
|
|
|
48 |
|
49 |
// final check in case $curlang has an unexpected value
|
50 |
// see https://wordpress.org/support/topic/detect-browser-language-sometimes-setting-null-language
|
51 |
-
$this->curlang = ($curlang instanceof PLL_Language) ? $curlang : $this->model->get_language($this->options['default_lang']);
|
52 |
|
53 |
$this->maybe_setcookie();
|
54 |
|
55 |
$GLOBALS['text_direction'] = $this->curlang->is_rtl ? 'rtl' : 'ltr';
|
56 |
-
do_action('pll_language_defined', $this->curlang->slug, $this->curlang);
|
57 |
}
|
58 |
|
59 |
/*
|
@@ -64,79 +73,105 @@ abstract class PLL_Choose_Lang {
|
|
64 |
*/
|
65 |
protected function maybe_setcookie() {
|
66 |
// check headers have not been sent to avoid ugly error
|
67 |
-
// cookie domain must be set to false for localhost (default value for COOKIE_DOMAIN) thanks to Stephen Harris.
|
68 |
-
if (!headers_sent() && PLL_COOKIE !== false && (!isset($_COOKIE[PLL_COOKIE]) || $_COOKIE[PLL_COOKIE] != $this->curlang->slug))
|
69 |
setcookie(
|
70 |
PLL_COOKIE,
|
71 |
$this->curlang->slug,
|
72 |
-
time() +
|
73 |
COOKIEPATH,
|
74 |
-
2 == $this->options['force_lang'] ? parse_url($this->links_model->home, PHP_URL_HOST) : COOKIE_DOMAIN
|
75 |
);
|
|
|
76 |
}
|
77 |
|
78 |
/*
|
79 |
-
*
|
|
|
80 |
*
|
81 |
-
* @since
|
82 |
*
|
83 |
-
* @return
|
84 |
*/
|
85 |
-
public function
|
86 |
-
|
87 |
-
if (isset($_COOKIE[PLL_COOKIE]))
|
88 |
-
return $this->model->get_language($_COOKIE[PLL_COOKIE]);
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
$accept_langs = array();
|
94 |
-
|
95 |
-
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
96 |
-
// break up string into pieces (languages and q factors)
|
97 |
-
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
|
98 |
|
99 |
-
|
100 |
-
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
121 |
}
|
122 |
-
$accept_langs = array_combine($k,$v);
|
123 |
}
|
|
|
124 |
}
|
|
|
|
|
|
|
|
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
foreach (
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
}
|
133 |
-
} // options['browser']
|
134 |
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
// 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
|
139 |
-
return ($lang = $this->model->get_language($slug)) ? $lang : $this->model->get_language($this->options['default_lang']);
|
140 |
}
|
141 |
|
142 |
/*
|
@@ -147,11 +182,10 @@ abstract class PLL_Choose_Lang {
|
|
147 |
protected function home_language() {
|
148 |
// test referer in case PLL_COOKIE is set to false
|
149 |
// thanks to Ov3rfly http://wordpress.org/support/topic/enhance-feature-when-front-page-is-visited-set-language-according-to-browser
|
150 |
-
$this->
|
151 |
-
$this->
|
152 |
-
|
153 |
-
|
154 |
-
);
|
155 |
}
|
156 |
|
157 |
/*
|
@@ -163,34 +197,22 @@ abstract class PLL_Choose_Lang {
|
|
163 |
*/
|
164 |
public function home_requested() {
|
165 |
// we are already on the right page
|
166 |
-
if ($this->options['default_lang'] == $this->curlang->slug && $this->options['hide_default']) {
|
167 |
-
$this->
|
|
|
168 |
}
|
169 |
// redirect to the home page in the right language
|
170 |
// test to avoid crash if get_home_url returns something wrong
|
171 |
// FIXME why this happens? http://wordpress.org/support/topic/polylang-crashes-1
|
172 |
// don't redirect if $_POST is not empty as it could break other plugins
|
173 |
// don't forget the query string which may be added by plugins
|
174 |
-
elseif (is_string($redirect = $this->curlang->home_url) && empty($_POST)) {
|
175 |
-
$redirect = empty($_SERVER['QUERY_STRING']) ? $redirect : $redirect . ($this->links_model->using_permalinks ? '?' : '&') . $_SERVER['QUERY_STRING'];
|
176 |
-
if ($redirect = apply_filters('pll_redirect_home', $redirect)) {
|
177 |
-
wp_redirect($redirect);
|
178 |
exit;
|
179 |
}
|
180 |
}
|
181 |
-
|
182 |
-
}
|
183 |
-
|
184 |
-
/*
|
185 |
-
* Adds query vars to query for home page
|
186 |
-
*
|
187 |
-
* @since 1.5
|
188 |
-
*/
|
189 |
-
protected function set_home_query_var() {
|
190 |
-
if ($this->page_on_front)
|
191 |
-
set_query_var('page_id', $this->page_on_front);
|
192 |
-
else
|
193 |
-
$this->set_lang_query_var($GLOBALS['wp_query'], $this->curlang);
|
194 |
}
|
195 |
|
196 |
/*
|
@@ -200,99 +222,51 @@ abstract class PLL_Choose_Lang {
|
|
200 |
*
|
201 |
* @param int $post_id the post beeing commented
|
202 |
*/
|
203 |
-
public function pre_comment_on_post($post_id) {
|
204 |
-
$this->set_language($this->model->
|
205 |
}
|
206 |
|
207 |
/*
|
208 |
* modifies some main query vars for home page and page for posts
|
209 |
-
* to enable one home page (and one page for posts) per language
|
210 |
*
|
211 |
* @since 1.2
|
212 |
*
|
213 |
* @param object $query instance of WP_Query
|
214 |
*/
|
215 |
-
public function parse_main_query($query) {
|
216 |
-
if (
|
217 |
return;
|
218 |
-
|
219 |
-
$qv = $query->query_vars;
|
220 |
-
|
221 |
-
// redirect the language page to the homepage when using a static front page
|
222 |
-
if ($this->options['redirect_lang'] && $this->page_on_front && (count($query->query) == 1 || (is_paged() && count($query->query) == 2)) && is_tax('language')) {
|
223 |
-
$this->set_language($this->model->get_language(get_query_var('lang')));
|
224 |
-
$query->set('page_id', $this->page_on_front);
|
225 |
-
$query->is_singular = $query->is_page = true;
|
226 |
-
$query->is_archive = $query->is_tax = false;
|
227 |
-
unset($query->query_vars['lang'], $query->queried_object); // reset queried object
|
228 |
}
|
229 |
|
230 |
-
|
231 |
-
|
232 |
-
$
|
233 |
-
|
234 |
-
// correct <!--nextpage--> for page_on_front
|
235 |
-
if (!empty($page_id) && in_array($page_id, $this->model->get_translations('post', $this->page_on_front)) && !empty($qv['paged'])) {
|
236 |
-
$query->set('page', $qv['paged']);
|
237 |
-
unset($query->query_vars['paged']);
|
238 |
-
}
|
239 |
}
|
240 |
|
241 |
// sets is_home on translated home page when it displays posts
|
242 |
// is_home must be true on page 2, 3... too
|
243 |
// as well as when searching an empty string: http://wordpress.org/support/topic/plugin-polylang-polylang-breaks-search-in-spun-theme
|
244 |
-
if (
|
245 |
-
$this->set_language($this->model->get_language(get_query_var('lang'))); // sets the language now otherwise it will be too late to filter sticky posts !
|
246 |
$query->is_home = true;
|
247 |
$query->is_archive = $query->is_tax = false;
|
248 |
}
|
249 |
-
|
250 |
-
// sets the language for posts page in case the front page displays a static page
|
251 |
-
if ($this->page_for_posts) {
|
252 |
-
$page_id = $this->get_page_id($query);
|
253 |
-
|
254 |
-
if (!empty($page_id) && in_array($page_id, $this->model->get_translations('post', $this->page_for_posts))) {
|
255 |
-
$this->set_language($this->model->get_post_language($page_id));
|
256 |
-
$this->set_lang_query_var($query, $this->curlang);
|
257 |
-
$query->is_singular = $query->is_page = false;
|
258 |
-
$query->is_home = $query->is_posts_page = true;
|
259 |
-
}
|
260 |
-
}
|
261 |
}
|
262 |
|
263 |
/*
|
264 |
* sets the language in query
|
265 |
-
* optimized for (needs) WP 3.5+
|
266 |
*
|
267 |
* @since 1.3
|
268 |
*/
|
269 |
-
public function set_lang_query_var(&$query, $lang) {
|
270 |
-
// defining directly the tax_query (rather than setting 'lang' avoids transforming the query by WP)
|
271 |
$query->query_vars['tax_query'][] = array(
|
272 |
'taxonomy' => 'language',
|
273 |
'field' => 'term_taxonomy_id', // since WP 3.5
|
274 |
'terms' => $lang->term_taxonomy_id,
|
275 |
-
'operator' => 'IN'
|
276 |
);
|
277 |
}
|
278 |
-
|
279 |
-
/*
|
280 |
-
* get queried page_id (if exists)
|
281 |
-
* If permalinks are used, WordPress does set and use $query->queried_object_id and sets $query->query_vars['page_id'] to 0
|
282 |
-
* and does set and use $query->query_vars['page_id'] if permalinks are not used :(
|
283 |
-
*
|
284 |
-
* @since 1.5
|
285 |
-
*
|
286 |
-
* @param object $query instance of WP_Query
|
287 |
-
* @return int page_id
|
288 |
-
*/
|
289 |
-
protected function get_page_id($query) {
|
290 |
-
if (!empty($query->query_vars['pagename']) && isset($query->queried_object_id))
|
291 |
-
return $query->queried_object_id;
|
292 |
-
|
293 |
-
if (isset($query->query_vars['page_id']))
|
294 |
-
return $query->query_vars['page_id'];
|
295 |
-
|
296 |
-
return 0; // no page queried
|
297 |
-
}
|
298 |
}
|
7 |
*/
|
8 |
abstract class PLL_Choose_Lang {
|
9 |
public $links_model, $model, $options;
|
10 |
+
public $curlang;
|
11 |
|
12 |
/*
|
13 |
* constructor
|
16 |
*
|
17 |
* @param object $polylang
|
18 |
*/
|
19 |
+
public function __construct( &$polylang ) {
|
20 |
$this->links_model = &$polylang->links_model;
|
21 |
$this->model = &$polylang->model;
|
22 |
$this->options = &$polylang->options;
|
23 |
|
|
|
|
|
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
|
31 |
+
*
|
32 |
+
* @since 1.8
|
33 |
+
*/
|
34 |
+
public function init() {
|
35 |
+
if ( PLL_AJAX_ON_FRONT || false === stripos( $_SERVER['PHP_SELF'], 'index.php' ) ) {
|
36 |
+
$this->set_language( empty( $_REQUEST['lang'] ) ? $this->get_preferred_language() : $this->model->get_language( $_REQUEST['lang'] ) );
|
37 |
+
}
|
38 |
|
39 |
+
add_action( 'pre_comment_on_post', array( &$this, 'pre_comment_on_post' ) ); // sets the language of comment
|
40 |
+
add_action( 'parse_query', array( &$this, 'parse_main_query' ), 2 ); // sets the language in special cases
|
41 |
}
|
42 |
|
43 |
/*
|
49 |
*
|
50 |
* @param object $curlang current language
|
51 |
*/
|
52 |
+
protected function set_language( $curlang ) {
|
53 |
// don't set the language a second time
|
54 |
+
if ( isset( $this->curlang ) ) {
|
55 |
return;
|
56 |
+
}
|
57 |
|
58 |
// final check in case $curlang has an unexpected value
|
59 |
// see https://wordpress.org/support/topic/detect-browser-language-sometimes-setting-null-language
|
60 |
+
$this->curlang = ( $curlang instanceof PLL_Language ) ? $curlang : $this->model->get_language( $this->options['default_lang'] );
|
61 |
|
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 |
/*
|
73 |
*/
|
74 |
protected function maybe_setcookie() {
|
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() + apply_filters( 'pll_cookie_expiration', YEAR_IN_SECONDS ),
|
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 |
*
|
92 |
+
* @since 1.8
|
93 |
*
|
94 |
+
* @return string|bool the preferred language slug or false
|
95 |
*/
|
96 |
+
public function get_preferred_browser_language() {
|
97 |
+
$accept_langs = array();
|
|
|
|
|
98 |
|
99 |
+
if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
|
100 |
+
// break up string into pieces ( languages and q factors )
|
101 |
+
preg_match_all( '/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*( 1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse );
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
+
$k = $lang_parse[1];
|
104 |
+
$v = $lang_parse[4];
|
105 |
|
106 |
+
if ( $n = count( $k ) ) {
|
107 |
+
// set default to 1 for any without q factor
|
108 |
+
foreach ( $v as $key => $val ) {
|
109 |
+
if ( '' === $val ) {
|
110 |
+
$v[ $key ] = 1;
|
111 |
+
}
|
112 |
+
}
|
113 |
|
114 |
+
// bubble sort ( need a stable sort for Android, so can't use a PHP sort function )
|
115 |
+
if ( $n > 1 ) {
|
116 |
+
for ( $i = 2; $i <= $n; $i++ ) {
|
117 |
+
for ( $j = 0; $j <= $n - 2; $j++ ) {
|
118 |
+
if ( $v[ $j ] < $v[ $j + 1 ] ) {
|
119 |
+
// swap values
|
120 |
+
$temp = $v[ $j ];
|
121 |
+
$v[ $j ] = $v[ $j + 1 ];
|
122 |
+
$v[ $j + 1 ] = $temp;
|
123 |
+
//swap keys
|
124 |
+
$temp = $k[ $j ];
|
125 |
+
$k[ $j ] = $k[ $j + 1 ];
|
126 |
+
$k[ $j + 1 ] = $temp;
|
127 |
+
}
|
128 |
+
}
|
129 |
}
|
|
|
130 |
}
|
131 |
+
$accept_langs = array_combine( $k,$v );
|
132 |
}
|
133 |
+
}
|
134 |
+
|
135 |
+
// looks through sorted list and use first one that matches our language list
|
136 |
+
$listlanguages = $this->model->get_languages_list( array( 'hide_empty' => true ) ); // hides languages with no post
|
137 |
|
138 |
+
foreach ( array_keys( $accept_langs ) as $accept_lang ) {
|
139 |
+
// first loop to match the exact locale
|
140 |
+
foreach ( $listlanguages as $language ) {
|
141 |
+
if ( 0 === strcasecmp( $accept_lang, $language->get_locale( 'display' ) ) ) {
|
142 |
+
return $language->slug;
|
143 |
+
}
|
144 |
}
|
|
|
145 |
|
146 |
+
// second loop to match the language set
|
147 |
+
foreach ( $listlanguages as $language ) {
|
148 |
+
if ( 0 === stripos( $accept_lang, $language->slug ) || 0 === stripos( $language->get_locale( 'display' ), $accept_lang ) ) {
|
149 |
+
return $language->slug;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
return false;
|
154 |
+
}
|
155 |
+
|
156 |
+
/*
|
157 |
+
* returns the language according to browser preference or the default language
|
158 |
+
*
|
159 |
+
* @since 0.1
|
160 |
+
*
|
161 |
+
* @return object browser preferred language or default language
|
162 |
+
*/
|
163 |
+
public function get_preferred_language() {
|
164 |
+
// check first if the user was already browsing this site
|
165 |
+
if ( isset( $_COOKIE[ PLL_COOKIE ] ) ) {
|
166 |
+
return $this->model->get_language( $_COOKIE[ PLL_COOKIE ] );
|
167 |
+
}
|
168 |
+
|
169 |
+
// sets the browsing language according to the browser preferences
|
170 |
+
// allow plugin to modify the preferred language ( useful for example to have a different fallback than the default language )
|
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 |
/*
|
182 |
protected function home_language() {
|
183 |
// test referer in case PLL_COOKIE is set to false
|
184 |
// thanks to Ov3rfly http://wordpress.org/support/topic/enhance-feature-when-front-page-is-visited-set-language-according-to-browser
|
185 |
+
$language = $this->options['hide_default'] && ( ( isset( $_SERVER['HTTP_REFERER'] ) && in_array( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_HOST ), $this->links_model->get_hosts() ) ) || ! $this->options['browser'] ) ?
|
186 |
+
$this->model->get_language( $this->options['default_lang'] ) :
|
187 |
+
$this->get_preferred_language(); // sets the language according to browser preference or default language
|
188 |
+
$this->set_language( $language );
|
|
|
189 |
}
|
190 |
|
191 |
/*
|
197 |
*/
|
198 |
public function home_requested() {
|
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
|
205 |
// test to avoid crash if get_home_url returns something wrong
|
206 |
// FIXME why this happens? http://wordpress.org/support/topic/polylang-crashes-1
|
207 |
// don't redirect if $_POST is not empty as it could break other plugins
|
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;
|
214 |
}
|
215 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
|
218 |
/*
|
222 |
*
|
223 |
* @param int $post_id the post beeing commented
|
224 |
*/
|
225 |
+
public function pre_comment_on_post( $post_id ) {
|
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 |
*
|
233 |
* @since 1.2
|
234 |
*
|
235 |
* @param object $query instance of WP_Query
|
236 |
*/
|
237 |
+
public function parse_main_query( $query ) {
|
238 |
+
if ( ! $query->is_main_query() ) {
|
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 );
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
}
|
246 |
|
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'] ) ) && is_tax( 'language' ) ) {
|
251 |
+
$this->set_language( $this->model->get_language( get_query_var( 'lang' ) ) ); // sets the language now otherwise it will be too late to filter sticky posts !
|
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 |
*
|
261 |
* @since 1.3
|
262 |
*/
|
263 |
+
public function set_lang_query_var( &$query, $lang ) {
|
264 |
+
// defining directly the tax_query ( rather than setting 'lang' avoids transforming the query by WP )
|
265 |
$query->query_vars['tax_query'][] = array(
|
266 |
'taxonomy' => 'language',
|
267 |
'field' => 'term_taxonomy_id', // since WP 3.5
|
268 |
'terms' => $lang->term_taxonomy_id,
|
269 |
+
'operator' => 'IN',
|
270 |
);
|
271 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
}
|
frontend/frontend-auto-translate.php
CHANGED
@@ -6,8 +6,7 @@
|
|
6 |
* @since 1.1
|
7 |
*/
|
8 |
class PLL_Frontend_Auto_Translate {
|
9 |
-
public $model;
|
10 |
-
|
11 |
|
12 |
/*
|
13 |
* constructor
|
@@ -16,11 +15,36 @@ class PLL_Frontend_Auto_Translate {
|
|
16 |
*
|
17 |
* @param object $polylang
|
18 |
*/
|
19 |
-
public function __construct(&$polylang) {
|
20 |
$this->model = &$polylang->model;
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
/*
|
@@ -30,124 +54,131 @@ class PLL_Frontend_Auto_Translate {
|
|
30 |
*
|
31 |
* @param object $query WP_Query object
|
32 |
*/
|
33 |
-
public function pre_get_posts($query) {
|
34 |
global $wpdb;
|
35 |
$qv = &$query->query_vars;
|
36 |
|
37 |
-
if ($query->is_main_query() || !empty($qv['lang']) || (!empty($qv['post_type']) &&
|
38 |
return;
|
39 |
-
|
40 |
-
$sign = create_function('$n', 'return $n > 0 ? 1 : ($n < 0 ? -1 : 0);');
|
41 |
|
42 |
// /!\ always keep untranslated as is
|
43 |
|
44 |
// term ids separated by a comma
|
45 |
$arr = array();
|
46 |
-
if (!empty($qv['cat'])) {
|
47 |
-
foreach (explode(',', $qv['cat']) as $cat)
|
48 |
-
$
|
|
|
|
|
49 |
|
50 |
-
$qv['cat'] = implode(',', $arr);
|
51 |
}
|
52 |
|
53 |
// category_name
|
54 |
$arr = array();
|
55 |
-
if (!empty($qv['category_name'])) {
|
56 |
-
foreach (explode(',', $qv['category_name']) as $slug)
|
57 |
-
$arr[] = (($cat = get_category_by_slug($slug)) && ($tr_id =
|
58 |
-
|
59 |
|
60 |
-
$qv['category_name'] = implode(',', $arr);
|
61 |
}
|
62 |
|
63 |
// array of term ids
|
64 |
-
foreach (array('category__and', 'category__in', 'category__not_in', 'tag__and', 'tag__in', 'tag__not_in') as $key) {
|
65 |
$arr = array();
|
66 |
-
if (!empty($qv[$key])) {
|
67 |
-
foreach ($qv[$key] as $cat)
|
68 |
-
$arr[] = ($tr =
|
69 |
-
|
70 |
-
$qv[$key] = $arr;
|
71 |
}
|
72 |
}
|
73 |
|
74 |
// tag
|
75 |
$arr = array();
|
76 |
-
if (!empty($qv['tag'])) {
|
77 |
-
$sep = strpos($qv['tag'], ',') !== false ? ',' : '+'; // two possible separators for tag slugs
|
78 |
-
foreach (explode($sep, $qv['tag']) as $slug)
|
79 |
-
$arr[] = (($tag = get_term_by('slug', $slug, 'post_tag')) && ($tr_id =
|
80 |
-
|
81 |
|
82 |
-
$qv['tag'] = implode($sep, $arr);
|
83 |
}
|
84 |
|
85 |
// tag_id can only take one id
|
86 |
-
if (!empty($qv['tag_id']) && $tr_id =
|
87 |
$qv['tag_id'] = $tr_id;
|
88 |
-
|
89 |
|
90 |
// array of tag slugs
|
91 |
-
foreach (array('tag_slug__and', 'tag_slug__in') as $key) {
|
92 |
$arr = array();
|
93 |
-
if (!empty($qv[$key])) {
|
94 |
-
foreach ($qv[$key] as $slug)
|
95 |
-
$arr[] = (($tag = get_term_by('slug', $slug, 'post_tag')) && ($tr_id =
|
96 |
-
|
97 |
|
98 |
-
$qv[$key] = $arr;
|
99 |
}
|
100 |
}
|
101 |
|
102 |
// custom taxonomies
|
103 |
// according to codex, this type of query is deprecated as of WP 3.1 but it does not appear in WP 3.5 source code
|
104 |
-
foreach (array_intersect($this->model->get_translated_taxonomies(), get_taxonomies(array('_builtin' => false))) as $taxonomy) {
|
105 |
-
$tax = get_taxonomy($taxonomy);
|
106 |
$arr = array();
|
107 |
-
if (!empty($qv[$tax->query_var])) {
|
108 |
-
$sep = strpos($qv[$tax->query_var], ',') !== false ? ',' : '+'; // two possible separators
|
109 |
-
foreach (explode($sep, $qv[$tax->query_var]) as $slug)
|
110 |
-
$arr[] = (($tag = get_term_by('slug', $slug, $taxonomy)) && ($tr_id =
|
111 |
-
|
112 |
|
113 |
-
$qv[$tax->query_var] = implode($sep, $arr);
|
114 |
}
|
115 |
}
|
116 |
|
117 |
// tax_query since WP 3.1
|
118 |
-
if (!empty($qv['tax_query']) && is_array($qv['tax_query']))
|
119 |
-
$qv['tax_query'] = $this->translate_tax_query_recursive($qv['tax_query']);
|
|
|
120 |
|
121 |
// p, page_id, post_parent can only take one id
|
122 |
-
foreach (array('p', 'page_id', 'post_parent') as $key)
|
123 |
-
if (!empty($qv[$key]) && $tr_id =
|
124 |
-
$qv[$key] = $tr_id;
|
|
|
|
|
125 |
|
126 |
// name, pagename can only take one slug
|
127 |
-
foreach (array('name', 'pagename') as $key) {
|
128 |
-
if (!empty($qv[$key])) {
|
129 |
// no function to get post by name except get_posts itself
|
130 |
-
$post_type = empty($qv['post_type']) ? 'post' : $qv['post_type'];
|
131 |
-
$id = $wpdb->get_var($wpdb->prepare("SELECT ID from $wpdb->posts WHERE post_type=%s AND post_name=%s", $post_type, $qv[$key]));
|
132 |
-
$qv[$key] = ($id && ($tr_id =
|
133 |
}
|
134 |
}
|
135 |
|
136 |
// array of post ids
|
137 |
// post_parent__in & post_parent__not_in since WP 3.6
|
138 |
-
foreach (array('post__in', 'post__not_in', 'post_parent__in', 'post_parent__not_in') as $key) {
|
139 |
$arr = array();
|
140 |
-
if (!empty($qv[$key])) {
|
141 |
// post__in used by the 2 functions below
|
142 |
// useless to filter them as output is already in the right language and would result in performance loss
|
143 |
-
foreach (debug_backtrace() as $trace)
|
144 |
-
if (in_array($trace['function'], array('wp_nav_menu', 'gallery_shortcode')))
|
145 |
return;
|
|
|
|
|
146 |
|
147 |
-
foreach ($qv[$key] as $p)
|
148 |
-
$arr[] = ($tr =
|
|
|
149 |
|
150 |
-
$qv[$key] = $arr;
|
151 |
}
|
152 |
}
|
153 |
}
|
@@ -161,10 +192,11 @@ class PLL_Frontend_Auto_Translate {
|
|
161 |
* @param array $taxonomies
|
162 |
* @return array modified $args
|
163 |
*/
|
164 |
-
public function get_terms_args($args, $taxonomies) {
|
165 |
-
if (!empty($args['include']) && $this->model->is_translated_taxonomy($taxonomies)) {
|
166 |
-
foreach(wp_parse_id_list($args['include']) as $id)
|
167 |
-
$arr[] = ($tr =
|
|
|
168 |
|
169 |
$args['include'] = $arr;
|
170 |
}
|
@@ -180,21 +212,21 @@ class PLL_Frontend_Auto_Translate {
|
|
180 |
* @param array $tax_queries
|
181 |
* @return array translated tax queries
|
182 |
*/
|
183 |
-
protected function translate_tax_query_recursive($tax_queries) {
|
184 |
-
foreach ($tax_queries as $key => $q) {
|
185 |
-
if (isset($q['taxonomy']) && $this->model->is_translated_taxonomy($q['taxonomy'])) {
|
186 |
$arr = array();
|
187 |
-
$field = isset($q['field']) && in_array($q['field'], array('slug', 'name')) ? $q['field'] : 'term_id';
|
188 |
-
foreach ( (array) $q['terms'] as $t)
|
189 |
-
$arr[] = (($tag = get_term_by($field, $t, $q['taxonomy'])) && ($tr_id =
|
190 |
-
|
191 |
|
192 |
-
$tax_queries[$key]['terms'] = $arr;
|
193 |
}
|
194 |
|
195 |
// nested queries
|
196 |
-
elseif (is_array($q)) {
|
197 |
-
$tax_queries[$key] = $this->translate_tax_query_recursive($q);
|
198 |
}
|
199 |
}
|
200 |
|
6 |
* @since 1.1
|
7 |
*/
|
8 |
class PLL_Frontend_Auto_Translate {
|
9 |
+
public $model, $curlang;
|
|
|
10 |
|
11 |
/*
|
12 |
* constructor
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
+
public function __construct( &$polylang ) {
|
19 |
$this->model = &$polylang->model;
|
20 |
+
$this->curlang = &$polylang->curlang;
|
21 |
+
|
22 |
+
add_action( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); // after main Polylang filter
|
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
|
30 |
+
*
|
31 |
+
* @param int $post_id
|
32 |
+
* @return int
|
33 |
+
*/
|
34 |
+
protected function get_post( $post_id ) {
|
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
|
42 |
+
*
|
43 |
+
* @param int $term_id
|
44 |
+
* @return int
|
45 |
+
*/
|
46 |
+
protected function get_term( $term_id ) {
|
47 |
+
return $this->model->term->get( $term_id, $this->curlang );
|
48 |
}
|
49 |
|
50 |
/*
|
54 |
*
|
55 |
* @param object $query WP_Query object
|
56 |
*/
|
57 |
+
public function pre_get_posts( $query ) {
|
58 |
global $wpdb;
|
59 |
$qv = &$query->query_vars;
|
60 |
|
61 |
+
if ( $query->is_main_query() || ! empty( $qv['lang'] ) || ( ! empty( $qv['post_type'] ) && ! $this->model->is_translated_post_type( $qv['post_type'] ) ) ) {
|
62 |
return;
|
63 |
+
}
|
|
|
64 |
|
65 |
// /!\ always keep untranslated as is
|
66 |
|
67 |
// term ids separated by a comma
|
68 |
$arr = array();
|
69 |
+
if ( ! empty( $qv['cat'] ) ) {
|
70 |
+
foreach ( explode( ',', $qv['cat'] ) as $cat ) {
|
71 |
+
$tr = $this->get_term( abs( $cat ) );
|
72 |
+
$arr[] = $cat < 0 ? -$tr : $tr;
|
73 |
+
}
|
74 |
|
75 |
+
$qv['cat'] = implode( ',', $arr );
|
76 |
}
|
77 |
|
78 |
// category_name
|
79 |
$arr = array();
|
80 |
+
if ( ! empty( $qv['category_name'] ) ) {
|
81 |
+
foreach ( explode( ',', $qv['category_name'] ) as $slug ) {
|
82 |
+
$arr[] = ( ( $cat = get_category_by_slug( $slug ) ) && ( $tr_id = $this->get_term( $cat->term_id ) ) && ! is_wp_error( $tr = get_category( $tr_id ) ) ) ? $tr->slug : $slug;
|
83 |
+
}
|
84 |
|
85 |
+
$qv['category_name'] = implode( ',', $arr );
|
86 |
}
|
87 |
|
88 |
// array of term ids
|
89 |
+
foreach ( array( 'category__and', 'category__in', 'category__not_in', 'tag__and', 'tag__in', 'tag__not_in' ) as $key ) {
|
90 |
$arr = array();
|
91 |
+
if ( ! empty( $qv[ $key ] ) ) {
|
92 |
+
foreach ( $qv[ $key ] as $cat ) {
|
93 |
+
$arr[] = ( $tr = $this->get_term( $cat ) ) ? $tr : $cat;
|
94 |
+
}
|
95 |
+
$qv[ $key ] = $arr;
|
96 |
}
|
97 |
}
|
98 |
|
99 |
// tag
|
100 |
$arr = array();
|
101 |
+
if ( ! empty( $qv['tag'] ) ) {
|
102 |
+
$sep = strpos( $qv['tag'], ',' ) !== false ? ',' : '+'; // two possible separators for tag slugs
|
103 |
+
foreach ( explode( $sep, $qv['tag'] ) as $slug ) {
|
104 |
+
$arr[] = ( ( $tag = get_term_by( 'slug', $slug, 'post_tag' ) ) && ( $tr_id = $this->get_term( $tag->term_id ) ) && ! is_wp_error( $tr = get_tag( $tr_id ) ) ) ? $tr->slug : $slug;
|
105 |
+
}
|
106 |
|
107 |
+
$qv['tag'] = implode( $sep, $arr );
|
108 |
}
|
109 |
|
110 |
// tag_id can only take one id
|
111 |
+
if ( ! empty( $qv['tag_id'] ) && $tr_id = $this->get_term( $qv['tag_id'] ) ) {
|
112 |
$qv['tag_id'] = $tr_id;
|
113 |
+
}
|
114 |
|
115 |
// array of tag slugs
|
116 |
+
foreach ( array( 'tag_slug__and', 'tag_slug__in' ) as $key ) {
|
117 |
$arr = array();
|
118 |
+
if ( ! empty( $qv[ $key ] ) ) {
|
119 |
+
foreach ( $qv[ $key ] as $slug ) {
|
120 |
+
$arr[] = ( ( $tag = get_term_by( 'slug', $slug, 'post_tag' ) ) && ( $tr_id = $this->get_term( $tag->term_id ) ) && ! is_wp_error( $tr = get_tag( $tr_id ) ) ) ? $tr->slug : $slug;
|
121 |
+
}
|
122 |
|
123 |
+
$qv[ $key ] = $arr;
|
124 |
}
|
125 |
}
|
126 |
|
127 |
// custom taxonomies
|
128 |
// according to codex, this type of query is deprecated as of WP 3.1 but it does not appear in WP 3.5 source code
|
129 |
+
foreach ( array_intersect( $this->model->get_translated_taxonomies(), get_taxonomies( array( '_builtin' => false ) ) ) as $taxonomy ) {
|
130 |
+
$tax = get_taxonomy( $taxonomy );
|
131 |
$arr = array();
|
132 |
+
if ( ! empty( $qv[ $tax->query_var ] ) ) {
|
133 |
+
$sep = strpos( $qv[ $tax->query_var ], ',' ) !== false ? ',' : '+'; // two possible separators
|
134 |
+
foreach ( explode( $sep, $qv[ $tax->query_var ] ) as $slug ) {
|
135 |
+
$arr[] = ( ( $tag = get_term_by( 'slug', $slug, $taxonomy ) ) && ( $tr_id = $this->get_term( $tag->term_id ) ) && ! is_wp_error( $tr = get_term( $tr_id, $taxonomy ) ) ) ? $tr->slug : $slug;
|
136 |
+
}
|
137 |
|
138 |
+
$qv[ $tax->query_var ] = implode( $sep, $arr );
|
139 |
}
|
140 |
}
|
141 |
|
142 |
// tax_query since WP 3.1
|
143 |
+
if ( ! empty( $qv['tax_query'] ) && is_array( $qv['tax_query'] ) ) {
|
144 |
+
$qv['tax_query'] = $this->translate_tax_query_recursive( $qv['tax_query'] );
|
145 |
+
}
|
146 |
|
147 |
// p, page_id, post_parent can only take one id
|
148 |
+
foreach ( array( 'p', 'page_id', 'post_parent' ) as $key ) {
|
149 |
+
if ( ! empty( $qv[ $key ] ) && $tr_id = $this->get_post( $qv[ $key ] ) ) {
|
150 |
+
$qv[ $key ] = $tr_id;
|
151 |
+
}
|
152 |
+
}
|
153 |
|
154 |
// name, pagename can only take one slug
|
155 |
+
foreach ( array( 'name', 'pagename' ) as $key ) {
|
156 |
+
if ( ! empty( $qv[ $key ] ) ) {
|
157 |
// no function to get post by name except get_posts itself
|
158 |
+
$post_type = empty( $qv['post_type'] ) ? 'post' : $qv['post_type'];
|
159 |
+
$id = $wpdb->get_var( $wpdb->prepare( "SELECT ID from $wpdb->posts WHERE post_type=%s AND post_name=%s", $post_type, $qv[ $key ] ) );
|
160 |
+
$qv[ $key ] = ( $id && ( $tr_id = $this->get_post( $id ) ) && $tr = get_post( $tr_id ) ) ? $tr->post_name : $qv[ $key ];
|
161 |
}
|
162 |
}
|
163 |
|
164 |
// array of post ids
|
165 |
// post_parent__in & post_parent__not_in since WP 3.6
|
166 |
+
foreach ( array( 'post__in', 'post__not_in', 'post_parent__in', 'post_parent__not_in' ) as $key ) {
|
167 |
$arr = array();
|
168 |
+
if ( ! empty( $qv[ $key ] ) ) {
|
169 |
// post__in used by the 2 functions below
|
170 |
// useless to filter them as output is already in the right language and would result in performance loss
|
171 |
+
foreach ( debug_backtrace() as $trace ) {
|
172 |
+
if ( in_array( $trace['function'], array( 'wp_nav_menu', 'gallery_shortcode' ) ) ) {
|
173 |
return;
|
174 |
+
}
|
175 |
+
}
|
176 |
|
177 |
+
foreach ( $qv[ $key ] as $p ) {
|
178 |
+
$arr[] = ( $tr = $this->get_post( $p ) ) ? $tr : $p;
|
179 |
+
}
|
180 |
|
181 |
+
$qv[ $key ] = $arr;
|
182 |
}
|
183 |
}
|
184 |
}
|
192 |
* @param array $taxonomies
|
193 |
* @return array modified $args
|
194 |
*/
|
195 |
+
public function get_terms_args( $args, $taxonomies ) {
|
196 |
+
if ( ! empty( $args['include'] ) && $this->model->is_translated_taxonomy( $taxonomies ) ) {
|
197 |
+
foreach ( wp_parse_id_list( $args['include'] ) as $id ) {
|
198 |
+
$arr[] = ( $tr = $this->get_term( $id ) ) ? $tr : $id;
|
199 |
+
}
|
200 |
|
201 |
$args['include'] = $arr;
|
202 |
}
|
212 |
* @param array $tax_queries
|
213 |
* @return array translated tax queries
|
214 |
*/
|
215 |
+
protected function translate_tax_query_recursive( $tax_queries ) {
|
216 |
+
foreach ( $tax_queries as $key => $q ) {
|
217 |
+
if ( isset( $q['taxonomy'] ) && $this->model->is_translated_taxonomy( $q['taxonomy'] ) ) {
|
218 |
$arr = array();
|
219 |
+
$field = isset( $q['field'] ) && in_array( $q['field'], array( 'slug', 'name' ) ) ? $q['field'] : 'term_id';
|
220 |
+
foreach ( (array) $q['terms'] as $t ) {
|
221 |
+
$arr[] = ( ( $tag = get_term_by( $field, $t, $q['taxonomy'] ) ) && ( $tr_id = $this->get_term( $tag->term_id ) ) && ! is_wp_error( $tr = get_term( $tr_id, $q['taxonomy'] ) ) ) ? $tr->$field : $t;
|
222 |
+
}
|
223 |
|
224 |
+
$tax_queries[ $key ]['terms'] = $arr;
|
225 |
}
|
226 |
|
227 |
// nested queries
|
228 |
+
elseif ( is_array( $q ) ) {
|
229 |
+
$tax_queries[ $key ] = $this->translate_tax_query_recursive( $q );
|
230 |
}
|
231 |
}
|
232 |
|
frontend/frontend-filters-links.php
ADDED
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* manages links filters on frontend
|
5 |
+
*
|
6 |
+
* @since 1.8
|
7 |
+
*/
|
8 |
+
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
|
16 |
+
*
|
17 |
+
* @since 1.8
|
18 |
+
*
|
19 |
+
* @param object $polylang
|
20 |
+
*/
|
21 |
+
public function __construct( &$polylang ) {
|
22 |
+
parent::__construct( $polylang );
|
23 |
+
|
24 |
+
$this->curlang = &$polylang->curlang;
|
25 |
+
$this->cache = new PLL_Cache();
|
26 |
+
|
27 |
+
// rewrites author and date links to filter them by language
|
28 |
+
foreach ( array( 'feed_link', 'author_link', 'search_link', 'year_link', 'month_link', 'day_link' ) as $filter ) {
|
29 |
+
add_filter( $filter, array( &$this, 'archive_link' ), 20 );
|
30 |
+
}
|
31 |
+
|
32 |
+
// rewrites post types archives links to filter them by language
|
33 |
+
add_filter( 'post_type_archive_link', array( &$this, 'post_type_archive_link' ), 20, 2 );
|
34 |
+
|
35 |
+
// meta in the html head section
|
36 |
+
add_action( 'wp_head', array( &$this, 'wp_head' ) );
|
37 |
+
|
38 |
+
// modifies the home url
|
39 |
+
if ( ! defined( 'PLL_FILTER_HOME_URL' ) || PLL_FILTER_HOME_URL ) {
|
40 |
+
add_filter( 'home_url', array( &$this, 'home_url' ), 10, 2 );
|
41 |
+
}
|
42 |
+
|
43 |
+
if ( $this->options['force_lang'] > 1 ) {
|
44 |
+
// rewrites next and previous post links when not automatically done by WordPress
|
45 |
+
add_filter( 'get_pagenum_link', array( &$this, 'archive_link' ), 20 );
|
46 |
+
|
47 |
+
// rewrites ajax url
|
48 |
+
add_filter( 'admin_url', array( &$this, 'admin_url' ), 10, 2 );
|
49 |
+
}
|
50 |
+
|
51 |
+
// redirects to canonical url before WordPress redirect_canonical
|
52 |
+
// but after Nextgen Gallery which hacks $_SERVER['REQUEST_URI'] !!! and restores it in 'template_redirect' with priority 1
|
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
|
60 |
+
*
|
61 |
+
* @param string $link
|
62 |
+
* @return string modified link
|
63 |
+
*/
|
64 |
+
public function archive_link( $link ) {
|
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 |
+
*
|
72 |
+
* @since 1.7.6
|
73 |
+
*
|
74 |
+
* @param string $link
|
75 |
+
* @param string $post_type
|
76 |
+
* @return string modified link
|
77 |
+
*/
|
78 |
+
public function post_type_archive_link( $link, $post_type ) {
|
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 |
+
*
|
86 |
+
* @since 0.7
|
87 |
+
*
|
88 |
+
* @param string $link post link
|
89 |
+
* @param object $post post object
|
90 |
+
* @return string modified post link
|
91 |
+
*/
|
92 |
+
public function post_link( $link, $post ) {
|
93 |
+
$cache_key = 'post:' . $post->ID;
|
94 |
+
if ( false === $_link = $this->cache->get( $cache_key ) ) {
|
95 |
+
$_link = parent::post_link( $link, $post );
|
96 |
+
$this->cache->set( $cache_key, $_link );
|
97 |
+
}
|
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 ) {
|
112 |
+
$cache_key = 'post:' . $post_id;
|
113 |
+
if ( false === $_link = $this->cache->get( $cache_key ) ) {
|
114 |
+
$_link = parent::_get_page_link( $link, $post_id );
|
115 |
+
$this->cache->set( $cache_key, $_link );
|
116 |
+
}
|
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 ) {
|
131 |
+
$cache_key = 'post:' . $post_id;
|
132 |
+
if ( false === $_link = $this->cache->get( $cache_key ) ) {
|
133 |
+
$_link = parent::attachment_link( $link, $post_id );
|
134 |
+
$this->cache->set( $cache_key, $_link );
|
135 |
+
}
|
136 |
+
return $_link;
|
137 |
+
}
|
138 |
+
|
139 |
+
/*
|
140 |
+
* modifies custom posts links
|
141 |
+
* caches the result
|
142 |
+
*
|
143 |
+
* @since 1.6
|
144 |
+
*
|
145 |
+
* @param string $link post link
|
146 |
+
* @param object $post post object
|
147 |
+
* @return string modified post link
|
148 |
+
*/
|
149 |
+
public function post_type_link( $link, $post ) {
|
150 |
+
$cache_key = 'post:' . $post->ID;
|
151 |
+
if ( false === $_link = $this->cache->get( $cache_key ) ) {
|
152 |
+
$_link = parent::post_type_link( $link, $post );
|
153 |
+
$this->cache->set( $cache_key, $_link );
|
154 |
+
}
|
155 |
+
return $_link;
|
156 |
+
}
|
157 |
+
|
158 |
+
/*
|
159 |
+
* modifies filtered taxonomies ( post format like ) and translated taxonomies links
|
160 |
+
* caches the result
|
161 |
+
*
|
162 |
+
* @since 0.7
|
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 ) {
|
170 |
+
$cache_key = 'term:' . $term->term_id;
|
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 |
+
|
177 |
+
else {
|
178 |
+
$_link = parent::term_link( $link, $term, $tax );
|
179 |
+
}
|
180 |
+
$this->cache->set( $cache_key, $_link );
|
181 |
+
}
|
182 |
+
return $_link;
|
183 |
+
}
|
184 |
+
|
185 |
+
/*
|
186 |
+
* outputs references to translated pages ( if exists ) in the html head section
|
187 |
+
*
|
188 |
+
* @since 0.1
|
189 |
+
*/
|
190 |
+
public function wp_head() {
|
191 |
+
// Google recommends to include self link https://support.google.com/webmasters/answer/189077?hl=en
|
192 |
+
foreach ( $this->model->get_languages_list() as $language ) {
|
193 |
+
if ( $url = $this->links->get_translation_url( $language ) ) {
|
194 |
+
$urls[ $language->get_locale( 'display' ) ] = $url;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
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 |
+
foreach ( $urls as $lang => $url ) {
|
202 |
+
printf( '<link rel="alternate" href="%s" hreflang="%s" />'."\n", esc_url( $url ), esc_attr( $lang ) );
|
203 |
+
}
|
204 |
+
|
205 |
+
// adds the site root url when the default language code is not hidden
|
206 |
+
// see https://wordpress.org/support/topic/implementation-of-hreflangx-default
|
207 |
+
if ( is_front_page() && ! $this->options['hide_default'] && $this->options['force_lang'] < 3 ) {
|
208 |
+
printf( '<link rel="alternate" href="%s" hreflang="x-default" />'."\n", esc_url( home_url( '/' ) ) );
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
/*
|
214 |
+
* filters the home url to get the right language
|
215 |
+
*
|
216 |
+
* @since 0.4
|
217 |
+
*
|
218 |
+
* @param string $url
|
219 |
+
* @param string $path
|
220 |
+
* @return string
|
221 |
+
*/
|
222 |
+
public function home_url( $url, $path ) {
|
223 |
+
if ( ! ( did_action( 'template_redirect' ) || did_action( 'login_init' ) ) || rtrim( $url,'/' ) != $this->links_model->home ) {
|
224 |
+
return $url;
|
225 |
+
}
|
226 |
+
|
227 |
+
static $white_list, $black_list; // avoid evaluating this at each function call
|
228 |
+
|
229 |
+
// we *want* to filter the home url in these cases
|
230 |
+
if ( empty( $white_list ) ) {
|
231 |
+
// on Windows get_theme_root() mixes / and \
|
232 |
+
// we want only \ for the comparison with debug_backtrace
|
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' ),
|
239 |
+
array( 'function' => 'login_footer' ),
|
240 |
+
) );
|
241 |
+
}
|
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' ),
|
248 |
+
) );
|
249 |
+
}
|
250 |
+
|
251 |
+
$traces = version_compare( PHP_VERSION, '5.2.5', '>=' ) ? debug_backtrace( false ) : debug_backtrace();
|
252 |
+
unset( $traces[0], $traces[1], $traces[2] ); // we don't need the last 3 calls (this function + apply_filters)
|
253 |
+
|
254 |
+
foreach ( $traces as $trace ) {
|
255 |
+
// black list first
|
256 |
+
foreach ( $black_list as $v ) {
|
257 |
+
if ( ( isset( $trace['file'], $v['file'] ) && false !== strpos( $trace['file'], $v['file'] ) ) || ( isset( $trace['function'], $v['function'] ) && $trace['function'] == $v['function'] ) ) {
|
258 |
+
return $url;
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
foreach ( $white_list as $v ) {
|
263 |
+
if ( ( isset( $trace['function'], $v['function'] ) && $trace['function'] == $v['function'] ) ||
|
264 |
+
( isset( $trace['file'], $v['file'] ) && false !== strpos( $trace['file'], $v['file'] ) && in_array( $trace['function'], array( 'home_url', 'get_home_url', 'bloginfo', 'get_bloginfo' ) ) ) ) {
|
265 |
+
$ok = true;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
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 admin url with path evaluated by WordPress
|
279 |
+
* @param string $path admin path
|
280 |
+
* @return string
|
281 |
+
*/
|
282 |
+
public function admin_url( $url, $path ) {
|
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 $do_redirect optional, whether to perform the redirection or not
|
294 |
+
* @return string if redirect is not performed
|
295 |
+
*/
|
296 |
+
public function check_canonical_url( $requested_url = '', $do_redirect = true ) {
|
297 |
+
global $wp_query, $post, $is_IIS;
|
298 |
+
|
299 |
+
// don't redirect in same cases as WP
|
300 |
+
if ( is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ( $is_IIS && ! iis7_supports_permalinks() ) ) {
|
301 |
+
return;
|
302 |
+
}
|
303 |
+
|
304 |
+
// don't redirect mysite.com/?attachment_id= to mysite.com/en/?attachment_id=
|
305 |
+
if ( 1 == $this->options['force_lang'] && is_attachment() && isset( $_GET['attachment_id'] ) ) {
|
306 |
+
return;
|
307 |
+
}
|
308 |
+
|
309 |
+
// if the default language code is not hidden and the static front page url contains the page name
|
310 |
+
// the customizer lands here and the code below would redirect to the list of posts
|
311 |
+
if ( isset( $_POST['wp_customize'], $_POST['customized'] ) ) {
|
312 |
+
return;
|
313 |
+
}
|
314 |
+
|
315 |
+
if ( empty( $requested_url ) ) {
|
316 |
+
$requested_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
317 |
+
}
|
318 |
+
|
319 |
+
if ( is_single() || is_page() ) {
|
320 |
+
if ( isset( $post->ID ) && $this->model->is_translated_post_type( $post->post_type ) ) {
|
321 |
+
$language = $this->model->post->get_language( (int) $post->ID );
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
elseif ( is_category() || is_tag() || is_tax() ) {
|
326 |
+
$obj = $wp_query->get_queried_object();
|
327 |
+
if ( $this->model->is_translated_taxonomy( $obj->taxonomy ) ) {
|
328 |
+
$language = $this->model->term->get_language( (int) $obj->term_id );
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
elseif ( $wp_query->is_posts_page ) {
|
333 |
+
$obj = $wp_query->get_queried_object();
|
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 |
+
|
345 |
+
// then get the right language code in url
|
346 |
+
$redirect_url = $this->options['force_lang'] ?
|
347 |
+
$this->links_model->switch_language_in_link( $redirect_url, $language ) :
|
348 |
+
$this->links_model->remove_language_from_link( $redirect_url ); // works only for default permalinks
|
349 |
+
}
|
350 |
+
|
351 |
+
// allow plugins to change the redirection or even cancel it by setting $redirect_url to false
|
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
|
355 |
+
if ( $do_redirect && $redirect_url && $requested_url != $redirect_url ) {
|
356 |
+
wp_redirect( $redirect_url, 301 );
|
357 |
+
exit;
|
358 |
+
}
|
359 |
+
|
360 |
+
return $redirect_url;
|
361 |
+
}
|
362 |
+
}
|
frontend/frontend-filters-search.php
CHANGED
@@ -15,43 +15,45 @@ class PLL_Frontend_Filters_Search {
|
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
-
public function __construct(&$polylang) {
|
19 |
$this->links_model = &$polylang->links_model;
|
20 |
$this->curlang = &$polylang->curlang;
|
21 |
|
22 |
// adds the language information in the search form
|
23 |
// low priority in case the search form is created using the same filter as described in http://codex.wordpress.org/Function_Reference/get_search_form
|
24 |
-
add_filter('get_search_form', array(&$this, 'get_search_form'), 99);
|
25 |
|
26 |
// adds the language information in admin bar search form
|
27 |
-
add_action('add_admin_bar_menus', array(&$this, 'add_admin_bar_menus'));
|
28 |
|
29 |
// adds javascript at the end of the document
|
30 |
// was used for WP < 3.6. kept just in case
|
31 |
-
if (defined('PLL_SEARCH_FORM_JS') && PLL_SEARCH_FORM_JS)
|
32 |
-
add_action('wp_footer', array(&$this, 'wp_print_footer_scripts'));
|
|
|
33 |
}
|
34 |
|
35 |
/*
|
36 |
* adds the language information in the search form
|
37 |
-
* does not work if searchform.php (prior to WP 3.6) is used or if the search form is hardcoded in another template file
|
38 |
*
|
39 |
* @since 0.1
|
40 |
*
|
41 |
* @param string $form search form
|
42 |
* @return string modified search form
|
43 |
*/
|
44 |
-
public function get_search_form($form) {
|
45 |
-
if ($form) {
|
46 |
-
if ($this->links_model->using_permalinks) {
|
47 |
// take care to modify only the url in the <form> tag
|
48 |
-
preg_match('#<form.+>#', $form, $matches);
|
49 |
-
$old = reset($matches);
|
50 |
-
$new = preg_replace('#' . $this->links_model->home . '\/?#', $this->curlang->search_url, $old);
|
51 |
-
$form = str_replace($old, $new, $form);
|
|
|
|
|
|
|
52 |
}
|
53 |
-
else
|
54 |
-
$form = str_replace('</form>', '<input type="hidden" name="lang" value="'.esc_attr($this->curlang->slug).'" /></form>', $form);
|
55 |
}
|
56 |
|
57 |
return $form;
|
@@ -63,29 +65,31 @@ class PLL_Frontend_Filters_Search {
|
|
63 |
* @since 1.2
|
64 |
*/
|
65 |
function add_admin_bar_menus() {
|
66 |
-
remove_action('admin_bar_menu', 'wp_admin_bar_search_menu', 4);
|
67 |
-
add_action('admin_bar_menu', array(&$this, 'admin_bar_search_menu'), 4);
|
68 |
}
|
69 |
|
70 |
/*
|
71 |
* rewrites the admin bar search form to pass our get_search form filter. See #21342
|
|
|
72 |
*
|
73 |
* @since 0.9
|
74 |
*
|
75 |
* @param object $wp_admin_bar
|
76 |
*/
|
77 |
-
public function admin_bar_search_menu($wp_admin_bar) {
|
78 |
$form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
|
79 |
$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
|
80 |
-
$form .= '<
|
|
|
81 |
$form .= '</form>';
|
82 |
|
83 |
-
$wp_admin_bar->add_menu(array(
|
84 |
'parent' => 'top-secondary',
|
85 |
'id' => 'search',
|
86 |
-
'title' => $this->get_search_form($form), // pass the get_search_form filter
|
87 |
-
'meta' => array('class' => 'admin-bar-search', 'tabindex' => -1)
|
88 |
-
));
|
89 |
}
|
90 |
|
91 |
/*
|
@@ -95,31 +99,31 @@ class PLL_Frontend_Filters_Search {
|
|
95 |
*/
|
96 |
public function wp_print_footer_scripts() {
|
97 |
// don't use directly e[0] just in case there is somewhere else an element named 's'
|
98 |
-
// check before if the hidden input has not already been introduced by get_search_form (FIXME: is there a way to improve this) ?
|
99 |
// thanks to AndyDeGroo for improving the code for compatility with old browsers
|
100 |
// http://wordpress.org/support/topic/development-of-polylang-version-08?replies=6#post-2645559
|
101 |
-
$lang = esc_js($this->curlang->slug);
|
102 |
$js = "//<![CDATA[
|
103 |
-
e = document.getElementsByName('s');
|
104 |
-
for (i = 0; i < e.length; i++) {
|
105 |
-
if (e[i].tagName.toUpperCase() == 'INPUT') {
|
106 |
s = e[i].parentNode.parentNode.children;
|
107 |
l = 0;
|
108 |
-
for (j = 0; j < s.length; j++) {
|
109 |
-
if (s[j].name == 'lang') {
|
110 |
l = 1;
|
111 |
}
|
112 |
}
|
113 |
-
if ( l == 0) {
|
114 |
-
var ih = document.createElement('input');
|
115 |
ih.type = 'hidden';
|
116 |
ih.name = 'lang';
|
117 |
ih.value = '$lang';
|
118 |
-
e[i].parentNode.appendChild(ih);
|
119 |
}
|
120 |
}
|
121 |
}
|
122 |
//]]>";
|
123 |
-
echo
|
124 |
}
|
125 |
}
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
+
public function __construct( &$polylang ) {
|
19 |
$this->links_model = &$polylang->links_model;
|
20 |
$this->curlang = &$polylang->curlang;
|
21 |
|
22 |
// adds the language information in the search form
|
23 |
// low priority in case the search form is created using the same filter as described in http://codex.wordpress.org/Function_Reference/get_search_form
|
24 |
+
add_filter( 'get_search_form', array( &$this, 'get_search_form' ), 99 );
|
25 |
|
26 |
// adds the language information in admin bar search form
|
27 |
+
add_action( 'add_admin_bar_menus', array( &$this, 'add_admin_bar_menus' ) );
|
28 |
|
29 |
// adds javascript at the end of the document
|
30 |
// was used for WP < 3.6. kept just in case
|
31 |
+
if ( defined( 'PLL_SEARCH_FORM_JS' ) && PLL_SEARCH_FORM_JS ) {
|
32 |
+
add_action( 'wp_footer', array( &$this, 'wp_print_footer_scripts' ) );
|
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 |
*
|
40 |
* @since 0.1
|
41 |
*
|
42 |
* @param string $form search form
|
43 |
* @return string modified search form
|
44 |
*/
|
45 |
+
public function get_search_form( $form ) {
|
46 |
+
if ( $form ) {
|
47 |
+
if ( $this->links_model->using_permalinks ) {
|
48 |
// take care to modify only the url in the <form> tag
|
49 |
+
preg_match( '#<form.+>#', $form, $matches );
|
50 |
+
$old = reset( $matches );
|
51 |
+
$new = preg_replace( '#' . esc_url( $this->links_model->home ) . '\/?#', esc_url( $this->curlang->search_url ), $old );
|
52 |
+
$form = str_replace( $old, $new, $form );
|
53 |
+
}
|
54 |
+
else {
|
55 |
+
$form = str_replace( '</form>', '<input type="hidden" name="lang" value="'.esc_attr( $this->curlang->slug ).'" /></form>', $form );
|
56 |
}
|
|
|
|
|
57 |
}
|
58 |
|
59 |
return $form;
|
65 |
* @since 1.2
|
66 |
*/
|
67 |
function add_admin_bar_menus() {
|
68 |
+
remove_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 );
|
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 |
*
|
76 |
* @since 0.9
|
77 |
*
|
78 |
* @param object $wp_admin_bar
|
79 |
*/
|
80 |
+
public function admin_bar_search_menu( $wp_admin_bar ) {
|
81 |
$form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
|
82 |
$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
|
83 |
+
$form .= '<label for="adminbar-search" class="screen-reader-text">' . __( 'Search' ) . '</label>';
|
84 |
+
$form .= '<input type="submit" class="adminbar-button" value="' . __( 'Search' ) . '"/>';
|
85 |
$form .= '</form>';
|
86 |
|
87 |
+
$wp_admin_bar->add_menu( array(
|
88 |
'parent' => 'top-secondary',
|
89 |
'id' => 'search',
|
90 |
+
'title' => $this->get_search_form( $form ), // pass the get_search_form filter
|
91 |
+
'meta' => array( 'class' => 'admin-bar-search', 'tabindex' => -1 ),
|
92 |
+
) );
|
93 |
}
|
94 |
|
95 |
/*
|
99 |
*/
|
100 |
public function wp_print_footer_scripts() {
|
101 |
// don't use directly e[0] just in case there is somewhere else an element named 's'
|
102 |
+
// check before if the hidden input has not already been introduced by get_search_form ( FIXME: is there a way to improve this ) ?
|
103 |
// thanks to AndyDeGroo for improving the code for compatility with old browsers
|
104 |
// http://wordpress.org/support/topic/development-of-polylang-version-08?replies=6#post-2645559
|
105 |
+
$lang = esc_js( $this->curlang->slug );
|
106 |
$js = "//<![CDATA[
|
107 |
+
e = document.getElementsByName( 's' );
|
108 |
+
for ( i = 0; i < e.length; i++ ) {
|
109 |
+
if ( e[i].tagName.toUpperCase() == 'INPUT' ) {
|
110 |
s = e[i].parentNode.parentNode.children;
|
111 |
l = 0;
|
112 |
+
for ( j = 0; j < s.length; j++ ) {
|
113 |
+
if ( s[j].name == 'lang' ) {
|
114 |
l = 1;
|
115 |
}
|
116 |
}
|
117 |
+
if ( l == 0 ) {
|
118 |
+
var ih = document.createElement( 'input' );
|
119 |
ih.type = 'hidden';
|
120 |
ih.name = 'lang';
|
121 |
ih.value = '$lang';
|
122 |
+
e[i].parentNode.appendChild( ih );
|
123 |
}
|
124 |
}
|
125 |
}
|
126 |
//]]>";
|
127 |
+
echo '<script type="text/javascript">' . $js . '</script>';
|
128 |
}
|
129 |
}
|
frontend/frontend-filters.php
CHANGED
@@ -13,55 +13,53 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
13 |
*
|
14 |
* @param object $polylang
|
15 |
*/
|
16 |
-
public function __construct(&$polylang) {
|
17 |
-
parent::__construct($polylang);
|
18 |
|
19 |
// filters the WordPress locale
|
20 |
-
add_filter('locale', array(&$this, 'get_locale'));
|
21 |
-
|
22 |
-
// translates page for posts and page on front
|
23 |
-
add_filter('option_page_on_front', 'pll_get_post');
|
24 |
-
add_filter('option_page_for_posts', 'pll_get_post');
|
25 |
|
26 |
// filter sticky posts by current language
|
27 |
-
add_filter('option_sticky_posts', array(&$this, 'option_sticky_posts'));
|
28 |
|
29 |
// adds cache domain when querying terms
|
30 |
-
add_filter('get_terms_args', array(&$this, 'get_terms_args'));
|
31 |
|
32 |
// filters categories and post tags by language
|
33 |
-
add_filter('terms_clauses', array(&$this, 'terms_clauses'), 10, 3);
|
34 |
|
35 |
// rewrites archives, next and previous post links to filter them by language
|
36 |
-
foreach (array('getarchives', 'get_previous_post', 'get_next_post') as $filter)
|
37 |
-
foreach (array('_join', '_where') as $clause)
|
38 |
-
add_filter($filter.$clause, array(&$this, 'posts'.$clause));
|
|
|
|
|
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 |
// translates biography
|
48 |
-
add_filter('get_user_metadata', array(&$this,'get_user_metadata'), 10, 3);
|
49 |
|
50 |
-
// set posts and terms language when created from frontend (ex with P2 theme)
|
51 |
-
add_action('save_post', array(&$this, 'save_post'), 200, 2);
|
52 |
-
add_action('create_term', array(&$this, 'save_term'), 10, 3);
|
53 |
-
add_action('edit_term', array(&$this, 'save_term'), 10, 3);
|
54 |
|
55 |
-
if ($this->options['media_support'])
|
56 |
-
add_action('add_attachment', array(&$this, 'set_default_language'));
|
|
|
57 |
|
58 |
// support theme customizer
|
59 |
// FIXME of course does not work if 'transport' is set to 'postMessage'
|
60 |
-
if (isset($_POST['wp_customize'], $_POST['customized'])) {
|
61 |
-
add_filter('
|
62 |
-
add_filter('
|
63 |
-
add_filter('pre_option_blogname', 'pll__', 20);
|
64 |
-
add_filter('pre_option_blogdescription', 'pll__', 20);
|
65 |
}
|
66 |
}
|
67 |
|
@@ -73,7 +71,7 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
73 |
* @param string $locale
|
74 |
* @return string
|
75 |
*/
|
76 |
-
public function get_locale($locale) {
|
77 |
return $this->curlang->locale;
|
78 |
}
|
79 |
|
@@ -85,13 +83,14 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
85 |
* @param array $posts list of sticky posts ids
|
86 |
* @return array modified list of sticky posts ids
|
87 |
*/
|
88 |
-
public function option_sticky_posts($posts) {
|
89 |
-
if ($this->curlang && !empty($posts)) {
|
90 |
-
update_object_term_cache($posts, 'post'); // to avoid queries in foreach
|
91 |
-
foreach ($posts as $key => $post_id) {
|
92 |
-
$lang = $this->model->
|
93 |
-
if (empty($lang) || $lang->term_id != $this->curlang->term_id)
|
94 |
-
unset($posts[$key]);
|
|
|
95 |
}
|
96 |
}
|
97 |
return $posts;
|
@@ -106,10 +105,10 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
106 |
* @param array $args
|
107 |
* @return array
|
108 |
*/
|
109 |
-
public function get_terms_args($args) {
|
110 |
-
$lang = isset($args['lang']) ? $args['lang'] : $this->curlang->slug;
|
111 |
-
$key = '_' . (is_array($lang) ? implode(',', $lang) : $lang);
|
112 |
-
$args['cache_domain'] = empty($args['cache_domain']) ? 'pll' . $key : $args['cache_domain'] . $key;
|
113 |
return $args;
|
114 |
}
|
115 |
|
@@ -123,13 +122,14 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
123 |
* @param array $args get_terms arguments
|
124 |
* @return array modified sql clauses
|
125 |
*/
|
126 |
-
public function terms_clauses($clauses, $taxonomies, $args) {
|
127 |
// does nothing except on taxonomies which are filterable
|
128 |
-
if (
|
129 |
return $clauses;
|
|
|
130 |
|
131 |
// adds our clauses to filter by language
|
132 |
-
return $this->model->terms_clauses($clauses, isset($args['lang']) ? $args['lang'] : $this->curlang);
|
133 |
}
|
134 |
|
135 |
/*
|
@@ -140,8 +140,8 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
140 |
* @param string $sql join clause
|
141 |
* @return string modified join clause
|
142 |
*/
|
143 |
-
public function posts_join($sql) {
|
144 |
-
return $sql . $this->model->join_clause(
|
145 |
}
|
146 |
|
147 |
/*
|
@@ -152,9 +152,9 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
152 |
* @param string $sql where clause
|
153 |
* @return string modified where clause
|
154 |
*/
|
155 |
-
public function posts_where($sql) {
|
156 |
-
preg_match("#post_type = '([^']+)'#", $sql, $matches); // find the queried post type
|
157 |
-
return !empty($matches[1]) && $this->model->is_translated_post_type($matches[1]) ? $sql . $this->model->where_clause($this->curlang
|
158 |
}
|
159 |
|
160 |
/*
|
@@ -167,8 +167,8 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
167 |
* @param object $widget WP_Widget object
|
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 |
/*
|
@@ -181,8 +181,8 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
181 |
* @param string $meta_key
|
182 |
* @return null|string
|
183 |
*/
|
184 |
-
public function get_user_metadata($null, $id, $meta_key) {
|
185 |
-
return
|
186 |
}
|
187 |
|
188 |
/*
|
@@ -192,21 +192,24 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
192 |
*
|
193 |
* @param int $post_id
|
194 |
*/
|
195 |
-
public function set_default_language($post_id) {
|
196 |
-
if (
|
197 |
-
if (isset($_REQUEST['lang']))
|
198 |
-
$this->model->
|
|
|
199 |
|
200 |
-
elseif (($parent_id = wp_get_post_parent_id($post_id)) && $parent_lang = $this->model->
|
201 |
-
$this->model->
|
|
|
202 |
|
203 |
-
else
|
204 |
-
$this->model->
|
|
|
205 |
}
|
206 |
}
|
207 |
|
208 |
/*
|
209 |
-
* called when a post (or page) is saved, published or updated
|
210 |
* does nothing except on post types which are filterable
|
211 |
* sets the language but does not allow to modify it
|
212 |
*
|
@@ -216,9 +219,10 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
216 |
* @param object $post
|
217 |
* @param bool $update whether it is an update or not
|
218 |
*/
|
219 |
-
public function save_post($post_id, $post) {
|
220 |
-
if ($this->model->is_translated_post_type($post->post_type))
|
221 |
-
$this->set_default_language($post_id);
|
|
|
222 |
}
|
223 |
|
224 |
/*
|
@@ -232,16 +236,19 @@ class PLL_Frontend_Filters extends PLL_Filters{
|
|
232 |
* @param int $tt_id term taxonomy id
|
233 |
* @param string $taxonomy
|
234 |
*/
|
235 |
-
public function save_term($term_id, $tt_id, $taxonomy) {
|
236 |
-
if ($this->model->is_translated_taxonomy($taxonomy) &&
|
237 |
-
if (isset($_REQUEST['lang']))
|
238 |
-
$this->model->
|
|
|
239 |
|
240 |
-
elseif (($term = get_term($term_id, $taxonomy)) && !empty($term->parent) && $parent_lang = $this->model->
|
241 |
-
$this->model->
|
|
|
242 |
|
243 |
-
else
|
244 |
-
$this->model->
|
|
|
245 |
}
|
246 |
}
|
247 |
}
|
13 |
*
|
14 |
* @param object $polylang
|
15 |
*/
|
16 |
+
public function __construct( &$polylang ) {
|
17 |
+
parent::__construct( $polylang );
|
18 |
|
19 |
// filters the WordPress locale
|
20 |
+
add_filter( 'locale', array( &$this, 'get_locale' ) );
|
|
|
|
|
|
|
|
|
21 |
|
22 |
// filter sticky posts by current language
|
23 |
+
add_filter( 'option_sticky_posts', array( &$this, 'option_sticky_posts' ) );
|
24 |
|
25 |
// adds cache domain when querying terms
|
26 |
+
add_filter( 'get_terms_args', array( &$this, 'get_terms_args' ) );
|
27 |
|
28 |
// filters categories and post tags by language
|
29 |
+
add_filter( 'terms_clauses', array( &$this, 'terms_clauses' ), 10, 3 );
|
30 |
|
31 |
// rewrites archives, next and previous post links to filter them by language
|
32 |
+
foreach ( array( 'getarchives', 'get_previous_post', 'get_next_post' ) as $filter ) {
|
33 |
+
foreach ( array( '_join', '_where' ) as $clause ) {
|
34 |
+
add_filter( $filter.$clause, array( &$this, 'posts'.$clause ) );
|
35 |
+
}
|
36 |
+
}
|
37 |
|
38 |
// filters the widgets according to the current language
|
39 |
+
add_filter( 'widget_display_callback', array( &$this, 'widget_display_callback' ), 10, 2 );
|
40 |
|
41 |
+
// strings translation ( must be applied before WordPress applies its default formatting filters )
|
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 |
// translates biography
|
47 |
+
add_filter( 'get_user_metadata', array( &$this, 'get_user_metadata' ), 10, 3 );
|
48 |
|
49 |
+
// set posts and terms language when created from frontend ( ex with P2 theme )
|
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 );
|
53 |
|
54 |
+
if ( $this->options['media_support'] ) {
|
55 |
+
add_action( 'add_attachment', array( &$this, 'set_default_language' ) );
|
56 |
+
}
|
57 |
|
58 |
// support theme customizer
|
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 );
|
62 |
+
add_filter( 'pre_option_blogdescription', 'pll__', 20 );
|
|
|
|
|
63 |
}
|
64 |
}
|
65 |
|
71 |
* @param string $locale
|
72 |
* @return string
|
73 |
*/
|
74 |
+
public function get_locale( $locale ) {
|
75 |
return $this->curlang->locale;
|
76 |
}
|
77 |
|
83 |
* @param array $posts list of sticky posts ids
|
84 |
* @return array modified list of sticky posts ids
|
85 |
*/
|
86 |
+
public function option_sticky_posts( $posts ) {
|
87 |
+
if ( $this->curlang && ! empty( $posts ) ) {
|
88 |
+
update_object_term_cache( $posts, 'post' ); // to avoid queries in foreach
|
89 |
+
foreach ( $posts as $key => $post_id ) {
|
90 |
+
$lang = $this->model->post->get_language( $post_id );
|
91 |
+
if ( empty( $lang ) || $lang->term_id != $this->curlang->term_id ) {
|
92 |
+
unset( $posts[ $key ] );
|
93 |
+
}
|
94 |
}
|
95 |
}
|
96 |
return $posts;
|
105 |
* @param array $args
|
106 |
* @return array
|
107 |
*/
|
108 |
+
public function get_terms_args( $args ) {
|
109 |
+
$lang = isset( $args['lang'] ) ? $args['lang'] : $this->curlang->slug;
|
110 |
+
$key = '_' . ( is_array( $lang ) ? implode( ',', $lang ) : $lang );
|
111 |
+
$args['cache_domain'] = empty( $args['cache_domain'] ) ? 'pll' . $key : $args['cache_domain'] . $key;
|
112 |
return $args;
|
113 |
}
|
114 |
|
122 |
* @param array $args get_terms arguments
|
123 |
* @return array modified sql clauses
|
124 |
*/
|
125 |
+
public function terms_clauses( $clauses, $taxonomies, $args ) {
|
126 |
// does nothing except on taxonomies which are filterable
|
127 |
+
if ( ! $this->model->is_translated_taxonomy( $taxonomies ) ) {
|
128 |
return $clauses;
|
129 |
+
}
|
130 |
|
131 |
// adds our clauses to filter by language
|
132 |
+
return $this->model->terms_clauses( $clauses, isset( $args['lang'] ) ? $args['lang'] : $this->curlang );
|
133 |
}
|
134 |
|
135 |
/*
|
140 |
* @param string $sql join clause
|
141 |
* @return string modified join clause
|
142 |
*/
|
143 |
+
public function posts_join( $sql ) {
|
144 |
+
return $sql . $this->model->post->join_clause();
|
145 |
}
|
146 |
|
147 |
/*
|
152 |
* @param string $sql where clause
|
153 |
* @return string modified where clause
|
154 |
*/
|
155 |
+
public function posts_where( $sql ) {
|
156 |
+
preg_match( "#post_type = '([^']+)'#", $sql, $matches ); // find the queried post type
|
157 |
+
return ! empty( $matches[1] ) && $this->model->is_translated_post_type( $matches[1] ) ? $sql . $this->model->post->where_clause( $this->curlang ) : $sql;
|
158 |
}
|
159 |
|
160 |
/*
|
167 |
* @param object $widget WP_Widget object
|
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 |
/*
|
181 |
* @param string $meta_key
|
182 |
* @return null|string
|
183 |
*/
|
184 |
+
public function get_user_metadata( $null, $id, $meta_key ) {
|
185 |
+
return 'description' == $meta_key && $this->curlang->slug != $this->options['default_lang'] ? get_user_meta( $id, 'description_'.$this->curlang->slug, true ) : $null;
|
186 |
}
|
187 |
|
188 |
/*
|
192 |
*
|
193 |
* @param int $post_id
|
194 |
*/
|
195 |
+
public function set_default_language( $post_id ) {
|
196 |
+
if ( ! $this->model->post->get_language( $post_id ) ) {
|
197 |
+
if ( isset( $_REQUEST['lang'] ) ) {
|
198 |
+
$this->model->post->set_language( $post_id, $_REQUEST['lang'] );
|
199 |
+
}
|
200 |
|
201 |
+
elseif ( ( $parent_id = wp_get_post_parent_id( $post_id ) ) && $parent_lang = $this->model->post->get_language( $parent_id ) ) {
|
202 |
+
$this->model->post->set_language( $post_id, $parent_lang );
|
203 |
+
}
|
204 |
|
205 |
+
else {
|
206 |
+
$this->model->post->set_language( $post_id, $this->curlang );
|
207 |
+
}
|
208 |
}
|
209 |
}
|
210 |
|
211 |
/*
|
212 |
+
* called when a post ( or page ) is saved, published or updated
|
213 |
* does nothing except on post types which are filterable
|
214 |
* sets the language but does not allow to modify it
|
215 |
*
|
219 |
* @param object $post
|
220 |
* @param bool $update whether it is an update or not
|
221 |
*/
|
222 |
+
public function save_post( $post_id, $post ) {
|
223 |
+
if ( $this->model->is_translated_post_type( $post->post_type ) ) {
|
224 |
+
$this->set_default_language( $post_id );
|
225 |
+
}
|
226 |
}
|
227 |
|
228 |
/*
|
236 |
* @param int $tt_id term taxonomy id
|
237 |
* @param string $taxonomy
|
238 |
*/
|
239 |
+
public function save_term( $term_id, $tt_id, $taxonomy ) {
|
240 |
+
if ( $this->model->is_translated_taxonomy( $taxonomy ) && ! $this->model->term->get_language( $term_id ) ) {
|
241 |
+
if ( isset( $_REQUEST['lang'] ) ) {
|
242 |
+
$this->model->term->set_language( $term_id, $_REQUEST['lang'] );
|
243 |
+
}
|
244 |
|
245 |
+
elseif ( ( $term = get_term( $term_id, $taxonomy ) ) && ! empty( $term->parent ) && $parent_lang = $this->model->term->get_language( $term->parent ) ) {
|
246 |
+
$this->model->term->set_language( $term_id, $parent_lang );
|
247 |
+
}
|
248 |
|
249 |
+
else {
|
250 |
+
$this->model->term->set_language( $term_id, $this->curlang );
|
251 |
+
}
|
252 |
}
|
253 |
}
|
254 |
}
|
frontend/frontend-links.php
CHANGED
@@ -6,8 +6,8 @@
|
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Frontend_Links extends PLL_Links {
|
9 |
-
public $curlang
|
10 |
-
|
11 |
|
12 |
/*
|
13 |
* constructor
|
@@ -16,428 +16,114 @@ class PLL_Frontend_Links extends PLL_Links {
|
|
16 |
*
|
17 |
* @param object $polylang
|
18 |
*/
|
19 |
-
public function __construct(&$polylang) {
|
20 |
-
parent::__construct($polylang);
|
21 |
|
22 |
$this->curlang = &$polylang->curlang;
|
23 |
-
$this->init_page_on_front_cache();
|
24 |
-
|
25 |
$this->cache = new PLL_Cache();
|
26 |
|
27 |
-
add_action('pll_language_defined', array(&$this, 'pll_language_defined'));
|
28 |
-
add_action('pll_language_defined', array(&$this, 'init_page_on_front_cache')); // translate page on front and page for posts
|
29 |
-
}
|
30 |
-
|
31 |
-
/*
|
32 |
-
* stores the page on front and page for posts ids
|
33 |
-
*
|
34 |
-
* @since 1.6
|
35 |
-
*/
|
36 |
-
public function init_page_on_front_cache() {
|
37 |
-
if ('page' == get_option('show_on_front')) {
|
38 |
-
$this->page_on_front = get_option('page_on_front');
|
39 |
-
$this->page_for_posts = get_option('page_for_posts');
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
/*
|
44 |
-
* adds filters once the language is defined
|
45 |
-
* low priority on links filters to come after any other modification
|
46 |
-
*
|
47 |
-
* @since 1.2
|
48 |
-
*/
|
49 |
-
public function pll_language_defined() {
|
50 |
-
// rewrites author and date links to filter them by language
|
51 |
-
foreach (array('feed_link', 'author_link', 'search_link', 'year_link', 'month_link', 'day_link') as $filter)
|
52 |
-
add_filter($filter, array(&$this, 'archive_link'), 20);
|
53 |
-
|
54 |
-
// rewrites post types archives links to filter them by language
|
55 |
-
add_filter('post_type_archive_link', array(&$this, 'post_type_archive_link'), 20, 2);
|
56 |
-
|
57 |
-
// modifies the page link in case the front page is not in the default language
|
58 |
-
add_filter('page_link', array(&$this, 'page_link'), 20, 2);
|
59 |
-
|
60 |
-
// meta in the html head section
|
61 |
-
add_action('wp_head', array(&$this, 'wp_head'));
|
62 |
-
|
63 |
-
// manages the redirection of the homepage
|
64 |
-
add_filter('redirect_canonical', array(&$this, 'redirect_canonical'), 10, 2);
|
65 |
-
|
66 |
-
// modifies the home url
|
67 |
-
if (!defined('PLL_FILTER_HOME_URL') || PLL_FILTER_HOME_URL)
|
68 |
-
add_filter('home_url', array(&$this, 'home_url'), 10, 2);
|
69 |
-
|
70 |
-
if ($this->options['force_lang'] > 1) {
|
71 |
-
// rewrites next and previous post links when not automatically done by WordPress
|
72 |
-
add_filter('get_pagenum_link', array(&$this, 'archive_link'), 20);
|
73 |
-
|
74 |
-
// rewrites ajax url
|
75 |
-
add_filter('admin_url', array(&$this, 'admin_url'), 10, 2);
|
76 |
-
}
|
77 |
-
|
78 |
-
// redirects to canonical url
|
79 |
-
add_action('wp', array(&$this, 'check_canonical_url'), 10, 0); // before WordPress redirect_canonical, avoid passing the WP object
|
80 |
-
}
|
81 |
-
|
82 |
-
/*
|
83 |
-
* modifies the author and date links to add the language parameter (as well as feed link)
|
84 |
-
*
|
85 |
-
* @since 0.4
|
86 |
-
*
|
87 |
-
* @param string $link
|
88 |
-
* @return string modified link
|
89 |
-
*/
|
90 |
-
public function archive_link($link) {
|
91 |
-
return $this->links_model->add_language_to_link($link, $this->curlang);
|
92 |
-
}
|
93 |
-
|
94 |
-
/*
|
95 |
-
* modifies the post type archive links to add the language parameter
|
96 |
-
* only if the post type is translated
|
97 |
-
*
|
98 |
-
* @since 1.7.6
|
99 |
-
*
|
100 |
-
* @param string $link
|
101 |
-
* @param string $post_type
|
102 |
-
* @return string modified link
|
103 |
-
*/
|
104 |
-
public function post_type_archive_link($link, $post_type) {
|
105 |
-
return $this->model->is_translated_post_type($post_type) ? $this->links_model->add_language_to_link($link, $this->curlang) : $link;
|
106 |
-
}
|
107 |
-
|
108 |
-
/*
|
109 |
-
* modifies post & page links
|
110 |
-
* caches the result
|
111 |
-
*
|
112 |
-
* @since 0.7
|
113 |
-
*
|
114 |
-
* @param string $link post link
|
115 |
-
* @param object $post post object
|
116 |
-
* @return string modified post link
|
117 |
-
*/
|
118 |
-
public function post_link($link, $post) {
|
119 |
-
$cache_key = 'post:' . $post->ID;
|
120 |
-
if (false === $_link = $this->cache->get($cache_key)) {
|
121 |
-
$_link = parent::post_link($link, $post);
|
122 |
-
$this->cache->set($cache_key, $_link);
|
123 |
-
}
|
124 |
-
return $_link;
|
125 |
-
}
|
126 |
-
|
127 |
-
/*
|
128 |
-
* modifies page links
|
129 |
-
* caches the result
|
130 |
-
*
|
131 |
-
* @since 1.7
|
132 |
-
*
|
133 |
-
* @param string $link post link
|
134 |
-
* @param int $post_id post ID
|
135 |
-
* @return string modified post link
|
136 |
-
*/
|
137 |
-
public function _get_page_link($link, $post_id) {
|
138 |
-
$cache_key = 'post:' . $post_id;
|
139 |
-
if (false === $_link = $this->cache->get($cache_key)) {
|
140 |
-
$_link = parent::_get_page_link($link, $post_id);
|
141 |
-
$this->cache->set($cache_key, $_link);
|
142 |
-
}
|
143 |
-
return $_link;
|
144 |
-
}
|
145 |
-
|
146 |
-
/*
|
147 |
-
* modifies attachment links
|
148 |
-
* caches the result
|
149 |
-
*
|
150 |
-
* @since 1.6.2
|
151 |
-
*
|
152 |
-
* @param string $link attachment link
|
153 |
-
* @param int $post_id attachment link
|
154 |
-
* @return string modified attachment link
|
155 |
-
*/
|
156 |
-
public function attachment_link($link, $post_id) {
|
157 |
-
$cache_key = 'post:' . $post_id;
|
158 |
-
if (false === $_link = $this->cache->get($cache_key)) {
|
159 |
-
$_link = parent::attachment_link($link, $post_id);
|
160 |
-
$this->cache->set($cache_key, $_link);
|
161 |
-
}
|
162 |
-
return $_link;
|
163 |
-
}
|
164 |
-
|
165 |
-
/*
|
166 |
-
* modifies custom posts links
|
167 |
-
* caches the result
|
168 |
-
*
|
169 |
-
* @since 1.6
|
170 |
-
*
|
171 |
-
* @param string $link post link
|
172 |
-
* @param object $post post object
|
173 |
-
* @return string modified post link
|
174 |
-
*/
|
175 |
-
public function post_type_link($link, $post) {
|
176 |
-
$cache_key = 'post:' . $post->ID;
|
177 |
-
if (false === $_link = $this->cache->get($cache_key)) {
|
178 |
-
$_link = parent::post_type_link($link, $post);
|
179 |
-
$this->cache->set($cache_key, $_link);
|
180 |
-
}
|
181 |
-
return $_link;
|
182 |
}
|
183 |
|
184 |
/*
|
185 |
-
*
|
186 |
-
* caches the result
|
187 |
-
*
|
188 |
-
* @since 0.7
|
189 |
-
*
|
190 |
-
* @param string $link
|
191 |
-
* @param object $term term object
|
192 |
-
* @param string $tax taxonomy name
|
193 |
-
* @return string modified link
|
194 |
-
*/
|
195 |
-
public function term_link($link, $term, $tax) {
|
196 |
-
$cache_key = 'term:' . $term->term_id;
|
197 |
-
if (false === $_link = $this->cache->get($cache_key)) {
|
198 |
-
if (in_array($tax, $this->model->get_filtered_taxonomies())) {
|
199 |
-
$_link = $this->links_model->add_language_to_link($link, $this->curlang);
|
200 |
-
$_link = apply_filters('pll_term_link', $_link, $this->curlang, $term);
|
201 |
-
}
|
202 |
-
|
203 |
-
else {
|
204 |
-
$_link = parent::term_link($link, $term, $tax);
|
205 |
-
}
|
206 |
-
$this->cache->set($cache_key, $_link);
|
207 |
-
}
|
208 |
-
return $_link;
|
209 |
-
}
|
210 |
-
|
211 |
-
/*
|
212 |
-
* modifies the page link in case the front page is not in the default language
|
213 |
-
*
|
214 |
-
* @since 0.7.2
|
215 |
-
*
|
216 |
-
* @param string $link
|
217 |
-
* @param int $id
|
218 |
-
* @return string modified link
|
219 |
-
*/
|
220 |
-
public function page_link($link, $id) {
|
221 |
-
if ($this->page_on_front && ($lang = $this->model->get_post_language($id)) && in_array($id, $this->model->get_translations('post', $this->page_on_front)))
|
222 |
-
return $lang->home_url;
|
223 |
-
|
224 |
-
return $link;
|
225 |
-
}
|
226 |
-
|
227 |
-
/*
|
228 |
-
* outputs references to translated pages (if exists) in the html head section
|
229 |
-
*
|
230 |
-
* @since 0.1
|
231 |
-
*/
|
232 |
-
public function wp_head() {
|
233 |
-
// Google recommends to include self link https://support.google.com/webmasters/answer/189077?hl=en
|
234 |
-
foreach ($this->model->get_languages_list() as $language) {
|
235 |
-
if ($url = $this->get_translation_url($language))
|
236 |
-
$urls[$language->slug] = $url;
|
237 |
-
}
|
238 |
-
|
239 |
-
// ouptputs the section only if there are translations ($urls always contains self link)
|
240 |
-
// don't output anything on paged archives: see https://wordpress.org/support/topic/hreflang-on-page2
|
241 |
-
if (!empty($urls) && count($urls) > 1 && !is_paged()) {
|
242 |
-
foreach ($urls as $lang => $url) {
|
243 |
-
printf('<link rel="alternate" href="%s" hreflang="%s" />'."\n", esc_url($url), esc_attr($lang));
|
244 |
-
}
|
245 |
-
|
246 |
-
// adds the site root url when the default language code is not hidden
|
247 |
-
// see https://wordpress.org/support/topic/implementation-of-hreflangx-default
|
248 |
-
if ( is_front_page() && ! $this->options['hide_default'] ) {
|
249 |
-
printf( '<link rel="alternate" href="%s" hreflang="x-default" />'."\n", home_url() );
|
250 |
-
}
|
251 |
-
}
|
252 |
-
}
|
253 |
-
|
254 |
-
/*
|
255 |
-
* manages canonical redirection of the homepage when using page on front
|
256 |
-
*
|
257 |
-
* @since 0.1
|
258 |
-
*
|
259 |
-
* @param string $redirect_url
|
260 |
-
* @param string $requested_url
|
261 |
-
* @return bool|string modified url, false if redirection is canceled
|
262 |
-
*/
|
263 |
-
public function redirect_canonical($redirect_url, $requested_url) {
|
264 |
-
global $wp_query;
|
265 |
-
if (is_page() && !is_feed() && isset($wp_query->queried_object) && $wp_query->queried_object->ID == $this->page_on_front) {
|
266 |
-
$url = is_paged() ? $this->links_model->add_paged_to_link($this->get_home_url(), $wp_query->query_vars['page']) : $this->get_home_url();
|
267 |
-
|
268 |
-
// don't forget additional query vars
|
269 |
-
$query = parse_url($redirect_url, PHP_URL_QUERY);
|
270 |
-
if (!empty($query)) {
|
271 |
-
parse_str($query, $query_vars);
|
272 |
-
$url = add_query_arg($query_vars, $url);
|
273 |
-
}
|
274 |
-
|
275 |
-
return $url;
|
276 |
-
}
|
277 |
-
|
278 |
-
// protect against chained redirects
|
279 |
-
if ($redirect_url != $this->check_canonical_url($redirect_url, false))
|
280 |
-
return false;
|
281 |
-
|
282 |
-
return $redirect_url;
|
283 |
-
}
|
284 |
-
|
285 |
-
/*
|
286 |
-
* checks if a file is in a directory or its subdirectories
|
287 |
-
* the comparison takes care of Windows on which WP can mix \ and /
|
288 |
-
*
|
289 |
-
* @since 1.7
|
290 |
-
*
|
291 |
-
* @param string $file
|
292 |
-
* @param string $dir
|
293 |
-
* @return bool
|
294 |
-
*/
|
295 |
-
protected function is_file_in($file, $dir) {
|
296 |
-
return strpos(str_replace('\\', '/', $file), str_replace('\\', '/', $dir)) !== false;
|
297 |
-
}
|
298 |
-
|
299 |
-
/*
|
300 |
-
* filters the home url to get the right language
|
301 |
-
*
|
302 |
-
* @since 0.4
|
303 |
-
*
|
304 |
-
* @param string $url
|
305 |
-
* @param string $path
|
306 |
-
* @return string
|
307 |
-
*/
|
308 |
-
public function home_url($url, $path) {
|
309 |
-
if (!(did_action('template_redirect') || did_action('login_init')) || rtrim($url,'/') != $this->links_model->home)
|
310 |
-
return $url;
|
311 |
-
|
312 |
-
static $white_list, $black_list; // avoid evaluating this at each function call
|
313 |
-
|
314 |
-
// we *want* to filter the home url in these cases
|
315 |
-
if (empty($white_list)) {
|
316 |
-
$white_list = apply_filters('pll_home_url_white_list', array(
|
317 |
-
array('file' => get_theme_root()),
|
318 |
-
array('function' => 'wp_nav_menu'),
|
319 |
-
array('function' => 'login_footer')
|
320 |
-
));
|
321 |
-
}
|
322 |
-
|
323 |
-
// we don't want to filter the home url in these cases
|
324 |
-
if (empty($black_list)) {
|
325 |
-
$black_list = apply_filters('pll_home_url_black_list', array(
|
326 |
-
array('file' => 'searchform.php'), // since WP 3.6 searchform.php is passed through get_search_form
|
327 |
-
array('function' => 'get_search_form')
|
328 |
-
));
|
329 |
-
}
|
330 |
-
|
331 |
-
$traces = version_compare(PHP_VERSION, '5.2.5', '>=') ? debug_backtrace(false) : debug_backtrace();
|
332 |
-
|
333 |
-
foreach ($traces as $trace) {
|
334 |
-
// black list first
|
335 |
-
foreach ($black_list as $v) {
|
336 |
-
if ((isset($trace['file'], $v['file']) && $this->is_file_in($trace['file'], $v['file'])) || (isset($trace['function'], $v['function']) && $trace['function'] == $v['function']))
|
337 |
-
return $url;
|
338 |
-
}
|
339 |
-
|
340 |
-
foreach ($white_list as $v) {
|
341 |
-
if ((isset($trace['function'], $v['function']) && $trace['function'] == $v['function']) ||
|
342 |
-
(isset($trace['file'], $v['file']) && $this->is_file_in($trace['file'], $v['file']) && in_array($trace['function'], array('home_url', 'get_home_url', 'bloginfo', 'get_bloginfo'))))
|
343 |
-
$ok = true;
|
344 |
-
}
|
345 |
-
}
|
346 |
-
|
347 |
-
return empty($ok) ? $url : (empty($path) ? rtrim($this->get_home_url($this->curlang), '/') : $this->get_home_url($this->curlang));
|
348 |
-
}
|
349 |
-
|
350 |
-
/*
|
351 |
-
* returns the url of the translation (if exists) of the current page
|
352 |
*
|
353 |
* @since 0.1
|
354 |
*
|
355 |
* @param object $language
|
356 |
* @return string
|
357 |
*/
|
358 |
-
public function get_translation_url($language) {
|
359 |
-
if (false !== $translation_url = $this->cache->get('translation_url:' . $language->slug))
|
360 |
-
return $translation_url;
|
361 |
-
|
362 |
global $wp_query;
|
363 |
-
|
364 |
-
$
|
|
|
|
|
365 |
|
366 |
// make sure that we have the queried object
|
367 |
// see https://wordpress.org/support/topic/patch-for-fixing-a-notice
|
368 |
$queried_object_id = $wp_query->get_queried_object_id();
|
369 |
|
370 |
-
//
|
371 |
-
if (
|
372 |
-
$
|
373 |
-
|
374 |
-
// page for posts
|
375 |
-
elseif ($wp_query->is_posts_page && !empty($queried_object_id) && ($id = $this->model->get_post($wp_query->queried_object_id, $language)))
|
376 |
-
$url = get_permalink($id);
|
377 |
|
378 |
-
|
379 |
-
|
380 |
-
|
|
|
381 |
|
382 |
-
|
383 |
-
$
|
|
|
|
|
384 |
|
385 |
-
|
386 |
-
|
387 |
|
388 |
-
|
389 |
-
|
|
|
|
|
390 |
|
391 |
-
|
392 |
-
|
393 |
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
|
|
399 |
}
|
400 |
}
|
401 |
}
|
402 |
}
|
403 |
}
|
404 |
-
}
|
405 |
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
|
|
|
|
|
|
|
|
410 |
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
}
|
419 |
-
}
|
420 |
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
|
|
426 |
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
|
|
435 |
|
436 |
-
|
437 |
-
|
|
|
|
|
|
|
438 |
|
439 |
-
$translation_url = apply_filters('pll_translation_url', (isset($url) && !is_wp_error($url) ? $url : null), $language->slug);
|
440 |
-
$this->cache->set('translation_url:' . $language->slug, $translation_url);
|
441 |
return $translation_url;
|
442 |
}
|
443 |
|
@@ -450,11 +136,11 @@ class PLL_Frontend_Links extends PLL_Links {
|
|
450 |
* @param object $language
|
451 |
* @return string
|
452 |
*/
|
453 |
-
public function get_archive_url($language) {
|
454 |
$url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
455 |
-
$url = $this->links_model->switch_language_in_link($url, $language);
|
456 |
-
$url = $this->links_model->remove_paged_from_link($url);
|
457 |
-
return apply_filters('pll_get_archive_url', $url, $language);
|
458 |
}
|
459 |
|
460 |
/*
|
@@ -465,101 +151,11 @@ class PLL_Frontend_Links extends PLL_Links {
|
|
465 |
* @param object $language optional defaults to current language
|
466 |
* @param bool $is_search optional wether we need the home url for a search form, defaults to false
|
467 |
*/
|
468 |
-
public function get_home_url($language = '', $is_search = false) {
|
469 |
-
if (empty($language))
|
470 |
-
$language = $this->curlang;
|
471 |
-
|
472 |
-
return parent::get_home_url($language, $is_search);
|
473 |
-
}
|
474 |
-
|
475 |
-
/*
|
476 |
-
* rewrites ajax url when using domains or subdomains
|
477 |
-
*
|
478 |
-
* @since 1.5
|
479 |
-
*
|
480 |
-
* @param string $url admin url with path evaluated by WordPress
|
481 |
-
* @param string $path admin path
|
482 |
-
* @return string
|
483 |
-
*/
|
484 |
-
public function admin_url($url, $path) {
|
485 |
-
return 'admin-ajax.php' === $path ? $this->links_model->switch_language_in_link($url, $this->curlang) : $url;
|
486 |
-
}
|
487 |
-
|
488 |
-
/*
|
489 |
-
* if the language code is not in agreement with the language of the content
|
490 |
-
* redirects incoming links to the proper URL to avoid duplicate content
|
491 |
-
*
|
492 |
-
* @since 0.9.6
|
493 |
-
*
|
494 |
-
* @param string $requested_url optional
|
495 |
-
* @param bool $do_redirect optional, whether to perform the redirection or not
|
496 |
-
* @return string if redirect is not performed
|
497 |
-
*/
|
498 |
-
public function check_canonical_url($requested_url = '', $do_redirect = true) {
|
499 |
-
global $wp_query, $post, $is_IIS;
|
500 |
-
|
501 |
-
// don't redirect in same cases as WP
|
502 |
-
if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) {
|
503 |
-
return;
|
504 |
-
}
|
505 |
-
|
506 |
-
// don't redirect mysite.com/?attachment_id= to mysite.com/en/?attachment_id=
|
507 |
-
if (1 == $this->options['force_lang'] && is_attachment() && isset($_GET['attachment_id']))
|
508 |
-
return;
|
509 |
-
|
510 |
-
// if the default language code is not hidden and the static front page url contains the page name
|
511 |
-
// the customizer lands here and the code below would redirect to the list of posts
|
512 |
-
if (isset($_POST['wp_customize'], $_POST['customized']))
|
513 |
-
return;
|
514 |
-
|
515 |
-
// don't redirect if we are on a static front page
|
516 |
-
if ($this->options['redirect_lang'] && isset($this->page_on_front) && is_page($this->page_on_front))
|
517 |
-
return;
|
518 |
-
|
519 |
-
if (empty($requested_url))
|
520 |
-
$requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
521 |
-
|
522 |
-
if (is_single() || is_page()) {
|
523 |
-
if (isset($post->ID) && $this->model->is_translated_post_type($post->post_type)) {
|
524 |
-
$language = $this->model->get_post_language((int)$post->ID);
|
525 |
-
}
|
526 |
-
}
|
527 |
-
|
528 |
-
elseif (is_category() || is_tag() || is_tax()) {
|
529 |
-
$obj = $wp_query->get_queried_object();
|
530 |
-
if ($this->model->is_translated_taxonomy($obj->taxonomy)) {
|
531 |
-
$language = $this->model->get_term_language((int)$obj->term_id);
|
532 |
-
}
|
533 |
-
}
|
534 |
-
|
535 |
-
elseif ($wp_query->is_posts_page) {
|
536 |
-
$obj = $wp_query->get_queried_object();
|
537 |
-
$language = $this->model->get_post_language((int)$obj->ID);
|
538 |
-
}
|
539 |
-
|
540 |
-
if (empty($language)) {
|
541 |
$language = $this->curlang;
|
542 |
-
$redirect_url = $requested_url;
|
543 |
-
}
|
544 |
-
else {
|
545 |
-
// first get the canonical url evaluated by WP
|
546 |
-
$redirect_url = (!$redirect_url = redirect_canonical($requested_url, false)) ? $requested_url : $redirect_url;
|
547 |
-
|
548 |
-
// then get the right language code in url
|
549 |
-
$redirect_url = $this->options['force_lang'] ?
|
550 |
-
$this->links_model->switch_language_in_link($redirect_url, $language) :
|
551 |
-
$this->links_model->remove_language_from_link($redirect_url); // works only for default permalinks
|
552 |
-
}
|
553 |
-
|
554 |
-
// allow plugins to change the redirection or even cancel it by setting $redirect_url to false
|
555 |
-
$redirect_url = apply_filters('pll_check_canonical_url', $redirect_url, $language);
|
556 |
-
|
557 |
-
// the language is not correctly set so let's redirect to the correct url for this object
|
558 |
-
if ($do_redirect && $redirect_url && $requested_url != $redirect_url) {
|
559 |
-
wp_redirect($redirect_url, 301);
|
560 |
-
exit;
|
561 |
}
|
562 |
|
563 |
-
return $
|
564 |
}
|
565 |
}
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Frontend_Links extends PLL_Links {
|
9 |
+
public $curlang;
|
10 |
+
public $cache; // our internal non persistent cache object
|
11 |
|
12 |
/*
|
13 |
* constructor
|
16 |
*
|
17 |
* @param object $polylang
|
18 |
*/
|
19 |
+
public function __construct( &$polylang ) {
|
20 |
+
parent::__construct( $polylang );
|
21 |
|
22 |
$this->curlang = &$polylang->curlang;
|
|
|
|
|
23 |
$this->cache = new PLL_Cache();
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
/*
|
28 |
+
* returns the url of the translation ( if exists ) of the current page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
*
|
30 |
* @since 0.1
|
31 |
*
|
32 |
* @param object $language
|
33 |
* @return string
|
34 |
*/
|
35 |
+
public function get_translation_url( $language ) {
|
|
|
|
|
|
|
36 |
global $wp_query;
|
37 |
+
|
38 |
+
if ( false !== $translation_url = $this->cache->get( 'translation_url:' . $language->slug ) ) {
|
39 |
+
return $translation_url;
|
40 |
+
}
|
41 |
|
42 |
// make sure that we have the queried object
|
43 |
// see https://wordpress.org/support/topic/patch-for-fixing-a-notice
|
44 |
$queried_object_id = $wp_query->get_queried_object_id();
|
45 |
|
46 |
+
// the filter will handle the static front page and posts page
|
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'];
|
|
|
|
|
|
|
50 |
|
51 |
+
// post and attachment
|
52 |
+
if ( is_single() && ( $this->options['media_support'] || ! is_attachment() ) && ( $id = $this->model->post->get( $queried_object_id, $language ) ) && $this->current_user_can_read( $id ) ) {
|
53 |
+
$url = get_permalink( $id );
|
54 |
+
}
|
55 |
|
56 |
+
// page
|
57 |
+
elseif ( is_page() && ( $id = $this->model->post->get( $queried_object_id, $language ) ) && $this->current_user_can_read( $id ) ) {
|
58 |
+
$url = get_page_link( $id );
|
59 |
+
}
|
60 |
|
61 |
+
elseif ( is_search() ) {
|
62 |
+
$url = $this->get_archive_url( $language );
|
63 |
|
64 |
+
// special case for search filtered by translated taxonomies: taxonomy terms are translated in the translation url
|
65 |
+
if ( ! empty( $wp_query->tax_query->queries ) ) {
|
66 |
+
foreach ( $wp_query->tax_query->queries as $tax_query ) {
|
67 |
+
if ( ! empty( $tax_query['taxonomy'] ) && $this->model->is_translated_taxonomy( $tax_query['taxonomy'] ) ) {
|
68 |
|
69 |
+
$tax = get_taxonomy( $tax_query['taxonomy'] );
|
70 |
+
$terms = get_terms( $tax->name, array( 'fields' => 'id=>slug' ) ); // filtered by current language
|
71 |
|
72 |
+
foreach ( $tax_query['terms'] as $slug ) {
|
73 |
+
$term_id = array_search( $slug, $terms ); // what is the term_id corresponding to taxonomy term?
|
74 |
+
if ( $term_id && $term_id = $this->model->term->get_translation( $term_id, $language ) ) { // get the translated term_id
|
75 |
+
$term = get_term( $term_id, $tax->name );
|
76 |
+
$url = str_replace( $slug, $term->slug, $url );
|
77 |
+
}
|
78 |
}
|
79 |
}
|
80 |
}
|
81 |
}
|
82 |
}
|
|
|
83 |
|
84 |
+
// translated taxonomy
|
85 |
+
// take care that is_tax() is false for categories and tags
|
86 |
+
elseif ( ( is_category() || is_tag() || is_tax() ) && ( $term = get_queried_object() ) && $this->model->is_translated_taxonomy( $term->taxonomy ) ) {
|
87 |
+
$lang = $this->model->term->get_language( $term->term_id );
|
88 |
+
|
89 |
+
if ( ! $lang || $language->slug == $lang->slug ) {
|
90 |
+
$url = get_term_link( $term, $term->taxonomy ); // self link
|
91 |
+
}
|
92 |
|
93 |
+
elseif ( $tr_id = $this->model->term->get_translation( $term->term_id, $language ) ) {
|
94 |
+
$tr_term = get_term( $tr_id, $term->taxonomy );
|
95 |
+
// check if translated term ( or children ) have posts
|
96 |
+
if ( $tr_term && ( $tr_term->count || ( is_taxonomy_hierarchical( $term->taxonomy ) && array_sum( wp_list_pluck( get_terms( $term->taxonomy, array( 'child_of' => $tr_term->term_id, 'lang' => $language->slug ) ), 'count' ) ) ) ) ) {
|
97 |
+
$url = get_term_link( $tr_term, $term->taxonomy );
|
98 |
+
}
|
99 |
+
}
|
100 |
}
|
|
|
101 |
|
102 |
+
// post type archive
|
103 |
+
elseif ( is_post_type_archive() ) {
|
104 |
+
if ( $this->model->is_translated_post_type( $qv['post_type'] ) && $this->model->count_posts( $language, array( 'post_type' => $qv['post_type'] ) ) ) {
|
105 |
+
$url = $this->get_archive_url( $language );
|
106 |
+
}
|
107 |
+
}
|
108 |
|
109 |
+
elseif ( is_archive() ) {
|
110 |
+
$keys = array( 'post_type', 'm', 'year', 'monthnum', 'day', 'author', 'author_name' );
|
111 |
+
$keys = array_merge( $keys, $this->model->get_filtered_taxonomies_query_vars() );
|
112 |
|
113 |
+
// check if there are existing translations before creating the url
|
114 |
+
if ( $this->model->count_posts( $language, array_intersect_key( $qv, array_flip( $keys ) ) ) ) {
|
115 |
+
$url = $this->get_archive_url( $language );
|
116 |
+
}
|
117 |
+
}
|
118 |
|
119 |
+
// front page when it is the list of posts
|
120 |
+
elseif ( is_front_page() ) {
|
121 |
+
$url = $this->get_home_url( $language );
|
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 |
|
136 |
* @param object $language
|
137 |
* @return string
|
138 |
*/
|
139 |
+
public function get_archive_url( $language ) {
|
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 |
/*
|
151 |
* @param object $language optional defaults to current language
|
152 |
* @param bool $is_search optional wether we need the home url for a search form, defaults to false
|
153 |
*/
|
154 |
+
public function get_home_url( $language = '', $is_search = false ) {
|
155 |
+
if ( empty( $language ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
$language = $this->curlang;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
|
159 |
+
return parent::get_home_url( $language, $is_search );
|
160 |
}
|
161 |
}
|
frontend/frontend-nav-menu.php
CHANGED
@@ -13,19 +13,25 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
13 |
*
|
14 |
* @since 1.2
|
15 |
*/
|
16 |
-
public function __construct(&$polylang) {
|
17 |
-
parent::__construct($polylang);
|
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 |
|
31 |
/*
|
@@ -37,8 +43,8 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
37 |
* @param object $b The second object to compare
|
38 |
* @return int -1 or 1 if $a is considered to be respectively less than or greater than $b.
|
39 |
*/
|
40 |
-
protected function usort_menu_items($a, $b) {
|
41 |
-
return ($a->menu_order < $b->menu_order) ? -1 : 1;
|
42 |
}
|
43 |
|
44 |
/*
|
@@ -50,27 +56,31 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
50 |
* @param array $items menu items
|
51 |
* @return array modified items
|
52 |
*/
|
53 |
-
public function wp_get_nav_menu_items($items) {
|
54 |
-
if (doing_action('customize_register')) { // needed since WP 4.3, doing_action available since WP 3.9
|
55 |
return $items;
|
56 |
}
|
57 |
|
58 |
// the customizer menus does not sort the items and we need them to be sorted before splitting the language switcher
|
59 |
-
usort($items, array($this, 'usort_menu_items'));
|
60 |
|
61 |
$new_items = array();
|
62 |
$offset = 0;
|
63 |
|
64 |
-
foreach ($items as $key => $item) {
|
65 |
-
if ($options = get_post_meta($item->ID, '_pll_menu_item', true)) {
|
66 |
$i = 0;
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
69 |
$lang_item = clone $item;
|
70 |
$lang_item->ID = $lang_item->ID . '-' . $lang['slug']; // a unique ID
|
71 |
-
$lang_item->title = $options['show_flags'] && $options['show_names'] ? $lang['flag'].' '.esc_html($lang['name']) : ($options['show_flags'] ? $lang['flag'] : esc_html($lang['name']));
|
72 |
$lang_item->url = $lang['url'];
|
73 |
-
$lang_item->lang = $lang['
|
74 |
$lang_item->classes = $lang['classes'];
|
75 |
$lang_item->menu_order += $offset + $i++;
|
76 |
$new_items[] = $lang_item;
|
@@ -94,11 +104,12 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
94 |
* @param object $item
|
95 |
* @return array ancestors ids
|
96 |
*/
|
97 |
-
public function get_ancestors($item) {
|
98 |
$ids = array();
|
99 |
$_anc_id = (int) $item->db_id;
|
100 |
-
while(($_anc_id = get_post_meta($_anc_id, '_menu_item_menu_item_parent', true)) && !in_array($_anc_id, $ids))
|
101 |
$ids[] = $_anc_id;
|
|
|
102 |
return $ids;
|
103 |
}
|
104 |
|
@@ -110,26 +121,27 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
110 |
* @param array $items
|
111 |
* @return array modified menu items
|
112 |
*/
|
113 |
-
public function wp_nav_menu_objects($items) {
|
114 |
$r_ids = $k_ids = array();
|
115 |
|
116 |
-
foreach ($items as $item) {
|
117 |
-
if (!empty($item->classes) && is_array($item->classes)) {
|
118 |
-
if (in_array('current-lang', $item->classes)) {
|
119 |
-
$item->classes = array_diff($item->classes, array('current-menu-item'));
|
120 |
-
$r_ids = array_merge($r_ids, $this->get_ancestors($item)); // remove the classes for these ancestors
|
121 |
}
|
122 |
-
elseif (in_array('current-menu-item', $item->classes)) {
|
123 |
-
$k_ids = array_merge($k_ids, $this->get_ancestors($item)); // keep the classes for these ancestors
|
124 |
}
|
125 |
}
|
126 |
}
|
127 |
|
128 |
-
$r_ids = array_diff($r_ids, $k_ids);
|
129 |
|
130 |
-
foreach ($items as $item) {
|
131 |
-
if (!empty($item->db_id) && in_array($item->db_id, $r_ids))
|
132 |
-
$item->classes = array_diff($item->classes, array('current-menu-ancestor', 'current-menu-parent', 'current_page_parent', 'current_page_ancestor'));
|
|
|
133 |
}
|
134 |
|
135 |
return $items;
|
@@ -144,9 +156,10 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
144 |
* @param array $atts
|
145 |
* @return array modified $atts
|
146 |
*/
|
147 |
-
public function nav_menu_link_attributes($atts, $item, $args) {
|
148 |
-
if (isset($item->lang))
|
149 |
-
$atts['hreflang'] = esc_attr($item->lang);
|
|
|
150 |
return $atts;
|
151 |
}
|
152 |
|
@@ -159,29 +172,30 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
159 |
* @param array|bool list of nav menus locations, false if menu locations have not been filled yet
|
160 |
* @return array|bool modified list of nav menus locations
|
161 |
*/
|
162 |
-
public function nav_menu_locations($menus) {
|
163 |
-
if (is_array($menus) && !empty($this->curlang)) {
|
164 |
// first get multilingual menu locations from DB
|
165 |
-
$theme = get_option('stylesheet');
|
166 |
|
167 |
-
foreach ($menus as $loc => $menu)
|
168 |
-
$menus[$loc] = empty($this->options['nav_menus'][$theme][$loc][$this->curlang->slug]) ? 0 : $this->options['nav_menus'][$theme][$loc][$this->curlang->slug];
|
|
|
169 |
|
170 |
// support for theme customizer
|
171 |
// let's look for multilingual menu locations directly in $_POST as there are not in customizer object
|
172 |
-
if (isset($_POST['wp_customize'], $_POST['customized'])) {
|
173 |
-
$customized = json_decode(wp_unslash($_POST['customized']));
|
174 |
-
|
175 |
-
if (is_object($customized)) {
|
176 |
-
foreach ($customized as $key => $c) {
|
177 |
-
if (false !== strpos($key, 'nav_menu_locations[')) {
|
178 |
-
$loc = substr(trim($key, ']'), 19);
|
179 |
-
|
180 |
-
|
181 |
-
$menus[$
|
182 |
}
|
183 |
-
elseif ($this->curlang->slug == $this->options['default_lang']) {
|
184 |
-
$menus[$loc] = $c;
|
185 |
}
|
186 |
}
|
187 |
}
|
@@ -200,7 +214,7 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
200 |
* @return array modified $args
|
201 |
*/
|
202 |
public function wp_nav_menu_args( $args ) {
|
203 |
-
$theme = get_option('stylesheet');
|
204 |
|
205 |
if ( empty( $this->curlang ) || empty( $this->options['nav_menus'][ $theme ] ) ) {
|
206 |
return $args;
|
@@ -237,4 +251,33 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
237 |
|
238 |
return $args;
|
239 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
}
|
13 |
*
|
14 |
* @since 1.2
|
15 |
*/
|
16 |
+
public function __construct( &$polylang ) {
|
17 |
+
parent::__construct( $polylang );
|
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 |
/*
|
43 |
* @param object $b The second object to compare
|
44 |
* @return int -1 or 1 if $a is considered to be respectively less than or greater than $b.
|
45 |
*/
|
46 |
+
protected function usort_menu_items( $a, $b ) {
|
47 |
+
return ( $a->menu_order < $b->menu_order ) ? -1 : 1;
|
48 |
}
|
49 |
|
50 |
/*
|
56 |
* @param array $items menu items
|
57 |
* @return array modified items
|
58 |
*/
|
59 |
+
public function wp_get_nav_menu_items( $items ) {
|
60 |
+
if ( doing_action( 'customize_register' ) ) { // needed since WP 4.3, doing_action available since WP 3.9
|
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();
|
68 |
$offset = 0;
|
69 |
|
70 |
+
foreach ( $items as $key => $item ) {
|
71 |
+
if ( $options = get_post_meta( $item->ID, '_pll_menu_item', true ) ) {
|
72 |
$i = 0;
|
73 |
|
74 |
+
$switcher = new PLL_Switcher;
|
75 |
+
$args = array_merge( array( 'raw' => 1 ), $options );
|
76 |
+
$the_languages = $switcher->the_languages( PLL()->links, $args );
|
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'].' '.esc_html( $lang['name'] ) : ( $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;
|
104 |
* @param object $item
|
105 |
* @return array ancestors ids
|
106 |
*/
|
107 |
+
public function get_ancestors( $item ) {
|
108 |
$ids = array();
|
109 |
$_anc_id = (int) $item->db_id;
|
110 |
+
while ( ( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) && ! in_array( $_anc_id, $ids ) ) {
|
111 |
$ids[] = $_anc_id;
|
112 |
+
}
|
113 |
return $ids;
|
114 |
}
|
115 |
|
121 |
* @param array $items
|
122 |
* @return array modified menu items
|
123 |
*/
|
124 |
+
public function wp_nav_menu_objects( $items ) {
|
125 |
$r_ids = $k_ids = array();
|
126 |
|
127 |
+
foreach ( $items as $item ) {
|
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 ) ); // remove the classes for these ancestors
|
132 |
}
|
133 |
+
elseif ( in_array( 'current-menu-item', $item->classes ) ) {
|
134 |
+
$k_ids = array_merge( $k_ids, $this->get_ancestors( $item ) ); // keep the classes for these ancestors
|
135 |
}
|
136 |
}
|
137 |
}
|
138 |
|
139 |
+
$r_ids = array_diff( $r_ids, $k_ids );
|
140 |
|
141 |
+
foreach ( $items as $item ) {
|
142 |
+
if ( ! empty( $item->db_id ) && in_array( $item->db_id, $r_ids ) ) {
|
143 |
+
$item->classes = array_diff( $item->classes, array( 'current-menu-ancestor', 'current-menu-parent', 'current_page_parent', 'current_page_ancestor' ) );
|
144 |
+
}
|
145 |
}
|
146 |
|
147 |
return $items;
|
156 |
* @param array $atts
|
157 |
* @return array modified $atts
|
158 |
*/
|
159 |
+
public function nav_menu_link_attributes( $atts, $item, $args ) {
|
160 |
+
if ( isset( $item->lang ) ) {
|
161 |
+
$atts['hreflang'] = esc_attr( $item->lang );
|
162 |
+
}
|
163 |
return $atts;
|
164 |
}
|
165 |
|
172 |
* @param array|bool list of nav menus locations, false if menu locations have not been filled yet
|
173 |
* @return array|bool modified list of nav menus locations
|
174 |
*/
|
175 |
+
public function nav_menu_locations( $menus ) {
|
176 |
+
if ( is_array( $menus ) && ! empty( $this->curlang ) ) {
|
177 |
// first get multilingual menu locations from DB
|
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 |
// support for theme customizer
|
185 |
// let's look for multilingual menu locations directly in $_POST as there are not in customizer object
|
186 |
+
if ( isset( $_POST['wp_customize'], $_POST['customized'] ) ) {
|
187 |
+
$customized = json_decode( wp_unslash( $_POST['customized'] ) );
|
188 |
+
|
189 |
+
if ( is_object( $customized ) ) {
|
190 |
+
foreach ( $customized as $key => $c ) {
|
191 |
+
if ( false !== strpos( $key, 'nav_menu_locations[' ) ) {
|
192 |
+
$loc = substr( trim( $key, ']' ), 19 );
|
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 |
}
|
201 |
}
|
214 |
* @return array modified $args
|
215 |
*/
|
216 |
public function wp_nav_menu_args( $args ) {
|
217 |
+
$theme = get_option( 'stylesheet' );
|
218 |
|
219 |
if ( empty( $this->curlang ) || empty( $this->options['nav_menus'][ $theme ] ) ) {
|
220 |
return $args;
|
251 |
|
252 |
return $args;
|
253 |
}
|
254 |
+
|
255 |
+
/*
|
256 |
+
* filters the nav menu location before the customizer so that it matches the temporary location in the customizer
|
257 |
+
*
|
258 |
+
* @since 1.8
|
259 |
+
*
|
260 |
+
* @param array $args wp_nav_menu $args
|
261 |
+
* @return array modified $args
|
262 |
+
*/
|
263 |
+
public function filter_args_before_customizer( $args ) {
|
264 |
+
if ( ! empty( $this->curlang ) ) {
|
265 |
+
$args['theme_location'] = $this->combine_location( $args['theme_location'], $this->curlang );
|
266 |
+
}
|
267 |
+
return $args;
|
268 |
+
}
|
269 |
+
|
270 |
+
/*
|
271 |
+
* filters the nav menu location after the customizer to get back the true nav menu location for the theme
|
272 |
+
*
|
273 |
+
* @since 1.8
|
274 |
+
*
|
275 |
+
* @param array $args wp_nav_menu $args
|
276 |
+
* @return array modified $args
|
277 |
+
*/
|
278 |
+
public function filter_args_after_customizer( $args ) {
|
279 |
+
$infos = $this->explode_location( $args['theme_location'] );
|
280 |
+
$args['theme_location'] = $infos['location'];
|
281 |
+
return $args;
|
282 |
+
}
|
283 |
}
|
frontend/frontend-static-pages.php
ADDED
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
14 |
+
*
|
15 |
+
* @param object $polylang
|
16 |
+
*/
|
17 |
+
public function __construct( &$polylang ) {
|
18 |
+
parent::__construct( $polylang );
|
19 |
+
|
20 |
+
$this->links_model = &$polylang->links_model;
|
21 |
+
$this->links = &$polylang->links;
|
22 |
+
$this->curlang = &$polylang->curlang;
|
23 |
+
|
24 |
+
add_action( 'pll_language_defined', array( &$this, 'pll_language_defined' ) );
|
25 |
+
add_action( 'pll_home_requested', array( &$this, 'pll_home_requested' ) );
|
26 |
+
|
27 |
+
// modifies the page link in case the front page is not in the default language
|
28 |
+
add_filter( 'page_link', array( &$this, 'page_link' ), 20, 2 );
|
29 |
+
|
30 |
+
// manages the redirection of the homepage
|
31 |
+
add_filter( 'redirect_canonical', array( &$this, 'redirect_canonical' ), 10, 2 );
|
32 |
+
|
33 |
+
add_filter( 'pll_pre_translation_url', array( &$this, 'pll_pre_translation_url' ), 10, 3 );
|
34 |
+
add_filter( 'pll_check_canonical_url', array( &$this, 'pll_check_canonical_url' ) );
|
35 |
+
|
36 |
+
add_filter( 'pll_set_language_from_query', array( &$this, 'page_on_front_query' ), 10, 2 );
|
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
|
44 |
+
*/
|
45 |
+
public function pll_language_defined() {
|
46 |
+
// translates our page on front and page for posts properties
|
47 |
+
$this->init();
|
48 |
+
|
49 |
+
// translates page for posts and page on front
|
50 |
+
add_filter( 'option_page_on_front', array( &$this, 'translate_page_on_front' ) );
|
51 |
+
add_filter( 'option_page_for_posts', array( &$this, 'translate_page_for_posts' ) );
|
52 |
+
|
53 |
+
// support theme customizer
|
54 |
+
if ( isset( $_POST['wp_customize'], $_POST['customized'] ) ) {
|
55 |
+
add_filter( 'pre_option_page_on_front', 'pll_get_post', 20 );
|
56 |
+
add_filter( 'pre_option_page_for_post', 'pll_get_post', 20 );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
/*
|
61 |
+
* translates the page_id query var when the site root page is requested
|
62 |
+
*
|
63 |
+
* @since 1.8
|
64 |
+
*/
|
65 |
+
public function pll_home_requested() {
|
66 |
+
set_query_var( 'page_id', $this->curlang->page_on_front );
|
67 |
+
}
|
68 |
+
|
69 |
+
/*
|
70 |
+
* translates page on front
|
71 |
+
*
|
72 |
+
* @since 1.8
|
73 |
+
*
|
74 |
+
* @param int $v page on front page id
|
75 |
+
* @return int
|
76 |
+
*/
|
77 |
+
public function translate_page_on_front( $v ) {
|
78 |
+
// returns the current page if there is no translation to avoid ugly notices
|
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
|
86 |
+
*
|
87 |
+
* @param int $v page for posts page id
|
88 |
+
* @return int
|
89 |
+
*/
|
90 |
+
public function translate_page_for_posts( $v ) {
|
91 |
+
// returns the current page if there is no translation to avoid ugly notices
|
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
|
99 |
+
*
|
100 |
+
* @param string $link
|
101 |
+
* @param int $id
|
102 |
+
* @return string modified link
|
103 |
+
*/
|
104 |
+
public function page_link( $link, $id ) {
|
105 |
+
if ( ( $lang = $this->model->post->get_language( $id ) ) && $id == $lang->page_on_front ) {
|
106 |
+
return $lang->home_url;
|
107 |
+
}
|
108 |
+
return $link;
|
109 |
+
}
|
110 |
+
|
111 |
+
/*
|
112 |
+
* manages canonical redirection of the homepage when using page on front
|
113 |
+
*
|
114 |
+
* @since 0.1
|
115 |
+
*
|
116 |
+
* @param string $redirect_url
|
117 |
+
* @param string $requested_url
|
118 |
+
* @return bool|string modified url, false if redirection is canceled
|
119 |
+
*/
|
120 |
+
public function redirect_canonical( $redirect_url, $requested_url ) {
|
121 |
+
global $wp_query;
|
122 |
+
if ( is_page() && ! is_feed() && isset( $wp_query->queried_object ) && $wp_query->queried_object->ID == $this->curlang->page_on_front ) {
|
123 |
+
$url = is_paged() ? $this->links_model->add_paged_to_link( $this->links->get_home_url(), $wp_query->query_vars['page'] ) : $this->links->get_home_url();
|
124 |
+
|
125 |
+
// don't forget additional query vars
|
126 |
+
$query = parse_url( $redirect_url, PHP_URL_QUERY );
|
127 |
+
if ( ! empty( $query ) ) {
|
128 |
+
parse_str( $query, $query_vars );
|
129 |
+
$query_vars = rawurlencode_deep( $query_vars ); // WP encodes query vars values
|
130 |
+
$url = add_query_arg( $query_vars, $url );
|
131 |
+
}
|
132 |
+
|
133 |
+
return $url;
|
134 |
+
}
|
135 |
+
|
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
|
143 |
+
*
|
144 |
+
* @param string $url not used
|
145 |
+
* @param object $language
|
146 |
+
* @param int $queried_object_id
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
public function pll_pre_translation_url( $url, $language, $queried_object_id ) {
|
150 |
+
if ( ! empty( $queried_object_id ) ) {
|
151 |
+
// page for posts
|
152 |
+
if ( $GLOBALS['wp_query']->is_posts_page && ( $id = $this->model->post->get( $queried_object_id, $language ) ) ) {
|
153 |
+
$url = get_permalink( $id );
|
154 |
+
}
|
155 |
+
|
156 |
+
// page on front
|
157 |
+
elseif ( is_front_page() && $language->page_on_front && ( $language->page_on_front == $this->model->post->get( $queried_object_id, $language ) ) ) {
|
158 |
+
$url = $language->home_url;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
return $url;
|
163 |
+
}
|
164 |
+
|
165 |
+
/*
|
166 |
+
* prevents canonical redirection if we are on a static front page
|
167 |
+
*
|
168 |
+
* @since 1.8
|
169 |
+
*
|
170 |
+
* @param string $redirect_url
|
171 |
+
* @return bool|string
|
172 |
+
*/
|
173 |
+
public function pll_check_canonical_url( $redirect_url ) {
|
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
|
181 |
+
*
|
182 |
+
* @param bool|object $lang
|
183 |
+
* @param object $query
|
184 |
+
* @return bool|object
|
185 |
+
*/
|
186 |
+
public function page_on_front_query( $lang, $query ) {
|
187 |
+
if ( ! empty( $lang ) || ! $this->page_on_front ) {
|
188 |
+
return $lang;
|
189 |
+
}
|
190 |
+
|
191 |
+
// the home page is requested
|
192 |
+
if ( did_action( 'home_requested' ) ) {
|
193 |
+
$query->set( 'page_id', $lang->page_on_front );
|
194 |
+
}
|
195 |
+
|
196 |
+
// redirect the language page to the homepage when using a static front page
|
197 |
+
elseif ( $this->options['redirect_lang'] && ( count( $query->query ) == 1 || ( is_paged() && count( $query->query ) == 2 ) ) && is_tax( 'language' ) ) {
|
198 |
+
$lang = $this->model->get_language( get_query_var( 'lang' ) );
|
199 |
+
$query->set( 'page_id', $lang->page_on_front );
|
200 |
+
$query->is_singular = $query->is_page = true;
|
201 |
+
$query->is_archive = $query->is_tax = false;
|
202 |
+
unset( $query->query_vars['lang'], $query->queried_object ); // reset queried object
|
203 |
+
}
|
204 |
+
|
205 |
+
// set the language when requesting a static front page
|
206 |
+
else {
|
207 |
+
$page_id = $this->get_page_id( $query );
|
208 |
+
$languages = $this->model->get_languages_list();
|
209 |
+
$pages = wp_list_pluck( $languages, 'page_on_front' );
|
210 |
+
|
211 |
+
if ( ! empty( $page_id ) && false !== $n = array_search( $page_id, $pages ) ) {
|
212 |
+
$lang = $languages[ $n ];
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
// correct <!--nextpage--> for page_on_front
|
217 |
+
if ( ! empty( $lang ) ) {
|
218 |
+
$query->set( 'page', $query->query_vars['paged'] );
|
219 |
+
unset( $query->query_vars['paged'] );
|
220 |
+
}
|
221 |
+
|
222 |
+
return $lang;
|
223 |
+
}
|
224 |
+
|
225 |
+
/*
|
226 |
+
* setups query vars when requesting a posts page
|
227 |
+
*
|
228 |
+
* @since 1.8
|
229 |
+
*
|
230 |
+
* @param bool|object $lang
|
231 |
+
* @param object $query
|
232 |
+
* @return bool|object
|
233 |
+
*/
|
234 |
+
public function page_for_posts_query( $lang, $query ) {
|
235 |
+
if ( empty( $lang ) && $this->page_for_posts ) {
|
236 |
+
$page_id = $this->get_page_id( $query );
|
237 |
+
|
238 |
+
if ( ! empty( $page_id ) && in_array( $page_id, $pages = $this->model->get_languages_list( array( 'fields' => 'page_for_posts' ) ) ) ) {
|
239 |
+
// fill the cache with all pages for posts to avoid one query per page later
|
240 |
+
// the posts_per_page limit is a trick to avoid splitting the query
|
241 |
+
get_posts( array( 'posts_per_page' => 999, 'post_type' => 'page', 'post__in' => $pages, 'lang' => '' ) );
|
242 |
+
|
243 |
+
$lang = $this->model->post->get_language( $page_id );
|
244 |
+
$query->is_singular = $query->is_page = false;
|
245 |
+
$query->is_home = $query->is_posts_page = true;
|
246 |
+
}
|
247 |
+
}
|
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 :(
|
255 |
+
*
|
256 |
+
* @since 1.5
|
257 |
+
*
|
258 |
+
* @param object $query instance of WP_Query
|
259 |
+
* @return int page_id
|
260 |
+
*/
|
261 |
+
protected function get_page_id( $query ) {
|
262 |
+
if ( ! empty( $query->query_vars['pagename'] ) && isset( $query->queried_object_id ) ) {
|
263 |
+
return $query->queried_object_id;
|
264 |
+
}
|
265 |
+
|
266 |
+
if ( isset( $query->query_vars['page_id'] ) ) {
|
267 |
+
return $query->query_vars['page_id'];
|
268 |
+
}
|
269 |
+
|
270 |
+
return 0; // no page queried
|
271 |
+
}
|
272 |
+
}
|
frontend/frontend.php
CHANGED
@@ -9,6 +9,8 @@
|
|
9 |
* model => inherited, reference to PLL_Model object
|
10 |
* links_model => inherited, reference to PLL_Links_Model object
|
11 |
* links => reference to PLL_Links object
|
|
|
|
|
12 |
* choose_lang => reference to PLL_Choose_lang object
|
13 |
* curlang => current language
|
14 |
* filters => reference to PLL_Filters object
|
@@ -29,17 +31,21 @@ class PLL_Frontend extends PLL_Base {
|
|
29 |
*
|
30 |
* @param object $links_model
|
31 |
*/
|
32 |
-
public function __construct(&$links_model) {
|
33 |
-
parent::__construct($links_model);
|
34 |
|
35 |
-
add_action('pll_language_defined', array(&$this, 'pll_language_defined'), 1);
|
|
|
|
|
|
|
36 |
|
37 |
// filters posts by language
|
38 |
-
add_action('parse_query', array(&$this, 'parse_query'), 6);
|
39 |
|
40 |
-
// not before '
|
41 |
-
if (!defined('PLL_AUTO_TRANSLATE') || PLL_AUTO_TRANSLATE)
|
42 |
-
add_action('
|
|
|
43 |
}
|
44 |
|
45 |
/*
|
@@ -48,14 +54,17 @@ class PLL_Frontend extends PLL_Base {
|
|
48 |
* @since 1.2
|
49 |
*/
|
50 |
public function init() {
|
51 |
-
$this->links = new PLL_Frontend_Links($this);
|
|
|
52 |
|
53 |
-
|
54 |
-
$
|
55 |
-
$
|
|
|
|
|
56 |
|
57 |
// need to load nav menu class early to correctly define the locations in the customizer when the language is set from the content
|
58 |
-
$this->nav_menu = new PLL_Frontend_Nav_Menu($this);
|
59 |
}
|
60 |
|
61 |
/*
|
@@ -65,8 +74,25 @@ class PLL_Frontend extends PLL_Base {
|
|
65 |
*/
|
66 |
public function pll_language_defined() {
|
67 |
// filters
|
68 |
-
$this->
|
69 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
|
72 |
/*
|
@@ -76,53 +102,41 @@ class PLL_Frontend extends PLL_Base {
|
|
76 |
*
|
77 |
* @param object $query WP_Query object
|
78 |
*/
|
79 |
-
public function parse_query($query) {
|
80 |
$qv = $query->query_vars;
|
81 |
|
82 |
-
// to avoid returning an empty result if the query includes a translated taxonomy in a different language
|
83 |
-
$has_tax = isset($query->tax_query->queries) && $this->
|
84 |
|
85 |
// allow filtering recent posts and secondary queries by the current language
|
86 |
// take care not to break queries for non visible post types such as nav_menu_items
|
87 |
// do not filter if lang is set to an empty value
|
88 |
// do not filter single page and translated taxonomies to avoid conflicts
|
89 |
-
if (!empty($this->curlang) && !isset($qv['lang']) &&
|
90 |
-
$this->choose_lang->set_lang_query_var($query, $this->curlang);
|
91 |
}
|
92 |
|
93 |
// modifies query vars when the language is queried
|
94 |
-
if (!empty($qv['lang'])) {
|
95 |
-
|
96 |
-
|
97 |
-
$queried_taxonomies = array_keys( $tax_query_in_and );
|
98 |
-
|
99 |
-
// do we query another custom taxonomy?
|
100 |
-
$taxonomies = array_diff($queried_taxonomies , array('language', 'category', 'post_tag'));
|
101 |
-
}
|
102 |
|
103 |
// remove pages query when the language is set unless we do a search
|
104 |
// take care not to break the single page, attachment and taxonomies queries!
|
105 |
-
if ( empty( $qv['post_type']) && ! $query->is_search && ! $query->is_page && ! $query->is_attachment && empty( $taxonomies ) ) {
|
106 |
$query->set( 'post_type', 'post' );
|
107 |
}
|
108 |
|
109 |
// unset the is_archive flag for language pages to prevent loading the archive template
|
110 |
// keep archive flag for comment feed otherwise the language filter does not work
|
111 |
-
if (empty($taxonomies) &&
|
112 |
$query->is_archive = false;
|
|
|
113 |
|
114 |
// unset the is_tax flag except if another custom tax is queried
|
115 |
-
|
116 |
-
if (empty($taxonomies) && ($query->is_author || $query->is_post_type_archive || $query->is_date || $query->is_search)) {
|
117 |
$query->is_tax = false;
|
118 |
-
unset($query->queried_object); // FIXME useless?
|
119 |
-
}
|
120 |
-
|
121 |
-
// move the language tax_query at the end to avoid it being the queried object
|
122 |
-
if (!empty($taxonomies) && 'language' == reset( $queried_taxonomies )) {
|
123 |
-
$query->tax_query->queried_terms['language'] = array_shift($query->tax_query->queried_terms);
|
124 |
-
unset($query->queried_object);
|
125 |
-
get_queried_object(); // necessary to avoid the language being the queried object
|
126 |
}
|
127 |
}
|
128 |
}
|
@@ -133,7 +147,7 @@ class PLL_Frontend extends PLL_Base {
|
|
133 |
* @since 1.2
|
134 |
*/
|
135 |
public function auto_translate() {
|
136 |
-
$this->auto_translate = new PLL_Frontend_Auto_Translate($this);
|
137 |
}
|
138 |
|
139 |
/*
|
@@ -142,16 +156,17 @@ class PLL_Frontend extends PLL_Base {
|
|
142 |
*
|
143 |
* @since 1.5.1
|
144 |
*/
|
145 |
-
public function switch_blog($new_blog, $old_blog) {
|
146 |
// need to check that some languages are defined when user is logged in, has several blogs, some without any languages
|
147 |
-
if (parent::switch_blog($new_blog, $old_blog) && did_action('pll_language_defined') && $this->model->get_languages_list()) {
|
148 |
static $restore_curlang;
|
149 |
-
if (empty($restore_curlang))
|
150 |
$restore_curlang = $this->curlang->slug; // to always remember the current language through blogs
|
|
|
151 |
|
152 |
-
$lang = $this->model->get_language($restore_curlang);
|
153 |
-
$this->curlang = $lang ? $lang : $this->model->get_language($this->options['default_lang']);
|
154 |
-
$this->
|
155 |
$this->load_strings_translations();
|
156 |
}
|
157 |
}
|
@@ -166,17 +181,30 @@ class PLL_Frontend extends PLL_Base {
|
|
166 |
* @param array $tax_queries
|
167 |
* @return bool
|
168 |
*/
|
169 |
-
protected function
|
170 |
-
foreach ($tax_queries as $tax_query) {
|
171 |
-
if (isset($tax_query['taxonomy']) && $this->model->
|
172 |
return true;
|
|
|
173 |
|
174 |
// nested queries
|
175 |
-
elseif (is_array($tax_query) && $this->
|
176 |
return true;
|
|
|
177 |
}
|
178 |
|
179 |
return false;
|
180 |
}
|
181 |
-
}
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
* model => inherited, reference to PLL_Model object
|
10 |
* links_model => inherited, reference to PLL_Links_Model object
|
11 |
* links => reference to PLL_Links object
|
12 |
+
* static_pages => reference to PLL_Frontend_Static_Pages object
|
13 |
+
* filters_links => inherited, reference to PLL_Frontend_Filters_Links object
|
14 |
* choose_lang => reference to PLL_Choose_lang object
|
15 |
* curlang => current language
|
16 |
* filters => reference to PLL_Filters object
|
31 |
*
|
32 |
* @param object $links_model
|
33 |
*/
|
34 |
+
public function __construct( &$links_model ) {
|
35 |
+
parent::__construct( $links_model );
|
36 |
|
37 |
+
add_action( 'pll_language_defined', array( &$this, 'pll_language_defined' ), 1 );
|
38 |
+
|
39 |
+
// avoids the language being the queried object when querying multiple taxonomies
|
40 |
+
add_action( 'parse_tax_query', array( &$this, 'parse_tax_query' ), 1 );
|
41 |
|
42 |
// filters posts by language
|
43 |
+
add_action( 'parse_query', array( &$this, 'parse_query' ), 6 );
|
44 |
|
45 |
+
// not before 'check_canonical_url'
|
46 |
+
if ( ! defined( 'PLL_AUTO_TRANSLATE' ) || PLL_AUTO_TRANSLATE ) {
|
47 |
+
add_action( 'template_redirect', array( &$this, 'auto_translate' ), 7 );
|
48 |
+
}
|
49 |
}
|
50 |
|
51 |
/*
|
54 |
* @since 1.2
|
55 |
*/
|
56 |
public function init() {
|
57 |
+
$this->links = new PLL_Frontend_Links( $this );
|
58 |
+
$this->static_pages = new PLL_Frontend_Static_Pages( $this );
|
59 |
|
60 |
+
// setup the language chooser
|
61 |
+
$c = array( 'Content', 'Url', 'Url', 'Domain' );
|
62 |
+
$class = 'PLL_Choose_Lang_' . $c[ $this->options['force_lang'] ];
|
63 |
+
$this->choose_lang = new $class( $this );
|
64 |
+
$this->choose_lang->init();
|
65 |
|
66 |
// need to load nav menu class early to correctly define the locations in the customizer when the language is set from the content
|
67 |
+
$this->nav_menu = new PLL_Frontend_Nav_Menu( $this );
|
68 |
}
|
69 |
|
70 |
/*
|
74 |
*/
|
75 |
public function pll_language_defined() {
|
76 |
// filters
|
77 |
+
$this->filters_links = new PLL_Frontend_Filters_Links( $this );
|
78 |
+
$this->filters = new PLL_Frontend_Filters( $this );
|
79 |
+
$this->filters_search = new PLL_Frontend_Filters_Search( $this );
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/*
|
84 |
+
* when querying multiple taxonomies, makes sure that the language is not the queried object
|
85 |
+
*
|
86 |
+
* @since 1.8
|
87 |
+
*
|
88 |
+
* @param object $query WP_Query object
|
89 |
+
*/
|
90 |
+
public function parse_tax_query( $query ) {
|
91 |
+
$queried_taxonomies = $this->get_queried_taxonomies( $query );
|
92 |
+
|
93 |
+
if ( ! empty( $queried_taxonomies ) && 'language' == reset( $queried_taxonomies ) ) {
|
94 |
+
$query->tax_query->queried_terms['language'] = array_shift( $query->tax_query->queried_terms );
|
95 |
+
}
|
96 |
}
|
97 |
|
98 |
/*
|
102 |
*
|
103 |
* @param object $query WP_Query object
|
104 |
*/
|
105 |
+
public function parse_query( $query ) {
|
106 |
$qv = $query->query_vars;
|
107 |
|
108 |
+
// to avoid returning an empty result if the query includes either a translated taxonomy in a different language or a non-translated taxonomy
|
109 |
+
$has_tax = isset( $query->tax_query->queries ) && $this->have_unfiltered_taxonomy( $query->tax_query->queries );
|
110 |
|
111 |
// allow filtering recent posts and secondary queries by the current language
|
112 |
// take care not to break queries for non visible post types such as nav_menu_items
|
113 |
// do not filter if lang is set to an empty value
|
114 |
// do not filter single page and translated taxonomies to avoid conflicts
|
115 |
+
if ( ! empty( $this->curlang ) && ! isset( $qv['lang'] ) && ! $has_tax && empty( $qv['page_id'] ) && empty( $qv['pagename'] ) && ( empty( $qv['post_type'] ) || $this->model->is_translated_post_type( $qv['post_type'] ) ) ) {
|
116 |
+
$this->choose_lang->set_lang_query_var( $query, $this->curlang );
|
117 |
}
|
118 |
|
119 |
// modifies query vars when the language is queried
|
120 |
+
if ( ! empty( $qv['lang'] ) ) {
|
121 |
+
// do we query a custom taxonomy?
|
122 |
+
$taxonomies = array_diff( $this->get_queried_taxonomies( $query ) , array( 'language', 'category', 'post_tag' ) );
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
// remove pages query when the language is set unless we do a search
|
125 |
// take care not to break the single page, attachment and taxonomies queries!
|
126 |
+
if ( empty( $qv['post_type'] ) && ! $query->is_search && ! $query->is_page && ! $query->is_attachment && empty( $taxonomies ) ) {
|
127 |
$query->set( 'post_type', 'post' );
|
128 |
}
|
129 |
|
130 |
// unset the is_archive flag for language pages to prevent loading the archive template
|
131 |
// keep archive flag for comment feed otherwise the language filter does not work
|
132 |
+
if ( empty( $taxonomies ) && ! $query->is_comment_feed && ! $query->is_post_type_archive && ! $query->is_date && ! $query->is_author && ! $query->is_category && ! $query->is_tag ) {
|
133 |
$query->is_archive = false;
|
134 |
+
}
|
135 |
|
136 |
// unset the is_tax flag except if another custom tax is queried
|
137 |
+
if ( empty( $taxonomies ) && ($query->is_category || $query->is_tag || $query->is_author || $query->is_post_type_archive || $query->is_date || $query->is_search || $query->is_feed ) ) {
|
|
|
138 |
$query->is_tax = false;
|
139 |
+
unset( $query->queried_object ); // FIXME useless?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
}
|
142 |
}
|
147 |
* @since 1.2
|
148 |
*/
|
149 |
public function auto_translate() {
|
150 |
+
$this->auto_translate = new PLL_Frontend_Auto_Translate( $this );
|
151 |
}
|
152 |
|
153 |
/*
|
156 |
*
|
157 |
* @since 1.5.1
|
158 |
*/
|
159 |
+
public function switch_blog( $new_blog, $old_blog ) {
|
160 |
// need to check that some languages are defined when user is logged in, has several blogs, some without any languages
|
161 |
+
if ( parent::switch_blog( $new_blog, $old_blog ) && did_action( 'pll_language_defined' ) && $this->model->get_languages_list() ) {
|
162 |
static $restore_curlang;
|
163 |
+
if ( empty( $restore_curlang ) ) {
|
164 |
$restore_curlang = $this->curlang->slug; // to always remember the current language through blogs
|
165 |
+
}
|
166 |
|
167 |
+
$lang = $this->model->get_language( $restore_curlang );
|
168 |
+
$this->curlang = $lang ? $lang : $this->model->get_language( $this->options['default_lang'] );
|
169 |
+
$this->static_pages->init();
|
170 |
$this->load_strings_translations();
|
171 |
}
|
172 |
}
|
181 |
* @param array $tax_queries
|
182 |
* @return bool
|
183 |
*/
|
184 |
+
protected function have_unfiltered_taxonomy( $tax_queries ) {
|
185 |
+
foreach ( $tax_queries as $tax_query ) {
|
186 |
+
if ( isset( $tax_query['taxonomy'] ) && ! $this->model->is_filtered_taxonomy( $tax_query['taxonomy'] ) && ! ( isset( $tax_query['operator'] ) && 'NOT IN' === $tax_query['operator'] ) ) {
|
187 |
return true;
|
188 |
+
}
|
189 |
|
190 |
// nested queries
|
191 |
+
elseif ( is_array( $tax_query ) && $this->have_unfiltered_taxonomy( $tax_query ) ) {
|
192 |
return true;
|
193 |
+
}
|
194 |
}
|
195 |
|
196 |
return false;
|
197 |
}
|
|
|
198 |
|
199 |
+
/*
|
200 |
+
* get queried taxonomies
|
201 |
+
*
|
202 |
+
* @since 1.8
|
203 |
+
*
|
204 |
+
* @param object $query WP_Query object
|
205 |
+
* @return array queried taxonomies
|
206 |
+
*/
|
207 |
+
protected function get_queried_taxonomies( $query ) {
|
208 |
+
return isset( $query->tax_query->queried_terms ) ? array_keys( wp_list_filter( $query->tax_query->queried_terms, array( 'operator' => 'NOT IN' ), 'NOT' ) ) : array();
|
209 |
+
}
|
210 |
+
}
|
include/api.php
CHANGED
@@ -6,11 +6,11 @@
|
|
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)
|
10 |
-
* hide_if_empty => hides languages with no posts (or pages) if set to 1 (default)
|
11 |
* show_flags => shows flags if set to 1, defaults to 0
|
12 |
-
* show_names => shows languages names if set to 1 (default)
|
13 |
-
* display_names_as =>
|
14 |
* force_home => forces linking to the home page is set to 1, defaults to 0
|
15 |
* hide_if_no_translation => hides the link if there is no translation if set to 1, defaults to 0
|
16 |
* hide_current => hides the current language if set to 1, defaults to 0
|
@@ -22,13 +22,13 @@
|
|
22 |
* @param array $args optional
|
23 |
* @return null|string|array null if displaying, array if raw is requested, string otherwise
|
24 |
*/
|
25 |
-
function pll_the_languages($args = '') {
|
26 |
-
|
27 |
-
|
28 |
-
$switcher = new PLL_Switcher;
|
29 |
-
return $switcher->the_languages($polylang->links, $args);
|
30 |
}
|
31 |
-
|
|
|
|
|
32 |
}
|
33 |
|
34 |
/*
|
@@ -39,9 +39,8 @@ function pll_the_languages($args = '') {
|
|
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 |
-
|
44 |
-
return isset($polylang->curlang->$field) ? $polylang->curlang->$field : false;
|
45 |
}
|
46 |
|
47 |
/*
|
@@ -52,9 +51,8 @@ function pll_current_language($field = 'slug') {
|
|
52 |
* @param string $field optional the language field to return 'name', 'locale', defaults to 'slug'
|
53 |
* @return string the requested field for the default language
|
54 |
*/
|
55 |
-
function pll_default_language($field = 'slug') {
|
56 |
-
|
57 |
-
return isset($polylang->options['default_lang']) && ($lang = $polylang->model->get_language($polylang->options['default_lang'])) && isset($lang->$field) ? $lang->$field : false;
|
58 |
}
|
59 |
|
60 |
/*
|
@@ -66,9 +64,8 @@ function pll_default_language($field = 'slug') {
|
|
66 |
* @param string $slug optional language code, defaults to current language
|
67 |
* @return int post id of the translation if exists
|
68 |
*/
|
69 |
-
function pll_get_post($post_id, $slug = '') {
|
70 |
-
|
71 |
-
return isset($polylang) && ($slug = $slug ? $slug : pll_current_language()) ? $polylang->model->get_post($post_id, $slug) : null;
|
72 |
}
|
73 |
|
74 |
/*
|
@@ -80,9 +77,8 @@ function pll_get_post($post_id, $slug = '') {
|
|
80 |
* @param string $slug optional language code, defaults to current language
|
81 |
* @return int term id of the translation if exists
|
82 |
*/
|
83 |
-
function pll_get_term($term_id, $slug = '') {
|
84 |
-
|
85 |
-
return isset($polylang) && ($slug = $slug ? $slug : pll_current_language()) ? $polylang->model->get_term($term_id, $slug) : null;
|
86 |
}
|
87 |
|
88 |
/*
|
@@ -90,16 +86,15 @@ function pll_get_term($term_id, $slug = '') {
|
|
90 |
*
|
91 |
* @since 0.8
|
92 |
*
|
93 |
-
* @param string $lang language code (optional on frontend)
|
94 |
* @return string
|
95 |
*/
|
96 |
-
function pll_home_url($lang = '') {
|
97 |
-
|
98 |
-
|
99 |
-
if (empty($lang))
|
100 |
$lang = pll_current_language();
|
|
|
101 |
|
102 |
-
return
|
103 |
}
|
104 |
|
105 |
/*
|
@@ -112,50 +107,52 @@ function pll_home_url($lang = '') {
|
|
112 |
* @param string $context optional the group in which the string is registered, defaults to 'polylang'
|
113 |
* @param bool $multiline optional wether the string table should display a multiline textarea or a single line input, defaults to single line
|
114 |
*/
|
115 |
-
function pll_register_string($name, $string, $context = 'polylang', $multiline = false) {
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
}
|
120 |
|
121 |
/*
|
122 |
-
* translates a string (previously registered with pll_register_string)
|
123 |
*
|
124 |
* @since 0.6
|
125 |
*
|
126 |
* @param string $string the string to translate
|
127 |
* @return string the string translation in the current language
|
128 |
*/
|
129 |
-
function pll__($string) {
|
130 |
static $cache; // cache object to avoid translating the same string several times
|
131 |
|
132 |
-
if (!did_action('pll_language_defined')) // no need for translation
|
133 |
return $string;
|
134 |
-
|
135 |
-
|
|
|
136 |
$cache = new PLL_Cache();
|
|
|
137 |
|
138 |
-
if (false === $str = $cache->get($string)) {
|
139 |
-
$str = __($string, 'pll_string');
|
140 |
-
$cache->set($string, $str);
|
141 |
}
|
142 |
|
143 |
return $str;
|
144 |
}
|
145 |
|
146 |
/*
|
147 |
-
* echoes a translated string (previously registered with pll_register_string)
|
148 |
*
|
149 |
* @since 0.6
|
150 |
*
|
151 |
* @param string $string the string to translate
|
152 |
*/
|
153 |
-
function pll_e($string) {
|
154 |
-
echo pll__($string
|
155 |
}
|
156 |
|
157 |
/*
|
158 |
-
* translates a string (previously registered with pll_register_string)
|
159 |
*
|
160 |
* @since 1.5.4
|
161 |
*
|
@@ -163,22 +160,24 @@ function pll_e($string) {
|
|
163 |
* @param string $lang language code
|
164 |
* @return string the string translation in the requested language
|
165 |
*/
|
166 |
-
function pll_translate_string($string, $lang) {
|
167 |
-
if (pll_current_language() == $lang)
|
168 |
-
return pll__($string);
|
|
|
169 |
|
170 |
static $cache; // cache object to avoid loading the same translations object several times
|
171 |
|
172 |
-
if (empty($cache))
|
173 |
$cache = new PLL_Cache();
|
|
|
174 |
|
175 |
-
if (false === $mo = $cache->get($lang)) {
|
176 |
$mo = new PLL_MO();
|
177 |
-
$mo->import_from_db(
|
178 |
-
$cache->set($lang, $mo);
|
179 |
}
|
180 |
|
181 |
-
return $mo->translate($string);
|
182 |
}
|
183 |
|
184 |
/*
|
@@ -189,9 +188,8 @@ function pll_translate_string($string, $lang) {
|
|
189 |
* @param string post type name
|
190 |
* @return bool
|
191 |
*/
|
192 |
-
function pll_is_translated_post_type($post_type) {
|
193 |
-
|
194 |
-
return isset($polylang) && $polylang->model->is_translated_post_type($post_type);
|
195 |
}
|
196 |
|
197 |
/*
|
@@ -202,9 +200,8 @@ function pll_is_translated_post_type($post_type) {
|
|
202 |
* @param string taxonomy name
|
203 |
* @return bool
|
204 |
*/
|
205 |
-
function pll_is_translated_taxonomy($tax) {
|
206 |
-
|
207 |
-
return isset($polylang) && $polylang->model->is_translated_taxonomy($tax);
|
208 |
}
|
209 |
|
210 |
/*
|
@@ -212,18 +209,17 @@ function pll_is_translated_taxonomy($tax) {
|
|
212 |
*
|
213 |
* list of parameters accepted in $args:
|
214 |
*
|
215 |
-
* hide_empty => hides languages with no posts if set to true (defaults to false)
|
216 |
-
* fields => return only that field if set (see PLL_Language for a list of fields)
|
217 |
*
|
218 |
* @since 1.5
|
219 |
*
|
220 |
* @param array $args list of parameters
|
221 |
* @return array
|
222 |
*/
|
223 |
-
function pll_languages_list($args = array()) {
|
224 |
-
|
225 |
-
|
226 |
-
return isset($polylang) ? $polylang->model->get_languages_list($args) : false;
|
227 |
}
|
228 |
|
229 |
/*
|
@@ -234,10 +230,8 @@ function pll_languages_list($args = array()) {
|
|
234 |
* @param int $post_id post id
|
235 |
* @param string $lang language code
|
236 |
*/
|
237 |
-
function pll_set_post_language($id, $lang) {
|
238 |
-
|
239 |
-
if (isset($polylang))
|
240 |
-
$polylang->model->set_post_language($id, $lang);
|
241 |
}
|
242 |
|
243 |
/*
|
@@ -248,10 +242,8 @@ function pll_set_post_language($id, $lang) {
|
|
248 |
* @param int $id term id
|
249 |
* @param string $lang language code
|
250 |
*/
|
251 |
-
function pll_set_term_language($id, $lang) {
|
252 |
-
|
253 |
-
if (isset($polylang))
|
254 |
-
$polylang->model->set_term_language($id, $lang);
|
255 |
}
|
256 |
|
257 |
/*
|
@@ -261,10 +253,8 @@ function pll_set_term_language($id, $lang) {
|
|
261 |
*
|
262 |
* @param array $arr an associative array of translations with language code as key and post id as value
|
263 |
*/
|
264 |
-
function pll_save_post_translations($arr) {
|
265 |
-
|
266 |
-
if (isset($polylang))
|
267 |
-
$polylang->model->save_translations('post', reset($arr), $arr);
|
268 |
}
|
269 |
|
270 |
/*
|
@@ -274,10 +264,8 @@ function pll_save_post_translations($arr) {
|
|
274 |
*
|
275 |
* @param array $arr an associative array of translations with language code as key and term id as value
|
276 |
*/
|
277 |
-
function pll_save_term_translations($arr) {
|
278 |
-
|
279 |
-
if (isset($polylang))
|
280 |
-
$polylang->model->save_translations('term', reset($arr), $arr);
|
281 |
}
|
282 |
|
283 |
/*
|
@@ -289,9 +277,8 @@ function pll_save_term_translations($arr) {
|
|
289 |
* @param string $field optional the language field to return 'name', 'locale', defaults to 'slug'
|
290 |
* @return bool|string the requested field for the post language, false if no language is associated to that post
|
291 |
*/
|
292 |
-
function pll_get_post_language($post_id, $field = 'slug') {
|
293 |
-
|
294 |
-
return isset($polylang) && ($lang = $polylang->model->get_post_language($post_id)) ? $lang->$field : false;
|
295 |
}
|
296 |
|
297 |
/*
|
@@ -303,9 +290,32 @@ function pll_get_post_language($post_id, $field = 'slug') {
|
|
303 |
* @param string $field optional the language field to return 'name', 'locale', defaults to 'slug'
|
304 |
* @return bool|string the requested field for the term language, false if no language is associated to that term
|
305 |
*/
|
306 |
-
function pll_get_term_language($term_id, $field = 'slug') {
|
307 |
-
|
308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
}
|
310 |
|
311 |
/*
|
@@ -314,10 +324,20 @@ function pll_get_term_language($term_id, $field = 'slug') {
|
|
314 |
* @since 1.5
|
315 |
*
|
316 |
* @param string $lang language code
|
317 |
-
* @param array $args (accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format)
|
318 |
* @return int posts count
|
319 |
*/
|
320 |
-
function pll_count_posts($lang, $args = array()) {
|
321 |
-
|
322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
}
|
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 )
|
10 |
+
* hide_if_empty => hides languages with no posts ( or pages ) if set to 1 ( default )
|
11 |
* show_flags => shows flags if set to 1, defaults to 0
|
12 |
+
* show_names => shows languages names if set to 1 ( default )
|
13 |
+
* display_names_as => whether to display the language name or code. valid options are 'slug' and 'name'
|
14 |
* force_home => forces linking to the home page is set to 1, defaults to 0
|
15 |
* hide_if_no_translation => hides the link if there is no translation if set to 1, defaults to 0
|
16 |
* hide_current => hides the current language if set to 1, defaults to 0
|
22 |
* @param array $args optional
|
23 |
* @return null|string|array null if displaying, array if raw is requested, string otherwise
|
24 |
*/
|
25 |
+
function pll_the_languages( $args = '' ) {
|
26 |
+
if ( PLL_ADMIN ) {
|
27 |
+
return '';
|
|
|
|
|
28 |
}
|
29 |
+
|
30 |
+
$switcher = new PLL_Switcher;
|
31 |
+
return $switcher->the_languages( PLL()->links, $args );
|
32 |
}
|
33 |
|
34 |
/*
|
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 |
/*
|
51 |
* @param string $field optional the language field to return 'name', 'locale', defaults to 'slug'
|
52 |
* @return string the requested field for the default language
|
53 |
*/
|
54 |
+
function pll_default_language( $field = 'slug' ) {
|
55 |
+
return ( $lang = PLL()->model->get_language( PLL()->options['default_lang'] ) ) && isset( $lang->$field ) ? $lang->$field : false;
|
|
|
56 |
}
|
57 |
|
58 |
/*
|
64 |
* @param string $slug optional language code, defaults to current language
|
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 |
/*
|
77 |
* @param string $slug optional language code, defaults to current language
|
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 |
/*
|
86 |
*
|
87 |
* @since 0.8
|
88 |
*
|
89 |
+
* @param string $lang language code ( optional on frontend )
|
90 |
* @return string
|
91 |
*/
|
92 |
+
function pll_home_url( $lang = '' ) {
|
93 |
+
if ( empty( $lang ) ) {
|
|
|
|
|
94 |
$lang = pll_current_language();
|
95 |
+
}
|
96 |
|
97 |
+
return empty( $lang ) ? home_url( '/' ) : PLL()->links->get_home_url( $lang );
|
98 |
}
|
99 |
|
100 |
/*
|
107 |
* @param string $context optional the group in which the string is registered, defaults to 'polylang'
|
108 |
* @param bool $multiline optional wether the string table should display a multiline textarea or a single line input, defaults to single line
|
109 |
*/
|
110 |
+
function pll_register_string( $name, $string, $context = 'polylang', $multiline = false ) {
|
111 |
+
if ( PLL_ADMIN ) {
|
112 |
+
PLL_Admin_Strings::register_string( $name, $string, $context, $multiline );
|
113 |
+
}
|
114 |
}
|
115 |
|
116 |
/*
|
117 |
+
* translates a string ( previously registered with pll_register_string )
|
118 |
*
|
119 |
* @since 0.6
|
120 |
*
|
121 |
* @param string $string the string to translate
|
122 |
* @return string the string translation in the current language
|
123 |
*/
|
124 |
+
function pll__( $string ) {
|
125 |
static $cache; // cache object to avoid translating the same string several times
|
126 |
|
127 |
+
if ( ! did_action( 'pll_language_defined' ) ) { // no need for translation
|
128 |
return $string;
|
129 |
+
}
|
130 |
+
|
131 |
+
if ( empty( $cache ) ) {
|
132 |
$cache = new PLL_Cache();
|
133 |
+
}
|
134 |
|
135 |
+
if ( false === $str = $cache->get( $string ) ) {
|
136 |
+
$str = __( $string, 'pll_string' );
|
137 |
+
$cache->set( $string, $str );
|
138 |
}
|
139 |
|
140 |
return $str;
|
141 |
}
|
142 |
|
143 |
/*
|
144 |
+
* echoes a translated string ( previously registered with pll_register_string )
|
145 |
*
|
146 |
* @since 0.6
|
147 |
*
|
148 |
* @param string $string the string to translate
|
149 |
*/
|
150 |
+
function pll_e( $string ) {
|
151 |
+
echo pll__( $string );
|
152 |
}
|
153 |
|
154 |
/*
|
155 |
+
* translates a string ( previously registered with pll_register_string )
|
156 |
*
|
157 |
* @since 1.5.4
|
158 |
*
|
160 |
* @param string $lang language code
|
161 |
* @return string the string translation in the requested language
|
162 |
*/
|
163 |
+
function pll_translate_string( $string, $lang ) {
|
164 |
+
if ( pll_current_language() == $lang ) {
|
165 |
+
return pll__( $string );
|
166 |
+
}
|
167 |
|
168 |
static $cache; // cache object to avoid loading the same translations object several times
|
169 |
|
170 |
+
if ( empty( $cache ) ) {
|
171 |
$cache = new PLL_Cache();
|
172 |
+
}
|
173 |
|
174 |
+
if ( false === $mo = $cache->get( $lang ) ) {
|
175 |
$mo = new PLL_MO();
|
176 |
+
$mo->import_from_db( PLL()->model->get_language( $lang ) );
|
177 |
+
$cache->set( $lang, $mo );
|
178 |
}
|
179 |
|
180 |
+
return $mo->translate( $string );
|
181 |
}
|
182 |
|
183 |
/*
|
188 |
* @param string post type name
|
189 |
* @return bool
|
190 |
*/
|
191 |
+
function pll_is_translated_post_type( $post_type ) {
|
192 |
+
return PLL()->model->is_translated_post_type( $post_type );
|
|
|
193 |
}
|
194 |
|
195 |
/*
|
200 |
* @param string taxonomy name
|
201 |
* @return bool
|
202 |
*/
|
203 |
+
function pll_is_translated_taxonomy( $tax ) {
|
204 |
+
return PLL()->model->is_translated_taxonomy( $tax );
|
|
|
205 |
}
|
206 |
|
207 |
/*
|
209 |
*
|
210 |
* list of parameters accepted in $args:
|
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 )
|
214 |
*
|
215 |
* @since 1.5
|
216 |
*
|
217 |
* @param array $args list of parameters
|
218 |
* @return array
|
219 |
*/
|
220 |
+
function pll_languages_list( $args = array() ) {
|
221 |
+
$args = wp_parse_args( $args, array( 'fields' => 'slug' ) );
|
222 |
+
return PLL()->model->get_languages_list( $args );
|
|
|
223 |
}
|
224 |
|
225 |
/*
|
230 |
* @param int $post_id post id
|
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 |
/*
|
242 |
* @param int $id term id
|
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 |
/*
|
253 |
*
|
254 |
* @param array $arr an associative array of translations with language code as key and post id as value
|
255 |
*/
|
256 |
+
function pll_save_post_translations( $arr ) {
|
257 |
+
PLL()->model->post->save_translations( reset( $arr ), $arr );
|
|
|
|
|
258 |
}
|
259 |
|
260 |
/*
|
264 |
*
|
265 |
* @param array $arr an associative array of translations with language code as key and term id as value
|
266 |
*/
|
267 |
+
function pll_save_term_translations( $arr ) {
|
268 |
+
PLL()->model->term->save_translations( reset( $arr ), $arr );
|
|
|
|
|
269 |
}
|
270 |
|
271 |
/*
|
277 |
* @param string $field optional the language field to return 'name', 'locale', defaults to 'slug'
|
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 |
/*
|
290 |
* @param string $field optional the language field to return 'name', 'locale', defaults to 'slug'
|
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 |
+
* returns an array of translations of a post
|
299 |
+
*
|
300 |
+
* @since 1.8
|
301 |
+
*
|
302 |
+
* @param int $post_id
|
303 |
+
* @return array an associative array of translations with language code as key and translation post_id as value
|
304 |
+
*/
|
305 |
+
function pll_get_post_translations( $post_id ) {
|
306 |
+
return PLL()->model->post->get_translations( $post_id );
|
307 |
+
}
|
308 |
+
|
309 |
+
/*
|
310 |
+
* returns an array of translations of a term
|
311 |
+
*
|
312 |
+
* @since 1.8
|
313 |
+
*
|
314 |
+
* @param int $term_id
|
315 |
+
* @return array an associative array of translations with language code as key and translation term_id as value
|
316 |
+
*/
|
317 |
+
function pll_get_term_translations( $term_id ) {
|
318 |
+
return PLL()->model->term->get_translations( $term_id );
|
319 |
}
|
320 |
|
321 |
/*
|
324 |
* @since 1.5
|
325 |
*
|
326 |
* @param string $lang language code
|
327 |
+
* @param array $args ( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format )
|
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 |
+
* allows to access the Polylang instance
|
336 |
+
* it is always preferable to use API functions
|
337 |
+
* internal methods may be changed without prior notice
|
338 |
+
*
|
339 |
+
* @since 1.8
|
340 |
+
*/
|
341 |
+
function PLL() {
|
342 |
+
return $GLOBALS['polylang'];
|
343 |
}
|
include/base.php
CHANGED
@@ -15,18 +15,18 @@ abstract class PLL_Base {
|
|
15 |
*
|
16 |
* @param object $links_model
|
17 |
*/
|
18 |
-
public function __construct(&$links_model) {
|
19 |
$this->links_model = &$links_model;
|
20 |
$this->model = &$links_model->model;
|
21 |
$this->options = &$this->model->options;
|
22 |
|
23 |
-
add_action('widgets_init', array(&$this, 'widgets_init'));
|
24 |
|
25 |
// user defined strings translations
|
26 |
-
add_action('pll_language_defined', array(&$this, 'load_strings_translations'), 5);
|
27 |
|
28 |
// switch_to_blog
|
29 |
-
add_action('switch_blog', array(&$this, 'switch_blog'), 10, 2);
|
30 |
}
|
31 |
|
32 |
/*
|
@@ -35,25 +35,26 @@ abstract class PLL_Base {
|
|
35 |
* @since 0.1
|
36 |
*/
|
37 |
public function widgets_init() {
|
38 |
-
register_widget('PLL_Widget_Languages');
|
39 |
|
40 |
// overwrites the calendar widget to filter posts by language
|
41 |
-
if (!defined('PLL_WIDGET_CALENDAR') || PLL_WIDGET_CALENDAR) {
|
42 |
-
unregister_widget('WP_Widget_Calendar');
|
43 |
-
register_widget('PLL_Widget_Calendar');
|
44 |
}
|
45 |
|
|
|
46 |
// overwrites the recent posts and recent comments widget to use a language dependant cache key
|
47 |
// useful only if using a cache plugin
|
48 |
-
if (defined('WP_CACHE') && WP_CACHE) {
|
49 |
-
if (!defined('PLL_WIDGET_RECENT_POSTS') || PLL_WIDGET_RECENT_POSTS) {
|
50 |
-
unregister_widget('WP_Widget_Recent_Posts');
|
51 |
-
register_widget('PLL_Widget_Recent_Posts');
|
52 |
}
|
53 |
|
54 |
-
if (!defined('PLL_WIDGET_RECENT_COMMENTS') || PLL_WIDGET_RECENT_COMMENTS) {
|
55 |
-
unregister_widget('WP_Widget_Recent_Comments');
|
56 |
-
register_widget('PLL_Widget_Recent_Comments');
|
57 |
}
|
58 |
}
|
59 |
}
|
@@ -65,7 +66,7 @@ abstract class PLL_Base {
|
|
65 |
*/
|
66 |
public function load_strings_translations() {
|
67 |
$mo = new PLL_MO();
|
68 |
-
$mo->import_from_db($this->model->get_language(get_locale()));
|
69 |
$GLOBALS['l10n']['pll_string'] = &$mo;
|
70 |
}
|
71 |
|
@@ -77,14 +78,14 @@ abstract class PLL_Base {
|
|
77 |
*
|
78 |
* @return bool not used by WP but by child class
|
79 |
*/
|
80 |
-
public function switch_blog($new_blog, $old_blog) {
|
81 |
-
$plugins = ($sitewide_plugins = get_site_option('active_sitewide_plugins')) && is_array($sitewide_plugins) ? array_keys($sitewide_plugins) : array();
|
82 |
-
$plugins = array_merge($plugins, get_option('active_plugins', array()));
|
83 |
|
84 |
// 2nd test needed when Polylang is not networked activated
|
85 |
// 3rd test needed when Polylang is networked activated and a new site is created
|
86 |
-
if ($new_blog != $old_blog && in_array(POLYLANG_BASENAME, $plugins) && get_option('polylang')) {
|
87 |
-
$this->options = get_option('polylang'); // needed for menus
|
88 |
$this->links_model = $this->model->get_links_model();
|
89 |
return true;
|
90 |
}
|
@@ -101,20 +102,22 @@ abstract class PLL_Base {
|
|
101 |
* @param string $func function name
|
102 |
* @param array $args function arguments
|
103 |
*/
|
104 |
-
public function __call($func, $args) {
|
105 |
-
foreach ($this as $prop => &$obj)
|
106 |
-
if (is_object($obj) && method_exists($obj, $func)) {
|
107 |
-
if (WP_DEBUG) {
|
108 |
$debug = debug_backtrace();
|
109 |
-
|
110 |
-
|
111 |
-
$
|
112 |
-
|
|
|
113 |
}
|
114 |
-
return call_user_func_array(array($obj, $func), $args);
|
115 |
}
|
|
|
116 |
|
117 |
$debug = debug_backtrace();
|
118 |
-
trigger_error(sprintf('Call to undefined function
|
119 |
}
|
120 |
}
|
15 |
*
|
16 |
* @param object $links_model
|
17 |
*/
|
18 |
+
public function __construct( &$links_model ) {
|
19 |
$this->links_model = &$links_model;
|
20 |
$this->model = &$links_model->model;
|
21 |
$this->options = &$this->model->options;
|
22 |
|
23 |
+
add_action( 'widgets_init', array( &$this, 'widgets_init' ) );
|
24 |
|
25 |
// user defined strings translations
|
26 |
+
add_action( 'pll_language_defined', array( &$this, 'load_strings_translations' ), 5 );
|
27 |
|
28 |
// switch_to_blog
|
29 |
+
add_action( 'switch_blog', array( &$this, 'switch_blog' ), 10, 2 );
|
30 |
}
|
31 |
|
32 |
/*
|
35 |
* @since 0.1
|
36 |
*/
|
37 |
public function widgets_init() {
|
38 |
+
register_widget( 'PLL_Widget_Languages' );
|
39 |
|
40 |
// overwrites the calendar widget to filter posts by language
|
41 |
+
if ( ! defined( 'PLL_WIDGET_CALENDAR' ) || PLL_WIDGET_CALENDAR ) {
|
42 |
+
unregister_widget( 'WP_Widget_Calendar' );
|
43 |
+
register_widget( 'PLL_Widget_Calendar' );
|
44 |
}
|
45 |
|
46 |
+
// backward compatibility with WP < 4.4
|
47 |
// overwrites the recent posts and recent comments widget to use a language dependant cache key
|
48 |
// useful only if using a cache plugin
|
49 |
+
if ( version_compare( $GLOBALS['wp_version'], '4.4', '<' ) && defined( 'WP_CACHE' ) && WP_CACHE ) {
|
50 |
+
if ( ! defined( 'PLL_WIDGET_RECENT_POSTS' ) || PLL_WIDGET_RECENT_POSTS ) {
|
51 |
+
unregister_widget( 'WP_Widget_Recent_Posts' );
|
52 |
+
register_widget( 'PLL_Widget_Recent_Posts' );
|
53 |
}
|
54 |
|
55 |
+
if ( ! defined( 'PLL_WIDGET_RECENT_COMMENTS' ) || PLL_WIDGET_RECENT_COMMENTS ) {
|
56 |
+
unregister_widget( 'WP_Widget_Recent_Comments' );
|
57 |
+
register_widget( 'PLL_Widget_Recent_Comments' );
|
58 |
}
|
59 |
}
|
60 |
}
|
66 |
*/
|
67 |
public function load_strings_translations() {
|
68 |
$mo = new PLL_MO();
|
69 |
+
$mo->import_from_db( $this->model->get_language( get_locale() ) );
|
70 |
$GLOBALS['l10n']['pll_string'] = &$mo;
|
71 |
}
|
72 |
|
78 |
*
|
79 |
* @return bool not used by WP but by child class
|
80 |
*/
|
81 |
+
public function switch_blog( $new_blog, $old_blog ) {
|
82 |
+
$plugins = ( $sitewide_plugins = get_site_option( 'active_sitewide_plugins' ) ) && is_array( $sitewide_plugins ) ? array_keys( $sitewide_plugins ) : array();
|
83 |
+
$plugins = array_merge( $plugins, get_option( 'active_plugins', array() ) );
|
84 |
|
85 |
// 2nd test needed when Polylang is not networked activated
|
86 |
// 3rd test needed when Polylang is networked activated and a new site is created
|
87 |
+
if ( $new_blog != $old_blog && in_array( POLYLANG_BASENAME, $plugins ) && get_option( 'polylang' ) ) {
|
88 |
+
$this->options = get_option( 'polylang' ); // needed for menus
|
89 |
$this->links_model = $this->model->get_links_model();
|
90 |
return true;
|
91 |
}
|
102 |
* @param string $func function name
|
103 |
* @param array $args function arguments
|
104 |
*/
|
105 |
+
public function __call( $func, $args ) {
|
106 |
+
foreach ( $this as $prop => &$obj ) {
|
107 |
+
if ( is_object( $obj ) && method_exists( $obj, $func ) ) {
|
108 |
+
if ( WP_DEBUG ) {
|
109 |
$debug = debug_backtrace();
|
110 |
+
$i = 1 + empty( $debug[1]['line'] ); // the file and line are in $debug[2] if the function was called using call_user_func
|
111 |
+
trigger_error( sprintf(
|
112 |
+
'%1$s was called incorrectly in %3$s on line %4$s: the call to $polylang->%1$s() has been deprecated in Polylang 1.2, use PLL()->%2$s->%1$s() instead.' . "\nError handler",
|
113 |
+
$func, $prop, $debug[ $i ]['file'], $debug[ $i ]['line']
|
114 |
+
) );
|
115 |
}
|
116 |
+
return call_user_func_array( array( $obj, $func ), $args );
|
117 |
}
|
118 |
+
}
|
119 |
|
120 |
$debug = debug_backtrace();
|
121 |
+
trigger_error( sprintf( 'Call to undefined function PLL()->%1$s() in %2$s on line %3$s' . "\nError handler", $func, $debug[0]['file'], $debug[0]['line'] ), E_USER_ERROR );
|
122 |
}
|
123 |
}
|
include/cache.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
* an extremely simple non persistent cache system
|
4 |
* not as fast as using directly an array but more readable
|
@@ -15,7 +16,7 @@ class PLL_Cache {
|
|
15 |
*/
|
16 |
public function __construct() {
|
17 |
$this->blog_id = get_current_blog_id();
|
18 |
-
add_action('switch_blog', array(&$this, 'switch_blog'));
|
19 |
}
|
20 |
|
21 |
/*
|
@@ -25,7 +26,7 @@ class PLL_Cache {
|
|
25 |
*
|
26 |
* @param int $new_blog
|
27 |
*/
|
28 |
-
public function switch_blog($new_blog) {
|
29 |
$this->blog_id = $new_blog;
|
30 |
}
|
31 |
|
@@ -37,8 +38,8 @@ class PLL_Cache {
|
|
37 |
* @param string $key
|
38 |
* @param mixed $data
|
39 |
*/
|
40 |
-
public function set($key, $data) {
|
41 |
-
$this->cache[$this->blog_id][$key] = $data;
|
42 |
}
|
43 |
|
44 |
/*
|
@@ -49,8 +50,8 @@ class PLL_Cache {
|
|
49 |
* @param string $key
|
50 |
* @return mixed $data
|
51 |
*/
|
52 |
-
public function get($key) {
|
53 |
-
return isset($this->cache[$this->blog_id][$key]) ? $this->cache[$this->blog_id][$key] : false;
|
54 |
}
|
55 |
|
56 |
/*
|
@@ -58,8 +59,12 @@ class PLL_Cache {
|
|
58 |
*
|
59 |
* @since 1.7
|
60 |
*/
|
61 |
-
public function clean() {
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
-
|
65 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
* an extremely simple non persistent cache system
|
5 |
* not as fast as using directly an array but more readable
|
16 |
*/
|
17 |
public function __construct() {
|
18 |
$this->blog_id = get_current_blog_id();
|
19 |
+
add_action( 'switch_blog', array( &$this, 'switch_blog' ) );
|
20 |
}
|
21 |
|
22 |
/*
|
26 |
*
|
27 |
* @param int $new_blog
|
28 |
*/
|
29 |
+
public function switch_blog( $new_blog ) {
|
30 |
$this->blog_id = $new_blog;
|
31 |
}
|
32 |
|
38 |
* @param string $key
|
39 |
* @param mixed $data
|
40 |
*/
|
41 |
+
public function set( $key, $data ) {
|
42 |
+
$this->cache[ $this->blog_id ][ $key ] = $data;
|
43 |
}
|
44 |
|
45 |
/*
|
50 |
* @param string $key
|
51 |
* @return mixed $data
|
52 |
*/
|
53 |
+
public function get( $key ) {
|
54 |
+
return isset( $this->cache[ $this->blog_id ][ $key ] ) ? $this->cache[ $this->blog_id ][ $key ] : false;
|
55 |
}
|
56 |
|
57 |
/*
|
59 |
*
|
60 |
* @since 1.7
|
61 |
*/
|
62 |
+
public function clean( $key = '' ) {
|
63 |
+
if ( empty( $key ) ) {
|
64 |
+
unset( $this->cache[ $this->blog_id ] );
|
65 |
+
}
|
66 |
+
else {
|
67 |
+
unset( $this->cache[ $this->blog_id ][ $key ] );
|
68 |
+
}
|
69 |
}
|
|
|
70 |
}
|
include/class-polylang.php
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // don't access directly
|
5 |
+
};
|
6 |
+
|
7 |
+
// default directory to store user data such as custom flags
|
8 |
+
if ( ! defined( 'PLL_LOCAL_DIR' ) ) {
|
9 |
+
define( 'PLL_LOCAL_DIR', WP_CONTENT_DIR . '/polylang' );
|
10 |
+
}
|
11 |
+
|
12 |
+
// includes local config file if exists
|
13 |
+
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
|
28 |
+
*/
|
29 |
+
public function __construct() {
|
30 |
+
// FIXME maybe not available on every installations but widely used by WP plugins
|
31 |
+
spl_autoload_register( array( &$this, 'autoload' ) ); // autoload classes
|
32 |
+
|
33 |
+
$install = new PLL_Install( POLYLANG_BASENAME );
|
34 |
+
|
35 |
+
// stopping here if we are going to deactivate the plugin ( avoids breaking rewrite rules )
|
36 |
+
if ( $install->is_deactivation() ) {
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
// plugin initialization
|
41 |
+
// take no action before all plugins are loaded
|
42 |
+
add_action( 'plugins_loaded', array( &$this, 'init' ), 1 );
|
43 |
+
|
44 |
+
// override load text domain waiting for the language to be defined
|
45 |
+
// here for plugins which load text domain as soon as loaded :(
|
46 |
+
if ( ! defined( 'PLL_OLT' ) || PLL_OLT ) {
|
47 |
+
PLL_OLT_Manager::instance();
|
48 |
+
}
|
49 |
+
|
50 |
+
// extra code for compatibility with some plugins
|
51 |
+
// loaded as soon as possible as we may need to act before other plugins are loaded
|
52 |
+
if ( ! defined( 'PLL_PLUGINS_COMPAT' ) || PLL_PLUGINS_COMPAT ) {
|
53 |
+
PLL_Plugins_Compat::instance();
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
/*
|
58 |
+
* autoload classes
|
59 |
+
*
|
60 |
+
* @since 1.2
|
61 |
+
*
|
62 |
+
* @param string $class
|
63 |
+
*/
|
64 |
+
public function autoload( $class ) {
|
65 |
+
// not a Polylang class
|
66 |
+
if ( 0 !== strncmp( 'PLL_', $class, 4 ) ) {
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
|
70 |
+
$class = str_replace( '_', '-', strtolower( substr( $class, 4 ) ) );
|
71 |
+
$to_remove = array( 'post-', 'term-', 'settings-', 'admin-', 'frontend-', '-config', '-compat', '-model', 'advanced-' );
|
72 |
+
$dir = str_replace( $to_remove, array(), $class );
|
73 |
+
|
74 |
+
$dirs = array(
|
75 |
+
PLL_FRONT_INC,
|
76 |
+
PLL_MODULES_INC,
|
77 |
+
PLL_MODULES_INC . "/$dir",
|
78 |
+
PLL_MODULES_INC . '/plugins',
|
79 |
+
PLL_INSTALL_INC,
|
80 |
+
PLL_ADMIN_INC,
|
81 |
+
PLL_SETTINGS_INC,
|
82 |
+
PLL_INC,
|
83 |
+
);
|
84 |
+
|
85 |
+
foreach ( $dirs as $dir ) {
|
86 |
+
if ( file_exists( $file = "$dir/$class.php" ) ) {
|
87 |
+
require_once( $file );
|
88 |
+
return;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
/*
|
94 |
+
* defines constants
|
95 |
+
* may be overriden by a plugin if set before plugins_loaded, 1
|
96 |
+
*
|
97 |
+
* @since 1.6
|
98 |
+
*/
|
99 |
+
static public function define_constants() {
|
100 |
+
// our url. Don't use WP_PLUGIN_URL http://wordpress.org/support/topic/ssl-doesnt-work-properly
|
101 |
+
if ( ! defined( 'POLYLANG_URL' ) ) {
|
102 |
+
define( 'POLYLANG_URL', plugins_url( '', POLYLANG_FILE ) );
|
103 |
+
}
|
104 |
+
|
105 |
+
// default url to access user data such as custom flags
|
106 |
+
if ( ! defined( 'PLL_LOCAL_URL' ) ) {
|
107 |
+
define( 'PLL_LOCAL_URL', content_url( '/polylang' ) );
|
108 |
+
}
|
109 |
+
|
110 |
+
// cookie name. no cookie will be used if set to false
|
111 |
+
if ( ! defined( 'PLL_COOKIE' ) ) {
|
112 |
+
define( 'PLL_COOKIE', 'pll_language' );
|
113 |
+
}
|
114 |
+
|
115 |
+
// avoid loading polylang admin for frontend ajax requests
|
116 |
+
// special test for plupload which does not use jquery ajax and thus does not pass our ajax prefilter
|
117 |
+
// special test for customize_save done in frontend but for which we want to load the admin
|
118 |
+
if ( ! defined( 'PLL_AJAX_ON_FRONT' ) ) {
|
119 |
+
$in = isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], array( 'upload-attachment', 'customize_save' ) );
|
120 |
+
define( 'PLL_AJAX_ON_FRONT', defined( 'DOING_AJAX' ) && DOING_AJAX && empty( $_REQUEST['pll_ajax_backend'] ) && ! $in );
|
121 |
+
}
|
122 |
+
|
123 |
+
// admin
|
124 |
+
if ( ! defined( 'PLL_ADMIN' ) ) {
|
125 |
+
define( 'PLL_ADMIN', defined( 'DOING_CRON' ) || ( is_admin() && ! PLL_AJAX_ON_FRONT ) );
|
126 |
+
}
|
127 |
+
|
128 |
+
// settings page whatever the tab
|
129 |
+
if ( ! defined( 'PLL_SETTINGS' ) ) {
|
130 |
+
define( 'PLL_SETTINGS', is_admin() && ( ( isset( $_GET['page'] ) && 'mlang' == $_GET['page'] ) || ( isset( $_POST['action'] ) && 'pll_save_options' == $_POST['action'] ) ) );
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
/*
|
135 |
+
* Polylang initialization
|
136 |
+
* setups models and separate admin and frontend
|
137 |
+
*
|
138 |
+
* @since 1.2
|
139 |
+
*/
|
140 |
+
public function init() {
|
141 |
+
global $polylang;
|
142 |
+
|
143 |
+
self::define_constants();
|
144 |
+
$options = get_option( 'polylang' );
|
145 |
+
|
146 |
+
// plugin upgrade
|
147 |
+
if ( $options && version_compare( $options['version'], POLYLANG_VERSION, '<' ) ) {
|
148 |
+
$upgrade = new PLL_Upgrade( $options );
|
149 |
+
if ( ! $upgrade->upgrade() ) { // if the version is too old
|
150 |
+
return;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
// /!\ this filter is fired *before* the $polylang object is available
|
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();
|
158 |
+
|
159 |
+
add_filter( 'pll_languages_list', array( 'PLL_Static_Pages', 'pll_languages_list' ), 2, 2 ); // before PLL_Links_Model
|
160 |
+
|
161 |
+
if ( PLL_SETTINGS ) {
|
162 |
+
$polylang = new PLL_Settings( $links_model );
|
163 |
+
}
|
164 |
+
elseif ( PLL_ADMIN ) {
|
165 |
+
$polylang = new PLL_Admin( $links_model );
|
166 |
+
}
|
167 |
+
// do nothing on frontend if no language is defined
|
168 |
+
elseif ( $model->get_languages_list() && empty( $_GET['deactivate-polylang'] ) ) {
|
169 |
+
$polylang = new PLL_Frontend( $links_model );
|
170 |
+
}
|
171 |
+
|
172 |
+
if ( ! $model->get_languages_list() ) {
|
173 |
+
do_action( 'pll_no_language_defined' ); // to load overriden textdomains
|
174 |
+
}
|
175 |
+
|
176 |
+
if ( ! empty( $polylang ) ) {
|
177 |
+
require_once( PLL_INC.'/api.php' ); // loads the API
|
178 |
+
|
179 |
+
if ( ! defined( 'PLL_WPML_COMPAT' ) || PLL_WPML_COMPAT ) {
|
180 |
+
PLL_WPML_Compat::instance(); // WPML API
|
181 |
+
PLL_WPML_Config::instance(); // wpml-config.xml
|
182 |
+
}
|
183 |
+
|
184 |
+
$polylang->init();
|
185 |
+
do_action( 'pll_init', $polylang );
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
new Polylang();
|
include/filters-links.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* manages links filters needed on both frontend and admin
|
5 |
+
*
|
6 |
+
* @since 1.8
|
7 |
+
*/
|
8 |
+
class PLL_Filters_Links {
|
9 |
+
public $links, $links_model, $model, $options;
|
10 |
+
|
11 |
+
/*
|
12 |
+
* constructor
|
13 |
+
*
|
14 |
+
* @since 1.8
|
15 |
+
*
|
16 |
+
* @param object $polylang
|
17 |
+
*/
|
18 |
+
public function __construct( &$polylang ) {
|
19 |
+
$this->links = &$polylang->links;
|
20 |
+
$this->links_model = &$polylang->links_model;
|
21 |
+
$this->model = &$polylang->model;
|
22 |
+
$this->options = &$polylang->options;
|
23 |
+
|
24 |
+
// low priority on links filters to come after any other modifications
|
25 |
+
if ( $this->options['force_lang'] ) {
|
26 |
+
add_filter( 'post_link', array( &$this, 'post_link' ), 20, 2 );
|
27 |
+
add_filter( '_get_page_link', array( &$this, '_get_page_link' ), 20, 2 );
|
28 |
+
}
|
29 |
+
|
30 |
+
add_filter( 'post_type_link', array( &$this, 'post_type_link' ), 20, 2 );
|
31 |
+
add_filter( 'term_link', array( &$this, 'term_link' ), 20, 3 );
|
32 |
+
|
33 |
+
if ( $this->options['force_lang'] > 0 ) {
|
34 |
+
add_filter( 'attachment_link', array( &$this, 'attachment_link' ), 20, 2 );
|
35 |
+
}
|
36 |
+
|
37 |
+
if ( 3 === $this->options['force_lang'] ) {
|
38 |
+
add_filter( 'preview_post_link', array( &$this, 'preview_post_link' ), 20 );
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
/*
|
43 |
+
* modifies post & page links
|
44 |
+
*
|
45 |
+
* @since 0.7
|
46 |
+
*
|
47 |
+
* @param string $link post link
|
48 |
+
* @param object $post post object
|
49 |
+
* @return string modified post link
|
50 |
+
*/
|
51 |
+
public function post_link( $link, $post ) {
|
52 |
+
// /!\ WP does not use pretty permalinks for preview
|
53 |
+
return false !== strpos( $link, 'preview=true' ) && false !== strpos( $link, 'p=' ) ? $link : $this->links_model->add_language_to_link( $link, $this->model->post->get_language( $post->ID ) );
|
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 ) {
|
67 |
+
// /!\ WP does not use pretty permalinks for preview
|
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
|
88 |
+
*
|
89 |
+
* @param string $link post link
|
90 |
+
* @param object $post post object
|
91 |
+
* @return string modified post link
|
92 |
+
*/
|
93 |
+
public function post_type_link( $link, $post ) {
|
94 |
+
// /!\ WP does not use pretty permalinks for preview
|
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 $post term object
|
111 |
+
* @param string $tax taxonomy name
|
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 |
+
|
121 |
+
// in case someone calls get_term_link for the 'language' taxonomy
|
122 |
+
if ( 'language' === $tax ) {
|
123 |
+
return $this->links_model->home_url( $term );
|
124 |
+
}
|
125 |
+
|
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
|
133 |
+
*
|
134 |
+
* @param string $url
|
135 |
+
* @return string modified url
|
136 |
+
*/
|
137 |
+
public function preview_post_link( $url ) {
|
138 |
+
return $this->links_model->remove_language_from_link( $url );
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
include/filters.php
CHANGED
@@ -15,17 +15,20 @@ class PLL_Filters {
|
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
-
public function __construct(&$polylang) {
|
19 |
$this->links_model = &$polylang->links_model;
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->options = &$polylang->options;
|
22 |
$this->curlang = &$polylang->curlang;
|
23 |
|
24 |
// filters the comments according to the current language
|
25 |
-
add_filter('comments_clauses', array(&$this, 'comments_clauses'), 10, 2);
|
26 |
|
27 |
// filters the get_pages function according to the current language
|
28 |
-
add_filter('get_pages', array(&$this, 'get_pages'), 10, 2);
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
/*
|
@@ -38,28 +41,31 @@ class PLL_Filters {
|
|
38 |
* @param object $query WP_Comment_Query object
|
39 |
* @return array modified $clauses
|
40 |
*/
|
41 |
-
public function comments_clauses($clauses, $query) {
|
42 |
global $wpdb;
|
43 |
|
44 |
// don't filter comments if comment ids or post ids are specified
|
45 |
$plucked = wp_array_slice_assoc( $query->query_vars, array( 'comment__in', 'parent', 'post_id', 'post__in', 'post_parent' ) );
|
46 |
$fields = array_filter( $plucked );
|
47 |
-
if (!empty($fields))
|
48 |
return $clauses;
|
|
|
49 |
|
50 |
// don't filter comments if a non translated post type is specified
|
51 |
-
if (!empty($query->query_vars['post_type']) &&
|
52 |
return $clauses;
|
|
|
53 |
|
54 |
-
$lang = empty($query->query_vars['lang']) ? $this->curlang : $this->model->get_language($query->query_vars['lang']);
|
55 |
|
56 |
-
if (!empty($lang)) {
|
57 |
// if this clause is not already added by WP
|
58 |
-
if (!strpos($clauses['join'], '.ID'))
|
59 |
$clauses['join'] .= " JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
|
|
|
60 |
|
61 |
-
$clauses['join'] .= $this->model->join_clause(
|
62 |
-
$clauses['where'] .= $this->model->where_clause($lang
|
63 |
}
|
64 |
return $clauses;
|
65 |
}
|
@@ -73,16 +79,17 @@ class PLL_Filters {
|
|
73 |
* @param array $args get_pages arguments
|
74 |
* @return array modified list of pages
|
75 |
*/
|
76 |
-
public function get_pages($pages, $args) {
|
77 |
-
$language = empty($args['lang']) ? $this->curlang : $this->model->get_language($args['lang']);
|
78 |
|
79 |
-
if (empty($language) || empty($pages) ||
|
80 |
return $pages;
|
|
|
81 |
|
82 |
static $once = false;
|
83 |
|
84 |
// obliged to redo the get_pages query if we want to get the right number
|
85 |
-
if (!empty($args['number']) &&
|
86 |
$once = true; // avoid infinite loop
|
87 |
|
88 |
$r = array(
|
@@ -91,34 +98,50 @@ class PLL_Filters {
|
|
91 |
'nopaging' => true,
|
92 |
'post_type' => $args['post_type'],
|
93 |
'fields' => 'ids',
|
94 |
-
'tax_query' => array(array(
|
95 |
'taxonomy' => 'language',
|
96 |
'field' => 'term_taxonomy_id', // since WP 3.5
|
97 |
'terms' => $language->term_taxonomy_id,
|
98 |
-
'operator' => 'NOT IN'
|
99 |
-
))
|
100 |
);
|
101 |
|
102 |
-
$args['exclude'] = array_merge($args['exclude'], get_posts($r));
|
103 |
-
$pages = get_pages($args);
|
104 |
}
|
105 |
|
106 |
-
$ids = wp_list_pluck($pages, 'ID');
|
107 |
|
108 |
// filters the queried list of pages by language
|
109 |
-
if (
|
110 |
-
$ids = array_intersect($ids, $this->model->get_objects_in_language($language));
|
111 |
|
112 |
-
foreach ($pages as $key => $page) {
|
113 |
-
if (!in_array($page->ID, $ids))
|
114 |
-
unset($pages[$key]);
|
|
|
115 |
}
|
116 |
}
|
117 |
|
118 |
// not done by WP but extremely useful for performance when manipulating taxonomies
|
119 |
-
update_object_term_cache($ids, $args['post_type']);
|
120 |
|
121 |
$once = false; // in case get_pages is called another time
|
122 |
return $pages;
|
123 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
+
public function __construct( &$polylang ) {
|
19 |
$this->links_model = &$polylang->links_model;
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->options = &$polylang->options;
|
22 |
$this->curlang = &$polylang->curlang;
|
23 |
|
24 |
// filters the comments according to the current language
|
25 |
+
add_filter( 'comments_clauses', array( &$this, 'comments_clauses' ), 10, 2 );
|
26 |
|
27 |
// filters the get_pages function according to the current language
|
28 |
+
add_filter( 'get_pages', array( &$this, 'get_pages' ), 10, 2 );
|
29 |
+
|
30 |
+
// converts the locale to a valid W3C locale
|
31 |
+
add_filter( 'language_attributes', array( &$this, 'language_attributes' ) );
|
32 |
}
|
33 |
|
34 |
/*
|
41 |
* @param object $query WP_Comment_Query object
|
42 |
* @return array modified $clauses
|
43 |
*/
|
44 |
+
public function comments_clauses( $clauses, $query ) {
|
45 |
global $wpdb;
|
46 |
|
47 |
// don't filter comments if comment ids or post ids are specified
|
48 |
$plucked = wp_array_slice_assoc( $query->query_vars, array( 'comment__in', 'parent', 'post_id', 'post__in', 'post_parent' ) );
|
49 |
$fields = array_filter( $plucked );
|
50 |
+
if ( ! empty( $fields ) ) {
|
51 |
return $clauses;
|
52 |
+
}
|
53 |
|
54 |
// don't filter comments if a non translated post type is specified
|
55 |
+
if ( ! empty( $query->query_vars['post_type'] ) && ! $this->model->is_translated_post_type( $query->query_vars['post_type'] ) ) {
|
56 |
return $clauses;
|
57 |
+
}
|
58 |
|
59 |
+
$lang = empty( $query->query_vars['lang'] ) ? $this->curlang : $this->model->get_language( $query->query_vars['lang'] );
|
60 |
|
61 |
+
if ( ! empty( $lang ) ) {
|
62 |
// if this clause is not already added by WP
|
63 |
+
if ( ! strpos( $clauses['join'], '.ID' ) ) {
|
64 |
$clauses['join'] .= " JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
|
65 |
+
}
|
66 |
|
67 |
+
$clauses['join'] .= $this->model->post->join_clause();
|
68 |
+
$clauses['where'] .= $this->model->post->where_clause( $lang );
|
69 |
}
|
70 |
return $clauses;
|
71 |
}
|
79 |
* @param array $args get_pages arguments
|
80 |
* @return array modified list of pages
|
81 |
*/
|
82 |
+
public function get_pages( $pages, $args ) {
|
83 |
+
$language = empty( $args['lang'] ) ? $this->curlang : $this->model->get_language( $args['lang'] );
|
84 |
|
85 |
+
if ( empty( $language ) || empty( $pages ) || ! $this->model->is_translated_post_type( $args['post_type'] ) ) {
|
86 |
return $pages;
|
87 |
+
}
|
88 |
|
89 |
static $once = false;
|
90 |
|
91 |
// obliged to redo the get_pages query if we want to get the right number
|
92 |
+
if ( ! empty( $args['number'] ) && ! $once ) {
|
93 |
$once = true; // avoid infinite loop
|
94 |
|
95 |
$r = array(
|
98 |
'nopaging' => true,
|
99 |
'post_type' => $args['post_type'],
|
100 |
'fields' => 'ids',
|
101 |
+
'tax_query' => array( array(
|
102 |
'taxonomy' => 'language',
|
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 ) );
|
110 |
+
$pages = get_pages( $args );
|
111 |
}
|
112 |
|
113 |
+
$ids = wp_list_pluck( $pages, 'ID' );
|
114 |
|
115 |
// filters the queried list of pages by language
|
116 |
+
if ( ! $once ) {
|
117 |
+
$ids = array_intersect( $ids, $this->model->post->get_objects_in_language( $language ) );
|
118 |
|
119 |
+
foreach ( $pages as $key => $page ) {
|
120 |
+
if ( ! in_array( $page->ID, $ids ) ) {
|
121 |
+
unset( $pages[ $key ] );
|
122 |
+
}
|
123 |
}
|
124 |
}
|
125 |
|
126 |
// not done by WP but extremely useful for performance when manipulating taxonomies
|
127 |
+
update_object_term_cache( $ids, $args['post_type'] );
|
128 |
|
129 |
$once = false; // in case get_pages is called another time
|
130 |
return $pages;
|
131 |
}
|
132 |
+
|
133 |
+
/*
|
134 |
+
* converts WordPress locale to valid W3 locale in html language attributes
|
135 |
+
*
|
136 |
+
* @since 1.8
|
137 |
+
*
|
138 |
+
* @param string $output language attributes
|
139 |
+
* @return string
|
140 |
+
*/
|
141 |
+
public function language_attributes( $output ) {
|
142 |
+
if ( $language = $this->model->get_language( get_locale() ) ) {
|
143 |
+
$output = str_replace( '"' . get_bloginfo( 'language' ) . '"', '"' . $language->get_locale( 'display' ) . '"', $output );
|
144 |
+
}
|
145 |
+
return $output;
|
146 |
+
}
|
147 |
}
|
include/language.php
CHANGED
@@ -16,9 +16,10 @@
|
|
16 |
* count => number of posts and pages in that language
|
17 |
* tl_term_id => id of the term in 'term_language' taxonomy
|
18 |
* tl_term_taxonomy_id => term taxonomy id in 'term_language' taxonomy
|
19 |
-
* tl_count => number of terms in that language (not used by Polylang)
|
20 |
-
* locale => language locale. Ex: en_US
|
21 |
* is_rtl => 1 if the language is rtl
|
|
|
22 |
* flag_url => url of the flag
|
23 |
* flag => html img of the flag
|
24 |
* custom_flag_url => url of the custom flag if exists, internal use only, moves to flag_url on frontend
|
@@ -27,6 +28,8 @@
|
|
27 |
* search_url => home url to use in search forms
|
28 |
* host => host of this language
|
29 |
* mo_id => id of the post storing strings translations
|
|
|
|
|
30 |
*
|
31 |
* @since 1.2
|
32 |
*/
|
@@ -46,17 +49,19 @@ class PLL_Language {
|
|
46 |
* @param object|array $language 'language' term or language object properties stored as an array
|
47 |
* @param object $term_language corresponding 'term_language' term
|
48 |
*/
|
49 |
-
public function __construct($language, $term_language = null) {
|
50 |
// build the object from all properties stored as an array
|
51 |
-
if (empty($term_language)) {
|
52 |
-
foreach ($language as $prop => $value)
|
53 |
$this->$prop = $value;
|
|
|
54 |
}
|
55 |
-
|
56 |
// build the object from taxonomies
|
57 |
else {
|
58 |
-
foreach ($language as $prop => $value)
|
59 |
-
$this->$prop = in_array($prop, array('term_id', 'term_taxonomy_id', 'count')) ? (int) $language->$prop : $language->$prop;
|
|
|
60 |
|
61 |
// although it would be convenient here, don't assume the term is shared between taxonomies as it may not be the case in future
|
62 |
// http://make.wordpress.org/core/2013/07/28/potential-roadmap-for-taxonomy-meta-and-post-relationships/
|
@@ -64,13 +69,16 @@ class PLL_Language {
|
|
64 |
$this->tl_term_taxonomy_id = (int) $term_language->term_taxonomy_id;
|
65 |
$this->tl_count = (int) $term_language->count;
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
$
|
|
|
|
|
|
|
70 |
|
71 |
$this->description = &$this->locale; // backward compatibility with Polylang < 1.2
|
72 |
|
73 |
-
$this->mo_id = PLL_MO::get_id($this);
|
74 |
$this->set_flag();
|
75 |
}
|
76 |
}
|
@@ -81,31 +89,35 @@ class PLL_Language {
|
|
81 |
* @since 1.2
|
82 |
*/
|
83 |
public function set_flag() {
|
84 |
-
$flags['']['url'] = '';
|
85 |
|
86 |
// Polylang builtin flags
|
87 |
-
if (file_exists(POLYLANG_DIR.($file = '/flags/'
|
88 |
-
$flags['']['url'] =
|
89 |
|
90 |
// if base64 encoded flags are preferred
|
91 |
-
if (!defined('PLL_ENCODED_FLAGS') || PLL_ENCODED_FLAGS)
|
92 |
-
$flags['']['src'] = 'data:image/png;base64,' . base64_encode(file_get_contents(POLYLANG_DIR
|
|
|
|
|
|
|
93 |
}
|
94 |
|
95 |
// custom flags ?
|
96 |
-
if (file_exists(PLL_LOCAL_DIR.($file = '/'
|
97 |
-
$flags['
|
|
|
98 |
}
|
99 |
|
100 |
-
foreach($flags as $key => $flag) {
|
101 |
-
$this->{$key . '
|
102 |
|
103 |
-
$this->{$key
|
104 |
sprintf(
|
105 |
'<img src="%s" title="%s" alt="%s" />',
|
106 |
$flag['src'],
|
107 |
-
esc_attr(apply_filters('pll_flag_title', $this->name, $this->slug, $this->locale)),
|
108 |
-
esc_attr($this->name)
|
109 |
),
|
110 |
$this->slug
|
111 |
);
|
@@ -114,15 +126,25 @@ class PLL_Language {
|
|
114 |
|
115 |
/*
|
116 |
* replace flag by custom flag
|
|
|
117 |
*
|
118 |
* @since 1.7
|
119 |
*/
|
120 |
public function set_custom_flag() {
|
121 |
// overwrite with custom flags on frontend only
|
122 |
-
if (!empty($this->custom_flag)) {
|
123 |
$this->flag = $this->custom_flag;
|
124 |
$this->flag_url = $this->custom_flag_url;
|
125 |
-
unset($this->custom_flag, $this->custom_flag_url); // hide this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
}
|
128 |
|
@@ -132,34 +154,21 @@ class PLL_Language {
|
|
132 |
* @since 1.2
|
133 |
*/
|
134 |
public function update_count() {
|
135 |
-
wp_update_term_count($this->term_taxonomy_id, 'language'); // posts count
|
136 |
-
wp_update_term_count($this->tl_term_taxonomy_id, 'term_language'); // terms count
|
137 |
}
|
138 |
|
139 |
/*
|
140 |
* set home_url and search_url properties
|
141 |
*
|
142 |
* @since 1.3
|
|
|
|
|
|
|
143 |
*/
|
144 |
-
public function set_home_url() {
|
145 |
-
|
146 |
-
|
147 |
-
// home url for search form (can't use the page url if a static page is used as front page)
|
148 |
-
$this->search_url = $polylang->links_model->home_url($this);
|
149 |
-
|
150 |
-
// add a trailing slash as done by WP on homepage (otherwise could break the search form when the permalink structure does not include one)
|
151 |
-
// only for pretty permalinks
|
152 |
-
if (get_option('permalink_structure'))
|
153 |
-
$this->search_url = trailingslashit($this->search_url);
|
154 |
-
|
155 |
-
$options = get_option('polylang');
|
156 |
-
|
157 |
-
// a static page is used as front page
|
158 |
-
if (!($options['hide_default'] && $this->slug == $options['default_lang']) && !$options['redirect_lang'] && 'page' == get_option('show_on_front') && ($page_on_front = get_option('page_on_front')) && $id = pll_get_post($page_on_front, $this))
|
159 |
-
$this->home_url = _get_page_link($id); // /!\ don't use get_page_link to avoid infinite loop
|
160 |
-
|
161 |
-
else
|
162 |
-
$this->home_url = $this->search_url;
|
163 |
}
|
164 |
|
165 |
/*
|
@@ -169,14 +178,45 @@ class PLL_Language {
|
|
169 |
* @since 1.6.4
|
170 |
*/
|
171 |
public function set_home_url_scheme() {
|
172 |
-
if (is_ssl()) {
|
173 |
-
$this->home_url = str_replace('http://', 'https://', $this->home_url);
|
174 |
-
$this->search_url = str_replace('http://', 'https://', $this->search_url);
|
175 |
}
|
176 |
|
177 |
else {
|
178 |
-
$this->home_url = str_replace('https://', 'http://', $this->home_url);
|
179 |
-
$this->search_url = str_replace('https://', 'http://', $this->search_url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
}
|
|
|
181 |
}
|
182 |
}
|
16 |
* count => number of posts and pages in that language
|
17 |
* tl_term_id => id of the term in 'term_language' taxonomy
|
18 |
* tl_term_taxonomy_id => term taxonomy id in 'term_language' taxonomy
|
19 |
+
* tl_count => number of terms in that language ( not used by Polylang )
|
20 |
+
* locale => WordPress language locale. Ex: en_US
|
21 |
* is_rtl => 1 if the language is rtl
|
22 |
+
* flag_code => code of the flag
|
23 |
* flag_url => url of the flag
|
24 |
* flag => html img of the flag
|
25 |
* custom_flag_url => url of the custom flag if exists, internal use only, moves to flag_url on frontend
|
28 |
* search_url => home url to use in search forms
|
29 |
* host => host of this language
|
30 |
* mo_id => id of the post storing strings translations
|
31 |
+
* page_on_front => id of the page on front in this language ( set from PLL_Model )
|
32 |
+
* page_for_posts => id of the page for posts in this language ( set from PLL_Model )
|
33 |
*
|
34 |
* @since 1.2
|
35 |
*/
|
49 |
* @param object|array $language 'language' term or language object properties stored as an array
|
50 |
* @param object $term_language corresponding 'term_language' term
|
51 |
*/
|
52 |
+
public function __construct( $language, $term_language = null ) {
|
53 |
// build the object from all properties stored as an array
|
54 |
+
if ( empty( $term_language ) ) {
|
55 |
+
foreach ( $language as $prop => $value ) {
|
56 |
$this->$prop = $value;
|
57 |
+
}
|
58 |
}
|
59 |
+
|
60 |
// build the object from taxonomies
|
61 |
else {
|
62 |
+
foreach ( $language as $prop => $value ) {
|
63 |
+
$this->$prop = in_array( $prop, array( 'term_id', 'term_taxonomy_id', 'count' ) ) ? (int) $language->$prop : $language->$prop;
|
64 |
+
}
|
65 |
|
66 |
// although it would be convenient here, don't assume the term is shared between taxonomies as it may not be the case in future
|
67 |
// http://make.wordpress.org/core/2013/07/28/potential-roadmap-for-taxonomy-meta-and-post-relationships/
|
69 |
$this->tl_term_taxonomy_id = (int) $term_language->term_taxonomy_id;
|
70 |
$this->tl_count = (int) $term_language->count;
|
71 |
|
72 |
+
// the description field can contain any property
|
73 |
+
// backward compatibility for is_rtl
|
74 |
+
$description = maybe_unserialize( $language->description );
|
75 |
+
foreach ( $description as $prop => $value ) {
|
76 |
+
'rtl' == $prop ? $this->is_rtl = $value : $this->$prop = $value;
|
77 |
+
}
|
78 |
|
79 |
$this->description = &$this->locale; // backward compatibility with Polylang < 1.2
|
80 |
|
81 |
+
$this->mo_id = PLL_MO::get_id( $this );
|
82 |
$this->set_flag();
|
83 |
}
|
84 |
}
|
89 |
* @since 1.2
|
90 |
*/
|
91 |
public function set_flag() {
|
92 |
+
$flags['flag']['url'] = '';
|
93 |
|
94 |
// Polylang builtin flags
|
95 |
+
if ( ! empty( $this->flag_code ) && file_exists( POLYLANG_DIR . ( $file = '/flags/' . $this->flag_code . '.png' ) ) ) {
|
96 |
+
$flags['flag']['url'] = esc_url_raw( POLYLANG_URL . $file );
|
97 |
|
98 |
// if base64 encoded flags are preferred
|
99 |
+
if ( ! defined( 'PLL_ENCODED_FLAGS' ) || PLL_ENCODED_FLAGS ) {
|
100 |
+
$flags['flag']['src'] = 'data:image/png;base64,' . base64_encode( file_get_contents( POLYLANG_DIR . $file ) );
|
101 |
+
} else {
|
102 |
+
$flags['flag']['src'] = esc_url( POLYLANG_URL . $file );
|
103 |
+
}
|
104 |
}
|
105 |
|
106 |
// custom flags ?
|
107 |
+
if ( file_exists( PLL_LOCAL_DIR . ( $file = '/' . $this->locale . '.png' ) ) || file_exists( PLL_LOCAL_DIR . ( $file = '/' . $this->locale . '.jpg' ) ) ) {
|
108 |
+
$flags['custom_flag']['url'] = esc_url_raw( PLL_LOCAL_URL . $file );
|
109 |
+
$flags['custom_flag']['src'] = esc_url( PLL_LOCAL_URL . $file );
|
110 |
}
|
111 |
|
112 |
+
foreach ( $flags as $key => $flag ) {
|
113 |
+
$this->{$key . '_url'} = empty( $flag['url'] ) ? '' : $flag['url'];
|
114 |
|
115 |
+
$this->{$key} = apply_filters( 'pll_get_flag', empty( $flag['src'] ) ? '' :
|
116 |
sprintf(
|
117 |
'<img src="%s" title="%s" alt="%s" />',
|
118 |
$flag['src'],
|
119 |
+
esc_attr( apply_filters( 'pll_flag_title', $this->name, $this->slug, $this->locale ) ),
|
120 |
+
esc_attr( $this->name )
|
121 |
),
|
122 |
$this->slug
|
123 |
);
|
126 |
|
127 |
/*
|
128 |
* replace flag by custom flag
|
129 |
+
* takes care of url scheme
|
130 |
*
|
131 |
* @since 1.7
|
132 |
*/
|
133 |
public function set_custom_flag() {
|
134 |
// overwrite with custom flags on frontend only
|
135 |
+
if ( ! empty( $this->custom_flag ) ) {
|
136 |
$this->flag = $this->custom_flag;
|
137 |
$this->flag_url = $this->custom_flag_url;
|
138 |
+
unset( $this->custom_flag, $this->custom_flag_url ); // hide this
|
139 |
+
}
|
140 |
+
|
141 |
+
// set url scheme, also for default flags
|
142 |
+
if ( is_ssl() ) {
|
143 |
+
$this->flag = str_replace( 'http://', 'https://', $this->flag );
|
144 |
+
$this->flag_url = str_replace( 'http://', 'https://', $this->flag_url );
|
145 |
+
} else {
|
146 |
+
$this->flag = str_replace( 'https://', 'http://', $this->flag );
|
147 |
+
$this->flag_url = str_replace( 'https://', 'http://', $this->flag_url );
|
148 |
}
|
149 |
}
|
150 |
|
154 |
* @since 1.2
|
155 |
*/
|
156 |
public function update_count() {
|
157 |
+
wp_update_term_count( $this->term_taxonomy_id, 'language' ); // posts count
|
158 |
+
wp_update_term_count( $this->tl_term_taxonomy_id, 'term_language' ); // terms count
|
159 |
}
|
160 |
|
161 |
/*
|
162 |
* set home_url and search_url properties
|
163 |
*
|
164 |
* @since 1.3
|
165 |
+
*
|
166 |
+
* @param string $search_url
|
167 |
+
* @param string $home_url
|
168 |
*/
|
169 |
+
public function set_home_url( $search_url, $home_url ) {
|
170 |
+
$this->search_url = $search_url;
|
171 |
+
$this->home_url = $home_url;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
173 |
|
174 |
/*
|
178 |
* @since 1.6.4
|
179 |
*/
|
180 |
public function set_home_url_scheme() {
|
181 |
+
if ( is_ssl() ) {
|
182 |
+
$this->home_url = str_replace( 'http://', 'https://', $this->home_url );
|
183 |
+
$this->search_url = str_replace( 'http://', 'https://', $this->search_url );
|
184 |
}
|
185 |
|
186 |
else {
|
187 |
+
$this->home_url = str_replace( 'https://', 'http://', $this->home_url );
|
188 |
+
$this->search_url = str_replace( 'https://', 'http://', $this->search_url );
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
/*
|
193 |
+
* returns the language locale
|
194 |
+
* converts WP locales to W3C valid locales for display
|
195 |
+
* @see #33511
|
196 |
+
*
|
197 |
+
* @since 1.8
|
198 |
+
*
|
199 |
+
* @param string $filter either 'display' or 'raw', defaults to raw
|
200 |
+
* @return string
|
201 |
+
*/
|
202 |
+
public function get_locale( $filter = 'raw' ) {
|
203 |
+
if ( 'display' == $filter ) {
|
204 |
+
static $valid_locales = array(
|
205 |
+
'bel' => 'be',
|
206 |
+
'bre' => 'br',
|
207 |
+
'de_DE_formal' => 'de_DE',
|
208 |
+
'dzo' => 'dz',
|
209 |
+
'ido' => 'io',
|
210 |
+
'kin' => 'rw',
|
211 |
+
'oci' => 'oc',
|
212 |
+
'mri' => 'mi',
|
213 |
+
'roh' => 'rm',
|
214 |
+
'srd' => 'sc',
|
215 |
+
'tuk' => 'tk',
|
216 |
+
);
|
217 |
+
$locale = isset( $valid_locales[ $this->locale ] ) ? $valid_locales[ $this->locale ] : $this->locale;
|
218 |
+
return str_replace( '_', '-', $locale );
|
219 |
}
|
220 |
+
return $this->locale;
|
221 |
}
|
222 |
}
|
include/links-default.php
CHANGED
@@ -20,8 +20,8 @@ class PLL_Links_Default extends PLL_Links_Model {
|
|
20 |
* @param object $lang language
|
21 |
* @return string modified url
|
22 |
*/
|
23 |
-
public function add_language_to_link($url, $lang) {
|
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 |
/*
|
@@ -33,8 +33,8 @@ class PLL_Links_Default extends PLL_Links_Model {
|
|
33 |
* @param string $url url to modify
|
34 |
* @return string modified url
|
35 |
*/
|
36 |
-
public function remove_language_from_link($url) {
|
37 |
-
return remove_query_arg('lang', $url);
|
38 |
}
|
39 |
|
40 |
/*
|
@@ -46,8 +46,8 @@ class PLL_Links_Default extends PLL_Links_Model {
|
|
46 |
* @param string $url url to modify
|
47 |
* @return string modified url
|
48 |
*/
|
49 |
-
function remove_paged_from_link($url) {
|
50 |
-
return remove_query_arg('paged', $url);
|
51 |
}
|
52 |
|
53 |
|
@@ -60,8 +60,8 @@ class PLL_Links_Default extends PLL_Links_Model {
|
|
60 |
* @param int $page
|
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 |
|
@@ -74,20 +74,23 @@ class PLL_Links_Default extends PLL_Links_Model {
|
|
74 |
* @return string language slug
|
75 |
*/
|
76 |
public function get_language_from_url() {
|
77 |
-
$pattern = '#lang=('.implode('|', $this->model->get_languages_list(array('fields' => 'slug'))).')#';
|
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 |
-
* returns the
|
83 |
-
* links_model interface
|
84 |
*
|
85 |
-
* @since 1.
|
86 |
*
|
87 |
-
* @param object $lang
|
88 |
* @return string
|
89 |
*/
|
90 |
-
public function
|
91 |
-
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
}
|
20 |
* @param object $lang language
|
21 |
* @return string modified url
|
22 |
*/
|
23 |
+
public function add_language_to_link( $url, $lang ) {
|
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 |
/*
|
33 |
* @param string $url url to modify
|
34 |
* @return string modified url
|
35 |
*/
|
36 |
+
public function remove_language_from_link( $url ) {
|
37 |
+
return remove_query_arg( 'lang', $url );
|
38 |
}
|
39 |
|
40 |
/*
|
46 |
* @param string $url url to modify
|
47 |
* @return string modified url
|
48 |
*/
|
49 |
+
function remove_paged_from_link( $url ) {
|
50 |
+
return remove_query_arg( 'paged', $url );
|
51 |
}
|
52 |
|
53 |
|
60 |
* @param int $page
|
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 |
|
74 |
* @return string language slug
|
75 |
*/
|
76 |
public function get_language_from_url() {
|
77 |
+
$pattern = '#lang=('.implode( '|', $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ).')#';
|
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 |
+
* returns the static front page url
|
|
|
83 |
*
|
84 |
+
* @since 1.8
|
85 |
*
|
86 |
+
* @param object $lang
|
87 |
* @return string
|
88 |
*/
|
89 |
+
public function front_page_url( $lang ) {
|
90 |
+
if ( $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ) {
|
91 |
+
return trailingslashit( $this->home );
|
92 |
+
}
|
93 |
+
$url = home_url( '/?page_id=' . $lang->page_on_front );
|
94 |
+
return $this->options['force_lang'] ? $this->add_language_to_link( $url, $lang ) : $url;
|
95 |
}
|
96 |
}
|
include/links-directory.php
CHANGED
@@ -8,8 +8,6 @@
|
|
8 |
* @since 1.2
|
9 |
*/
|
10 |
class PLL_Links_Directory extends PLL_Links_Permalinks {
|
11 |
-
protected $index = 'index.php'; // need this before $wp_rewrite is created, also harcoded in wp-includes/rewrite.php
|
12 |
-
protected $root;
|
13 |
|
14 |
/*
|
15 |
* constructor
|
@@ -18,13 +16,16 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
18 |
*
|
19 |
* @param object $model PLL_Model instance
|
20 |
*/
|
21 |
-
public function __construct(&$model) {
|
22 |
-
parent::__construct($model);
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
add_action('pll_init', array(&$this, 'init'));
|
28 |
}
|
29 |
|
30 |
/*
|
@@ -33,13 +34,15 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
33 |
* @since 1.6
|
34 |
*/
|
35 |
public function init() {
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
// make sure to prepare rewrite rules when flushing
|
39 |
-
add_action('pre_option_rewrite_rules', array(&$this, 'prepare_rewrite_rules'));
|
40 |
-
|
41 |
-
// refresh rewrite rules if the 'page_on_front' option is modified
|
42 |
-
add_action('update_option_page_on_front', 'flush_rewrite_rules');
|
43 |
}
|
44 |
|
45 |
/*
|
@@ -52,11 +55,11 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
52 |
* @param object $lang language
|
53 |
* @return string modified url
|
54 |
*/
|
55 |
-
public function add_language_to_link($url, $lang) {
|
56 |
-
if (!empty($lang)) {
|
57 |
$base = $this->options['rewrite'] ? '' : 'language/';
|
58 |
$slug = $this->options['default_lang'] == $lang->slug && $this->options['hide_default'] ? '' : $base . $lang->slug . '/';
|
59 |
-
return str_replace($this->home . '/' . $this->root, $this->home . '/' . $this->root . $slug, $url);
|
60 |
}
|
61 |
return $url;
|
62 |
}
|
@@ -70,15 +73,17 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
70 |
* @param string $url url to modify
|
71 |
* @return string modified url
|
72 |
*/
|
73 |
-
function remove_language_from_link($url) {
|
74 |
-
foreach ($this->model->get_languages_list() as $language)
|
75 |
-
if (
|
76 |
$languages[] = $language->slug;
|
|
|
|
|
77 |
|
78 |
-
if (!empty($languages)) {
|
79 |
-
$pattern = str_replace('/', '\/', $this->home . '/' . $this->root);
|
80 |
-
$pattern = '#' . $pattern . ($this->options['rewrite'] ? '' : 'language\/') . '('.implode('|', $languages).')(\/|$)#';
|
81 |
-
$url = preg_replace($pattern, $this->home . '/' . $this->root, $url);
|
82 |
}
|
83 |
return $url;
|
84 |
}
|
@@ -92,10 +97,10 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
92 |
* @return string language slug
|
93 |
*/
|
94 |
public function get_language_from_url() {
|
95 |
-
$requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
96 |
-
$pattern = str_replace('/', '\/', $this->home . '/' . $this->root . ($this->options['rewrite'] ? '' : 'language/'));
|
97 |
-
$pattern = '#' . $pattern . '('. implode('|', $this->model->get_languages_list(array('fields' => 'slug'))) . ')(\/|$)#';
|
98 |
-
return preg_match($pattern, trailingslashit($requested_url), $matches) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
99 |
}
|
100 |
|
101 |
/*
|
@@ -107,8 +112,10 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
107 |
* @param object $lang PLL_Language object
|
108 |
* @return string
|
109 |
*/
|
110 |
-
public function home_url($lang) {
|
111 |
-
|
|
|
|
|
112 |
}
|
113 |
|
114 |
/*
|
@@ -117,9 +124,9 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
117 |
* @since 1.2
|
118 |
*/
|
119 |
function add_permastruct() {
|
120 |
-
// language information always in front of the uri ('with_front' => false)
|
121 |
// the 3rd parameter structure has been modified in WP 3.4
|
122 |
-
add_permastruct('language', $this->options['rewrite'] ? '%language%' : 'language/%language%', array('with_front' => false));
|
123 |
}
|
124 |
|
125 |
/*
|
@@ -130,20 +137,17 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
130 |
* @param array $pre not used
|
131 |
* @return unmodified $pre
|
132 |
*/
|
133 |
-
public function prepare_rewrite_rules($pre) {
|
134 |
-
static $done = false; // make sure to add filters only one time
|
135 |
-
|
136 |
// don't modify the rules if there is no languages created yet
|
137 |
-
if ($this->model->get_languages_list() &&
|
138 |
// suppress the rules created by WordPress for our taxonomy
|
139 |
-
add_filter('language_rewrite_rules', '__return_empty_array');
|
140 |
|
141 |
-
foreach ($this->get_rewrite_rules_filters() as $type)
|
142 |
-
add_filter($type . '_rewrite_rules', array(&$this, 'rewrite_rules'));
|
143 |
-
|
144 |
-
add_filter('rewrite_rules_array', array(&$this, 'rewrite_rules')); // needed for post type archives
|
145 |
|
146 |
-
|
147 |
}
|
148 |
return $pre;
|
149 |
}
|
@@ -158,60 +162,65 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
158 |
* @param array $rules rewrite rules
|
159 |
* @return array modified rewrite rules
|
160 |
*/
|
161 |
-
public function rewrite_rules($rules) {
|
162 |
-
$filter = str_replace('_rewrite_rules', '', current_filter());
|
163 |
|
164 |
global $wp_rewrite;
|
165 |
$newrules = array();
|
166 |
|
167 |
-
$languages = $this->model->get_languages_list(array('fields' => 'slug'));
|
168 |
-
if ($this->options['hide_default'])
|
169 |
-
$languages = array_diff($languages, array($this->options['default_lang']));
|
|
|
170 |
|
171 |
-
if (!empty($languages))
|
172 |
-
$slug = $wp_rewrite->root . ($this->options['rewrite'] ? '' : 'language/') . '('.implode('|', $languages).')/';
|
|
|
173 |
|
174 |
// for custom post type archives
|
175 |
-
$cpts = array_intersect($this->model->get_translated_post_types(), get_post_types(array('_builtin' => false)));
|
176 |
-
$cpts = $cpts ? '#post_type=('.implode('|', $cpts).')#' : '';
|
177 |
-
|
178 |
-
foreach ($rules as $key => $rule) {
|
179 |
-
//
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
array('[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]'),
|
185 |
-
array('[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]'),
|
186 |
$rule
|
187 |
); // should be enough!
|
|
|
188 |
|
189 |
-
if ($this->options['hide_default']) {
|
190 |
-
$newrules[$key] = $rules[$key];
|
191 |
// unset only if we hide the code for the default language as check_language_code_in_url will do its job in other cases
|
192 |
-
unset($rules[$key]);
|
193 |
}
|
194 |
}
|
195 |
|
196 |
// rewrite rules filtered by language
|
197 |
-
elseif (in_array($filter, $this->always_rewrite) || in_array($filter, $this->model->get_filtered_taxonomies()) || ($cpts && preg_match($cpts, $rule) && !strpos($rule, 'name=')) || (
|
198 |
-
if (isset($slug))
|
199 |
-
$newrules[$slug.str_replace($wp_rewrite->root, '', $key)] = str_replace(
|
200 |
-
array('[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?'),
|
201 |
-
array('[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&'),
|
202 |
$rule
|
203 |
); // should be enough!
|
|
|
204 |
|
205 |
-
if ($this->options['hide_default'])
|
206 |
-
$newrules[$key] = str_replace('?', '?lang='
|
|
|
207 |
|
208 |
-
unset($rules[$key]); // now useless
|
209 |
}
|
210 |
}
|
211 |
|
212 |
// the home rewrite rule
|
213 |
-
if (
|
214 |
-
$newrules[$slug.'?$'] = $wp_rewrite->index.'?lang=$matches[1]';
|
|
|
215 |
|
216 |
return $newrules + $rules;
|
217 |
}
|
8 |
* @since 1.2
|
9 |
*/
|
10 |
class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
|
|
|
11 |
|
12 |
/*
|
13 |
* constructor
|
16 |
*
|
17 |
* @param object $model PLL_Model instance
|
18 |
*/
|
19 |
+
public function __construct( &$model ) {
|
20 |
+
parent::__construct( $model );
|
21 |
|
22 |
+
if ( did_action( 'pll_init' ) ) {
|
23 |
+
$this->init();
|
24 |
+
}
|
25 |
+
else {
|
26 |
+
add_action( 'pll_init', array( &$this, 'init' ) );
|
27 |
+
}
|
28 |
|
|
|
29 |
}
|
30 |
|
31 |
/*
|
34 |
* @since 1.6
|
35 |
*/
|
36 |
public function init() {
|
37 |
+
if ( did_action( 'setup_theme' ) ) {
|
38 |
+
$this->add_permastruct();
|
39 |
+
}
|
40 |
+
else {
|
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 |
/*
|
55 |
* @param object $lang language
|
56 |
* @return string modified url
|
57 |
*/
|
58 |
+
public function add_language_to_link( $url, $lang ) {
|
59 |
+
if ( ! empty( $lang ) ) {
|
60 |
$base = $this->options['rewrite'] ? '' : 'language/';
|
61 |
$slug = $this->options['default_lang'] == $lang->slug && $this->options['hide_default'] ? '' : $base . $lang->slug . '/';
|
62 |
+
return str_replace( $this->home . '/' . $this->root, $this->home . '/' . $this->root . $slug, $url );
|
63 |
}
|
64 |
return $url;
|
65 |
}
|
73 |
* @param string $url url to modify
|
74 |
* @return string modified url
|
75 |
*/
|
76 |
+
function remove_language_from_link( $url ) {
|
77 |
+
foreach ( $this->model->get_languages_list() as $language ) {
|
78 |
+
if ( ! $this->options['hide_default'] || $this->options['default_lang'] != $language->slug ) {
|
79 |
$languages[] = $language->slug;
|
80 |
+
}
|
81 |
+
}
|
82 |
|
83 |
+
if ( ! empty( $languages ) ) {
|
84 |
+
$pattern = str_replace( '/', '\/', $this->home . '/' . $this->root );
|
85 |
+
$pattern = '#' . $pattern . ( $this->options['rewrite'] ? '' : 'language\/' ) . '('.implode( '|', $languages ).')(\/|$)#';
|
86 |
+
$url = preg_replace( $pattern, $this->home . '/' . $this->root, $url );
|
87 |
}
|
88 |
return $url;
|
89 |
}
|
97 |
* @return string language slug
|
98 |
*/
|
99 |
public function get_language_from_url() {
|
100 |
+
$requested_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
101 |
+
$pattern = str_replace( '/', '\/', $this->home . '/' . $this->root . ( $this->options['rewrite'] ? '' : 'language/' ) );
|
102 |
+
$pattern = '#' . $pattern . '('. implode( '|', $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) . ')(\/|$)#';
|
103 |
+
return preg_match( $pattern, trailingslashit( $requested_url ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
104 |
}
|
105 |
|
106 |
/*
|
112 |
* @param object $lang PLL_Language object
|
113 |
* @return string
|
114 |
*/
|
115 |
+
public function home_url( $lang ) {
|
116 |
+
$base = $this->options['rewrite'] ? '' : 'language/';
|
117 |
+
$slug = $this->options['default_lang'] == $lang->slug && $this->options['hide_default'] ? '' : '/' . $this->root . $base . $lang->slug;
|
118 |
+
return trailingslashit( $this->home . $slug );
|
119 |
}
|
120 |
|
121 |
/*
|
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 |
/*
|
137 |
* @param array $pre not used
|
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 ) {
|
147 |
+
add_filter( $type . '_rewrite_rules', array( &$this, 'rewrite_rules' ) );
|
148 |
+
}
|
|
|
149 |
|
150 |
+
add_filter( 'rewrite_rules_array', array( &$this, 'rewrite_rules' ) ); // needed for post type archives
|
151 |
}
|
152 |
return $pre;
|
153 |
}
|
162 |
* @param array $rules rewrite rules
|
163 |
* @return array modified rewrite rules
|
164 |
*/
|
165 |
+
public function rewrite_rules( $rules ) {
|
166 |
+
$filter = str_replace( '_rewrite_rules', '', current_filter() );
|
167 |
|
168 |
global $wp_rewrite;
|
169 |
$newrules = array();
|
170 |
|
171 |
+
$languages = $this->model->get_languages_list( array( 'fields' => 'slug' ) );
|
172 |
+
if ( $this->options['hide_default'] ) {
|
173 |
+
$languages = array_diff( $languages, array( $this->options['default_lang'] ) );
|
174 |
+
}
|
175 |
|
176 |
+
if ( ! empty( $languages ) ) {
|
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 |
+
}
|
224 |
|
225 |
return $newrules + $rules;
|
226 |
}
|
include/links-domain.php
CHANGED
@@ -9,6 +9,20 @@
|
|
9 |
*/
|
10 |
class PLL_Links_Domain extends PLL_Links_Permalinks {
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/*
|
13 |
* adds the language code in url
|
14 |
* links_model interface
|
@@ -19,9 +33,10 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
19 |
* @param object $lang language
|
20 |
* @return string modified url
|
21 |
*/
|
22 |
-
public function add_language_to_link($url, $lang) {
|
23 |
-
if (!empty($lang) && !empty($this->options['domains'][$lang->slug]))
|
24 |
-
$url = str_replace($this->home, $this->options['domains'][$lang->slug], $url);
|
|
|
25 |
return $url;
|
26 |
}
|
27 |
|
@@ -34,9 +49,10 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
34 |
* @param string $url url to modify
|
35 |
* @return string modified url
|
36 |
*/
|
37 |
-
public function remove_language_from_link($url) {
|
38 |
-
if (!empty($this->options['domains']))
|
39 |
-
$url = str_replace((is_ssl() ? 'https://' : 'http://') . parse_url($url, PHP_URL_HOST) . parse_url($this->home, PHP_URL_PATH), $this->home, $url);
|
|
|
40 |
return $url;
|
41 |
}
|
42 |
|
@@ -49,7 +65,7 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
49 |
* @return string language slug
|
50 |
*/
|
51 |
public function get_language_from_url() {
|
52 |
-
return ($lang = array_search( (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . parse_url($this->home, PHP_URL_PATH), $this->options['domains'] ) ) ? $lang : $this->options['default_lang'];
|
53 |
}
|
54 |
|
55 |
/*
|
@@ -61,8 +77,8 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
61 |
* @param object $lang PLL_Language object
|
62 |
* @return string
|
63 |
*/
|
64 |
-
function home_url($lang) {
|
65 |
-
return empty($this->options['domains'][$lang->slug]) ? $this->home : $this->options['domains'][$lang->slug];
|
66 |
}
|
67 |
|
68 |
/*
|
@@ -73,6 +89,23 @@ class PLL_Links_Domain extends PLL_Links_Permalinks {
|
|
73 |
* @return array list of hosts
|
74 |
*/
|
75 |
public function get_hosts() {
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
}
|
9 |
*/
|
10 |
class PLL_Links_Domain extends PLL_Links_Permalinks {
|
11 |
|
12 |
+
/*
|
13 |
+
* constructor
|
14 |
+
*
|
15 |
+
* @since 1.8
|
16 |
+
*
|
17 |
+
* @param object $model PLL_Model instance
|
18 |
+
*/
|
19 |
+
public function __construct( &$model ) {
|
20 |
+
parent::__construct( $model );
|
21 |
+
|
22 |
+
add_filter( 'site_url', array( &$this, 'site_url' ) );
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
/*
|
27 |
* adds the language code in url
|
28 |
* links_model interface
|
33 |
* @param object $lang language
|
34 |
* @return string modified url
|
35 |
*/
|
36 |
+
public function add_language_to_link( $url, $lang ) {
|
37 |
+
if ( ! empty( $lang ) && ! empty( $this->options['domains'][ $lang->slug ] ) ) {
|
38 |
+
$url = str_replace( $this->home, $this->options['domains'][ $lang->slug ], $url );
|
39 |
+
}
|
40 |
return $url;
|
41 |
}
|
42 |
|
49 |
* @param string $url url to modify
|
50 |
* @return string modified url
|
51 |
*/
|
52 |
+
public function remove_language_from_link( $url ) {
|
53 |
+
if ( ! empty( $this->options['domains'] ) ) {
|
54 |
+
$url = str_replace( ( is_ssl() ? 'https://' : 'http://' ) . parse_url( $url, PHP_URL_HOST ) . parse_url( $this->home, PHP_URL_PATH ), $this->home, $url );
|
55 |
+
}
|
56 |
return $url;
|
57 |
}
|
58 |
|
65 |
* @return string language slug
|
66 |
*/
|
67 |
public function get_language_from_url() {
|
68 |
+
return ( $lang = array_search( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . parse_url( $this->home, PHP_URL_PATH ), $this->options['domains'] ) ) ? $lang : $this->options['default_lang'];
|
69 |
}
|
70 |
|
71 |
/*
|
77 |
* @param object $lang PLL_Language object
|
78 |
* @return string
|
79 |
*/
|
80 |
+
function home_url( $lang ) {
|
81 |
+
return trailingslashit( empty( $this->options['domains'][ $lang->slug ] ) ? $this->home : $this->options['domains'][ $lang->slug ] );
|
82 |
}
|
83 |
|
84 |
/*
|
89 |
* @return array list of hosts
|
90 |
*/
|
91 |
public function get_hosts() {
|
92 |
+
foreach ( $this->options['domains'] as $domain ) {
|
93 |
+
$hosts[] = parse_url( $domain, PHP_URL_HOST );
|
94 |
+
}
|
95 |
+
return $hosts;
|
96 |
+
}
|
97 |
+
|
98 |
+
/*
|
99 |
+
* returns the correct site url ( mainly to get the correct login form )
|
100 |
+
*
|
101 |
+
* @since 1.8
|
102 |
+
*
|
103 |
+
* @param string $url
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
public function site_url( $url ) {
|
107 |
+
$lang = $this->get_language_from_url();
|
108 |
+
$lang = $this->model->get_language( $lang );
|
109 |
+
return $this->add_language_to_link( $url, $lang );
|
110 |
}
|
111 |
}
|
include/links-model.php
CHANGED
@@ -17,11 +17,17 @@ abstract class PLL_Links_Model {
|
|
17 |
*
|
18 |
* @param object $model PLL_Model instance
|
19 |
*/
|
20 |
-
public function __construct(&$model) {
|
21 |
$this->model = &$model;
|
22 |
$this->options = &$model->options;
|
23 |
|
24 |
$this->home = home_url();
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
/*
|
@@ -33,9 +39,9 @@ abstract class PLL_Links_Model {
|
|
33 |
* @param object $lang language
|
34 |
* @return string modified url
|
35 |
*/
|
36 |
-
public function switch_language_in_link($url, $lang) {
|
37 |
-
$url = $this->remove_language_from_link($url);
|
38 |
-
return $this->add_language_to_link($url, $lang);
|
39 |
}
|
40 |
|
41 |
/*
|
@@ -46,6 +52,81 @@ abstract class PLL_Links_Model {
|
|
46 |
* @return array list of hosts
|
47 |
*/
|
48 |
public function get_hosts() {
|
49 |
-
return array(parse_url($this->home, PHP_URL_HOST));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
}
|
17 |
*
|
18 |
* @param object $model PLL_Model instance
|
19 |
*/
|
20 |
+
public function __construct( &$model ) {
|
21 |
$this->model = &$model;
|
22 |
$this->options = &$model->options;
|
23 |
|
24 |
$this->home = home_url();
|
25 |
+
|
26 |
+
add_filter( 'pll_languages_list', array( &$this, 'pll_languages_list' ), 4 ); // after PLL_Static_Pages
|
27 |
+
add_filter( 'pll_after_languages_cache', array( &$this, 'pll_after_languages_cache' ) );
|
28 |
+
|
29 |
+
// adds our domains or subdomains to allowed hosts for safe redirection
|
30 |
+
add_filter( 'allowed_redirect_hosts', array( &$this, 'allowed_redirect_hosts' ) );
|
31 |
}
|
32 |
|
33 |
/*
|
39 |
* @param object $lang language
|
40 |
* @return string modified url
|
41 |
*/
|
42 |
+
public function switch_language_in_link( $url, $lang ) {
|
43 |
+
$url = $this->remove_language_from_link( $url );
|
44 |
+
return $this->add_language_to_link( $url, $lang );
|
45 |
}
|
46 |
|
47 |
/*
|
52 |
* @return array list of hosts
|
53 |
*/
|
54 |
public function get_hosts() {
|
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 |
+
*
|
63 |
+
* @param object $lang PLL_Language object
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function home_url( $lang ) {
|
67 |
+
$url = trailingslashit( $this->home );
|
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 |
+
*
|
76 |
+
* @param object $language
|
77 |
+
*/
|
78 |
+
protected function set_home_url( $language ) {
|
79 |
+
$search_url = $this->home_url( $language );
|
80 |
+
$home_url = empty( $language->page_on_front ) || $this->options['redirect_lang'] ? $search_url : $this->front_page_url( $language );
|
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 |
+
*
|
89 |
+
* @param array $languages array of PLL_Language objects
|
90 |
+
* @return array
|
91 |
+
*/
|
92 |
+
public function pll_languages_list( $languages ) {
|
93 |
+
foreach ( $languages as $language ) {
|
94 |
+
$this->set_home_url( $language );
|
95 |
+
}
|
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 |
+
*
|
105 |
+
* @param array $languages array of PLL_Language objects
|
106 |
+
* @return array
|
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 |
+
*
|
126 |
+
* @param array $hosts allowed hosts
|
127 |
+
* @return array
|
128 |
+
*/
|
129 |
+
public function allowed_redirect_hosts( $hosts ) {
|
130 |
+
return array_unique( array_merge( $hosts, $this->get_hosts() ) );
|
131 |
}
|
132 |
}
|
include/links-permalinks.php
CHANGED
@@ -7,7 +7,25 @@
|
|
7 |
*/
|
8 |
abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
9 |
public $using_permalinks = true;
|
10 |
-
protected $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
/*
|
13 |
* returns the link to the first page when using pretty permalinks
|
@@ -17,8 +35,8 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
17 |
* @param string $url url to modify
|
18 |
* @return string modified url
|
19 |
*/
|
20 |
-
public function remove_paged_from_link($url) {
|
21 |
-
return preg_replace('#\/page\/[0-9]+\/#', '/', $url); // FIXME trailing slash ?
|
22 |
}
|
23 |
|
24 |
/*
|
@@ -30,8 +48,37 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
30 |
* @param int $page
|
31 |
* @return string modified url
|
32 |
*/
|
33 |
-
public function add_paged_to_link($url, $page) {
|
34 |
-
return trailingslashit($url) . 'page/' . $page; // FIXME trailing slash ?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
/*
|
@@ -41,8 +88,8 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
41 |
*/
|
42 |
public function get_rewrite_rules_filters() {
|
43 |
// make sure we have the right post types and taxonomies
|
44 |
-
$types = array_values(array_merge($this->model->get_translated_post_types(), $this->model->get_translated_taxonomies(), $this->model->get_filtered_taxonomies()));
|
45 |
-
$types = array_merge($this->always_rewrite, $types);
|
46 |
-
return apply_filters('pll_rewrite_rules', $types); // allow plugins to add rewrite rules to the language filter
|
47 |
}
|
48 |
}
|
7 |
*/
|
8 |
abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
9 |
public $using_permalinks = true;
|
10 |
+
protected $index = 'index.php'; // need this before $wp_rewrite is created, also harcoded in wp-includes/rewrite.php
|
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 |
+
*
|
19 |
+
* @param object $model PLL_Model instance
|
20 |
+
*/
|
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
|
35 |
* @param string $url url to modify
|
36 |
* @return string modified url
|
37 |
*/
|
38 |
+
public function remove_paged_from_link( $url ) {
|
39 |
+
return preg_replace( '#\/page\/[0-9]+\/#', '/', $url ); // FIXME trailing slash ?
|
40 |
}
|
41 |
|
42 |
/*
|
48 |
* @param int $page
|
49 |
* @return string modified url
|
50 |
*/
|
51 |
+
public function add_paged_to_link( $url, $page ) {
|
52 |
+
return trailingslashit( $url ) . 'page/' . $page; // FIXME trailing slash ?
|
53 |
+
}
|
54 |
+
|
55 |
+
/*
|
56 |
+
* returns the home url
|
57 |
+
*
|
58 |
+
* @since 1.3.1
|
59 |
+
*
|
60 |
+
* @param object $lang PLL_Language object
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function home_url( $lang ) {
|
64 |
+
return trailingslashit( parent::home_url( $lang ) );
|
65 |
+
}
|
66 |
+
|
67 |
+
/*
|
68 |
+
* returns the static front page url
|
69 |
+
*
|
70 |
+
* @since 1.8
|
71 |
+
*
|
72 |
+
* @param object $lang
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function front_page_url( $lang ) {
|
76 |
+
if ( $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ) {
|
77 |
+
return trailingslashit( $this->home );
|
78 |
+
}
|
79 |
+
$url = home_url( $this->root . get_page_uri( $lang->page_on_front ) );
|
80 |
+
$url = $this->use_trailing_slashes ? trailingslashit( $url ) : untrailingslashit( $url );
|
81 |
+
return $this->options['force_lang'] ? $this->add_language_to_link( $url, $lang ) : $url;
|
82 |
}
|
83 |
|
84 |
/*
|
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 |
+
return apply_filters( 'pll_rewrite_rules', $types ); // allow plugins to add rewrite rules to the language filter
|
94 |
}
|
95 |
}
|
include/links-subdomain.php
CHANGED
@@ -9,10 +9,10 @@
|
|
9 |
*/
|
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 |
/*
|
@@ -25,9 +25,10 @@ class PLL_Links_Subdomain extends PLL_Links_Permalinks {
|
|
25 |
* @param object $lang language
|
26 |
* @return string modified url
|
27 |
*/
|
28 |
-
public function add_language_to_link($url, $lang) {
|
29 |
-
if (!empty($lang))
|
30 |
-
$url = $this->options['default_lang'] == $lang->slug && $this->options['hide_default'] ? $url : str_replace($this->www, '://'
|
|
|
31 |
return $url;
|
32 |
}
|
33 |
|
@@ -40,13 +41,16 @@ class PLL_Links_Subdomain extends PLL_Links_Permalinks {
|
|
40 |
* @param string $url url to modify
|
41 |
* @return string modified url
|
42 |
*/
|
43 |
-
public function remove_language_from_link($url) {
|
44 |
-
foreach ($this->model->get_languages_list() as $language)
|
45 |
-
if (
|
46 |
$languages[] = $language->slug;
|
|
|
|
|
47 |
|
48 |
-
if (!empty($languages))
|
49 |
-
$url = preg_replace('#:\/\/'
|
|
|
50 |
|
51 |
return $url;
|
52 |
}
|
@@ -60,21 +64,8 @@ class PLL_Links_Subdomain extends PLL_Links_Permalinks {
|
|
60 |
* @return string language slug
|
61 |
*/
|
62 |
public function get_language_from_url() {
|
63 |
-
$pattern = '#('.implode('|', $this->model->get_languages_list(array('fields' => 'slug'))).')\.#';
|
64 |
-
return preg_match($pattern, trailingslashit($_SERVER['HTTP_HOST']), $matches) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
65 |
-
}
|
66 |
-
|
67 |
-
/*
|
68 |
-
* returns the home url
|
69 |
-
* links_model interface
|
70 |
-
*
|
71 |
-
* @since 1.3.1
|
72 |
-
*
|
73 |
-
* @param object $lang PLL_Language object
|
74 |
-
* @return string
|
75 |
-
*/
|
76 |
-
public function home_url($lang) {
|
77 |
-
return $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ? $this->home : $this->add_language_to_link($this->home, $lang);
|
78 |
}
|
79 |
|
80 |
/*
|
@@ -85,8 +76,9 @@ class PLL_Links_Subdomain extends PLL_Links_Permalinks {
|
|
85 |
* @return array list of hosts
|
86 |
*/
|
87 |
public function get_hosts() {
|
88 |
-
foreach ($this->model->get_languages_list() as $lang)
|
89 |
-
$hosts[] = parse_url($this->home_url($lang), PHP_URL_HOST);
|
|
|
90 |
return $hosts;
|
91 |
}
|
92 |
}
|
9 |
*/
|
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 |
/*
|
25 |
* @param object $lang language
|
26 |
* @return string modified url
|
27 |
*/
|
28 |
+
public function add_language_to_link( $url, $lang ) {
|
29 |
+
if ( ! empty( $lang ) ) {
|
30 |
+
$url = $this->options['default_lang'] == $lang->slug && $this->options['hide_default'] ? $url : str_replace( $this->www, '://' . $lang->slug . '.', $url );
|
31 |
+
}
|
32 |
return $url;
|
33 |
}
|
34 |
|
41 |
* @param string $url url to modify
|
42 |
* @return string modified url
|
43 |
*/
|
44 |
+
public function remove_language_from_link( $url ) {
|
45 |
+
foreach ( $this->model->get_languages_list() as $language ) {
|
46 |
+
if ( ! $this->options['hide_default'] || $this->options['default_lang'] != $language->slug ) {
|
47 |
$languages[] = $language->slug;
|
48 |
+
}
|
49 |
+
}
|
50 |
|
51 |
+
if ( ! empty( $languages ) ) {
|
52 |
+
$url = preg_replace( '#:\/\/(' . implode( '|', $languages ) . ')\.#', $this->www, $url );
|
53 |
+
}
|
54 |
|
55 |
return $url;
|
56 |
}
|
64 |
* @return string language slug
|
65 |
*/
|
66 |
public function get_language_from_url() {
|
67 |
+
$pattern = '#('.implode( '|', $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ).')\.#';
|
68 |
+
return preg_match( $pattern, trailingslashit( $_SERVER['HTTP_HOST'] ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
|
71 |
/*
|
76 |
* @return array list of hosts
|
77 |
*/
|
78 |
public function get_hosts() {
|
79 |
+
foreach ( $this->model->get_languages_list() as $lang ) {
|
80 |
+
$hosts[] = parse_url( $this->home_url( $lang ), PHP_URL_HOST );
|
81 |
+
}
|
82 |
return $hosts;
|
83 |
}
|
84 |
}
|
include/links.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
/*
|
4 |
-
* manages links
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
@@ -15,135 +15,10 @@ class PLL_Links {
|
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
-
public function __construct(&$polylang) {
|
19 |
$this->links_model = &$polylang->links_model;
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->options = &$polylang->options;
|
22 |
-
|
23 |
-
// adds our domains or subdomains to allowed hosts for safe redirection
|
24 |
-
add_filter('allowed_redirect_hosts', array(&$this, 'allowed_redirect_hosts'));
|
25 |
-
|
26 |
-
// low priority on links filters to come after any other modifications
|
27 |
-
if ($this->options['force_lang']) {
|
28 |
-
add_filter('post_link', array(&$this, 'post_link'), 20, 2);
|
29 |
-
add_filter('_get_page_link', array(&$this, '_get_page_link'), 20, 2);
|
30 |
-
}
|
31 |
-
|
32 |
-
add_filter('post_type_link', array(&$this, 'post_type_link'), 20, 2);
|
33 |
-
add_filter('term_link', array(&$this, 'term_link'), 20, 3);
|
34 |
-
|
35 |
-
if ($this->options['force_lang'] > 1)
|
36 |
-
add_filter('attachment_link', array(&$this, 'attachment_link'), 20, 2);
|
37 |
-
|
38 |
-
if (3 == $this->options['force_lang'])
|
39 |
-
add_filter('preview_post_link', array(&$this, 'preview_post_link'), 20);
|
40 |
-
}
|
41 |
-
|
42 |
-
/*
|
43 |
-
* adds our domains or subdomains to allowed hosts for safe redirection
|
44 |
-
*
|
45 |
-
* @since 1.4.3
|
46 |
-
*
|
47 |
-
* @param array $hosts allowed hosts
|
48 |
-
* @return array
|
49 |
-
*/
|
50 |
-
public function allowed_redirect_hosts($hosts) {
|
51 |
-
return array_unique(array_merge($hosts, $this->links_model->get_hosts()));
|
52 |
-
}
|
53 |
-
|
54 |
-
/*
|
55 |
-
* modifies post & page links
|
56 |
-
*
|
57 |
-
* @since 0.7
|
58 |
-
*
|
59 |
-
* @param string $link post link
|
60 |
-
* @param object $post post object
|
61 |
-
* @return string modified post link
|
62 |
-
*/
|
63 |
-
public function post_link($link, $post) {
|
64 |
-
// /!\ WP does not use pretty permalinks for preview
|
65 |
-
return ($query = parse_url($link, PHP_URL_QUERY)) && false !== strpos($query, 'p=') ? $link : $this->links_model->add_language_to_link($link, $this->model->get_post_language($post->ID));
|
66 |
-
}
|
67 |
-
|
68 |
-
|
69 |
-
/*
|
70 |
-
* modifies page links
|
71 |
-
*
|
72 |
-
* @since 1.7
|
73 |
-
*
|
74 |
-
* @param string $link post link
|
75 |
-
* @param int $post_id post ID
|
76 |
-
* @return string modified post link
|
77 |
-
*/
|
78 |
-
public function _get_page_link($link, $post_id) {
|
79 |
-
// /!\ WP does not use pretty permalinks for preview
|
80 |
-
return ($query = parse_url($link, PHP_URL_QUERY)) && false !== strpos($query, 'page_id=') ? $link : $this->links_model->add_language_to_link($link, $this->model->get_post_language($post_id));
|
81 |
-
}
|
82 |
-
|
83 |
-
/*
|
84 |
-
* modifies attachment links
|
85 |
-
*
|
86 |
-
* @since 1.6.2
|
87 |
-
*
|
88 |
-
* @param string $link attachment link
|
89 |
-
* @param int $post_id attachment link
|
90 |
-
* @return string modified attachment link
|
91 |
-
*/
|
92 |
-
public function attachment_link($link, $post_id) {
|
93 |
-
return $this->links_model->add_language_to_link($link, $this->model->get_post_language($post_id));
|
94 |
-
}
|
95 |
-
|
96 |
-
/*
|
97 |
-
* modifies custom posts links
|
98 |
-
*
|
99 |
-
* @since 1.6
|
100 |
-
*
|
101 |
-
* @param string $link post link
|
102 |
-
* @param object $post post object
|
103 |
-
* @return string modified post link
|
104 |
-
*/
|
105 |
-
public function post_type_link($link, $post) {
|
106 |
-
// /!\ WP does not use pretty permalinks for preview
|
107 |
-
$query = parse_url($link, PHP_URL_QUERY);
|
108 |
-
if ((!$query || false === strpos($query, 'p=')) && $this->model->is_translated_post_type($post->post_type)) {
|
109 |
-
$lang = $this->model->get_post_language($post->ID);
|
110 |
-
$link = $this->options['force_lang'] ? $this->links_model->add_language_to_link($link, $lang) : $link;
|
111 |
-
$link = apply_filters('pll_post_type_link', $link, $lang, $post);
|
112 |
-
}
|
113 |
-
|
114 |
-
return $link;
|
115 |
-
}
|
116 |
-
|
117 |
-
/*
|
118 |
-
* modifies term link
|
119 |
-
*
|
120 |
-
* @since 0.7
|
121 |
-
*
|
122 |
-
* @param string $link term link
|
123 |
-
* @param object $post term object
|
124 |
-
* @param string $tax taxonomy name
|
125 |
-
* @return string modified term link
|
126 |
-
*/
|
127 |
-
public function term_link($link, $term, $tax) {
|
128 |
-
if ($this->model->is_translated_taxonomy($tax)) {
|
129 |
-
$lang = $this->model->get_term_language($term->term_id);
|
130 |
-
$link = $this->options['force_lang'] ? $this->links_model->add_language_to_link($link, $lang) : $link;
|
131 |
-
$link = apply_filters('pll_term_link', $link, $lang, $term);
|
132 |
-
}
|
133 |
-
|
134 |
-
return $link;
|
135 |
-
}
|
136 |
-
|
137 |
-
/*
|
138 |
-
* FIXME: keeps the preview post link on default domain when using multiple domains
|
139 |
-
*
|
140 |
-
* @since 1.6.1
|
141 |
-
*
|
142 |
-
* @param string $url
|
143 |
-
* @return string modified url
|
144 |
-
*/
|
145 |
-
public function preview_post_link($url) {
|
146 |
-
return $this->links_model->remove_language_from_link($url);
|
147 |
}
|
148 |
|
149 |
/*
|
@@ -154,66 +29,11 @@ class PLL_Links {
|
|
154 |
* @param object|string $language
|
155 |
* @param bool $is_search optional wether we need the home url for a search form, defaults to false
|
156 |
*/
|
157 |
-
public function get_home_url($language, $is_search = false) {
|
158 |
-
$language = is_object($language) ? $language : $this->model->get_language($language);
|
159 |
return $is_search ? $language->search_url : $language->home_url;
|
160 |
}
|
161 |
|
162 |
-
/*
|
163 |
-
* get the link to create a new post translation
|
164 |
-
*
|
165 |
-
* @since 1.5
|
166 |
-
*
|
167 |
-
* @param int $post_id
|
168 |
-
* @param object $language
|
169 |
-
* @return string
|
170 |
-
*/
|
171 |
-
public function get_new_post_translation_link($post_id, $language) {
|
172 |
-
$post_type = get_post_type($post_id);
|
173 |
-
|
174 |
-
if ('attachment' == $post_type) {
|
175 |
-
$args = array(
|
176 |
-
'action' => 'translate_media',
|
177 |
-
'from_media' => $post_id,
|
178 |
-
'new_lang' => $language->slug
|
179 |
-
);
|
180 |
-
|
181 |
-
// add nonce for media as we will directly publish a new attachment from a clic on this link
|
182 |
-
return wp_nonce_url(add_query_arg($args, admin_url('admin.php')), 'translate_media');
|
183 |
-
}
|
184 |
-
else {
|
185 |
-
$args = array(
|
186 |
-
'post_type' => $post_type,
|
187 |
-
'from_post' => $post_id,
|
188 |
-
'new_lang' => $language->slug
|
189 |
-
);
|
190 |
-
|
191 |
-
return add_query_arg($args, admin_url('post-new.php'));
|
192 |
-
}
|
193 |
-
}
|
194 |
-
|
195 |
-
/*
|
196 |
-
* get the link to create a new term translation
|
197 |
-
*
|
198 |
-
* @since 1.5
|
199 |
-
*
|
200 |
-
* @param int $term_id
|
201 |
-
* @param string $taxonomy
|
202 |
-
* @param string $post_type
|
203 |
-
* @param object $language
|
204 |
-
* @return string
|
205 |
-
*/
|
206 |
-
public function get_new_term_translation_link($term_id, $taxonomy, $post_type, $language) {
|
207 |
-
$args = array(
|
208 |
-
'taxonomy' => $taxonomy,
|
209 |
-
'post_type' => $post_type,
|
210 |
-
'from_tag' => $term_id,
|
211 |
-
'new_lang' => $language->slug
|
212 |
-
);
|
213 |
-
|
214 |
-
return add_query_arg($args, admin_url('edit-tags.php'));
|
215 |
-
}
|
216 |
-
|
217 |
/*
|
218 |
* checks if the current user can read the post
|
219 |
*
|
@@ -222,14 +42,14 @@ class PLL_Links {
|
|
222 |
* @param int $post_id
|
223 |
* @return bool
|
224 |
*/
|
225 |
-
public function current_user_can_read($post_id) {
|
226 |
-
$post = get_post($post_id);
|
227 |
-
if (in_array($post->post_status, get_post_stati(array('public' => true))))
|
228 |
return true;
|
|
|
229 |
|
230 |
-
$post_type_object = get_post_type_object($post->post_type);
|
231 |
$user = wp_get_current_user();
|
232 |
-
return is_user_logged_in() && (current_user_can($post_type_object->cap->read_private_posts) || $user->ID == $post->post_author);
|
233 |
}
|
234 |
}
|
235 |
-
|
1 |
<?php
|
2 |
|
3 |
/*
|
4 |
+
* manages links related functions
|
5 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
15 |
*
|
16 |
* @param object $polylang
|
17 |
*/
|
18 |
+
public function __construct( &$polylang ) {
|
19 |
$this->links_model = &$polylang->links_model;
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->options = &$polylang->options;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
/*
|
29 |
* @param object|string $language
|
30 |
* @param bool $is_search optional wether we need the home url for a search form, defaults to false
|
31 |
*/
|
32 |
+
public function get_home_url( $language, $is_search = false ) {
|
33 |
+
$language = is_object( $language ) ? $language : $this->model->get_language( $language );
|
34 |
return $is_search ? $language->search_url : $language->home_url;
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
/*
|
38 |
* checks if the current user can read the post
|
39 |
*
|
42 |
* @param int $post_id
|
43 |
* @return bool
|
44 |
*/
|
45 |
+
public function current_user_can_read( $post_id ) {
|
46 |
+
$post = get_post( $post_id );
|
47 |
+
if ( in_array( $post->post_status, get_post_stati( array( 'public' => true ) ) ) ) {
|
48 |
return true;
|
49 |
+
}
|
50 |
|
51 |
+
$post_type_object = get_post_type_object( $post->post_type );
|
52 |
$user = wp_get_current_user();
|
53 |
+
return is_user_logged_in() && ( current_user_can( $post_type_object->cap->read_private_posts ) || $user->ID == $post->post_author );
|
54 |
}
|
55 |
}
|
|
include/mo.php
CHANGED
@@ -13,8 +13,9 @@ class PLL_MO extends MO {
|
|
13 |
* @since 1.2
|
14 |
*/
|
15 |
public function __construct() {
|
16 |
-
if (!post_type_exists('polylang_mo'))
|
17 |
-
register_post_type('polylang_mo', array('rewrite' => false, 'query_var' => false, '_pll' => true));
|
|
|
18 |
}
|
19 |
|
20 |
/*
|
@@ -24,27 +25,25 @@ class PLL_MO extends MO {
|
|
24 |
*
|
25 |
* @param object $lang the language in which we want to export strings
|
26 |
*/
|
27 |
-
public function export_to_db($lang) {
|
28 |
-
$this->add_entry($this->make_entry('', '')); // empty string translation, just in case
|
29 |
|
30 |
// would be convenient to store the whole object but it would take a huge space in DB
|
31 |
// so let's keep only the strings in an array
|
32 |
$strings = array();
|
33 |
-
foreach ($this->entries as $entry)
|
34 |
-
$strings[] = array($entry->singular, $this->translate($entry->singular));
|
35 |
-
|
36 |
-
$post = get_post($lang->mo_id, ARRAY_A); // wp_insert_post wants an array
|
37 |
|
38 |
-
|
39 |
-
$GLOBALS['polylang']->model->clean_languages_cache(); // to set mo_id
|
40 |
|
41 |
$post['post_title'] = 'polylang_mo_' . $lang->term_id;
|
42 |
// json_encode would take less space but is slower to decode
|
43 |
// wp_insert_post expects slashed data
|
44 |
-
$post['post_content'] = addslashes(serialize($strings));
|
45 |
$post['post_status'] = 'private'; // to avoid a conflict with WP Super Cache. See https://wordpress.org/support/topic/polylang_mo-and-404s-take-2
|
46 |
$post['post_type'] = 'polylang_mo';
|
47 |
-
wp_insert_post($post);
|
48 |
}
|
49 |
|
50 |
/*
|
@@ -54,13 +53,14 @@ class PLL_MO extends MO {
|
|
54 |
*
|
55 |
* @param object $lang the language in which we want to get strings
|
56 |
*/
|
57 |
-
public function import_from_db($lang) {
|
58 |
-
if (!empty($lang->mo_id)) {
|
59 |
-
$post = get_post($lang->mo_id, OBJECT);
|
60 |
-
$strings = unserialize($post->post_content);
|
61 |
-
if (is_array($strings)) {
|
62 |
-
foreach ($strings as $msg)
|
63 |
-
$this->add_entry($this->make_entry($msg[0], $msg[1]));
|
|
|
64 |
}
|
65 |
}
|
66 |
}
|
@@ -73,8 +73,8 @@ class PLL_MO extends MO {
|
|
73 |
* @param object $lang
|
74 |
* @return int
|
75 |
*/
|
76 |
-
public static function get_id($lang) {
|
77 |
global $wpdb;
|
78 |
-
return $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", 'polylang_mo_' . $lang->term_id, 'polylang_mo'));
|
79 |
}
|
80 |
}
|
13 |
* @since 1.2
|
14 |
*/
|
15 |
public function __construct() {
|
16 |
+
if ( ! post_type_exists( 'polylang_mo' ) ) {
|
17 |
+
register_post_type( 'polylang_mo', array( 'rewrite' => false, 'query_var' => false, '_pll' => true ) );
|
18 |
+
}
|
19 |
}
|
20 |
|
21 |
/*
|
25 |
*
|
26 |
* @param object $lang the language in which we want to export strings
|
27 |
*/
|
28 |
+
public function export_to_db( $lang ) {
|
29 |
+
$this->add_entry( $this->make_entry( '', '' ) ); // empty string translation, just in case
|
30 |
|
31 |
// would be convenient to store the whole object but it would take a huge space in DB
|
32 |
// so let's keep only the strings in an array
|
33 |
$strings = array();
|
34 |
+
foreach ( $this->entries as $entry ) {
|
35 |
+
$strings[] = array( $entry->singular, $this->translate( $entry->singular ) );
|
36 |
+
}
|
|
|
37 |
|
38 |
+
$post = get_post( $lang->mo_id, ARRAY_A ); // wp_insert_post wants an array
|
|
|
39 |
|
40 |
$post['post_title'] = 'polylang_mo_' . $lang->term_id;
|
41 |
// json_encode would take less space but is slower to decode
|
42 |
// wp_insert_post expects slashed data
|
43 |
+
$post['post_content'] = addslashes( serialize( $strings ) );
|
44 |
$post['post_status'] = 'private'; // to avoid a conflict with WP Super Cache. See https://wordpress.org/support/topic/polylang_mo-and-404s-take-2
|
45 |
$post['post_type'] = 'polylang_mo';
|
46 |
+
wp_insert_post( $post );
|
47 |
}
|
48 |
|
49 |
/*
|
53 |
*
|
54 |
* @param object $lang the language in which we want to get strings
|
55 |
*/
|
56 |
+
public function import_from_db( $lang ) {
|
57 |
+
if ( ! empty( $lang->mo_id ) ) {
|
58 |
+
$post = get_post( $lang->mo_id, OBJECT );
|
59 |
+
$strings = unserialize( $post->post_content );
|
60 |
+
if ( is_array( $strings ) ) {
|
61 |
+
foreach ( $strings as $msg ) {
|
62 |
+
$this->add_entry( $this->make_entry( $msg[0], $msg[1] ) );
|
63 |
+
}
|
64 |
}
|
65 |
}
|
66 |
}
|
73 |
* @param object $lang
|
74 |
* @return int
|
75 |
*/
|
76 |
+
public static function get_id( $lang ) {
|
77 |
global $wpdb;
|
78 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", 'polylang_mo_' . $lang->term_id, 'polylang_mo' ) );
|
79 |
}
|
80 |
}
|
include/model.php
CHANGED
@@ -6,8 +6,9 @@
|
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Model {
|
|
|
9 |
public $options;
|
10 |
-
|
11 |
|
12 |
/*
|
13 |
* constructor: registers custom taxonomies and setups filters and actions
|
@@ -16,156 +17,67 @@ class PLL_Model {
|
|
16 |
*
|
17 |
* @param array $options Polylang options
|
18 |
*/
|
19 |
-
public function __construct(&$options) {
|
20 |
$this->options = &$options;
|
21 |
-
$this->cache = new PLL_Cache();
|
22 |
-
|
23 |
-
// register our taxonomies as soon as possible
|
24 |
-
// this is early registration, not ready for rewrite rules as wp_rewrite will be setup later
|
25 |
-
$args = array('label' => false, 'public' => false, 'query_var' => false, 'rewrite' => false, '_pll' => true);
|
26 |
-
register_taxonomy('language', null, $args);
|
27 |
-
register_taxonomy('term_language', 'term', $args);
|
28 |
-
register_taxonomy('term_translations', 'term', $args);
|
29 |
-
$args['update_count_callback'] = '_update_generic_term_count'; // count *all* posts to avoid deleting in clean_translations_terms
|
30 |
-
register_taxonomy('post_translations', null, $args);
|
31 |
-
|
32 |
-
add_filter('get_terms', array(&$this, '_prime_terms_cache'), 10, 2);
|
33 |
-
add_filter('wp_get_object_terms', array(&$this, 'wp_get_object_terms'), 10, 3);
|
34 |
-
|
35 |
-
// we need to clean languages cache when editing a language,
|
36 |
-
// when editing page of front, page for posts or when modifying the permalink structure
|
37 |
-
add_action('edited_term_taxonomy', array(&$this, 'clean_languages_cache'), 10, 2);
|
38 |
-
add_action('update_option_page_on_front', array(&$this, 'clean_languages_cache'));
|
39 |
-
add_action('update_option_page_for_posts', array(&$this, 'clean_languages_cache'));
|
40 |
-
add_action('update_option_permalink_structure', array(&$this, 'clean_languages_cache'));
|
41 |
-
add_action('update_option_siteurl', array(&$this, 'clean_languages_cache'));
|
42 |
-
add_action('update_option_home', array(&$this, 'clean_languages_cache'));
|
43 |
-
|
44 |
-
// registers completely the language taxonomy
|
45 |
-
add_action('setup_theme', array(&$this, 'register_taxonomy'), 1);
|
46 |
-
|
47 |
-
// setups post types to translate
|
48 |
-
add_action('registered_post_type', array(&$this, 'registered_post_type'));
|
49 |
-
|
50 |
-
// just in case someone would like to display the language description ;-)
|
51 |
-
add_filter('language_description', '__return_empty_string');
|
52 |
-
}
|
53 |
-
|
54 |
-
/*
|
55 |
-
* cache language and translations when terms are queried by get_terms
|
56 |
-
*
|
57 |
-
* @since 1.2
|
58 |
-
*
|
59 |
-
* @param array $terms queried terms
|
60 |
-
* @param array $taxonomies queried taxonomies
|
61 |
-
* @return array unmodified $terms
|
62 |
-
*/
|
63 |
-
public function _prime_terms_cache($terms, $taxonomies) {
|
64 |
-
if ($this->is_translated_taxonomy($taxonomies)) {
|
65 |
-
foreach ($terms as $term) {
|
66 |
-
$term_ids[] = is_object($term) ? $term->term_id : (int) $term;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
if (!empty($term_ids))
|
71 |
-
update_object_term_cache(array_unique($term_ids), 'term'); // adds language and translation of terms to cache
|
72 |
-
return $terms;
|
73 |
-
}
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
* @since 1.2
|
79 |
-
*
|
80 |
-
* @param array $terms terms found
|
81 |
-
* @param array $object_ids not used
|
82 |
-
* @param array $taxonomies terms taxonomies
|
83 |
-
* @return array unmodified $terms
|
84 |
-
*/
|
85 |
-
public function wp_get_object_terms($terms, $object_ids, $taxonomies) {
|
86 |
-
$taxonomies = explode("', '", trim($taxonomies, "'"));
|
87 |
-
if (!in_array('term_translations', $taxonomies))
|
88 |
-
$this->_prime_terms_cache($terms, $taxonomies);
|
89 |
-
return $terms;
|
90 |
-
}
|
91 |
-
|
92 |
-
/*
|
93 |
-
* wrap wp_get_object_terms to cache it and return only one object
|
94 |
-
* inspired by the function get_the_terms
|
95 |
-
*
|
96 |
-
* @since 1.2
|
97 |
-
*
|
98 |
-
* @param int $object_id post_id or term_id
|
99 |
-
* @param string $taxonomy Polylang taxonomy depending if we are looking for a post (or term) language (or translation)
|
100 |
-
* @return bool|object the term associated to the object in the requested taxonomy if exists, false otherwise
|
101 |
-
*/
|
102 |
-
public function get_object_term($object_id, $taxonomy) {
|
103 |
-
if (empty($object_id))
|
104 |
-
return false;
|
105 |
-
|
106 |
-
$object_id = (int) $object_id;
|
107 |
-
$term = get_object_term_cache($object_id, $taxonomy);
|
108 |
-
|
109 |
-
if (false === $term) {
|
110 |
-
// query language and translations at the same time
|
111 |
-
$taxonomies = (false !== strpos($taxonomy, 'term_')) ?
|
112 |
-
array('term_language', 'term_translations') :
|
113 |
-
array('language', 'post_translations');
|
114 |
-
|
115 |
-
// query terms
|
116 |
-
foreach (wp_get_object_terms($object_id, $taxonomies) as $t) {
|
117 |
-
$terms[$t->taxonomy] = $t;
|
118 |
-
if ($t->taxonomy == $taxonomy)
|
119 |
-
$term = $t;
|
120 |
-
}
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
}
|
128 |
-
else {
|
129 |
-
$term = reset($term);
|
130 |
-
}
|
131 |
|
132 |
-
|
|
|
133 |
}
|
134 |
|
135 |
/*
|
136 |
* returns the list of available languages
|
137 |
-
* caches the list in a db transient (except flags), unless PLL_CACHE_LANGUAGES is set to false
|
138 |
-
* caches the list (with flags) in the private property $languages
|
139 |
*
|
140 |
* list of parameters accepted in $args:
|
141 |
*
|
142 |
-
* hide_empty => hides languages with no posts if set to true (defaults to false)
|
143 |
-
* fields => return only that field if set (see PLL_Language for a list of fields)
|
144 |
*
|
145 |
* @since 0.1
|
146 |
*
|
147 |
* @param array $args
|
148 |
* @return array|string|int list of PLL_Language objects or PLL_Language object properties
|
149 |
*/
|
150 |
-
public function get_languages_list($args = array()) {
|
151 |
-
if (false === $languages = $this->cache->get('languages')) {
|
152 |
|
153 |
// create the languages from taxonomies
|
154 |
-
if ((defined('PLL_CACHE_LANGUAGES') && !PLL_CACHE_LANGUAGES) || false === ($languages = get_transient('pll_languages_list'))) {
|
155 |
-
$languages = get_terms('language', array('hide_empty' => false, 'orderby'=> 'term_group'));
|
156 |
-
$languages = empty($languages) || is_wp_error($languages) ? array() : $languages;
|
157 |
|
158 |
-
$term_languages = get_terms('term_language', array('hide_empty' => false));
|
159 |
-
$term_languages = empty($term_languages) || is_wp_error($term_languages) ?
|
160 |
-
array() : array_combine(wp_list_pluck($term_languages, 'slug'), $term_languages);
|
161 |
|
162 |
-
if (!empty($languages) && !empty($term_languages)) {
|
163 |
// don't use array_map + create_function to instantiate an autoloaded class as it breaks badly in old versions of PHP
|
164 |
-
foreach ($languages as $k => $v) {
|
165 |
-
$languages[$k] = new PLL_Language($v, $term_languages['pll_' . $v->slug]);
|
166 |
}
|
167 |
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
}
|
170 |
else {
|
171 |
$languages = array(); // in case something went wrong
|
@@ -174,57 +86,32 @@ class PLL_Model {
|
|
174 |
|
175 |
// create the languages directly from arrays stored in transients
|
176 |
else {
|
177 |
-
foreach ($languages as $k => $v) {
|
178 |
-
$languages[$k] = new PLL_Language($v);
|
179 |
}
|
180 |
}
|
181 |
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
-
//
|
185 |
-
|
|
|
|
|
186 |
}
|
187 |
|
188 |
-
$args = wp_parse_args($args, array('hide_empty' => false));
|
189 |
|
190 |
// remove empty languages if requested
|
191 |
-
|
192 |
-
|
193 |
-
return empty($args['fields']) ? $languages : wp_list_pluck($languages, $args['fields']);
|
194 |
-
}
|
195 |
-
|
196 |
-
/*
|
197 |
-
* fills home urls and flags in language list and set transient in db
|
198 |
-
* delayed to be sure we have access to $wp_rewrite for home urls
|
199 |
-
* languages objects are not cached in db if PLL_CACHE_LANGUAGES is set to false
|
200 |
-
* home urls are not cached in db if PLL_CACHE_HOME_URL is set to false
|
201 |
-
*
|
202 |
-
* @since 1.4
|
203 |
-
*/
|
204 |
-
public function _languages_list() {
|
205 |
-
// cache the languages after getting the home urls
|
206 |
-
if ((!defined('PLL_CACHE_LANGUAGES') || PLL_CACHE_LANGUAGES) && false === get_transient('pll_languages_list')) {
|
207 |
-
foreach ($languages = $this->cache->get('languages') as $language)
|
208 |
-
$language->set_home_url();
|
209 |
-
|
210 |
-
// don't store directly objects as it badly break with some hosts (GoDaddy) due to race conditions when using object cache
|
211 |
-
// thanks to captin411 for catching this!
|
212 |
-
// see https://wordpress.org/support/topic/fatal-error-pll_model_languages_list?replies=8#post-6782255
|
213 |
-
set_transient('pll_languages_list', array_map(create_function('$o', 'return (array) $o;'), $languages));
|
214 |
}
|
215 |
|
216 |
-
|
217 |
-
// get the home urls when not cached
|
218 |
-
if ((defined('PLL_CACHE_LANGUAGES') && !PLL_CACHE_LANGUAGES) || (defined('PLL_CACHE_HOME_URL') && !PLL_CACHE_HOME_URL))
|
219 |
-
$language->set_home_url();
|
220 |
-
|
221 |
-
// ensures that the (possibly cached) home url uses the right scheme http or https
|
222 |
-
$language->set_home_url_scheme();
|
223 |
-
|
224 |
-
// use custom flags on frontend only
|
225 |
-
if (!PLL_ADMIN)
|
226 |
-
$language->set_custom_flag();
|
227 |
-
}
|
228 |
}
|
229 |
|
230 |
/*
|
@@ -237,15 +124,15 @@ class PLL_Model {
|
|
237 |
* @param int $term not used
|
238 |
* @param string $taxonomy taxonomy name
|
239 |
*/
|
240 |
-
public function clean_languages_cache($term = 0, $taxonomy = null) {
|
241 |
// depending on WP version, the action is passed an object or a string
|
242 |
// backward compatibility with WP < 4.2
|
243 |
-
if ( !empty($taxonomy) && is_object($taxonomy) ) {
|
244 |
$taxonomy = $taxonomy->name;
|
245 |
}
|
246 |
|
247 |
-
if (empty($taxonomy) || 'language' == $taxonomy) {
|
248 |
-
delete_transient('pll_languages_list');
|
249 |
$this->cache->clean();
|
250 |
}
|
251 |
}
|
@@ -258,307 +145,22 @@ class PLL_Model {
|
|
258 |
* @param int|string term_id, tl_term_id, slug or locale of the queried language
|
259 |
* @return object|bool PLL_Language object, false if no language found
|
260 |
*/
|
261 |
-
public function get_language($value) {
|
262 |
-
if (is_object($value))
|
263 |
-
return $this->get_language($value->term_id); // will force cast to PLL_Language
|
264 |
-
|
265 |
-
if (false === $return = $this->cache->get('language:' . $value)) {
|
266 |
-
foreach ($this->get_languages_list() as $lang) {
|
267 |
-
$this->cache->set('language:' . $lang->term_id, $lang);
|
268 |
-
$this->cache->set('language:' . $lang->tl_term_id, $lang);
|
269 |
-
$this->cache->set('language:' . $lang->slug, $lang);
|
270 |
-
$this->cache->set('language:' . $lang->locale, $lang);
|
271 |
-
}
|
272 |
-
$return = $this->cache->get('language:' . $value);
|
273 |
-
}
|
274 |
-
|
275 |
-
return $return;
|
276 |
-
}
|
277 |
-
|
278 |
-
/*
|
279 |
-
* saves translations for posts or terms
|
280 |
-
*
|
281 |
-
* @since 0.5
|
282 |
-
*
|
283 |
-
* @param string $type either 'post' or 'term'
|
284 |
-
* @param int $id post id or term id
|
285 |
-
* @param array $translations: an associative array of translations with language code as key and translation id as value
|
286 |
-
*/
|
287 |
-
public function save_translations($type, $id, $translations) {
|
288 |
-
$id = (int) $id;
|
289 |
-
|
290 |
-
if (($lang = call_user_func(array(&$this, 'get_'.$type.'_language'), $id)) && isset($translations) && is_array($translations)) {
|
291 |
-
// sanitize the translations array
|
292 |
-
$translations = array_map('intval', $translations);
|
293 |
-
$translations = array_merge(array($lang->slug => $id), $translations); // make sure this object is in translations
|
294 |
-
$translations = array_diff($translations, array(0)); // don't keep non translated languages
|
295 |
-
$translations = array_intersect_key($translations, array_flip($this->get_languages_list(array('fields' => 'slug')))); // keep only valid languages slugs as keys
|
296 |
-
|
297 |
-
// unlink removed translations
|
298 |
-
$old_translations = $this->get_translations($type, $id);
|
299 |
-
foreach (array_diff_assoc($old_translations, $translations) as $object_id)
|
300 |
-
$this->delete_translation($type, $object_id);
|
301 |
-
|
302 |
-
// don't create a translation group for untranslated posts as it is useless
|
303 |
-
// but we need one for terms to allow relationships remap when importing from a WXR file
|
304 |
-
if ('term' == $type || count($translations) > 1) {
|
305 |
-
$terms = wp_get_object_terms($translations, $type . '_translations');
|
306 |
-
$term = reset($terms);
|
307 |
-
|
308 |
-
// create a new term if necessary
|
309 |
-
if (empty($term)) {
|
310 |
-
wp_insert_term($group = uniqid('pll_'), $type . '_translations', array('description' => serialize($translations)));
|
311 |
-
}
|
312 |
-
else {
|
313 |
-
// take care not to overwrite extra data stored in description field, if any
|
314 |
-
$d = unserialize($term->description);
|
315 |
-
$d = is_array($d) ? array_diff_key($d, $old_translations) : array(); // remove old translations
|
316 |
-
$d = array_merge($d, $translations); // add new one
|
317 |
-
wp_update_term($group = (int) $term->term_id, $type . '_translations', array('description' => serialize($d)));
|
318 |
-
}
|
319 |
-
|
320 |
-
// link all translations to the new term
|
321 |
-
foreach($translations as $p)
|
322 |
-
wp_set_object_terms($p, $group, $type . '_translations');
|
323 |
-
|
324 |
-
// clean now unused translation groups
|
325 |
-
foreach (wp_list_pluck($terms, 'term_id') as $term_id) {
|
326 |
-
$term = get_term($term_id, $type . '_translations');
|
327 |
-
if (empty($term->count))
|
328 |
-
wp_delete_term($term_id, $type . '_translations');
|
329 |
-
}
|
330 |
-
}
|
331 |
}
|
332 |
-
}
|
333 |
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
* @param int $id post id or term id
|
341 |
-
*/
|
342 |
-
public function delete_translation($type, $id) {
|
343 |
-
global $wpdb;
|
344 |
-
$id = (int) $id;
|
345 |
-
$term = $this->get_object_term($id, $type . '_translations');
|
346 |
-
|
347 |
-
if (!empty($term)) {
|
348 |
-
$d = unserialize($term->description);
|
349 |
-
$slug = array_search($id, $this->get_translations($type, $id)); // in case some plugin stores the same value with different key
|
350 |
-
unset($d[$slug]);
|
351 |
-
|
352 |
-
if (empty($d))
|
353 |
-
wp_delete_term((int) $term->term_id, $type . '_translations');
|
354 |
-
else
|
355 |
-
wp_update_term((int) $term->term_id, $type . '_translations', array('description' => serialize($d)));
|
356 |
-
|
357 |
-
if ('post' == $type)
|
358 |
-
wp_set_object_terms($id, null, $type . '_translations');
|
359 |
-
|
360 |
-
elseif ($wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->terms WHERE term_id = %d;", $id))) {
|
361 |
-
// always keep a group for terms to allow relationships remap when importing from a WXR file
|
362 |
-
$translations[$slug] = $id;
|
363 |
-
wp_insert_term($group = uniqid('pll_'), $type . '_translations', array('description' => serialize($translations)));
|
364 |
-
wp_set_object_terms($id, $group, $type . '_translations');
|
365 |
}
|
|
|
366 |
}
|
367 |
-
}
|
368 |
-
|
369 |
-
/*
|
370 |
-
* returns the id of the translation of a post or term
|
371 |
-
*
|
372 |
-
* @since 0.5
|
373 |
-
*
|
374 |
-
* @param string $type either 'post' or 'term'
|
375 |
-
* @param int $id post id or term id
|
376 |
-
* @param object|string $lang object or slug
|
377 |
-
* @return bool|int post id or term id of the translation, flase if there is none
|
378 |
-
*/
|
379 |
-
public function get_translation($type, $id, $lang) {
|
380 |
-
if (!$lang = $this->get_language($lang))
|
381 |
-
return false;
|
382 |
-
|
383 |
-
$translations = $this->get_translations($type, $id);
|
384 |
-
|
385 |
-
return isset($translations[$lang->slug]) ? $translations[$lang->slug] : false;
|
386 |
-
}
|
387 |
-
|
388 |
-
/*
|
389 |
-
* returns an array of translations of a post or term
|
390 |
-
*
|
391 |
-
* @since 0.5
|
392 |
-
*
|
393 |
-
* @param string $type either 'post' or 'term'
|
394 |
-
* @param int $id post id or term id
|
395 |
-
* @return array an associative array of translations with language code as key and translation id as value
|
396 |
-
*/
|
397 |
-
public function get_translations($type, $id) {
|
398 |
-
$type = ($type == 'post' || $this->is_translated_post_type($type)) ? 'post' : (($type == 'term' || $this->is_translated_taxonomy($type)) ? 'term' : false);
|
399 |
-
$translations = $type && ($term = $this->get_object_term($id, $type . '_translations')) && !empty($term) ? unserialize($term->description) : array();
|
400 |
-
|
401 |
-
// make sure we return only translations (thus we allow plugins to store other informations in the array)
|
402 |
-
$translations = array_intersect_key($translations, array_flip($this->get_languages_list(array('fields' => 'slug'))));
|
403 |
-
|
404 |
-
// make sure to return at least the passed post or term in its translation array
|
405 |
-
if (empty($translations) && $type && $lang = call_user_func(array(&$this, 'get_'.$type.'_language'), $id))
|
406 |
-
$translations = array($lang->slug => $id);
|
407 |
-
|
408 |
-
return $translations;
|
409 |
-
}
|
410 |
-
|
411 |
-
/*
|
412 |
-
* store the post language in the database
|
413 |
-
*
|
414 |
-
* @since 0.6
|
415 |
-
*
|
416 |
-
* @param int $post_id post id
|
417 |
-
* @param int|string|object language (term_id or slug or object)
|
418 |
-
*/
|
419 |
-
public function set_post_language($post_id, $lang) {
|
420 |
-
wp_set_post_terms((int) $post_id, $lang ? $this->get_language($lang)->slug : '', 'language' );
|
421 |
-
}
|
422 |
-
|
423 |
-
/*
|
424 |
-
* returns the language of a post
|
425 |
-
*
|
426 |
-
* @since 0.1
|
427 |
-
*
|
428 |
-
* @param int $post_id post id
|
429 |
-
* @return bool|object PLL_Language object, false if no language is associated to that post
|
430 |
-
*/
|
431 |
-
public function get_post_language($post_id) {
|
432 |
-
$lang = $this->get_object_term($post_id, 'language' );
|
433 |
-
return ($lang) ? $this->get_language($lang) : false;
|
434 |
-
}
|
435 |
-
|
436 |
-
/*
|
437 |
-
* among the post and its translations, returns the id of the post which is in $lang
|
438 |
-
*
|
439 |
-
* @since 0.1
|
440 |
-
*
|
441 |
-
* @param int $post_id post id
|
442 |
-
* @param int|string|object language (term_id or slug or object)
|
443 |
-
* @return bool|int the translation post id if exists, otherwise the post id, false if the post has no language
|
444 |
-
*/
|
445 |
-
public function get_post($post_id, $lang) {
|
446 |
-
$post_lang = $this->get_post_language($post_id);
|
447 |
-
if (!$lang || !$post_lang)
|
448 |
-
return false;
|
449 |
|
450 |
-
|
451 |
-
return $post_lang->term_id == $lang->term_id ? $post_id : $this->get_translation('post', $post_id, $lang);
|
452 |
-
}
|
453 |
-
|
454 |
-
/*
|
455 |
-
* stores the term language in the database
|
456 |
-
*
|
457 |
-
* @since 0.6
|
458 |
-
*
|
459 |
-
* @param int $term_id term id
|
460 |
-
* @param int|string|object language (term_id or slug or object)
|
461 |
-
*/
|
462 |
-
public function set_term_language($term_id, $lang) {
|
463 |
-
$term_id = (int) $term_id;
|
464 |
-
wp_set_object_terms($term_id, $lang ? $this->get_language($lang)->tl_term_id : '', 'term_language');
|
465 |
-
|
466 |
-
// add translation group for correct WXR export
|
467 |
-
$translations = $this->get_translations('term', $term_id);
|
468 |
-
if ($slug = array_search($term_id, $translations))
|
469 |
-
unset($translations[$slug]);
|
470 |
-
|
471 |
-
$this->save_translations('term', $term_id, $translations);
|
472 |
-
}
|
473 |
-
|
474 |
-
/*
|
475 |
-
* removes the term language in database
|
476 |
-
*
|
477 |
-
* @since 0.5
|
478 |
-
*
|
479 |
-
* @param int $term_id term id
|
480 |
-
*/
|
481 |
-
public function delete_term_language($term_id) {
|
482 |
-
wp_delete_object_term_relationships($term_id, 'term_language');
|
483 |
-
}
|
484 |
-
|
485 |
-
/*
|
486 |
-
* returns the language of a term
|
487 |
-
*
|
488 |
-
* @since 0.1
|
489 |
-
*
|
490 |
-
* @param int|string $value term id or term slug
|
491 |
-
* @param string $taxonomy optional taxonomy needed when the term slug is passed as first parameter
|
492 |
-
* @return bool|object PLL_Language object, false if no language is associated to that term
|
493 |
-
*/
|
494 |
-
public function get_term_language($value, $taxonomy = '') {
|
495 |
-
if (is_numeric($value))
|
496 |
-
$term_id = $value;
|
497 |
-
|
498 |
-
// get_term_by still not cached in WP 3.5.1 but internally, the function is always called by term_id
|
499 |
-
elseif (is_string($value) && $taxonomy)
|
500 |
-
$term_id = get_term_by('slug', $value , $taxonomy)->term_id;
|
501 |
-
|
502 |
-
// get the language and make sure it is a PLL_Language object
|
503 |
-
return isset($term_id) && ($lang = $this->get_object_term($term_id, 'term_language')) ? $this->get_language($lang->term_id) : false;
|
504 |
-
}
|
505 |
-
|
506 |
-
/*
|
507 |
-
* among the term and its translations, returns the id of the term which is in $lang
|
508 |
-
*
|
509 |
-
* @since 0.1
|
510 |
-
*
|
511 |
-
* @param int $term_id term id
|
512 |
-
* @param int|string|object language (term_id or slug or object)
|
513 |
-
* @return bool|int the translation term id if exists, otherwise the term id, false if the term has no language
|
514 |
-
*/
|
515 |
-
public function get_term($term_id, $lang) {
|
516 |
-
$lg = $this->get_term_language($term_id); // FIXME is this necessary?
|
517 |
-
if (!$lang || !$lg)
|
518 |
-
return false;
|
519 |
-
|
520 |
-
$lang = $this->get_language($lang);
|
521 |
-
return $lg->term_id == $lang->term_id ? $term_id : $this->get_translation('term', $term_id, $lang);
|
522 |
-
}
|
523 |
-
|
524 |
-
/*
|
525 |
-
* a join clause to add to sql queries when filtering by language is needed directly in query
|
526 |
-
*
|
527 |
-
* @since 1.2
|
528 |
-
*
|
529 |
-
* @param string $type either 'post' or 'term'
|
530 |
-
* @return string join clause
|
531 |
-
*/
|
532 |
-
public function join_clause($type) {
|
533 |
-
global $wpdb;
|
534 |
-
return " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = " . ('term' == $type ? "t.term_id" : "ID");
|
535 |
-
}
|
536 |
-
|
537 |
-
/*
|
538 |
-
* a where clause to add to sql queries when filtering by language is needed directly in query
|
539 |
-
*
|
540 |
-
* @since 1.2
|
541 |
-
*
|
542 |
-
* @param object|array|string $lang a PLL_Language object or a comma separated list of languag slug or an array of language slugs
|
543 |
-
* @param string $type either 'post' or 'term'
|
544 |
-
* @return string where clause
|
545 |
-
*/
|
546 |
-
public function where_clause($lang, $type) {
|
547 |
-
global $wpdb;
|
548 |
-
$tt_id = 'term' == $type ? 'tl_term_taxonomy_id' : 'term_taxonomy_id';
|
549 |
-
|
550 |
-
// $lang is an object
|
551 |
-
// generally the case if the query is coming from Polylang
|
552 |
-
if (is_object($lang))
|
553 |
-
return $wpdb->prepare(" AND pll_tr.term_taxonomy_id = %d", $lang->$tt_id);
|
554 |
-
|
555 |
-
// $lang is a comma separated list of slugs (or an array of slugs)
|
556 |
-
// generally the case is the query is coming from outside with 'lang' parameter
|
557 |
-
$slugs = is_array($lang) ? $lang : explode(',', $lang);
|
558 |
-
foreach ($slugs as $slug)
|
559 |
-
$languages[] = (int) $this->get_language($slug)->$tt_id;
|
560 |
-
|
561 |
-
return " AND pll_tr.term_taxonomy_id IN (" . implode(',', $languages) . ")";
|
562 |
}
|
563 |
|
564 |
/*
|
@@ -570,36 +172,14 @@ class PLL_Model {
|
|
570 |
* @param object $lang PLL_Language object
|
571 |
* @return array modifed list of clauses
|
572 |
*/
|
573 |
-
public function terms_clauses($clauses, $lang) {
|
574 |
-
if (!empty($lang)) {
|
575 |
-
$clauses['join'] .= $this->join_clause(
|
576 |
-
$clauses['where'] .= $this->where_clause($lang
|
577 |
}
|
578 |
return $clauses;
|
579 |
}
|
580 |
|
581 |
-
/*
|
582 |
-
* register the language taxonomy
|
583 |
-
*
|
584 |
-
* @since 1.2
|
585 |
-
*/
|
586 |
-
public function register_taxonomy() {
|
587 |
-
// registers the language taxonomy
|
588 |
-
register_taxonomy('language', $this->get_translated_post_types(), array(
|
589 |
-
'labels' => array(
|
590 |
-
'name' => __('Languages', 'polylang'),
|
591 |
-
'singular_name' => __('Language', 'polylang'),
|
592 |
-
'all_items' => __('All languages', 'polylang'),
|
593 |
-
),
|
594 |
-
'public' => true, // since WP 4.4 we must set it to true for WP to accept our query var
|
595 |
-
'show_ui' => false,
|
596 |
-
'show_in_nav_menus' => false,
|
597 |
-
'query_var' => 'lang',
|
598 |
-
'rewrite' => $this->options['force_lang'] < 2, // no rewrite for domains and sub-domains
|
599 |
-
'_pll' => true // polylang taxonomy
|
600 |
-
));
|
601 |
-
}
|
602 |
-
|
603 |
/*
|
604 |
* returns post types that need to be translated
|
605 |
* the post types list is cached for better better performance
|
@@ -610,37 +190,26 @@ class PLL_Model {
|
|
610 |
* @param bool $filter true if we should return only valid registered post types
|
611 |
* @return array post type names for which Polylang manages languages and translations
|
612 |
*/
|
613 |
-
public function get_translated_post_types($filter = true) {
|
614 |
-
if (
|
615 |
-
|
616 |
-
|
617 |
-
if (empty($post_types)) {
|
618 |
-
$post_types = array('post' => 'post', 'page' => 'page');
|
619 |
|
620 |
-
if (!empty($this->options['media_support']))
|
621 |
$post_types['attachement'] = 'attachment';
|
|
|
622 |
|
623 |
-
if (!empty($this->options['post_types']) && is_array($this->options['post_types']))
|
624 |
-
$post_types = array_merge($post_types, array_combine($this->options['post_types'], $this->options['post_types']));
|
625 |
-
|
626 |
-
$post_types = apply_filters('pll_get_post_types', $post_types , false);
|
627 |
-
}
|
628 |
|
629 |
-
|
630 |
-
}
|
631 |
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
* @since 1.2
|
636 |
-
*
|
637 |
-
* @param string $post_type post type name
|
638 |
-
*/
|
639 |
-
public function registered_post_type($post_type) {
|
640 |
-
if ($this->is_translated_post_type($post_type)) {
|
641 |
-
register_taxonomy_for_object_type('language', $post_type);
|
642 |
-
register_taxonomy_for_object_type('post_translations', $post_type);
|
643 |
}
|
|
|
|
|
644 |
}
|
645 |
|
646 |
/*
|
@@ -651,9 +220,9 @@ class PLL_Model {
|
|
651 |
* @param string|array $post_type post type name or array of post type names
|
652 |
* @return bool
|
653 |
*/
|
654 |
-
public function is_translated_post_type($post_type) {
|
655 |
-
$post_types = $this->get_translated_post_types(false);
|
656 |
-
return (is_array($post_type) && array_intersect($post_type, $post_types) || in_array($post_type, $post_types));
|
657 |
}
|
658 |
|
659 |
/*
|
@@ -664,20 +233,21 @@ class PLL_Model {
|
|
664 |
* @param bool $filter true if we should return only valid registered taxonmies
|
665 |
* @return array array of registered taxonomy names for which Polylang manages languages and translations
|
666 |
*/
|
667 |
-
public function get_translated_taxonomies($filter = true) {
|
668 |
-
if (
|
669 |
-
|
670 |
-
|
671 |
-
if (empty($taxonomies)) {
|
672 |
-
$taxonomies = array('category' => 'category', 'post_tag' => 'post_tag');
|
673 |
|
674 |
-
if (!empty($this->options['taxonomies']) && is_array($this->options['taxonomies']))
|
675 |
-
$taxonomies = array_merge($taxonomies, array_combine($this->options['taxonomies'], $this->options['taxonomies']));
|
|
|
676 |
|
677 |
-
$taxonomies = apply_filters('pll_get_taxonomies', $taxonomies, false);
|
|
|
|
|
|
|
678 |
}
|
679 |
|
680 |
-
return $filter ? array_intersect($taxonomies, get_taxonomies()) : $taxonomies;
|
681 |
}
|
682 |
|
683 |
/*
|
@@ -688,29 +258,30 @@ class PLL_Model {
|
|
688 |
* @param string|array $tax taxonomy name or array of taxonomy names
|
689 |
* @return bool
|
690 |
*/
|
691 |
-
public function is_translated_taxonomy($tax) {
|
692 |
-
$taxonomies = $this->get_translated_taxonomies(false);
|
693 |
-
return (is_array($tax) && array_intersect($tax, $taxonomies) || in_array($tax, $taxonomies));
|
694 |
}
|
695 |
|
696 |
/*
|
697 |
-
* return taxonomies that need to be filtered (post_format like)
|
698 |
*
|
699 |
* @since 1.7
|
700 |
*
|
701 |
* @param bool $filter true if we should return only valid registered taxonomies
|
702 |
* @return array array of registered taxonomy names
|
703 |
*/
|
704 |
-
public function get_filtered_taxonomies($filter = true) {
|
705 |
-
if (did_action('after_setup_theme'))
|
706 |
static $taxonomies = null;
|
|
|
707 |
|
708 |
-
if (empty($taxonomies)) {
|
709 |
-
$taxonomies = array('post_format' => 'post_format');
|
710 |
-
$taxonomies = apply_filters('pll_filtered_taxonomies', $taxonomies, false);
|
711 |
}
|
712 |
|
713 |
-
return $filter ? array_intersect($taxonomies, get_taxonomies()) : $taxonomies;
|
714 |
}
|
715 |
|
716 |
/*
|
@@ -721,9 +292,9 @@ class PLL_Model {
|
|
721 |
* @param string|array $tax taxonomy name or array of taxonomy names
|
722 |
* @return bool
|
723 |
*/
|
724 |
-
public function is_filtered_taxonomy($tax) {
|
725 |
-
$taxonomies = $this->get_filtered_taxonomies(false);
|
726 |
-
return (is_array($tax) && array_intersect($tax, $taxonomies) || in_array($tax, $taxonomies));
|
727 |
}
|
728 |
|
729 |
/*
|
@@ -735,8 +306,8 @@ class PLL_Model {
|
|
735 |
*/
|
736 |
public function get_filtered_taxonomies_query_vars() {
|
737 |
$query_vars = array();
|
738 |
-
foreach ($this->get_filtered_taxonomies() as $filtered_tax) {
|
739 |
-
$tax = get_taxonomy($filtered_tax);
|
740 |
$query_vars[] = $tax->query_var;
|
741 |
}
|
742 |
return $query_vars;
|
@@ -749,36 +320,38 @@ class PLL_Model {
|
|
749 |
*
|
750 |
* @param object|string|int $lang language
|
751 |
*/
|
752 |
-
public function create_default_category($lang) {
|
753 |
-
$lang = $this->get_language($lang);
|
754 |
|
755 |
// create a new category
|
756 |
// FIXME this is translated in admin language when we would like it in $lang
|
757 |
-
$cat_name = __('Uncategorized');
|
758 |
-
$cat_slug = sanitize_title($cat_name . '-' . $lang->slug);
|
759 |
-
$cat = wp_insert_term($cat_name, 'category', array('slug' => $cat_slug));
|
760 |
|
761 |
-
// check that the category was not previously created (in case the language was deleted and recreated)
|
762 |
-
$cat = isset($cat->error_data['term_exists']) ? $cat->error_data['term_exists'] : $cat['term_id'];
|
763 |
|
764 |
// set language
|
765 |
-
$this->
|
766 |
|
767 |
// this is a translation of the default category
|
768 |
-
$default = (int) get_option('default_category');
|
769 |
-
$translations = $this->get_translations(
|
770 |
-
if (empty($translations)) {
|
771 |
-
if ($lg = $this->
|
772 |
-
$translations[$lg->slug] = $default;
|
773 |
-
|
|
|
774 |
$translations = array();
|
|
|
775 |
}
|
776 |
|
777 |
-
$this->save_translations(
|
778 |
}
|
779 |
|
780 |
/*
|
781 |
-
* it is possible to have several terms with the same name in the same taxonomy (one per language)
|
782 |
* but the native term_exists will return true even if only one exists
|
783 |
* so here the function adds the language parameter
|
784 |
*
|
@@ -790,21 +363,22 @@ class PLL_Model {
|
|
790 |
* @param string|object $language the language slug or object
|
791 |
* @return null|int the term_id of the found term
|
792 |
*/
|
793 |
-
public function term_exists($term_name, $taxonomy, $parent, $language) {
|
794 |
global $wpdb;
|
795 |
|
796 |
-
$term_name = trim(wp_unslash($term_name));
|
797 |
|
798 |
$select = "SELECT t.term_id FROM $wpdb->terms AS t";
|
799 |
$join = " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
|
800 |
-
$join .= $this->join_clause(
|
801 |
-
$where = $wpdb->prepare(" WHERE tt.taxonomy = %s AND t.name = %s", $taxonomy, $term_name);
|
802 |
-
$where .= $this->where_clause($this->get_language($language)
|
803 |
|
804 |
-
if ($parent > 0)
|
805 |
-
$where .= $wpdb->prepare(" AND tt.parent = %d", $parent);
|
|
|
806 |
|
807 |
-
return $wpdb->get_var($select . $join . $where);
|
808 |
}
|
809 |
|
810 |
/*
|
@@ -813,97 +387,90 @@ class PLL_Model {
|
|
813 |
* @since 1.2
|
814 |
*
|
815 |
* @param object lang
|
816 |
-
* @param array $q WP_Query arguments (accepted: post_type, m, year, monthnum, day, author, author_name, post_format)
|
817 |
* @return int
|
818 |
*/
|
819 |
-
public function count_posts($lang, $q = array()) {
|
820 |
global $wpdb;
|
821 |
|
822 |
-
if (!is_array($q['post_type']))
|
823 |
-
$q['post_type'] = array($q['post_type']);
|
|
|
824 |
|
825 |
-
foreach ($q['post_type'] as $key => $type) {
|
826 |
-
if (!post_type_exists($type))
|
827 |
-
unset($q['post_type'][$key]);
|
|
|
828 |
}
|
829 |
|
830 |
-
if (empty($q['post_type']))
|
831 |
-
$q['post_type'] = array('post'); // we *need* a post type
|
|
|
832 |
|
833 |
-
$cache_key = md5(serialize($q));
|
834 |
-
$counts = wp_cache_get($cache_key, 'pll_count_posts');
|
835 |
|
836 |
-
if (false === $counts) {
|
837 |
-
$select = "SELECT pll_tr.term_taxonomy_id, COUNT(*) AS num_posts FROM {$wpdb->posts} AS p";
|
838 |
-
$join = $this->join_clause(
|
839 |
$where = " WHERE post_status = 'publish'";
|
840 |
-
$where .= $wpdb->prepare(" AND p.post_type IN ('%s')", join("', '", $q['post_type']));
|
841 |
-
$where .= $this->where_clause($this->get_languages_list()
|
842 |
$groupby = " GROUP BY pll_tr.term_taxonomy_id";
|
843 |
|
844 |
-
if (!empty($q['m'])) {
|
845 |
-
$q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']);
|
846 |
-
$where .= $wpdb->prepare(" AND YEAR(p.post_date) = %d", substr($q['m'], 0, 4));
|
847 |
-
if ( strlen($q['m']) > 5 )
|
848 |
-
$where .= $wpdb->prepare(" AND MONTH(p.post_date) = %d", substr($q['m'], 4, 2));
|
849 |
-
|
850 |
-
|
|
|
|
|
851 |
}
|
852 |
|
853 |
-
if (!empty($q['year']))
|
854 |
-
$where .= $wpdb->prepare(" AND YEAR(p.post_date) = %d", $q['year']);
|
|
|
855 |
|
856 |
-
if (!empty($q['monthnum']))
|
857 |
-
$where .= $wpdb->prepare(" AND MONTH(p.post_date) = %d", $q['monthnum']);
|
|
|
858 |
|
859 |
-
if (!empty($q['day']))
|
860 |
-
$where .= $wpdb->prepare(" AND DAYOFMONTH(p.post_date) = %d", $q['day']);
|
|
|
861 |
|
862 |
-
if (!empty($q['author_name'])) {
|
863 |
-
$author = get_user_by('slug', sanitize_title_for_query($q['author_name']));
|
864 |
-
if ($author)
|
865 |
$q['author'] = $author->ID;
|
|
|
866 |
}
|
867 |
|
868 |
-
if (!empty($q['author']))
|
869 |
-
$where .= $wpdb->prepare(" AND p.post_author = %d", $q['author']);
|
|
|
870 |
|
871 |
-
// filtered taxonomies (post_format)
|
872 |
-
foreach ($this->get_filtered_taxonomies_query_vars() as $tax_qv) {
|
873 |
-
if (!empty($q[$tax_qv])) {
|
874 |
$join .= " INNER JOIN {$wpdb->term_relationships} AS tr ON tr.object_id = p.ID";
|
875 |
$join .= " INNER JOIN {$wpdb->term_taxonomy} AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id";
|
876 |
$join .= " INNER JOIN {$wpdb->terms} AS t ON t.term_id = tt.term_id";
|
877 |
-
$where .= $wpdb->prepare(" AND t.slug = %s", $q[$tax_qv]);
|
878 |
}
|
879 |
}
|
880 |
|
881 |
-
$res = $wpdb->get_results($select . $join . $where . $groupby, ARRAY_A);
|
882 |
-
foreach ((array) $res as $row)
|
883 |
-
$counts[$row['term_taxonomy_id']] = $row['num_posts'];
|
|
|
884 |
|
885 |
-
wp_cache_set($cache_key, $counts, 'pll_count_posts');
|
886 |
}
|
887 |
|
888 |
-
return empty($counts[$lang->term_taxonomy_id]) ? 0 : $counts[$lang->term_taxonomy_id];
|
889 |
-
}
|
890 |
-
|
891 |
-
/*
|
892 |
-
* returns ids of objects in a language similarly to get_objects_in_term for a taxonomy
|
893 |
-
* faster than get_objects_in_term as it avoids a JOIN
|
894 |
-
*
|
895 |
-
* @since 1.4
|
896 |
-
*
|
897 |
-
* @param object $lang a PLL_Language object
|
898 |
-
* @param string $type optional, either 'post' or 'term', defaults to 'post'
|
899 |
-
* @return array
|
900 |
-
*/
|
901 |
-
public function get_objects_in_language($lang, $type = 'post') {
|
902 |
-
global $wpdb;
|
903 |
-
return $wpdb->get_col($wpdb->prepare("
|
904 |
-
SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d",
|
905 |
-
'term' == $type ? $lang->tl_term_taxonomy_id : $lang->term_taxonomy_id
|
906 |
-
));
|
907 |
}
|
908 |
|
909 |
/*
|
@@ -914,12 +481,71 @@ class PLL_Model {
|
|
914 |
* @return object implementing "links_model interface"
|
915 |
*/
|
916 |
public function get_links_model() {
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
922 |
}
|
923 |
-
|
|
|
|
|
924 |
}
|
925 |
}
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Model {
|
9 |
+
public $cache; // our internal non persistent cache object
|
10 |
public $options;
|
11 |
+
public $post, $term; // translated objects models
|
12 |
|
13 |
/*
|
14 |
* constructor: registers custom taxonomies and setups filters and actions
|
17 |
*
|
18 |
* @param array $options Polylang options
|
19 |
*/
|
20 |
+
public function __construct( &$options ) {
|
21 |
$this->options = &$options;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
$this->cache = new PLL_Cache();
|
24 |
+
$this->post = new PLL_Translated_Post( $this ); // translated post sub model
|
25 |
+
$this->term = new PLL_Translated_Term( $this ); // translated term sub model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
// we need to clean languages cache when editing a language and when modifying the permalink structure
|
28 |
+
add_action( 'edited_term_taxonomy', array( &$this, 'clean_languages_cache' ), 10, 2 );
|
29 |
+
add_action( 'update_option_permalink_structure', array( &$this, 'clean_languages_cache' ) );
|
30 |
+
add_action( 'update_option_siteurl', array( &$this, 'clean_languages_cache' ) );
|
31 |
+
add_action( 'update_option_home', array( &$this, 'clean_languages_cache' ) );
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
// just in case someone would like to display the language description ;- )
|
34 |
+
add_filter( 'language_description', '__return_empty_string' );
|
35 |
}
|
36 |
|
37 |
/*
|
38 |
* returns the list of available languages
|
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 |
*
|
42 |
* list of parameters accepted in $args:
|
43 |
*
|
44 |
+
* hide_empty => hides languages with no posts if set to true ( defaults to false )
|
45 |
+
* fields => return only that field if set ( see PLL_Language for a list of fields )
|
46 |
*
|
47 |
* @since 0.1
|
48 |
*
|
49 |
* @param array $args
|
50 |
* @return array|string|int list of PLL_Language objects or PLL_Language object properties
|
51 |
*/
|
52 |
+
public function get_languages_list( $args = array() ) {
|
53 |
+
if ( false === $languages = $this->cache->get( 'languages' ) ) {
|
54 |
|
55 |
// create the languages from taxonomies
|
56 |
+
if ( ( defined( 'PLL_CACHE_LANGUAGES' ) && ! PLL_CACHE_LANGUAGES ) || false === ( $languages = get_transient( 'pll_languages_list' ) ) ) {
|
57 |
+
$languages = get_terms( 'language', array( 'hide_empty' => false, 'orderby' => 'term_group' ) );
|
58 |
+
$languages = empty( $languages ) || is_wp_error( $languages ) ? array() : $languages;
|
59 |
|
60 |
+
$term_languages = get_terms( 'term_language', array( 'hide_empty' => false ) );
|
61 |
+
$term_languages = empty( $term_languages ) || is_wp_error( $term_languages ) ?
|
62 |
+
array() : array_combine( wp_list_pluck( $term_languages, 'slug' ), $term_languages );
|
63 |
|
64 |
+
if ( ! empty( $languages ) && ! empty( $term_languages ) ) {
|
65 |
// don't use array_map + create_function to instantiate an autoloaded class as it breaks badly in old versions of PHP
|
66 |
+
foreach ( $languages as $k => $v ) {
|
67 |
+
$languages[ $k ] = new PLL_Language( $v, $term_languages[ 'pll_' . $v->slug ] );
|
68 |
}
|
69 |
|
70 |
+
// we will need the languages list to allow its access in the filter below
|
71 |
+
$this->cache->set( 'languages', $languages );
|
72 |
+
|
73 |
+
// filters the list of languages *before* it is stored in the persistent cache
|
74 |
+
// /!\ this filter is fired *before* the $polylang object is available
|
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
|
78 |
+
// thanks to captin411 for catching this!
|
79 |
+
// see https://wordpress.org/support/topic/fatal-error-pll_model_languages_list?replies=8#post-6782255;
|
80 |
+
set_transient( 'pll_languages_list', array_map( 'get_object_vars', $languages ) );
|
81 |
}
|
82 |
else {
|
83 |
$languages = array(); // in case something went wrong
|
86 |
|
87 |
// create the languages directly from arrays stored in transients
|
88 |
else {
|
89 |
+
foreach ( $languages as $k => $v ) {
|
90 |
+
$languages[ $k ] = new PLL_Language( $v );
|
91 |
}
|
92 |
}
|
93 |
|
94 |
+
// custom flags
|
95 |
+
if ( ! PLL_ADMIN ) {
|
96 |
+
foreach ( $languages as $language ) {
|
97 |
+
$language->set_custom_flag();
|
98 |
+
}
|
99 |
+
}
|
100 |
|
101 |
+
// filters the list of languages *after* it is stored in the persistent cache
|
102 |
+
// /!\ this filter is fired *before* the $polylang object is available
|
103 |
+
$languages = apply_filters( 'pll_after_languages_cache', $languages );
|
104 |
+
$this->cache->set( 'languages', $languages );
|
105 |
}
|
106 |
|
107 |
+
$args = wp_parse_args( $args, array( 'hide_empty' => false ) );
|
108 |
|
109 |
// remove empty languages if requested
|
110 |
+
if ( $args['hide_empty'] ) {
|
111 |
+
$languages = wp_list_filter( $languages, array( 'count' => 0 ), 'NOT' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
|
114 |
+
return empty( $args['fields'] ) ? $languages : wp_list_pluck( $languages, $args['fields'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
|
117 |
/*
|
124 |
* @param int $term not used
|
125 |
* @param string $taxonomy taxonomy name
|
126 |
*/
|
127 |
+
public function clean_languages_cache( $term = 0, $taxonomy = null ) {
|
128 |
// depending on WP version, the action is passed an object or a string
|
129 |
// backward compatibility with WP < 4.2
|
130 |
+
if ( ! empty( $taxonomy ) && is_object( $taxonomy ) ) {
|
131 |
$taxonomy = $taxonomy->name;
|
132 |
}
|
133 |
|
134 |
+
if ( empty( $taxonomy ) || 'language' == $taxonomy ) {
|
135 |
+
delete_transient( 'pll_languages_list' );
|
136 |
$this->cache->clean();
|
137 |
}
|
138 |
}
|
145 |
* @param int|string term_id, tl_term_id, slug or locale of the queried language
|
146 |
* @return object|bool PLL_Language object, false if no language found
|
147 |
*/
|
148 |
+
public function get_language( $value ) {
|
149 |
+
if ( is_object( $value ) ) {
|
150 |
+
return $value instanceof PLL_Language ? $value : $this->get_language( $value->term_id ); // will force cast to PLL_Language
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
|
|
152 |
|
153 |
+
if ( false === $return = $this->cache->get( 'language:' . $value ) ) {
|
154 |
+
foreach ( $this->get_languages_list() as $lang ) {
|
155 |
+
$this->cache->set( 'language:' . $lang->term_id, $lang );
|
156 |
+
$this->cache->set( 'language:' . $lang->tl_term_id, $lang );
|
157 |
+
$this->cache->set( 'language:' . $lang->slug, $lang );
|
158 |
+
$this->cache->set( 'language:' . $lang->locale, $lang );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
+
$return = $this->cache->get( 'language:' . $value );
|
161 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
+
return $return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
}
|
165 |
|
166 |
/*
|
172 |
* @param object $lang PLL_Language object
|
173 |
* @return array modifed list of clauses
|
174 |
*/
|
175 |
+
public function terms_clauses( $clauses, $lang ) {
|
176 |
+
if ( ! empty( $lang ) ) {
|
177 |
+
$clauses['join'] .= $this->term->join_clause();
|
178 |
+
$clauses['where'] .= $this->term->where_clause( $lang );
|
179 |
}
|
180 |
return $clauses;
|
181 |
}
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
/*
|
184 |
* returns post types that need to be translated
|
185 |
* the post types list is cached for better better performance
|
190 |
* @param bool $filter true if we should return only valid registered post types
|
191 |
* @return array post type names for which Polylang manages languages and translations
|
192 |
*/
|
193 |
+
public function get_translated_post_types( $filter = true ) {
|
194 |
+
if ( false === $post_types = $this->cache->get( 'post_types' ) ) {
|
195 |
+
$post_types = array( 'post' => 'post', 'page' => 'page' );
|
|
|
|
|
|
|
196 |
|
197 |
+
if ( ! empty( $this->options['media_support'] ) ) {
|
198 |
$post_types['attachement'] = 'attachment';
|
199 |
+
}
|
200 |
|
201 |
+
if ( ! empty( $this->options['post_types'] ) && is_array( $this->options['post_types'] ) ) {
|
202 |
+
$post_types = array_merge( $post_types, array_combine( $this->options['post_types'], $this->options['post_types'] ) );
|
203 |
+
}
|
|
|
|
|
204 |
|
205 |
+
$post_types = apply_filters( 'pll_get_post_types', $post_types , false );
|
|
|
206 |
|
207 |
+
if ( did_action( 'after_setup_theme' ) ) {
|
208 |
+
$this->cache->set( 'post_types', $post_types );
|
209 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
}
|
211 |
+
|
212 |
+
return $filter ? array_intersect( $post_types, get_post_types() ) : $post_types;
|
213 |
}
|
214 |
|
215 |
/*
|
220 |
* @param string|array $post_type post type name or array of post type names
|
221 |
* @return bool
|
222 |
*/
|
223 |
+
public function is_translated_post_type( $post_type ) {
|
224 |
+
$post_types = $this->get_translated_post_types( false );
|
225 |
+
return ( is_array( $post_type ) && array_intersect( $post_type, $post_types ) || in_array( $post_type, $post_types ) );
|
226 |
}
|
227 |
|
228 |
/*
|
233 |
* @param bool $filter true if we should return only valid registered taxonmies
|
234 |
* @return array array of registered taxonomy names for which Polylang manages languages and translations
|
235 |
*/
|
236 |
+
public function get_translated_taxonomies( $filter = true ) {
|
237 |
+
if ( false === $taxonomies = $this->cache->get( 'taxonomies' ) ) {
|
238 |
+
$taxonomies = array( 'category' => 'category', 'post_tag' => 'post_tag' );
|
|
|
|
|
|
|
239 |
|
240 |
+
if ( ! empty( $this->options['taxonomies'] ) && is_array( $this->options['taxonomies'] ) ) {
|
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 );
|
247 |
+
}
|
248 |
}
|
249 |
|
250 |
+
return $filter ? array_intersect( $taxonomies, get_taxonomies() ) : $taxonomies;
|
251 |
}
|
252 |
|
253 |
/*
|
258 |
* @param string|array $tax taxonomy name or array of taxonomy names
|
259 |
* @return bool
|
260 |
*/
|
261 |
+
public function is_translated_taxonomy( $tax ) {
|
262 |
+
$taxonomies = $this->get_translated_taxonomies( false );
|
263 |
+
return ( is_array( $tax ) && array_intersect( $tax, $taxonomies ) || in_array( $tax, $taxonomies ) );
|
264 |
}
|
265 |
|
266 |
/*
|
267 |
+
* return taxonomies that need to be filtered ( post_format like )
|
268 |
*
|
269 |
* @since 1.7
|
270 |
*
|
271 |
* @param bool $filter true if we should return only valid registered taxonomies
|
272 |
* @return array array of registered taxonomy names
|
273 |
*/
|
274 |
+
public function get_filtered_taxonomies( $filter = true ) {
|
275 |
+
if ( did_action( 'after_setup_theme' ) ) {
|
276 |
static $taxonomies = null;
|
277 |
+
}
|
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 |
/*
|
292 |
* @param string|array $tax taxonomy name or array of taxonomy names
|
293 |
* @return bool
|
294 |
*/
|
295 |
+
public function is_filtered_taxonomy( $tax ) {
|
296 |
+
$taxonomies = $this->get_filtered_taxonomies( false );
|
297 |
+
return ( is_array( $tax ) && array_intersect( $tax, $taxonomies ) || in_array( $tax, $taxonomies ) );
|
298 |
}
|
299 |
|
300 |
/*
|
306 |
*/
|
307 |
public function get_filtered_taxonomies_query_vars() {
|
308 |
$query_vars = array();
|
309 |
+
foreach ( $this->get_filtered_taxonomies() as $filtered_tax ) {
|
310 |
+
$tax = get_taxonomy( $filtered_tax );
|
311 |
$query_vars[] = $tax->query_var;
|
312 |
}
|
313 |
return $query_vars;
|
320 |
*
|
321 |
* @param object|string|int $lang language
|
322 |
*/
|
323 |
+
public function create_default_category( $lang ) {
|
324 |
+
$lang = $this->get_language( $lang );
|
325 |
|
326 |
// create a new category
|
327 |
// FIXME this is translated in admin language when we would like it in $lang
|
328 |
+
$cat_name = __( 'Uncategorized' );
|
329 |
+
$cat_slug = sanitize_title( $cat_name . '-' . $lang->slug );
|
330 |
+
$cat = wp_insert_term( $cat_name, 'category', array( 'slug' => $cat_slug ) );
|
331 |
|
332 |
+
// check that the category was not previously created ( in case the language was deleted and recreated )
|
333 |
+
$cat = isset( $cat->error_data['term_exists'] ) ? $cat->error_data['term_exists'] : $cat['term_id'];
|
334 |
|
335 |
// set language
|
336 |
+
$this->term->set_language( (int) $cat, $lang );
|
337 |
|
338 |
// this is a translation of the default category
|
339 |
+
$default = (int) get_option( 'default_category' );
|
340 |
+
$translations = $this->term->get_translations( $default );
|
341 |
+
if ( empty( $translations ) ) {
|
342 |
+
if ( $lg = $this->term->get_language( $default ) ) {
|
343 |
+
$translations[ $lg->slug ] = $default;
|
344 |
+
}
|
345 |
+
else {
|
346 |
$translations = array();
|
347 |
+
}
|
348 |
}
|
349 |
|
350 |
+
$this->term->save_translations( (int) $cat, $translations );
|
351 |
}
|
352 |
|
353 |
/*
|
354 |
+
* it is possible to have several terms with the same name in the same taxonomy ( one per language )
|
355 |
* but the native term_exists will return true even if only one exists
|
356 |
* so here the function adds the language parameter
|
357 |
*
|
363 |
* @param string|object $language the language slug or object
|
364 |
* @return null|int the term_id of the found term
|
365 |
*/
|
366 |
+
public function term_exists( $term_name, $taxonomy, $parent, $language ) {
|
367 |
global $wpdb;
|
368 |
|
369 |
+
$term_name = trim( wp_unslash( $term_name ) );
|
370 |
|
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( " WHERE tt.taxonomy = %s AND t.name = %s", $taxonomy, $term_name );
|
375 |
+
$where .= $this->term->where_clause( $this->get_language( $language ) );
|
376 |
|
377 |
+
if ( $parent > 0 ) {
|
378 |
+
$where .= $wpdb->prepare( " AND tt.parent = %d", $parent );
|
379 |
+
}
|
380 |
|
381 |
+
return $wpdb->get_var( $select . $join . $where );
|
382 |
}
|
383 |
|
384 |
/*
|
387 |
* @since 1.2
|
388 |
*
|
389 |
* @param object lang
|
390 |
+
* @param array $q WP_Query arguments ( accepted: post_type, m, year, monthnum, day, author, author_name, post_format )
|
391 |
* @return int
|
392 |
*/
|
393 |
+
public function count_posts( $lang, $q = array() ) {
|
394 |
global $wpdb;
|
395 |
|
396 |
+
if ( ! is_array( $q['post_type'] ) ) {
|
397 |
+
$q['post_type'] = array( $q['post_type'] );
|
398 |
+
}
|
399 |
|
400 |
+
foreach ( $q['post_type'] as $key => $type ) {
|
401 |
+
if ( ! post_type_exists( $type ) ) {
|
402 |
+
unset( $q['post_type'][ $key ] );
|
403 |
+
}
|
404 |
}
|
405 |
|
406 |
+
if ( empty( $q['post_type'] ) ) {
|
407 |
+
$q['post_type'] = array( 'post' ); // we *need* a post type
|
408 |
+
}
|
409 |
|
410 |
+
$cache_key = md5( serialize( $q ) );
|
411 |
+
$counts = wp_cache_get( $cache_key, 'pll_count_posts' );
|
412 |
|
413 |
+
if ( false === $counts ) {
|
414 |
+
$select = "SELECT pll_tr.term_taxonomy_id, COUNT( * ) AS num_posts FROM {$wpdb->posts} AS p";
|
415 |
+
$join = $this->post->join_clause();
|
416 |
$where = " WHERE post_status = 'publish'";
|
417 |
+
$where .= $wpdb->prepare( " AND p.post_type IN ( '%s' )", join( "', '", $q['post_type'] ) );
|
418 |
+
$where .= $this->post->where_clause( $this->get_languages_list() );
|
419 |
$groupby = " GROUP BY pll_tr.term_taxonomy_id";
|
420 |
|
421 |
+
if ( ! empty( $q['m'] ) ) {
|
422 |
+
$q['m'] = '' . preg_replace( '|[^0-9]|', '', $q['m'] );
|
423 |
+
$where .= $wpdb->prepare( " AND YEAR( p.post_date ) = %d", substr( $q['m'], 0, 4 ) );
|
424 |
+
if ( strlen( $q['m'] ) > 5 ) {
|
425 |
+
$where .= $wpdb->prepare( " AND MONTH( p.post_date ) = %d", substr( $q['m'], 4, 2 ) );
|
426 |
+
}
|
427 |
+
if ( strlen( $q['m'] ) > 7 ) {
|
428 |
+
$where .= $wpdb->prepare( " AND DAYOFMONTH( p.post_date ) = %d", substr( $q['m'], 6, 2 ) );
|
429 |
+
}
|
430 |
}
|
431 |
|
432 |
+
if ( ! empty( $q['year'] ) ) {
|
433 |
+
$where .= $wpdb->prepare( " AND YEAR( p.post_date ) = %d", $q['year'] );
|
434 |
+
}
|
435 |
|
436 |
+
if ( ! empty( $q['monthnum'] ) ) {
|
437 |
+
$where .= $wpdb->prepare( " AND MONTH( p.post_date ) = %d", $q['monthnum'] );
|
438 |
+
}
|
439 |
|
440 |
+
if ( ! empty( $q['day'] ) ) {
|
441 |
+
$where .= $wpdb->prepare( " AND DAYOFMONTH( p.post_date ) = %d", $q['day'] );
|
442 |
+
}
|
443 |
|
444 |
+
if ( ! empty( $q['author_name'] ) ) {
|
445 |
+
$author = get_user_by( 'slug', sanitize_title_for_query( $q['author_name'] ) );
|
446 |
+
if ( $author ) {
|
447 |
$q['author'] = $author->ID;
|
448 |
+
}
|
449 |
}
|
450 |
|
451 |
+
if ( ! empty( $q['author'] ) ) {
|
452 |
+
$where .= $wpdb->prepare( " AND p.post_author = %d", $q['author'] );
|
453 |
+
}
|
454 |
|
455 |
+
// filtered taxonomies ( post_format )
|
456 |
+
foreach ( $this->get_filtered_taxonomies_query_vars() as $tax_qv ) {
|
457 |
+
if ( ! empty( $q[ $tax_qv ] ) ) {
|
458 |
$join .= " INNER JOIN {$wpdb->term_relationships} AS tr ON tr.object_id = p.ID";
|
459 |
$join .= " INNER JOIN {$wpdb->term_taxonomy} AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id";
|
460 |
$join .= " INNER JOIN {$wpdb->terms} AS t ON t.term_id = tt.term_id";
|
461 |
+
$where .= $wpdb->prepare( " AND t.slug = %s", $q[ $tax_qv ] );
|
462 |
}
|
463 |
}
|
464 |
|
465 |
+
$res = $wpdb->get_results( $select . $join . $where . $groupby, ARRAY_A );
|
466 |
+
foreach ( (array) $res as $row ) {
|
467 |
+
$counts[ $row['term_taxonomy_id'] ] = $row['num_posts'];
|
468 |
+
}
|
469 |
|
470 |
+
wp_cache_set( $cache_key, $counts, 'pll_count_posts' );
|
471 |
}
|
472 |
|
473 |
+
return empty( $counts[ $lang->term_taxonomy_id ] ) ? 0 : $counts[ $lang->term_taxonomy_id ];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
}
|
475 |
|
476 |
/*
|
481 |
* @return object implementing "links_model interface"
|
482 |
*/
|
483 |
public function get_links_model() {
|
484 |
+
$c = array( 'Directory', 'Directory', 'Subdomain', 'Domain' );
|
485 |
+
$class = get_option( 'permalink_structure' ) ? 'PLL_Links_' . $c[ $this->options['force_lang'] ] : 'PLL_Links_Default';
|
486 |
+
return new $class( $this );
|
487 |
+
}
|
488 |
+
|
489 |
+
/*
|
490 |
+
* some backward compatibility with Polylang < 1.8
|
491 |
+
* allows for example to call $polylang->model->get_post_languages( $post_id ) instead of $polylang->model->post->get_language( $post_id )
|
492 |
+
* this works but should be slower than the direct call, thus an error is triggered in debug mode
|
493 |
+
*
|
494 |
+
* @since 1.8
|
495 |
+
*
|
496 |
+
* @param string $func function name
|
497 |
+
* @param array $args function arguments
|
498 |
+
*/
|
499 |
+
public function __call( $func, $args ) {
|
500 |
+
$f = $func;
|
501 |
+
|
502 |
+
switch ( $func ) {
|
503 |
+
case 'get_object_term':
|
504 |
+
$o = false === strpos( $args[1], 'term' ) ? 'post' : 'term';
|
505 |
+
break;
|
506 |
+
|
507 |
+
case 'save_translations':
|
508 |
+
case 'delete_translation':
|
509 |
+
case 'get_translations':
|
510 |
+
case 'get_translation':
|
511 |
+
case 'join_clause':
|
512 |
+
$o = ( 'post' == $args[0] || $this->is_translated_post_type( $args[0] ) ) ? 'post' : ( 'term' == $args[0] || $this->is_translated_taxonomy( $args[0] ) ? 'term' : false );
|
513 |
+
unset( $args[0] );
|
514 |
+
break;
|
515 |
+
|
516 |
+
case 'set_post_language':
|
517 |
+
case 'get_post_language':
|
518 |
+
case 'set_term_language':
|
519 |
+
case 'get_term_language':
|
520 |
+
case 'delete_term_language':
|
521 |
+
case 'get_post':
|
522 |
+
case 'get_term':
|
523 |
+
$str = explode( '_', $func );
|
524 |
+
$f = empty( $str[2] ) ? $str[0] : $str[0] . '_' . $str[2];
|
525 |
+
$o = $str[1];
|
526 |
+
break;
|
527 |
+
|
528 |
+
case 'where_clause':
|
529 |
+
case 'get_objects_in_language':
|
530 |
+
$o = $args[1];
|
531 |
+
unset( $args[1] );
|
532 |
+
break;
|
533 |
+
}
|
534 |
+
|
535 |
+
if ( ! empty( $o ) && is_object( $this->$o ) && method_exists( $this->$o, $f ) ) {
|
536 |
+
if ( WP_DEBUG ) {
|
537 |
+
$debug = debug_backtrace();
|
538 |
+
$i = 1 + empty( $debug[1]['line'] ); // the file and line are in $debug[2] if the function was called using call_user_func
|
539 |
+
|
540 |
+
trigger_error( sprintf(
|
541 |
+
'%1$s was called incorrectly in %4$s on line %5$s: the call to $polylang->model->%1$s() has been deprecated in Polylang 1.8, use PLL()->model->%2$s->%3$s() instead.' . "\nError handler",
|
542 |
+
$func, $o, $f, $debug[ $i ]['file'], $debug[ $i ]['line']
|
543 |
+
) );
|
544 |
+
}
|
545 |
+
return call_user_func_array( array( $this->$o, $f ), $args );
|
546 |
}
|
547 |
+
|
548 |
+
$debug = debug_backtrace();
|
549 |
+
trigger_error( sprintf( 'Call to undefined function PLL()->model->%1$s() in %2$s on line %3$s' . "\nError handler", $func, $debug[0]['file'], $debug[0]['line'] ), E_USER_ERROR );
|
550 |
}
|
551 |
}
|
include/nav-menu.php
CHANGED
@@ -16,16 +16,16 @@ class PLL_Nav_Menu {
|
|
16 |
*
|
17 |
* @param object $polylang
|
18 |
*/
|
19 |
-
public function __construct(&$polylang) {
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->options = &$polylang->options;
|
22 |
|
23 |
// integration with WP customizer
|
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 |
*
|
31 |
* @since 1.2
|
@@ -34,13 +34,46 @@ class PLL_Nav_Menu {
|
|
34 |
static $once;
|
35 |
global $_wp_registered_nav_menus;
|
36 |
|
37 |
-
if (isset($_wp_registered_nav_menus) &&
|
38 |
-
foreach ($_wp_registered_nav_menus as $loc => $name)
|
39 |
-
foreach ($this->model->get_languages_list() as $lang)
|
40 |
-
$arr[$
|
|
|
|
|
41 |
|
42 |
$_wp_registered_nav_menus = $arr;
|
43 |
$once = true;
|
44 |
}
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
16 |
*
|
17 |
* @param object $polylang
|
18 |
*/
|
19 |
+
public function __construct( &$polylang ) {
|
20 |
$this->model = &$polylang->model;
|
21 |
$this->options = &$polylang->options;
|
22 |
|
23 |
// integration with WP customizer
|
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 |
*
|
31 |
* @since 1.2
|
34 |
static $once;
|
35 |
global $_wp_registered_nav_menus;
|
36 |
|
37 |
+
if ( isset( $_wp_registered_nav_menus ) && ! $once ) {
|
38 |
+
foreach ( $_wp_registered_nav_menus as $loc => $name ) {
|
39 |
+
foreach ( $this->model->get_languages_list() as $lang ) {
|
40 |
+
$arr[ $this->combine_location( $loc, $lang ) ] = $name . ' ' . $lang->name;
|
41 |
+
}
|
42 |
+
}
|
43 |
|
44 |
$_wp_registered_nav_menus = $arr;
|
45 |
$once = true;
|
46 |
}
|
47 |
}
|
48 |
+
|
49 |
+
/*
|
50 |
+
* creates a temporary nav menu location from a location and a language
|
51 |
+
*
|
52 |
+
* @since 1.8
|
53 |
+
*
|
54 |
+
* @param string $loc nav menu location
|
55 |
+
* @param object $lang
|
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
|
66 |
+
*
|
67 |
+
* @param string $loc temporary location
|
68 |
+
* @return array
|
69 |
+
* 'location' => nav menu location
|
70 |
+
* 'lang' => language slug
|
71 |
+
*/
|
72 |
+
public function explode_location( $loc ) {
|
73 |
+
$infos = explode( '___', $loc );
|
74 |
+
if ( 1 == count( $infos ) ) {
|
75 |
+
$infos[] = $this->options['default_lang'];
|
76 |
+
}
|
77 |
+
return array_combine( array( 'location', 'lang' ), $infos );
|
78 |
+
}
|
79 |
}
|
include/olt-manager.php
CHANGED
@@ -5,7 +5,7 @@
|
|
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
|
7 |
* this class differs text domain loading until the language is defined
|
8 |
-
* either in a plugins_loaded action or in a wp action (when the language is set from content on frontend)
|
9 |
*
|
10 |
* @since 1.2
|
11 |
*/
|
@@ -25,17 +25,17 @@ class PLL_OLT_Manager {
|
|
25 |
$this->default_locale = get_locale();
|
26 |
|
27 |
// filters for text domain management
|
28 |
-
add_filter('override_load_textdomain', array(&$this, 'mofile'), 10, 3);
|
29 |
-
add_filter('gettext', array(&$this, 'gettext'), 10, 3);
|
30 |
-
add_filter('gettext_with_context', array(&$this, 'gettext_with_context'), 10, 4);
|
31 |
|
32 |
// loads text domains
|
33 |
-
add_action('pll_language_defined', array(&$this, 'load_textdomains'), 2); // after PLL_Frontend::pll_language_defined
|
34 |
-
add_action('pll_no_language_defined', array(&$this, 'load_textdomains'));
|
35 |
|
36 |
-
// allows Polylang to be the first plugin loaded ;-)
|
37 |
-
add_filter('pre_update_option_active_plugins', array(&$this, 'make_polylang_first'));
|
38 |
-
add_filter('pre_update_option_active_sitewide_plugins', array(&$this, 'make_polylang_first'));
|
39 |
}
|
40 |
|
41 |
/*
|
@@ -46,8 +46,9 @@ class PLL_OLT_Manager {
|
|
46 |
* @return object
|
47 |
*/
|
48 |
static public function instance() {
|
49 |
-
if (empty(self::$instance))
|
50 |
self::$instance = new self();
|
|
|
51 |
|
52 |
return self::$instance;
|
53 |
}
|
@@ -59,52 +60,56 @@ class PLL_OLT_Manager {
|
|
59 |
*/
|
60 |
public function load_textdomains() {
|
61 |
// our override_load_textdomain filter has done its job. let's remove it before calling load_textdomain
|
62 |
-
remove_filter('override_load_textdomain', array(&$this, 'mofile'), 10, 3);
|
63 |
-
remove_filter('gettext', array(&$this, 'gettext'), 10, 3);
|
64 |
-
remove_filter('gettext_with_context', array(&$this, 'gettext_with_context'), 10, 4);
|
65 |
$new_locale = get_locale();
|
66 |
|
67 |
// don't try to save time for en_US as some users have theme written in another language
|
68 |
// now we can load all overriden text domains with the right language
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
75 |
}
|
76 |
}
|
77 |
}
|
78 |
|
79 |
// first remove taxonomies and post_types labels that we don't need to translate
|
80 |
-
$taxonomies = array('language', 'term_language', 'term_translations', 'post_translations');
|
81 |
-
$post_types = array('polylang_mo');
|
82 |
|
83 |
// we don't need to translate core taxonomies and post types labels when setting the language from the url
|
84 |
// as they will be translated when registered the second time
|
85 |
-
if (!did_action('setup_theme')) {
|
86 |
-
$taxonomies = array_merge(array('category', 'post_tag', 'nav_menu', 'link_category', 'post_format'), $taxonomies);
|
87 |
-
$post_types = array_merge(array('post', 'page', 'attachment', 'revision', 'nav_menu_item'), $post_types);
|
88 |
}
|
89 |
|
90 |
// translate labels of post types and taxonomies
|
91 |
-
foreach (array_diff_key($GLOBALS['wp_taxonomies'], array_flip($taxonomies)) as $tax)
|
92 |
-
$this->translate_labels($tax);
|
93 |
-
|
94 |
-
|
|
|
|
|
95 |
|
96 |
-
// act only if the language has not been set early (before default textdomain loading and $wp_locale creation)
|
97 |
-
if (did_action('after_setup_theme')) {
|
98 |
// reinitializes wp_locale for weekdays and months
|
99 |
-
unset($GLOBALS['wp_locale']);
|
100 |
$GLOBALS['wp_locale'] = new WP_Locale();
|
101 |
}
|
102 |
|
103 |
// allow plugins to translate text the same way we do for post types and taxonomies labels
|
104 |
-
do_action_ref_array('pll_translate_labels', array(&$this->labels));
|
105 |
|
106 |
// free memory
|
107 |
-
unset($this->default_locale, $this->list_textdomains, $this->labels);
|
108 |
}
|
109 |
|
110 |
/*
|
@@ -117,8 +122,8 @@ class PLL_OLT_Manager {
|
|
117 |
* @param string $mofile translation file name
|
118 |
* @return bool always true
|
119 |
*/
|
120 |
-
public function mofile($bool, $domain, $mofile) {
|
121 |
-
$this->list_textdomains[] = array
|
122 |
return true; // prevents WP loading text domains as we will load them all later
|
123 |
}
|
124 |
|
@@ -132,9 +137,10 @@ class PLL_OLT_Manager {
|
|
132 |
* @param string $domain text domain
|
133 |
* @return string unmodified $translation
|
134 |
*/
|
135 |
-
public function gettext($translation, $text, $domain) {
|
136 |
-
if (is_string($text)) // avoid a warning with some buggy plugins which pass an array
|
137 |
-
$this->labels[$text] = array('domain' => $domain);
|
|
|
138 |
return $translation;
|
139 |
}
|
140 |
|
@@ -149,8 +155,8 @@ class PLL_OLT_Manager {
|
|
149 |
* @param string $domain text domain
|
150 |
* @return string unmodified $translation
|
151 |
*/
|
152 |
-
public function gettext_with_context($translation, $text, $context, $domain) {
|
153 |
-
$this->labels[$text] = array('domain' => $domain, 'context' => $context);
|
154 |
return $translation;
|
155 |
}
|
156 |
|
@@ -161,36 +167,36 @@ class PLL_OLT_Manager {
|
|
161 |
*
|
162 |
* @param object $type either a post type or a taxonomy
|
163 |
*/
|
164 |
-
public function translate_labels($type) {
|
165 |
-
// use static array to avoid translating several times the same (default) labels
|
166 |
static $translated = array();
|
167 |
|
168 |
-
foreach($type->labels as $key => $label) {
|
169 |
-
if (is_string($label) && isset($this->labels[$label])) {
|
170 |
-
if (empty($translated[$label])) {
|
171 |
-
$type->labels->$key = $translated[$label] = isset($this->labels[$label]['context']) ?
|
172 |
-
_x($label, $this->labels[$label]['context'], $this->labels[$label]['domain']) :
|
173 |
-
__($label, $this->labels[$label]['domain']);
|
174 |
}
|
175 |
else {
|
176 |
-
$type->labels->$key = $translated[$label];
|
177 |
}
|
178 |
}
|
179 |
}
|
180 |
}
|
181 |
|
182 |
/*
|
183 |
-
* allows Polylang to be the first plugin loaded ;-)
|
184 |
*
|
185 |
* @since 1.2
|
186 |
*
|
187 |
* @param array $plugins list of active plugins
|
188 |
* @return array list of active plugins
|
189 |
*/
|
190 |
-
public function make_polylang_first($plugins) {
|
191 |
-
if ($key = array_search(POLYLANG_BASENAME, $plugins)) {
|
192 |
-
unset($plugins[$key]);
|
193 |
-
array_unshift($plugins, POLYLANG_BASENAME);
|
194 |
}
|
195 |
return $plugins;
|
196 |
}
|
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
|
7 |
* this class differs text domain loading until the language is defined
|
8 |
+
* either in a plugins_loaded action or in a wp action ( when the language is set from content on frontend )
|
9 |
*
|
10 |
* @since 1.2
|
11 |
*/
|
25 |
$this->default_locale = get_locale();
|
26 |
|
27 |
// filters for text domain management
|
28 |
+
add_filter( 'override_load_textdomain', array( &$this, 'mofile' ), 10, 3 );
|
29 |
+
add_filter( 'gettext', array( &$this, 'gettext' ), 10, 3 );
|
30 |
+
add_filter( 'gettext_with_context', array( &$this, 'gettext_with_context' ), 10, 4 );
|
31 |
|
32 |
// loads text domains
|
33 |
+
add_action( 'pll_language_defined', array( &$this, 'load_textdomains' ), 2 ); // after PLL_Frontend::pll_language_defined
|
34 |
+
add_action( 'pll_no_language_defined', array( &$this, 'load_textdomains' ) );
|
35 |
|
36 |
+
// allows Polylang to be the first plugin loaded ;- )
|
37 |
+
add_filter( 'pre_update_option_active_plugins', array( &$this, 'make_polylang_first' ) );
|
38 |
+
add_filter( 'pre_update_option_active_sitewide_plugins', array( &$this, 'make_polylang_first' ) );
|
39 |
}
|
40 |
|
41 |
/*
|
46 |
* @return object
|
47 |
*/
|
48 |
static public function instance() {
|
49 |
+
if ( empty( self::$instance ) ) {
|
50 |
self::$instance = new self();
|
51 |
+
}
|
52 |
|
53 |
return self::$instance;
|
54 |
}
|
60 |
*/
|
61 |
public function load_textdomains() {
|
62 |
// our override_load_textdomain filter has done its job. let's remove it before calling load_textdomain
|
63 |
+
remove_filter( 'override_load_textdomain', array( &$this, 'mofile' ), 10, 3 );
|
64 |
+
remove_filter( 'gettext', array( &$this, 'gettext' ), 10, 3 );
|
65 |
+
remove_filter( 'gettext_with_context', array( &$this, 'gettext_with_context' ), 10, 4 );
|
66 |
$new_locale = get_locale();
|
67 |
|
68 |
// don't try to save time for en_US as some users have theme written in another language
|
69 |
// now we can load all overriden text domains with the right language
|
70 |
+
if ( ! empty( $this->list_textdomains ) ) {
|
71 |
+
foreach ( $this->list_textdomains as $textdomain ) {
|
72 |
+
if ( ! load_textdomain( $textdomain['domain'], str_replace( "{$this->default_locale}.mo", "$new_locale.mo", $textdomain['mo'] ) ) ) {
|
73 |
+
// since WP 3.5 themes may store languages files in /wp-content/languages/themes
|
74 |
+
if ( ! load_textdomain( $textdomain['domain'], WP_LANG_DIR . "/themes/{$textdomain['domain']}-$new_locale.mo" ) ) {
|
75 |
+
// since WP 3.7 plugins may store languages files in /wp-content/languages/plugins
|
76 |
+
load_textdomain( $textdomain['domain'], WP_LANG_DIR . "/plugins/{$textdomain['domain']}-$new_locale.mo" );
|
77 |
+
}
|
78 |
}
|
79 |
}
|
80 |
}
|
81 |
|
82 |
// first remove taxonomies and post_types labels that we don't need to translate
|
83 |
+
$taxonomies = array( 'language', 'term_language', 'term_translations', 'post_translations' );
|
84 |
+
$post_types = array( 'polylang_mo' );
|
85 |
|
86 |
// we don't need to translate core taxonomies and post types labels when setting the language from the url
|
87 |
// as they will be translated when registered the second time
|
88 |
+
if ( ! did_action( 'setup_theme' ) ) {
|
89 |
+
$taxonomies = array_merge( array( 'category', 'post_tag', 'nav_menu', 'link_category', 'post_format' ), $taxonomies );
|
90 |
+
$post_types = array_merge( array( 'post', 'page', 'attachment', 'revision', 'nav_menu_item' ), $post_types );
|
91 |
}
|
92 |
|
93 |
// translate labels of post types and taxonomies
|
94 |
+
foreach ( array_diff_key( $GLOBALS['wp_taxonomies'], array_flip( $taxonomies ) ) as $tax ) {
|
95 |
+
$this->translate_labels( $tax );
|
96 |
+
}
|
97 |
+
foreach ( array_diff_key( $GLOBALS['wp_post_types'], array_flip( $post_types ) ) as $pt ) {
|
98 |
+
$this->translate_labels( $pt );
|
99 |
+
}
|
100 |
|
101 |
+
// act only if the language has not been set early ( before default textdomain loading and $wp_locale creation )
|
102 |
+
if ( did_action( 'after_setup_theme' ) ) {
|
103 |
// reinitializes wp_locale for weekdays and months
|
104 |
+
unset( $GLOBALS['wp_locale'] );
|
105 |
$GLOBALS['wp_locale'] = new WP_Locale();
|
106 |
}
|
107 |
|
108 |
// allow plugins to translate text the same way we do for post types and taxonomies labels
|
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 |
/*
|
122 |
* @param string $mofile translation file name
|
123 |
* @return bool always true
|
124 |
*/
|
125 |
+
public function mofile( $bool, $domain, $mofile ) {
|
126 |
+
$this->list_textdomains[] = array( 'mo' => $mofile, 'domain' => $domain );
|
127 |
return true; // prevents WP loading text domains as we will load them all later
|
128 |
}
|
129 |
|
137 |
* @param string $domain text domain
|
138 |
* @return string unmodified $translation
|
139 |
*/
|
140 |
+
public function gettext( $translation, $text, $domain ) {
|
141 |
+
if ( is_string( $text ) ) { // avoid a warning with some buggy plugins which pass an array
|
142 |
+
$this->labels[ $text ] = array( 'domain' => $domain );
|
143 |
+
}
|
144 |
return $translation;
|
145 |
}
|
146 |
|
155 |
* @param string $domain text domain
|
156 |
* @return string unmodified $translation
|
157 |
*/
|
158 |
+
public function gettext_with_context( $translation, $text, $context, $domain ) {
|
159 |
+
$this->labels[ $text ] = array( 'domain' => $domain, 'context' => $context );
|
160 |
return $translation;
|
161 |
}
|
162 |
|
167 |
*
|
168 |
* @param object $type either a post type or a taxonomy
|
169 |
*/
|
170 |
+
public function translate_labels( $type ) {
|
171 |
+
// use static array to avoid translating several times the same ( default ) labels
|
172 |
static $translated = array();
|
173 |
|
174 |
+
foreach ( $type->labels as $key => $label ) {
|
175 |
+
if ( is_string( $label ) && isset( $this->labels[ $label ] ) ) {
|
176 |
+
if ( empty( $translated[ $label ] ) ) {
|
177 |
+
$type->labels->$key = $translated[ $label ] = isset( $this->labels[ $label ]['context'] ) ?
|
178 |
+
_x( $label, $this->labels[ $label ]['context'], $this->labels[ $label ]['domain'] ) :
|
179 |
+
__( $label, $this->labels[ $label ]['domain'] );
|
180 |
}
|
181 |
else {
|
182 |
+
$type->labels->$key = $translated[ $label ];
|
183 |
}
|
184 |
}
|
185 |
}
|
186 |
}
|
187 |
|
188 |
/*
|
189 |
+
* allows Polylang to be the first plugin loaded ;- )
|
190 |
*
|
191 |
* @since 1.2
|
192 |
*
|
193 |
* @param array $plugins list of active plugins
|
194 |
* @return array list of active plugins
|
195 |
*/
|
196 |
+
public function make_polylang_first( $plugins ) {
|
197 |
+
if ( $key = array_search( POLYLANG_BASENAME, $plugins ) ) {
|
198 |
+
unset( $plugins[ $key ] );
|
199 |
+
array_unshift( $plugins, POLYLANG_BASENAME );
|
200 |
}
|
201 |
return $plugins;
|
202 |
}
|
include/plugins-compat.php
DELETED
@@ -1,402 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* manages compatibility with 3rd party plugins (and themes)
|
5 |
-
* this class is available as soon as the plugin is loaded
|
6 |
-
*
|
7 |
-
* @since 1.0
|
8 |
-
*/
|
9 |
-
class PLL_Plugins_Compat {
|
10 |
-
static protected $instance; // for singleton
|
11 |
-
|
12 |
-
/*
|
13 |
-
* constructor
|
14 |
-
*
|
15 |
-
* @since 1.0
|
16 |
-
*/
|
17 |
-
protected function __construct() {
|
18 |
-
// WordPress Importer
|
19 |
-
add_action('init', array(&$this, 'maybe_wordpress_importer'));
|
20 |
-
|
21 |
-
// YARPP
|
22 |
-
// just makes YARPP aware of the language taxonomy (after Polylang registered it)
|
23 |
-
add_action('init', create_function('',"\$GLOBALS['wp_taxonomies']['language']->yarpp_support = 1;"), 20);
|
24 |
-
|
25 |
-
// Yoast SEO
|
26 |
-
add_action('pll_language_defined', array(&$this, 'wpseo_init'));
|
27 |
-
|
28 |
-
// Custom field template
|
29 |
-
add_action('add_meta_boxes', array(&$this, 'cft_copy'), 10, 2);
|
30 |
-
|
31 |
-
// Aqua Resizer
|
32 |
-
add_filter('pll_home_url_black_list', create_function('$arr', "return array_merge(\$arr, array(array('function' => 'aq_resize')));"));
|
33 |
-
|
34 |
-
// Twenty Fourteen
|
35 |
-
if ( 'twentyfourteen' == get_template() ) {
|
36 |
-
add_filter('transient_featured_content_ids', array(&$this, 'twenty_fourteen_featured_content_ids'));
|
37 |
-
add_filter('option_featured-content', array(&$this, 'twenty_fourteen_option_featured_content'));
|
38 |
-
}
|
39 |
-
|
40 |
-
// Jetpack 3
|
41 |
-
add_action('jetpack_widget_get_top_posts', array(&$this, 'jetpack_widget_get_top_posts'), 10, 3);
|
42 |
-
add_filter('grunion_contact_form_field_html', array(&$this, 'grunion_contact_form_field_html_filter'), 10, 3);
|
43 |
-
add_filter('jetpack_open_graph_tags', array(&$this, 'jetpack_ogp'));
|
44 |
-
|
45 |
-
// Jetpack infinite scroll
|
46 |
-
if ( !defined( 'PLL_AJAX_ON_FRONT' ) && isset( $_GET['infinity'], $_POST['action'] ) && 'infinite_scroll' == $_POST['action'] ) {
|
47 |
-
define( 'PLL_AJAX_ON_FRONT', true );
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
/*
|
52 |
-
* access to the single instance of the class
|
53 |
-
*
|
54 |
-
* @since 1.7
|
55 |
-
*
|
56 |
-
* @return object
|
57 |
-
*/
|
58 |
-
static public function instance() {
|
59 |
-
if (empty(self::$instance))
|
60 |
-
self::$instance = new self();
|
61 |
-
|
62 |
-
return self::$instance;
|
63 |
-
}
|
64 |
-
|
65 |
-
/*
|
66 |
-
* WordPress Importer
|
67 |
-
* if WordPress Importer is active, replace the wordpress_importer_init function
|
68 |
-
*
|
69 |
-
* @since 1.2
|
70 |
-
*/
|
71 |
-
function maybe_wordpress_importer() {
|
72 |
-
if (defined('WP_LOAD_IMPORTERS') && class_exists('WP_Import')) {
|
73 |
-
remove_action('admin_init', 'wordpress_importer_init');
|
74 |
-
add_action('admin_init', array(&$this, 'wordpress_importer_init'));
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
/*
|
79 |
-
* WordPress Importer
|
80 |
-
* loads our child class PLL_WP_Import instead of WP_Import
|
81 |
-
*
|
82 |
-
* @since 1.2
|
83 |
-
*/
|
84 |
-
function wordpress_importer_init() {
|
85 |
-
$class = new ReflectionClass('WP_Import');
|
86 |
-
load_plugin_textdomain( 'wordpress-importer', false, basename(dirname( $class->getFileName() )) . '/languages' );
|
87 |
-
|
88 |
-
$GLOBALS['wp_import'] = new PLL_WP_Import();
|
89 |
-
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' ) );
|
90 |
-
}
|
91 |
-
|
92 |
-
/*
|
93 |
-
* Yoast SEO
|
94 |
-
* translate options
|
95 |
-
* add specific filters and actions
|
96 |
-
*
|
97 |
-
* @since 1.6.4
|
98 |
-
*/
|
99 |
-
public function wpseo_init() {
|
100 |
-
global $polylang;
|
101 |
-
|
102 |
-
if (!defined('WPSEO_VERSION') || PLL_ADMIN)
|
103 |
-
return;
|
104 |
-
|
105 |
-
// reloads options once the language has been defined to enable translations
|
106 |
-
// useful only when the language is set from content
|
107 |
-
if (did_action('wp_loaded')) {
|
108 |
-
if (version_compare(WPSEO_VERSION, '1.7.2', '<')) {
|
109 |
-
global $wpseo_front;
|
110 |
-
}
|
111 |
-
else {
|
112 |
-
$wpseo_front = WPSEO_Frontend::get_instance();
|
113 |
-
}
|
114 |
-
|
115 |
-
$options = version_compare(WPSEO_VERSION, '1.5', '<') ? get_wpseo_options_arr() : WPSEO_Options::get_option_names();
|
116 |
-
foreach ( $options as $opt )
|
117 |
-
$wpseo_front->options = array_merge( $wpseo_front->options, (array) get_option( $opt ) );
|
118 |
-
}
|
119 |
-
|
120 |
-
// one sitemap per language when using multiple domains or subdomains
|
121 |
-
// because WPSEO does not accept several domains or subdomains in one sitemap
|
122 |
-
if ($polylang->options['force_lang'] > 1) {
|
123 |
-
add_filter('wpseo_enable_xml_sitemap_transient_caching', '__return_false'); // disable cache! otherwise WPSEO keeps only one domain (thanks to Junaid Bhura)
|
124 |
-
add_filter('home_url', array(&$this, 'wpseo_home_url'), 10, 2); // fix home_url
|
125 |
-
add_filter('wpseo_posts_join', array(&$this, 'wpseo_posts_join'), 10, 2);
|
126 |
-
add_filter('wpseo_posts_where', array(&$this, 'wpseo_posts_where'), 10, 2);
|
127 |
-
add_filter('wpseo_typecount_join', array(&$this, 'wpseo_posts_join'), 10, 2);
|
128 |
-
add_filter('wpseo_typecount_where', array(&$this, 'wpseo_posts_where'), 10, 2);
|
129 |
-
}
|
130 |
-
|
131 |
-
// one sitemap for all languages when the language is set from the content or directory name
|
132 |
-
else {
|
133 |
-
add_filter('get_terms_args', array(&$this, 'wpseo_remove_terms_filter'));
|
134 |
-
}
|
135 |
-
|
136 |
-
add_filter('pll_home_url_white_list', create_function('$arr', "return array_merge(\$arr, array(array('file' => 'wordpress-seo')));"));
|
137 |
-
add_action('wpseo_opengraph', array(&$this, 'wpseo_ogp'), 2);
|
138 |
-
add_filter( 'wpseo_canonical', array( &$this, 'wpseo_canonical' ) );
|
139 |
-
}
|
140 |
-
|
141 |
-
/*
|
142 |
-
* Yoast SEO
|
143 |
-
* fixes the home url as well as the stylesheet url
|
144 |
-
* only when using multiple domains or subdomains
|
145 |
-
*
|
146 |
-
* @since 1.6.4
|
147 |
-
*
|
148 |
-
* @param string $url
|
149 |
-
* @return $url
|
150 |
-
*/
|
151 |
-
public function wpseo_home_url($url, $path) {
|
152 |
-
global $polylang;
|
153 |
-
|
154 |
-
$uri = empty($path) ? ltrim($_SERVER['REQUEST_URI'], '/') : $path;
|
155 |
-
|
156 |
-
if ('sitemap_index.xml' === $uri || preg_match('#([^/]+?)-sitemap([0-9]+)?\.xml|([a-z]+)?-?sitemap\.xsl#', $uri))
|
157 |
-
$url = $polylang->links_model->switch_language_in_link($url, $polylang->curlang);
|
158 |
-
|
159 |
-
return $url;
|
160 |
-
}
|
161 |
-
|
162 |
-
/*
|
163 |
-
* Yoast SEO
|
164 |
-
* modifies the sql request for posts sitemaps
|
165 |
-
* only when using multiple domains or subdomains
|
166 |
-
*
|
167 |
-
* @since 1.6.4
|
168 |
-
*
|
169 |
-
* @param string $sql join clause
|
170 |
-
* @param string $post_type
|
171 |
-
* @return string
|
172 |
-
*/
|
173 |
-
public function wpseo_posts_join($sql, $post_type) {
|
174 |
-
global $polylang;
|
175 |
-
return pll_is_translated_post_type($post_type) ? $sql. $polylang->model->join_clause('post') : $sql;
|
176 |
-
}
|
177 |
-
|
178 |
-
/*
|
179 |
-
* Yoast SEO
|
180 |
-
* modifies the sql request for posts sitemaps
|
181 |
-
* only when using multiple domains or subdomains
|
182 |
-
*
|
183 |
-
* @since 1.6.4
|
184 |
-
*
|
185 |
-
* @param string $sql where clause
|
186 |
-
* @param string $post_type
|
187 |
-
* @return string
|
188 |
-
*/
|
189 |
-
public function wpseo_posts_where($sql, $post_type) {
|
190 |
-
global $polylang;
|
191 |
-
return pll_is_translated_post_type($post_type) ? $sql . $polylang->model->where_clause($polylang->curlang, 'post') : $sql;
|
192 |
-
}
|
193 |
-
|
194 |
-
/*
|
195 |
-
* Yoast SEO
|
196 |
-
* removes the language filter for the taxonomy sitemaps
|
197 |
-
* only when the language is set from the content or directory name
|
198 |
-
*
|
199 |
-
* @since 1.0.3
|
200 |
-
*
|
201 |
-
* @param array $args get_terms arguments
|
202 |
-
* @return array modified list of arguments
|
203 |
-
*/
|
204 |
-
public function wpseo_remove_terms_filter($args) {
|
205 |
-
if (isset($GLOBALS['wp_query']->query['sitemap']))
|
206 |
-
$args['lang'] = 0;
|
207 |
-
return $args;
|
208 |
-
}
|
209 |
-
|
210 |
-
/*
|
211 |
-
* Yoast SEO
|
212 |
-
* adds opengraph support for translations
|
213 |
-
*
|
214 |
-
* @since 1.6
|
215 |
-
*/
|
216 |
-
public function wpseo_ogp() {
|
217 |
-
global $polylang, $wpseo_og;
|
218 |
-
|
219 |
-
// WPSEO already deals with the locale
|
220 |
-
if (isset($polylang) && method_exists($wpseo_og, 'og_tag')) {
|
221 |
-
foreach ($polylang->model->get_languages_list() as $language) {
|
222 |
-
if ($language->slug != $polylang->curlang->slug && $polylang->links->get_translation_url($language) && $fb_locale = self::get_fb_locale($language)) {
|
223 |
-
$wpseo_og->og_tag('og:locale:alternate', $fb_locale);
|
224 |
-
}
|
225 |
-
}
|
226 |
-
}
|
227 |
-
}
|
228 |
-
|
229 |
-
/*
|
230 |
-
* Yoast SEO
|
231 |
-
* fixes the canonical front page url as unlike WP, WPSEO does not add a trailing slash to the canonical front page url
|
232 |
-
*
|
233 |
-
* @since 1.7.10
|
234 |
-
*
|
235 |
-
* @param string $url
|
236 |
-
* @return $url
|
237 |
-
*/
|
238 |
-
public function wpseo_canonical( $url ) {
|
239 |
-
return is_front_page( $url ) ? trailingslashit( $url ) : $url;
|
240 |
-
}
|
241 |
-
|
242 |
-
/*
|
243 |
-
* Custom field template does check $_REQUEST['post'] to populate the custom fields values
|
244 |
-
*
|
245 |
-
* @since 1.0.2
|
246 |
-
*
|
247 |
-
* @param string $post_type unused
|
248 |
-
* @param object $post current post object
|
249 |
-
*/
|
250 |
-
public function cft_copy($post_type, $post) {
|
251 |
-
global $custom_field_template;
|
252 |
-
if (isset($custom_field_template, $_REQUEST['from_post'], $_REQUEST['new_lang']) && !empty($post))
|
253 |
-
$_REQUEST['post'] = $post->ID;
|
254 |
-
}
|
255 |
-
|
256 |
-
/*
|
257 |
-
* rewrites the function Featured_Content::get_featured_post_ids()
|
258 |
-
*
|
259 |
-
* @since 1.4
|
260 |
-
*
|
261 |
-
* @param array $ids featured posts ids
|
262 |
-
* @return array modified featured posts ids (include all languages)
|
263 |
-
*/
|
264 |
-
public function twenty_fourteen_featured_content_ids($featured_ids) {
|
265 |
-
global $polylang;
|
266 |
-
|
267 |
-
if (empty($polylang) || false !== $featured_ids)
|
268 |
-
return $featured_ids;
|
269 |
-
|
270 |
-
$settings = Featured_Content::get_setting();
|
271 |
-
|
272 |
-
if (!$term = get_term_by( 'name', $settings['tag-name'], 'post_tag' ))
|
273 |
-
return $featured_ids;
|
274 |
-
|
275 |
-
// get featured tag translations
|
276 |
-
$tags = $polylang->model->get_translations('term' ,$term->term_id);
|
277 |
-
$ids = array();
|
278 |
-
|
279 |
-
// Query for featured posts in all languages
|
280 |
-
// one query per language to get the correct number of posts per language
|
281 |
-
foreach ($tags as $tag) {
|
282 |
-
$_ids = get_posts(array(
|
283 |
-
'lang' => 0, // avoid language filters
|
284 |
-
'fields' => 'ids',
|
285 |
-
'numberposts' => Featured_Content::$max_posts,
|
286 |
-
'tax_query' => array(array(
|
287 |
-
'taxonomy' => 'post_tag',
|
288 |
-
'terms' => (int) $tag,
|
289 |
-
)),
|
290 |
-
));
|
291 |
-
|
292 |
-
$ids = array_merge($ids, $_ids);
|
293 |
-
}
|
294 |
-
|
295 |
-
$ids = array_map( 'absint', $ids );
|
296 |
-
set_transient( 'featured_content_ids', $ids );
|
297 |
-
|
298 |
-
return $ids;
|
299 |
-
}
|
300 |
-
|
301 |
-
/*
|
302 |
-
* translates the featured tag id in featured content settings
|
303 |
-
* mainly to allow hiding it when requested in featured content options
|
304 |
-
* acts only on frontend
|
305 |
-
*
|
306 |
-
* @since 1.4
|
307 |
-
*
|
308 |
-
* @param array $settings featured content settings
|
309 |
-
* @return array modified $settings
|
310 |
-
*/
|
311 |
-
public function twenty_fourteen_option_featured_content($settings) {
|
312 |
-
if (!PLL_ADMIN && $settings['tag-id'] && $tr = pll_get_term($settings['tag-id']))
|
313 |
-
$settings['tag-id'] = $tr;
|
314 |
-
|
315 |
-
return $settings;
|
316 |
-
}
|
317 |
-
|
318 |
-
/*
|
319 |
-
* adapted from the same function in jetpack-3.0.2/3rd-party/wpml.php
|
320 |
-
*
|
321 |
-
* @since 1.5.4
|
322 |
-
*/
|
323 |
-
public function jetpack_widget_get_top_posts( $posts, $post_ids, $count ) {
|
324 |
-
foreach ( $posts as $k => $post ) {
|
325 |
-
if (pll_current_language() !== pll_get_post_language($post['post_id']))
|
326 |
-
unset( $posts[ $k ] );
|
327 |
-
}
|
328 |
-
|
329 |
-
return $posts;
|
330 |
-
}
|
331 |
-
|
332 |
-
/*
|
333 |
-
* adapted from the same function in jetpack-3.0.2/3rd-party/wpml.php
|
334 |
-
* keeps using 'icl_translate' as the function registers the string
|
335 |
-
*
|
336 |
-
* @since 1.5.4
|
337 |
-
*/
|
338 |
-
public function grunion_contact_form_field_html_filter( $r, $field_label, $id ){
|
339 |
-
if ( function_exists( 'icl_translate' ) ) {
|
340 |
-
if ( pll_current_language() !== pll_default_language() ) {
|
341 |
-
$label_translation = icl_translate( 'jetpack ', $field_label . '_label', $field_label );
|
342 |
-
$r = str_replace( $field_label, $label_translation, $r );
|
343 |
-
}
|
344 |
-
}
|
345 |
-
|
346 |
-
return $r;
|
347 |
-
}
|
348 |
-
|
349 |
-
/*
|
350 |
-
* adds opengraph support for locale and translations
|
351 |
-
*
|
352 |
-
* @since 1.6
|
353 |
-
*
|
354 |
-
* @param array $tags opengraph tags to output
|
355 |
-
* @return array
|
356 |
-
*/
|
357 |
-
public function jetpack_ogp($tags) {
|
358 |
-
global $polylang;
|
359 |
-
|
360 |
-
if (isset($polylang)) {
|
361 |
-
foreach ($polylang->model->get_languages_list() as $language) {
|
362 |
-
if ($language->slug != $polylang->curlang->slug && $polylang->links->get_translation_url($language) && $fb_locale = self::get_fb_locale($language))
|
363 |
-
$tags['og:locale:alternate'][] = $fb_locale;
|
364 |
-
if ($language->slug == $polylang->curlang->slug && $fb_locale = self::get_fb_locale($language))
|
365 |
-
$tags['og:locale'] = $fb_locale;
|
366 |
-
}
|
367 |
-
}
|
368 |
-
return $tags;
|
369 |
-
}
|
370 |
-
|
371 |
-
/*
|
372 |
-
* correspondance between WordPress locales and Facebook locales
|
373 |
-
* @see http://wpcentral.io/internationalization/
|
374 |
-
* @see https://www.facebook.com/translations/FacebookLocales.xml
|
375 |
-
*
|
376 |
-
* @since 1.6
|
377 |
-
*
|
378 |
-
* @param object $language
|
379 |
-
* @return bool|string
|
380 |
-
*/
|
381 |
-
static public function get_fb_locale($language) {
|
382 |
-
static $facebook_locales = array(
|
383 |
-
'af' => 'af_ZA', 'ar' => 'ar_AR', 'az' => 'az_AZ', 'bel' => 'be_BY', 'bg_BG' => 'bg_BG', 'bn_BD' => 'bn_IN',
|
384 |
-
'bs_BA' => 'bs_BA', 'ca' => 'ca_ES', 'ckb' => 'ku_TR', 'cs_CZ' => 'cs_CZ', 'cy' => 'cy_GB', 'da_DK' => 'da_DK',
|
385 |
-
'de_DE' => 'de_DE', 'el' => 'el_GR', 'en_US' => 'en_US', 'en_GB' => 'en_GB', 'eo' => 'eo_EO', 'es_CL' => 'es_LA',
|
386 |
-
'es_CO' => 'es_LA', 'es_MX' => 'es_LA', 'es_PE' => 'es_LA', 'es_PR' => 'es_LA', 'es_VE' => 'es_LA', 'es_ES' => 'es_ES',
|
387 |
-
'et' => 'et_EE', 'eu' => 'eu_ES', 'fa_IR' => 'fa_IR', 'fi' => 'fi_FI', 'fo' => 'fo_FO', 'fr_CA' => 'fr_CA',
|
388 |
-
'fr_FR' => 'fr_FR', 'fy' => 'fy_NL', 'ga' => 'ga_IE', 'gl_ES' => 'gl_ES', 'gn' => 'gn_PY', 'gu_IN' => 'gu_IN',
|
389 |
-
'he_IL' => 'he_IL', 'hi_IN' => 'hi_IN', 'hr' => 'hr_HR', 'hu_HU' => 'hu_HU', 'hy' => 'hy_AM', 'id_ID' => 'id_ID',
|
390 |
-
'is_IS' => 'is_IS', 'it_IT' => 'it_IT', 'ja' => 'ja_JP', 'jv_ID' => 'jv_ID', 'ka_GE' => 'ka_GE', 'kk' => 'kk_KZ',
|
391 |
-
'km' => 'km_kH', 'kn' => 'kn_IN', 'ko_KR' => 'ko_KR', 'lt_LT' => 'lt_LT', 'lv' => 'lv_LV', 'mk_MK' => 'mk_MK',
|
392 |
-
'ml_IN' => 'ml_IN', 'mn' => 'mn_MN', 'mr' => 'mr_IN', 'ms_MY' => 'ms_MY', 'ne_NP' => 'ne_NP', 'nb_NO' => 'nb_NO',
|
393 |
-
'nl_NL' => 'nl_NL', 'nn_NO' => 'nn_NO', 'pa_IN' => 'pa_IN', 'pl_PL' => 'pl_PL', 'ps' => 'ps_AF', 'pt_BR' => 'pt_BR',
|
394 |
-
'pt_PT' => 'pt_PT', 'ps' => 'ps_AF', 'ro_RO' => 'ro_RO', 'ru_RU' => 'ru_RU', 'si_LK' => 'si_LK', 'sk_SK' => 'sk_SK',
|
395 |
-
'sl_SI' => 'sl_SI', 'sq' => 'sq_AL', 'sr_RS' => 'sr_RS', 'sv_SE' => 'sv_SE', 'sw' => 'sw_KE', 'ta_IN' => 'ta_IN',
|
396 |
-
'te' => 'te_IN', 'tg' => 'tg_TJ', 'th' => 'th_TH', 'ph' => 'tl_PH', 'tr_TR' => 'tr_TR', 'uk' => 'uk_UA',
|
397 |
-
'ur' => 'ur_PK', 'uz_UZ' => 'uz_UZ', 'vi' => 'vi_VN', 'zh_CN' => 'zh_CN', 'zh_HK' => 'zh_HK', 'zh_TW' => 'zh_TW'
|
398 |
-
);
|
399 |
-
|
400 |
-
return isset($facebook_locales[$language->locale]) ? $facebook_locales[$language->locale] : false;
|
401 |
-
}
|
402 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include/pointer.php
CHANGED
@@ -31,9 +31,9 @@ class PLL_Pointer {
|
|
31 |
*
|
32 |
* @param array $args
|
33 |
*/
|
34 |
-
public function __construct($args) {
|
35 |
$this->args = $args;
|
36 |
-
add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'));
|
37 |
}
|
38 |
|
39 |
/*
|
@@ -42,15 +42,16 @@ class PLL_Pointer {
|
|
42 |
* @since 1.7.7
|
43 |
*/
|
44 |
public function enqueue_scripts() {
|
45 |
-
$dismissed = explode(',', get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
|
46 |
-
if (in_array($this->args['pointer'], $dismissed) || !current_user_can('manage_options'))
|
47 |
return;
|
|
|
48 |
|
49 |
// Add pointer javascript
|
50 |
-
add_action('admin_print_footer_scripts', array(&$this, 'print_js'));
|
51 |
|
52 |
-
wp_enqueue_style('wp-pointer');
|
53 |
-
wp_enqueue_script('wp-pointer');
|
54 |
}
|
55 |
|
56 |
/*
|
@@ -61,48 +62,48 @@ class PLL_Pointer {
|
|
61 |
public function print_js() {
|
62 |
|
63 |
// add optional buttons
|
64 |
-
if (!empty($this->args['buttons'])) {
|
65 |
$b = "
|
66 |
-
var widget = pointer.pointer('widget');
|
67 |
-
var buttons = $('.wp-pointer-buttons', widget);
|
68 |
-
$('a.close', widget).remove();"; // removes the WP button
|
69 |
|
70 |
// all the buttons use the standard WP ajax action to remember the pointer has been dismissed
|
71 |
-
foreach ($this->args['buttons'] as $button) {
|
72 |
-
$b .= sprintf("
|
73 |
-
$('<a>').addClass('%s').html('%s').css('margin-left', '10px').click(function() {
|
74 |
-
$.post(ajaxurl, {
|
75 |
pointer: '%s',
|
76 |
action: 'dismiss-wp-pointer'
|
77 |
-
}, function(response) {
|
78 |
%s
|
79 |
-
});
|
80 |
-
}).appendTo(buttons);",
|
81 |
-
empty($button['link']) ? 'button' : 'button button-primary',
|
82 |
$button['label'],
|
83 |
$this->args['pointer'],
|
84 |
-
empty($button['link']) ? "pointer.pointer('close')" : sprintf("location.href = '%s'", $button['link'])
|
85 |
);
|
86 |
}
|
87 |
}
|
88 |
|
89 |
-
$js = sprintf("
|
90 |
//<![CDATA[
|
91 |
-
jQuery(document).ready(function($) {
|
92 |
-
var pointer = $('#%s').pointer({
|
93 |
content: '%s',
|
94 |
%s
|
95 |
%s
|
96 |
-
});
|
97 |
-
pointer.pointer('open');
|
98 |
%s
|
99 |
-
});
|
100 |
// ]]>",
|
101 |
$this->args['id'],
|
102 |
-
sprintf('<h3>%s</h3><p>%s</p>', $this->args['title'], $this->args['content']),
|
103 |
-
empty($this->args['position']) ? '' : sprintf('position: {edge: "%s", align: "%s",},', $this->args['position']['edge'], $this->args['position']['align']),
|
104 |
-
empty($this->args['width']) ? '' : sprintf('pointerWidth: %d,', $this->args['width']),
|
105 |
-
empty($b) ? '' : $b
|
106 |
);
|
107 |
echo "<script type='text/javascript'>" .$js. "</script>";
|
108 |
}
|
31 |
*
|
32 |
* @param array $args
|
33 |
*/
|
34 |
+
public function __construct( $args ) {
|
35 |
$this->args = $args;
|
36 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
|
37 |
}
|
38 |
|
39 |
/*
|
42 |
* @since 1.7.7
|
43 |
*/
|
44 |
public function enqueue_scripts() {
|
45 |
+
$dismissed = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
|
46 |
+
if ( in_array( $this->args['pointer'], $dismissed ) || ! current_user_can( 'manage_options' ) ) {
|
47 |
return;
|
48 |
+
}
|
49 |
|
50 |
// Add pointer javascript
|
51 |
+
add_action( 'admin_print_footer_scripts', array( &$this, 'print_js' ) );
|
52 |
|
53 |
+
wp_enqueue_style( 'wp-pointer' );
|
54 |
+
wp_enqueue_script( 'wp-pointer' );
|
55 |
}
|
56 |
|
57 |
/*
|
62 |
public function print_js() {
|
63 |
|
64 |
// add optional buttons
|
65 |
+
if ( ! empty( $this->args['buttons'] ) ) {
|
66 |
$b = "
|
67 |
+
var widget = pointer.pointer( 'widget' );
|
68 |
+
var buttons = $( '.wp-pointer-buttons', widget );
|
69 |
+
$( 'a.close', widget ).remove();"; // removes the WP button
|
70 |
|
71 |
// all the buttons use the standard WP ajax action to remember the pointer has been dismissed
|
72 |
+
foreach ( $this->args['buttons'] as $button ) {
|
73 |
+
$b .= sprintf( "
|
74 |
+
$( '<a>' ).addClass( '%s' ).html( '%s' ).css( 'margin-left', '10px' ).click( function() {
|
75 |
+
$.post( ajaxurl, {
|
76 |
pointer: '%s',
|
77 |
action: 'dismiss-wp-pointer'
|
78 |
+
}, function( response ) {
|
79 |
%s
|
80 |
+
} );
|
81 |
+
} ).appendTo( buttons );",
|
82 |
+
empty( $button['link'] ) ? 'button' : 'button button-primary',
|
83 |
$button['label'],
|
84 |
$this->args['pointer'],
|
85 |
+
empty( $button['link'] ) ? "pointer.pointer( 'close' )" : sprintf( "location.href = '%s'", $button['link'] )
|
86 |
);
|
87 |
}
|
88 |
}
|
89 |
|
90 |
+
$js = sprintf( "
|
91 |
//<![CDATA[
|
92 |
+
jQuery( document ).ready( function( $ ) {
|
93 |
+
var pointer = $( '#%s' ).pointer( {
|
94 |
content: '%s',
|
95 |
%s
|
96 |
%s
|
97 |
+
} );
|
98 |
+
pointer.pointer( 'open' );
|
99 |
%s
|
100 |
+
} );
|
101 |
// ]]>",
|
102 |
$this->args['id'],
|
103 |
+
sprintf( '<h3>%s</h3><p>%s</p>', $this->args['title'], $this->args['content'] ),
|
104 |
+
empty( $this->args['position'] ) ? '' : sprintf( 'position: {edge: "%s", align: "%s",},', $this->args['position']['edge'], $this->args['position']['align'] ),
|
105 |
+
empty( $this->args['width'] ) ? '' : sprintf( 'pointerWidth: %d,', $this->args['width'] ),
|
106 |
+
empty( $b ) ? '' : $b
|
107 |
);
|
108 |
echo "<script type='text/javascript'>" .$js. "</script>";
|
109 |
}
|
include/static-pages.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* base class to manage the static front page and the page for posts
|
5 |
+
*
|
6 |
+
* @since 1.8
|
7 |
+
*/
|
8 |
+
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
|
16 |
+
*
|
17 |
+
* @param object $polylang
|
18 |
+
*/
|
19 |
+
public function __construct( &$polylang ) {
|
20 |
+
$this->model = &$polylang->model;
|
21 |
+
$this->options = &$polylang->options;
|
22 |
+
|
23 |
+
$this->init();
|
24 |
+
|
25 |
+
// clean the languages cache when editing page of front, page for posts
|
26 |
+
add_action( 'update_option_page_on_front', array( &$this->model, 'clean_languages_cache' ) );
|
27 |
+
add_action( 'update_option_page_for_posts', array( &$this->model, 'clean_languages_cache' ) );
|
28 |
+
|
29 |
+
// refresh rewrite rules when the page on front is modified
|
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
|
37 |
+
*/
|
38 |
+
public function init() {
|
39 |
+
if ( 'page' == get_option( 'show_on_front' ) ) {
|
40 |
+
$this->page_on_front = get_option( 'page_on_front' );
|
41 |
+
$this->page_for_posts = get_option( 'page_for_posts' );
|
42 |
+
}
|
43 |
+
|
44 |
+
else {
|
45 |
+
$this->page_on_front = 0;
|
46 |
+
$this->page_for_posts = 0;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/*
|
51 |
+
* adds page_on_front and page_for_posts properties to the language objects
|
52 |
+
*
|
53 |
+
* @since 1.8
|
54 |
+
*
|
55 |
+
* @param array $languages
|
56 |
+
* @param object $model
|
57 |
+
*/
|
58 |
+
public static function pll_languages_list( $languages, $model ) {
|
59 |
+
foreach ( $languages as $k => $language ) {
|
60 |
+
$languages[ $k ]->page_on_front = $model->post->get( get_option( 'page_on_front' ), $language );
|
61 |
+
$languages[ $k ]->page_for_posts = $model->post->get( get_option( 'page_for_posts' ), $language );
|
62 |
+
}
|
63 |
+
|
64 |
+
return $languages;
|
65 |
+
}
|
66 |
+
}
|
include/switcher.php
CHANGED
@@ -17,19 +17,20 @@ class PLL_Switcher {
|
|
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') {
|
21 |
$options = array(
|
22 |
-
'show_names' => array('string' => __('Displays language names', 'polylang'), 'default' => 1),
|
23 |
-
'show_flags' => array('string' => __('Displays flags', 'polylang'), 'default' => 0),
|
24 |
-
'force_home' => array('string' => __('Forces link to front page', 'polylang'), 'default' => 0),
|
25 |
-
'hide_current' => array('string' => __('Hides the current language', 'polylang'), 'default' => 0),
|
26 |
-
'hide_if_no_translation' => array('string' => __('Hides languages with no translation', 'polylang'), 'default' => 0),
|
27 |
);
|
28 |
|
29 |
-
if (
|
30 |
-
$options = array('dropdown' => array('string' => __('Displays as dropdown', 'polylang'), 'default' => 0)) + $options;
|
|
|
31 |
|
32 |
-
return
|
33 |
}
|
34 |
|
35 |
/*
|
@@ -44,45 +45,49 @@ class PLL_Switcher {
|
|
44 |
* @param array $args
|
45 |
* @return array
|
46 |
*/
|
47 |
-
protected function get_elements($links, $args) {
|
48 |
-
foreach ($links->model->get_languages_list(array('hide_empty' => $args['hide_if_empty'])) as $language) {
|
49 |
$id = (int) $language->term_id;
|
50 |
$slug = $language->slug;
|
51 |
-
$
|
|
|
52 |
$url = null; // avoids potential notice
|
53 |
|
54 |
-
if ($current_lang =
|
55 |
-
if ($args['hide_current'] &&
|
56 |
continue; // hide current language except for dropdown
|
57 |
-
|
|
|
58 |
$classes[] = 'current-lang';
|
|
|
59 |
}
|
60 |
|
61 |
-
if ( $args['post_id']
|
62 |
-
$url =
|
63 |
-
}
|
64 |
-
elseif ( $args['post_id'] === null ) {
|
65 |
$url = $links->get_translation_url( $language );
|
66 |
}
|
67 |
|
68 |
-
if ($no_translation = empty($url))
|
69 |
$classes[] = 'no-translation';
|
|
|
70 |
|
71 |
-
$url = apply_filters('pll_the_language_link', $url, $slug, $language->locale);
|
72 |
|
73 |
// hide if no translation exists
|
74 |
-
if (empty($url) && $args['hide_if_no_translation'])
|
75 |
continue;
|
|
|
76 |
|
77 |
$url = empty( $url ) || $args['force_home'] ? $links->get_home_url( $language ) : $url ; // if the page is not translated, link to the home page
|
78 |
|
79 |
-
$name = $args['show_names'] ||
|
80 |
-
$flag = $args['raw'] &&
|
81 |
|
82 |
-
$out[] = compact('id', 'slug', 'name', 'url', 'flag', 'current_lang', 'no_translation', 'classes');
|
83 |
}
|
84 |
-
return empty($out) ? array() : $out;
|
85 |
|
|
|
86 |
}
|
87 |
|
88 |
/*
|
@@ -93,7 +98,7 @@ class PLL_Switcher {
|
|
93 |
*
|
94 |
* dropdown => the list is displayed as dropdown if set, defaults to 0
|
95 |
* echo => echoes the list if set to 1, defaults to 1
|
96 |
-
* hide_if_empty => hides languages with no posts (or pages) if set to 1, defaults to 1
|
97 |
* show_flags => displays flags if set to 1, defaults to 0
|
98 |
* show_names => show language names if set to 1, defaults to 1
|
99 |
* display_names_as => wether to display the language name or its slug, valid options are 'slug' and 'name', defaults to name
|
@@ -109,12 +114,12 @@ class PLL_Switcher {
|
|
109 |
* @param array $args
|
110 |
* @return string|array either the html markup of the switcher or the raw elements to build a custom language switcher
|
111 |
*/
|
112 |
-
public function the_languages($links, $args = '') {
|
113 |
$defaults = array(
|
114 |
'dropdown' => 0, // display as list and not as dropdown
|
115 |
'echo' => 1, // echoes the list
|
116 |
-
'hide_if_empty' => 1, // hides languages with no posts (or pages)
|
117 |
-
'menu' => 0, // not for nav menu (this argument is deprecated since v1.1.1)
|
118 |
'show_flags' => 0, // don't show flags
|
119 |
'show_names' => 1, // show language names
|
120 |
'display_names_as' => 'name', // valid options are slug and name
|
@@ -124,102 +129,54 @@ class PLL_Switcher {
|
|
124 |
'post_id' => null, // if not null, link to translations of post defined by post_id
|
125 |
'raw' => 0, // set this to true to build your own custom language switcher
|
126 |
);
|
127 |
-
$args = wp_parse_args($args, $defaults);
|
128 |
-
$args = apply_filters('pll_the_languages_args', $args);
|
129 |
|
130 |
// prevents showing empty options in dropdown
|
131 |
-
if ($args['dropdown'])
|
132 |
$args['show_names'] = 1;
|
|
|
133 |
|
134 |
-
$elements = $this->get_elements($links, $args);
|
135 |
|
136 |
-
if ($args['raw'])
|
137 |
return $elements;
|
|
|
138 |
|
139 |
-
if ($args['dropdown']) {
|
140 |
$args['name'] = 'lang_choice_' . $args['dropdown'];
|
141 |
$walker = new PLL_Walker_Dropdown();
|
142 |
-
$args['selected'] =
|
143 |
}
|
144 |
-
else
|
145 |
$walker = new PLL_Walker_List();
|
|
|
146 |
|
147 |
-
$out = apply_filters('pll_the_languages', $walker->walk($elements, $args), $args);
|
148 |
|
149 |
// javascript to switch the language when using a dropdown list
|
150 |
-
if ($args['dropdown']) {
|
151 |
-
foreach ($links->model->get_languages_list() as $language) {
|
152 |
-
$urls[$language->slug] = $args['force_home'] || ($url = $links->get_translation_url($language))
|
153 |
}
|
154 |
|
155 |
-
// accept only few valid characters for the urls_x variable name (as the widget id includes '-' which is invalid)
|
156 |
-
$out .= sprintf('
|
157 |
<script type="text/javascript">
|
158 |
//<![CDATA[
|
159 |
var %1$s = %2$s;
|
160 |
-
document.getElementById("%3$s").onchange = function() {
|
161 |
location.href = %1$s[this.value];
|
162 |
}
|
163 |
//]]>
|
164 |
</script>',
|
165 |
-
'urls_' . preg_replace('#[^a-zA-Z0-9]#', '', $args['dropdown']), json_encode($urls), esc_js($args['name'])
|
166 |
);
|
167 |
}
|
168 |
|
169 |
-
if ($args['echo'])
|
170 |
echo $out;
|
|
|
171 |
return $out;
|
172 |
}
|
173 |
}
|
174 |
-
|
175 |
-
/*
|
176 |
-
* displays a language list
|
177 |
-
*
|
178 |
-
* @since 1.2
|
179 |
-
*/
|
180 |
-
class PLL_Walker_List extends Walker {
|
181 |
-
var $db_fields = array ('parent' => 'parent', 'id' => 'id');
|
182 |
-
|
183 |
-
/*
|
184 |
-
* outputs one element
|
185 |
-
*
|
186 |
-
* @since 1.2
|
187 |
-
*
|
188 |
-
* @see Walker::start_el
|
189 |
-
*/
|
190 |
-
function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) {
|
191 |
-
$output .= sprintf(
|
192 |
-
"\t".'<li class="%s"><a hreflang="%s" href="%s">%s</a></li>'."\n",
|
193 |
-
implode(' ', $element->classes),
|
194 |
-
esc_attr($element->slug),
|
195 |
-
esc_url($element->url),
|
196 |
-
$args['show_flags'] && $args['show_names'] ? $element->flag.' '.esc_html($element->name) : $element->flag.esc_html($element->name)
|
197 |
-
);
|
198 |
-
}
|
199 |
-
|
200 |
-
/*
|
201 |
-
* overrides Walker::display_element as it expects an object with a parent property
|
202 |
-
*
|
203 |
-
* @since 1.2
|
204 |
-
*
|
205 |
-
* @see Walker::display_element
|
206 |
-
*/
|
207 |
-
function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
|
208 |
-
$element = (object) $element; // make sure we have an object
|
209 |
-
$element->parent = $element->id = 0; // don't care about this
|
210 |
-
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
211 |
-
}
|
212 |
-
|
213 |
-
/*
|
214 |
-
* overrides Walker:walk to set depth argument
|
215 |
-
*
|
216 |
-
* @since 1.2
|
217 |
-
*
|
218 |
-
* @param array $elements elements to display
|
219 |
-
* @param array $args
|
220 |
-
* @return string
|
221 |
-
*/
|
222 |
-
function walk($elements, $args = array()) {
|
223 |
-
return parent::walk($elements, -1, $args);
|
224 |
-
}
|
225 |
-
}
|
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' ) {
|
21 |
$options = array(
|
22 |
+
'show_names' => array( 'string' => __( 'Displays language names', 'polylang' ), 'default' => 1 ),
|
23 |
+
'show_flags' => array( 'string' => __( 'Displays flags', 'polylang' ), 'default' => 0 ),
|
24 |
+
'force_home' => array( 'string' => __( 'Forces link to front page', 'polylang' ), 'default' => 0 ),
|
25 |
+
'hide_current' => array( 'string' => __( 'Hides the current language', 'polylang' ), 'default' => 0 ),
|
26 |
+
'hide_if_no_translation' => array( 'string' => __( 'Hides languages with no translation', 'polylang' ), 'default' => 0 ),
|
27 |
);
|
28 |
|
29 |
+
if ( 'menu' != $type ) {
|
30 |
+
$options = array( 'dropdown' => array( 'string' => __( 'Displays as dropdown', 'polylang' ), 'default' => 0 ) ) + $options;
|
31 |
+
}
|
32 |
|
33 |
+
return wp_list_pluck( $options, $key );
|
34 |
}
|
35 |
|
36 |
/*
|
45 |
* @param array $args
|
46 |
* @return array
|
47 |
*/
|
48 |
+
protected function get_elements( $links, $args ) {
|
49 |
+
foreach ( $links->model->get_languages_list( array( 'hide_empty' => $args['hide_if_empty'] ) ) as $language ) {
|
50 |
$id = (int) $language->term_id;
|
51 |
$slug = $language->slug;
|
52 |
+
$locale = $language->get_locale( 'display' );
|
53 |
+
$classes = array( 'lang-item', 'lang-item-' . $id, 'lang-item-' . esc_attr( $slug ) );
|
54 |
$url = null; // avoids potential notice
|
55 |
|
56 |
+
if ( $current_lang = $links->curlang->slug == $slug ) {
|
57 |
+
if ( $args['hide_current'] && ! $args['dropdown'] ) {
|
58 |
continue; // hide current language except for dropdown
|
59 |
+
}
|
60 |
+
else {
|
61 |
$classes[] = 'current-lang';
|
62 |
+
}
|
63 |
}
|
64 |
|
65 |
+
if ( null !== $args['post_id'] && ( $tr_id = $links->model->post->get( $args['post_id'], $language ) ) && $links->current_user_can_read( $tr_id ) ) {
|
66 |
+
$url = get_permalink( $tr_id );
|
67 |
+
} elseif ( null === $args['post_id'] ) {
|
|
|
68 |
$url = $links->get_translation_url( $language );
|
69 |
}
|
70 |
|
71 |
+
if ( $no_translation = empty( $url ) ) {
|
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
|
78 |
+
if ( empty( $url ) && $args['hide_if_no_translation'] ) {
|
79 |
continue;
|
80 |
+
}
|
81 |
|
82 |
$url = empty( $url ) || $args['force_home'] ? $links->get_home_url( $language ) : $url ; // if the page is not translated, link to the home page
|
83 |
|
84 |
+
$name = $args['show_names'] || ! $args['show_flags'] || $args['raw'] ? ( 'slug' == $args['display_names_as'] ? $slug : $language->name ) : '';
|
85 |
+
$flag = $args['raw'] && ! $args['show_flags'] ? $language->flag_url : ( $args['show_flags'] ? $language->flag : '' );
|
86 |
|
87 |
+
$out[ $slug ] = compact( 'id', 'slug', 'locale', 'name', 'url', 'flag', 'current_lang', 'no_translation', 'classes' );
|
88 |
}
|
|
|
89 |
|
90 |
+
return empty( $out ) ? array() : $out;
|
91 |
}
|
92 |
|
93 |
/*
|
98 |
*
|
99 |
* dropdown => the list is displayed as dropdown if set, defaults to 0
|
100 |
* echo => echoes the list if set to 1, defaults to 1
|
101 |
+
* hide_if_empty => hides languages with no posts ( or pages ) if set to 1, defaults to 1
|
102 |
* show_flags => displays flags if set to 1, defaults to 0
|
103 |
* show_names => show language names if set to 1, defaults to 1
|
104 |
* display_names_as => wether to display the language name or its slug, valid options are 'slug' and 'name', defaults to name
|
114 |
* @param array $args
|
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 = '' ) {
|
118 |
$defaults = array(
|
119 |
'dropdown' => 0, // display as list and not as dropdown
|
120 |
'echo' => 1, // echoes the list
|
121 |
+
'hide_if_empty' => 1, // hides languages with no posts ( or pages )
|
122 |
+
'menu' => 0, // not for nav menu ( this argument is deprecated since v1.1.1 )
|
123 |
'show_flags' => 0, // don't show flags
|
124 |
'show_names' => 1, // show language names
|
125 |
'display_names_as' => 'name', // valid options are slug and name
|
129 |
'post_id' => null, // if not null, link to translations of post defined by post_id
|
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
|
136 |
+
if ( $args['dropdown'] ) {
|
137 |
$args['show_names'] = 1;
|
138 |
+
}
|
139 |
|
140 |
+
$elements = $this->get_elements( $links, $args );
|
141 |
|
142 |
+
if ( $args['raw'] ) {
|
143 |
return $elements;
|
144 |
+
}
|
145 |
|
146 |
+
if ( $args['dropdown'] ) {
|
147 |
$args['name'] = 'lang_choice_' . $args['dropdown'];
|
148 |
$walker = new PLL_Walker_Dropdown();
|
149 |
+
$args['selected'] = $links->curlang->slug;
|
150 |
}
|
151 |
+
else {
|
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
|
158 |
+
if ( $args['dropdown'] ) {
|
159 |
+
foreach ( $links->model->get_languages_list() as $language ) {
|
160 |
+
$urls[ $language->slug ] = $args['force_home'] || ( $url = $links->get_translation_url( $language ) ) === null ? $links->get_home_url( $language ) : $url;
|
161 |
}
|
162 |
|
163 |
+
// accept only few valid characters for the urls_x variable name ( as the widget id includes '-' which is invalid )
|
164 |
+
$out .= sprintf( '
|
165 |
<script type="text/javascript">
|
166 |
//<![CDATA[
|
167 |
var %1$s = %2$s;
|
168 |
+
document.getElementById( "%3$s" ).onchange = function() {
|
169 |
location.href = %1$s[this.value];
|
170 |
}
|
171 |
//]]>
|
172 |
</script>',
|
173 |
+
'urls_' . preg_replace( '#[^a-zA-Z0-9]#', '', $args['dropdown'] ), json_encode( $urls ), esc_js( $args['name'] )
|
174 |
);
|
175 |
}
|
176 |
|
177 |
+
if ( $args['echo'] ) {
|
178 |
echo $out;
|
179 |
+
}
|
180 |
return $out;
|
181 |
}
|
182 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include/translated-object.php
ADDED
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* setups the objects languages and translations model
|
5 |
+
*
|
6 |
+
* @since 1.8
|
7 |
+
*/
|
8 |
+
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 |
+
|
15 |
+
// register our taxonomies as soon as possible
|
16 |
+
// this is early registration, not ready for rewrite rules as wp_rewrite will be setup later
|
17 |
+
$args = array( 'label' => false, 'public' => false, 'query_var' => false, 'rewrite' => false, '_pll' => true );
|
18 |
+
register_taxonomy( $this->tax_language, $this->object_type, $args );
|
19 |
+
$args['update_count_callback'] = '_update_generic_term_count'; // count *all* posts to avoid deleting in clean_translations_terms
|
20 |
+
register_taxonomy( $this->tax_translations, $this->object_type, $args );
|
21 |
+
}
|
22 |
+
|
23 |
+
/*
|
24 |
+
* wrap wp_get_object_terms to cache it and return only one object
|
25 |
+
* inspired by the function get_the_terms
|
26 |
+
*
|
27 |
+
* @since 1.2
|
28 |
+
*
|
29 |
+
* @param int $object_id post_id or term_id
|
30 |
+
* @param string $taxonomy Polylang taxonomy depending if we are looking for a post ( or term ) language ( or translation )
|
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 ) {
|
34 |
+
if ( empty( $object_id ) ) {
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
$object_id = (int) $object_id;
|
39 |
+
$term = get_object_term_cache( $object_id, $taxonomy );
|
40 |
+
|
41 |
+
if ( false === $term ) {
|
42 |
+
// query language and translations at the same time
|
43 |
+
$taxonomies = array( $this->tax_language, $this->tax_translations );
|
44 |
+
|
45 |
+
// query terms
|
46 |
+
foreach ( wp_get_object_terms( $object_id, $taxonomies ) as $t ) {
|
47 |
+
$terms[ $t->taxonomy ] = $t;
|
48 |
+
if ( $t->taxonomy == $taxonomy ) {
|
49 |
+
$term = $t;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
// store it the way WP wants it
|
54 |
+
// set an empty cache if no term found in the taxonomy
|
55 |
+
foreach ( $taxonomies as $tax ) {
|
56 |
+
wp_cache_add( $object_id, empty( $terms[ $tax ] ) ? array() : array( $terms[ $tax ] ), $tax . '_relationships' );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
else {
|
60 |
+
$term = reset( $term );
|
61 |
+
}
|
62 |
+
|
63 |
+
return empty( $term ) ? false : $term;
|
64 |
+
}
|
65 |
+
|
66 |
+
/*
|
67 |
+
* tells wether to store a translation term
|
68 |
+
*
|
69 |
+
* @since 1.8
|
70 |
+
*
|
71 |
+
* @param array $translations: an associative array of translations with language code as key and translation id as value
|
72 |
+
*/
|
73 |
+
protected function keep_translation_group( $translations ) {
|
74 |
+
return count( $translations ) > 1;
|
75 |
+
}
|
76 |
+
|
77 |
+
/*
|
78 |
+
* saves translations for posts or terms
|
79 |
+
*
|
80 |
+
* @since 0.5
|
81 |
+
*
|
82 |
+
* @param int $id post id or term id
|
83 |
+
* @param array $translations: an associative array of translations with language code as key and translation id as value
|
84 |
+
*/
|
85 |
+
public function save_translations( $id, $translations ) {
|
86 |
+
$id = (int) $id;
|
87 |
+
|
88 |
+
if ( ( $lang = $this->get_language( $id ) ) && isset( $translations ) && is_array( $translations ) ) {
|
89 |
+
// sanitize the translations array
|
90 |
+
$translations = array_map( 'intval', $translations );
|
91 |
+
$translations = array_merge( array( $lang->slug => $id ), $translations ); // make sure this object is in translations
|
92 |
+
$translations = array_diff( $translations, array( 0 ) ); // don't keep non translated languages
|
93 |
+
$translations = array_intersect_key( $translations, array_flip( $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) ); // keep only valid languages slugs as keys
|
94 |
+
|
95 |
+
// unlink removed translations
|
96 |
+
$old_translations = $this->get_translations( $id );
|
97 |
+
foreach ( array_diff_assoc( $old_translations, $translations ) as $object_id ) {
|
98 |
+
$this->delete_translation( $object_id );
|
99 |
+
}
|
100 |
+
|
101 |
+
// don't create a translation group for untranslated posts as it is useless
|
102 |
+
// but we need one for terms to allow relationships remap when importing from a WXR file
|
103 |
+
if ( $this->keep_translation_group( $translations ) ) {
|
104 |
+
$terms = wp_get_object_terms( $translations, $this->tax_translations );
|
105 |
+
$term = reset( $terms );
|
106 |
+
|
107 |
+
// create a new term if necessary
|
108 |
+
if ( empty( $term ) ) {
|
109 |
+
wp_insert_term( $group = uniqid( 'pll_' ), $this->tax_translations, array( 'description' => serialize( $translations ) ) );
|
110 |
+
}
|
111 |
+
else {
|
112 |
+
// take care not to overwrite extra data stored in description field, if any
|
113 |
+
$d = unserialize( $term->description );
|
114 |
+
$d = is_array( $d ) ? array_diff_key( $d, $old_translations ) : array(); // remove old translations
|
115 |
+
$d = array_merge( $d, $translations ); // add new one
|
116 |
+
wp_update_term( $group = (int) $term->term_id, $this->tax_translations, array( 'description' => serialize( $d ) ) );
|
117 |
+
}
|
118 |
+
|
119 |
+
// link all translations to the new term
|
120 |
+
foreach ( $translations as $p ) {
|
121 |
+
wp_set_object_terms( $p, $group, $this->tax_translations );
|
122 |
+
}
|
123 |
+
|
124 |
+
// clean now unused translation groups
|
125 |
+
foreach ( wp_list_pluck( $terms, 'term_id' ) as $term_id ) {
|
126 |
+
$term = get_term( $term_id, $this->tax_translations );
|
127 |
+
if ( empty( $term->count ) ) {
|
128 |
+
wp_delete_term( $term_id, $this->tax_translations );
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
/*
|
136 |
+
* deletes a translation of a post or term
|
137 |
+
*
|
138 |
+
* @since 0.5
|
139 |
+
*
|
140 |
+
* @param int $id post id or term id
|
141 |
+
*/
|
142 |
+
public function delete_translation( $id ) {
|
143 |
+
$id = (int) $id;
|
144 |
+
$term = $this->get_object_term( $id, $this->tax_translations );
|
145 |
+
|
146 |
+
if ( ! empty( $term ) ) {
|
147 |
+
$d = unserialize( $term->description );
|
148 |
+
$slug = array_search( $id, $this->get_translations( $id ) ); // in case some plugin stores the same value with different key
|
149 |
+
unset( $d[ $slug ] );
|
150 |
+
|
151 |
+
if ( empty( $d ) ) {
|
152 |
+
wp_delete_term( (int) $term->term_id, $this->tax_translations );
|
153 |
+
}
|
154 |
+
else {
|
155 |
+
wp_update_term( (int) $term->term_id, $this->tax_translations, array( 'description' => serialize( $d ) ) );
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
/*
|
161 |
+
* returns an array of translations of a post or term
|
162 |
+
*
|
163 |
+
* @since 0.5
|
164 |
+
*
|
165 |
+
* @param int $id post id or term id
|
166 |
+
* @return array an associative array of translations with language code as key and translation id as value
|
167 |
+
*/
|
168 |
+
public function get_translations( $id ) {
|
169 |
+
$term = $this->get_object_term( $id, $this->tax_translations );
|
170 |
+
$translations = empty( $term ) ? array() : unserialize( $term->description );
|
171 |
+
|
172 |
+
// make sure we return only translations ( thus we allow plugins to store other informations in the array )
|
173 |
+
$translations = array_intersect_key( $translations, array_flip( $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) );
|
174 |
+
|
175 |
+
// make sure to return at least the passed post or term in its translation array
|
176 |
+
if ( empty( $translations ) && $lang = $this->get_language( $id ) ) {
|
177 |
+
$translations = array( $lang->slug => $id );
|
178 |
+
}
|
179 |
+
|
180 |
+
return $translations;
|
181 |
+
}
|
182 |
+
|
183 |
+
/*
|
184 |
+
* returns the id of the translation of a post or term
|
185 |
+
*
|
186 |
+
* @since 0.5
|
187 |
+
*
|
188 |
+
* @param int $id post id or term id
|
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 |
+
*/
|
192 |
+
public function get_translation( $id, $lang ) {
|
193 |
+
if ( ! $lang = $this->model->get_language( $lang ) ) {
|
194 |
+
return false;
|
195 |
+
}
|
196 |
+
|
197 |
+
$translations = $this->get_translations( $id );
|
198 |
+
|
199 |
+
return isset( $translations[ $lang->slug ] ) ? $translations[ $lang->slug ] : false;
|
200 |
+
}
|
201 |
+
|
202 |
+
/*
|
203 |
+
* among the object and its translations, returns the id of the object which is in $lang
|
204 |
+
*
|
205 |
+
* @since 0.1
|
206 |
+
*
|
207 |
+
* @param int $id post id or term id
|
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 ) {
|
212 |
+
$obj_lang = $this->get_language( $id ); // FIXME is this necessary?
|
213 |
+
if ( ! $lang || ! $obj_lang ) {
|
214 |
+
return false;
|
215 |
+
}
|
216 |
+
|
217 |
+
$lang = $this->model->get_language( $lang );
|
218 |
+
return $obj_lang->term_id == $lang->term_id ? $id : $this->get_translation( $id, $lang );
|
219 |
+
}
|
220 |
+
|
221 |
+
/*
|
222 |
+
* a where clause to add to sql queries when filtering by language is needed directly in query
|
223 |
+
*
|
224 |
+
* @since 1.2
|
225 |
+
*
|
226 |
+
* @param object|array|string $lang a PLL_Language object or a comma separated list of languag slug or an array of language slugs
|
227 |
+
* @return string where clause
|
228 |
+
*/
|
229 |
+
public function where_clause( $lang ) {
|
230 |
+
global $wpdb;
|
231 |
+
$tt_id = $this->tax_tt;
|
232 |
+
|
233 |
+
// $lang is an object
|
234 |
+
// generally the case if the query is coming from Polylang
|
235 |
+
if ( is_object( $lang ) ) {
|
236 |
+
return $wpdb->prepare( ' AND pll_tr.term_taxonomy_id = %d', $lang->$tt_id );
|
237 |
+
}
|
238 |
+
|
239 |
+
// $lang is a comma separated list of slugs ( or an array of slugs )
|
240 |
+
// generally the case is the query is coming from outside with 'lang' parameter
|
241 |
+
$slugs = is_array( $lang ) ? $lang : explode( ',', $lang );
|
242 |
+
foreach ( $slugs as $slug ) {
|
243 |
+
$languages[] = (int) $this->model->get_language( $slug )->$tt_id;
|
244 |
+
}
|
245 |
+
|
246 |
+
return ' AND pll_tr.term_taxonomy_id IN ( ' . implode( ',', $languages ) . ' )';
|
247 |
+
}
|
248 |
+
|
249 |
+
/*
|
250 |
+
* returns ids of objects in a language similarly to get_objects_in_term for a taxonomy
|
251 |
+
* faster than get_objects_in_term as it avoids a JOIN
|
252 |
+
*
|
253 |
+
* @since 1.4
|
254 |
+
*
|
255 |
+
* @param object $lang a PLL_Language object
|
256 |
+
* @return array
|
257 |
+
*/
|
258 |
+
public function get_objects_in_language( $lang ) {
|
259 |
+
global $wpdb;
|
260 |
+
$tt_id = $this->tax_tt;
|
261 |
+
return $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $lang->$tt_id ) );
|
262 |
+
}
|
263 |
+
}
|
include/translated-post.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
public function __construct( &$model ) {
|
11 |
+
// init properties
|
12 |
+
$this->object_type = null;
|
13 |
+
$this->tax_language = 'language';
|
14 |
+
$this->tax_translations = 'post_translations';
|
15 |
+
$this->tax_tt = 'term_taxonomy_id';
|
16 |
+
|
17 |
+
parent::__construct( $model );
|
18 |
+
|
19 |
+
// registers completely the language taxonomy
|
20 |
+
add_action( 'setup_theme', array( &$this, 'register_taxonomy' ), 1 );
|
21 |
+
|
22 |
+
// setups post types to translate
|
23 |
+
add_action( 'registered_post_type', array( &$this, 'registered_post_type' ) );
|
24 |
+
|
25 |
+
// forces updating posts cache
|
26 |
+
add_action( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
|
27 |
+
}
|
28 |
+
|
29 |
+
/*
|
30 |
+
* store the post language in the database
|
31 |
+
*
|
32 |
+
* @since 0.6
|
33 |
+
*
|
34 |
+
* @param int $post_id post id
|
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 |
+
* returns the language of a post
|
43 |
+
*
|
44 |
+
* @since 0.1
|
45 |
+
*
|
46 |
+
* @param int $post_id post id
|
47 |
+
* @return bool|object PLL_Language object, false if no language is associated to that post
|
48 |
+
*/
|
49 |
+
public function get_language( $post_id ) {
|
50 |
+
$lang = $this->get_object_term( $post_id, 'language' );
|
51 |
+
return ( $lang ) ? $this->model->get_language( $lang ) : false;
|
52 |
+
}
|
53 |
+
|
54 |
+
/*
|
55 |
+
* deletes a translation
|
56 |
+
*
|
57 |
+
* @since 0.5
|
58 |
+
*
|
59 |
+
* @param int $id post id
|
60 |
+
*/
|
61 |
+
public function delete_translation( $id ) {
|
62 |
+
parent::delete_translation( $id );
|
63 |
+
wp_set_object_terms( $id, null, $this->tax_translations );
|
64 |
+
}
|
65 |
+
|
66 |
+
/*
|
67 |
+
* a join clause to add to sql queries when filtering by language is needed directly in query
|
68 |
+
*
|
69 |
+
* @since 1.2
|
70 |
+
*
|
71 |
+
* @return string join clause
|
72 |
+
*/
|
73 |
+
public function join_clause() {
|
74 |
+
global $wpdb;
|
75 |
+
return " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = ID";
|
76 |
+
}
|
77 |
+
|
78 |
+
/*
|
79 |
+
* register the language taxonomy
|
80 |
+
*
|
81 |
+
* @since 1.2
|
82 |
+
*/
|
83 |
+
public function register_taxonomy() {
|
84 |
+
register_taxonomy( 'language', $this->model->get_translated_post_types(), array(
|
85 |
+
'labels' => array(
|
86 |
+
'name' => __( 'Languages', 'polylang' ),
|
87 |
+
'singular_name' => __( 'Language', 'polylang' ),
|
88 |
+
'all_items' => __( 'All languages', 'polylang' ),
|
89 |
+
),
|
90 |
+
'public' => true, // since WP 4.4 we must set it to true for WP to accept our query var
|
91 |
+
'show_ui' => false, // hide the taxonomy on admin side
|
92 |
+
'show_in_nav_menus' => false, // no metabox for nav menus
|
93 |
+
'query_var' => 'lang',
|
94 |
+
'rewrite' => $this->model->options['force_lang'] < 2, // no rewrite for domains and sub-domains
|
95 |
+
'_pll' => true, // polylang taxonomy
|
96 |
+
) );
|
97 |
+
}
|
98 |
+
|
99 |
+
/*
|
100 |
+
* check if registered post type must be translated
|
101 |
+
*
|
102 |
+
* @since 1.2
|
103 |
+
*
|
104 |
+
* @param string $post_type post type name
|
105 |
+
*/
|
106 |
+
public function registered_post_type( $post_type ) {
|
107 |
+
if ( $this->model->is_translated_post_type( $post_type ) ) {
|
108 |
+
register_taxonomy_for_object_type( 'language', $post_type );
|
109 |
+
register_taxonomy_for_object_type( 'post_translations', $post_type );
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
/*
|
114 |
+
* forces calling 'update_object_term_cache' when querying posts or pages
|
115 |
+
* this is especially useful for nav menus with a lot of pages
|
116 |
+
* without doing this, we would have one query per page in the menu to get the page language for the permalink
|
117 |
+
*
|
118 |
+
* @since 1.8
|
119 |
+
*
|
120 |
+
* @param object $query reference to the query object
|
121 |
+
*/
|
122 |
+
public function pre_get_posts( $query ) {
|
123 |
+
if ( ! empty( $query->query['post_type'] ) && $this->model->is_translated_post_type( $query->query['post_type'] ) ) {
|
124 |
+
$query->query_vars['update_post_term_cache'] = true;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
include/translated-term.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
public function __construct( &$model ) {
|
11 |
+
$this->object_type = 'term';
|
12 |
+
$this->tax_language = 'term_language';
|
13 |
+
$this->tax_translations = 'term_translations';
|
14 |
+
$this->tax_tt = 'tl_term_taxonomy_id';
|
15 |
+
|
16 |
+
parent::__construct( $model );
|
17 |
+
|
18 |
+
// filters to prime terms cache
|
19 |
+
add_filter( 'get_terms', array( &$this, '_prime_terms_cache' ), 10, 2 );
|
20 |
+
add_filter( 'wp_get_object_terms', array( &$this, 'wp_get_object_terms' ), 10, 3 );
|
21 |
+
}
|
22 |
+
|
23 |
+
/*
|
24 |
+
* stores the term language in the database
|
25 |
+
*
|
26 |
+
* @since 0.6
|
27 |
+
*
|
28 |
+
* @param int $term_id term id
|
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;
|
33 |
+
wp_set_object_terms( $term_id, $lang ? $this->model->get_language( $lang )->tl_term_id : '', 'term_language' );
|
34 |
+
|
35 |
+
// add translation group for correct WXR export
|
36 |
+
$translations = $this->get_translations( $term_id );
|
37 |
+
if ( $slug = array_search( $term_id, $translations ) ) {
|
38 |
+
unset( $translations[ $slug ] );
|
39 |
+
}
|
40 |
+
|
41 |
+
$this->save_translations( $term_id, $translations );
|
42 |
+
}
|
43 |
+
|
44 |
+
/*
|
45 |
+
* removes the term language in database
|
46 |
+
*
|
47 |
+
* @since 0.5
|
48 |
+
*
|
49 |
+
* @param int $term_id term id
|
50 |
+
*/
|
51 |
+
public function delete_language( $term_id ) {
|
52 |
+
wp_delete_object_term_relationships( $term_id, 'term_language' );
|
53 |
+
}
|
54 |
+
|
55 |
+
/*
|
56 |
+
* returns the language of a term
|
57 |
+
*
|
58 |
+
* @since 0.1
|
59 |
+
*
|
60 |
+
* @param int|string $value term id or term slug
|
61 |
+
* @param string $taxonomy optional taxonomy needed when the term slug is passed as first parameter
|
62 |
+
* @return bool|object PLL_Language object, false if no language is associated to that term
|
63 |
+
*/
|
64 |
+
public function get_language( $value, $taxonomy = '' ) {
|
65 |
+
if ( is_numeric( $value ) ) {
|
66 |
+
$term_id = $value;
|
67 |
+
}
|
68 |
+
|
69 |
+
// get_term_by still not cached in WP 3.5.1 but internally, the function is always called by term_id
|
70 |
+
elseif ( is_string( $value ) && $taxonomy ) {
|
71 |
+
$term_id = get_term_by( 'slug', $value , $taxonomy )->term_id;
|
72 |
+
}
|
73 |
+
|
74 |
+
// get the language and make sure it is a PLL_Language 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 |
+
* tells the parent class to always store a translation term
|
80 |
+
*
|
81 |
+
* @since 1.8
|
82 |
+
*
|
83 |
+
* @param array $translations: an associative array of translations with language code as key and translation id as value
|
84 |
+
*/
|
85 |
+
protected function keep_translation_group( $translations ) {
|
86 |
+
return true;
|
87 |
+
}
|
88 |
+
|
89 |
+
/*
|
90 |
+
* deletes a translation
|
91 |
+
*
|
92 |
+
* @since 0.5
|
93 |
+
*
|
94 |
+
* @param int $id term id
|
95 |
+
*/
|
96 |
+
public function delete_translation( $id ) {
|
97 |
+
global $wpdb;
|
98 |
+
$slug = array_search( $id, $this->get_translations( $id ) ); // in case some plugin stores the same value with different key
|
99 |
+
|
100 |
+
parent::delete_translation( $id );
|
101 |
+
|
102 |
+
if ( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( * ) FROM $wpdb->terms WHERE term_id = %d;", $id ) ) ) {
|
103 |
+
// always keep a group for terms to allow relationships remap when importing from a WXR file
|
104 |
+
$translations[ $slug ] = $id;
|
105 |
+
wp_insert_term( $group = uniqid( 'pll_' ), 'term_translations', array( 'description' => serialize( $translations ) ) );
|
106 |
+
wp_set_object_terms( $id, $group, 'term_translations' );
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
/*
|
111 |
+
* a join clause to add to sql queries when filtering by language is needed directly in query
|
112 |
+
*
|
113 |
+
* @since 1.2
|
114 |
+
*
|
115 |
+
* @return string join clause
|
116 |
+
*/
|
117 |
+
public function join_clause() {
|
118 |
+
global $wpdb;
|
119 |
+
return " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = t.term_id";
|
120 |
+
}
|
121 |
+
|
122 |
+
/*
|
123 |
+
* cache language and translations when terms are queried by get_terms
|
124 |
+
*
|
125 |
+
* @since 1.2
|
126 |
+
*
|
127 |
+
* @param array $terms queried terms
|
128 |
+
* @param array $taxonomies queried taxonomies
|
129 |
+
* @return array unmodified $terms
|
130 |
+
*/
|
131 |
+
public function _prime_terms_cache( $terms, $taxonomies ) {
|
132 |
+
if ( $this->model->is_translated_taxonomy( $taxonomies ) ) {
|
133 |
+
foreach ( $terms as $term ) {
|
134 |
+
$term_ids[] = is_object( $term ) ? $term->term_id : (int) $term;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
if ( ! empty( $term_ids ) ) {
|
139 |
+
update_object_term_cache( array_unique( $term_ids ), 'term' ); // adds language and translation of terms to cache
|
140 |
+
}
|
141 |
+
return $terms;
|
142 |
+
}
|
143 |
+
|
144 |
+
/*
|
145 |
+
* when terms are found for posts, add their language and translations to cache
|
146 |
+
*
|
147 |
+
* @since 1.2
|
148 |
+
*
|
149 |
+
* @param array $terms terms found
|
150 |
+
* @param array $object_ids not used
|
151 |
+
* @param array $taxonomies terms taxonomies
|
152 |
+
* @return array unmodified $terms
|
153 |
+
*/
|
154 |
+
public function wp_get_object_terms( $terms, $object_ids, $taxonomies ) {
|
155 |
+
$taxonomies = explode( "', '", trim( $taxonomies, "'" ) );
|
156 |
+
if ( ! in_array( 'term_translations', $taxonomies ) ) {
|
157 |
+
$this->_prime_terms_cache( $terms, $taxonomies );
|
158 |
+
}
|
159 |
+
return $terms;
|
160 |
+
}
|
161 |
+
}
|
include/walker-dropdown.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Walker_Dropdown extends Walker {
|
9 |
-
var $db_fields = array
|
10 |
|
11 |
/*
|
12 |
* outputs one element
|
@@ -19,9 +19,9 @@ class PLL_Walker_Dropdown extends Walker {
|
|
19 |
$value = $args['value'];
|
20 |
$output .= sprintf(
|
21 |
"\t".'<option value="%s"%s>%s</option>'."\n",
|
22 |
-
esc_attr($element->$value),
|
23 |
-
isset($args['selected']) && $args['selected'] === $element->$value ? ' selected="selected"' : '',
|
24 |
-
esc_html($element->name)
|
25 |
);
|
26 |
}
|
27 |
|
@@ -57,26 +57,26 @@ class PLL_Walker_Dropdown extends Walker {
|
|
57 |
* @param array $args
|
58 |
* @return string
|
59 |
*/
|
60 |
-
function walk($elements, $args = array()) {
|
61 |
$output = '';
|
62 |
-
$args = wp_parse_args($args, array('value' => 'slug', 'name' => 'lang_choice'));
|
63 |
|
64 |
-
if (!empty($args['flag'])) {
|
65 |
-
$current = wp_list_filter($elements, array($args['value'] => $args['selected']));
|
66 |
-
$lang = reset($current);
|
67 |
$output = sprintf(
|
68 |
'<span class="pll-select-flag">%s</span>',
|
69 |
-
empty($lang->flag) ? esc_html($lang->slug) : $lang->flag
|
70 |
);
|
71 |
}
|
72 |
|
73 |
$output .= sprintf(
|
74 |
'<select name="%1$s" %2$s%3$s%4$s>' . "\n" . '%5$s' . "\n" . '</select>'."\n",
|
75 |
-
$name = esc_attr($args['name']),
|
76 |
-
isset($args['id']) &&
|
77 |
-
empty($args['class']) ? '' : ' class="' . esc_attr($args['class']) . '"',
|
78 |
-
empty($args['disabled']) ? '' : ' disabled="disabled"',
|
79 |
-
parent::walk($elements, -1, $args)
|
80 |
);
|
81 |
|
82 |
return $output;
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Walker_Dropdown extends Walker {
|
9 |
+
var $db_fields = array( 'parent' => 'parent', 'id' => 'id' );
|
10 |
|
11 |
/*
|
12 |
* outputs one element
|
19 |
$value = $args['value'];
|
20 |
$output .= sprintf(
|
21 |
"\t".'<option value="%s"%s>%s</option>'."\n",
|
22 |
+
esc_attr( $element->$value ),
|
23 |
+
isset( $args['selected'] ) && $args['selected'] === $element->$value ? ' selected="selected"' : '',
|
24 |
+
esc_html( $element->name )
|
25 |
);
|
26 |
}
|
27 |
|
57 |
* @param array $args
|
58 |
* @return string
|
59 |
*/
|
60 |
+
function walk( $elements, $args = array() ) {
|
61 |
$output = '';
|
62 |
+
$args = wp_parse_args( $args, array( 'value' => 'slug', 'name' => 'lang_choice' ) );
|
63 |
|
64 |
+
if ( ! empty( $args['flag'] ) ) {
|
65 |
+
$current = wp_list_filter( $elements, array( $args['value'] => $args['selected'] ) );
|
66 |
+
$lang = reset( $current );
|
67 |
$output = sprintf(
|
68 |
'<span class="pll-select-flag">%s</span>',
|
69 |
+
empty( $lang->flag ) ? esc_html( $lang->slug ) : $lang->flag
|
70 |
);
|
71 |
}
|
72 |
|
73 |
$output .= sprintf(
|
74 |
'<select name="%1$s" %2$s%3$s%4$s>' . "\n" . '%5$s' . "\n" . '</select>'."\n",
|
75 |
+
$name = esc_attr( $args['name'] ),
|
76 |
+
isset( $args['id'] ) && ! $args['id'] ? '' : ' id="' . ( empty( $args['id'] ) ? $name : esc_attr( $args['id'] ) ) . '"',
|
77 |
+
empty( $args['class'] ) ? '' : ' class="' . esc_attr( $args['class'] ) . '"',
|
78 |
+
empty( $args['disabled'] ) ? '' : ' disabled="disabled"',
|
79 |
+
parent::walk( $elements, -1, $args )
|
80 |
);
|
81 |
|
82 |
return $output;
|
include/walker-list.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*
|
16 |
+
* @see Walker::start_el
|
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 |
+
$args['show_flags'] && $args['show_names'] ? $element->flag.' '.esc_html( $element->name ) : $element->flag.esc_html( $element->name )
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
/*
|
29 |
+
* overrides Walker::display_element as it expects an object with a parent property
|
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; // make sure we have an object
|
37 |
+
$element->parent = $element->id = 0; // don't care about this
|
38 |
+
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
39 |
+
}
|
40 |
+
|
41 |
+
/*
|
42 |
+
* overrides Walker:walk to set depth argument
|
43 |
+
*
|
44 |
+
* @since 1.2
|
45 |
+
*
|
46 |
+
* @param array $elements elements to display
|
47 |
+
* @param array $args
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
function walk( $elements, $args = array() ) {
|
51 |
+
return parent::walk( $elements, -1, $args );
|
52 |
+
}
|
53 |
+
}
|
include/widget-calendar.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if(!class_exists('WP_Widget_Calendar')){
|
4 |
require_once( ABSPATH . '/wp-includes/default-widgets.php' );
|
5 |
}
|
6 |
|
@@ -25,12 +25,13 @@ 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 )
|
31 |
echo $args['before_title'] . $title . $args['after_title'];
|
|
|
32 |
echo '<div id="calendar_wrap">';
|
33 |
-
empty(
|
34 |
echo '</div>';
|
35 |
echo $args['after_widget'];
|
36 |
}
|
@@ -44,15 +45,15 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
44 |
* @param bool $echo Optional, default is true. Set to false for return.
|
45 |
* @return string|null String when retrieving, null when displaying.
|
46 |
*/
|
47 |
-
static function get_calendar($initial = true, $echo = true) {
|
48 |
-
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts
|
49 |
|
50 |
-
$join_clause =
|
51 |
-
$where_clause =
|
52 |
|
53 |
-
$key = md5(
|
54 |
if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
|
55 |
-
if ( is_array($cache) && isset( $cache[ $key ] ) ) {
|
56 |
if ( $echo ) {
|
57 |
/** This filter is documented in wp-includes/general-template.php */
|
58 |
echo apply_filters( 'get_calendar', $cache[$key] );
|
@@ -64,12 +65,12 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
64 |
}
|
65 |
}
|
66 |
|
67 |
-
if ( !is_array($cache) )
|
68 |
$cache = array();
|
69 |
|
70 |
// Quick check. If we have no posts at all, abort!
|
71 |
if ( !$posts ) {
|
72 |
-
$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
|
73 |
if ( !$gotsome ) {
|
74 |
$cache[ $key ] = '';
|
75 |
wp_cache_set( 'get_calendar', $cache, 'calendar' );
|
@@ -77,65 +78,65 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
77 |
}
|
78 |
}
|
79 |
|
80 |
-
if ( isset($_GET['w']) )
|
81 |
-
$w = ''.intval($_GET['w']);
|
82 |
|
83 |
// week_begins = 0 stands for Sunday
|
84 |
-
$week_begins = intval(get_option('start_of_week'));
|
85 |
|
86 |
// Let's figure out when we are
|
87 |
-
if ( !empty($monthnum) && !empty($year) ) {
|
88 |
-
$thismonth = ''.zeroise(intval($monthnum), 2);
|
89 |
-
$thisyear = ''.intval($year);
|
90 |
-
} elseif ( !empty($w) ) {
|
91 |
// We need to get the month from MySQL
|
92 |
-
$thisyear = ''.intval(substr($m, 0, 4));
|
93 |
-
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
94 |
-
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
95 |
-
} elseif ( !empty($m) ) {
|
96 |
-
$thisyear = ''.intval(substr($m, 0, 4));
|
97 |
-
if ( strlen($m) < 6 )
|
98 |
$thismonth = '01';
|
99 |
else
|
100 |
-
$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
|
101 |
} else {
|
102 |
-
$thisyear = gmdate('Y', current_time('timestamp'));
|
103 |
-
$thismonth = gmdate('m', current_time('timestamp'));
|
104 |
}
|
105 |
|
106 |
-
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
107 |
-
$last_day = date('t', $unixmonth);
|
108 |
|
109 |
// Get the next and previous month and year with at least one post
|
110 |
-
$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
111 |
FROM $wpdb->posts $join_clause
|
112 |
WHERE post_date < '$thisyear-$thismonth-01'
|
113 |
AND post_type = 'post' AND post_status = 'publish' $where_clause
|
114 |
ORDER BY post_date DESC
|
115 |
-
LIMIT 1"); #modified#
|
116 |
-
$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
117 |
FROM $wpdb->posts $join_clause
|
118 |
WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
|
119 |
AND post_type = 'post' AND post_status = 'publish' $where_clause
|
120 |
ORDER BY post_date ASC
|
121 |
-
LIMIT 1"); #modified#
|
122 |
|
123 |
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
|
124 |
-
$calendar_caption = _x('%1$s %2$s', 'calendar caption');
|
125 |
$calendar_output = '<table id="wp-calendar">
|
126 |
-
<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
|
127 |
<thead>
|
128 |
<tr>';
|
129 |
|
130 |
$myweek = array();
|
131 |
|
132 |
for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
|
133 |
-
$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
|
134 |
}
|
135 |
|
136 |
foreach ( $myweek as $wd ) {
|
137 |
-
$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
|
138 |
-
$wd = esc_attr($wd);
|
139 |
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
|
140 |
}
|
141 |
|
@@ -147,7 +148,7 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
147 |
<tr>';
|
148 |
|
149 |
if ( $previous ) {
|
150 |
-
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
|
151 |
} else {
|
152 |
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
|
153 |
}
|
@@ -155,7 +156,7 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
155 |
$calendar_output .= "\n\t\t".'<td class="pad"> </td>';
|
156 |
|
157 |
if ( $next ) {
|
158 |
-
$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
|
159 |
} else {
|
160 |
$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
|
161 |
}
|
@@ -170,24 +171,24 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
170 |
$daywithpost = array();
|
171 |
|
172 |
// Get days with posts
|
173 |
-
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
|
174 |
FROM $wpdb->posts $join_clause
|
175 |
WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
|
176 |
AND post_type = 'post' AND post_status = 'publish' $where_clause
|
177 |
-
AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N); #modified#
|
178 |
if ( $dayswithposts ) {
|
179 |
foreach ( (array) $dayswithposts as $daywith ) {
|
180 |
$daywithpost[] = $daywith[0];
|
181 |
}
|
182 |
}
|
183 |
|
184 |
-
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
|
185 |
$ak_title_separator = "\n";
|
186 |
else
|
187 |
$ak_title_separator = ', ';
|
188 |
|
189 |
$ak_titles_for_day = array();
|
190 |
-
$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
|
191 |
."FROM $wpdb->posts $join_clause "
|
192 |
."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
|
193 |
."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
|
@@ -199,9 +200,9 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
199 |
/** This filter is documented in wp-includes/post-template.php */
|
200 |
$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
|
201 |
|
202 |
-
if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
|
203 |
$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
204 |
-
if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
|
205 |
$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
|
206 |
else
|
207 |
$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
|
@@ -209,34 +210,34 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
|
|
209 |
}
|
210 |
|
211 |
// See how much we should pad in the beginning
|
212 |
-
$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
|
213 |
if ( 0 != $pad )
|
214 |
-
$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';
|
215 |
|
216 |
-
$daysinmonth = intval(date('t', $unixmonth));
|
217 |
for ( $day = 1; $day <= $daysinmonth; ++$day ) {
|
218 |
-
if ( isset($newrow) && $newrow )
|
219 |
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
220 |
$newrow = false;
|
221 |
|
222 |
-
if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
|
223 |
$calendar_output .= '<td id="today">';
|
224 |
else
|
225 |
$calendar_output .= '<td>';
|
226 |
|
227 |
-
if ( in_array($day, $daywithpost) ) // any posts today?
|
228 |
$calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
|
229 |
else
|
230 |
$calendar_output .= $day;
|
231 |
$calendar_output .= '</td>';
|
232 |
|
233 |
-
if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
|
234 |
$newrow = true;
|
235 |
}
|
236 |
|
237 |
-
$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
|
238 |
if ( $pad != 0 && $pad != 7 )
|
239 |
-
$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';
|
240 |
|
241 |
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
|
242 |
|
1 |
<?php
|
2 |
|
3 |
+
if ( ! class_exists( 'WP_Widget_Calendar' ) ) {
|
4 |
require_once( ABSPATH . '/wp-includes/default-widgets.php' );
|
5 |
}
|
6 |
|
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 ) {
|
31 |
echo $args['before_title'] . $title . $args['after_title'];
|
32 |
+
}
|
33 |
echo '<div id="calendar_wrap">';
|
34 |
+
empty( PLL()->curlang ) ? get_calendar() : self::get_calendar(); #modified#
|
35 |
echo '</div>';
|
36 |
echo $args['after_widget'];
|
37 |
}
|
45 |
* @param bool $echo Optional, default is true. Set to false for return.
|
46 |
* @return string|null String when retrieving, null when displaying.
|
47 |
*/
|
48 |
+
static function get_calendar( $initial = true, $echo = true ) {
|
49 |
+
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
|
50 |
|
51 |
+
$join_clause = PLL()->model->post->join_clause(); #added#
|
52 |
+
$where_clause = PLL()->model->post->where_clause( PLL()->curlang ); #added#
|
53 |
|
54 |
+
$key = md5( PLL()->curlang->slug . $m . $monthnum . $year ); #modified#
|
55 |
if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
|
56 |
+
if ( is_array( $cache ) && isset( $cache[ $key ] ) ) {
|
57 |
if ( $echo ) {
|
58 |
/** This filter is documented in wp-includes/general-template.php */
|
59 |
echo apply_filters( 'get_calendar', $cache[$key] );
|
65 |
}
|
66 |
}
|
67 |
|
68 |
+
if ( !is_array( $cache ) )
|
69 |
$cache = array();
|
70 |
|
71 |
// Quick check. If we have no posts at all, abort!
|
72 |
if ( !$posts ) {
|
73 |
+
$gotsome = $wpdb->get_var( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
|
74 |
if ( !$gotsome ) {
|
75 |
$cache[ $key ] = '';
|
76 |
wp_cache_set( 'get_calendar', $cache, 'calendar' );
|
78 |
}
|
79 |
}
|
80 |
|
81 |
+
if ( isset( $_GET['w'] ) )
|
82 |
+
$w = ''.intval( $_GET['w'] );
|
83 |
|
84 |
// week_begins = 0 stands for Sunday
|
85 |
+
$week_begins = intval( get_option( 'start_of_week' ) );
|
86 |
|
87 |
// Let's figure out when we are
|
88 |
+
if ( !empty( $monthnum ) && !empty( $year ) ) {
|
89 |
+
$thismonth = ''.zeroise( intval( $monthnum ), 2 );
|
90 |
+
$thisyear = ''.intval( $year );
|
91 |
+
} elseif ( !empty( $w ) ) {
|
92 |
// We need to get the month from MySQL
|
93 |
+
$thisyear = ''.intval( substr( $m, 0, 4 ) );
|
94 |
+
$d = ( ( $w - 1 ) * 7 ) + 6; //it seems MySQL's weeks disagree with PHP's
|
95 |
+
$thismonth = $wpdb->get_var( "SELECT DATE_FORMAT( ( DATE_ADD( '{$thisyear}0101', INTERVAL $d DAY ) ), '%m' )" );
|
96 |
+
} elseif ( !empty( $m ) ) {
|
97 |
+
$thisyear = ''.intval( substr( $m, 0, 4 ) );
|
98 |
+
if ( strlen( $m ) < 6 )
|
99 |
$thismonth = '01';
|
100 |
else
|
101 |
+
$thismonth = ''.zeroise( intval( substr( $m, 4, 2 ) ), 2 );
|
102 |
} else {
|
103 |
+
$thisyear = gmdate( 'Y', current_time( 'timestamp' ) );
|
104 |
+
$thismonth = gmdate( 'm', current_time( 'timestamp' ) );
|
105 |
}
|
106 |
|
107 |
+
$unixmonth = mktime( 0, 0 , 0, $thismonth, 1, $thisyear );
|
108 |
+
$last_day = date( 't', $unixmonth );
|
109 |
|
110 |
// Get the next and previous month and year with at least one post
|
111 |
+
$previous = $wpdb->get_row( "SELECT MONTH( post_date ) AS month, YEAR( post_date ) AS year
|
112 |
FROM $wpdb->posts $join_clause
|
113 |
WHERE post_date < '$thisyear-$thismonth-01'
|
114 |
AND post_type = 'post' AND post_status = 'publish' $where_clause
|
115 |
ORDER BY post_date DESC
|
116 |
+
LIMIT 1" ); #modified#
|
117 |
+
$next = $wpdb->get_row( "SELECT MONTH( post_date ) AS month, YEAR( post_date ) AS year
|
118 |
FROM $wpdb->posts $join_clause
|
119 |
WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
|
120 |
AND post_type = 'post' AND post_status = 'publish' $where_clause
|
121 |
ORDER BY post_date ASC
|
122 |
+
LIMIT 1" ); #modified#
|
123 |
|
124 |
/* translators: Calendar caption: 1: month name, 2: 4-digit year */
|
125 |
+
$calendar_caption = _x( '%1$s %2$s', 'calendar caption' );
|
126 |
$calendar_output = '<table id="wp-calendar">
|
127 |
+
<caption>' . sprintf( $calendar_caption, $wp_locale->get_month( $thismonth ), date( 'Y', $unixmonth ) ) . '</caption>
|
128 |
<thead>
|
129 |
<tr>';
|
130 |
|
131 |
$myweek = array();
|
132 |
|
133 |
for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
|
134 |
+
$myweek[] = $wp_locale->get_weekday( ( $wdcount+$week_begins )%7 );
|
135 |
}
|
136 |
|
137 |
foreach ( $myweek as $wd ) {
|
138 |
+
$day_name = ( true == $initial ) ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
|
139 |
+
$wd = esc_attr( $wd );
|
140 |
$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
|
141 |
}
|
142 |
|
148 |
<tr>';
|
149 |
|
150 |
if ( $previous ) {
|
151 |
+
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">« ' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) . '</a></td>';
|
152 |
} else {
|
153 |
$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
|
154 |
}
|
156 |
$calendar_output .= "\n\t\t".'<td class="pad"> </td>';
|
157 |
|
158 |
if ( $next ) {
|
159 |
+
$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link( $next->year, $next->month ) . '">' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) . ' »</a></td>';
|
160 |
} else {
|
161 |
$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
|
162 |
}
|
171 |
$daywithpost = array();
|
172 |
|
173 |
// Get days with posts
|
174 |
+
$dayswithposts = $wpdb->get_results( "SELECT DISTINCT DAYOFMONTH( post_date )
|
175 |
FROM $wpdb->posts $join_clause
|
176 |
WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
|
177 |
AND post_type = 'post' AND post_status = 'publish' $where_clause
|
178 |
+
AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N ); #modified#
|
179 |
if ( $dayswithposts ) {
|
180 |
foreach ( (array) $dayswithposts as $daywith ) {
|
181 |
$daywithpost[] = $daywith[0];
|
182 |
}
|
183 |
}
|
184 |
|
185 |
+
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false || stripos( $_SERVER['HTTP_USER_AGENT'], 'camino' ) !== false || stripos( $_SERVER['HTTP_USER_AGENT'], 'safari' ) !== false )
|
186 |
$ak_title_separator = "\n";
|
187 |
else
|
188 |
$ak_title_separator = ', ';
|
189 |
|
190 |
$ak_titles_for_day = array();
|
191 |
+
$ak_post_titles = $wpdb->get_results( "SELECT ID, post_title, DAYOFMONTH( post_date ) as dom "
|
192 |
."FROM $wpdb->posts $join_clause "
|
193 |
."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
|
194 |
."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
|
200 |
/** This filter is documented in wp-includes/post-template.php */
|
201 |
$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
|
202 |
|
203 |
+
if ( empty( $ak_titles_for_day['day_'.$ak_post_title->dom] ) )
|
204 |
$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
|
205 |
+
if ( empty( $ak_titles_for_day["$ak_post_title->dom"] ) ) // first one
|
206 |
$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
|
207 |
else
|
208 |
$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
|
210 |
}
|
211 |
|
212 |
// See how much we should pad in the beginning
|
213 |
+
$pad = calendar_week_mod( date( 'w', $unixmonth )-$week_begins );
|
214 |
if ( 0 != $pad )
|
215 |
+
$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr( $pad ) .'" class="pad"> </td>';
|
216 |
|
217 |
+
$daysinmonth = intval( date( 't', $unixmonth ) );
|
218 |
for ( $day = 1; $day <= $daysinmonth; ++$day ) {
|
219 |
+
if ( isset( $newrow ) && $newrow )
|
220 |
$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
|
221 |
$newrow = false;
|
222 |
|
223 |
+
if ( $day == gmdate( 'j', current_time( 'timestamp' ) ) && $thismonth == gmdate( 'm', current_time( 'timestamp' ) ) && $thisyear == gmdate( 'Y', current_time( 'timestamp' ) ) )
|
224 |
$calendar_output .= '<td id="today">';
|
225 |
else
|
226 |
$calendar_output .= '<td>';
|
227 |
|
228 |
+
if ( in_array( $day, $daywithpost ) ) // any posts today?
|
229 |
$calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
|
230 |
else
|
231 |
$calendar_output .= $day;
|
232 |
$calendar_output .= '</td>';
|
233 |
|
234 |
+
if ( 6 == calendar_week_mod( date( 'w', mktime( 0, 0 , 0, $thismonth, $day, $thisyear ) )-$week_begins ) )
|
235 |
$newrow = true;
|
236 |
}
|
237 |
|
238 |
+
$pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0 , 0, $thismonth, $day, $thisyear ) )-$week_begins );
|
239 |
if ( $pad != 0 && $pad != 7 )
|
240 |
+
$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr( $pad ) .'"> </td>';
|
241 |
|
242 |
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
|
243 |
|
include/widget-languages.php
CHANGED
@@ -13,7 +13,7 @@ class PLL_Widget_Languages extends WP_Widget {
|
|
13 |
* @since 0.1
|
14 |
*/
|
15 |
function __construct() {
|
16 |
-
parent::__construct('polylang', __('Language Switcher', 'polylang'), array( 'description' => __( 'Displays a language switcher', 'polylang')));
|
17 |
}
|
18 |
|
19 |
/*
|
@@ -24,20 +24,21 @@ class PLL_Widget_Languages extends WP_Widget {
|
|
24 |
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
25 |
* @param array $instance The settings for the particular instance of the widget
|
26 |
*/
|
27 |
-
function widget($args, $instance) {
|
28 |
-
global $polylang;
|
29 |
-
|
30 |
// sets a unique id for dropdown
|
31 |
-
$instance['dropdown'] = empty($instance['dropdown']) ? 0 : $args['widget_id'];
|
32 |
-
|
33 |
-
if (
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
/*
|
@@ -50,9 +51,10 @@ class PLL_Widget_Languages extends WP_Widget {
|
|
50 |
* @return array Settings to save or bool false to cancel saving
|
51 |
*/
|
52 |
function update( $new_instance, $old_instance ) {
|
53 |
-
$instance['title'] = strip_tags($new_instance['title']);
|
54 |
-
foreach (array_keys(PLL_Switcher::get_switcher_options('widget')) as $key)
|
55 |
-
$instance[$key] = !empty($new_instance[$key]) ? 1 : 0;
|
|
|
56 |
|
57 |
return $instance;
|
58 |
}
|
@@ -64,37 +66,37 @@ class PLL_Widget_Languages extends WP_Widget {
|
|
64 |
*
|
65 |
* @param array $instance Current settings
|
66 |
*/
|
67 |
-
function form($instance) {
|
68 |
// default values
|
69 |
-
$instance = wp_parse_args( (array)$instance, array_merge(array('title' => ''), PLL_Switcher::get_switcher_options('widget', 'default')) );
|
70 |
|
71 |
// title
|
72 |
$title = sprintf(
|
73 |
'<p><label for="%1$s">%2$s</label><input class="widefat" id="%1$s" name="%3$s" type="text" value="%4$s" /></p>',
|
74 |
-
$this->get_field_id('title'),
|
75 |
-
__('Title:', 'polylang'),
|
76 |
-
$this->get_field_name('title'),
|
77 |
-
esc_attr($instance['title'])
|
78 |
);
|
79 |
|
80 |
$fields = '';
|
81 |
-
foreach (PLL_Switcher::get_switcher_options('widget') as $key => $str)
|
82 |
$fields .= sprintf(
|
83 |
'<div class = "%5$s" %6$s><input type="checkbox" class="checkbox" id="%1$s" name="%2$s" %3$s/> <label for="%1$s">%4$s</label></div>',
|
84 |
-
$this->get_field_id($key),
|
85 |
-
$this->get_field_name($key),
|
86 |
-
$instance[$key] ? 'checked="checked"' : '',
|
87 |
-
esc_html($str),
|
88 |
-
in_array($key, array('show_names', 'show_flags', 'hide_current')) ? 'no-dropdown-' . $this->id : '',
|
89 |
-
!empty($instance['dropdown']) && in_array($key, array('show_names', 'show_flags', 'hide_current')) ? 'style="display:none;"' : ''
|
90 |
);
|
91 |
-
|
92 |
|
93 |
echo $title.'<p>'.$fields.'</p>';
|
94 |
|
95 |
// FIXME echoing script in form is not very clean
|
96 |
// but it does not work if enqueued properly :
|
97 |
-
// clicking save on a widget makes this code unreachable for the just saved widget (?!)
|
98 |
$this->admin_print_script();
|
99 |
}
|
100 |
|
@@ -106,37 +108,38 @@ class PLL_Widget_Languages extends WP_Widget {
|
|
106 |
public function admin_print_script() {
|
107 |
static $js = '';
|
108 |
|
109 |
-
if ($js)
|
110 |
return;
|
|
|
111 |
|
112 |
$js = "
|
113 |
<script type='text/javascript'>
|
114 |
//<![CDATA[
|
115 |
-
jQuery(document).ready(function($) {
|
116 |
-
function pll_toggle(a, test) {
|
117 |
test ? a.show() : a.hide();
|
118 |
}
|
119 |
|
120 |
var widgets = new Array();
|
121 |
-
$('.widget-id').each( function(){
|
122 |
-
var this_id = $(this).attr('value');
|
123 |
|
124 |
// remove all options if dropdown is checked
|
125 |
-
$('#widget-'+this_id+'-dropdown').change(function() {
|
126 |
-
pll_toggle($('.no-dropdown-'+this_id), 'checked' != $(this).attr('checked'));
|
127 |
-
});
|
128 |
|
129 |
// disallow unchecking both show names and show flags
|
130 |
var options = ['-show_flags', '-show_names'];
|
131 |
-
$.each(options, function(i, v) {
|
132 |
-
$('#widget-'+this_id+v).change(function() {
|
133 |
-
if ('checked' != $(this).attr('checked'))
|
134 |
-
$('#widget-'+this_id+options[1-i]).prop('checked', true);
|
135 |
-
});
|
136 |
-
});
|
137 |
-
|
138 |
-
});
|
139 |
-
});
|
140 |
//]]>
|
141 |
</script>";
|
142 |
|
13 |
* @since 0.1
|
14 |
*/
|
15 |
function __construct() {
|
16 |
+
parent::__construct( 'polylang', __( 'Language Switcher', 'polylang' ), array( 'description' => __( 'Displays a language switcher', 'polylang' ) ) );
|
17 |
}
|
18 |
|
19 |
/*
|
24 |
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
25 |
* @param array $instance The settings for the particular instance of the widget
|
26 |
*/
|
27 |
+
function widget( $args, $instance ) {
|
|
|
|
|
28 |
// sets a unique id for dropdown
|
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'];
|
36 |
+
if ( $title ) {
|
37 |
+
echo $args['before_title'] . $title . $args['after_title'];
|
38 |
+
}
|
39 |
+
echo $instance['dropdown'] ? $list : "<ul>\n" . $list . "</ul>\n";
|
40 |
+
echo $args['after_widget'];
|
41 |
+
}
|
42 |
}
|
43 |
|
44 |
/*
|
51 |
* @return array Settings to save or bool false to cancel saving
|
52 |
*/
|
53 |
function update( $new_instance, $old_instance ) {
|
54 |
+
$instance['title'] = strip_tags( $new_instance['title'] );
|
55 |
+
foreach ( array_keys( PLL_Switcher::get_switcher_options( 'widget' ) ) as $key ) {
|
56 |
+
$instance[ $key ] = ! empty( $new_instance[ $key ] ) ? 1 : 0;
|
57 |
+
}
|
58 |
|
59 |
return $instance;
|
60 |
}
|
66 |
*
|
67 |
* @param array $instance Current settings
|
68 |
*/
|
69 |
+
function form( $instance ) {
|
70 |
// default values
|
71 |
+
$instance = wp_parse_args( (array) $instance, array_merge( array( 'title' => '' ), PLL_Switcher::get_switcher_options( 'widget', 'default' ) ) );
|
72 |
|
73 |
// title
|
74 |
$title = sprintf(
|
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' ),
|
78 |
+
$this->get_field_name( 'title' ),
|
79 |
+
esc_attr( $instance['title'] )
|
80 |
);
|
81 |
|
82 |
$fields = '';
|
83 |
+
foreach ( PLL_Switcher::get_switcher_options( 'widget' ) as $key => $str ) {
|
84 |
$fields .= sprintf(
|
85 |
'<div class = "%5$s" %6$s><input type="checkbox" class="checkbox" id="%1$s" name="%2$s" %3$s/> <label for="%1$s">%4$s</label></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 $title.'<p>'.$fields.'</p>';
|
96 |
|
97 |
// FIXME echoing script in form is not very clean
|
98 |
// but it does not work if enqueued properly :
|
99 |
+
// clicking save on a widget makes this code unreachable for the just saved widget ( ?! )
|
100 |
$this->admin_print_script();
|
101 |
}
|
102 |
|
108 |
public function admin_print_script() {
|
109 |
static $js = '';
|
110 |
|
111 |
+
if ( $js ) {
|
112 |
return;
|
113 |
+
}
|
114 |
|
115 |
$js = "
|
116 |
<script type='text/javascript'>
|
117 |
//<![CDATA[
|
118 |
+
jQuery( document ).ready( function( $ ) {
|
119 |
+
function pll_toggle( a, test ) {
|
120 |
test ? a.show() : a.hide();
|
121 |
}
|
122 |
|
123 |
var widgets = new Array();
|
124 |
+
$( '.widget-id' ).each( function(){
|
125 |
+
var this_id = $( this ).attr( 'value' );
|
126 |
|
127 |
// remove all options if dropdown is checked
|
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 |
</script>";
|
145 |
|
include/widget-recent-comments.php
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if(!class_exists('WP_Widget_Recent_Comments')){
|
4 |
require_once( ABSPATH . '/wp-includes/default-widgets.php' );
|
5 |
}
|
6 |
|
7 |
/*
|
|
|
8 |
* obliged to rewrite the whole functionnality to have a language dependant cache key
|
9 |
* code base is WP 4.2
|
10 |
*
|
@@ -26,7 +27,7 @@ class PLL_Widget_Recent_Comments extends WP_Widget_Recent_Comments {
|
|
26 |
|
27 |
$cache = array();
|
28 |
if ( ! $this->is_preview() ) {
|
29 |
-
$cache = wp_cache_get('widget_recent_comments', 'widget');
|
30 |
}
|
31 |
if ( ! is_array( $cache ) ) {
|
32 |
$cache = array();
|
@@ -36,8 +37,8 @@ class PLL_Widget_Recent_Comments extends WP_Widget_Recent_Comments {
|
|
36 |
$args['widget_id'] = $this->id;
|
37 |
|
38 |
$lang = pll_current_language(); #added
|
39 |
-
if ( isset( $cache[ $args['widget_id'] ]
|
40 |
-
echo $cache[ $args['widget_id'] ]
|
41 |
return;
|
42 |
}
|
43 |
|
@@ -78,7 +79,7 @@ class PLL_Widget_Recent_Comments extends WP_Widget_Recent_Comments {
|
|
78 |
$post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
|
79 |
_prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
|
80 |
|
81 |
-
foreach ( (array) $comments as $comment) {
|
82 |
$output .= '<li class="recentcomments">';
|
83 |
/* translators: comments widget: 1: comment author, 2: post link */
|
84 |
$output .= sprintf( _x( '%1$s on %2$s', 'widgets' ),
|
@@ -94,19 +95,8 @@ class PLL_Widget_Recent_Comments extends WP_Widget_Recent_Comments {
|
|
94 |
echo $output;
|
95 |
|
96 |
if ( ! $this->is_preview() ) {
|
97 |
-
$cache[ $args['widget_id'] ]
|
98 |
wp_cache_set( 'widget_recent_comments', $cache, 'widget' );
|
99 |
}
|
100 |
}
|
101 |
-
|
102 |
-
/*
|
103 |
-
* backward compatibility with WP < 3.9
|
104 |
-
*
|
105 |
-
* @since 1.5
|
106 |
-
*
|
107 |
-
* @return bool
|
108 |
-
*/
|
109 |
-
function is_preview() {
|
110 |
-
return version_compare($GLOBALS['wp_version'], '3.9', '<') ? false : parent::is_preview();
|
111 |
-
}
|
112 |
}
|
1 |
<?php
|
2 |
|
3 |
+
if ( ! class_exists( 'WP_Widget_Recent_Comments' ) ) {
|
4 |
require_once( ABSPATH . '/wp-includes/default-widgets.php' );
|
5 |
}
|
6 |
|
7 |
/*
|
8 |
+
* backward compatibility with WP < 4.4
|
9 |
* obliged to rewrite the whole functionnality to have a language dependant cache key
|
10 |
* code base is WP 4.2
|
11 |
*
|
27 |
|
28 |
$cache = array();
|
29 |
if ( ! $this->is_preview() ) {
|
30 |
+
$cache = wp_cache_get( 'widget_recent_comments', 'widget' );
|
31 |
}
|
32 |
if ( ! is_array( $cache ) ) {
|
33 |
$cache = array();
|
37 |
$args['widget_id'] = $this->id;
|
38 |
|
39 |
$lang = pll_current_language(); #added
|
40 |
+
if ( isset( $cache[ $args['widget_id'] ][ $lang ] ) ) { #modified#
|
41 |
+
echo $cache[ $args['widget_id'] ][ $lang ]; #modified#
|
42 |
return;
|
43 |
}
|
44 |
|
79 |
$post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
|
80 |
_prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
|
81 |
|
82 |
+
foreach ( (array) $comments as $comment ) {
|
83 |
$output .= '<li class="recentcomments">';
|
84 |
/* translators: comments widget: 1: comment author, 2: post link */
|
85 |
$output .= sprintf( _x( '%1$s on %2$s', 'widgets' ),
|
95 |
echo $output;
|
96 |
|
97 |
if ( ! $this->is_preview() ) {
|
98 |
+
$cache[ $args['widget_id'] ][ $lang ] = $output; #modified#
|
99 |
wp_cache_set( 'widget_recent_comments', $cache, 'widget' );
|
100 |
}
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
include/widget-recent-posts.php
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if(!class_exists('WP_Widget_Recent_Posts')){
|
4 |
require_once( ABSPATH . '/wp-includes/default-widgets.php' );
|
5 |
}
|
6 |
|
7 |
/*
|
|
|
8 |
* obliged to rewrite the whole functionnality to have a language dependant cache key
|
9 |
* code base is WP 4.2
|
10 |
*
|
@@ -21,7 +22,7 @@ class PLL_Widget_Recent_Posts extends WP_Widget_Recent_Posts {
|
|
21 |
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
22 |
* @param array $instance The settings for the particular instance of the widget
|
23 |
*/
|
24 |
-
public function widget($args, $instance) {
|
25 |
$cache = array();
|
26 |
if ( ! $this->is_preview() ) {
|
27 |
$cache = wp_cache_get( 'widget_recent_posts', 'widget' );
|
@@ -36,8 +37,8 @@ class PLL_Widget_Recent_Posts extends WP_Widget_Recent_Posts {
|
|
36 |
}
|
37 |
|
38 |
$lang = pll_current_language(); #added
|
39 |
-
if ( isset( $cache[ $args['widget_id'] ]
|
40 |
-
echo $cache[ $args['widget_id'] ]
|
41 |
return;
|
42 |
}
|
43 |
|
@@ -69,7 +70,7 @@ class PLL_Widget_Recent_Posts extends WP_Widget_Recent_Posts {
|
|
69 |
'ignore_sticky_posts' => true
|
70 |
) ) );
|
71 |
|
72 |
-
if ($r->have_posts()) :
|
73 |
?>
|
74 |
<?php echo $args['before_widget']; ?>
|
75 |
<?php if ( $title ) {
|
@@ -93,21 +94,10 @@ class PLL_Widget_Recent_Posts extends WP_Widget_Recent_Posts {
|
|
93 |
endif;
|
94 |
|
95 |
if ( ! $this->is_preview() ) {
|
96 |
-
$cache[ $args['widget_id'] ]
|
97 |
wp_cache_set( 'widget_recent_posts', $cache, 'widget' );
|
98 |
} else {
|
99 |
ob_end_flush();
|
100 |
}
|
101 |
}
|
102 |
-
|
103 |
-
/*
|
104 |
-
* backward compatibility with WP < 3.9
|
105 |
-
*
|
106 |
-
* @since 1.5
|
107 |
-
*
|
108 |
-
* @return bool
|
109 |
-
*/
|
110 |
-
function is_preview() {
|
111 |
-
return version_compare($GLOBALS['wp_version'], '3.9', '<') ? false : parent::is_preview();
|
112 |
-
}
|
113 |
}
|
1 |
<?php
|
2 |
|
3 |
+
if ( ! class_exists( 'WP_Widget_Recent_Posts' ) ) {
|
4 |
require_once( ABSPATH . '/wp-includes/default-widgets.php' );
|
5 |
}
|
6 |
|
7 |
/*
|
8 |
+
* backward compatibility with WP < 4.4
|
9 |
* obliged to rewrite the whole functionnality to have a language dependant cache key
|
10 |
* code base is WP 4.2
|
11 |
*
|
22 |
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
23 |
* @param array $instance The settings for the particular instance of the widget
|
24 |
*/
|
25 |
+
public function widget( $args, $instance ) {
|
26 |
$cache = array();
|
27 |
if ( ! $this->is_preview() ) {
|
28 |
$cache = wp_cache_get( 'widget_recent_posts', 'widget' );
|
37 |
}
|
38 |
|
39 |
$lang = pll_current_language(); #added
|
40 |
+
if ( isset( $cache[ $args['widget_id'] ][ $lang ] ) ) { #modified#
|
41 |
+
echo $cache[ $args['widget_id'] ][ $lang ]; #modified#
|
42 |
return;
|
43 |
}
|
44 |
|
70 |
'ignore_sticky_posts' => true
|
71 |
) ) );
|
72 |
|
73 |
+
if ( $r->have_posts() ) :
|
74 |
?>
|
75 |
<?php echo $args['before_widget']; ?>
|
76 |
<?php if ( $title ) {
|
94 |
endif;
|
95 |
|
96 |
if ( ! $this->is_preview() ) {
|
97 |
+
$cache[ $args['widget_id'] ][ $lang ] = ob_get_flush(); #modified#
|
98 |
wp_cache_set( 'widget_recent_posts', $cache, 'widget' );
|
99 |
} else {
|
100 |
ob_end_flush();
|
101 |
}
|
102 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
}
|
include/wpml-compat.php
DELETED
@@ -1,365 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* compatibility with WPML API. See http://wpml.org/documentation/support/wpml-coding-api/
|
4 |
-
*/
|
5 |
-
|
6 |
-
/*
|
7 |
-
* defines two WPML constants once the language has been defined
|
8 |
-
* the compatibility with WPML is not perfect on admin side as the constants are defined
|
9 |
-
* in 'setup_theme' by Polylang (based on user info) and 'plugins_loaded' by WPML (based on cookie)
|
10 |
-
*
|
11 |
-
* @since 0.9.5
|
12 |
-
*/
|
13 |
-
function pll_define_wpml_constants() {
|
14 |
-
global $polylang;
|
15 |
-
|
16 |
-
if (!empty($polylang->curlang)) {
|
17 |
-
if(!defined('ICL_LANGUAGE_CODE'))
|
18 |
-
define('ICL_LANGUAGE_CODE', $polylang->curlang->slug);
|
19 |
-
|
20 |
-
if(!defined('ICL_LANGUAGE_NAME'))
|
21 |
-
define('ICL_LANGUAGE_NAME', $polylang->curlang->name);
|
22 |
-
}
|
23 |
-
|
24 |
-
elseif (PLL_ADMIN) {
|
25 |
-
if(!defined('ICL_LANGUAGE_CODE'))
|
26 |
-
define('ICL_LANGUAGE_CODE', 'all');
|
27 |
-
|
28 |
-
if(!defined('ICL_LANGUAGE_NAME'))
|
29 |
-
define('ICL_LANGUAGE_NAME', '');
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
add_action('pll_language_defined', 'pll_define_wpml_constants');
|
34 |
-
|
35 |
-
/*
|
36 |
-
* link to the home page in the active language
|
37 |
-
*
|
38 |
-
* @since 0.9.4
|
39 |
-
*
|
40 |
-
* @return string
|
41 |
-
*/
|
42 |
-
if (!function_exists('icl_get_home_url')) {
|
43 |
-
function icl_get_home_url() {
|
44 |
-
return pll_home_url();
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
/*
|
49 |
-
* used for building custom language selectors
|
50 |
-
* available only on frontend
|
51 |
-
*
|
52 |
-
* list of paramaters accepted in $args
|
53 |
-
*
|
54 |
-
* skip_missing => wether to skip missing translation or not, 0 or 1, defaults to 0
|
55 |
-
* orderby => 'id', 'code', 'name', defaults to 'id'
|
56 |
-
* order => 'ASC' or 'DESC', defaults to 'ASC'
|
57 |
-
* link_empty_to => link to use when the translation is missing {$lang} is replaced by the language code
|
58 |
-
*
|
59 |
-
* list of parameters returned per language:
|
60 |
-
*
|
61 |
-
* id => the language id
|
62 |
-
* active => wether this is the active language or no, 0 or 1
|
63 |
-
* native_name => the language name
|
64 |
-
* missing => wether the translation is missing or not, 0 or 1
|
65 |
-
* translated_name => empty, does not exist in Polylang
|
66 |
-
* language_code => the language code (slug)
|
67 |
-
* country_flag_url => the url of the flag
|
68 |
-
* url => the url of the translation
|
69 |
-
*
|
70 |
-
* @since 1.0
|
71 |
-
*
|
72 |
-
* @param string|array $args optional
|
73 |
-
* @return array array of arrays per language
|
74 |
-
*/
|
75 |
-
if (!function_exists('icl_get_languages')) {
|
76 |
-
function icl_get_languages($args = '') {
|
77 |
-
global $polylang;
|
78 |
-
if (empty($polylang))
|
79 |
-
return array();
|
80 |
-
|
81 |
-
$args = wp_parse_args($args, array('skip_missing' => 0, 'orderby' => 'id', 'order' => 'ASC'));
|
82 |
-
$orderby = (isset($args['orderby']) && $args['orderby'] == 'code') ? 'slug' : (isset($args['orderby']) && $args['orderby'] == 'name' ? 'name' : 'id');
|
83 |
-
$order = (!empty($args['order']) && $args['order'] == 'desc') ? 'DESC' : 'ASC';
|
84 |
-
|
85 |
-
$arr = array();
|
86 |
-
|
87 |
-
foreach ($polylang->model->get_languages_list(array('hide_empty' => true, 'orderby' => $orderby, 'order' => $order)) as $lang) {
|
88 |
-
// we can find a translation only on frontend
|
89 |
-
if (method_exists($polylang->links, 'get_translation_url'))
|
90 |
-
$url = $polylang->links->get_translation_url($lang);
|
91 |
-
|
92 |
-
// it seems that WPML does not bother of skip_missing parameter on admin side and before the $wp_query object has been filled
|
93 |
-
if (empty($url) && !empty($args['skip_missing']) && !is_admin() && did_action('parse_query'))
|
94 |
-
continue;
|
95 |
-
|
96 |
-
$arr[$lang->slug] = array(
|
97 |
-
'id' => $lang->term_id,
|
98 |
-
'active' => isset($polylang->curlang->slug) && $polylang->curlang->slug == $lang->slug ? 1 : 0,
|
99 |
-
'native_name' => $lang->name,
|
100 |
-
'missing' => empty($url) ? 1 : 0,
|
101 |
-
'translated_name' => '', // does not exist in Polylang
|
102 |
-
'language_code' => $lang->slug,
|
103 |
-
'country_flag_url' => $lang->flag_url,
|
104 |
-
'url' => !empty($url) ? $url :
|
105 |
-
(empty($args['link_empty_to']) ? $polylang->links->get_home_url($lang) :
|
106 |
-
str_replace('{$lang}', $lang->slug, $args['link_empty_to']))
|
107 |
-
);
|
108 |
-
}
|
109 |
-
return $arr;
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
/*
|
114 |
-
* used for creating language dependent links in themes
|
115 |
-
*
|
116 |
-
* @since 1.0
|
117 |
-
*
|
118 |
-
* @param int $id object id
|
119 |
-
* @param string $type optional, post type or taxonomy name of the object, defaults to 'post'
|
120 |
-
* @param string $text optional the link text. If not specified will produce the name of the element in the current language
|
121 |
-
* @param array $args optional an array of arguments to add to the link, defaults to empty
|
122 |
-
* @param string $anchor optional the anchor to add to teh link, defaults to empty
|
123 |
-
* @return string a language dependent link
|
124 |
-
*/
|
125 |
-
if (!function_exists('icl_link_to_element')) {
|
126 |
-
function icl_link_to_element($id, $type = 'post', $text = '', $args = array(), $anchor = '') {
|
127 |
-
global $polylang;
|
128 |
-
|
129 |
-
if ($type == 'tag')
|
130 |
-
$type = 'post_tag';
|
131 |
-
|
132 |
-
if (isset($polylang) && ($lang = pll_current_language()) && ($tr_id = $polylang->model->get_translation($type, $id, $lang)) && $polylang->links->current_user_can_read($tr_id))
|
133 |
-
$id = $tr_id;
|
134 |
-
|
135 |
-
if (post_type_exists($type)) {
|
136 |
-
$link = get_permalink($id);
|
137 |
-
if (empty($text))
|
138 |
-
$text = get_the_title($id);
|
139 |
-
}
|
140 |
-
elseif (taxonomy_exists($type)) {
|
141 |
-
$link = get_term_link($id, $type);
|
142 |
-
if (empty($text) && ($term = get_term($id, $type)) && !empty($term) && !is_wp_error($term))
|
143 |
-
$text = $term->name;
|
144 |
-
}
|
145 |
-
|
146 |
-
if (empty($link) || is_wp_error($link))
|
147 |
-
return '';
|
148 |
-
|
149 |
-
if (!empty($args))
|
150 |
-
$link .= (false === strpos($link, '?') ? '?' : '&' ) . http_build_query($args);
|
151 |
-
|
152 |
-
if (!empty($anchor))
|
153 |
-
$link .= '#' . $anchor;
|
154 |
-
|
155 |
-
return sprintf('<a href="%s">%s</a>', esc_url($link), esc_html($text));
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
/*
|
160 |
-
* used for calculating the IDs of objects (usually categories) in the current language
|
161 |
-
*
|
162 |
-
* @since 0.9.5
|
163 |
-
*
|
164 |
-
* @param int $id object id
|
165 |
-
* @param string $type, post type or taxonomy name of the object, defaults to 'post'
|
166 |
-
* @param bool $return_original_if_missing optional, true if Polylang should return the original id if the translation is missing, defaults to false
|
167 |
-
* @param string $lang optional language code, defaults to current language
|
168 |
-
* @return int|null the object id of the translation, null if the translation is missing and $return_original_if_missing set to false
|
169 |
-
*/
|
170 |
-
if (!function_exists('icl_object_id')) {
|
171 |
-
function icl_object_id($id, $type, $return_original_if_missing = false, $lang = false) {
|
172 |
-
global $polylang;
|
173 |
-
return isset($polylang) && ($lang = $lang ? $lang : pll_current_language()) && ($tr_id = $polylang->model->get_translation($type, $id, $lang)) ? $tr_id :
|
174 |
-
($return_original_if_missing ? $id : null);
|
175 |
-
}
|
176 |
-
}
|
177 |
-
|
178 |
-
/*
|
179 |
-
* registers a string for translation in the "strings translation" panel
|
180 |
-
*
|
181 |
-
* @since 0.9.3
|
182 |
-
*
|
183 |
-
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
184 |
-
* @param string $name a unique name for the string
|
185 |
-
* @param string $string the string to register
|
186 |
-
*/
|
187 |
-
if (!function_exists('icl_register_string')) {
|
188 |
-
function icl_register_string($context, $name, $string) {
|
189 |
-
PLL_WPML_Compat::instance()->register_string($context, $name, $string);
|
190 |
-
}
|
191 |
-
}
|
192 |
-
|
193 |
-
/*
|
194 |
-
* removes a string from the "strings translation" panel
|
195 |
-
*
|
196 |
-
* @since 1.0.2
|
197 |
-
*
|
198 |
-
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
199 |
-
* @param string $name a unique name for the string
|
200 |
-
*/
|
201 |
-
if (!function_exists('icl_unregister_string')) {
|
202 |
-
function icl_unregister_string($context, $name) {
|
203 |
-
PLL_WPML_Compat::instance()->unregister_string($context, $name);
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
/*
|
208 |
-
* gets the translated value of a string (previously registered with icl_register_string or pll_register_string)
|
209 |
-
*
|
210 |
-
* @since 0.9.3
|
211 |
-
*
|
212 |
-
* @param string $context not used by Polylang
|
213 |
-
* @param string $name not used by Polylang
|
214 |
-
* @param string $string the string to translated
|
215 |
-
* @return string the translated string in the current language
|
216 |
-
*/
|
217 |
-
if (!function_exists('icl_t')) {
|
218 |
-
function icl_t($context, $name, $string) {
|
219 |
-
return pll__($string);
|
220 |
-
}
|
221 |
-
}
|
222 |
-
|
223 |
-
/*
|
224 |
-
* undocumented function used by NextGen Gallery
|
225 |
-
* seems to be used to both register and translate a string
|
226 |
-
* used in PLL_Plugins_Compat for Jetpack with only 3 arguments
|
227 |
-
*
|
228 |
-
* @since 1.0.2
|
229 |
-
*
|
230 |
-
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
231 |
-
* @param string $name a unique name for the string
|
232 |
-
* @param string $string the string to register
|
233 |
-
* @param bool $bool optional, not used by Polylang
|
234 |
-
* @return string the translated string in the current language
|
235 |
-
*/
|
236 |
-
if (!function_exists('icl_translate')) {
|
237 |
-
function icl_translate($context, $name, $string, $bool = false) {
|
238 |
-
PLL_WPML_Compat::instance()->register_string($context, $name, $string);
|
239 |
-
return pll__($string);
|
240 |
-
}
|
241 |
-
}
|
242 |
-
|
243 |
-
/*
|
244 |
-
* undocumented function used by Types
|
245 |
-
* FIXME: tested only with Types
|
246 |
-
* probably incomplete as Types locks the custom fields for a new post, but not when edited
|
247 |
-
* this is probably linked to the fact that WPML has always an original post in the default language and not Polylang :)
|
248 |
-
*
|
249 |
-
* @since 1.1.2
|
250 |
-
*
|
251 |
-
* @return array
|
252 |
-
*/
|
253 |
-
if (!function_exists('wpml_get_copied_fields_for_post_edit')) {
|
254 |
-
function wpml_get_copied_fields_for_post_edit() {
|
255 |
-
if (empty($_GET['from_post']))
|
256 |
-
return array();
|
257 |
-
|
258 |
-
// don't know what WPML does but Polylang does copy all public meta keys by default
|
259 |
-
foreach ($keys = array_unique(array_keys(get_post_custom((int) $_GET['from_post']))) as $k => $meta_key)
|
260 |
-
if (is_protected_meta($meta_key))
|
261 |
-
unset ($keys[$k]);
|
262 |
-
|
263 |
-
// apply our filter and fill the expected output (see /types/embedded/includes/fields-post.php)
|
264 |
-
$arr['fields'] = array_unique(apply_filters('pll_copy_post_metas', empty($keys) ? array() : $keys, false));
|
265 |
-
$arr['original_post_id'] = (int) $_GET['from_post'];
|
266 |
-
return $arr;
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
/*
|
271 |
-
* undocumented function used by Warp 6 by Yootheme
|
272 |
-
*
|
273 |
-
* @since 1.0.5
|
274 |
-
*
|
275 |
-
* @return string default language code
|
276 |
-
*/
|
277 |
-
if (!function_exists('icl_get_default_language')) {
|
278 |
-
function icl_get_default_language() {
|
279 |
-
return pll_default_language();
|
280 |
-
}
|
281 |
-
}
|
282 |
-
|
283 |
-
/*
|
284 |
-
* registers strings in a persistent way as done by WPML
|
285 |
-
*
|
286 |
-
* @since 1.0.2
|
287 |
-
*/
|
288 |
-
class PLL_WPML_Compat {
|
289 |
-
static protected $instance; // for singleton
|
290 |
-
static protected $strings; // used for cache
|
291 |
-
|
292 |
-
/*
|
293 |
-
* constructor
|
294 |
-
*
|
295 |
-
* @since 1.0.2
|
296 |
-
*/
|
297 |
-
protected function __construct() {
|
298 |
-
self::$strings = get_option('polylang_wpml_strings', array());
|
299 |
-
|
300 |
-
add_action('pll_get_strings', array(&$this, 'get_strings'));
|
301 |
-
}
|
302 |
-
|
303 |
-
/*
|
304 |
-
* access to the single instance of the class
|
305 |
-
*
|
306 |
-
* @since 1.7
|
307 |
-
*
|
308 |
-
* @return object
|
309 |
-
*/
|
310 |
-
static public function instance() {
|
311 |
-
if (empty(self::$instance))
|
312 |
-
self::$instance = new self();
|
313 |
-
|
314 |
-
return self::$instance;
|
315 |
-
}
|
316 |
-
|
317 |
-
/*
|
318 |
-
* unlike pll_register_string, icl_register_string stores the string in database
|
319 |
-
* so we need to do the same as some plugins or themes may expect this
|
320 |
-
* we use a serialized option to do this
|
321 |
-
*
|
322 |
-
* @since 1.0.2
|
323 |
-
*
|
324 |
-
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
325 |
-
* @param string $name a unique name for the string
|
326 |
-
* @param string $string the string to register
|
327 |
-
*/
|
328 |
-
public function register_string($context, $name, $string) {
|
329 |
-
// registers the string if it does not exist yet
|
330 |
-
$to_register = array('context' => $context, 'name'=> $name, 'string' => $string, 'multiline' => false, 'icl' => true);
|
331 |
-
if (!in_array($to_register, self::$strings) && $to_register['string']) {
|
332 |
-
self::$strings[] = $to_register;
|
333 |
-
update_option('polylang_wpml_strings', self::$strings);
|
334 |
-
}
|
335 |
-
}
|
336 |
-
|
337 |
-
/*
|
338 |
-
* removes a string from the registered strings list
|
339 |
-
*
|
340 |
-
* @since 1.0.2
|
341 |
-
*
|
342 |
-
* @param string $context the group in which the string is registered, defaults to 'polylang'
|
343 |
-
* @param string $name a unique name for the string
|
344 |
-
*/
|
345 |
-
public function unregister_string($context, $name) {
|
346 |
-
foreach (self::$strings as $key=>$string) {
|
347 |
-
if ($string['context'] == $context && $string['name'] == $name) {
|
348 |
-
unset(self::$strings[$key]);
|
349 |
-
update_option('polylang_wpml_strings', self::$strings);
|
350 |
-
}
|
351 |
-
}
|
352 |
-
}
|
353 |
-
|
354 |
-
/*
|
355 |
-
* adds strings registered by icl_register_string to those registered by pll_register_string
|
356 |
-
*
|
357 |
-
* @since 1.0.2
|
358 |
-
*
|
359 |
-
* @param array $strings existing registered strings
|
360 |
-
* @return array registered strings with added strings through WPML API
|
361 |
-
*/
|
362 |
-
public function get_strings($strings) {
|
363 |
-
return empty(self::$strings) ? $strings : array_merge($strings, self::$strings);
|
364 |
-
}
|
365 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include/wpml-config.php
DELETED
@@ -1,341 +0,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
|
7 |
-
* the xml parser has been adapted from http://php.net/manual/en/function.xml-parse-into-struct.php#84261
|
8 |
-
* many thanks to wickedfather at hotmail dot com
|
9 |
-
*
|
10 |
-
* @since 1.0
|
11 |
-
*/
|
12 |
-
class PLL_WPML_Config {
|
13 |
-
static protected $instance; // for singleton
|
14 |
-
protected $values, $index, $strings;
|
15 |
-
public $tags;
|
16 |
-
|
17 |
-
/*
|
18 |
-
* constructor
|
19 |
-
*
|
20 |
-
* @since 1.0
|
21 |
-
*/
|
22 |
-
public function __construct() {
|
23 |
-
$this->init();
|
24 |
-
}
|
25 |
-
|
26 |
-
/*
|
27 |
-
* access to the single instance of the class
|
28 |
-
*
|
29 |
-
* @since 1.7
|
30 |
-
*
|
31 |
-
* @return object
|
32 |
-
*/
|
33 |
-
static public function instance() {
|
34 |
-
if (empty(self::$instance))
|
35 |
-
self::$instance = new self();
|
36 |
-
|
37 |
-
return self::$instance;
|
38 |
-
}
|
39 |
-
|
40 |
-
/*
|
41 |
-
* parses the wpml-config.xml file
|
42 |
-
*
|
43 |
-
* @since 1.0
|
44 |
-
*
|
45 |
-
* @param string wpml-config.xml file content
|
46 |
-
* @param string $context identifies where the file was found
|
47 |
-
*/
|
48 |
-
protected function xml_parse($xml, $context) {
|
49 |
-
$parser = xml_parser_create();
|
50 |
-
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
51 |
-
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
|
52 |
-
xml_parse_into_struct($parser, $xml, $this->values);
|
53 |
-
xml_parser_free($parser);
|
54 |
-
|
55 |
-
$this->index = 0;
|
56 |
-
$arr = $this->xml_parse_recursive();
|
57 |
-
$arr = $arr['wpml-config'];
|
58 |
-
|
59 |
-
$keys = array(
|
60 |
-
array('custom-fields', 'custom-field'),
|
61 |
-
array('custom-types','custom-type'),
|
62 |
-
array('taxonomies','taxonomy'),
|
63 |
-
array('admin-texts','key')
|
64 |
-
);
|
65 |
-
|
66 |
-
foreach ($keys as $k) {
|
67 |
-
if (isset($arr[$k[0]])) {
|
68 |
-
if (!isset($arr[$k[0]][$k[1]][0])) {
|
69 |
-
$elem = $arr[$k[0]][$k[1]];
|
70 |
-
unset($arr[$k[0]][$k[1]]);
|
71 |
-
$arr[$k[0]][$k[1]][0] = $elem;
|
72 |
-
}
|
73 |
-
|
74 |
-
$this->tags[$k[0]][$context] = $arr[$k[0]];
|
75 |
-
}
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
/*
|
80 |
-
* recursively parses the wpml-config.xml file
|
81 |
-
*
|
82 |
-
* @since 1.0
|
83 |
-
*
|
84 |
-
* @return array
|
85 |
-
*/
|
86 |
-
protected function xml_parse_recursive() {
|
87 |
-
$found = array();
|
88 |
-
$tagCount = array();
|
89 |
-
|
90 |
-
while (isset($this->values[$this->index])) {
|
91 |
-
extract($this->values[$this->index]);
|
92 |
-
$this->index++;
|
93 |
-
|
94 |
-
if ($type == 'close')
|
95 |
-
return $found;
|
96 |
-
|
97 |
-
if (isset($tagCount[$tag])) {
|
98 |
-
if ($tagCount[$tag] == 1)
|
99 |
-
$found[$tag] = array($found[$tag]);
|
100 |
-
|
101 |
-
$tagRef = &$found[$tag][$tagCount[$tag]];
|
102 |
-
$tagCount[$tag]++;
|
103 |
-
}
|
104 |
-
else {
|
105 |
-
$tagCount[$tag] = 1;
|
106 |
-
$tagRef = &$found[$tag];
|
107 |
-
}
|
108 |
-
|
109 |
-
if ($type == 'open') {
|
110 |
-
$tagRef = $this->xml_parse_recursive();
|
111 |
-
if (isset($attributes))
|
112 |
-
$tagRef['attributes'] = $attributes;
|
113 |
-
}
|
114 |
-
|
115 |
-
if ($type == 'complete') {
|
116 |
-
if (isset($attributes)) {
|
117 |
-
$tagRef['attributes'] = $attributes;
|
118 |
-
$tagRef = &$tagRef['value'];
|
119 |
-
}
|
120 |
-
if (isset($value))
|
121 |
-
$tagRef = $value;
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
return $found;
|
126 |
-
}
|
127 |
-
|
128 |
-
/*
|
129 |
-
* finds the wpml-config.xml files to parse and setup filters
|
130 |
-
*
|
131 |
-
* @since 1.0
|
132 |
-
*/
|
133 |
-
public function init() {
|
134 |
-
$this->tags = array();
|
135 |
-
|
136 |
-
// theme
|
137 |
-
if (file_exists($file = ($template = get_template_directory()) .'/wpml-config.xml'))
|
138 |
-
$this->xml_parse(file_get_contents($file), get_template()); // FIXME fopen + fread + fclose quicker ?
|
139 |
-
|
140 |
-
// child theme
|
141 |
-
if ($template != ($stylesheet = get_stylesheet_directory()) && file_exists($file = $stylesheet.'/wpml-config.xml'))
|
142 |
-
$this->xml_parse(file_get_contents($file), get_stylesheet());
|
143 |
-
|
144 |
-
// plugins
|
145 |
-
// don't forget sitewide active plugins thanks to Reactorshop http://wordpress.org/support/topic/polylang-and-yoast-seo-plugin/page/2?replies=38#post-4801829
|
146 |
-
$plugins = (is_multisite() && $sitewide_plugins = get_site_option('active_sitewide_plugins')) && is_array($sitewide_plugins) ? array_keys($sitewide_plugins) : array();
|
147 |
-
$plugins = array_merge($plugins, get_option('active_plugins'));
|
148 |
-
|
149 |
-
foreach ($plugins as $plugin) {
|
150 |
-
if (file_exists($file = WP_PLUGIN_DIR.'/'.dirname($plugin).'/wpml-config.xml'))
|
151 |
-
$this->xml_parse(file_get_contents($file), dirname($plugin));
|
152 |
-
}
|
153 |
-
|
154 |
-
// custom
|
155 |
-
if (file_exists($file = PLL_LOCAL_DIR.'/wpml-config.xml'))
|
156 |
-
$this->xml_parse(file_get_contents($file), 'polylang');
|
157 |
-
|
158 |
-
if (isset($this->tags['custom-fields']))
|
159 |
-
add_filter('pll_copy_post_metas', array(&$this, 'copy_post_metas'), 10, 2);
|
160 |
-
|
161 |
-
if (isset($this->tags['custom-types']))
|
162 |
-
add_filter('pll_get_post_types', array(&$this, 'translate_types'), 10, 2);
|
163 |
-
|
164 |
-
if (isset($this->tags['taxonomies']))
|
165 |
-
add_filter('pll_get_taxonomies', array(&$this, 'translate_taxonomies'), 10, 2);
|
166 |
-
|
167 |
-
if (!isset($this->tags['admin-texts']))
|
168 |
-
return;
|
169 |
-
|
170 |
-
// get a cleaner array for easy manipulation
|
171 |
-
foreach ($this->tags['admin-texts'] as $context => $arr)
|
172 |
-
foreach ($arr as $keys)
|
173 |
-
$this->strings[$context] = $this->admin_texts_recursive($keys);
|
174 |
-
|
175 |
-
foreach ($this->strings as $context => $options) {
|
176 |
-
foreach ($options as $option_name => $value) {
|
177 |
-
if (PLL_ADMIN) { // backend
|
178 |
-
$option = get_option($option_name);
|
179 |
-
if (is_string($option) && $value == 1)
|
180 |
-
pll_register_string($option_name, $option, $context);
|
181 |
-
elseif (is_array($option) && is_array($value))
|
182 |
-
$this->register_string_recursive($context, $value, $option); // for a serialized option
|
183 |
-
}
|
184 |
-
else
|
185 |
-
add_filter('option_'.$option_name, array(&$this, 'translate_strings'));
|
186 |
-
}
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
/*
|
191 |
-
* arranges strings in a cleaner way
|
192 |
-
*
|
193 |
-
* @since 1.0
|
194 |
-
*
|
195 |
-
* @param array $keys
|
196 |
-
* @return array
|
197 |
-
*/
|
198 |
-
protected function admin_texts_recursive($keys) {
|
199 |
-
if (!isset($keys[0])) {
|
200 |
-
$elem = $keys;
|
201 |
-
unset($keys);
|
202 |
-
$keys[0] = $elem;
|
203 |
-
}
|
204 |
-
foreach ($keys as $key)
|
205 |
-
$strings[$key['attributes']['name']] = isset($key['key']) ? $this->admin_texts_recursive($key['key']) : 1;
|
206 |
-
|
207 |
-
return $strings;
|
208 |
-
}
|
209 |
-
|
210 |
-
/*
|
211 |
-
* recursively registers strings for a serialized option
|
212 |
-
*
|
213 |
-
* @since 1.0
|
214 |
-
*
|
215 |
-
* @param string $context the group in which the strings will be registered
|
216 |
-
* @param array $strings
|
217 |
-
* @param array $options
|
218 |
-
*/
|
219 |
-
protected function register_string_recursive($context, $strings, $options) {
|
220 |
-
foreach ($options as $name => $value) {
|
221 |
-
if (isset($strings[$name])) {
|
222 |
-
// allow numeric values to be translated
|
223 |
-
// https://wordpress.org/support/topic/wpml-configxml-strings-skipped-when-numbers-ids
|
224 |
-
if ((is_numeric($value) || is_string($value)) && $strings[$name] == 1)
|
225 |
-
pll_register_string($name, $value, $context);
|
226 |
-
elseif (is_array($value) && is_array($strings[$name]))
|
227 |
-
$this->register_string_recursive($context, $strings[$name], $value);
|
228 |
-
}
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
/*
|
233 |
-
* adds custom fields to the list of metas to copy when creating a new translation
|
234 |
-
*
|
235 |
-
* @since 1.0
|
236 |
-
*
|
237 |
-
* @param array $metas the list of custom fields to copy or synchronize
|
238 |
-
* @param bool $sync true for sync, false for copy
|
239 |
-
* @return array the list of custom fields to copy or synchronize
|
240 |
-
*/
|
241 |
-
public function copy_post_metas($metas, $sync) {
|
242 |
-
foreach ($this->tags['custom-fields'] as $context) {
|
243 |
-
foreach ($context['custom-field'] as $cf) {
|
244 |
-
// copy => copy and synchronize
|
245 |
-
// translate => copy but don't synchronize
|
246 |
-
// ignore => don't copy
|
247 |
-
// see http://wordpress.org/support/topic/custom-field-values-override-other-translation-values?replies=8#post-4655563
|
248 |
-
if ('copy' == $cf['attributes']['action'] || (!$sync && 'translate' == $cf['attributes']['action']))
|
249 |
-
$metas[] = $cf['value'];
|
250 |
-
else
|
251 |
-
$metas = array_diff($metas, array($cf['value']));
|
252 |
-
}
|
253 |
-
}
|
254 |
-
return $metas;
|
255 |
-
}
|
256 |
-
|
257 |
-
/*
|
258 |
-
* language and translation management for custom post types
|
259 |
-
*
|
260 |
-
* @since 1.0
|
261 |
-
*
|
262 |
-
* @param array $types list of post type names for which Polylang manages language and translations
|
263 |
-
* @param bool $hide true when displaying the list in Polylang settings
|
264 |
-
* @return array list of post type names for which Polylang manages language and translations
|
265 |
-
*/
|
266 |
-
public function translate_types($types, $hide) {
|
267 |
-
foreach ($this->tags['custom-types'] as $context) {
|
268 |
-
foreach ($context['custom-type'] as $pt) {
|
269 |
-
if ($pt['attributes']['translate'] == 1 && !$hide)
|
270 |
-
$types[$pt['value']] = $pt['value'];
|
271 |
-
else
|
272 |
-
unset ($types[$pt['value']]); // the author decided what to do with the post type so don't allow the user to change this
|
273 |
-
}
|
274 |
-
}
|
275 |
-
return $types;
|
276 |
-
}
|
277 |
-
|
278 |
-
/*
|
279 |
-
* language and translation management for custom taxonomies
|
280 |
-
*
|
281 |
-
* @since 1.0
|
282 |
-
*
|
283 |
-
* @param array $taxonomies list of taxonomy names for which Polylang manages language and translations
|
284 |
-
* @param bool $hide true when displaying the list in Polylang settings
|
285 |
-
* @return array list of taxonomy names for which Polylang manages language and translations
|
286 |
-
*/
|
287 |
-
public function translate_taxonomies($taxonomies, $hide) {
|
288 |
-
foreach ($this->tags['taxonomies'] as $context) {
|
289 |
-
foreach ($context['taxonomy'] as $tax) {
|
290 |
-
if ($tax['attributes']['translate'] == 1 && !$hide)
|
291 |
-
$taxonomies[$tax['value']] = $tax['value'];
|
292 |
-
else
|
293 |
-
unset ($taxonomies[$tax['value']]); // the author decided what to do with the taxonomy so don't allow the user to change this
|
294 |
-
}
|
295 |
-
}
|
296 |
-
|
297 |
-
return $taxonomies;
|
298 |
-
}
|
299 |
-
|
300 |
-
/*
|
301 |
-
* translates the strings for an option
|
302 |
-
*
|
303 |
-
* @since 1.0
|
304 |
-
*
|
305 |
-
* @param array|string either a string to translate or a list of strings to translate
|
306 |
-
* @return array|string translated string(s)
|
307 |
-
*/
|
308 |
-
public function translate_strings($value) {
|
309 |
-
if (is_array($value)) {
|
310 |
-
$option = substr(current_filter(), 7);
|
311 |
-
foreach ($this->strings as $context => $options) {
|
312 |
-
if (array_key_exists($option, $options))
|
313 |
-
return $this->translate_strings_recursive($options[$option], $value); // for a serialized option
|
314 |
-
}
|
315 |
-
}
|
316 |
-
return pll__($value);
|
317 |
-
}
|
318 |
-
|
319 |
-
/*
|
320 |
-
* recursively translates strings for a serialized option
|
321 |
-
*
|
322 |
-
* @since 1.0
|
323 |
-
*
|
324 |
-
* @param array $strings
|
325 |
-
* @param array|string $values either a string to translate or a list of strings to translate
|
326 |
-
* @return array|string translated string(s)
|
327 |
-
*/
|
328 |
-
protected function translate_strings_recursive($strings, $values) {
|
329 |
-
foreach ($values as $name => $value) {
|
330 |
-
if (isset($strings[$name])) {
|
331 |
-
// allow numeric values to be translated
|
332 |
-
// https://wordpress.org/support/topic/wpml-configxml-strings-skipped-when-numbers-ids
|
333 |
-
if ((is_numeric($value) || is_string($value)) && $strings[$name] == 1)
|
334 |
-
$values[$name] = pll__($value);
|
335 |
-
elseif (is_array($value) && is_array($strings[$name]))
|
336 |
-
$values[$name] = $this->translate_strings_recursive($strings[$name], $value);
|
337 |
-
}
|
338 |
-
}
|
339 |
-
return $values;
|
340 |
-
}
|
341 |
-
} // class PLL_WPML_Config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Silence is golden.
|
3 |
-
?>
|
|
|
|
|
|
install/install-base.php
CHANGED
@@ -13,15 +13,15 @@ class PLL_Install_Base {
|
|
13 |
*
|
14 |
* @since 1.7
|
15 |
*/
|
16 |
-
public function __construct($plugin_basename) {
|
17 |
$this->plugin_basename = $plugin_basename;
|
18 |
|
19 |
// manages plugin activation and deactivation
|
20 |
-
register_activation_hook($plugin_basename, array(&$this, 'activate'));
|
21 |
-
register_deactivation_hook($plugin_basename, array(&$this, 'deactivate'));
|
22 |
|
23 |
// blog creation on multisite
|
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 |
/*
|
@@ -32,7 +32,7 @@ class PLL_Install_Base {
|
|
32 |
* @return bool true if the plugin is currently beeing deactivated
|
33 |
*/
|
34 |
public function is_deactivation() {
|
35 |
-
return isset($_GET['action'], $_GET['plugin']) && 'deactivate' == $_GET['action'] && $this->plugin_basename == $_GET['plugin'];
|
36 |
}
|
37 |
|
38 |
/*
|
@@ -42,21 +42,22 @@ class PLL_Install_Base {
|
|
42 |
*
|
43 |
* @param string $what either 'activate' or 'deactivate'
|
44 |
*/
|
45 |
-
protected function do_for_all_blogs($what, $networkwide) {
|
46 |
// network
|
47 |
-
if (is_multisite() && $networkwide) {
|
48 |
global $wpdb;
|
49 |
|
50 |
-
foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {
|
51 |
-
switch_to_blog($blog_id);
|
52 |
-
|
53 |
}
|
54 |
restore_current_blog();
|
55 |
}
|
56 |
|
57 |
// single blog
|
58 |
-
else
|
59 |
-
|
|
|
60 |
}
|
61 |
|
62 |
/*
|
@@ -64,8 +65,8 @@ class PLL_Install_Base {
|
|
64 |
*
|
65 |
* @since 1.7
|
66 |
*/
|
67 |
-
public function activate($networkwide) {
|
68 |
-
$this->do_for_all_blogs('activate', $networkwide);
|
69 |
}
|
70 |
|
71 |
/*
|
@@ -82,8 +83,8 @@ class PLL_Install_Base {
|
|
82 |
*
|
83 |
* @since 0.1
|
84 |
*/
|
85 |
-
public function deactivate($networkwide) {
|
86 |
-
$this->do_for_all_blogs('deactivate', $networkwide);
|
87 |
}
|
88 |
|
89 |
/*
|
@@ -96,14 +97,14 @@ class PLL_Install_Base {
|
|
96 |
}
|
97 |
|
98 |
/*
|
99 |
-
* blog creation on multisite (to set default options)
|
100 |
*
|
101 |
* @since 0.9.4
|
102 |
*
|
103 |
* @param int $blog_id
|
104 |
*/
|
105 |
-
public function wpmu_new_blog($blog_id) {
|
106 |
-
switch_to_blog($blog_id);
|
107 |
$this->_activate();
|
108 |
restore_current_blog();
|
109 |
}
|
13 |
*
|
14 |
* @since 1.7
|
15 |
*/
|
16 |
+
public function __construct( $plugin_basename ) {
|
17 |
$this->plugin_basename = $plugin_basename;
|
18 |
|
19 |
// manages plugin activation and deactivation
|
20 |
+
register_activation_hook( $plugin_basename, array( &$this, 'activate' ) );
|
21 |
+
register_deactivation_hook( $plugin_basename, array( &$this, 'deactivate' ) );
|
22 |
|
23 |
// blog creation on multisite
|
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 |
/*
|
32 |
* @return bool true if the plugin is currently beeing deactivated
|
33 |
*/
|
34 |
public function is_deactivation() {
|
35 |
+
return isset( $_GET['action'], $_GET['plugin'] ) && 'deactivate' == $_GET['action'] && $this->plugin_basename == $_GET['plugin'];
|
36 |
}
|
37 |
|
38 |
/*
|
42 |
*
|
43 |
* @param string $what either 'activate' or 'deactivate'
|
44 |
*/
|
45 |
+
protected function do_for_all_blogs( $what, $networkwide ) {
|
46 |
// network
|
47 |
+
if ( is_multisite() && $networkwide ) {
|
48 |
global $wpdb;
|
49 |
|
50 |
+
foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) {
|
51 |
+
switch_to_blog( $blog_id );
|
52 |
+
'activate' == $what ? $this->_activate() : $this->_deactivate();
|
53 |
}
|
54 |
restore_current_blog();
|
55 |
}
|
56 |
|
57 |
// single blog
|
58 |
+
else {
|
59 |
+
'activate' == $what ? $this->_activate() : $this->_deactivate();
|
60 |
+
}
|
61 |
}
|
62 |
|
63 |
/*
|
65 |
*
|
66 |
* @since 1.7
|
67 |
*/
|
68 |
+
public function activate( $networkwide ) {
|
69 |
+
$this->do_for_all_blogs( 'activate', $networkwide );
|
70 |
}
|
71 |
|
72 |
/*
|
83 |
*
|
84 |
* @since 0.1
|
85 |
*/
|
86 |
+
public function deactivate( $networkwide ) {
|
87 |
+
$this->do_for_all_blogs( 'deactivate', $networkwide );
|
88 |
}
|
89 |
|
90 |
/*
|
97 |
}
|
98 |
|
99 |
/*
|
100 |
+
* blog creation on multisite ( to set default options )
|
101 |
*
|
102 |
* @since 0.9.4
|
103 |
*
|
104 |
* @param int $blog_id
|
105 |
*/
|
106 |
+
public function wpmu_new_blog( $blog_id ) {
|
107 |
+
switch_to_blog( $blog_id );
|
108 |
$this->_activate();
|
109 |
restore_current_blog();
|
110 |
}
|
install/install.php
CHANGED
@@ -12,22 +12,47 @@ class PLL_Install extends PLL_Install_Base {
|
|
12 |
*
|
13 |
* @since 0.1
|
14 |
*/
|
15 |
-
public function activate($networkwide) {
|
16 |
global $wp_version;
|
17 |
|
18 |
Polylang::define_constants();
|
19 |
|
20 |
-
load_plugin_textdomain('polylang', false, basename(POLYLANG_DIR).'/languages'); // plugin i18n
|
21 |
|
22 |
-
if (version_compare($wp_version, PLL_MIN_WP_VERSION , '<'))
|
23 |
-
die
|
24 |
-
|
25 |
-
|
|
|
26 |
PLL_MIN_WP_VERSION
|
27 |
)
|
28 |
-
));
|
|
|
|
|
|
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
/*
|
@@ -36,44 +61,27 @@ class PLL_Install extends PLL_Install_Base {
|
|
36 |
* @since 0.5
|
37 |
*/
|
38 |
protected function _activate() {
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
$upgrade = new PLL_Upgrade($options);
|
45 |
-
$upgrade->upgrade_at_activation();
|
46 |
}
|
47 |
}
|
48 |
// defines default values for options in case this is the first installation
|
49 |
else {
|
50 |
-
|
51 |
-
'browser' => 1, // default language for the front page is set by browser preference
|
52 |
-
'rewrite' => 1, // remove /language/ in permalinks (was the opposite before 0.7.2)
|
53 |
-
'hide_default' => 0, // do not remove URL language information for default language
|
54 |
-
'force_lang' => 1, // add URL language information (was 0 before 1.7)
|
55 |
-
'redirect_lang' => 0, // do not redirect the language page to the homepage
|
56 |
-
'media_support' => 1, // support languages and translation for media by default
|
57 |
-
'sync' => array(), // synchronisation is disabled by default (was the opposite before 1.2)
|
58 |
-
'post_types' => array_values(get_post_types(array('_builtin' => false, 'show_ui' => true))),
|
59 |
-
'taxonomies' => array_values(get_taxonomies(array('_builtin' => false, 'show_ui' => true))),
|
60 |
-
'domains' => array(),
|
61 |
-
'version' => POLYLANG_VERSION,
|
62 |
-
);
|
63 |
-
|
64 |
-
update_option('polylang', $options);
|
65 |
}
|
66 |
|
67 |
-
//
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
$polylang->links_model = $polylang->model->get_links_model();
|
72 |
-
do_action('pll_init');
|
73 |
|
74 |
// don't use flush_rewrite_rules at network activation. See #32471
|
75 |
// thanks to RavanH for the trick. See https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/
|
76 |
-
|
|
|
77 |
}
|
78 |
|
79 |
/*
|
@@ -82,6 +90,6 @@ class PLL_Install extends PLL_Install_Base {
|
|
82 |
* @since 0.5
|
83 |
*/
|
84 |
protected function _deactivate() {
|
85 |
-
delete_option('rewrite_rules'); // don't use flush_rewrite_rules at network activation. See #32471
|
86 |
}
|
87 |
}
|
12 |
*
|
13 |
* @since 0.1
|
14 |
*/
|
15 |
+
public function activate( $networkwide ) {
|
16 |
global $wp_version;
|
17 |
|
18 |
Polylang::define_constants();
|
19 |
|
20 |
+
load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ).'/languages' ); // plugin i18n
|
21 |
|
22 |
+
if ( version_compare( $wp_version, PLL_MIN_WP_VERSION , '<' ) ) {
|
23 |
+
die( sprintf( '<p style = "font-family: sans-serif; font-size: 12px; color: #333; margin: -5px">%s</p>',
|
24 |
+
/* translators: %s are WordPress version numbers */
|
25 |
+
sprintf( __( 'You are using WordPress %s. Polylang requires at least WordPress %s.', 'polylang' ),
|
26 |
+
esc_html( $wp_version ),
|
27 |
PLL_MIN_WP_VERSION
|
28 |
)
|
29 |
+
) );
|
30 |
+
}
|
31 |
+
$this->do_for_all_blogs( 'activate', $networkwide );
|
32 |
+
}
|
33 |
|
34 |
+
/*
|
35 |
+
* get default Polylang options
|
36 |
+
*
|
37 |
+
* @since 1.8
|
38 |
+
*
|
39 |
+
* return array
|
40 |
+
*/
|
41 |
+
static public function get_default_options() {
|
42 |
+
return array(
|
43 |
+
'browser' => 1, // default language for the front page is set by browser preference
|
44 |
+
'rewrite' => 1, // remove /language/ in permalinks ( was the opposite before 0.7.2 )
|
45 |
+
'hide_default' => 0, // do not remove URL language information for default language
|
46 |
+
'force_lang' => 1, // add URL language information ( was 0 before 1.7 )
|
47 |
+
'redirect_lang' => 0, // do not redirect the language page to the homepage
|
48 |
+
'media_support' => 1, // support languages and translation for media by default
|
49 |
+
'uninstall' => 0, // do not remove data when uninstalling Polylang
|
50 |
+
'sync' => array(), // synchronisation is disabled by default ( was the opposite before 1.2 )
|
51 |
+
'post_types' => array_values( get_post_types( array( '_builtin' => false, 'show_ui' => true ) ) ),
|
52 |
+
'taxonomies' => array_values( get_taxonomies( array( '_builtin' => false, 'show_ui' => true ) ) ),
|
53 |
+
'domains' => array(),
|
54 |
+
'version' => POLYLANG_VERSION,
|
55 |
+
);
|
56 |
}
|
57 |
|
58 |
/*
|
61 |
* @since 0.5
|
62 |
*/
|
63 |
protected function _activate() {
|
64 |
+
if ( $options = get_option( 'polylang' ) ) {
|
65 |
+
// check if we will be able to upgrade
|
66 |
+
if ( version_compare( $options['version'], POLYLANG_VERSION, '<' ) ) {
|
67 |
+
$upgrade = new PLL_Upgrade( $options );
|
68 |
+
$upgrade->can_activate();
|
|
|
|
|
69 |
}
|
70 |
}
|
71 |
// defines default values for options in case this is the first installation
|
72 |
else {
|
73 |
+
update_option( 'polylang', self::get_default_options() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
+
// avoid 1 query on every pages if no wpml strings is registered
|
77 |
+
if ( ! get_option( 'polylang_wpml_strings' ) ) {
|
78 |
+
update_option( 'polylang_wpml_strings', array() );
|
79 |
+
}
|
|
|
|
|
80 |
|
81 |
// don't use flush_rewrite_rules at network activation. See #32471
|
82 |
// thanks to RavanH for the trick. See https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/
|
83 |
+
// rewrite rules are created at next page load :)
|
84 |
+
delete_option( 'rewrite_rules' );
|
85 |
}
|
86 |
|
87 |
/*
|
90 |
* @since 0.5
|
91 |
*/
|
92 |
protected function _deactivate() {
|
93 |
+
delete_option( 'rewrite_rules' ); // don't use flush_rewrite_rules at network activation. See #32471
|
94 |
}
|
95 |
}
|
install/upgrade.php
CHANGED
@@ -13,20 +13,20 @@ class PLL_Upgrade {
|
|
13 |
*
|
14 |
* @since 1.2
|
15 |
*/
|
16 |
-
public function __construct(&$options) {
|
17 |
$this->options = &$options;
|
18 |
}
|
19 |
|
20 |
/*
|
21 |
-
*
|
22 |
*
|
23 |
* @since 1.2
|
24 |
*/
|
25 |
-
public function
|
26 |
-
if (
|
27 |
ob_start();
|
28 |
-
$this->admin_notices();
|
29 |
-
die(ob_get_contents());
|
30 |
}
|
31 |
}
|
32 |
|
@@ -38,10 +38,12 @@ class PLL_Upgrade {
|
|
38 |
* @return bool true if upgrade is possible, false otherwise
|
39 |
*/
|
40 |
public function upgrade() {
|
41 |
-
if (
|
42 |
-
add_action('all_admin_notices', array(&$this, 'admin_notices'));
|
43 |
return false;
|
44 |
}
|
|
|
|
|
45 |
return true;
|
46 |
}
|
47 |
|
@@ -57,11 +59,7 @@ class PLL_Upgrade {
|
|
57 |
*/
|
58 |
public function can_upgrade() {
|
59 |
// don't manage upgrade from version < 0.8
|
60 |
-
|
61 |
-
return false;
|
62 |
-
|
63 |
-
add_action('admin_init', array(&$this, '_upgrade'));
|
64 |
-
return true;
|
65 |
}
|
66 |
|
67 |
/*
|
@@ -70,12 +68,13 @@ class PLL_Upgrade {
|
|
70 |
* @since 1.0
|
71 |
*/
|
72 |
public function admin_notices() {
|
73 |
-
load_plugin_textdomain('polylang', false, basename(POLYLANG_DIR).'/languages');
|
74 |
printf(
|
75 |
'<div class="error"><p>%s</p><p>%s</p></div>',
|
76 |
-
__('Polylang has been deactivated because you upgraded from a too old version.', 'polylang'),
|
77 |
sprintf(
|
78 |
-
|
|
|
79 |
'<strong>0.9.8</strong>',
|
80 |
POLYLANG_VERSION
|
81 |
)
|
@@ -88,18 +87,20 @@ class PLL_Upgrade {
|
|
88 |
* @since 1.2
|
89 |
*/
|
90 |
public function _upgrade() {
|
91 |
-
foreach (array('0.9', '1.0', '1.1', '1.2', '1.2.1', '1.2.3', '1.3', '1.4', '1.4.1', '1.4.4', '1.5', '1.6', '1.7.4') as $version)
|
92 |
-
if (version_compare($this->options['version'], $version, '<'))
|
93 |
-
call_user_func(array(&$this, 'upgrade_' . str_replace('.', '_', $version)));
|
|
|
|
|
94 |
|
95 |
$delete_pre_1_2_data = get_transient( 'pll_upgrade_1_4' );
|
96 |
if ( false !== $delete_pre_1_2_data && absint( $delete_pre_1_2_data ) < time() ) {
|
97 |
$this->delete_pre_1_2_data();
|
98 |
}
|
99 |
|
100 |
-
$this->options['previous_version'] = $this->options['version']; // remember the previous version of Polylang
|
101 |
$this->options['version'] = POLYLANG_VERSION;
|
102 |
-
update_option('polylang', $this->options);
|
103 |
}
|
104 |
|
105 |
/*
|
@@ -108,7 +109,7 @@ class PLL_Upgrade {
|
|
108 |
* @since 1.2
|
109 |
*/
|
110 |
protected function upgrade_0_9() {
|
111 |
-
$this->options['sync'] = defined('PLL_SYNC') && !PLL_SYNC ? 0 : 1; // the option replaces PLL_SYNC in 0.9
|
112 |
}
|
113 |
|
114 |
/*
|
@@ -118,15 +119,15 @@ class PLL_Upgrade {
|
|
118 |
*/
|
119 |
protected function upgrade_1_0() {
|
120 |
// the option replaces PLL_MEDIA_SUPPORT in 1.0
|
121 |
-
$this->options['media_support'] = defined('PLL_MEDIA_SUPPORT') && !PLL_MEDIA_SUPPORT ? 0 : 1;
|
122 |
|
123 |
// split the synchronization options in 1.0
|
124 |
-
$this->options['sync'] = empty($this->options['sync']) ? array() : array_keys(
|
125 |
|
126 |
// set default values for post types and taxonomies to translate
|
127 |
-
$this->options['post_types'] = array_values(get_post_types(array('_builtin' => false, 'show_ui' => true)));
|
128 |
-
$this->options['taxonomies'] = array_values(get_taxonomies(array('_builtin' => false, 'show_ui' => true)));
|
129 |
-
update_option('polylang', $this->options);
|
130 |
|
131 |
flush_rewrite_rules(); // rewrite rules have been modified in 1.0
|
132 |
}
|
@@ -138,17 +139,18 @@ class PLL_Upgrade {
|
|
138 |
*/
|
139 |
protected function upgrade_1_1() {
|
140 |
// update strings register with icl_register_string
|
141 |
-
$strings = get_option('polylang_wpml_strings');
|
142 |
-
if ($strings) {
|
143 |
-
foreach ($strings as $key => $string)
|
144 |
-
$strings[$key]['icl'] = 1;
|
145 |
-
|
|
|
146 |
}
|
147 |
|
148 |
// move polylang_widgets options
|
149 |
-
if ($widgets = get_option('polylang_widgets')) {
|
150 |
$this->options['widgets'] = $widgets;
|
151 |
-
delete_option('polylang_widgets');
|
152 |
}
|
153 |
}
|
154 |
|
@@ -161,96 +163,107 @@ class PLL_Upgrade {
|
|
161 |
$this->options['domains'] = array(); // option added in 1.2
|
162 |
|
163 |
// need to register the taxonomies
|
164 |
-
foreach (array('language', 'term_language', 'post_translations', 'term_translations') as $taxonomy)
|
165 |
-
register_taxonomy($taxonomy, null , array('label' => false, 'public' => false, 'query_var' => false, 'rewrite' => false));
|
|
|
166 |
|
167 |
// abort if the db upgrade has already been done previously
|
168 |
-
if (get_terms('term_language', array('hide_empty' => 0)))
|
169 |
return;
|
|
|
170 |
|
171 |
-
set_time_limit(0); // in case we upgrade a huge site
|
172 |
|
173 |
// upgrade old model based on metas to new model based on taxonomies
|
174 |
global $wpdb;
|
175 |
$wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
|
176 |
-
$languages = get_terms('language', array('hide_empty' => 0)); // don't use get_languages_list which can't work with the old model
|
177 |
|
178 |
-
foreach($languages as $lang) {
|
179 |
// first update language with new storage for locale and text direction
|
180 |
-
$text_direction = get_metadata('term', $lang->term_id, '_rtl', true);
|
181 |
-
$desc = serialize(array('locale' => $lang->description, 'rtl' => $text_direction));
|
182 |
-
wp_update_term((int) $lang->term_id, 'language', array('description' => $desc));
|
183 |
|
184 |
// add language to new 'term_language' taxonomy
|
185 |
-
$term_lang = wp_insert_term($lang->name, 'term_language', array('slug' => 'pll_' . $lang->slug));
|
186 |
-
$lang_tt_ids[$lang->term_id] = $term_lang['term_taxonomy_id']; // keep the term taxonomy id for future
|
187 |
}
|
188 |
|
189 |
// get all terms with a language defined
|
190 |
-
$terms = $wpdb->get_results("SELECT term_id, meta_value FROM $wpdb->termmeta WHERE meta_key = '_language'");
|
191 |
-
foreach ($terms as $key => $term)
|
192 |
-
$terms[$key] = $wpdb->prepare('(%d, %d)', $term->term_id, $lang_tt_ids[$term->meta_value]);
|
|
|
193 |
|
194 |
-
$terms = array_unique($terms);
|
195 |
|
196 |
// assign language to each term
|
197 |
-
if (!empty($terms))
|
198 |
-
$wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES " . implode(',', $terms));
|
|
|
199 |
|
200 |
// translations
|
201 |
-
foreach (array('post', 'term') as $type) {
|
202 |
$table = $type . 'meta';
|
203 |
$terms = $slugs = $tts = $trs = array();
|
204 |
|
205 |
// get all translated objects
|
206 |
-
$objects = $wpdb->get_col("SELECT DISTINCT meta_value FROM {$wpdb->$table} WHERE meta_key = '_translations'");
|
207 |
|
208 |
-
if (empty($objects))
|
209 |
continue;
|
|
|
210 |
|
211 |
-
foreach ($objects as $obj) {
|
212 |
-
$term = uniqid('pll_'); // the term name
|
213 |
-
$terms[] = $wpdb->prepare('("%1$s", "%1$s")', $term);
|
214 |
-
$slugs[] = $wpdb->prepare('"%s"', $term);
|
215 |
-
$translations = maybe_unserialize(maybe_unserialize($obj)); // 2 unserialize due to an old storage bug
|
216 |
-
$description[$term] = serialize($translations);
|
217 |
}
|
218 |
|
219 |
-
$terms = array_unique($terms);
|
220 |
|
221 |
// insert terms
|
222 |
-
if (!empty($terms))
|
223 |
-
$wpdb->query("INSERT INTO $wpdb->terms (slug, name) VALUES " . implode(',', $terms));
|
|
|
224 |
|
225 |
// get all terms with their term_id
|
226 |
-
$terms = $wpdb->get_results("SELECT term_id, slug FROM $wpdb->terms WHERE slug IN (" . implode(',', $slugs) . ")");
|
227 |
|
228 |
// prepare terms taxonomy relationship
|
229 |
-
foreach ($terms as $term)
|
230 |
-
$tts[] = $wpdb->prepare('(%d, "%s", "%s")', $term->term_id, $type . '_translations', $description[$term->slug]);
|
|
|
231 |
|
232 |
-
$tts = array_unique($tts);
|
233 |
|
234 |
// insert term_taxonomy
|
235 |
-
if (!empty($tts))
|
236 |
-
$wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description) VALUES " . implode(',', $tts));
|
|
|
237 |
|
238 |
// get all terms with term_taxonomy_id
|
239 |
-
$terms = get_terms($type . '_translations', array('hide_empty' => false));
|
240 |
|
241 |
// prepare objects relationships
|
242 |
-
foreach ($terms as $term) {
|
243 |
-
$translations = unserialize($term->description);
|
244 |
-
foreach ($translations as $object_id)
|
245 |
-
if (!empty($object_id))
|
246 |
-
$trs[] = $wpdb->prepare('(%d, %d)', $object_id, $term->term_taxonomy_id);
|
|
|
|
|
247 |
}
|
248 |
|
249 |
-
$trs = array_unique($trs);
|
250 |
|
251 |
// insert term_relationships
|
252 |
-
if (!empty($trs))
|
253 |
-
$wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES " . implode(',', $trs));
|
|
|
254 |
}
|
255 |
|
256 |
// upgrade of string translations is now in upgrade_1_2_1
|
@@ -264,12 +277,13 @@ class PLL_Upgrade {
|
|
264 |
*/
|
265 |
protected function upgrade_1_2_1() {
|
266 |
// strings translations
|
267 |
-
foreach(get_terms('language', array('hide_empty' => 0)) as $lang) {
|
268 |
-
if ($strings = get_option('polylang_mo'
|
269 |
$mo = new PLL_MO();
|
270 |
-
foreach ($strings as $msg)
|
271 |
-
$mo->add_entry($mo->make_entry($msg[0], $msg[1]));
|
272 |
-
|
|
|
273 |
}
|
274 |
}
|
275 |
}
|
@@ -283,66 +297,70 @@ class PLL_Upgrade {
|
|
283 |
public function upgrade_1_2_3() {
|
284 |
// old version < 1.1
|
285 |
// multilingal locations and switcher item were stored in a dedicated option
|
286 |
-
if (version_compare($this->options['version'], '1.1', '<')) {
|
287 |
-
if ($menu_lang = get_option('polylang_nav_menus')) {
|
288 |
-
foreach ($menu_lang as $location => $arr) {
|
289 |
-
if (!in_array($location, array_keys(get_registered_nav_menus())))
|
290 |
continue;
|
|
|
291 |
|
292 |
-
$switch_options = array_slice($arr, -5, 5);
|
293 |
-
$translations = array_diff_key($arr, $switch_options);
|
294 |
-
$has_switcher = array_shift($switch_options);
|
295 |
|
296 |
-
foreach (get_terms('language', array('hide_empty' => 0)) as $lang) {
|
297 |
// move nav menus locations
|
298 |
-
if (!empty($translations[$lang->slug]))
|
299 |
-
$locations[$location][$lang->slug] = $translations[$lang->slug];
|
|
|
300 |
|
301 |
// create the menu items for the language switcher
|
302 |
-
if (!empty($has_switcher)) {
|
303 |
-
$menu_item_db_id = wp_update_nav_menu_item($translations[$lang->slug], 0, array(
|
304 |
-
'menu-item-title' => __('Language switcher', 'polylang'),
|
305 |
'menu-item-url' => '#pll_switcher',
|
306 |
-
'menu-item-status' => 'publish'
|
307 |
-
));
|
308 |
|
309 |
-
update_post_meta($menu_item_db_id, '_pll_menu_item', $switch_options);
|
310 |
}
|
311 |
}
|
312 |
}
|
313 |
|
314 |
-
if (!empty($locations))
|
315 |
-
$this->options['nav_menus'][get_option('stylesheet')] = $locations;
|
|
|
316 |
|
317 |
-
delete_option('polylang_nav_menus');
|
318 |
}
|
319 |
-
|
320 |
}
|
321 |
|
322 |
-
elseif (empty($this->options['nav_menus'])) {
|
323 |
-
$menus = get_theme_mod('nav_menu_locations');
|
324 |
|
325 |
-
if (is_array($menus)) {
|
326 |
// if old version < 1.2
|
327 |
// clean the WP option as it was a bad idea to pollute it
|
328 |
-
if (version_compare($this->options['version'], '1.2', '<')) {
|
329 |
-
foreach ($menus as $loc => $menu) {
|
330 |
-
if ($pos = strpos($loc, '#'))
|
331 |
-
unset($menus[$loc]);
|
|
|
332 |
}
|
333 |
|
334 |
-
set_theme_mod('nav_menu_locations', $menus);
|
335 |
}
|
336 |
|
337 |
// get the multilingual locations
|
338 |
-
foreach ($menus as $loc => $menu) {
|
339 |
-
foreach (get_terms('language', array('hide_empty' => 0)) as $lang) {
|
340 |
-
$arr[$loc][$lang->slug] = pll_get_term($menu, $lang);
|
341 |
}
|
342 |
}
|
343 |
|
344 |
-
if (!empty($arr))
|
345 |
-
$this->options['nav_menus'][get_option('stylesheet')] = $arr;
|
|
|
346 |
}
|
347 |
}
|
348 |
}
|
@@ -355,13 +373,13 @@ class PLL_Upgrade {
|
|
355 |
*/
|
356 |
protected function upgrade_1_3() {
|
357 |
$usermeta = 'description_' . $this->options['default_lang'];
|
358 |
-
$query = new WP_User_Query(array('blog_id' => $GLOBALS['blog_id'], 'meta_key' => $usermeta));
|
359 |
|
360 |
-
foreach ($query->get_results() as $user) {
|
361 |
-
$desc = get_user_meta($user->ID, $usermeta, true);
|
362 |
-
if (!empty($desc)) {
|
363 |
-
update_user_meta($user->ID, 'description', $desc);
|
364 |
-
delete_user_meta($user->ID, $usermeta);
|
365 |
}
|
366 |
}
|
367 |
}
|
@@ -374,8 +392,8 @@ class PLL_Upgrade {
|
|
374 |
* @since 1.4
|
375 |
*/
|
376 |
protected function upgrade_1_4() {
|
377 |
-
set_transient('pll_upgrade_1_4', time() + 60 * 24 * 60 * 60); // 60 days
|
378 |
-
delete_transient('pll_languages_list');
|
379 |
}
|
380 |
|
381 |
/*
|
@@ -390,19 +408,20 @@ class PLL_Upgrade {
|
|
390 |
$wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb in case WP < 4.4
|
391 |
|
392 |
// do nothing if the termmeta table does not exists
|
393 |
-
if (count($wpdb->get_results("SHOW TABLES LIKE '$wpdb->termmeta'"))) {
|
394 |
-
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = '_translations'");
|
395 |
-
$wpdb->query("DELETE FROM $wpdb->termmeta WHERE meta_key = '_language'");
|
396 |
-
$wpdb->query("DELETE FROM $wpdb->termmeta WHERE meta_key = '_rtl'");
|
397 |
-
$wpdb->query("DELETE FROM $wpdb->termmeta WHERE meta_key = '_translations'");
|
398 |
}
|
399 |
|
400 |
// delete the strings translations
|
401 |
-
$languages = get_terms('language', array('hide_empty'=>false));
|
402 |
-
foreach ($languages as $lang)
|
403 |
-
delete_option('polylang_mo'
|
|
|
404 |
|
405 |
-
delete_transient('pll_upgrade_1_4');
|
406 |
}
|
407 |
|
408 |
/*
|
@@ -412,8 +431,9 @@ class PLL_Upgrade {
|
|
412 |
* @since 1.4.1
|
413 |
*/
|
414 |
protected function upgrade_1_4_1() {
|
415 |
-
if (3 == $this->options['force_lang'])
|
416 |
$this->options['browser'] = $this->options['hide_default'] = 0;
|
|
|
417 |
}
|
418 |
|
419 |
/*
|
@@ -423,17 +443,17 @@ class PLL_Upgrade {
|
|
423 |
* @since 1.4.4
|
424 |
*/
|
425 |
protected function upgrade_1_4_4() {
|
426 |
-
foreach ($GLOBALS['wp_registered_widgets'] as $widget) {
|
427 |
-
if (!empty($this->options['widgets'][$widget['id']]) && !empty($widget['callback'][0]) && !empty($widget['params'][0]['number'])) {
|
428 |
$obj = $widget['callback'][0];
|
429 |
-
if (is_object($obj) && method_exists($obj, 'get_settings') && method_exists($obj, 'save_settings')) {
|
430 |
$settings = $obj->get_settings();
|
431 |
-
$settings[$widget['params'][0]['number']]['pll_lang'] = $this->options['widgets'][$widget['id']];
|
432 |
-
$obj->save_settings($settings);
|
433 |
}
|
434 |
}
|
435 |
}
|
436 |
-
unset($this->options['widgets']);
|
437 |
}
|
438 |
|
439 |
/*
|
@@ -443,7 +463,7 @@ class PLL_Upgrade {
|
|
443 |
* @since 1.5
|
444 |
*/
|
445 |
protected function upgrade_1_5() {
|
446 |
-
delete_transient('pll_languages_list');
|
447 |
}
|
448 |
|
449 |
/*
|
@@ -453,7 +473,7 @@ class PLL_Upgrade {
|
|
453 |
* @since 1.6
|
454 |
*/
|
455 |
protected function upgrade_1_6() {
|
456 |
-
if (version_compare($GLOBALS['wp_version'], '4.0', '>=')) {
|
457 |
self::download_language_packs();
|
458 |
}
|
459 |
}
|
@@ -467,33 +487,36 @@ class PLL_Upgrade {
|
|
467 |
* @since 1.6
|
468 |
*/
|
469 |
static function download_language_packs() {
|
470 |
-
$languages = pll_languages_list(array('fields' => 'locale'));
|
471 |
|
472 |
// prevents upgrade if the .po file is already here. Let WP manage the upgrades :)
|
473 |
-
foreach ($languages as $key => $locale) {
|
474 |
-
if (file_exists(WP_LANG_DIR . "/$locale.po"))
|
475 |
-
unset($languages[$key]);
|
|
|
476 |
}
|
477 |
|
478 |
-
if (empty($languages))
|
479 |
return;
|
|
|
480 |
|
481 |
-
require_once(ABSPATH . 'wp-admin/includes/translation-install.php');
|
482 |
$translations = wp_get_available_translations();
|
483 |
-
if (
|
484 |
return;
|
|
|
485 |
|
486 |
-
foreach ($translations as $translation) {
|
487 |
-
if (in_array($translation['language'], $languages)) {
|
488 |
$translation['type'] = 'core';
|
489 |
$translations_to_load[] = (object) $translation;
|
490 |
}
|
491 |
}
|
492 |
|
493 |
-
if (!empty($translations_to_load)) {
|
494 |
-
require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
|
495 |
-
$upgrader = new Language_Pack_Upgrader(new Automatic_Upgrader_Skin);
|
496 |
-
$upgrader->bulk_upgrade($translations_to_load, array('clear_update_cache' => false));
|
497 |
}
|
498 |
}
|
499 |
|
@@ -503,7 +526,30 @@ class PLL_Upgrade {
|
|
503 |
* @since 1.7.4
|
504 |
*/
|
505 |
protected function upgrade_1_7_4() {
|
506 |
-
delete_transient('pll_languages_list'); // deletes language cache (due to flag properties added in 1.7, page on front removed in 1.7.2, home url fixes in 1.7.4)
|
507 |
flush_rewrite_rules(); // flush rewrite rules due to custom taxonomy rewrite rule bug fix
|
508 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
509 |
}
|
13 |
*
|
14 |
* @since 1.2
|
15 |
*/
|
16 |
+
public function __construct( &$options ) {
|
17 |
$this->options = &$options;
|
18 |
}
|
19 |
|
20 |
/*
|
21 |
+
* check if upgrade is possible otherwise die to avoid activation
|
22 |
*
|
23 |
* @since 1.2
|
24 |
*/
|
25 |
+
public function can_activate() {
|
26 |
+
if ( ! $this->can_upgrade() ) {
|
27 |
ob_start();
|
28 |
+
$this->admin_notices(); // FIXME the error message is displayed two times
|
29 |
+
die( ob_get_contents() );
|
30 |
}
|
31 |
}
|
32 |
|
38 |
* @return bool true if upgrade is possible, false otherwise
|
39 |
*/
|
40 |
public function upgrade() {
|
41 |
+
if ( ! $this->can_upgrade() ) {
|
42 |
+
add_action( 'all_admin_notices', array( &$this, 'admin_notices' ) );
|
43 |
return false;
|
44 |
}
|
45 |
+
|
46 |
+
add_action( 'admin_init', array( &$this, '_upgrade' ) );
|
47 |
return true;
|
48 |
}
|
49 |
|
59 |
*/
|
60 |
public function can_upgrade() {
|
61 |
// don't manage upgrade from version < 0.8
|
62 |
+
return version_compare( $this->options['version'], '0.8', '>=' );
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
/*
|
68 |
* @since 1.0
|
69 |
*/
|
70 |
public function admin_notices() {
|
71 |
+
load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' );
|
72 |
printf(
|
73 |
'<div class="error"><p>%s</p><p>%s</p></div>',
|
74 |
+
__( 'Polylang has been deactivated because you upgraded from a too old version.', 'polylang' ),
|
75 |
sprintf(
|
76 |
+
/* translators: %s are Polylang version numbers */
|
77 |
+
__( 'Please upgrade first to %s before ugrading to %s.', 'polylang' ),
|
78 |
'<strong>0.9.8</strong>',
|
79 |
POLYLANG_VERSION
|
80 |
)
|
87 |
* @since 1.2
|
88 |
*/
|
89 |
public function _upgrade() {
|
90 |
+
foreach ( array( '0.9', '1.0', '1.1', '1.2', '1.2.1', '1.2.3', '1.3', '1.4', '1.4.1', '1.4.4', '1.5', '1.6', '1.7.4', '1.8' ) as $version ) {
|
91 |
+
if ( version_compare( $this->options['version'], $version, '<' ) ) {
|
92 |
+
call_user_func( array( &$this, 'upgrade_' . str_replace( '.', '_', $version ) ) );
|
93 |
+
}
|
94 |
+
}
|
95 |
|
96 |
$delete_pre_1_2_data = get_transient( 'pll_upgrade_1_4' );
|
97 |
if ( false !== $delete_pre_1_2_data && absint( $delete_pre_1_2_data ) < time() ) {
|
98 |
$this->delete_pre_1_2_data();
|
99 |
}
|
100 |
|
101 |
+
$this->options['previous_version'] = $this->options['version']; // remember the previous version of Polylang since v1.7.7
|
102 |
$this->options['version'] = POLYLANG_VERSION;
|
103 |
+
update_option( 'polylang', $this->options );
|
104 |
}
|
105 |
|
106 |
/*
|
109 |
* @since 1.2
|
110 |
*/
|
111 |
protected function upgrade_0_9() {
|
112 |
+
$this->options['sync'] = defined( 'PLL_SYNC' ) && ! PLL_SYNC ? 0 : 1; // the option replaces PLL_SYNC in 0.9
|
113 |
}
|
114 |
|
115 |
/*
|
119 |
*/
|
120 |
protected function upgrade_1_0() {
|
121 |
// the option replaces PLL_MEDIA_SUPPORT in 1.0
|
122 |
+
$this->options['media_support'] = defined( 'PLL_MEDIA_SUPPORT' ) && ! PLL_MEDIA_SUPPORT ? 0 : 1;
|
123 |
|
124 |
// split the synchronization options in 1.0
|
125 |
+
$this->options['sync'] = empty( $this->options['sync'] ) ? array() : array_keys( PLL_Settings_Sync::list_metas_to_sync() );
|
126 |
|
127 |
// set default values for post types and taxonomies to translate
|
128 |
+
$this->options['post_types'] = array_values( get_post_types( array( '_builtin' => false, 'show_ui' => true ) ) );
|
129 |
+
$this->options['taxonomies'] = array_values( get_taxonomies( array( '_builtin' => false, 'show_ui' => true ) ) );
|
130 |
+
update_option( 'polylang', $this->options );
|
131 |
|
132 |
flush_rewrite_rules(); // rewrite rules have been modified in 1.0
|
133 |
}
|
139 |
*/
|
140 |
protected function upgrade_1_1() {
|
141 |
// update strings register with icl_register_string
|
142 |
+
$strings = get_option( 'polylang_wpml_strings' );
|
143 |
+
if ( $strings ) {
|
144 |
+
foreach ( $strings as $key => $string ) {
|
145 |
+
$strings[ $key ]['icl'] = 1;
|
146 |
+
}
|
147 |
+
update_option( 'polylang_wpml_strings', $strings );
|
148 |
}
|
149 |
|
150 |
// move polylang_widgets options
|
151 |
+
if ( $widgets = get_option( 'polylang_widgets' ) ) {
|
152 |
$this->options['widgets'] = $widgets;
|
153 |
+
delete_option( 'polylang_widgets' );
|
154 |
}
|
155 |
}
|
156 |
|
163 |
$this->options['domains'] = array(); // option added in 1.2
|
164 |
|
165 |
// need to register the taxonomies
|
166 |
+
foreach ( array( 'language', 'term_language', 'post_translations', 'term_translations' ) as $taxonomy ) {
|
167 |
+
register_taxonomy( $taxonomy, null , array( 'label' => false, 'public' => false, 'query_var' => false, 'rewrite' => false ) );
|
168 |
+
}
|
169 |
|
170 |
// abort if the db upgrade has already been done previously
|
171 |
+
if ( get_terms( 'term_language', array( 'hide_empty' => 0 ) ) ) {
|
172 |
return;
|
173 |
+
}
|
174 |
|
175 |
+
set_time_limit( 0 ); // in case we upgrade a huge site
|
176 |
|
177 |
// upgrade old model based on metas to new model based on taxonomies
|
178 |
global $wpdb;
|
179 |
$wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
|
180 |
+
$languages = get_terms( 'language', array( 'hide_empty' => 0 ) ); // don't use get_languages_list which can't work with the old model
|
181 |
|
182 |
+
foreach ( $languages as $lang ) {
|
183 |
// first update language with new storage for locale and text direction
|
184 |
+
$text_direction = get_metadata( 'term', $lang->term_id, '_rtl', true );
|
185 |
+
$desc = serialize( array( 'locale' => $lang->description, 'rtl' => $text_direction ) );
|
186 |
+
wp_update_term( (int) $lang->term_id, 'language', array( 'description' => $desc ) );
|
187 |
|
188 |
// add language to new 'term_language' taxonomy
|
189 |
+
$term_lang = wp_insert_term( $lang->name, 'term_language', array( 'slug' => 'pll_' . $lang->slug ) );
|
190 |
+
$lang_tt_ids[ $lang->term_id ] = $term_lang['term_taxonomy_id']; // keep the term taxonomy id for future
|
191 |
}
|
192 |
|
193 |
// get all terms with a language defined
|
194 |
+
$terms = $wpdb->get_results( "SELECT term_id, meta_value FROM $wpdb->termmeta WHERE meta_key = '_language'" );
|
195 |
+
foreach ( $terms as $key => $term ) {
|
196 |
+
$terms[ $key ] = $wpdb->prepare( '( %d, %d )', $term->term_id, $lang_tt_ids[ $term->meta_value ] );
|
197 |
+
}
|
198 |
|
199 |
+
$terms = array_unique( $terms );
|
200 |
|
201 |
// assign language to each term
|
202 |
+
if ( ! empty( $terms ) ) {
|
203 |
+
$wpdb->query( "INSERT INTO $wpdb->term_relationships ( object_id, term_taxonomy_id ) VALUES " . implode( ',', $terms ) );
|
204 |
+
}
|
205 |
|
206 |
// translations
|
207 |
+
foreach ( array( 'post', 'term' ) as $type ) {
|
208 |
$table = $type . 'meta';
|
209 |
$terms = $slugs = $tts = $trs = array();
|
210 |
|
211 |
// get all translated objects
|
212 |
+
$objects = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->$table} WHERE meta_key = '_translations'" );
|
213 |
|
214 |
+
if ( empty( $objects ) ) {
|
215 |
continue;
|
216 |
+
}
|
217 |
|
218 |
+
foreach ( $objects as $obj ) {
|
219 |
+
$term = uniqid( 'pll_' ); // the term name
|
220 |
+
$terms[] = $wpdb->prepare( '( "%1$s", "%1$s" )', $term );
|
221 |
+
$slugs[] = $wpdb->prepare( '"%s"', $term );
|
222 |
+
$translations = maybe_unserialize( maybe_unserialize( $obj ) ); // 2 unserialize due to an old storage bug
|
223 |
+
$description[ $term ] = serialize( $translations );
|
224 |
}
|
225 |
|
226 |
+
$terms = array_unique( $terms );
|
227 |
|
228 |
// insert terms
|
229 |
+
if ( ! empty( $terms ) ) {
|
230 |
+
$wpdb->query( "INSERT INTO $wpdb->terms ( slug, name ) VALUES " . implode( ',', $terms ) );
|
231 |
+
}
|
232 |
|
233 |
// get all terms with their term_id
|
234 |
+
$terms = $wpdb->get_results( "SELECT term_id, slug FROM $wpdb->terms WHERE slug IN ( " . implode( ',', $slugs ) . " )" );
|
235 |
|
236 |
// prepare terms taxonomy relationship
|
237 |
+
foreach ( $terms as $term ) {
|
238 |
+
$tts[] = $wpdb->prepare( '( %d, "%s", "%s" )', $term->term_id, $type . '_translations', $description[ $term->slug ] );
|
239 |
+
}
|
240 |
|
241 |
+
$tts = array_unique( $tts );
|
242 |
|
243 |
// insert term_taxonomy
|
244 |
+
if ( ! empty( $tts ) ) {
|
245 |
+
$wpdb->query( "INSERT INTO $wpdb->term_taxonomy ( term_id, taxonomy, description ) VALUES " . implode( ',', $tts ) );
|
246 |
+
}
|
247 |
|
248 |
// get all terms with term_taxonomy_id
|
249 |
+
$terms = get_terms( $type . '_translations', array( 'hide_empty' => false ) );
|
250 |
|
251 |
// prepare objects relationships
|
252 |
+
foreach ( $terms as $term ) {
|
253 |
+
$translations = unserialize( $term->description );
|
254 |
+
foreach ( $translations as $object_id ) {
|
255 |
+
if ( ! empty( $object_id ) ) {
|
256 |
+
$trs[] = $wpdb->prepare( '( %d, %d )', $object_id, $term->term_taxonomy_id );
|
257 |
+
}
|
258 |
+
}
|
259 |
}
|
260 |
|
261 |
+
$trs = array_unique( $trs );
|
262 |
|
263 |
// insert term_relationships
|
264 |
+
if ( ! empty( $trs ) ) {
|
265 |
+
$wpdb->query( "INSERT INTO $wpdb->term_relationships ( object_id, term_taxonomy_id ) VALUES " . implode( ',', $trs ) );
|
266 |
+
}
|
267 |
}
|
268 |
|
269 |
// upgrade of string translations is now in upgrade_1_2_1
|
277 |
*/
|
278 |
protected function upgrade_1_2_1() {
|
279 |
// strings translations
|
280 |
+
foreach ( get_terms( 'language', array( 'hide_empty' => 0 ) ) as $lang ) {
|
281 |
+
if ( $strings = get_option( 'polylang_mo' . $lang->term_id ) ) {
|
282 |
$mo = new PLL_MO();
|
283 |
+
foreach ( $strings as $msg ) {
|
284 |
+
$mo->add_entry( $mo->make_entry( $msg[0], $msg[1] ) );
|
285 |
+
}
|
286 |
+
$mo->export_to_db( $lang );
|
287 |
}
|
288 |
}
|
289 |
}
|
297 |
public function upgrade_1_2_3() {
|
298 |
// old version < 1.1
|
299 |
// multilingal locations and switcher item were stored in a dedicated option
|
300 |
+
if ( version_compare( $this->options['version'], '1.1', '<' ) ) {
|
301 |
+
if ( $menu_lang = get_option( 'polylang_nav_menus' ) ) {
|
302 |
+
foreach ( $menu_lang as $location => $arr ) {
|
303 |
+
if ( ! in_array( $location, array_keys( get_registered_nav_menus() ) ) ) {
|
304 |
continue;
|
305 |
+
}
|
306 |
|
307 |
+
$switch_options = array_slice( $arr, -5, 5 );
|
308 |
+
$translations = array_diff_key( $arr, $switch_options );
|
309 |
+
$has_switcher = array_shift( $switch_options );
|
310 |
|
311 |
+
foreach ( get_terms( 'language', array( 'hide_empty' => 0 ) ) as $lang ) {
|
312 |
// move nav menus locations
|
313 |
+
if ( ! empty( $translations[ $lang->slug ] ) ) {
|
314 |
+
$locations[ $location ][ $lang->slug ] = $translations[ $lang->slug ];
|
315 |
+
}
|
316 |
|
317 |
// create the menu items for the language switcher
|
318 |
+
if ( ! empty( $has_switcher ) ) {
|
319 |
+
$menu_item_db_id = wp_update_nav_menu_item( $translations[ $lang->slug ], 0, array(
|
320 |
+
'menu-item-title' => __( 'Language switcher', 'polylang' ),
|
321 |
'menu-item-url' => '#pll_switcher',
|
322 |
+
'menu-item-status' => 'publish',
|
323 |
+
) );
|
324 |
|
325 |
+
update_post_meta( $menu_item_db_id, '_pll_menu_item', $switch_options );
|
326 |
}
|
327 |
}
|
328 |
}
|
329 |
|
330 |
+
if ( ! empty( $locations ) ) {
|
331 |
+
$this->options['nav_menus'][ get_option( 'stylesheet' ) ] = $locations;
|
332 |
+
}
|
333 |
|
334 |
+
delete_option( 'polylang_nav_menus' );
|
335 |
}
|
|
|
336 |
}
|
337 |
|
338 |
+
elseif ( empty( $this->options['nav_menus'] ) ) {
|
339 |
+
$menus = get_theme_mod( 'nav_menu_locations' );
|
340 |
|
341 |
+
if ( is_array( $menus ) ) {
|
342 |
// if old version < 1.2
|
343 |
// clean the WP option as it was a bad idea to pollute it
|
344 |
+
if ( version_compare( $this->options['version'], '1.2', '<' ) ) {
|
345 |
+
foreach ( $menus as $loc => $menu ) {
|
346 |
+
if ( $pos = strpos( $loc, '#' ) ) {
|
347 |
+
unset( $menus[ $loc ] );
|
348 |
+
}
|
349 |
}
|
350 |
|
351 |
+
set_theme_mod( 'nav_menu_locations', $menus );
|
352 |
}
|
353 |
|
354 |
// get the multilingual locations
|
355 |
+
foreach ( $menus as $loc => $menu ) {
|
356 |
+
foreach ( get_terms( 'language', array( 'hide_empty' => 0 ) ) as $lang ) {
|
357 |
+
$arr[ $loc ][ $lang->slug ] = pll_get_term( $menu, $lang );
|
358 |
}
|
359 |
}
|
360 |
|
361 |
+
if ( ! empty( $arr ) ) {
|
362 |
+
$this->options['nav_menus'][ get_option( 'stylesheet' ) ] = $arr;
|
363 |
+
}
|
364 |
}
|
365 |
}
|
366 |
}
|
373 |
*/
|
374 |
protected function upgrade_1_3() {
|
375 |
$usermeta = 'description_' . $this->options['default_lang'];
|
376 |
+
$query = new WP_User_Query( array( 'blog_id' => $GLOBALS['blog_id'], 'meta_key' => $usermeta ) );
|
377 |
|
378 |
+
foreach ( $query->get_results() as $user ) {
|
379 |
+
$desc = get_user_meta( $user->ID, $usermeta, true );
|
380 |
+
if ( ! empty( $desc ) ) {
|
381 |
+
update_user_meta( $user->ID, 'description', $desc );
|
382 |
+
delete_user_meta( $user->ID, $usermeta );
|
383 |
}
|
384 |
}
|
385 |
}
|
392 |
* @since 1.4
|
393 |
*/
|
394 |
protected function upgrade_1_4() {
|
395 |
+
set_transient( 'pll_upgrade_1_4', time() + 60 * 24 * 60 * 60 ); // 60 days
|
396 |
+
delete_transient( 'pll_languages_list' );
|
397 |
}
|
398 |
|
399 |
/*
|
408 |
$wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb in case WP < 4.4
|
409 |
|
410 |
// do nothing if the termmeta table does not exists
|
411 |
+
if ( count( $wpdb->get_results( "SHOW TABLES LIKE '$wpdb->termmeta'" ) ) ) {
|
412 |
+
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_translations'" );
|
413 |
+
$wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = '_language'" );
|
414 |
+
$wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = '_rtl'" );
|
415 |
+
$wpdb->query( "DELETE FROM $wpdb->termmeta WHERE meta_key = '_translations'" );
|
416 |
}
|
417 |
|
418 |
// delete the strings translations
|
419 |
+
$languages = get_terms( 'language', array( 'hide_empty' => false ) );
|
420 |
+
foreach ( $languages as $lang ) {
|
421 |
+
delete_option( 'polylang_mo' . $lang->term_id );
|
422 |
+
}
|
423 |
|
424 |
+
delete_transient( 'pll_upgrade_1_4' );
|
425 |
}
|
426 |
|
427 |
/*
|
431 |
* @since 1.4.1
|
432 |
*/
|
433 |
protected function upgrade_1_4_1() {
|
434 |
+
if ( 3 == $this->options['force_lang'] ) {
|
435 |
$this->options['browser'] = $this->options['hide_default'] = 0;
|
436 |
+
}
|
437 |
}
|
438 |
|
439 |
/*
|
443 |
* @since 1.4.4
|
444 |
*/
|
445 |
protected function upgrade_1_4_4() {
|
446 |
+
foreach ( $GLOBALS['wp_registered_widgets'] as $widget ) {
|
447 |
+
if ( ! empty( $this->options['widgets'][ $widget['id'] ] ) && ! empty( $widget['callback'][0] ) && ! empty( $widget['params'][0]['number'] ) ) {
|
448 |
$obj = $widget['callback'][0];
|
449 |
+
if ( is_object( $obj ) && method_exists( $obj, 'get_settings' ) && method_exists( $obj, 'save_settings' ) ) {
|
450 |
$settings = $obj->get_settings();
|
451 |
+
$settings[ $widget['params'][0]['number'] ]['pll_lang'] = $this->options['widgets'][ $widget['id'] ];
|
452 |
+
$obj->save_settings( $settings );
|
453 |
}
|
454 |
}
|
455 |
}
|
456 |
+
unset( $this->options['widgets'] );
|
457 |
}
|
458 |
|
459 |
/*
|
463 |
* @since 1.5
|
464 |
*/
|
465 |
protected function upgrade_1_5() {
|
466 |
+
delete_transient( 'pll_languages_list' );
|
467 |
}
|
468 |
|
469 |
/*
|
473 |
* @since 1.6
|
474 |
*/
|
475 |
protected function upgrade_1_6() {
|
476 |
+
if ( version_compare( $GLOBALS['wp_version'], '4.0', '>=' ) ) {
|
477 |
self::download_language_packs();
|
478 |
}
|
479 |
}
|
487 |
* @since 1.6
|
488 |
*/
|
489 |
static function download_language_packs() {
|
490 |
+
$languages = pll_languages_list( array( 'fields' => 'locale' ) );
|
491 |
|
492 |
// prevents upgrade if the .po file is already here. Let WP manage the upgrades :)
|
493 |
+
foreach ( $languages as $key => $locale ) {
|
494 |
+
if ( file_exists( WP_LANG_DIR . "/$locale.po" ) ) {
|
495 |
+
unset( $languages[ $key ] );
|
496 |
+
}
|
497 |
}
|
498 |
|
499 |
+
if ( empty( $languages ) ) {
|
500 |
return;
|
501 |
+
}
|
502 |
|
503 |
+
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
|
504 |
$translations = wp_get_available_translations();
|
505 |
+
if ( ! $translations ) {
|
506 |
return;
|
507 |
+
}
|
508 |
|
509 |
+
foreach ( $translations as $translation ) {
|
510 |
+
if ( in_array( $translation['language'], $languages ) ) {
|
511 |
$translation['type'] = 'core';
|
512 |
$translations_to_load[] = (object) $translation;
|
513 |
}
|
514 |
}
|
515 |
|
516 |
+
if ( ! empty( $translations_to_load ) ) {
|
517 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
518 |
+
$upgrader = new Language_Pack_Upgrader( new Automatic_Upgrader_Skin );
|
519 |
+
$upgrader->bulk_upgrade( $translations_to_load, array( 'clear_update_cache' => false ) );
|
520 |
}
|
521 |
}
|
522 |
|
526 |
* @since 1.7.4
|
527 |
*/
|
528 |
protected function upgrade_1_7_4() {
|
529 |
+
delete_transient( 'pll_languages_list' ); // deletes language cache (due to flag properties added in 1.7, page on front removed in 1.7.2, home url fixes in 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
|
537 |
+
*/
|
538 |
+
protected function upgrade_1_8() {
|
539 |
+
// adds the flag code in languages stored in DB
|
540 |
+
include( PLL_SETTINGS_INC . '/languages.php' );
|
541 |
+
|
542 |
+
$terms = get_terms( 'language', array( 'hide_empty' => 0 ) );
|
543 |
+
|
544 |
+
foreach ( $terms as $lang ) {
|
545 |
+
$description = maybe_unserialize( $lang->description );
|
546 |
+
if ( isset( $languages[ $description['locale'] ] ) ) {
|
547 |
+
$description['flag_code'] = $languages[ $description['locale'] ][4];
|
548 |
+
$description = serialize( $description );
|
549 |
+
wp_update_term( (int) $lang->term_id, 'language', array( 'description' => $description ) );
|
550 |
+
}
|
551 |
+
}
|
552 |
+
|
553 |
+
delete_transient( 'pll_languages_list' );
|
554 |
+
}
|
555 |
}
|
js/admin.js
CHANGED
@@ -1,37 +1,166 @@
|
|
1 |
-
jQuery(document).ready(function($) {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
//
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( document ).ready(function( $ ) {
|
2 |
+
var transitionTimeout;
|
3 |
+
|
4 |
+
// languages list table
|
5 |
+
// accessibility to row actions on focus
|
6 |
+
// mainly copy paste of WP code from common.js
|
7 |
+
$( 'table.languages' ).on({ // restricted to languages list table
|
8 |
+
focusin: function() {
|
9 |
+
clearTimeout( transitionTimeout );
|
10 |
+
focusedRowActions = $( this ).find( '.row-actions' );
|
11 |
+
// transitionTimeout is necessary for Firefox, but Chrome won't remove the CSS class without a little help.
|
12 |
+
$( '.row-actions' ).not( this ).removeClass( 'visible' );
|
13 |
+
focusedRowActions.addClass( 'visible' );
|
14 |
+
},
|
15 |
+
focusout: function() {
|
16 |
+
// Tabbing between post title and .row-actions links needs a brief pause, otherwise
|
17 |
+
// the .row-actions div gets hidden in transit in some browsers ( ahem, Firefox ).
|
18 |
+
transitionTimeout = setTimeout(function() {
|
19 |
+
focusedRowActions.removeClass( 'visible' );
|
20 |
+
}, 30 );
|
21 |
+
}
|
22 |
+
}, 'tr' ); // acts on the whole tr instead of single td as we have actions links in several columns
|
23 |
+
|
24 |
+
// extends selectmenu to add flags in menu items
|
25 |
+
$.widget( "custom.iconselectmenu", $.ui.selectmenu, {
|
26 |
+
_renderItem: function( ul, item ) {
|
27 |
+
var li = $( "<li>", { text: item.label } );
|
28 |
+
|
29 |
+
if ( item.value ) {
|
30 |
+
$( "<img>", {
|
31 |
+
src: pll_flag_base_url + item.value + '.png',
|
32 |
+
"class": "ui-icon"
|
33 |
+
}).appendTo( li );
|
34 |
+
}
|
35 |
+
|
36 |
+
return li.appendTo( ul );
|
37 |
+
}
|
38 |
+
});
|
39 |
+
|
40 |
+
// allows to display the flag for the selected menu item
|
41 |
+
function add_icon( event, ui ) {
|
42 |
+
var value = $( this ).val();
|
43 |
+
if ( value ) {
|
44 |
+
var txt = $( this ).iconselectmenu( "widget" ).children( ":last" );
|
45 |
+
var img = $( '<img class="ui-icon" >' ).appendTo( txt );
|
46 |
+
img.attr( "src", pll_flag_base_url + value + '.png' );
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
// overrides the flag dropdown list with our customized jquery ui selectmenu
|
51 |
+
$( "#flag_list" ).iconselectmenu({
|
52 |
+
create: add_icon,
|
53 |
+
select: add_icon,
|
54 |
+
});
|
55 |
+
|
56 |
+
// languages form
|
57 |
+
// fills the fields based on the language dropdown list choice
|
58 |
+
$( '#lang_list' ).change(function() {
|
59 |
+
value = $( this ).val().split( '-' );
|
60 |
+
selected = $( "select option:selected" ).text().split( ' - ' );
|
61 |
+
$( '#lang_slug' ).val( value[0] );
|
62 |
+
$( '#lang_locale' ).val( value[1] );
|
63 |
+
$( 'input[name="rtl"]' ).val( [value[2]] );
|
64 |
+
$( '#lang_name' ).val( selected[0] );
|
65 |
+
$( '#flag_list option[value="' + value[3] + '"]' ).attr( 'selected', 'selected' );
|
66 |
+
|
67 |
+
// recreate the jquery ui selectmenu
|
68 |
+
$( "#flag_list" ).iconselectmenu( 'destroy' ).iconselectmenu({
|
69 |
+
create: add_icon,
|
70 |
+
select: add_icon,
|
71 |
+
})
|
72 |
+
});
|
73 |
+
|
74 |
+
// strings translations
|
75 |
+
// save translations when pressing enter
|
76 |
+
$( '.translation input' ).keypress(function( event ){
|
77 |
+
if ( 13 === event.keyCode ) {
|
78 |
+
event.preventDefault();
|
79 |
+
$( '#submit' ).click();
|
80 |
+
}
|
81 |
+
});
|
82 |
+
|
83 |
+
// settings page
|
84 |
+
// click on configure link
|
85 |
+
$( '#the-list' ).on( 'click', '.configure>a', function(){
|
86 |
+
$( '.pll-configure' ).hide().prev().show();
|
87 |
+
$( this ).closest( 'tr' ).hide().next().show();
|
88 |
+
return false;
|
89 |
+
});
|
90 |
+
|
91 |
+
// cancel
|
92 |
+
$( '#the-list' ).on( 'click', '.cancel', function(){
|
93 |
+
$( this ).closest( 'tr' ).hide().prev().show();
|
94 |
+
});
|
95 |
+
|
96 |
+
// save settings
|
97 |
+
$( '#the-list' ).on( 'click', '.save', function(){
|
98 |
+
var tr = $( this ).closest( 'tr' );
|
99 |
+
var parts = tr.attr( 'id' ).split( '-' );
|
100 |
+
|
101 |
+
var data = {
|
102 |
+
action: 'pll_save_options',
|
103 |
+
module: parts[parts.length - 1],
|
104 |
+
_pll_nonce: $( '#_pll_nonce' ).val()
|
105 |
+
}
|
106 |
+
|
107 |
+
data = tr.find( ':input' ).serialize() + '&' + $.param( data );
|
108 |
+
|
109 |
+
$.post( ajaxurl, data , function( response ) {
|
110 |
+
if ( response.success ) {
|
111 |
+
tr.hide().prev().show(); // close only if there is no error
|
112 |
+
}
|
113 |
+
|
114 |
+
$( '.settings-error' ).remove(); // remove previous messages if any
|
115 |
+
$( '.nav-tab-wrapper' ).after( response.data );
|
116 |
+
|
117 |
+
// Make notices dismissible
|
118 |
+
// copy paste of common.js from WP 4.2.2
|
119 |
+
$( '.notice.is-dismissible' ).each(function() {
|
120 |
+
var $this = $( this ),
|
121 |
+
$button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ),
|
122 |
+
btnText = commonL10n.dismiss || '';
|
123 |
+
|
124 |
+
// Ensure plain text
|
125 |
+
$button.find( '.screen-reader-text' ).text( btnText );
|
126 |
+
|
127 |
+
$this.append( $button );
|
128 |
+
|
129 |
+
$button.on( 'click.wp-dismiss-notice', function( event ) {
|
130 |
+
event.preventDefault();
|
131 |
+
$this.fadeTo( 100 , 0, function() {
|
132 |
+
$( this ).slideUp( 100, function() {
|
133 |
+
$( this ).remove();
|
134 |
+
});
|
135 |
+
});
|
136 |
+
});
|
137 |
+
});
|
138 |
+
});
|
139 |
+
});
|
140 |
+
|
141 |
+
// act when pressing enter or esc in configurations
|
142 |
+
$( '.pll-configure' ).keypress(function( event ){
|
143 |
+
if ( 13 === event.keyCode ) {
|
144 |
+
event.preventDefault();
|
145 |
+
$( this ).find( '.save' ).click();
|
146 |
+
}
|
147 |
+
|
148 |
+
if ( 27 === event.keyCode ) {
|
149 |
+
event.preventDefault();
|
150 |
+
$( this ).find( '.cancel' ).click();
|
151 |
+
}
|
152 |
+
});
|
153 |
+
|
154 |
+
// settings URL modifications
|
155 |
+
// manages visibility of fields
|
156 |
+
$( "input[name='force_lang']" ).change(function() {
|
157 |
+
function pll_toggle( a, test ) {
|
158 |
+
test ? a.show() : a.hide();
|
159 |
+
}
|
160 |
+
|
161 |
+
var value = $( this ).val();
|
162 |
+
pll_toggle( $( '#pll-domains-table' ), 3 == value );
|
163 |
+
pll_toggle( $( "#pll-hide-default" ), 3 > value );
|
164 |
+
pll_toggle( $( "#pll-rewrite" ), 2 > value );
|
165 |
+
});
|
166 |
+
});
|
js/admin.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(a){a("#lang_list").change(function(){value=
|
1 |
+
jQuery(document).ready(function(b){var a;b("table.languages").on({focusin:function(){clearTimeout(a);focusedRowActions=b(this).find(".row-actions");b(".row-actions").not(this).removeClass("visible");focusedRowActions.addClass("visible")},focusout:function(){a=setTimeout(function(){focusedRowActions.removeClass("visible")},30)}},"tr");b.widget("custom.iconselectmenu",b.ui.selectmenu,{_renderItem:function(e,f){var d=b("<li>",{text:f.label});if(f.value){b("<img>",{src:pll_flag_base_url+f.value+".png","class":"ui-icon"}).appendTo(d)}return d.appendTo(e)}});function c(f,h){var g=b(this).val();if(g){var d=b(this).iconselectmenu("widget").children(":last");var e=b('<img class="ui-icon" >').appendTo(d);e.attr("src",pll_flag_base_url+g+".png")}}b("#flag_list").iconselectmenu({create:c,select:c});b("#lang_list").change(function(){value=b(this).val().split("-");selected=b("select option:selected").text().split(" - ");b("#lang_slug").val(value[0]);b("#lang_locale").val(value[1]);b('input[name="rtl"]').val([value[2]]);b("#lang_name").val(selected[0]);b('#flag_list option[value="'+value[3]+'"]').attr("selected","selected");b("#flag_list").iconselectmenu("destroy").iconselectmenu({create:c,select:c})});b(".translation input").keypress(function(d){if(13===d.keyCode){d.preventDefault();b("#submit").click()}});b("#the-list").on("click",".configure>a",function(){b(".pll-configure").hide().prev().show();b(this).closest("tr").hide().next().show();return false});b("#the-list").on("click",".cancel",function(){b(this).closest("tr").hide().prev().show()});b("#the-list").on("click",".save",function(){var e=b(this).closest("tr");var f=e.attr("id").split("-");var d={action:"pll_save_options",module:f[f.length-1],_pll_nonce:b("#_pll_nonce").val()};d=e.find(":input").serialize()+"&"+b.param(d);b.post(ajaxurl,d,function(g){if(g.success){e.hide().prev().show()}b(".settings-error").remove();b(".nav-tab-wrapper").after(g.data);b(".notice.is-dismissible").each(function(){var j=b(this),i=b('<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>'),h=commonL10n.dismiss||"";i.find(".screen-reader-text").text(h);j.append(i);i.on("click.wp-dismiss-notice",function(k){k.preventDefault();j.fadeTo(100,0,function(){b(this).slideUp(100,function(){b(this).remove()})})})})})});b(".pll-configure").keypress(function(d){if(13===d.keyCode){d.preventDefault();b(this).find(".save").click()}if(27===d.keyCode){d.preventDefault();b(this).find(".cancel").click()}});b("input[name='force_lang']").change(function(){function d(f,g){g?f.show():f.hide()}var e=b(this).val();d(b("#pll-domains-table"),3==e);d(b("#pll-hide-default"),3>e);d(b("#pll-rewrite"),2>e)})});
|
js/media.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
// when clicking on attach link, filters find post list per media language
|
2 |
-
(function($){
|
3 |
-
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
|
4 |
-
options.data = 'pll_post_id='
|
5 |
});
|
6 |
-
})(jQuery)
|
1 |
// when clicking on attach link, filters find post list per media language
|
2 |
+
(function( $ ){
|
3 |
+
$.ajaxPrefilter(function ( options, originalOptions, jqXHR ) {
|
4 |
+
options.data = 'pll_post_id=' + $( '#affected' ).val() + '&' + options.data;
|
5 |
});
|
6 |
+
})( jQuery )
|
js/nav-menu.js
CHANGED
@@ -1,68 +1,68 @@
|
|
1 |
-
jQuery(document).ready(function($) {
|
2 |
-
$('#update-nav-menu').bind('click', function(e) {
|
3 |
-
if ( e.target && e.target.className && -1 != e.target.className.indexOf('item-edit')) {
|
4 |
-
$("input[value='#pll_switcher'][type=text]").parent().parent().parent().each(
|
5 |
-
var item = $(this).attr('id').substring(19);
|
6 |
-
$(this).children('p:not(.field-move)').remove(); // remove default fields we don't need
|
7 |
|
8 |
-
h = $('<input>').attr({
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
});
|
14 |
-
$(this).append(h);
|
15 |
|
16 |
-
h = $('<input>').attr({
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
});
|
22 |
-
$(this).append(h);
|
23 |
|
24 |
// a hidden field which exits only if our jQuery code has been executed
|
25 |
-
h = $('<input>').attr({
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
});
|
31 |
-
$(this).append(h);
|
32 |
|
33 |
-
ids = Array('hide_if_no_translation', 'hide_current','force_home','show_flags','show_names'); // reverse order
|
34 |
|
35 |
// add the fields
|
36 |
-
for(var i = 0; i < ids.length; i++) {
|
37 |
-
p = $('<p>').attr('class', 'description');
|
38 |
-
$(this).prepend(p);
|
39 |
-
label = $('<label>').attr('for', 'menu-item-'+ids[i]+'-'+item).text(' '+pll_data.strings[i]);
|
40 |
-
p.append(label);
|
41 |
-
cb = $('<input>').attr({
|
42 |
-
type:
|
43 |
-
id:
|
44 |
-
name:
|
45 |
value: 1
|
46 |
});
|
47 |
-
if ((typeof(pll_data.val[item]) != 'undefined' && pll_data.val[item][ids[i]] == 1) || (typeof(pll_data.val[item]) == 'undefined' && ids[i] == 'show_names')) // show_names as default value
|
48 |
-
cb.prop('checked', true);
|
49 |
-
|
|
|
50 |
}
|
51 |
});
|
52 |
|
53 |
// disallow unchecking both show names and show flags
|
54 |
-
$('.menu-item-data-object-id').each(function() {
|
55 |
-
var id = $(this).val();
|
56 |
var options = ['names-', 'flags-'];
|
57 |
-
$.each(options, function(i, v) {
|
58 |
-
$('#edit-menu-item-show_'+v+id).change(function() {
|
59 |
-
if ('checked' != $(this).attr('checked'))
|
60 |
-
$('#edit-menu-item-show_'+options[1-i]+id).prop('checked', true);
|
|
|
61 |
});
|
62 |
});
|
63 |
});
|
64 |
-
|
65 |
}
|
66 |
});
|
67 |
-
|
68 |
});
|
1 |
+
jQuery( document ).ready(function( $ ) {
|
2 |
+
$( '#update-nav-menu' ).bind( 'click', function( e ) {
|
3 |
+
if ( e.target && e.target.className && -1 != e.target.className.indexOf( 'item-edit' ) ) {
|
4 |
+
$( "input[value='#pll_switcher'][type=text]" ).parent().parent().parent().each(function(){
|
5 |
+
var item = $( this ).attr( 'id' ).substring( 19 );
|
6 |
+
$( this ).children( 'p:not( .field-move )' ).remove(); // remove default fields we don't need
|
7 |
|
8 |
+
h = $( '<input>' ).attr({
|
9 |
+
type: 'hidden',
|
10 |
+
id: 'edit-menu-item-title-' + item,
|
11 |
+
name: 'menu-item-title[' + item + ']',
|
12 |
+
value: pll_data.title
|
13 |
});
|
14 |
+
$( this ).append( h );
|
15 |
|
16 |
+
h = $( '<input>' ).attr({
|
17 |
+
type: 'hidden',
|
18 |
+
id: 'edit-menu-item-url-' + item,
|
19 |
+
name: 'menu-item-url[' + item + ']',
|
20 |
+
value: '#pll_switcher'
|
21 |
});
|
22 |
+
$( this ).append( h );
|
23 |
|
24 |
// a hidden field which exits only if our jQuery code has been executed
|
25 |
+
h = $( '<input>' ).attr({
|
26 |
+
type: 'hidden',
|
27 |
+
id: 'edit-menu-item-pll-detect-' + item,
|
28 |
+
name: 'menu-item-pll-detect[' + item + ']',
|
29 |
+
value: 1
|
30 |
});
|
31 |
+
$( this ).append( h );
|
32 |
|
33 |
+
ids = Array( 'hide_if_no_translation', 'hide_current','force_home','show_flags','show_names' ); // reverse order
|
34 |
|
35 |
// add the fields
|
36 |
+
for ( var i = 0; i < ids.length; i++ ) {
|
37 |
+
p = $( '<p>' ).attr( 'class', 'description' );
|
38 |
+
$( this ).prepend( p );
|
39 |
+
label = $( '<label>' ).attr( 'for', 'edit-menu-item-' + ids[ i ] + '-' + item ).text( ' ' + pll_data.strings[ i ] );
|
40 |
+
p.append( label );
|
41 |
+
cb = $( '<input>' ).attr({
|
42 |
+
type: 'checkbox',
|
43 |
+
id: 'edit-menu-item-' + ids[ i ] + '-' + item,
|
44 |
+
name: 'menu-item-' + ids[ i ] + '[' + item + ']',
|
45 |
value: 1
|
46 |
});
|
47 |
+
if ( ( typeof( pll_data.val[ item ] ) != 'undefined' && pll_data.val[ item ][ ids[ i ] ] == 1 ) || ( typeof( pll_data.val[ item ] ) == 'undefined' && ids[ i ] == 'show_names' ) ) { // show_names as default value
|
48 |
+
cb.prop( 'checked', true );
|
49 |
+
}
|
50 |
+
label.prepend( cb );
|
51 |
}
|
52 |
});
|
53 |
|
54 |
// disallow unchecking both show names and show flags
|
55 |
+
$( '.menu-item-data-object-id' ).each(function() {
|
56 |
+
var id = $( this ).val();
|
57 |
var options = ['names-', 'flags-'];
|
58 |
+
$.each( options, function( i, v ) {
|
59 |
+
$( '#edit-menu-item-show_' + v + id ).change(function() {
|
60 |
+
if ( 'checked' != $( this ).attr( 'checked' ) ) {
|
61 |
+
$( '#edit-menu-item-show_' + options[ 1 - i ] + id ).prop( 'checked', true );
|
62 |
+
}
|
63 |
});
|
64 |
});
|
65 |
});
|
|
|
66 |
}
|
67 |
});
|
|
|
68 |
});
|
js/nav-menu.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(a){a("#update-nav-menu").bind("click",function(b){if(b.target&&b.target.className&&-1!=b.target.className.indexOf("item-edit")){a("input[value='#pll_switcher'][type=text]").parent().parent().parent().each(function(){var d=a(this).attr("id").substring(19);a(this).children("p:not(.field-move)").remove();h=a("<input>").attr({type:"hidden",id:"edit-menu-item-title-"+d,name:"menu-item-title["+d+"]",value:pll_data.title});a(this).append(h);h=a("<input>").attr({type:"hidden",id:"edit-menu-item-url-"+d,name:"menu-item-url["+d+"]",value:"#pll_switcher"});a(this).append(h);h=a("<input>").attr({type:"hidden",id:"edit-menu-item-pll-detect-"+d,name:"menu-item-pll-detect["+d+"]",value:1});a(this).append(h);ids=Array("hide_if_no_translation","hide_current","force_home","show_flags","show_names");for(var c=0;c<ids.length;c++){p=a("<p>").attr("class","description");a(this).prepend(p);label=a("<label>").attr("for","menu-item-"+ids[c]+"-"+d).text(" "+pll_data.strings[c]);p.append(label);cb=a("<input>").attr({type:"checkbox",id:"edit-menu-item-"+ids[c]+"-"+d,name:"menu-item-"+ids[c]+"["+d+"]",value:1});if((typeof(pll_data.val[d])!="undefined"&&pll_data.val[d][ids[c]]==1)||(typeof(pll_data.val[d])=="undefined"&&ids[c]=="show_names")){cb.prop("checked",true)}label.prepend(cb)}});a(".menu-item-data-object-id").each(function(){var d=a(this).val();var c=["names-","flags-"];a.each(c,function(f,e){a("#edit-menu-item-show_"+e+d).change(function(){if("checked"!=a(this).attr("checked")){a("#edit-menu-item-show_"+c[1-f]+d).prop("checked",true)}})})})}})});
|
1 |
+
jQuery(document).ready(function(a){a("#update-nav-menu").bind("click",function(b){if(b.target&&b.target.className&&-1!=b.target.className.indexOf("item-edit")){a("input[value='#pll_switcher'][type=text]").parent().parent().parent().each(function(){var d=a(this).attr("id").substring(19);a(this).children("p:not( .field-move )").remove();h=a("<input>").attr({type:"hidden",id:"edit-menu-item-title-"+d,name:"menu-item-title["+d+"]",value:pll_data.title});a(this).append(h);h=a("<input>").attr({type:"hidden",id:"edit-menu-item-url-"+d,name:"menu-item-url["+d+"]",value:"#pll_switcher"});a(this).append(h);h=a("<input>").attr({type:"hidden",id:"edit-menu-item-pll-detect-"+d,name:"menu-item-pll-detect["+d+"]",value:1});a(this).append(h);ids=Array("hide_if_no_translation","hide_current","force_home","show_flags","show_names");for(var c=0;c<ids.length;c++){p=a("<p>").attr("class","description");a(this).prepend(p);label=a("<label>").attr("for","edit-menu-item-"+ids[c]+"-"+d).text(" "+pll_data.strings[c]);p.append(label);cb=a("<input>").attr({type:"checkbox",id:"edit-menu-item-"+ids[c]+"-"+d,name:"menu-item-"+ids[c]+"["+d+"]",value:1});if((typeof(pll_data.val[d])!="undefined"&&pll_data.val[d][ids[c]]==1)||(typeof(pll_data.val[d])=="undefined"&&ids[c]=="show_names")){cb.prop("checked",true)}label.prepend(cb)}});a(".menu-item-data-object-id").each(function(){var d=a(this).val();var c=["names-","flags-"];a.each(c,function(f,e){a("#edit-menu-item-show_"+e+d).change(function(){if("checked"!=a(this).attr("checked")){a("#edit-menu-item-show_"+c[1-f]+d).prop("checked",true)}})})})}})});
|
js/post.js
CHANGED
@@ -1,263 +1,237 @@
|
|
1 |
-
// tag suggest
|
2 |
-
// valid for both tag metabox and quick edit
|
3 |
-
(function($){
|
4 |
-
$.ajaxPrefilter(function
|
5 |
-
if(-1 !== options.url.indexOf('action=ajax-tag-search') && ((lang = $('
|
6 |
-
options.data = 'lang='+lang+'&'+options.data;
|
7 |
-
}
|
8 |
-
});
|
9 |
-
})(jQuery);
|
10 |
-
|
11 |
-
// overrides tagBox.get
|
12 |
-
(function($){
|
13 |
-
// overrides function to add the language
|
14 |
-
tagBox.get = function(id) {
|
15 |
-
var tax = id.substr(id.indexOf('-')+1);
|
16 |
-
|
17 |
-
// add the language in the $_POST variable
|
18 |
-
var data = {
|
19 |
-
action: 'get-tagcloud',
|
20 |
-
lang:
|
21 |
-
tax:
|
22 |
-
}
|
23 |
-
|
24 |
-
$.post(ajaxurl, data, function(r, stat) {
|
25 |
-
if ( 0 == r || 'success' != stat )
|
26 |
-
r = wpAjax.broken;
|
27 |
-
|
28 |
-
|
29 |
-
$('
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
if
|
36 |
-
|
37 |
-
$('.the-tagcloud').
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
var
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
})
|
99 |
-
|
100 |
-
|
101 |
-
//
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
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 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
taxonomyParts.
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
//
|
153 |
-
|
154 |
-
|
155 |
-
.attr('
|
156 |
-
.attr('
|
157 |
-
.attr('
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
$('#
|
184 |
-
$('#' + tax + '-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
}
|
195 |
-
});
|
196 |
-
|
197 |
-
// modifies the language in the tag cloud
|
198 |
-
$('.tagcloud-link').each(function() {
|
199 |
-
var id = $(this).attr('id');
|
200 |
-
tagBox.get(id);
|
201 |
-
});
|
202 |
-
});
|
203 |
-
});
|
204 |
-
|
205 |
-
//
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
$(this).autocomplete({
|
239 |
-
minLength: 0,
|
240 |
-
|
241 |
-
source: ajaxurl + '?action=pll_posts_not_translated&post_language=' + $('#post_lang_choice').val() +
|
242 |
-
'&translation_language=' + tr_lang + '&post_type=' + $('#post_type').val() +
|
243 |
-
'&_pll_nonce=' + $('#_pll_nonce').val(),
|
244 |
-
|
245 |
-
select: function(event, ui) {
|
246 |
-
$('#htr_lang_'+tr_lang).val(ui.item.id);
|
247 |
-
td.html(ui.item.link);
|
248 |
-
},
|
249 |
-
});
|
250 |
-
|
251 |
-
// when the input box is emptied
|
252 |
-
$(this).blur(function() {
|
253 |
-
if (!$(this).val()) {
|
254 |
-
$('#htr_lang_'+tr_lang).val(0);
|
255 |
-
td.html(td.siblings('.hidden').children().clone());
|
256 |
-
}
|
257 |
-
});
|
258 |
-
|
259 |
-
});
|
260 |
-
}
|
261 |
-
|
262 |
-
init_translations();
|
263 |
-
});
|
1 |
+
// tag suggest
|
2 |
+
// valid for both tag metabox and quick edit
|
3 |
+
(function( $ ){
|
4 |
+
$.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
|
5 |
+
if ( -1 !== options.url.indexOf( 'action=ajax-tag-search' ) && ( ( lang = $( '.post_lang_choice' ).val() ) || ( lang = $( ':input[name="inline_lang_choice"]' ).val() ) ) ) {
|
6 |
+
options.data = 'lang=' + lang + '&' + options.data;
|
7 |
+
}
|
8 |
+
});
|
9 |
+
})( jQuery );
|
10 |
+
|
11 |
+
// overrides tagBox.get
|
12 |
+
(function( $ ){
|
13 |
+
// overrides function to add the language
|
14 |
+
tagBox.get = function( id ) {
|
15 |
+
var tax = id.substr( id.indexOf( '-' ) + 1 );
|
16 |
+
|
17 |
+
// add the language in the $_POST variable
|
18 |
+
var data = {
|
19 |
+
action: 'get-tagcloud',
|
20 |
+
lang: $( '.post_lang_choice' ).val(),
|
21 |
+
tax: tax
|
22 |
+
}
|
23 |
+
|
24 |
+
$.post( ajaxurl, data, function( r, stat ) {
|
25 |
+
if ( 0 == r || 'success' != stat ) {
|
26 |
+
r = wpAjax.broken;
|
27 |
+
}
|
28 |
+
|
29 |
+
r = $( '<p id="tagcloud-' + tax + '" class="the-tagcloud">' + r + '</p>' );
|
30 |
+
$( 'a', r ).click(function(){
|
31 |
+
tagBox.flushTags( $( this ).closest( '.inside' ).children( '.tagsdiv' ), this );
|
32 |
+
return false;
|
33 |
+
});
|
34 |
+
|
35 |
+
// add an if else condition to allow modifying the tags outputed when switching the language
|
36 |
+
if ( v = $( '.the-tagcloud' ).css( 'display' ) ) {
|
37 |
+
$( '.the-tagcloud' ).replaceWith( r );
|
38 |
+
$( '.the-tagcloud' ).css( 'display', v );
|
39 |
+
}
|
40 |
+
else {
|
41 |
+
$( '#' + id ).after( r );
|
42 |
+
}
|
43 |
+
});
|
44 |
+
}
|
45 |
+
})( jQuery );
|
46 |
+
|
47 |
+
// quick edit
|
48 |
+
(function( $ ) {
|
49 |
+
$( document ).bind( 'DOMNodeInserted', function( e ) {
|
50 |
+
var t = $( e.target );
|
51 |
+
|
52 |
+
// WP inserts the quick edit from
|
53 |
+
if ( 'inline-edit' == t.attr( 'id' ) ) {
|
54 |
+
var post_id = t.prev().attr( 'id' ).replace( "post-", "" );
|
55 |
+
|
56 |
+
if ( post_id > 0 ) {
|
57 |
+
// language dropdown
|
58 |
+
var select = t.find( ':input[name="inline_lang_choice"]' );
|
59 |
+
var lang = $( '#lang_' + post_id ).html();
|
60 |
+
select.val( lang ); // populates the dropdown
|
61 |
+
|
62 |
+
filter_terms( lang ); // initial filter for category checklist
|
63 |
+
filter_pages( lang ); // initial filter for parent dropdown
|
64 |
+
|
65 |
+
// modify category checklist an parent dropdown on language change
|
66 |
+
select.change(function() {
|
67 |
+
filter_terms( $( this ).val() );
|
68 |
+
filter_pages( $( this ).val() );
|
69 |
+
});
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
// filter category checklist
|
74 |
+
function filter_terms( lang ) {
|
75 |
+
if ( "undefined" != typeof( pll_term_languages ) ) {
|
76 |
+
$.each( pll_term_languages, function( lg, term_tax ) {
|
77 |
+
$.each( term_tax, function( tax, terms ) {
|
78 |
+
$.each( terms, function( i ) {
|
79 |
+
id = '#' + tax + '-' + pll_term_languages[ lg ][ tax ][ i ];
|
80 |
+
lang == lg ? $( id ).show() : $( id ).hide();
|
81 |
+
});
|
82 |
+
});
|
83 |
+
});
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
// filter parent page dropdown list
|
88 |
+
function filter_pages( lang ) {
|
89 |
+
if ( "undefined" != typeof( pll_page_languages ) ) {
|
90 |
+
$.each( pll_page_languages, function( lg, pages ) {
|
91 |
+
$.each( pages, function( i ) {
|
92 |
+
v = $( '#post_parent option[value="' + pll_page_languages[ lg ][ i ] + '"]' );
|
93 |
+
lang == lg ? v.show() : v.hide();
|
94 |
+
});
|
95 |
+
});
|
96 |
+
}
|
97 |
+
}
|
98 |
+
});
|
99 |
+
})( jQuery );
|
100 |
+
|
101 |
+
// update rows of translated posts when the language is modified in quick edit
|
102 |
+
// acts on ajaxSuccess event
|
103 |
+
(function( $ ) {
|
104 |
+
$( document ).ajaxSuccess(function( event, xhr, settings ) {
|
105 |
+
function update_rows( post_id ) {
|
106 |
+
// collect old translations
|
107 |
+
var translations = new Array;
|
108 |
+
$( '.translation_' + post_id ).each(function() {
|
109 |
+
translations.push( $( this ).parent().parent().attr( 'id' ).substring( 5 ) );
|
110 |
+
});
|
111 |
+
|
112 |
+
var data = {
|
113 |
+
action: 'pll_update_post_rows',
|
114 |
+
post_id: post_id,
|
115 |
+
translations: translations.join( ',' ),
|
116 |
+
post_type: $( "input[name='post_type']" ).val(),
|
117 |
+
screen: $( "input[name='screen']" ).val(),
|
118 |
+
_pll_nonce: $( "input[name='_inline_edit']" ).val() // reuse quick edit nonce
|
119 |
+
}
|
120 |
+
|
121 |
+
// get the modified rows in ajax and update them
|
122 |
+
$.post( ajaxurl, data, function( response ) {
|
123 |
+
if ( response ) {
|
124 |
+
var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
|
125 |
+
$.each( res.responses, function() {
|
126 |
+
if ( 'row' == this.what ) {
|
127 |
+
$( "#post-" + this.supplemental.post_id ).replaceWith( this.data );
|
128 |
+
}
|
129 |
+
});
|
130 |
+
}
|
131 |
+
});
|
132 |
+
}
|
133 |
+
|
134 |
+
var data = wpAjax.unserialize( settings.data ); // what were the data sent by the ajax request?
|
135 |
+
if ( 'undefined' != typeof( data['action'] ) && 'inline-save' == data['action'] ) {
|
136 |
+
update_rows( data['post_ID'] );
|
137 |
+
}
|
138 |
+
});
|
139 |
+
})( jQuery );
|
140 |
+
|
141 |
+
jQuery( document ).ready(function( $ ) {
|
142 |
+
// collect taxonomies - code partly copied from WordPress
|
143 |
+
var taxonomies = new Array();
|
144 |
+
$( '.categorydiv' ).each(function(){
|
145 |
+
var this_id = $( this ).attr( 'id' ), taxonomyParts, taxonomy;
|
146 |
+
|
147 |
+
taxonomyParts = this_id.split( '-' );
|
148 |
+
taxonomyParts.shift();
|
149 |
+
taxonomy = taxonomyParts.join( '-' );
|
150 |
+
taxonomies.push( taxonomy ); // store the taxonomy for future use
|
151 |
+
|
152 |
+
// add our hidden field in the new category form - for each hierarchical taxonomy
|
153 |
+
// to set the language when creating a new category
|
154 |
+
$( '#' + taxonomy + '-add-submit' ).before( $( '<input />' )
|
155 |
+
.attr( 'type', 'hidden' )
|
156 |
+
.attr( 'id', taxonomy + '-lang' )
|
157 |
+
.attr( 'name', 'term_lang_choice' )
|
158 |
+
.attr( 'value', $( '.post_lang_choice' ).val() )
|
159 |
+
);
|
160 |
+
});
|
161 |
+
|
162 |
+
// ajax for changing the post's language in the languages metabox
|
163 |
+
$( '.post_lang_choice' ).change(function() {
|
164 |
+
var data = {
|
165 |
+
action: 'post_lang_choice',
|
166 |
+
lang: $( this ).val(),
|
167 |
+
post_type: $( '#post_type' ).val(),
|
168 |
+
taxonomies: taxonomies,
|
169 |
+
post_id: $( '#post_ID' ).val(),
|
170 |
+
_pll_nonce: $( '#_pll_nonce' ).val()
|
171 |
+
}
|
172 |
+
|
173 |
+
$.post( ajaxurl, data , function( response ) {
|
174 |
+
var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
|
175 |
+
$.each( res.responses, function() {
|
176 |
+
switch ( this.what ) {
|
177 |
+
case 'translations': // translations fields
|
178 |
+
$( '.translations' ).html( this.data );
|
179 |
+
init_translations();
|
180 |
+
break;
|
181 |
+
case 'taxonomy': // categories metabox for posts
|
182 |
+
var tax = this.data;
|
183 |
+
$( '#' + tax + 'checklist' ).html( this.supplemental.all );
|
184 |
+
$( '#' + tax + 'checklist-pop' ).html( this.supplemental.populars );
|
185 |
+
$( '#new' + tax + '_parent' ).replaceWith( this.supplemental.dropdown );
|
186 |
+
$( '#' + tax + '-lang' ).val( $( '.post_lang_choice' ).val() ); // hidden field
|
187 |
+
break;
|
188 |
+
case 'pages': // parent dropdown list for pages
|
189 |
+
$( '#parent_id' ).html( this.data );
|
190 |
+
break;
|
191 |
+
case 'flag': // flag in front of the select dropdown
|
192 |
+
$( '.pll-select-flag' ).html( this.data );
|
193 |
+
break;
|
194 |
+
}
|
195 |
+
});
|
196 |
+
|
197 |
+
// modifies the language in the tag cloud
|
198 |
+
$( '.tagcloud-link' ).each(function() {
|
199 |
+
var id = $( this ).attr( 'id' );
|
200 |
+
tagBox.get( id );
|
201 |
+
});
|
202 |
+
});
|
203 |
+
});
|
204 |
+
|
205 |
+
// translations autocomplete input box
|
206 |
+
function init_translations() {
|
207 |
+
$( '.tr_lang' ).each(function(){
|
208 |
+
var tr_lang = $( this ).attr( 'id' ).substring( 8 );
|
209 |
+
var td = $( this ).parent().siblings( '.pll-edit-column' );
|
210 |
+
|
211 |
+
$( this ).autocomplete({
|
212 |
+
minLength: 0,
|
213 |
+
|
214 |
+
source: ajaxurl + '?action=pll_posts_not_translated' +
|
215 |
+
'&post_language=' + $( '.post_lang_choice' ).val() +
|
216 |
+
'&translation_language=' + tr_lang +
|
217 |
+
'&post_type=' + $( '#post_type' ).val() +
|
218 |
+
'&_pll_nonce=' + $( '#_pll_nonce' ).val(),
|
219 |
+
|
220 |
+
select: function( event, ui ) {
|
221 |
+
$( '#htr_lang_' + tr_lang ).val( ui.item.id );
|
222 |
+
td.html( ui.item.link );
|
223 |
+
},
|
224 |
+
});
|
225 |
+
|
226 |
+
// when the input box is emptied
|
227 |
+
$( this ).blur(function() {
|
228 |
+
if ( ! $( this ).val() ) {
|
229 |
+
$( '#htr_lang_' + tr_lang ).val( 0 );
|
230 |
+
td.html( td.siblings( '.hidden' ).children().clone() );
|
231 |
+
}
|
232 |
+
});
|
233 |
+
});
|
234 |
+
}
|
235 |
+
|
236 |
+
init_translations();
|
237 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/post.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(a){a.ajaxPrefilter(function(b,d,c){if(-1!==b.url.indexOf("action=ajax-tag-search")&&((lang=a("
|
1 |
+
(function(a){a.ajaxPrefilter(function(b,d,c){if(-1!==b.url.indexOf("action=ajax-tag-search")&&((lang=a(".post_lang_choice").val())||(lang=a(':input[name="inline_lang_choice"]').val()))){b.data="lang="+lang+"&"+b.data}})})(jQuery);(function(a){tagBox.get=function(d){var b=d.substr(d.indexOf("-")+1);var c={action:"get-tagcloud",lang:a(".post_lang_choice").val(),tax:b};a.post(ajaxurl,c,function(f,e){if(0==f||"success"!=e){f=wpAjax.broken}f=a('<p id="tagcloud-'+b+'" class="the-tagcloud">'+f+"</p>");a("a",f).click(function(){tagBox.flushTags(a(this).closest(".inside").children(".tagsdiv"),this);return false});if(v=a(".the-tagcloud").css("display")){a(".the-tagcloud").replaceWith(f);a(".the-tagcloud").css("display",v)}else{a("#"+d).after(f)}})}})(jQuery);(function(a){a(document).bind("DOMNodeInserted",function(h){var f=a(h.target);if("inline-edit"==f.attr("id")){var d=f.prev().attr("id").replace("post-","");if(d>0){var b=f.find(':input[name="inline_lang_choice"]');var i=a("#lang_"+d).html();b.val(i);g(i);c(i);b.change(function(){g(a(this).val());c(a(this).val())})}}function g(e){if("undefined"!=typeof(pll_term_languages)){a.each(pll_term_languages,function(j,k){a.each(k,function(l,m){a.each(m,function(n){id="#"+l+"-"+pll_term_languages[j][l][n];e==j?a(id).show():a(id).hide()})})})}}function c(e){if("undefined"!=typeof(pll_page_languages)){a.each(pll_page_languages,function(k,j){a.each(j,function(l){v=a('#post_parent option[value="'+pll_page_languages[k][l]+'"]');e==k?v.show():v.hide()})})}}})})(jQuery);(function(a){a(document).ajaxSuccess(function(d,f,c){function b(h){var g=new Array;a(".translation_"+h).each(function(){g.push(a(this).parent().parent().attr("id").substring(5))});var i={action:"pll_update_post_rows",post_id:h,translations:g.join(","),post_type:a("input[name='post_type']").val(),screen:a("input[name='screen']").val(),_pll_nonce:a("input[name='_inline_edit']").val()};a.post(ajaxurl,i,function(j){if(j){var k=wpAjax.parseAjaxResponse(j,"ajax-response");a.each(k.responses,function(){if("row"==this.what){a("#post-"+this.supplemental.post_id).replaceWith(this.data)}})}})}var e=wpAjax.unserialize(c.data);if("undefined"!=typeof(e.action)&&"inline-save"==e.action){b(e.post_ID)}})})(jQuery);jQuery(document).ready(function(c){var b=new Array();c(".categorydiv").each(function(){var f=c(this).attr("id"),e,d;e=f.split("-");e.shift();d=e.join("-");b.push(d);c("#"+d+"-add-submit").before(c("<input />").attr("type","hidden").attr("id",d+"-lang").attr("name","term_lang_choice").attr("value",c(".post_lang_choice").val()))});c(".post_lang_choice").change(function(){var d={action:"post_lang_choice",lang:c(this).val(),post_type:c("#post_type").val(),taxonomies:b,post_id:c("#post_ID").val(),_pll_nonce:c("#_pll_nonce").val()};c.post(ajaxurl,d,function(e){var f=wpAjax.parseAjaxResponse(e,"ajax-response");c.each(f.responses,function(){switch(this.what){case"translations":c(".translations").html(this.data);a();break;case"taxonomy":var g=this.data;c("#"+g+"checklist").html(this.supplemental.all);c("#"+g+"checklist-pop").html(this.supplemental.populars);c("#new"+g+"_parent").replaceWith(this.supplemental.dropdown);c("#"+g+"-lang").val(c(".post_lang_choice").val());break;case"pages":c("#parent_id").html(this.data);break;case"flag":c(".pll-select-flag").html(this.data);break}});c(".tagcloud-link").each(function(){var g=c(this).attr("id");tagBox.get(g)})})});function a(){c(".tr_lang").each(function(){var d=c(this).attr("id").substring(8);var e=c(this).parent().siblings(".pll-edit-column");c(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_posts_not_translated&post_language="+c(".post_lang_choice").val()+"&translation_language="+d+"&post_type="+c("#post_type").val()+"&_pll_nonce="+c("#_pll_nonce").val(),select:function(f,g){c("#htr_lang_"+d).val(g.item.id);e.html(g.item.link)}});c(this).blur(function(){if(!c(this).val()){c("#htr_lang_"+d).val(0);e.html(e.siblings(".hidden").children().clone())}})})}a()});
|
js/term.js
CHANGED
@@ -1,157 +1,159 @@
|
|
1 |
-
// quick edit
|
2 |
-
(function($) {
|
3 |
-
$(document).bind('DOMNodeInserted', function(e) {
|
4 |
-
var t = $(e.target);
|
5 |
-
|
6 |
-
// WP inserts the quick edit from
|
7 |
-
if ('inline-edit' == t.attr('id')) {
|
8 |
-
var term_id = t.prev().attr('id').replace("tag-", "");
|
9 |
-
|
10 |
-
if (term_id > 0) {
|
11 |
-
// language dropdown
|
12 |
-
var select = t.find(':input[name="inline_lang_choice"]');
|
13 |
-
var lang = $('#lang_' + term_id).html();
|
14 |
-
select.val(lang); // populates the dropdown
|
15 |
-
|
16 |
-
// disable the language dropdown for default categories
|
17 |
-
var default_cat = $('#default_cat_' + term_id).html();
|
18 |
-
if (term_id == default_cat) {
|
19 |
-
select.prop('disabled', true);
|
20 |
-
}
|
21 |
-
}
|
22 |
-
}
|
23 |
-
});
|
24 |
-
})(jQuery);
|
25 |
-
|
26 |
-
|
27 |
-
// update rows of translated terms when adding / deleting a translation or when the language is modified in quick edit
|
28 |
-
// acts on ajaxSuccess event
|
29 |
-
(function($) {
|
30 |
-
$(document).ajaxSuccess(function(event, xhr, settings) {
|
31 |
-
function update_rows(term_id) {
|
32 |
-
// collect old translations
|
33 |
-
var translations = new Array;
|
34 |
-
$('.translation_'+term_id).each(function() {
|
35 |
-
translations.push($(this).parent().parent().attr('id').substring(4));
|
36 |
-
});
|
37 |
-
|
38 |
-
var data = {
|
39 |
-
action:
|
40 |
-
term_id:
|
41 |
-
translations: translations.join(','),
|
42 |
-
taxonomy:
|
43 |
-
screen:
|
44 |
-
_pll_nonce:
|
45 |
-
}
|
46 |
-
|
47 |
-
// get the modified rows in ajax and update them
|
48 |
-
$.post(ajaxurl, data, function(response) {
|
49 |
-
if (response) {
|
50 |
-
var res = wpAjax.parseAjaxResponse(response, 'ajax-response');
|
51 |
-
$.each(res.responses, function() {
|
52 |
-
if ('row' == this.what) {
|
53 |
-
$("#tag-"+this.supplemental.term_id).replaceWith(this.data);
|
54 |
-
}
|
55 |
-
});
|
56 |
-
}
|
57 |
-
});
|
58 |
-
}
|
59 |
-
|
60 |
-
var data = wpAjax.unserialize(settings.data); // what were the data sent by the ajax request?
|
61 |
-
if ('undefined' != typeof(data['action'])) {
|
62 |
-
switch(data['action']) {
|
63 |
-
// when adding a term, the new term_id is in the ajax response
|
64 |
-
case 'add-tag':
|
65 |
-
res = wpAjax.parseAjaxResponse(xhr.responseXML, 'ajax-response');
|
66 |
-
$.each(res.responses, function() {
|
67 |
-
if ('term' == this.what) {
|
68 |
-
update_rows(this.supplemental.term_id);
|
69 |
-
}
|
70 |
-
});
|
71 |
-
|
72 |
-
// and also reset translations hidden input fields
|
73 |
-
$('.htr_lang').val(0);
|
74 |
-
break;
|
75 |
-
|
76 |
-
// when deleting a term
|
77 |
-
case 'delete-tag':
|
78 |
-
update_rows(data['tag_ID']);
|
79 |
-
|
80 |
-
|
81 |
-
// in case the language is modified in quick edit and breaks translations
|
82 |
-
case 'inline-save-tax':
|
83 |
-
update_rows(data['tax_ID']);
|
84 |
-
|
85 |
-
}
|
86 |
-
}
|
87 |
-
});
|
88 |
-
})(jQuery);
|
89 |
-
|
90 |
-
jQuery(document).ready(function($) {
|
91 |
-
// translations autocomplete input box
|
92 |
-
function init_translations() {
|
93 |
-
$('.tr_lang').each(function(){
|
94 |
-
var tr_lang = $(this).attr('id').substring(8);
|
95 |
-
var td = $(this).parent().siblings('.pll-edit-column');
|
96 |
-
|
97 |
-
$(this).autocomplete({
|
98 |
-
minLength: 0,
|
99 |
-
|
100 |
-
source: ajaxurl + '?action=pll_terms_not_translated
|
101 |
-
'&
|
102 |
-
'&
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
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 |
-
|
140 |
-
|
141 |
-
|
142 |
-
case '
|
143 |
-
$(
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
});
|
|
|
|
1 |
+
// quick edit
|
2 |
+
(function( $ ) {
|
3 |
+
$( document ).bind( 'DOMNodeInserted', function( e ) {
|
4 |
+
var t = $( e.target );
|
5 |
+
|
6 |
+
// WP inserts the quick edit from
|
7 |
+
if ( 'inline-edit' == t.attr( 'id' ) ) {
|
8 |
+
var term_id = t.prev().attr( 'id' ).replace( "tag-", "" );
|
9 |
+
|
10 |
+
if ( term_id > 0 ) {
|
11 |
+
// language dropdown
|
12 |
+
var select = t.find( ':input[name="inline_lang_choice"]' );
|
13 |
+
var lang = $( '#lang_' + term_id ).html();
|
14 |
+
select.val( lang ); // populates the dropdown
|
15 |
+
|
16 |
+
// disable the language dropdown for default categories
|
17 |
+
var default_cat = $( '#default_cat_' + term_id ).html();
|
18 |
+
if ( term_id == default_cat ) {
|
19 |
+
select.prop( 'disabled', true );
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
23 |
+
});
|
24 |
+
})( jQuery );
|
25 |
+
|
26 |
+
|
27 |
+
// update rows of translated terms when adding / deleting a translation or when the language is modified in quick edit
|
28 |
+
// acts on ajaxSuccess event
|
29 |
+
(function( $ ) {
|
30 |
+
$( document ).ajaxSuccess(function( event, xhr, settings ) {
|
31 |
+
function update_rows( term_id ) {
|
32 |
+
// collect old translations
|
33 |
+
var translations = new Array;
|
34 |
+
$( '.translation_' + term_id ).each(function() {
|
35 |
+
translations.push( $( this ).parent().parent().attr( 'id' ).substring( 4 ) );
|
36 |
+
});
|
37 |
+
|
38 |
+
var data = {
|
39 |
+
action: 'pll_update_term_rows',
|
40 |
+
term_id: term_id,
|
41 |
+
translations: translations.join( ',' ),
|
42 |
+
taxonomy: $( "input[name='taxonomy']" ).val(),
|
43 |
+
screen: $( "input[name='screen']" ).val(),
|
44 |
+
_pll_nonce: $( '#_pll_nonce' ).val()
|
45 |
+
}
|
46 |
+
|
47 |
+
// get the modified rows in ajax and update them
|
48 |
+
$.post( ajaxurl, data, function( response ) {
|
49 |
+
if ( response ) {
|
50 |
+
var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
|
51 |
+
$.each( res.responses, function() {
|
52 |
+
if ( 'row' == this.what ) {
|
53 |
+
$( "#tag-" + this.supplemental.term_id ).replaceWith( this.data );
|
54 |
+
}
|
55 |
+
});
|
56 |
+
}
|
57 |
+
});
|
58 |
+
}
|
59 |
+
|
60 |
+
var data = wpAjax.unserialize( settings.data ); // what were the data sent by the ajax request?
|
61 |
+
if ( 'undefined' != typeof( data['action'] ) ) {
|
62 |
+
switch ( data['action'] ) {
|
63 |
+
// when adding a term, the new term_id is in the ajax response
|
64 |
+
case 'add-tag':
|
65 |
+
res = wpAjax.parseAjaxResponse( xhr.responseXML, 'ajax-response' );
|
66 |
+
$.each( res.responses, function() {
|
67 |
+
if ( 'term' == this.what ) {
|
68 |
+
update_rows( this.supplemental.term_id );
|
69 |
+
}
|
70 |
+
});
|
71 |
+
|
72 |
+
// and also reset translations hidden input fields
|
73 |
+
$( '.htr_lang' ).val( 0 );
|
74 |
+
break;
|
75 |
+
|
76 |
+
// when deleting a term
|
77 |
+
case 'delete-tag':
|
78 |
+
update_rows( data['tag_ID'] );
|
79 |
+
break;
|
80 |
+
|
81 |
+
// in case the language is modified in quick edit and breaks translations
|
82 |
+
case 'inline-save-tax':
|
83 |
+
update_rows( data['tax_ID'] );
|
84 |
+
break;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
});
|
88 |
+
})( jQuery );
|
89 |
+
|
90 |
+
jQuery( document ).ready(function( $ ) {
|
91 |
+
// translations autocomplete input box
|
92 |
+
function init_translations() {
|
93 |
+
$( '.tr_lang' ).each(function(){
|
94 |
+
var tr_lang = $( this ).attr( 'id' ).substring( 8 );
|
95 |
+
var td = $( this ).parent().siblings( '.pll-edit-column' );
|
96 |
+
|
97 |
+
$( this ).autocomplete({
|
98 |
+
minLength: 0,
|
99 |
+
|
100 |
+
source: ajaxurl + '?action=pll_terms_not_translated' +
|
101 |
+
'&term_language=' + $( '#term_lang_choice' ).val() +
|
102 |
+
'&term_id=' + $( "input[name='tag_ID']" ).val() +
|
103 |
+
'&taxonomy=' + $( "input[name='taxonomy']" ).val() +
|
104 |
+
'&translation_language=' + tr_lang +
|
105 |
+
'&post_type=' + typenow +
|
106 |
+
'&_pll_nonce=' + $( '#_pll_nonce' ).val(),
|
107 |
+
|
108 |
+
select: function( event, ui ) {
|
109 |
+
$( '#htr_lang_' + tr_lang ).val( ui.item.id );
|
110 |
+
td.html( ui.item.link );
|
111 |
+
},
|
112 |
+
});
|
113 |
+
|
114 |
+
// when the input box is emptied
|
115 |
+
$( this ).blur(function() {
|
116 |
+
if ( ! $( this ).val() ) {
|
117 |
+
$( '#htr_lang_' + tr_lang ).val( 0 );
|
118 |
+
td.html( td.siblings( '.hidden' ).children().clone() );
|
119 |
+
}
|
120 |
+
});
|
121 |
+
});
|
122 |
+
}
|
123 |
+
|
124 |
+
init_translations();
|
125 |
+
|
126 |
+
// ajax for changing the term's language
|
127 |
+
$( '#term_lang_choice' ).change(function() {
|
128 |
+
var data = {
|
129 |
+
action: 'term_lang_choice',
|
130 |
+
lang: $( this ).val(),
|
131 |
+
from_tag: $( "input[name='from_tag']" ).val(),
|
132 |
+
term_id: $( "input[name='tag_ID']" ).val(),
|
133 |
+
taxonomy: $( "input[name='taxonomy']" ).val(),
|
134 |
+
post_type: typenow,
|
135 |
+
_pll_nonce: $( '#_pll_nonce' ).val()
|
136 |
+
}
|
137 |
+
|
138 |
+
$.post( ajaxurl, data, function( response ) {
|
139 |
+
var res = wpAjax.parseAjaxResponse( response, 'ajax-response' );
|
140 |
+
$.each( res.responses, function() {
|
141 |
+
switch ( this.what ) {
|
142 |
+
case 'translations': // translations fields
|
143 |
+
$( "#term-translations" ).html( this.data );
|
144 |
+
init_translations();
|
145 |
+
break;
|
146 |
+
case 'parent': // parent dropdown list for hierarchical taxonomies
|
147 |
+
$( '#parent' ).replaceWith( this.data );
|
148 |
+
break;
|
149 |
+
case 'tag_cloud': // popular items
|
150 |
+
$( '.tagcloud' ).replaceWith( this.data );
|
151 |
+
break;
|
152 |
+
case 'flag': // flag in front of the select dropdown
|
153 |
+
$( '.pll-select-flag' ).html( this.data );
|
154 |
+
break;
|
155 |
+
}
|
156 |
+
});
|
157 |
+
});
|
158 |
+
});
|
159 |
+
});
|
js/term.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(a){a(document).bind("DOMNodeInserted",function(f){var c=a(f.target);if("inline-edit"==c.attr("id")){var d=c.prev().attr("id").replace("tag-","");if(d>0){var b=c.find(':input[name="inline_lang_choice"]');var h=a("#lang_"+d).html();b.val(h);var g=a("#default_cat_"+d).html();if(d==g){b.prop("disabled",true)}}}})})(jQuery);(function(a){a(document).ajaxSuccess(function(d,f,c){function b(i){var g=new Array;a(".translation_"+i).each(function(){g.push(a(this).parent().parent().attr("id").substring(4))});var h={action:"pll_update_term_rows",term_id:i,translations:g.join(","),taxonomy:a("input[name='taxonomy']").val(),screen:a("input[name='screen']").val(),_pll_nonce:a("#_pll_nonce").val()};a.post(ajaxurl,h,function(j){if(j){var k=wpAjax.parseAjaxResponse(j,"ajax-response");a.each(k.responses,function(){if("row"==this.what){a("#tag-"+this.supplemental.term_id).replaceWith(this.data)}})}})}var e=wpAjax.unserialize(c.data);if("undefined"!=typeof(e.action)){switch(e.action){case"add-tag":res=wpAjax.parseAjaxResponse(f.responseXML,"ajax-response");a.each(res.responses,function(){if("term"==this.what){b(this.supplemental.term_id)}});a(".htr_lang").val(0);break;case"delete-tag":b(e.tag_ID);break;case"inline-save-tax":b(e.tax_ID);break}}})})(jQuery);jQuery(document).ready(function(b){function a(){b(".tr_lang").each(function(){var c=b(this).attr("id").substring(8);var d=b(this).parent().siblings(".pll-edit-column");b(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_terms_not_translated&term_language="+b("#term_lang_choice").val()+"&term_id="+b("input[name='tag_ID']").val()+"&taxonomy="+b("input[name='taxonomy']").val()+"&translation_language="+c+"&post_type="+typenow+"&_pll_nonce="+b("#_pll_nonce").val(),select:function(e,f){b("#htr_lang_"+c).val(f.item.id);d.html(f.item.link)}});b(this).blur(function(){if(!b(this).val()){b("#htr_lang_"+c).val(0);d.html(d.siblings(".hidden").children().clone())}})})}a();b("#term_lang_choice").change(function(){var c={action:"term_lang_choice",lang:b(this).val(),from_tag:b("input[name='from_tag']").val(),term_id:b("input[name='tag_ID']").val(),taxonomy:b("input[name='taxonomy']").val(),post_type:typenow,_pll_nonce:b("#_pll_nonce").val()};b.post(ajaxurl,c,function(d){var e=wpAjax.parseAjaxResponse(d,"ajax-response");b.each(e.responses,function(){switch(this.what){case"translations":b("#term-translations").html(this.data);a();break;case"parent":b("#parent").replaceWith(this.data);break;case"tag_cloud":b(".tagcloud").replaceWith(this.data);break;case"flag":b(".pll-select-flag").html(this.data);break
|
1 |
+
(function(a){a(document).bind("DOMNodeInserted",function(f){var c=a(f.target);if("inline-edit"==c.attr("id")){var d=c.prev().attr("id").replace("tag-","");if(d>0){var b=c.find(':input[name="inline_lang_choice"]');var h=a("#lang_"+d).html();b.val(h);var g=a("#default_cat_"+d).html();if(d==g){b.prop("disabled",true)}}}})})(jQuery);(function(a){a(document).ajaxSuccess(function(d,f,c){function b(i){var g=new Array;a(".translation_"+i).each(function(){g.push(a(this).parent().parent().attr("id").substring(4))});var h={action:"pll_update_term_rows",term_id:i,translations:g.join(","),taxonomy:a("input[name='taxonomy']").val(),screen:a("input[name='screen']").val(),_pll_nonce:a("#_pll_nonce").val()};a.post(ajaxurl,h,function(j){if(j){var k=wpAjax.parseAjaxResponse(j,"ajax-response");a.each(k.responses,function(){if("row"==this.what){a("#tag-"+this.supplemental.term_id).replaceWith(this.data)}})}})}var e=wpAjax.unserialize(c.data);if("undefined"!=typeof(e.action)){switch(e.action){case"add-tag":res=wpAjax.parseAjaxResponse(f.responseXML,"ajax-response");a.each(res.responses,function(){if("term"==this.what){b(this.supplemental.term_id)}});a(".htr_lang").val(0);break;case"delete-tag":b(e.tag_ID);break;case"inline-save-tax":b(e.tax_ID);break}}})})(jQuery);jQuery(document).ready(function(b){function a(){b(".tr_lang").each(function(){var c=b(this).attr("id").substring(8);var d=b(this).parent().siblings(".pll-edit-column");b(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_terms_not_translated&term_language="+b("#term_lang_choice").val()+"&term_id="+b("input[name='tag_ID']").val()+"&taxonomy="+b("input[name='taxonomy']").val()+"&translation_language="+c+"&post_type="+typenow+"&_pll_nonce="+b("#_pll_nonce").val(),select:function(e,f){b("#htr_lang_"+c).val(f.item.id);d.html(f.item.link)}});b(this).blur(function(){if(!b(this).val()){b("#htr_lang_"+c).val(0);d.html(d.siblings(".hidden").children().clone())}})})}a();b("#term_lang_choice").change(function(){var c={action:"term_lang_choice",lang:b(this).val(),from_tag:b("input[name='from_tag']").val(),term_id:b("input[name='tag_ID']").val(),taxonomy:b("input[name='taxonomy']").val(),post_type:typenow,_pll_nonce:b("#_pll_nonce").val()};b.post(ajaxurl,c,function(d){var e=wpAjax.parseAjaxResponse(d,"ajax-response");b.each(e.responses,function(){switch(this.what){case"translations":b("#term-translations").html(this.data);a();break;case"parent":b("#parent").replaceWith(this.data);break;case"tag_cloud":b(".tagcloud").replaceWith(this.data);break;case"flag":b(".pll-select-flag").html(this.data);break}})})})});
|
js/user.js
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
jQuery(document).ready(function($) {
|
2 |
// biography
|
3 |
// FIXME there is probably a more efficient way to do this
|
4 |
-
var td = $('#description').parent();
|
5 |
-
var d = $('#description').clone();
|
6 |
-
var span = td.children('.description').clone();
|
7 |
td.children().remove();
|
8 |
|
9 |
-
$('.biography').each(
|
10 |
-
lang = $(this).attr('name').split('
|
11 |
desc = d.clone();
|
12 |
-
desc.attr('name', 'description_'+lang[0]);
|
13 |
-
desc.html($(this).val());
|
14 |
-
td.append('<div>'+lang[1]+'</div');
|
15 |
-
td.append(desc);
|
16 |
});
|
17 |
|
18 |
-
td.append('<br />');
|
19 |
-
td.append(span);
|
20 |
});
|
1 |
+
jQuery( document ).ready(function( $ ) {
|
2 |
// biography
|
3 |
// FIXME there is probably a more efficient way to do this
|
4 |
+
var td = $( '#description' ).parent();
|
5 |
+
var d = $( '#description' ).clone();
|
6 |
+
var span = td.children( '.description' ).clone();
|
7 |
td.children().remove();
|
8 |
|
9 |
+
$( '.biography' ).each(function(){
|
10 |
+
lang = $( this ).attr( 'name' ).split( '___' );
|
11 |
desc = d.clone();
|
12 |
+
desc.attr( 'name', 'description_' + lang[0] );
|
13 |
+
desc.html( $( this ).val() );
|
14 |
+
td.append( '<div>' + lang[1] + '</div' );
|
15 |
+
td.append( desc );
|
16 |
});
|
17 |
|
18 |
+
td.append( '<br />' );
|
19 |
+
td.append( span );
|
20 |
});
|
js/user.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(b){var e=b("#description").parent();var c=b("#description").clone();var a=e.children(".description").clone();e.children().remove();b(".biography").each(function(){lang=b(this).attr("name").split("
|
1 |
+
jQuery(document).ready(function(b){var e=b("#description").parent();var c=b("#description").clone();var a=e.children(".description").clone();e.children().remove();b(".biography").each(function(){lang=b(this).attr("name").split("___");desc=c.clone();desc.attr("name","description_"+lang[0]);desc.html(b(this).val());e.append("<div>"+lang[1]+"</div");e.append(desc)});e.append("<br />");e.append(a)});
|
languages/polylang-da_DK.mo
DELETED
Binary file
|
languages/polylang-da_DK.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: Patrick Holberg Hesselberg <super-patzen@live.dk>\n"
|
8 |
-
"Language-Team: \n"
|
9 |
-
"Language: da_DK\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.7.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 er forsynet med en omfattende %sdocumentation%s (kun Engelsk). Den "
|
30 |
-
"informerer om, hvordan du opsætter dit flersprogede site og hvordan du "
|
31 |
-
"bruger det på et daglig basis, en FAQ, samt en dokumentation for "
|
32 |
-
"programmører til at bruge det i deres plugins og temaer."
|
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 |
-
"Du vil også finde brugbar information i %ssupport forum%s. Men glem ikke at "
|
41 |
-
"lave en søgning, før du opretter et nyt emne."
|
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 er gratis og frigivet under den samme licens som WordPress, %sGPL%s."
|
50 |
-
|
51 |
-
#: admin/view-about.php:22
|
52 |
-
#, php-format
|
53 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
54 |
-
msgstr ""
|
55 |
-
"Hvis du tænker over, hvordan du kan hjælpe dette projekt, %slæs dette%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 |
-
"Endelig, hvis du kan lide dette plugin, eller hjælper din virksomhed, er "
|
63 |
-
"donationer til forfatteren meget værdsat."
|
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 "Sprog"
|
69 |
-
|
70 |
-
#: include/switcher.php:22
|
71 |
-
msgid "Displays language names"
|
72 |
-
msgstr "Vis sprog navne"
|
73 |
-
|
74 |
-
#: include/switcher.php:23
|
75 |
-
msgid "Displays flags"
|
76 |
-
msgstr "Vis flag"
|
77 |
-
|
78 |
-
#: include/switcher.php:24
|
79 |
-
msgid "Forces link to front page"
|
80 |
-
msgstr "Tvinger link til forsiden"
|
81 |
-
|
82 |
-
#: include/switcher.php:25
|
83 |
-
msgid "Hides the current language"
|
84 |
-
msgstr "Skjuler det nuværende sprog"
|
85 |
-
|
86 |
-
#: include/switcher.php:30
|
87 |
-
msgid "Displays as dropdown"
|
88 |
-
msgstr "Viser som dropdown"
|
89 |
-
|
90 |
-
#: admin/admin.php:267
|
91 |
-
msgid "Filters content by language"
|
92 |
-
msgstr "Filtrerer indhold efter sprog"
|
93 |
-
|
94 |
-
#: admin/admin.php:258
|
95 |
-
msgid "Show all languages"
|
96 |
-
msgstr "Vis alle sprog"
|
97 |
-
|
98 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
99 |
-
msgid "Add new translation"
|
100 |
-
msgstr "Tilføj ny oversættelse"
|
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 "Sprog"
|
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 "Oversættelser"
|
113 |
-
|
114 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
115 |
-
msgid "Sets the language"
|
116 |
-
msgstr "Indstiller sproget"
|
117 |
-
|
118 |
-
#: admin/admin-filters.php:52
|
119 |
-
msgid "The widget is displayed for:"
|
120 |
-
msgstr "Widget vises i:"
|
121 |
-
|
122 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
123 |
-
msgid "All languages"
|
124 |
-
msgstr "Alle sprog"
|
125 |
-
|
126 |
-
#: admin/admin-filters.php:123
|
127 |
-
msgid "Admin language"
|
128 |
-
msgstr "Administrator sprog"
|
129 |
-
|
130 |
-
#: admin/admin-filters.php:126
|
131 |
-
msgid "WordPress default"
|
132 |
-
msgstr "WordPress standard"
|
133 |
-
|
134 |
-
#: admin/admin.php:167 admin/settings.php:102
|
135 |
-
msgid "Settings"
|
136 |
-
msgstr "Indstillinger"
|
137 |
-
|
138 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
139 |
-
msgid "Upgrading language files…"
|
140 |
-
msgstr "Opgradering sprogfiler files…"
|
141 |
-
|
142 |
-
#: admin/settings.php:62
|
143 |
-
msgid "About Polylang"
|
144 |
-
msgstr "Om Polylang"
|
145 |
-
|
146 |
-
#: admin/settings.php:78
|
147 |
-
msgid "Strings translations"
|
148 |
-
msgstr "Strings oversættelser"
|
149 |
-
|
150 |
-
#: admin/settings.php:101
|
151 |
-
msgid "Strings translation"
|
152 |
-
msgstr "Strings oversættelse"
|
153 |
-
|
154 |
-
#: admin/admin-model.php:244
|
155 |
-
msgid "Enter a valid WordPress locale"
|
156 |
-
msgstr "Indtast en gyldig WordPress locale"
|
157 |
-
|
158 |
-
#: admin/admin-model.php:252
|
159 |
-
msgid "The language code must be unique"
|
160 |
-
msgstr "Sprogkoden skal være unik"
|
161 |
-
|
162 |
-
#: admin/admin-model.php:256
|
163 |
-
msgid "The language must have a name"
|
164 |
-
msgstr "Sproget skal have et navn"
|
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 |
-
"Sproget var oprettet, men WordPress sprogfilen blev ikke downloadet. Du skal "
|
172 |
-
"installere den manuelt."
|
173 |
-
|
174 |
-
#: admin/admin-strings.php:59
|
175 |
-
msgid "Widget title"
|
176 |
-
msgstr "Widget titel"
|
177 |
-
|
178 |
-
# @ polylang
|
179 |
-
#: admin/settings.php:319
|
180 |
-
msgid "Taxonomies"
|
181 |
-
msgstr "Taksonomier"
|
182 |
-
|
183 |
-
# @ polylang
|
184 |
-
#: admin/settings.php:320
|
185 |
-
msgid "Custom fields"
|
186 |
-
msgstr "Egne felter"
|
187 |
-
|
188 |
-
# @ polylang
|
189 |
-
#: admin/settings.php:321
|
190 |
-
msgid "Comment status"
|
191 |
-
msgstr "Kommentar status"
|
192 |
-
|
193 |
-
# @ polylang
|
194 |
-
#: admin/settings.php:322
|
195 |
-
msgid "Ping status"
|
196 |
-
msgstr "Ping status"
|
197 |
-
|
198 |
-
# @ polylang
|
199 |
-
#: admin/settings.php:323
|
200 |
-
msgid "Sticky posts"
|
201 |
-
msgstr "Fastgjorte indlæg"
|
202 |
-
|
203 |
-
# @ polylang
|
204 |
-
#: admin/settings.php:324
|
205 |
-
msgid "Published date"
|
206 |
-
msgstr "Dato udgivet"
|
207 |
-
|
208 |
-
# @ polylang
|
209 |
-
#: admin/settings.php:325
|
210 |
-
msgid "Post format"
|
211 |
-
msgstr "Indlægsformat"
|
212 |
-
|
213 |
-
#: admin/settings.php:326
|
214 |
-
msgid "Page parent"
|
215 |
-
msgstr "Side forælder"
|
216 |
-
|
217 |
-
# @ polylang
|
218 |
-
#: admin/settings.php:327
|
219 |
-
msgid "Page template"
|
220 |
-
msgstr "Sideskabelon"
|
221 |
-
|
222 |
-
#: admin/settings.php:328
|
223 |
-
msgid "Page order"
|
224 |
-
msgstr "Side rækkefølge"
|
225 |
-
|
226 |
-
# @ polylang
|
227 |
-
#: admin/settings.php:329
|
228 |
-
msgid "Featured image"
|
229 |
-
msgstr "Fremhævet billede"
|
230 |
-
|
231 |
-
#: admin/view-tab-lang.php:21
|
232 |
-
msgid "Edit language"
|
233 |
-
msgstr "Rediger sprog"
|
234 |
-
|
235 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
236 |
-
msgid "Add new language"
|
237 |
-
msgstr "Tilføj nyt sprog"
|
238 |
-
|
239 |
-
#: admin/view-tab-lang.php:37
|
240 |
-
msgid "Choose a language"
|
241 |
-
msgstr "Vælg sprog"
|
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 "Du kan vælge et sprog fra listen eller redigere det direkte nedenfor."
|
246 |
-
|
247 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
248 |
-
msgid "Full name"
|
249 |
-
msgstr "Fulde navn"
|
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 "Navnet er hvordan det bliver vist på din side (for eksempel: Engelsk)."
|
254 |
-
|
255 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
256 |
-
msgid "Locale"
|
257 |
-
msgstr "Landestandard"
|
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 |
-
"WordPress Landestandarden for sproget (for eksempel: da_DK). Du skal "
|
265 |
-
"installere .mo filen til dette sprog."
|
266 |
-
|
267 |
-
#: admin/view-tab-lang.php:70
|
268 |
-
msgid "Language code"
|
269 |
-
msgstr "Sprogkode"
|
270 |
-
|
271 |
-
#: admin/view-tab-lang.php:76
|
272 |
-
msgid "Text direction"
|
273 |
-
msgstr "Tekst retning"
|
274 |
-
|
275 |
-
#: admin/view-tab-lang.php:80
|
276 |
-
msgid "left to right"
|
277 |
-
msgstr "venstre til højre"
|
278 |
-
|
279 |
-
#: admin/view-tab-lang.php:85
|
280 |
-
msgid "right to left"
|
281 |
-
msgstr "højre til venstre"
|
282 |
-
|
283 |
-
#: admin/view-tab-lang.php:87
|
284 |
-
msgid "Choose the text direction for the language"
|
285 |
-
msgstr "Vælg en tekstretning for sproget"
|
286 |
-
|
287 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
288 |
-
msgid "Order"
|
289 |
-
msgstr "Sorter"
|
290 |
-
|
291 |
-
#: admin/view-tab-lang.php:93
|
292 |
-
msgid "Position of the language in the language switcher"
|
293 |
-
msgstr "Position af sproget i sprog skifteren"
|
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 "Sprog skifter"
|
300 |
-
|
301 |
-
#: admin/view-tab-strings.php:8
|
302 |
-
msgid "Search translations"
|
303 |
-
msgstr "Søg oversættelser"
|
304 |
-
|
305 |
-
#: admin/view-tab-strings.php:11
|
306 |
-
msgid "Clean strings translation database"
|
307 |
-
msgstr "Rene strings database oversættelse"
|
308 |
-
|
309 |
-
#: admin/view-tab-settings.php:14
|
310 |
-
msgid "Default language"
|
311 |
-
msgstr "Standard sprog"
|
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 |
-
"Der er indlæg, sider, kategorier eller tags uden et valgt sprog. Vil du "
|
319 |
-
"sætte dem til det standard sprog ?"
|
320 |
-
|
321 |
-
#: admin/view-tab-settings.php:149
|
322 |
-
msgid "Detect browser language"
|
323 |
-
msgstr "Find browser sprog"
|
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 |
-
"Når forsiden vises, skal du indstille sprog i overensstemmelse med browseren "
|
331 |
-
"præference"
|
332 |
-
|
333 |
-
#: admin/view-tab-settings.php:37
|
334 |
-
msgid "URL modifications"
|
335 |
-
msgstr "URL ændringer"
|
336 |
-
|
337 |
-
#: admin/view-tab-settings.php:93
|
338 |
-
msgid "Hide URL language information for default language"
|
339 |
-
msgstr "Skjul URL sprog information for standardsprog"
|
340 |
-
|
341 |
-
# @ polylang
|
342 |
-
#: admin/view-tab-settings.php:162
|
343 |
-
msgid "Media"
|
344 |
-
msgstr "Medier"
|
345 |
-
|
346 |
-
# @ polylang
|
347 |
-
#: admin/view-tab-settings.php:168
|
348 |
-
msgid "Activate languages and translations for media"
|
349 |
-
msgstr "Aktiver sprog og oversættelser for medier"
|
350 |
-
|
351 |
-
#: admin/view-tab-settings.php:215
|
352 |
-
msgid "Synchronization"
|
353 |
-
msgstr "Synkronisering"
|
354 |
-
|
355 |
-
# @ polylang
|
356 |
-
#: admin/view-tab-settings.php:176
|
357 |
-
msgid "Custom post types"
|
358 |
-
msgstr "Brugerdefineret indlægstype"
|
359 |
-
|
360 |
-
# @ polylang
|
361 |
-
#: admin/view-tab-settings.php:189
|
362 |
-
msgid "Activate languages and translations for custom post types."
|
363 |
-
msgstr "Aktiver sprog og oversættelser for brugerdefineret indlægstype"
|
364 |
-
|
365 |
-
# @ polylang
|
366 |
-
#: admin/view-tab-settings.php:196
|
367 |
-
msgid "Custom taxonomies"
|
368 |
-
msgstr "Brugerdefineret taksonomi"
|
369 |
-
|
370 |
-
# @ polylang
|
371 |
-
#: admin/view-tab-settings.php:209
|
372 |
-
msgid "Activate languages and translations for custom taxonomies."
|
373 |
-
msgstr "Aktiver sprog og oversættelser for brugerdefineret taksonomi"
|
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 "Rediger"
|
379 |
-
|
380 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
381 |
-
msgid "Delete"
|
382 |
-
msgstr "Slet"
|
383 |
-
|
384 |
-
#: admin/table-languages.php:76
|
385 |
-
msgid "Code"
|
386 |
-
msgstr "Kode"
|
387 |
-
|
388 |
-
#: admin/table-languages.php:78
|
389 |
-
msgid "Flag"
|
390 |
-
msgstr "Flag"
|
391 |
-
|
392 |
-
#: admin/table-languages.php:79
|
393 |
-
msgid "Posts"
|
394 |
-
msgstr "Indlæg"
|
395 |
-
|
396 |
-
#: admin/table-string.php:110
|
397 |
-
msgid "Name"
|
398 |
-
msgstr "Navn"
|
399 |
-
|
400 |
-
#: admin/table-string.php:111
|
401 |
-
msgid "String"
|
402 |
-
msgstr "String"
|
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 "Opret ny"
|
408 |
-
|
409 |
-
#: include/widget-languages.php:16
|
410 |
-
msgid "Language Switcher"
|
411 |
-
msgstr "Sprog Skifter"
|
412 |
-
|
413 |
-
#: include/widget-languages.php:16
|
414 |
-
msgid "Displays a language switcher"
|
415 |
-
msgstr "Viser en sprog skifter"
|
416 |
-
|
417 |
-
#: include/widget-languages.php:75
|
418 |
-
msgid "Title:"
|
419 |
-
msgstr "Titel:"
|
420 |
-
|
421 |
-
# @ polylang
|
422 |
-
#. translators: plugin header field 'Description'
|
423 |
-
#: polylang.php:0
|
424 |
-
msgid "Adds multilingual capability to WordPress"
|
425 |
-
msgstr "Tilføjer flersproget funktionalitet til 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 "Du bruger WordPress %s. Polylang kræver mindst 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 er blevet deaktiveret, fordi du har opgraderet fra en for gammel "
|
438 |
-
"version."
|
439 |
-
|
440 |
-
# @ polylang
|
441 |
-
#: install/upgrade.php:78
|
442 |
-
#, php-format
|
443 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
444 |
-
msgstr "Opgrader først til %s, før du op opdragere til %s."
|
445 |
-
|
446 |
-
# @ polylang
|
447 |
-
#: admin/table-string.php:109
|
448 |
-
msgid "Group"
|
449 |
-
msgstr "Gruppe"
|
450 |
-
|
451 |
-
# @ polylang
|
452 |
-
#: admin/table-string.php:187
|
453 |
-
msgid "View all groups"
|
454 |
-
msgstr "Vis alle grupper"
|
455 |
-
|
456 |
-
# @ polylang
|
457 |
-
#: admin/table-languages.php:59
|
458 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
459 |
-
msgstr "Du er ved at slette dette sprog permanent. Er du sikker?"
|
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 |
-
"Brug denne til at fjerne ubrugte strenge fra databasen, for eksempel efter "
|
468 |
-
"et plugin er blevet afinstalleret."
|
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 |
-
"Synkronisering indstillingerne gør det muligt at opretholde nøjagtig samme "
|
478 |
-
"værdier (eller oversættelser i tilfælde af taksonomier og side forælder), af "
|
479 |
-
"meta indhold mellem oversættelserne af et indlæg eller side."
|
480 |
-
|
481 |
-
#: admin/admin-model.php:248
|
482 |
-
msgid "The language code contains invalid characters"
|
483 |
-
msgstr "Sprogkoden indeholder ugyldige tegn"
|
484 |
-
|
485 |
-
# @ polylang
|
486 |
-
#: admin/view-tab-settings.php:43
|
487 |
-
msgid "The language is set from content"
|
488 |
-
msgstr "Sproget er sat fra indholdet"
|
489 |
-
|
490 |
-
#: admin/view-tab-settings.php:46
|
491 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
492 |
-
msgstr "Indlæg, sider, kategorier og tags url'er er ikke ændret."
|
493 |
-
|
494 |
-
#: admin/view-tab-settings.php:51
|
495 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
496 |
-
msgstr "Sproget er sat fra mappenavet i pæne permalinks"
|
497 |
-
|
498 |
-
# @ polylang
|
499 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
500 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
501 |
-
msgid "Example:"
|
502 |
-
msgstr "Eksempel:"
|
503 |
-
|
504 |
-
#: admin/view-tab-settings.php:60
|
505 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
506 |
-
msgstr "Sproget er sat fra subdomæne navnet i pæne permalinks"
|
507 |
-
|
508 |
-
# @ polylang
|
509 |
-
#: admin/view-tab-settings.php:69
|
510 |
-
msgid "The language is set from different domains"
|
511 |
-
msgstr "Sproget er indstillet fra forskellige domæner"
|
512 |
-
|
513 |
-
#: admin/view-tab-settings.php:107
|
514 |
-
msgid "Remove /language/ in pretty permalinks"
|
515 |
-
msgstr "Fjern /language/ i pæne permalinks"
|
516 |
-
|
517 |
-
#: admin/view-tab-settings.php:116
|
518 |
-
msgid "Keep /language/ in pretty permalinks"
|
519 |
-
msgstr "Behold /language/ i pæne permalinks"
|
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 |
-
"Forside url'en indeholder sprogkoden, istedet for sidenavn eller side id"
|
528 |
-
|
529 |
-
# @ polylang
|
530 |
-
#: admin/view-tab-settings.php:139
|
531 |
-
#, php-format
|
532 |
-
msgid "Example: %s instead of %s"
|
533 |
-
msgstr "Eksempel: %s istedet for %s"
|
534 |
-
|
535 |
-
#: admin/admin-model.php:38
|
536 |
-
msgid "Impossible to add the language."
|
537 |
-
msgstr "Umuligt at tilføje sproget."
|
538 |
-
|
539 |
-
# @ polylang
|
540 |
-
#: admin/admin-model.php:66
|
541 |
-
msgid "Language added."
|
542 |
-
msgstr "Sprog tilføjet."
|
543 |
-
|
544 |
-
# @ polylang
|
545 |
-
#: admin/admin-model.php:146
|
546 |
-
msgid "Language deleted."
|
547 |
-
msgstr "Sprog slettet."
|
548 |
-
|
549 |
-
# @ polylang
|
550 |
-
#: admin/admin-model.php:227
|
551 |
-
msgid "Language updated."
|
552 |
-
msgstr "Sprog opdateret"
|
553 |
-
|
554 |
-
# @ polylang
|
555 |
-
#: admin/settings.php:239
|
556 |
-
msgid "Translations updated."
|
557 |
-
msgstr "Oversættelser opdateret."
|
558 |
-
|
559 |
-
#: admin/view-tab-lang.php:72
|
560 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
561 |
-
msgstr "Sprogcode - helst 2-ords ISO 639-1 (eksempel: dk)"
|
562 |
-
|
563 |
-
# @ polylang
|
564 |
-
#: admin/admin-filters.php:203
|
565 |
-
msgid "The chosen static front page must be translated in all languages."
|
566 |
-
msgstr "Den valgte statiske forside skal oversættes i alle sprog."
|
567 |
-
|
568 |
-
#: admin/admin-strings.php:60
|
569 |
-
msgid "Widget text"
|
570 |
-
msgstr "Widget tekst"
|
571 |
-
|
572 |
-
# @ polylang
|
573 |
-
#: admin/settings.php:52
|
574 |
-
msgid "Recommended plugins"
|
575 |
-
msgstr "Anbefalede plugins"
|
576 |
-
|
577 |
-
# @ polylang
|
578 |
-
#: admin/view-tab-settings.php:51
|
579 |
-
msgid "The language is set from the code in the URL"
|
580 |
-
msgstr "Sproget er sat fra koden i URL'en"
|
581 |
-
|
582 |
-
# @ polylang
|
583 |
-
#: include/switcher.php:26
|
584 |
-
msgid "Hides languages with no translation"
|
585 |
-
msgstr "Skjuler sprog uden oversættelse"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-el.mo
DELETED
Binary file
|
languages/polylang-el.po
DELETED
@@ -1,675 +0,0 @@
|
|
1 |
-
# Theodotos Andreou <theo@ubuntucy.org>, 2012, 2013, 2014, 2015.
|
2 |
-
msgid ""
|
3 |
-
msgstr ""
|
4 |
-
"Project-Id-Version: polylang\n"
|
5 |
-
"Report-Msgid-Bugs-To: \n"
|
6 |
-
"POT-Creation-Date: \n"
|
7 |
-
"PO-Revision-Date: 2015-02-15 15:36+0300\n"
|
8 |
-
"Last-Translator: Theodotos Andreou <theo@ubuntucy.org>\n"
|
9 |
-
"Language-Team: Cyprus Ubuntu Loco Team\n"
|
10 |
-
"Language: el\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 παρέχει εκτενή %sτεκμηρίωση%s (μόνο στα Αγγλικά). Περιέχει "
|
33 |
-
"πληροφορίες πως να ρυθμίσετε τον πολυγλωσσικό σας ιστοτόπο και να τον "
|
34 |
-
"χρησιμοποιήσετε σε καθημερινή βάση, λίστα συχνών ερωτήσεων (FAQ), καθώς και "
|
35 |
-
"τεκμηρίωση για προγραμματιστές για προσαρμογή των προσθέτων και θεμάτων τους."
|
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 |
-
"Θα βρείτε επίσης χρήσιμες πληροφορίες στο %sφόρουμ%s υποστήριξης. Μην "
|
45 |
-
"παραλείψετε να ψάξετε πρώτα αν έχει απαντηθεί το ερώτημα σας πριν ανοίξετε "
|
46 |
-
"καινούργιο θέμα."
|
47 |
-
|
48 |
-
# @ polylang
|
49 |
-
#: admin/view-about.php:16
|
50 |
-
#, php-format
|
51 |
-
msgid ""
|
52 |
-
"Polylang is free of charge and is released under the same license as "
|
53 |
-
"WordPress, the %sGPL%s."
|
54 |
-
msgstr ""
|
55 |
-
"Το Polylang είναι δωρεάν και διανέμεται κάτω από την ίδια άδεια χρήσης όπως "
|
56 |
-
"και το WordPress, την %sΓενική Άδεια Χρήσης - GPL%s."
|
57 |
-
|
58 |
-
# @ polylang
|
59 |
-
#: admin/view-about.php:22
|
60 |
-
#, php-format
|
61 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
62 |
-
msgstr "Αν θέλετε να βοηθήσετε, απλά, %sδιαβάστε εδώ%s."
|
63 |
-
|
64 |
-
# @ polylang
|
65 |
-
#: admin/view-about.php:27
|
66 |
-
msgid ""
|
67 |
-
"Finally if you like this plugin or if it helps your business, donations to "
|
68 |
-
"the author are greatly appreciated."
|
69 |
-
msgstr ""
|
70 |
-
"Τέλος αν σας αρέσει αυτό το πρόσθετο ή αν σας βοηθά στην επιχείρηση σας, οι "
|
71 |
-
"δωρεές στο δημιουργό θα εκτιμηθούν ιδιαίτερα. "
|
72 |
-
|
73 |
-
# @ polylang
|
74 |
-
#: admin/admin-filters-post.php:115 admin/admin.php:90 admin/settings.php:70
|
75 |
-
#: admin/settings.php:97 include/model.php:561
|
76 |
-
msgid "Languages"
|
77 |
-
msgstr "Γλώσσες"
|
78 |
-
|
79 |
-
# @ polylang
|
80 |
-
#: include/switcher.php:22
|
81 |
-
msgid "Displays language names"
|
82 |
-
msgstr "Εμφάνιση ονομάτων γλώσσας"
|
83 |
-
|
84 |
-
# @ polylang
|
85 |
-
#: include/switcher.php:23
|
86 |
-
msgid "Displays flags"
|
87 |
-
msgstr "Εμφάνιση σημαιών"
|
88 |
-
|
89 |
-
# @ polylang
|
90 |
-
#: include/switcher.php:24
|
91 |
-
msgid "Forces link to front page"
|
92 |
-
msgstr "Υποχρεωτική παραπομπή συνδέσμου στην αρχική σελίδα"
|
93 |
-
|
94 |
-
# @ polylang
|
95 |
-
#: include/switcher.php:25
|
96 |
-
msgid "Hides the current language"
|
97 |
-
msgstr "Απόκρυψη τρέχουσας γλώσσας"
|
98 |
-
|
99 |
-
# @ polylang
|
100 |
-
#: include/switcher.php:30
|
101 |
-
msgid "Displays as dropdown"
|
102 |
-
msgstr "Εμφάνιση σαν κυλιόμενο μενού"
|
103 |
-
|
104 |
-
# @ polylang
|
105 |
-
#: admin/admin.php:267
|
106 |
-
msgid "Filters content by language"
|
107 |
-
msgstr "Φιλτράρισμα περιεχομένου βάση γλώσσας"
|
108 |
-
|
109 |
-
# @ polylang
|
110 |
-
#: admin/admin.php:258
|
111 |
-
msgid "Show all languages"
|
112 |
-
msgstr "Εμφάνιση όλων των γλωσσών"
|
113 |
-
|
114 |
-
# @ polylang
|
115 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
116 |
-
msgid "Add new translation"
|
117 |
-
msgstr "Προσθήκη νέας μετάφρασης"
|
118 |
-
|
119 |
-
# @ polylang
|
120 |
-
#: admin/admin-filters-columns.php:173 admin/admin-filters-media.php:55
|
121 |
-
#: admin/admin-filters-post.php:141 admin/admin-filters-term.php:75
|
122 |
-
#: admin/admin-filters-term.php:122 include/model.php:562
|
123 |
-
msgid "Language"
|
124 |
-
msgstr "Γλώσσα"
|
125 |
-
|
126 |
-
# @ polylang
|
127 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
128 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
129 |
-
#: admin/view-translations-term.php:11
|
130 |
-
msgid "Translations"
|
131 |
-
msgstr "Μεταφράσεις"
|
132 |
-
|
133 |
-
# @ polylang
|
134 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
135 |
-
msgid "Sets the language"
|
136 |
-
msgstr "Ορισμός γλώσσας"
|
137 |
-
|
138 |
-
# @ polylang
|
139 |
-
#: admin/admin-filters.php:52
|
140 |
-
msgid "The widget is displayed for:"
|
141 |
-
msgstr "Η μονάδα εμφανίζεται για:"
|
142 |
-
|
143 |
-
# @ polylang
|
144 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
145 |
-
msgid "All languages"
|
146 |
-
msgstr "Όλες οι γλώσσες"
|
147 |
-
|
148 |
-
# @ polylang
|
149 |
-
#: admin/admin-filters.php:123
|
150 |
-
msgid "Admin language"
|
151 |
-
msgstr "Γλώσσα διαχείρισης"
|
152 |
-
|
153 |
-
#: admin/admin-filters.php:126
|
154 |
-
msgid "WordPress default"
|
155 |
-
msgstr "Προκαθορισμένο σε WordPress"
|
156 |
-
|
157 |
-
# @ default
|
158 |
-
# @ polylang
|
159 |
-
#: admin/admin.php:167 admin/settings.php:102
|
160 |
-
msgid "Settings"
|
161 |
-
msgstr "Ρυθμίσεις"
|
162 |
-
|
163 |
-
# @ polylang
|
164 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
165 |
-
msgid "Upgrading language files…"
|
166 |
-
msgstr "Αναβάθμιση αρχείων γλώσσας…"
|
167 |
-
|
168 |
-
# @ polylang
|
169 |
-
#: admin/settings.php:62
|
170 |
-
msgid "About Polylang"
|
171 |
-
msgstr "Σχετικά με το Polylang"
|
172 |
-
|
173 |
-
# @ polylang
|
174 |
-
#: admin/settings.php:78
|
175 |
-
msgid "Strings translations"
|
176 |
-
msgstr "Μετάφραση συμβολοσειρών"
|
177 |
-
|
178 |
-
# @ polylang
|
179 |
-
#: admin/settings.php:101
|
180 |
-
msgid "Strings translation"
|
181 |
-
msgstr "Μετάφραση συμβολοσειρών"
|
182 |
-
|
183 |
-
# @ polylang
|
184 |
-
#: admin/admin-model.php:244
|
185 |
-
msgid "Enter a valid WordPress locale"
|
186 |
-
msgstr "Εισάγετε μια έγκυρη τοπικοποίηση WordPress"
|
187 |
-
|
188 |
-
# @ polylang
|
189 |
-
#: admin/admin-model.php:252
|
190 |
-
msgid "The language code must be unique"
|
191 |
-
msgstr "Ο κώδικας γλώσσας θα πρέπει να είναι μοναδικός"
|
192 |
-
|
193 |
-
# @ polylang
|
194 |
-
#: admin/admin-model.php:256
|
195 |
-
msgid "The language must have a name"
|
196 |
-
msgstr "Η γλώσσα πρέπει να έχει όνομα"
|
197 |
-
|
198 |
-
# @ polylang
|
199 |
-
#: admin/admin.php:367 admin/settings.php:180
|
200 |
-
msgid ""
|
201 |
-
"The language was created, but the WordPress language file was not "
|
202 |
-
"downloaded. Please install it manually."
|
203 |
-
msgstr ""
|
204 |
-
"Η γλώσσα δημιουργήθηκε αλλά το αρχείο γλώσσας του WordPress δεν έχει "
|
205 |
-
"κατέβει. Παρακαλώ εγκαταστήστε το εσείς."
|
206 |
-
|
207 |
-
# @ polylang
|
208 |
-
#: admin/admin-strings.php:59
|
209 |
-
msgid "Widget title"
|
210 |
-
msgstr "Τίτλος μονάδας"
|
211 |
-
|
212 |
-
# @ polylang
|
213 |
-
#: admin/settings.php:319
|
214 |
-
msgid "Taxonomies"
|
215 |
-
msgstr "Ταξινομήσεις"
|
216 |
-
|
217 |
-
# @ polylang
|
218 |
-
#: admin/settings.php:320
|
219 |
-
msgid "Custom fields"
|
220 |
-
msgstr "Προσαρμοσμένα πεδία"
|
221 |
-
|
222 |
-
# @ polylang
|
223 |
-
#: admin/settings.php:321
|
224 |
-
msgid "Comment status"
|
225 |
-
msgstr "Κατάσταση σχολίου"
|
226 |
-
|
227 |
-
# @ polylang
|
228 |
-
#: admin/settings.php:322
|
229 |
-
msgid "Ping status"
|
230 |
-
msgstr "Κατάσταση ping"
|
231 |
-
|
232 |
-
# @ polylang
|
233 |
-
#: admin/settings.php:323
|
234 |
-
msgid "Sticky posts"
|
235 |
-
msgstr "Μόνιμα άρθρα"
|
236 |
-
|
237 |
-
# @ polylang
|
238 |
-
#: admin/settings.php:324
|
239 |
-
msgid "Published date"
|
240 |
-
msgstr "Ημερομηνία δημοσίευσης"
|
241 |
-
|
242 |
-
# @ polylang
|
243 |
-
#: admin/settings.php:325
|
244 |
-
msgid "Post format"
|
245 |
-
msgstr "Μορφή άρθρου"
|
246 |
-
|
247 |
-
# @ default
|
248 |
-
#: admin/settings.php:326
|
249 |
-
msgid "Page parent"
|
250 |
-
msgstr "Μητρική σελίδα"
|
251 |
-
|
252 |
-
# @ polylang
|
253 |
-
#: admin/settings.php:327
|
254 |
-
msgid "Page template"
|
255 |
-
msgstr "Πρότυπο σελίδας"
|
256 |
-
|
257 |
-
# @ polylang
|
258 |
-
#: admin/settings.php:328
|
259 |
-
msgid "Page order"
|
260 |
-
msgstr "Διάταξη σελίδων"
|
261 |
-
|
262 |
-
# @ polylang
|
263 |
-
#: admin/settings.php:329
|
264 |
-
msgid "Featured image"
|
265 |
-
msgstr "Επιλεγμένη εικόνα"
|
266 |
-
|
267 |
-
# @ polylang
|
268 |
-
#: admin/view-tab-lang.php:21
|
269 |
-
msgid "Edit language"
|
270 |
-
msgstr "Επεξεργασία γλώσσας"
|
271 |
-
|
272 |
-
# @ polylang
|
273 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
274 |
-
msgid "Add new language"
|
275 |
-
msgstr "Προσθήκη νέας γλώσσας"
|
276 |
-
|
277 |
-
# @ polylang
|
278 |
-
#: admin/view-tab-lang.php:37
|
279 |
-
msgid "Choose a language"
|
280 |
-
msgstr "Επιλογή γλώσσας"
|
281 |
-
|
282 |
-
# @ polylang
|
283 |
-
#: admin/view-tab-lang.php:51
|
284 |
-
msgid "You can choose a language in the list or directly edit it below."
|
285 |
-
msgstr ""
|
286 |
-
"Μπορείτε να επιλέξετε μια γλώσσα από την λίστα ή να την επεξεργαστείτε πιο "
|
287 |
-
"κάτω."
|
288 |
-
|
289 |
-
# @ polylang
|
290 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
291 |
-
msgid "Full name"
|
292 |
-
msgstr "Πλήρες όνομα"
|
293 |
-
|
294 |
-
# @ polylang
|
295 |
-
#: admin/view-tab-lang.php:57
|
296 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
297 |
-
msgstr "Το όνομα καθορίζει πως θα εμφανίζεται στην σελίδα σας (πχ: Ελληνικά)."
|
298 |
-
|
299 |
-
# @ polylang
|
300 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
301 |
-
msgid "Locale"
|
302 |
-
msgstr "Τοπικοποίηση"
|
303 |
-
|
304 |
-
# @ polylang
|
305 |
-
#: admin/view-tab-lang.php:66
|
306 |
-
msgid ""
|
307 |
-
"WordPress Locale for the language (for example: en_US). You will need to "
|
308 |
-
"install the .mo file for this language."
|
309 |
-
msgstr ""
|
310 |
-
"Τοπικοποίηση WordPress για την γλώσσα (πχ: en_US). Θα χρειαστεί να "
|
311 |
-
"εγκαταστήσετε το αρχείο .mo για αυτή την γλώσσα."
|
312 |
-
|
313 |
-
# @ polylang
|
314 |
-
#: admin/view-tab-lang.php:70
|
315 |
-
msgid "Language code"
|
316 |
-
msgstr "Κώδικας γλώσσας"
|
317 |
-
|
318 |
-
# @ polylang
|
319 |
-
#: admin/view-tab-lang.php:76
|
320 |
-
msgid "Text direction"
|
321 |
-
msgstr "Κατεύθυνση κειμένου"
|
322 |
-
|
323 |
-
# @ polylang
|
324 |
-
#: admin/view-tab-lang.php:80
|
325 |
-
msgid "left to right"
|
326 |
-
msgstr "αριστερά προς δεξιά"
|
327 |
-
|
328 |
-
# @ polylang
|
329 |
-
#: admin/view-tab-lang.php:85
|
330 |
-
msgid "right to left"
|
331 |
-
msgstr "δεξιά προς αριστερά"
|
332 |
-
|
333 |
-
# @ polylang
|
334 |
-
#: admin/view-tab-lang.php:87
|
335 |
-
msgid "Choose the text direction for the language"
|
336 |
-
msgstr "Επιλογή κατεύθυνσης κειμένου για γλώσσα"
|
337 |
-
|
338 |
-
# @ polylang
|
339 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
340 |
-
msgid "Order"
|
341 |
-
msgstr "Εντολή"
|
342 |
-
|
343 |
-
# @ polylang
|
344 |
-
#: admin/view-tab-lang.php:93
|
345 |
-
msgid "Position of the language in the language switcher"
|
346 |
-
msgstr "Θέση της γλώσσας στον επιλογέα γλώσσας"
|
347 |
-
|
348 |
-
# @ polylang
|
349 |
-
#: admin/admin-nav-menu.php:54 admin/admin-nav-menu.php:92
|
350 |
-
#: admin/admin-nav-menu.php:95 admin/admin-nav-menu.php:126
|
351 |
-
#: admin/admin-nav-menu.php:188 install/upgrade.php:301
|
352 |
-
msgid "Language switcher"
|
353 |
-
msgstr "Επιλογέας γλώσσας"
|
354 |
-
|
355 |
-
# @ polylang
|
356 |
-
#: admin/view-tab-strings.php:8
|
357 |
-
msgid "Search translations"
|
358 |
-
msgstr "Αναζήτηση μεταφράσεων"
|
359 |
-
|
360 |
-
# @ polylang
|
361 |
-
#: admin/view-tab-strings.php:11
|
362 |
-
msgid "Clean strings translation database"
|
363 |
-
msgstr "Καθαρισμός βάσης δεδομένων συμβολοσειρών μετάφρασης"
|
364 |
-
|
365 |
-
# @ polylang
|
366 |
-
#: admin/view-tab-settings.php:14
|
367 |
-
msgid "Default language"
|
368 |
-
msgstr "Προκαθορισμένη γλώσσα"
|
369 |
-
|
370 |
-
# @ polylang
|
371 |
-
#: admin/view-tab-settings.php:29
|
372 |
-
msgid ""
|
373 |
-
"There are posts, pages, categories or tags without language set. Do you want "
|
374 |
-
"to set them all to default language ?"
|
375 |
-
msgstr ""
|
376 |
-
"Υπάρχουν άρθρα, σελίδες, κατηγορίες ή ετικέτες χωρίς καθορισμό γλώσσας. "
|
377 |
-
"Θέλετε να οριστούν όλα στην προκαθορισμένη γλώσσα;"
|
378 |
-
|
379 |
-
# @ polylang
|
380 |
-
#: admin/view-tab-settings.php:149
|
381 |
-
msgid "Detect browser language"
|
382 |
-
msgstr "Αναγνώριση γλώσσας φυλλομετρητή"
|
383 |
-
|
384 |
-
# @ polylang
|
385 |
-
#: admin/view-tab-settings.php:155
|
386 |
-
msgid ""
|
387 |
-
"When the front page is visited, set the language according to the browser "
|
388 |
-
"preference"
|
389 |
-
msgstr ""
|
390 |
-
"Όταν καλείται η αρχική σελίδα, να καθορίζεται η γλώσσα βάση των προτιμήσεων "
|
391 |
-
"του φυλλομετρητή"
|
392 |
-
|
393 |
-
# @ polylang
|
394 |
-
#: admin/view-tab-settings.php:37
|
395 |
-
msgid "URL modifications"
|
396 |
-
msgstr "Τροποποιήσεις URL"
|
397 |
-
|
398 |
-
# @ polylang
|
399 |
-
#: admin/view-tab-settings.php:93
|
400 |
-
msgid "Hide URL language information for default language"
|
401 |
-
msgstr ""
|
402 |
-
"Απόκρυψη των πληροφοριών γλώσσας από URL, για την προκαθορισμένη γλώσσα"
|
403 |
-
|
404 |
-
# @ polylang
|
405 |
-
#: admin/view-tab-settings.php:162
|
406 |
-
msgid "Media"
|
407 |
-
msgstr "Μέσα"
|
408 |
-
|
409 |
-
# @ polylang
|
410 |
-
#: admin/view-tab-settings.php:168
|
411 |
-
msgid "Activate languages and translations for media"
|
412 |
-
msgstr "Ενεργοποίηση γλωσσών και μεταφράσεων για μέσο"
|
413 |
-
|
414 |
-
#: admin/view-tab-settings.php:215
|
415 |
-
msgid "Synchronization"
|
416 |
-
msgstr "Συγχρονισμός"
|
417 |
-
|
418 |
-
# @ polylang
|
419 |
-
#: admin/view-tab-settings.php:176
|
420 |
-
msgid "Custom post types"
|
421 |
-
msgstr "Ειδικοί τύποι άρθρων"
|
422 |
-
|
423 |
-
# @ polylang
|
424 |
-
#: admin/view-tab-settings.php:189
|
425 |
-
msgid "Activate languages and translations for custom post types."
|
426 |
-
msgstr "Ενεργοποίηση γλωσσών και μεταφράσεων για ειδικούς τύπους άρθρων"
|
427 |
-
|
428 |
-
# @ polylang
|
429 |
-
#: admin/view-tab-settings.php:196
|
430 |
-
msgid "Custom taxonomies"
|
431 |
-
msgstr "Ειδικές ταξινομίσεις"
|
432 |
-
|
433 |
-
# @ polylang
|
434 |
-
#: admin/view-tab-settings.php:209
|
435 |
-
msgid "Activate languages and translations for custom taxonomies."
|
436 |
-
msgstr "Ενεργοποίηση γλωσσών και μεταφράσεων για ειδικές ταξινομίσεις"
|
437 |
-
|
438 |
-
# @ polylang
|
439 |
-
#: admin/admin-filters-post.php:433 admin/admin-filters-term.php:642
|
440 |
-
#: admin/table-languages.php:54 admin/view-translations-media.php:21
|
441 |
-
msgid "Edit"
|
442 |
-
msgstr "Επεξεργασία"
|
443 |
-
|
444 |
-
# @ polylang
|
445 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
446 |
-
msgid "Delete"
|
447 |
-
msgstr "Διαγραφή"
|
448 |
-
|
449 |
-
# @ polylang
|
450 |
-
#: admin/table-languages.php:76
|
451 |
-
msgid "Code"
|
452 |
-
msgstr "Κώδικας"
|
453 |
-
|
454 |
-
# @ polylang
|
455 |
-
#: admin/table-languages.php:78
|
456 |
-
msgid "Flag"
|
457 |
-
msgstr "Σημαία"
|
458 |
-
|
459 |
-
# @ polylang
|
460 |
-
#: admin/table-languages.php:79
|
461 |
-
msgid "Posts"
|
462 |
-
msgstr "Άρθρα"
|
463 |
-
|
464 |
-
# @ polylang
|
465 |
-
#: admin/table-string.php:110
|
466 |
-
msgid "Name"
|
467 |
-
msgstr "Όνομα"
|
468 |
-
|
469 |
-
# @ polylang
|
470 |
-
#: admin/table-string.php:111
|
471 |
-
msgid "String"
|
472 |
-
msgstr "Συμβολοσειρά"
|
473 |
-
|
474 |
-
# @ polylang
|
475 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
476 |
-
#: admin/view-translations-term.php:30
|
477 |
-
msgid "Add new"
|
478 |
-
msgstr "Προσθήκη νέου"
|
479 |
-
|
480 |
-
# @ polylang
|
481 |
-
#: include/widget-languages.php:16
|
482 |
-
msgid "Language Switcher"
|
483 |
-
msgstr "Επιλογέας γλώσσας"
|
484 |
-
|
485 |
-
# @ polylang
|
486 |
-
#: include/widget-languages.php:16
|
487 |
-
msgid "Displays a language switcher"
|
488 |
-
msgstr "Εμφάνιση επιλογέα γλώσσας"
|
489 |
-
|
490 |
-
# @ polylang
|
491 |
-
#: include/widget-languages.php:75
|
492 |
-
msgid "Title:"
|
493 |
-
msgstr "Τίτλος:"
|
494 |
-
|
495 |
-
# @ polylang
|
496 |
-
#. translators: plugin header field 'Description'
|
497 |
-
#: polylang.php:0
|
498 |
-
msgid "Adds multilingual capability to WordPress"
|
499 |
-
msgstr "Προσθέτει πολυγλωσσική δυνατότητα στο WordPress"
|
500 |
-
|
501 |
-
# @ polylang
|
502 |
-
#: install/install.php:24
|
503 |
-
#, php-format
|
504 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
505 |
-
msgstr ""
|
506 |
-
"Χρησιμοποιείτε WordPress %s. Το Polylang χρειάζεται τουλάχιστον 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 έχει απενεργοποιηθεί γιατί αναβαθμίσατε από πολύ παλιά έκδοση."
|
514 |
-
|
515 |
-
# @ polylang
|
516 |
-
#: install/upgrade.php:78
|
517 |
-
#, php-format
|
518 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
519 |
-
msgstr "Παρακαλώ αναβαθμίστε πρώτα σε %s πριν αναβαθμίσετε σε %s"
|
520 |
-
|
521 |
-
# @ polylang
|
522 |
-
#: admin/table-string.php:109
|
523 |
-
msgid "Group"
|
524 |
-
msgstr "Ομάδα"
|
525 |
-
|
526 |
-
# @ polylang
|
527 |
-
#: admin/table-string.php:187
|
528 |
-
msgid "View all groups"
|
529 |
-
msgstr "Προβολή όλων των ομάδων"
|
530 |
-
|
531 |
-
# @ polylang
|
532 |
-
#: admin/table-languages.php:59
|
533 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
534 |
-
msgstr ""
|
535 |
-
"Πρόκειται να διαγράψετε οριστικά αυτή τη γλώσσα. Είστε σίγουροι για αυτό;"
|
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 |
-
"Χρησιμοποιείστε αυτό για να αφαιρέσετε αχρησιμοποίητες συμβολοσειρές από την "
|
544 |
-
"βάση δεδομένων, για παράδειγμα μετά την αφαίρεση κάποιου πρόσθετου."
|
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 |
-
"Η επιλογές συγχρονισμού επιτρέπουν την διατήρηση των ίδιων ακριβώς τιμών (ή "
|
554 |
-
"μεταφράσεων στην περίπτωση ταξονομιών και μητρικών σελίδων) μετα- "
|
555 |
-
"περιεχομένου μεταξύ των μεταφράσεων ενός άρθρου ή μιας σελίδας. "
|
556 |
-
|
557 |
-
# @ polylang
|
558 |
-
#: admin/admin-model.php:248
|
559 |
-
msgid "The language code contains invalid characters"
|
560 |
-
msgstr "Το όνομα του κώδικα γλώσσας περιέχει μη έγκυρους χαρακτήρες."
|
561 |
-
|
562 |
-
# @ polylang
|
563 |
-
#: admin/view-tab-settings.php:43
|
564 |
-
msgid "The language is set from content"
|
565 |
-
msgstr "Η γλώσσα ορίζεται μέσω περιεχομένου"
|
566 |
-
|
567 |
-
# @ polylang
|
568 |
-
#: admin/view-tab-settings.php:46
|
569 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
570 |
-
msgstr ""
|
571 |
-
"Δεν έχουν αλλαχθεί, άρθρα, σελίδες, κατηγορίες ή ετικέτες διευθύνσεων URL"
|
572 |
-
|
573 |
-
# @ polylang
|
574 |
-
#: admin/view-tab-settings.php:51
|
575 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
576 |
-
msgstr ""
|
577 |
-
"Η γλώσσα ορίζεται από το όνομα καταλόγου σε κομψούς μόνιμους συνδέσμους"
|
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 "Παράδειγμα:"
|
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 "Η γλώσσα ορίζεται από τον υπο-τομέα σε κομψούς μόνιμους συνδέσμους"
|
589 |
-
|
590 |
-
# @ polylang
|
591 |
-
#: admin/view-tab-settings.php:69
|
592 |
-
msgid "The language is set from different domains"
|
593 |
-
msgstr "Η γλώσσα ορίζεται από διαφορετικούς τομείς"
|
594 |
-
|
595 |
-
# @ polylang
|
596 |
-
#: admin/view-tab-settings.php:107
|
597 |
-
msgid "Remove /language/ in pretty permalinks"
|
598 |
-
msgstr "Αφαίρεση /language/ από μόνιμους συνδέσμους"
|
599 |
-
|
600 |
-
# @ polylang
|
601 |
-
#: admin/view-tab-settings.php:116
|
602 |
-
msgid "Keep /language/ in pretty permalinks"
|
603 |
-
msgstr "Διατήρηση /language/ σε μόνιμους συνδέσμους"
|
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 |
-
"Ο κώδικας γλώσσας να περιέχεται στη διεύθυνση της αρχικής σελίδας αντί στο "
|
612 |
-
"όνομα τη ταυτότητα της σελίδας"
|
613 |
-
|
614 |
-
# @ polylang
|
615 |
-
#: admin/view-tab-settings.php:139
|
616 |
-
#, php-format
|
617 |
-
msgid "Example: %s instead of %s"
|
618 |
-
msgstr "Παράδειγμα: %s αντί %s"
|
619 |
-
|
620 |
-
# @ polylang
|
621 |
-
#: admin/admin-model.php:38
|
622 |
-
msgid "Impossible to add the language."
|
623 |
-
msgstr "Αδυναμία προσθήκης γλώσσας."
|
624 |
-
|
625 |
-
# @ polylang
|
626 |
-
#: admin/admin-model.php:66
|
627 |
-
msgid "Language added."
|
628 |
-
msgstr "Η γλώσσα προστέθηκε"
|
629 |
-
|
630 |
-
# @ polylang
|
631 |
-
#: admin/admin-model.php:146
|
632 |
-
msgid "Language deleted."
|
633 |
-
msgstr "Η γλώσσα διαγράφηκε."
|
634 |
-
|
635 |
-
# @ polylang
|
636 |
-
#: admin/admin-model.php:227
|
637 |
-
msgid "Language updated."
|
638 |
-
msgstr "Η γλώσσα ενημερώθηκε."
|
639 |
-
|
640 |
-
# @ polylang
|
641 |
-
#: admin/settings.php:239
|
642 |
-
msgid "Translations updated."
|
643 |
-
msgstr "Η μεταφράσεις ενημερώθηκαν."
|
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 |
-
"Κώδικας γλώσσας - κατά προτίμηση 2 γράμματα ISO 631-1 (για παράδειγμα: el)"
|
650 |
-
|
651 |
-
# @ polylang
|
652 |
-
#: admin/admin-filters.php:203
|
653 |
-
msgid "The chosen static front page must be translated in all languages."
|
654 |
-
msgstr ""
|
655 |
-
"Η επιλεγμένη στατική πρώτη σελίδα πρέπει να μεταφραστεί σε όλες τις γλώσσες"
|
656 |
-
|
657 |
-
# @ polylang
|
658 |
-
#: admin/admin-strings.php:60
|
659 |
-
msgid "Widget text"
|
660 |
-
msgstr "Κείμενο μονάδας"
|
661 |
-
|
662 |
-
# @ polylang
|
663 |
-
#: admin/settings.php:52
|
664 |
-
msgid "Recommended plugins"
|
665 |
-
msgstr "Προτεινόμενα πρόσθετα"
|
666 |
-
|
667 |
-
# @ polylang
|
668 |
-
#: admin/view-tab-settings.php:51
|
669 |
-
msgid "The language is set from the code in the URL"
|
670 |
-
msgstr "Η γλώσσα ορίζεται από τον κώδικα στην διεύθυνση URL"
|
671 |
-
|
672 |
-
# @ polylang
|
673 |
-
#: include/switcher.php:26
|
674 |
-
msgid "Hides languages with no translation"
|
675 |
-
msgstr "Απόκρυψη γλωσσών χωρίς μετάφραση"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-fr_FR.mo
DELETED
Binary file
|
languages/polylang-fr_FR.po
DELETED
@@ -1,701 +0,0 @@
|
|
1 |
-
# Translation of Stable (latest release) in French (France)
|
2 |
-
# This file is distributed under the same license as the Stable (latest release) package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"PO-Revision-Date: 2015-10-22 12:06:37+0000\n"
|
6 |
-
"MIME-Version: 1.0\n"
|
7 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
-
"Content-Transfer-Encoding: 8bit\n"
|
9 |
-
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
10 |
-
"X-Generator: GlotPress/1.0-alpha-1100\n"
|
11 |
-
"Project-Id-Version: Stable (latest release)\n"
|
12 |
-
|
13 |
-
#: lingotek/lingotek.php:85
|
14 |
-
msgid "Activated"
|
15 |
-
msgstr "Activé"
|
16 |
-
|
17 |
-
#: lingotek/lingotek.php:85
|
18 |
-
msgid "Activate"
|
19 |
-
msgstr "Activer"
|
20 |
-
|
21 |
-
#: lingotek/lingotek.php:90
|
22 |
-
msgid "Request Translation"
|
23 |
-
msgstr "Demande de traduction"
|
24 |
-
|
25 |
-
#: lingotek/lingotek.php:96
|
26 |
-
msgid "Request Services"
|
27 |
-
msgstr "Demande de services"
|
28 |
-
|
29 |
-
#: lingotek/lingotek.php:103
|
30 |
-
msgid "Polylang is now fully integrated with Lingotek, a professional translation management system!"
|
31 |
-
msgstr "Polylang est maintenant entièrement compatible avec Lingotek, un système professionnel de gestion de traduction."
|
32 |
-
|
33 |
-
#: lingotek/lingotek.php:106
|
34 |
-
msgid "Automatically Translate My Site"
|
35 |
-
msgstr "Traduire automatiquement mon site"
|
36 |
-
|
37 |
-
#: lingotek/lingotek.php:107
|
38 |
-
msgid "Polylang is now fully integrated with Lingotek!"
|
39 |
-
msgstr "Polylang est maintenant entièrement compatible avec Lingotek !"
|
40 |
-
|
41 |
-
#: lingotek/lingotek.php:109 lingotek/lingotek.php:120
|
42 |
-
msgid "Access free machine translation for your site for up to 100,000 characters."
|
43 |
-
msgstr "Accédez gratuitement à la machine de traduction automatique pour votre site jusqu'à 100 000 caractères."
|
44 |
-
|
45 |
-
#: lingotek/lingotek.php:110
|
46 |
-
msgid "Machine translation is an excellent option if you're on a tight budget, looking for near-instant results, and are okay with less-than-perfect quality."
|
47 |
-
msgstr "La machine de traduction est une excellente option si vous avez un budget serré, êtes à la recherche de résultats quasi immédiat et ok avec une qualité un peu moins que parfaite."
|
48 |
-
|
49 |
-
#: lingotek/lingotek.php:117
|
50 |
-
msgid "Translation Management System"
|
51 |
-
msgstr "Système de gestion de traduction"
|
52 |
-
|
53 |
-
#: lingotek/lingotek.php:118
|
54 |
-
msgid "Do you need to connect to a professional translation management system?"
|
55 |
-
msgstr "Avez-vous besoin d’être connecté à un système de gestion professionnel de traduction ?"
|
56 |
-
|
57 |
-
#: lingotek/lingotek.php:121
|
58 |
-
msgid "Access an online translator workbench."
|
59 |
-
msgstr "Accédez à notre workbench de traducteurs en ligne."
|
60 |
-
|
61 |
-
#: lingotek/lingotek.php:122
|
62 |
-
msgid "Have linguists compare side-by-side versions of original and translated text."
|
63 |
-
msgstr ""
|
64 |
-
|
65 |
-
#: lingotek/lingotek.php:123
|
66 |
-
msgid "Save and re-use previously translated material (leverage translation memory (TM))."
|
67 |
-
msgstr ""
|
68 |
-
|
69 |
-
#: lingotek/lingotek.php:130
|
70 |
-
msgid "Professionally Translate My Site"
|
71 |
-
msgstr "Traduire professionnellement mon site"
|
72 |
-
|
73 |
-
#: lingotek/lingotek.php:131
|
74 |
-
msgid "Do you need to professionally translate your site?"
|
75 |
-
msgstr "Avez-vous besoin de professionnels pour traduire votre site ?"
|
76 |
-
|
77 |
-
#: lingotek/lingotek.php:133
|
78 |
-
msgid "Start the process of getting a professional translation bid."
|
79 |
-
msgstr ""
|
80 |
-
|
81 |
-
#: lingotek/lingotek.php:134
|
82 |
-
msgid "Activate account so Lingotek can get an accurate count of how many words you have on your site and which languages you wish to translate into."
|
83 |
-
msgstr ""
|
84 |
-
|
85 |
-
#: lingotek/lingotek.php:135
|
86 |
-
msgid "Once activated click on the request translation bid and a certified translation project manager will contact you to give a no obligations translation bid."
|
87 |
-
msgstr ""
|
88 |
-
|
89 |
-
#: lingotek/lingotek.php:142
|
90 |
-
msgid "Need Extra Services?"
|
91 |
-
msgstr "Besoin de services supplémentaires ?"
|
92 |
-
|
93 |
-
#: lingotek/lingotek.php:143
|
94 |
-
msgid "Do you need help translating your site?"
|
95 |
-
msgstr "Avez-vous besoin d'aide pour faire traduire votre site ?"
|
96 |
-
|
97 |
-
#: lingotek/lingotek.php:145
|
98 |
-
msgid "Start the process of getting extra services."
|
99 |
-
msgstr ""
|
100 |
-
|
101 |
-
#: lingotek/lingotek.php:146
|
102 |
-
msgid "Do you need someone to run your localization project?"
|
103 |
-
msgstr "Avez-vous besoin de quelqu'un pour gérer votre projet de localisation ?"
|
104 |
-
|
105 |
-
#: lingotek/lingotek.php:147
|
106 |
-
msgid "Do you need customized workflows?"
|
107 |
-
msgstr "Avez-vous besoin de workflows personnalisés ?"
|
108 |
-
|
109 |
-
#: lingotek/lingotek.php:148
|
110 |
-
msgid "Do you you have existing Translation Memories you would like to use?"
|
111 |
-
msgstr "Avez-vous déjà des Mémoires de Traduction que vous voulez réutiliser ?"
|
112 |
-
|
113 |
-
#: lingotek/lingotek.php:149
|
114 |
-
msgid "Do you need help creating glossaries and terminologies?"
|
115 |
-
msgstr ""
|
116 |
-
|
117 |
-
#: lingotek/lingotek.php:254
|
118 |
-
msgid "Learn more..."
|
119 |
-
msgstr "En savoir plus…"
|
120 |
-
|
121 |
-
#. Plugin Name of the plugin/theme
|
122 |
-
msgid "Polylang"
|
123 |
-
msgstr "Polylang"
|
124 |
-
|
125 |
-
#. Plugin URI of the plugin/theme
|
126 |
-
msgid "http://polylang.wordpress.com/"
|
127 |
-
msgstr "http://polylang.wordpress.com/"
|
128 |
-
|
129 |
-
#. Description of the plugin/theme
|
130 |
-
msgid "Adds multilingual capability to WordPress"
|
131 |
-
msgstr "Permet une utilisation multilingue de WordPress"
|
132 |
-
|
133 |
-
#. Author of the plugin/theme
|
134 |
-
msgid "Frédéric Demarle"
|
135 |
-
msgstr "Frédéric Demarle"
|
136 |
-
|
137 |
-
#. Author URI of the plugin/theme
|
138 |
-
msgid "http://polylang.wordpress.com"
|
139 |
-
msgstr "http://polylang.wordpress.com"
|
140 |
-
|
141 |
-
#: admin/admin-filters-columns.php:141 admin/admin-filters-columns.php:236
|
142 |
-
msgid "Add new translation"
|
143 |
-
msgstr "Ajouter une nouvelle traduction"
|
144 |
-
|
145 |
-
#: admin/admin-filters-columns.php:161
|
146 |
-
msgid "— No Change —"
|
147 |
-
msgstr "— Aucun changement —"
|
148 |
-
|
149 |
-
#: admin/admin-filters-columns.php:174 admin/admin-filters-media.php:55
|
150 |
-
#: admin/admin-filters-post.php:159 admin/admin-filters-term.php:85
|
151 |
-
#: admin/admin-filters-term.php:136 include/model.php:591
|
152 |
-
msgid "Language"
|
153 |
-
msgstr "Langue"
|
154 |
-
|
155 |
-
#: admin/admin-filters-post.php:133 admin/admin.php:96 admin/settings.php:70
|
156 |
-
#: admin/settings.php:97 include/model.php:590
|
157 |
-
msgid "Languages"
|
158 |
-
msgstr "Langues"
|
159 |
-
|
160 |
-
#: admin/admin-filters-post.php:239
|
161 |
-
msgid "(no parent)"
|
162 |
-
msgstr "(pas de parent)"
|
163 |
-
|
164 |
-
#: admin/admin-filters-post.php:474 admin/admin-filters-term.php:763
|
165 |
-
#: admin/table-languages.php:65 admin/view-translations-media.php:21
|
166 |
-
msgid "Edit"
|
167 |
-
msgstr "Modifier"
|
168 |
-
|
169 |
-
#: admin/admin-filters-term.php:92 admin/admin-filters-term.php:144
|
170 |
-
msgid "Sets the language"
|
171 |
-
msgstr "Définit la langue"
|
172 |
-
|
173 |
-
#: admin/admin-filters-term.php:454
|
174 |
-
msgid "None"
|
175 |
-
msgstr "Aucun"
|
176 |
-
|
177 |
-
#: admin/admin-filters.php:52
|
178 |
-
msgid "The widget is displayed for:"
|
179 |
-
msgstr "Afficher le widget pour :"
|
180 |
-
|
181 |
-
#: admin/admin-filters.php:55 include/model.php:592
|
182 |
-
msgid "All languages"
|
183 |
-
msgstr "Toutes les langues"
|
184 |
-
|
185 |
-
#: admin/admin-filters.php:123
|
186 |
-
msgid "Admin language"
|
187 |
-
msgstr "Langue pour l’interface d’administration"
|
188 |
-
|
189 |
-
#: admin/admin-filters.php:126
|
190 |
-
msgid "WordPress default"
|
191 |
-
msgstr "Langue par défaut de WordPress"
|
192 |
-
|
193 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
194 |
-
msgid "Upgrading language files…"
|
195 |
-
msgstr "Mise à jour des fichiers de langues…"
|
196 |
-
|
197 |
-
#: admin/admin-filters.php:203
|
198 |
-
msgid "The chosen static front page must be translated in all languages."
|
199 |
-
msgstr "La page d'accueil statique doit être traduite dans toutes les langues."
|
200 |
-
|
201 |
-
#: admin/admin-model.php:38
|
202 |
-
msgid "Impossible to add the language."
|
203 |
-
msgstr "Impossible d'ajouter la langue."
|
204 |
-
|
205 |
-
#: admin/admin-model.php:66
|
206 |
-
msgid "Language added."
|
207 |
-
msgstr "Langue ajoutée."
|
208 |
-
|
209 |
-
#: admin/admin-model.php:145
|
210 |
-
msgid "Language deleted."
|
211 |
-
msgstr "Langue supprimée."
|
212 |
-
|
213 |
-
#: admin/admin-model.php:224
|
214 |
-
msgid "Language updated."
|
215 |
-
msgstr "Langue mise à jour."
|
216 |
-
|
217 |
-
#: admin/admin-model.php:241
|
218 |
-
msgid "Enter a valid WordPress locale"
|
219 |
-
msgstr "Entrez un code local WordPress valide"
|
220 |
-
|
221 |
-
#: admin/admin-model.php:245
|
222 |
-
msgid "The language code contains invalid characters"
|
223 |
-
msgstr "Le code de la langue contient des caractères invalides"
|
224 |
-
|
225 |
-
#: admin/admin-model.php:249
|
226 |
-
msgid "The language code must be unique"
|
227 |
-
msgstr "Le code de la langue doit être unique"
|
228 |
-
|
229 |
-
#: admin/admin-model.php:254
|
230 |
-
msgid "The language must have a name"
|
231 |
-
msgstr "La langue doit avoir un nom"
|
232 |
-
|
233 |
-
#: admin/admin-nav-menu.php:52 admin/admin-nav-menu.php:73
|
234 |
-
#: admin/admin-nav-menu.php:76 admin/admin-nav-menu.php:107
|
235 |
-
#: admin/admin-nav-menu.php:169 install/upgrade.php:302
|
236 |
-
msgid "Language switcher"
|
237 |
-
msgstr "Liste des langues"
|
238 |
-
|
239 |
-
#: admin/admin-strings.php:54
|
240 |
-
msgid "Site Title"
|
241 |
-
msgstr "Titre du site"
|
242 |
-
|
243 |
-
#: admin/admin-strings.php:55
|
244 |
-
msgid "Tagline"
|
245 |
-
msgstr "Slogan"
|
246 |
-
|
247 |
-
#: admin/admin-strings.php:56
|
248 |
-
msgid "Date Format"
|
249 |
-
msgstr "Format de date"
|
250 |
-
|
251 |
-
#: admin/admin-strings.php:57
|
252 |
-
msgid "Time Format"
|
253 |
-
msgstr "Format d’heure"
|
254 |
-
|
255 |
-
#: admin/admin-strings.php:59
|
256 |
-
msgid "Widget title"
|
257 |
-
msgstr "Titre du widget"
|
258 |
-
|
259 |
-
#: admin/admin-strings.php:60
|
260 |
-
msgid "Widget text"
|
261 |
-
msgstr "Widget texte"
|
262 |
-
|
263 |
-
#: admin/admin.php:204 admin/settings.php:102
|
264 |
-
msgid "Settings"
|
265 |
-
msgstr "Réglages"
|
266 |
-
|
267 |
-
#: admin/admin.php:312
|
268 |
-
msgid "Show all languages"
|
269 |
-
msgstr "Afficher toutes les langues"
|
270 |
-
|
271 |
-
#: admin/admin.php:321
|
272 |
-
msgid "Filters content by language"
|
273 |
-
msgstr "Filtrer le contenu par langue"
|
274 |
-
|
275 |
-
#: admin/admin.php:419 admin/settings.php:183
|
276 |
-
msgid "The language was created, but the WordPress language file was not downloaded. Please install it manually."
|
277 |
-
msgstr "La langue a été créée, mais le fichier de langue WordPress n’a pu être téléchargé. Merci de l’installer manuellement."
|
278 |
-
|
279 |
-
#: admin/settings.php:52
|
280 |
-
msgid "Recommended plugins"
|
281 |
-
msgstr "Extensions recommandées"
|
282 |
-
|
283 |
-
#: admin/settings.php:62
|
284 |
-
msgid "About Polylang"
|
285 |
-
msgstr "À propos de Polylang"
|
286 |
-
|
287 |
-
#: admin/settings.php:78
|
288 |
-
msgid "Strings translations"
|
289 |
-
msgstr "Traductions des chaînes"
|
290 |
-
|
291 |
-
#: admin/settings.php:101
|
292 |
-
msgid "Strings translation"
|
293 |
-
msgstr "Traduction des chaînes"
|
294 |
-
|
295 |
-
#: admin/settings.php:242
|
296 |
-
msgid "Translations updated."
|
297 |
-
msgstr "Traductions mises à jour."
|
298 |
-
|
299 |
-
#: admin/settings.php:300
|
300 |
-
msgid "Settings saved."
|
301 |
-
msgstr "Réglages enregistrées."
|
302 |
-
|
303 |
-
#: admin/settings.php:321
|
304 |
-
msgid "Taxonomies"
|
305 |
-
msgstr "Taxinomies"
|
306 |
-
|
307 |
-
#: admin/settings.php:322
|
308 |
-
msgid "Custom fields"
|
309 |
-
msgstr "Champs personnalisés"
|
310 |
-
|
311 |
-
#: admin/settings.php:323
|
312 |
-
msgid "Comment status"
|
313 |
-
msgstr "Autorisation des commentaires"
|
314 |
-
|
315 |
-
#: admin/settings.php:324
|
316 |
-
msgid "Ping status"
|
317 |
-
msgstr "Autorisation des pings"
|
318 |
-
|
319 |
-
#: admin/settings.php:325
|
320 |
-
msgid "Sticky posts"
|
321 |
-
msgstr "Articles mis en avant"
|
322 |
-
|
323 |
-
#: admin/settings.php:326
|
324 |
-
msgid "Published date"
|
325 |
-
msgstr "Date de publication"
|
326 |
-
|
327 |
-
#: admin/settings.php:327
|
328 |
-
msgid "Post format"
|
329 |
-
msgstr "Format"
|
330 |
-
|
331 |
-
#: admin/settings.php:328
|
332 |
-
msgid "Page parent"
|
333 |
-
msgstr "Page parent"
|
334 |
-
|
335 |
-
#: admin/settings.php:329
|
336 |
-
msgid "Page template"
|
337 |
-
msgstr "Modèle de page"
|
338 |
-
|
339 |
-
#: admin/settings.php:330
|
340 |
-
msgid "Page order"
|
341 |
-
msgstr "Ordre des pages"
|
342 |
-
|
343 |
-
#: admin/settings.php:331
|
344 |
-
msgid "Featured image"
|
345 |
-
msgstr "Image à la Une"
|
346 |
-
|
347 |
-
#: admin/table-languages.php:70
|
348 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
349 |
-
msgstr "Êtes-vous sûr de vouloir supprimer cette langue définitivement ?"
|
350 |
-
|
351 |
-
#: admin/table-languages.php:71 admin/table-string.php:168
|
352 |
-
msgid "Delete"
|
353 |
-
msgstr "Supprimer"
|
354 |
-
|
355 |
-
#: admin/table-languages.php:85 admin/view-tab-lang.php:55
|
356 |
-
msgid "Full name"
|
357 |
-
msgstr "Nom"
|
358 |
-
|
359 |
-
#: admin/table-languages.php:86 admin/view-tab-lang.php:61
|
360 |
-
msgid "Locale"
|
361 |
-
msgstr "Code local"
|
362 |
-
|
363 |
-
#: admin/table-languages.php:87
|
364 |
-
msgid "Code"
|
365 |
-
msgstr "Code"
|
366 |
-
|
367 |
-
#: admin/table-languages.php:88 admin/view-tab-lang.php:91
|
368 |
-
msgid "Order"
|
369 |
-
msgstr "Ordre"
|
370 |
-
|
371 |
-
#: admin/table-languages.php:89
|
372 |
-
msgid "Flag"
|
373 |
-
msgstr "Drapeau"
|
374 |
-
|
375 |
-
#: admin/table-languages.php:90
|
376 |
-
msgid "Posts"
|
377 |
-
msgstr "Articles"
|
378 |
-
|
379 |
-
#: admin/table-string.php:109
|
380 |
-
msgid "String"
|
381 |
-
msgstr "Chaîne"
|
382 |
-
|
383 |
-
#: admin/table-string.php:110
|
384 |
-
msgid "Name"
|
385 |
-
msgstr "Nom"
|
386 |
-
|
387 |
-
#: admin/table-string.php:111
|
388 |
-
msgid "Group"
|
389 |
-
msgstr "Groupe"
|
390 |
-
|
391 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
392 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
393 |
-
#: admin/view-translations-term.php:11
|
394 |
-
msgid "Translations"
|
395 |
-
msgstr "Traductions"
|
396 |
-
|
397 |
-
#: admin/table-string.php:187
|
398 |
-
msgid "View all groups"
|
399 |
-
msgstr "Voir tous les groupes"
|
400 |
-
|
401 |
-
#: admin/table-string.php:200
|
402 |
-
msgid "Filter"
|
403 |
-
msgstr "Filtre"
|
404 |
-
|
405 |
-
#: admin/view-about.php:3
|
406 |
-
msgid "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 programmers to adapt their plugins and themes."
|
407 |
-
msgstr "Polylang est fourni avec une %sdocumentation%s (en anglais). Elle explique comment installer votre site multilingue et l’utiliser au jour le jour. Elle contient aussi une FAQ et une documentation pour les développeurs leur permettant d’adapter leurs extensions et leurs thèmes."
|
408 |
-
|
409 |
-
#: admin/view-about.php:9
|
410 |
-
msgid "You will also find useful information in the %ssupport forum%s. However don't forget to make a search before posting a new topic."
|
411 |
-
msgstr "Vous pouvez aussi trouver des informations dans le %sforum de support%s (en anglais). Cependant, n’oubliez pas de faire une recherche avant de publier."
|
412 |
-
|
413 |
-
#: admin/view-about.php:16
|
414 |
-
msgid "Polylang is free of charge and is released under the same license as WordPress, the %sGPL%s."
|
415 |
-
msgstr "Polylang est gratuit et publié sous la même licence que WordPress, la %sGPL%s."
|
416 |
-
|
417 |
-
#: admin/view-about.php:22
|
418 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
419 |
-
msgstr "Si vous souhaitez aider le projet, %slisez ceci%s."
|
420 |
-
|
421 |
-
#: admin/view-about.php:27
|
422 |
-
msgid "Finally if you like this plugin or if it helps your business, donations to the author are greatly appreciated."
|
423 |
-
msgstr "Enfin, si vous aimez cette extension ou si elle vous aide dans votre business, vous pouvez faire un don à l’auteur."
|
424 |
-
|
425 |
-
#: admin/view-tab-lang.php:21
|
426 |
-
msgid "Edit language"
|
427 |
-
msgstr "Modifier la langue"
|
428 |
-
|
429 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:103
|
430 |
-
msgid "Add new language"
|
431 |
-
msgstr "Ajouter une nouvelle langue"
|
432 |
-
|
433 |
-
#: admin/view-tab-lang.php:37
|
434 |
-
msgid "Choose a language"
|
435 |
-
msgstr "Choisir une langue"
|
436 |
-
|
437 |
-
#: admin/view-tab-lang.php:51
|
438 |
-
msgid "You can choose a language in the list or directly edit it below."
|
439 |
-
msgstr "Choisissez une langue dans la liste ou modifiez-la directement ci-dessous."
|
440 |
-
|
441 |
-
#: admin/view-tab-lang.php:57
|
442 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
443 |
-
msgstr "Le nom est utilisé un peu partout sur le site (par exemple : Français)"
|
444 |
-
|
445 |
-
#: admin/view-tab-lang.php:66
|
446 |
-
msgid "WordPress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
|
447 |
-
msgstr "Code local utilisé par WordPress pour la langue (par exemple : fr_FR). Vous aurez besoin d’installer les fichiers .mo correspondant."
|
448 |
-
|
449 |
-
#: admin/view-tab-lang.php:70
|
450 |
-
msgid "Language code"
|
451 |
-
msgstr "Code de la langue"
|
452 |
-
|
453 |
-
#: admin/view-tab-lang.php:72
|
454 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
455 |
-
msgstr "Code de langue, de préférence code ISO 639-1 à 2 lettres (par exemple : fr)"
|
456 |
-
|
457 |
-
#: admin/view-tab-lang.php:76
|
458 |
-
msgid "Text direction"
|
459 |
-
msgstr "Système d’écriture"
|
460 |
-
|
461 |
-
#: admin/view-tab-lang.php:80
|
462 |
-
msgid "left to right"
|
463 |
-
msgstr "de gauche à droite"
|
464 |
-
|
465 |
-
#: admin/view-tab-lang.php:85
|
466 |
-
msgid "right to left"
|
467 |
-
msgstr "de droite à gauche"
|
468 |
-
|
469 |
-
#: admin/view-tab-lang.php:87
|
470 |
-
msgid "Choose the text direction for the language"
|
471 |
-
msgstr "Choisir le système d’écriture pour la langue"
|
472 |
-
|
473 |
-
#: admin/view-tab-lang.php:93
|
474 |
-
msgid "Position of the language in the language switcher"
|
475 |
-
msgstr "Position de la langue dans la liste de langues"
|
476 |
-
|
477 |
-
#: admin/view-tab-lang.php:103
|
478 |
-
msgid "Update"
|
479 |
-
msgstr "Mise à jour"
|
480 |
-
|
481 |
-
#: admin/view-tab-settings.php:14
|
482 |
-
msgid "Default language"
|
483 |
-
msgstr "Langue par défaut"
|
484 |
-
|
485 |
-
#: admin/view-tab-settings.php:29
|
486 |
-
msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
|
487 |
-
msgstr "Il y a des articles, pages, catégories ou étiquettes sans jeu de langue. Voulez-vous leur attribuer la langue par défaut ?"
|
488 |
-
|
489 |
-
#: admin/view-tab-settings.php:37
|
490 |
-
msgid "URL modifications"
|
491 |
-
msgstr "Modifications des URL"
|
492 |
-
|
493 |
-
#: admin/view-tab-settings.php:43
|
494 |
-
msgid "The language is set from content"
|
495 |
-
msgstr "La langue est déterminée par le contenu"
|
496 |
-
|
497 |
-
#: admin/view-tab-settings.php:46
|
498 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
499 |
-
msgstr "Les adresses des articles, pages, catégories et mots clés ne sont pas modifiées."
|
500 |
-
|
501 |
-
#: admin/view-tab-settings.php:51
|
502 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
503 |
-
msgstr "La langue est déterminée par le nom du répertoire dans les permaliens"
|
504 |
-
|
505 |
-
#: admin/view-tab-settings.php:51
|
506 |
-
msgid "The language is set from the code in the URL"
|
507 |
-
msgstr "La langue est déterminée par le code dans l'URL"
|
508 |
-
|
509 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
510 |
-
#: admin/view-tab-settings.php:109 admin/view-tab-settings.php:118
|
511 |
-
msgid "Example:"
|
512 |
-
msgstr "Exemple :"
|
513 |
-
|
514 |
-
#: admin/view-tab-settings.php:60
|
515 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
516 |
-
msgstr "La langue est déterminée par le sous-domaine dans les permaliens"
|
517 |
-
|
518 |
-
#: admin/view-tab-settings.php:69
|
519 |
-
msgid "The language is set from different domains"
|
520 |
-
msgstr "La langue est déterminée par des noms de domaine différents"
|
521 |
-
|
522 |
-
#: admin/view-tab-settings.php:92
|
523 |
-
msgid "Hide URL language information for default language"
|
524 |
-
msgstr "Cacher l’information de langue dans l’URL pour la langue par défaut"
|
525 |
-
|
526 |
-
#: admin/view-tab-settings.php:106
|
527 |
-
msgid "Remove /language/ in pretty permalinks"
|
528 |
-
msgstr "Supprimer /language/ dans les permaliens"
|
529 |
-
|
530 |
-
#: admin/view-tab-settings.php:115
|
531 |
-
msgid "Keep /language/ in pretty permalinks"
|
532 |
-
msgstr "Conserver /language/ dans les permaliens"
|
533 |
-
|
534 |
-
#: admin/view-tab-settings.php:130
|
535 |
-
msgid "The front page url contains the language code instead of the page name or page id"
|
536 |
-
msgstr "L'adresse de la page d'accueil contient le code de la langue au lieu du nom de la page"
|
537 |
-
|
538 |
-
#: admin/view-tab-settings.php:138
|
539 |
-
msgid "Example: %s instead of %s"
|
540 |
-
msgstr "Exemple : %s au lieu de %s"
|
541 |
-
|
542 |
-
#: admin/view-tab-settings.php:148
|
543 |
-
msgid "Detect browser language"
|
544 |
-
msgstr "Détecter la langue du navigateur"
|
545 |
-
|
546 |
-
#: admin/view-tab-settings.php:154
|
547 |
-
msgid "When the front page is visited, set the language according to the browser preference"
|
548 |
-
msgstr "Lorsque la page d’accueil est visitée, le visiteur est redirigé en fonction des préférences de langue de son navigateur"
|
549 |
-
|
550 |
-
#: admin/view-tab-settings.php:161
|
551 |
-
msgid "Media"
|
552 |
-
msgstr "Médias"
|
553 |
-
|
554 |
-
#: admin/view-tab-settings.php:167
|
555 |
-
msgid "Activate languages and translations for media"
|
556 |
-
msgstr "Activer la gestion des langues et des traductions pour les médias."
|
557 |
-
|
558 |
-
#: admin/view-tab-settings.php:175
|
559 |
-
msgid "Custom post types"
|
560 |
-
msgstr "Types de contenu personnalisé"
|
561 |
-
|
562 |
-
#: admin/view-tab-settings.php:188
|
563 |
-
msgid "Activate languages and translations for custom post types."
|
564 |
-
msgstr "Activer la gestion des langues et des traductions pour les types de contenu."
|
565 |
-
|
566 |
-
#: admin/view-tab-settings.php:195
|
567 |
-
msgid "Custom taxonomies"
|
568 |
-
msgstr "Taxinomies"
|
569 |
-
|
570 |
-
#: admin/view-tab-settings.php:208
|
571 |
-
msgid "Activate languages and translations for custom taxonomies."
|
572 |
-
msgstr "Activer la gestion des langues et des traductions pour les taxinomies."
|
573 |
-
|
574 |
-
#: admin/view-tab-settings.php:214
|
575 |
-
msgid "Synchronization"
|
576 |
-
msgstr "Synchronisation"
|
577 |
-
|
578 |
-
#: admin/view-tab-settings.php:225
|
579 |
-
msgid "The synchronization options allow to maintain exact same values (or translations in the case of taxonomies and page parent) of meta content between the translations of a post or page."
|
580 |
-
msgstr "Les options de synchronisation permettent de maintenir les mêmes valeurs de métacontenus entre les traductions d’un article ou d’une page (ou de les traduire dans le cas des taxinomies et de la page parent)"
|
581 |
-
|
582 |
-
#: admin/view-tab-strings.php:8
|
583 |
-
msgid "Search translations"
|
584 |
-
msgstr "Chercher dans les traductions"
|
585 |
-
|
586 |
-
#: admin/view-tab-strings.php:11
|
587 |
-
msgid "Clean strings translation database"
|
588 |
-
msgstr "Nettoyer les chaines de traduction de la base de données"
|
589 |
-
|
590 |
-
#: admin/view-tab-strings.php:12
|
591 |
-
msgid "Use this to remove unused strings from database, for example after a plugin has been uninstalled."
|
592 |
-
msgstr "Utilisez cette option pour supprimer les phrases inutiles dans la base de données, par exemple après avoir déssinstallé une extension."
|
593 |
-
|
594 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
595 |
-
#: admin/view-translations-term.php:30
|
596 |
-
msgid "Add new"
|
597 |
-
msgstr "Ajouter"
|
598 |
-
|
599 |
-
#: frontend/frontend-filters-search.php:80
|
600 |
-
msgid "Search"
|
601 |
-
msgstr "Rechercher"
|
602 |
-
|
603 |
-
#: include/model.php:755
|
604 |
-
msgid "Uncategorized"
|
605 |
-
msgstr "Non classé"
|
606 |
-
|
607 |
-
#: include/plugins-compat.php:89
|
608 |
-
msgid "Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file."
|
609 |
-
msgstr "Importation d’<strong>articles, pages, commentaires, champs personnalisés, catégories et étiquettes</strong> depuis un fichier export de WordPress."
|
610 |
-
|
611 |
-
#: include/switcher.php:22
|
612 |
-
msgid "Displays language names"
|
613 |
-
msgstr "Afficher le nom des langues"
|
614 |
-
|
615 |
-
#: include/switcher.php:23
|
616 |
-
msgid "Displays flags"
|
617 |
-
msgstr "Afficher les drapeaux"
|
618 |
-
|
619 |
-
#: include/switcher.php:24
|
620 |
-
msgid "Forces link to front page"
|
621 |
-
msgstr "Force le lien vers la page d’accueil"
|
622 |
-
|
623 |
-
#: include/switcher.php:25
|
624 |
-
msgid "Hides the current language"
|
625 |
-
msgstr "Cacher la langue courante"
|
626 |
-
|
627 |
-
#: include/switcher.php:26
|
628 |
-
msgid "Hides languages with no translation"
|
629 |
-
msgstr "Cacher les langues sans traduction"
|
630 |
-
|
631 |
-
#: include/switcher.php:30
|
632 |
-
msgid "Displays as dropdown"
|
633 |
-
msgstr "Afficher en liste déroulante"
|
634 |
-
|
635 |
-
#. translators: Calendar caption: 1: month name, 2: 4-digit year
|
636 |
-
#: include/widget-calendar.php:124
|
637 |
-
msgctxt "calendar caption"
|
638 |
-
msgid "%1$s %2$s"
|
639 |
-
msgstr "%1$s %2$s"
|
640 |
-
|
641 |
-
#: include/widget-languages.php:16
|
642 |
-
msgid "Language Switcher"
|
643 |
-
msgstr "Liste des langues"
|
644 |
-
|
645 |
-
#: include/widget-languages.php:16
|
646 |
-
msgid "Displays a language switcher"
|
647 |
-
msgstr "Afficher la liste des langues"
|
648 |
-
|
649 |
-
#: include/widget-languages.php:75
|
650 |
-
msgid "Title:"
|
651 |
-
msgstr "Titre :"
|
652 |
-
|
653 |
-
#: include/widget-recent-comments.php:46
|
654 |
-
msgid "Recent Comments"
|
655 |
-
msgstr "Commentaires récents"
|
656 |
-
|
657 |
-
#. translators: comments widget: 1: comment author, 2: post link
|
658 |
-
#: include/widget-recent-comments.php:84
|
659 |
-
msgctxt "widgets"
|
660 |
-
msgid "%1$s on %2$s"
|
661 |
-
msgstr "%1$s sur %2$s"
|
662 |
-
|
663 |
-
#: include/widget-recent-posts.php:46
|
664 |
-
msgid "Recent Posts"
|
665 |
-
msgstr "Articles récents"
|
666 |
-
|
667 |
-
#: install/install.php:24
|
668 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
669 |
-
msgstr "Vous utilisez WordPress %s. Polylang nécessite au moins WordPress %s."
|
670 |
-
|
671 |
-
#: install/upgrade.php:76
|
672 |
-
msgid "Polylang has been deactivated because you upgraded from a too old version."
|
673 |
-
msgstr "Polylang a été désactivé parce que vous avez fait une mise à jour depuis une version trop ancienne."
|
674 |
-
|
675 |
-
#: install/upgrade.php:78
|
676 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
677 |
-
msgstr "Veuillez d’abord mettre à jour en %s avant de mettre à jour en %s."
|
678 |
-
|
679 |
-
#: lingotek/lingotek.php:26
|
680 |
-
msgid "You’ve just upgraded to the latest version of Polylang! Would you like to automatically translate your website for free?"
|
681 |
-
msgstr "Vous venez juste de mettre à jour Polylang dans sa dernière version ! Voulez vous traduire automatiquement traduire votre site gratuitement ?"
|
682 |
-
|
683 |
-
#: lingotek/lingotek.php:30
|
684 |
-
msgid "Close"
|
685 |
-
msgstr "Fermer"
|
686 |
-
|
687 |
-
#: lingotek/lingotek.php:33
|
688 |
-
msgid "Learn more"
|
689 |
-
msgstr "En savoir plus"
|
690 |
-
|
691 |
-
#: lingotek/lingotek.php:39
|
692 |
-
msgid "Click on Activate Lingotek to start translating."
|
693 |
-
msgstr "Cliquez sur Activer Lingotek pour lancer la traduction."
|
694 |
-
|
695 |
-
#: lingotek/lingotek.php:42
|
696 |
-
msgid "Activate Lingotek"
|
697 |
-
msgstr "Activer Lingotek"
|
698 |
-
|
699 |
-
#: lingotek/lingotek.php:54
|
700 |
-
msgid "Congratulations!"
|
701 |
-
msgstr "Félicitations !"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-gl_ES.mo
DELETED
Binary file
|
languages/polylang-gl_ES.po
DELETED
@@ -1,667 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: Polylang v1.7beta1\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: \n"
|
6 |
-
"PO-Revision-Date: 2015-05-13 00:53+0100\n"
|
7 |
-
"Last-Translator: enfeitizador <enfeitizador@gmail.com>\n"
|
8 |
-
"Language-Team: #fedellaengalego | http://fedellar.wordpress.com/ "
|
9 |
-
"<fedellar@enfeitizador.es>\n"
|
10 |
-
"Language: gl_ES\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-Poedit-SourceCharset: UTF-8\n"
|
16 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
17 |
-
"_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"
|
18 |
-
"X-Poedit-Basepath: ../\n"
|
19 |
-
"X-Textdomain-Support: yes\n"
|
20 |
-
"X-Generator: Poedit 1.8beta1\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 provéese cunha extensa %sdocumentación%s (só en ingles). Inlúe "
|
33 |
-
"información de como configurar o teu sitio multilingüe e usalo a diario, "
|
34 |
-
"preguntas habituais, así como documentación a programadores para adaptar "
|
35 |
-
"complementos e temas."
|
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 |
-
"Atoparás información útil no %sforo de axuda%s. Porén, non esqueza facer "
|
45 |
-
"unha busca antes de crear un tema novo."
|
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 está libre de custes e liberado baixo a mesma licenza que "
|
55 |
-
"WordPress, a %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 se pregunta como axudar co proxecto, só %slea isto%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 |
-
"Por último, se che gusta este complemento ou che axuda no negocio, as "
|
70 |
-
"doazóns ao autor son moi apreciadas."
|
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 "Idiomas"
|
77 |
-
|
78 |
-
# @ polylang
|
79 |
-
#: include/switcher.php:22
|
80 |
-
msgid "Displays language names"
|
81 |
-
msgstr "Amosar nomes de idiomas"
|
82 |
-
|
83 |
-
# @ polylang
|
84 |
-
#: include/switcher.php:23
|
85 |
-
msgid "Displays flags"
|
86 |
-
msgstr "Amosar bandeiras"
|
87 |
-
|
88 |
-
# @ polylang
|
89 |
-
#: include/switcher.php:24
|
90 |
-
msgid "Forces link to front page"
|
91 |
-
msgstr "Forzar ligazón á páxina principal"
|
92 |
-
|
93 |
-
# @ polylang
|
94 |
-
#: include/switcher.php:25
|
95 |
-
msgid "Hides the current language"
|
96 |
-
msgstr "Agochar o idioma actual"
|
97 |
-
|
98 |
-
# @ polylang
|
99 |
-
#: include/switcher.php:30
|
100 |
-
msgid "Displays as dropdown"
|
101 |
-
msgstr "Amosar como despregable"
|
102 |
-
|
103 |
-
# @ polylang
|
104 |
-
#: admin/admin.php:267
|
105 |
-
msgid "Filters content by language"
|
106 |
-
msgstr "Filtrar contido por idioma"
|
107 |
-
|
108 |
-
# @ polylang
|
109 |
-
#: admin/admin.php:258
|
110 |
-
msgid "Show all languages"
|
111 |
-
msgstr "Amosar todos os idiomas"
|
112 |
-
|
113 |
-
# @ polylang
|
114 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
115 |
-
msgid "Add new translation"
|
116 |
-
msgstr "Engadir nova tradución"
|
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 "Idioma"
|
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 "Traducións"
|
131 |
-
|
132 |
-
# @ polylang
|
133 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
134 |
-
msgid "Sets the language"
|
135 |
-
msgstr "Configurar o idioma"
|
136 |
-
|
137 |
-
# @ polylang
|
138 |
-
#: admin/admin-filters.php:52
|
139 |
-
msgid "The widget is displayed for:"
|
140 |
-
msgstr "O trebello amósase para:"
|
141 |
-
|
142 |
-
# @ polylang
|
143 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
144 |
-
msgid "All languages"
|
145 |
-
msgstr "Todos os idiomas"
|
146 |
-
|
147 |
-
# @ polylang
|
148 |
-
#: admin/admin-filters.php:123
|
149 |
-
msgid "Admin language"
|
150 |
-
msgstr "Administrar idioma"
|
151 |
-
|
152 |
-
# @ polylang
|
153 |
-
#: admin/admin-filters.php:126
|
154 |
-
msgid "WordPress default"
|
155 |
-
msgstr "Predefinido WordPress"
|
156 |
-
|
157 |
-
# @ polylang
|
158 |
-
#: admin/admin.php:167 admin/settings.php:102
|
159 |
-
msgid "Settings"
|
160 |
-
msgstr "Axustes"
|
161 |
-
|
162 |
-
# @ polylang
|
163 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
164 |
-
msgid "Upgrading language files…"
|
165 |
-
msgstr "Actualizando ficheiros de idioma…"
|
166 |
-
|
167 |
-
# @ polylang
|
168 |
-
#: admin/settings.php:62
|
169 |
-
msgid "About Polylang"
|
170 |
-
msgstr "Sobre Polylang"
|
171 |
-
|
172 |
-
# @ polylang
|
173 |
-
#: admin/settings.php:78
|
174 |
-
msgid "Strings translations"
|
175 |
-
msgstr "Cadeas traducións"
|
176 |
-
|
177 |
-
# @ polylang
|
178 |
-
#: admin/settings.php:101
|
179 |
-
msgid "Strings translation"
|
180 |
-
msgstr "Cadeas tradución"
|
181 |
-
|
182 |
-
# @ polylang
|
183 |
-
#: admin/admin-model.php:244
|
184 |
-
msgid "Enter a valid WordPress locale"
|
185 |
-
msgstr "Insire unha configuración rexional de idioma de WordPess válido"
|
186 |
-
|
187 |
-
# @ polylang
|
188 |
-
#: admin/admin-model.php:252
|
189 |
-
msgid "The language code must be unique"
|
190 |
-
msgstr "O código de idioma debe ser único"
|
191 |
-
|
192 |
-
# @ polylang
|
193 |
-
#: admin/admin-model.php:256
|
194 |
-
msgid "The language must have a name"
|
195 |
-
msgstr "O idioma debe ter un nome"
|
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 |
-
"O idioma creouse, pero o ficheiro de idioma do WordPress non se descargou. "
|
204 |
-
"Instáleo manualmente."
|
205 |
-
|
206 |
-
# @ polylang
|
207 |
-
#: admin/admin-strings.php:59
|
208 |
-
msgid "Widget title"
|
209 |
-
msgstr "Título do trebello"
|
210 |
-
|
211 |
-
# @ polylang
|
212 |
-
#: admin/settings.php:319
|
213 |
-
msgid "Taxonomies"
|
214 |
-
msgstr "Taxonomías"
|
215 |
-
|
216 |
-
# @ polylang
|
217 |
-
#: admin/settings.php:320
|
218 |
-
msgid "Custom fields"
|
219 |
-
msgstr "Campos personalizados"
|
220 |
-
|
221 |
-
# @ polylang
|
222 |
-
#: admin/settings.php:321
|
223 |
-
msgid "Comment status"
|
224 |
-
msgstr "Estado do comentario"
|
225 |
-
|
226 |
-
# @ polylang
|
227 |
-
#: admin/settings.php:322
|
228 |
-
msgid "Ping status"
|
229 |
-
msgstr "Estado do ping"
|
230 |
-
|
231 |
-
# @ polylang
|
232 |
-
#: admin/settings.php:323
|
233 |
-
msgid "Sticky posts"
|
234 |
-
msgstr "Artigos fixos"
|
235 |
-
|
236 |
-
# @ polylang
|
237 |
-
#: admin/settings.php:324
|
238 |
-
msgid "Published date"
|
239 |
-
msgstr "Data de publicación"
|
240 |
-
|
241 |
-
# @ polylang
|
242 |
-
#: admin/settings.php:325
|
243 |
-
msgid "Post format"
|
244 |
-
msgstr "Formato de artigo"
|
245 |
-
|
246 |
-
# @ polylang
|
247 |
-
#: admin/settings.php:326
|
248 |
-
msgid "Page parent"
|
249 |
-
msgstr "Páxina primaria"
|
250 |
-
|
251 |
-
# @ polylang
|
252 |
-
#: admin/settings.php:327
|
253 |
-
msgid "Page template"
|
254 |
-
msgstr "Páxina modelo"
|
255 |
-
|
256 |
-
# @ polylang
|
257 |
-
#: admin/settings.php:328
|
258 |
-
msgid "Page order"
|
259 |
-
msgstr "Orde de páxina"
|
260 |
-
|
261 |
-
# @ polylang
|
262 |
-
#: admin/settings.php:329
|
263 |
-
msgid "Featured image"
|
264 |
-
msgstr "Imaxe destacada"
|
265 |
-
|
266 |
-
# @ polylang
|
267 |
-
#: admin/view-tab-lang.php:21
|
268 |
-
msgid "Edit language"
|
269 |
-
msgstr "Editar idioma"
|
270 |
-
|
271 |
-
# @ polylang
|
272 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
273 |
-
msgid "Add new language"
|
274 |
-
msgstr "Engadir novo idioma"
|
275 |
-
|
276 |
-
# @ polylang
|
277 |
-
#: admin/view-tab-lang.php:37
|
278 |
-
msgid "Choose a language"
|
279 |
-
msgstr "Escolla un idioma"
|
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 "Podes escoller un idioma na lista ou editalo directamente abaixo."
|
285 |
-
|
286 |
-
# @ polylang
|
287 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
288 |
-
msgid "Full name"
|
289 |
-
msgstr "Nome completo"
|
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 "O nome como se amosará no teu sitio (por exemplo: Inglés)."
|
295 |
-
|
296 |
-
# @ polylang
|
297 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
298 |
-
msgid "Locale"
|
299 |
-
msgstr "Configuración rexional"
|
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 |
-
"Configuración rexional do idioma WordPress (por exemplo: en_US). Necesitarás "
|
308 |
-
"instalar o ficheiro .mo deste idioma."
|
309 |
-
|
310 |
-
# @ polylang
|
311 |
-
#: admin/view-tab-lang.php:70
|
312 |
-
msgid "Language code"
|
313 |
-
msgstr "Código de idioma"
|
314 |
-
|
315 |
-
# @ polylang
|
316 |
-
#: admin/view-tab-lang.php:76
|
317 |
-
msgid "Text direction"
|
318 |
-
msgstr "Orientación do texto"
|
319 |
-
|
320 |
-
# @ polylang
|
321 |
-
#: admin/view-tab-lang.php:80
|
322 |
-
msgid "left to right"
|
323 |
-
msgstr "esquerda a dereita"
|
324 |
-
|
325 |
-
# @ polylang
|
326 |
-
#: admin/view-tab-lang.php:85
|
327 |
-
msgid "right to left"
|
328 |
-
msgstr "dereita a esquerda"
|
329 |
-
|
330 |
-
# @ polylang
|
331 |
-
#: admin/view-tab-lang.php:87
|
332 |
-
msgid "Choose the text direction for the language"
|
333 |
-
msgstr "Escolla a orientación do texto para o idioma"
|
334 |
-
|
335 |
-
# @ polylang
|
336 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
337 |
-
msgid "Order"
|
338 |
-
msgstr "Orde"
|
339 |
-
|
340 |
-
# @ polylang
|
341 |
-
#: admin/view-tab-lang.php:93
|
342 |
-
msgid "Position of the language in the language switcher"
|
343 |
-
msgstr "Posición do idioma no conmutador de idioma"
|
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 "Conmutador de idioma"
|
351 |
-
|
352 |
-
# @ polylang
|
353 |
-
#: admin/view-tab-strings.php:8
|
354 |
-
msgid "Search translations"
|
355 |
-
msgstr "Buscar traducións"
|
356 |
-
|
357 |
-
# @ polylang
|
358 |
-
#: admin/view-tab-strings.php:11
|
359 |
-
msgid "Clean strings translation database"
|
360 |
-
msgstr "Limpar base de datos das cadeas de tradución"
|
361 |
-
|
362 |
-
# @ polylang
|
363 |
-
#: admin/view-tab-settings.php:14
|
364 |
-
msgid "Default language"
|
365 |
-
msgstr "Idioma predefinido"
|
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 |
-
"Hai artigos, páxinas, categorías ou etiquetas sen idioma definido. Desexa "
|
374 |
-
"configuralos co idioma predefinido?"
|
375 |
-
|
376 |
-
# @ polylang
|
377 |
-
#: admin/view-tab-settings.php:149
|
378 |
-
msgid "Detect browser language"
|
379 |
-
msgstr "Detectar idioma do navegador"
|
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 |
-
"Cando se visite a páxina principal, configure o idioma acorde ás "
|
388 |
-
"preferencias do navegador"
|
389 |
-
|
390 |
-
# @ polylang
|
391 |
-
#: admin/view-tab-settings.php:37
|
392 |
-
msgid "URL modifications"
|
393 |
-
msgstr "Modificacións URL"
|
394 |
-
|
395 |
-
# @ polylang
|
396 |
-
#: admin/view-tab-settings.php:93
|
397 |
-
msgid "Hide URL language information for default language"
|
398 |
-
msgstr "Agochar información URL de idioma para o predefinido"
|
399 |
-
|
400 |
-
# @ polylang
|
401 |
-
#: admin/view-tab-settings.php:162
|
402 |
-
msgid "Media"
|
403 |
-
msgstr "Multimedia"
|
404 |
-
|
405 |
-
# @ polylang
|
406 |
-
#: admin/view-tab-settings.php:168
|
407 |
-
msgid "Activate languages and translations for media"
|
408 |
-
msgstr "Activar idiomas e traducións para multimedia"
|
409 |
-
|
410 |
-
# @ polylang
|
411 |
-
#: admin/view-tab-settings.php:215
|
412 |
-
msgid "Synchronization"
|
413 |
-
msgstr "Sincronización"
|
414 |
-
|
415 |
-
# @ polylang
|
416 |
-
#: admin/view-tab-settings.php:176
|
417 |
-
msgid "Custom post types"
|
418 |
-
msgstr "Tipos de artigos personalizados"
|
419 |
-
|
420 |
-
# @ polylang
|
421 |
-
#: admin/view-tab-settings.php:189
|
422 |
-
msgid "Activate languages and translations for custom post types."
|
423 |
-
msgstr "Activar idiomas e traducións para tipos de artigo personalizado."
|
424 |
-
|
425 |
-
# @ polylang
|
426 |
-
#: admin/view-tab-settings.php:196
|
427 |
-
msgid "Custom taxonomies"
|
428 |
-
msgstr "Taxonomías personalizadas"
|
429 |
-
|
430 |
-
# @ polylang
|
431 |
-
#: admin/view-tab-settings.php:209
|
432 |
-
msgid "Activate languages and translations for custom taxonomies."
|
433 |
-
msgstr "Activar idiomas e traducións para taxonomías personalizadas."
|
434 |
-
|
435 |
-
# @ polylang
|
436 |
-
#: admin/admin-filters-post.php:433 admin/admin-filters-term.php:642
|
437 |
-
#: admin/table-languages.php:54 admin/view-translations-media.php:21
|
438 |
-
msgid "Edit"
|
439 |
-
msgstr "Editar"
|
440 |
-
|
441 |
-
# @ polylang
|
442 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
443 |
-
msgid "Delete"
|
444 |
-
msgstr "Eliminar"
|
445 |
-
|
446 |
-
# @ polylang
|
447 |
-
#: admin/table-languages.php:76
|
448 |
-
msgid "Code"
|
449 |
-
msgstr "Código"
|
450 |
-
|
451 |
-
# "Bandeira" sáese do espazo reservado á cadea
|
452 |
-
#: admin/table-languages.php:78
|
453 |
-
msgid "Flag"
|
454 |
-
msgstr "Marca"
|
455 |
-
|
456 |
-
# @ polylang
|
457 |
-
#: admin/table-languages.php:79
|
458 |
-
msgid "Posts"
|
459 |
-
msgstr "Artigos"
|
460 |
-
|
461 |
-
# @ polylang
|
462 |
-
#: admin/table-string.php:110
|
463 |
-
msgid "Name"
|
464 |
-
msgstr "Nome"
|
465 |
-
|
466 |
-
# @ polylang
|
467 |
-
#: admin/table-string.php:111
|
468 |
-
msgid "String"
|
469 |
-
msgstr "Cadea"
|
470 |
-
|
471 |
-
# @ polylang
|
472 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
473 |
-
#: admin/view-translations-term.php:30
|
474 |
-
msgid "Add new"
|
475 |
-
msgstr "Engadir novo"
|
476 |
-
|
477 |
-
# @ polylang
|
478 |
-
#: include/widget-languages.php:16
|
479 |
-
msgid "Language Switcher"
|
480 |
-
msgstr "Conmutador de idioma"
|
481 |
-
|
482 |
-
# @ polylang
|
483 |
-
#: include/widget-languages.php:16
|
484 |
-
msgid "Displays a language switcher"
|
485 |
-
msgstr "Amosar un conmutador de idioma"
|
486 |
-
|
487 |
-
# @ polylang
|
488 |
-
#: include/widget-languages.php:75
|
489 |
-
msgid "Title:"
|
490 |
-
msgstr "Título:"
|
491 |
-
|
492 |
-
# @ polylang
|
493 |
-
#. translators: plugin header field 'Description'
|
494 |
-
#: polylang.php:0
|
495 |
-
msgid "Adds multilingual capability to WordPress"
|
496 |
-
msgstr "Engade funcionalidades multilingüe a WordPress"
|
497 |
-
|
498 |
-
# @ polylang
|
499 |
-
#: install/install.php:24
|
500 |
-
#, php-format
|
501 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
502 |
-
msgstr "Estás a usar WordPress %s. Polylang require polo menos WordPress %s."
|
503 |
-
|
504 |
-
# @ polylang
|
505 |
-
#: install/upgrade.php:76
|
506 |
-
msgid ""
|
507 |
-
"Polylang has been deactivated because you upgraded from a too old version."
|
508 |
-
msgstr ""
|
509 |
-
"Polylang desactivouse porque actualizaches dende un versión demasiado vella."
|
510 |
-
|
511 |
-
# @ polylang
|
512 |
-
#: install/upgrade.php:78
|
513 |
-
#, php-format
|
514 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
515 |
-
msgstr "Actualiza primeiro para %s antes de actualizares a %s."
|
516 |
-
|
517 |
-
# @ polylang
|
518 |
-
#: admin/table-string.php:109
|
519 |
-
msgid "Group"
|
520 |
-
msgstr "Grupo"
|
521 |
-
|
522 |
-
# @ polylang
|
523 |
-
#: admin/table-string.php:187
|
524 |
-
msgid "View all groups"
|
525 |
-
msgstr "Ver todos os grupos"
|
526 |
-
|
527 |
-
# @ polylang
|
528 |
-
#: admin/table-languages.php:59
|
529 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
530 |
-
msgstr "Vas eliminar permanentemente este idioma. Estás seguro?"
|
531 |
-
|
532 |
-
# @ polylang
|
533 |
-
#: admin/view-tab-strings.php:12
|
534 |
-
msgid ""
|
535 |
-
"Use this to remove unused strings from database, for example after a plugin "
|
536 |
-
"has been uninstalled."
|
537 |
-
msgstr ""
|
538 |
-
"Usa isto para eliminar cadeas sen uso da base de datos, pro exemplo despois "
|
539 |
-
"de desinstalarse un complemento."
|
540 |
-
|
541 |
-
# @ polylang
|
542 |
-
#: admin/view-tab-settings.php:226
|
543 |
-
msgid ""
|
544 |
-
"The synchronization options allow to maintain exact same values (or "
|
545 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
546 |
-
"between the translations of a post or page."
|
547 |
-
msgstr ""
|
548 |
-
"As opcións de sincronización permiten manter os mesmo valores (ou traducións "
|
549 |
-
"no caso de taxonomías e páxina primaria) do contido META entre as traducións "
|
550 |
-
"dun artigo ou páxina."
|
551 |
-
|
552 |
-
# @ polylang
|
553 |
-
#: admin/admin-model.php:248
|
554 |
-
msgid "The language code contains invalid characters"
|
555 |
-
msgstr "O idioma contén caracteres non válidos"
|
556 |
-
|
557 |
-
# @ polylang
|
558 |
-
#: admin/view-tab-settings.php:43
|
559 |
-
msgid "The language is set from content"
|
560 |
-
msgstr "O idioma estableceuse desde o contido"
|
561 |
-
|
562 |
-
# @ polylang
|
563 |
-
#: admin/view-tab-settings.php:46
|
564 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
565 |
-
msgstr "Non se modificaron artigos, páxinas, categorías e etiquetas URL."
|
566 |
-
|
567 |
-
# @ polylang
|
568 |
-
#: admin/view-tab-settings.php:51
|
569 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
570 |
-
msgstr "O idioma estableceuse desde o nome do cartafol nas ligazóns á man"
|
571 |
-
|
572 |
-
# @ polylang
|
573 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
574 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
575 |
-
msgid "Example:"
|
576 |
-
msgstr "Exemplo:"
|
577 |
-
|
578 |
-
# @ polylang
|
579 |
-
#: admin/view-tab-settings.php:60
|
580 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
581 |
-
msgstr "O idioma estableceuse desde o nome do subdominio nas ligazóns á man"
|
582 |
-
|
583 |
-
# @ polylang
|
584 |
-
#: admin/view-tab-settings.php:69
|
585 |
-
msgid "The language is set from different domains"
|
586 |
-
msgstr "O idioma estableceuse desde diferentes dominios"
|
587 |
-
|
588 |
-
# @ polylang
|
589 |
-
#: admin/view-tab-settings.php:107
|
590 |
-
msgid "Remove /language/ in pretty permalinks"
|
591 |
-
msgstr "Eliminar /idioma/ nas ligazóns permanentes á man"
|
592 |
-
|
593 |
-
# @ polylang
|
594 |
-
#: admin/view-tab-settings.php:116
|
595 |
-
msgid "Keep /language/ in pretty permalinks"
|
596 |
-
msgstr "Manter /idioma/ nas ligazóns permanentes á man"
|
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 |
-
"A URL da páxina de portada contén o código de idioma no lugar do nome ou a "
|
605 |
-
"ID de páxina"
|
606 |
-
|
607 |
-
# @ polylang
|
608 |
-
#: admin/view-tab-settings.php:139
|
609 |
-
#, php-format
|
610 |
-
msgid "Example: %s instead of %s"
|
611 |
-
msgstr "Exemplo: %s no lugar de %s"
|
612 |
-
|
613 |
-
# @ polylang
|
614 |
-
#: admin/admin-model.php:38
|
615 |
-
msgid "Impossible to add the language."
|
616 |
-
msgstr "Imposible engadir o idioma."
|
617 |
-
|
618 |
-
# @ polylang
|
619 |
-
#: admin/admin-model.php:66
|
620 |
-
msgid "Language added."
|
621 |
-
msgstr "Idioma engadido."
|
622 |
-
|
623 |
-
# @ polylang
|
624 |
-
#: admin/admin-model.php:146
|
625 |
-
msgid "Language deleted."
|
626 |
-
msgstr "Idioma detectado."
|
627 |
-
|
628 |
-
# @ polylang
|
629 |
-
#: admin/admin-model.php:227
|
630 |
-
msgid "Language updated."
|
631 |
-
msgstr "Idioma actualizado."
|
632 |
-
|
633 |
-
# @ polylang
|
634 |
-
#: admin/settings.php:239
|
635 |
-
msgid "Translations updated."
|
636 |
-
msgstr "Traducións actualizadas."
|
637 |
-
|
638 |
-
# @ polylang
|
639 |
-
#: admin/view-tab-lang.php:72
|
640 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
641 |
-
msgstr "Código de idioma - preferible ISO 639-1 de 2 letras (por exemplo: en)"
|
642 |
-
|
643 |
-
# @ polylang
|
644 |
-
#: admin/admin-filters.php:203
|
645 |
-
msgid "The chosen static front page must be translated in all languages."
|
646 |
-
msgstr ""
|
647 |
-
"A páxina estática de portada escollida débese traducir en todos os idiomas."
|
648 |
-
|
649 |
-
# @ polylang
|
650 |
-
#: admin/admin-strings.php:60
|
651 |
-
msgid "Widget text"
|
652 |
-
msgstr "Texto de trebello"
|
653 |
-
|
654 |
-
# @ polylang
|
655 |
-
#: admin/settings.php:52
|
656 |
-
msgid "Recommended plugins"
|
657 |
-
msgstr "Complementos recomendados"
|
658 |
-
|
659 |
-
# @ polylang
|
660 |
-
#: admin/view-tab-settings.php:51
|
661 |
-
msgid "The language is set from the code in the URL"
|
662 |
-
msgstr "O idioma estableceuse desde o código na URL"
|
663 |
-
|
664 |
-
# @ polylang
|
665 |
-
#: include/switcher.php:26
|
666 |
-
msgid "Hides languages with no translation"
|
667 |
-
msgstr "Agochar idiomas sen tradución"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-it_IT.mo
DELETED
Binary file
|
languages/polylang-it_IT.po
DELETED
@@ -1,600 +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: Luca Barbetti <lucabarbetti@gmail.com>\n"
|
8 |
-
"Language-Team: Luca Barbetti <lucabarbetti@gmail.com>\n"
|
9 |
-
"Language: it_IT\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.7.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 è completo di un'ampia %sdocumentazione%s (solamente in inglese). "
|
30 |
-
"La documentazione comprende informazioni su come impostare un sito "
|
31 |
-
"multilingue e come usarlo quotidianamente, un elenco di domande frequenti "
|
32 |
-
"(FAQ), ed anche informazioni per i programmatori che volessero adattare i "
|
33 |
-
"propri plugin e temi."
|
34 |
-
|
35 |
-
#: admin/view-about.php:9
|
36 |
-
#, php-format
|
37 |
-
msgid ""
|
38 |
-
"You will also find useful information in the %ssupport forum%s. However "
|
39 |
-
"don't forget to make a search before posting a new topic."
|
40 |
-
msgstr ""
|
41 |
-
"Si possono trovare informazioni utili anche nel %sforum di supporto%s. "
|
42 |
-
"Comunque, prima di inviare una richiesta per un nuovo argomento, è sempre "
|
43 |
-
"buona regola fare una ricerca."
|
44 |
-
|
45 |
-
#: admin/view-about.php:16
|
46 |
-
#, php-format
|
47 |
-
msgid ""
|
48 |
-
"Polylang is free of charge and is released under the same license as "
|
49 |
-
"WordPress, the %sGPL%s."
|
50 |
-
msgstr ""
|
51 |
-
"Polylang è gratuito ed è stato rilasciato con la stessa licenza di "
|
52 |
-
"WordPress, la %sGPL%s."
|
53 |
-
|
54 |
-
#: admin/view-about.php:22
|
55 |
-
#, php-format
|
56 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
57 |
-
msgstr ""
|
58 |
-
"Per sapere come poter aiutare questo progetto è sufficiente %sleggere questo"
|
59 |
-
"%s."
|
60 |
-
|
61 |
-
#: admin/view-about.php:27
|
62 |
-
msgid ""
|
63 |
-
"Finally if you like this plugin or if it helps your business, donations to "
|
64 |
-
"the author are greatly appreciated."
|
65 |
-
msgstr ""
|
66 |
-
"Infine, se il plugin vi è stato utile per il vostro business, considerate la "
|
67 |
-
"possibilità di fare una donazione a favore dell'autore."
|
68 |
-
|
69 |
-
#: admin/admin-filters-post.php:115 admin/admin.php:90 admin/settings.php:70
|
70 |
-
#: admin/settings.php:97 include/model.php:561
|
71 |
-
msgid "Languages"
|
72 |
-
msgstr "Lingue"
|
73 |
-
|
74 |
-
#: include/switcher.php:22
|
75 |
-
msgid "Displays language names"
|
76 |
-
msgstr "Visualizza i nomi delle lingue"
|
77 |
-
|
78 |
-
#: include/switcher.php:23
|
79 |
-
msgid "Displays flags"
|
80 |
-
msgstr "Visualizza le bandiere"
|
81 |
-
|
82 |
-
#: include/switcher.php:24
|
83 |
-
msgid "Forces link to front page"
|
84 |
-
msgstr "Forza il collegamento alla pagina iniziale"
|
85 |
-
|
86 |
-
#: include/switcher.php:25
|
87 |
-
msgid "Hides the current language"
|
88 |
-
msgstr "Nascondi la lingua corrente"
|
89 |
-
|
90 |
-
#: include/switcher.php:30
|
91 |
-
msgid "Displays as dropdown"
|
92 |
-
msgstr "Visualizza come menu a discesa"
|
93 |
-
|
94 |
-
#: admin/admin.php:267
|
95 |
-
msgid "Filters content by language"
|
96 |
-
msgstr "Filtra il contenuto per lingua"
|
97 |
-
|
98 |
-
#: admin/admin.php:258
|
99 |
-
msgid "Show all languages"
|
100 |
-
msgstr "Mostra tutte le lingue"
|
101 |
-
|
102 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
103 |
-
msgid "Add new translation"
|
104 |
-
msgstr "Aggiungi nuova traduzione"
|
105 |
-
|
106 |
-
#: admin/admin-filters-columns.php:173 admin/admin-filters-media.php:55
|
107 |
-
#: admin/admin-filters-post.php:141 admin/admin-filters-term.php:75
|
108 |
-
#: admin/admin-filters-term.php:122 include/model.php:562
|
109 |
-
msgid "Language"
|
110 |
-
msgstr "Lingua"
|
111 |
-
|
112 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
113 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
114 |
-
#: admin/view-translations-term.php:11
|
115 |
-
msgid "Translations"
|
116 |
-
msgstr "Traduzioni"
|
117 |
-
|
118 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
119 |
-
msgid "Sets the language"
|
120 |
-
msgstr "Imposta la lingua"
|
121 |
-
|
122 |
-
#: admin/admin-filters.php:52
|
123 |
-
msgid "The widget is displayed for:"
|
124 |
-
msgstr "Il widget viene visualizzato per:"
|
125 |
-
|
126 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
127 |
-
msgid "All languages"
|
128 |
-
msgstr "Tutte le lingue"
|
129 |
-
|
130 |
-
#: admin/admin-filters.php:123
|
131 |
-
msgid "Admin language"
|
132 |
-
msgstr "Lingua degli amministratori"
|
133 |
-
|
134 |
-
#: admin/admin-filters.php:126
|
135 |
-
msgid "WordPress default"
|
136 |
-
msgstr "Impostazione predefinita di WordPress"
|
137 |
-
|
138 |
-
#: admin/admin.php:167 admin/settings.php:102
|
139 |
-
msgid "Settings"
|
140 |
-
msgstr "Impostazioni"
|
141 |
-
|
142 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
143 |
-
msgid "Upgrading language files…"
|
144 |
-
msgstr "Aggiornamento dei file di lingua…"
|
145 |
-
|
146 |
-
#: admin/settings.php:62
|
147 |
-
msgid "About Polylang"
|
148 |
-
msgstr "Informazioni su Polylang"
|
149 |
-
|
150 |
-
#: admin/settings.php:78
|
151 |
-
msgid "Strings translations"
|
152 |
-
msgstr "Traduzioni delle stringhe"
|
153 |
-
|
154 |
-
#: admin/settings.php:101
|
155 |
-
msgid "Strings translation"
|
156 |
-
msgstr "Traduzione delle stringhe"
|
157 |
-
|
158 |
-
#: admin/admin-model.php:244
|
159 |
-
msgid "Enter a valid WordPress locale"
|
160 |
-
msgstr "Inserire impostazioni locali valide per WordPress"
|
161 |
-
|
162 |
-
#: admin/admin-model.php:252
|
163 |
-
msgid "The language code must be unique"
|
164 |
-
msgstr "Il codice della lingua deve essere unico"
|
165 |
-
|
166 |
-
#: admin/admin-model.php:256
|
167 |
-
msgid "The language must have a name"
|
168 |
-
msgstr "La lingua deve avere un nome"
|
169 |
-
|
170 |
-
#: admin/admin.php:367 admin/settings.php:180
|
171 |
-
msgid ""
|
172 |
-
"The language was created, but the WordPress language file was not "
|
173 |
-
"downloaded. Please install it manually."
|
174 |
-
msgstr ""
|
175 |
-
"La lingua è stata creata, ma il file della lingua di WordPress non è stato "
|
176 |
-
"scaricato. Installarlo manualmente."
|
177 |
-
|
178 |
-
#: admin/admin-strings.php:59
|
179 |
-
msgid "Widget title"
|
180 |
-
msgstr "Titolo del widget"
|
181 |
-
|
182 |
-
# @ polylang
|
183 |
-
#: admin/settings.php:319
|
184 |
-
msgid "Taxonomies"
|
185 |
-
msgstr "Tassonomie"
|
186 |
-
|
187 |
-
# @ polylang
|
188 |
-
#: admin/settings.php:320
|
189 |
-
msgid "Custom fields"
|
190 |
-
msgstr "Campi personalizzati"
|
191 |
-
|
192 |
-
# @ polylang
|
193 |
-
#: admin/settings.php:321
|
194 |
-
msgid "Comment status"
|
195 |
-
msgstr "Stato del commento"
|
196 |
-
|
197 |
-
# @ polylang
|
198 |
-
#: admin/settings.php:322
|
199 |
-
msgid "Ping status"
|
200 |
-
msgstr "Stato di ping"
|
201 |
-
|
202 |
-
# @ polylang
|
203 |
-
#: admin/settings.php:323
|
204 |
-
msgid "Sticky posts"
|
205 |
-
msgstr "Articoli evidenziati"
|
206 |
-
|
207 |
-
# @ polylang
|
208 |
-
#: admin/settings.php:324
|
209 |
-
msgid "Published date"
|
210 |
-
msgstr "Data di pubblicazione"
|
211 |
-
|
212 |
-
# @ polylang
|
213 |
-
#: admin/settings.php:325
|
214 |
-
msgid "Post format"
|
215 |
-
msgstr "Formato articolo"
|
216 |
-
|
217 |
-
#: admin/settings.php:326
|
218 |
-
msgid "Page parent"
|
219 |
-
msgstr "Pagina padre"
|
220 |
-
|
221 |
-
# @ polylang
|
222 |
-
#: admin/settings.php:327
|
223 |
-
msgid "Page template"
|
224 |
-
msgstr "Modello pagina"
|
225 |
-
|
226 |
-
#: admin/settings.php:328
|
227 |
-
msgid "Page order"
|
228 |
-
msgstr "Ordine pagine"
|
229 |
-
|
230 |
-
# @ polylang
|
231 |
-
#: admin/settings.php:329
|
232 |
-
msgid "Featured image"
|
233 |
-
msgstr "Immagine evidenziata"
|
234 |
-
|
235 |
-
#: admin/view-tab-lang.php:21
|
236 |
-
msgid "Edit language"
|
237 |
-
msgstr "Modifica lingua"
|
238 |
-
|
239 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
240 |
-
msgid "Add new language"
|
241 |
-
msgstr "Aggiungi nuova lingua"
|
242 |
-
|
243 |
-
#: admin/view-tab-lang.php:37
|
244 |
-
msgid "Choose a language"
|
245 |
-
msgstr "Scegli una lingua"
|
246 |
-
|
247 |
-
#: admin/view-tab-lang.php:51
|
248 |
-
msgid "You can choose a language in the list or directly edit it below."
|
249 |
-
msgstr ""
|
250 |
-
"Scegliere una lingua dall'elenco o inserirla direttamente nei campi a "
|
251 |
-
"seguire."
|
252 |
-
|
253 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
254 |
-
msgid "Full name"
|
255 |
-
msgstr "Nome completo"
|
256 |
-
|
257 |
-
#: admin/view-tab-lang.php:57
|
258 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
259 |
-
msgstr "Il nome come appare sul sito."
|
260 |
-
|
261 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
262 |
-
msgid "Locale"
|
263 |
-
msgstr "Impostazioni locali"
|
264 |
-
|
265 |
-
#: admin/view-tab-lang.php:66
|
266 |
-
msgid ""
|
267 |
-
"WordPress Locale for the language (for example: en_US). You will need to "
|
268 |
-
"install the .mo file for this language."
|
269 |
-
msgstr ""
|
270 |
-
"Impostazioni locali di WordPress per la lingua (per esempio: en_US). è "
|
271 |
-
"necessario installare il file .mo per questa lingua."
|
272 |
-
|
273 |
-
#: admin/view-tab-lang.php:70
|
274 |
-
msgid "Language code"
|
275 |
-
msgstr "Codice della lingua"
|
276 |
-
|
277 |
-
#: admin/view-tab-lang.php:76
|
278 |
-
msgid "Text direction"
|
279 |
-
msgstr "Direzione del testo"
|
280 |
-
|
281 |
-
#: admin/view-tab-lang.php:80
|
282 |
-
msgid "left to right"
|
283 |
-
msgstr "Da sinistra a destra"
|
284 |
-
|
285 |
-
#: admin/view-tab-lang.php:85
|
286 |
-
msgid "right to left"
|
287 |
-
msgstr "Da destra a sinistra"
|
288 |
-
|
289 |
-
#: admin/view-tab-lang.php:87
|
290 |
-
msgid "Choose the text direction for the language"
|
291 |
-
msgstr "Scegliere la direzione del testo per la lingua"
|
292 |
-
|
293 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
294 |
-
msgid "Order"
|
295 |
-
msgstr "Ordinamento"
|
296 |
-
|
297 |
-
#: admin/view-tab-lang.php:93
|
298 |
-
msgid "Position of the language in the language switcher"
|
299 |
-
msgstr "Posizione della lingua nel selettore di lingua"
|
300 |
-
|
301 |
-
#: admin/admin-nav-menu.php:54 admin/admin-nav-menu.php:92
|
302 |
-
#: admin/admin-nav-menu.php:95 admin/admin-nav-menu.php:126
|
303 |
-
#: admin/admin-nav-menu.php:188 install/upgrade.php:301
|
304 |
-
msgid "Language switcher"
|
305 |
-
msgstr "Selettore di lingua"
|
306 |
-
|
307 |
-
#: admin/view-tab-strings.php:8
|
308 |
-
msgid "Search translations"
|
309 |
-
msgstr "Ricerca in traduzioni"
|
310 |
-
|
311 |
-
#: admin/view-tab-strings.php:11
|
312 |
-
msgid "Clean strings translation database"
|
313 |
-
msgstr "Cancellare le stringhe di traduzione dal database"
|
314 |
-
|
315 |
-
#: admin/view-tab-settings.php:14
|
316 |
-
msgid "Default language"
|
317 |
-
msgstr "Lingua predefinita"
|
318 |
-
|
319 |
-
#: admin/view-tab-settings.php:29
|
320 |
-
msgid ""
|
321 |
-
"There are posts, pages, categories or tags without language set. Do you want "
|
322 |
-
"to set them all to default language ?"
|
323 |
-
msgstr ""
|
324 |
-
"Ci sono articoli, pagine, categorie o tag per i quali la lingua non è stata "
|
325 |
-
"impostata. Si desidera impostarla per tutti come la lingua predefinita?"
|
326 |
-
|
327 |
-
#: admin/view-tab-settings.php:149
|
328 |
-
msgid "Detect browser language"
|
329 |
-
msgstr "Individua la lingua del browser"
|
330 |
-
|
331 |
-
#: admin/view-tab-settings.php:155
|
332 |
-
msgid ""
|
333 |
-
"When the front page is visited, set the language according to the browser "
|
334 |
-
"preference"
|
335 |
-
msgstr ""
|
336 |
-
"Imposta la lingua secondo le preferenze del browser quando viene visitata la "
|
337 |
-
"pagina iniziale"
|
338 |
-
|
339 |
-
#: admin/view-tab-settings.php:37
|
340 |
-
msgid "URL modifications"
|
341 |
-
msgstr "modifiche dell'URL"
|
342 |
-
|
343 |
-
#: admin/view-tab-settings.php:93
|
344 |
-
msgid "Hide URL language information for default language"
|
345 |
-
msgstr ""
|
346 |
-
"Nascondi le informazioni relative alla lingua dall'URL per la lingua "
|
347 |
-
"predefinita"
|
348 |
-
|
349 |
-
# @ polylang
|
350 |
-
#: admin/view-tab-settings.php:162
|
351 |
-
msgid "Media"
|
352 |
-
msgstr "Media"
|
353 |
-
|
354 |
-
# @ polylang
|
355 |
-
#: admin/view-tab-settings.php:168
|
356 |
-
msgid "Activate languages and translations for media"
|
357 |
-
msgstr "Attiva lingue e traduzioni per i media"
|
358 |
-
|
359 |
-
#: admin/view-tab-settings.php:215
|
360 |
-
msgid "Synchronization"
|
361 |
-
msgstr "Sincronizzazione"
|
362 |
-
|
363 |
-
# @ polylang
|
364 |
-
#: admin/view-tab-settings.php:176
|
365 |
-
msgid "Custom post types"
|
366 |
-
msgstr "Tipi di articoli personalizzati"
|
367 |
-
|
368 |
-
# @ polylang
|
369 |
-
#: admin/view-tab-settings.php:189
|
370 |
-
msgid "Activate languages and translations for custom post types."
|
371 |
-
msgstr "Attiva lingue e traduzioni per i tipi di articoli personalizzati."
|
372 |
-
|
373 |
-
# @ polylang
|
374 |
-
#: admin/view-tab-settings.php:196
|
375 |
-
msgid "Custom taxonomies"
|
376 |
-
msgstr "Tassonomie personalizzate"
|
377 |
-
|
378 |
-
# @ polylang
|
379 |
-
#: admin/view-tab-settings.php:209
|
380 |
-
msgid "Activate languages and translations for custom taxonomies."
|
381 |
-
msgstr "Attiva lingue e traduzioni per tassonomie personalizzate"
|
382 |
-
|
383 |
-
#: admin/admin-filters-post.php:433 admin/admin-filters-term.php:642
|
384 |
-
#: admin/table-languages.php:54 admin/view-translations-media.php:21
|
385 |
-
msgid "Edit"
|
386 |
-
msgstr "Modifica"
|
387 |
-
|
388 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
389 |
-
msgid "Delete"
|
390 |
-
msgstr "Cancella"
|
391 |
-
|
392 |
-
#: admin/table-languages.php:76
|
393 |
-
msgid "Code"
|
394 |
-
msgstr "Codice"
|
395 |
-
|
396 |
-
#: admin/table-languages.php:78
|
397 |
-
msgid "Flag"
|
398 |
-
msgstr "Bandiera"
|
399 |
-
|
400 |
-
#: admin/table-languages.php:79
|
401 |
-
msgid "Posts"
|
402 |
-
msgstr "Articoli"
|
403 |
-
|
404 |
-
#: admin/table-string.php:110
|
405 |
-
msgid "Name"
|
406 |
-
msgstr "Nome"
|
407 |
-
|
408 |
-
#: admin/table-string.php:111
|
409 |
-
msgid "String"
|
410 |
-
msgstr "Stringa"
|
411 |
-
|
412 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
413 |
-
#: admin/view-translations-term.php:30
|
414 |
-
msgid "Add new"
|
415 |
-
msgstr "Aggiungi nuovo"
|
416 |
-
|
417 |
-
#: include/widget-languages.php:16
|
418 |
-
msgid "Language Switcher"
|
419 |
-
msgstr "Selettore di lingua"
|
420 |
-
|
421 |
-
#: include/widget-languages.php:16
|
422 |
-
msgid "Displays a language switcher"
|
423 |
-
msgstr "Visualizza un selettore di lingua"
|
424 |
-
|
425 |
-
#: include/widget-languages.php:75
|
426 |
-
msgid "Title:"
|
427 |
-
msgstr "Titolo:"
|
428 |
-
|
429 |
-
# @ polylang
|
430 |
-
#. translators: plugin header field 'Description'
|
431 |
-
#: polylang.php:0
|
432 |
-
msgid "Adds multilingual capability to WordPress"
|
433 |
-
msgstr "Aggiungi funzionalità multilingua a WordPress"
|
434 |
-
|
435 |
-
#: install/install.php:24
|
436 |
-
#, php-format
|
437 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
438 |
-
msgstr ""
|
439 |
-
"Si sta utilizzando WordPress %s. Polylang richiede almeno WordPress %s."
|
440 |
-
|
441 |
-
# @ polylang
|
442 |
-
#: install/upgrade.php:76
|
443 |
-
msgid ""
|
444 |
-
"Polylang has been deactivated because you upgraded from a too old version."
|
445 |
-
msgstr ""
|
446 |
-
"Polylang è stato disabilitato perché è stato fatto un'aggiornamento da una "
|
447 |
-
"versione troppo vecchia."
|
448 |
-
|
449 |
-
# @ polylang
|
450 |
-
#: install/upgrade.php:78
|
451 |
-
#, php-format
|
452 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
453 |
-
msgstr "È necessario aggiornare alla %s prima di aggiornare alla %s."
|
454 |
-
|
455 |
-
# @ polylang
|
456 |
-
#: admin/table-string.php:109
|
457 |
-
msgid "Group"
|
458 |
-
msgstr "Gruppo"
|
459 |
-
|
460 |
-
# @ polylang
|
461 |
-
#: admin/table-string.php:187
|
462 |
-
msgid "View all groups"
|
463 |
-
msgstr "Visualizza tutti i gruppi"
|
464 |
-
|
465 |
-
# @ polylang
|
466 |
-
#: admin/table-languages.php:59
|
467 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
468 |
-
msgstr "Si sta per cancellare permanentemente questa lingua. Siete sicuri?"
|
469 |
-
|
470 |
-
# @ polylang
|
471 |
-
#: admin/view-tab-strings.php:12
|
472 |
-
msgid ""
|
473 |
-
"Use this to remove unused strings from database, for example after a plugin "
|
474 |
-
"has been uninstalled."
|
475 |
-
msgstr ""
|
476 |
-
"Usare questo per rimuovere stringhe inutilizzate dal database, per esempio "
|
477 |
-
"dopo la disinstallazione di un plugin."
|
478 |
-
|
479 |
-
# @ polylang
|
480 |
-
#: admin/view-tab-settings.php:226
|
481 |
-
msgid ""
|
482 |
-
"The synchronization options allow to maintain exact same values (or "
|
483 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
484 |
-
"between the translations of a post or page."
|
485 |
-
msgstr ""
|
486 |
-
"Le opzioni di sincronizzazione permettono di mantenere esattamente gli "
|
487 |
-
"stessi valori (o traduzioni, nel caso di tassonomie e pagine genitore) del "
|
488 |
-
"meta contenuto tra le traduzioni di un articolo o una pagina."
|
489 |
-
|
490 |
-
#: admin/admin-model.php:248
|
491 |
-
msgid "The language code contains invalid characters"
|
492 |
-
msgstr "Il codice della lingua contiene caratteri non validi"
|
493 |
-
|
494 |
-
# @ polylang
|
495 |
-
#: admin/view-tab-settings.php:43
|
496 |
-
msgid "The language is set from content"
|
497 |
-
msgstr "La lingua viene impostata dal contenuto"
|
498 |
-
|
499 |
-
#: admin/view-tab-settings.php:46
|
500 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
501 |
-
msgstr "Gli URL di articoli, pagine, categorie e tag non vengono modificati. "
|
502 |
-
|
503 |
-
#: admin/view-tab-settings.php:51
|
504 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
505 |
-
msgstr ""
|
506 |
-
"La lingua viene impostata dal nome della directory nei pretty permalink"
|
507 |
-
|
508 |
-
# @ polylang
|
509 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
510 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
511 |
-
msgid "Example:"
|
512 |
-
msgstr "Esempio:"
|
513 |
-
|
514 |
-
#: admin/view-tab-settings.php:60
|
515 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
516 |
-
msgstr ""
|
517 |
-
"La lingua viene impostata dal nome del sottodominio nei pretty permalink"
|
518 |
-
|
519 |
-
# @ polylang
|
520 |
-
#: admin/view-tab-settings.php:69
|
521 |
-
msgid "The language is set from different domains"
|
522 |
-
msgstr "La lingua è impostata da domini diversi"
|
523 |
-
|
524 |
-
#: admin/view-tab-settings.php:107
|
525 |
-
msgid "Remove /language/ in pretty permalinks"
|
526 |
-
msgstr "Rimuove /language/ dai pretty permalink"
|
527 |
-
|
528 |
-
#: admin/view-tab-settings.php:116
|
529 |
-
msgid "Keep /language/ in pretty permalinks"
|
530 |
-
msgstr "Mantiene /language/ nei pretty permalink"
|
531 |
-
|
532 |
-
# @ polylang
|
533 |
-
#: admin/view-tab-settings.php:131
|
534 |
-
msgid ""
|
535 |
-
"The front page url contains the language code instead of the page name or "
|
536 |
-
"page id"
|
537 |
-
msgstr ""
|
538 |
-
"L'URL della pagina iniziale contiene il codice della lingua invece del suo "
|
539 |
-
"nome o del suo ID "
|
540 |
-
|
541 |
-
# @ polylang
|
542 |
-
#: admin/view-tab-settings.php:139
|
543 |
-
#, php-format
|
544 |
-
msgid "Example: %s instead of %s"
|
545 |
-
msgstr "Esempio: %s invece di %s"
|
546 |
-
|
547 |
-
#: admin/admin-model.php:38
|
548 |
-
msgid "Impossible to add the language."
|
549 |
-
msgstr "Non è possibile aggiungere la lingua."
|
550 |
-
|
551 |
-
# @ polylang
|
552 |
-
#: admin/admin-model.php:66
|
553 |
-
msgid "Language added."
|
554 |
-
msgstr "La lingua è stata aggiunta."
|
555 |
-
|
556 |
-
# @ polylang
|
557 |
-
#: admin/admin-model.php:146
|
558 |
-
msgid "Language deleted."
|
559 |
-
msgstr "La lingua è stata eliminata"
|
560 |
-
|
561 |
-
# @ polylang
|
562 |
-
#: admin/admin-model.php:227
|
563 |
-
msgid "Language updated."
|
564 |
-
msgstr "La lingua è stata aggiornata."
|
565 |
-
|
566 |
-
# @ polylang
|
567 |
-
#: admin/settings.php:239
|
568 |
-
msgid "Translations updated."
|
569 |
-
msgstr "Le traduzioni sono state aggiornate."
|
570 |
-
|
571 |
-
#: admin/view-tab-lang.php:72
|
572 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
573 |
-
msgstr ""
|
574 |
-
"Codice della lingua - preferibilmente del tipo ISO 639-1 a 2 lettere (per "
|
575 |
-
"esempio: en) "
|
576 |
-
|
577 |
-
# @ polylang
|
578 |
-
#: admin/admin-filters.php:203
|
579 |
-
msgid "The chosen static front page must be translated in all languages."
|
580 |
-
msgstr ""
|
581 |
-
"La pagina iniziale statica prescelta deve essere tradotta in tutte le lingue"
|
582 |
-
|
583 |
-
#: admin/admin-strings.php:60
|
584 |
-
msgid "Widget text"
|
585 |
-
msgstr "Testo del widget"
|
586 |
-
|
587 |
-
# @ polylang
|
588 |
-
#: admin/settings.php:52
|
589 |
-
msgid "Recommended plugins"
|
590 |
-
msgstr "Plugin raccomandati"
|
591 |
-
|
592 |
-
# @ polylang
|
593 |
-
#: admin/view-tab-settings.php:51
|
594 |
-
msgid "The language is set from the code in the URL"
|
595 |
-
msgstr "La lingua viene impostata dal codice dell'URL"
|
596 |
-
|
597 |
-
# @ polylang
|
598 |
-
#: include/switcher.php:26
|
599 |
-
msgid "Hides languages with no translation"
|
600 |
-
msgstr "Nasconde lingue senza traduzione"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-ja.mo
DELETED
Binary file
|
languages/polylang-ja.po
DELETED
@@ -1,612 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: Polylang v1.7beta1\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: \n"
|
6 |
-
"PO-Revision-Date: 2015-07-18 08:55+0200\n"
|
7 |
-
"Last-Translator: \n"
|
8 |
-
"Language-Team: \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;_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"
|
15 |
-
"X-Poedit-Basepath: ..\n"
|
16 |
-
"X-Textdomain-Support: yes\n"
|
17 |
-
"Language: ja\n"
|
18 |
-
"X-Generator: Poedit 1.8.2\n"
|
19 |
-
"X-Poedit-SearchPath-0: .\n"
|
20 |
-
|
21 |
-
# @ polylang
|
22 |
-
#: admin/view-about.php:3
|
23 |
-
#, php-format
|
24 |
-
msgid "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 programmers to adapt their plugins and themes."
|
25 |
-
msgstr "Polylang は、多言語サイトをセットアップする方法や日常的に使用する方法から FAQ まで、包括的な内容を盛り込んだ%sドキュメンテーション%s (English のみ) を参照して活用できます。また、プログラマーが独自のプラグインやテーマを Polylang に対応させるためのドキュメンテーションも用意されています。"
|
26 |
-
|
27 |
-
# @ polylang
|
28 |
-
#: admin/view-about.php:9
|
29 |
-
#, php-format
|
30 |
-
msgid "You will also find useful information in the %ssupport forum%s. However don't forget to make a search before posting a new topic."
|
31 |
-
msgstr "さらに、%sサポートフォーラム%sで必要な情報を入手することもできます。ただし、新規トピックを投稿する前に、同じようなトピックがないか検索してください。"
|
32 |
-
|
33 |
-
# @ polylang
|
34 |
-
#: admin/view-about.php:16
|
35 |
-
#, php-format
|
36 |
-
msgid "Polylang is free of charge and is released under the same license as WordPress, the %sGPL%s."
|
37 |
-
msgstr "Polyland は無料であり、WordPress と同じライセンスである %sGPL%s でリリースされています。"
|
38 |
-
|
39 |
-
# @ polylang
|
40 |
-
#: admin/view-about.php:22
|
41 |
-
#, php-format
|
42 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
43 |
-
msgstr "「このプロジェクトの役に立てれば」とお考えの方は、%sこちら%sをお読みください。"
|
44 |
-
|
45 |
-
# @ polylang If I translate literally, it sounds redundant (the string before sounds similar). So I transalted as "Also, (I) will be grateful if you can support/help (me) in the form of donation."
|
46 |
-
#: admin/view-about.php:27
|
47 |
-
msgid "Finally if you like this plugin or if it helps your business, donations to the author are greatly appreciated."
|
48 |
-
msgstr "また、寄付という形でご支援をいただければ大変幸甚です (右下の Donate ボタンをクリックしてください)。"
|
49 |
-
|
50 |
-
# @ polylang
|
51 |
-
#: admin/admin-filters-post.php:115 admin/admin.php:90 admin/settings.php:70
|
52 |
-
#: admin/settings.php:97 include/model.php:561
|
53 |
-
msgid "Languages"
|
54 |
-
msgstr "言語"
|
55 |
-
|
56 |
-
# @ polylang
|
57 |
-
#: include/switcher.php:22
|
58 |
-
msgid "Displays language names"
|
59 |
-
msgstr "言語名を表示する"
|
60 |
-
|
61 |
-
# @ polylang
|
62 |
-
#: include/switcher.php:23
|
63 |
-
msgid "Displays flags"
|
64 |
-
msgstr "国旗を表示する"
|
65 |
-
|
66 |
-
# @ polylang
|
67 |
-
#: include/switcher.php:24
|
68 |
-
msgid "Forces link to front page"
|
69 |
-
msgstr "フロントページへのリンクを強制する"
|
70 |
-
|
71 |
-
# @ polylang
|
72 |
-
#: include/switcher.php:25
|
73 |
-
msgid "Hides the current language"
|
74 |
-
msgstr "現在の言語を非表示にする"
|
75 |
-
|
76 |
-
# @ polylang
|
77 |
-
#: include/switcher.php:30
|
78 |
-
msgid "Displays as dropdown"
|
79 |
-
msgstr "ドロップダウンとして表示する"
|
80 |
-
|
81 |
-
# @ polylang
|
82 |
-
#: admin/admin.php:267
|
83 |
-
msgid "Filters content by language"
|
84 |
-
msgstr "言語でコンテンツをフィルターする"
|
85 |
-
|
86 |
-
# @ polylang
|
87 |
-
#: admin/admin.php:258
|
88 |
-
msgid "Show all languages"
|
89 |
-
msgstr "すべての言語を表示"
|
90 |
-
|
91 |
-
# @ polylang
|
92 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
93 |
-
msgid "Add new translation"
|
94 |
-
msgstr "翻訳を追加"
|
95 |
-
|
96 |
-
# @ polylang
|
97 |
-
#: admin/admin-filters-columns.php:173 admin/admin-filters-media.php:55
|
98 |
-
#: admin/admin-filters-post.php:141 admin/admin-filters-term.php:75
|
99 |
-
#: admin/admin-filters-term.php:122 include/model.php:562
|
100 |
-
msgid "Language"
|
101 |
-
msgstr "言語"
|
102 |
-
|
103 |
-
# @ polylang
|
104 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
105 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
106 |
-
#: admin/view-translations-term.php:11
|
107 |
-
msgid "Translations"
|
108 |
-
msgstr "翻訳"
|
109 |
-
|
110 |
-
# @ polylang
|
111 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
112 |
-
msgid "Sets the language"
|
113 |
-
msgstr "言語を設定する"
|
114 |
-
|
115 |
-
# @ polylang
|
116 |
-
#: admin/admin-filters.php:52
|
117 |
-
msgid "The widget is displayed for:"
|
118 |
-
msgstr "ウジェットを表示する言語:"
|
119 |
-
|
120 |
-
# @ polylang
|
121 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
122 |
-
msgid "All languages"
|
123 |
-
msgstr "すべての言語"
|
124 |
-
|
125 |
-
# @ polylang I've seen this somewhere, but I don't remember. I translated as "Language for administration." Is this OK?
|
126 |
-
#: admin/admin-filters.php:123
|
127 |
-
msgid "Admin language"
|
128 |
-
msgstr "管理用言語"
|
129 |
-
|
130 |
-
# @ polylang
|
131 |
-
#: admin/admin-filters.php:126
|
132 |
-
msgid "WordPress default"
|
133 |
-
msgstr "WordPress のデフォルト"
|
134 |
-
|
135 |
-
# @ polylang
|
136 |
-
#: admin/admin.php:167 admin/settings.php:102
|
137 |
-
msgid "Settings"
|
138 |
-
msgstr "設定"
|
139 |
-
|
140 |
-
# @ polylang
|
141 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
142 |
-
msgid "Upgrading language files…"
|
143 |
-
msgstr "言語ファイルのアップグレード中…"
|
144 |
-
|
145 |
-
# @ polylang
|
146 |
-
#: admin/settings.php:62
|
147 |
-
msgid "About Polylang"
|
148 |
-
msgstr "Polylang について"
|
149 |
-
|
150 |
-
# @ polylang
|
151 |
-
#: admin/settings.php:78
|
152 |
-
msgid "Strings translations"
|
153 |
-
msgstr "文字列翻訳"
|
154 |
-
|
155 |
-
# @ polylang
|
156 |
-
#: admin/settings.php:101
|
157 |
-
msgid "Strings translation"
|
158 |
-
msgstr "文字列翻訳"
|
159 |
-
|
160 |
-
# @ polylang
|
161 |
-
#: admin/admin-model.php:244
|
162 |
-
msgid "Enter a valid WordPress locale"
|
163 |
-
msgstr "有効な WordPress ロケールを入力してください"
|
164 |
-
|
165 |
-
# @ polylang
|
166 |
-
#: admin/admin-model.php:252
|
167 |
-
msgid "The language code must be unique"
|
168 |
-
msgstr "言語コードは一意である必要があります"
|
169 |
-
|
170 |
-
# @ polylang
|
171 |
-
#: admin/admin-model.php:256
|
172 |
-
msgid "The language must have a name"
|
173 |
-
msgstr "言語に名称が必要です"
|
174 |
-
|
175 |
-
# @ polylang
|
176 |
-
#: admin/admin.php:367 admin/settings.php:180
|
177 |
-
msgid "The language was created, but the WordPress language file was not downloaded. Please install it manually."
|
178 |
-
msgstr "言語は作成されましたが、WordPress の言語ファイルはダウンロードされませんでした。このファイルを手動でインストールしてください。"
|
179 |
-
|
180 |
-
# @ polylang
|
181 |
-
#: admin/admin-strings.php:59
|
182 |
-
msgid "Widget title"
|
183 |
-
msgstr "ウィジェットのタイトル"
|
184 |
-
|
185 |
-
# @ polylang
|
186 |
-
#: admin/settings.php:319
|
187 |
-
msgid "Taxonomies"
|
188 |
-
msgstr "タクソノミー"
|
189 |
-
|
190 |
-
# @ polylang
|
191 |
-
#: admin/settings.php:320
|
192 |
-
msgid "Custom fields"
|
193 |
-
msgstr "カスタムフィールド"
|
194 |
-
|
195 |
-
# @ polylang
|
196 |
-
#: admin/settings.php:321
|
197 |
-
msgid "Comment status"
|
198 |
-
msgstr "コメントのステータス"
|
199 |
-
|
200 |
-
# @ polylang
|
201 |
-
#: admin/settings.php:322
|
202 |
-
msgid "Ping status"
|
203 |
-
msgstr "Ping のステータス"
|
204 |
-
|
205 |
-
# @ polylang
|
206 |
-
#: admin/settings.php:323
|
207 |
-
msgid "Sticky posts"
|
208 |
-
msgstr "付箋紙"
|
209 |
-
|
210 |
-
# @ polylang
|
211 |
-
#: admin/settings.php:324
|
212 |
-
msgid "Published date"
|
213 |
-
msgstr "公開日"
|
214 |
-
|
215 |
-
# @ polylang
|
216 |
-
#: admin/settings.php:325
|
217 |
-
msgid "Post format"
|
218 |
-
msgstr "投稿フォーマット"
|
219 |
-
|
220 |
-
# @ polylang
|
221 |
-
#: admin/settings.php:326
|
222 |
-
msgid "Page parent"
|
223 |
-
msgstr "親ページ"
|
224 |
-
|
225 |
-
# @ polylang
|
226 |
-
#: admin/settings.php:327
|
227 |
-
msgid "Page template"
|
228 |
-
msgstr "ページテンプレート"
|
229 |
-
|
230 |
-
# @ polylang
|
231 |
-
#: admin/settings.php:328
|
232 |
-
msgid "Page order"
|
233 |
-
msgstr "ページの順序"
|
234 |
-
|
235 |
-
# @ polylang
|
236 |
-
#: admin/settings.php:329
|
237 |
-
msgid "Featured image"
|
238 |
-
msgstr "アイキャッチ画像"
|
239 |
-
|
240 |
-
# @ polylang
|
241 |
-
#: admin/view-tab-lang.php:21
|
242 |
-
msgid "Edit language"
|
243 |
-
msgstr "言語を編集"
|
244 |
-
|
245 |
-
# @ polylang
|
246 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
247 |
-
msgid "Add new language"
|
248 |
-
msgstr "言語を追加"
|
249 |
-
|
250 |
-
# @ polylang
|
251 |
-
#: admin/view-tab-lang.php:37
|
252 |
-
msgid "Choose a language"
|
253 |
-
msgstr "言語を選択"
|
254 |
-
|
255 |
-
# @ polylang
|
256 |
-
#: admin/view-tab-lang.php:51
|
257 |
-
msgid "You can choose a language in the list or directly edit it below."
|
258 |
-
msgstr "リストから言語を選択するか、以下で言語を直接編集してください。"
|
259 |
-
|
260 |
-
# @ polylang
|
261 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
262 |
-
msgid "Full name"
|
263 |
-
msgstr "名称"
|
264 |
-
|
265 |
-
# @ polylang
|
266 |
-
#: admin/view-tab-lang.php:57
|
267 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
268 |
-
msgstr "サイトに表示される名称 (「English」など)。"
|
269 |
-
|
270 |
-
# @ polylang
|
271 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
272 |
-
msgid "Locale"
|
273 |
-
msgstr "ロケール"
|
274 |
-
|
275 |
-
# @ polylang
|
276 |
-
#: admin/view-tab-lang.php:66
|
277 |
-
msgid "WordPress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
|
278 |
-
msgstr "言語の WordPress ロケール (「en_GB」など)。この言語の .mo ファイルをインストールする必要があります。"
|
279 |
-
|
280 |
-
# @ polylang
|
281 |
-
#: admin/view-tab-lang.php:70
|
282 |
-
msgid "Language code"
|
283 |
-
msgstr "言語コード"
|
284 |
-
|
285 |
-
# @ polylang
|
286 |
-
#: admin/view-tab-lang.php:76
|
287 |
-
msgid "Text direction"
|
288 |
-
msgstr "テキストの方向"
|
289 |
-
|
290 |
-
# @ polylang
|
291 |
-
#: admin/view-tab-lang.php:80
|
292 |
-
msgid "left to right"
|
293 |
-
msgstr "左から右"
|
294 |
-
|
295 |
-
# @ polylang
|
296 |
-
#: admin/view-tab-lang.php:85
|
297 |
-
msgid "right to left"
|
298 |
-
msgstr "右から左"
|
299 |
-
|
300 |
-
# @ polylang
|
301 |
-
#: admin/view-tab-lang.php:87
|
302 |
-
msgid "Choose the text direction for the language"
|
303 |
-
msgstr "この言語のテキストの方向を選択してください"
|
304 |
-
|
305 |
-
# @ polylang
|
306 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
307 |
-
msgid "Order"
|
308 |
-
msgstr "順序"
|
309 |
-
|
310 |
-
# @ polylang
|
311 |
-
#: admin/view-tab-lang.php:93
|
312 |
-
msgid "Position of the language in the language switcher"
|
313 |
-
msgstr "この言語の言語スイッチャーでの位置を指定してください"
|
314 |
-
|
315 |
-
# @ polylang
|
316 |
-
#: admin/admin-nav-menu.php:54 admin/admin-nav-menu.php:92
|
317 |
-
#: admin/admin-nav-menu.php:95 admin/admin-nav-menu.php:126
|
318 |
-
#: admin/admin-nav-menu.php:188 install/upgrade.php:301
|
319 |
-
msgid "Language switcher"
|
320 |
-
msgstr "言語スイッチャー"
|
321 |
-
|
322 |
-
# @ polylang
|
323 |
-
#: admin/view-tab-strings.php:8
|
324 |
-
msgid "Search translations"
|
325 |
-
msgstr "翻訳を検索"
|
326 |
-
|
327 |
-
# @ polylang
|
328 |
-
#: admin/view-tab-strings.php:11
|
329 |
-
msgid "Clean strings translation database"
|
330 |
-
msgstr "文字列翻訳データベースをクリーンアップする"
|
331 |
-
|
332 |
-
# @ polylang
|
333 |
-
#: admin/view-tab-settings.php:14
|
334 |
-
msgid "Default language"
|
335 |
-
msgstr "デフォルトの言語"
|
336 |
-
|
337 |
-
# @ polylang I don't know how to translate this "set." I need to know what "without language set" means.
|
338 |
-
#: admin/view-tab-settings.php:29
|
339 |
-
msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
|
340 |
-
msgstr "言語が設定されていない投稿、ページ、カテゴリー、またはタグがあります。これらすべてをデフォルトの言語に設定しますか?"
|
341 |
-
|
342 |
-
# @ polylang
|
343 |
-
#: admin/view-tab-settings.php:149
|
344 |
-
msgid "Detect browser language"
|
345 |
-
msgstr "ブラウザーの言語の検出"
|
346 |
-
|
347 |
-
# @ polylang
|
348 |
-
#: admin/view-tab-settings.php:155
|
349 |
-
msgid "When the front page is visited, set the language according to the browser preference"
|
350 |
-
msgstr "フロントページへのアクセスがあったときに、ブラウザーの環境設定に応じて言語を設定する"
|
351 |
-
|
352 |
-
# @ polylang
|
353 |
-
#: admin/view-tab-settings.php:37
|
354 |
-
msgid "URL modifications"
|
355 |
-
msgstr "URL の修正"
|
356 |
-
|
357 |
-
# @ polylang I translated as "Do not show language information for default language in URL."
|
358 |
-
#: admin/view-tab-settings.php:93
|
359 |
-
msgid "Hide URL language information for default language"
|
360 |
-
msgstr "URL にデフォルトの言語の言語情報を表示しない"
|
361 |
-
|
362 |
-
# @ polylang
|
363 |
-
#: admin/view-tab-settings.php:162
|
364 |
-
msgid "Media"
|
365 |
-
msgstr "メディア"
|
366 |
-
|
367 |
-
# @ polylang
|
368 |
-
#: admin/view-tab-settings.php:168
|
369 |
-
msgid "Activate languages and translations for media"
|
370 |
-
msgstr "メディアの言語と翻訳を有効にする"
|
371 |
-
|
372 |
-
# @ polylang
|
373 |
-
#: admin/view-tab-settings.php:215
|
374 |
-
msgid "Synchronization"
|
375 |
-
msgstr "同期"
|
376 |
-
|
377 |
-
# @ polylang
|
378 |
-
#: admin/view-tab-settings.php:176
|
379 |
-
msgid "Custom post types"
|
380 |
-
msgstr "カスタム投稿タイプ"
|
381 |
-
|
382 |
-
# @ polylang
|
383 |
-
#: admin/view-tab-settings.php:189
|
384 |
-
msgid "Activate languages and translations for custom post types."
|
385 |
-
msgstr "カスタム投稿タイプの言語と翻訳を有効にする"
|
386 |
-
|
387 |
-
# @ polylang
|
388 |
-
#: admin/view-tab-settings.php:196
|
389 |
-
msgid "Custom taxonomies"
|
390 |
-
msgstr "カスタムタクソノミー"
|
391 |
-
|
392 |
-
# @ polylang
|
393 |
-
#: admin/view-tab-settings.php:209
|
394 |
-
msgid "Activate languages and translations for custom taxonomies."
|
395 |
-
msgstr "カスタムタクソノミーの言語と翻訳を有効にする"
|
396 |
-
|
397 |
-
# @ polylang
|
398 |
-
#: admin/admin-filters-post.php:433 admin/admin-filters-term.php:642
|
399 |
-
#: admin/table-languages.php:54 admin/view-translations-media.php:21
|
400 |
-
msgid "Edit"
|
401 |
-
msgstr "編集"
|
402 |
-
|
403 |
-
# @ polylang
|
404 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
405 |
-
msgid "Delete"
|
406 |
-
msgstr "削除"
|
407 |
-
|
408 |
-
# @ polylang
|
409 |
-
#: admin/table-languages.php:76
|
410 |
-
msgid "Code"
|
411 |
-
msgstr "コード"
|
412 |
-
|
413 |
-
# @ polylang
|
414 |
-
#: admin/table-languages.php:78
|
415 |
-
msgid "Flag"
|
416 |
-
msgstr "国旗"
|
417 |
-
|
418 |
-
# @ polylang
|
419 |
-
#: admin/table-languages.php:79
|
420 |
-
msgid "Posts"
|
421 |
-
msgstr "投稿"
|
422 |
-
|
423 |
-
# @ polylang
|
424 |
-
#: admin/table-string.php:110
|
425 |
-
msgid "Name"
|
426 |
-
msgstr "名前"
|
427 |
-
|
428 |
-
# @ polylang
|
429 |
-
#: admin/table-string.php:111
|
430 |
-
msgid "String"
|
431 |
-
msgstr "文字列"
|
432 |
-
|
433 |
-
# @ polylang
|
434 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
435 |
-
#: admin/view-translations-term.php:30
|
436 |
-
msgid "Add new"
|
437 |
-
msgstr "新規追加"
|
438 |
-
|
439 |
-
# @ polylang
|
440 |
-
#: include/widget-languages.php:16
|
441 |
-
msgid "Language Switcher"
|
442 |
-
msgstr "言語スイッチャー"
|
443 |
-
|
444 |
-
# @ polylang
|
445 |
-
#: include/widget-languages.php:16
|
446 |
-
msgid "Displays a language switcher"
|
447 |
-
msgstr "言語スイッチャーを表示する"
|
448 |
-
|
449 |
-
# @ polylang
|
450 |
-
#: include/widget-languages.php:75
|
451 |
-
msgid "Title:"
|
452 |
-
msgstr "タイトル:"
|
453 |
-
|
454 |
-
# @ polylang
|
455 |
-
#. translators: plugin header field 'Description'
|
456 |
-
#: polylang.php:0
|
457 |
-
msgid "Adds multilingual capability to WordPress"
|
458 |
-
msgstr "WordPress に多言語機能を追加する"
|
459 |
-
|
460 |
-
# @ polylang
|
461 |
-
#: install/install.php:24
|
462 |
-
#, php-format
|
463 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
464 |
-
msgstr "WordPress %s を使用されています。Polylang を使用するには、WordPress %s 以降が必要です。"
|
465 |
-
|
466 |
-
# @ polylang
|
467 |
-
#: install/upgrade.php:76
|
468 |
-
msgid "Polylang has been deactivated because you upgraded from a too old version."
|
469 |
-
msgstr "アップグレード元のバージョンが古いため、Polylang は無効になっています。"
|
470 |
-
|
471 |
-
# @ polylang
|
472 |
-
#: install/upgrade.php:78
|
473 |
-
#, php-format
|
474 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
475 |
-
msgstr "%s にアップグレードする前に、まず %s にアップグレードしてください。"
|
476 |
-
|
477 |
-
# @ polylang
|
478 |
-
#: admin/table-string.php:109
|
479 |
-
msgid "Group"
|
480 |
-
msgstr "グループ"
|
481 |
-
|
482 |
-
# @ polylang
|
483 |
-
#: admin/table-string.php:187
|
484 |
-
msgid "View all groups"
|
485 |
-
msgstr "すべてのグループを表示"
|
486 |
-
|
487 |
-
# @ polylang
|
488 |
-
#: admin/table-languages.php:59
|
489 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
490 |
-
msgstr "この言語を完全に削除しますか?"
|
491 |
-
|
492 |
-
# @ polylang
|
493 |
-
#: admin/view-tab-strings.php:12
|
494 |
-
msgid "Use this to remove unused strings from database, for example after a plugin has been uninstalled."
|
495 |
-
msgstr "これをオンにすると、使用されていない文字列がデータベースから削除されます (プラグインをアンインストールした後など)。"
|
496 |
-
|
497 |
-
# @ polylang I translated as "The synchronization options allow to synchronize values (or translations ..."
|
498 |
-
#: admin/view-tab-settings.php:226
|
499 |
-
msgid "The synchronization options allow to maintain exact same values (or translations in the case of taxonomies and page parent) of meta content between the translations of a post or page."
|
500 |
-
msgstr "同期オプションを使用することにより、投稿の翻訳とページの翻訳の間で、メタコンテンツの値 (タクソノミーと親ページの場合は翻訳)を同期させることができます。"
|
501 |
-
|
502 |
-
# @ polylang
|
503 |
-
#: admin/admin-model.php:248
|
504 |
-
msgid "The language code contains invalid characters"
|
505 |
-
msgstr "言語コードに無効な文字が含まれています"
|
506 |
-
|
507 |
-
# @ polylang
|
508 |
-
#: admin/view-tab-settings.php:43
|
509 |
-
msgid "The language is set from content"
|
510 |
-
msgstr "言語はコンテンツから設定される"
|
511 |
-
|
512 |
-
# @ polylang
|
513 |
-
#: admin/view-tab-settings.php:46
|
514 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
515 |
-
msgstr "投稿、ページ、カテゴリー、およびタグの URL は修正されません。"
|
516 |
-
|
517 |
-
# @ polylang
|
518 |
-
#: admin/view-tab-settings.php:51
|
519 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
520 |
-
msgstr "言語はプリティーパーマリンク内のディレクトリ名から設定される"
|
521 |
-
|
522 |
-
# @ polylang
|
523 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
524 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
525 |
-
msgid "Example:"
|
526 |
-
msgstr "例:"
|
527 |
-
|
528 |
-
# @ polylang
|
529 |
-
#: admin/view-tab-settings.php:60
|
530 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
531 |
-
msgstr "言語はプリティーパーマリンク内のサブドメイン名から設定される"
|
532 |
-
|
533 |
-
# @ polylang
|
534 |
-
#: admin/view-tab-settings.php:69
|
535 |
-
msgid "The language is set from different domains"
|
536 |
-
msgstr "言語は他のドメインから設定される"
|
537 |
-
|
538 |
-
# @ polylang
|
539 |
-
#: admin/view-tab-settings.php:107
|
540 |
-
msgid "Remove /language/ in pretty permalinks"
|
541 |
-
msgstr "プリティーパーマリンクの /language/ を削除する"
|
542 |
-
|
543 |
-
# @ polylang
|
544 |
-
#: admin/view-tab-settings.php:116
|
545 |
-
msgid "Keep /language/ in pretty permalinks"
|
546 |
-
msgstr "プリティーパーマリンクの /language/ を維持する"
|
547 |
-
|
548 |
-
# @ polylang
|
549 |
-
#: admin/view-tab-settings.php:131
|
550 |
-
msgid "The front page url contains the language code instead of the page name or page id"
|
551 |
-
msgstr "フロントページの URL にページ名またはページ ID の代わりに言語コードが含まれています"
|
552 |
-
|
553 |
-
# @ polylang
|
554 |
-
#: admin/view-tab-settings.php:139
|
555 |
-
#, php-format
|
556 |
-
msgid "Example: %s instead of %s"
|
557 |
-
msgstr "例: %s ではなく %s"
|
558 |
-
|
559 |
-
# @ polylang
|
560 |
-
#: admin/admin-model.php:38
|
561 |
-
msgid "Impossible to add the language."
|
562 |
-
msgstr "この言語は追加できません。"
|
563 |
-
|
564 |
-
# @ polylang
|
565 |
-
#: admin/admin-model.php:66
|
566 |
-
msgid "Language added."
|
567 |
-
msgstr "言語が追加されました。"
|
568 |
-
|
569 |
-
# @ polylang
|
570 |
-
#: admin/admin-model.php:146
|
571 |
-
msgid "Language deleted."
|
572 |
-
msgstr "言語が削除されました。"
|
573 |
-
|
574 |
-
# @ polylang
|
575 |
-
#: admin/admin-model.php:227
|
576 |
-
msgid "Language updated."
|
577 |
-
msgstr "言語が更新されました。"
|
578 |
-
|
579 |
-
# @ polylang
|
580 |
-
#: admin/settings.php:239
|
581 |
-
msgid "Translations updated."
|
582 |
-
msgstr "翻訳が更新されました。"
|
583 |
-
|
584 |
-
# @ polylang
|
585 |
-
#: admin/view-tab-lang.php:72
|
586 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
587 |
-
msgstr "言語コード。ISO 639-1 準拠の 2 文字 (「en」など) を使用することを推奨します。"
|
588 |
-
|
589 |
-
# @ polylang
|
590 |
-
#: admin/admin-filters.php:203
|
591 |
-
msgid "The chosen static front page must be translated in all languages."
|
592 |
-
msgstr "選択されている静的フロントページは、すべての言語で翻訳されている必要があります。"
|
593 |
-
|
594 |
-
# @ polylang
|
595 |
-
#: admin/admin-strings.php:60
|
596 |
-
msgid "Widget text"
|
597 |
-
msgstr "ウィジェットのテキスト"
|
598 |
-
|
599 |
-
# @ polylang
|
600 |
-
#: admin/settings.php:52
|
601 |
-
msgid "Recommended plugins"
|
602 |
-
msgstr "推奨プラグイン"
|
603 |
-
|
604 |
-
# @ polylang
|
605 |
-
#: admin/view-tab-settings.php:51
|
606 |
-
msgid "The language is set from the code in the URL"
|
607 |
-
msgstr "言語は URL 内のコードから設定される"
|
608 |
-
|
609 |
-
# @ polylang
|
610 |
-
#: include/switcher.php:26
|
611 |
-
msgid "Hides languages with no translation"
|
612 |
-
msgstr "翻訳がない言語を非表示にする"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-nl_NL.mo
DELETED
Binary file
|
languages/polylang-nl_NL.po
DELETED
@@ -1,656 +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: \n"
|
8 |
-
"Language-Team: \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: nl_NL\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 is voorzien van uitgebreide %sdocumentatie%s (alleen in engels). "
|
32 |
-
"Dit omvat informatie hoe een meertalige site opgezet kan worden en het "
|
33 |
-
"gebruik op dagelijkse basis, een FAQ en ook documentatie voor ontwikkelaars "
|
34 |
-
"voor het aanpassen van hun plugins en thema's."
|
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 |
-
"Je kunt ook bruikbare information vinden in het %s support forum%s. Vergeet "
|
44 |
-
"niet eerst een zoekopdracht uit te voeren voordat je een nieuw item post."
|
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 is gratis te gebruiken en is vrijgegeven onder dezelfde licentie "
|
54 |
-
"als WordPress, de %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 "Ben je benieuwd hoe je dit project kan ondersteunen, %slees dit%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 |
-
"Tot slot, wanneer deze plugin je bevalt of wanneer het jouw bedrijfsvoering "
|
69 |
-
"ondersteunt, donaties ten behoeve van de auteur wordt zeer gewaardeerd."
|
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 "Talen"
|
76 |
-
|
77 |
-
# @ polylang
|
78 |
-
#: include/switcher.php:22
|
79 |
-
msgid "Displays language names"
|
80 |
-
msgstr "Toon namen van talen"
|
81 |
-
|
82 |
-
# @ polylang
|
83 |
-
#: include/switcher.php:23
|
84 |
-
msgid "Displays flags"
|
85 |
-
msgstr "Toon vlaggen"
|
86 |
-
|
87 |
-
# @ polylang
|
88 |
-
#: include/switcher.php:24
|
89 |
-
msgid "Forces link to front page"
|
90 |
-
msgstr "Forceer link naar startpagina"
|
91 |
-
|
92 |
-
# @ polylang
|
93 |
-
#: include/switcher.php:25
|
94 |
-
msgid "Hides the current language"
|
95 |
-
msgstr "Verberg huidige taal"
|
96 |
-
|
97 |
-
# @ polylang
|
98 |
-
#: include/switcher.php:30
|
99 |
-
msgid "Displays as dropdown"
|
100 |
-
msgstr "Toon als dropdown"
|
101 |
-
|
102 |
-
# @ polylang
|
103 |
-
#: admin/admin.php:267
|
104 |
-
msgid "Filters content by language"
|
105 |
-
msgstr ""
|
106 |
-
|
107 |
-
# @ polylang
|
108 |
-
#: admin/admin.php:258
|
109 |
-
msgid "Show all languages"
|
110 |
-
msgstr "Toon alle talen"
|
111 |
-
|
112 |
-
# @ polylang
|
113 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
114 |
-
msgid "Add new translation"
|
115 |
-
msgstr "Voeg nieuwe vertaling toe"
|
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 "Taal"
|
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 "Vertalingen"
|
130 |
-
|
131 |
-
# @ polylang
|
132 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
133 |
-
msgid "Sets the language"
|
134 |
-
msgstr "Stelt de taal in"
|
135 |
-
|
136 |
-
# @ polylang
|
137 |
-
#: admin/admin-filters.php:52
|
138 |
-
msgid "The widget is displayed for:"
|
139 |
-
msgstr "Het widget wordt getoond voor:"
|
140 |
-
|
141 |
-
# @ polylang
|
142 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
143 |
-
msgid "All languages"
|
144 |
-
msgstr "Alle talen"
|
145 |
-
|
146 |
-
# @ polylang
|
147 |
-
#: admin/admin-filters.php:123
|
148 |
-
msgid "Admin language"
|
149 |
-
msgstr "Admin taal"
|
150 |
-
|
151 |
-
#: admin/admin-filters.php:126
|
152 |
-
msgid "WordPress default"
|
153 |
-
msgstr ""
|
154 |
-
|
155 |
-
# @ default
|
156 |
-
# @ polylang
|
157 |
-
#: admin/admin.php:167 admin/settings.php:102
|
158 |
-
msgid "Settings"
|
159 |
-
msgstr "Instellingen"
|
160 |
-
|
161 |
-
# @ polylang
|
162 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
163 |
-
msgid "Upgrading language files…"
|
164 |
-
msgstr "Aanpassen taalbestanden…"
|
165 |
-
|
166 |
-
# @ polylang
|
167 |
-
#: admin/settings.php:62
|
168 |
-
msgid "About Polylang"
|
169 |
-
msgstr "Over Polylang"
|
170 |
-
|
171 |
-
# @ polylang
|
172 |
-
#: admin/settings.php:78
|
173 |
-
msgid "Strings translations"
|
174 |
-
msgstr "Tekstvertalingen"
|
175 |
-
|
176 |
-
# @ polylang
|
177 |
-
#: admin/settings.php:101
|
178 |
-
msgid "Strings translation"
|
179 |
-
msgstr "Tekstvertaling"
|
180 |
-
|
181 |
-
# @ polylang
|
182 |
-
#: admin/admin-model.php:244
|
183 |
-
msgid "Enter a valid WordPress locale"
|
184 |
-
msgstr "Voer een geldige WordPress lokaal in"
|
185 |
-
|
186 |
-
# @ polylang
|
187 |
-
#: admin/admin-model.php:252
|
188 |
-
msgid "The language code must be unique"
|
189 |
-
msgstr "De taalcode moet uniek zijn"
|
190 |
-
|
191 |
-
# @ polylang
|
192 |
-
#: admin/admin-model.php:256
|
193 |
-
msgid "The language must have a name"
|
194 |
-
msgstr "De taal moet een naam hebben"
|
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 |
-
"De taal was gecreëerd, maar het WordPress taalbestand was niet gedownload. "
|
203 |
-
"Handmatige installatie is noodzakelijk."
|
204 |
-
|
205 |
-
# @ polylang
|
206 |
-
#: admin/admin-strings.php:59
|
207 |
-
msgid "Widget title"
|
208 |
-
msgstr "Widget titel"
|
209 |
-
|
210 |
-
# @ polylang
|
211 |
-
#: admin/settings.php:319
|
212 |
-
msgid "Taxonomies"
|
213 |
-
msgstr ""
|
214 |
-
|
215 |
-
# @ polylang
|
216 |
-
#: admin/settings.php:320
|
217 |
-
msgid "Custom fields"
|
218 |
-
msgstr ""
|
219 |
-
|
220 |
-
# @ polylang
|
221 |
-
#: admin/settings.php:321
|
222 |
-
msgid "Comment status"
|
223 |
-
msgstr ""
|
224 |
-
|
225 |
-
# @ polylang
|
226 |
-
#: admin/settings.php:322
|
227 |
-
msgid "Ping status"
|
228 |
-
msgstr ""
|
229 |
-
|
230 |
-
# @ polylang
|
231 |
-
#: admin/settings.php:323
|
232 |
-
msgid "Sticky posts"
|
233 |
-
msgstr ""
|
234 |
-
|
235 |
-
# @ polylang
|
236 |
-
#: admin/settings.php:324
|
237 |
-
msgid "Published date"
|
238 |
-
msgstr ""
|
239 |
-
|
240 |
-
# @ polylang
|
241 |
-
#: admin/settings.php:325
|
242 |
-
msgid "Post format"
|
243 |
-
msgstr ""
|
244 |
-
|
245 |
-
# @ polylang
|
246 |
-
#: admin/settings.php:326
|
247 |
-
msgid "Page parent"
|
248 |
-
msgstr ""
|
249 |
-
|
250 |
-
# @ polylang
|
251 |
-
#: admin/settings.php:327
|
252 |
-
msgid "Page template"
|
253 |
-
msgstr ""
|
254 |
-
|
255 |
-
# @ polylang
|
256 |
-
#: admin/settings.php:328
|
257 |
-
msgid "Page order"
|
258 |
-
msgstr ""
|
259 |
-
|
260 |
-
# @ polylang
|
261 |
-
#: admin/settings.php:329
|
262 |
-
msgid "Featured image"
|
263 |
-
msgstr ""
|
264 |
-
|
265 |
-
# @ polylang
|
266 |
-
#: admin/view-tab-lang.php:21
|
267 |
-
msgid "Edit language"
|
268 |
-
msgstr "Wijzig taal"
|
269 |
-
|
270 |
-
# @ polylang
|
271 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
272 |
-
msgid "Add new language"
|
273 |
-
msgstr "Voeg nieuwe taal toe"
|
274 |
-
|
275 |
-
# @ polylang
|
276 |
-
#: admin/view-tab-lang.php:37
|
277 |
-
msgid "Choose a language"
|
278 |
-
msgstr "Kies een taal"
|
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 "Kies een taal uit de lijst of vul deze direct hieronder in."
|
284 |
-
|
285 |
-
# @ polylang
|
286 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
287 |
-
msgid "Full name"
|
288 |
-
msgstr "Volledige naam"
|
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 "De naam geeft aan hoe het op je site getoond wordt (b.v.: Nederlands)."
|
294 |
-
|
295 |
-
# @ polylang
|
296 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
297 |
-
msgid "Locale"
|
298 |
-
msgstr "Locale"
|
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 voor de taal (bv.: nl_NL). Installeer het .mo bestand voor "
|
307 |
-
"deze taal."
|
308 |
-
|
309 |
-
# @ polylang
|
310 |
-
#: admin/view-tab-lang.php:70
|
311 |
-
msgid "Language code"
|
312 |
-
msgstr "Taalcode"
|
313 |
-
|
314 |
-
# @ polylang
|
315 |
-
#: admin/view-tab-lang.php:76
|
316 |
-
msgid "Text direction"
|
317 |
-
msgstr "Tekstrichting"
|
318 |
-
|
319 |
-
# @ polylang
|
320 |
-
#: admin/view-tab-lang.php:80
|
321 |
-
msgid "left to right"
|
322 |
-
msgstr "van links naar rechts"
|
323 |
-
|
324 |
-
# @ polylang
|
325 |
-
#: admin/view-tab-lang.php:85
|
326 |
-
msgid "right to left"
|
327 |
-
msgstr "van rechts naar links"
|
328 |
-
|
329 |
-
# @ polylang
|
330 |
-
#: admin/view-tab-lang.php:87
|
331 |
-
msgid "Choose the text direction for the language"
|
332 |
-
msgstr "Kies de tekstrichting voor de taal"
|
333 |
-
|
334 |
-
# @ polylang
|
335 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
336 |
-
msgid "Order"
|
337 |
-
msgstr "Volgorde"
|
338 |
-
|
339 |
-
# @ polylang
|
340 |
-
#: admin/view-tab-lang.php:93
|
341 |
-
msgid "Position of the language in the language switcher"
|
342 |
-
msgstr "Positionering van de taal in de taalschakelaar"
|
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 "Taalschakelaar"
|
350 |
-
|
351 |
-
# @ polylang
|
352 |
-
#: admin/view-tab-strings.php:8
|
353 |
-
msgid "Search translations"
|
354 |
-
msgstr ""
|
355 |
-
|
356 |
-
# @ polylang
|
357 |
-
#: admin/view-tab-strings.php:11
|
358 |
-
msgid "Clean strings translation database"
|
359 |
-
msgstr ""
|
360 |
-
|
361 |
-
# @ polylang
|
362 |
-
#: admin/view-tab-settings.php:14
|
363 |
-
msgid "Default language"
|
364 |
-
msgstr "Standaardtaal"
|
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 |
-
"Er zijn berichten, pagina's, categorieën of tags zonder taalinstelling. Deze "
|
373 |
-
"allemaal instellen op de standaardtaal?"
|
374 |
-
|
375 |
-
# @ polylang
|
376 |
-
#: admin/view-tab-settings.php:149
|
377 |
-
msgid "Detect browser language"
|
378 |
-
msgstr "Bepaal de taal van de browser"
|
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 |
-
"Wanneer de startpagina bezocht is, stel dan de taal in op basis van de "
|
387 |
-
"voorkeur van de browser"
|
388 |
-
|
389 |
-
# @ polylang
|
390 |
-
#: admin/view-tab-settings.php:37
|
391 |
-
msgid "URL modifications"
|
392 |
-
msgstr "URL aanpassingen"
|
393 |
-
|
394 |
-
# @ polylang
|
395 |
-
#: admin/view-tab-settings.php:93
|
396 |
-
msgid "Hide URL language information for default language"
|
397 |
-
msgstr "Verberg URL taalinformatie voor de standaardtaal"
|
398 |
-
|
399 |
-
# @ polylang
|
400 |
-
#: admin/view-tab-settings.php:162
|
401 |
-
msgid "Media"
|
402 |
-
msgstr ""
|
403 |
-
|
404 |
-
# @ polylang
|
405 |
-
#: admin/view-tab-settings.php:168
|
406 |
-
msgid "Activate languages and translations for media"
|
407 |
-
msgstr ""
|
408 |
-
|
409 |
-
#: admin/view-tab-settings.php:215
|
410 |
-
msgid "Synchronization"
|
411 |
-
msgstr ""
|
412 |
-
|
413 |
-
# @ polylang
|
414 |
-
#: admin/view-tab-settings.php:176
|
415 |
-
msgid "Custom post types"
|
416 |
-
msgstr ""
|
417 |
-
|
418 |
-
# @ polylang
|
419 |
-
#: admin/view-tab-settings.php:189
|
420 |
-
msgid "Activate languages and translations for custom post types."
|
421 |
-
msgstr ""
|
422 |
-
|
423 |
-
# @ polylang
|
424 |
-
#: admin/view-tab-settings.php:196
|
425 |
-
msgid "Custom taxonomies"
|
426 |
-
msgstr ""
|
427 |
-
|
428 |
-
# @ polylang
|
429 |
-
#: admin/view-tab-settings.php:209
|
430 |
-
msgid "Activate languages and translations for custom taxonomies."
|
431 |
-
msgstr ""
|
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 "Wijzig"
|
438 |
-
|
439 |
-
# @ polylang
|
440 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
441 |
-
msgid "Delete"
|
442 |
-
msgstr "Verwijder"
|
443 |
-
|
444 |
-
# @ polylang
|
445 |
-
#: admin/table-languages.php:76
|
446 |
-
msgid "Code"
|
447 |
-
msgstr "Taalcode"
|
448 |
-
|
449 |
-
# @ polylang
|
450 |
-
#: admin/table-languages.php:78
|
451 |
-
msgid "Flag"
|
452 |
-
msgstr "Vlag"
|
453 |
-
|
454 |
-
# @ polylang
|
455 |
-
#: admin/table-languages.php:79
|
456 |
-
msgid "Posts"
|
457 |
-
msgstr "Berichten"
|
458 |
-
|
459 |
-
# @ polylang
|
460 |
-
#: admin/table-string.php:110
|
461 |
-
msgid "Name"
|
462 |
-
msgstr "Naam"
|
463 |
-
|
464 |
-
# @ polylang
|
465 |
-
#: admin/table-string.php:111
|
466 |
-
msgid "String"
|
467 |
-
msgstr "Tekst"
|
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 "Voeg nieuwe toe"
|
474 |
-
|
475 |
-
# @ polylang
|
476 |
-
#: include/widget-languages.php:16
|
477 |
-
msgid "Language Switcher"
|
478 |
-
msgstr "Taalschakelaar"
|
479 |
-
|
480 |
-
# @ polylang
|
481 |
-
#: include/widget-languages.php:16
|
482 |
-
msgid "Displays a language switcher"
|
483 |
-
msgstr "Toon een taalschakelaar"
|
484 |
-
|
485 |
-
# @ polylang
|
486 |
-
#: include/widget-languages.php:75
|
487 |
-
msgid "Title:"
|
488 |
-
msgstr "Titel:"
|
489 |
-
|
490 |
-
# @ polylang
|
491 |
-
#. translators: plugin header field 'Description'
|
492 |
-
#: polylang.php:0
|
493 |
-
msgid "Adds multilingual capability to WordPress"
|
494 |
-
msgstr ""
|
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 "Je gebruikt WordPress %s. Polylang vereist tenminste WordPress %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 ""
|
507 |
-
|
508 |
-
# @ polylang
|
509 |
-
#: install/upgrade.php:78
|
510 |
-
#, php-format
|
511 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
512 |
-
msgstr ""
|
513 |
-
|
514 |
-
# @ polylang
|
515 |
-
#: admin/table-string.php:109
|
516 |
-
msgid "Group"
|
517 |
-
msgstr ""
|
518 |
-
|
519 |
-
# @ polylang
|
520 |
-
#: admin/table-string.php:187
|
521 |
-
msgid "View all groups"
|
522 |
-
msgstr ""
|
523 |
-
|
524 |
-
# @ polylang
|
525 |
-
#: admin/table-languages.php:59
|
526 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
527 |
-
msgstr ""
|
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 |
-
|
536 |
-
# @ polylang
|
537 |
-
#: admin/view-tab-settings.php:226
|
538 |
-
msgid ""
|
539 |
-
"The synchronization options allow to maintain exact same values (or "
|
540 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
541 |
-
"between the translations of a post or page."
|
542 |
-
msgstr ""
|
543 |
-
|
544 |
-
# @ polylang
|
545 |
-
#: admin/admin-model.php:248
|
546 |
-
msgid "The language code contains invalid characters"
|
547 |
-
msgstr ""
|
548 |
-
|
549 |
-
# @ polylang
|
550 |
-
#: admin/view-tab-settings.php:43
|
551 |
-
msgid "The language is set from content"
|
552 |
-
msgstr ""
|
553 |
-
|
554 |
-
# @ polylang
|
555 |
-
#: admin/view-tab-settings.php:46
|
556 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
557 |
-
msgstr ""
|
558 |
-
|
559 |
-
# @ polylang
|
560 |
-
#: admin/view-tab-settings.php:51
|
561 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
562 |
-
msgstr ""
|
563 |
-
|
564 |
-
# @ polylang
|
565 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
566 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
567 |
-
msgid "Example:"
|
568 |
-
msgstr ""
|
569 |
-
|
570 |
-
# @ polylang
|
571 |
-
#: admin/view-tab-settings.php:60
|
572 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
573 |
-
msgstr ""
|
574 |
-
|
575 |
-
# @ polylang
|
576 |
-
#: admin/view-tab-settings.php:69
|
577 |
-
msgid "The language is set from different domains"
|
578 |
-
msgstr ""
|
579 |
-
|
580 |
-
# @ polylang
|
581 |
-
#: admin/view-tab-settings.php:107
|
582 |
-
msgid "Remove /language/ in pretty permalinks"
|
583 |
-
msgstr ""
|
584 |
-
|
585 |
-
# @ polylang
|
586 |
-
#: admin/view-tab-settings.php:116
|
587 |
-
msgid "Keep /language/ in pretty permalinks"
|
588 |
-
msgstr ""
|
589 |
-
|
590 |
-
# @ polylang
|
591 |
-
#: admin/view-tab-settings.php:131
|
592 |
-
msgid ""
|
593 |
-
"The front page url contains the language code instead of the page name or "
|
594 |
-
"page id"
|
595 |
-
msgstr ""
|
596 |
-
|
597 |
-
# @ polylang
|
598 |
-
#: admin/view-tab-settings.php:139
|
599 |
-
#, php-format
|
600 |
-
msgid "Example: %s instead of %s"
|
601 |
-
msgstr ""
|
602 |
-
|
603 |
-
# @ polylang
|
604 |
-
#: admin/admin-model.php:38
|
605 |
-
msgid "Impossible to add the language."
|
606 |
-
msgstr ""
|
607 |
-
|
608 |
-
# @ polylang
|
609 |
-
#: admin/admin-model.php:66
|
610 |
-
msgid "Language added."
|
611 |
-
msgstr ""
|
612 |
-
|
613 |
-
# @ polylang
|
614 |
-
#: admin/admin-model.php:146
|
615 |
-
msgid "Language deleted."
|
616 |
-
msgstr ""
|
617 |
-
|
618 |
-
# @ polylang
|
619 |
-
#: admin/admin-model.php:227
|
620 |
-
msgid "Language updated."
|
621 |
-
msgstr ""
|
622 |
-
|
623 |
-
# @ polylang
|
624 |
-
#: admin/settings.php:239
|
625 |
-
msgid "Translations updated."
|
626 |
-
msgstr ""
|
627 |
-
|
628 |
-
# @ polylang
|
629 |
-
#: admin/view-tab-lang.php:72
|
630 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
631 |
-
msgstr ""
|
632 |
-
|
633 |
-
# @ polylang
|
634 |
-
#: admin/admin-filters.php:203
|
635 |
-
msgid "The chosen static front page must be translated in all languages."
|
636 |
-
msgstr ""
|
637 |
-
|
638 |
-
# @ polylang
|
639 |
-
#: admin/admin-strings.php:60
|
640 |
-
msgid "Widget text"
|
641 |
-
msgstr ""
|
642 |
-
|
643 |
-
# @ polylang
|
644 |
-
#: admin/settings.php:52
|
645 |
-
msgid "Recommended plugins"
|
646 |
-
msgstr ""
|
647 |
-
|
648 |
-
# @ polylang
|
649 |
-
#: admin/view-tab-settings.php:51
|
650 |
-
msgid "The language is set from the code in the URL"
|
651 |
-
msgstr ""
|
652 |
-
|
653 |
-
# @ polylang
|
654 |
-
#: include/switcher.php:26
|
655 |
-
msgid "Hides languages with no translation"
|
656 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-pt_PT.mo
DELETED
Binary file
|
languages/polylang-pt_PT.po
DELETED
@@ -1,701 +0,0 @@
|
|
1 |
-
# Translation of Stable (latest release) in Portuguese (Portugal)
|
2 |
-
# This file is distributed under the same license as the Stable (latest release) package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"PO-Revision-Date: 2015-11-04 12:53:02+0000\n"
|
6 |
-
"MIME-Version: 1.0\n"
|
7 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
8 |
-
"Content-Transfer-Encoding: 8bit\n"
|
9 |
-
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
10 |
-
"X-Generator: GlotPress/1.0-alpha-1100\n"
|
11 |
-
"Project-Id-Version: Stable (latest release)\n"
|
12 |
-
|
13 |
-
#: lingotek/lingotek.php:85
|
14 |
-
msgid "Activated"
|
15 |
-
msgstr "Activado"
|
16 |
-
|
17 |
-
#: lingotek/lingotek.php:85
|
18 |
-
msgid "Activate"
|
19 |
-
msgstr "Activar"
|
20 |
-
|
21 |
-
#: lingotek/lingotek.php:90
|
22 |
-
msgid "Request Translation"
|
23 |
-
msgstr "Requesitar tradução"
|
24 |
-
|
25 |
-
#: lingotek/lingotek.php:96
|
26 |
-
msgid "Request Services"
|
27 |
-
msgstr "Requesitar serviços"
|
28 |
-
|
29 |
-
#: lingotek/lingotek.php:103
|
30 |
-
msgid "Polylang is now fully integrated with Lingotek, a professional translation management system!"
|
31 |
-
msgstr "O Polylang está agora completamente integrado com o Lingotek, um sistema profissional de gestão de tradução!"
|
32 |
-
|
33 |
-
#: lingotek/lingotek.php:106
|
34 |
-
msgid "Automatically Translate My Site"
|
35 |
-
msgstr "Traduzir o meu site automaticamente"
|
36 |
-
|
37 |
-
#: lingotek/lingotek.php:107
|
38 |
-
msgid "Polylang is now fully integrated with Lingotek!"
|
39 |
-
msgstr "O Polylang está agora completamente integrado com o Lingotek!"
|
40 |
-
|
41 |
-
#: lingotek/lingotek.php:109 lingotek/lingotek.php:120
|
42 |
-
msgid "Access free machine translation for your site for up to 100,000 characters."
|
43 |
-
msgstr "Aceda a tradução mecânica gratuita para o seu site até 100,000 caracteres."
|
44 |
-
|
45 |
-
#: lingotek/lingotek.php:110
|
46 |
-
msgid "Machine translation is an excellent option if you're on a tight budget, looking for near-instant results, and are okay with less-than-perfect quality."
|
47 |
-
msgstr "A tradução mecânica é uma boa opção se tiver um orçamento limitado, se quiser resultados imediatos, ou se não se importar de ter uma tradução de fraca qualidade."
|
48 |
-
|
49 |
-
#: lingotek/lingotek.php:117
|
50 |
-
msgid "Translation Management System"
|
51 |
-
msgstr "Sistema de gestão de traduções"
|
52 |
-
|
53 |
-
#: lingotek/lingotek.php:118
|
54 |
-
msgid "Do you need to connect to a professional translation management system?"
|
55 |
-
msgstr "Precisa de se conectar a um sistema profissional de gestão de tradução?"
|
56 |
-
|
57 |
-
#: lingotek/lingotek.php:121
|
58 |
-
msgid "Access an online translator workbench."
|
59 |
-
msgstr "Aceda a uma ferramenta de tradução online."
|
60 |
-
|
61 |
-
#: lingotek/lingotek.php:122
|
62 |
-
msgid "Have linguists compare side-by-side versions of original and translated text."
|
63 |
-
msgstr "Mantenha lado a lado o texto traduzido nas versões original e traduzida."
|
64 |
-
|
65 |
-
#: lingotek/lingotek.php:123
|
66 |
-
msgid "Save and re-use previously translated material (leverage translation memory (TM))."
|
67 |
-
msgstr "Guarde e reutilize material traduzido previamente (memória de traduções (MT))"
|
68 |
-
|
69 |
-
#: lingotek/lingotek.php:130
|
70 |
-
msgid "Professionally Translate My Site"
|
71 |
-
msgstr "Traduzir o meu site com profissionalismo"
|
72 |
-
|
73 |
-
#: lingotek/lingotek.php:131
|
74 |
-
msgid "Do you need to professionally translate your site?"
|
75 |
-
msgstr "Precisa de traduzir o seu site com profissionalismo?"
|
76 |
-
|
77 |
-
#: lingotek/lingotek.php:133
|
78 |
-
msgid "Start the process of getting a professional translation bid."
|
79 |
-
msgstr "Comece o processo para obter uma oferta de tradução profissional."
|
80 |
-
|
81 |
-
#: lingotek/lingotek.php:134
|
82 |
-
msgid "Activate account so Lingotek can get an accurate count of how many words you have on your site and which languages you wish to translate into."
|
83 |
-
msgstr "Active a sua conta para o Lingotek contar com precisão as palavras que tem no seu site e saber para que idiomas pretende traduzir."
|
84 |
-
|
85 |
-
#: lingotek/lingotek.php:135
|
86 |
-
msgid "Once activated click on the request translation bid and a certified translation project manager will contact you to give a no obligations translation bid."
|
87 |
-
msgstr "Assim que estiver activado, clique em requerer oferta de tradução e será contactado por um gestor certificado de projecto de tradução para lhe fazer uma oferta de tradução sem qualquer obrigação."
|
88 |
-
|
89 |
-
#: lingotek/lingotek.php:142
|
90 |
-
msgid "Need Extra Services?"
|
91 |
-
msgstr "Precisa de serviços extra?"
|
92 |
-
|
93 |
-
#: lingotek/lingotek.php:143
|
94 |
-
msgid "Do you need help translating your site?"
|
95 |
-
msgstr "Precisa de ajuda para traduzir o seu site?"
|
96 |
-
|
97 |
-
#: lingotek/lingotek.php:145
|
98 |
-
msgid "Start the process of getting extra services."
|
99 |
-
msgstr "Comece o processo de obter serviços extra."
|
100 |
-
|
101 |
-
#: lingotek/lingotek.php:146
|
102 |
-
msgid "Do you need someone to run your localization project?"
|
103 |
-
msgstr "Precisa de alguém para gerir o seu projecto de tradução?"
|
104 |
-
|
105 |
-
#: lingotek/lingotek.php:147
|
106 |
-
msgid "Do you need customized workflows?"
|
107 |
-
msgstr "Precisa de um fluxo de trabalho personalizado?"
|
108 |
-
|
109 |
-
#: lingotek/lingotek.php:148
|
110 |
-
msgid "Do you you have existing Translation Memories you would like to use?"
|
111 |
-
msgstr "Tem alguma Memória de traduções que queira utilizar?"
|
112 |
-
|
113 |
-
#: lingotek/lingotek.php:149
|
114 |
-
msgid "Do you need help creating glossaries and terminologies?"
|
115 |
-
msgstr "Precisa de ajuda na criação de glossários e terminologias?"
|
116 |
-
|
117 |
-
#: lingotek/lingotek.php:254
|
118 |
-
msgid "Learn more..."
|
119 |
-
msgstr "Saiba mais…"
|
120 |
-
|
121 |
-
#. Plugin Name of the plugin/theme
|
122 |
-
msgid "Polylang"
|
123 |
-
msgstr "Polylang"
|
124 |
-
|
125 |
-
#. Plugin URI of the plugin/theme
|
126 |
-
msgid "http://polylang.wordpress.com/"
|
127 |
-
msgstr "http://polylang.wordpress.com/"
|
128 |
-
|
129 |
-
#. Description of the plugin/theme
|
130 |
-
msgid "Adds multilingual capability to WordPress"
|
131 |
-
msgstr "Adiciona capacidade multilingue ao WordPress"
|
132 |
-
|
133 |
-
#. Author of the plugin/theme
|
134 |
-
msgid "Frédéric Demarle"
|
135 |
-
msgstr "Frédéric Demarle"
|
136 |
-
|
137 |
-
#. Author URI of the plugin/theme
|
138 |
-
msgid "http://polylang.wordpress.com"
|
139 |
-
msgstr "http://polylang.wordpress.com"
|
140 |
-
|
141 |
-
#: admin/admin-filters-columns.php:141 admin/admin-filters-columns.php:236
|
142 |
-
msgid "Add new translation"
|
143 |
-
msgstr "Adicionar nova tradução"
|
144 |
-
|
145 |
-
#: admin/admin-filters-columns.php:161
|
146 |
-
msgid "— No Change —"
|
147 |
-
msgstr "— Não alterar —"
|
148 |
-
|
149 |
-
#: admin/admin-filters-columns.php:174 admin/admin-filters-media.php:55
|
150 |
-
#: admin/admin-filters-post.php:159 admin/admin-filters-term.php:85
|
151 |
-
#: admin/admin-filters-term.php:136 include/model.php:591
|
152 |
-
msgid "Language"
|
153 |
-
msgstr "Idioma"
|
154 |
-
|
155 |
-
#: admin/admin-filters-post.php:133 admin/admin.php:96 admin/settings.php:70
|
156 |
-
#: admin/settings.php:97 include/model.php:590
|
157 |
-
msgid "Languages"
|
158 |
-
msgstr "Idiomas"
|
159 |
-
|
160 |
-
#: admin/admin-filters-post.php:239
|
161 |
-
msgid "(no parent)"
|
162 |
-
msgstr "(sem superior)"
|
163 |
-
|
164 |
-
#: admin/admin-filters-post.php:474 admin/admin-filters-term.php:763
|
165 |
-
#: admin/table-languages.php:65 admin/view-translations-media.php:21
|
166 |
-
msgid "Edit"
|
167 |
-
msgstr "Editar"
|
168 |
-
|
169 |
-
#: admin/admin-filters-term.php:92 admin/admin-filters-term.php:144
|
170 |
-
msgid "Sets the language"
|
171 |
-
msgstr "Define o idioma"
|
172 |
-
|
173 |
-
#: admin/admin-filters-term.php:454
|
174 |
-
msgid "None"
|
175 |
-
msgstr "Nenhuma"
|
176 |
-
|
177 |
-
#: admin/admin-filters.php:52
|
178 |
-
msgid "The widget is displayed for:"
|
179 |
-
msgstr "O widget é mostrado para:"
|
180 |
-
|
181 |
-
#: admin/admin-filters.php:55 include/model.php:592
|
182 |
-
msgid "All languages"
|
183 |
-
msgstr "Todas os idiomas"
|
184 |
-
|
185 |
-
#: admin/admin-filters.php:123
|
186 |
-
msgid "Admin language"
|
187 |
-
msgstr "Idioma da administração"
|
188 |
-
|
189 |
-
#: admin/admin-filters.php:126
|
190 |
-
msgid "WordPress default"
|
191 |
-
msgstr "Por omissão do WordPress"
|
192 |
-
|
193 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
194 |
-
msgid "Upgrading language files…"
|
195 |
-
msgstr "A actualizar ficheiros de idioma…"
|
196 |
-
|
197 |
-
#: admin/admin-filters.php:203
|
198 |
-
msgid "The chosen static front page must be translated in all languages."
|
199 |
-
msgstr "A página inicial estática tem que estar traduzida em todos os idiomas."
|
200 |
-
|
201 |
-
#: admin/admin-model.php:38
|
202 |
-
msgid "Impossible to add the language."
|
203 |
-
msgstr "Impossível adicionar o idioma."
|
204 |
-
|
205 |
-
#: admin/admin-model.php:66
|
206 |
-
msgid "Language added."
|
207 |
-
msgstr "Idioma adicionado."
|
208 |
-
|
209 |
-
#: admin/admin-model.php:145
|
210 |
-
msgid "Language deleted."
|
211 |
-
msgstr "Idioma eliminado."
|
212 |
-
|
213 |
-
#: admin/admin-model.php:224
|
214 |
-
msgid "Language updated."
|
215 |
-
msgstr "Idioma actualizado."
|
216 |
-
|
217 |
-
#: admin/admin-model.php:241
|
218 |
-
msgid "Enter a valid WordPress locale"
|
219 |
-
msgstr "Introduza um código Locale válido do WordPress"
|
220 |
-
|
221 |
-
#: admin/admin-model.php:245
|
222 |
-
msgid "The language code contains invalid characters"
|
223 |
-
msgstr "O código do idioma contém caracteres inválidos"
|
224 |
-
|
225 |
-
#: admin/admin-model.php:249
|
226 |
-
msgid "The language code must be unique"
|
227 |
-
msgstr "O código do idioma tem que ser único"
|
228 |
-
|
229 |
-
#: admin/admin-model.php:254
|
230 |
-
msgid "The language must have a name"
|
231 |
-
msgstr "O idioma tem que ter um nome"
|
232 |
-
|
233 |
-
#: admin/admin-nav-menu.php:52 admin/admin-nav-menu.php:73
|
234 |
-
#: admin/admin-nav-menu.php:76 admin/admin-nav-menu.php:107
|
235 |
-
#: admin/admin-nav-menu.php:169 install/upgrade.php:302
|
236 |
-
msgid "Language switcher"
|
237 |
-
msgstr "Selector de idioma"
|
238 |
-
|
239 |
-
#: admin/admin-strings.php:54
|
240 |
-
msgid "Site Title"
|
241 |
-
msgstr "Título do site"
|
242 |
-
|
243 |
-
#: admin/admin-strings.php:55
|
244 |
-
msgid "Tagline"
|
245 |
-
msgstr "Descrição"
|
246 |
-
|
247 |
-
#: admin/admin-strings.php:56
|
248 |
-
msgid "Date Format"
|
249 |
-
msgstr "Formato da data"
|
250 |
-
|
251 |
-
#: admin/admin-strings.php:57
|
252 |
-
msgid "Time Format"
|
253 |
-
msgstr "Formato da hora"
|
254 |
-
|
255 |
-
#: admin/admin-strings.php:59
|
256 |
-
msgid "Widget title"
|
257 |
-
msgstr "Título do widget"
|
258 |
-
|
259 |
-
#: admin/admin-strings.php:60
|
260 |
-
msgid "Widget text"
|
261 |
-
msgstr "Texto do widget"
|
262 |
-
|
263 |
-
#: admin/admin.php:204 admin/settings.php:102
|
264 |
-
msgid "Settings"
|
265 |
-
msgstr "Definições"
|
266 |
-
|
267 |
-
#: admin/admin.php:312
|
268 |
-
msgid "Show all languages"
|
269 |
-
msgstr "Mostrar todos os idiomas"
|
270 |
-
|
271 |
-
#: admin/admin.php:321
|
272 |
-
msgid "Filters content by language"
|
273 |
-
msgstr "Filtrar conteúdo pelo idioma"
|
274 |
-
|
275 |
-
#: admin/admin.php:419 admin/settings.php:183
|
276 |
-
msgid "The language was created, but the WordPress language file was not downloaded. Please install it manually."
|
277 |
-
msgstr "O idioma foi criado mas o ficheiro de idioma do WordPress não foi descarregado. Por favor, instale manualmente."
|
278 |
-
|
279 |
-
#: admin/settings.php:52
|
280 |
-
msgid "Recommended plugins"
|
281 |
-
msgstr "Plugins recomendados"
|
282 |
-
|
283 |
-
#: admin/settings.php:62
|
284 |
-
msgid "About Polylang"
|
285 |
-
msgstr "Sobre o Polylang"
|
286 |
-
|
287 |
-
#: admin/settings.php:78
|
288 |
-
msgid "Strings translations"
|
289 |
-
msgstr "Traduções de strings"
|
290 |
-
|
291 |
-
#: admin/settings.php:101
|
292 |
-
msgid "Strings translation"
|
293 |
-
msgstr "Tradução de strings"
|
294 |
-
|
295 |
-
#: admin/settings.php:242
|
296 |
-
msgid "Translations updated."
|
297 |
-
msgstr "Traduções actualizadas."
|
298 |
-
|
299 |
-
#: admin/settings.php:300
|
300 |
-
msgid "Settings saved."
|
301 |
-
msgstr "Definições guardadas."
|
302 |
-
|
303 |
-
#: admin/settings.php:321
|
304 |
-
msgid "Taxonomies"
|
305 |
-
msgstr "Taxonomias"
|
306 |
-
|
307 |
-
#: admin/settings.php:322
|
308 |
-
msgid "Custom fields"
|
309 |
-
msgstr "Campos personalizados"
|
310 |
-
|
311 |
-
#: admin/settings.php:323
|
312 |
-
msgid "Comment status"
|
313 |
-
msgstr "Estado de comentário"
|
314 |
-
|
315 |
-
#: admin/settings.php:324
|
316 |
-
msgid "Ping status"
|
317 |
-
msgstr "Estado de ping"
|
318 |
-
|
319 |
-
#: admin/settings.php:325
|
320 |
-
msgid "Sticky posts"
|
321 |
-
msgstr "Artigos fixos"
|
322 |
-
|
323 |
-
#: admin/settings.php:326
|
324 |
-
msgid "Published date"
|
325 |
-
msgstr "Data de publicação"
|
326 |
-
|
327 |
-
#: admin/settings.php:327
|
328 |
-
msgid "Post format"
|
329 |
-
msgstr "Formato de artigo"
|
330 |
-
|
331 |
-
#: admin/settings.php:328
|
332 |
-
msgid "Page parent"
|
333 |
-
msgstr "Página superior"
|
334 |
-
|
335 |
-
#: admin/settings.php:329
|
336 |
-
msgid "Page template"
|
337 |
-
msgstr "Modelo de página"
|
338 |
-
|
339 |
-
#: admin/settings.php:330
|
340 |
-
msgid "Page order"
|
341 |
-
msgstr "Ordem da página"
|
342 |
-
|
343 |
-
#: admin/settings.php:331
|
344 |
-
msgid "Featured image"
|
345 |
-
msgstr "Imagem de destaque"
|
346 |
-
|
347 |
-
#: admin/table-languages.php:70
|
348 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
349 |
-
msgstr "Está prestes a eliminar este idioma permanentemente. Tem a certeza?"
|
350 |
-
|
351 |
-
#: admin/table-languages.php:71 admin/table-string.php:168
|
352 |
-
msgid "Delete"
|
353 |
-
msgstr "Eliminar"
|
354 |
-
|
355 |
-
#: admin/table-languages.php:85 admin/view-tab-lang.php:55
|
356 |
-
msgid "Full name"
|
357 |
-
msgstr "Nome completo"
|
358 |
-
|
359 |
-
#: admin/table-languages.php:86 admin/view-tab-lang.php:61
|
360 |
-
msgid "Locale"
|
361 |
-
msgstr "Código Locale"
|
362 |
-
|
363 |
-
#: admin/table-languages.php:87
|
364 |
-
msgid "Code"
|
365 |
-
msgstr "Código"
|
366 |
-
|
367 |
-
#: admin/table-languages.php:88 admin/view-tab-lang.php:91
|
368 |
-
msgid "Order"
|
369 |
-
msgstr "Ordem"
|
370 |
-
|
371 |
-
#: admin/table-languages.php:89
|
372 |
-
msgid "Flag"
|
373 |
-
msgstr "Bandeira"
|
374 |
-
|
375 |
-
#: admin/table-languages.php:90
|
376 |
-
msgid "Posts"
|
377 |
-
msgstr "Artigos"
|
378 |
-
|
379 |
-
#: admin/table-string.php:109
|
380 |
-
msgid "String"
|
381 |
-
msgstr "String"
|
382 |
-
|
383 |
-
#: admin/table-string.php:110
|
384 |
-
msgid "Name"
|
385 |
-
msgstr "Nome"
|
386 |
-
|
387 |
-
#: admin/table-string.php:111
|
388 |
-
msgid "Group"
|
389 |
-
msgstr "Grupo"
|
390 |
-
|
391 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
392 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
393 |
-
#: admin/view-translations-term.php:11
|
394 |
-
msgid "Translations"
|
395 |
-
msgstr "Traduções"
|
396 |
-
|
397 |
-
#: admin/table-string.php:187
|
398 |
-
msgid "View all groups"
|
399 |
-
msgstr "Ver todos os grupos"
|
400 |
-
|
401 |
-
#: admin/table-string.php:200
|
402 |
-
msgid "Filter"
|
403 |
-
msgstr "Filtrar"
|
404 |
-
|
405 |
-
#: admin/view-about.php:3
|
406 |
-
msgid "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 programmers to adapt their plugins and themes."
|
407 |
-
msgstr "O polylang está provido de uma extensa %sdocumentação%s (apenas em Inglês). Inclui informações sobre como configurar e utilizar diariamente o seu site multilingue, perguntas frequentes, assim como documentação para os programadores adaptarem os seus plugins e temas."
|
408 |
-
|
409 |
-
#: admin/view-about.php:9
|
410 |
-
msgid "You will also find useful information in the %ssupport forum%s. However don't forget to make a search before posting a new topic."
|
411 |
-
msgstr "Também encontrará informações úteis no %sfórum de suporte%s, no entanto, não se esqueça de pesquisar antes de publicar um novo tópico."
|
412 |
-
|
413 |
-
#: admin/view-about.php:16
|
414 |
-
msgid "Polylang is free of charge and is released under the same license as WordPress, the %sGPL%s."
|
415 |
-
msgstr "O Polylang é gratuito e é distribuído sob a mesma licença que o WordPress, o %sGPL%s."
|
416 |
-
|
417 |
-
#: admin/view-about.php:22
|
418 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
419 |
-
msgstr "Se pretender ajudar o projecto, %sleia isto%s."
|
420 |
-
|
421 |
-
#: admin/view-about.php:27
|
422 |
-
msgid "Finally if you like this plugin or if it helps your business, donations to the author are greatly appreciated."
|
423 |
-
msgstr "Por fim, se gostar deste plugin ou se este está a ajudá-lo no seu negócio, os donativos ao autor serão muito apreciados."
|
424 |
-
|
425 |
-
#: admin/view-tab-lang.php:21
|
426 |
-
msgid "Edit language"
|
427 |
-
msgstr "Editar idioma"
|
428 |
-
|
429 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:103
|
430 |
-
msgid "Add new language"
|
431 |
-
msgstr "Adicionar novo idioma"
|
432 |
-
|
433 |
-
#: admin/view-tab-lang.php:37
|
434 |
-
msgid "Choose a language"
|
435 |
-
msgstr "Escolha um idioma"
|
436 |
-
|
437 |
-
#: admin/view-tab-lang.php:51
|
438 |
-
msgid "You can choose a language in the list or directly edit it below."
|
439 |
-
msgstr "Pode escolher um idioma da lista ou editá-lo directamente abaixo."
|
440 |
-
|
441 |
-
#: admin/view-tab-lang.php:57
|
442 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
443 |
-
msgstr "O nome que aparece no seu site. (por exemplo: Português)v"
|
444 |
-
|
445 |
-
#: admin/view-tab-lang.php:66
|
446 |
-
msgid "WordPress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
|
447 |
-
msgstr "Código Locale do WordPress para o idioma (por exemplo: pt_PT). Terá que instalar o ficheiro .mo para este idioma."
|
448 |
-
|
449 |
-
#: admin/view-tab-lang.php:70
|
450 |
-
msgid "Language code"
|
451 |
-
msgstr "Código do idioma"
|
452 |
-
|
453 |
-
#: admin/view-tab-lang.php:72
|
454 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
455 |
-
msgstr "Código do idioma - de preferência em ISO 639-1 de duas letras (por exemplo: pt)"
|
456 |
-
|
457 |
-
#: admin/view-tab-lang.php:76
|
458 |
-
msgid "Text direction"
|
459 |
-
msgstr "Direcção do texto"
|
460 |
-
|
461 |
-
#: admin/view-tab-lang.php:80
|
462 |
-
msgid "left to right"
|
463 |
-
msgstr "Esquerda para a direita"
|
464 |
-
|
465 |
-
#: admin/view-tab-lang.php:85
|
466 |
-
msgid "right to left"
|
467 |
-
msgstr "Direita para a esquerda"
|
468 |
-
|
469 |
-
#: admin/view-tab-lang.php:87
|
470 |
-
msgid "Choose the text direction for the language"
|
471 |
-
msgstr "Escolha a direcção do texto para o idioma"
|
472 |
-
|
473 |
-
#: admin/view-tab-lang.php:93
|
474 |
-
msgid "Position of the language in the language switcher"
|
475 |
-
msgstr "Posição do idioma no selector de idioma"
|
476 |
-
|
477 |
-
#: admin/view-tab-lang.php:103
|
478 |
-
msgid "Update"
|
479 |
-
msgstr "Actualizar"
|
480 |
-
|
481 |
-
#: admin/view-tab-settings.php:14
|
482 |
-
msgid "Default language"
|
483 |
-
msgstr "Idioma por omissão"
|
484 |
-
|
485 |
-
#: admin/view-tab-settings.php:29
|
486 |
-
msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
|
487 |
-
msgstr "Existem artigos, páginas, categorias ou etiquetas sem idioma definido. Deseja definir todos para idioma por omissão?"
|
488 |
-
|
489 |
-
#: admin/view-tab-settings.php:37
|
490 |
-
msgid "URL modifications"
|
491 |
-
msgstr "Modificações do URL"
|
492 |
-
|
493 |
-
#: admin/view-tab-settings.php:43
|
494 |
-
msgid "The language is set from content"
|
495 |
-
msgstr "O idioma é definido a partir do conteúdo"
|
496 |
-
|
497 |
-
#: admin/view-tab-settings.php:46
|
498 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
499 |
-
msgstr "Não modifica o URL dos artigos, páginas, categorias e etiquetas."
|
500 |
-
|
501 |
-
#: admin/view-tab-settings.php:51
|
502 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
503 |
-
msgstr "O idioma é definido a partir do caminho nas ligações permanentes."
|
504 |
-
|
505 |
-
#: admin/view-tab-settings.php:51
|
506 |
-
msgid "The language is set from the code in the URL"
|
507 |
-
msgstr "O idioma é definido a partir do código no URL"
|
508 |
-
|
509 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
510 |
-
#: admin/view-tab-settings.php:109 admin/view-tab-settings.php:118
|
511 |
-
msgid "Example:"
|
512 |
-
msgstr "Exemplo:"
|
513 |
-
|
514 |
-
#: admin/view-tab-settings.php:60
|
515 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
516 |
-
msgstr "O idioma é definido a partir do subdomínio nas ligações permanentes"
|
517 |
-
|
518 |
-
#: admin/view-tab-settings.php:69
|
519 |
-
msgid "The language is set from different domains"
|
520 |
-
msgstr "O idioma é definido a partir de domínios diferentes"
|
521 |
-
|
522 |
-
#: admin/view-tab-settings.php:92
|
523 |
-
msgid "Hide URL language information for default language"
|
524 |
-
msgstr "Esconder do URL a informação do idioma por omissão"
|
525 |
-
|
526 |
-
#: admin/view-tab-settings.php:106
|
527 |
-
msgid "Remove /language/ in pretty permalinks"
|
528 |
-
msgstr "Remover /language/ das ligações permanentes"
|
529 |
-
|
530 |
-
#: admin/view-tab-settings.php:115
|
531 |
-
msgid "Keep /language/ in pretty permalinks"
|
532 |
-
msgstr "Deixar /language/ nas ligações permanentes"
|
533 |
-
|
534 |
-
#: admin/view-tab-settings.php:130
|
535 |
-
msgid "The front page url contains the language code instead of the page name or page id"
|
536 |
-
msgstr "O URL da página inicial contém o código do idioma em vez do nome ou ID da página"
|
537 |
-
|
538 |
-
#: admin/view-tab-settings.php:138
|
539 |
-
msgid "Example: %s instead of %s"
|
540 |
-
msgstr "Exemplo: %s em vez de %s"
|
541 |
-
|
542 |
-
#: admin/view-tab-settings.php:148
|
543 |
-
msgid "Detect browser language"
|
544 |
-
msgstr "Detectar o idioma do navegador"
|
545 |
-
|
546 |
-
#: admin/view-tab-settings.php:154
|
547 |
-
msgid "When the front page is visited, set the language according to the browser preference"
|
548 |
-
msgstr "Quando a pagina inicial for visitada, definir o idioma consoante as preferências do navegador"
|
549 |
-
|
550 |
-
#: admin/view-tab-settings.php:161
|
551 |
-
msgid "Media"
|
552 |
-
msgstr "Multimédia"
|
553 |
-
|
554 |
-
#: admin/view-tab-settings.php:167
|
555 |
-
msgid "Activate languages and translations for media"
|
556 |
-
msgstr "Activar idiomas e traduções para multimédia"
|
557 |
-
|
558 |
-
#: admin/view-tab-settings.php:175
|
559 |
-
msgid "Custom post types"
|
560 |
-
msgstr "Tipos de artigo personalizados"
|
561 |
-
|
562 |
-
#: admin/view-tab-settings.php:188
|
563 |
-
msgid "Activate languages and translations for custom post types."
|
564 |
-
msgstr "Activar idiomas e traduções para tipos de artigo personalizados."
|
565 |
-
|
566 |
-
#: admin/view-tab-settings.php:195
|
567 |
-
msgid "Custom taxonomies"
|
568 |
-
msgstr "Taxonomias personalizadas"
|
569 |
-
|
570 |
-
#: admin/view-tab-settings.php:208
|
571 |
-
msgid "Activate languages and translations for custom taxonomies."
|
572 |
-
msgstr "Activar idiomas e traduções para taxonomias personalizadas."
|
573 |
-
|
574 |
-
#: admin/view-tab-settings.php:214
|
575 |
-
msgid "Synchronization"
|
576 |
-
msgstr "Sincronização"
|
577 |
-
|
578 |
-
#: admin/view-tab-settings.php:225
|
579 |
-
msgid "The synchronization options allow to maintain exact same values (or translations in the case of taxonomies and page parent) of meta content between the translations of a post or page."
|
580 |
-
msgstr "As opçãos de sincronização permitem manter exactamente os mesmos valores (ou traduções no caso de taxonomias e páginas superiores) de meta conteúdo entre as traduções de um artigo ou página."
|
581 |
-
|
582 |
-
#: admin/view-tab-strings.php:8
|
583 |
-
msgid "Search translations"
|
584 |
-
msgstr "Pesquisar traduções"
|
585 |
-
|
586 |
-
#: admin/view-tab-strings.php:11
|
587 |
-
msgid "Clean strings translation database"
|
588 |
-
msgstr "Limpar base de dados das traduções de strings"
|
589 |
-
|
590 |
-
#: admin/view-tab-strings.php:12
|
591 |
-
msgid "Use this to remove unused strings from database, for example after a plugin has been uninstalled."
|
592 |
-
msgstr "Utilize isto para remover da base de dados as strings não utilizadas, por exemplo, quando um plugin é desinstalado."
|
593 |
-
|
594 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
595 |
-
#: admin/view-translations-term.php:30
|
596 |
-
msgid "Add new"
|
597 |
-
msgstr "Adicionar nova"
|
598 |
-
|
599 |
-
#: frontend/frontend-filters-search.php:80
|
600 |
-
msgid "Search"
|
601 |
-
msgstr "Pesquisar"
|
602 |
-
|
603 |
-
#: include/model.php:755
|
604 |
-
msgid "Uncategorized"
|
605 |
-
msgstr "Sem categoria"
|
606 |
-
|
607 |
-
#: include/plugins-compat.php:89
|
608 |
-
msgid "Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file."
|
609 |
-
msgstr "Importar <strong>artigos, páginas, comentários, campos personalizados, categorias e etiquetas</strong> a partir de um ficheiro de exportação do WordPress."
|
610 |
-
|
611 |
-
#: include/switcher.php:22
|
612 |
-
msgid "Displays language names"
|
613 |
-
msgstr "Mostra nomes dos idiomas"
|
614 |
-
|
615 |
-
#: include/switcher.php:23
|
616 |
-
msgid "Displays flags"
|
617 |
-
msgstr "Mostra bandeiras"
|
618 |
-
|
619 |
-
#: include/switcher.php:24
|
620 |
-
msgid "Forces link to front page"
|
621 |
-
msgstr "Força ligação para a página inicial"
|
622 |
-
|
623 |
-
#: include/switcher.php:25
|
624 |
-
msgid "Hides the current language"
|
625 |
-
msgstr "Esconde o idioma actual"
|
626 |
-
|
627 |
-
#: include/switcher.php:26
|
628 |
-
msgid "Hides languages with no translation"
|
629 |
-
msgstr "Esconde idiomas sem tradução"
|
630 |
-
|
631 |
-
#: include/switcher.php:30
|
632 |
-
msgid "Displays as dropdown"
|
633 |
-
msgstr "Mostra como caixa de selecção"
|
634 |
-
|
635 |
-
#. translators: Calendar caption: 1: month name, 2: 4-digit year
|
636 |
-
#: include/widget-calendar.php:124
|
637 |
-
msgctxt "calendar caption"
|
638 |
-
msgid "%1$s %2$s"
|
639 |
-
msgstr "%1$s %2$s"
|
640 |
-
|
641 |
-
#: include/widget-languages.php:16
|
642 |
-
msgid "Language Switcher"
|
643 |
-
msgstr "Selector de idioma"
|
644 |
-
|
645 |
-
#: include/widget-languages.php:16
|
646 |
-
msgid "Displays a language switcher"
|
647 |
-
msgstr "Mostra o selector de idioma"
|
648 |
-
|
649 |
-
#: include/widget-languages.php:75
|
650 |
-
msgid "Title:"
|
651 |
-
msgstr "Título:"
|
652 |
-
|
653 |
-
#: include/widget-recent-comments.php:46
|
654 |
-
msgid "Recent Comments"
|
655 |
-
msgstr "Comentários recentes"
|
656 |
-
|
657 |
-
#. translators: comments widget: 1: comment author, 2: post link
|
658 |
-
#: include/widget-recent-comments.php:84
|
659 |
-
msgctxt "widgets"
|
660 |
-
msgid "%1$s on %2$s"
|
661 |
-
msgstr "%1$s em %2$s"
|
662 |
-
|
663 |
-
#: include/widget-recent-posts.php:46
|
664 |
-
msgid "Recent Posts"
|
665 |
-
msgstr "Artigos recentes"
|
666 |
-
|
667 |
-
#: install/install.php:24
|
668 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
669 |
-
msgstr "Está a utilizar o WordPress %s. O Polylang necessita pelo menos da versão %s do WordPress."
|
670 |
-
|
671 |
-
#: install/upgrade.php:76
|
672 |
-
msgid "Polylang has been deactivated because you upgraded from a too old version."
|
673 |
-
msgstr "O Polylang foi desactivado porque actualizou a partir de uma versão muito antiga."
|
674 |
-
|
675 |
-
#: install/upgrade.php:78
|
676 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
677 |
-
msgstr "Por favor, actualize primeiro para %s antes de actualizar para %s."
|
678 |
-
|
679 |
-
#: lingotek/lingotek.php:26
|
680 |
-
msgid "You’ve just upgraded to the latest version of Polylang! Would you like to automatically translate your website for free?"
|
681 |
-
msgstr "Actualizou agora mesmo para a última versão do Polylang! Gostaria de traduzir o seu site de modo automático e gratuito?"
|
682 |
-
|
683 |
-
#: lingotek/lingotek.php:30
|
684 |
-
msgid "Close"
|
685 |
-
msgstr "Fechar"
|
686 |
-
|
687 |
-
#: lingotek/lingotek.php:33
|
688 |
-
msgid "Learn more"
|
689 |
-
msgstr "Saiba mais"
|
690 |
-
|
691 |
-
#: lingotek/lingotek.php:39
|
692 |
-
msgid "Click on Activate Lingotek to start translating."
|
693 |
-
msgstr "Clique em Activar Lingotek para começar a traduzir."
|
694 |
-
|
695 |
-
#: lingotek/lingotek.php:42
|
696 |
-
msgid "Activate Lingotek"
|
697 |
-
msgstr "Activar Lingotek"
|
698 |
-
|
699 |
-
#: lingotek/lingotek.php:54
|
700 |
-
msgid "Congratulations!"
|
701 |
-
msgstr "Parabéns!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-ro_RO.mo
DELETED
Binary file
|
languages/polylang-ro_RO.po
DELETED
@@ -1,676 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: Polylang v1.7beta1\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: \n"
|
6 |
-
"PO-Revision-Date: 2015-07-01 19:41+0300\n"
|
7 |
-
"Last-Translator: \n"
|
8 |
-
"Language-Team: \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=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?"
|
13 |
-
"2:1));\n"
|
14 |
-
"X-Poedit-SourceCharset: utf-8\n"
|
15 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
16 |
-
"_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"
|
17 |
-
"X-Poedit-Basepath: ..\n"
|
18 |
-
"X-Textdomain-Support: yes\n"
|
19 |
-
"X-Generator: Poedit 1.8.2\n"
|
20 |
-
"Language: ro\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 include o %sdocumentație%s detaliată (disponibilă doar în limba "
|
33 |
-
"engleză), care include informații precum: cum să îți configurezi situl "
|
34 |
-
"multilingvistic și cum să îl utilizezi zilnic, o listă de întrebări puse "
|
35 |
-
"frecvent, precum și o documentație pentru programatori, pentru a-și adapta "
|
36 |
-
"extensiile și temele lor pentru Polylang."
|
37 |
-
|
38 |
-
# @ polylang
|
39 |
-
#: admin/view-about.php:9
|
40 |
-
#, php-format
|
41 |
-
msgid ""
|
42 |
-
"You will also find useful information in the %ssupport forum%s. However "
|
43 |
-
"don't forget to make a search before posting a new topic."
|
44 |
-
msgstr ""
|
45 |
-
"Veți găsi informații utile și în %sforumurile de suport%s. Cu toate acestea, "
|
46 |
-
"nu uita să cauți în postările existente, înainte de a deschide un subiect "
|
47 |
-
"nou."
|
48 |
-
|
49 |
-
# @ polylang
|
50 |
-
#: admin/view-about.php:16
|
51 |
-
#, php-format
|
52 |
-
msgid ""
|
53 |
-
"Polylang is free of charge and is released under the same license as "
|
54 |
-
"WordPress, the %sGPL%s."
|
55 |
-
msgstr ""
|
56 |
-
"Polylang este gratis și este disponibil sub aceeași licență ca WordPress, "
|
57 |
-
"%sGPL%s."
|
58 |
-
|
59 |
-
# @ polylang
|
60 |
-
#: admin/view-about.php:22
|
61 |
-
#, php-format
|
62 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
63 |
-
msgstr "Dacă vreți să știți cum puteți să ajutați proiectul, %scitiți aici%s."
|
64 |
-
|
65 |
-
# @ polylang
|
66 |
-
#: admin/view-about.php:27
|
67 |
-
msgid ""
|
68 |
-
"Finally if you like this plugin or if it helps your business, donations to "
|
69 |
-
"the author are greatly appreciated."
|
70 |
-
msgstr ""
|
71 |
-
"Nu în ultimul rând, dacă vă place această extensie, sau dacă vă ajută "
|
72 |
-
"afacerea, donațiile către autor sunt binevenite."
|
73 |
-
|
74 |
-
# @ polylang
|
75 |
-
#: admin/admin-filters-post.php:115 admin/admin.php:90 admin/settings.php:70
|
76 |
-
#: admin/settings.php:97 include/model.php:561
|
77 |
-
msgid "Languages"
|
78 |
-
msgstr "Limbi disponibile"
|
79 |
-
|
80 |
-
# @ polylang
|
81 |
-
#: include/switcher.php:22
|
82 |
-
msgid "Displays language names"
|
83 |
-
msgstr "Numele afișat al limbilor disponibile"
|
84 |
-
|
85 |
-
# @ polylang
|
86 |
-
#: include/switcher.php:23
|
87 |
-
msgid "Displays flags"
|
88 |
-
msgstr "Steagurile afișate ale limbilor disponibile"
|
89 |
-
|
90 |
-
# @ polylang
|
91 |
-
#: include/switcher.php:24
|
92 |
-
msgid "Forces link to front page"
|
93 |
-
msgstr "Forțează link-ul către prima pagină"
|
94 |
-
|
95 |
-
# @ polylang
|
96 |
-
#: include/switcher.php:25
|
97 |
-
msgid "Hides the current language"
|
98 |
-
msgstr "Ascunde limba curentă"
|
99 |
-
|
100 |
-
# @ polylang
|
101 |
-
#: include/switcher.php:30
|
102 |
-
msgid "Displays as dropdown"
|
103 |
-
msgstr "Afișaj ca listă dropdown"
|
104 |
-
|
105 |
-
# @ polylang
|
106 |
-
#: admin/admin.php:267
|
107 |
-
msgid "Filters content by language"
|
108 |
-
msgstr "Filtrează conținutul după limbă"
|
109 |
-
|
110 |
-
# @ polylang
|
111 |
-
#: admin/admin.php:258
|
112 |
-
msgid "Show all languages"
|
113 |
-
msgstr "Afișează toate limbile"
|
114 |
-
|
115 |
-
# @ polylang
|
116 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
117 |
-
msgid "Add new translation"
|
118 |
-
msgstr "Adaugă traduceri noi"
|
119 |
-
|
120 |
-
# @ polylang
|
121 |
-
#: admin/admin-filters-columns.php:173 admin/admin-filters-media.php:55
|
122 |
-
#: admin/admin-filters-post.php:141 admin/admin-filters-term.php:75
|
123 |
-
#: admin/admin-filters-term.php:122 include/model.php:562
|
124 |
-
msgid "Language"
|
125 |
-
msgstr "Limbi"
|
126 |
-
|
127 |
-
# @ polylang
|
128 |
-
#: admin/table-string.php:112 admin/view-translations-media.php:5
|
129 |
-
#: admin/view-translations-post.php:5 admin/view-translations-term.php:6
|
130 |
-
#: admin/view-translations-term.php:11
|
131 |
-
msgid "Translations"
|
132 |
-
msgstr "Traduceri"
|
133 |
-
|
134 |
-
# @ polylang
|
135 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
136 |
-
msgid "Sets the language"
|
137 |
-
msgstr "Setează limba"
|
138 |
-
|
139 |
-
# @ polylang
|
140 |
-
#: admin/admin-filters.php:52
|
141 |
-
msgid "The widget is displayed for:"
|
142 |
-
msgstr "Widget-ul este afișat pentru:"
|
143 |
-
|
144 |
-
# @ polylang
|
145 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
146 |
-
msgid "All languages"
|
147 |
-
msgstr "Toate limbile"
|
148 |
-
|
149 |
-
# @ polylang
|
150 |
-
#: admin/admin-filters.php:123
|
151 |
-
msgid "Admin language"
|
152 |
-
msgstr "Limba de admin"
|
153 |
-
|
154 |
-
# @ polylang
|
155 |
-
#: admin/admin-filters.php:126
|
156 |
-
msgid "Wordpress default"
|
157 |
-
msgstr "Wordpress default"
|
158 |
-
|
159 |
-
# @ polylang
|
160 |
-
#: admin/admin.php:167 admin/settings.php:102
|
161 |
-
msgid "Settings"
|
162 |
-
msgstr "Setări"
|
163 |
-
|
164 |
-
# @ polylang
|
165 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
166 |
-
msgid "Upgrading language files…"
|
167 |
-
msgstr "Actualizarea fișierelor lingvistice;"
|
168 |
-
|
169 |
-
# @ polylang
|
170 |
-
#: admin/settings.php:62
|
171 |
-
msgid "About Polylang"
|
172 |
-
msgstr "Despre Polylang"
|
173 |
-
|
174 |
-
# @ polylang
|
175 |
-
#: admin/settings.php:78
|
176 |
-
msgid "Strings translations"
|
177 |
-
msgstr "Traduceri generale"
|
178 |
-
|
179 |
-
# @ polylang
|
180 |
-
#: admin/settings.php:101
|
181 |
-
msgid "Strings translation"
|
182 |
-
msgstr "Traduceri generale"
|
183 |
-
|
184 |
-
# @ polylang
|
185 |
-
#: admin/admin-model.php:244
|
186 |
-
msgid "Enter a valid WordPress locale"
|
187 |
-
msgstr "Introdu o localizare validă pentru WordPress"
|
188 |
-
|
189 |
-
# @ polylang
|
190 |
-
#: admin/admin-model.php:252
|
191 |
-
msgid "The language code must be unique"
|
192 |
-
msgstr "Codul de limbă trebuie să fie unic"
|
193 |
-
|
194 |
-
# @ polylang
|
195 |
-
#: admin/admin-model.php:256
|
196 |
-
msgid "The language must have a name"
|
197 |
-
msgstr "Limba trebuie să aibă un nume"
|
198 |
-
|
199 |
-
# @ polylang
|
200 |
-
#: admin/admin.php:367 admin/settings.php:180
|
201 |
-
msgid ""
|
202 |
-
"The language was created, but the WordPress language file was not "
|
203 |
-
"downloaded. Please install it manually."
|
204 |
-
msgstr ""
|
205 |
-
"Limba a fost creată, dar fișierul de limbă Wordpress nu a fost downloadat. "
|
206 |
-
"Te rugăm să-l instalezi manual."
|
207 |
-
|
208 |
-
# @ polylang
|
209 |
-
#: admin/admin-strings.php:59
|
210 |
-
msgid "Widget title"
|
211 |
-
msgstr "Titlu widget"
|
212 |
-
|
213 |
-
# @ polylang
|
214 |
-
#: admin/settings.php:319
|
215 |
-
msgid "Taxonomies"
|
216 |
-
msgstr "Taxonomii"
|
217 |
-
|
218 |
-
# @ polylang
|
219 |
-
#: admin/settings.php:320
|
220 |
-
msgid "Custom fields"
|
221 |
-
msgstr "Câmpuri customizate"
|
222 |
-
|
223 |
-
# @ polylang
|
224 |
-
#: admin/settings.php:321
|
225 |
-
msgid "Comment status"
|
226 |
-
msgstr "Status comentariu"
|
227 |
-
|
228 |
-
# @ polylang
|
229 |
-
#: admin/settings.php:322
|
230 |
-
msgid "Ping status"
|
231 |
-
msgstr "Status ping"
|
232 |
-
|
233 |
-
# @ polylang
|
234 |
-
#: admin/settings.php:323
|
235 |
-
msgid "Sticky posts"
|
236 |
-
msgstr "Postări importante"
|
237 |
-
|
238 |
-
# @ polylang
|
239 |
-
#: admin/settings.php:324
|
240 |
-
msgid "Published date"
|
241 |
-
msgstr "Data publicării"
|
242 |
-
|
243 |
-
# @ polylang
|
244 |
-
#: admin/settings.php:325
|
245 |
-
msgid "Post format"
|
246 |
-
msgstr "Formatul postării"
|
247 |
-
|
248 |
-
# @ polylang
|
249 |
-
#: admin/settings.php:326
|
250 |
-
msgid "Page parent"
|
251 |
-
msgstr "Pagina părinte"
|
252 |
-
|
253 |
-
# @ polylang
|
254 |
-
#: admin/settings.php:327
|
255 |
-
msgid "Page template"
|
256 |
-
msgstr "Template de pagină"
|
257 |
-
|
258 |
-
# @ polylang
|
259 |
-
#: admin/settings.php:328
|
260 |
-
msgid "Page order"
|
261 |
-
msgstr "Ordinea paginii"
|
262 |
-
|
263 |
-
# @ polylang
|
264 |
-
#: admin/settings.php:329
|
265 |
-
msgid "Featured image"
|
266 |
-
msgstr "Imagine atașată"
|
267 |
-
|
268 |
-
# @ polylang
|
269 |
-
#: admin/view-tab-lang.php:21
|
270 |
-
msgid "Edit language"
|
271 |
-
msgstr "Editează limba"
|
272 |
-
|
273 |
-
# @ polylang
|
274 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
275 |
-
msgid "Add new language"
|
276 |
-
msgstr "Adaugă o limbă nouă"
|
277 |
-
|
278 |
-
# @ polylang
|
279 |
-
#: admin/view-tab-lang.php:37
|
280 |
-
msgid "Choose a language"
|
281 |
-
msgstr "Alege o limbă"
|
282 |
-
|
283 |
-
# @ polylang
|
284 |
-
#: admin/view-tab-lang.php:51
|
285 |
-
msgid "You can choose a language in the list or directly edit it below."
|
286 |
-
msgstr "Alege o limbă din listă sau editează-le direct dedesubt."
|
287 |
-
|
288 |
-
# @ polylang
|
289 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
290 |
-
msgid "Full name"
|
291 |
-
msgstr "Nume și prenume"
|
292 |
-
|
293 |
-
# @ polylang
|
294 |
-
#: admin/view-tab-lang.php:57
|
295 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
296 |
-
msgstr "Numele, așa cum va fi afișat pe sait (spre exemplu: Engleză)."
|
297 |
-
|
298 |
-
# @ polylang
|
299 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
300 |
-
msgid "Locale"
|
301 |
-
msgstr "Localizare"
|
302 |
-
|
303 |
-
# @ polylang
|
304 |
-
#: admin/view-tab-lang.php:66
|
305 |
-
msgid ""
|
306 |
-
"Wordpress Locale for the language (for example: en_US). You will need to "
|
307 |
-
"install the .mo file for this language."
|
308 |
-
msgstr ""
|
309 |
-
"Localizarea WordPress pentru limbă (spre exemplu ro_RO). Va trebui să "
|
310 |
-
"instalezi fișierul .mo al acestei limbi."
|
311 |
-
|
312 |
-
# @ polylang
|
313 |
-
#: admin/view-tab-lang.php:70
|
314 |
-
msgid "Language code"
|
315 |
-
msgstr "Codul de limbă"
|
316 |
-
|
317 |
-
# @ polylang
|
318 |
-
#: admin/view-tab-lang.php:76
|
319 |
-
msgid "Text direction"
|
320 |
-
msgstr "Direcția textului"
|
321 |
-
|
322 |
-
# @ polylang
|
323 |
-
#: admin/view-tab-lang.php:80
|
324 |
-
msgid "left to right"
|
325 |
-
msgstr "stânga-dreapta"
|
326 |
-
|
327 |
-
# @ polylang
|
328 |
-
#: admin/view-tab-lang.php:85
|
329 |
-
msgid "right to left"
|
330 |
-
msgstr "dreapta-stânga"
|
331 |
-
|
332 |
-
# @ polylang
|
333 |
-
#: admin/view-tab-lang.php:87
|
334 |
-
msgid "Choose the text direction for the language"
|
335 |
-
msgstr "Alege direcția textului pentru limbă"
|
336 |
-
|
337 |
-
# @ polylang
|
338 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
339 |
-
msgid "Order"
|
340 |
-
msgstr "Ordine"
|
341 |
-
|
342 |
-
# @ polylang
|
343 |
-
#: admin/view-tab-lang.php:93
|
344 |
-
msgid "Position of the language in the language switcher"
|
345 |
-
msgstr "Poziția limbii în lista de schimbare"
|
346 |
-
|
347 |
-
# @ polylang
|
348 |
-
#: admin/admin-nav-menu.php:54 admin/admin-nav-menu.php:92
|
349 |
-
#: admin/admin-nav-menu.php:95 admin/admin-nav-menu.php:126
|
350 |
-
#: admin/admin-nav-menu.php:188 install/upgrade.php:301
|
351 |
-
msgid "Language switcher"
|
352 |
-
msgstr "Lista de schimbare"
|
353 |
-
|
354 |
-
# @ polylang
|
355 |
-
#: admin/view-tab-strings.php:8
|
356 |
-
msgid "Search translations"
|
357 |
-
msgstr "Caută traduceri"
|
358 |
-
|
359 |
-
# @ polylang
|
360 |
-
#: admin/view-tab-strings.php:11
|
361 |
-
msgid "Clean strings translation database"
|
362 |
-
msgstr "Șterge baza de date de traduceri generale"
|
363 |
-
|
364 |
-
# @ polylang
|
365 |
-
#: admin/view-tab-settings.php:14
|
366 |
-
msgid "Default language"
|
367 |
-
msgstr "Limba principală"
|
368 |
-
|
369 |
-
# @ polylang
|
370 |
-
#: admin/view-tab-settings.php:29
|
371 |
-
msgid ""
|
372 |
-
"There are posts, pages, categories or tags without language set. Do you want "
|
373 |
-
"to set them all to default language ?"
|
374 |
-
msgstr ""
|
375 |
-
"Sunt postări, pagini, categorii sau taguri fără o limbă atașată. Dorești să "
|
376 |
-
"le atașezi la limba principală?"
|
377 |
-
|
378 |
-
# @ polylang
|
379 |
-
#: admin/view-tab-settings.php:149
|
380 |
-
msgid "Detect browser language"
|
381 |
-
msgstr "Detectează limba browserului"
|
382 |
-
|
383 |
-
# @ polylang
|
384 |
-
#: admin/view-tab-settings.php:155
|
385 |
-
msgid ""
|
386 |
-
"When the front page is visited, set the language according to the browser "
|
387 |
-
"preference"
|
388 |
-
msgstr ""
|
389 |
-
"Când este accesată pagina principipală, setează limba potrivit preferințelor "
|
390 |
-
"browserului"
|
391 |
-
|
392 |
-
# @ polylang
|
393 |
-
#: admin/view-tab-settings.php:37
|
394 |
-
msgid "URL modifications"
|
395 |
-
msgstr "Modificări de URL"
|
396 |
-
|
397 |
-
# @ polylang
|
398 |
-
#: admin/view-tab-settings.php:93
|
399 |
-
msgid "Hide URL language information for default language"
|
400 |
-
msgstr "Ascunde informațiile de limbă în URL pentru limba principală"
|
401 |
-
|
402 |
-
# @ polylang
|
403 |
-
#: admin/view-tab-settings.php:162
|
404 |
-
msgid "Media"
|
405 |
-
msgstr "Media"
|
406 |
-
|
407 |
-
# @ polylang
|
408 |
-
#: admin/view-tab-settings.php:168
|
409 |
-
msgid "Activate languages and translations for media"
|
410 |
-
msgstr "Activează limbi și traduceri pentru media"
|
411 |
-
|
412 |
-
# @ polylang
|
413 |
-
#: admin/view-tab-settings.php:215
|
414 |
-
msgid "Synchronization"
|
415 |
-
msgstr "Sincronizare"
|
416 |
-
|
417 |
-
# @ polylang
|
418 |
-
#: admin/view-tab-settings.php:176
|
419 |
-
msgid "Custom post types"
|
420 |
-
msgstr "Postări customizate"
|
421 |
-
|
422 |
-
# @ polylang
|
423 |
-
#: admin/view-tab-settings.php:189
|
424 |
-
msgid "Activate languages and translations for custom post types."
|
425 |
-
msgstr "Activează limbi și traduceri pentru postări customizate."
|
426 |
-
|
427 |
-
# @ polylang
|
428 |
-
#: admin/view-tab-settings.php:196
|
429 |
-
msgid "Custom taxonomies"
|
430 |
-
msgstr "Taxonomii customizate"
|
431 |
-
|
432 |
-
# @ polylang
|
433 |
-
#: admin/view-tab-settings.php:209
|
434 |
-
msgid "Activate languages and translations for custom taxonomies."
|
435 |
-
msgstr "Activează limbi și traduceri pentru taxonomii customizate."
|
436 |
-
|
437 |
-
# @ polylang
|
438 |
-
#: admin/admin-filters-post.php:433 admin/admin-filters-term.php:642
|
439 |
-
#: admin/table-languages.php:54 admin/view-translations-media.php:21
|
440 |
-
msgid "Edit"
|
441 |
-
msgstr "Editează"
|
442 |
-
|
443 |
-
# @ polylang
|
444 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
445 |
-
msgid "Delete"
|
446 |
-
msgstr "Șterge"
|
447 |
-
|
448 |
-
# @ polylang
|
449 |
-
#: admin/table-languages.php:76
|
450 |
-
msgid "Code"
|
451 |
-
msgstr "Cod"
|
452 |
-
|
453 |
-
# @ polylang
|
454 |
-
#: admin/table-languages.php:78
|
455 |
-
msgid "Flag"
|
456 |
-
msgstr "Steag"
|
457 |
-
|
458 |
-
# @ polylang
|
459 |
-
#: admin/table-languages.php:79
|
460 |
-
msgid "Posts"
|
461 |
-
msgstr "Postări"
|
462 |
-
|
463 |
-
# @ polylang
|
464 |
-
#: admin/table-string.php:110
|
465 |
-
msgid "Name"
|
466 |
-
msgstr "Nume"
|
467 |
-
|
468 |
-
# @ polylang
|
469 |
-
#: admin/table-string.php:111
|
470 |
-
msgid "String"
|
471 |
-
msgstr "Șiruri de caractere"
|
472 |
-
|
473 |
-
# @ polylang
|
474 |
-
#: admin/view-translations-media.php:30 admin/view-translations-post.php:21
|
475 |
-
#: admin/view-translations-term.php:30
|
476 |
-
msgid "Add new"
|
477 |
-
msgstr "Adaugă"
|
478 |
-
|
479 |
-
# @ polylang
|
480 |
-
#: include/widget-languages.php:16
|
481 |
-
msgid "Language Switcher"
|
482 |
-
msgstr "Lista de limbi"
|
483 |
-
|
484 |
-
# @ polylang
|
485 |
-
#: include/widget-languages.php:16
|
486 |
-
msgid "Displays a language switcher"
|
487 |
-
msgstr "Afișează lista de limbi"
|
488 |
-
|
489 |
-
# @ polylang
|
490 |
-
#: include/widget-languages.php:75
|
491 |
-
msgid "Title:"
|
492 |
-
msgstr "Titlu"
|
493 |
-
|
494 |
-
# @ polylang
|
495 |
-
#. translators: plugin header field 'Description'
|
496 |
-
#: polylang.php:0
|
497 |
-
msgid "Adds multilingual capability to WordPress"
|
498 |
-
msgstr "Adaugă capacitate multilingvistică pentru WordPress"
|
499 |
-
|
500 |
-
# @ polylang
|
501 |
-
#: install/install.php:24
|
502 |
-
#, php-format
|
503 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
504 |
-
msgstr ""
|
505 |
-
"Folosești Wordpress versiunea %s. Polylang are nevoie de cel puțin WordPress "
|
506 |
-
"versiunea %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 a fost dezactivat, deoarece ai upgradat de la o versiune prea veche."
|
514 |
-
|
515 |
-
# @ polylang
|
516 |
-
#: install/upgrade.php:78
|
517 |
-
#, php-format
|
518 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
519 |
-
msgstr ""
|
520 |
-
"Te rugăm, upgradează întâi la versiunea %s, înainte de a upgrada la "
|
521 |
-
"versiunea %s."
|
522 |
-
|
523 |
-
# @ polylang
|
524 |
-
#: admin/table-string.php:109
|
525 |
-
msgid "Group"
|
526 |
-
msgstr "Grup"
|
527 |
-
|
528 |
-
# @ polylang
|
529 |
-
#: admin/table-string.php:187
|
530 |
-
msgid "View all groups"
|
531 |
-
msgstr "Vezi toate grupurile"
|
532 |
-
|
533 |
-
# @ polylang
|
534 |
-
#: admin/table-languages.php:59
|
535 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
536 |
-
msgstr "Ești pe cale să ștergi această limbă permanent. Ești sigur?"
|
537 |
-
|
538 |
-
# @ polylang
|
539 |
-
#: admin/view-tab-strings.php:12
|
540 |
-
msgid ""
|
541 |
-
"Use this to remove unused strings from database, for example after a plugin "
|
542 |
-
"has been uninstalled."
|
543 |
-
msgstr ""
|
544 |
-
"Folosește asta pentru a înlătura orice șiruri de caractere nefolosite din "
|
545 |
-
"baza de date, spre exemplu, după dezinstalarea unei extensii."
|
546 |
-
|
547 |
-
# @ polylang
|
548 |
-
#: admin/view-tab-settings.php:226
|
549 |
-
msgid ""
|
550 |
-
"The synchronization options allow to maintain exact same values (or "
|
551 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
552 |
-
"between the translations of a post or page."
|
553 |
-
msgstr ""
|
554 |
-
"Opțiunile de sincronizare permit menținerea acelorași valori (sau traduceri, "
|
555 |
-
"în cazul taxonomiilor și a paginii părinte) a conținutului meta, între "
|
556 |
-
"traducerile unei postări sau pagini."
|
557 |
-
|
558 |
-
# @ polylang
|
559 |
-
#: admin/admin-model.php:248
|
560 |
-
msgid "The language code contains invalid characters"
|
561 |
-
msgstr "Codul de limbă conține caractere invalide"
|
562 |
-
|
563 |
-
# @ polylang
|
564 |
-
#: admin/view-tab-settings.php:43
|
565 |
-
msgid "The language is set from content"
|
566 |
-
msgstr "Limba este stabilită din conținut"
|
567 |
-
|
568 |
-
# @ polylang
|
569 |
-
#: admin/view-tab-settings.php:46
|
570 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
571 |
-
msgstr ""
|
572 |
-
"Postările, paginile, categoriile și URL-urile tagurilor nu sunt modificate."
|
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 "Limba e stabilită din numele directorului, în permalink-uri drăguțe"
|
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 "Exemplu:"
|
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 ""
|
589 |
-
"Limba este stabilită din numele subdomeniilor, în permalinkuril drăguțe."
|
590 |
-
|
591 |
-
# @ polylang
|
592 |
-
#: admin/view-tab-settings.php:69
|
593 |
-
msgid "The language is set from different domains"
|
594 |
-
msgstr "Limba este stabilită din domenii diferite"
|
595 |
-
|
596 |
-
# @ polylang
|
597 |
-
#: admin/view-tab-settings.php:107
|
598 |
-
msgid "Remove /language/ in pretty permalinks"
|
599 |
-
msgstr "Înlătură /language/ din link-uri."
|
600 |
-
|
601 |
-
# @ polylang
|
602 |
-
#: admin/view-tab-settings.php:116
|
603 |
-
msgid "Keep /language/ in pretty permalinks"
|
604 |
-
msgstr "Păstreaza /language/ în link-uri."
|
605 |
-
|
606 |
-
# @ polylang
|
607 |
-
#: admin/view-tab-settings.php:131
|
608 |
-
msgid ""
|
609 |
-
"The front page url contains the language code instead of the page name or "
|
610 |
-
"page id"
|
611 |
-
msgstr ""
|
612 |
-
"URL-ul paginii de pornire conține codul de limbă și nu numele paginii sau id-"
|
613 |
-
"ul acesteia"
|
614 |
-
|
615 |
-
# @ polylang
|
616 |
-
#: admin/view-tab-settings.php:139
|
617 |
-
#, php-format
|
618 |
-
msgid "Example: %s instead of %s"
|
619 |
-
msgstr "Exemplu: %s în loc de %s"
|
620 |
-
|
621 |
-
# @ polylang
|
622 |
-
#: admin/admin-model.php:38
|
623 |
-
msgid "Impossible to add the language."
|
624 |
-
msgstr "Imposibil de adăugat limba."
|
625 |
-
|
626 |
-
# @ polylang
|
627 |
-
#: admin/admin-model.php:66
|
628 |
-
msgid "Language added."
|
629 |
-
msgstr "Limbă identificată."
|
630 |
-
|
631 |
-
# @ polylang
|
632 |
-
#: admin/admin-model.php:146
|
633 |
-
msgid "Language deleted."
|
634 |
-
msgstr "Limbă ștearsă."
|
635 |
-
|
636 |
-
# @ polylang
|
637 |
-
#: admin/admin-model.php:227
|
638 |
-
msgid "Language updated."
|
639 |
-
msgstr "Limbă actualizată."
|
640 |
-
|
641 |
-
# @ polylang
|
642 |
-
#: admin/settings.php:239
|
643 |
-
msgid "Translations updated."
|
644 |
-
msgstr "Traduceri actualizate."
|
645 |
-
|
646 |
-
# @ polylang
|
647 |
-
#: admin/view-tab-lang.php:72
|
648 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
649 |
-
msgstr ""
|
650 |
-
"Codul de limbă - preferabil 2 litere, în formatul ISO 639-1 (spre exemplu: "
|
651 |
-
"ro)"
|
652 |
-
|
653 |
-
# @ polylang
|
654 |
-
#: admin/admin-filters.php:203
|
655 |
-
msgid "The chosen static front page must be translated in all languages."
|
656 |
-
msgstr "Pagina principală statică trebuie tradusă în toate limbile."
|
657 |
-
|
658 |
-
# @ polylang
|
659 |
-
#: admin/admin-strings.php:60
|
660 |
-
msgid "Widget text"
|
661 |
-
msgstr "Textul de widget."
|
662 |
-
|
663 |
-
# @ polylang
|
664 |
-
#: admin/settings.php:52
|
665 |
-
msgid "Recommended plugins"
|
666 |
-
msgstr "Extensii recomandate"
|
667 |
-
|
668 |
-
# @ polylang
|
669 |
-
#: admin/view-tab-settings.php:51
|
670 |
-
msgid "The language is set from the code in the URL"
|
671 |
-
msgstr "Limba este stabilită din codul din URL"
|
672 |
-
|
673 |
-
# @ polylang
|
674 |
-
#: include/switcher.php:26
|
675 |
-
msgid "Hides languages with no translation"
|
676 |
-
msgstr "Ascunde limbile fără traduceri"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-sk_SK.mo
DELETED
Binary file
|
languages/polylang-sk_SK.po
DELETED
@@ -1,668 +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: 2015-04-12 16:19+0200\n"
|
7 |
-
"Last-Translator: Maros Kucera <maros.kucera@hotmail.com>\n"
|
8 |
-
"Language-Team: Slovak <>\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=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
|
13 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
14 |
-
"X-Poedit-KeywordsList: _e;__;_x\n"
|
15 |
-
"X-Poedit-Basepath: .\n"
|
16 |
-
"Language: sk_SK\n"
|
17 |
-
"X-Poedit-SearchPath-0: ..\n"
|
18 |
-
"X-Poedit-SearchPath-1: ../include\n"
|
19 |
-
|
20 |
-
#: admin/view-about.php:3
|
21 |
-
#, php-format
|
22 |
-
msgid ""
|
23 |
-
"Polylang is provided with an extensive %sdocumentation%s (in English only). "
|
24 |
-
"It includes information on how to set up your multilingual site and use it "
|
25 |
-
"on a daily basis, a FAQ, as well as a documentation for programmers to adapt "
|
26 |
-
"their plugins and themes."
|
27 |
-
msgstr ""
|
28 |
-
"Polylang je vybavený rozsiahlou %sdokumentáciou%s (iba v angličtine). "
|
29 |
-
"Obsahuje informácie o tom, ako nastaviť svoje viacjazyčné stránky a používať "
|
30 |
-
"ho na dennej báze, FAQ, ako aj dokumentáciu pre programátorov na "
|
31 |
-
"prispôsobenie svojich modulov a tém."
|
32 |
-
|
33 |
-
#: admin/view-about.php:9
|
34 |
-
#, php-format
|
35 |
-
msgid ""
|
36 |
-
"You will also find useful information in the %ssupport forum%s. However "
|
37 |
-
"don't forget to make a search before posting a new topic."
|
38 |
-
msgstr ""
|
39 |
-
"Užitočné informácie môžete nájsť aj na %sfóre podpory%s. Pred vytvorením "
|
40 |
-
"novej otázky však nezabudnite skúsiť svoj problém vyhľadať."
|
41 |
-
|
42 |
-
#: admin/view-about.php:16
|
43 |
-
#, php-format
|
44 |
-
msgid ""
|
45 |
-
"Polylang is free of charge and is released under the same license as "
|
46 |
-
"WordPress, the %sGPL%s."
|
47 |
-
msgstr ""
|
48 |
-
"Polylang je zadarmo a je uvoľnený pod rovnakou licenciou ako WordPress, "
|
49 |
-
"%sGPL%s."
|
50 |
-
|
51 |
-
#: admin/view-about.php:22
|
52 |
-
#, php-format
|
53 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
54 |
-
msgstr ""
|
55 |
-
"Ak by vás zaujímalo, ako môžete pomôcť projektu, %sprečítajte si toto %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 |
-
"Na záver, ak máte radi tento plugin alebo pomáha vašej firme, autor veľmi "
|
63 |
-
"ocení všetky dary."
|
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 "Jazyky"
|
69 |
-
|
70 |
-
#: include/switcher.php:22
|
71 |
-
msgid "Displays language names"
|
72 |
-
msgstr "Zobrazí názvy jazykov"
|
73 |
-
|
74 |
-
#: include/switcher.php:23
|
75 |
-
msgid "Displays flags"
|
76 |
-
msgstr "Zobrazí vlajky"
|
77 |
-
|
78 |
-
#: include/switcher.php:24
|
79 |
-
msgid "Forces link to front page"
|
80 |
-
msgstr "Vynúti odkaz na úvodnú stránku"
|
81 |
-
|
82 |
-
#: include/switcher.php:25
|
83 |
-
msgid "Hides the current language"
|
84 |
-
msgstr "Skryje aktuálne používaný jazyk"
|
85 |
-
|
86 |
-
#: include/switcher.php:30
|
87 |
-
msgid "Displays as dropdown"
|
88 |
-
msgstr "Zobrazí ako rozbaľovací zoznam"
|
89 |
-
|
90 |
-
#: admin/admin.php:267
|
91 |
-
msgid "Filters content by language"
|
92 |
-
msgstr "Filtruje obsah podľa jazyka"
|
93 |
-
|
94 |
-
#: admin/admin.php:258
|
95 |
-
msgid "Show all languages"
|
96 |
-
msgstr "Zobraziť všetky jazyky"
|
97 |
-
|
98 |
-
#: admin/admin-filters-columns.php:140 admin/admin-filters-columns.php:230
|
99 |
-
msgid "Add new translation"
|
100 |
-
msgstr "Pridanie nového prekladu"
|
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 "Jazyk"
|
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 "Preklady"
|
113 |
-
|
114 |
-
#: admin/admin-filters-term.php:82 admin/admin-filters-term.php:130
|
115 |
-
msgid "Sets the language"
|
116 |
-
msgstr "Nastaví jazyk"
|
117 |
-
|
118 |
-
#: admin/admin-filters.php:52
|
119 |
-
msgid "The widget is displayed for:"
|
120 |
-
msgstr "Widget zobrazí pre:"
|
121 |
-
|
122 |
-
#: admin/admin-filters.php:55 include/model.php:563
|
123 |
-
msgid "All languages"
|
124 |
-
msgstr "Všetky jazyky"
|
125 |
-
|
126 |
-
#: admin/admin-filters.php:123
|
127 |
-
msgid "Admin language"
|
128 |
-
msgstr "Jazyk administračného rozhrania"
|
129 |
-
|
130 |
-
#: admin/admin-filters.php:126
|
131 |
-
msgid "WordPress default"
|
132 |
-
msgstr "Predvolené vo WordPresse"
|
133 |
-
|
134 |
-
#: admin/admin.php:167 admin/settings.php:102
|
135 |
-
msgid "Settings"
|
136 |
-
msgstr "Nastavenia"
|
137 |
-
|
138 |
-
#: admin/admin-filters.php:160 admin/admin-filters.php:169
|
139 |
-
msgid "Upgrading language files…"
|
140 |
-
msgstr "Aktualizácia jazykových súborov &#8230;"
|
141 |
-
|
142 |
-
#: admin/settings.php:62
|
143 |
-
msgid "About Polylang"
|
144 |
-
msgstr "O Polylangu"
|
145 |
-
|
146 |
-
#: admin/settings.php:78
|
147 |
-
msgid "Strings translations"
|
148 |
-
msgstr "Preklady reťazcov"
|
149 |
-
|
150 |
-
#: admin/settings.php:101
|
151 |
-
msgid "Strings translation"
|
152 |
-
msgstr "Preklad reťazcov"
|
153 |
-
|
154 |
-
#: admin/admin-model.php:244
|
155 |
-
msgid "Enter a valid WordPress locale"
|
156 |
-
msgstr "Zadajte platný WordPress locale reťazec"
|
157 |
-
|
158 |
-
#: admin/admin-model.php:252
|
159 |
-
msgid "The language code must be unique"
|
160 |
-
msgstr "Kód jazyka musí byť jedinečný"
|
161 |
-
|
162 |
-
#: admin/admin-model.php:256
|
163 |
-
msgid "The language must have a name"
|
164 |
-
msgstr "Jazyk musí mať názov"
|
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 |
-
"Jazyk bol vytvorený, ale WordPress jazykový súbor sa neprevzal. Prosím "
|
172 |
-
"nainštalujte ho manuálne."
|
173 |
-
|
174 |
-
#: admin/admin-strings.php:59
|
175 |
-
msgid "Widget title"
|
176 |
-
msgstr "Titulok widgetu"
|
177 |
-
|
178 |
-
# @ polylang
|
179 |
-
#: admin/settings.php:319
|
180 |
-
msgid "Taxonomies"
|
181 |
-
msgstr "Taxonómie"
|
182 |
-
|
183 |
-
# @ polylang
|
184 |
-
#: admin/settings.php:320
|
185 |
-
msgid "Custom fields"
|
186 |
-
msgstr "Vlastné polia"
|
187 |
-
|
188 |
-
# @ polylang
|
189 |
-
#: admin/settings.php:321
|
190 |
-
msgid "Comment status"
|
191 |
-
msgstr "Stav komentára"
|
192 |
-
|
193 |
-
# @ polylang
|
194 |
-
#: admin/settings.php:322
|
195 |
-
msgid "Ping status"
|
196 |
-
msgstr "Stav pingu"
|
197 |
-
|
198 |
-
# @ polylang
|
199 |
-
#: admin/settings.php:323
|
200 |
-
msgid "Sticky posts"
|
201 |
-
msgstr "Pripnuté články"
|
202 |
-
|
203 |
-
# @ polylang
|
204 |
-
#: admin/settings.php:324
|
205 |
-
msgid "Published date"
|
206 |
-
msgstr "Dátum publikácie"
|
207 |
-
|
208 |
-
# @ polylang
|
209 |
-
#: admin/settings.php:325
|
210 |
-
msgid "Post format"
|
211 |
-
msgstr "Formát článku"
|
212 |
-
|
213 |
-
#: admin/settings.php:326
|
214 |
-
msgid "Page parent"
|
215 |
-
msgstr "Rodič stránky"
|
216 |
-
|
217 |
-
# @ polylang
|
218 |
-
#: admin/settings.php:327
|
219 |
-
msgid "Page template"
|
220 |
-
msgstr "Šablóna stránky"
|
221 |
-
|
222 |
-
#: admin/settings.php:328
|
223 |
-
msgid "Page order"
|
224 |
-
msgstr "Poradie stránky"
|
225 |
-
|
226 |
-
# @ polylang
|
227 |
-
#: admin/settings.php:329
|
228 |
-
msgid "Featured image"
|
229 |
-
msgstr "Vybraný obrázok"
|
230 |
-
|
231 |
-
#: admin/view-tab-lang.php:21
|
232 |
-
msgid "Edit language"
|
233 |
-
msgstr "Upraviť jazyk"
|
234 |
-
|
235 |
-
#: admin/view-tab-lang.php:21 admin/view-tab-lang.php:96
|
236 |
-
msgid "Add new language"
|
237 |
-
msgstr "Pridať nový jazyk"
|
238 |
-
|
239 |
-
#: admin/view-tab-lang.php:37
|
240 |
-
msgid "Choose a language"
|
241 |
-
msgstr "Vyberte jazyk"
|
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 ""
|
246 |
-
"Môžete si zvoliť ľubovoľný jazyk zo zoznamu alebo ho priamo upraviť nižšie."
|
247 |
-
|
248 |
-
#: admin/table-languages.php:74 admin/view-tab-lang.php:55
|
249 |
-
msgid "Full name"
|
250 |
-
msgstr "Celé meno"
|
251 |
-
|
252 |
-
#: admin/view-tab-lang.php:57
|
253 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
254 |
-
msgstr "Meno je zobrazené na vašich stránkach (napríklad: angličtina)."
|
255 |
-
|
256 |
-
#: admin/table-languages.php:75 admin/view-tab-lang.php:61
|
257 |
-
msgid "Locale"
|
258 |
-
msgstr "Locale reťazec"
|
259 |
-
|
260 |
-
#: admin/view-tab-lang.php:66
|
261 |
-
msgid ""
|
262 |
-
"WordPress Locale for the language (for example: en_US). You will need to "
|
263 |
-
"install the .mo file for this language."
|
264 |
-
msgstr ""
|
265 |
-
"WordPress Locale reťazec jazyka (napríklad: en_US). Budete musieť "
|
266 |
-
"nainštalovať .mo súbor pre tento jazyk."
|
267 |
-
|
268 |
-
#: admin/view-tab-lang.php:70
|
269 |
-
msgid "Language code"
|
270 |
-
msgstr "Kód jazyka"
|
271 |
-
|
272 |
-
#: admin/view-tab-lang.php:76
|
273 |
-
msgid "Text direction"
|
274 |
-
msgstr "Smer textu"
|
275 |
-
|
276 |
-
#: admin/view-tab-lang.php:80
|
277 |
-
msgid "left to right"
|
278 |
-
msgstr "zľava doprava"
|
279 |
-
|
280 |
-
#: admin/view-tab-lang.php:85
|
281 |
-
msgid "right to left"
|
282 |
-
msgstr "sprava doľava"
|
283 |
-
|
284 |
-
#: admin/view-tab-lang.php:87
|
285 |
-
msgid "Choose the text direction for the language"
|
286 |
-
msgstr "Výber smeru textu pre jazyk"
|
287 |
-
|
288 |
-
#: admin/table-languages.php:77 admin/view-tab-lang.php:91
|
289 |
-
msgid "Order"
|
290 |
-
msgstr "Poradie"
|
291 |
-
|
292 |
-
#: admin/view-tab-lang.php:93
|
293 |
-
msgid "Position of the language in the language switcher"
|
294 |
-
msgstr "Poradie jazyka v prepínači jazykov"
|
295 |
-
|
296 |
-
#: admin/admin-nav-menu.php:54 admin/admin-nav-menu.php:92
|
297 |
-
#: admin/admin-nav-menu.php:95 admin/admin-nav-menu.php:126
|
298 |
-
#: admin/admin-nav-menu.php:188 install/upgrade.php:301
|
299 |
-
msgid "Language switcher"
|
300 |
-
msgstr "Prepínač jazykov"
|
301 |
-
|
302 |
-
#: admin/view-tab-strings.php:8
|
303 |
-
msgid "Search translations"
|
304 |
-
msgstr "Preklady vyhľadávania"
|
305 |
-
|
306 |
-
#: admin/view-tab-strings.php:11
|
307 |
-
msgid "Clean strings translation database"
|
308 |
-
msgstr "Vyčistiť databázu reťazcov prekladu"
|
309 |
-
|
310 |
-
#: admin/view-tab-settings.php:14
|
311 |
-
msgid "Default language"
|
312 |
-
msgstr "Predvolený jazyk"
|
313 |
-
|
314 |
-
#: admin/view-tab-settings.php:29
|
315 |
-
msgid ""
|
316 |
-
"There are posts, pages, categories or tags without language set. Do you want "
|
317 |
-
"to set them all to default language ?"
|
318 |
-
msgstr ""
|
319 |
-
"Existujú príspevky, stránky, kategórie alebo značky bez nastaveného jazyka. "
|
320 |
-
"Chcete ich jazyk nastaviť na predvolený?"
|
321 |
-
|
322 |
-
#: admin/view-tab-settings.php:149
|
323 |
-
msgid "Detect browser language"
|
324 |
-
msgstr "Detekovať jazyk prehliadača"
|
325 |
-
|
326 |
-
#: admin/view-tab-settings.php:155
|
327 |
-
msgid ""
|
328 |
-
"When the front page is visited, set the language according to the browser "
|
329 |
-
"preference"
|
330 |
-
msgstr ""
|
331 |
-
"Pri navštívení úvodnej stránky nastaví jazyk podľa preferencie prehliadača"
|
332 |
-
|
333 |
-
#: admin/view-tab-settings.php:37
|
334 |
-
msgid "URL modifications"
|
335 |
-
msgstr "Úpravy URL"
|
336 |
-
|
337 |
-
#: admin/view-tab-settings.php:93
|
338 |
-
msgid "Hide URL language information for default language"
|
339 |
-
msgstr "Skryť informáciu o jazyku v URL pre predvolený jazyk"
|
340 |
-
|
341 |
-
# @ polylang
|
342 |
-
#: admin/view-tab-settings.php:162
|
343 |
-
msgid "Media"
|
344 |
-
msgstr "Médiá"
|
345 |
-
|
346 |
-
# @ polylang
|
347 |
-
#: admin/view-tab-settings.php:168
|
348 |
-
msgid "Activate languages and translations for media"
|
349 |
-
msgstr "Zapnúť jazyky a preklady pre médiá"
|
350 |
-
|
351 |
-
#: admin/view-tab-settings.php:215
|
352 |
-
msgid "Synchronization"
|
353 |
-
msgstr "Synchronizácia"
|
354 |
-
|
355 |
-
# @ polylang
|
356 |
-
#: admin/view-tab-settings.php:176
|
357 |
-
msgid "Custom post types"
|
358 |
-
msgstr "Vlastné typy obsahu"
|
359 |
-
|
360 |
-
# @ polylang
|
361 |
-
#: admin/view-tab-settings.php:189
|
362 |
-
msgid "Activate languages and translations for custom post types."
|
363 |
-
msgstr "Zapnúť jazyky a preklady pre vlastné typy obsahu."
|
364 |
-
|
365 |
-
# @ polylang
|
366 |
-
#: admin/view-tab-settings.php:196
|
367 |
-
msgid "Custom taxonomies"
|
368 |
-
msgstr "Vlastné taxonómie"
|
369 |
-
|
370 |
-
# @ polylang
|
371 |
-
#: admin/view-tab-settings.php:209
|
372 |
-
msgid "Activate languages and translations for custom taxonomies."
|
373 |
-
msgstr "Zapnúť jazyky a preklady pre vlastné taxonómie."
|
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 "Upraviť"
|
379 |
-
|
380 |
-
#: admin/table-languages.php:60 admin/table-string.php:168
|
381 |
-
msgid "Delete"
|
382 |
-
msgstr "Odstrániť"
|
383 |
-
|
384 |
-
#: admin/table-languages.php:76
|
385 |
-
msgid "Code"
|
386 |
-
msgstr "Kód"
|
387 |
-
|
388 |
-
#: admin/table-languages.php:78
|
389 |
-
msgid "Flag"
|
390 |
-
msgstr "Vlajka"
|
391 |
-
|
392 |
-
#: admin/table-languages.php:79
|
393 |
-
msgid "Posts"
|
394 |
-
msgstr "Príspevky"
|
395 |
-
|
396 |
-
#: admin/table-string.php:110
|
397 |
-
msgid "Name"
|
398 |
-
msgstr "Meno"
|
399 |
-
|
400 |
-
#: admin/table-string.php:111
|
401 |
-
msgid "String"
|
402 |
-
msgstr "Reťazec"
|
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 "Pridať nové"
|
408 |
-
|
409 |
-
#: include/widget-languages.php:16
|
410 |
-
msgid "Language Switcher"
|
411 |
-
msgstr "Prepínač jazykov"
|
412 |
-
|
413 |
-
#: include/widget-languages.php:16
|
414 |
-
msgid "Displays a language switcher"
|
415 |
-
msgstr "Zobrazí prepínač jazykov"
|
416 |
-
|
417 |
-
#: include/widget-languages.php:75
|
418 |
-
msgid "Title:"
|
419 |
-
msgstr "Titulok:"
|
420 |
-
|
421 |
-
# @ polylang
|
422 |
-
#. translators: plugin header field 'Description'
|
423 |
-
#: polylang.php:0
|
424 |
-
msgid "Adds multilingual capability to WordPress"
|
425 |
-
msgstr "Pridá viacjazyčnosť do WordPressu"
|
426 |
-
|
427 |
-
#: install/install.php:24
|
428 |
-
#, php-format
|
429 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
430 |
-
msgstr "Používate WordPress %s. Polylang vyžaduje aspoň 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 bol deactivvovaný, pretože ste aktualizovali z príliš starej verzie."
|
438 |
-
|
439 |
-
# @ polylang
|
440 |
-
#: install/upgrade.php:78
|
441 |
-
#, php-format
|
442 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
443 |
-
msgstr "Najprv prosím aktualizujte na %s, až potom na %s."
|
444 |
-
|
445 |
-
# @ polylang
|
446 |
-
#: admin/table-string.php:109
|
447 |
-
msgid "Group"
|
448 |
-
msgstr "Skupina"
|
449 |
-
|
450 |
-
# @ polylang
|
451 |
-
#: admin/table-string.php:187
|
452 |
-
msgid "View all groups"
|
453 |
-
msgstr "Zobraziť všetky skupiny"
|
454 |
-
|
455 |
-
# @ polylang
|
456 |
-
#: admin/table-languages.php:59
|
457 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
458 |
-
msgstr "Chystáte sa navždy odstrániť tento jazyk. Naozaj chcete pokračovať?"
|
459 |
-
|
460 |
-
# @ polylang
|
461 |
-
#: admin/view-tab-strings.php:12
|
462 |
-
msgid ""
|
463 |
-
"Use this to remove unused strings from database, for example after a plugin "
|
464 |
-
"has been uninstalled."
|
465 |
-
msgstr ""
|
466 |
-
"Túto voľbu použite na vymazanie nepoužívaných reťazcov z databázy, napríklad "
|
467 |
-
"po odinštalovaní modulu."
|
468 |
-
|
469 |
-
# @ polylang
|
470 |
-
#: admin/view-tab-settings.php:226
|
471 |
-
msgid ""
|
472 |
-
"The synchronization options allow to maintain exact same values (or "
|
473 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
474 |
-
"between the translations of a post or page."
|
475 |
-
msgstr ""
|
476 |
-
"Možnosti synchronizácie umožňujú zachovať presne rovnaké hodnoty (alebo "
|
477 |
-
"preklady v prípade taxonómií a rodičov stránky) meta údajov vo všetkých "
|
478 |
-
"prekladoch článku alebo stránky."
|
479 |
-
|
480 |
-
#: admin/admin-model.php:248
|
481 |
-
msgid "The language code contains invalid characters"
|
482 |
-
msgstr "Kód jazyka obsahuje neplatné znaky"
|
483 |
-
|
484 |
-
#: admin/view-tab-settings.php:43
|
485 |
-
msgid "The language is set from content"
|
486 |
-
msgstr "Jazyk sa nastaví v závislosti od obsahu"
|
487 |
-
|
488 |
-
#: admin/view-tab-settings.php:46
|
489 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
490 |
-
msgstr "URL článkov, stránok, kategórií a značiek sa nemenia."
|
491 |
-
|
492 |
-
#: admin/view-tab-settings.php:51
|
493 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
494 |
-
msgstr "Jazyk sa nastaví v závislosti od mena priečinka v trvalom odkaze"
|
495 |
-
|
496 |
-
# @ polylang
|
497 |
-
#: admin/view-tab-settings.php:54 admin/view-tab-settings.php:63
|
498 |
-
#: admin/view-tab-settings.php:110 admin/view-tab-settings.php:119
|
499 |
-
msgid "Example:"
|
500 |
-
msgstr "Príklad:"
|
501 |
-
|
502 |
-
#: admin/view-tab-settings.php:60
|
503 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
504 |
-
msgstr "Jazyk sa nastaví v závislosti od subdomény v trvalom odkaze"
|
505 |
-
|
506 |
-
# @ polylang
|
507 |
-
#: admin/view-tab-settings.php:69
|
508 |
-
msgid "The language is set from different domains"
|
509 |
-
msgstr "Jazyk sa nastaví v závislosti od domény"
|
510 |
-
|
511 |
-
#: admin/view-tab-settings.php:107
|
512 |
-
msgid "Remove /language/ in pretty permalinks"
|
513 |
-
msgstr "Odstrániť /language/ z trvalých odkazov"
|
514 |
-
|
515 |
-
#: admin/view-tab-settings.php:116
|
516 |
-
msgid "Keep /language/ in pretty permalinks"
|
517 |
-
msgstr "Ponechať /language/ v trvalých odkazoch"
|
518 |
-
|
519 |
-
# @ polylang
|
520 |
-
#: admin/view-tab-settings.php:131
|
521 |
-
msgid ""
|
522 |
-
"The front page url contains the language code instead of the page name or "
|
523 |
-
"page id"
|
524 |
-
msgstr ""
|
525 |
-
"URL úvodnej stránky obsahuje kód jazyka namiesto mena stránky alebo ID "
|
526 |
-
"stránky"
|
527 |
-
|
528 |
-
# @ polylang
|
529 |
-
#: admin/view-tab-settings.php:139
|
530 |
-
#, php-format
|
531 |
-
msgid "Example: %s instead of %s"
|
532 |
-
msgstr "Príklad: %s namiesto %s"
|
533 |
-
|
534 |
-
#: admin/admin-model.php:38
|
535 |
-
msgid "Impossible to add the language."
|
536 |
-
msgstr "Nie je možné pridať jazyk."
|
537 |
-
|
538 |
-
# @ polylang
|
539 |
-
#: admin/admin-model.php:66
|
540 |
-
msgid "Language added."
|
541 |
-
msgstr "Jazyk bol pridaný."
|
542 |
-
|
543 |
-
# @ polylang
|
544 |
-
#: admin/admin-model.php:146
|
545 |
-
msgid "Language deleted."
|
546 |
-
msgstr "Jazyk bol odstránený."
|
547 |
-
|
548 |
-
# @ polylang
|
549 |
-
#: admin/admin-model.php:227
|
550 |
-
msgid "Language updated."
|
551 |
-
msgstr "Jazyk bol aktualizovaný."
|
552 |
-
|
553 |
-
# @ polylang
|
554 |
-
#: admin/settings.php:239
|
555 |
-
msgid "Translations updated."
|
556 |
-
msgstr "Preklady boli aktualizované."
|
557 |
-
|
558 |
-
#: admin/view-tab-lang.php:72
|
559 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
560 |
-
msgstr "Kód jazyka - najlepšie 2-písmenový ISO 639-1 kód (napríklad: sk)"
|
561 |
-
|
562 |
-
# @ polylang
|
563 |
-
#: admin/admin-filters.php:203
|
564 |
-
msgid "The chosen static front page must be translated in all languages."
|
565 |
-
msgstr "Zvolená úvodná stránka musí byť preložená vo všetkých jazykoch."
|
566 |
-
|
567 |
-
#: admin/admin-strings.php:60
|
568 |
-
msgid "Widget text"
|
569 |
-
msgstr "Text widgetu"
|
570 |
-
|
571 |
-
# @ polylang
|
572 |
-
#: admin/settings.php:52
|
573 |
-
msgid "Recommended plugins"
|
574 |
-
msgstr "Odporúčané moduly"
|
575 |
-
|
576 |
-
#: admin/view-tab-settings.php:51
|
577 |
-
msgid "The language is set from the code in the URL"
|
578 |
-
msgstr "Jazyk sa nastaví v závislosti od kódu v URL"
|
579 |
-
|
580 |
-
#: include/switcher.php:26
|
581 |
-
msgid "Hides languages with no translation"
|
582 |
-
msgstr "Skryje jazyky bez prekladov"
|
583 |
-
|
584 |
-
#~ msgid "2-letters ISO 639-1 language code (for example: en)"
|
585 |
-
#~ msgstr "2-listy kód ISO 639-1 jazyk (napríklad: en)"
|
586 |
-
|
587 |
-
#~ msgid "Translation"
|
588 |
-
#~ msgstr "Preklad"
|
589 |
-
|
590 |
-
#~ msgid "ID of pages in other languages:"
|
591 |
-
#~ msgstr "ID stránok v iných jazykoch:"
|
592 |
-
|
593 |
-
#~ msgid "Page ID"
|
594 |
-
#~ msgstr "Identifikácia stránky"
|
595 |
-
|
596 |
-
#~ msgid "Post ID"
|
597 |
-
#~ msgstr "Post ID"
|
598 |
-
|
599 |
-
#~ msgid "No untranslated term"
|
600 |
-
#~ msgstr "Žiadne nepreložené obdobie"
|
601 |
-
|
602 |
-
#~ msgid ""
|
603 |
-
#~ "When using static front page, redirect the language page (example: %s) to "
|
604 |
-
#~ "the front page in the right language"
|
605 |
-
#~ msgstr ""
|
606 |
-
#~ "Pri použití statické predná strana, presmerovať stránku jazyka (príklad: "
|
607 |
-
#~ "%s) na prednej strane v správneho jazyka"
|
608 |
-
|
609 |
-
#~ msgid ""
|
610 |
-
#~ "For some reasons, Polylang could not create a table in your database."
|
611 |
-
#~ msgstr "Pre niektoré dôvody, Polylang by mohlo vytvoriť tabuľku v databáze."
|
612 |
-
|
613 |
-
#~ msgid "Displays a language switcher at the end of the menu"
|
614 |
-
#~ msgstr "Prepínač jazykov sa zobrazuje na konci menu"
|
615 |
-
|
616 |
-
#~ msgid "Theme locations and languages"
|
617 |
-
#~ msgstr "Téma miest a jazykov"
|
618 |
-
|
619 |
-
#~ msgid ""
|
620 |
-
#~ "Please go to the %slanguages page%s to set theme locations and languages"
|
621 |
-
#~ msgstr ""
|
622 |
-
#~ "Prosím, choďte na slanguages %stránku %s nastaviť tému lokality a jazyky"
|
623 |
-
|
624 |
-
#~ msgid "Menus"
|
625 |
-
#~ msgstr "Menu"
|
626 |
-
|
627 |
-
#~ msgid "Error: Restore of local flags failed!"
|
628 |
-
#~ msgstr "Chyba: Obnovenie miestnej vlajok zlyhalo!"
|
629 |
-
|
630 |
-
#~ msgid "Please move your local flags from %s to %s"
|
631 |
-
#~ msgstr "Prosím presunúť svoje miestne vlajky od %s do %s"
|
632 |
-
|
633 |
-
#~ msgid "%1$s %2$s"
|
634 |
-
#~ msgstr "%1$s %2$s"
|
635 |
-
|
636 |
-
#~ msgid "View posts for %1$s %2$s"
|
637 |
-
#~ msgstr "View posts for %1$s %2$s"
|
638 |
-
|
639 |
-
#~ msgid "Site Title"
|
640 |
-
#~ msgstr "Názov lokality"
|
641 |
-
|
642 |
-
#~ msgid "Tagline"
|
643 |
-
#~ msgstr "Slogan"
|
644 |
-
|
645 |
-
#~ msgid "— No Change —"
|
646 |
-
#~ msgstr "&mdash; Žiadna zmena &mdash;"
|
647 |
-
|
648 |
-
#~ msgid "Page's language:"
|
649 |
-
#~ msgstr "Stránky jazyka:"
|
650 |
-
|
651 |
-
#~ msgid "Post's language:"
|
652 |
-
#~ msgstr "Príspevok jazyk:"
|
653 |
-
|
654 |
-
#~ msgid "None"
|
655 |
-
#~ msgstr "Žiadny"
|
656 |
-
|
657 |
-
#~ msgid "Update"
|
658 |
-
#~ msgstr "Aktualizácia"
|
659 |
-
|
660 |
-
#~ msgid ""
|
661 |
-
#~ "Allow to synchronize categories, tags, featured image and other metas "
|
662 |
-
#~ "between translations of a post or page"
|
663 |
-
#~ msgstr ""
|
664 |
-
#~ "Umožňujú synchronizovať kategórie, značky, Odporúčané image a ostatné "
|
665 |
-
#~ "metas medzi preklady príspevok alebo stránku"
|
666 |
-
|
667 |
-
#~ msgid "Search"
|
668 |
-
#~ msgstr "Hľadať"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang-sv_SE.mo
DELETED
Binary file
|
languages/polylang-sv_SE.po
DELETED
@@ -1,661 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: polylang\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: 2015-02-15 09:08+0100\n"
|
6 |
-
"PO-Revision-Date: \n"
|
7 |
-
"Last-Translator: Jon Täng <contact@jontang.se>\n"
|
8 |
-
"Language-Team: \n"
|
9 |
-
"Language: sv_SE\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.7.4\n"
|
18 |
-
"X-Poedit-SearchPath-0: ..\n"
|
19 |
-
"X-Poedit-SearchPath-1: ../include\n"
|
20 |
-
|
21 |
-
#: ../admin/admin-filters-columns.php:140
|
22 |
-
#: ../admin/admin-filters-columns.php:230
|
23 |
-
msgid "Add new translation"
|
24 |
-
msgstr "Lägg till översättning"
|
25 |
-
|
26 |
-
#: ../admin/admin-filters-columns.php:160
|
27 |
-
msgid "— No Change —"
|
28 |
-
msgstr "— Ingen förändring —"
|
29 |
-
|
30 |
-
#: ../admin/admin-filters-columns.php:173 ../admin/admin-filters-media.php:55
|
31 |
-
#: ../admin/admin-filters-post.php:141 ../admin/admin-filters-term.php:75
|
32 |
-
#: ../admin/admin-filters-term.php:122 ../include/model.php:562
|
33 |
-
msgid "Language"
|
34 |
-
msgstr "Språk"
|
35 |
-
|
36 |
-
#: ../admin/admin-filters-post.php:115 ../admin/admin.php:90
|
37 |
-
#: ../admin/settings.php:70 ../admin/settings.php:97 ../include/model.php:561
|
38 |
-
msgid "Languages"
|
39 |
-
msgstr "Språk"
|
40 |
-
|
41 |
-
#: ../admin/admin-filters-post.php:433 ../admin/admin-filters-term.php:642
|
42 |
-
#: ../admin/table-languages.php:54 ../admin/view-translations-media.php:21
|
43 |
-
msgid "Edit"
|
44 |
-
msgstr "Redigera"
|
45 |
-
|
46 |
-
#: ../admin/admin-filters-term.php:82 ../admin/admin-filters-term.php:130
|
47 |
-
msgid "Sets the language"
|
48 |
-
msgstr "Ställer in språk"
|
49 |
-
|
50 |
-
#: ../admin/admin-filters-term.php:384
|
51 |
-
msgid "None"
|
52 |
-
msgstr "Inget"
|
53 |
-
|
54 |
-
#: ../admin/admin-filters.php:52
|
55 |
-
msgid "The widget is displayed for:"
|
56 |
-
msgstr "Widgeten visas för:"
|
57 |
-
|
58 |
-
#: ../admin/admin-filters.php:55 ../include/model.php:563
|
59 |
-
msgid "All languages"
|
60 |
-
msgstr "Alla språk"
|
61 |
-
|
62 |
-
#: ../admin/admin-filters.php:123
|
63 |
-
msgid "Admin language"
|
64 |
-
msgstr "Språk i Admin"
|
65 |
-
|
66 |
-
#: ../admin/admin-filters.php:126
|
67 |
-
msgid "WordPress default"
|
68 |
-
msgstr "WordPress standard"
|
69 |
-
|
70 |
-
#: ../admin/admin-filters.php:160 ../admin/admin-filters.php:169
|
71 |
-
msgid "Upgrading language files…"
|
72 |
-
msgstr "Uppgraderar språkfiler…"
|
73 |
-
|
74 |
-
# @ polylang
|
75 |
-
#: ../admin/admin-filters.php:203
|
76 |
-
msgid "The chosen static front page must be translated in all languages."
|
77 |
-
msgstr "Den valda statiska framsidan måste vara översatt på alla språk."
|
78 |
-
|
79 |
-
#: ../admin/admin-model.php:38
|
80 |
-
msgid "Impossible to add the language."
|
81 |
-
msgstr "Omöjligt att lägga till språket."
|
82 |
-
|
83 |
-
# @ polylang
|
84 |
-
#: ../admin/admin-model.php:66
|
85 |
-
msgid "Language added."
|
86 |
-
msgstr "Språk tillagt"
|
87 |
-
|
88 |
-
# @ polylang
|
89 |
-
#: ../admin/admin-model.php:146
|
90 |
-
msgid "Language deleted."
|
91 |
-
msgstr "Språk borttaget"
|
92 |
-
|
93 |
-
# @ polylang
|
94 |
-
#: ../admin/admin-model.php:227
|
95 |
-
msgid "Language updated."
|
96 |
-
msgstr "Språk uppdaterat"
|
97 |
-
|
98 |
-
#: ../admin/admin-model.php:244
|
99 |
-
msgid "Enter a valid WordPress locale"
|
100 |
-
msgstr "Ange ett giltigt språkprefix"
|
101 |
-
|
102 |
-
#: ../admin/admin-model.php:248
|
103 |
-
msgid "The language code contains invalid characters"
|
104 |
-
msgstr "Språkkoden innehåller felaktiga tecken"
|
105 |
-
|
106 |
-
#: ../admin/admin-model.php:252
|
107 |
-
msgid "The language code must be unique"
|
108 |
-
msgstr "Språkkoden måste vara unik"
|
109 |
-
|
110 |
-
#: ../admin/admin-model.php:256
|
111 |
-
msgid "The language must have a name"
|
112 |
-
msgstr "Språket måste ha ett namn"
|
113 |
-
|
114 |
-
#: ../admin/admin-nav-menu.php:54 ../admin/admin-nav-menu.php:92
|
115 |
-
#: ../admin/admin-nav-menu.php:95 ../admin/admin-nav-menu.php:126
|
116 |
-
#: ../admin/admin-nav-menu.php:188 ../install/upgrade.php:301
|
117 |
-
msgid "Language switcher"
|
118 |
-
msgstr "Språkväljare"
|
119 |
-
|
120 |
-
#: ../admin/admin-strings.php:54
|
121 |
-
msgid "Site Title"
|
122 |
-
msgstr "Titel för webbplats"
|
123 |
-
|
124 |
-
#: ../admin/admin-strings.php:55
|
125 |
-
msgid "Tagline"
|
126 |
-
msgstr "Slogan"
|
127 |
-
|
128 |
-
#: ../admin/admin-strings.php:56
|
129 |
-
msgid "Date Format"
|
130 |
-
msgstr "Datumformat"
|
131 |
-
|
132 |
-
#: ../admin/admin-strings.php:57
|
133 |
-
msgid "Time Format"
|
134 |
-
msgstr "Tidsformat"
|
135 |
-
|
136 |
-
#: ../admin/admin-strings.php:59
|
137 |
-
msgid "Widget title"
|
138 |
-
msgstr "Widgetrubrik"
|
139 |
-
|
140 |
-
#: ../admin/admin-strings.php:60
|
141 |
-
msgid "Widget text"
|
142 |
-
msgstr "Widgettext"
|
143 |
-
|
144 |
-
#: ../admin/admin.php:167 ../admin/settings.php:102
|
145 |
-
msgid "Settings"
|
146 |
-
msgstr "Inställningar"
|
147 |
-
|
148 |
-
#: ../admin/admin.php:258
|
149 |
-
msgid "Show all languages"
|
150 |
-
msgstr "Visa alla språk"
|
151 |
-
|
152 |
-
#: ../admin/admin.php:267
|
153 |
-
msgid "Filters content by language"
|
154 |
-
msgstr "Filtrerar innehåll efter språk"
|
155 |
-
|
156 |
-
#: ../admin/admin.php:367 ../admin/settings.php:180
|
157 |
-
msgid ""
|
158 |
-
"The language was created, but the WordPress language file was not "
|
159 |
-
"downloaded. Please install it manually."
|
160 |
-
msgstr ""
|
161 |
-
"Språket lades till, men språkfilen till WordPress laddades inte ner. Var god "
|
162 |
-
"och installera den manuellt."
|
163 |
-
|
164 |
-
#: ../admin/settings.php:52
|
165 |
-
msgid "Recommended plugins"
|
166 |
-
msgstr "Rekommenderade tillägg"
|
167 |
-
|
168 |
-
#: ../admin/settings.php:62
|
169 |
-
msgid "About Polylang"
|
170 |
-
msgstr "Om Polylang"
|
171 |
-
|
172 |
-
#: ../admin/settings.php:78
|
173 |
-
msgid "Strings translations"
|
174 |
-
msgstr "Textsträngöversättningar"
|
175 |
-
|
176 |
-
#: ../admin/settings.php:101
|
177 |
-
msgid "Strings translation"
|
178 |
-
msgstr "Textsträngöversättning"
|
179 |
-
|
180 |
-
# @ polylang
|
181 |
-
#: ../admin/settings.php:239
|
182 |
-
msgid "Translations updated."
|
183 |
-
msgstr "Översättning uppdaterad"
|
184 |
-
|
185 |
-
#: ../admin/settings.php:298
|
186 |
-
msgid "Settings saved."
|
187 |
-
msgstr "Inställningarna sparade."
|
188 |
-
|
189 |
-
# @ polylang
|
190 |
-
#: ../admin/settings.php:319
|
191 |
-
msgid "Taxonomies"
|
192 |
-
msgstr "Taxonomier"
|
193 |
-
|
194 |
-
# @ polylang
|
195 |
-
#: ../admin/settings.php:320
|
196 |
-
msgid "Custom fields"
|
197 |
-
msgstr "Egna fält"
|
198 |
-
|
199 |
-
# @ polylang
|
200 |
-
#: ../admin/settings.php:321
|
201 |
-
msgid "Comment status"
|
202 |
-
msgstr "Kommentarstatus"
|
203 |
-
|
204 |
-
# @ polylang
|
205 |
-
#: ../admin/settings.php:322
|
206 |
-
msgid "Ping status"
|
207 |
-
msgstr "Pingstatus"
|
208 |
-
|
209 |
-
# @ polylang
|
210 |
-
#: ../admin/settings.php:323
|
211 |
-
msgid "Sticky posts"
|
212 |
-
msgstr "Klistrade inlägg"
|
213 |
-
|
214 |
-
# @ polylang
|
215 |
-
#: ../admin/settings.php:324
|
216 |
-
msgid "Published date"
|
217 |
-
msgstr "Publiceringsdatum"
|
218 |
-
|
219 |
-
# @ polylang
|
220 |
-
#: ../admin/settings.php:325
|
221 |
-
msgid "Post format"
|
222 |
-
msgstr "Format"
|
223 |
-
|
224 |
-
#: ../admin/settings.php:326
|
225 |
-
msgid "Page parent"
|
226 |
-
msgstr "Sidförälder"
|
227 |
-
|
228 |
-
# @ polylang
|
229 |
-
#: ../admin/settings.php:327
|
230 |
-
msgid "Page template"
|
231 |
-
msgstr "Sidmall"
|
232 |
-
|
233 |
-
#: ../admin/settings.php:328
|
234 |
-
msgid "Page order"
|
235 |
-
msgstr "Sidordning"
|
236 |
-
|
237 |
-
# @ polylang
|
238 |
-
#: ../admin/settings.php:329
|
239 |
-
msgid "Featured image"
|
240 |
-
msgstr "Utvald bild"
|
241 |
-
|
242 |
-
# @ polylang
|
243 |
-
#: ../admin/table-languages.php:59
|
244 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
245 |
-
msgstr "Du håller på att ta bort detta språk permanent. Är du säker?"
|
246 |
-
|
247 |
-
#: ../admin/table-languages.php:60 ../admin/table-string.php:168
|
248 |
-
msgid "Delete"
|
249 |
-
msgstr "Ta bort"
|
250 |
-
|
251 |
-
#: ../admin/table-languages.php:74 ../admin/view-tab-lang.php:55
|
252 |
-
msgid "Full name"
|
253 |
-
msgstr "Fullständigt namn"
|
254 |
-
|
255 |
-
#: ../admin/table-languages.php:75 ../admin/view-tab-lang.php:61
|
256 |
-
msgid "Locale"
|
257 |
-
msgstr "Språkprefix"
|
258 |
-
|
259 |
-
#: ../admin/table-languages.php:76
|
260 |
-
msgid "Code"
|
261 |
-
msgstr "Språkkod"
|
262 |
-
|
263 |
-
#: ../admin/table-languages.php:77 ../admin/view-tab-lang.php:91
|
264 |
-
msgid "Order"
|
265 |
-
msgstr "Ordning"
|
266 |
-
|
267 |
-
#: ../admin/table-languages.php:78
|
268 |
-
msgid "Flag"
|
269 |
-
msgstr "Flagga"
|
270 |
-
|
271 |
-
#: ../admin/table-languages.php:79
|
272 |
-
msgid "Posts"
|
273 |
-
msgstr "Inlägg"
|
274 |
-
|
275 |
-
# @ polylang
|
276 |
-
#: ../admin/table-string.php:109
|
277 |
-
msgid "Group"
|
278 |
-
msgstr "Grupp"
|
279 |
-
|
280 |
-
#: ../admin/table-string.php:110
|
281 |
-
msgid "Name"
|
282 |
-
msgstr "Namn"
|
283 |
-
|
284 |
-
#: ../admin/table-string.php:111
|
285 |
-
msgid "String"
|
286 |
-
msgstr "Sträng"
|
287 |
-
|
288 |
-
#: ../admin/table-string.php:112 ../admin/view-translations-media.php:5
|
289 |
-
#: ../admin/view-translations-post.php:5 ../admin/view-translations-term.php:6
|
290 |
-
#: ../admin/view-translations-term.php:11
|
291 |
-
msgid "Translations"
|
292 |
-
msgstr "Översättningar"
|
293 |
-
|
294 |
-
# @ polylang
|
295 |
-
#: ../admin/table-string.php:187
|
296 |
-
msgid "View all groups"
|
297 |
-
msgstr "Visa alla grupper"
|
298 |
-
|
299 |
-
#: ../admin/table-string.php:200
|
300 |
-
msgid "Filter"
|
301 |
-
msgstr "Filter"
|
302 |
-
|
303 |
-
#: ../admin/view-about.php:3
|
304 |
-
#, php-format
|
305 |
-
msgid ""
|
306 |
-
"Polylang is provided with an extensive %sdocumentation%s (in English only). "
|
307 |
-
"It includes information on how to set up your multilingual site and use it "
|
308 |
-
"on a daily basis, a FAQ, as well as a documentation for programmers to adapt "
|
309 |
-
"their plugins and themes."
|
310 |
-
msgstr ""
|
311 |
-
"Polylang är försedd med en omfattande %sdokumentation%s (endast på "
|
312 |
-
"Engelska). Den innehåller information om hur du konfigurerar en flerspråkig "
|
313 |
-
"hemsida samt hur du dagligen kan använda dig av den, en FAQ. Dessutom finns "
|
314 |
-
"en dokumentation som visar hur programmerare kan anpassa sina tillägg och "
|
315 |
-
"teman till Polylang."
|
316 |
-
|
317 |
-
#: ../admin/view-about.php:9
|
318 |
-
#, php-format
|
319 |
-
msgid ""
|
320 |
-
"You will also find useful information in the %ssupport forum%s. However "
|
321 |
-
"don't forget to make a search before posting a new topic."
|
322 |
-
msgstr ""
|
323 |
-
"Du kan också hitta hjälpsam information vid %ssupportforumet%s. Glöm dock "
|
324 |
-
"inte att göra en sökning före du gör en ny tråd."
|
325 |
-
|
326 |
-
#: ../admin/view-about.php:16
|
327 |
-
#, php-format
|
328 |
-
msgid ""
|
329 |
-
"Polylang is free of charge and is released under the same license as "
|
330 |
-
"WordPress, the %sGPL%s."
|
331 |
-
msgstr ""
|
332 |
-
"Polylang är gratis och det är publicerat under samma licens som WordPress "
|
333 |
-
"%sGPL%s."
|
334 |
-
|
335 |
-
#: ../admin/view-about.php:22
|
336 |
-
#, php-format
|
337 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
338 |
-
msgstr ""
|
339 |
-
"Om du undrar på vilket sätt du kan hjälpa detta projekt, %släs detta%s."
|
340 |
-
|
341 |
-
#: ../admin/view-about.php:27
|
342 |
-
msgid ""
|
343 |
-
"Finally if you like this plugin or if it helps your business, donations to "
|
344 |
-
"the author are greatly appreciated."
|
345 |
-
msgstr ""
|
346 |
-
"Slutligen, ifall du tycker om detta tillägg, eller om det hjälper din "
|
347 |
-
"verksamhet, en donation till skaparen är mycket uppskattade."
|
348 |
-
|
349 |
-
#: ../admin/view-tab-lang.php:21
|
350 |
-
msgid "Edit language"
|
351 |
-
msgstr "Redigera språk"
|
352 |
-
|
353 |
-
#: ../admin/view-tab-lang.php:21 ../admin/view-tab-lang.php:96
|
354 |
-
msgid "Add new language"
|
355 |
-
msgstr "Lägg till nytt språk"
|
356 |
-
|
357 |
-
#: ../admin/view-tab-lang.php:37
|
358 |
-
msgid "Choose a language"
|
359 |
-
msgstr "Välj ett språk"
|
360 |
-
|
361 |
-
#: ../admin/view-tab-lang.php:51
|
362 |
-
msgid "You can choose a language in the list or directly edit it below."
|
363 |
-
msgstr ""
|
364 |
-
"Du kan välja ett fördefinierat språk från rullgardinsmenyn ovan, alternativt "
|
365 |
-
"själv fylla i alla fält nedanför."
|
366 |
-
|
367 |
-
#: ../admin/view-tab-lang.php:57
|
368 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
369 |
-
msgstr "Namnet är hur språket visas på din sida (t.ex. Engelska)"
|
370 |
-
|
371 |
-
#: ../admin/view-tab-lang.php:66
|
372 |
-
msgid ""
|
373 |
-
"WordPress Locale for the language (for example: en_US). You will need to "
|
374 |
-
"install the .mo file for this language."
|
375 |
-
msgstr ""
|
376 |
-
"WordPress språkprefix för språket (t.ex: en_US). Du kan komma att behöva "
|
377 |
-
"installera .mo filen för detta språk."
|
378 |
-
|
379 |
-
#: ../admin/view-tab-lang.php:70
|
380 |
-
msgid "Language code"
|
381 |
-
msgstr "Språkkod"
|
382 |
-
|
383 |
-
#: ../admin/view-tab-lang.php:72
|
384 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
385 |
-
msgstr "Språkkod - helst två bokstäver (ISO 639-1), exempelvis: sv"
|
386 |
-
|
387 |
-
#: ../admin/view-tab-lang.php:76
|
388 |
-
msgid "Text direction"
|
389 |
-
msgstr "Textriktning"
|
390 |
-
|
391 |
-
#: ../admin/view-tab-lang.php:80
|
392 |
-
msgid "left to right"
|
393 |
-
msgstr "från vänster till höger"
|
394 |
-
|
395 |
-
#: ../admin/view-tab-lang.php:85
|
396 |
-
msgid "right to left"
|
397 |
-
msgstr "från höger till vänster"
|
398 |
-
|
399 |
-
#: ../admin/view-tab-lang.php:87
|
400 |
-
msgid "Choose the text direction for the language"
|
401 |
-
msgstr "Välj textrikting för språket"
|
402 |
-
|
403 |
-
#: ../admin/view-tab-lang.php:93
|
404 |
-
msgid "Position of the language in the language switcher"
|
405 |
-
msgstr "Språkets position i språkväljaren"
|
406 |
-
|
407 |
-
#: ../admin/view-tab-lang.php:96
|
408 |
-
msgid "Update"
|
409 |
-
msgstr "Uppdatera"
|
410 |
-
|
411 |
-
#: ../admin/view-tab-settings.php:14
|
412 |
-
msgid "Default language"
|
413 |
-
msgstr "Standardspråk"
|
414 |
-
|
415 |
-
#: ../admin/view-tab-settings.php:29
|
416 |
-
msgid ""
|
417 |
-
"There are posts, pages, categories or tags without language set. Do you want "
|
418 |
-
"to set them all to default language ?"
|
419 |
-
msgstr ""
|
420 |
-
"Det finns artiklar, sidor, kategorier, eller taggar, utan ett valt språk. "
|
421 |
-
"Vill du ställa in dem till standardspråket?"
|
422 |
-
|
423 |
-
#: ../admin/view-tab-settings.php:37
|
424 |
-
msgid "URL modifications"
|
425 |
-
msgstr "URL-ändringar"
|
426 |
-
|
427 |
-
# @ polylang
|
428 |
-
#: ../admin/view-tab-settings.php:43
|
429 |
-
msgid "The language is set from content"
|
430 |
-
msgstr "Språket bestäms utav innehåll"
|
431 |
-
|
432 |
-
#: ../admin/view-tab-settings.php:46
|
433 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
434 |
-
msgstr "Posters, sidors, kategoriers och taggars permalänkar ändras inte."
|
435 |
-
|
436 |
-
#: ../admin/view-tab-settings.php:51
|
437 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
438 |
-
msgstr "Språket visas som katalog i permalänkstrukturen"
|
439 |
-
|
440 |
-
#: ../admin/view-tab-settings.php:51
|
441 |
-
msgid "The language is set from the code in the URL"
|
442 |
-
msgstr "Språket väljs från kod i URL:en"
|
443 |
-
|
444 |
-
#: ../admin/view-tab-settings.php:54 ../admin/view-tab-settings.php:63
|
445 |
-
#: ../admin/view-tab-settings.php:110 ../admin/view-tab-settings.php:119
|
446 |
-
msgid "Example:"
|
447 |
-
msgstr "Exempel:"
|
448 |
-
|
449 |
-
#: ../admin/view-tab-settings.php:60
|
450 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
451 |
-
msgstr "Språket visas som subdomän i permalänkstrukturen"
|
452 |
-
|
453 |
-
# @ polylang
|
454 |
-
#: ../admin/view-tab-settings.php:69
|
455 |
-
msgid "The language is set from different domains"
|
456 |
-
msgstr "Språket bestäms utifrån toppdomän/domännamn:"
|
457 |
-
|
458 |
-
#: ../admin/view-tab-settings.php:93
|
459 |
-
msgid "Hide URL language information for default language"
|
460 |
-
msgstr "Göm språket i permalänkar för standardspråket."
|
461 |
-
|
462 |
-
#: ../admin/view-tab-settings.php:107
|
463 |
-
msgid "Remove /language/ in pretty permalinks"
|
464 |
-
msgstr "Ta bort katalogen /language/ i permalänkstrukturen"
|
465 |
-
|
466 |
-
#: ../admin/view-tab-settings.php:116
|
467 |
-
msgid "Keep /language/ in pretty permalinks"
|
468 |
-
msgstr "Behåll katalogen /language/ i permalänkstrukturen. Exempel:"
|
469 |
-
|
470 |
-
#: ../admin/view-tab-settings.php:131
|
471 |
-
msgid ""
|
472 |
-
"The front page url contains the language code instead of the page name or "
|
473 |
-
"page id"
|
474 |
-
msgstr ""
|
475 |
-
"Startsidans permalänk visar språkkoden istället för sidans sidnamn eller ID"
|
476 |
-
|
477 |
-
#: ../admin/view-tab-settings.php:139
|
478 |
-
#, php-format
|
479 |
-
msgid "Example: %s instead of %s"
|
480 |
-
msgstr "Exempel: %s istället för %s"
|
481 |
-
|
482 |
-
#: ../admin/view-tab-settings.php:149
|
483 |
-
msgid "Detect browser language"
|
484 |
-
msgstr "Upptäck webbläsarens språkinställning"
|
485 |
-
|
486 |
-
#: ../admin/view-tab-settings.php:155
|
487 |
-
msgid ""
|
488 |
-
"When the front page is visited, set the language according to the browser "
|
489 |
-
"preference"
|
490 |
-
msgstr ""
|
491 |
-
"När förstasidan besöks, välj språk enligt webbläsarens språkinställning"
|
492 |
-
|
493 |
-
# @ polylang
|
494 |
-
#: ../admin/view-tab-settings.php:162
|
495 |
-
msgid "Media"
|
496 |
-
msgstr "Media"
|
497 |
-
|
498 |
-
# @ polylang
|
499 |
-
#: ../admin/view-tab-settings.php:168
|
500 |
-
msgid "Activate languages and translations for media"
|
501 |
-
msgstr "Aktivera språk och översättningar för media."
|
502 |
-
|
503 |
-
# @ polylang
|
504 |
-
#: ../admin/view-tab-settings.php:176
|
505 |
-
msgid "Custom post types"
|
506 |
-
msgstr "Posttyper"
|
507 |
-
|
508 |
-
# @ polylang
|
509 |
-
#: ../admin/view-tab-settings.php:189
|
510 |
-
msgid "Activate languages and translations for custom post types."
|
511 |
-
msgstr "Aktivera språk och översättningar för posttyper (custom post types)."
|
512 |
-
|
513 |
-
# @ polylang
|
514 |
-
#: ../admin/view-tab-settings.php:196
|
515 |
-
msgid "Custom taxonomies"
|
516 |
-
msgstr "Taxonomier"
|
517 |
-
|
518 |
-
# @ polylang
|
519 |
-
#: ../admin/view-tab-settings.php:209
|
520 |
-
msgid "Activate languages and translations for custom taxonomies."
|
521 |
-
msgstr "Aktivera språk och översättningar för taxonomier."
|
522 |
-
|
523 |
-
#: ../admin/view-tab-settings.php:215
|
524 |
-
msgid "Synchronization"
|
525 |
-
msgstr "Synkronisering"
|
526 |
-
|
527 |
-
# @ polylang
|
528 |
-
#: ../admin/view-tab-settings.php:226
|
529 |
-
msgid ""
|
530 |
-
"The synchronization options allow to maintain exact same values (or "
|
531 |
-
"translations in the case of taxonomies and page parent) of meta content "
|
532 |
-
"between the translations of a post or page."
|
533 |
-
msgstr ""
|
534 |
-
"Välj om översättning av objekt (post eller sida) ska använda samma värden "
|
535 |
-
"för metainnehåll, taxonomier, postföräldrar med mera, som objektet i "
|
536 |
-
"standardspråket har."
|
537 |
-
|
538 |
-
#: ../admin/view-tab-strings.php:8
|
539 |
-
msgid "Search translations"
|
540 |
-
msgstr "Sök översättningar"
|
541 |
-
|
542 |
-
#: ../admin/view-tab-strings.php:11
|
543 |
-
msgid "Clean strings translation database"
|
544 |
-
msgstr "Töm strängöversättningar i databasen"
|
545 |
-
|
546 |
-
# @ polylang
|
547 |
-
#: ../admin/view-tab-strings.php:12
|
548 |
-
msgid ""
|
549 |
-
"Use this to remove unused strings from database, for example after a plugin "
|
550 |
-
"has been uninstalled."
|
551 |
-
msgstr ""
|
552 |
-
"Använd denna för att ta bort oanvända textsträngar från databasen, t.ex. "
|
553 |
-
"efter att ett tillägg har avinstallerats."
|
554 |
-
|
555 |
-
#: ../admin/view-translations-media.php:30
|
556 |
-
#: ../admin/view-translations-post.php:21
|
557 |
-
#: ../admin/view-translations-term.php:30
|
558 |
-
msgid "Add new"
|
559 |
-
msgstr "Lägg till"
|
560 |
-
|
561 |
-
#: ../frontend/frontend-filters-search.php:80
|
562 |
-
msgid "Search"
|
563 |
-
msgstr "Sök"
|
564 |
-
|
565 |
-
#: ../include/model.php:723
|
566 |
-
msgid "Uncategorized"
|
567 |
-
msgstr "Okategoriserad"
|
568 |
-
|
569 |
-
#: ../include/plugins-compat.php:67
|
570 |
-
msgid ""
|
571 |
-
"Import <strong>posts, pages, comments, custom fields, categories, and tags</"
|
572 |
-
"strong> from a WordPress export file."
|
573 |
-
msgstr ""
|
574 |
-
"Importera <strong>inlägg, sidor, kommentarer, egna metafält, kategorier och "
|
575 |
-
"etiketter</strong> från en WordPress-exportfil."
|
576 |
-
|
577 |
-
#: ../include/switcher.php:22
|
578 |
-
msgid "Displays language names"
|
579 |
-
msgstr "Visa språknamn"
|
580 |
-
|
581 |
-
#: ../include/switcher.php:23
|
582 |
-
msgid "Displays flags"
|
583 |
-
msgstr "Visa flaggor"
|
584 |
-
|
585 |
-
#: ../include/switcher.php:24
|
586 |
-
msgid "Forces link to front page"
|
587 |
-
msgstr "Tvingar länk till framsidan"
|
588 |
-
|
589 |
-
#: ../include/switcher.php:25
|
590 |
-
msgid "Hides the current language"
|
591 |
-
msgstr "Gömmer aktuellt språk"
|
592 |
-
|
593 |
-
#: ../include/switcher.php:26
|
594 |
-
msgid "Hides languages with no translation"
|
595 |
-
msgstr "Gömmer språk utan översättning"
|
596 |
-
|
597 |
-
#: ../include/switcher.php:30
|
598 |
-
msgid "Displays as dropdown"
|
599 |
-
msgstr "Visa som rullgardinsmeny"
|
600 |
-
|
601 |
-
#. translators: Calendar caption: 1: month name, 2: 4-digit year
|
602 |
-
#: ../include/widget-calendar.php:125
|
603 |
-
#, php-format
|
604 |
-
msgid "%1$s %2$s"
|
605 |
-
msgstr "%1$s %2$s"
|
606 |
-
|
607 |
-
#: ../include/widget-calendar.php:151 ../include/widget-calendar.php:159
|
608 |
-
#, php-format
|
609 |
-
msgid "View posts for %1$s %2$s"
|
610 |
-
msgstr "Visar poster för %1$s %2$s"
|
611 |
-
|
612 |
-
#: ../include/widget-languages.php:16
|
613 |
-
msgid "Language Switcher"
|
614 |
-
msgstr "Språkväljaren"
|
615 |
-
|
616 |
-
#: ../include/widget-languages.php:16
|
617 |
-
msgid "Displays a language switcher"
|
618 |
-
msgstr "Visar en språkväljare"
|
619 |
-
|
620 |
-
#: ../include/widget-languages.php:75
|
621 |
-
msgid "Title:"
|
622 |
-
msgstr "Rubrik:"
|
623 |
-
|
624 |
-
#: ../include/widget-recent-comments.php:46
|
625 |
-
msgid "Recent Comments"
|
626 |
-
msgstr "Tidigare kommentarer"
|
627 |
-
|
628 |
-
#. translators: comments widget: 1: comment author, 2: post link
|
629 |
-
#: ../include/widget-recent-comments.php:82
|
630 |
-
#, php-format
|
631 |
-
msgid "%1$s on %2$s"
|
632 |
-
msgstr "%1$s den %2$s"
|
633 |
-
|
634 |
-
#: ../include/widget-recent-posts.php:46
|
635 |
-
msgid "Recent Posts"
|
636 |
-
msgstr "Tidigare poster"
|
637 |
-
|
638 |
-
#: ../install/install.php:24
|
639 |
-
#, php-format
|
640 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
641 |
-
msgstr "Du använder WordPress %s. Polylang kräver åtminstone WordPress %s."
|
642 |
-
|
643 |
-
# @ polylang
|
644 |
-
#: ../install/upgrade.php:76
|
645 |
-
msgid ""
|
646 |
-
"Polylang has been deactivated because you upgraded from a too old version."
|
647 |
-
msgstr ""
|
648 |
-
"Polylang har blivit inaktiverat p.g.a. att du uppgraderade från en för "
|
649 |
-
"gammal version."
|
650 |
-
|
651 |
-
# @ polylang
|
652 |
-
#: ../install/upgrade.php:78
|
653 |
-
#, php-format
|
654 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
655 |
-
msgstr "Uppdatera först till %s före du uppdaterar till %s."
|
656 |
-
|
657 |
-
#~ msgid "A translation does already exist for %s"
|
658 |
-
#~ msgstr "En översättning finns redan för %s"
|
659 |
-
|
660 |
-
#~ msgid "2-letters ISO 639-1 language code (for example: en)"
|
661 |
-
#~ msgstr "Språkkod [ISO 639-1] består av två boktäver (exempel: en)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/polylang.pot
DELETED
@@ -1,640 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: Polylang v1.7beta1\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: \n"
|
6 |
-
"PO-Revision-Date: 2015-02-14 07:58:51+0000\n"
|
7 |
-
"Last-Translator: \n"
|
8 |
-
"Language-Team: \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-Language: \n"
|
14 |
-
"X-Poedit-Country: \n"
|
15 |
-
"X-Poedit-SourceCharset: utf-8\n"
|
16 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_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"
|
17 |
-
"X-Poedit-Basepath: ../\n"
|
18 |
-
"X-Poedit-Bookmarks: \n"
|
19 |
-
"X-Poedit-SearchPath-0: .\n"
|
20 |
-
"X-Textdomain-Support: yes"
|
21 |
-
|
22 |
-
#: admin/view-about.php:3
|
23 |
-
#, php-format
|
24 |
-
#@ polylang
|
25 |
-
msgid "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 programmers to adapt their plugins and themes."
|
26 |
-
msgstr ""
|
27 |
-
|
28 |
-
#: admin/view-about.php:9
|
29 |
-
#, php-format
|
30 |
-
#@ polylang
|
31 |
-
msgid "You will also find useful information in the %ssupport forum%s. However don't forget to make a search before posting a new topic."
|
32 |
-
msgstr ""
|
33 |
-
|
34 |
-
#: admin/view-about.php:16
|
35 |
-
#, php-format
|
36 |
-
#@ polylang
|
37 |
-
msgid "Polylang is free of charge and is released under the same license as WordPress, the %sGPL%s."
|
38 |
-
msgstr ""
|
39 |
-
|
40 |
-
#: admin/view-about.php:22
|
41 |
-
#, php-format
|
42 |
-
#@ polylang
|
43 |
-
msgid "If you wonder how you can help the project, just %sread this%s."
|
44 |
-
msgstr ""
|
45 |
-
|
46 |
-
#: admin/view-about.php:27
|
47 |
-
#@ polylang
|
48 |
-
msgid "Finally if you like this plugin or if it helps your business, donations to the author are greatly appreciated."
|
49 |
-
msgstr ""
|
50 |
-
|
51 |
-
#: admin/admin-filters-post.php:115
|
52 |
-
#: admin/admin.php:90
|
53 |
-
#: admin/settings.php:70
|
54 |
-
#: admin/settings.php:97
|
55 |
-
#: include/model.php:561
|
56 |
-
#@ polylang
|
57 |
-
msgid "Languages"
|
58 |
-
msgstr ""
|
59 |
-
|
60 |
-
#: include/switcher.php:22
|
61 |
-
#@ polylang
|
62 |
-
msgid "Displays language names"
|
63 |
-
msgstr ""
|
64 |
-
|
65 |
-
#: include/switcher.php:23
|
66 |
-
#@ polylang
|
67 |
-
msgid "Displays flags"
|
68 |
-
msgstr ""
|
69 |
-
|
70 |
-
#: include/switcher.php:24
|
71 |
-
#@ polylang
|
72 |
-
msgid "Forces link to front page"
|
73 |
-
msgstr ""
|
74 |
-
|
75 |
-
#: include/switcher.php:25
|
76 |
-
#@ polylang
|
77 |
-
msgid "Hides the current language"
|
78 |
-
msgstr ""
|
79 |
-
|
80 |
-
#: include/switcher.php:30
|
81 |
-
#@ polylang
|
82 |
-
msgid "Displays as dropdown"
|
83 |
-
msgstr ""
|
84 |
-
|
85 |
-
#: admin/admin.php:267
|
86 |
-
#@ polylang
|
87 |
-
msgid "Filters content by language"
|
88 |
-
msgstr ""
|
89 |
-
|
90 |
-
#: admin/admin.php:258
|
91 |
-
#@ polylang
|
92 |
-
msgid "Show all languages"
|
93 |
-
msgstr ""
|
94 |
-
|
95 |
-
#: admin/admin-filters-columns.php:140
|
96 |
-
#: admin/admin-filters-columns.php:230
|
97 |
-
#@ polylang
|
98 |
-
msgid "Add new translation"
|
99 |
-
msgstr ""
|
100 |
-
|
101 |
-
#: admin/admin-filters-columns.php:173
|
102 |
-
#: admin/admin-filters-media.php:55
|
103 |
-
#: admin/admin-filters-post.php:141
|
104 |
-
#: admin/admin-filters-term.php:75
|
105 |
-
#: admin/admin-filters-term.php:122
|
106 |
-
#: include/model.php:562
|
107 |
-
#@ polylang
|
108 |
-
msgid "Language"
|
109 |
-
msgstr ""
|
110 |
-
|
111 |
-
#: admin/table-string.php:112
|
112 |
-
#: admin/view-translations-media.php:5
|
113 |
-
#: admin/view-translations-post.php:5
|
114 |
-
#: admin/view-translations-term.php:6
|
115 |
-
#: admin/view-translations-term.php:11
|
116 |
-
#@ polylang
|
117 |
-
msgid "Translations"
|
118 |
-
msgstr ""
|
119 |
-
|
120 |
-
#: admin/admin-filters-term.php:82
|
121 |
-
#: admin/admin-filters-term.php:130
|
122 |
-
#@ polylang
|
123 |
-
msgid "Sets the language"
|
124 |
-
msgstr ""
|
125 |
-
|
126 |
-
#: admin/admin-filters.php:52
|
127 |
-
#@ polylang
|
128 |
-
msgid "The widget is displayed for:"
|
129 |
-
msgstr ""
|
130 |
-
|
131 |
-
#: admin/admin-filters.php:55
|
132 |
-
#: include/model.php:563
|
133 |
-
#@ polylang
|
134 |
-
msgid "All languages"
|
135 |
-
msgstr ""
|
136 |
-
|
137 |
-
#: admin/admin-filters.php:123
|
138 |
-
#@ polylang
|
139 |
-
msgid "Admin language"
|
140 |
-
msgstr ""
|
141 |
-
|
142 |
-
#: admin/admin-filters.php:126
|
143 |
-
#@ polylang
|
144 |
-
msgid "WordPress default"
|
145 |
-
msgstr ""
|
146 |
-
|
147 |
-
#: admin/admin.php:167
|
148 |
-
#: admin/settings.php:102
|
149 |
-
#@ polylang
|
150 |
-
msgid "Settings"
|
151 |
-
msgstr ""
|
152 |
-
|
153 |
-
#: admin/admin-filters.php:160
|
154 |
-
#: admin/admin-filters.php:169
|
155 |
-
#@ polylang
|
156 |
-
msgid "Upgrading language files…"
|
157 |
-
msgstr ""
|
158 |
-
|
159 |
-
#: admin/settings.php:62
|
160 |
-
#@ polylang
|
161 |
-
msgid "About Polylang"
|
162 |
-
msgstr ""
|
163 |
-
|
164 |
-
#: admin/settings.php:78
|
165 |
-
#@ polylang
|
166 |
-
msgid "Strings translations"
|
167 |
-
msgstr ""
|
168 |
-
|
169 |
-
#: admin/settings.php:101
|
170 |
-
#@ polylang
|
171 |
-
msgid "Strings translation"
|
172 |
-
msgstr ""
|
173 |
-
|
174 |
-
#: admin/admin-model.php:244
|
175 |
-
#@ polylang
|
176 |
-
msgid "Enter a valid WordPress locale"
|
177 |
-
msgstr ""
|
178 |
-
|
179 |
-
#: admin/admin-model.php:252
|
180 |
-
#@ polylang
|
181 |
-
msgid "The language code must be unique"
|
182 |
-
msgstr ""
|
183 |
-
|
184 |
-
#: admin/admin-model.php:256
|
185 |
-
#@ polylang
|
186 |
-
msgid "The language must have a name"
|
187 |
-
msgstr ""
|
188 |
-
|
189 |
-
#: admin/admin.php:367
|
190 |
-
#: admin/settings.php:180
|
191 |
-
#@ polylang
|
192 |
-
msgid "The language was created, but the WordPress language file was not downloaded. Please install it manually."
|
193 |
-
msgstr ""
|
194 |
-
|
195 |
-
#: admin/admin-strings.php:59
|
196 |
-
#@ polylang
|
197 |
-
msgid "Widget title"
|
198 |
-
msgstr ""
|
199 |
-
|
200 |
-
#: admin/settings.php:319
|
201 |
-
#@ polylang
|
202 |
-
msgid "Taxonomies"
|
203 |
-
msgstr ""
|
204 |
-
|
205 |
-
#: admin/settings.php:320
|
206 |
-
#@ polylang
|
207 |
-
msgid "Custom fields"
|
208 |
-
msgstr ""
|
209 |
-
|
210 |
-
#: admin/settings.php:321
|
211 |
-
#@ polylang
|
212 |
-
msgid "Comment status"
|
213 |
-
msgstr ""
|
214 |
-
|
215 |
-
#: admin/settings.php:322
|
216 |
-
#@ polylang
|
217 |
-
msgid "Ping status"
|
218 |
-
msgstr ""
|
219 |
-
|
220 |
-
#: admin/settings.php:323
|
221 |
-
#@ polylang
|
222 |
-
msgid "Sticky posts"
|
223 |
-
msgstr ""
|
224 |
-
|
225 |
-
#: admin/settings.php:324
|
226 |
-
#@ polylang
|
227 |
-
msgid "Published date"
|
228 |
-
msgstr ""
|
229 |
-
|
230 |
-
#: admin/settings.php:325
|
231 |
-
#@ polylang
|
232 |
-
msgid "Post format"
|
233 |
-
msgstr ""
|
234 |
-
|
235 |
-
#: admin/settings.php:326
|
236 |
-
#@ polylang
|
237 |
-
msgid "Page parent"
|
238 |
-
msgstr ""
|
239 |
-
|
240 |
-
#: admin/settings.php:327
|
241 |
-
#@ polylang
|
242 |
-
msgid "Page template"
|
243 |
-
msgstr ""
|
244 |
-
|
245 |
-
#: admin/settings.php:328
|
246 |
-
#@ polylang
|
247 |
-
msgid "Page order"
|
248 |
-
msgstr ""
|
249 |
-
|
250 |
-
#: admin/settings.php:329
|
251 |
-
#@ polylang
|
252 |
-
msgid "Featured image"
|
253 |
-
msgstr ""
|
254 |
-
|
255 |
-
#: admin/view-tab-lang.php:21
|
256 |
-
#@ polylang
|
257 |
-
msgid "Edit language"
|
258 |
-
msgstr ""
|
259 |
-
|
260 |
-
#: admin/view-tab-lang.php:21
|
261 |
-
#: admin/view-tab-lang.php:96
|
262 |
-
#@ polylang
|
263 |
-
msgid "Add new language"
|
264 |
-
msgstr ""
|
265 |
-
|
266 |
-
#: admin/view-tab-lang.php:37
|
267 |
-
#@ polylang
|
268 |
-
msgid "Choose a language"
|
269 |
-
msgstr ""
|
270 |
-
|
271 |
-
#: admin/view-tab-lang.php:51
|
272 |
-
#@ polylang
|
273 |
-
msgid "You can choose a language in the list or directly edit it below."
|
274 |
-
msgstr ""
|
275 |
-
|
276 |
-
#: admin/table-languages.php:74
|
277 |
-
#: admin/view-tab-lang.php:55
|
278 |
-
#@ polylang
|
279 |
-
msgid "Full name"
|
280 |
-
msgstr ""
|
281 |
-
|
282 |
-
#: admin/view-tab-lang.php:57
|
283 |
-
#@ polylang
|
284 |
-
msgid "The name is how it is displayed on your site (for example: English)."
|
285 |
-
msgstr ""
|
286 |
-
|
287 |
-
#: admin/table-languages.php:75
|
288 |
-
#: admin/view-tab-lang.php:61
|
289 |
-
#@ polylang
|
290 |
-
msgid "Locale"
|
291 |
-
msgstr ""
|
292 |
-
|
293 |
-
#: admin/view-tab-lang.php:66
|
294 |
-
#@ polylang
|
295 |
-
msgid "WordPress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
|
296 |
-
msgstr ""
|
297 |
-
|
298 |
-
#: admin/view-tab-lang.php:70
|
299 |
-
#@ polylang
|
300 |
-
msgid "Language code"
|
301 |
-
msgstr ""
|
302 |
-
|
303 |
-
#: admin/view-tab-lang.php:76
|
304 |
-
#@ polylang
|
305 |
-
msgid "Text direction"
|
306 |
-
msgstr ""
|
307 |
-
|
308 |
-
#: admin/view-tab-lang.php:80
|
309 |
-
#@ polylang
|
310 |
-
msgid "left to right"
|
311 |
-
msgstr ""
|
312 |
-
|
313 |
-
#: admin/view-tab-lang.php:85
|
314 |
-
#@ polylang
|
315 |
-
msgid "right to left"
|
316 |
-
msgstr ""
|
317 |
-
|
318 |
-
#: admin/view-tab-lang.php:87
|
319 |
-
#@ polylang
|
320 |
-
msgid "Choose the text direction for the language"
|
321 |
-
msgstr ""
|
322 |
-
|
323 |
-
#: admin/table-languages.php:77
|
324 |
-
#: admin/view-tab-lang.php:91
|
325 |
-
#@ polylang
|
326 |
-
msgid "Order"
|
327 |
-
msgstr ""
|
328 |
-
|
329 |
-
#: admin/view-tab-lang.php:93
|
330 |
-
#@ polylang
|
331 |
-
msgid "Position of the language in the language switcher"
|
332 |
-
msgstr ""
|
333 |
-
|
334 |
-
#: admin/admin-nav-menu.php:54
|
335 |
-
#: admin/admin-nav-menu.php:92
|
336 |
-
#: admin/admin-nav-menu.php:95
|
337 |
-
#: admin/admin-nav-menu.php:126
|
338 |
-
#: admin/admin-nav-menu.php:188
|
339 |
-
#: install/upgrade.php:301
|
340 |
-
#@ polylang
|
341 |
-
msgid "Language switcher"
|
342 |
-
msgstr ""
|
343 |
-
|
344 |
-
#: admin/view-tab-strings.php:8
|
345 |
-
#@ polylang
|
346 |
-
msgid "Search translations"
|
347 |
-
msgstr ""
|
348 |
-
|
349 |
-
#: admin/view-tab-strings.php:11
|
350 |
-
#@ polylang
|
351 |
-
msgid "Clean strings translation database"
|
352 |
-
msgstr ""
|
353 |
-
|
354 |
-
#: admin/view-tab-settings.php:14
|
355 |
-
#@ polylang
|
356 |
-
msgid "Default language"
|
357 |
-
msgstr ""
|
358 |
-
|
359 |
-
#: admin/view-tab-settings.php:29
|
360 |
-
#@ polylang
|
361 |
-
msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
|
362 |
-
msgstr ""
|
363 |
-
|
364 |
-
#: admin/view-tab-settings.php:149
|
365 |
-
#@ polylang
|
366 |
-
msgid "Detect browser language"
|
367 |
-
msgstr ""
|
368 |
-
|
369 |
-
#: admin/view-tab-settings.php:155
|
370 |
-
#@ polylang
|
371 |
-
msgid "When the front page is visited, set the language according to the browser preference"
|
372 |
-
msgstr ""
|
373 |
-
|
374 |
-
#: admin/view-tab-settings.php:37
|
375 |
-
#@ polylang
|
376 |
-
msgid "URL modifications"
|
377 |
-
msgstr ""
|
378 |
-
|
379 |
-
#: admin/view-tab-settings.php:93
|
380 |
-
#@ polylang
|
381 |
-
msgid "Hide URL language information for default language"
|
382 |
-
msgstr ""
|
383 |
-
|
384 |
-
#: admin/view-tab-settings.php:162
|
385 |
-
#@ polylang
|
386 |
-
msgid "Media"
|
387 |
-
msgstr ""
|
388 |
-
|
389 |
-
#: admin/view-tab-settings.php:168
|
390 |
-
#@ polylang
|
391 |
-
msgid "Activate languages and translations for media"
|
392 |
-
msgstr ""
|
393 |
-
|
394 |
-
#: admin/view-tab-settings.php:215
|
395 |
-
#@ polylang
|
396 |
-
msgid "Synchronization"
|
397 |
-
msgstr ""
|
398 |
-
|
399 |
-
#: admin/view-tab-settings.php:176
|
400 |
-
#@ polylang
|
401 |
-
msgid "Custom post types"
|
402 |
-
msgstr ""
|
403 |
-
|
404 |
-
#: admin/view-tab-settings.php:189
|
405 |
-
#@ polylang
|
406 |
-
msgid "Activate languages and translations for custom post types."
|
407 |
-
msgstr ""
|
408 |
-
|
409 |
-
#: admin/view-tab-settings.php:196
|
410 |
-
#@ polylang
|
411 |
-
msgid "Custom taxonomies"
|
412 |
-
msgstr ""
|
413 |
-
|
414 |
-
#: admin/view-tab-settings.php:209
|
415 |
-
#@ polylang
|
416 |
-
msgid "Activate languages and translations for custom taxonomies."
|
417 |
-
msgstr ""
|
418 |
-
|
419 |
-
#: admin/admin-filters-post.php:433
|
420 |
-
#: admin/admin-filters-term.php:642
|
421 |
-
#: admin/table-languages.php:54
|
422 |
-
#: admin/view-translations-media.php:21
|
423 |
-
#@ polylang
|
424 |
-
msgid "Edit"
|
425 |
-
msgstr ""
|
426 |
-
|
427 |
-
#: admin/table-languages.php:60
|
428 |
-
#: admin/table-string.php:168
|
429 |
-
#@ polylang
|
430 |
-
msgid "Delete"
|
431 |
-
msgstr ""
|
432 |
-
|
433 |
-
#: admin/table-languages.php:76
|
434 |
-
#@ polylang
|
435 |
-
msgid "Code"
|
436 |
-
msgstr ""
|
437 |
-
|
438 |
-
#: admin/table-languages.php:78
|
439 |
-
#@ polylang
|
440 |
-
msgid "Flag"
|
441 |
-
msgstr ""
|
442 |
-
|
443 |
-
#: admin/table-languages.php:79
|
444 |
-
#@ polylang
|
445 |
-
msgid "Posts"
|
446 |
-
msgstr ""
|
447 |
-
|
448 |
-
#: admin/table-string.php:110
|
449 |
-
#@ polylang
|
450 |
-
msgid "Name"
|
451 |
-
msgstr ""
|
452 |
-
|
453 |
-
#: admin/table-string.php:111
|
454 |
-
#@ polylang
|
455 |
-
msgid "String"
|
456 |
-
msgstr ""
|
457 |
-
|
458 |
-
#: admin/view-translations-media.php:30
|
459 |
-
#: admin/view-translations-post.php:21
|
460 |
-
#: admin/view-translations-term.php:30
|
461 |
-
#@ polylang
|
462 |
-
msgid "Add new"
|
463 |
-
msgstr ""
|
464 |
-
|
465 |
-
#: include/widget-languages.php:16
|
466 |
-
#@ polylang
|
467 |
-
msgid "Language Switcher"
|
468 |
-
msgstr ""
|
469 |
-
|
470 |
-
#: include/widget-languages.php:16
|
471 |
-
#@ polylang
|
472 |
-
msgid "Displays a language switcher"
|
473 |
-
msgstr ""
|
474 |
-
|
475 |
-
#: include/widget-languages.php:75
|
476 |
-
#@ polylang
|
477 |
-
msgid "Title:"
|
478 |
-
msgstr ""
|
479 |
-
|
480 |
-
#. translators: plugin header field 'Description'
|
481 |
-
#: polylang.php:0
|
482 |
-
#@ polylang
|
483 |
-
msgid "Adds multilingual capability to WordPress"
|
484 |
-
msgstr ""
|
485 |
-
|
486 |
-
#: install/install.php:24
|
487 |
-
#, php-format
|
488 |
-
#@ polylang
|
489 |
-
msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
|
490 |
-
msgstr ""
|
491 |
-
|
492 |
-
#: install/upgrade.php:76
|
493 |
-
#@ polylang
|
494 |
-
msgid "Polylang has been deactivated because you upgraded from a too old version."
|
495 |
-
msgstr ""
|
496 |
-
|
497 |
-
#: install/upgrade.php:78
|
498 |
-
#, php-format
|
499 |
-
#@ polylang
|
500 |
-
msgid "Please upgrade first to %s before ugrading to %s."
|
501 |
-
msgstr ""
|
502 |
-
|
503 |
-
#: admin/table-string.php:109
|
504 |
-
#@ polylang
|
505 |
-
msgid "Group"
|
506 |
-
msgstr ""
|
507 |
-
|
508 |
-
#: admin/table-string.php:187
|
509 |
-
#@ polylang
|
510 |
-
msgid "View all groups"
|
511 |
-
msgstr ""
|
512 |
-
|
513 |
-
#: admin/table-languages.php:59
|
514 |
-
#@ polylang
|
515 |
-
msgid "You are about to permanently delete this language. Are you sure?"
|
516 |
-
msgstr ""
|
517 |
-
|
518 |
-
#: admin/view-tab-strings.php:12
|
519 |
-
#@ polylang
|
520 |
-
msgid "Use this to remove unused strings from database, for example after a plugin has been uninstalled."
|
521 |
-
msgstr ""
|
522 |
-
|
523 |
-
#: admin/view-tab-settings.php:226
|
524 |
-
#@ polylang
|
525 |
-
msgid "The synchronization options allow to maintain exact same values (or translations in the case of taxonomies and page parent) of meta content between the translations of a post or page."
|
526 |
-
msgstr ""
|
527 |
-
|
528 |
-
#: admin/admin-model.php:248
|
529 |
-
#@ polylang
|
530 |
-
msgid "The language code contains invalid characters"
|
531 |
-
msgstr ""
|
532 |
-
|
533 |
-
#: admin/view-tab-settings.php:43
|
534 |
-
#@ polylang
|
535 |
-
msgid "The language is set from content"
|
536 |
-
msgstr ""
|
537 |
-
|
538 |
-
#: admin/view-tab-settings.php:46
|
539 |
-
#@ polylang
|
540 |
-
msgid "Posts, pages, categories and tags urls are not modified."
|
541 |
-
msgstr ""
|
542 |
-
|
543 |
-
#: admin/view-tab-settings.php:51
|
544 |
-
#@ polylang
|
545 |
-
msgid "The language is set from the directory name in pretty permalinks"
|
546 |
-
msgstr ""
|
547 |
-
|
548 |
-
#: admin/view-tab-settings.php:54
|
549 |
-
#: admin/view-tab-settings.php:63
|
550 |
-
#: admin/view-tab-settings.php:110
|
551 |
-
#: admin/view-tab-settings.php:119
|
552 |
-
#@ polylang
|
553 |
-
msgid "Example:"
|
554 |
-
msgstr ""
|
555 |
-
|
556 |
-
#: admin/view-tab-settings.php:60
|
557 |
-
#@ polylang
|
558 |
-
msgid "The language is set from the subdomain name in pretty permalinks"
|
559 |
-
msgstr ""
|
560 |
-
|
561 |
-
#: admin/view-tab-settings.php:69
|
562 |
-
#@ polylang
|
563 |
-
msgid "The language is set from different domains"
|
564 |
-
msgstr ""
|
565 |
-
|
566 |
-
#: admin/view-tab-settings.php:107
|
567 |
-
#@ polylang
|
568 |
-
msgid "Remove /language/ in pretty permalinks"
|
569 |
-
msgstr ""
|
570 |
-
|
571 |
-
#: admin/view-tab-settings.php:116
|
572 |
-
#@ polylang
|
573 |
-
msgid "Keep /language/ in pretty permalinks"
|
574 |
-
msgstr ""
|
575 |
-
|
576 |
-
#: admin/view-tab-settings.php:131
|
577 |
-
#@ polylang
|
578 |
-
msgid "The front page url contains the language code instead of the page name or page id"
|
579 |
-
msgstr ""
|
580 |
-
|
581 |
-
#: admin/view-tab-settings.php:139
|
582 |
-
#, php-format
|
583 |
-
#@ polylang
|
584 |
-
msgid "Example: %s instead of %s"
|
585 |
-
msgstr ""
|
586 |
-
|
587 |
-
#: admin/admin-model.php:38
|
588 |
-
#@ polylang
|
589 |
-
msgid "Impossible to add the language."
|
590 |
-
msgstr ""
|
591 |
-
|
592 |
-
#: admin/admin-model.php:66
|
593 |
-
#@ polylang
|
594 |
-
msgid "Language added."
|
595 |
-
msgstr ""
|
596 |
-
|
597 |
-
#: admin/admin-model.php:146
|
598 |
-
#@ polylang
|
599 |
-
msgid "Language deleted."
|
600 |
-
msgstr ""
|
601 |
-
|
602 |
-
#: admin/admin-model.php:227
|
603 |
-
#@ polylang
|
604 |
-
msgid "Language updated."
|
605 |
-
msgstr ""
|
606 |
-
|
607 |
-
#: admin/settings.php:239
|
608 |
-
#@ polylang
|
609 |
-
msgid "Translations updated."
|
610 |
-
msgstr ""
|
611 |
-
|
612 |
-
#: admin/view-tab-lang.php:72
|
613 |
-
#@ polylang
|
614 |
-
msgid "Language code - preferably 2-letters ISO 639-1 (for example: en)"
|
615 |
-
msgstr ""
|
616 |
-
|
617 |
-
#: admin/admin-filters.php:203
|
618 |
-
#@ polylang
|
619 |
-
msgid "The chosen static front page must be translated in all languages."
|
620 |
-
msgstr ""
|
621 |
-
|
622 |
-
#: admin/admin-strings.php:60
|
623 |
-
#@ polylang
|
624 |
-
msgid "Widget text"
|
625 |
-
msgstr ""
|
626 |
-
|
627 |
-
#: admin/settings.php:52
|
628 |
-
#@ polylang
|
629 |
-
msgid "Recommended plugins"
|
630 |
-
msgstr ""
|
631 |
-
|
632 |
-
#: admin/view-tab-settings.php:51
|
633 |
-
#@ polylang
|
634 |
-
msgid "The language is set from the code in the URL"
|
635 |
-
msgstr ""
|
636 |
-
|
637 |
-
#: include/switcher.php:26
|
638 |
-
#@ polylang
|
639 |
-
msgid "Hides languages with no translation"
|
640 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lingotek/lingotek.php
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
3 |
/*
|
4 |
* class to manage Lingotek ads
|
5 |
*
|
@@ -13,50 +17,52 @@ class PLL_Lingotek {
|
|
13 |
* @since 1.7.7
|
14 |
*/
|
15 |
public function __construct() {
|
16 |
-
$options = get_option('polylang');
|
17 |
|
18 |
// the Lingotek tab
|
19 |
-
add_filter('pll_settings_tabs', array(&$this, 'add_tab'));
|
20 |
-
add_action('pll_settings_active_tab_lingotek', array(&$this, 'display_tab'));
|
21 |
|
22 |
-
if (PLL_SETTINGS && isset($_GET['tab']) && 'lingotek' == $_GET['tab'])
|
23 |
-
add_action('admin_print_styles', array(&$this, 'print_css'));
|
|
|
24 |
|
25 |
// the pointer
|
26 |
-
$content = __('You’ve just upgraded to the latest version of Polylang! Would you like to automatically translate your website for free?', 'polylang');
|
27 |
|
28 |
$buttons = array(
|
29 |
array(
|
30 |
-
'label' => __('Close')
|
31 |
),
|
32 |
array(
|
33 |
-
'label' => __('Learn more', 'polylang'),
|
34 |
-
'link' => admin_url('admin.php?page=mlang&tab=lingotek'),
|
35 |
-
)
|
36 |
);
|
37 |
|
38 |
-
if ($link = $this->get_activate_link())
|
39 |
-
$content .= ' ' . __('Click on Activate Lingotek to start translating.', 'polylang');
|
40 |
|
41 |
$buttons[] = array(
|
42 |
-
'label' => __('Activate Lingotek', 'polylang'),
|
43 |
-
'link' => str_replace('&', '&', $link) // wp_nonce_url escapes the url for html display. Here we want it for js
|
44 |
);
|
|
|
45 |
|
46 |
$args = array(
|
47 |
'pointer' => 'pll_lgt',
|
48 |
-
'id' => empty($options['previous_version']) ? 'nav-tab-lingotek' : 'wp-admin-bar-languages',
|
49 |
'position' => array(
|
50 |
'edge' => 'top',
|
51 |
'align' => 'left',
|
52 |
),
|
53 |
'width' => 380,
|
54 |
-
'title' => __('Congratulations!', 'polylang'),
|
55 |
'content' => $content,
|
56 |
-
'buttons' => $buttons
|
57 |
);
|
58 |
|
59 |
-
new PLL_Pointer($args);
|
60 |
}
|
61 |
|
62 |
/*
|
@@ -67,7 +73,7 @@ class PLL_Lingotek {
|
|
67 |
* @param array $tabs list of tabs
|
68 |
* @return array modified liste of tabs
|
69 |
*/
|
70 |
-
public function add_tab($tabs) {
|
71 |
$tabs['lingotek'] = 'Lingotek';
|
72 |
return $tabs;
|
73 |
}
|
@@ -82,73 +88,73 @@ class PLL_Lingotek {
|
|
82 |
|
83 |
$links = array(
|
84 |
'activate' => array(
|
85 |
-
'label' => is_plugin_active(self::LINGOTEK) ? __('Activated', 'polylang') : __('Activate', 'polylang'),
|
86 |
'link' => $activate_link,
|
87 |
-
'classes' => 'button button-primary' . ($activate_link ? '' : ' disabled')
|
88 |
),
|
89 |
'translation' => array(
|
90 |
-
'label' => __('Request Translation', 'polylang'),
|
91 |
'link' => 'http://www.lingotek.com/wordpress/translation_bid',
|
92 |
'new_tab' => true,
|
93 |
-
'classes' => 'button button-primary'
|
94 |
),
|
95 |
'services' => array(
|
96 |
-
'label' =>
|
97 |
'link' => 'http://www.lingotek.com/wordpress/extra_services',
|
98 |
'new_tab' => true,
|
99 |
-
'classes' => 'button button-primary'
|
100 |
)
|
101 |
);
|
102 |
|
103 |
-
printf('<p>%s</p>', __('Polylang is now fully integrated with Lingotek, a professional translation management system!', 'polylang'));
|
104 |
|
105 |
$this->box(
|
106 |
-
__('Automatically Translate My Site', 'polylang'),
|
107 |
-
__('Polylang is now fully integrated with Lingotek!', 'polylang'),
|
108 |
array(
|
109 |
-
__('Access free machine translation for your site for up to 100,000 characters.', 'polylang'),
|
110 |
-
__('Machine translation is an excellent option if you\'re on a tight budget, looking for near-instant results, and are okay with less-than-perfect quality.', 'polylang'),
|
111 |
),
|
112 |
-
array_intersect_key($links, array_flip(array('activate'))),
|
113 |
'image01.gif'
|
114 |
);
|
115 |
|
116 |
$this->box(
|
117 |
-
__('Translation Management System', 'polylang'),
|
118 |
-
__('Do you need to connect to a professional translation management system?', 'polylang'),
|
119 |
array(
|
120 |
-
__('Access free machine translation for your site for up to 100,000 characters.', 'polylang'),
|
121 |
-
__('Access an online translator workbench.', 'polylang'),
|
122 |
-
__('Have linguists compare side-by-side versions of original and translated text.', 'polylang'),
|
123 |
-
__('Save and re-use previously translated material (leverage translation memory (TM)).', 'polylang'),
|
124 |
),
|
125 |
-
array_intersect_key($links, array_flip(array('activate'))),
|
126 |
'image02.png'
|
127 |
);
|
128 |
|
129 |
$this->box(
|
130 |
-
__('Professionally Translate My Site', 'polylang'),
|
131 |
-
__('Do you need to professionally translate your site?', 'polylang'),
|
132 |
array(
|
133 |
-
__('Start the process of getting a professional translation bid.', 'polylang'),
|
134 |
-
__('Activate account so Lingotek can get an accurate count of how many words you have on your site and which languages you wish to translate into.', 'polylang'),
|
135 |
-
__('Once activated click on the request translation bid and a certified translation project manager will contact you to give a no obligations translation bid.', 'polylang'),
|
136 |
),
|
137 |
-
array_intersect_key($links, array_flip(array('activate','translation'))),
|
138 |
'image03.png'
|
139 |
);
|
140 |
|
141 |
$this->box(
|
142 |
-
__('Need Extra Services?', 'polylang'),
|
143 |
-
__('Do you need help translating your site?', 'polylang'),
|
144 |
array(
|
145 |
-
__('Start the process of getting extra services.', 'polylang'),
|
146 |
-
__('Do you need someone to run your localization project?', 'polylang'),
|
147 |
-
__('Do you need customized workflows?', 'polylang'),
|
148 |
-
__('Do you have existing Translation Memories you would like to use?', 'polylang'),
|
149 |
-
__('Do you need help creating glossaries and terminologies?', 'polylang'),
|
150 |
),
|
151 |
-
array_intersect_key($links, array_flip(array('activate','services'))),
|
152 |
'i
|
1 |
<?php
|
2 |
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // don't access directly
|
5 |
+
};
|
6 |
+
|
7 |
/*
|
8 |
* class to manage Lingotek ads
|
9 |
*
|
17 |
* @since 1.7.7
|
18 |
*/
|
19 |
public function __construct() {
|
20 |
+
$options = get_option( 'polylang' );
|
21 |
|
22 |
// the Lingotek tab
|
23 |
+
add_filter( 'pll_settings_tabs', array( &$this, 'add_tab' ) );
|
24 |
+
add_action( 'pll_settings_active_tab_lingotek', array( &$this, 'display_tab' ) );
|
25 |
|
26 |
+
if ( PLL_SETTINGS && isset( $_GET['tab'] ) && 'lingotek' == $_GET['tab'] ) {
|
27 |
+
add_action( 'admin_print_styles', array( &$this, 'print_css' ) );
|
28 |
+
}
|
29 |
|
30 |
// the pointer
|
31 |
+
$content = __( 'You’ve just upgraded to the latest version of Polylang! Would you like to automatically translate your website for free?', 'polylang' );
|
32 |
|
33 |
$buttons = array(
|
34 |
array(
|
35 |
+
'label' => __( 'Close' ),
|
36 |
),
|
37 |
array(
|
38 |
+
'label' => __( 'Learn more', 'polylang' ),
|
39 |
+
'link' => admin_url( 'admin.php?page=mlang&tab=lingotek' ),
|
40 |
+
),
|
41 |
);
|
42 |
|
43 |
+
if ( $link = $this->get_activate_link() ) {
|
44 |
+
$content .= ' ' . __( 'Click on Activate Lingotek to start translating.', 'polylang' );
|
45 |
|
46 |
$buttons[] = array(
|
47 |
+
'label' => __( 'Activate Lingotek', 'polylang' ),
|
48 |
+
'link' => str_replace( '&', '&', $link ), // wp_nonce_url escapes the url for html display. Here we want it for js
|
49 |
);
|
50 |
+
}
|
51 |
|
52 |
$args = array(
|
53 |
'pointer' => 'pll_lgt',
|
54 |
+
'id' => empty( $options['previous_version'] ) ? 'nav-tab-lingotek' : 'wp-admin-bar-languages',
|
55 |
'position' => array(
|
56 |
'edge' => 'top',
|
57 |
'align' => 'left',
|
58 |
),
|
59 |
'width' => 380,
|
60 |
+
'title' => __( 'Congratulations!', 'polylang' ),
|
61 |
'content' => $content,
|
62 |
+
'buttons' => $buttons,
|
63 |
);
|
64 |
|
65 |
+
new PLL_Pointer( $args );
|
66 |
}
|
67 |
|
68 |
/*
|
73 |
* @param array $tabs list of tabs
|
74 |
* @return array modified liste of tabs
|
75 |
*/
|
76 |
+
public function add_tab( $tabs ) {
|
77 |
$tabs['lingotek'] = 'Lingotek';
|
78 |
return $tabs;
|
79 |
}
|
88 |
|
89 |
$links = array(
|
90 |
'activate' => array(
|
91 |
+
'label' => is_plugin_active( self::LINGOTEK ) ? __( 'Activated', 'polylang' ) : __( 'Activate', 'polylang' ),
|
92 |
'link' => $activate_link,
|
93 |
+
'classes' => 'button button-primary' . ( $activate_link ? '' : ' disabled' ),
|
94 |
),
|
95 |
'translation' => array(
|
96 |
+
'label' => __( 'Request Translation', 'polylang' ),
|
97 |
'link' => 'http://www.lingotek.com/wordpress/translation_bid',
|
98 |
'new_tab' => true,
|
99 |
+
'classes' => 'button button-primary',
|
100 |
),
|
101 |
'services' => array(
|
102 |
+
'label' => __( 'Request Services', 'polylang' ),
|
103 |
'link' => 'http://www.lingotek.com/wordpress/extra_services',
|
104 |
'new_tab' => true,
|
105 |
+
'classes' => 'button button-primary',
|
106 |
)
|
107 |
);
|
108 |
|
109 |
+
printf( '<p>%s</p>', __( 'Polylang is now fully integrated with Lingotek, a professional translation management system!', 'polylang' ) );
|
110 |
|
111 |
$this->box(
|
112 |
+
__( 'Automatically Translate My Site', 'polylang' ),
|
113 |
+
__( 'Polylang is now fully integrated with Lingotek!', 'polylang' ),
|
114 |
array(
|
115 |
+
__( 'Access free machine translation for your site for up to 100,000 characters.', 'polylang' ),
|
116 |
+
__( 'Machine translation is an excellent option if you\'re on a tight budget, looking for near-instant results, and are okay with less-than-perfect quality.', 'polylang' ),
|
117 |
),
|
118 |
+
array_intersect_key( $links, array_flip( array( 'activate' ) ) ),
|
119 |
'image01.gif'
|
120 |
);
|
121 |
|
122 |
$this->box(
|
123 |
+
__( 'Translation Management System', 'polylang' ),
|
124 |
+
__( 'Do you need to connect to a professional translation management system?', 'polylang' ),
|
125 |
array(
|
126 |
+
__( 'Access free machine translation for your site for up to 100,000 characters.', 'polylang' ),
|
127 |
+
__( 'Access an online translator workbench.', 'polylang' ),
|
128 |
+
__( 'Have linguists compare side-by-side versions of original and translated text.', 'polylang' ),
|
129 |
+
__( 'Save and re-use previously translated material (leverage translation memory (TM)).', 'polylang' ),
|
130 |
),
|
131 |
+
array_intersect_key( $links, array_flip( array( 'activate' ) ) ),
|
132 |
'image02.png'
|
133 |
);
|
134 |
|
135 |
$this->box(
|
136 |
+
__( 'Professionally Translate My Site', 'polylang' ),
|
137 |
+
__( 'Do you need to professionally translate your site?', 'polylang' ),
|
138 |
array(
|
139 |
+
__( 'Start the process of getting a professional translation bid.', 'polylang' ),
|
140 |
+
__( 'Activate account so Lingotek can get an accurate count of how many words you have on your site and which languages you wish to translate into.', 'polylang' ),
|
141 |
+
__( 'Once activated click on the request translation bid and a certified translation project manager will contact you to give a no obligations translation bid.', 'polylang' ),
|
142 |
),
|
143 |
+
array_intersect_key( $links, array_flip( array( 'activate', 'translation' ) ) ),
|
144 |
'image03.png'
|
145 |
);
|
146 |
|
147 |
$this->box(
|
148 |
+
__( 'Need Extra Services?', 'polylang' ),
|
149 |
+
__( 'Do you need help translating your site?', 'polylang' ),
|
150 |
array(
|
151 |
+
__( 'Start the process of getting extra services.', 'polylang' ),
|
152 |
+
__( 'Do you need someone to run your localization project?', 'polylang' ),
|
153 |
+
__( 'Do you need customized workflows?', 'polylang' ),
|
154 |
+
__( 'Do you have existing Translation Memories you would like to use?', 'polylang' ),
|
155 |
+
__( 'Do you need help creating glossaries and terminologies?', 'polylang' ),
|
156 |
),
|
157 |
+
array_intersect_key( $links, array_flip( array( 'activate', 'services' ) ) ),
|
158 |
'i
|